From 721800d4389c53bd624b2e262d2243f21412c844 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 21 Apr 2016 06:43:45 +0000 Subject: [PATCH] CachePruning: early exit if no path supplied From: Mehdi Amini llvm-svn: 266965 --- llvm/lib/Support/CachePruning.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Support/CachePruning.cpp b/llvm/lib/Support/CachePruning.cpp index fb11b0e..75da2e7 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)) { -- 2.7.4