// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:47 -print-decls | count 1 &&
// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:47 -print-decls | grep 't1.c:5:12,' &&
// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:6:20 -print-decls | count 1 &&
-// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:6:20 -print-decls | grep 't1.c:3:19,'
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:6:20 -print-decls | grep 't1.c:3:19,' &&
+
+// field test
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:21:6 -print-decls | count 1 &&
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:21:6 -print-decls | grep 't1.c:12:7,' &&
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:22:21 -print-decls | count 1 &&
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:22:21 -print-decls | grep 't1.c:16:7,'
// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:30 -print-refs | count 3 &&
// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:30 -print-refs | grep 't1.c:5:27,' &&
// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:30 -print-refs | grep 't1.c:5:44,' &&
-// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:30 -print-refs | grep 't1.c:6:26,'
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:5:30 -print-refs | grep 't1.c:6:26,' &&
+
+// field test
+// FIXME: References point at the start of MemberExpr, make them point at the field instead.
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:12:7 -print-refs | count 1 &&
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:12:7 -print-refs | grep 't1.c:21:3,' &&
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:16:7 -print-refs | count 1 &&
+// RUN: index-test %t1.ast %t2.ast -point-at %S/t1.c:16:7 -print-refs | grep 't1.c:22:3,'
int local_var2 = for_var + 1;
}
}
+
+struct S {
+ int field_var;
+};
// RUN: index-test %t.ast -point-at %S/resolve-loc-input.c:8:9 | grep local_var2 &&
// RUN: index-test %t.ast -point-at %S/resolve-loc-input.c:8:30 | grep local_var2 &&
// RUN: index-test %t.ast -point-at %S/resolve-loc-input.c:8:30 | grep 'for_var + 1' &&
+
+// fields test.
+// RUN: index-test %t.ast -point-at %S/resolve-loc-input.c:13:10 | grep field_var
}
bar_func();
}
+
+struct S1 {
+ int x;
+};
+
+struct S2 {
+ int x;
+};
+
+void field_test(void) {
+ struct S1 s1;
+ s1.x = 0;
+ ((struct S2 *)0)->x = 0;
+}
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();
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
ProcessASTLocation(ASTLoc, IdxProvider);
}
}
+
+ if (HadErrors)
+ return 1;
if (!DisableFree) {
for (int i=0, e=TUnits.size(); i != e; ++i)