From 256053b31e697fdf0cc48f17d621c82fc3b8dff0 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Fri, 17 Dec 2010 21:22:22 +0000 Subject: [PATCH] Replace all uses of PathV1::isAbsolute with PathV2::is_{absolute,relative}. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122087 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/FileManager.cpp | 9 +++++---- lib/Basic/FileSystemStatCache.cpp | 2 +- lib/Checker/HTMLDiagnostics.cpp | 2 +- lib/Driver/Driver.cpp | 10 ++++++---- lib/Frontend/CacheTokens.cpp | 5 ++--- lib/Frontend/InitHeaderSearch.cpp | 4 ++-- lib/Lex/HeaderSearch.cpp | 2 +- lib/Serialization/ASTReader.cpp | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 488d4c3b8d..921778d7d1 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -392,10 +392,11 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size, void FileManager::FixupRelativePath(llvm::sys::Path &path, const FileSystemOptions &FSOpts) { - if (FSOpts.WorkingDir.empty() || path.isAbsolute()) return; - - llvm::sys::Path NewPath(FSOpts.WorkingDir); - NewPath.appendComponent(path.str()); + if (FSOpts.WorkingDir.empty() || llvm::sys::path::is_absolute(path.str())) + return; + + llvm::SmallString<128> NewPath(FSOpts.WorkingDir); + llvm::sys::path::append(NewPath, path.str()); path = NewPath; } diff --git a/lib/Basic/FileSystemStatCache.cpp b/lib/Basic/FileSystemStatCache.cpp index d9e89cd8df..c8b07af295 100644 --- a/lib/Basic/FileSystemStatCache.cpp +++ b/lib/Basic/FileSystemStatCache.cpp @@ -113,7 +113,7 @@ MemorizeStatCalls::getStat(const char *Path, struct stat &StatBuf, return Result; // Cache file 'stat' results and directories with absolutely paths. - if (!S_ISDIR(StatBuf.st_mode) || llvm::sys::Path(Path).isAbsolute()) + if (!S_ISDIR(StatBuf.st_mode) || llvm::sys::path::is_absolute(Path)) StatCalls[Path] = StatBuf; return Result; diff --git a/lib/Checker/HTMLDiagnostics.cpp b/lib/Checker/HTMLDiagnostics.cpp index c6223695d8..b175fcaaeb 100644 --- a/lib/Checker/HTMLDiagnostics.cpp +++ b/lib/Checker/HTMLDiagnostics.cpp @@ -199,7 +199,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, std::string DirName = ""; - if (!llvm::sys::Path(Entry->getName()).isAbsolute()) { + if (llvm::sys::path::is_relative(Entry->getName())) { llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory(); DirName = P.str() + "/"; } diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 621ce8dd58..e021dcd43a 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -30,6 +30,7 @@ #include "llvm/ADT/OwningPtr.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" @@ -757,14 +758,15 @@ void Driver::BuildActions(const ToolChain &TC, const ArgList &Args, // Check that the file exists, if enabled. if (CheckInputsExist && memcmp(Value, "-", 2) != 0) { - llvm::sys::Path Path(Value); + llvm::SmallString<64> Path(Value); if (Arg *WorkDir = Args.getLastArg(options::OPT_working_directory)) - if (!Path.isAbsolute()) { + if (llvm::sys::path::is_absolute(Path.str())) { Path = WorkDir->getValue(Args); - Path.appendComponent(Value); + llvm::sys::path::append(Path, Value); } - if (!Path.exists()) + bool exists = false; + if (/*error_code ec =*/llvm::sys::fs::exists(Value, exists) || !exists) Diag(clang::diag::err_drv_no_such_file) << Path.str(); else Inputs.push_back(std::make_pair(Ty, A)); diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp index ee8c8aaa2c..cd5723aa82 100644 --- a/lib/Frontend/CacheTokens.cpp +++ b/lib/Frontend/CacheTokens.cpp @@ -475,8 +475,7 @@ void PTHWriter::GeneratePTH(const std::string &MainFile) { const FileEntry *FE = C.Entry; // FIXME: Handle files with non-absolute paths. - llvm::sys::Path P(FE->getName()); - if (!P.isAbsolute()) + if (llvm::sys::path::is_relative(FE->getName())) continue; const llvm::MemoryBuffer *B = C.getBuffer(PP.getDiagnostics(), SM); @@ -525,7 +524,7 @@ public: PM.insert(PTHEntryKeyVariant(Path), PTHEntry()); else if (S_ISDIR(StatBuf.st_mode)) { // Only cache directories with absolute paths. - if (!llvm::sys::Path(Path).isAbsolute()) + if (llvm::sys::path::is_relative(Path)) return Result; PM.insert(PTHEntryKeyVariant(&StatBuf, Path), PTHEntry()); diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp index 438556e8da..5bae3ea396 100644 --- a/lib/Frontend/InitHeaderSearch.cpp +++ b/lib/Frontend/InitHeaderSearch.cpp @@ -106,10 +106,10 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, // Compute the actual path, taking into consideration -isysroot. llvm::SmallString<256> MappedPathStorage; llvm::StringRef MappedPathStr = Path.toStringRef(MappedPathStorage); - llvm::sys::Path MappedPath(MappedPathStr); // Handle isysroot. - if (Group == System && !IgnoreSysRoot && MappedPath.isAbsolute() && + if (Group == System && !IgnoreSysRoot && + llvm::sys::path::is_absolute(MappedPathStr) && IncludeSysroot != llvm::sys::Path::GetRootDirectory()) { MappedPathStorage.clear(); MappedPathStr = diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 6b7409081b..d11e87f8a9 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -211,7 +211,7 @@ const FileEntry *HeaderSearch::LookupFile(llvm::StringRef Filename, const DirectoryLookup *&CurDir, const FileEntry *CurFileEnt) { // If 'Filename' is absolute, check to see if it exists and no searching. - if (llvm::sys::Path::isAbsolute(Filename.begin(), Filename.size())) { + if (llvm::sys::path::is_absolute(Filename)) { CurDir = 0; // If this was an #include_next "/absolute/file", fail. diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index a4ba496774..724ebdf96c 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1703,7 +1703,7 @@ void ASTReader::MaybeAddSystemRootToFilename(std::string &Filename) { if (!RelocatablePCH) return; - if (Filename.empty() || llvm::sys::Path(Filename).isAbsolute()) + if (Filename.empty() || llvm::sys::path::is_absolute(Filename)) return; if (isysroot == 0) { -- 2.40.0