forked from OSchip/llvm-project
[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
This commit is contained in:
parent
3004a759bc
commit
e456d2ba8b
|
@ -1771,6 +1771,7 @@ void DeclContext::localUncachedLookup(DeclarationName Name,
|
||||||
if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) {
|
if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) {
|
||||||
lookup_result LookupResults = lookup(Name);
|
lookup_result LookupResults = lookup(Name);
|
||||||
Results.insert(Results.end(), LookupResults.begin(), LookupResults.end());
|
Results.insert(Results.end(), LookupResults.begin(), LookupResults.end());
|
||||||
|
if (!Results.empty())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4924,9 +4924,9 @@ TEST_P(ASTImporterLookupTableTest,
|
||||||
FooDC->getRedeclContext()->localUncachedLookup(FooName, FoundDecls);
|
FooDC->getRedeclContext()->localUncachedLookup(FooName, FoundDecls);
|
||||||
EXPECT_EQ(FoundDecls.size(), 0u);
|
EXPECT_EQ(FoundDecls.size(), 0u);
|
||||||
|
|
||||||
// Cannot find in the LookupTable of its LexicalDC (A).
|
// Finds via linear search of its LexicalDC (A).
|
||||||
FooLexicalDC->getRedeclContext()->localUncachedLookup(FooName, FoundDecls);
|
FooLexicalDC->getRedeclContext()->localUncachedLookup(FooName, FoundDecls);
|
||||||
EXPECT_EQ(FoundDecls.size(), 0u);
|
EXPECT_EQ(FoundDecls.size(), 1u);
|
||||||
|
|
||||||
// Can't find in the list of Decls of the DC.
|
// Can't find in the list of Decls of the DC.
|
||||||
EXPECT_EQ(findInDeclListOfDC(FooDC, FooName), nullptr);
|
EXPECT_EQ(findInDeclListOfDC(FooDC, FooName), nullptr);
|
||||||
|
|
|
@ -34,7 +34,6 @@ class TestTemplateWithSameArg(TestBase):
|
||||||
self.main_source_file = lldb.SBFileSpec("main.cpp")
|
self.main_source_file = lldb.SBFileSpec("main.cpp")
|
||||||
|
|
||||||
@add_test_categories(["gmodules"])
|
@add_test_categories(["gmodules"])
|
||||||
@skipIf(bugnumber='rdar://96581048')
|
|
||||||
def test_same_template_arg(self):
|
def test_same_template_arg(self):
|
||||||
lldbutil.run_to_source_breakpoint(self, "Break here", self.main_source_file)
|
lldbutil.run_to_source_breakpoint(self, "Break here", self.main_source_file)
|
||||||
|
|
||||||
|
@ -51,7 +50,6 @@ class TestTemplateWithSameArg(TestBase):
|
||||||
])
|
])
|
||||||
|
|
||||||
@add_test_categories(["gmodules"])
|
@add_test_categories(["gmodules"])
|
||||||
@skipIf(bugnumber='rdar://96581048')
|
|
||||||
def test_duplicate_decls(self):
|
def test_duplicate_decls(self):
|
||||||
lldbutil.run_to_source_breakpoint(self, "Break here", self.main_source_file)
|
lldbutil.run_to_source_breakpoint(self, "Break here", self.main_source_file)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue