aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-23 17:57:17 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-23 17:57:17 +0000
commitedab047e10d745a65d12c8cb36be2ba9e96c9e0e (patch)
tree4b22df06f421c7acd3ca09e57e9f88333f0ecd6e /tools
parentdd3e2d90418de46b77a9dde3bb992390610e343a (diff)
[libclang] Introduce a CXCursor_ObjCSelfExpr cursor, which is the equivalent of CXCursor_CXXThisExpr for C++ code.
rdar://13717006 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/libclang/CIndex.cpp2
-rw-r--r--tools/libclang/CXCursor.cpp16
2 files changed, 17 insertions, 1 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index d29e3d8608..0a8a068998 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -3588,6 +3588,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("ObjCStringLiteral");
case CXCursor_ObjCBoolLiteralExpr:
return cxstring::createRef("ObjCBoolLiteralExpr");
+ case CXCursor_ObjCSelfExpr:
+ return cxstring::createRef("ObjCSelfExpr");
case CXCursor_ObjCEncodeExpr:
return cxstring::createRef("ObjCEncodeExpr");
case CXCursor_ObjCSelectorExpr:
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp
index e490b5da3d..b5682055b9 100644
--- a/tools/libclang/CXCursor.cpp
+++ b/tools/libclang/CXCursor.cpp
@@ -435,7 +435,21 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
K = CXCursor_SizeOfPackExpr;
break;
- case Stmt::DeclRefExprClass:
+ case Stmt::DeclRefExprClass:
+ if (const ImplicitParamDecl *IPD =
+ dyn_cast_or_null<ImplicitParamDecl>(cast<DeclRefExpr>(S)->getDecl())) {
+ if (const ObjCMethodDecl *MD =
+ dyn_cast<ObjCMethodDecl>(IPD->getDeclContext())) {
+ if (MD->getSelfDecl() == IPD) {
+ K = CXCursor_ObjCSelfExpr;
+ break;
+ }
+ }
+ }
+
+ K = CXCursor_DeclRefExpr;
+ break;
+
case Stmt::DependentScopeDeclRefExprClass:
case Stmt::SubstNonTypeTemplateParmExprClass:
case Stmt::SubstNonTypeTemplateParmPackExprClass: