diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2019-10-16 19:12:34 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2019-10-16 19:12:34 +0000 |
commit | 5d56c7bcdfca9528235a5aabe0b7fc3f39d91c45 (patch) | |
tree | 523aaa40eed0276dcb824ef2f337c3d3d1cc1d3e | |
parent | 0c4d48f076a953410ab8a4baf46ad85ac0afe024 (diff) | |
download | clang-5d56c7bcdfca9528235a5aabe0b7fc3f39d91c45.tar.gz |
Replace platform-dependent `stat` with `llvm::sys::fs::status`. NFC intended.
Reviewers: bruno, sammccall
Reviewed By: sammccall
Subscribers: jkorous, dexonsmith, arphaman, ributzka, cfe-commits
Differential Revision: https://reviews.llvm.org/D69011
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375031 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 15 | ||||
-rw-r--r-- | tools/libclang/CIndexCodeCompletion.cpp | 4 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 97b9266741..a01224f6e0 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -50,8 +50,6 @@ #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" -#include <sys/stat.h> -#include <system_error> #include <time.h> #include <utility> @@ -1389,16 +1387,16 @@ static void writeTimestampFile(StringRef TimestampFile) { /// Prune the module cache of modules that haven't been accessed in /// a long time. static void pruneModuleCache(const HeaderSearchOptions &HSOpts) { - struct stat StatBuf; + llvm::sys::fs::file_status StatBuf; llvm::SmallString<128> TimestampFile; TimestampFile = HSOpts.ModuleCachePath; assert(!TimestampFile.empty()); llvm::sys::path::append(TimestampFile, "modules.timestamp"); // Try to stat() the timestamp file. - if (::stat(TimestampFile.c_str(), &StatBuf)) { + if (std::error_code EC = llvm::sys::fs::status(TimestampFile, StatBuf)) { // If the timestamp file wasn't there, create one now. - if (errno == ENOENT) { + if (EC == std::errc::no_such_file_or_directory) { writeTimestampFile(TimestampFile); } return; @@ -1406,7 +1404,8 @@ static void pruneModuleCache(const HeaderSearchOptions &HSOpts) { // Check whether the time stamp is older than our pruning interval. // If not, do nothing. - time_t TimeStampModTime = StatBuf.st_mtime; + time_t TimeStampModTime = + llvm::sys::toTimeT(StatBuf.getLastModificationTime()); time_t CurrentTime = time(nullptr); if (CurrentTime - TimeStampModTime <= time_t(HSOpts.ModuleCachePruneInterval)) return; @@ -1438,11 +1437,11 @@ static void pruneModuleCache(const HeaderSearchOptions &HSOpts) { // Look at this file. If we can't stat it, there's nothing interesting // there. - if (::stat(File->path().c_str(), &StatBuf)) + if (llvm::sys::fs::status(File->path(), StatBuf)) continue; // If the file has been used recently enough, leave it there. - time_t FileAccessTime = StatBuf.st_atime; + time_t FileAccessTime = llvm::sys::toTimeT(StatBuf.getLastAccessedTime()); if (CurrentTime - FileAccessTime <= time_t(HSOpts.ModuleCachePruneAfter)) { continue; diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp index 1588812802..1311f66ce0 100644 --- a/tools/libclang/CIndexCodeCompletion.cpp +++ b/tools/libclang/CIndexCodeCompletion.cpp @@ -803,8 +803,8 @@ clang_codeCompleteAt_Impl(CXTranslationUnit TU, const char *complete_filename, os << arg << ".pth"; } pchName.push_back('\0'); - struct stat stat_results; - if (stat(pchName.str().c_str(), &stat_results) == 0) + llvm::sys::fs::file_status stat_results; + if (!llvm::sys::fs::status(pchName, stat_results)) usesPCH = true; continue; } |