]> granicus.if.org Git - clang/commitdiff
Use a unique_ptr instead of manual memory management for LineTable
authorNico Weber <nicolasweber@gmx.de>
Mon, 15 Jul 2019 17:27:46 +0000 (17:27 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 15 Jul 2019 17:27:46 +0000 (17:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@366088 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceManager.h
lib/Basic/SourceManager.cpp

index 388fc1c1f862226e2929e6300a1dfefa3d1e0631..e32f749ae6abdf639eac4e0f8aabc282dbafebf1 100644 (file)
@@ -679,7 +679,7 @@ class SourceManager : public RefCountedBase<SourceManager> {
   /// Holds information for \#line directives.
   ///
   /// This is referenced by indices from SLocEntryTable.
-  LineTableInfo *LineTable = nullptr;
+  std::unique_ptr<LineTableInfo> LineTable;
 
   /// These ivars serve as a cache used in the getLineNumber
   /// method which is used to speedup getLineNumber calls to nearby locations.
index c7588aa796fe70f6d3894af1e230919188f6966e..12b0305e707c93210eba72348083576a5a4448f2 100644 (file)
@@ -329,7 +329,7 @@ void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
 
 LineTableInfo &SourceManager::getLineTable() {
   if (!LineTable)
-    LineTable = new LineTableInfo();
+    LineTable.reset(new LineTableInfo());
   return *LineTable;
 }
 
@@ -345,8 +345,6 @@ SourceManager::SourceManager(DiagnosticsEngine &Diag, FileManager &FileMgr,
 }
 
 SourceManager::~SourceManager() {
-  delete LineTable;
-
   // Delete FileEntry objects corresponding to content caches.  Since the actual
   // content cache objects are bump pointer allocated, we just have to run the
   // dtors, but we call the deallocate method for completeness.