diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-01 17:38:59 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-01 17:38:59 +0000 |
commit | e9ebd852ec1effa393bcc4aad73d9c657a5279c1 (patch) | |
tree | 052669dac34fd31547c5ca8b2a54d915c713056c /tools | |
parent | 81d2d38d2d774a2550fa0d2efffa707e7a53b39c (diff) |
[libclang] Make clang_Cursor_getArgument work with call-exprs.
Patch by Matthias Kleine!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libclang/CXCursor.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index 73d11f943a..7b01ec2de0 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -939,6 +939,13 @@ int clang_Cursor_getNumArguments(CXCursor C) { return FD->param_size(); } + if (clang_isExpression(C.kind)) { + const Expr *E = cxcursor::getCursorExpr(C); + if (const CallExpr *CE = dyn_cast<CallExpr>(E)) { + return CE->getNumArgs(); + } + } + return -1; } @@ -956,6 +963,17 @@ CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i) { } } + if (clang_isExpression(C.kind)) { + const Expr *E = cxcursor::getCursorExpr(C); + if (const CallExpr *CE = dyn_cast<CallExpr>(E)) { + if (i < CE->getNumArgs()) { + return cxcursor::MakeCXCursor(CE->getArg(i), + getCursorDecl(C), + cxcursor::getCursorTU(C)); + } + } + } + return clang_getNullCursor(); } |