Fix tests failure on 75993812d5c1f269b781c34987748f2a792a579d
authorZequan Wu <zequanwu@google.com>
Fri, 19 May 2023 17:34:29 +0000 (13:34 -0400)
committerZequan Wu <zequanwu@google.com>
Fri, 19 May 2023 17:34:40 +0000 (13:34 -0400)
It follows the rules:
1. Use native path if it's already absolute
2. Use Windows back-slash if it's windows formatting.
3. Use Posix style otherwise.

clang/lib/AST/TypePrinter.cpp

index 42bbbde..4444ded 100644 (file)
@@ -1392,9 +1392,11 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) {
         // clang::DirectoryLookup::LookupFile when the file path is relative
         // path.
         llvm::sys::path::Style Style =
-            !llvm::sys::path::is_absolute(WrittenFile) && Policy.MSVCFormatting
-                ? llvm::sys::path::Style::windows_backslash
-                : llvm::sys::path::Style::native;
+            llvm::sys::path::is_absolute(WrittenFile)
+                ? llvm::sys::path::Style::native
+                : (Policy.MSVCFormatting
+                       ? llvm::sys::path::Style::windows_backslash
+                       : llvm::sys::path::Style::posix);
         llvm::sys::path::native(WrittenFile, Style);
         OS << WrittenFile << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
       }