Skip to content

Commit 42546c2

Browse files
author
Peter Goodman
authored
Fixed issue where 'include'-directives were accidentally ignored. (#569)
1 parent bb6f258 commit 42546c2

File tree

3 files changed

+9195
-9189
lines changed

3 files changed

+9195
-9189
lines changed

bin/Index/IndexCompileJob.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,9 +2009,24 @@ std::vector<EntityRange> FragmentCollector::FindTLMs(void) {
20092009
if (IsUsed(dmd.value())) {
20102010
add_macro(std::move(md));
20112011
used_defines.emplace_back(std::move(dmd.value()));
2012-
break;
20132012
}
20142013
continue;
2014+
2015+
// Define directives can be embedded within macro expansions. Go locate
2016+
// those, just in case we didn't cover them above.
2017+
} else {
2018+
for (auto maybe_def : FindDirectivesInMacro(md)) {
2019+
if (auto def = pasta::DefineMacroDirective::From(maybe_def)) {
2020+
2021+
// Unconditionally add a `#define` that is inside of another macro
2022+
// (e.g. an expansion) even if it isn't used.
2023+
add_macro(def.value());
2024+
2025+
if (IsUsed(def.value())) {
2026+
used_defines.emplace_back(std::move(def.value()));
2027+
}
2028+
}
2029+
}
20152030
}
20162031

20172032
add_macro(md);
@@ -2021,17 +2036,6 @@ std::vector<EntityRange> FragmentCollector::FindTLMs(void) {
20212036
// the relevant begin-of-file markers.
20222037
auto ild = pasta::IncludeLikeMacroDirective::From(md);
20232038
if (!ild) {
2024-
2025-
// Define directives can be embedded within macro expansions. Go locate
2026-
// those, just in case we didn't cover them above.
2027-
for (auto dir : FindDirectivesInMacro(md)) {
2028-
if (auto dmd = pasta::DefineMacroDirective::From(dir)) {
2029-
if (IsUsed(dmd.value())) {
2030-
used_defines.emplace_back(std::move(dmd.value()));
2031-
}
2032-
}
2033-
}
2034-
20352039
continue;
20362040
}
20372041

@@ -2940,7 +2944,6 @@ void FragmentCollector::FillPendingFragments(EntityGroupRange group_range) {
29402944

29412945
// Things like namespaces.
29422946
if (ShouldHideFromIndexer(decl)) {
2943-
// LOG(ERROR) << "hidden " << RawEntity(decl);
29442947
continue;
29452948

29462949
// E.g. if there's something like: `typedef struct page *pgtable_t;`,

bin/Index/LinkExternalReferencesInFragment.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,12 @@ void LinkExternalReferencesInFragment(
489489
// issue/condition in `FindTLMs` in file
490490
// `bin/Index/IndexCompileJob.cpp`.
491491
if (!macro_name->FileLocation()) {
492+
assert(def->IsCommandLine() || def->IsBuiltin());
492493
continue;
493494
}
494495

496+
// If we're here it basically means we found a use of a definition
497+
// but we didn't persist the definition.
495498
assert(false);
496499
continue;
497500
}

0 commit comments

Comments
 (0)