diff options
author | Ben Langmuir <blangmuir@apple.com> | 2017-08-16 23:12:21 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2017-08-16 23:12:21 +0000 |
commit | fd6e39c40b0f78274bc00f785f2e30cd497dd1c2 (patch) | |
tree | 8d0147cac4b5885454667b99a53694a3988b48ab /clang/lib/Index/USRGeneration.cpp | |
parent | 4abc3f6036017f0996ccc860a174773a989316b1 (diff) | |
download | bcm5719-llvm-fd6e39c40b0f78274bc00f785f2e30cd497dd1c2.tar.gz bcm5719-llvm-fd6e39c40b0f78274bc00f785f2e30cd497dd1c2.zip |
[index] Add indexing for unresolved-using declarations
In dependent contexts we end up referencing these, so make sure they
have USRs, and have their declarations indexed. For the most part they
behave like typedefs, but we also need to worry about having multiple
using declarations with the same "name".
rdar://problem/33883650
llvm-svn: 311053
Diffstat (limited to 'clang/lib/Index/USRGeneration.cpp')
-rw-r--r-- | clang/lib/Index/USRGeneration.cpp | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index 21054b099a8..c4fe737e511 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -99,6 +99,8 @@ public: void VisitVarDecl(const VarDecl *D); void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D); void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D); + void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D); + void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D); void VisitLinkageSpecDecl(const LinkageSpecDecl *D) { IgnoreResults = true; @@ -112,14 +114,6 @@ public: IgnoreResults = true; } - void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) { - IgnoreResults = true; - } - - void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D) { - IgnoreResults = true; - } - bool ShouldGenerateLocation(const NamedDecl *D); bool isLocal(const NamedDecl *D) { @@ -609,6 +603,16 @@ bool USRGenerator::GenLoc(const Decl *D, bool IncludeOffset) { return IgnoreResults; } +static void printQualifier(llvm::raw_ostream &Out, ASTContext &Ctx, NestedNameSpecifier *NNS) { + // FIXME: Encode the qualifier, don't just print it. + PrintingPolicy PO(Ctx.getLangOpts()); + PO.SuppressTagKeyword = true; + PO.SuppressUnwrittenScope = true; + PO.ConstantArraySizeAsWritten = false; + PO.AnonymousTagLocations = false; + NNS->print(Out, PO); +} + void USRGenerator::VisitType(QualType T) { // This method mangles in USR information for types. It can possibly // just reuse the naming-mangling logic used by codegen, although the @@ -797,13 +801,7 @@ void USRGenerator::VisitType(QualType T) { } if (const DependentNameType *DNT = T->getAs<DependentNameType>()) { Out << '^'; - // FIXME: Encode the qualifier, don't just print it. - PrintingPolicy PO(Ctx.getLangOpts()); - PO.SuppressTagKeyword = true; - PO.SuppressUnwrittenScope = true; - PO.ConstantArraySizeAsWritten = false; - PO.AnonymousTagLocations = false; - DNT->getQualifier()->print(Out, PO); + printQualifier(Out, Ctx, DNT->getQualifier()); Out << ':' << DNT->getIdentifier()->getName(); return; } @@ -912,6 +910,26 @@ void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) { } } +void USRGenerator::VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) { + if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D))) + return; + VisitDeclContext(D->getDeclContext()); + Out << "@UUV@"; + printQualifier(Out, D->getASTContext(), D->getQualifier()); + EmitDeclName(D); +} + +void USRGenerator::VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D) { + if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D))) + return; + VisitDeclContext(D->getDeclContext()); + Out << "@UUT@"; + printQualifier(Out, D->getASTContext(), D->getQualifier()); + Out << D->getName(); // Simple name. +} + + + //===----------------------------------------------------------------------===// // USR generation functions. //===----------------------------------------------------------------------===// |