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 {
1501
1501
// No definition, no lookup result.
1502
1502
return ;
1503
1503
}
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
+ }
1505
1513
}
1506
1514
}
1507
1515
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 {
37
37
class Inside_AnotherNext {};
38
38
}
39
39
40
+ namespace A {
41
+ class C ;
42
+ }
43
+ namespace B {
44
+ using namespace A ;
45
+ }
46
+
40
47
.rawInput 0
41
48
42
49
// ROOT-6095: names introduced in a scopeless enum should be available in the
@@ -106,3 +113,20 @@ decl
106
113
decl = utils ::Lookup ::Named (& S , "EvenLess" , context );
107
114
decl
108
115
//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