diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-14 03:19:30 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-14 03:19:30 +0000 |
commit | e6cd787ee15468a35141ae8462767eb6a1b4f258 (patch) | |
tree | 788713f5713cb49469bb89c1993f4d7f48012f91 /clang/tools/index-test/index-test.cpp | |
parent | eeaaead73657bb0903e0a0ede60fbf5c1e671ee9 (diff) | |
download | bcm5719-llvm-e6cd787ee15468a35141ae8462767eb6a1b4f258.tar.gz bcm5719-llvm-e6cd787ee15468a35141ae8462767eb6a1b4f258.zip |
For index-test, if the ASTLocation points at a CallExpr, get a Decl out of it.
llvm-svn: 75599
Diffstat (limited to 'clang/tools/index-test/index-test.cpp')
-rw-r--r-- | clang/tools/index-test/index-test.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/clang/tools/index-test/index-test.cpp b/clang/tools/index-test/index-test.cpp index b7471a1c9d0..63c86aac464 100644 --- a/clang/tools/index-test/index-test.cpp +++ b/clang/tools/index-test/index-test.cpp @@ -150,18 +150,27 @@ static void ProcessDecl(Decl *D) { } } +static Decl *getDeclFromExpr(Stmt *E) { + if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E)) + return RefExpr->getDecl(); + if (MemberExpr *ME = dyn_cast<MemberExpr>(E)) + return ME->getMemberDecl(); + if (CallExpr *CE = dyn_cast<CallExpr>(E)) + return getDeclFromExpr(CE->getCallee()); + if (CastExpr *CE = dyn_cast<CastExpr>(E)) + return getDeclFromExpr(CE->getSubExpr()); + + return 0; +} + static void ProcessASTLocation(ASTLocation ASTLoc, IndexProvider &IdxProvider) { assert(ASTLoc.isValid()); Decl *D = 0; - if (ASTLoc.isStmt()) { - if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(ASTLoc.getStmt())) - D = RefExpr->getDecl(); - else if (MemberExpr *ME = dyn_cast<MemberExpr>(ASTLoc.getStmt())) - D = ME->getMemberDecl(); - } else { + if (ASTLoc.isStmt()) + D = getDeclFromExpr(ASTLoc.getStmt()); + else D = ASTLoc.getDecl(); - } if (D == 0) { llvm::errs() << "Error: Couldn't get a Decl out of the ASTLocation"; |