Skip to content

Commit

Permalink
Fixed issue where 'include'-directives were accidentally ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
pgoodman committed Aug 24, 2024
1 parent bb6f258 commit 3a203b7
Show file tree
Hide file tree
Showing 3 changed files with 9,195 additions and 9,189 deletions.
29 changes: 16 additions & 13 deletions bin/Index/IndexCompileJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,9 +2009,24 @@ std::vector<EntityRange> FragmentCollector::FindTLMs(void) {
if (IsUsed(dmd.value())) {
add_macro(std::move(md));
used_defines.emplace_back(std::move(dmd.value()));
break;
}
continue;

// Define directives can be embedded within macro expansions. Go locate
// those, just in case we didn't cover them above.
} else {
for (auto maybe_def : FindDirectivesInMacro(md)) {
if (auto def = pasta::DefineMacroDirective::From(maybe_def)) {

// Unconditionally add a `#define` that is inside of another macro
// (e.g. an expansion) even if it isn't used.
add_macro(def.value());

if (IsUsed(def.value())) {
used_defines.emplace_back(std::move(def.value()));
}
}
}
}

add_macro(md);
Expand All @@ -2021,17 +2036,6 @@ std::vector<EntityRange> FragmentCollector::FindTLMs(void) {
// the relevant begin-of-file markers.
auto ild = pasta::IncludeLikeMacroDirective::From(md);
if (!ild) {

// Define directives can be embedded within macro expansions. Go locate
// those, just in case we didn't cover them above.
for (auto dir : FindDirectivesInMacro(md)) {
if (auto dmd = pasta::DefineMacroDirective::From(dir)) {
if (IsUsed(dmd.value())) {
used_defines.emplace_back(std::move(dmd.value()));
}
}
}

continue;
}

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

// Things like namespaces.
if (ShouldHideFromIndexer(decl)) {
// LOG(ERROR) << "hidden " << RawEntity(decl);
continue;

// E.g. if there's something like: `typedef struct page *pgtable_t;`,
Expand Down
3 changes: 3 additions & 0 deletions bin/Index/LinkExternalReferencesInFragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,12 @@ void LinkExternalReferencesInFragment(
// issue/condition in `FindTLMs` in file
// `bin/Index/IndexCompileJob.cpp`.
if (!macro_name->FileLocation()) {
assert(def->IsCommandLine() || def->IsBuiltin());
continue;
}

// If we're here it basically means we found a use of a definition
// but we didn't persist the definition.
assert(false);
continue;
}
Expand Down
Loading

0 comments on commit 3a203b7

Please sign in to comment.