]> granicus.if.org Git - clang/commitdiff
Document that CompilerInvocation::createDiagnostics keeps a reference to the Diagnost...
authorDaniel Dunbar <daniel@zuster.org>
Sun, 6 Dec 2009 09:56:30 +0000 (09:56 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 6 Dec 2009 09:56:30 +0000 (09:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90704 91177308-0d34-0410-b5e6-96231b3b80d8

examples/wpa/clang-wpa.cpp
include/clang/Frontend/CompilerInstance.h
tools/CIndex/CIndex.cpp
tools/index-test/index-test.cpp

index cca7907ba0978dcbe157c1b967ae1b93b14adf02..ae789fa9ae3cfd1675c28f04f84b265c4e1ee4a7 100644 (file)
@@ -33,8 +33,9 @@ int main(int argc, char **argv) {
   if (InputFilenames.empty())
     return 0;
 
+  DiagnosticOptions DiagOpts;
   llvm::OwningPtr<Diagnostic> Diags(
-    CompilerInstance::createDiagnostics(DiagnosticOptions(), argc, argv));
+    CompilerInstance::createDiagnostics(DiagOpts, argc, argv));
 
   for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
     const std::string &InFile = InputFilenames[i];
index 27153b63c839988d3d95b24ef1d963ab84b93a2d..18ec429db7e8e4ec6e8433a55f5bf8d91d99e5c5 100644 (file)
@@ -419,9 +419,13 @@ public:
   /// logging information.
   ///
   /// Note that this creates an unowned DiagnosticClient, if using directly the
-  /// caller is responsible for releaseing the returned Diagnostic's client
+  /// caller is responsible for releasing the returned Diagnostic's client
   /// eventually.
   ///
+  /// \param Opts - The diagnostic options; note that the created text
+  /// diagnostic object contains a reference to these options and its lifetime
+  /// must extend past that of the diagnostic engine.
+  ///
   /// \return The new object on success, or null on failure.
   static Diagnostic *createDiagnostics(const DiagnosticOptions &Opts,
                                        int Argc, char **Argv);
index 9259818e0ecaf6027d6dd3040898fc1d92c90c3d..5e8e02df1a9252594a5ea7c5b5eb8e5f7ef4eb47 100644 (file)
@@ -292,6 +292,7 @@ public:
 };
 
 class CIndexer : public Indexer {
+  DiagnosticOptions DiagOpts;
   IgnoreDiagnosticsClient IgnoreDiagClient;
   llvm::OwningPtr<Diagnostic> TextDiags;
   Diagnostic IgnoreDiags;
@@ -308,7 +309,7 @@ public:
                                      OnlyLocalDecls(false),
                                      DisplayDiagnostics(false) {
     TextDiags.reset(
-      CompilerInstance::createDiagnostics(DiagnosticOptions(), 0, 0));
+      CompilerInstance::createDiagnostics(DiagOpts, 0, 0));
   }
 
   virtual ~CIndexer() { delete &getProgram(); }
index d13b2d492645bf2cea2d6a7e9334b65d3781ff35..0b1971f797c4738309e0e35fb5a79922ce050e77 100644 (file)
@@ -238,8 +238,9 @@ int main(int argc, char **argv) {
   Indexer Idxer(Prog);
   llvm::SmallVector<TUnit*, 4> TUnits;
 
+  DiagnosticOptions DiagOpts;
   llvm::OwningPtr<Diagnostic> Diags(
-    CompilerInstance::createDiagnostics(DiagnosticOptions(), argc, argv));
+    CompilerInstance::createDiagnostics(DiagOpts, argc, argv));
 
   // If no input was specified, read from stdin.
   if (InputFilenames.empty())