File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1501,7 +1501,15 @@ namespace utils {
15011501 // No definition, no lookup result.
15021502 return ;
15031503 }
1504- S->LookupQualifiedName (R, const_cast <DeclContext*>(primaryWithin));
1504+ bool res =
1505+ S->LookupQualifiedName (R, const_cast <DeclContext*>(primaryWithin));
1506+
1507+ // If the lookup fails and the context is a namespace, try to lookup in
1508+ // the namespaces by setting NotForRedeclaration.
1509+ if (!res && primaryWithin->isNamespace ()) {
1510+ R.setRedeclarationKind (Sema::NotForRedeclaration);
1511+ S->LookupQualifiedName (R, const_cast <DeclContext*>(primaryWithin));
1512+ }
15051513 }
15061514 }
15071515
Original file line number Diff line number Diff line change 1+ DisableFormat : true
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ namespace AnotherNext {
3737class Inside_AnotherNext {};
3838}
3939
40+ namespace A {
41+ class C ;
42+ }
43+ namespace B {
44+ using namespace A ;
45+ }
46+
4047.rawInput 0
4148
4249// ROOT-6095: names introduced in a scopeless enum should be available in the
@@ -106,3 +113,20 @@ decl
106113decl = utils ::Lookup ::Named (& S , "EvenLess" , context );
107114decl
108115//CHECK: (const clang::NamedDecl *) {{0x0*$|nullptr}}
116+
117+ // Lookup the declaration for namespace B.
118+ decl = utils ::Lookup ::Named (& S , "B" , nullptr );
119+ decl
120+ // CHECK: (const clang::NamedDecl *) 0x{{[1-9a-f][0-9a-f]*$}}
121+
122+ const clang ::DeclContext * contextB = llvm ::dyn_cast < clang ::DeclContext > (decl );
123+ contextB
124+ // CHECK: (const clang::DeclContext *) 0x{{[1-9a-f][0-9a-f]*$}}
125+
126+ // Lookup 'C' from namespace B.
127+ decl = utils ::Lookup ::Named (& S , "C" , contextB );
128+ decl
129+ // CHECK: (const clang::NamedDecl *) 0x{{[1-9a-f][0-9a-f]*$}}
130+
131+ decl -> getQualifiedNameAsString ()
132+ // CHECK: (std::string) "A::C"
You can’t perform that action at this time.
0 commit comments