Skip to content

Commit 468dc32

Browse files
committed
[NFC] Make DeclContext::noload_lookup() accept transparent context
Now the `DeclContext::noload_lookup()` asserts that 'this' is not a transparent context. However, this is not consistent with `DeclContext::lookup()`, which will lookup into its parent context if 'this' is a transparent context. This patch makes the behavior of `DeclContext::noload_lookup()` to be consistent with `DeclContext::lookup()`, to lookup into the parent context if 'this' is a transparent context.
1 parent a75b3e9 commit 468dc32

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/lib/AST/DeclBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,9 +1852,9 @@ DeclContext::lookup(DeclarationName Name) const {
18521852

18531853
DeclContext::lookup_result
18541854
DeclContext::noload_lookup(DeclarationName Name) {
1855-
assert(getDeclKind() != Decl::LinkageSpec &&
1856-
getDeclKind() != Decl::Export &&
1857-
"should not perform lookups into transparent contexts");
1855+
// For transparent DeclContext, we should lookup in their enclosing context.
1856+
if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export)
1857+
return getParent()->noload_lookup(Name);
18581858

18591859
DeclContext *PrimaryContext = getPrimaryContext();
18601860
if (PrimaryContext != this)

0 commit comments

Comments
 (0)