Handle struct fields through the index-test tool.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75596 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp
index 815d0d0..b7471a1 100644
--- a/tools/index-test/index-test.cpp
+++ b/tools/index-test/index-test.cpp
@@ -95,6 +95,8 @@
llvm::cl::desc("Disable freeing of memory on exit"),
llvm::cl::init(false));
+static bool HadErrors = false;
+
static void ProcessDecl(Decl *D) {
assert(D);
llvm::raw_ostream &OS = llvm::outs();
@@ -155,10 +157,17 @@
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 {
D = ASTLoc.getDecl();
}
- assert(D);
+
+ if (D == 0) {
+ llvm::errs() << "Error: Couldn't get a Decl out of the ASTLocation";
+ HadErrors = true;
+ return;
+ }
Entity *Ent = Entity::get(D, IdxProvider.getProgram());
// If there is no Entity associated with this Decl, it means that it's not
@@ -267,6 +276,9 @@
ProcessASTLocation(ASTLoc, IdxProvider);
}
}
+
+ if (HadErrors)
+ return 1;
if (!DisableFree) {
for (int i=0, e=TUnits.size(); i != e; ++i)