summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CachePruning.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-03-20 16:41:57 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-03-20 16:41:57 +0000
commit25a17ba4c7cae20b301e01c6654c272fe38314b9 (patch)
tree5dd3af1e8aee5ca2f1c04b3be25ff320d90b2723 /llvm/lib/Support/CachePruning.cpp
parente593049fb057a014e912973e8717463e060c9d60 (diff)
downloadbcm5719-llvm-25a17ba4c7cae20b301e01c6654c272fe38314b9.tar.gz
bcm5719-llvm-25a17ba4c7cae20b301e01c6654c272fe38314b9.zip
Support, LTO: When pruning a directory, ignore files matching a prefix.
This is a safeguard against data loss if the user specifies a directory that is not a cache directory. Teach the existing cache pruning clients to create files with appropriate names. Differential Revision: https://reviews.llvm.org/D31109 llvm-svn: 298271
Diffstat (limited to 'llvm/lib/Support/CachePruning.cpp')
-rw-r--r--llvm/lib/Support/CachePruning.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/CachePruning.cpp b/llvm/lib/Support/CachePruning.cpp
index 5d81e10469b..aca12363956 100644
--- a/llvm/lib/Support/CachePruning.cpp
+++ b/llvm/lib/Support/CachePruning.cpp
@@ -180,8 +180,11 @@ bool llvm::pruneCache(StringRef Path, CachePruningPolicy Policy) {
// Walk all of the files within this directory.
for (sys::fs::directory_iterator File(CachePathNative, EC), FileEnd;
File != FileEnd && !EC; File.increment(EC)) {
- // Do not touch the timestamp.
- if (File->path() == TimestampFile)
+ // Ignore any files not beginning with the string "llvmcache-". This
+ // includes the timestamp file as well as any files created by the user.
+ // This acts as a safeguard against data loss if the user specifies the
+ // wrong directory as their cache directory.
+ if (!sys::path::filename(File->path()).startswith("llvmcache-"))
continue;
// Look at this file. If we can't stat it, there's nothing interesting
OpenPOWER on IntegriCloud