Clean "./" from __FILE__ expansion.
authorPaul Pluzhnikov <ppluzhnikov@google.com>
Thu, 2 Jun 2022 21:58:56 +0000 (17:58 -0400)
committerAlan Zhao <ayzhao@google.com>
Thu, 2 Jun 2022 22:00:19 +0000 (18:00 -0400)
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

clang/lib/Lex/PPMacroExpansion.cpp

index 9d1090b..07ee07e 100644 (file)
@@ -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);
   }
 }