[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-06-01 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2129cc1b3a14: [clang][Darwin] Error out when missing 
requested libarclite library (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c
  clang/test/Driver/arclite-link.c


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck 
-check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE 
%s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK-ARCLITE-OSX: try increasing the minimum deployment target
 // CHECK-ARCLITE-OSX: -lfoo
 // CHECK-ARCLITE-OSX: libarclite_macosx.a
 // CHECK-ARCLITE-OSX: -framework
Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK: try increasing the minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1221,6 +1221,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB 

[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-31 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 527261.
keith added a comment.

Improve error message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c
  clang/test/Driver/arclite-link.c


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck 
-check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE 
%s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK-ARCLITE-OSX: try increasing the minimum deployment target
 // CHECK-ARCLITE-OSX: -lfoo
 // CHECK-ARCLITE-OSX: libarclite_macosx.a
 // CHECK-ARCLITE-OSX: -framework
Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK: try increasing the minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK-ARCLITE-OSX: try incre

[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-19 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 523899.
keith added a comment.

Improve test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c


Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a'.
+// CHECK: This likely means you need to increase your minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you 
need to increase your minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a'.
+// CHECK: This likely means you need to increase your minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you need to increase your minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-19 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
Herald added a project: All.
keith requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Starting with the SDKs provided with Xcode 14.3, this library no longer
exists. Before this change this results in an opaque linker error in the
case that your deployment target is low enough that this library is
added. This produces a more useful error message in that case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c


Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,7 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path
+// CHECK: This likely means you need to increase your minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you 
need to increase your minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,7 @@
 // RUN:   -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path
+// CHECK: This likely means you need to increase your minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you need to increase your minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147561: [clang] don't serialize MODULE_DIRECTORY with ModuleFileHomeIsCwd

2023-04-04 Thread Keith Smiley via Phabricator via cfe-commits
keith accepted this revision.
keith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Modules/module-file-home-is-cwd.m:7-8
 // RUN: -o %t/mod.pcm
 // RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t/mod.pcm | FileCheck %s 
--check-prefix=INPUT
 

Instead of doing 2 invocations you can do `--check-prefixes=CHECK,INPUT`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147561

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


[PATCH] D126598: Fixed typo in hmaptool CMakeLists.txt

2022-05-28 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50f2e4992456: [clang][cmake] Fixed typo in hmaptool 
CMakeLists.txt (authored by danielh2942, committed by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126598

Files:
  clang/utils/hmaptool/CMakeLists.txt


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@
COMMAND "${CMAKE_COMMAND}" -E copy 
"${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}}" COMPONENT 
hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT 
hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}}" COMPONENT hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124767: [Clang] Map .gcda paths according to -fcoverage-prefix-map

2022-05-02 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

I took this comment from the issue:

> Since the feature you're proposing is specific to gcov, using a separate flag 
> that matches the name used by GCC would be preferable to me.

To mean that we should introduce a new flag matching gcc's name. I think in 
general fewer flags would be preferred though, so I think it depends on if it 
would ever make sense to have separate values for these in the same build?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124767

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


[PATCH] D124767: [Clang] Map .gcda paths according to -fcoverage-prefix-map

2022-05-02 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Based on the issue it sounds like this should be gated behind a new 
`-fprofile-prefix-map` flag? I assume we'd also want `-ffile-prefix-map` to 
apply to it as well, similar to the others. And we'll definitely want some 
tests here!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124767

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-03-23 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfcca10c69aaa: [AArch64] Add support for -march=native for 
Apple M1 CPU (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp

Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -41,6 +41,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #endif
 #ifdef _AIX
 #include 
@@ -1297,32 +1299,45 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
-return "generic";
+  switch (Family) {
+  case CPUFAMILY_ARM_SWIFT:
+return "swift";
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:
+return "apple-a8";
+  case CPUFAMILY_ARM_TWISTER:
+return "apple-a9";
+  case CPUFAMILY_ARM_HURRICANE:
+return "apple-a10";
+  case CPUFAMILY_ARM_MONSOON_MISTRAL:
+return "apple-a11";
+  case CPUFAMILY_ARM_VORTEX_TEMPEST:
+return "apple-a12";
+  case CPUFAMILY_ARM_LIGHTNING_THUNDER:
+return "apple-a13";
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:
+// Default to the newest CPU we know about.
+return "apple-m1";
   }
-  switch (hostInfo.cpu_subtype) {
-case CPU_SUBTYPE_ARM_V7S:
-  return "swift";
-default:;
-}
-
-  return "generic";
 }
 #elif defined(_AIX)
 StringRef sys::getHostCPUName() {
@@ -1453,9 +1468,6 @@
 #elif defined(__linux__) && defined(__s390x__)
 int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
 #elif defined(__APPLE__)
-#include 
-#include 
-
 // Gets the number of *physical cores* on the machine.
 int computeHostNumPhysicalCores() {
   uint32_t count;
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
keith abandoned this revision.
keith added a comment.

There were 2 competing revisions for this bug fix, I landed 
https://reviews.llvm.org/D121663 instead since it sounds like having an empty 
`directory` is more correct in this case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D121663: reland: [clang] Don't append the working directory to absolute paths

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2db7d5e9c52: reland: [clang] Don't append the working 
directory to absolute paths (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121663

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang -g 
-ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", 
directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: 
"./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g -fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s -emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

You're right it's version 5 not 4, maybe the issue is that some platforms (like 
macOS) are defaulting to 4 intentionally for now? I guess I thought 6 because 
passing 6 also reproduces, but I didn't also try 5.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/test/Modules/module-debuginfo-prefix.m:24
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|.:}}OVERRIDE{{/|}}DebugObjC.h", 
directory: "")

probinson wrote:
> Does this want to be 
> `"%{fs-src-root}OVERRIDE%{fs-sep}DebugObjC.h"` ?
That can only be used in the RUN invocations, but unfortunately regardless it 
could be used here because of the escaped backslashes, so it requires a regex 
like this instead 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-15 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

I actually mean dwarf 6, which appears to be partially implemented according to 
https://lists.llvm.org/pipermail/llvm-dev/2020-April/141055.html

I discovered the issue from the failed tests on 
https://reviews.llvm.org/D113718 where you can see the test output contains a 
checksum that otherwise doesn't appear. Passing `-dwarf-version=6` reproduces 
the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D121663: reland: [clang] Don't append the working directory to absolute paths

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added a reviewer: aprantl.
Herald added a project: All.
keith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a bug that happens when using -fdebug-prefix-map to remap an
absolute path to a relative path. Since the path was absolute before
remapping, it is safe to assume that concatenating the remapped working
directory would be wrong.

This was originally submitted as https://reviews.llvm.org/D113718, but
reverted because when testing with dwarf 6 enabled, the tests were too
strict.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121663

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang -g 
-ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", 
directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: 
"./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -6,6 +6,9 @@
 // RUN: %clang -g -fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang -g -ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s -emit-llvm -o - | FileCheck %s
 
+// RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+// RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
+
 #include "Inputs/stdio.h"
 
 int main(int argc, char **argv) {
@@ -40,3 +43,7 @@
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs{{/|}}stdio.h", directory: "{{/|.:}}UNLIKELY_PATH{{/|}}empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:
 // CHECK-SYSROOT: !DICompileUnit({{.*}}sysroot: "{{/|.:}}UNLIKELY_PATH{{/|}}empty"
+
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-REL-SAME:directory: ""
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,7 +444,8 @@
   File = FileBuf;
 }
   } else {
-Dir = CurDir;
+if (!llvm::sys::path::is_absolute(FileName))
+  Dir = CurDir;
 File = RemappedFile;
   }
   llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 415307.
keith added a comment.

Fix tests with dwarf 6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,7 +4,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -21,6 +21,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|.:}}OVERRIDE{{/|}}DebugObjC.h", 
directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. 
%t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. 
relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir"
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: 
"."
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,9 @@
   Dir = DirBuf;
   File = FileBuf;
 }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+Dir = llvm::sys::path::parent_path(RemappedFile);
