From 6c05f3abb9d639abe360bde5919e17f913883173 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Mon, 15 May 2017 10:41:04 +0000 Subject: [PATCH] [index] Store correct location for namespace nested name qualifiers rdar://32195200 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303046 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Index/IndexTypeSourceInfo.cpp | 2 +- test/Index/Core/index-source.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Index/IndexTypeSourceInfo.cpp b/lib/Index/IndexTypeSourceInfo.cpp index e9ca651e00..ae27ebe6ea 100644 --- a/lib/Index/IndexTypeSourceInfo.cpp +++ b/lib/Index/IndexTypeSourceInfo.cpp @@ -212,7 +212,7 @@ void IndexingContext::indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, if (!DC) DC = Parent->getLexicalDeclContext(); - SourceLocation Loc = NNS.getSourceRange().getBegin(); + SourceLocation Loc = NNS.getLocalBeginLoc(); switch (NNS.getNestedNameSpecifier()->getKind()) { case NestedNameSpecifier::Identifier: diff --git a/test/Index/Core/index-source.cpp b/test/Index/Core/index-source.cpp index cae7508c5f..48ca3a9b57 100644 --- a/test/Index/Core/index-source.cpp +++ b/test/Index/Core/index-source.cpp @@ -314,3 +314,21 @@ class ClassWithCorrectSpecialization, Record::C> { }; // CHECK: [[@LINE-2]]:57 | class/C++ | Cls | c:@S@Cls | | Ref | rel: 0 // CHECK: [[@LINE-3]]:71 | static-property/C++ | C | c:@S@Record@C | __ZN6Record1CE | Ref,Read | rel: 0 // CHECK: [[@LINE-4]]:63 | struct/C++ | Record | c:@S@Record | | Ref | rel: 0 + +namespace ns { +// CHECK: [[@LINE-1]]:11 | namespace/C++ | ns | c:@N@ns | | Decl | rel: 0 +namespace inner { +// CHECK: [[@LINE-1]]:11 | namespace/C++ | inner | c:@N@ns@N@inner | | Decl,RelChild | rel: 1 +void func(); + +} +namespace innerAlias = inner; +} + +void ::ns::inner::func() { +// CHECK: [[@LINE-1]]:8 | namespace/C++ | ns | c:@N@ns | | Ref,RelCont | rel: 1 +// CHECK: [[@LINE-2]]:12 | namespace/C++ | inner | c:@N@ns@N@inner | | Ref,RelCont | rel: 1 + ns::innerAlias::func(); +// CHECK: [[@LINE-1]]:3 | namespace/C++ | ns | c:@N@ns | | Ref,RelCont | rel: 1 +// CHECK: [[@LINE-2]]:7 | namespace-alias/C++ | innerAlias | c:@N@ns@NA@innerAlias | | Ref,RelCont | rel: 1 +} -- 2.40.0