This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Search template parameter scopes before searching namespace/file scopes when performing unqualified name lookup
Needs ReviewPublic

Authored by ahatanak on Mar 30 2023, 3:57 PM.

Details

Summary

This fixes a bug where namespace scopes were being searched before template parameter scopes.

Delay searching namespace/file scopes in Sema::CppLookupName until all local scopes are searched.

Diff Detail

Event Timeline

ahatanak created this revision.Mar 30 2023, 3:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 3:57 PM
ahatanak requested review of this revision.Mar 30 2023, 3:57 PM
ahatanak updated this revision to Diff 542150.Jul 19 2023, 12:30 PM
  • Defer collecting using directives until lookup into local scopes is done.
  • Simplify the second loop.
  • Add more comments.
ahatanak added inline comments.Jul 19 2023, 12:54 PM
clang/lib/Sema/SemaLookup.cpp
1392

I noticed that we aren't visiting the contexts from the inside out despite the comment here: https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaLookup.cpp#L133

// A given context is only every visited once, so it is important
// that contexts be visited from the inside out in order to get
// the effective DCs right.

But I think that's OK. I haven't been able to come up with an example where this is causing a problem.

1418

I think this line can be moved to the beginning of the function .I can try that after committing this patch.

ahatanak added inline comments.Jul 19 2023, 1:06 PM
clang/lib/Sema/SemaLookup.cpp
1397

This isn't needed as InnermostFileScope is set at the beginning of the loop.

ahatanak updated this revision to Diff 542165.Jul 19 2023, 1:09 PM

Remove unneeded code.