summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-05-07 20:39:40 +0000
committerTed Kremenek <kremenek@apple.com>2010-05-07 20:39:40 +0000
commit37c220c8ed4d75ad42e5725aa1dcc7f90ca9f489 (patch)
treee6df4adcce89871891d29179fd2e43ca5685b2eb
parenta99fa1aee11875b4e4854236c9f9afef733263ad (diff)
downloadbcm5719-llvm-37c220c8ed4d75ad42e5725aa1dcc7f90ca9f489.tar.gz
bcm5719-llvm-37c220c8ed4d75ad42e5725aa1dcc7f90ca9f489.zip
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. llvm-svn: 103289
-rw-r--r--clang/test/Index/usrs.cpp63
-rw-r--r--clang/tools/libclang/CIndexUSRs.cpp25
2 files changed, 58 insertions, 30 deletions
diff --git a/clang/test/Index/usrs.cpp b/clang/test/Index/usrs.cpp
index 45495e6a6b1..b6a6d3dadab 100644
--- a/clang/test/Index/usrs.cpp
+++ b/clang/test/Index/usrs.cpp
@@ -44,6 +44,10 @@ namespace foo { namespace taz {
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 @@ extern "C" {
// RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s
// CHECK: usrs.cpp c:@N@foo Extent=[1:11 - 4:2]
// CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8]
-// CHECK: usrs.cpp c:@N@foo@F@bar#I Extent=[3:8 - 3:18]
-// CHECK: usrs.cpp c:usrs.cpp@3:12@N@foo@F@bar#I@z Extent=[3:12 - 3:17]
+// CHECK: usrs.cpp c:@N@foo@F@bar#I# Extent=[3:8 - 3:18]
+// CHECK: usrs.cpp c:usrs.cpp@3:12@N@foo@F@bar#I#@z Extent=[3:12 - 3:17]
// CHECK: usrs.cpp c:@N@bar Extent=[5:11 - 8:2]
// CHECK: usrs.cpp c:usrs.cpp@6:15@N@bar@T@QType Extent=[6:15 - 6:20]
-// CHECK: usrs.cpp c:@N@bar@F@bar#I Extent=[7:8 - 7:20]
-// CHECK: usrs.cpp c:usrs.cpp@7:12@N@bar@F@bar#I@z Extent=[7:12 - 7:19]
+// CHECK: usrs.cpp c:@N@bar@F@bar#I# Extent=[7:8 - 7:20]
+// CHECK: usrs.cpp c:usrs.cpp@7:12@N@bar@F@bar#I#@z Extent=[7:12 - 7:19]
// CHECK: usrs.cpp c:@C@ClsA Extent=[10:1 - 14:2]
// CHECK: usrs.cpp c:@C@ClsA@FI@a Extent=[12:7 - 12:8]
// CHECK: usrs.cpp c:@C@ClsA@FI@b Extent=[12:10 - 12:11]
-// CHECK: usrs.cpp c:@C@ClsA@F@ClsA#I#I Extent=[13:3 - 13:37]
-// CHECK: usrs.cpp c:usrs.cpp@13:8@C@ClsA@F@ClsA#I#I@A Extent=[13:8 - 13:13]
-// CHECK: usrs.cpp c:usrs.cpp@13:15@C@ClsA@F@ClsA#I#I@B Extent=[13:15 - 13:20]
+// CHECK: usrs.cpp c:@C@ClsA@F@ClsA#I#I# Extent=[13:3 - 13:37]
+// CHECK: usrs.cpp c:usrs.cpp@13:8@C@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13]
+// CHECK: usrs.cpp c:usrs.cpp@13:15@C@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20]
// CHECK: usrs.cpp c:@N@foo Extent=[16:11 - 22:2]
// CHECK: usrs.cpp c:@N@foo@C@ClsB Extent=[17:3 - 21:4]
-// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@ClsB Extent=[19:5 - 19:27]
-// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result Extent=[20:9 - 20:17]
-// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result Extent=[24:16 - 26:2]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@ClsB# Extent=[19:5 - 19:27]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[20:9 - 20:17]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[24:16 - 26:2]
// CHECK: usrs.cpp c:@aN@C@ClsC Extent=[29:3 - 29:35]
// CHECK: usrs.cpp c:@aN@w Extent=[30:3 - 30:8]
// CHECK: usrs.cpp c:@z Extent=[33:1 - 33:6]
// CHECK: usrs.cpp c:@N@foo Extent=[35:11 - 40:2]
// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[35:27 - 39:2]
// CHECK: usrs.cpp c:@N@foo@N@taz@x Extent=[36:3 - 36:8]
-// CHECK: usrs.cpp c:usrs.cpp@37:21@N@foo@N@taz@F@add#I#I Extent=[37:21 - 37:56]
-// CHECK: usrs.cpp c:usrs.cpp@37:25@N@foo@N@taz@F@add#I#I@a Extent=[37:25 - 37:30]
-// CHECK: usrs.cpp c:usrs.cpp@37:32@N@foo@N@taz@F@add#I#I@b Extent=[37:32 - 37:37]
-// CHECK: usrs.cpp c:@N@foo@N@taz@F@sub#I#I Extent=[38:8 - 38:25]
-// CHECK: usrs.cpp c:usrs.cpp@38:12@N@foo@N@taz@F@sub#I#I@a Extent=[38:12 - 38:17]
-// CHECK: usrs.cpp c:usrs.cpp@38:19@N@foo@N@taz@F@sub#I#I@b Extent=[38:19 - 38:24]
-// CHECK: usrs.cpp c:@N@foo Extent=[42:11 - 48:3]
-// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[42:27 - 48:2]
-// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD Extent=[43:3 - 47:4]
-// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#I Extent=[45:11 - 45:52]
-// CHECK: usrs.cpp c:usrs.cpp@45:21@N@foo@N@taz@C@ClsD@F@operator=#I@x Extent=[45:21 - 45:26]
-// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#d Extent=[46:11 - 46:61]
-// CHECK: usrs.cpp c:usrs.cpp@46:21@N@foo@N@taz@C@ClsD@F@operator=#d@x Extent=[46:21 - 46:29]
-// CHECK: usrs.cpp c:@F@rez Extent=[51:8 - 51:25]
-// CHECK: usrs.cpp c:usrs.cpp@51:12@F@rez@a Extent=[51:12 - 51:17]
-// CHECK: usrs.cpp c:usrs.cpp@51:19@F@rez@b Extent=[51:19 - 51:24]
+// CHECK: usrs.cpp c:usrs.cpp@37:21@N@foo@N@taz@F@add#I#I# Extent=[37:21 - 37:56]
+// CHECK: usrs.cpp c:usrs.cpp@37:25@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30]
+// CHECK: usrs.cpp c:usrs.cpp@37:32@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37]
+// CHECK: usrs.cpp c:@N@foo@N@taz@F@sub#I#I# Extent=[38:8 - 38:25]
+// CHECK: usrs.cpp c:usrs.cpp@38:12@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17]
+// CHECK: usrs.cpp c:usrs.cpp@38:19@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24]
+// CHECK: usrs.cpp c:@N@foo Extent=[42:11 - 52:3]
+// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[42:27 - 52:2]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD Extent=[43:3 - 51:4]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#I# Extent=[45:11 - 45:52]
+// CHECK: usrs.cpp c:usrs.cpp@45:21@N@foo@N@taz@C@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#d# Extent=[46:11 - 46:61]
+// CHECK: usrs.cpp c:usrs.cpp@46:21@N@foo@N@taz@C@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD# Extent=[47:11 - 47:62]
+// CHECK: usrs.cpp c:usrs.cpp@47:27@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD#@x Extent=[47:27 - 47:34]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@qux#S Extent=[48:16 - 48:21]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@uz#I.#S Extent=[49:16 - 49:30]
+// CHECK: usrs.cpp c:usrs.cpp@49:19@N@foo@N@taz@C@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1 Extent=[50:10 - 50:62]
+// CHECK: usrs.cpp c:usrs.cpp@50:27@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1@x Extent=[50:27 - 50:34]
+// CHECK: usrs.cpp c:@F@rez Extent=[55:8 - 55:25]
+// CHECK: usrs.cpp c:usrs.cpp@55:12@F@rez@a Extent=[55:12 - 55:17]
+// CHECK: usrs.cpp c:usrs.cpp@55:19@F@rez@b Extent=[55:19 - 55:24]
diff --git a/clang/tools/libclang/CIndexUSRs.cpp b/clang/tools/libclang/CIndexUSRs.cpp
index 2a9d0c76f52..9b489a86f19 100644
--- a/clang/tools/libclang/CIndexUSRs.cpp
+++ b/clang/tools/libclang/CIndexUSRs.cpp
@@ -171,6 +171,13 @@ void USRGenerator::VisitFunctionDecl(FunctionDecl *D) {
}
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 @@ void USRGenerator::VisitType(QualType T) {
// 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 @@ void USRGenerator::VisitType(QualType T) {
T = CT->getElementType();
continue;
}
+ if (const TagType *TT = T->getAs<TagType>()) {
+ Out << '$';
+ VisitTagDecl(TT->getDecl());
+ return;
+ }
// Unhandled type.
Out << ' ';
OpenPOWER on IntegriCloud