aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2025-01-17 12:46:00 +0800
committerGitHub <noreply@github.com>2025-01-17 12:46:00 +0800
commit263fed7ce9d2c155af44829018673caa67fa4f47 (patch)
tree9e63a4d0789dd0c7893b98d830b34f4c4439d2c7 /clang/lib/AST/DeclBase.cpp
parenta4e87da963a67aed33b672582406d576553b2399 (diff)
downloadllvm-263fed7ce9d2c155af44829018673caa67fa4f47.zip
llvm-263fed7ce9d2c155af44829018673caa67fa4f47.tar.gz
llvm-263fed7ce9d2c155af44829018673caa67fa4f47.tar.bz2
[AST] Add OriginalDC argument to ExternalASTSource::FindExternalVisibleDeclsByName (#123152)
Part for relanding https://github.com/llvm/llvm-project/pull/122887. I split this to test where the performance regession comes from if modules are not used.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index fb701f7..7c2dcf9 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1856,9 +1856,16 @@ DeclContext::lookup(DeclarationName Name) const {
if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
return getParent()->lookup(Name);
- const DeclContext *PrimaryContext = getPrimaryContext();
- if (PrimaryContext != this)
- return PrimaryContext->lookup(Name);
+ return getPrimaryContext()->lookupImpl(Name, this);
+}
+
+DeclContext::lookup_result
+DeclContext::lookupImpl(DeclarationName Name,
+ const DeclContext *OriginalLookupDC) const {
+ assert(this == getPrimaryContext() &&
+ "lookupImpl should only be called with primary DC!");
+ assert(getDeclKind() != Decl::LinkageSpec && getDeclKind() != Decl::Export &&
+ "We shouldn't lookup in transparent DC.");
// If we have an external source, ensure that any later redeclarations of this
// context have been loaded, since they may add names to the result of this
@@ -1889,7 +1896,8 @@ DeclContext::lookup(DeclarationName Name) const {
if (!R.second && !R.first->second.hasExternalDecls())
return R.first->second.getLookupResult();
- if (Source->FindExternalVisibleDeclsByName(this, Name) || !R.second) {
+ if (Source->FindExternalVisibleDeclsByName(this, Name, OriginalLookupDC) ||
+ !R.second) {
if (StoredDeclsMap *Map = LookupPtr) {
StoredDeclsMap::iterator I = Map->find(Name);
if (I != Map->end())
@@ -2115,7 +2123,8 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal) {
if (ExternalASTSource *Source = getParentASTContext().getExternalSource())
if (hasExternalVisibleStorage() &&
Map->find(D->getDeclName()) == Map->end())
- Source->FindExternalVisibleDeclsByName(this, D->getDeclName());
+ Source->FindExternalVisibleDeclsByName(this, D->getDeclName(),
+ D->getDeclContext());
// Insert this declaration into the map.
StoredDeclsList &DeclNameEntries = (*Map)[D->getDeclName()];