[cfe-commits] r139547 - in /cfe/trunk: test/Index/annotate-tokens.c test/Index/annotate-tokens.m test/Index/blocks.c test/Index/c-index-api-loadTU-test.m test/Index/c-index-getCursor-test.m test/Index/load-stmts.cpp test/Index/recursive-cxx-member-calls.cpp tools/libclang/CIndex.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Sep 12 15:17:26 PDT 2011


Author: akirtzidis
Date: Mon Sep 12 17:17:26 2011
New Revision: 139547

URL: http://llvm.org/viewvc/llvm-project?rev=139547&view=rev
Log:
[libclang] For getDeclFromExpr in CIndex.cpp, associate the decl of
a DeclRefExpr, MemberExpr, etc. with a CastExpr if it is ImplicitCast,
since the implicit cast is the one that is invisible in source code.

Modified:
    cfe/trunk/test/Index/annotate-tokens.c
    cfe/trunk/test/Index/annotate-tokens.m
    cfe/trunk/test/Index/blocks.c
    cfe/trunk/test/Index/c-index-api-loadTU-test.m
    cfe/trunk/test/Index/c-index-getCursor-test.m
    cfe/trunk/test/Index/load-stmts.cpp
    cfe/trunk/test/Index/recursive-cxx-member-calls.cpp
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/annotate-tokens.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.c?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens.c (original)
+++ cfe/trunk/test/Index/annotate-tokens.c Mon Sep 12 17:17:26 2011
@@ -38,10 +38,10 @@
 // CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition)
 // CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
 // CHECK: Punctuation: "=" [4:12 - 4:13] VarDecl=t_ptr:4:6 (Definition)
-// CHECK: Punctuation: "(" [4:14 - 4:15] UnexposedExpr=ptr:3:14
+// CHECK: Punctuation: "(" [4:14 - 4:15] UnexposedExpr=
 // CHECK: Identifier: "T" [4:15 - 4:16] TypeRef=T:1:13
-// CHECK: Punctuation: "*" [4:17 - 4:18] UnexposedExpr=ptr:3:14
-// CHECK: Punctuation: ")" [4:18 - 4:19] UnexposedExpr=ptr:3:14
+// CHECK: Punctuation: "*" [4:17 - 4:18] UnexposedExpr=
+// CHECK: Punctuation: ")" [4:18 - 4:19] UnexposedExpr=
 // CHECK: Identifier: "ptr" [4:19 - 4:22] DeclRefExpr=ptr:3:14
 // CHECK: Punctuation: ";" [4:22 - 4:23] UnexposedStmt=
 // CHECK: Punctuation: "(" [5:3 - 5:4] UnexposedExpr=

Modified: cfe/trunk/test/Index/annotate-tokens.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.m?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens.m (original)
+++ cfe/trunk/test/Index/annotate-tokens.m Mon Sep 12 17:17:26 2011
@@ -299,9 +299,9 @@
 // CHECK: Punctuation: ")" [43:18 - 43:19] ParmDecl=x:43:19 (Definition)
 // CHECK: Identifier: "x" [43:19 - 43:20] ParmDecl=x:43:19 (Definition)
 // CHECK: Punctuation: "{" [44:1 - 44:2] UnexposedStmt=
-// CHECK: Punctuation: "(" [45:3 - 45:4] UnexposedExpr=x:43:19
-// CHECK: Keyword: "void" [45:4 - 45:8] UnexposedExpr=x:43:19
-// CHECK: Punctuation: ")" [45:8 - 45:9] UnexposedExpr=x:43:19
+// CHECK: Punctuation: "(" [45:3 - 45:4] UnexposedExpr=
+// CHECK: Keyword: "void" [45:4 - 45:8] UnexposedExpr=
+// CHECK: Punctuation: ")" [45:8 - 45:9] UnexposedExpr=
 // CHECK: Identifier: "x" [45:10 - 45:11] DeclRefExpr=x:43:19
 // CHECK: Punctuation: ";" [45:11 - 45:12] UnexposedStmt=
 // CHECK: Punctuation: "}" [46:1 - 46:2] UnexposedStmt=
@@ -442,9 +442,9 @@
 // CHECK: Punctuation: "(" [87:7 - 87:8] FunctionDecl=f:87:6 (Definition)
 // CHECK: Punctuation: ")" [87:8 - 87:9] FunctionDecl=f:87:6 (Definition)
 // CHECK: Punctuation: "{" [87:10 - 87:11] UnexposedStmt=
