[cfe-commits] r103289 - in /cfe/trunk: test/Index/usrs.cpp tools/libclang/CIndexUSRs.cpp

Ted Kremenek kremenek at apple.com
Fri May 7 13:39:40 PDT 2010


Author: kremenek
Date: Fri May  7 15:39:40 2010
New Revision: 103289

URL: http://llvm.org/viewvc/llvm-project?rev=103289&view=rev
Log:
Extend C++ usrs to include type mangling for tag decl arguments, indicating whether a method
is static, and mangling in the qualifers of the method.

Modified:
    cfe/trunk/test/Index/usrs.cpp
    cfe/trunk/tools/libclang/CIndexUSRs.cpp

Modified: cfe/trunk/test/Index/usrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs.cpp?rev=103289&r1=103288&r2=103289&view=diff
==============================================================================
--- cfe/trunk/test/Index/usrs.cpp (original)
+++ cfe/trunk/test/Index/usrs.cpp Fri May  7 15:39:40 2010
@@ -44,6 +44,10 @@
   public:
     ClsD& operator=(int x) { a = x; return *this; }
     ClsD& operator=(double x) { a = (int) x; return *this; }
+    ClsD& operator=(const ClsD &x) { a = x.a; return *this; }
+    static int qux();
+    static int uz(int z, ...);
+    bool operator==(const ClsD &x) const { return a == x.a; }
   };
 }}
 
@@ -54,43 +58,50 @@
 // RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s
 // CHECK: usrs.cpp c:@N at foo Extent=[1:11 - 4:2]
 // CHECK: usrs.cpp c:@N at foo@x Extent=[2:3 - 2:8]
-// CHECK: usrs.cpp c:@N at foo@F at bar#I Extent=[3:8 - 3:18]
-// CHECK: usrs.cpp c:usrs.cpp at 3:12 at N@foo at F@bar#I at z Extent=[3:12 - 3:17]
+// CHECK: usrs.cpp c:@N at foo@F at bar#I# Extent=[3:8 - 3:18]
+// CHECK: usrs.cpp c:usrs.cpp at 3:12 at N@foo at F@bar#I#@z Extent=[3:12 - 3:17]
 // CHECK: usrs.cpp c:@N at bar Extent=[5:11 - 8:2]
 // CHECK: usrs.cpp c:usrs.cpp at 6:15 at N@bar at T@QType Extent=[6:15 - 6:20]
-// CHECK: usrs.cpp c:@N at bar@F at bar#I Extent=[7:8 - 7:20]
-// CHECK: usrs.cpp c:usrs.cpp at 7:12 at N@bar at F@bar#I at z Extent=[7:12 - 7:19]
+// CHECK: usrs.cpp c:@N at bar@F at bar#I# Extent=[7:8 - 7:20]
+// CHECK: usrs.cpp c:usrs.cpp at 7:12 at N@bar at F@bar#I#@z Extent=[7:12 - 7:19]
 // CHECK: usrs.cpp c:@C at ClsA Extent=[10:1 - 14:2]
 // CHECK: usrs.cpp c:@C at ClsA@FI at a Extent=[12:7 - 12:8]
 // CHECK: usrs.cpp c:@C at ClsA@FI at b Extent=[12:10 - 12:11]
-// CHECK: usrs.cpp c:@C at ClsA@F at ClsA#I#I Extent=[13:3 - 13:37]
-// CHECK: usrs.cpp c:usrs.cpp at 13:8 at C@ClsA at F@ClsA#I#I at A Extent=[13:8 - 13:13]
-// CHECK: usrs.cpp c:usrs.cpp at 13:15 at C@ClsA at F@ClsA#I#I at B Extent=[13:15 - 13:20]
+// CHECK: usrs.cpp c:@C at ClsA@F at ClsA#I#I# Extent=[13:3 - 13:37]
+// CHECK: usrs.cpp c:usrs.cpp at 13:8 at C@ClsA at F@ClsA#I#I#@A Extent=[13:8 - 13:13]
+// CHECK: usrs.cpp c:usrs.cpp at 13:15 at C@ClsA at F@ClsA#I#I#@B Extent=[13:15 - 13:20]
 // CHECK: usrs.cpp c:@N at foo Extent=[16:11 - 22:2]
 // CHECK: usrs.cpp c:@N at foo@C at ClsB Extent=[17:3 - 21:4]
