summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/USRGeneration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Index/USRGeneration.cpp')
-rw-r--r--clang/lib/Index/USRGeneration.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index cb30090adc0..2722f081fef 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -426,7 +426,8 @@ void USRGenerator::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
void USRGenerator::VisitTagDecl(const TagDecl *D) {
// Add the location of the tag decl to handle resolution across
// translation units.
- if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
+ if (!isa<EnumDecl>(D) &&
+ ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
return;
D = D->getCanonicalDecl();
@@ -482,8 +483,16 @@ void USRGenerator::VisitTagDecl(const TagDecl *D) {
else {
if (D->isEmbeddedInDeclarator() && !D->isFreeStanding()) {
printLoc(Out, D->getLocation(), Context->getSourceManager(), true);
- } else
+ } else {
Buf[off] = 'a';
+ if (auto *ED = dyn_cast<EnumDecl>(D)) {
+ // Distinguish USRs of anonymous enums by using their first enumerator.
+ auto enum_range = ED->enumerators();
+ if (enum_range.begin() != enum_range.end()) {
+ Out << '@' << **enum_range.begin();
+ }
+ }
+ }
}
}
OpenPOWER on IntegriCloud