-// CHECK: Punctuation: "(" [88:3 - 88:4] UnexposedExpr=Proto:85:1
-// CHECK: Keyword: "void" [88:4 - 88:8] UnexposedExpr=Proto:85:1
-// CHECK: Punctuation: ")" [88:8 - 88:9] UnexposedExpr=Proto:85:1
+// CHECK: Punctuation: "(" [88:3 - 88:4] UnexposedExpr=
+// CHECK: Keyword: "void" [88:4 - 88:8] UnexposedExpr=
+// CHECK: Punctuation: ")" [88:8 - 88:9] UnexposedExpr=
 // CHECK: Punctuation: "@" [88:9 - 88:10] UnexposedExpr=Proto:85:1
 // CHECK: Keyword: "protocol" [88:10 - 88:18] UnexposedExpr=Proto:85:1
 // CHECK: Punctuation: "(" [88:18 - 88:19] UnexposedExpr=Proto:85:1

Modified: cfe/trunk/test/Index/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/blocks.c?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/blocks.c (original)
+++ cfe/trunk/test/Index/blocks.c Mon Sep 12 17:17:26 2011
@@ -24,7 +24,7 @@
 // CHECK: blocks.c:9:28: UnexposedStmt= Extent=[9:28 - 9:58]
 // CHECK: blocks.c:9:30: UnexposedStmt= Extent=[9:30 - 9:55]
 // CHECK: blocks.c:9:37: UnexposedExpr= Extent=[9:37 - 9:55]
-// CHECK: blocks.c:9:37: UnexposedExpr=x:4:19 Extent=[9:37 - 9:51]
+// CHECK: blocks.c:9:37: UnexposedExpr= Extent=[9:37 - 9:51]
 // CHECK: blocks.c:9:38: TypeRef=int_t:3:13 Extent=[9:38 - 9:43]
 // CHECK: blocks.c:9:50: MemberRefExpr=x:4:19 SingleRefName=[9:50 - 9:51] RefName=[9:50 - 9:51] Extent=[9:45 - 9:51]
 // CHECK: blocks.c:9:45: DeclRefExpr=foo:9:23 Extent=[9:45 - 9:48]

Modified: cfe/trunk/test/Index/c-index-api-loadTU-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-api-loadTU-test.m?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/c-index-api-loadTU-test.m (original)
+++ cfe/trunk/test/Index/c-index-api-loadTU-test.m Mon Sep 12 17:17:26 2011
@@ -137,7 +137,7 @@
 // CHECK: c-index-api-loadTU-test.m:54:3: UnexposedExpr=main:46:5 Extent=[54:3 - 54:7]
 // CHECK: c-index-api-loadTU-test.m:54:3: DeclRefExpr=main:46:5 Extent=[54:3 - 54:7]
 // CHECK: c-index-api-loadTU-test.m:54:8: DeclRefExpr=someEnum:43:3 Extent=[54:8 - 54:16]
-// CHECK: c-index-api-loadTU-test.m:54:18: UnexposedExpr=bee:47:8 Extent=[54:18 - 54:36]
+// CHECK: c-index-api-loadTU-test.m:54:18: UnexposedExpr= Extent=[54:18 - 54:36]
 // CHECK: c-index-api-loadTU-test.m:54:33: DeclRefExpr=bee:47:8 Extent=[54:33 - 54:36]
 // CHECK: c-index-api-loadTU-test.m:62:12: ObjCInterfaceDecl=TestAttributes:62:12 Extent=[62:1 - 67:5]
 // CHECK: c-index-api-loadTU-test.m:63:19: ObjCIvarDecl=anOutlet:63:19 (Definition) Extent=[58:18 - 63:27]

Modified: cfe/trunk/test/Index/c-index-getCursor-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-getCursor-test.m?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/c-index-getCursor-test.m (original)
+++ cfe/trunk/test/Index/c-index-getCursor-test.m Mon Sep 12 17:17:26 2011
@@ -158,7 +158,7 @@
 // CHECK: [52:7 - 52:8] CallExpr=main:44:5
 // CHECK: [52:8 - 52:16] DeclRefExpr=someEnum:41:3
 // CHECK: [52:16 - 52:18] CallExpr=main:44:5
-// CHECK: [52:18 - 52:33] UnexposedExpr=bee:45:8
+// CHECK: [52:18 - 52:33] UnexposedExpr=
 // CHECK: [52:33 - 52:36] DeclRefExpr=bee:45:8
 // CHECK: [52:36 - 52:37] CallExpr=main:44:5
 // CHECK: [52:37 - 53:2] UnexposedStmt=

Modified: cfe/trunk/test/Index/load-stmts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-stmts.cpp?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/load-stmts.cpp (original)
+++ cfe/trunk/test/Index/load-stmts.cpp Mon Sep 12 17:17:26 2011
@@ -202,8 +202,9 @@
 // CHECK: load-stmts.cpp:80:21: DeclRefExpr=j:79:44 Extent=[80:21 - 80:22]
 // CHECK: load-stmts.cpp:82:9: TypeRef=Integer:81:15 Extent=[82:9 - 82:16]
 // CHECK: load-stmts.cpp:82:17: DeclRefExpr=i:79:37 Extent=[82:17 - 82:18]
