[cfe-commits] r94927 - in /cfe/trunk/tools/CIndex: CIndex.cpp CIndexCodeCompletion.cpp CIndexDiagnostic.cpp CIndexDiagnostic.h
Daniel Dunbar
daniel at zuster.org
Sat Jan 30 15:31:40 PST 2010
Author: ddunbar
Date: Sat Jan 30 17:31:40 2010
New Revision: 94927
URL: http://llvm.org/viewvc/llvm-project?rev=94927&view=rev
Log:
CIndex: Fix ReportSerializedDiagnostics to honor the DiagnosticClient contract
that diagnostics with a source location should occur inside
{Begin,End}SourceFile.
Note that code completion is currently passing in an invalid LangOptions object
due to its implementation, I need to sort this out with Doug.
Modified:
cfe/trunk/tools/CIndex/CIndex.cpp
cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp
cfe/trunk/tools/CIndex/CIndexDiagnostic.cpp
cfe/trunk/tools/CIndex/CIndexDiagnostic.h
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=94927&r1=94926&r2=94927&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Sat Jan 30 17:31:40 2010
@@ -1095,7 +1095,8 @@
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();
Modified: cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp?rev=94927&r1=94926&r2=94927&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndexCodeCompletion.cpp Sat Jan 30 17:31:40 2010
@@ -178,6 +178,8 @@
/// \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 @@
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();
Modified: cfe/trunk/tools/CIndex/CIndexDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndexDiagnostic.cpp?rev=94927&r1=94926&r2=94927&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndexDiagnostic.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndexDiagnostic.cpp Sat Jan 30 17:31:40 2010
@@ -215,7 +215,8 @@
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 @@
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 @@
if (!DB.isActive())
return;
}
+
+ Diags.getClient()->EndSourceFile();
}
Modified: cfe/trunk/tools/CIndex/CIndexDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndexDiagnostic.h?rev=94927&r1=94926&r2=94927&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndexDiagnostic.h (original)
+++ cfe/trunk/tools/CIndex/CIndexDiagnostic.h Sat Jan 30 17:31:40 2010
@@ -24,6 +24,7 @@
namespace clang {
class Diagnostic;
+class LangOptions;
class Preprocessor;
/**
@@ -55,7 +56,8 @@
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
More information about the cfe-commits
mailing list