From 23430ccb042f11eda205c390d4c2a0d07d08b2e6 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 11 Aug 2014 21:29:24 +0000 Subject: unique_ptr-ify FileSystemStatCache::setNextStatCache And in the process, discover that FileManager::removeStatCache had a double-delete when removing an element from the middle of the list (at the beginning or the end of the list, there was no problem) and add a unit test to exercise the code path (which successfully crashed when run (with modifications to match the old API) without this patch applied) llvm-svn: 215388 --- clang/lib/Frontend/CacheTokens.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend') diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp index 14f7027e468..23f22ada7fc 100644 --- a/clang/lib/Frontend/CacheTokens.cpp +++ b/clang/lib/Frontend/CacheTokens.cpp @@ -572,8 +572,10 @@ void clang::CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS) { PTHWriter PW(*OS, PP); // Install the 'stat' system call listener in the FileManager. - StatListener *StatCache = new StatListener(PW.getPM()); - PP.getFileManager().addStatCache(StatCache, /*AtBeginning=*/true); + auto StatCacheOwner = llvm::make_unique(PW.getPM()); + StatListener *StatCache = StatCacheOwner.get(); + PP.getFileManager().addStatCache(std::move(StatCacheOwner), + /*AtBeginning=*/true); // Lex through the entire file. This will populate SourceManager with // all of the header information. -- cgit v1.2.3