r366085 - Use a unique_ptr instead of manual memory management for CustomDiagInfo
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 10:20:34 PDT 2019
Author: nico
Date: Mon Jul 15 10:20:34 2019
New Revision: 366085
URL: http://llvm.org/viewvc/llvm-project?rev=366085&view=rev
Log:
Use a unique_ptr instead of manual memory management for CustomDiagInfo
Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=366085&r1=366084&r2=366085&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Mon Jul 15 10:20:34 2019
@@ -169,7 +169,7 @@ public:
private:
/// Information for uniquing and looking up custom diags.
- diag::CustomDiagInfo *CustomDiagInfo;
+ std::unique_ptr<diag::CustomDiagInfo> CustomDiagInfo;
public:
DiagnosticIDs();
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=366085&r1=366084&r2=366085&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Mon Jul 15 10:20:34 2019
@@ -311,11 +311,9 @@ namespace clang {
// 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 @@ DiagnosticIDs::~DiagnosticIDs() {
/// 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);
}
More information about the cfe-commits
mailing list