aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/Indexing.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-04-11 02:11:16 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-04-11 02:11:16 +0000
commite722ed6f5464232e23be52f4976312ef526fae99 (patch)
treea0996067f02cadf86b040e792f2dc5cfb19ba4fc /tools/libclang/Indexing.cpp
parent259052d8c819d101f6f627f960f56e582ecbcebc (diff)
[libclang] If displayDiagnostics is set (when calling clang_createIndex), make sure to
output the errors that occurred even if we did not get an AST (e.g. because the PCH failed to load). Also honor displayDiagnostics in clang_indexSourceFile(). rdar://11203489 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r--tools/libclang/Indexing.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 6ece54857a..e660c4d6eb 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -388,7 +388,8 @@ static void clang_indexSourceFile_Impl(void *UserData) {
}
}
- Unit = ASTUnit::LoadFromCompilerInvocationAction(CInvok.getPtr(), Diags,
+ DiagnosticErrorTrap DiagTrap(*Diags);
+ bool Success = ASTUnit::LoadFromCompilerInvocationAction(CInvok.getPtr(), Diags,
IndexAction.get(),
Unit,
Persistent,
@@ -397,7 +398,10 @@ static void clang_indexSourceFile_Impl(void *UserData) {
/*CaptureDiagnostics=*/true,
PrecompilePreamble,
CacheCodeCompletionResults);
- if (!Unit)
+ if (DiagTrap.hasErrorOccurred() && CXXIdx->getDisplayDiagnostics())
+ printDiagsToStderr(Unit);
+
+ if (!Success)
return;
if (out_TU)