[index] 'using namespace' declarations in functions should record

the reference to the namespace

rdar://32323190

llvm-svn: 303555
This commit is contained in:
Alex Lorenz 2017-05-22 14:39:39 +00:00
parent f2dc6492ed
commit d65b3e4212
3 changed files with 19 additions and 2 deletions

View File

@ -568,8 +568,12 @@ public:
const DeclContext *DC = D->getDeclContext()->getRedeclContext();
const NamedDecl *Parent = dyn_cast<NamedDecl>(DC);
IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
D->getLexicalDeclContext());
// NNS for the local 'using namespace' directives is visited by the body
// visitor.
if (!D->getParentFunctionOrMethod())
IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
D->getLexicalDeclContext());
return IndexCtx.handleReference(D->getNominatedNamespaceAsWritten(),
D->getLocation(), Parent,
D->getLexicalDeclContext(),

View File

@ -61,6 +61,8 @@ bool index::isFunctionLocalSymbol(const Decl *D) {
if (isa<ObjCTypeParamDecl>(D))
return true;
if (isa<UsingDirectiveDecl>(D))
return false;
if (!D->getParentFunctionOrMethod())
return false;

View File

@ -339,3 +339,14 @@ void ::ns::inner::func() {
// CHECK: [[@LINE-1]]:3 | namespace/C++ | ns | c:@N@ns | <no-cgname> | Ref,RelCont | rel: 1
// CHECK: [[@LINE-2]]:7 | namespace-alias/C++ | innerAlias | c:@N@ns@NA@innerAlias | <no-cgname> | Ref,RelCont | rel: 1
}
void innerUsingNamespace() {
using namespace ns;
// CHECK: [[@LINE-1]]:19 | namespace/C++ | ns | c:@N@ns | <no-cgname> | Ref,RelCont | rel: 1
{
using namespace ns::innerAlias;
// CHECK: [[@LINE-1]]:25 | namespace-alias/C++ | innerAlias | c:@N@ns@NA@innerAlias | <no-cgname> | Ref,RelCont | rel: 1
// CHECK: [[@LINE-2]]:21 | namespace/C++ | ns | c:@N@ns | <no-cgname> | Ref,RelCont | rel: 1
// CHECK-NOT: [[@LINE-3]]:21
}
}