client. Fixes a libclang leak.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124614
91177308-0d34-0410-b5e6-
96231b3b80d8
///
/// \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.
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());
}
fclose(fp);
+ clang_disposeTranslationUnit(TU);
+ clang_disposeIndex(Idx);
return 0;
}