r246714 - Use new utility function to clean leading junk from pathnames. NFC

Douglas Katzman via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 2 14:14:53 PDT 2015


Author: dougk
Date: Wed Sep  2 16:14:53 2015
New Revision: 246714

URL: http://llvm.org/viewvc/llvm-project?rev=246714&view=rev
Log:
Use new utility function to clean leading junk from pathnames. NFC

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Frontend/DependencyFile.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=246714&r1=246713&r2=246714&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Sep  2 16:14:53 2015
@@ -264,6 +264,7 @@ void Clang::AddPreprocessingOptions(Comp
     const char *DepFile;
     if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
       DepFile = MF->getValue();
+      llvm::errs()<<"Your depfile is "<<DepFile<<"\n";
       C.addFailureResultFile(DepFile, &JA);
     } else if (Output.getType() == types::TY_Dependencies) {
       DepFile = Output.getFilename();

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=246714&r1=246713&r2=246714&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Wed Sep  2 16:14:53 2015
@@ -51,15 +51,8 @@ struct DepCollectorPPCallbacks : public
     if (!FE)
       return;
 
-    StringRef Filename = FE->getName();
-
-    // Remove leading "./" (or ".//" or "././" etc.)
-    while (Filename.size() > 2 && Filename[0] == '.' &&
-           llvm::sys::path::is_separator(Filename[1])) {
-      Filename = Filename.substr(1);
-      while (llvm::sys::path::is_separator(Filename[0]))
-        Filename = Filename.substr(1);
-    }
+    StringRef Filename =
+        llvm::sys::path::remove_leading_dotslash(FE->getName());
 
     DepCollector.maybeAddDependency(Filename, /*FromModule*/false,
                                    FileType != SrcMgr::C_User,
@@ -295,15 +288,7 @@ void DFGImpl::FileChanged(SourceLocation
   if (!FileMatchesDepCriteria(Filename.data(), FileType))
     return;
 
-  // Remove leading "./" (or ".//" or "././" etc.)
-  while (Filename.size() > 2 && Filename[0] == '.' &&
-         llvm::sys::path::is_separator(Filename[1])) {
-    Filename = Filename.substr(1);
-    while (llvm::sys::path::is_separator(Filename[0]))
-      Filename = Filename.substr(1);
-  }
-    
-  AddFilename(Filename);
+  AddFilename(llvm::sys::path::remove_leading_dotslash(Filename));
 }
 
 void DFGImpl::InclusionDirective(SourceLocation HashLoc,




More information about the cfe-commits mailing list