[cfe-commits] r118297 - in /cfe/trunk: test/Index/get-cursor.cpp test/Index/index-templates.cpp test/Index/load-stmts.cpp tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Fri Nov 5 14:11:19 PDT 2010
Author: dgregor
Date: Fri Nov 5 16:11:19 2010
New Revision: 118297
URL: http://llvm.org/viewvc/llvm-project?rev=118297&view=rev
Log:
Teach clang_getCursorReferenced() that a
CXXConstructorExpr/CXXTemporaryObjectExpr references the constructor
it calls. Then, tweak clang_getCursor() to prefer such a call over a
type reference to the type being called.
Modified:
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/test/Index/index-templates.cpp
cfe/trunk/test/Index/load-stmts.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=118297&r1=118296&r2=118297&view=diff
==============================================================================
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Fri Nov 5 16:11:19 2010
@@ -23,8 +23,11 @@
// RUN: c-index-test -cursor-at=%s:14:23 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
// CHECK-VALUE-REF: DeclRefExpr=value:10:12
-// FIXME: c-index-test -cursor-at=%s:12:18 %s | FileCheck -check-prefix=CHECK-TYPE-REF %s
-// RUN: c-index-test -cursor-at=%s:13:18 %s | FileCheck -check-prefix=CHECK-TYPE-REF %s
-// FIXME: c-index-test -cursor-at=%s:14:19 %s | FileCheck -check-prefix=CHECK-TYPE-REF %s
-// RUN: c-index-test -cursor-at=%s:17:10 %s | FileCheck -check-prefix=CHECK-TYPE-REF %s
+// RUN: c-index-test -cursor-at=%s:12:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
+// RUN: c-index-test -cursor-at=%s:13:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR2 %s
+// RUN: c-index-test -cursor-at=%s:14:19 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
+// RUN: c-index-test -cursor-at=%s:17:10 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR3 %s
// CHECK-TYPE-REF: TypeRef=struct X:3:8
+// CHECK-CONSTRUCTOR1: CallExpr=X:5:3
+// CHECK-CONSTRUCTOR2: CallExpr=X:6:3
+// CHECK-CONSTRUCTOR3: CallExpr=X:4:3
Modified: cfe/trunk/test/Index/index-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-templates.cpp?rev=118297&r1=118296&r2=118297&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-templates.cpp (original)
+++ cfe/trunk/test/Index/index-templates.cpp Fri Nov 5 16:11:19 2010
@@ -162,7 +162,7 @@
// CHECK-LOAD: index-templates.cpp:54:15: DeclRefExpr=OneDimension:35:16 Extent=[54:15 - 54:27]
// CHECK-LOAD: index-templates.cpp:54:29: TemplateRef=array:37:8 Extent=[54:29 - 54:34]
// CHECK-LOAD: index-templates.cpp:55:8: MemberRefExpr=getAs:50:26 Extent=[55:3 - 55:23]
-// CHECK-LOAD: index-templates.cpp:55:3: CallExpr= Extent=[55:3 - 55:7]
+// CHECK-LOAD: index-templates.cpp:55:3: CallExpr=Z4:49:8 Extent=[55:3 - 55:7]
// CHECK-LOAD: index-templates.cpp:55:14: TypeRef=Unsigned:42:18 Extent=[55:14 - 55:22]
// CHECK-LOAD: index-templates.cpp:68:6: FunctionTemplate=unresolved_exprs:68:6 (Definition)
// CHECK-LOAD: index-templates.cpp:69:3: OverloadedDeclRef=swap[60:6, 59:39, 58:27]
Modified: cfe/trunk/test/Index/load-stmts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-stmts.cpp?rev=118297&r1=118296&r2=118297&view=diff
==============================================================================
--- cfe/trunk/test/Index/load-stmts.cpp (original)
+++ cfe/trunk/test/Index/load-stmts.cpp Fri Nov 5 16:11:19 2010
@@ -215,7 +215,7 @@
// CHECK: load-stmts.cpp:104:5: MemberRef=member:100:7 Extent=[104:5 - 104:11]
// CHECK: load-stmts.cpp:104:12: DeclRefExpr=x:103:22 Extent=[104:12 - 104:13]
// CHECK: load-stmts.cpp:104:16: TypeRef=struct Base:94:8 Extent=[104:16 - 104:2
-// CHECK: load-stmts.cpp:104:16: CallExpr= Extent=[104:16 - 104:23]
+// CHECK: load-stmts.cpp:104:16: CallExpr=Base:95:3 Extent=[104:16 - 104:23]
// CHECK: load-stmts.cpp:104:21: DeclRefExpr=x:103:22 Extent=[104:21 - 104:22]
// CHECK: load-stmts.cpp:107:6: FunctionDecl=considered_harmful:107:6 (Definition)
// CHECK: load-stmts.cpp:108:2: LabelStmt=start_over Extent=[108:2 - 109:28]
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=118297&r1=118296&r2=118297&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Nov 5 16:11:19 2010
@@ -2435,6 +2435,9 @@
if (CallExpr *CE = dyn_cast<CallExpr>(E))
return getDeclFromExpr(CE->getCallee());
+ if (CXXConstructExpr *CE = llvm::dyn_cast<CXXConstructExpr>(E))
+ if (!CE->isElidable())
+ return CE->getConstructor();
if (ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(E))
return OME->getMethodDecl();
@@ -2870,6 +2873,15 @@
CXCursor parent,
CXClientData client_data) {
CXCursor *BestCursor = static_cast<CXCursor *>(client_data);
+
+ // If our current best cursor is the construction of a temporary object,
+ // don't replace that cursor with a type reference, because we want
+ // clang_getCursor() to point at the constructor.
+ if (clang_isExpression(BestCursor->kind) &&
+ isa<CXXTemporaryObjectExpr>(getCursorExpr(*BestCursor)) &&
+ cursor.kind == CXCursor_TypeRef)
+ return CXChildVisit_Recurse;
+
*BestCursor = cursor;
return CXChildVisit_Recurse;
}
More information about the cfe-commits
mailing list