-// CHECK: load-stmts.cpp:83:3: UnexposedExpr=i:79:37 Extent=[83:3 - 83:13]
+// CHECK: load-stmts.cpp:83:3: UnexposedExpr= Extent=[83:3 - 83:13]
 // CHECK: load-stmts.cpp:83:4: TypeRef=Integer:81:15 Extent=[83:4 - 83:11]
+// CHECK: load-stmts.cpp:83:12: UnexposedExpr=i:79:37 Extent=[83:12 - 83:13]
 // CHECK: load-stmts.cpp:83:12: DeclRefExpr=i:79:37 Extent=[83:12 - 83:13]
 // CHECK: load-stmts.cpp:84:3: UnexposedExpr= Extent=[84:3 - 84:12]
 // CHECK: load-stmts.cpp:84:3: TypeRef=Integer:81:15 Extent=[84:3 - 84:10]
@@ -225,5 +226,6 @@
 // CHECK: load-stmts.cpp:108:2: LabelStmt=start_over Extent=[108:2 - 109:28]
 // CHECK: load-stmts.cpp:109:17: LabelRef=start_over:108:2 Extent=[109:17 - 109:27]
 // CHECK: load-stmts.cpp:113:10: LabelRef=start_over:108:2 Extent=[113:10 - 113:20]
-// CHECK: load-stmts.cpp:117:9: UnexposedExpr=ip:116:17 Extent=[117:9 - 117:38]
+// CHECK: load-stmts.cpp:117:35: UnexposedExpr=ip:116:17 Extent=[117:35 - 117:37]
+// CHECK: load-stmts.cpp:117:35: DeclRefExpr=ip:116:17 Extent=[117:35 - 117:37]
 

Modified: cfe/trunk/test/Index/recursive-cxx-member-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/recursive-cxx-member-calls.cpp?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/test/Index/recursive-cxx-member-calls.cpp (original)
+++ cfe/trunk/test/Index/recursive-cxx-member-calls.cpp Mon Sep 12 17:17:26 2011
@@ -952,16 +952,16 @@
 // CHECK-tokens: Keyword: "return" [105:3 - 105:9] UnexposedStmt=
 // FIXME: Missing "llvm" namespace reference below
 // CHECK-tokens: Identifier: "llvm" [105:10 - 105:14] NamespaceRef=llvm:82:11
-// CHECK-tokens: Punctuation: "::" [105:14 - 105:16] UnexposedExpr=StringSwitch:87:12
+// CHECK-tokens: Punctuation: "::" [105:14 - 105:16] UnexposedExpr=
 // CHECK-tokens: Identifier: "StringSwitch" [105:16 - 105:28] TemplateRef=StringSwitch:83:47
-// CHECK-tokens: Punctuation: "<" [105:29 - 105:30] UnexposedExpr=StringSwitch:87:12
+// CHECK-tokens: Punctuation: "<" [105:29 - 105:30] UnexposedExpr=
 // CHECK-tokens: Identifier: "AttributeList" [105:31 - 105:44] TypeRef=class clang::AttributeList:12:9
-// CHECK-tokens: Punctuation: "::" [105:44 - 105:46] UnexposedExpr=StringSwitch:87:12
+// CHECK-tokens: Punctuation: "::" [105:44 - 105:46] UnexposedExpr=
 // CHECK-tokens: Identifier: "Kind" [105:46 - 105:50] TypeRef=enum clang::AttributeList::Kind:13:10
 // CHECK-tokens: Punctuation: ">" [105:51 - 105:52] CallExpr=StringSwitch:87:12
 // CHECK-tokens: Punctuation: "(" [105:53 - 105:54] CallExpr=StringSwitch:87:12
 // CHECK-tokens: Identifier: "AttrName" [105:54 - 105:62] DeclRefExpr=AttrName:101:19
-// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] UnexposedExpr=StringSwitch:87:12
+// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] UnexposedExpr=
 // CHECK-tokens: Punctuation: "." [106:5 - 106:6] MemberRefExpr=Case:88:42
 // CHECK-tokens: Identifier: "Case" [106:6 - 106:10] MemberRefExpr=Case:88:42
 // CHECK-tokens: Punctuation: "(" [106:10 - 106:11] CallExpr=Case:88:42
@@ -1707,7 +1707,7 @@
 // CHECK: 54:11: DeclRefExpr=memcmp:7:7 Extent=[54:11 - 54:17]
 // CHECK: 54:18: UnexposedExpr=Data:43:15 Extent=[54:18 - 54:22]
 // CHECK: 54:18: MemberRefExpr=Data:43:15 Extent=[54:18 - 54:22]
