Use a unique_ptr instead of manual memory management for CustomDiagInfo
llvm-svn: 366085
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index f189e5d..e30e375 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -311,11 +311,9 @@
// Common Diagnostic implementation
//===----------------------------------------------------------------------===//
-DiagnosticIDs::DiagnosticIDs() { CustomDiagInfo = nullptr; }
+DiagnosticIDs::DiagnosticIDs() {}
-DiagnosticIDs::~DiagnosticIDs() {
- delete CustomDiagInfo;
-}
+DiagnosticIDs::~DiagnosticIDs() {}
/// getCustomDiagID - Return an ID for a diagnostic with the specified message
/// and level. If this is the first request for this diagnostic, it is
@@ -325,7 +323,7 @@
/// mapped to a unique DiagID.
unsigned DiagnosticIDs::getCustomDiagID(Level L, StringRef FormatString) {
if (!CustomDiagInfo)
- CustomDiagInfo = new diag::CustomDiagInfo();
+ CustomDiagInfo.reset(new diag::CustomDiagInfo());
return CustomDiagInfo->getOrCreateDiagID(L, FormatString, *this);
}