[cfe-commits] r93799 - /cfe/trunk/tools/CIndex/CIndexUSRs.cpp

Ted Kremenek kremenek at apple.com
Mon Jan 18 14:42:21 PST 2010


Author: kremenek
Date: Mon Jan 18 16:42:20 2010
New Revision: 93799

URL: http://llvm.org/viewvc/llvm-project?rev=93799&view=rev
Log:
Refactor USR generation for TagDecls into a common method.

Modified:
    cfe/trunk/tools/CIndex/CIndexUSRs.cpp

Modified: cfe/trunk/tools/CIndex/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndexUSRs.cpp?rev=93799&r1=93798&r2=93799&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndexUSRs.cpp Mon Jan 18 16:42:20 2010
@@ -78,7 +78,6 @@
   
   void VisitBlockDecl(BlockDecl *D);
   void VisitDeclContext(DeclContext *D);
-  void VisitEnumDecl(EnumDecl *D);
   void VisitFieldDecl(FieldDecl *D);
   void VisitFunctionDecl(FunctionDecl *D);
   void VisitNamedDecl(NamedDecl *D);
@@ -86,8 +85,7 @@
   void VisitObjCContainerDecl(ObjCContainerDecl *CD);  
   void VisitObjCMethodDecl(ObjCMethodDecl *MD);
   void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
-  void VisitRecordDecl(RecordDecl *D);
-  void VisitTagDeclCommon(TagDecl *D);
+  void VisitTagDecl(TagDecl *D);
   void VisitTypedefDecl(TypedefDecl *D);
 };
 } // end anonymous namespace
@@ -103,12 +101,6 @@
     Visit(D);
 }
 
-void USRGenerator::VisitEnumDecl(EnumDecl *D) {
-  VisitDeclContext(D->getDeclContext());
-  Out << "@E^";
-  VisitTagDeclCommon(D);
-}
-
 void USRGenerator::VisitFieldDecl(FieldDecl *D) {
   const std::string &s = D->getNameAsString();
   if (s.empty()) {
@@ -137,12 +129,6 @@
   Out << "@N^" << D->getNameAsString();
 }
 
-void USRGenerator::VisitRecordDecl(RecordDecl *D) {
-  VisitDeclContext(D->getDeclContext());
-  Out << "@S^";
-  VisitTagDeclCommon(D);
-}
-
 void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
   Visit(cast<Decl>(D->getDeclContext()));
   Out << (D->isInstanceMethod() ? "(im)" : "(cm)");
@@ -180,7 +166,15 @@
   Out << "(py)" << D->getName();
 }
 
-void USRGenerator::VisitTagDeclCommon(TagDecl *D) {
+void USRGenerator::VisitTagDecl(TagDecl *D) {
+  VisitDeclContext(D->getDeclContext());
+  switch (D->getTagKind()) {
+    case TagDecl::TK_struct: Out << "@S^"; break;
+    case TagDecl::TK_class:  Out << "@C^"; break;
+    case TagDecl::TK_union:  Out << "@U^"; break;
+    case TagDecl::TK_enum:   Out << "@E^"; break;
+  }
+  
   // FIXME: Better support for anonymous structures and enums.
   const std::string &s = D->getNameAsString();
   if (s.empty()) {





More information about the cfe-commits mailing list