[clang][ASTImporter] DeclContext::localUncachedLookup: Continue lookup into decl...
authorMichael Buch <michaelbuch12@gmail.com>
Thu, 15 Sep 2022 02:37:08 +0000 (22:37 -0400)
committerMichael Buch <michaelbuch12@gmail.com>
Fri, 16 Sep 2022 16:38:50 +0000 (12:38 -0400)
commite456d2ba8bcadaa63386b339a4f2abcb39505502
tree0752351bb7a1d0948086731e103849b70a92ff1a
parent3004a759bcdf7b0a2a3a4220ed216d20defbd081
[clang][ASTImporter] DeclContext::localUncachedLookup: Continue lookup into decl chain when regular lookup fails

The uncached lookup is mainly used in the ASTImporter/LLDB code-path
where we're not allowed to load from external storage. When importing
a FieldDecl with a DeclContext that had no external visible storage
(but came from a Clang module or PCH) the above call to `lookup(Name)`
the regular `DeclContext::lookup` fails because:
1. `DeclContext::buildLookup` doesn't set `LookupPtr` for decls
   that came from a module
2. LLDB doesn't use the `SharedImporterState`

In such a case we would never continue with the "slow" path of iterating
through the decl chain on the DeclContext. In some cases this means that
ASTNodeImporter::VisitFieldDecl ends up importing a decl into the
DeclContext a second time.

The patch removes the short-circuit in the case where we don't find
any decls via the regular lookup.

**Tests**

* Un-skip the failing LLDB API tests

Differential Revision: https://reviews.llvm.org/D133945
clang/lib/AST/DeclBase.cpp
clang/unittests/AST/ASTImporterTest.cpp
lldb/test/API/lang/cpp/gmodules/template-with-same-arg/TestTemplateWithSameArg.py