diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-15 23:34:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-15 23:34:31 +0000 |
commit | c5b48b3319be4d7a421871e32fb016cff93172e6 (patch) | |
tree | bcfdd58548c1fdc6ff909c9353ff1baf0966f853 | |
parent | 823000cdeeb2deb861dd92463d739c1e71fea5d2 (diff) |
Refactor USR logic for EnumDecls and RecordDecls so that both handle 'anonymous' declarations in the same way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93585 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/CIndex/CIndexUSRs.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tools/CIndex/CIndexUSRs.cpp b/tools/CIndex/CIndexUSRs.cpp index 12157f4b1d..b52b9da921 100644 --- a/tools/CIndex/CIndexUSRs.cpp +++ b/tools/CIndex/CIndexUSRs.cpp @@ -82,6 +82,7 @@ public: void VisitObjCMethodDecl(ObjCMethodDecl *MD); void VisitObjCPropertyDecl(ObjCPropertyDecl *D); void VisitRecordDecl(RecordDecl *D); + void VisitTagDeclCommon(TagDecl *D); void VisitTypedefDecl(TypedefDecl *D); }; } // end anonymous namespace @@ -100,11 +101,7 @@ void USRGenerator::VisitDeclContext(DeclContext *DC) { void USRGenerator::VisitEnumDecl(EnumDecl *D) { VisitDeclContext(D->getDeclContext()); Out << "@E^"; - const std::string &s = D->getNameAsString(); - if (s.empty()) - Out << "anon"; - else - Out << s; + VisitTagDeclCommon(D); } void USRGenerator::VisitFunctionDecl(FunctionDecl *D) { @@ -127,16 +124,7 @@ void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) { void USRGenerator::VisitRecordDecl(RecordDecl *D) { VisitDeclContext(D->getDeclContext()); Out << "@S^"; - // FIXME: Better support for anonymous structures. - const std::string &s = D->getNameAsString(); - if (s.empty()) { - if (TypedefDecl *TD = D->getTypedefForAnonDecl()) - Out << "^anontd^" << TD->getNameAsString(); - else - Out << "^anon"; - } - else - Out << s; + VisitTagDeclCommon(D); } void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) { @@ -176,6 +164,19 @@ void USRGenerator::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { Out << "(py)" << D->getName(); } +void USRGenerator::VisitTagDeclCommon(TagDecl *D) { + // FIXME: Better support for anonymous structures and enums. + const std::string &s = D->getNameAsString(); + if (s.empty()) { + if (TypedefDecl *TD = D->getTypedefForAnonDecl()) + Out << "^anontd^" << TD->getNameAsString(); + else + Out << "^anon"; + } + else + Out << s; +} + void USRGenerator::VisitTypedefDecl(TypedefDecl *D) { DeclContext *DC = D->getDeclContext(); if (NamedDecl *DCN = dyn_cast<NamedDecl>(DC)) |