c-index-test shouldn't crash when a goto has no matching label. Fixes <rdar://problem/9123493>.

llvm-svn: 127711
This commit is contained in:
Ted Kremenek 2011-03-15 23:47:49 +00:00
parent a4c3154fca
commit 6f7008dcb6
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,13 @@
// RUN: c-index-test -test-load-source local %s 2>&1 | FileCheck %s
// <rdar://problem/9123493>
void test() {
goto exit;
}
int foo;
int
// CHECK: cindex-on-invalid.m:6:70: error: expected identifier or '('
// CHECK: cindex-on-invalid.m:5:8: error: use of undeclared label 'exit'
// CHECK: cindex-on-invalid.m:13:1: error: expected identifier or '('

View File

@ -3709,7 +3709,9 @@ CXCursor clang_getCursorReferenced(CXCursor C) {
if (clang_isStatement(C.kind)) {
Stmt *S = getCursorStmt(C);
if (GotoStmt *Goto = dyn_cast_or_null<GotoStmt>(S))
return MakeCXCursor(Goto->getLabel()->getStmt(), getCursorDecl(C), tu);
if (LabelDecl *label = Goto->getLabel())
if (LabelStmt *labelS = label->getStmt())
return MakeCXCursor(labelS, getCursorDecl(C), tu);
return clang_getNullCursor();
}