-// CHECK: 54:24: UnexposedExpr=Data:43:15 Extent=[54:24 - 54:35]
+// CHECK: 54:31: UnexposedExpr=Data:43:15 Extent=[54:24 - 54:35]
 // CHECK: 54:31: MemberRefExpr=Data:43:15 SingleRefName=[54:31 - 54:35] RefName=[54:31 - 54:35] Extent=[54:24 - 54:35]
 // CHECK: 54:24: DeclRefExpr=Prefix:52:29 Extent=[54:24 - 54:30]
 // CHECK: 54:44: MemberRefExpr=Length:44:10 SingleRefName=[54:44 - 54:50] RefName=[54:44 - 54:50] Extent=[54:37 - 54:50]
@@ -1734,7 +1734,7 @@
 // CHECK: 58:14: MemberRefExpr=end:50:12 Extent=[58:14 - 58:17]
 // CHECK: 58:29: MemberRefExpr=Length:44:10 SingleRefName=[58:29 - 58:35] RefName=[58:29 - 58:35] Extent=[58:22 - 58:35]
 // CHECK: 58:22: DeclRefExpr=Suffix:56:27 Extent=[58:22 - 58:28]
-// CHECK: 58:37: UnexposedExpr=Data:43:15 Extent=[58:37 - 58:48]
+// CHECK: 58:44: UnexposedExpr=Data:43:15 Extent=[58:37 - 58:48]
 // CHECK: 58:44: MemberRefExpr=Data:43:15 SingleRefName=[58:44 - 58:48] RefName=[58:44 - 58:48] Extent=[58:37 - 58:48]
 // CHECK: 58:37: DeclRefExpr=Suffix:56:27 Extent=[58:37 - 58:43]
 // CHECK: 58:57: MemberRefExpr=Length:44:10 SingleRefName=[58:57 - 58:63] RefName=[58:57 - 58:63] Extent=[58:50 - 58:63]
@@ -1790,7 +1790,7 @@
 // CHECK: 74:5: UnexposedStmt= Extent=[74:5 - 74:61]
 // CHECK: 74:17: VarDecl=p:74:17 (Definition) Extent=[74:5 - 74:60]
 // CHECK: 74:21: UnexposedExpr= Extent=[74:21 - 74:60]
-// CHECK: 74:21: UnexposedExpr=second:4:55 Extent=[74:21 - 74:56]
+// CHECK: 74:50: UnexposedExpr=second:4:55 Extent=[74:21 - 74:56]
 // CHECK: 74:50: MemberRefExpr=second:4:55 SingleRefName=[74:50 - 74:56] RefName=[74:50 - 74:56] Extent=[74:21 - 74:56]
 // CHECK: 74:21: UnexposedExpr= Extent=[74:21 - 74:48]
 // CHECK: 74:22: UnexposedExpr= Extent=[74:22 - 74:47]
@@ -2079,7 +2079,7 @@
 // CHECK: 107:6: MemberRefExpr=Case:88:42 SingleRefName=[107:6 - 107:10] RefName=[107:6 - 107:10] Extent=[105:10 - 107:10]
 // CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 106:27]
 // CHECK: 106:6: MemberRefExpr=Case:88:42 SingleRefName=[106:6 - 106:10] RefName=[106:6 - 106:10] Extent=[105:10 - 106:10]
-// CHECK: 105:10: UnexposedExpr=StringSwitch:87:12 Extent=[105:10 - 105:63]
+// CHECK: 105:10: UnexposedExpr= Extent=[105:10 - 105:63]
 // CHECK: 105:16: TemplateRef=StringSwitch:83:47 Extent=[105:16 - 105:28]
 // CHECK: 105:10: CallExpr=StringSwitch:87:12 Extent=[105:10 - 105:62]
 // CHECK: 105:54: CallExpr=StringRef:38:7 Extent=[105:54 - 105:62]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=139547&r1=139546&r2=139547&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Sep 12 17:17:26 2011
@@ -2963,7 +2963,7 @@
 //===----------------------------------------------------------------------===//
 
 static Decl *getDeclFromExpr(Stmt *E) {
-  if (CastExpr *CE = dyn_cast<CastExpr>(E))
+  if (ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E))
     return getDeclFromExpr(CE->getSubExpr());
 
   if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
@@ -2999,6 +2999,9 @@
 }
 
 static SourceLocation getLocationFromExpr(Expr *E) {
+  if (ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E))
+    return getLocationFromExpr(CE->getSubExpr());
+
   if (ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E))
     return /*FIXME:*/Msg->getLeftLoc();
   if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))





More information about the cfe-commits mailing list