-// CHECK: usrs.cpp c:@N at foo@C at ClsB@F at ClsB Extent=[19:5 - 19:27]
-// CHECK: usrs.cpp c:@N at foo@C at ClsB@F at result Extent=[20:9 - 20:17]
-// CHECK: usrs.cpp c:@N at foo@C at ClsB@F at result Extent=[24:16 - 26:2]
+// CHECK: usrs.cpp c:@N at foo@C at ClsB@F at ClsB# Extent=[19:5 - 19:27]
+// CHECK: usrs.cpp c:@N at foo@C at ClsB@F at result#1 Extent=[20:9 - 20:17]
+// CHECK: usrs.cpp c:@N at foo@C at ClsB@F at result#1 Extent=[24:16 - 26:2]
 // CHECK: usrs.cpp c:@aN at C@ClsC Extent=[29:3 - 29:35]
 // CHECK: usrs.cpp c:@aN at w Extent=[30:3 - 30:8]
 // CHECK: usrs.cpp c:@z Extent=[33:1 - 33:6]
 // CHECK: usrs.cpp c:@N at foo Extent=[35:11 - 40:2]
 // CHECK: usrs.cpp c:@N at foo@N at taz Extent=[35:27 - 39:2]
 // CHECK: usrs.cpp c:@N at foo@N at taz@x Extent=[36:3 - 36:8]
-// CHECK: usrs.cpp c:usrs.cpp at 37:21 at N@foo at N@taz at F@add#I#I Extent=[37:21 - 37:56]
-// CHECK: usrs.cpp c:usrs.cpp at 37:25 at N@foo at N@taz at F@add#I#I at a Extent=[37:25 - 37:30]
-// CHECK: usrs.cpp c:usrs.cpp at 37:32 at N@foo at N@taz at F@add#I#I at b Extent=[37:32 - 37:37]
-// CHECK: usrs.cpp c:@N at foo@N at taz@F at sub#I#I Extent=[38:8 - 38:25]
-// CHECK: usrs.cpp c:usrs.cpp at 38:12 at N@foo at N@taz at F@sub#I#I at a Extent=[38:12 - 38:17]
-// CHECK: usrs.cpp c:usrs.cpp at 38:19 at N@foo at N@taz at F@sub#I#I at b Extent=[38:19 - 38:24]
-// CHECK: usrs.cpp c:@N at foo Extent=[42:11 - 48:3]
-// CHECK: usrs.cpp c:@N at foo@N at taz Extent=[42:27 - 48:2]
-// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD Extent=[43:3 - 47:4]
-// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at operator=#I Extent=[45:11 - 45:52]
-// CHECK: usrs.cpp c:usrs.cpp at 45:21 at N@foo at N@taz at C@ClsD at F@operator=#I at x Extent=[45:21 - 45:26]
-// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at operator=#d Extent=[46:11 - 46:61]
-// CHECK: usrs.cpp c:usrs.cpp at 46:21 at N@foo at N@taz at C@ClsD at F@operator=#d at x Extent=[46:21 - 46:29]
-// CHECK: usrs.cpp c:@F at rez Extent=[51:8 - 51:25]
-// CHECK: usrs.cpp c:usrs.cpp at 51:12 at F@rez at a Extent=[51:12 - 51:17]
-// CHECK: usrs.cpp c:usrs.cpp at 51:19 at F@rez at b Extent=[51:19 - 51:24]
+// CHECK: usrs.cpp c:usrs.cpp at 37:21 at N@foo at N@taz at F@add#I#I# Extent=[37:21 - 37:56]
+// CHECK: usrs.cpp c:usrs.cpp at 37:25 at N@foo at N@taz at F@add#I#I#@a Extent=[37:25 - 37:30]
+// CHECK: usrs.cpp c:usrs.cpp at 37:32 at N@foo at N@taz at F@add#I#I#@b Extent=[37:32 - 37:37]
+// CHECK: usrs.cpp c:@N at foo@N at taz@F at sub#I#I# Extent=[38:8 - 38:25]
+// CHECK: usrs.cpp c:usrs.cpp at 38:12 at N@foo at N@taz at F@sub#I#I#@a Extent=[38:12 - 38:17]
+// CHECK: usrs.cpp c:usrs.cpp at 38:19 at N@foo at N@taz at F@sub#I#I#@b Extent=[38:19 - 38:24]
+// CHECK: usrs.cpp c:@N at foo Extent=[42:11 - 52:3]
+// CHECK: usrs.cpp c:@N at foo@N at taz Extent=[42:27 - 52:2]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD Extent=[43:3 - 51:4]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at operator=#I# Extent=[45:11 - 45:52]
+// CHECK: usrs.cpp c:usrs.cpp at 45:21 at N@foo at N@taz at C@ClsD at F@operator=#I#@x Extent=[45:21 - 45:26]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at operator=#d# Extent=[46:11 - 46:61]
+// CHECK: usrs.cpp c:usrs.cpp at 46:21 at N@foo at N@taz at C@ClsD at F@operator=#d#@x Extent=[46:21 - 46:29]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at operator=#&1$@N at foo@N at taz@C at ClsD# Extent=[47:11 - 47:62]
+// CHECK: usrs.cpp c:usrs.cpp at 47:27 at N@foo at N@taz at C@ClsD at F@operator=#&1$@N at foo@N at taz@C at ClsD#@x Extent=[47:27 - 47:34]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at qux#S Extent=[48:16 - 48:21]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at uz#I.#S Extent=[49:16 - 49:30]
+// CHECK: usrs.cpp c:usrs.cpp at 49:19 at N@foo at N@taz at C@ClsD at F@uz#I.#S at z Extent=[49:19 - 49:24]
+// CHECK: usrs.cpp c:@N at foo@N at taz@C at ClsD@F at operator==#&1$@N at foo@N at taz@C at ClsD#1 Extent=[50:10 - 50:62]
+// CHECK: usrs.cpp c:usrs.cpp at 50:27 at N@foo at N@taz at C@ClsD at F@operator==#&1$@N at foo@N at taz@C at ClsD#1 at x Extent=[50:27 - 50:34]
+// CHECK: usrs.cpp c:@F at rez Extent=[55:8 - 55:25]
+// CHECK: usrs.cpp c:usrs.cpp at 55:12 at F@rez at a Extent=[55:12 - 55:17]
+// CHECK: usrs.cpp c:usrs.cpp at 55:19 at F@rez at b Extent=[55:19 - 55:24]
 

