[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location
Alan Zhao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 30 15:01:12 PDT 2022
ayzhao updated this revision to Diff 419277.
ayzhao added a comment.
Remove errant diff
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122766/new/
https://reviews.llvm.org/D122766
Files:
clang/lib/AST/Expr.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/file_test_windows.c
Index: clang/test/Preprocessor/file_test_windows.c
===================================================================
--- clang/test/Preprocessor/file_test_windows.c
+++ clang/test/Preprocessor/file_test_windows.c
@@ -8,19 +8,19 @@
filename: __FILE__
#include "Inputs/include-file-test/file_test.h"
-// CHECK: filename: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
-// CHECK: filename: "A:\\UNLIKELY_PATH\\empty/Inputs/include-file-test/file_test.h"
-// CHECK: basefile: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
+// CHECK: filename: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
+// CHECK: filename: "A:/UNLIKELY_PATH/empty/Inputs/include-file-test/file_test.h"
+// CHECK: basefile: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
// CHECK-NOT: filename:
-// CHECK-EVIL: filename: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
-// CHECK-EVIL: filename: "A:\\UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
-// CHECK-EVIL: basefile: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
+// CHECK-EVIL: filename: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
+// CHECK-EVIL: filename: "A:/UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
+// CHECK-EVIL: basefile: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
// CHECK-EVIL-NOT: filename:
-// CHECK-CASE: filename: "A:\\UNLIKELY_PATH_BASE\\file_test_windows.c"
-// CHECK-CASE: filename: "A:\\UNLIKELY_PATH_INC\\include-file-test/file_test.h"
-// CHECK-CASE: basefile: "A:\\UNLIKELY_PATH_BASE\\file_test_windows.c"
+// CHECK-CASE: filename: "A:/UNLIKELY_PATH_BASE/file_test_windows.c"
+// CHECK-CASE: filename: "A:/UNLIKELY_PATH_INC/include-file-test/file_test.h"
+// CHECK-CASE: basefile: "A:/UNLIKELY_PATH_BASE/file_test_windows.c"
// CHECK-CASE-NOT: filename:
// CHECK-REMOVE: filename: "file_test_windows.c"
Index: clang/lib/Lex/PPMacroExpansion.cpp
===================================================================
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1512,6 +1512,10 @@
FN += PLoc.getFilename();
}
getLangOpts().remapPathPrefix(FN);
+ if (getTargetInfo().getTriple().isOSWindows()) {
+ llvm::sys::path::make_preferred(FN,
+ llvm::sys::path::Style::windows_slash);
+ }
Lexer::Stringify(FN);
OS << '"' << FN << '"';
}
Index: clang/lib/AST/Expr.cpp
===================================================================
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2191,6 +2191,10 @@
case SourceLocExpr::File: {
SmallString<256> Path(PLoc.getFilename());
Ctx.getLangOpts().remapPathPrefix(Path);
+ if (Ctx.getTargetInfo().getTriple().isOSWindows()) {
+ llvm::sys::path::make_preferred(Path,
+ llvm::sys::path::Style::windows_slash);
+ }
return MakeStringLiteral(Path);
}
case SourceLocExpr::Function: {
@@ -2224,6 +2228,10 @@
if (Name == "_M_file_name") {
SmallString<256> Path(PLoc.getFilename());
Ctx.getLangOpts().remapPathPrefix(Path);
+ if (Ctx.getTargetInfo().getTriple().isOSWindows()) {
+ llvm::sys::path::make_preferred(
+ Path, llvm::sys::path::Style::windows_slash);
+ }
Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(Path);
} else if (Name == "_M_function_name") {
// Note: this emits the PrettyFunction name -- different than what
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122766.419277.patch
Type: text/x-patch
Size: 3454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220330/301b73c6/attachment-0001.bin>
More information about the cfe-commits
mailing list