--- /dev/null
+// RUN: not c-index-test -test-load-source local %s > %t 2> %t.err
+// RUN: FileCheck %s < %t.err
+
+// CHECK: error: expected identifier or '('
+// CHECK: Unable to load translation unit!
+
+int foo;
+int
command_line_args + num_command_line_args);
void *MainAddr = (void *)(uintptr_t)clang_createTranslationUnit;
- return ASTUnit::LoadFromCommandLine(Args.data(), Args.data() + Args.size(),
- CXXIdx->getDiags(), "<clang>", MainAddr,
- CXXIdx->getOnlyLocalDecls(),
- /* UseBumpAllocator = */ true);
+
+ unsigned NumErrors = CXXIdx->getDiags().getNumErrors();
+ llvm::OwningPtr<ASTUnit> Unit(
+ ASTUnit::LoadFromCommandLine(Args.data(), Args.data() + Args.size(),
+ CXXIdx->getDiags(), "<clang>", MainAddr,
+ CXXIdx->getOnlyLocalDecls(),
+ /* UseBumpAllocator = */ true));
+
+ // FIXME: Until we have broader testing, just drop the entire AST if we
+ // encountered an error.
+ if (NumErrors != CXXIdx->getDiags().getNumErrors())
+ return 0;
+
+ return Unit.take();
}
// Build up the arguments for invoking 'clang'.