diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-11 00:39:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-11 00:39:14 +0000 |
commit | e47be3e9682e82da15059006f43c7f3c021e4fff (patch) | |
tree | 949de514619f85922014fd05a870d393849d9534 /include/clang/Frontend/CompilerInstance.h | |
parent | e27e9d673346056e6ff7dca1d7fb1d75dfd42956 (diff) |
Improve ASTUnit's capture of diagnostics so that the
diagnostic-capturing client lives as long as the ASTUnit itself
does. Otherwise, we can end up with crashes when we get a diagnostic
outside of parsing/code completion. The circumstances under which this
happen are really hard to reproduce, because a file needs to change
from under us.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend/CompilerInstance.h')
-rw-r--r-- | include/clang/Frontend/CompilerInstance.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 3db6077029..f5d6221efc 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -477,8 +477,14 @@ public: /// Create the diagnostics engine using the invocation's diagnostic options /// and replace any existing one with it. /// - /// Note that this routine also replaces the diagnostic client. - void createDiagnostics(int Argc, const char* const *Argv); + /// Note that this routine also replaces the diagnostic client, + /// allocating one if one is not provided. + /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the Diagnostic inside this AST + /// unit. + void createDiagnostics(int Argc, const char* const *Argv, + DiagnosticClient *Client = 0); /// Create a Diagnostic object with a the TextDiagnosticPrinter. /// @@ -486,18 +492,24 @@ public: /// when the diagnostic options indicate that the compiler should output /// logging information. /// - /// Note that this creates an unowned DiagnosticClient, if using directly the - /// caller is responsible for releasing the returned Diagnostic's client - /// eventually. + /// If no diagnostic client is provided, this creates a + /// DiagnosticClient that is owned by the returned diagnostic + /// object, if using directly the 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. /// + /// \param Client If non-NULL, a diagnostic client that will be + /// attached to (and, then, owned by) the returned Diagnostic + /// object. + /// /// \return The new object on success, or null on failure. static llvm::IntrusiveRefCntPtr<Diagnostic> createDiagnostics(const DiagnosticOptions &Opts, int Argc, - const char* const *Argv); + const char* const *Argv, + DiagnosticClient *Client = 0); /// Create the file manager and replace any existing one with it. void createFileManager(); |