[cfe-commits] r93404 - /cfe/trunk/tools/CIndex/CIndexUSRs.cpp
Ted Kremenek
kremenek at apple.com
Wed Jan 13 17:50:21 PST 2010
Author: kremenek
Date: Wed Jan 13 19:50:21 2010
New Revision: 93404
URL: http://llvm.org/viewvc/llvm-project?rev=93404&view=rev
Log:
Further tweak USR generation by shorting names and distinguish between namespaces and functions.
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=93404&r1=93403&r2=93404&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndexUSRs.cpp Wed Jan 13 19:50:21 2010
@@ -67,37 +67,56 @@
//===----------------------------------------------------------------------===//
namespace {
- class USRGenerator : public DeclVisitor<USRGenerator> {
- llvm::raw_ostream &Out;
- public:
- USRGenerator(llvm::raw_ostream &out) : Out(out) {}
-
- void VisitNamedDecl(NamedDecl *D);
- void VisitObjCContainerDecl(ObjCContainerDecl *CD);
- void VisitObjCMethodDecl(ObjCMethodDecl *MD);
- void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
- void VisitRecordDecl(RecordDecl *D);
- void VisitTypedefDecl(TypedefDecl *D);
- };
+class USRGenerator : public DeclVisitor<USRGenerator> {
+ llvm::raw_ostream &Out;
+public:
+ USRGenerator(llvm::raw_ostream &out) : Out(out) {}
+
+ void VisitBlockDecl(BlockDecl *D);
+ void VisitDeclContext(DeclContext *D);
+ void VisitFunctionDecl(FunctionDecl *D);
+ void VisitNamedDecl(NamedDecl *D);
+ void VisitNamespaceDecl(NamespaceDecl *D);
+ void VisitObjCContainerDecl(ObjCContainerDecl *CD);
+ void VisitObjCMethodDecl(ObjCMethodDecl *MD);
+ void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
+ void VisitRecordDecl(RecordDecl *D);
+ void VisitTypedefDecl(TypedefDecl *D);
+};
} // end anonymous namespace
+void USRGenerator::VisitBlockDecl(BlockDecl *D) {
+ VisitDeclContext(D->getDeclContext());
+ // FIXME: Better support for anonymous blocks.
+ Out << "@B^anon";
+}
+
+void USRGenerator::VisitDeclContext(DeclContext *DC) {
+ if (NamedDecl *D = dyn_cast<NamedDecl>(DC))
+ Visit(D);
+}
+
+void USRGenerator::VisitFunctionDecl(FunctionDecl *D) {
+ VisitDeclContext(D->getDeclContext());
+ Out << "@F^" << D->getNameAsString();
+}
void USRGenerator::VisitNamedDecl(NamedDecl *D) {
- DeclContext *DC = D->getDeclContext();
- if (NamedDecl *DCN = dyn_cast<NamedDecl>(DC))
- Visit(DCN);
-
+ VisitDeclContext(D->getDeclContext());
const std::string &s = D->getNameAsString();
assert(!s.empty());
- Out << '@' << s;
+ Out << "@^" << s;
+}
+
+void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) {
+ VisitDeclContext(D->getDeclContext());
+ Out << "@N^" << D->getNameAsString();
}
void USRGenerator::VisitRecordDecl(RecordDecl *D) {
- DeclContext *DC = D->getDeclContext();
- if (NamedDecl *DCN = dyn_cast<NamedDecl>(DC))
- Visit(DCN);
-
- Out << "@struct^";
+ VisitDeclContext(D->getDeclContext());
+ Out << "@S^";
+ // FIXME: Better support for anonymous structures.
const std::string &s = D->getNameAsString();
if (s.empty())
Out << "^anon";
More information about the cfe-commits
mailing list