]> granicus.if.org Git - clang/commitdiff
Fix memory leak caused by r286096.
authorEric Liu <ioeric@google.com>
Mon, 7 Nov 2016 18:40:41 +0000 (18:40 +0000)
committerEric Liu <ioeric@google.com>
Mon, 7 Nov 2016 18:40:41 +0000 (18:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286132 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Tooling/RefactoringTest.cpp

index 31b14eac97982b41970402365dac4d3d72df1f26..c9149a2669854418870e7b8f6741f04375a18afc 100644 (file)
@@ -977,7 +977,7 @@ TEST(DeduplicateByFileTest, PathsWithDots) {
   std::map<std::string, Replacements> FileToReplaces;
   llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> VFS(
       new vfs::InMemoryFileSystem());
-  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
+  FileManager FileMgr(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
   StringRef Path1 = "a/b/.././c.h";
   StringRef Path2 = "a/c.h";
@@ -989,7 +989,7 @@ TEST(DeduplicateByFileTest, PathsWithDots) {
   EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
   FileToReplaces[Path1] = Replacements();
   FileToReplaces[Path2] = Replacements();
-  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
   EXPECT_EQ(Path1, FileToReplaces.begin()->first);
 }
@@ -998,7 +998,7 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) {
   std::map<std::string, Replacements> FileToReplaces;
   llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> VFS(
       new vfs::InMemoryFileSystem());
-  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
+  FileManager FileMgr(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
   StringRef Path1 = "./a/b/c.h";
   StringRef Path2 = "a/b/c.h";
@@ -1010,7 +1010,7 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) {
   EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
   FileToReplaces[Path1] = Replacements();
   FileToReplaces[Path2] = Replacements();
-  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
   EXPECT_EQ(Path1, FileToReplaces.begin()->first);
 }
@@ -1019,7 +1019,7 @@ TEST(DeduplicateByFileTest, NonExistingFilePath) {
   std::map<std::string, Replacements> FileToReplaces;
   llvm::IntrusiveRefCntPtr<vfs::InMemoryFileSystem> VFS(
       new vfs::InMemoryFileSystem());
-  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
+  FileManager FileMgr(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
   StringRef Path1 = "./a/b/c.h";
   StringRef Path2 = "a/b/c.h";
@@ -1029,7 +1029,7 @@ TEST(DeduplicateByFileTest, NonExistingFilePath) {
 #endif
   FileToReplaces[Path1] = Replacements();
   FileToReplaces[Path2] = Replacements();
-  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
   EXPECT_TRUE(FileToReplaces.empty());
 }