aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/CIndex/CIndex.cpp3
-rw-r--r--tools/CIndex/CIndexCodeCompletion.cpp8
-rw-r--r--tools/CIndex/CIndexDiagnostic.cpp7
-rw-r--r--tools/CIndex/CIndexDiagnostic.h4
4 files changed, 18 insertions, 4 deletions
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index 1afd8c23ba..718aff02ed 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -1095,7 +1095,8 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
ATU->unlinkTemporaryFile();
ReportSerializedDiagnostics(DiagnosticsFile, *Diags,
- num_unsaved_files, unsaved_files);
+ num_unsaved_files, unsaved_files,
+ ATU->getASTContext().getLangOptions());
for (unsigned i = 0, e = TemporaryFiles.size(); i != e; ++i)
TemporaryFiles[i].eraseFromDisk();
diff --git a/tools/CIndex/CIndexCodeCompletion.cpp b/tools/CIndex/CIndexCodeCompletion.cpp
index fe4eb8af11..4e41c5f1c7 100644
--- a/tools/CIndex/CIndexCodeCompletion.cpp
+++ b/tools/CIndex/CIndexCodeCompletion.cpp
@@ -178,6 +178,8 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
/// \brief The memory buffer from which we parsed the results. We
/// retain this buffer because the completion strings point into it.
llvm::MemoryBuffer *Buffer;
+
+ LangOptions LangOpts;
};
CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
@@ -339,8 +341,12 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
Results->Buffer = F;
}
+ // FIXME: The LangOptions we are passing here are not at all correct. However,
+ // in the current design we must pass something in so the SourceLocations have
+ // a LangOptions object to refer to.
ReportSerializedDiagnostics(DiagnosticsFile, *Diags,
- num_unsaved_files, unsaved_files);
+ num_unsaved_files, unsaved_files,
+ Results->LangOpts);
for (unsigned i = 0, e = TemporaryFiles.size(); i != e; ++i)
TemporaryFiles[i].eraseFromDisk();
diff --git a/tools/CIndex/CIndexDiagnostic.cpp b/tools/CIndex/CIndexDiagnostic.cpp
index 52de8bbc91..c48872cebc 100644
--- a/tools/CIndex/CIndexDiagnostic.cpp
+++ b/tools/CIndex/CIndexDiagnostic.cpp
@@ -215,7 +215,8 @@ CXString clang_getDiagnosticFixItReplacement(CXDiagnostic Diag,
void clang::ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath,
Diagnostic &Diags,
unsigned num_unsaved_files,
- struct CXUnsavedFile *unsaved_files) {
+ struct CXUnsavedFile *unsaved_files,
+ const LangOptions &LangOpts) {
using llvm::MemoryBuffer;
using llvm::StringRef;
MemoryBuffer *F = MemoryBuffer::getFile(DiagnosticsPath.c_str());
@@ -244,6 +245,8 @@ void clang::ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath,
SourceMgr.overrideFileContents(File, Buffer);
}
+ Diags.getClient()->BeginSourceFile(LangOpts, 0);
+
// Parse the diagnostics, emitting them one by one until we've
// exhausted the data.
StringRef Buffer = F->getBuffer();
@@ -254,4 +257,6 @@ void clang::ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath,
if (!DB.isActive())
return;
}
+
+ Diags.getClient()->EndSourceFile();
}
diff --git a/tools/CIndex/CIndexDiagnostic.h b/tools/CIndex/CIndexDiagnostic.h
index 62d219cea9..5fef01e555 100644
--- a/tools/CIndex/CIndexDiagnostic.h
+++ b/tools/CIndex/CIndexDiagnostic.h
@@ -24,6 +24,7 @@ class Path;
namespace clang {
class Diagnostic;
+class LangOptions;
class Preprocessor;
/**
@@ -55,7 +56,8 @@ public:
void ReportSerializedDiagnostics(const llvm::sys::Path &DiagnosticsPath,
Diagnostic &Diags,
unsigned num_unsaved_files,
- struct CXUnsavedFile *unsaved_files);
+ struct CXUnsavedFile *unsaved_files,
+ const LangOptions &LangOpts);
} // end namespace clang