[clang] 4ad17d2 - Clean "./" from __FILE__ expansion.

Alan Zhao via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 2 15:00:26 PDT 2022


Author: Paul Pluzhnikov
Date: 2022-06-02T18:00:19-04:00
New Revision: 4ad17d2e96a382e5f595bab30920ba26762a6fa9

URL: https://github.com/llvm/llvm-project/commit/4ad17d2e96a382e5f595bab30920ba26762a6fa9
DIFF: https://github.com/llvm/llvm-project/commit/4ad17d2e96a382e5f595bab30920ba26762a6fa9.diff

LOG: Clean "./" from __FILE__ expansion.

This is alternative to https://reviews.llvm.org/D121733
and helps with Clang header modules in which FILE
may expand to "./foo.h" or "foo.h" depending on whether the file was
included directly or not.

Only do this when UseTargetPathSeparator is true, as we are already
changing the path in that case.

Reviewed By: ayzhao

Differential Revision: https://reviews.llvm.org/D126396

Added: 
    

Modified: 
    clang/lib/Lex/PPMacroExpansion.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 9d1090be8e09..07ee07e20bb2 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1895,9 +1895,9 @@ void Preprocessor::processPathForFileMacro(SmallVectorImpl<char> &Path,
   LangOpts.remapPathPrefix(Path);
   if (LangOpts.UseTargetPathSeparator) {
     if (TI.getTriple().isOSWindows())
-      llvm::sys::path::make_preferred(
-          Path, llvm::sys::path::Style::windows_backslash);
+      llvm::sys::path::remove_dots(Path, false,
+                                   llvm::sys::path::Style::windows_backslash);
     else
-      llvm::sys::path::make_preferred(Path, llvm::sys::path::Style::posix);
+      llvm::sys::path::remove_dots(Path, false, llvm::sys::path::Style::posix);
   }
 }


        


More information about the cfe-commits mailing list