Document that CompilerInvocation::createDiagnostics keeps a reference to the DiagnosticOptions, and update callers to make sure they don't pass in a temporary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90704 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index 9259818..5e8e02d 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -292,6 +292,7 @@
};
class CIndexer : public Indexer {
+ DiagnosticOptions DiagOpts;
IgnoreDiagnosticsClient IgnoreDiagClient;
llvm::OwningPtr<Diagnostic> TextDiags;
Diagnostic IgnoreDiags;
@@ -308,7 +309,7 @@
OnlyLocalDecls(false),
DisplayDiagnostics(false) {
TextDiags.reset(
- CompilerInstance::createDiagnostics(DiagnosticOptions(), 0, 0));
+ CompilerInstance::createDiagnostics(DiagOpts, 0, 0));
}
virtual ~CIndexer() { delete &getProgram(); }
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp
index d13b2d4..0b1971f 100644
--- a/tools/index-test/index-test.cpp
+++ b/tools/index-test/index-test.cpp
@@ -238,8 +238,9 @@
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())