Document that CompilerInvocation::createDiagnostics keeps a reference to the DiagnosticOptions, and update callers to make sure they don't pass in a temporary.

llvm-svn: 90704
This commit is contained in:
Daniel Dunbar 2009-12-06 09:56:30 +00:00
parent a6cb9f21be
commit 1597da4c05
4 changed files with 11 additions and 4 deletions

View 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];

View 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);

View 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(); }

View 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())