aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CacheTokens.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-11 21:29:24 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-11 21:29:24 +0000
commit23430ccb042f11eda205c390d4c2a0d07d08b2e6 (patch)
tree8753c0e6cd148fe8b0bd60064a55ff3d6da6893f /clang/lib/Frontend/CacheTokens.cpp
parentbe4b5171d3663eaee01823c33148de081ffe9e80 (diff)
downloadllvm-23430ccb042f11eda205c390d4c2a0d07d08b2e6.zip
llvm-23430ccb042f11eda205c390d4c2a0d07d08b2e6.tar.gz
llvm-23430ccb042f11eda205c390d4c2a0d07d08b2e6.tar.bz2
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
Diffstat (limited to 'clang/lib/Frontend/CacheTokens.cpp')
-rw-r--r--clang/lib/Frontend/CacheTokens.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp
index 14f7027..23f22ad 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<StatListener>(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.