[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D150817#4356305 , @TWeaver wrote:

> Hello and good afternoon from the UK,
>
> I believe this patch has caused failures on the following buildbot:
>
> https://lab.llvm.org/buildbot/#/builders/216/builds/21493
>
> are you able to take a look?
>
> thanks,
> Tom W

Thanks for reporting. Hope this fix it: 
https://reviews.llvm.org/rGfe69bb64415ef6fe01ebbb1d1a801e85bd6bd879.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150817/new/

https://reviews.llvm.org/D150817

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-19 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

Hello and good afternoon from the UK,

I believe this patch has caused failures on the following buildbot:

https://lab.llvm.org/buildbot/#/builders/216/builds/21493

are you able to take a look?

thanks,
Tom W


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150817/new/

https://reviews.llvm.org/D150817

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-19 Thread Zequan Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG75993812d5c1: Use windows baskslash on anonymous tag 
locations if using MSVCFormatting and… (authored by zequanwu).

Changed prior to commit:
  https://reviews.llvm.org/D150817?vs=523171=523742#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150817/new/

https://reviews.llvm.org/D150817

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/CodeGen/Inputs/debug-info-slash.cpp
  clang/test/CodeGen/Inputs/debug-info-slash.h
  clang/test/CodeGen/debug-info-slash.test


Index: clang/test/CodeGen/debug-info-slash.test
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.test
@@ -0,0 +1,10 @@
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g  
%t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g  
%t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN:   lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h
Index: clang/test/CodeGen/Inputs/debug-info-slash.h
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.h
@@ -0,0 +1,6 @@
+template 
+void f1() {}
+void a() {
+  auto Lambda = [] {};
+  f1();
+}
Index: clang/test/CodeGen/Inputs/debug-info-slash.cpp
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.cpp
@@ -0,0 +1,2 @@
+#include "Inputs/debug-info-slash.h"
+int main() { a(); return 0; }
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1385,11 +1385,18 @@
   if (PLoc.isValid()) {
 OS << " at ";
 StringRef File = PLoc.getFilename();
+llvm::SmallString<1024> WrittenFile(File);
 if (auto *Callbacks = Policy.Callbacks)
-  OS << Callbacks->remapPath(File);
-else
-  OS << File;
-OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+  WrittenFile = Callbacks->remapPath(File);
+// Fix inconsistent path separator created by
+// 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::native(WrittenFile, Style);
+OS << WrittenFile << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }
 }
 


Index: clang/test/CodeGen/debug-info-slash.test
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.test
@@ -0,0 +1,10 @@
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g  %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g  %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN:   lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h
Index: clang/test/CodeGen/Inputs/debug-info-slash.h
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.h
@@ -0,0 +1,6 @@
+template 
+void f1() {}
+void a() {
+  auto Lambda = [] {};
+  f1();
+}
Index: clang/test/CodeGen/Inputs/debug-info-slash.cpp
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.cpp
@@ -0,0 +1,2 @@
+#include "Inputs/debug-info-slash.h"
+int main() { a(); return 0; }
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1385,11 +1385,18 @@
   if (PLoc.isValid()) {
 OS << " at ";
 StringRef File = PLoc.getFilename();
+llvm::SmallString<1024> WrittenFile(File);
 if (auto *Callbacks = Policy.Callbacks)
-  OS << Callbacks->remapPath(File);
-else
-  OS << File;
-OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+  WrittenFile = Callbacks->remapPath(File);
+// Fix 

[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-19 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

Nice! lgtm




Comment at: clang/lib/AST/TypePrinter.cpp:1391
+  WrittenFile = Callbacks->remapPath(File);
+// The following tries to fix inconsistent path separator created by
+// clang::DirectoryLookup::LookupFile when the file path is relative

nit: If you want you could drop the "The following tries to" part to make this 
more concise.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150817/new/

https://reviews.llvm.org/D150817

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150817/new/

https://reviews.llvm.org/D150817

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-17 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added a reviewer: hans.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a nondeterminism on debug info when building on windows natively vs
cross building to windows.

[1] 
https://github.com/llvm/llvm-project/blob/llvmorg-17-init/clang/lib/Lex/HeaderSearch.cpp#L465


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150817

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/CodeGen/Inputs/debug-info-slash.cpp
  clang/test/CodeGen/Inputs/debug-info-slash.h
  clang/test/CodeGen/debug-info-slash.test


Index: clang/test/CodeGen/debug-info-slash.test
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.test
@@ -0,0 +1,10 @@
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g  
%t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g  
%t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN:   lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h
Index: clang/test/CodeGen/Inputs/debug-info-slash.h
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.h
@@ -0,0 +1,6 @@
+template 
+void f1() {}
+void a() {
+  auto Lambda = [] {};
+  f1();
+}
Index: clang/test/CodeGen/Inputs/debug-info-slash.cpp
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.cpp
@@ -0,0 +1,2 @@
+#include "Inputs/debug-info-slash.h"
+int main() { a(); return 0; }
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1385,11 +1385,18 @@
   if (PLoc.isValid()) {
 OS << " at ";
 StringRef File = PLoc.getFilename();
+llvm::SmallString<1024> WrittenFile(File);
 if (auto *Callbacks = Policy.Callbacks)
-  OS << Callbacks->remapPath(File);
-else
-  OS << File;
-OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+  WrittenFile = Callbacks->remapPath(File);
+// The following tries to fix inconsistent path separator created by
+// 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::native(WrittenFile, Style);
+OS << WrittenFile << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }
 }
 


Index: clang/test/CodeGen/debug-info-slash.test
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.test
@@ -0,0 +1,10 @@
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g  %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g  %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN:   lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h
Index: clang/test/CodeGen/Inputs/debug-info-slash.h
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.h
@@ -0,0 +1,6 @@
+template 
+void f1() {}
+void a() {
+  auto Lambda = [] {};
+  f1();
+}
Index: clang/test/CodeGen/Inputs/debug-info-slash.cpp
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.cpp
@@ -0,0 +1,2 @@
+#include "Inputs/debug-info-slash.h"
+int main() { a(); return 0; }
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1385,11 +1385,18 @@
   if (PLoc.isValid()) {
 OS << " at ";
 StringRef File = PLoc.getFilename();
+llvm::SmallString<1024> WrittenFile(File);
 if (auto *Callbacks = Policy.Callbacks)
-  OS << Callbacks->remapPath(File);
-else
-  OS << File;
-OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+  WrittenFile = Callbacks->remapPath(File);