Modified: cfe/trunk/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexUSRs.cpp?rev=103289&r1=103288&r2=103289&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexUSRs.cpp Fri May  7 15:39:40 2010
@@ -171,6 +171,13 @@
   }
   if (D->isVariadic())
     Out << '.';
+  Out << '#';
+  if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
+    if (MD->isStatic())
+      Out << 'S';
+    if (unsigned quals = MD->getTypeQualifiers())
+      Out << (char)('0' + quals);
+  }
 }
 
 void USRGenerator::VisitNamedDecl(NamedDecl *D) {
@@ -372,15 +379,20 @@
   // This method mangles in USR information for types.  It can possibly
   // just reuse the naming-mangling logic used by codegen, although the
   // requirements for USRs might not be the same.
+  ASTContext &Ctx = AU->getASTContext();
+
   do {
-    T = T.getTypePtr()->getCanonicalTypeInternal();
+    T = Ctx.getCanonicalType(T);
     Qualifiers Q = T.getQualifiers();
+    unsigned qVal = 0;
     if (Q.hasConst())
-      Out << '1';
+      qVal |= 0x1;
     if (Q.hasVolatile())
-      Out << '2';
+      qVal |= 0x2;
     if (Q.hasRestrict())
-      Out << '3';
+      qVal |= 0x4;
+    if(qVal)
+      Out << ((char) ('0' + qVal));
 
     // Mangle in ObjC GC qualifiers?
 
@@ -477,6 +489,11 @@
       T = CT->getElementType();
       continue;
     }
+    if (const TagType *TT = T->getAs<TagType>()) {
+      Out << '$';
+      VisitTagDecl(TT->getDecl());
+      return;
+    }
 
     // Unhandled type.
     Out << ' ';





More information about the cfe-commits mailing list