aboutsummaryrefslogtreecommitdiff
path: root/tools/index-test/index-test.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-18 21:17:58 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-18 21:17:58 +0000
commitdc50c64c13322dd81b10263cbb023fb1f7eae1fd (patch)
treee6b17761f2ce1cf4151b7798c6888f154d114c20 /tools/index-test/index-test.cpp
parent9b9685dc713679581b3953cd9ece0001b63f551f (diff)
Introduce ASTLocation::getReferencedDecl(), for getting the declaration that the ASTLocation references.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/index-test/index-test.cpp')
-rw-r--r--tools/index-test/index-test.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp
index 10449ed0ba..9f02c2284f 100644
--- a/tools/index-test/index-test.cpp
+++ b/tools/index-test/index-test.cpp
@@ -141,30 +141,12 @@ 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())
- D = getDeclFromExpr(ASTLoc.getStmt());
- else
- D = ASTLoc.getDecl();
-
+ Decl *D = ASTLoc.getReferencedDecl();
if (D == 0) {
- llvm::errs() << "Error: Couldn't get a Decl out of the ASTLocation";
+ llvm::errs() << "Error: Couldn't get a referenced Decl for the ASTLocation";
HadErrors = true;
return;
}