]> granicus.if.org Git - clang/commitdiff
CIndex: Fix ReportSerializedDiagnostics to honor the DiagnosticClient contract
authorDaniel Dunbar <daniel@zuster.org>
Sat, 30 Jan 2010 23:31:40 +0000 (23:31 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 30 Jan 2010 23:31:40 +0000 (23:31 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94927 91177308-0d34-0410-b5e6-96231b3b80d8

tools/CIndex/CIndex.cpp
tools/CIndex/CIndexCodeCompletion.cpp
tools/CIndex/CIndexDiagnostic.cpp
tools/CIndex/CIndexDiagnostic.h

index 1afd8c23ba140e9fe4e3ccf7933a379d319d1b42..718aff02ed04fd2797a60ef2121a1faae276867e 100644 (file)
@@ -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();
index fe4eb8af1165ee8ad4f2b29b7694a88f47ae469e..4e41c5f1c7b5b95d3642516804483047d4d6b270 100644 (file)
@@ -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();
index 52de8bbc912ed0985285bbe34b46509a076e79fb..c48872cebcf24466ddfc7edaaf667adfe8fe685f 100644 (file)
@@ -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();
 }
index 62d219cea9b192baa4105fa1fa8240126870a2cb..5fef01e555ae3b1b054f1762cd969338b96005ea 100644 (file)
@@ -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