]> granicus.if.org Git - clang/commitdiff
Replace all uses of PathV1::isAbsolute with PathV2::is_{absolute,relative}.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Fri, 17 Dec 2010 21:22:22 +0000 (21:22 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Fri, 17 Dec 2010 21:22:22 +0000 (21:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122087 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/FileManager.cpp
lib/Basic/FileSystemStatCache.cpp
lib/Checker/HTMLDiagnostics.cpp
lib/Driver/Driver.cpp
lib/Frontend/CacheTokens.cpp
lib/Frontend/InitHeaderSearch.cpp
lib/Lex/HeaderSearch.cpp
lib/Serialization/ASTReader.cpp

index 488d4c3b8dfeb489a4f8f928d70291907f8d3059..921778d7d1c74302c155de650be6b7a057a4c7b6 100644 (file)
@@ -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;
 }
 
index d9e89cd8dfd9a7fcd702bd790c1f5738ecad35ed..c8b07af295da4eb2a0ea8496abf9deebb3aa7724 100644 (file)
@@ -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;
index c6223695d84c4fd38d21c74efa5e93a4b12da072..b175fcaaeb8266e73dda08c8dc74f0014c22b5a7 100644 (file)
@@ -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() + "/";
   }
index 621ce8dd580a9d351c73a5fa33076fb38727c813..e021dcd43ae6853c95c017d7a4fb51b0f7f63842 100644 (file)
@@ -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));
index ee8c8aaa2c2adf6cc536430629e67e804da47c7f..cd5723aa82c24c899d77472e0dfcf31884b59227 100644 (file)
@@ -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());
index 438556e8da6708e08a31250a9d78d912e3ffb626..5bae3ea3967e464b59f9f5f20589f1101c917f0d 100644 (file)
@@ -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 =
index 6b7409081bed96fb04a3de4470e2033c29103067..d11e87f8a9a4d9c0dfcb54c04bf2fa4105fb44d2 100644 (file)
@@ -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.
index a4ba4967742a1e7e4159959c4d7b33ac01738eb7..724ebdf96cb664a8b3eb399333d76402d343ec91 100644 (file)
@@ -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) {