[llvm] r266965 - CachePruning: early exit if no path supplied

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 23:43:46 PDT 2016


Author: mehdi_amini
Date: Thu Apr 21 01:43:45 2016
New Revision: 266965

URL: http://llvm.org/viewvc/llvm-project?rev=266965&view=rev
Log:
CachePruning: early exit if no path supplied

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/lib/Support/CachePruning.cpp

Modified: llvm/trunk/lib/Support/CachePruning.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CachePruning.cpp?rev=266965&r1=266964&r2=266965&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CachePruning.cpp (original)
+++ llvm/trunk/lib/Support/CachePruning.cpp Thu Apr 21 01:43:45 2016
@@ -33,8 +33,15 @@ static void writeTimestampFile(StringRef
 
 /// 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)) {




More information about the llvm-commits mailing list