aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/Indexing.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-01 02:42:50 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-01 02:42:50 +0000
commit996e6e564af7483e2d5e0b70df5fdb9f79ec4b5a (patch)
treea0602e3d756ca406211e375f4b4c97ad3d9c5677 /tools/libclang/Indexing.cpp
parent185dbd7782a45d0f830218bfbc196c6b664ed8d9 (diff)
[libclang] Create a diagnostic set to pass at the end of indexing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r--tools/libclang/Indexing.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index f462c14dbf..50c37bc51f 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -12,6 +12,7 @@
#include "CXSourceLocation.h"
#include "CXTranslationUnit.h"
#include "CXString.h"
+#include "CIndexDiagnostic.h"
#include "CIndexer.h"
#include "clang/Frontend/ASTUnit.h"
@@ -31,6 +32,8 @@ using namespace cxstring;
using namespace cxtu;
using namespace cxindex;
+static void indexDiagnostics(CXTranslationUnit TU, IndexingContext &IdxCtx);
+
namespace {
//===----------------------------------------------------------------------===//
@@ -158,13 +161,15 @@ public:
class IndexingFrontendAction : public ASTFrontendAction {
IndexingContext IndexCtx;
+ CXTranslationUnit CXTU;
public:
IndexingFrontendAction(CXClientData clientData,
IndexerCallbacks &indexCallbacks,
unsigned indexOptions,
CXTranslationUnit cxTU)
- : IndexCtx(clientData, indexCallbacks, indexOptions, cxTU) { }
+ : IndexCtx(clientData, indexCallbacks, indexOptions, cxTU),
+ CXTU(cxTU) { }
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
@@ -174,6 +179,10 @@ public:
return new IndexingConsumer(IndexCtx);
}
+ virtual void EndSourceFileAction() {
+ indexDiagnostics(CXTU, IndexCtx);
+ }
+
virtual TranslationUnitKind getTranslationUnitKind() { return TU_Prefix; }
virtual bool hasCodeCompletionSupport() const { return false; }
};
@@ -334,7 +343,6 @@ static void clang_indexSourceFile_Impl(void *UserData) {
bool Persistent = requestedToGetTU;
StringRef ResourceFilesPath = CXXIdx->getClangResourcesPath();
bool OnlyLocalDecls = false;
- bool CaptureDiagnostics = true;
bool PrecompilePreamble = false;
bool CacheCodeCompletionResults = false;
PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts();
@@ -360,13 +368,12 @@ static void clang_indexSourceFile_Impl(void *UserData) {
Persistent,
ResourceFilesPath,
OnlyLocalDecls,
- CaptureDiagnostics,
+ /*CaptureDiagnostics=*/true,
PrecompilePreamble,
CacheCodeCompletionResults);
if (!Unit)
return;
- // FIXME: Set state of the ASTUnit according to the TU_options.
if (out_TU)
*out_TU = CXTU->takeTU();
@@ -450,8 +457,11 @@ static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) {
}
static void indexDiagnostics(CXTranslationUnit TU, IndexingContext &IdxCtx) {
- // FIXME: Create a CXDiagnosticSet from TU;
- // IdxCtx.handleDiagnosticSet(Set);
+ if (!IdxCtx.hasDiagnosticCallback())
+ return;
+
+ CXDiagnosticSetImpl *DiagSet = cxdiag::lazyCreateDiags(TU);
+ IdxCtx.handleDiagnosticSet(DiagSet);
}
static void clang_indexTranslationUnit_Impl(void *UserData) {