summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CachePruning.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-21 06:43:45 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-21 06:43:45 +0000
commit721800d4389c53bd624b2e262d2243f21412c844 (patch)
treed4d09f43d261bc9479d2de6ad2f52eb08daea392 /llvm/lib/Support/CachePruning.cpp
parent9df9a9cd53c0a248e60ff65745495a6dec7cfcfe (diff)
downloadbcm5719-llvm-721800d4389c53bd624b2e262d2243f21412c844.tar.gz
bcm5719-llvm-721800d4389c53bd624b2e262d2243f21412c844.zip
CachePruning: early exit if no path supplied
From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266965
Diffstat (limited to 'llvm/lib/Support/CachePruning.cpp')
-rw-r--r--llvm/lib/Support/CachePruning.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Support/CachePruning.cpp b/llvm/lib/Support/CachePruning.cpp
index fb11b0e1299..75da2e70ec9 100644
--- a/llvm/lib/Support/CachePruning.cpp
+++ b/llvm/lib/Support/CachePruning.cpp
@@ -33,8 +33,15 @@ static void writeTimestampFile(StringRef TimestampFile) {
/// Prune the cache of files that haven't been accessed in a long time.
bool CachePruning::prune() {
- SmallString<128> TimestampFile(Path);
- sys::path::append(TimestampFile, "llvmcache.timestamp");
+ if (Path.empty())
+ return false;
+
+ bool isPathDir;
+ if (sys::fs::is_directory(Path, isPathDir))
+ return false;
+
+ if (!isPathDir)
+ return false;
if (Expiration == 0 && PercentageOfAvailableSpace == 0) {
DEBUG(dbgs() << "No pruning settings set, exit early\n");
@@ -43,6 +50,8 @@ bool CachePruning::prune() {
}
// Try to stat() the timestamp file.
+ SmallString<128> TimestampFile(Path);
+ sys::path::append(TimestampFile, "llvmcache.timestamp");
sys::fs::file_status FileStatus;
sys::TimeValue CurrentTime = sys::TimeValue::now();
if (sys::fs::status(TimestampFile, FileStatus)) {
OpenPOWER on IntegriCloud