diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/Diagnostic.h | 5 | ||||
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 7 | ||||
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index fd34fdec1e3..19e7c91f532 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -335,10 +335,7 @@ public: /// /// \param ShouldOwnClient true if the diagnostic object should take /// ownership of \c client. - void setClient(DiagnosticClient *client, bool ShouldOwnClient = true) { - Client = client; - OwnsDiagClient = ShouldOwnClient; - } + void setClient(DiagnosticClient *client, bool ShouldOwnClient = true); /// setErrorLimit - Specify a limit for the number of errors we should /// emit before giving up. Zero disables the limit. diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 9a263c1d0bc..31e33315cce 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -62,6 +62,13 @@ Diagnostic::~Diagnostic() { delete Client; } +void Diagnostic::setClient(DiagnosticClient *client, bool ShouldOwnClient) { + if (OwnsDiagClient && Client) + delete Client; + + Client = client; + OwnsDiagClient = ShouldOwnClient; +} void Diagnostic::pushMappings(SourceLocation Loc) { DiagStateOnPushStack.push_back(GetCurDiagState()); diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 808f4e96171..8c87d376519 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -827,6 +827,8 @@ static int perform_file_scan(const char *ast_file, const char *source_file, } fclose(fp); + clang_disposeTranslationUnit(TU); + clang_disposeIndex(Idx); return 0; } |