+File = llvm::sys::path::filename(RemappedFile);
   } else {
 Dir = CurDir;
 File = RemappedFile;


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,7 +4,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -21,6 +21,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|.:}}OVERRIDE{{/|}}DebugObjC.h", directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. %t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s -emit-l

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb22d71806b7: [clang] Fix DIFile directory root on Windows 
(authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - -main-file-name debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - -fdebug-compilation-dir %p | FileCheck %s -check-prefix 
CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - -isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix 
CHECK-SYSROOT
+// RUN: %clang -g 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang -g 
-ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
 #include "Inputs/stdio.h"
 
@@ -19,26 +19,24 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-SAME:directory: ""
 // CHECK-NOT: !DIFile(filename:
 
-// CHECK-COMPILATION-DIR: !DIFile(filename: "

[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Bump, I think I've covered everything here, let me know if not!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

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


[PATCH] D111457: [test] Add lit helper for windows paths

2022-03-14 Thread Keith Smiley 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 rG6541d3e979c1: [test] Add lit helper for windows paths 
(authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1121,6 +1122,12 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+substitutions.extend([
+('%{fs-src-root}', pathlib.Path(sourcedir).anchor),
+('%{fs-tmp-root}', pathlib.Path(tmpBase).anchor),
+('%{fs-sep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fs-src-root}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fs-tmp-root}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fs-sep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fs-src-root}  root component of file system paths pointing to the 
LLVM checkout
+ %{fs-tmp-root}  root component of file system paths pointing to the 
test's temporary directory
+ %{fs-sep}   file system path separator
  %t  temporary file name unique to the test
  %basename_t The last path component of %t but without the 
``.tmp`` extension
  %T  parent directory of %t (not unique, deprecated, do 
not use)


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1121,6 +1122,12 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+substitutions.extend([
+('%{fs-src-root}', pathlib.Path(sourcedir).anchor),
+('%{fs-tmp-root}', pathlib.Path(tmpBase).anchor),
+('%{fs-sep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fs-src-root}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fs-tmp-root}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fs-sep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fs-src-root}  root component of file system paths pointing to the LLVM checkout
+ %{fs-tmp-root}  root component of file system paths pointing to t

[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 415292.
keith added a comment.
Herald added a project: All.

Update subsitutions with slashes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,7 +4,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -21,6 +21,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|.:}}OVERRIDE{{/|}}DebugObjC.h", 
directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. 
%t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. 
relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir")
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: 
".")
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,9 @@
   Dir = DirBuf;
   File = FileBuf;
 }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+Dir = llvm::sys::path::parent_path(RemappedFile);
+File = llvm::sys::path::filename(RemappedFile);
   } else {
 Dir = CurDir;
 File = RemappedFile;


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,7 +4,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fs-sep}Inputs=%{fs-src-root}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -21,6 +21,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|.:}}OVERRIDE{{/|}}DebugObjC.h", directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. %t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=stan

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 415291.
keith marked an inline comment as done.
keith added a comment.

Update subsitutions with dashes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - -main-file-name debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - -fdebug-compilation-dir %p | FileCheck %s -check-prefix 
CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty %s -emit-llvm 
-o - -isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix 
CHECK-SYSROOT
+// RUN: %clang -g 
-fdebug-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang -g 
-ffile-prefix-map=%p=%{fs-src-root}UNLIKELY_PATH%{fs-sep}empty -S -c %s 
-emit-llvm -o - | FileCheck %s
 
 #include "Inputs/stdio.h"
 
@@ -19,26 +19,24 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-SAME:directory: ""
 // CHECK-NOT: !DIFile(filename:
 
-// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: 
"/UNLIKELY_P

[PATCH] D111457: [test] Add lit helper for windows paths

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 415290.
keith added a comment.

Update substitutions to use dashes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1121,6 +1122,12 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+substitutions.extend([
+('%{fs-src-root}', pathlib.Path(sourcedir).anchor),
+('%{fs-tmp-root}', pathlib.Path(tmpBase).anchor),
+('%{fs-sep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fs-src-root}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fs-tmp-root}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fs-sep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fs-src-root}  root component of file system paths pointing to the 
LLVM checkout
+ %{fs-tmp-root}  root component of file system paths pointing to the 
test's temporary directory
+ %{fs-sep}   file system path separator
  %t  temporary file name unique to the test
  %basename_t The last path component of %t but without the 
``.tmp`` extension
  %T  parent directory of %t (not unique, deprecated, do 
not use)


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1121,6 +1122,12 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+substitutions.extend([
+('%{fs-src-root}', pathlib.Path(sourcedir).anchor),
+('%{fs-tmp-root}', pathlib.Path(tmpBase).anchor),
+('%{fs-sep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fs-src-root}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fs-tmp-root}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fs-sep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fs-src-root}  root component of file system paths pointing to the LLVM checkout
+ %{fs-tmp-root}  root component of file system paths pointing to the test's temporary directory
+ %{fs-sep}   file system path separator
  %t  temporary fi

[PATCH] D100692: clang-tidy: discover binaries in build dir

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5da83eeb91ba: clang-tidy: discover binaries in build dir 
(authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100692

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- run-clang-tidy.py - Parallel clang-tidy runner *- python -*--===#
 #
@@ -41,6 +41,7 @@
 import json
 import multiprocessing
 import os
+import queue
 import re
 import shutil
 import subprocess
@@ -54,13 +55,6 @@
 except ImportError:
   yaml = None
 
-is_py2 = sys.version[0] == '2'
-
-if is_py2:
-import Queue as queue
-else:
-import queue as queue
-
 
 def strtobool(val):
   """Convert a string representation of truth to a bool following LLVM's CLI argument parsing."""
@@ -158,20 +152,29 @@
 open(mergefile, 'w').close()
 
 
-def check_clang_apply_replacements_binary(args):
-  """Checks if invoking supplied clang-apply-replacements binary works."""
-  try:
-subprocess.check_call([args.clang_apply_replacements_binary, '--version'])
-  except:
-print('Unable to run clang-apply-replacements. Is clang-apply-replacements '
-  'binary correctly specified?', file=sys.stderr)
-traceback.print_exc()
-sys.exit(1)
+def find_binary(arg, name, build_path):
+  """Get the path for a binary or exit"""
+  if arg:
+if shutil.which(arg):
+  return arg
+else:
+  raise SystemExit(
+"error: passed binary '{}' was not found or is not executable"
+.format(arg))
+
+  built_path = os.path.join(build_path, "bin", name)
+  binary = shutil.which(name) or shutil.which(built_path)
+  if binary:
+return binary
+  else:
+raise SystemExit(
+  "error: failed to find {} in $PATH or at {}"
+  .format(name, built_path))
 
 
-def apply_fixes(args, tmpdir):
+def apply_fixes(args, clang_apply_replacements_binary, tmpdir):
   """Calls clang-apply-fixes on a given directory."""
-  invocation = [args.clang_apply_replacements_binary]
+  invocation = [clang_apply_replacements_binary]
   if args.format:
 invocation.append('-format')
   if args.style:
@@ -180,11 +183,12 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
+def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock,
+ failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
-invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
+invocation = get_tidy_invocation(name, clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
@@ -210,15 +214,13 @@
   parser = argparse.ArgumentParser(description='Runs clang-tidy over all files '
'in a compilation database. Requires '
'clang-tidy and clang-apply-replacements in '
-   '$PATH.')
+   '$PATH or in your build directory.')
   parser.add_argument('-allow-enabling-alpha-checkers',
   action='store_true', help='allow alpha checkers from '
 'clang-analyzer.')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
-  default='clang-tidy',
   help='path to clang-tidy binary')
   parser.add_argument('-clang-apply-replacements-binary', metavar='PATH',
-  default='clang-apply-replacements',
   help='path to clang-apply-replacements binary')
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
@@ -278,8 +280,18 @@
 # Find our database
 build_path = find_compilation_database(db_path)
 
+  clang_tidy_binary = find_binary(args.clang_tidy_binary, "clang-tidy",
+  build_path)
+
+  tmpdir = None
+  if args.fix or (yaml and args.export_fixes):
+clang_apply_replacements_binary = find_binary(
+  args.clang_apply_replacements_binary, "clang-apply-replacements",
+  build_path)
+tmpdir = tempfile.mkdtemp()
+
   try:
-invocation = get_tidy_invocation("", args.clang_tidy_binary, args.checks,
+invocation = get_tidy_invocation("", clang_tidy_binary, args.checks,
  None, build_path, a

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-03-14 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Ping, all green here, I just had to mess with the test regex a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

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


[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-03-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 415004.
keith added a comment.

Replace \w with .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
| FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-main-file-name debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
+// RUN: %clang -g -fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty 
-S -c %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang -g -ffile-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty 
-S -c %s -emit-llvm -o - | FileCheck %s
 
 #include "Inputs/stdio.h"
 
@@ -19,26 +19,24 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK: !DIFile(filename: 
"{{/|.:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-SAME:directory: ""
 // CHECK-NOT: !DIFile(filename:
 
-// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: 
"/UNLIKELY_PATH/empty")
-// CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}Inputs/stdio.h

[PATCH] D111457: [test] Add lit helper for windows paths

2022-03-13 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.
Herald added a project: All.

@compnerd can you re-review here? I think I covered your feedback, let me know!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-03-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 414976.
keith added a comment.
Herald added a project: All.

Remove variables from test expectations

This didn't work out because of the double vs single slash of the expansions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
| FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-main-file-name debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
+// RUN: %clang -g -fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty 
-S -c %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang -g -ffile-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty 
-S -c %s -emit-llvm -o - | FileCheck %s
 
 #include "Inputs/stdio.h"
 
@@ -19,26 +19,24 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH{{/|}}empty{{/|}}",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK: !DIFile(filename: 
"{{/|\w:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-SAME:directory: ""
 // CHECK-NOT: !DIFile(filename:
 
-// CHECK-COMPILATION

[PATCH] D100692: clang-tidy: discover binaries in build dir

2022-03-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 414975.
keith added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100692

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 #===- run-clang-tidy.py - Parallel clang-tidy runner *- python -*--===#
 #
@@ -41,6 +41,7 @@
 import json
 import multiprocessing
 import os
+import queue
 import re
 import shutil
 import subprocess
@@ -54,13 +55,6 @@
 except ImportError:
   yaml = None
 
-is_py2 = sys.version[0] == '2'
-
-if is_py2:
-import Queue as queue
-else:
-import queue as queue
-
 
 def strtobool(val):
   """Convert a string representation of truth to a bool following LLVM's CLI argument parsing."""
@@ -158,20 +152,29 @@
 open(mergefile, 'w').close()
 
 
-def check_clang_apply_replacements_binary(args):
-  """Checks if invoking supplied clang-apply-replacements binary works."""
-  try:
-subprocess.check_call([args.clang_apply_replacements_binary, '--version'])
-  except:
-print('Unable to run clang-apply-replacements. Is clang-apply-replacements '
-  'binary correctly specified?', file=sys.stderr)
-traceback.print_exc()
-sys.exit(1)
+def find_binary(arg, name, build_path):
+  """Get the path for a binary or exit"""
+  if arg:
+if shutil.which(arg):
+  return arg
+else:
+  raise SystemExit(
+"error: passed binary '{}' was not found or is not executable"
+.format(arg))
 
+  built_path = os.path.join(build_path, "bin", name)
+  binary = shutil.which(name) or shutil.which(built_path)
+  if binary:
+return binary
+  else:
+raise SystemExit(
+  "error: failed to find {} in $PATH or at {}"
+  .format(name, built_path))
 
-def apply_fixes(args, tmpdir):
+
+def apply_fixes(args, clang_apply_replacements_binary, tmpdir):
   """Calls clang-apply-fixes on a given directory."""
-  invocation = [args.clang_apply_replacements_binary]
+  invocation = [clang_apply_replacements_binary]
   if args.format:
 invocation.append('-format')
   if args.style:
@@ -180,11 +183,12 @@
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
+def run_tidy(args, clang_tidy_binary, tmpdir, build_path, queue, lock,
+ failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
-invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
+invocation = get_tidy_invocation(name, clang_tidy_binary, args.checks,
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
@@ -210,15 +214,13 @@
   parser = argparse.ArgumentParser(description='Runs clang-tidy over all files '
'in a compilation database. Requires '
'clang-tidy and clang-apply-replacements in '
-   '$PATH.')
+   '$PATH or in your build directory.')
   parser.add_argument('-allow-enabling-alpha-checkers',
   action='store_true', help='allow alpha checkers from '
 'clang-analyzer.')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
-  default='clang-tidy',
   help='path to clang-tidy binary')
   parser.add_argument('-clang-apply-replacements-binary', metavar='PATH',
-  default='clang-apply-replacements',
   help='path to clang-apply-replacements binary')
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
@@ -278,8 +280,18 @@
 # Find our database
 build_path = find_compilation_database(db_path)
 
+  clang_tidy_binary = find_binary(args.clang_tidy_binary, "clang-tidy",
+  build_path)
+
+  tmpdir = None
+  if args.fix or (yaml and args.export_fixes):
+clang_apply_replacements_binary = find_binary(
+  args.clang_apply_replacements_binary, "clang-apply-replacements",
+  build_path)
+tmpdir = tempfile.mkdtemp()
+
   try:
-invocation = get_tidy_invocation("", args.clang_tidy_binary, args.checks,
+invocation = get_tidy_invocation("", clang_tidy_binary, args.checks,
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
   

[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-03-12 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 414878.
keith added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp

Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -38,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #endif
 #ifdef _AIX
 #include 
@@ -1294,32 +1296,45 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
-return "generic";
+  switch (Family) {
+  case CPUFAMILY_ARM_SWIFT:
+return "swift";
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:
+return "apple-a8";
+  case CPUFAMILY_ARM_TWISTER:
+return "apple-a9";
+  case CPUFAMILY_ARM_HURRICANE:
+return "apple-a10";
+  case CPUFAMILY_ARM_MONSOON_MISTRAL:
+return "apple-a11";
+  case CPUFAMILY_ARM_VORTEX_TEMPEST:
+return "apple-a12";
+  case CPUFAMILY_ARM_LIGHTNING_THUNDER:
+return "apple-a13";
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:
+// Default to the newest CPU we know about.
+return "apple-m1";
   }
-  switch (hostInfo.cpu_subtype) {
-case CPU_SUBTYPE_ARM_V7S:
-  return "swift";
-default:;
-}
-
-  return "generic";
 }
 #elif defined(_AIX)
 StringRef sys::getHostCPUName() {
@@ -1450,9 +1465,6 @@
 #elif defined(__linux__) && defined(__s390x__)
 int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
 #elif defined(__APPLE__)
-#include 
-#include 
-
 // Gets the number of *physical cores* on the machine.
 int computeHostNumPhysicalCores() {
   uint32_t count;
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-03-12 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 414866.
keith added a comment.
Herald added a project: All.

Update default to latest known CPU


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp

Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -38,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #endif
 #ifdef _AIX
 #include 
@@ -1294,32 +1296,45 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
-return "generic";
+  switch (Family) {
+  case CPUFAMILY_ARM_SWIFT:
+return "swift";
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:
+return "apple-a8";
+  case CPUFAMILY_ARM_TWISTER:
+return "apple-a9";
+  case CPUFAMILY_ARM_HURRICANE:
+return "apple-a10";
+  case CPUFAMILY_ARM_MONSOON_MISTRAL:
+return "apple-a11";
+  case CPUFAMILY_ARM_VORTEX_TEMPEST:
+return "apple-a12";
+  case CPUFAMILY_ARM_LIGHTNING_THUNDER:
+return "apple-a13";
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:
+// Default to the knewest CPU we know about.
+return "apple-m1";
   }
-  switch (hostInfo.cpu_subtype) {
-case CPU_SUBTYPE_ARM_V7S:
-  return "swift";
-default:;
-}
-
-  return "generic";
 }
 #elif defined(_AIX)
 StringRef sys::getHostCPUName() {
@@ -1450,9 +1465,6 @@
 #elif defined(__linux__) && defined(__s390x__)
 int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
 #elif defined(__APPLE__)
-#include 
-#include 
-
 // Gets the number of *physical cores* on the machine.
 int computeHostNumPhysicalCores() {
   uint32_t count;
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100692: clang-tidy: discover binaries in build dir

2022-03-12 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.
Herald added subscribers: cfe-commits, carlosgalvezp.
Herald added a project: All.

Ping, it seems like https://reviews.llvm.org/D101037 is stalled but the docs at 
this point state py >=3.6 is required for working on llvm so I think we're good 
here https://llvm.org/docs/GettingStarted.html#software


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100692

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


[PATCH] D111457: [test] Add lit helper for windows paths

2022-02-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

For reference here's an example of a test that uses this 
https://reviews.llvm.org/D111579


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D111457: [test] Add lit helper for windows paths

2022-02-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/utils/lit/lit/TestRunner.py:1124
+if kIsWindows:
+fs_root = 'C:\\'
+substitutions.extend([

probinson wrote:
> rnk wrote:
> > It is pretty common to run the LLVM test suite on secondary drives, 
> > especially on buildbot VMs, to separate build disk usage from the root 
> > partition. Can we have two separators, `${srcroot}` and `${tmproot}` that 
> > expand to the drive letter of the source and temp path base? That seems 
> > like it would be general and implementable.
> +1.  I don't even do builds on C: drive, on one of my machines.
Updated, I kept the `fs` prefixing thinking that `srcroot` and `tmproot` might 
be too confusable as an alternative to `%t` and friends, let me know what you 
think!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-02-28 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411926.
keith added a comment.

Fix parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,23 +4,21 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
-// RUN: cat %t-mod.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
-// RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 #ifdef MODULES
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "[[ROOT]]OVERRIDE[[SEP]]DebugObjC.h", directory: 
"")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. 
%t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. 
relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir")
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: 
".")
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,9 @@
   Dir = DirBuf;
   File = FileBuf;
 }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+Dir = llvm::sys::path::parent_path(RemappedFile);
+File = llvm::sys::path::filename(RemappedFile);
   } else {
 Dir = CurDir;
 File = RemappedFile;


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,23 +4,21 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
-// RUN: cat %t-mod.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
-// RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 #ifdef MODULES
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "[[ROOT]]OVERRIDE[[SEP]]DebugObjC.h", directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,1

[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-02-28 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411923.
keith added a comment.

Update test with new variable names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,23 +4,21 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
-// RUN: cat %t-mod.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
-// RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 #ifdef MODULES
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "[[ROOT]]OVERRIDE[[SEP]]DebugObjC.h", directory: 
"")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. 
%t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. 
relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir")
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: 
".")
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,9 @@
   Dir = DirBuf;
   File = FileBuf;
 }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+Dir = llvm::sys::path::parent_path(RemappedFile);
+File = llvm::sys::path::filename(RemappedFile);
   } else {
 Dir = CurDir;
 File = RemappedFile;


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,23 +4,21 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
-// RUN: cat %t-mod.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fssrcroot}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
-// RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 #ifdef MODULES
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "[[ROOT]]OVERRIDE[[SEP]]DebugObjC.h", directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-02-28 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411922.
keith added a comment.

Update tests with new syntax and FileCheck variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
| FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME -DROOT=%{fssrcroot} 
-DSEP=%{fssep}
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL -DROOT=%{fssrcroot} -DSEP=%{fssep}
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-main-file-name debug-prefix-map.c | FileCheck %s -DROOT=%{fssrcroot} 
-DSEP=%{fssep}
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR 
-DROOT=%{fssrcroot} -DSEP=%{fssep}
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT 
-DROOT=%{fssrcroot} -DSEP=%{fssep}
+// RUN: %clang -g -fdebug-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty 
-S -c %s -emit-llvm -o - | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
+// RUN: %clang -g -ffile-prefix-map=%p=%{fssrcroot}UNLIKELY_PATH%{fssep}empty 
-S -c %s -emit-llvm -o - | FileCheck %s -DROOT=%{fssrcroot} -DSEP=%{fssep}
 
 #include "Inputs/stdio.h"
 
@@ -19,26 +19,24 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"[[ROOT]]UNLIKELY_PATH[[SEP]]empty[[SEP]]",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"[[ROOT]]UNLIKELY_PATH[[SEP]]empty[[SEP]]{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"[[ROOT]]UNLIKELY_PATH[[SEP]]empty[[SEP]]Inputs[[SEP]]stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: "[[ROOT]]UNLIKELY_PATH=empty[[SEP]]{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"[[ROOT]]UNLIKELY_PATH=empty[[SEP]]{{.*}}Inputs[[SEP]]stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "[[ROOT]]UNLIKELY_PATH[[SEP]]empty[[SEP]]{{.*}}",
+// CHECK: !DIFile(filename: 
"[[ROOT]]UNLIKELY_PATH[[SEP]]empty[[SEP]]{{.*}}Inputs[[SEP]]stdio.h",
+// CHECK-SAME: 

[PATCH] D111457: [test] Add lit helper for windows paths

2022-02-28 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411921.
keith marked 3 inline comments as done.
keith edited the summary of this revision.
keith added a comment.

Use the actual drive on windows, split out into fssrcroot and fstmproot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1119,6 +1120,12 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+substitutions.extend([
+('%{fssrcroot}', pathlib.Path(sourcedir).anchor),
+('%{fstmproot}', pathlib.Path(tmpBase).anchor),
+('%{fssep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fssrcroot}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fstmproot}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fssep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fssrcroot}root component of file system paths pointing to the 
LLVM checkout
+ %{fstmproot}root component of file system paths pointing to the 
test's temporary directory
+ %{fssep}file system path separator
  %t  temporary file name unique to the test
  %basename_t The last path component of %t but without the 
``.tmp`` extension
  %T  parent directory of %t (not unique, deprecated, do 
not use)


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -6,6 +6,7 @@
 import os, signal, subprocess, sys
 import re
 import stat
+import pathlib
 import platform
 import shutil
 import tempfile
@@ -1119,6 +1120,12 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+substitutions.extend([
+('%{fssrcroot}', pathlib.Path(sourcedir).anchor),
+('%{fstmproot}', pathlib.Path(tmpBase).anchor),
+('%{fssep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,18 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fssrcroot}``
+   Expands to the root component of file system paths for the source directory,
+   i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on Windows.
+
+``${fstmproot}``
+   Expands to the root component of file system paths for the test's temporary
+   directory, i.e. ``/`` on Unix systems or ``C:\`` (or another drive) on
+   Windows.
+
+``${fssep}``
+   Expands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,9 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fssrcroot}root component of file system paths pointing to the LLVM checkout
+ %{fstmproot}root component of file system paths pointing to the test's temporary d

[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2022-02-25 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411576.
keith added a comment.

Update test with new specifiers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,7 +4,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fsroot}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fsroot}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -21,6 +21,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|C:}}OVERRIDE{{/|}}DebugObjC.h", 
directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. 
%t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. 
relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir")
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: 
".")
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -443,6 +443,9 @@
   Dir = DirBuf;
   File = FileBuf;
 }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+Dir = llvm::sys::path::parent_path(RemappedFile);
+File = llvm::sys::path::filename(RemappedFile);
   } else {
 Dir = CurDir;
 File = RemappedFile;


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -4,7 +4,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fsroot}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -12,7 +12,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{fssep}Inputs=%{fsroot}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -21,6 +21,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|C:}}OVERRIDE{{/|}}DebugObjC.h", directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. %t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s -emit-llvm -o - | Fi

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2022-02-25 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411575.
keith marked 3 inline comments as done.
keith added a comment.

Add more test path changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fsroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fsroot}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fsroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-main-file-name debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fsroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{fsroot}UNLIKELY_PATH%{fssep}empty %s -emit-llvm -o - 
-isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
+// RUN: %clang -g -fdebug-prefix-map=%p=%{fsroot}UNLIKELY_PATH%{fssep}empty -S 
-c %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang -g -ffile-prefix-map=%p=%{fsroot}UNLIKELY_PATH%{fssep}empty -S 
-c %s -emit-llvm -o - | FileCheck %s
 
 #include "Inputs/stdio.h"
 
@@ -19,23 +19,21 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}"
+// CHECK: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-SAME:directory: ""
 // CHECK-NOT: !DIFile(filename:
 
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: 
"/UNLIKELY_PATH/empty")
Index: clang/lib/CodeGen/CGDebugInfo.cpp

[PATCH] D111457: [clang][test] Add lit helper for windows paths

2022-02-25 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 411573.
keith added a comment.
Herald added subscribers: llvm-commits, delcypher.
Herald added a project: LLVM.

Move config to llvm lit config, add docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

Files:
  llvm/docs/CommandGuide/lit.rst
  llvm/docs/TestingGuide.rst
  llvm/utils/lit/lit/TestRunner.py


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -1119,6 +1119,14 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+fs_root = os.path.sep
+if kIsWindows:
+fs_root = 'C:\\'
+substitutions.extend([
+('%{fsroot}', fs_root),
+('%{fssep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,13 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fsroot}``
+   Expands to the root component of file system paths, i.e. ``/`` on Unix
+   systems or ``C:\`` on Windows.
+
+``${fssep}``
+   Exp``ands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,8 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fsroot}   root component of file system paths
+ %{fssep}file system path separator
  %t  temporary file name unique to the test
  %basename_t The last path component of %t but without the 
``.tmp`` extension
  %T  parent directory of %t (not unique, deprecated, do 
not use)


Index: llvm/utils/lit/lit/TestRunner.py
===
--- llvm/utils/lit/lit/TestRunner.py
+++ llvm/utils/lit/lit/TestRunner.py
@@ -1119,6 +1119,14 @@
   ('%basename_t', baseName),
   ('%T', tmpDir)])
 
+fs_root = os.path.sep
+if kIsWindows:
+fs_root = 'C:\\'
+substitutions.extend([
+('%{fsroot}', fs_root),
+('%{fssep}', os.path.sep),
+])
+
 # "%/[STpst]" should be normalized.
 substitutions.extend([
 ('%/s', sourcepath.replace('\\', '/')),
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -569,6 +569,13 @@
 
Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
 
+``${fsroot}``
+   Expands to the root component of file system paths, i.e. ``/`` on Unix
+   systems or ``C:\`` on Windows.
+
+``${fssep}``
+   Exp``ands to the file system separator, i.e. ``/`` or ``\`` on Windows.
+
 ``%/s, %/S, %/t, %/T:``
 
   Act like the corresponding substitution above but replace any ``\``
Index: llvm/docs/CommandGuide/lit.rst
===
--- llvm/docs/CommandGuide/lit.rst
+++ llvm/docs/CommandGuide/lit.rst
@@ -523,6 +523,8 @@
  %S  source dir (directory of the file currently being run)
  %p  same as %S
  %{pathsep}  path separator
+ %{fsroot}   root component of file system paths
+ %{fssep}file system path separator
  %t  temporary file name unique to the test
  %basename_t The last path component of %t but without the ``.tmp`` extension
  %T  parent directory of %t (not unique, deprecated, do not use)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2022-02-18 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D102669#3325467 , @steakhal wrote:

> Hi @keith, I've seen you commented on a clang driver-related issue: "Why does 
> march=native not work on Apple M1?" 
> 
> You might also have some valuable insight about this weird behavior about the 
> detected target triple in a regular mode and using the `-cc1` mode.
> You don't need to go through the whole conversation, the last few comments 
> should be enough.
> Feel free to invite more people if you think.

I'm not very familiar with the logic or history here, but I did look into this 
a bit, and I don't see a clear solution. I think the logic that lives in the 
Darwin driver code for creating the triple would have to be called from the 
default triple logic that's used in the cc1 case. I imagine to make this test 
pass you'd be best off making sure you always call clang or cc1, and not 
intermix them, or provide a default triple in all cases that's stable if 
possible. I do think it would be nice to unify the triple logic between these 2 
places, but I imagine folks who know this code better than I do have opinions 
there.


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

https://reviews.llvm.org/D102669

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-18 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/lib/Support/Host.cpp:1326
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:

jrtc27 wrote:
> ARM only calls it cyclone, AArch64 allows both but apple-a7 is the canonical 
> name (the comment above the cyclone alias states it's for old bitcode 
> compatibility)
I saw this comment:

```
// Support cyclone as an alias for apple-a7 so we can still LTO old bitcode.
def : ProcessorModel<"cyclone", CycloneModel, ProcessorFeatures.AppleA7,
 [TuneAppleA7]>;
```

And thought that implied that the `a7` name would be preferred to the "old" 
name for this case of case, wdyt?



Comment at: llvm/lib/Support/Host.cpp:1340
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:

ab wrote:
> jrtc27 wrote:
> > Maybe a question for AArch64 maintainers about whether apple-a14 or 
> > apple-m1 should be used... they're the same thing from the backend's 
> > perspective just with different names. Shame the naming doesn't separate 
> > out the "generation" from the specific configuration like you see for other 
> > backends (apple-aN is almost that as it omits all the bionic etc marketing 
> > name fluff, except apple-m1 comes along and ruins that).
> Seems fine to stick to the `apple-aNN` names here.  (we already have a 
> similar situation with `apple-sN`)
I felt like the `m1` name would be preferred here even though they're aliases 
just because I assume since this is for host CPUs you're more likely to hit 
this on an m1 machine than something that has an a14, which might lead to some 
user confusion. For example if you run `clang -march=native -###` with this 
change, you see `apple-m1` in the invocation, I would personally be surprised 
if I saw a14 there on my mac, even if they're the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-18 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 410040.
keith marked 2 inline comments as done.
keith added a comment.

Code review improvements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp

Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -43,6 +43,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #endif
 #ifdef _AIX
 #include 
@@ -1299,32 +1301,44 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
+  switch (Family) {
+  case CPUFAMILY_ARM_SWIFT:
+return "swift";
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:
+return "apple-a8";
+  case CPUFAMILY_ARM_TWISTER:
+return "apple-a9";
+  case CPUFAMILY_ARM_HURRICANE:
+return "apple-a10";
+  case CPUFAMILY_ARM_MONSOON_MISTRAL:
+return "apple-a11";
+  case CPUFAMILY_ARM_VORTEX_TEMPEST:
+return "apple-a12";
+  case CPUFAMILY_ARM_LIGHTNING_THUNDER:
+return "apple-a13";
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:
 return "generic";
   }
-  switch (hostInfo.cpu_subtype) {
-case CPU_SUBTYPE_ARM_V7S:
-  return "swift";
-default:;
-}
-
-  return "generic";
 }
 #elif defined(_AIX)
 StringRef sys::getHostCPUName() {
@@ -1455,9 +1469,6 @@
 #elif defined(__linux__) && defined(__s390x__)
 int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
 #elif defined(__APPLE__)
-#include 
-#include 
-
 // Gets the number of *physical cores* on the machine.
 int computeHostNumPhysicalCores() {
   uint32_t count;
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-17 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Thanks for the tips! I left the default as generic here, but I totally take 
your point on defaulting to the newest and I'm happy to update if you feel 
strongly, lmk what you think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-17 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 409849.
keith added a comment.

Update to read CPU from sysctl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp


Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1299,32 +1299,48 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#include 
+#include 
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
+
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  int Error = sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
+  assert(!Error && "Fetching hw.cpufamily failed");
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
+  switch (Family) {
+  case CPUFAMILY_ARM_SWIFT:
+return "swift";
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:
+return "apple-a8";
+  case CPUFAMILY_ARM_TWISTER:
+return "apple-a9";
+  case CPUFAMILY_ARM_HURRICANE:
+return "apple-a10";
+  case CPUFAMILY_ARM_MONSOON_MISTRAL:
+return "apple-a11";
+  case CPUFAMILY_ARM_VORTEX_TEMPEST:
+return "apple-a12";
+  case CPUFAMILY_ARM_LIGHTNING_THUNDER:
+return "apple-a13";
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:
 return "generic";
   }
-  switch (hostInfo.cpu_subtype) {
-case CPU_SUBTYPE_ARM_V7S:
-  return "swift";
-default:;
-}
-
-  return "generic";
 }
 #elif defined(_AIX)
 StringRef sys::getHostCPUName() {
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = 
llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;


Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1299,32 +1299,48 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#include 
+#include 
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
+
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  int Error = sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
+  assert(!Error && "Fetching hw.cpufamily failed");
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM"

[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-14 Thread Keith Smiley via Phabricator via cfe-commits
keith added reviewers: beanz, efriedma.
keith added a comment.

Adding folks from https://reviews.llvm.org/D69597


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-14 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
Herald added subscribers: dexonsmith, pengfei, hiraditya, kristof.beyls.
keith requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This improves the getHostCPUName check for Apple M1 
 CPUs, which
previously would always be considered cyclone instead. This also enables
`-march=native` support when building on M1  CPUs 
which would previously
fail. This isn't as sophisticated as the X86 CPU feature checking which
consults the CPU via getHostCPUFeatures, but this is still better than
before. This CPU selection could also be invalid if this was run on an
iOS device instead, ideally we can improve those cases as they come up.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp


Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1299,11 +1299,7 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
 StringRef sys::getHostCPUName() {
   host_basic_info_data_t hostInfo;
   mach_msg_type_number_t infoCount;
@@ -1314,15 +1310,23 @@
 &infoCount);
   mach_port_deallocate(mach_task_self(), hostPort);
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
-return "generic";
-  }
-  switch (hostInfo.cpu_subtype) {
+  if (hostInfo.cpu_type == CPU_TYPE_ARM) {
+switch (hostInfo.cpu_subtype) {
 case CPU_SUBTYPE_ARM_V7S:
   return "swift";
-default:;
+default:
+  break;
 }
+  } else if (hostInfo.cpu_type == CPU_TYPE_ARM64) {
+switch (hostInfo.cpu_subtype) {
+case CPU_SUBTYPE_ARM64E:
+  return "apple-m1";
+default:
+  return "cyclone";
+}
+  } else {
+assert(false && "CPUType not equal to ARM/ARM64 should not be possible");
+  }
 
   return "generic";
 }
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = 
llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;


Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1299,11 +1299,7 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
 StringRef sys::getHostCPUName() {
   host_basic_info_data_t hostInfo;
   mach_msg_type_number_t infoCount;
@@ -1314,15 +1310,23 @@
 &infoCount);
   mach_port_deallocate(mach_task_self(), hostPort);
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
-return "generic";
-  }
-  switch (hostInfo.cpu_subtype) {
+  if (hostInfo.cpu_type == CPU_TYPE_ARM) {
+switch (hostInfo.cpu_subtype) {
 case CPU_SUBTYPE_ARM_V7S:
   return "swift";
-default:;
+default:
+  break;
 }
+  } else if (hostInfo.cpu_type == CPU_TYPE_ARM64) {
+switch (hostInfo.cpu_subtype) {
+case CPU_SUBTYPE_ARM64E:
+  return "apple-m1";
+default:
+  return "cyclone";
+}
+  } else {
+assert(false && "CPUType not equal to ARM/ARM64 should not be possible");
+  }
 
   return "generic";
 }
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKin

[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-02-03 Thread Keith Smiley 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 rG502f14d6f2ee: [VFS] Add a "redirecting-with" field 
to overlays (authored by bnbarham, committed by keith).

Changed prior to commit:
  https://reviews.llvm.org/D117937?vs=404999&id=405758#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

Files:
  clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
  clang/test/VFS/Inputs/unknown-redirect.yaml
  clang/test/VFS/fallback.c
  clang/test/VFS/parse-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1910,7 +1910,25 @@
   Lower);
   EXPECT_EQ(nullptr, FS.get());
 
-  EXPECT_EQ(26, NumDiagnostics);
+  // invalid redirect kind
+  FS = getFromYAMLString("{ 'redirecting-with': 'none', 'roots': [{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/A',\n"
+ "  'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // redirect and fallthrough passed
+  FS = getFromYAMLString("{ 'redirecting-with': 'fallthrough',\n"
+ "  'fallthrough': true,\n"
+ "  'roots': [{\n"
+ "'type': 'directory-remap',\n"
+ "'name': '//root/A',\n"
+ "'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  EXPECT_EQ(28, NumDiagnostics);
 }
 
 TEST_F(VFSFromYAMLTest, UseExternalName) {
@@ -2710,6 +2728,121 @@
   EXPECT_FALSE(FS->exists(_c.path("c")));
 }
 
+TEST_F(VFSFromYAMLTest, RedirectingWith) {
+  IntrusiveRefCntPtr Both(new DummyFileSystem());
+  Both->addDirectory("//root/a");
+  Both->addRegularFile("//root/a/f");
+  Both->addDirectory("//root/b");
+  Both->addRegularFile("//root/b/f");
+
+  IntrusiveRefCntPtr AOnly(new DummyFileSystem());
+  AOnly->addDirectory("//root/a");
+  AOnly->addRegularFile("//root/a/f");
+
+  IntrusiveRefCntPtr BOnly(new DummyFileSystem());
+  BOnly->addDirectory("//root/b");
+  BOnly->addRegularFile("//root/b/f");
+
+  auto BaseStr = std::string("  'roots': [\n"
+ "{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/a',\n"
+ "  'external-contents': '//root/b'\n"
+ "}\n"
+ "  ]\n"
+ "}");
+  auto FallthroughStr = "{ 'redirecting-with': 'fallthrough',\n" + BaseStr;
+  auto FallbackStr = "{ 'redirecting-with': 'fallback',\n" + BaseStr;
+  auto RedirectOnlyStr = "{ 'redirecting-with': 'redirect-only',\n" + BaseStr;
+
+  auto ExpectPath = [&](vfs::FileSystem &FS, StringRef Expected,
+StringRef Message) {
+auto AF = FS.openFileForRead("//root/a/f");
+ASSERT_FALSE(AF.getError()) << Message;
+auto AFName = (*AF)->getName();
+ASSERT_FALSE(AFName.getError()) << Message;
+EXPECT_EQ(Expected.str(), AFName.get()) << Message;
+
+auto AS = FS.status("//root/a/f");
+ASSERT_FALSE(AS.getError()) << Message;
+EXPECT_EQ(Expected.str(), AS->getName()) << Message;
+  };
+
+  auto ExpectFailure = [&](vfs::FileSystem &FS, StringRef Message) {
+EXPECT_TRUE(FS.openFileForRead("//root/a/f").getError()) << Message;
+EXPECT_TRUE(FS.status("//root/a/f").getError()) << Message;
+  };
+
+  {
+// `f` in both `a` and `b`
+
+// `fallthrough` tries `external-name` first, so should be `b`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(FallthroughStr, Both);
+ASSERT_TRUE(Fallthrough.get() != nullptr);
+ExpectPath(*Fallthrough, "//root/b/f", "fallthrough, both exist");
+
+// `fallback` tries the original name first, so should be `a`
+IntrusiveRefCntPtr Fallback =
+getFromYAMLString(FallbackStr, Both);
+ASSERT_TRUE(Fallback.get() != nullptr);
+ExpectPath(*Fallback, "//root/a/f", "fallback, both exist");
+
+// `redirect-only` is the same as `fallthrough` but doesn't try the
+// original on failure, so no change here (ie. `b`)
+IntrusiveRefCntPtr Redirect =
+getFromYAMLString(RedirectOnlyStr, Both);
+ASSERT_TRUE(Redirect.get() != nullptr);
+ExpectPath(*Redirect, "//root/b/f", "redirect-only, both exist");
+  }
+
+  {
+// `f` in `a` only
+
+// Fallthrough to the original path, `a`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(

[PATCH] D111457: [clang][test] Add lit helper for windows paths

2022-01-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/test/lit.cfg.py:60
+if platform.system() == 'Windows':
+root_sep = 'C:\\'
+else:

compnerd wrote:
> This isn't really a separator, this is the root itself.  I think that it 
> makes sense to name it accordingly.  Please do not hard code this to `C:\`.  
> There is no guarantee that the root is `C:\`.
Yea I didn't like the original naming here either, any suggestions? I avoid 
`path` in these because of the existing `pathsep`, maybe `fsroot` and `fssep`?

What are you suggesting in place of hardcoding `C:\`? I don't think we could 
detect what folks are using in the tests, so it does seem like it would be up 
for individual tests to do this however it makes sense. It appears that there 
are a few hundred uses of this in tests today, does that break in general if 
you're using another drive?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:575
+///   instead>
+///   'redirecting-with': 

bnbarham wrote:
> keith wrote:
> > I think `redirecting-with` is fine, and I can't come up with something 
> > better
> Thanks. Do you know if this format is documented anywhere that I would need 
> to update?
Folks here used to joke that the source was the documentation, and based on a 
quick search that still seems to be the case, I don't see any places where the 
others are mentioned


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-01-28 Thread Keith Smiley via Phabricator via cfe-commits
keith accepted this revision.
keith added a comment.
This revision is now accepted and ready to land.

I'm definitely not a VFS expert, but I do think this is much nicer than trying 
to do the other workarounds with multiple VFSs that you described, I left some 
minor comments, I reviewed carefully but this logic was and is quite dense so 
I'm heavily relying on the test coverage.




Comment at: llvm/include/llvm/Support/VirtualFileSystem.h:575
+///   instead>
+///   'redirecting-with': 

I think `redirecting-with` is fine, and I can't come up with something better



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1341
+Iters.push_back(ExternalIter);
+  } else {
+Iters.push_back(ExternalIter);

I know we can only get here if the redirection != redirectOnly, but I think it 
might be more readable if we had an explicit else if here with fallthrough, and 
then added an else with an unreachable to make it clear, and make sure if we 
ever move stuff around we revisit this ordering



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1455-1456
+  return RedirectingFileSystem::RedirectKind::RedirectOnly;
+}
+return None;
+  }

Should this case error because the set value was invalid / a typo? Maybe this 
bubbles up actually?



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1870
+}
+  } else if (Key == "redirecting-with") {
+if (auto Kind = parseRedirectKind(I.getValue())) {

Should we error in the case that both this key and `fallthrough` are present? 
Maybe that's too strict for backwards compat, but right now I guess 
`fallthrough` could overwrite this value depending on order?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

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


[PATCH] D117730: [DNM][VFS] Do not overwrite the path when nesting RedirectingFileSystems

2022-01-24 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D117730#3262622 , @dexonsmith 
wrote:

> @keith, any thoughts on this? IIRC, you'd found a few other bugs while you 
> were in there which you'd left for later; not sure if this is related to them 
> or not.

This issue wasn't one of the ones on my radar, but in general this change seems 
safe to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117730

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


[PATCH] D116174: [clang] support relative roots to vfs overlays

2021-12-22 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

This LGTM but I'm interested to hear from folks with more knowledge about the 
VFS' desired behavior to comment on if this will have any unexpected side 
effects


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116174

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


[PATCH] D114974: [clang][Darwin] Remove old lld implementation handling

2021-12-02 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGace03d0df4fa: [clang][Darwin] Remove old lld implementation 
handling (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114974

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/darwin-ld-demangle-lld.c
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c

Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
Index: clang/test/Driver/darwin-ld-platform-version-macos.c
===
--- clang/test/Driver/darwin-ld-platform-version-macos.c
+++ clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
Index: clang/test/Driver/darwin-ld-platform-version-ios.c
===
--- clang/test/Driver/darwin-ld-platform-version-ios.c
+++ clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
Index: clang/test/Driver/darwin-ld-demangle-lld.c
===
--- clang/test/Driver/darwin-ld-demangle-lld.c
+++ clang/test/Driver/darwin-ld-demangle-lld.c
@@ -1,11 +1,6 @@
 // With -fuse-ld=lld, -demangle is always passed to the linker on Darwin.
 // REQUIRES: shell
 
-// FIXME: Remove this test case when we remove the lld.darwinold backend.
-// RUN: %clang --target=x86_64-apple-darwin -### \
-// RUN:   -fuse-ld=lld.darwinold -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
-// RUN:   | FileCheck %s
-
 // RUN: %clang --target=x86_64-apple-darwin -### \
 // RUN:   -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
 // RUN:   | FileCheck %s
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -64,7 +64,7 @@
   void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const InputInfoList &Inputs, unsigned Version[5],
-   bool LinkerIsLLD, bool LinkerIsLLDDarwinNew) const;
+   bool LinkerIsLLD) const;
 
 public:
   Linker(const ToolChain &TC) : MachOTool("darwin::Linker", "linker", TC) {}
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -209,8 +209,7 @@
 void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Arg

[PATCH] D114974: [clang][Darwin] Remove old lld implementation handling

2021-12-02 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added reviewers: int3, MaskRay, oontvoo, thakis.
keith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This now assumes that for the darwin driver any lld is the "new" macho
lld implementation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114974

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/darwin-ld-demangle-lld.c
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c

Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
Index: clang/test/Driver/darwin-ld-platform-version-macos.c
===
--- clang/test/Driver/darwin-ld-platform-version-macos.c
+++ clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld \
 // RUN:   -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
 // RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
Index: clang/test/Driver/darwin-ld-platform-version-ios.c
===
--- clang/test/Driver/darwin-ld-platform-version-ios.c
+++ clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,9 +1,5 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinold \
-// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
-// RUN:   -### %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
 // RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
 // RUN:   -### %t.o 2>&1 \
Index: clang/test/Driver/darwin-ld-demangle-lld.c
===
--- clang/test/Driver/darwin-ld-demangle-lld.c
+++ clang/test/Driver/darwin-ld-demangle-lld.c
@@ -1,11 +1,6 @@
 // With -fuse-ld=lld, -demangle is always passed to the linker on Darwin.
 // REQUIRES: shell
 
-// FIXME: Remove this test case when we remove the lld.darwinold backend.
-// RUN: %clang --target=x86_64-apple-darwin -### \
-// RUN:   -fuse-ld=lld.darwinold -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
-// RUN:   | FileCheck %s
-
 // RUN: %clang --target=x86_64-apple-darwin -### \
 // RUN:   -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
 // RUN:   | FileCheck %s
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -64,7 +64,7 @@
   void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const InputInfoList &Inputs, unsigned Version[5],
-   bool LinkerIsLLD, bool LinkerIsLLDDarwinNew) const;
+   bool LinkerIsLLD) const;
 
 public:
   Linker(const ToolChain &TC) : MachOTool("darwin::Linker", "linker", TC) {}
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -209,8 +209,7 @@
 void darwin::Linker::AddLinkA

[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-12-02 Thread Keith Smiley 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 rG9e3552523ebd: [lld-macho] Remove old macho darwin lld 
(authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

Files:
  lld/CMakeLists.txt
  lld/include/lld/Common/Driver.h
  lld/include/lld/Core/Reference.h
  lld/include/lld/ReaderWriter/MachOLinkingContext.h
  lld/include/lld/ReaderWriter/YamlContext.h
  lld/lib/CMakeLists.txt
  lld/lib/Core/CMakeLists.txt
  lld/lib/Core/DefinedAtom.cpp
  lld/lib/Core/Error.cpp
  lld/lib/Core/File.cpp
  lld/lib/Core/LinkingContext.cpp
  lld/lib/Core/Reader.cpp
  lld/lib/Core/Resolver.cpp
  lld/lib/Core/SymbolTable.cpp
  lld/lib/Core/Writer.cpp
  lld/lib/Driver/CMakeLists.txt
  lld/lib/Driver/DarwinLdDriver.cpp
  lld/lib/Driver/DarwinLdOptions.td
  lld/lib/ReaderWriter/CMakeLists.txt
  lld/lib/ReaderWriter/FileArchive.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.h
  lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  lld/lib/ReaderWriter/MachO/Atoms.h
  lld/lib/ReaderWriter/MachO/CMakeLists.txt
  lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
  lld/lib/ReaderWriter/MachO/DebugInfo.h
  lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
  lld/lib/ReaderWriter/MachO/File.h
  lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
  lld/lib/ReaderWriter/MachO/GOTPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.h
  lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
  lld/lib/ReaderWriter/MachO/MachOPasses.h
  lld/lib/ReaderWriter/MachO/ObjCPass.cpp
  lld/lib/ReaderWriter/MachO/SectCreateFile.h
  lld/lib/ReaderWriter/MachO/ShimPass.cpp
  lld/lib/ReaderWriter/MachO/StubsPass.cpp
  lld/lib/ReaderWriter/MachO/TLVPass.cpp
  lld/lib/ReaderWriter/MachO/WriterMachO.cpp
  lld/lib/ReaderWriter/YAML/CMakeLists.txt
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lld/test/CMakeLists.txt
  lld/test/darwin/Inputs/native-and-mach-o.objtxt
  lld/test/darwin/Inputs/native-and-mach-o2.objtxt
  lld/test/darwin/cmdline-lto_library.objtxt
  lld/test/darwin/cmdline-objc_gc.objtxt
  lld/test/darwin/cmdline-objc_gc_compaction.objtxt
  lld/test/darwin/cmdline-objc_gc_only.objtxt
  lld/test/darwin/native-and-mach-o.objtxt
  lld/test/mach-o/Inputs/DependencyDump.py
  lld/test/mach-o/Inputs/MacOSX.sdk/usr/lib/libSystem.tbd
  lld/test/mach-o/Inputs/PIE.yaml
  lld/test/mach-o/Inputs/arm-interworking.yaml
  lld/test/mach-o/Inputs/arm-shims.yaml
  lld/test/mach-o/Inputs/arm64/libSystem.yaml
  lld/test/mach-o/Inputs/armv7/libSystem.yaml
  lld/test/mach-o/Inputs/bar.yaml
  lld/test/mach-o/Inputs/cstring-sections.yaml
  lld/test/mach-o/Inputs/exported_symbols_list.exp
  lld/test/mach-o/Inputs/full.filelist
  lld/test/mach-o/Inputs/got-order.yaml
  lld/test/mach-o/Inputs/got-order2.yaml
  lld/test/mach-o/Inputs/hello-world-arm64.yaml
  lld/test/mach-o/Inputs/hello-world-armv6.yaml
  lld/test/mach-o/Inputs/hello-world-armv7.yaml
  lld/test/mach-o/Inputs/hello-world-x86.yaml
  lld/test/mach-o/Inputs/hello-world-x86_64.yaml
  lld/test/mach-o/Inputs/hw.raw_bytes
  lld/test/mach-o/Inputs/interposing-section.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-2.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-3.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64.yaml
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmyshared.dylib
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmystatic.a
  lld/test/mach-o/Inputs/lib-search-paths/usr/local/lib/file.o
  lld/test/mach-o/Inputs/libbar.a
  lld/test/mach-o/Inputs/libfoo.a
  lld/test/mach-o/Inputs/no-version-min-load-command-object.yaml
  lld/test/mach-o/Inputs/order_file-basic.order
  lld/test/mach-o/Inputs/partial.filelist
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal2.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal3.yaml
  lld/test/mach-o/Inputs/swift-version-1.yaml
  lld/test/mach-o/Inputs/unwind-info-simple-arm64.yaml
  lld/test/mach-o/Inputs/use-dylib-install-names.yaml
  lld/test/mach-o/Inputs/use-simple-dylib.yaml
  lld/test/mach-o/Inputs/write-final-sections.yaml
  lld/test/mach-o/Inputs/wrong-arch-error.yaml
  lld/test/mach-o/Inputs/x86/libSystem.yaml
  lld/test/mach-o/Inputs/x86_64/libSystem.yaml
  lld/test/mach-

[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-12-01 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 391065.
keith marked an inline comment as done.
keith added a comment.

Remove lld/lib directory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

Files:
  lld/CMakeLists.txt
  lld/include/lld/Common/Driver.h
  lld/include/lld/Core/Reference.h
  lld/include/lld/ReaderWriter/MachOLinkingContext.h
  lld/include/lld/ReaderWriter/YamlContext.h
  lld/lib/CMakeLists.txt
  lld/lib/Core/CMakeLists.txt
  lld/lib/Core/DefinedAtom.cpp
  lld/lib/Core/Error.cpp
  lld/lib/Core/File.cpp
  lld/lib/Core/LinkingContext.cpp
  lld/lib/Core/Reader.cpp
  lld/lib/Core/Resolver.cpp
  lld/lib/Core/SymbolTable.cpp
  lld/lib/Core/Writer.cpp
  lld/lib/Driver/CMakeLists.txt
  lld/lib/Driver/DarwinLdDriver.cpp
  lld/lib/Driver/DarwinLdOptions.td
  lld/lib/ReaderWriter/CMakeLists.txt
  lld/lib/ReaderWriter/FileArchive.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.h
  lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  lld/lib/ReaderWriter/MachO/Atoms.h
  lld/lib/ReaderWriter/MachO/CMakeLists.txt
  lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
  lld/lib/ReaderWriter/MachO/DebugInfo.h
  lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
  lld/lib/ReaderWriter/MachO/File.h
  lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
  lld/lib/ReaderWriter/MachO/GOTPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.h
  lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
  lld/lib/ReaderWriter/MachO/MachOPasses.h
  lld/lib/ReaderWriter/MachO/ObjCPass.cpp
  lld/lib/ReaderWriter/MachO/SectCreateFile.h
  lld/lib/ReaderWriter/MachO/ShimPass.cpp
  lld/lib/ReaderWriter/MachO/StubsPass.cpp
  lld/lib/ReaderWriter/MachO/TLVPass.cpp
  lld/lib/ReaderWriter/MachO/WriterMachO.cpp
  lld/lib/ReaderWriter/YAML/CMakeLists.txt
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lld/test/CMakeLists.txt
  lld/test/darwin/Inputs/native-and-mach-o.objtxt
  lld/test/darwin/Inputs/native-and-mach-o2.objtxt
  lld/test/darwin/cmdline-lto_library.objtxt
  lld/test/darwin/cmdline-objc_gc.objtxt
  lld/test/darwin/cmdline-objc_gc_compaction.objtxt
  lld/test/darwin/cmdline-objc_gc_only.objtxt
  lld/test/darwin/native-and-mach-o.objtxt
  lld/test/mach-o/Inputs/DependencyDump.py
  lld/test/mach-o/Inputs/MacOSX.sdk/usr/lib/libSystem.tbd
  lld/test/mach-o/Inputs/PIE.yaml
  lld/test/mach-o/Inputs/arm-interworking.yaml
  lld/test/mach-o/Inputs/arm-shims.yaml
  lld/test/mach-o/Inputs/arm64/libSystem.yaml
  lld/test/mach-o/Inputs/armv7/libSystem.yaml
  lld/test/mach-o/Inputs/bar.yaml
  lld/test/mach-o/Inputs/cstring-sections.yaml
  lld/test/mach-o/Inputs/exported_symbols_list.exp
  lld/test/mach-o/Inputs/full.filelist
  lld/test/mach-o/Inputs/got-order.yaml
  lld/test/mach-o/Inputs/got-order2.yaml
  lld/test/mach-o/Inputs/hello-world-arm64.yaml
  lld/test/mach-o/Inputs/hello-world-armv6.yaml
  lld/test/mach-o/Inputs/hello-world-armv7.yaml
  lld/test/mach-o/Inputs/hello-world-x86.yaml
  lld/test/mach-o/Inputs/hello-world-x86_64.yaml
  lld/test/mach-o/Inputs/hw.raw_bytes
  lld/test/mach-o/Inputs/interposing-section.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-2.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-3.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64.yaml
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmyshared.dylib
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmystatic.a
  lld/test/mach-o/Inputs/lib-search-paths/usr/local/lib/file.o
  lld/test/mach-o/Inputs/libbar.a
  lld/test/mach-o/Inputs/libfoo.a
  lld/test/mach-o/Inputs/no-version-min-load-command-object.yaml
  lld/test/mach-o/Inputs/order_file-basic.order
  lld/test/mach-o/Inputs/partial.filelist
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal2.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal3.yaml
  lld/test/mach-o/Inputs/swift-version-1.yaml
  lld/test/mach-o/Inputs/unwind-info-simple-arm64.yaml
  lld/test/mach-o/Inputs/use-dylib-install-names.yaml
  lld/test/mach-o/Inputs/use-simple-dylib.yaml
  lld/test/mach-o/Inputs/write-final-sections.yaml
  lld/test/mach-o/Inputs/wrong-arch-error.yaml
  lld/test/mach-o/Inputs/x86/libSystem.yaml
  lld/test/mach-o/Inputs/x86_64/libSystem.yaml
  lld/test/mach-o/PIE.yaml
  lld/test/mach-o/align_text.yaml
  lld/test/mach-o/arm-interworking-movw.yaml
 

[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 390911.
keith added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

Files:
  lld/CMakeLists.txt
  lld/include/lld/Common/Driver.h
  lld/include/lld/Core/Reference.h
  lld/include/lld/ReaderWriter/MachOLinkingContext.h
  lld/include/lld/ReaderWriter/YamlContext.h
  lld/lib/CMakeLists.txt
  lld/lib/Driver/CMakeLists.txt
  lld/lib/Driver/DarwinLdDriver.cpp
  lld/lib/Driver/DarwinLdOptions.td
  lld/lib/ReaderWriter/CMakeLists.txt
  lld/lib/ReaderWriter/FileArchive.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.h
  lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  lld/lib/ReaderWriter/MachO/Atoms.h
  lld/lib/ReaderWriter/MachO/CMakeLists.txt
  lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
  lld/lib/ReaderWriter/MachO/DebugInfo.h
  lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
  lld/lib/ReaderWriter/MachO/File.h
  lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
  lld/lib/ReaderWriter/MachO/GOTPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.h
  lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
  lld/lib/ReaderWriter/MachO/MachOPasses.h
  lld/lib/ReaderWriter/MachO/ObjCPass.cpp
  lld/lib/ReaderWriter/MachO/SectCreateFile.h
  lld/lib/ReaderWriter/MachO/ShimPass.cpp
  lld/lib/ReaderWriter/MachO/StubsPass.cpp
  lld/lib/ReaderWriter/MachO/TLVPass.cpp
  lld/lib/ReaderWriter/MachO/WriterMachO.cpp
  lld/lib/ReaderWriter/YAML/CMakeLists.txt
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lld/test/CMakeLists.txt
  lld/test/darwin/Inputs/native-and-mach-o.objtxt
  lld/test/darwin/Inputs/native-and-mach-o2.objtxt
  lld/test/darwin/cmdline-lto_library.objtxt
  lld/test/darwin/cmdline-objc_gc.objtxt
  lld/test/darwin/cmdline-objc_gc_compaction.objtxt
  lld/test/darwin/cmdline-objc_gc_only.objtxt
  lld/test/darwin/native-and-mach-o.objtxt
  lld/test/mach-o/Inputs/DependencyDump.py
  lld/test/mach-o/Inputs/MacOSX.sdk/usr/lib/libSystem.tbd
  lld/test/mach-o/Inputs/PIE.yaml
  lld/test/mach-o/Inputs/arm-interworking.yaml
  lld/test/mach-o/Inputs/arm-shims.yaml
  lld/test/mach-o/Inputs/arm64/libSystem.yaml
  lld/test/mach-o/Inputs/armv7/libSystem.yaml
  lld/test/mach-o/Inputs/bar.yaml
  lld/test/mach-o/Inputs/cstring-sections.yaml
  lld/test/mach-o/Inputs/exported_symbols_list.exp
  lld/test/mach-o/Inputs/full.filelist
  lld/test/mach-o/Inputs/got-order.yaml
  lld/test/mach-o/Inputs/got-order2.yaml
  lld/test/mach-o/Inputs/hello-world-arm64.yaml
  lld/test/mach-o/Inputs/hello-world-armv6.yaml
  lld/test/mach-o/Inputs/hello-world-armv7.yaml
  lld/test/mach-o/Inputs/hello-world-x86.yaml
  lld/test/mach-o/Inputs/hello-world-x86_64.yaml
  lld/test/mach-o/Inputs/hw.raw_bytes
  lld/test/mach-o/Inputs/interposing-section.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-2.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-3.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64.yaml
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmyshared.dylib
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmystatic.a
  lld/test/mach-o/Inputs/lib-search-paths/usr/local/lib/file.o
  lld/test/mach-o/Inputs/libbar.a
  lld/test/mach-o/Inputs/libfoo.a
  lld/test/mach-o/Inputs/no-version-min-load-command-object.yaml
  lld/test/mach-o/Inputs/order_file-basic.order
  lld/test/mach-o/Inputs/partial.filelist
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal2.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal3.yaml
  lld/test/mach-o/Inputs/swift-version-1.yaml
  lld/test/mach-o/Inputs/unwind-info-simple-arm64.yaml
  lld/test/mach-o/Inputs/use-dylib-install-names.yaml
  lld/test/mach-o/Inputs/use-simple-dylib.yaml
  lld/test/mach-o/Inputs/write-final-sections.yaml
  lld/test/mach-o/Inputs/wrong-arch-error.yaml
  lld/test/mach-o/Inputs/x86/libSystem.yaml
  lld/test/mach-o/Inputs/x86_64/libSystem.yaml
  lld/test/mach-o/PIE.yaml
  lld/test/mach-o/align_text.yaml
  lld/test/mach-o/arm-interworking-movw.yaml
  lld/test/mach-o/arm-interworking.yaml
  lld/test/mach-o/arm-shims.yaml
  lld/test/mach-o/arm-subsections-via-symbols.yaml
  lld/test/mach-o/arm64-reloc-negDelta32-fixup.yaml
  lld/test/mach-o/arm64-relocs-errors-delta64-offset.yaml
  lld/test/mach-o/arm64-section-order.yaml
  lld/test/mach-o/bind-opcodes.ya

[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 390910.
keith added a comment.

Stragglers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

Files:
  lld/CMakeLists.txt
  lld/include/lld/Common/Driver.h
  lld/include/lld/Core/Reference.h
  lld/include/lld/ReaderWriter/MachOLinkingContext.h
  lld/include/lld/ReaderWriter/YamlContext.h
  lld/lib/CMakeLists.txt
  lld/lib/Driver/CMakeLists.txt
  lld/lib/Driver/DarwinLdDriver.cpp
  lld/lib/Driver/DarwinLdOptions.td
  lld/lib/ReaderWriter/CMakeLists.txt
  lld/lib/ReaderWriter/FileArchive.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.h
  lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  lld/lib/ReaderWriter/MachO/Atoms.h
  lld/lib/ReaderWriter/MachO/CMakeLists.txt
  lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
  lld/lib/ReaderWriter/MachO/DebugInfo.h
  lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
  lld/lib/ReaderWriter/MachO/File.h
  lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
  lld/lib/ReaderWriter/MachO/GOTPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.h
  lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
  lld/lib/ReaderWriter/MachO/MachOPasses.h
  lld/lib/ReaderWriter/MachO/ObjCPass.cpp
  lld/lib/ReaderWriter/MachO/SectCreateFile.h
  lld/lib/ReaderWriter/MachO/ShimPass.cpp
  lld/lib/ReaderWriter/MachO/StubsPass.cpp
  lld/lib/ReaderWriter/MachO/TLVPass.cpp
  lld/lib/ReaderWriter/MachO/WriterMachO.cpp
  lld/lib/ReaderWriter/YAML/CMakeLists.txt
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lld/test/CMakeLists.txt
  lld/test/darwin/Inputs/native-and-mach-o.objtxt
  lld/test/darwin/Inputs/native-and-mach-o2.objtxt
  lld/test/darwin/cmdline-lto_library.objtxt
  lld/test/darwin/cmdline-objc_gc.objtxt
  lld/test/darwin/cmdline-objc_gc_compaction.objtxt
  lld/test/darwin/cmdline-objc_gc_only.objtxt
  lld/test/darwin/native-and-mach-o.objtxt
  lld/test/mach-o/Inputs/DependencyDump.py
  lld/test/mach-o/Inputs/MacOSX.sdk/usr/lib/libSystem.tbd
  lld/test/mach-o/Inputs/PIE.yaml
  lld/test/mach-o/Inputs/arm-interworking.yaml
  lld/test/mach-o/Inputs/arm-shims.yaml
  lld/test/mach-o/Inputs/arm64/libSystem.yaml
  lld/test/mach-o/Inputs/armv7/libSystem.yaml
  lld/test/mach-o/Inputs/bar.yaml
  lld/test/mach-o/Inputs/cstring-sections.yaml
  lld/test/mach-o/Inputs/exported_symbols_list.exp
  lld/test/mach-o/Inputs/full.filelist
  lld/test/mach-o/Inputs/got-order.yaml
  lld/test/mach-o/Inputs/got-order2.yaml
  lld/test/mach-o/Inputs/hello-world-arm64.yaml
  lld/test/mach-o/Inputs/hello-world-armv6.yaml
  lld/test/mach-o/Inputs/hello-world-armv7.yaml
  lld/test/mach-o/Inputs/hello-world-x86.yaml
  lld/test/mach-o/Inputs/hello-world-x86_64.yaml
  lld/test/mach-o/Inputs/hw.raw_bytes
  lld/test/mach-o/Inputs/interposing-section.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-2.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-3.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64.yaml
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmyshared.dylib
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmystatic.a
  lld/test/mach-o/Inputs/lib-search-paths/usr/local/lib/file.o
  lld/test/mach-o/Inputs/libbar.a
  lld/test/mach-o/Inputs/libfoo.a
  lld/test/mach-o/Inputs/no-version-min-load-command-object.yaml
  lld/test/mach-o/Inputs/order_file-basic.order
  lld/test/mach-o/Inputs/partial.filelist
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal2.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal3.yaml
  lld/test/mach-o/Inputs/swift-version-1.yaml
  lld/test/mach-o/Inputs/unwind-info-simple-arm64.yaml
  lld/test/mach-o/Inputs/use-dylib-install-names.yaml
  lld/test/mach-o/Inputs/use-simple-dylib.yaml
  lld/test/mach-o/Inputs/write-final-sections.yaml
  lld/test/mach-o/Inputs/wrong-arch-error.yaml
  lld/test/mach-o/Inputs/x86/libSystem.yaml
  lld/test/mach-o/Inputs/x86_64/libSystem.yaml
  lld/test/mach-o/PIE.yaml
  lld/test/mach-o/align_text.yaml
  lld/test/mach-o/arm-interworking-movw.yaml
  lld/test/mach-o/arm-interworking.yaml
  lld/test/mach-o/arm-shims.yaml
  lld/test/mach-o/arm-subsections-via-symbols.yaml
  lld/test/mach-o/arm64-reloc-negDelta32-fixup.yaml
  lld/test/mach-o/arm64-relocs-errors-delta64-offset.yaml
  lld/test/mach-o/arm64-section-order.yaml
  lld/test/mach-o/bind-opcodes.ya

[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 390908.
keith added a comment.
Herald added subscribers: dang, sstefan1, mgrang.
Herald added a reviewer: jdoerfert.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.

More deletions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

Files:
  lld/CMakeLists.txt
  lld/include/lld/ReaderWriter/MachOLinkingContext.h
  lld/include/lld/ReaderWriter/YamlContext.h
  lld/lib/CMakeLists.txt
  lld/lib/Driver/CMakeLists.txt
  lld/lib/Driver/DarwinLdDriver.cpp
  lld/lib/Driver/DarwinLdOptions.td
  lld/lib/ReaderWriter/CMakeLists.txt
  lld/lib/ReaderWriter/FileArchive.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler.h
  lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
  lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  lld/lib/ReaderWriter/MachO/Atoms.h
  lld/lib/ReaderWriter/MachO/CMakeLists.txt
  lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
  lld/lib/ReaderWriter/MachO/DebugInfo.h
  lld/lib/ReaderWriter/MachO/ExecutableAtoms.h
  lld/lib/ReaderWriter/MachO/File.h
  lld/lib/ReaderWriter/MachO/FlatNamespaceFile.h
  lld/lib/ReaderWriter/MachO/GOTPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.cpp
  lld/lib/ReaderWriter/MachO/LayoutPass.h
  lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
  lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
  lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
  lld/lib/ReaderWriter/MachO/MachOPasses.h
  lld/lib/ReaderWriter/MachO/ObjCPass.cpp
  lld/lib/ReaderWriter/MachO/SectCreateFile.h
  lld/lib/ReaderWriter/MachO/ShimPass.cpp
  lld/lib/ReaderWriter/MachO/StubsPass.cpp
  lld/lib/ReaderWriter/MachO/TLVPass.cpp
  lld/lib/ReaderWriter/MachO/WriterMachO.cpp
  lld/lib/ReaderWriter/YAML/CMakeLists.txt
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lld/test/CMakeLists.txt
  lld/test/darwin/Inputs/native-and-mach-o.objtxt
  lld/test/darwin/Inputs/native-and-mach-o2.objtxt
  lld/test/darwin/cmdline-lto_library.objtxt
  lld/test/darwin/cmdline-objc_gc.objtxt
  lld/test/darwin/cmdline-objc_gc_compaction.objtxt
  lld/test/darwin/cmdline-objc_gc_only.objtxt
  lld/test/darwin/native-and-mach-o.objtxt
  lld/test/mach-o/Inputs/DependencyDump.py
  lld/test/mach-o/Inputs/MacOSX.sdk/usr/lib/libSystem.tbd
  lld/test/mach-o/Inputs/PIE.yaml
  lld/test/mach-o/Inputs/arm-interworking.yaml
  lld/test/mach-o/Inputs/arm-shims.yaml
  lld/test/mach-o/Inputs/arm64/libSystem.yaml
  lld/test/mach-o/Inputs/armv7/libSystem.yaml
  lld/test/mach-o/Inputs/bar.yaml
  lld/test/mach-o/Inputs/cstring-sections.yaml
  lld/test/mach-o/Inputs/exported_symbols_list.exp
  lld/test/mach-o/Inputs/full.filelist
  lld/test/mach-o/Inputs/got-order.yaml
  lld/test/mach-o/Inputs/got-order2.yaml
  lld/test/mach-o/Inputs/hello-world-arm64.yaml
  lld/test/mach-o/Inputs/hello-world-armv6.yaml
  lld/test/mach-o/Inputs/hello-world-armv7.yaml
  lld/test/mach-o/Inputs/hello-world-x86.yaml
  lld/test/mach-o/Inputs/hello-world-x86_64.yaml
  lld/test/mach-o/Inputs/hw.raw_bytes
  lld/test/mach-o/Inputs/interposing-section.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-2.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64-3.yaml
  lld/test/mach-o/Inputs/lazy-bind-x86_64.yaml
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmyshared.dylib
  lld/test/mach-o/Inputs/lib-search-paths/usr/lib/libmystatic.a
  lld/test/mach-o/Inputs/lib-search-paths/usr/local/lib/file.o
  lld/test/mach-o/Inputs/libbar.a
  lld/test/mach-o/Inputs/libfoo.a
  lld/test/mach-o/Inputs/no-version-min-load-command-object.yaml
  lld/test/mach-o/Inputs/order_file-basic.order
  lld/test/mach-o/Inputs/partial.filelist
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal2.yaml
  lld/test/mach-o/Inputs/re-exported-dylib-ordinal3.yaml
  lld/test/mach-o/Inputs/swift-version-1.yaml
  lld/test/mach-o/Inputs/unwind-info-simple-arm64.yaml
  lld/test/mach-o/Inputs/use-dylib-install-names.yaml
  lld/test/mach-o/Inputs/use-simple-dylib.yaml
  lld/test/mach-o/Inputs/write-final-sections.yaml
  lld/test/mach-o/Inputs/wrong-arch-error.yaml
  lld/test/mach-o/Inputs/x86/libSystem.yaml
  lld/test/mach-o/Inputs/x86_64/libSystem.yaml
  lld/test/mach-o/PIE.yaml
  lld/test/mach-o/align_text.yaml
  lld/test/mach-o/arm-interworking-movw.yaml
  lld/test/mach-o/arm-interworking.yaml
  lld/test/mach-o/arm-shims.yaml
  lld/test/mach-o/arm-subsections-via-symbols.yaml
  lld/test/mach-o/arm64-reloc-negDelta32-fixup.yaml
  lld/test/mach-o/arm64-relocs-errors-delt

[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D114842#3163229 , @int3 wrote:

> lgtm. Could you make a post to llvm-dev before landing this? Thanks!

Sent!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

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


[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D114842#3163232 , @MaskRay wrote:

> Consider moving the clang driver change to a separate change so that the 
> removal is a more pure file deletion (other than some build system changes)

Fair enough, I'll submit as a follow up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

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


[PATCH] D114842: [lld-macho] Remove old macho darwin lld

2021-11-30 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

I chose to remove the darwinnew / darwinold symlinks here as well. Let me know 
if you all think we should leave those around for a while for some reason


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114842

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


[PATCH] D113832: reland: [VFS] Use original path when falling back to external FS

2021-11-13 Thread Keith Smiley via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86e2af8043c7: reland: [VFS] Use original path when falling 
back to external FS (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113832

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new Dumm

[PATCH] D113832: reland: [VFS] Use original path when falling back to external FS

2021-11-13 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added a reviewer: dexonsmith.
Herald added subscribers: pengfei, hiraditya.
keith requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This reverts commit f0cf544d6f6fe6cbca4c07772998272d6bb433d8 
.

Just a small change to fix:

  
/home/buildbot/as-builder-4/llvm-clang-x86_64-expensive-checks-ubuntu/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp:
 In static member function ‘static 
llvm::ErrorOr > 
llvm::vfs::File::getWithPath(llvm::ErrorOr >, 
const llvm::Twine&)’:
  
/home/buildbot/as-builder-4/llvm-clang-x86_64-expensive-checks-ubuntu/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp:2084:10:
 error: could not convert ‘F’ from ‘std::unique_ptr’ to 
‘llvm::ErrorOr >’
 return F;
^


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113832

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorO

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-11-13 Thread Keith Smiley 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 rGc972175649f4: [VFS] Use original path when falling back to 
external FS (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegula

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-11-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 387030.
keith added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/Virt

[PATCH] D113645: [clangd] Allow Unix config paths on Darwin

2021-11-12 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D113645#3126652 , @kadircet wrote:

> I got a couple of concerns about the general ideas in the change. Even though 
> the convenience of using ~/.config/clangd/config.yaml seems nice, I think 
> it'll just end up creating confusion in the long run.
>
> According to various macOS developer documentation & QAs, canonical user 
> config directory for applications are `~/Library/Preferences` (see 
> https://developer.apple.com/library/archive/qa/qa1170/_index.html#//apple_ref/doc/uid/DTS10001702-CH1-SECTION3
>  and various others).

While this makes sense, I think the practical realities today are that 
`~/.config` is always preferred by unix style tools, even when on macOS.

> Regarding XDG_CONFIG_HOME, AFAICT macOS doesn't really implement `XDG Base 
> Directory Specification`, so querying its existence in that platform seems 
> controversial.

Yea I considered still omitting that one, but figured it was fair to simplify 
the compiler conditionals and assume that if someone had that variable set on 
macOS it was intentional. But I think it would be fine to exclude.

> Another concern is around multiple user config files. Clangd's config 
> mechanism actually implements overriding of previous config options, and user 
> config file is the most authoritative one and in the case of multiple such 
> config files it's unclear which one should have precedence. So i don't think 
> we should ever use "multiple" user config files.

Yea this makes sense. Theoretically we could check these "search paths" to 
determine if the configs actually existed to make that more clear, but with 
`--log=verbose` the order of operations is clear where clangd is searching for 
these so I think that shouldn't be a common issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113645

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


[PATCH] D113645: [clangd] Allow Unix config paths on Darwin

2021-11-10 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
Herald added subscribers: dexonsmith, usaxena95, kadircet, arphaman, hiraditya.
keith requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, MaskRay, ilya-biryukov.
Herald added projects: LLVM, clang-tools-extra.

It's common for CLIs on macOS to read configuration files from more
unix-standard directories with either dotfiles directly in ~ or files in
~/.config. Previously macOS clangd configuration only read from
~/Library/Preferences on macOS, now it respects the other Unix
directories with XDG_CONFIG_HOME or just ~/.config as a fallback. This
is implemented by changing user_config_directory to
user_config_directories which sets a vector of paths to search,
maintaining the previous order of operations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113645

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -509,9 +509,10 @@
 TEST(Support, ConfigDirectoryWithEnv) {
   WithEnv Env("XDG_CONFIG_HOME", "/xdg/config");
 
-  SmallString<128> ConfigDir;
-  EXPECT_TRUE(path::user_config_directory(ConfigDir));
-  EXPECT_EQ("/xdg/config", ConfigDir);
+  std::vector ConfigDirs;
+  EXPECT_TRUE(path::user_config_directories(ConfigDirs));
+  std::vector Expected = {"/xdg/config"};
+  EXPECT_EQ(Expected, ConfigDirs);
 }
 
 TEST(Support, ConfigDirectoryNoEnv) {
@@ -521,9 +522,10 @@
   ASSERT_TRUE(path::home_directory(Fallback));
   path::append(Fallback, ".config");
 
-  SmallString<128> CacheDir;
-  EXPECT_TRUE(path::user_config_directory(CacheDir));
-  EXPECT_EQ(Fallback, CacheDir);
+  std::vector ConfigDirs;
+  EXPECT_TRUE(path::user_config_directories(ConfigDirs));
+  std::vector Expected = {std::string(Fallback)};
+  EXPECT_EQ(Expected, ConfigDirs);
 }
 
 TEST(Support, CacheDirectoryWithEnv) {
@@ -549,13 +551,41 @@
 
 #ifdef __APPLE__
 TEST(Support, ConfigDirectory) {
-  SmallString<128> Fallback;
-  ASSERT_TRUE(path::home_directory(Fallback));
-  path::append(Fallback, "Library/Preferences");
+  WithEnv Env("XDG_CONFIG_HOME", nullptr);
 
-  SmallString<128> ConfigDir;
-  EXPECT_TRUE(path::user_config_directory(ConfigDir));
-  EXPECT_EQ(Fallback, ConfigDir);
+  SmallString<128> HomerDir;
+  ASSERT_TRUE(path::home_directory(HomerDir));
+
+  SmallString<128> Preferences = HomerDir;
+  path::append(Preferences, "Library/Preferences");
+
+  SmallString<128> ConfigDir = HomerDir;
+  path::append(ConfigDir, ".config");
+
+  std::vector ConfigDirs;
+  EXPECT_TRUE(path::user_config_directories(ConfigDirs));
+  std::vector Expected = {std::string(Preferences),
+   std::string(ConfigDir)};
+  EXPECT_TRUE(Expected == ConfigDirs);
+}
+
+TEST(Support, XDGConfigDirectory) {
+  WithEnv Env("XDG_CONFIG_HOME", "/xdg/config");
+
+  SmallString<128> HomerDir;
+  ASSERT_TRUE(path::home_directory(HomerDir));
+
+  SmallString<128> Preferences = HomerDir;
+  path::append(Preferences, "Library/Preferences");
+
+  SmallString<128> ConfigDir = HomerDir;
+  path::append(ConfigDir, ".config");
+
+  std::vector ConfigDirs;
+  EXPECT_TRUE(path::user_config_directories(ConfigDirs));
+  std::vector Expected = {std::string(Preferences), "/xdg/config",
+   std::string(ConfigDir)};
+  EXPECT_TRUE(Expected == ConfigDirs);
 }
 #endif
 
Index: llvm/lib/Support/Windows/Path.inc
===
--- llvm/lib/Support/Windows/Path.inc
+++ llvm/lib/Support/Windows/Path.inc
@@ -1434,10 +1434,13 @@
   return getKnownFolderPath(FOLDERID_Profile, result);
 }
 
-bool user_config_directory(SmallVectorImpl &result) {
+bool user_config_directories(std::vector &results) {
   // Either local or roaming appdata may be suitable in some cases, depending
   // on the data. Local is more conservative, Roaming may not always be correct.
-  return getKnownFolderPath(FOLDERID_LocalAppData, result);
+  SmallString result;
+  bool found = getKnownFolderPath(FOLDERID_LocalAppData, &result);
+  results.push_back(result.c_str());
+  return found;
 }
 
 bool cache_directory(SmallVectorImpl &result) {
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -1363,27 +1363,34 @@
   return false;
 }
 
-bool user_config_directory(SmallVectorImpl &result) {
+bool user_config_directories(std::vector &results) {
+  bool found = false;
+  SmallString<128> result;
 #ifdef __APPLE__
   // Mac: ~/Library/Preferences/
   if (home_directory(result)) {
 append(result, "Library", "Preferences");
-return true;
+results.push_back(result.c_str());

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-11-10 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

@JDevlieghere can you take another pass?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-11-05 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

@dexonsmith can you take another look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D112767: [clang][driver] Fix multiarch output name with -Wl arg

2021-10-29 Thread Keith Smiley via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd8a9507ef8c: [clang][driver] Fix multiarch output name with 
-Wl arg (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112767

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
 // CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - 
"darwin::Linker", inputs: [(input arg), 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - 
"darwin::Linker", inputs: [(input arg), 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - 
"darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
 
 // Check that we only use dsymutil when needed.
 //
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4697,8 +4697,14 @@
 CachedResults, A->getOffloadingDeviceKind()));
   }
 
-  // Always use the first input as the base input.
+  // Always use the first file input as the base input.
   const char *BaseInput = InputInfos[0].getBaseInput();
+  for (auto &Info : InputInfos) {
+if (Info.isFilename()) {
+  BaseInput = Info.getBaseInput();
+  break;
+}
+  }
 
   // ... except dsymutil actions, which use their actual input as the base
   // input.


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
 // CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
 
 // Check that we only use dsymutil when needed.
 //
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4697,8 +4697,14 @@
 CachedResults, A->getOffloadingDeviceKind()));
   }
 
-  // Always use the first input as the base input.
+  // Always use the first file input as the base input.
   const char *BaseInput = InputInfos[0].getBaseInput();
+  for (auto &Info : InputInfos) {
+if (Info.isFilename()) {
+  BaseInput = Info.getBaseInput();
+  break;
+}
+  }
 
   // ... except dsymutil actions, which use their actual input as the base
   // input.
___
cfe-commits mailing l

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-29 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

@dexonsmith turns out the test I was adding is broken on main today too. If 
it's alright with you I will punt that to another diff to not increase the 
scope of this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-29 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 383406.
keith added a comment.

Remove broken test for now

Turns out this fails on main as well, so I'll punt this to another change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: llvm/lib/Support/VirtualFileSystem.cp

[PATCH] D112767: [clang][driver] Fix multiarch output name with -Wl arg

2021-10-28 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 383213.
keith marked an inline comment as done.
keith added a comment.

Update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112767

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
 // CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - 
"darwin::Linker", inputs: [(input arg), 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - 
"darwin::Linker", inputs: [(input arg), 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - 
"darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
 
 // Check that we only use dsymutil when needed.
 //
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4694,8 +4694,14 @@
 CachedResults, A->getOffloadingDeviceKind()));
   }
 
-  // Always use the first input as the base input.
+  // Always use the first file input as the base input.
   const char *BaseInput = InputInfos[0].getBaseInput();
+  for (auto &Info : InputInfos) {
+if (Info.isFilename()) {
+  BaseInput = Info.getBaseInput();
+  break;
+}
+  }
 
   // ... except dsymutil actions, which use their actual input as the base
   // input.


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
 // CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
 
 // Check that we only use dsymutil when needed.
 //
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4694,8 +4694,14 @@
 CachedResults, A->getOffloadingDeviceKind()));
   }
 
-  // Always use the first input as the base input.
+  // Always use the first file input as the base input.
   const char *BaseInput = InputInfos[0].getBaseInput();
+  for (auto &Info : InputInfos) {
+if (Info.isFilename()) {
+  BaseInput = Info.getBaseInput();
+  break;
+}
+  }
 
   // ... except dsymutil actions, which use their actual input as the base
   // input.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[PATCH] D112767: [clang][driver] Fix multiarch output name with -Wl arg

2021-10-28 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added reviewers: ddunbar, JDevlieghere.
keith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously if you passed a `-Wl,-foo` _before_ the source filename, the
first `InputInfos`, which is used for the base input name would be an
`InputArg` kind, which would never have a base input name. Now we use
that by default, but pick the first `InputInfo` that is of kind
`Filename` to get the name from if there is one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112767

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
 // CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - 
"darwin::Linker", inputs: [(input arg), 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - 
"darwin::Linker", inputs: [(input arg), 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - 
"darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
 
 // Check that we only use dsymutil when needed.
 //
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4696,6 +4696,12 @@
 
   // Always use the first input as the base input.
   const char *BaseInput = InputInfos[0].getBaseInput();
+  for (auto &Info : InputInfos) {
+if (Info.isFilename()) {
+  BaseInput = Info.getBaseInput();
+  break;
+}
+  }
 
   // ... except dsymutil actions, which use their actual input as the base
   // input.


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -51,6 +51,14 @@
 // CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
 // CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Wl,-foo -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Linker", inputs: [(input arg), "{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME-WITH-ARG: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
 
 // Check that we only use dsymutil when needed.
 //
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4696,6 +4696,12 @@
 
   // Always use the first input as the base input.
   const char *BaseInput = InputInfos[0].getBaseInput();
+  for (auto &Info : InputInfos) {
+if (Info.isFilename()) {
+  BaseInput = Info.getBaseInput();
+  break;
+}
+  }
 
   // ... except dsymutil actions, which use their actual input as the base
   // input.
__

[PATCH] D111457: [clang][test] Add lit helper for windows paths

2021-10-25 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D111457#3082398 , @mstorsjo wrote:

> In D111457#3073726 , @keith wrote:
>
>> In D111457#3066508 , @mstorsjo 
>> wrote:
>>
>>> Wouldn't this one also be solved pretty much the same, but differently, by 
>>> changing `if (llvm::sys::path::is_absolute(RemappedFile)) {` into 
>>> `is_absolute_gnu`?
>>
>> I think it //could// but also users could still remap to native window's 
>> paths, so likely we'd want this test as well I think either way?
>
> I guess this might be a good addition as a new test, yeah, but I think it 
> would be good to keep this test as is too, and change the code to use 
> `is_absolute_gnu` (and fix up the test reference here to expect an empty 
> directory in the output).
>
>>> Since we're remapping debug paths, it's plausible that the target path can 
>>> be a different style (when cross compiling, where debug prefix remapping is 
>>> kinda important), and then it's probably good to use a more lax definition 
>>> of whether a path is absolute. (Alternatively, we maybe should try to 
>>> detect the kind of path used and use the appropriate style as argument to 
>>> `is_absolute`, but I don't think that necessarily helps here.)
>>
>> Good point here, I could definitely see wanting to support the entire matrix 
>> of host windows paths vs not, and target windows paths vs not, but I think 
>> that would require significantly more changes for other places that call 
>> `llvm::sys::path::*` APIs and also use the default `native` argument (I'm 
>> not sure how difficult this would be, but it would require a bit of auditing)
>
> I would expect that to mostly work so far, except for corner cases like 
> these. Auditing probably doesn't hurt if one wants to spend the effort, 
> otherwise I'd just expect it to work and try it out and see if one runs into 
> any issues somewhere, if someone has such a usecase.

Yep this makes sense. I would rather not scope that into this if that's ok. 
Since this test was already invalid and broken (actual fix in 
https://reviews.llvm.org/D111579) I would rather land these and then take that 
on to unblock my original use case (https://reviews.llvm.org/D111587) if I can 
find some more time


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-22 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/unittests/Support/VirtualFileSystemTest.cpp:1738
+
+TEST_F(VFSFromYAMLTest, RelativePathHitWithoutCWD) {
+  IntrusiveRefCntPtr BaseFS(

So this test case is actually failing. The difference between it and the others 
is I don't call `FS->setCurrentWorkingDirectory("//root/foo")`. This results in 
us (with my most recent change here) performing this logic:

1. Fetch the absolute //root/foo/vfsname
2. This results in `realname` being returned
3. We attempt to canonicalize `realname`, but we have no `pwd`, so this doesn't 
result in a valid path
4. everything fails past this

It seems to me, without having a ton of context here, that the value returned 
from the VFS lookup should actually be `//root/foo/realname`, since otherwise 
we could likely hit one of the same issues as those discussed above where if 
you actually had this situation:

- `mkdir /root/foo /root/bar`
- `touch /root/foo/realname /root/bar/realname`
- `cd /root/bar`
- lookup `/root/foo/vfsname`, get back `realname`
- canonicalize `realname` to the wrong path `/root/bar/realname`

You'd end up with the wrong file, but I don't think this is actually new 
behavior with my change?

@dexonsmith  wdyt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-19 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 380821.
keith added a comment.

Fix test paths on windows

Otherwise this resulted in a json string with non-escaped backslashes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,153 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, RelativePathHitWithoutCWD) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  Memor

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-19 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1179-1180
 
+  if (ExternalFS)
+ExternalFS->setCurrentWorkingDirectory(Path);
+

dexonsmith wrote:
> keith wrote:
> > JDevlieghere wrote:
> > > I'm pretty sure there was a reason we stopped doing this. There should be 
> > > some discussion about that in my original patch. 
> > So it sounds like it was related to this:
> > 
> > > [fallthrough] ... but not for relative paths that would get resolved 
> > > incorrectly at the lower layer (for example, in case of the 
> > > RealFileSystem, because the strictly virtual path does not exist).
> > 
> > But if I remove that 2 of my new tests `ReturnsInternalPathVFSHit` and 
> > `ReturnsExternalPathVFSHit` do not pass. I think the behavior of them is 
> > what we want, what do you think?
> We stopped doing this because it puts ExternalFS in an unknown state since 
> `Path` may not exist there. Future calls with relative paths could do very 
> strange things.
> 
> E.g., here's a simple testcase that demonstrates something going very wrong:
> - external FS has file `/1/a`
> - redirecting FS has file `/2/b` (and passes through to external FS)
> - execute: `cd /1 && cd /2 && stat a`
> 
> The correct result is for the `stat` to fail because `/2/a` doesn't exist. 
> But your change above will instead find `/1/a` in ExternalFS.
> 
> Another example:
> - external FS has file `/1/a` and `/1/nest/c`
> - redirecting FS has file `/2/b`
> - execute: `cd /1/nest && cd /2 && cd .. && stat a`
> 
> External FS will have CWD of `/1`, redirecting will have CWD of `/`, and 
> `stat a` will erroneously give the result for `/1/a` instead of `/a`.
> 
> (Probably it'd be good to add tests for cases like this...)
> 
> To safely call `ExternalFS->setCurrentWorkingDirectory()`, you'll need extra 
> state (and checks anywhere `ExternalFS` is used) tracking whether it has a 
> valid working directory. If it does not, then it should not be queried, or it 
> should only be sent absolute paths, or (etc.); and there should also be a way 
> to re-establish a valid working directory.
> 
Ok I definitely understand the use case now. This is probably something we 
should add tests for I guess, since I didn't seem to break anything with all my 
changes here.

I've updated the logic here, the core issue my new tests were failing without 
this is because the redirect from the VFS that is returned is not canonicalized 
itself, meaning when you asked for `vfsname` you would get `vfsmappedname` 
back, instead of `//absolute/path/to/vfsmappedname`. Since we stopped doing 
this `cd`, that wasn't enough. With my new change here we're now canonicalizing 
the return path as well, which is canonicalized against the working directory 
of the VFS itself.

The one thing I'm unusure about here, is why this isn't being done by the 
values returned from the VFS instead. I've added a new test here 
`VFSFromYAMLTest.RelativePathHitWithoutCWD` that illustrates the behavior I'm 
talking about. Requesting the absolute file path still fails because my 
canonicalization of the remapped path is incorrect, and it should be based on 
the directory's root instead of the VFS's PWD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-19 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 380802.
keith marked 2 inline comments as done.
keith added a comment.

Remove `cd` of ExternalFS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,153 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, RelativePathHitWithoutCWD) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents 

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2021-10-19 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/test/CodeGen/debug-prefix-map.c:24
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",

mstorsjo wrote:
> mstorsjo wrote:
> > keith wrote:
> > > keith wrote:
> > > > mstorsjo wrote:
> > > > > I presume that this patch goes on top of D111457? It might be good to 
> > > > > set that one as the parent revision of this one, so that the premerge 
> > > > > test runs applies them on top of each other (right now, this one 
> > > > > failed to apply).
> > > > > 
> > > > > Isn't this particular change present (`directory` being `""` here) 
> > > > > already after the previous patch?
> > > > > 
> > > > > 
> > > > That is marked as the parent of this patch in phab, but maybe I need to 
> > > > do something else to get them to apply?
> > > > Isn't this particular change present (directory being "" here) already 
> > > > after the previous patch?
> > > 
> > > This does still require this change since otherwise directory still gets 
> > > `C:`
> > > 
> > > 
> > Hmm, it seems like the premerge testing managed to start running this 
> > before the parent was set (and I didn't notice it when I looked at the 
> > patches the last round). If you reupload the patch later when this already 
> > is set, I think it should work though - but no hurry with that right now.
> Oh, ok.
Ah that's on my order of operations then, I submitted this, and then started 
the pre-warm, and haven't updated it since. Good to know, thanks. I will make 
sure CI passes here before landing anything regardless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

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


[PATCH] D111457: [clang][test] Add lit helper for windows paths

2021-10-19 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

In D111457#3066508 , @mstorsjo wrote:

> Wouldn't this one also be solved pretty much the same, but differently, by 
> changing `if (llvm::sys::path::is_absolute(RemappedFile)) {` into 
> `is_absolute_gnu`?

I think it //could// but also users could still remap to native window's paths, 
so likely we'd want this test as well I think either way?

> Since we're remapping debug paths, it's plausible that the target path can be 
> a different style (when cross compiling, where debug prefix remapping is 
> kinda important), and then it's probably good to use a more lax definition of 
> whether a path is absolute. (Alternatively, we maybe should try to detect the 
> kind of path used and use the appropriate style as argument to `is_absolute`, 
> but I don't think that necessarily helps here.)

Good point here, I could definitely see wanting to support the entire matrix of 
host windows paths vs not, and target windows paths vs not, but I think that 
would require significantly more changes for other places that call 
`llvm::sys::path::*` APIs and also use the default `native` argument (I'm not 
sure how difficult this would be, but it would require a bit of auditing)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


[PATCH] D111269: [clang][Driver] Make multiarch output file basenames reproducible

2021-10-19 Thread Keith Smiley 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 rG17386cb4dc89: [clang][Driver] Make multiarch output file 
basenames reproducible (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111269

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4960,7 +4960,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4960,7 +4960,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2021-10-19 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/test/CodeGen/debug-prefix-map.c:24
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",

mstorsjo wrote:
> I presume that this patch goes on top of D111457? It might be good to set 
> that one as the parent revision of this one, so that the premerge test runs 
> applies them on top of each other (right now, this one failed to apply).
> 
> Isn't this particular change present (`directory` being `""` here) already 
> after the previous patch?
> 
> 
That is marked as the parent of this patch in phab, but maybe I need to do 
something else to get them to apply?



Comment at: clang/test/CodeGen/debug-prefix-map.c:24
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",

keith wrote:
> mstorsjo wrote:
> > I presume that this patch goes on top of D111457? It might be good to set 
> > that one as the parent revision of this one, so that the premerge test runs 
> > applies them on top of each other (right now, this one failed to apply).
> > 
> > Isn't this particular change present (`directory` being `""` here) already 
> > after the previous patch?
> > 
> > 
> That is marked as the parent of this patch in phab, but maybe I need to do 
> something else to get them to apply?
> Isn't this particular change present (directory being "" here) already after 
> the previous patch?

This does still require this change since otherwise directory still gets `C:`




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-15 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 380125.
keith added a comment.

Improve lit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Su

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-14 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 379882.
keith added a comment.

Fix format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-14 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 379881.
keith marked an inline comment as done.
keith added a comment.

Extract fallback status logic to another function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: llvm/lib/Support/VirtualFileSystem.cpp
==

[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-14 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1179-1180
 
+  if (ExternalFS)
+ExternalFS->setCurrentWorkingDirectory(Path);
+

JDevlieghere wrote:
> I'm pretty sure there was a reason we stopped doing this. There should be 
> some discussion about that in my original patch. 
So it sounds like it was related to this:

> [fallthrough] ... but not for relative paths that would get resolved 
> incorrectly at the lower layer (for example, in case of the RealFileSystem, 
> because the strictly virtual path does not exist).

But if I remove that 2 of my new tests `ReturnsInternalPathVFSHit` and 
`ReturnsExternalPathVFSHit` do not pass. I think the behavior of them is what 
we want, what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D111269: [clang][Driver] Make multiarch output file basenames reproducible

2021-10-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 379570.
keith added a comment.

Fix windows test paths


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111269

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4961,7 +4961,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|\\}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|\\}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4961,7 +4961,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-13 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Ok I've updated the diff here based on @dexonsmith's original suggestion, and 
some offline discussion with @JDevlieghere

The new logic remaps the files and statuses, in the fallback to the external FS 
case, to use the originally requested path. I opted not to use the second 
suggestion with passing the `struct` containing both paths through because of 
the churn that would have on the API to maintain the current public signatures 
while also supporting that. This approach is analogous to how we're currently 
remapping the statuses for `use-external-names` as well. Please let me know 
what you think!

Note there's some churn from me renaming `Path` -> `CanonicalPath` and `Path_` 
-> `OriginalPath`, let me know if you'd prefer I extract this into a separate 
diff that we land first without any logic changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-13 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 379559.
keith marked 4 inline comments as done.
keith added a comment.

Update to remap file paths after fetching them from the external FS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

Files:
  clang/test/VFS/relative-path-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1627,6 +1627,114 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/a", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
+  auto RemappedFS = vfs::RedirectingFileSystem::create(
+  {}, /*UseExternalNames=*/false, *BaseFS);
+
+  auto OpenedF = RemappedFS->openFileForRead("a");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("a", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("a", OpenedS->getName());
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
+
+  auto DirectS = RemappedFS->status("a");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("a", DirectS->getName());
+  EXPECT_FALSE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': true,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("realname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("realname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("realname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
+TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
+  IntrusiveRefCntPtr BaseFS(
+  new vfs::InMemoryFileSystem);
+  BaseFS->addFile("//root/foo/realname", 0,
+  MemoryBuffer::getMemBuffer("contents of a"));
+  auto FS =
+  getFromYAMLString("{ 'use-external-names': false,\n"
+"  'roots': [\n"
+"{\n"
+"  'type': 'directory',\n"
+"  'name': '//root/foo',\n"
+"  'contents': [ {\n"
+"  'type': 'file',\n"
+"  'name': 'vfsname',\n"
+"  'external-contents': 'realname'\n"
+"}\n"
+"  ]\n"
+"}]}",
+BaseFS);
+  ASSERT_FALSE(FS->setCurrentWorkingDirectory("//root/foo"));
+
+  auto OpenedF = FS->openFileForRead("vfsname");
+  ASSERT_FALSE(OpenedF.getError());
+  llvm::ErrorOr Name = (*OpenedF)->getName();
+  ASSERT_FALSE(Name.getError());
+  EXPECT_EQ("vfsname", Name.get());
+
+  auto OpenedS = (*OpenedF)->status();
+  ASSERT_FALSE(OpenedS.getError());
+  EXPECT_EQ("vfsname", OpenedS->getName());
+  EXPECT_TRUE(OpenedS->IsVFSMapped);
+
+  auto DirectS = FS->status("vfsname");
+  ASSERT_FALSE(DirectS.getError());
+  EXPECT_EQ("vfsname", DirectS->getName());
+  EXPECT_TRUE(DirectS->IsVFSMapped);
+
+  EXPECT_EQ(0, NumDiagnostics);
+}
+
 TEST_F(VFSFromYAMLTest, CaseInsensitive) {
   IntrusiveRefCntPtr Lower(new DummyFileSystem());
   Lower->addRegularFile("//root/foo/bar/a");
Index: llvm/lib/Support/VirtualFileSys

[PATCH] D111352: [clang] Fix absolute file paths with -fdebug-prefix-map

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

https://reviews.llvm.org/D111587


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111352

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


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

This broke tests on windows (see the new parent revisions in the stack) 
otherwise the actual change's behavior, outside of the tests, is unchanged


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111587

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


[PATCH] D111587: re-land: [clang] Fix absolute file paths with -fdebug-prefix-map

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added a reviewer: probinson.
keith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously if you passed an absolute path to clang, where only part of
the path to the file was remapped, it would result in the file's DIFile
being stored with a duplicate path, for example:

  !DIFile(filename: "./ios/Sources/bar.c", directory: "./ios/Sources")

This change handles absolute paths, specifically in the case they are
remapped to something relative, and uses the dirname for the directory,
and basename for the filename.

This also adds a test verifying this behavior for more standard uses as
well.

This reverts commit 68e49aea9ac4dca550df70706cc845de04939c03 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111587

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c
  clang/test/Modules/module-debuginfo-prefix.m


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -3,7 +3,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{sep}Inputs=%{rootsep}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -11,7 +11,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{sep}Inputs=%{rootsep}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -20,6 +20,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRIDE/DebugObjC.h", directory: 
"{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: "{{/|C:}}OVERRIDE{{/|}}DebugObjC.h", 
directory: "")
Index: clang/test/CodeGen/relative-debug-prefix-map.c
===
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. 
%t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s 
-emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. 
relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir")
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: 
".")
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -446,6 +446,9 @@
   Dir = DirBuf;
   File = FileBuf;
 }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+Dir = llvm::sys::path::parent_path(RemappedFile);
+File = llvm::sys::path::filename(RemappedFile);
   } else {
 Dir = CurDir;
 File = RemappedFile;


Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -3,7 +3,7 @@
 // Modules:
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{sep}Inputs=%{rootsep}OVERRIDE \
 // RUN:   -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
 // RUN:   -I %S/Inputs -I %t -emit-llvm -o %t.ll \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-mod.ll
@@ -11,7 +11,7 @@
 
 // PCH:
 // RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
-// RUN:   -fdebug-prefix-map=%S/Inputs=/OVERRIDE \
+// RUN:   -fdebug-prefix-map=%S%{sep}Inputs=%{rootsep}OVERRIDE \
 // RUN:   -o %t.pch %S/Inputs/DebugObjC.h \
 // RUN:   -mllvm -debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
@@ -20,6 +20,4 @@
 @import DebugObjC;
 #endif
 
-// Dir should always be empty, but on Windows we can't recognize /var
-// as being an absolute path.
-// CHECK: !DIFile(filename: "/OVERRI

[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith added a reviewer: compnerd.
keith added a comment.

Adding since you might be interested in this, I think the Swift logic is also 
derived from this so it might have the same difference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111579

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


[PATCH] D111579: [clang] Fix DIFile directory root on Windows

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On unix systems this logic would not separate the file and directory of
the DIFile unless they shared more components at the start than just the
root path character. The logic to do this was unix specific so it didn't
work on Windows. Now we check if the entire root_path is the same as
what you were going to set as the Dir and use the full filepath in that
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111579

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-prefix-map.c


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -19,23 +19,21 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
-// On POSIX systems "Dir" should actually be empty, but on Windows we
-// can't recognize "/UNLIKELY_PATH" as being an absolute path.
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
-// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
+// CHECK-NO-MAIN-FILE-NAME-SAME:directory: "")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
-// CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK-EVIL: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-EVIL-SAME:directory: "")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}"
-// CHECK: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
-// CHECK-SAME:directory: "{{()|(.*:.*)}}")
+// CHECK: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}"
+// CHECK: !DIFile(filename: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
+// CHECK-SAME:directory: ""
 // CHECK-NOT: !DIFile(filename:
 
 // CHECK-COMPILATION-DIR: !DIFile(filename: "{{.*}}", directory: 
"{{/|C:}}UNLIKELY_PATH{{/|}}empty")
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -427,16 +427,16 @@
   SmallString<128> DirBuf;
   SmallString<128> FileBuf;
   if (llvm::sys::path::is_absolute(RemappedFile)) {
-// Strip the common prefix (if it is more than just "/") from current
-// directory and FileName for a more space-efficient encoding.
+// Strip the common prefix (if it is more than just "/" or "C:\") from
+// current directory and FileName for a more space-efficient encoding.
 auto FileIt = llvm::sys::path::begin(RemappedFile);
 auto FileE = llvm::sys::path::end(RemappedFile);
 auto CurDirIt = llvm::sys::path::begin(CurDir);
 auto CurDirE = llvm::sys::path::end(CurDir);
 for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
   llvm::sys::path::append(DirBuf, *CurDirIt);
-if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
-  // Don't strip the common prefix if it is only the root "/"
+if (llvm::sys::path::root_path(DirBuf) == DirBuf) {
+  // Don't strip the common prefix if it is only the root ("/" or "C:\")
   // since that would make LLVM diagnostic locations confusing.
   Dir = {};
   File = RemappedFile;


Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -19,23 +19,21 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
-// On P

[PATCH] D111269: [clang][Driver] Make multiarch output file basenames reproducible

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 378796.
keith added a comment.

Fix slashes for windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111269

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: 
[{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: 
["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|}}darwin-dsymutil-x86_64.o"], output: 
"{{.*}}{{/|}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", 
inputs: ["{{.*}}{{/|}}darwin-dsymutil-arm64.o"], output: 
"{{.*}}{{/|}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", 
inputs: ["{{.*}}{{/|}}darwin-dsymutil-x86_64.out", 
"{{.*}}{{/|}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4961,7 +4961,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }


Index: clang/test/Driver/darwin-dsymutil.c
===
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -42,6 +42,16 @@
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: [{{.*}}], output: "[[outfile]]"
 // CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["[[outfile]]"], output: "[[dsymfile]]"
 
+// Check output name derivation for multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -arch x86_64 -arch arm64 -ccc-print-bindings %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MULTIARCH-OUTPUT-NAME < %t %s
+//
+// CHECK-MULTIARCH-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|}}darwin-dsymutil-x86_64.o"], output: "{{.*}}{{/|}}darwin-dsymutil-x86_64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Linker", inputs: ["{{.*}}{{/|}}darwin-dsymutil-arm64.o"], output: "{{.*}}{{/|}}darwin-dsymutil-arm64.out"
+// CHECK-MULTIARCH-OUTPUT-NAME: "arm64-apple-darwin10" - "darwin::Lipo", inputs: ["{{.*}}{{/|}}darwin-dsymutil-x86_64.out", "{{.*}}{{/|}}darwin-dsymutil-arm64.out"], output: "a.out"
+
 // Check that we only use dsymutil when needed.
 //
 // RUN: touch %t.o
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4961,7 +4961,13 @@
 return "";
   }
 } else {
-  TmpName = GetTemporaryPath(Split.first, Suffix);
+  if (MultipleArchs && !BoundArch.empty()) {
+TmpName = GetTemporaryDirectory(Split.first);
+llvm::sys::path::append(TmpName,
+Split.first + "-" + BoundArch + "." + Suffix);
+  } else {
+TmpName = GetTemporaryPath(Split.first, Suffix);
+  }
 }
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111457: [clang][test] Add lit helper for windows paths

2021-10-11 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 378725.
keith marked 2 inline comments as done.
keith added a comment.

Allow empty leading on windows

This behavior is currently broken, the directory should never be `/` or `C:\` 
but the logic is broken and only handles `/`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

Files:
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -56,6 +56,16 @@
 config.substitutions.append(('%PATH%', config.environment['PATH']))
 
 
+if platform.system() == 'Windows':
+root_sep = 'C:\\'
+else:
+root_sep = os.path.sep
+
+config.substitutions.extend([
+('%{rootsep}', root_sep),
+('%{sep}', os.path.sep),
+])
+
 # For each occurrence of a clang tool name, replace it with the full path to
 # the build directory holding that tool.  We explicitly specify the directories
 # to search to ensure that we get the tools just built and not some random
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-NO-MAIN-FILE-NAME
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s 
-check-prefix CHECK-EVIL
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name 
debug-prefix-map.c | FileCheck %s
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
-// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -isysroot %p 
-debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
-// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{rootsep}UNLIKELY_PATH%{sep}empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{rootsep}UNLIKELY_PATH=empty %s -emit-llvm -o - | 
FileCheck %s -check-prefix CHECK-EVIL
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{rootsep}UNLIKELY_PATH%{sep}empty %s -emit-llvm -o - 
-main-file-name debug-prefix-map.c | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{rootsep}UNLIKELY_PATH%{sep}empty %s -emit-llvm -o - 
-fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
+// RUN: %clang_cc1 -debug-info-kind=standalone 
-fdebug-prefix-map=%p=%{rootsep}UNLIKELY_PATH%{sep}empty %s -emit-llvm -o - 
-isysroot %p -debugger-tuning=lldb | FileCheck %s -check-prefix CHECK-SYSROOT
+// RUN: %clang -g -fdebug-prefix-map=%p=%{rootsep}UNLIKELY_PATH%{sep}empty -S 
-c %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang -g -ffile-prefix-map=%p=%{rootsep}UNLIKELY_PATH%{sep}empty -S 
-c %s -emit-llvm -o - | FileCheck %s
 
 #include "Inputs/stdio.h"
 
@@ -19,26 +19,26 @@
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}{{.*}}",
 // On POSIX systems "Dir" should actually be empty, but on Windows we
 // can't recognize "/UNLIKELY_PATH" as being an absolute path.
 // CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH{{/|}}empty{{/|}}Inputs{{/|}}stdio.h",
 // CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
+// CHECK-EVIL: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"{{/|C:|()}}UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs{{/|}}stdio.h",
 // CHECK-EVIL-SAME:directory: "{{()

[PATCH] D111457: [clang][test] Add lit helper for windows paths

2021-10-08 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/test/lit.cfg.py:60
+if platform.system() == 'Windows':
+root_sep = 'C:\\'
+else:

rmaz wrote:
> `c:\`?
Do you mean lowercase or a single slash? I see ~2x the number of uppercase vs 
lowercase in this codebase now, and the second is just because of escaping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111457

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


  1   2   >