[PATCH] D62888: [NewPM] Port Sancov

2019-07-12 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added inline comments.



Comment at: 
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1022-1026
+SanitizerCoverage::getSectionStart(const std::string &Section) const {
+  return getSectionStartImpl(TargetTriple, Section);
 }
 
+std::string SanitizerCoverage::getSectionEnd(const std::string &Section) const 
{

buildbots are complaining about warnings from these being unused.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62888



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


[PATCH] D65545: Handle some fs::remove failures

2019-08-02 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

> I haven't updated all ignored instances of fs::remove, I therefore can't mark 
> it LLVM_NODISCARD for now.

I think I remember reading that casting a `[[nodiscard]]` functions return to 
void was broken on some compilers, ie still warns. You cast `fs::remove` to 
void a lot here which is a great way to show intent (I wish we mentioned this 
in the style guide) but if I'm not just making this up, it might not be worth 
the trouble to give `fs::remove` the nodiscard attribute. Maybe something to 
look into if you ever do this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65545



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


[PATCH] D63518: BitStream reader: propagate errors

2019-06-27 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added inline comments.



Comment at: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp:205
+  return MaybeBitCode.takeError();
+switch (unsigned BitCode = MaybeBitCode.get()) {
 default: // Default behavior: reject

This and an identical switch on line 5367 cause an unused variable warning from 
this commit. I don't know if the build bots report on this, or the proper way 
to tell you about this but hopefully you will see it :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D63518



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


[PATCH] D68931: [clang] [clang-offload-bundler] Fix finding installed llvm-objcopy

2019-10-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:469
 // Find llvm-objcopy in order to create the bundle binary.
 ErrorOr Objcopy = sys::findProgramByName(
 "llvm-objcopy", sys::path::parent_path(BundlerExecutable));

I'd be fine removing this FWIW. Is there a high chance they will be in the same 
directory? I think on a mac, there is very little chance this will be true 
because Apple preinstalls clang in /usr/bin, but not llvm-objcopy that would 
have to go in /usr/local/bin. Is it enough of an optimization to keep? Up to 
you I think.


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

https://reviews.llvm.org/D68931



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


[PATCH] D133117: [clang] Give better message for unsupported no_sanitize on globals

2022-09-01 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6d6e33abc2e: [clang] Give better message for unsupported 
no_sanitize on globals (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D133117?vs=457284&id=457428#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133117

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaCXX/attr-no-sanitize.cpp


Index: clang/test/SemaCXX/attr-no-sanitize.cpp
===
--- clang/test/SemaCXX/attr-no-sanitize.cpp
+++ clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -6,6 +6,9 @@
 
 int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' 
attribute requires a string}}
 
+__attribute__((no_sanitize("all"))) int global; // 
expected-warning{{'no_sanitize' attribute argument 'all' not supported on a 
global variable}}
+__attribute__((no_sanitize("unknown"))) int global2; // 
expected-warning{{unknown sanitizer 'unknown' ignored}}
+
 // DUMP-LABEL: FunctionDecl {{.*}} f3
 // DUMP: NoSanitizeAttr {{.*}} address
 // PRINT: int f3() __attribute__((no_sanitize("address")))
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7877,8 +7877,8 @@
 SanitizerName != "coverage")
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << 
SanitizerName;
 else if (isGlobalVar(D) && 
!isSanitizerAttributeAllowedOnGlobals(SanitizerName))
-  S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
-  << AL << ExpectedFunctionOrMethod;
+  S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global)
+  << AL << SanitizerName;
 Sanitizers.push_back(SanitizerName);
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4052,6 +4052,9 @@
 def warn_attribute_type_not_supported : Warning<
   "%0 attribute argument not supported: %1">,
   InGroup;
+def warn_attribute_type_not_supported_global : Warning<
+  "%0 attribute argument '%1' not supported on a global variable">,
+  InGroup;
 def warn_attribute_unknown_visibility : Warning<"unknown visibility %0">,
   InGroup;
 def warn_attribute_protected_visibility :
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -127,6 +127,9 @@
   supports both c and c++ language.
 - When diagnosing multi-level pack expansions of mismatched lengths, Clang will
   now, in most cases, be able to point to the relevant outer parameter.
+- no_sanitize("...") on a global variable for known but not relevant sanitizers
+  is now just a warning. It now says that this will be ignored instead of
+  incorrectly saying no_sanitize only applies to functions and methods.
 
 Non-comprehensive list of changes in this release
 -


Index: clang/test/SemaCXX/attr-no-sanitize.cpp
===
--- clang/test/SemaCXX/attr-no-sanitize.cpp
+++ clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -6,6 +6,9 @@
 
 int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' attribute requires a string}}
 
+__attribute__((no_sanitize("all"))) int global; // expected-warning{{'no_sanitize' attribute argument 'all' not supported on a global variable}}
+__attribute__((no_sanitize("unknown"))) int global2; // expected-warning{{unknown sanitizer 'unknown' ignored}}
+
 // DUMP-LABEL: FunctionDecl {{.*}} f3
 // DUMP: NoSanitizeAttr {{.*}} address
 // PRINT: int f3() __attribute__((no_sanitize("address")))
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7877,8 +7877,8 @@
 SanitizerName != "coverage")
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
 else if (isGlobalVar(D) && !isSanitizerAttributeAllowedOnGlobals(SanitizerName))
-  S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
-  << AL << ExpectedFunctionOrMethod;
+  S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global)
+  << AL << SanitizerName;
 Sanitizers.push_back(SanitizerName);
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/Diagn

[PATCH] D133117: [clang] Give better message for unsupported no_sanitize on globals

2022-09-01 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added a comment.

In D133117#3764721 , @aaron.ballman 
wrote:

> LGTM aside from a requested change in diagnostic wording (no need for 
> additional review), though please also add a release note when landing so 
> people know about the improvement here.

Sure, this and the inline have been addressed in the commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133117

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


[PATCH] D127800: [llvm-driver] Generate symlinks instead of executables for tools

2022-09-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added inline comments.



Comment at: llvm/cmake/modules/AddLLVM.cmake:1283
 macro(add_llvm_tool name)
+  cmake_parse_arguments(ARG "DEPENDS;GENERATE_DRIVER" "" "" ${ARGN})
   if( NOT LLVM_BUILD_TOOLS )

Amir wrote:
> Sorry for a late question but I don't see any use of ARG_DEPENDS - is it 
> intentional or there's an omission somewhere?
It looks like this was superfluous and likely copied from a place where DEPENDS 
is used. It's not necessary for depends to be used here, as it wasn't being 
used before for `add_llvm_tool`. I'll remove this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127800

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-23 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D122335#3403281 , 
@hubert.reinterpretcast wrote:

> For users on Windows, would this cause extra trouble if they wanted to see 
> what was included?

Is `tar(1)` not available on Windows?


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

https://reviews.llvm.org/D122335

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-23 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 417754.
abrachet added a comment.
Herald added a subscriber: arphaman.

Fix test failures outside of Driver/


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

https://reviews.llvm.org/D122335

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"   \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include 
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===
--- clang/test/Modules/crash-vfs-path-traversal.m
+++ clang/test/Modules/crash-vfs-path-traversal.m
@@ -13,18 +13,18 @@
 // RUN: not %clang -fsyntax-only %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-23 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D122335#3403474 , @aaron.ballman 
wrote:

> Yup, I'm okay with that compiler engineer requirement; I think our existing 
> requirements on Windows already pull in a useful `tar` program even though it 
> doesn't seem like we have any tests relying on it being installed yet.

There are actually a couple tests in lld that use `tar` 
https://github.com/llvm/llvm-project/blob/main/lld/test/ELF/reproduce-backslash.s#L8

Looks like there are some test failures on Windows my guess is their `tar` 
doesn't support the `--wildcards` flag. I'd rather not make these `UNSUPORTED: 
windows`, but am unsure how to move forward otherwise.


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

https://reviews.llvm.org/D122335

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-23 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 417756.
abrachet added a comment.

Rebase


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

https://reviews.llvm.org/D122335

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"   \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include 
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===
--- clang/test/Modules/crash-vfs-path-traversal.m
+++ clang/test/Modules/crash-vfs-path-traversal.m
@@ -13,18 +13,18 @@
 // RUN: not %clang -fsyntax-only %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/

[PATCH] D122613: [Driver] Make -moutline-atomics default for aarch64-fuchsia targets

2022-03-28 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.h:81
+  bool IsAArch64OutlineAtomicsDefault(
+  const llvm::opt::ArgList &Args) const override {
+return true;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122613

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-29 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 419014.
abrachet added a comment.
Herald added a subscriber: mgorny.

- Add new build option `CLANG_CRASH_SAVE_TEMPS` which defaults to Off, or On if 
`CMAKE_BUILD_TYPE` is Debug. It retains the old behavior alongside the tar file.
- Mark tests which use `tar(1)` as `UNSUPPORTED: windows`, it seems either the 
Windows bots don't have `tar` or it doesn't support `--wildcards`


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

https://reviews.llvm.org/D122335

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/CMakeLists.txt
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-save-temps.c
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -37,6 +37,7 @@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@
 config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
+config.save_crash_temps = @CLANG_CRASH_SAVE_TEMPS@
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -158,6 +158,10 @@
 if platform.system() not in ['Darwin', 'Fuchsia']:
 config.available_features.add('libgcc')
 
+if config.save_crash_temps:
+print("\n\n\n\n\nsave_crash_temps is true\n\n\n\n\n")
+config.available_features.add('save-crash-temps')
+
 # Case-insensitive file system
 
 
Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/c

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 419165.
abrachet marked 2 inline comments as done.
abrachet added a comment.

- Define `CLANG_CRASH_SAVE_TEMPS` in config.h and not with `add_definitions`
- Add `CLANG_CRASH_SAVE_TEMPS` env var to force emitting individual 
preprocessed sources


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

https://reviews.llvm.org/D122335

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-save-temps.c
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"   \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include 
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 2 inline comments as done.
abrachet added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:1434
 StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
+#ifdef CLANG_CRASH_SAVE_TEMPS
+  constexpr bool SaveReproTemps = true;

arichardson wrote:
> This could be simplified with `#cmakedefine01` in the config header
Thanks I like that a lot better.



Comment at: clang/test/Driver/crash-report-clang-cl.cpp:1
+// UNSUPPORTED: windows
+

arichardson wrote:
> I think it would be cleaner to add a new feature if tar is available in $PATH 
> instead of ignoring all windows bots. Some might have tar installed.
It's not clear to me what the Windows builders don't like. `tar(1)` is used in 
some lld tests. My guess is that the tar shipped on Windows doesn't support 
`--wildcards` which is seemingly necessary here because the tar file will have 
a random name, and it's member files are prefixed with that name. I don't have 
easy access to a Windows machine to test that theory though.

I've gone with your suggestion to have an env var. Do you think I should remove 
`UNSUPPORTED: windows` on all tests or just this one?



Comment at: clang/test/Driver/crash-report-clang-cl.cpp:8
 // RUN: -fcrash-diagnostics-dir=%t -- %s 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-clang-cl-*.cpp | FileCheck --check-prefix=CHECKSRC 
%s
-// RUN: cat %t/crash-report-clang-cl-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-clang-cl-*.cpp" \
+// RUN: | FileCheck --check-prefix=CHECKSRC %s

arichardson wrote:
> Alternatively, if we had an env var/command line option to keep the cpp/sh, 
> we could use that to avoid the dependency on tar in this test.
Sure.



Comment at: clang/test/Driver/crash-report-save-temps.c:14
+
+// RUN: false

arichardson wrote:
> Is this line intentional?
Nope, thanks.


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

https://reviews.llvm.org/D122335

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 419170.
abrachet marked 2 inline comments as done.
abrachet added a comment.

reabase


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

https://reviews.llvm.org/D122335

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-save-temps.c
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"   \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include 
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===
--- clang/test/Modules/crash-vfs-path-traversal.m
+++ clang/test/Modules/crash-vfs-path-traversal.

[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-03-31 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 419491.
abrachet added a comment.

Rebase so patch applies


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

https://reviews.llvm.org/D121560

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/claim-unused.c
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/ObjdumpOptID.h
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -258,6 +258,16 @@
   OS << "#endif // PREFIX\n\n";
 
   OS << "/\n";
+
+  OS << R"(
+#ifndef OPT_PREFIX
+#define OPT_PREFIX
+#endif
+
+#define CAT_(A, B) A ## B
+#define CAT(A, B) CAT_(A, B)
+#define GET_OPT(OPT) CAT(OPT_PREFIX, OPT)
+  )";
   OS << "// Groups\n\n";
   OS << "#ifdef OPTION\n";
   for (const Record &R : llvm::make_pointee_range(Groups)) {
@@ -298,6 +308,9 @@
 OS << ", nullptr";
 
 // The option Values (unused for groups).
+OS << ", nullptr";
+
+// NoArgUnusedWith (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -388,6 +401,20 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+
+// List of flags who's presence should cause this flag to not warn if used.
+OS << ", ";
+std::vector List = R.getValueAsListOfDefs("NoArgUnusedWith");
+if (!List.size()) {
+  OS << "nullptr";
+  return;
+}
+OS << "((const unsigned *)&(unsigned []){";
+// First element is the length of the array.
+OS << List.size();
+for (Record *R : List)
+  OS << ", GET_OPT(" << R->getName() << ")";
+OS << "})";
   };
 
   auto IsMarshallingOption = [](const Record &R) {
@@ -405,6 +432,11 @@
   OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
+  OS << R"(#undef GET_OPT
+#undef CAT
+#undef CAT_
+#undef OPT_PREFIX
+)";
 
   auto CmpMarshallingOpts = [](const Record *const *A, const Record *const *B) {
 unsigned AID = (*A)->getID();
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,7 +18,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   OPT_##ID,
 #include "Opts.inc"
   LastOption
@@ -37,9 +37,9 @@
 
 static const OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
-   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
+   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES, UNUSEDWITH},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -18,9 +18,9 @@
 static const OptionWithMarshallingInfo MarshallingTable[] = {
 #define OPTION_WITH_MARSHALLING(  

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-04-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 420299.
abrachet added a comment.

Fixing failing tests in Modules/


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

https://reviews.llvm.org/D122335

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-save-temps.c
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -9,19 +9,20 @@
 // RUN: mkdir -p %t/i/Frameworks/A.framework/Frameworks
 // RUN: ln -s ../../B.framework %t/i/Frameworks/A.framework/Frameworks/B.framework
 
-// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
-// RUN: not %clang -nostdinc -fsyntax-only %s \
-// RUN: -F %/t/i/Frameworks -fmodules \
+// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= CLANG_CRASH_SAVE_TEMPS= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: not %clang -nostdinc -fsyntax-only %s   \
+// RUN: -F %/t/i/Frameworks -fmodules   \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.m
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.sh
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +40,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +54,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -6,23 +6,26 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t
 
-// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
-// RUN: not %clang -fsyntax-only -nostdinc %s \
-// RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
+// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= CLANG_CRASH_SAVE_TEMPS= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: not %clang -fsyntax-only -nostdinc %s   \
+// RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/\
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t

[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-04-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 420375.
abrachet added a comment.

Actually clang-format...


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

https://reviews.llvm.org/D121560

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/claim-unused.c
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/ObjdumpOptID.h
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -258,6 +258,16 @@
   OS << "#endif // PREFIX\n\n";
 
   OS << "/\n";
+
+  OS << R"(
+#ifndef OPT_PREFIX
+#define OPT_PREFIX
+#endif
+
+#define CAT_(A, B) A ## B
+#define CAT(A, B) CAT_(A, B)
+#define GET_OPT(OPT) CAT(OPT_PREFIX, OPT)
+  )";
   OS << "// Groups\n\n";
   OS << "#ifdef OPTION\n";
   for (const Record &R : llvm::make_pointee_range(Groups)) {
@@ -298,6 +308,9 @@
 OS << ", nullptr";
 
 // The option Values (unused for groups).
+OS << ", nullptr";
+
+// NoArgUnusedWith (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -388,6 +401,20 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+
+// List of flags who's presence should cause this flag to not warn if used.
+OS << ", ";
+std::vector List = R.getValueAsListOfDefs("NoArgUnusedWith");
+if (!List.size()) {
+  OS << "nullptr";
+  return;
+}
+OS << "((const unsigned *)&(unsigned []){";
+// First element is the length of the array.
+OS << List.size();
+for (Record *R : List)
+  OS << ", GET_OPT(" << R->getName() << ")";
+OS << "})";
   };
 
   auto IsMarshallingOption = [](const Record &R) {
@@ -405,6 +432,11 @@
   OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
+  OS << R"(#undef GET_OPT
+#undef CAT
+#undef CAT_
+#undef OPT_PREFIX
+)";
 
   auto CmpMarshallingOpts = [](const Record *const *A, const Record *const *B) {
 unsigned AID = (*A)->getID();
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,7 +18,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   OPT_##ID,
 #include "Opts.inc"
   LastOption
@@ -37,9 +37,10 @@
 
 static const OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
-  {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
-   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
+  {PREFIX,NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class, \
+   PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES,  \
+   UNUSEDWITH},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -18,9 +18,9 @@
 sta

[PATCH] D130514: [CMake][Fuchsia] Enable assertions and backtraces in stage 1 build

2022-07-25 Thread Alex Brachet 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 rG0df7d8bc355d: [CMake][Fuchsia] Enable assertions and 
backtraces in stage 1 build (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130514

Files:
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -34,8 +34,8 @@
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
-set(LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if(APPLE)
   set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -34,8 +34,8 @@
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
-set(LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if(APPLE)
   set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5fd03b00ee02: [Driver] Re-run lld with --reproduce when it 
crashes (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Compilation.h
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/lit.local.cfg
  clang/test/Driver/lld-repro.c

Index: clang/test/Driver/lld-repro.c
===
--- /dev/null
+++ clang/test/Driver/lld-repro.c
@@ -0,0 +1,26 @@
+// REQUIRES: lld
+
+// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN:   | FileCheck %s
+
+// check that we still get lld's output
+// CHECK: error: undefined symbol: a
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}/linker-crash-{{.*}}.tar
+// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.sh
+// CHECK-NEXT: note: diagnostic msg:
+// CHECK: 
+
+// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-LINKER
+// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-LINKER
+
+// NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are located at:
+
+extern int a;
+int main() {
+  return a;
+}
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,3 +1,5 @@
+from lit.llvm import llvm_config
+
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.clcpp', '.hip', '.hlsl']
 config.substitutions = list(config.substitutions)
@@ -16,3 +18,6 @@
 for name in driver_overwrite_env_vars:
   if name in config.environment:
 del config.environment[name]
+
+if llvm_config.use_lld(required=False):
+config.available_features.add('lld')
Index: clang/test/Driver/crash-report.cpp
===
--- clang/test/Driver/crash-report.cpp
+++ clang/test/Driver/crash-report.cpp
@@ -27,6 +27,29 @@
 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
 
+// Test manually specifying -fcrash-diagnostics[=[compiler|all]] emits
+// diagnostics
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics 2>&1 |\
+// RUN:  FileCheck %s
+// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1   \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1  \
+// RUN:  not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics=compiler 2>&1 |\
+// RUN:  FileCheck %s
+// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1  \
+// RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \
+// RUN:  not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics=all 2>&1 |\
+// RUN:  FileCheck %s
+// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
+// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
+
 // REQUIRES: crash-recovery
 
 #ifdef PARSER
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1507,11 +1507,36 @@
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
-  // Don't try to generate diagnostics for link or dsymutil jobs.
-  if (FailingCommand.getCreator().isLinkJob() ||
-  FailingCommand.getCreator().isDsymutilJob())
+  unsigned Level = 1;
+  if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_EQ)) {
+Level = llvm::StringSwitch(A->getValue())
+.Case("off", 0)
+.Case("compiler", 1)
+.Case("all", 2)
+.Default(1);
+  }
+  if (!Level)
 return;
 
+ 

[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3691843 , @MaskRay wrote:

> LGTM
>
> (Note: This is a patch which I think would benefit from a second look and 
> 2.5h from approval to push was too short for others to react on this patch.)

Ack, I'll give more time in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3692032 , @thakis wrote:

> This breaks tests on mac and win:
> http://45.33.8.238/macm1/41545/step_7.txt
> http://45.33.8.238/win/63579/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

Should be fixed in 
https://github.com/llvm/llvm-project/commit/9028966a717239cf586d6c4f606965d444176dc4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-08-02 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3693458 , @probinson wrote:

> There is now cross-project-tests which would seem to be the appropriate place 
> for a test that wants to run both clang and lld.

Thanks for pointing that out. I'll look into moving the test there




Comment at: clang/lib/Driver/Driver.cpp:1638
+llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
+ArgList.push_back(Saver.save(Twine{"--reproduce="} + TmpName).data());
+NewLLDInvocation.replaceArguments(std::move(ArgList));

thakis wrote:
> This does the wrong thing on Windows, I think (the flag is spelled 
> /reproduce:path there I think?)
Ah yeah good catch. Unfortunately this wasn't caught upstream because I quickly 
had to change to explicit target because *-ps4 target doesn't support 
`-fuse-ld` and there didn't already exist a PS4 lit feature that I could mark 
as unsupported. This was actually why you saw test failures on non linux 
platforms.

I'll make a new review that correctly uses `/reproduce:`. Thanks again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D130226: [clang-doc] Default to Standalone executor and improve documentation

2022-08-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added inline comments.



Comment at: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp:195
+  $ clang-doc --executor=all-TUs compile_commands.json
+  )";
+

Is it intentional that the rest of this help message also has two spaces before 
the text? It seems like the only other `Overview` passed to 
`createExecutorFromCommandLineArgs` in clangd has the same formatting. It also 
has the trailing whitespace on newline, but I don't think it should


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130226

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


[PATCH] D131214: [clang][Driver] Pass correct reproduce flag to lld-link

2022-08-08 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 450836.

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

https://reviews.llvm.org/D131214

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/lld-repro.c


Index: clang/test/Driver/lld-repro.c
===
--- clang/test/Driver/lld-repro.c
+++ clang/test/Driver/lld-repro.c
@@ -1,6 +1,7 @@
-// REQUIRES: lld, x86-registered-target
+// REQUIRES: lld
+// UNSUPPORTED: ps4
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +14,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1635,7 +1635,11 @@
 const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
 Command NewLLDInvocation = Cmd;
 llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-ArgList.push_back(Saver.save(Twine{"--reproduce="} + TmpName).data());
+Twine ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce=";
+ArgList.push_back(Saver.save(ReproduceOption + TmpName).data());
 NewLLDInvocation.replaceArguments(std::move(ArgList));
 
 // Redirect stdout/stderr to /dev/null.


Index: clang/test/Driver/lld-repro.c
===
--- clang/test/Driver/lld-repro.c
+++ clang/test/Driver/lld-repro.c
@@ -1,6 +1,7 @@
-// REQUIRES: lld, x86-registered-target
+// REQUIRES: lld
+// UNSUPPORTED: ps4
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +14,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are located at:
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1635,7 +1635,11 @@
 const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
 Command NewLLDInvocation = Cmd;
 llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-ArgList.push_back(Saver.save(Twine{"--reproduce="} + TmpName).data());
+Twine ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce=";
+ArgList.push_back(Saver.save(ReproduceOption + TmpName).data());
 NewLLDInvocation.replaceArguments(std::move(ArgList));
 
 // Redirect stdout/stderr to /dev/null.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131214: [clang][Driver] Pass correct reproduce flag to lld-link

2022-08-08 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 2 inline comments as done.
abrachet added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:1639
+Twine ReproduceOption =
+C.getDefaultToolChain().getTriple().isOSBinFormatCOFF()
+? "/reproduce:"

mstorsjo wrote:
> thakis wrote:
> > @mstorsjo, will this do the right thing for mingw?
> The correct thing for the mingw linker interface would be to do the same 
> thing as for GNU style linkers, i.e. using the unix parameter form.
> 
> (With the lld mingw interface, the canonical way to pass options through to 
> the underlying lld-link interface is e.g. `-Xlink=/reproduce:`. But as an 
> unintended loophole, as long as you pass lld-link options with a leading 
> slash instead of a dash, e.g. if you pass e.g. `/reproduce:` directly to the 
> mingw interface, the mingw interface considers it a filename and passes it 
> through as-is to lld-link, and lld-link the interprets it as an option. But 
> that's not the kosher way to do it IMO.)
> 
> Thus, here, I think the correct thing would be to check 
> `C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()`.
Thanks


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

https://reviews.llvm.org/D131214

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


[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-03-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet created this revision.
abrachet added reviewers: MaskRay, thakis.
Herald added subscribers: ormris, dang, usaxena95, kadircet, rupprecht, 
arphaman, steven_wu, hiraditya, arichardson, sbc100, emaste.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
abrachet requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, aheejin.
Herald added projects: LLVM, clang-tools-extra.

`NoArgUnusedWith` can be used for options which together are redundant or not 
meaningful. This patch adds an example for `-static-libcxx` and `-nostdlib`. 
The former isn't meaningful with the latter. Projects might elect to build with 
a flag like `static-libcxx` globally and use `nostdlib` for specific TU's, in 
this case they would get unused args warnings.


https://reviews.llvm.org/D121560

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/claim-unused.c
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/ObjdumpOptID.h
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -258,6 +258,16 @@
   OS << "#endif // PREFIX\n\n";
 
   OS << "/\n";
+
+  OS << R"(
+#ifndef OPT_PREFIX
+#define OPT_PREFIX
+#endif
+
+#define CAT_(A, B) A ## B
+#define CAT(A, B) CAT_(A, B)
+#define GET_OPT(OPT) CAT(OPT_PREFIX, OPT)
+  )";
   OS << "// Groups\n\n";
   OS << "#ifdef OPTION\n";
   for (const Record &R : llvm::make_pointee_range(Groups)) {
@@ -298,6 +308,9 @@
 OS << ", nullptr";
 
 // The option Values (unused for groups).
+OS << ", nullptr";
+
+// NoArgUnusedWith (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -388,6 +401,20 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+
+// List of flags who's presence should cause this flag to not warn if used.
+OS << ", ";
+std::vector List = R.getValueAsListOfDefs("NoArgUnusedWith");
+if (!List.size()) {
+  OS << "nullptr";
+  return;
+}
+OS << "((const unsigned *)&(unsigned []){";
+// First element is the length of the array.
+OS << List.size();
+for (Record *R : List)
+  OS << ", GET_OPT(" << R->getName() << ")";
+OS << "})";
   };
 
   auto IsMarshallingOption = [](const Record &R) {
@@ -405,6 +432,11 @@
   OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
+  OS << R"(#undef GET_OPT
+#undef CAT
+#undef CAT_
+#undef OPT_PREFIX
+)";
 
   auto CmpMarshallingOpts = [](const Record *const *A, const Record *const *B) {
 unsigned AID = (*A)->getID();
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,7 +18,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   OPT_##ID,
 #include "Opts.inc"
   LastOption
@@ -37,9 +37,9 @@
 
 static const OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARG

[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-03-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 414965.
abrachet edited the summary of this revision.
abrachet added a comment.

Update example to have multiple options in NoArgUnusedWith


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

https://reviews.llvm.org/D121560

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/claim-unused.c
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/ObjdumpOptID.h
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -258,6 +258,16 @@
   OS << "#endif // PREFIX\n\n";
 
   OS << "/\n";
+
+  OS << R"(
+#ifndef OPT_PREFIX
+#define OPT_PREFIX
+#endif
+
+#define CAT_(A, B) A ## B
+#define CAT(A, B) CAT_(A, B)
+#define GET_OPT(OPT) CAT(OPT_PREFIX, OPT)
+  )";
   OS << "// Groups\n\n";
   OS << "#ifdef OPTION\n";
   for (const Record &R : llvm::make_pointee_range(Groups)) {
@@ -298,6 +308,9 @@
 OS << ", nullptr";
 
 // The option Values (unused for groups).
+OS << ", nullptr";
+
+// NoArgUnusedWith (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -388,6 +401,20 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+
+// List of flags who's presence should cause this flag to not warn if used.
+OS << ", ";
+std::vector List = R.getValueAsListOfDefs("NoArgUnusedWith");
+if (!List.size()) {
+  OS << "nullptr";
+  return;
+}
+OS << "((const unsigned *)&(unsigned []){";
+// First element is the length of the array.
+OS << List.size();
+for (Record *R : List)
+  OS << ", GET_OPT(" << R->getName() << ")";
+OS << "})";
   };
 
   auto IsMarshallingOption = [](const Record &R) {
@@ -405,6 +432,11 @@
   OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
+  OS << R"(#undef GET_OPT
+#undef CAT
+#undef CAT_
+#undef OPT_PREFIX
+)";
 
   auto CmpMarshallingOpts = [](const Record *const *A, const Record *const *B) {
 unsigned AID = (*A)->getID();
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,7 +18,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   OPT_##ID,
 #include "Opts.inc"
   LastOption
@@ -37,9 +37,9 @@
 
 static const OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
-   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
+   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES, UNUSEDWITH},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -18,9 +18,9 @@
 static const OptionWithM

[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-03-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added a comment.

In D121560#3378181 , @MaskRay wrote:

>> This patch adds an example for -static-libcxx and -nostdlib.
>
> We have -static-libstdc++ but not -static-libc++. (D53238 
>  attempts to add `-static` and name it 
> `-static=c++stdlib`)

Thank you, updated the description

>> NoArgUnusedWith can be used for options which together are redundant or not 
>> meaningful.
>
> I agree that `-Wunused-command-line-argument` sometimes gets in the way and 
> removing the warnings is sometimes inconvenient.
>
> You can currently avoid the warning with: `--start-no-unused-arguments 
> -static-libstdc++ --end-no-unused-arguments`.

Yeah, we are currently using this in some places, but if you just globally set 
`-static-libstdc++` as `--start-no-unused-arguments -static-libstdc++ 
--end-no-unused-arguments`, then you lose out when it should actually warn. 
Likewise right now we set `-Wno-unused-command-line-argument` in a few places 
where this is an issue

> For `NoArgUnusedWith`, intuitively I am unsure it is the desired interface. 
> For `-static-libstdc++`, you probably want to remove the diagnostic with 
> `-nostdlib++` and `-nodefaultlibs` as well. There are just so many similar 
> options.

Added to the example both of these flags to show `NoArgUnusedWith` can support 
multiple flags. There's a lot more redundant flags, and I'll get to some in 
follow up patches




Comment at: clang/lib/Driver/Driver.cpp:4426
 
+  std::function ConsideredUsed =
+  [&ConsideredUsed](llvm::opt::DerivedArgList &Args, Arg *A) {

MaskRay wrote:
> Unless you want to capture it somewhere.
Indeed, `ConsideredUsed` is used in the llvm::any_of call


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

https://reviews.llvm.org/D121560

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


[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-03-22 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 417313.
abrachet marked an inline comment as done.
abrachet added a comment.
Herald added subscribers: pmatos, asb, StephenFan.

clang-format


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

https://reviews.llvm.org/D121560

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/DriverOptions.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/claim-unused.c
  lld/COFF/Driver.h
  lld/COFF/DriverUtils.cpp
  lld/ELF/Driver.h
  lld/ELF/DriverUtils.cpp
  lld/MachO/Driver.h
  lld/MachO/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/wasm/Driver.cpp
  lldb/tools/driver/Driver.cpp
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-cvtres/llvm-cvtres.cpp
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-mt/llvm-mt.cpp
  llvm/tools/llvm-nm/llvm-nm.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/tools/llvm-objdump/ObjdumpOptID.h
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-rc/llvm-rc.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/llvm-size/llvm-size.cpp
  llvm/tools/llvm-strings/llvm-strings.cpp
  llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
  llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/OptionParsingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -258,6 +258,16 @@
   OS << "#endif // PREFIX\n\n";
 
   OS << "/\n";
+
+  OS << R"(
+#ifndef OPT_PREFIX
+#define OPT_PREFIX
+#endif
+
+#define CAT_(A, B) A ## B
+#define CAT(A, B) CAT_(A, B)
+#define GET_OPT(OPT) CAT(OPT_PREFIX, OPT)
+  )";
   OS << "// Groups\n\n";
   OS << "#ifdef OPTION\n";
   for (const Record &R : llvm::make_pointee_range(Groups)) {
@@ -298,6 +308,9 @@
 OS << ", nullptr";
 
 // The option Values (unused for groups).
+OS << ", nullptr";
+
+// NoArgUnusedWith (unused for groups).
 OS << ", nullptr)\n";
   }
   OS << "\n";
@@ -388,6 +401,20 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+
+// List of flags who's presence should cause this flag to not warn if used.
+OS << ", ";
+std::vector List = R.getValueAsListOfDefs("NoArgUnusedWith");
+if (!List.size()) {
+  OS << "nullptr";
+  return;
+}
+OS << "((const unsigned *)&(unsigned []){";
+// First element is the length of the array.
+OS << List.size();
+for (Record *R : List)
+  OS << ", GET_OPT(" << R->getName() << ")";
+OS << "})";
   };
 
   auto IsMarshallingOption = [](const Record &R) {
@@ -405,6 +432,11 @@
   OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
+  OS << R"(#undef GET_OPT
+#undef CAT
+#undef CAT_
+#undef OPT_PREFIX
+)";
 
   auto CmpMarshallingOpts = [](const Record *const *A, const Record *const *B) {
 unsigned AID = (*A)->getID();
Index: llvm/unittests/Option/OptionParsingTest.cpp
===
--- llvm/unittests/Option/OptionParsingTest.cpp
+++ llvm/unittests/Option/OptionParsingTest.cpp
@@ -18,7 +18,7 @@
 enum ID {
   OPT_INVALID = 0, // This is not an option ID.
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
   OPT_##ID,
 #include "Opts.inc"
   LastOption
@@ -37,9 +37,10 @@
 
 static const OptTable::Info InfoTable[] = {
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
-   HELPTEXT, METAVAR, VALUES)  \
-  {PREFIX, NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class,\
-   PARAM,  FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES},
+   HELPTEXT, METAVAR, VALUES, UNUSEDWITH)  \
+  {PREFIX,NAME,  HELPTEXT,METAVAR, OPT_##ID,  Option::KIND##Class, \
+   PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, VALUES,  \
+   UNUSEDWITH},
 #include "Opts.inc"
 #undef OPTION
 };
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingT

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-04-08 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

Ping :)


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

https://reviews.llvm.org/D122335

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


[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

2022-04-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D121560#3439570 , @MaskRay wrote:

> If you need a -static-libstdc++ not subject to unused argument warning, 
> --start-no-unused-arguments and D53238  
> (-static=c++stdlib) may be better choices.

That patch might help for `-static-libstdc++` in particular and other -static-* 
flags, however there are other flags that this will help with in the future. 
What about `-nostdlib -noprofilelib`. I'm currently only interested with 
`-nostdlib` and haven't looked into other flags but I suspect this could help 
in other instances too. Could be helpful with sanitizers too, but all their 
flags get read into SanitizerArgs so there are never warnings there.

I don't think --start-no-unused arguments is as good as a solution here. For a 
large project build, I think `--{start,end}-no-unused-arguments` is too heavy a 
hand. You would just end up putting it everywhere and lose any warnings that 
might be useful. This patch is specifically trying to reduce the need for those.


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

https://reviews.llvm.org/D121560

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-04-18 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

Ping :)


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

https://reviews.llvm.org/D122335

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


[PATCH] D120074: [Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld

2022-02-17 Thread Alex Brachet 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 rGb9f4dff8ab40: [Driver][Fuchsia][NFC] Use GetLinkerPath to 
see if linker is lld (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120074

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -53,9 +53,9 @@
   CmdArgs.push_back("-z");
   CmdArgs.push_back("now");
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
-  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
-  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
+  bool IsLLD;
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath(&IsLLD));
+  if (IsLLD) {
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rodynamic");
 CmdArgs.push_back("-z");


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -53,9 +53,9 @@
   CmdArgs.push_back("-z");
   CmdArgs.push_back("now");
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
-  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
-  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
+  bool IsLLD;
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath(&IsLLD));
+  if (IsLLD) {
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rodynamic");
 CmdArgs.push_back("-z");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109977: LLVM Driver Multicall tool

2022-07-14 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added a comment.

In D109977#3611683 , @mgorny wrote:

> This seems to have broken standalone builds for Gentoo.
>
> While building Clang, I get:
>
>   CMake Error at /usr/lib/llvm/15/lib/cmake/llvm/LLVM-Config.cmake:138 
> (message):
> Target Sparc is not in the set of libraries.
>   Call Stack (most recent call first):
> /usr/lib/llvm/15/lib/cmake/llvm/LLVM-Config.cmake:263 
> (llvm_expand_pseudo_components)
> /usr/lib/llvm/15/lib/cmake/llvm/LLVM-Config.cmake:102 
> (llvm_map_components_to_libnames)
> /usr/lib/llvm/15/lib/cmake/llvm/LLVM-Config.cmake:95 
> (explicit_llvm_config)
> /usr/lib/llvm/15/lib/cmake/llvm/AddLLVM.cmake:901 (llvm_config)
> cmake/modules/AddClang.cmake:146 (add_llvm_executable)
> cmake/modules/AddClang.cmake:156 (add_clang_executable)
> tools/driver/CMakeLists.txt:25 (add_clang_tool)
>
> (or a similar message for another target)

Could I have a cmake invocation or a bot link?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-07-18 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D109977#3652467 , @mgorny wrote:

> In D109977#3652091 , @abrachet 
> wrote:
>
>> Could I have a cmake invocation or a bot link?
>
> The exact CMake invocation for clang is:
>
>   cmake -C 
> /var/tmp/portage/sys-devel/clang-15.0.0./work/x/y/clang-abi_x86_64.amd64/gentoo_common_config.cmake
>  -G Ninja -DCMAKE_INSTALL_PREFIX=/usr 
> -DLLVM_CMAKE_PATH=/usr/lib/llvm/15/lib64/cmake/llvm 
> -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm/15 
> -DCMAKE_INSTALL_MANDIR=/usr/lib/llvm/15/share/man 
> -DCLANG_RESOURCE_DIR=../../../../lib/clang/15.0.0 -DBUILD_SHARED_LIBS=OFF 
> -DCLANG_LINK_CLANG_DYLIB=ON 
> -DLLVM_DISTRIBUTION_COMPONENTS="clang-cmake-exports;clang-headers;clang-resource-headers;libclang-headers;clang-cpp;libclang;bash-autocomplete;libclang-python-bindings;c-index-test;clang;clang-format;clang-offload-bundler;clang-offload-wrapper;clang-refactor;clang-repl;clang-rename;clang-scan-deps;diagtool;hmaptool;clang-apply-replacements;clang-change-namespace;clang-doc;clang-include-fixer;clang-move;clang-query;clang-reorder-fields;clang-tidy;clang-tidy-headers;clangd;find-all-symbols;modularize;pp-trace;docs-clang-man;docs-clang-tools-man;clang-check;clang-extdef-mapping;scan-build;scan-build-py;scan-view;"
>  
> -DLLVM_TARGETS_TO_BUILD="SystemZ;WebAssembly;BPF;Hexagon;VE;XCore;X86;Sparc;NVPTX;ARM;AVR;Lanai;AMDGPU;Mips;AArch64;PowerPC;MSP430;RISCV"
>  -DLLVM_BUILD_TESTS=no -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON 
> -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=no -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp 
> -DCMAKE_DISABLE_FIND_PACKAGE_CUDA=ON -DCLANG_DEFAULT_CXX_STDLIB= 
> -DCLANG_DEFAULT_RTLIB= -DCLANG_DEFAULT_LINKER= 
> -DCLANG_DEFAULT_PIE_ON_LINUX=yes -DCLANG_DEFAULT_UNWINDLIB= 
> -DCLANG_ENABLE_ARCMT=yes -DCLANG_ENABLE_STATIC_ANALYZER=yes 
> -DPython3_EXECUTABLE=/usr/bin/python3.10 -DLLVM_BUILD_DOCS=ON 
> -DLLVM_ENABLE_SPHINX=ON 
> -DCLANG_INSTALL_SPHINX_HTML_DIR=/usr/share/doc/clang-15.0.0./html 
> -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR=/usr/share/doc/clang-15.0.0./tools-extra
>  -DSPHINX_WARNINGS_AS_ERRORS=OFF 
> -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=/var/tmp/portage/sys-devel/clang-15.0.0./work/clang-tools-extra
>  -DCLANG_INCLUDE_DOCS=ON -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON 
> -DCMAKE_BUILD_TYPE=RelWithDebInfo 
> -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/sys-devel/clang-15.0.0./work/x/y/clang-abi_x86_64.amd64/gentoo_toolchain.cmake
>  /var/tmp/portage/sys-devel/clang-15.0.0./work/clang

This won't work for me because I will need gentoo_common_config.cmake, though I 
would rather work with the shorter reproducer you have provided.

> Though I can reproduce it with much shorter:
>
>   mkdir build
>   cd build
>   cmake ../clang -G Ninja
>
> (matching installed version of LLVM 15 must be on PATH)

Are you sure it should be in PATH? I have added installed LLVM from ToT to a 
directory, put that in path yet CMake still finds 
/usr/lib/llvm-13/cmake/AddLLVM.cmake instead. I can't find any documentation on 
the standalone build, unfortunately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-07-18 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

Thanks @mgorny I was able to get CMake to run. Although I didn't end up with 
the same error as you. I simply had warnings:

  CMake Warning (dev) at /usr/local/lib/cmake/llvm/TableGen.cmake:103 
(add_custom_command):
Policy CMP0116 is not set: Ninja generators transform DEPFILEs from
add_custom_command().  Run "cmake --help-policy CMP0116" for policy
details.  Use the cmake_policy command to set the policy and suppress this
warning.
  Call Stack (most recent call first):
cmake/modules/AddClang.cmake:25 (tablegen)
include/clang/AST/CMakeLists.txt:1 (clang_tablegen)
  This warning is for project developers.  Use -Wno-dev to suppress it.

When running just `cmake ../clang -G Ninja` did you delete CMakeCache.txt? If 
you didn't then perhaps something from the full command you gave stayed around 
and caused the error. I suspect then I will need the full command you have 
supplied above including gentoo_common_config.cmake. Likely I will not need 
gentoo_toolchain.cmake

In D109977#3660778 , @MaskRay wrote:

> Personally I really wish that the build system issue can be fixed in the 
> upcoming 15.0.0 release and encourage distributions to use it to decrease 
> executable sizes.

Me too. For these tools to be installable as symlinks to the llvm driver, 
D127800  will need to land, as well as a 
follow up after that patch. Maybe I could entice you to take a look :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-07-19 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D109977#3662859 , @mgorny wrote:

> The actual problem is that you're passing `${USE_SHARED}` to `llvm_config()` 
> (in `add_llvm_executable`) before it's defined. Moving the definition earlier 
> fixed this error but uncovers another problem:

Thanks for looking into it more. As for what @maskray said this mode won't work 
with `LLVM_TOOL_LLVM_DRIVER_BUILD=On` and it looks like because we were using 
this variable before setting, it was always empty anyway. For the reproducer 
that you gave the following diff works. Do you want to try this diff with the 
full gentoo build that was breaking? If it works then we can commit this.

  diff --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
  index 8e1385e90b82..5563a7848ec3 100644
  --- a/llvm/cmake/modules/AddLLVM.cmake
  +++ b/llvm/cmake/modules/AddLLVM.cmake
  @@ -909,7 +909,7 @@ macro(add_llvm_executable name)
   
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOLS ${name})
   target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB})
  -llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
  +llvm_config(${obj_name} ${LLVM_LINK_COMPONENTS})
 endif()
   
 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D127800: [llvm-driver] Generate symlinks instead of executables for tools

2022-07-19 Thread Alex Brachet 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 rG09d4dbc3829e: [llvm-driver] Generate symlinks instead of 
executables for tools (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127800

Files:
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/CMakeLists.txt
  llvm/tools/llvm-driver/CMakeLists.txt

Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- llvm/tools/llvm-driver/CMakeLists.txt
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -15,11 +15,8 @@
   "${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def"
   "${def_decl}${LLVM_EXTRA_DRIVER_ENTRIES}#undef LLVM_DRIVER_TOOL\n")
 
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-add_llvm_tool(llvm-driver
-  llvm-driver.cpp
-  )
+target_include_directories(llvm-driver PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_sources(llvm-driver PRIVATE llvm-driver.cpp)
 
 set_target_properties(llvm-driver PROPERTIES OUTPUT_NAME llvm)
 
@@ -29,3 +26,13 @@
   # dsymutil uses some CoreFoundation stuff on Darwin...
   target_link_libraries(llvm-driver PRIVATE "-framework CoreFoundation")
 endif(APPLE)
+
+macro(generate_driver_tool_targets)
+  get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
+  get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY LLVM_DRIVER_TOOL_SYMLINKS)
+  foreach(name IN LISTS LLVM_DRIVER_TOOLS LLVM_DRIVER_TOOL_SYMLINKS)
+add_llvm_tool_symlink(${name} llvm-driver ALWAYS_GENERATE)
+# Always generate install targets
+llvm_install_symlink(${name} llvm-driver ALWAYS_GENERATE)
+  endforeach()
+endmacro()
Index: llvm/tools/CMakeLists.txt
===
--- llvm/tools/CMakeLists.txt
+++ llvm/tools/CMakeLists.txt
@@ -21,6 +21,10 @@
   set(LLVM_TOOL_LTO_BUILD Off)
 endif()
 
+if (LLVM_TOOL_LLVM_DRIVER_BUILD)
+  add_llvm_tool(llvm-driver)
+endif()
+
 # Add LTO, llvm-ar, llvm-config, and llvm-profdata before clang, ExternalProject
 # requires targets specified in DEPENDS to exist before the call to
 # ExternalProject_Add.
@@ -58,4 +62,8 @@
   # This is explicitly added at the end _after_ all tool projects so that it can
   # scrape up tools from other projects into itself.
   add_subdirectory(llvm-driver)
+  # This must be here otherwise CMake complains in add_llvm_tool_symlink that
+  # it can't add_custom_command that happens after llvm-driver is built because
+  # llvm-driver was not created in that directory.
+  generate_driver_tool_targets()
 endif()
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -863,12 +863,8 @@
   endif()
 endmacro(add_llvm_library name)
 
-macro(add_llvm_executable name)
-  cmake_parse_arguments(ARG
-"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS;GENERATE_DRIVER"
-"ENTITLEMENTS;BUNDLE_PATH"
-"DEPENDS"
-${ARGN})
+macro(generate_llvm_objects name)
+  cmake_parse_arguments(ARG "GENERATE_DRIVER" "" "DEPENDS" ${ARGN})
 
   llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
 
@@ -911,7 +907,15 @@
 target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB})
 llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
   endif()
+endmacro()
 
+macro(add_llvm_executable name)
+  cmake_parse_arguments(ARG
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
+"ENTITLEMENTS;BUNDLE_PATH"
+""
+${ARGN})
+  generate_llvm_objects(${name} ${ARG_UNPARSED_ARGUMENTS})
   add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
 
   if(XCODE)
@@ -1276,30 +1280,36 @@
 endif()
 
 macro(add_llvm_tool name)
+  cmake_parse_arguments(ARG "DEPENDS;GENERATE_DRIVER" "" "" ${ARGN})
   if( NOT LLVM_BUILD_TOOLS )
 set(EXCLUDE_FROM_ALL ON)
   endif()
-  add_llvm_executable(${name} ${ARGN})
-
-  if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
-if( LLVM_BUILD_TOOLS )
-  get_target_export_arg(${name} LLVM export_to_llvmexports)
-  install(TARGETS ${name}
-  ${export_to_llvmexports}
-  RUNTIME DESTINATION ${LLVM_TOOLS_INSTALL_DIR}
-  COMPONENT ${name})
-
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
+  if(ARG_GENERATE_DRIVER AND LLVM_TOOL_LLVM_DRIVER_BUILD)
+generate_llvm_objects(${name} ${ARGN})
+add_custom_target(${name} DEPENDS llvm-driver)
+  else()
+add_llvm_executable(${name} ${ARGN})
+
+if ( ${name} IN_LIST L

[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-07-22 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D128465#3672515 , @MaskRay wrote:

> I am still seeing the
>
>   zstdConfig.cmake
>   zstd-config.cmake
>
> warning. @ckissane @phosek will you fix it? :)

I've quieted the warnings in 
https://github.com/llvm/llvm-project/commit/a71a01bc10d509bd4e746e7d277c4613ef886875,
 though I'm just now seeing @phosek's suggestion to use `CONFIG` I'm not sure 
what that does


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[PATCH] D136703: [Driver][Fuchsia] Make -mfix-cortex-a53-835769 default when targeting Fuchsia

2022-10-25 Thread Alex Brachet 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 rG4981a186b3aa: [Driver][Fuchsia] Make -mfix-cortex-a53-835769 
default when targeting Fuchsia (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136703

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-fix-cortex-a53-835769.c


Index: clang/test/Driver/aarch64-fix-cortex-a53-835769.c
===
--- clang/test/Driver/aarch64-fix-cortex-a53-835769.c
+++ clang/test/Driver/aarch64-fix-cortex-a53-835769.c
@@ -8,6 +8,12 @@
 // RUN: %clang -target aarch64-android-eabi %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-YES %s
 
+// RUN: %clang --target=aarch64-fuchsia %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-YES %s
+
+// RUN: %clang --target=aarch64-fuchsia -mcpu=cortex-a73 %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEF %s
+
 // CHECK-DEF-NOT: "{[+-]}fix-cortex-a53-835769"
 // CHECK-YES: "+fix-cortex-a53-835769"
 // CHECK-NO: "-fix-cortex-a53-835769"
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "AArch64.h"
+#include "../CommonArgs.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -615,6 +616,10 @@
   } else if (Triple.isAndroid()) {
 // Enabled A53 errata (835769) workaround by default on android
 Features.push_back("+fix-cortex-a53-835769");
+  } else if (Triple.isOSFuchsia()) {
+std::string CPU = getCPUName(D, Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  Features.push_back("+fix-cortex-a53-835769");
   }
 
   if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))


Index: clang/test/Driver/aarch64-fix-cortex-a53-835769.c
===
--- clang/test/Driver/aarch64-fix-cortex-a53-835769.c
+++ clang/test/Driver/aarch64-fix-cortex-a53-835769.c
@@ -8,6 +8,12 @@
 // RUN: %clang -target aarch64-android-eabi %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-YES %s
 
+// RUN: %clang --target=aarch64-fuchsia %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-YES %s
+
+// RUN: %clang --target=aarch64-fuchsia -mcpu=cortex-a73 %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEF %s
+
 // CHECK-DEF-NOT: "{[+-]}fix-cortex-a53-835769"
 // CHECK-YES: "+fix-cortex-a53-835769"
 // CHECK-NO: "-fix-cortex-a53-835769"
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "AArch64.h"
+#include "../CommonArgs.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -615,6 +616,10 @@
   } else if (Triple.isAndroid()) {
 // Enabled A53 errata (835769) workaround by default on android
 Features.push_back("+fix-cortex-a53-835769");
+  } else if (Triple.isOSFuchsia()) {
+std::string CPU = getCPUName(D, Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  Features.push_back("+fix-cortex-a53-835769");
   }
 
   if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135340: [PGO] Make emitted symbols hidden

2022-10-25 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 470597.
abrachet added a comment.

Use sed to filter nm output instead of grep. grep exits with exit code 1 
because there are no matching lines. This is expected because there are no more 
external symbols other than `_main` and `__mh_execute_header`, note `_foo` has 
been dead stripped.


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

https://reviews.llvm.org/D135340

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/InstrProfilingNameVar.c
  compiler-rt/lib/profile/InstrProfilingVersionVar.c
  compiler-rt/test/profile/instrprof-darwin-dead-strip.c
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/comdat_internal.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/filename.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll
  llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll

Index: llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
===
--- llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
+++ llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
@@ -17,11 +17,11 @@
 ; RUN: llvm-dis %t.2.4.opt.bc -o - | FileCheck %s --check-prefixes=CSGEN,NOPREVAILING
 
 ;; Prevailing __llvm_profile_raw_version is kept by LTO.
-; PREVAILING: @__llvm_profile_raw_version = constant i64
+; PREVAILING: @__llvm_profile_raw_version = hidden constant i64
 
 ;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
 ;; declaration is retained.
-; NOPREVAILING: @__llvm_profile_raw_version = external constant i64
+; NOPREVAILING: @__llvm_profile_raw_version = external hidden constant i64
 ; CSGEN: @__profc_
 ; CSGEN: @__profd_
 
Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -8,7 +8,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_test_switch = private constant [11 x i8] c"test_switch"
 
 define void @test_switch(i32 %i) {
Index: llvm/test/Transforms/PGOProfile/single_bb.ll
===
--- llvm/test/Transforms/PGOProfile/single_bb.ll
+++ llvm/test/Transforms/PGOProfile/single_bb.ll
@@ -3,7 +3,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_single_bb = private constant [9 x i8] c"single_bb"
 
 define i32 @single_bb() {
Index: llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
===
--- llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
+++ llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
@@ -11,11 +11,11 @@
 ; RUN: llvm-dis %t.0.0.preopt.bc -o - | FileCheck %s --check-prefix=IRPGOBE
 
 ;; Before LTO, we should have the __llvm_profile_raw_version definition.
-; IRPGOPRE: @__llvm_profile_raw_version = constant i64
+; IRPGOPRE: @__llvm_profile_raw_version = hidden constant i64
 
 ;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
 ;; declaration is retained.
-; IRPGOBE: @__llvm_profile_raw_version = external constant i64
+; IRPGOBE: @__llvm_profile_raw_version = external hidden constant i64
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Transforms/PGOProfile/loop2.ll
===
--- llvm/test/Transforms/PGOProfile/loop2.ll
+++ llvm/test/Transforms/PGOProfile/loop2.ll
@@ -8,7 +8,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_test_nested_for = private constant [15 x i8] c"test_nested_for"
 
 define i32 @test_nested_for(i32 %r, i32 %s) {
Index: llvm/test/Transforms/PGOProfile/loop1.ll
===
--- llvm/te

[PATCH] D135340: [PGO] Make emitted symbols hidden

2022-10-25 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D135340#3882280 , @thakis wrote:

> This is still breaking `   Profile-x86_64 :: instrprof-darwin-dead-strip.c` 
> on mac. I'm reverting this again for now.

Sorry about that, I've tested it locally and it should be good to go now. But 
I'll give some time before resubmitting if you'd like to look it over.


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

https://reviews.llvm.org/D135340

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


[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-08-16 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added subscribers: mcgrathr, abrachet.
abrachet added a comment.

This is breaking us.

  template  struct S; // #1
  
  template  struct S {}; // #2

The following compiled before but is now broken, (we use 
`-fclang-abi-compat=13.0`). We get a warning from 
`-Winvalid-partial-specialization`

This change _does_ make https://eel.is/c++draft/temp.func.order#example-5 work, 
ie for function overload resolution but regresses the type deduction example 
above.

There seem to be examples in the standard that suggest #2 is more specialized. 
@mcgrathr found 
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1432 and 
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1395 among 
others. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

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


[PATCH] D128745: [c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

2022-08-16 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D128745#3727715 , @ychen wrote:

> In D128745#3727697 , @abrachet 
> wrote:
>
>> This is breaking us.
>>
>>   template  struct S; // #1
>>   
>>   template  struct S {}; // #2
>>
>> The following compiled before but is now broken, (we use 
>> `-fclang-abi-compat=13.0`). We get a warning from 
>> `-Winvalid-partial-specialization`
>>
>> This change _does_ make https://eel.is/c++draft/temp.func.order#example-5 
>> work, ie for function overload resolution but regresses the type deduction 
>> example above.
>>
>> There seem to be examples in the standard that suggest #2 is more 
>> specialized. @mcgrathr found 
>> https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1432 and 
>> https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1395 among 
>> others. WDYT?
>
> I tried your test case but was unable to reproduce the issue. Is this the 
> complete test case? I'm asking because the provided test case does not 
> involve deduction.

Just that input is enough to get the error. I did `clang++ test.cpp 
-fsyntax-only -fclang-abi-compat=14.0`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

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


[PATCH] D117616: GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-08-18 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

While digging around failures we were seeing related to this I found some 
behavior that diverges from gcc. See https://godbolt.org/z/qe18Wh4jf


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117616

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


[PATCH] D131214: [clang][Driver] Pass correct reproduce flag to lld-link

2022-08-18 Thread Alex Brachet via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
abrachet marked an inline comment as done.
Closed by commit rG377dddf4a083: [clang][Driver] Pass correct reproduce flag to 
lld-link (authored by abrachet).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D131214?vs=450836&id=453763#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131214

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/lld-repro.c


Index: clang/test/Driver/lld-repro.c
===
--- clang/test/Driver/lld-repro.c
+++ clang/test/Driver/lld-repro.c
@@ -1,6 +1,7 @@
-// REQUIRES: lld, x86-registered-target
+// REQUIRES: lld
+// UNSUPPORTED: ps4
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +14,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1631,7 +1631,11 @@
 const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
 Command NewLLDInvocation = Cmd;
 llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-ArgList.push_back(Saver.save(Twine{"--reproduce="} + TmpName).data());
+StringRef ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce=";
+ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
 NewLLDInvocation.replaceArguments(std::move(ArgList));
 
 // Redirect stdout/stderr to /dev/null.


Index: clang/test/Driver/lld-repro.c
===
--- clang/test/Driver/lld-repro.c
+++ clang/test/Driver/lld-repro.c
@@ -1,6 +1,7 @@
-// REQUIRES: lld, x86-registered-target
+// REQUIRES: lld
+// UNSUPPORTED: ps4
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +14,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are located at:
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1631,7 +1631,11 @@
 const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
 Command NewLLDInvocation = Cmd;
 llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-ArgList.push_back(Saver.save(Twine{"--reproduce="} + TmpName).data());
+StringRef ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce

[PATCH] D131214: [clang][Driver] Pass correct reproduce flag to lld-link

2022-08-18 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D131214#3733317 , @thakis wrote:

> The removal of the explicit target broke the test on Mac: 
> http://45.33.8.238/macm1/42754/step_7.txt
>
> (Just need to be more permissive about leading underscores)
>
> Please take a look and revert for now if it takes a while to fix.

Thanks should be fixed by 
https://github.com/llvm/llvm-project/commit/c175d80be2ed496debb98d47f315aa5e60116768


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131214

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


[PATCH] D134289: [Driver] Make --execute-only the default for aarch64-fuchsia

2022-09-20 Thread Alex Brachet 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 rG16f735d2fbe8: [Driver] Make --execute-only the default for 
aarch64-fuchsia (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D134289?vs=461609&id=461637#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134289

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -41,7 +41,7 @@
 // CHECK: "-pie"
 // CHECK: "--build-id"
 // CHECK: "--hash-style=gnu"
-// CHECK-AARCH64: "--fix-cortex-a53-843419"
+// CHECK-AARCH64: "--execute-only" "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
 // CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -87,6 +87,8 @@
   }
 
   if (ToolChain.getArch() == llvm::Triple::aarch64) {
+CmdArgs.push_back("--execute-only");
+
 std::string CPU = getCPUName(D, Args, Triple);
 if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
   CmdArgs.push_back("--fix-cortex-a53-843419");


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -41,7 +41,7 @@
 // CHECK: "-pie"
 // CHECK: "--build-id"
 // CHECK: "--hash-style=gnu"
-// CHECK-AARCH64: "--fix-cortex-a53-843419"
+// CHECK-AARCH64: "--execute-only" "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
 // CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -87,6 +87,8 @@
   }
 
   if (ToolChain.getArch() == llvm::Triple::aarch64) {
+CmdArgs.push_back("--execute-only");
+
 std::string CPU = getCPUName(D, Args, Triple);
 if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
   CmdArgs.push_back("--fix-cortex-a53-843419");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134289: [Driver] Make --execute-only the default for aarch64-fuchsia

2022-09-20 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added inline comments.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:93
   CmdArgs.push_back("--fix-cortex-a53-843419");
+CmdArgs.push_back("--execute-only");
   }

mcgrathr wrote:
> This is a little confusing to read when it's after the other lines.
> I'd put it first in the block with a blank line after it.
> 
Fixed in commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134289

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


[PATCH] D134640: Unwind-tables: move back to original logic outline for kind.

2022-09-26 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added a comment.
This revision is now accepted and ready to land.

Thanks! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134640

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


[PATCH] D134640: Unwind-tables: move back to original logic outline for kind.

2022-09-28 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

Ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134640

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


[PATCH] D132416: [Driver][Fuchsia] Add default linker flags

2022-09-30 Thread Alex Brachet 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 rG5dfc8ebee5d6: [Driver][Fuchsia] Add default linker flags 
(authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D132416?vs=454924&id=464266#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132416

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.c
  clang/test/Driver/fuchsia.cpp

Index: clang/test/Driver/fuchsia.cpp
===
--- clang/test/Driver/fuchsia.cpp
+++ clang/test/Driver/fuchsia.cpp
@@ -2,32 +2,42 @@
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clangxx -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform -fuse-ld=gold 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LD,CHECK-X86_64 %s
 // RUN: %clangxx -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
 // RUN: %clangxx -### %s --target=riscv64-unknown-fuchsia \
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
 // RUN: %clangxx -### %s --target=x86_64-fuchsia \
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
 // RUN: %clangxx -### %s --target=aarch64-fuchsia \
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
 // RUN: %clangxx -### %s --target=riscv64-fuchsia \
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
 // CHECK: "-cc1"
 // CHECK-X86_64: "-triple" "x86_64-unknown-fuchsia"
 // CHECK-AARCH64: "-triple" "aarch64-unknown-fuchsia"
@@ -40,7 +50,8 @@
 // CHECK-RISCV64: "-internal-isystem" "{{.*[/\\]}}include{{/|}}riscv64-unknown-fuchsia{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-isystem" "{{.*[/\\]}}include{{/|}}c++{{/|}}v1"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
-// CHECK: {{.*}}ld.lld{{.*}}" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments"
+// CHECK-LLD: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr"
+// CHECK-LD: {{.*}}ld.gold{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "combreloc" "-z" "text"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -1,27 +1,35 @@
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixe

[PATCH] D134979: [llvm-driver][NFC] Simplify handling of tool symlinks

2022-10-01 Thread Alex Brachet 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 rGaa1c58b9c67a: [llvm-driver][NFC] Simplify handling of tool 
symlinks (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134979

Files:
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/llvm-driver/CMakeLists.txt


Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- llvm/tools/llvm-driver/CMakeLists.txt
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -5,15 +5,17 @@
 
 foreach(tool ${LLVM_DRIVER_TOOLS})
   string(REPLACE "-" "_" tool_entry ${tool})
-  string(REPLACE "llvm-" "" tool ${tool})
-  set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n")
+  get_property(tool_aliases GLOBAL PROPERTY LLVM_DRIVER_TOOL_ALIASES_${tool})
+  foreach(alias ${tool_aliases})
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${alias})
+string(REPLACE "llvm-" "" alias ${alias})
+set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
+  endforeach()
 endforeach()
 
-get_property(LLVM_EXTRA_DRIVER_ENTRIES GLOBAL PROPERTY 
LLVM_EXTRA_DRIVER_ENTRIES)
-
 file(WRITE
   "${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def"
-  "${def_decl}${LLVM_EXTRA_DRIVER_ENTRIES}#undef LLVM_DRIVER_TOOL\n")
+  "${def_decl}#undef LLVM_DRIVER_TOOL\n")
 
 target_include_directories(llvm-driver PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 target_sources(llvm-driver PRIVATE llvm-driver.cpp)
@@ -28,9 +30,8 @@
 endif(APPLE)
 
 macro(generate_driver_tool_targets)
-  get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY 
LLVM_DRIVER_TOOL_SYMLINKS)
-  foreach(name IN LISTS LLVM_DRIVER_TOOLS LLVM_DRIVER_TOOL_SYMLINKS)
+  foreach(name ${LLVM_DRIVER_TOOL_SYMLINKS})
 add_llvm_tool_symlink(${name} llvm-driver ALWAYS_GENERATE)
 # Always generate install targets
 llvm_install_symlink(LLVM ${name} llvm-driver ALWAYS_GENERATE)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -916,6 +916,7 @@
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_OBJLIBS "${obj_name}")
 
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOLS ${name})
+  set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${name} 
${name})
   target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB})
   llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
 endif()
@@ -2032,7 +2033,6 @@
 function(llvm_install_symlink project name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
-set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
 return()
   endif()
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
@@ -2079,11 +2079,7 @@
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
 
   if (${target} IN_LIST LLVM_DRIVER_TOOLS)
-string(REPLACE "-" "_" tool_entry ${target})
-string(REPLACE "-" "_" key ${link_name})
-string(REPLACE "llvm-" "" tool_name ${link_name})
-set_property(GLOBAL APPEND_STRING PROPERTY
- LLVM_EXTRA_DRIVER_ENTRIES "LLVM_DRIVER_TOOL(\"${tool_name}\", 
${tool_entry})\n")
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${target} 
${link_name})
   endif()
   set(dest_binary "$")
 
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -182,7 +182,7 @@
 macro(add_clang_symlink name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
-set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} 
${name})
   else()
 llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE)
 # Always generate install targets


Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- llvm/tools/llvm-driver/CMakeLists.txt
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -5,15 +5,17 @@
 
 foreach(tool ${LLVM_DRIVER_TOOLS})
   string(REPLACE "-" "_" tool_entry ${tool})
-  string(REPLACE "llvm-" "" tool ${tool})
-  set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n")
+  get_property(tool_aliases GLOBAL PROPERTY LLVM_DRIVER_TOOL_ALIASES_${tool})
+  foreach(alias ${tool_al

[PATCH] D131310: [llvm-driver] Support single distributions

2022-10-01 Thread Alex Brachet 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 rG3b0df701b0d9: [llvm-driver] Support single distributions 
(authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131310

Files:
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/LLVMDistributionSupport.cmake


Index: llvm/cmake/modules/LLVMDistributionSupport.cmake
===
--- llvm/cmake/modules/LLVMDistributionSupport.cmake
+++ llvm/cmake/modules/LLVMDistributionSupport.cmake
@@ -244,6 +244,8 @@
 set(distributions "")
   endif()
 
+  get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY 
LLVM_DRIVER_TOOL_SYMLINKS)
+
   foreach(distribution ${distributions})
 if(distribution STREQUAL "")
   set(distribution_target distribution)
@@ -268,12 +270,16 @@
 
   if(TARGET install-${target})
 add_dependencies(install-${distribution_target} install-${target})
+  elseif(TARGET install-llvm-driver AND ${target} IN_LIST 
LLVM_DRIVER_TOOL_SYMLINKS)
+add_dependencies(install-${distribution_target} install-llvm-driver)
   else()
 message(SEND_ERROR "Specified distribution component '${target}' 
doesn't have an install target")
   endif()
 
   if(TARGET install-${target}-stripped)
 add_dependencies(install-${distribution_target}-stripped 
install-${target}-stripped)
+  elseif(TARGET install-llvm-driver-stripped AND ${target} IN_LIST 
LLVM_DRIVER_TOOL_SYMLINKS)
+add_dependencies(install-${distribution_target}-stripped 
install-llvm-driver-stripped)
   else()
 message(SEND_ERROR
 "Specified distribution component '${target}' doesn't have an 
install-stripped target."
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -910,7 +910,9 @@
 
 list(APPEND ALL_FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-driver.cpp)
 
-if (LLVM_TOOL_LLVM_DRIVER_BUILD)
+if (LLVM_TOOL_LLVM_DRIVER_BUILD
+AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+   )
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_COMPONENTS 
${LLVM_LINK_COMPONENTS})
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_DEPS ${ARG_DEPENDS} 
${LLVM_COMMON_DEPENDS})
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_OBJLIBS "${obj_name}")
@@ -1301,7 +1303,10 @@
   if( NOT LLVM_BUILD_TOOLS )
 set(EXCLUDE_FROM_ALL ON)
   endif()
-  if(ARG_GENERATE_DRIVER AND LLVM_TOOL_LLVM_DRIVER_BUILD)
+  if(ARG_GENERATE_DRIVER
+ AND LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 generate_llvm_objects(${name} ${ARGN})
 add_custom_target(${name} DEPENDS llvm-driver)
   else()
@@ -2032,7 +2037,10 @@
 
 function(llvm_install_symlink project name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
-  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND ${dest} IN_LIST LLVM_DRIVER_TOOLS
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${dest} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 return()
   endif()
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -153,7 +153,10 @@
   if (NOT CLANG_BUILD_TOOLS)
 set(EXCLUDE_FROM_ALL ON)
   endif()
-  if(ARG_GENERATE_DRIVER AND LLVM_TOOL_LLVM_DRIVER_BUILD)
+  if(ARG_GENERATE_DRIVER
+ AND LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 set(get_obj_args ${ARGN})
 list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
 generate_llvm_objects(${name} ${get_obj_args})
@@ -181,7 +184,10 @@
 
 macro(add_clang_symlink name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
-  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND ${dest} IN_LIST LLVM_DRIVER_TOOLS
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${dest} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} 
${name})
   else()
 llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE)


Index: llvm/cmake/modules/LLVMDistributionSupport.cmake
===
--- llvm/cmake/modules/LLVMDi

[PATCH] D135471: [CMake] Drop libLTO and switch to PIE for Fuchsia toolchain

2022-10-07 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added a comment.
This revision is now accepted and ready to land.

Nice thats 71mb saved :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135471

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


[PATCH] D135340: [PGO] Make emitted symbols hidden

2022-10-13 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecac223b0e4b: [PGO] Make emitted symbols hidden (authored by 
abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135340

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/comdat_internal.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/filename.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll
  llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll

Index: llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
===
--- llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
+++ llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
@@ -17,11 +17,11 @@
 ; RUN: llvm-dis %t.2.4.opt.bc -o - | FileCheck %s --check-prefixes=CSGEN,NOPREVAILING
 
 ;; Prevailing __llvm_profile_raw_version is kept by LTO.
-; PREVAILING: @__llvm_profile_raw_version = constant i64
+; PREVAILING: @__llvm_profile_raw_version = hidden constant i64
 
 ;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
 ;; declaration is retained.
-; NOPREVAILING: @__llvm_profile_raw_version = external constant i64
+; NOPREVAILING: @__llvm_profile_raw_version = external hidden constant i64
 ; CSGEN: @__profc_
 ; CSGEN: @__profd_
 
Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -8,7 +8,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_test_switch = private constant [11 x i8] c"test_switch"
 
 define void @test_switch(i32 %i) {
Index: llvm/test/Transforms/PGOProfile/single_bb.ll
===
--- llvm/test/Transforms/PGOProfile/single_bb.ll
+++ llvm/test/Transforms/PGOProfile/single_bb.ll
@@ -3,7 +3,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_single_bb = private constant [9 x i8] c"single_bb"
 
 define i32 @single_bb() {
Index: llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
===
--- llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
+++ llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
@@ -11,11 +11,11 @@
 ; RUN: llvm-dis %t.0.0.preopt.bc -o - | FileCheck %s --check-prefix=IRPGOBE
 
 ;; Before LTO, we should have the __llvm_profile_raw_version definition.
-; IRPGOPRE: @__llvm_profile_raw_version = constant i64
+; IRPGOPRE: @__llvm_profile_raw_version = hidden constant i64
 
 ;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
 ;; declaration is retained.
-; IRPGOBE: @__llvm_profile_raw_version = external constant i64
+; IRPGOBE: @__llvm_profile_raw_version = external hidden constant i64
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Transforms/PGOProfile/loop2.ll
===
--- llvm/test/Transforms/PGOProfile/loop2.ll
+++ llvm/test/Transforms/PGOProfile/loop2.ll
@@ -8,7 +8,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_test_nested_for = private constant [15 x i8] c"test_nested_for"
 
 define i32 @test_nested_for(i32 %r, i32 %s) {
Index: llvm/test/Transforms/PGOProfile/loop1.ll
===
--- llvm/test/Transforms/PGOProfile/loop1.ll
+++ llvm/test/Transforms/PGOProfile/loop1.ll
@@ -9,7 +9,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_

[PATCH] D135916: Itanium ABI: Pack non-pod members of packed types

2022-10-14 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135916

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


[PATCH] D128567: [WIP][Fuchsia] Set LLVM_TOOL_LLD_BUILD to allow some extra runtimes tests to run

2022-10-17 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D128567#3863178 , @aeubanks wrote:

> I've noticed that we're skipping compiler-rt tests with `REQUIRED: 
> lld-available` because `LLVM_TOOL_LLD_BUILD` needs to be defined. any update 
> on the proposed alternative?

I think the canonical way this is done throughout the code base is with

  from lit.llvm import llvm_config
  
  if llvm_config.use_lld(required=False):
  config.available_features.add('lld')

Though, what I think we don't do currently here or elsewhere is conditionally 
add test deps on `lld` if it is specified in `LLVM_ENABLE_PROJECTS`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128567

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


[PATCH] D135340: [PGO] Make emitted symbols hidden

2022-10-17 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 468425.
abrachet added a comment.

The error @zequanwu ran into happens only on MacOS because it this Darwin-only 
test happens to be the only one that tests instrprof with no code. 
`__llvm_profile_filename` doesn't get emitted in this case so it ends up 
pulling in the one in libprofile.a which is not hidden. I've changed this to 
make `__llvm_profile_filename` hidden, as well as `__llvm_profile_raw_version` 
even though that symbol is always emitted.

@cishida, to verify, the comment in InstrProfilingVersionVar.c said that 
`__llvm_profile_raw_version` was not hidden on Apple platforms because of TAPI, 
it should be ok to mark this as hidden in libprofile.a, right? I'm guessing 
this should be no different than when the symbol is emitted by llvm.


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

https://reviews.llvm.org/D135340

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/InstrProfilingNameVar.c
  compiler-rt/lib/profile/InstrProfilingVersionVar.c
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/comdat_internal.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll
  llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll

Index: llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
===
--- llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
+++ llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll
@@ -17,11 +17,11 @@
 ; RUN: llvm-dis %t.2.4.opt.bc -o - | FileCheck %s --check-prefixes=CSGEN,NOPREVAILING
 
 ;; Prevailing __llvm_profile_raw_version is kept by LTO.
-; PREVAILING: @__llvm_profile_raw_version = constant i64
+; PREVAILING: @__llvm_profile_raw_version = hidden constant i64
 
 ;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
 ;; declaration is retained.
-; NOPREVAILING: @__llvm_profile_raw_version = external constant i64
+; NOPREVAILING: @__llvm_profile_raw_version = external hidden constant i64
 ; CSGEN: @__profc_
 ; CSGEN: @__profd_
 
Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -8,7 +8,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_test_switch = private constant [11 x i8] c"test_switch"
 
 define void @test_switch(i32 %i) {
Index: llvm/test/Transforms/PGOProfile/single_bb.ll
===
--- llvm/test/Transforms/PGOProfile/single_bb.ll
+++ llvm/test/Transforms/PGOProfile/single_bb.ll
@@ -3,7 +3,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
+; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
 ; GEN: @__profn_single_bb = private constant [9 x i8] c"single_bb"
 
 define i32 @single_bb() {
Index: llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
===
--- llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
+++ llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
@@ -11,11 +11,11 @@
 ; RUN: llvm-dis %t.0.0.preopt.bc -o - | FileCheck %s --check-prefix=IRPGOBE
 
 ;; Before LTO, we should have the __llvm_profile_raw_version definition.
-; IRPGOPRE: @__llvm_profile_raw_version = constant i64
+; IRPGOPRE: @__llvm_profile_raw_version = hidden constant i64
 
 ;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
 ;; declaration is retained.
-; IRPGOBE: @__llvm_profile_raw_version = external constant i64
+; IRPGOBE: @__llvm_profile_raw_version = external hidden constant i64
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Transforms/PGOProfile/loop2.ll
===
--- llvm/test/Transforms/PGOProfile/loop2.ll
+++ llvm/test/Transforms/PGOProfile/loop2.ll
@@ -8,7 +8,7 @@
 target triple = "x86_64-unknown-linux-gnu"
 
 ; GEN: $__llvm_profile_raw_version = comdat any
-; GEN: @__llvm_profile_raw_version =

[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-11-02 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3902789 , @thakis wrote:

> I noticed that when using `-fcrash-diagnostics=all` and the linker crashes, 
> clang creates both preprocessor and linker repros:
>
>   clang: note: diagnostic msg: 
> /var/folders/w6/wpbtszrs7jl9dc9l5qtdkvg0gn/T/main-241332.c
>   clang: note: diagnostic msg: 
> /var/folders/w6/wpbtszrs7jl9dc9l5qtdkvg0gn/T/linker-crash-945b07.tar
>   clang: note: diagnostic msg: 
> /var/folders/w6/wpbtszrs7jl9dc9l5qtdkvg0gn/T/main-241332.sh
>
> Is that intentional? I would've expected to only get the linker repro when 
> the linker crashes.

I didn't really make a conscious decision one way or the other. I guess 
reproing all jobs leading to a crash somewhat makes sense, though it also 
doesn't seem that helpful to get the preprocessed source file. I'll send out a 
patch to fix this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D120175: [Driver] Re-run lld with --reproduce when it crashes

2022-11-02 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120175#3902838 , @thakis wrote:

> Great, thanks :)
>
> For context, we're trying to use this flag In Production to try and debug a 
> linker crash, but making the compiler repro failed for some reason – and then 
> we wondered why that step has to happen at all :)

Nice, I'm happy folks are using (or trying to use) this in production :). We've 
found that it has saved us quite a bit of time.

D137289  is up to stop generating the 
preprocessed sources for linker crashes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120175

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


[PATCH] D137289: [Driver] Don't preprocess source files when reproducing linker crashes

2022-11-02 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78ed64d89fd6: [Driver] Don't preprocess source files 
when reproducing linker crashes (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137289

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/lld-repro.c

Index: clang/test/Driver/lld-repro.c
===
--- clang/test/Driver/lld-repro.c
+++ clang/test/Driver/lld-repro.c
@@ -1,22 +1,28 @@
 // REQUIRES: lld
 // UNSUPPORTED: ps4, ps5
 
-// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: echo "-nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t" \
+// RUN:   | sed -e 's/\\//g' > %t.rsp
+
+// RUN: not %clang %s @%t.rsp -fcrash-diagnostics=all 2>&1 \
+// RUN:   | FileCheck %s
+
+// Test that the reproducer can still be created even when the input source cannot be preprocessed
+// again, like when reading from stdin.
+// RUN: not %clang -x c - @%t.rsp -fcrash-diagnostics=all 2>&1 < %s \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
 // CHECK: error: undefined symbol: {{_?}}a
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.c
 // CHECK-NEXT: note: diagnostic msg: {{.*}}linker-crash-{{.*}}.tar
-// CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.sh
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s @%t.rsp -fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s @%t.rsp 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are located at:
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1527,6 +1527,11 @@
   return false;
 }
 
+static const char BugReporMsg[] =
+"\n\n\n"
+"PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
+"Preprocessed source(s) and associated run script(s) are located at:";
+
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
@@ -1582,6 +1587,29 @@
   // Suppress tool output.
   C.initCompilationForDiagnostics();
 
+  // If lld failed, rerun it again with --reproduce.
+  if (IsLLD) {
+const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
+Command NewLLDInvocation = Cmd;
+llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
+StringRef ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce=";
+ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
+NewLLDInvocation.replaceArguments(std::move(ArgList));
+
+// Redirect stdout/stderr to /dev/null.
+NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
+Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
+Diag(clang::diag::note_drv_command_failed_diag_msg) << TmpName;
+Diag(clang::diag::note_drv_command_failed_diag_msg)
+<< "\n\n";
+if (Report)
+  Report->TemporaryFiles.push_back(TmpName);
+return;
+  }
+
   // Construct the list of inputs.
   InputList Inputs;
   BuildInputs(C.getDefaultToolChain(), C.getArgs(), Inputs);
@@ -1659,22 +1687,6 @@
 return;
   }
 
-  // If lld failed, rerun it again with --reproduce.
-  if (IsLLD) {
-const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
-Command NewLLDInvocation = Cmd;
-llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-StringRef ReproduceOption =
-C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
-? "/reproduce:"
-: "--reproduce=";
-ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
-NewLLDInvocation.replaceArguments(std::move(ArgList));
-
-// Redirect stdout/stderr to /dev/null.
-NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
-  }
-
   const ArgStringList &TempFiles = C.getTempFiles();
   if (TempFiles.empty()) {
 Diag(clang::diag::note_drv_command_failed_diag_ms

[PATCH] D136554: Implement CWG2631

2022-11-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

Hi, we're hitting an assertion failure after this patch

  llvm-project/clang/lib/Sema/SemaDecl.cpp:15589: Decl 
*clang::Sema::ActOnFinishFunctionBody(Decl *, Stmt *, bool): Assertion 
`MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking"' 
failed.

Here is a reproducer 
https://storage.googleapis.com/fuchsia-artifacts/builds/8798414214460746113/build-debug/clang-crashreports/symbol_server_unittest-48a521.cpp
 and 
https://storage.googleapis.com/fuchsia-artifacts/builds/8798414214460746113/build-debug/clang-crashreports/symbol_server_unittest-48a521.sh
 unfortunately creduce was taking too long before I gave up on it, so sorry it 
hasn't been reduced at all.

I've verified that with this reverted the problem goes away. Could we revert 
unless there is a quick fix forward?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D136554: Implement CWG2631

2022-11-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D136554#3909198 , @cor3ntin wrote:

> In D136554#3909196 , @abrachet 
> wrote:
>
>> Hi, we're hitting an assertion failure after this patch
>>
>>   llvm-project/clang/lib/Sema/SemaDecl.cpp:15589: Decl 
>> *clang::Sema::ActOnFinishFunctionBody(Decl *, Stmt *, bool): Assertion 
>> `MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking"' 
>> failed.
>>
>> Here is a reproducer 
>> https://storage.googleapis.com/fuchsia-artifacts/builds/8798414214460746113/build-debug/clang-crashreports/symbol_server_unittest-48a521.cpp
>>  and 
>> https://storage.googleapis.com/fuchsia-artifacts/builds/8798414214460746113/build-debug/clang-crashreports/symbol_server_unittest-48a521.sh
>>  unfortunately creduce was taking too long before I gave up on it, so sorry 
>> it hasn't been reduced at all.
>>
>> I've verified that with this reverted the problem goes away. Could we revert 
>> unless there is a quick fix forward?
>
> Thanks for reporting that. Did you tried a more recent commit? We fixed that 
> issue today. (Along with z couple additional issues)

Yes, this happens at HEAD (currently ba65584d 
)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D137269: [Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms.

2022-11-09 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

I believe this patch might be the cause of some assertion failures we are 
seeing in a two stage lto build, as it's only happening for arm64-darwin. See 
https://ci.chromium.org/ui/p/fuchsia/builders/prod/clang-mac-xarm64/b8798097341668696785/overview
 and it's corresponding build logs 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8798097341668696785/+/u/clang/build/stdout

  [4060/4274](20) Linking CXX executable bin/clang-refactor
  FAILED: bin/clang-refactor 
  : && /opt/s/w/ir/x/w/staging/llvm_build/./bin/clang++ 
--target=arm64-apple-darwin 
--sysroot=/opt/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
 -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -flto 
-ffile-prefix-map=/opt/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins=../staging/llvm_build/tools/clang/stage2-bins
 -ffile-prefix-map=/opt/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes 
-fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -isysroot 
/opt/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
 -mmacosx-version-min=10.13 -Wl,-headerpad_max_install_names -nostdlib++ 
/opt/s/w/ir/x/w/staging/llvm_build/lib/libc++.a -stdlib=libc++ 
-static-libstdc++ -fno-pie -fuse-ld=lld -Wl,--color-diagnostics -flto 
-Wl,-lto_library -Wl,/opt/s/w/ir/x/w/staging/llvm_build/./lib/libLTO.dylib
-Wl,-dead_strip 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
 -o bin/clang-refactor  -Wl,-rpath,@loader_path/../lib  lib/libLLVMOption.a  
lib/libLLVMSupport.a  lib/libclangAST.a  lib/libclangBasic.a  
lib/libclangFormat.a  lib/libclangFrontend.a  lib/libclangLex.a  
lib/libclangRewrite.a  lib/libclangSerialization.a  lib/libclangTooling.a  
lib/libclangToolingCore.a  lib/libclangToolingRefactoring.a  
lib/libclangIndex.a  lib/libclangFormat.a  lib/libclangToolingInclusions.a  
lib/libclangFrontend.a  lib/libclangDriver.a  lib/libLLVMWindowsDriver.a  
lib/libLLVMOption.a  lib/libclangParse.a  lib/libclangSerialization.a  
lib/libclangSema.a  lib/libclangEdit.a  lib/libclangAnalysis.a  
lib/libclangASTMatchers.a  lib/libclangAST.a  lib/libLLVMFrontendOpenMP.a  
lib/libLLVMScalarOpts.a  lib/libLLVMAggressiveInstCombine.a  
lib/libLLVMInstCombine.a  lib/libLLVMTransformUtils.a  lib/libLLVMAnalysis.a  
lib/libLLVMProfileData.a  lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoPDB.a  
lib/libLLVMDebugInfoMSF.a  lib/libLLVMDebugInfoDWARF.a  lib/libLLVMObject.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMDebugInfoCodeView.a  
lib/libLLVMIRReader.a  lib/libLLVMAsmParser.a  lib/libLLVMTextAPI.a  
lib/libclangSupport.a  lib/libLLVMFrontendHLSL.a  lib/libLLVMBitReader.a  
lib/libclangToolingCore.a  lib/libclangRewrite.a  lib/libclangLex.a  
lib/libclangBasic.a  lib/libLLVMCore.a  lib/libLLVMBinaryFormat.a  
lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMSupport.a  -lm  
/opt/s/w/ir/x/w/staging/zlib_install/lib/libz.a  
/opt/s/w/ir/x/w/staging/zstd_install_prefix/lib/libzstd.a  
lib/libLLVMDemangle.a && :
  clang++: warning: argument unused during compilation: '-static-libstdc++' 
[-Wunused-command-line-argument]
  Assertion failed: (BitWidth == RHS.BitWidth && "Bit widths must be the 
same"), function operator+=, file 
/opt/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Support/APInt.cpp, line 189.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.Program arguments: /opt/s/w/ir/x/w/staging/llvm_build/./bin/ld64.lld 
-demangle -dynamic -arch arm64 -platform_version macos 11.0.0 11.0 -no_pie 
-mllvm -global-isel -mllvm -global-isel-abort=0 -syslibroot 
/opt/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
 -o bin/clang-refactor -headerpad_max_install_names 
/opt/s/w/ir/x/w/staging/llvm_build/lib/libc++.a --color-diagnostics 
-lto_library /opt/s/w/ir/x/w/staging/llvm_build/./lib/libLTO.dylib -dead_strip 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
 -rpath @loader_path/../lib lib/libLLVMOption.a lib/libLLVMSupport.a 
lib/libclangAST.a lib/libclangBasic.a lib/libclangFormat.a 
lib/libclangFrontend.a lib/libclangLex.a lib/libclangRewrite.a 
lib/libclangSerialization.a lib/lib

[PATCH] D142649: [CMake] Remove libLTO from Fuchsia toolchain

2023-01-26 Thread Alex Brachet 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 rG7aa27081e43f: [CMake] Remove libLTO from Fuchsia toolchain 
(authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142649

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -289,7 +289,6 @@
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   lld
-  LTO
   clang-apply-replacements
   clang-doc
   clang-format


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -289,7 +289,6 @@
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   lld
-  LTO
   clang-apply-replacements
   clang-doc
   clang-format
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139949: [clang-scan-deps] Migrate to OptTable

2023-01-13 Thread Alex Brachet 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 rG0c60ec699fc1: [clang-scan-deps] Migrate to OptTable 
(authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D139949?vs=486012&id=489054#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139949

Files:
  clang/tools/clang-scan-deps/CMakeLists.txt
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  clang/tools/clang-scan-deps/Opts.td
  llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -2197,11 +2197,24 @@
 ],
 )
 
+gentbl(
+name = "ScanDepsTableGen",
+strip_include_prefix = "include/clang/tools/clang-scan-deps",
+tbl_outs = [(
+"-gen-opt-parser-defs",
+"include/clang/tools/clang-scan-deps/Opts.inc",
+)],
+tblgen = "//llvm:llvm-tblgen",
+td_file = "tools/clang-scan-deps/Opts.td",
+td_srcs = [ "//llvm:include/llvm/Option/OptParser.td" ],
+)
+
 cc_binary(
 name = "clang-scan-deps",
 srcs = glob(["tools/clang-scan-deps/*.cpp"]),
 stamp = 0,
 deps = [
+":ScanDepsTableGen",
 ":driver",
 ":frontend",
 ":tooling",
Index: llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
+++ llvm/utils/gn/secondary/clang/tools/clang-scan-deps/BUILD.gn
@@ -1,6 +1,14 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("Opts") {
+  visibility = [ ":clang-scan-deps" ]
+  args = [ "-gen-opt-parser-defs" ]
+}
+
 executable("clang-scan-deps") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
+":Opts",
 "//clang/lib/AST",
 "//clang/lib/Basic",
 "//clang/lib/CodeGen",
Index: clang/tools/clang-scan-deps/Opts.td
===
--- /dev/null
+++ clang/tools/clang-scan-deps/Opts.td
@@ -0,0 +1,34 @@
+include "llvm/Option/OptParser.td"
+
+class F : Flag<["-"], name>, HelpText;
+class Arg : Separate<["-"], name>, HelpText;
+
+multiclass Eq {
+def NAME #_EQ : Joined<["-", "--"], name #"=">, HelpText;
+def : Separate<["-", "--"], name>, Alias(NAME #_EQ)>;
+}
+
+def help : Flag<["--"], "help">, HelpText<"Display this help">;
+def version : Flag<["--"], "version">, HelpText<"Display the version">;
+
+defm mode : Eq<"mode", "The preprocessing mode used to compute the dependencies">;
+
+defm format : Eq<"format", "The output format for the dependencies">;
+
+defm module_files_dir : Eq<"module-files-dir",
+"The build directory for modules. Defaults to the value of '-fmodules-cache-path=' from command lines for implicit modules">;
+
+def optimize_args : F<"optimize-args", "Whether to optimize command-line arguments of modules">;
+def eager_load_pcm : F<"eager-load-pcm", "Load PCM files eagerly (instead of lazily on import)">;
+
+def j : Arg<"j", "Number of worker threads to use (default: use all concurrent threads)">;
+
+defm compilation_database : Eq<"compilation-database", "Compilation database">;
+defm module_name : Eq<"module-name", "the module of which the dependencies are to be computed">;
+defm dependency_target : Eq<"dependency-target", "The names of dependency targets for the dependency file">;
+
+def deprecated_driver_command : F<"deprecated-driver-command", "use a single driver command to build the tu (deprecated)">;
+
+defm resource_dir_recipe : Eq<"resource-dir-recipe", "How to produce missing '-resource-dir' argument">;
+
+def verbose : F<"v", "Use verbose output">;
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -26,11 +26,163 @@
 #include 
 #include 
 
+#include "Opts.inc"
+
 using namespace clang;
 using namespace tooling::dependencies;
 
 namespace {
 
+using namespace llvm::opt;
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  OPT_##ID,
+#include "Opts.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Opts.inc"
+#undef PREFIX
+
+const llvm::opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, M

[PATCH] D139949: [clang-scan-deps] Migrate to OptTable

2023-01-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 2 inline comments as done.
abrachet added inline comments.



Comment at: utils/bazel/llvm-project-overlay/clang/BUILD.bazel:2207
 ":frontend",
+":ScanDepsTableGen",
 ":tooling",

GMNGeoffrey wrote:
> MaskRay wrote:
> > Move this before `:driver`
> Buildifier sorts these. Why does it need to be before driver? If it's really 
> required, add a comment to prevent buildifier from sorting: 
> http://go/buildifier#do-not-sort
> Move this before `:driver`

Done in commit



Comment at: utils/bazel/llvm-project-overlay/clang/BUILD.bazel:2207
 ":frontend",
+":ScanDepsTableGen",
 ":tooling",

abrachet wrote:
> GMNGeoffrey wrote:
> > MaskRay wrote:
> > > Move this before `:driver`
> > Buildifier sorts these. Why does it need to be before driver? If it's 
> > really required, add a comment to prevent buildifier from sorting: 
> > http://go/buildifier#do-not-sort
> > Move this before `:driver`
> 
> Done in commit
> Move this before `:driver`




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139949

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


[PATCH] D127933: [clang] Don't emit IFUNC when targeting Fuchsia

2022-06-16 Thread Alex Brachet 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 rGf4f6adc451a2: [clang] Don't emit IFUNC when targeting 
Fuchsia (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127933

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/test/CodeGen/attr-target-mv-va-args.c


Index: clang/test/CodeGen/attr-target-mv-va-args.c
===
--- clang/test/CodeGen/attr-target-mv-va-args.c
+++ clang/test/CodeGen/attr-target-mv-va-args.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s 
-o - | FileCheck %s --check-prefix=LINUX
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s 
-o - | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s 
-o - | FileCheck %s --check-prefixes=NO-IFUNC,WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-fuchsia -emit-llvm %s -o 
- | FileCheck %s --check-prefixes=NO-IFUNC,FUCHSIA
 int __attribute__((target("sse4.2"))) foo(int i, ...) { return 0; }
 int __attribute__((target("arch=sandybridge"))) foo(int i, ...);
 int __attribute__((target("arch=ivybridge"))) foo(int i, ...) {return 1;}
@@ -27,19 +28,21 @@
 // LINUX: ret i32 (i32, ...)* @foo
 // LINUX: declare i32 @foo.arch_sandybridge(i32 noundef, ...)
 
-// WINDOWS: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...)
-// WINDOWS: ret i32 0
-// WINDOWS: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...)
-// WINDOWS: ret i32 1
-// WINDOWS: define dso_local i32 @foo(i32 noundef %i, ...)
-// WINDOWS: ret i32 2
-// WINDOWS: define dso_local i32 @bar()
-// WINDOWS: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, 
double
-// WINDOWS: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 
2.2{{[0-9Ee+]+}}, i8* noundef getelementptr inbounds
+// NO-IFUNC: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 0
+// NO-IFUNC: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 1
+// NO-IFUNC: define dso_local i32 @foo(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 2
+// NO-IFUNC: define dso_local i32 @bar()
+// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, 
double
+// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 
2.2{{[0-9Ee+]+}}, i8* noundef getelementptr inbounds
 
 // WINDOWS: define weak_odr dso_local i32 @foo.resolver(i32 %0, ...) comdat
-// WINDOWS: musttail call i32 (i32, ...) @foo.arch_sandybridge
-// WINDOWS: musttail call i32 (i32, ...) @foo.arch_ivybridge
-// WINDOWS: musttail call i32 (i32, ...) @foo.sse4.2
-// WINDOWS: musttail call i32 (i32, ...) @foo
+// FUCHSIA: define weak_odr i32 @foo.resolver(i32 %0, ...) comdat
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_sandybridge
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_ivybridge
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.sse4.2
+// NO-IFUNC: musttail call i32 (i32, ...) @foo
 // WINDOWS: declare dso_local i32 @foo.arch_sandybridge(i32 noundef, ...)
+// FUCHSIA: declare i32 @foo.arch_sandybridge(i32 noundef, ...)
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1355,7 +1355,9 @@
   bool supportsMultiVersioning() const { return getTriple().isX86(); }
 
   /// Identify whether this target supports IFuncs.
-  bool supportsIFunc() const { return getTriple().isOSBinFormatELF(); }
+  bool supportsIFunc() const {
+return getTriple().isOSBinFormatELF() && !getTriple().isOSFuchsia();
+  }
 
   // Validate the contents of the __builtin_cpu_supports(const char*)
   // argument.


Index: clang/test/CodeGen/attr-target-mv-va-args.c
===
--- clang/test/CodeGen/attr-target-mv-va-args.c
+++ clang/test/CodeGen/attr-target-mv-va-args.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-fuchsia -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,FUCHSIA
 int __attribute__((target("sse4.2"))) foo(int i, ...) { return 0; }
 int __attribute__((target("arch=sandybridge"))) foo(int i, ...);
 int __attribute__((target("arch=ivybridge"))) foo(int i, ...) {return 1

[PATCH] D120201: [Clang] Extend -gen-reproducer flag

2022-05-27 Thread Alex Brachet 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 rG684c08010876: [Clang] Extend -gen-reproducer flag (authored 
by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D120201?vs=432047&id=432575#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120201

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/emit-reproducer.c
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -482,32 +482,37 @@
   }
 
   std::unique_ptr C(TheDriver.BuildCompilation(Args));
+
+  Driver::ReproLevel ReproLevel = Driver::ReproLevel::OnCrash;
+  if (Arg *A = C->getArgs().getLastArg(options::OPT_gen_reproducer_eq)) {
+auto Level = llvm::StringSwitch>(A->getValue())
+ .Case("off", Driver::ReproLevel::Off)
+ .Case("crash", Driver::ReproLevel::OnCrash)
+ .Case("error", Driver::ReproLevel::OnError)
+ .Case("always", Driver::ReproLevel::Always)
+ .Default(None);
+if (!Level) {
+  llvm::errs() << "Unknown value for " << A->getSpelling() << ": '"
+   << A->getValue() << "'\n";
+  return 1;
+}
+ReproLevel = *Level;
+  }
+  if (!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+ReproLevel = Driver::ReproLevel::Always;
+
   int Res = 1;
   bool IsCrash = false;
+  Driver::CommandStatus CommandStatus = Driver::CommandStatus::Ok;
+  // Pretend the first command failed if ReproStatus is Always.
+  const Command *FailingCommand = &*C->getJobs().begin();
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-// Force a crash to test the diagnostics.
-if (TheDriver.GenReproducer) {
-  Diags.Report(diag::err_drv_force_crash)
-<< !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
-
-  // Pretend that every command failed.
-  FailingCommands.clear();
-  for (const auto &J : C->getJobs())
-if (const Command *C = dyn_cast(&J))
-  FailingCommands.push_back(std::make_pair(-1, C));
-
-  // Print the bug report message that would be printed if we did actually
-  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
-  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
-llvm::dbgs() << llvm::getBugReportMsg();
-}
-
 for (const auto &P : FailingCommands) {
   int CommandRes = P.first;
-  const Command *FailingCommand = P.second;
+  FailingCommand = P.second;
   if (!Res)
 Res = CommandRes;
 
@@ -526,13 +531,21 @@
   // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
   IsCrash |= CommandRes > 128;
 #endif
-  if (IsCrash) {
-TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+  CommandStatus =
+  IsCrash ? Driver::CommandStatus::Crash : Driver::CommandStatus::Error;
+  if (IsCrash)
 break;
-  }
 }
   }
 
+  // Print the bug report message that would be printed if we did actually
+  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
+  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+llvm::dbgs() << llvm::getBugReportMsg();
+  if (TheDriver.maybeGenerateCompilationDiagnostics(CommandStatus, ReproLevel,
+*C, *FailingCommand))
+Res = 1;
+
   Diags.getClient()->finish();
 
   if (!UseNewCC1Process && IsCrash) {
Index: clang/test/Driver/emit-reproducer.c
===
--- /dev/null
+++ clang/test/Driver/emit-reproducer.c
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t && mkdir %t
+
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t -gen-reproducer=off2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t -fno-crash-diagnostics 2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t -gen-reproducer=crash  2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t -gen-reproducer=error  2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t -gen-reproducer=always 2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL %s -fcrash-diagnostics-dir=%t -gen-reproducer2>&1 | FileCheck %s
+
+// RUN: not %clang -DERROR %s -fcrash-diagnostics-dir=%t -gen-reproducer=off2>&1 | FileCheck %s --check-prefix=NOT

[PATCH] D120201: [Clang] Extend -gen-reproducer flag

2022-05-27 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added inline comments.



Comment at: clang/test/Driver/emit-reproducer.c:1
+// RUN: rm -rf %t; mkdir %t
+

hans wrote:
> I'm not sure if lit handles that semicolon, or if it hands this over to the 
> shell, in which case it won't work on windows.
> Instead, `rm -rf %t && mkdir %t` seems common among clang tests.
> 
> Otherwise, this is a nice test file :-)
Thanks :) updated it in the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120201

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


[PATCH] D120201: [Clang] Extend -gen-reproducer flag

2022-05-31 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 433120.
abrachet marked an inline comment as done.
abrachet added a comment.

Fix tests on macOS and compile test with `-fsyntax-only`


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

https://reviews.llvm.org/D120201

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report-crashfile.m
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -482,32 +482,37 @@
   }
 
   std::unique_ptr C(TheDriver.BuildCompilation(Args));
+
+  Driver::ReproLevel ReproLevel = Driver::ReproLevel::OnCrash;
+  if (Arg *A = C->getArgs().getLastArg(options::OPT_gen_reproducer_eq)) {
+auto Level = llvm::StringSwitch>(A->getValue())
+ .Case("off", Driver::ReproLevel::Off)
+ .Case("crash", Driver::ReproLevel::OnCrash)
+ .Case("error", Driver::ReproLevel::OnError)
+ .Case("always", Driver::ReproLevel::Always)
+ .Default(None);
+if (!Level) {
+  llvm::errs() << "Unknown value for " << A->getSpelling() << ": '"
+   << A->getValue() << "'\n";
+  return 1;
+}
+ReproLevel = *Level;
+  }
+  if (!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+ReproLevel = Driver::ReproLevel::Always;
+
   int Res = 1;
   bool IsCrash = false;
+  Driver::CommandStatus CommandStatus = Driver::CommandStatus::Ok;
+  // Pretend the first command failed if ReproStatus is Always.
+  const Command *FailingCommand = &*C->getJobs().begin();
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-// Force a crash to test the diagnostics.
-if (TheDriver.GenReproducer) {
-  Diags.Report(diag::err_drv_force_crash)
-<< !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
-
-  // Pretend that every command failed.
-  FailingCommands.clear();
-  for (const auto &J : C->getJobs())
-if (const Command *C = dyn_cast(&J))
-  FailingCommands.push_back(std::make_pair(-1, C));
-
-  // Print the bug report message that would be printed if we did actually
-  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
-  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
-llvm::dbgs() << llvm::getBugReportMsg();
-}
-
 for (const auto &P : FailingCommands) {
   int CommandRes = P.first;
-  const Command *FailingCommand = P.second;
+  FailingCommand = P.second;
   if (!Res)
 Res = CommandRes;
 
@@ -526,13 +531,21 @@
   // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
   IsCrash |= CommandRes > 128;
 #endif
-  if (IsCrash) {
-TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+  CommandStatus =
+  IsCrash ? Driver::CommandStatus::Crash : Driver::CommandStatus::Error;
+  if (IsCrash)
 break;
-  }
 }
   }
 
+  // Print the bug report message that would be printed if we did actually
+  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
+  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+llvm::dbgs() << llvm::getBugReportMsg();
+  if (TheDriver.maybeGenerateCompilationDiagnostics(CommandStatus, ReproLevel,
+*C, *FailingCommand))
+Res = 1;
+
   Diags.getClient()->finish();
 
   if (!UseNewCC1Process && IsCrash) {
Index: clang/test/Driver/crash-report-crashfile.m
===
--- clang/test/Driver/crash-report-crashfile.m
+++ clang/test/Driver/crash-report-crashfile.m
@@ -17,8 +17,8 @@
 @import simple;
 const int x = MODULE_MACRO;
 
-// CRASH_ENV: failing because environment variable 'FORCE_CLANG_DIAGNOSTICS_CRASH' is set
 // CRASH_ENV: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script.
+// CRASH_ENV: failing because environment variable 'FORCE_CLANG_DIAGNOSTICS_CRASH' is set
 // CRASH_ENV: Preprocessed source(s) and associated run script(s) are located at:
 // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.m
 // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.cache
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -198,8 +198,7 @@
   CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), CCPrintProcessStats(false),
   TargetTriple(TargetTriple), Saver(Alloc), CheckInputsExist(true),
-  ProbePrecompiled(true), GenReproducer(false),
-  SuppressMissingInputWarning(false) {
+  ProbePrecompiled(true), SuppressMi

[PATCH] D120201: [Clang] Extend -gen-reproducer flag

2022-05-31 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 433122.

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

https://reviews.llvm.org/D120201

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/emit-reproducer.c
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -482,32 +482,37 @@
   }
 
   std::unique_ptr C(TheDriver.BuildCompilation(Args));
+
+  Driver::ReproLevel ReproLevel = Driver::ReproLevel::OnCrash;
+  if (Arg *A = C->getArgs().getLastArg(options::OPT_gen_reproducer_eq)) {
+auto Level = llvm::StringSwitch>(A->getValue())
+ .Case("off", Driver::ReproLevel::Off)
+ .Case("crash", Driver::ReproLevel::OnCrash)
+ .Case("error", Driver::ReproLevel::OnError)
+ .Case("always", Driver::ReproLevel::Always)
+ .Default(None);
+if (!Level) {
+  llvm::errs() << "Unknown value for " << A->getSpelling() << ": '"
+   << A->getValue() << "'\n";
+  return 1;
+}
+ReproLevel = *Level;
+  }
+  if (!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+ReproLevel = Driver::ReproLevel::Always;
+
   int Res = 1;
   bool IsCrash = false;
+  Driver::CommandStatus CommandStatus = Driver::CommandStatus::Ok;
+  // Pretend the first command failed if ReproStatus is Always.
+  const Command *FailingCommand = &*C->getJobs().begin();
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-// Force a crash to test the diagnostics.
-if (TheDriver.GenReproducer) {
-  Diags.Report(diag::err_drv_force_crash)
-<< !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
-
-  // Pretend that every command failed.
-  FailingCommands.clear();
-  for (const auto &J : C->getJobs())
-if (const Command *C = dyn_cast(&J))
-  FailingCommands.push_back(std::make_pair(-1, C));
-
-  // Print the bug report message that would be printed if we did actually
-  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
-  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
-llvm::dbgs() << llvm::getBugReportMsg();
-}
-
 for (const auto &P : FailingCommands) {
   int CommandRes = P.first;
-  const Command *FailingCommand = P.second;
+  FailingCommand = P.second;
   if (!Res)
 Res = CommandRes;
 
@@ -526,13 +531,21 @@
   // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html
   IsCrash |= CommandRes > 128;
 #endif
-  if (IsCrash) {
-TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+  CommandStatus =
+  IsCrash ? Driver::CommandStatus::Crash : Driver::CommandStatus::Error;
+  if (IsCrash)
 break;
-  }
 }
   }
 
+  // Print the bug report message that would be printed if we did actually
+  // crash, but only if we're crashing due to FORCE_CLANG_DIAGNOSTICS_CRASH.
+  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"))
+llvm::dbgs() << llvm::getBugReportMsg();
+  if (TheDriver.maybeGenerateCompilationDiagnostics(CommandStatus, ReproLevel,
+*C, *FailingCommand))
+Res = 1;
+
   Diags.getClient()->finish();
 
   if (!UseNewCC1Process && IsCrash) {
Index: clang/test/Driver/emit-reproducer.c
===
--- /dev/null
+++ clang/test/Driver/emit-reproducer.c
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t && mkdir %t
+
+// RUN: echo "%s -fcrash-diagnostics-dir=%t -fsyntax-only" > %t.rsp
+
+// RUN: not %clang -DFATAL @%t.rsp -gen-reproducer=off2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DFATAL @%t.rsp -fno-crash-diagnostics 2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DFATAL @%t.rsp2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL @%t.rsp -gen-reproducer=crash  2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL @%t.rsp -gen-reproducer=error  2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL @%t.rsp -gen-reproducer=always 2>&1 | FileCheck %s
+// RUN: not %clang -DFATAL @%t.rsp -gen-reproducer2>&1 | FileCheck %s
+
+// RUN: not %clang -DERROR @%t.rsp -gen-reproducer=off2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DERROR @%t.rsp -fno-crash-diagnostics 2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DERROR @%t.rsp2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DERROR @%t.rsp -gen-reproducer=crash  2>&1 | FileCheck %s --check-prefix=NOT
+// RUN: not %clang -DERROR @%t.rsp -gen-reproducer=error  2>&1 | FileCheck %s
+// RUN: not %clang -DERROR @%t.rsp -gen-reproducer=always

[PATCH] D126548: [InstrProf] Stop exporting lprofDirMode

2022-05-31 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35a032eaf429: [InstrProf] Stop exporting lprofDirMode 
(authored by abrachet).
Herald added subscribers: Sanitizers, cfe-commits, Enna1.
Herald added projects: clang, Sanitizers.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126548

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/lib/profile/InstrProfilingUtil.c


Index: compiler-rt/lib/profile/InstrProfilingUtil.c
===
--- compiler-rt/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -46,7 +46,7 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
-COMPILER_RT_WEAK unsigned lprofDirMode = 0755;
+COMPILER_RT_VISIBILITY unsigned lprofDirMode = 0755;
 
 COMPILER_RT_VISIBILITY
 void __llvm_profile_recursive_mkdir(char *path) {
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1349,7 +1349,6 @@
   addExportedSymbol(CmdArgs, "___llvm_profile_filename");
   addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
 }
-addExportedSymbol(CmdArgs, "_lprofDirMode");
   }
 
   // Align __llvm_prf_{cnts,data} sections to the maximum expected page


Index: compiler-rt/lib/profile/InstrProfilingUtil.c
===
--- compiler-rt/lib/profile/InstrProfilingUtil.c
+++ compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -46,7 +46,7 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
-COMPILER_RT_WEAK unsigned lprofDirMode = 0755;
+COMPILER_RT_VISIBILITY unsigned lprofDirMode = 0755;
 
 COMPILER_RT_VISIBILITY
 void __llvm_profile_recursive_mkdir(char *path) {
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1349,7 +1349,6 @@
   addExportedSymbol(CmdArgs, "___llvm_profile_filename");
   addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
 }
-addExportedSymbol(CmdArgs, "_lprofDirMode");
   }
 
   // Align __llvm_prf_{cnts,data} sections to the maximum expected page
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120201: [Clang] Extend -gen-reproducer flag

2022-05-31 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

In D120201#3547834 , @dyung wrote:

> The test you added seems to be failing on the PS4 Windows bot. A quick glance 
> seems to suggest that you aren't properly escaping the path separators 
> somewhere. Can you take a look and revert if you need time to investigate?
>
> https://lab.llvm.org/buildbot/#/builders/216/builds/5164

Should be fixed by 
https://github.com/llvm/llvm-project/commit/a0ef52cc102504c4282dec7001664ee020396681


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

https://reviews.llvm.org/D120201

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


[PATCH] D124758: [analyzer] Implement assume in terms of assumeDual

2022-06-03 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

As a heads up, because I'm not sure how often folks look at Github Issues. This 
patch causes a stack overflow on some Objective-C++ code. I have filed 
https://github.com/llvm/llvm-project/issues/55851. Could you take a look 
@martong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124758

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet commandeered this revision.
abrachet added a reviewer: beanz.
abrachet added a comment.

I spoke to @beanz offline to make sure he is still ok with the patch being 
commandeered. Thanks for the patch @beanz, very excited about this :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 434277.
abrachet added a comment.
Herald added a subscriber: hiraditya.

- `llvm llvm-$tool` -> `llvm $tool`
- Error messages will now show `$tool: error: ...` instead of `error: ...`


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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -30,6 +30,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,72 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+// This function handles the case of not recognizing the tool requested, or if
+// --help or --version are passed directly to the llvm driver.
+int UnknownMain(int Argc, char **Argv) {
+  cl::OptionCategory LLVMDriverCategory("llvm options");
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  cl::SubCommand key##Subcommand(tool, tool);
+#include "LLVMDriverTools.def"
+
+  cl::HideUnrelatedOptions(LLVMDriverCategory);
+  cl::ParseCommandLineOptions(Argc, Argv, "llvm compiler driver\n");
+  if (Argc < 2) {
+cl::PrintHelpMessage();
+return 1;
+  }
+
+  llvm_unreachable("We should never get here, parsing should always exit.");
+  return 1;
+}
+
+extern bool IsLLVMDriver;
+
+int main(int Argc, char **Argv) {
+  IsLLVMDriver = true;
+  llvm::StringRef LaunchedTool = sys::path::stem(Argv[0]);
+  // If the driver is launched directly.
+  int PassThroughArgC = Argc;
+  char **PassThroughArgV = Argv;
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+if (Argc < 2)
+  return UnknownMain(Argc, Argv);
+LaunchedTool = Argv[1];
+ConsumeFirstArg = true;
+  }
+
+  // if it is launched through a symlink that is the tool name.
+  typedef int (*MainFunction)(int, char **);
+  MainFunction Func = StringSwitch(LaunchedTool)
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) .Case(tool, entry##_main)
+#include "LLVMDriverTools.def"
+  .Default(UnknownMain);
+  // If the main function is unknown we don't consume any args, so that we can
+  // print the appropriate help spew.
+  if (Func != UnknownMain && ConsumeFirstArg) {
+--PassThroughArgC;
+++PassThroughArgV;
+  }
+
+  return Func(PassThroughArgC, PassThroughArgV);
+}
Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- /dev/null
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -0,0 +1,31 @@
+get_property(LLVM_COMMON_DEPENDS GLOBAL PROPERTY LLVM_DRIVER_DEPS)
+get_p

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-04 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 5 inline comments as done.
abrachet added a comment.

In D109977#3378312 , @phosek wrote:

> Another potential future improvement is error reporting for subcommands:
>
>   $ ./bin/llvm clang   
>   llvm: error: no input files
>   $ ./bin/clang
>   clang-15: error: no input files
>
> Ideally, the multicall tool would produce the same error message.

It's difficult to make the error message the same, ie `clang-15`, but hopefully 
the name the tool was invoked with is enough.




Comment at: llvm/tools/llvm-driver/llvm-driver.cpp:43
+  if (LaunchedTool == "llvm") {
+LaunchedTool = Argv[1];
+ConsumeFirstArg = true;

phosek wrote:
> When the tool is invoked without any arguments (that is, simply as 
> `./bin/llvm`) this will lead to out-of-bounds array access. We should handle 
> this case explicitly.
This will now print the help message



Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:404
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);

beanz wrote:
> aganea wrote:
> > Shouldn't we say:
> > ```
> > int objcopy_main(int argc, char **argv) {
> > ```
> > here and the other places + all supporting code, if we want `llvm objcopy` 
> > (without the dash) like @phosek suggests?
> I had a different thought for that. I think we want the tools to respond to 
> llvm-objcopy since we will want them to exist in parallel to binutils tools 
> just like the current tools do today.
> 
> Many of the current tools also support symlink-redirection, to support that 
> we'll need to have a multiplex where multiple tool names point to the same 
> `main` function.
> 
> Handling that was my point (1) in the `main` commit message, and I intended 
> to work on it in a follow-on commit.
> Shouldn't we say:
> ```
> int objcopy_main(int argc, char **argv) {
> ```
> here and the other places + all supporting code, if we want `llvm objcopy` 
> (without the dash) like @phosek suggests?

I've kept name of the function as is, but `llvm objcopy` is now supported, and 
`llvm llvm-objcopy` is not


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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 434352.
abrachet marked an inline comment as done.
abrachet edited the summary of this revision.
abrachet added a comment.

Better handling of names with version, ie `llvm-cxxfilt-15` -> `cxxfilt`


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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   ToolName = argv[0];
 
Index: llvm/tools/llvm-objcopy/CMakeLists.txt
===
--- llvm/tools/llvm-objcopy/CMakeLists.txt
+++ llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -30,6 +30,7 @@
   ObjcopyOptsTableGen
   InstallNameToolOptsTableGen
   StripOptsTableGen
+  GENERATE_DRIVER
   )
 
 add_llvm_tool_symlink(llvm-install-name-tool llvm-objcopy)
Index: llvm/tools/llvm-driver/llvm-driver.cpp
===
--- /dev/null
+++ llvm/tools/llvm-driver/llvm-driver.cpp
@@ -0,0 +1,79 @@
+//===-- llvm-driver.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  int entry##_main(int argc, char **argv);
+#include "LLVMDriverTools.def"
+
+constexpr char subcommands[] =
+#define LLVM_DRIVER_TOOL(tool, entry, key) "  " tool "\n"
+#include "LLVMDriverTools.def"
+;
+
+static void printHelpMessage() {
+  llvm::outs() << "OVERVIEW: llvm toolchain driver\n\n"
+   << "USAGE: llvm [subcommand] [options]\n\n"
+   << "SUBCOMMANDS:\n\n"
+   << subcommands
+   << "\n  Type \"llvm  --help\" to get more help on a "
+  "specific subcommand\n\n"
+   << "OPTIONS:\n\n  --help - Display this message";
+}
+
+static int findTool(int Argc, char **Argv) {
+  if (!Argc) {
+printHelpMessage();
+return 1;
+  }
+
+  StringRef ToolName = Argv[0];
+
+  if (ToolName == "--help") {
+printHelpMessage();
+return 0;
+  }
+  if (ToolName == "--version") {
+cl::PrintVersionMessage();
+return 0;
+  }
+
+  StringRef Stem = sys::path::stem(ToolName);
+  auto Is = [=](StringRef Tool) {
+auto I = Stem.rfind_insensitive(Tool);
+return I != StringRef::npos && (I + Tool.size() == Stem.size() ||
+!llvm::isAlnum(Stem[I + Tool.size()]));
+  };
+
+#define LLVM_DRIVER_TOOL(tool, entry, key) \
+  if (Is(tool))\
+return entry##_main(Argc, Argv);
+#include "LLVMDriverTools.def"
+
+  if (Is("llvm"))
+return findTool(Argc - 1, Argv + 1);
+
+  printHelpMessage();
+  return 1;
+}
+
+extern bool IsLLVMDriver;
+
+int main(int Argc, char **Argv) {
+  IsLLVMDriver = true;
+  return findTool(Argc, Argv);
+}
Index: llvm/tools/llvm-driver/CMakeLists.txt
===
--- /dev/null
+++ llvm/tools/llvm-driver/CMakeLists.txt
@@ -0,0 +1,31 @@
+get_property(LLVM_COMMON_DEPENDS GLOBAL PROPERTY LLVM_DRIVER_DEPS)
+get_property(LLVM_DRIVER_OBJLIBS GLOBAL PROPERTY LLVM_DRIVER_OBJLIBS)
+
+get_property(LLVM_D

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 5 inline comments as done.
abrachet added a comment.

In D109977#3558762 , @MaskRay wrote:

> Thanks for picking up the change. I confirm that I can build `llvm` without 
> an error and it appears to work fine.
>
>> llvm-driver can be disabled from builds by setting 
>> LLVM_TOOL_LLVM_DRIVER_BUILD=Off.
>
> I think this should be opt-in. The new `llvm` executable takes a lot of space 
> and not needed by many developers/build bots.
> It's useful to some groups (distributions) but they can specify the option 
> themselves.
> I think the modified code is quite stable, so don't worry about regressions 
> just because this is not opt-in.

I didn't update the commits message, now it properly says that it can be opted 
in by setting `LLVM_TOOL_LLVM_DRIVER_BUILD` to `On`

In D109977#3558768 , @MaskRay wrote:

>   % /tmp/out/custom1/bin/llvm --help
>   ...

The output now looks like:

  OVERVIEW: llvm toolchain driver
  
  USAGE: llvm [subcommand] [options]
  
  SUBCOMMANDS:
  
ar
clang
dsymutil
cxxfilt
objcopy
ranlib
lib
dlltool
clang++
clang-cl
clang-cpp
install-name-tool
bitcode-strip
strip
  
Type "llvm  --help" to get more help on a specific subcommand
  
  OPTIONS:
  
--help - Display this message

What do you think?




Comment at: llvm/tools/llvm-driver/llvm-driver.cpp:50
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+if (Argc < 2)

MaskRay wrote:
> Some distributions may want to use something like llvm-15. See some binary 
> utilities how the version is handled.
Thank's I've taken this from objcopy's code


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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 434370.
abrachet marked an inline comment as done.
abrachet added a comment.

- Fix bazel build, `llvm-driver` can't be built by bazel, but the existing 
tools which lost their `main` will still work.
- Remove `--version`
- Fix `dsymutil` not depending on `DsymutilTableGen` which caused a dependency 
ordering problem on the bots


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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -2594,12 +2594,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "dsymutil_main",
+src = "cmake/driver-template.cpp.in",
+out = "dsymutil_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "dsymutil"
+},
+)
+
 cc_binary(
 name = "dsymutil",
 srcs = glob([
 "tools/dsymutil/*.cpp",
 "tools/dsymutil/*.h",
-]),
+]) + ["dsymutil_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2689,12 +2698,21 @@
 ],
 )
 
+template_rule(
+name = "ar_main",
+src = "cmake/driver-template.cpp.in",
+out = "ar_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_ar"
+},
+)
+
 cc_binary(
 name = "llvm-ar",
 srcs = glob([
 "tools/llvm-ar/*.cpp",
 "tools/llvm-ar/*.h",
-]),
+]) + ["ar_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2882,12 +2900,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "cxxfilt_main",
+src = "cmake/driver-template.cpp.in",
+out = "cxxfilt_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_cxxfilt"
+},
+)
+
 cc_binary(
 name = "llvm-cxxfilt",
 srcs = glob([
 "tools/llvm-cxxfilt/*.cpp",
 "tools/llvm-cxxfilt/*.h",
-]),
+]) + ["cxxfilt_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -3416,12 +3443,22 @@
 ],
 )
 
+template_rule(
+name = "objcopy_main",
+src = "cmake/driver-template.cpp.in",
+out = "objcopy_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_objcopy"
+},
+)
+
+
 cc_binary(
 name = "llvm-objcopy",
 srcs = glob([
 "tools/llvm-objcopy/*.cpp",
 "tools/llvm-objcopy/*.h",
-]),
+]) + ["objcopy_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -5,6 +5,7 @@
 load("//llvm:tblgen.bzl", "gentbl")
 load("//llvm:binary_alias.bzl", "binary_alias")
 load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
+load("//llvm:template_rule.bzl", "template_rule")
 
 package(
 default_visibility = ["//visibility:public"],
@@ -1925,12 +1926,21 @@
 ],
 )
 
+template_rule(
+name = "clang_main",
+src = "//llvm:cmake/driver-template.cpp.in",
+out = "clang_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "clang"
+},
+)
+
 cc_library(
 name = "clang-driver",
 srcs = glob([
 "tools/driver/*.cpp",
 "tools/driver/*.h",
-]),
+]) + ["clang_main.cpp"],
 copts = [
 # Disable stack frame size checks in the driver because
 # clang::ensureStackAddressSpace allocates a large array on the stack.
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(i

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 2 inline comments as done.
abrachet added inline comments.



Comment at: llvm/cmake/modules/AddLLVM.cmake:2030
+string(REPLACE "-" "_" key ${link_name})
+string(REPLACE "+" "p" key ${key})
+string(REPLACE "llvm-" "" tool_name ${link_name})

phosek wrote:
> Alternative substitution for `+` would be `x` which is used elsewhere in 
> LLVM, for example `libcxx`, `libcxxabi` or `cxxfilt`.
Upon closer inspection we are no longer using that parameter of the macro, so I 
have removed it.



Comment at: llvm/tools/llvm-driver/llvm-driver.cpp:50
+  bool ConsumeFirstArg = false;
+  if (LaunchedTool == "llvm") {
+if (Argc < 2)

MaskRay wrote:
> abrachet wrote:
> > MaskRay wrote:
> > > Some distributions may want to use something like llvm-15. See some 
> > > binary utilities how the version is handled.
> > Thank's I've taken this from objcopy's code
> The format of `cl::PrintVersionMessage();` is not so good for user-facing 
> tools. Consider omitting it.
> 
> `llvm-objcopy --version` should probably use a style similar to `clang 
> --version` but the priority isn't high.
I've just removed `--version` completely for now. I don't think it is that 
pressing. 


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

https://reviews.llvm.org/D109977

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


[PATCH] D109977: LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
abrachet marked 2 inline comments as done.
Closed by commit rGf06abbb39380: LLVM Driver Multicall tool (authored by beanz, 
committed by abrachet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

Files:
  clang/cmake/modules/AddClang.cmake
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/driver.cpp
  llvm/CMakeLists.txt
  llvm/cmake/driver-template.cpp.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/test/tools/llvm-driver/help-passthrough.test
  llvm/test/tools/llvm-driver/help.test
  llvm/test/tools/llvm-driver/symlink-call.test
  llvm/tools/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llvm-ar/CMakeLists.txt
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cxxfilt/CMakeLists.txt
  llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
  llvm/tools/llvm-driver/CMakeLists.txt
  llvm/tools/llvm-driver/llvm-driver.cpp
  llvm/tools/llvm-objcopy/CMakeLists.txt
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -2594,12 +2594,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "dsymutil_main",
+src = "cmake/driver-template.cpp.in",
+out = "dsymutil_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "dsymutil"
+},
+)
+
 cc_binary(
 name = "dsymutil",
 srcs = glob([
 "tools/dsymutil/*.cpp",
 "tools/dsymutil/*.h",
-]),
+]) + ["dsymutil_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2689,12 +2698,21 @@
 ],
 )
 
+template_rule(
+name = "ar_main",
+src = "cmake/driver-template.cpp.in",
+out = "ar_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_ar"
+},
+)
+
 cc_binary(
 name = "llvm-ar",
 srcs = glob([
 "tools/llvm-ar/*.cpp",
 "tools/llvm-ar/*.h",
-]),
+]) + ["ar_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -2882,12 +2900,21 @@
 td_srcs = ["include/llvm/Option/OptParser.td"],
 )
 
+template_rule(
+name = "cxxfilt_main",
+src = "cmake/driver-template.cpp.in",
+out = "cxxfilt_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_cxxfilt"
+},
+)
+
 cc_binary(
 name = "llvm-cxxfilt",
 srcs = glob([
 "tools/llvm-cxxfilt/*.cpp",
 "tools/llvm-cxxfilt/*.h",
-]),
+]) + ["cxxfilt_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
@@ -3416,12 +3443,22 @@
 ],
 )
 
+template_rule(
+name = "objcopy_main",
+src = "cmake/driver-template.cpp.in",
+out = "objcopy_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "llvm_objcopy"
+},
+)
+
+
 cc_binary(
 name = "llvm-objcopy",
 srcs = glob([
 "tools/llvm-objcopy/*.cpp",
 "tools/llvm-objcopy/*.h",
-]),
+]) + ["objcopy_main.cpp"],
 copts = llvm_copts,
 stamp = 0,
 deps = [
Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -5,6 +5,7 @@
 load("//llvm:tblgen.bzl", "gentbl")
 load("//llvm:binary_alias.bzl", "binary_alias")
 load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
+load("//llvm:template_rule.bzl", "template_rule")
 
 package(
 default_visibility = ["//visibility:public"],
@@ -1925,12 +1926,21 @@
 ],
 )
 
+template_rule(
+name = "clang_main",
+src = "//llvm:cmake/driver-template.cpp.in",
+out = "clang_main.cpp",
+substitutions = {
+"@TOOL_NAME@": "clang"
+},
+)
+
 cc_library(
 name = "clang-driver",
 srcs = glob([
 "tools/driver/*.cpp",
 "tools/driver/*.h",
-]),
+]) + ["clang_main.cpp"],
 copts = [
 # Disable stack frame size checks in the driver because
 # clang::ensureStackAddressSpace allocates a large array on the stack.
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -223,7 +223,7 @@
   return Error::success();
 }
 
-int main(int argc, char **argv) {
+int llvm_objcopy_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   

[PATCH] D109977: LLVM Driver Multicall tool

2022-06-06 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked an inline comment as done.
abrachet added inline comments.



Comment at: llvm/test/lit.cfg.py:142
 tools = [
+ToolSubst('%llvm', FindTool('llvm')),
 ToolSubst('%lli', FindTool('lli'), post='.', extra_args=lli_args),

thakis wrote:
> This causes `llvm-lit: 
> /Users/thakis/src/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126: note: 
> Did not find llvm in /Users/thakis/src/llvm-build-2/bin` if llvm-driver isn't 
> enabled (which it isn't by default). Any reason not to add this one only `if 
> config.have_llvm_driver`?
Fixed in rG553c2af5360b993376d3c000cf53850605940307


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109977

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


[PATCH] D126678: [clang] Allow CLANG_MODULE_CACHE_PATH env var to override module caching behavior

2022-06-09 Thread Alex Brachet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
abrachet marked an inline comment as done.
Closed by commit rGfac39d14b129: [clang] Allow CLANG_MODULE_CACHE_PATH env var 
to override module caching… (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126678

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules-cache-path.m


Index: clang/test/Driver/modules-cache-path.m
===
--- clang/test/Driver/modules-cache-path.m
+++ clang/test/Driver/modules-cache-path.m
@@ -1,2 +1,10 @@
 // RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-DEFAULT
 // CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
+
+// RUN: env CLANG_MODULE_CACHE_PATH=/dev/null \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=OVERRIDE
+// OVERRIDE: -fmodules-cache-path=/dev/null
+
+// RUN: env CLANG_MODULE_CACHE_PATH= \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=DISABLE
+// DISABLE-NOT: -fmodules-cache-path=
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3600,6 +3600,11 @@
 }
 
 bool Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) {
+  if (const char *Str = std::getenv("CLANG_MODULE_CACHE_PATH")) {
+Twine Path{Str};
+Path.toVector(Result);
+return Path.getSingleStringRef() != "";
+  }
   if (llvm::sys::path::cache_directory(Result)) {
 llvm::sys::path::append(Result, "clang");
 llvm::sys::path::append(Result, "ModuleCache");


Index: clang/test/Driver/modules-cache-path.m
===
--- clang/test/Driver/modules-cache-path.m
+++ clang/test/Driver/modules-cache-path.m
@@ -1,2 +1,10 @@
 // RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEFAULT
 // CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
+
+// RUN: env CLANG_MODULE_CACHE_PATH=/dev/null \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=OVERRIDE
+// OVERRIDE: -fmodules-cache-path=/dev/null
+
+// RUN: env CLANG_MODULE_CACHE_PATH= \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=DISABLE
+// DISABLE-NOT: -fmodules-cache-path=
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3600,6 +3600,11 @@
 }
 
 bool Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) {
+  if (const char *Str = std::getenv("CLANG_MODULE_CACHE_PATH")) {
+Twine Path{Str};
+Path.toVector(Result);
+return Path.getSingleStringRef() != "";
+  }
   if (llvm::sys::path::cache_directory(Result)) {
 llvm::sys::path::append(Result, "clang");
 llvm::sys::path::append(Result, "ModuleCache");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-09-27 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

  struct S {
template 
constexpr bool a(F&& f) const {
  // This works previously in clang and on gcc
  return f(1); // no matching function for call to object of type ...
}
  };
  
  template 
  struct S1 {
void f() {
  auto test = [] (auto) {
S s;
// Remove this constexpr and it compiles fine.
constexpr auto f = [](auto&&) { return true; };
return s.a(f);
  };
  test(1);
}
  };
  
  void a() {
S1 s;
s.f();
  }

The following doesn't compile after this change (I've verified that reverting 
makes the issue go away). This code also compiles fine on gcc. Would you mind 
taking a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155064

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-08-01 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added a comment.

> I am curious what @phosek 's failures were about.

I created D156792  which should fix those 
errors, and explains what the errors were.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[PATCH] D156792: [Driver] Fix test usages of --rtlib= without --unwindlib=

2023-08-01 Thread Alex Brachet 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 rGd5ca1602f641: [Driver] Fix test usages of --rtlib= without 
--unwindlib= (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D156792?vs=546030&id=546168#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156792

Files:
  clang/test/Driver/csky-toolchain.c
  clang/test/Driver/env.c
  clang/test/Driver/gcc-install-dir.cpp
  clang/test/Driver/gcc-toolchain.cpp
  clang/test/Driver/linux-cross.cpp
  clang/test/Driver/linux-ld.c
  clang/test/Driver/loongarch-toolchain.c
  clang/test/Driver/miamcu-opt.c
  clang/test/Driver/nolibc.c
  clang/test/Driver/pic.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c
  clang/test/OpenMP/linking.c

Index: clang/test/OpenMP/linking.c
===
--- clang/test/OpenMP/linking.c
+++ clang/test/OpenMP/linking.c
@@ -4,24 +4,24 @@
 // FIXME: Replace DEFAULT_OPENMP_LIB below with the value chosen at configure time.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -fopenmp -target i386-unknown-linux -rtlib=platform \
+// RUN: -fopenmp -target i386-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-32 %s
 // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-32: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
 // CHECK-LD-32: "-lpthread" "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -fopenmp -target x86_64-unknown-linux -rtlib=platform \
+// RUN: -fopenmp -target x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-64 %s
 // CHECK-LD-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-64: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
 // CHECK-LD-64: "-lpthread" "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -fopenmp=libgomp -target i386-unknown-linux -rtlib=platform \
+// RUN: -fopenmp=libgomp -target i386-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-GOMP-LD-32 %s
 
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target i386-unknown-linux -rtlib=platform | FileCheck --check-prefix SIMD-ONLY2 %s
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target i386-unknown-linux -rtlib=platform --unwindlib=platform | FileCheck --check-prefix SIMD-ONLY2 %s
 // SIMD-ONLY2-NOT: lgomp
 // SIMD-ONLY2-NOT: lomp
 // SIMD-ONLY2-NOT: liomp
@@ -29,27 +29,27 @@
 // CHECK-GOMP-LD-32: "-lgomp" "-lrt"
 // CHECK-GOMP-LD-32: "-lpthread" "-lc"
 
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target i386-unknown-linux -rtlib=platform | FileCheck --check-prefix SIMD-ONLY2 %s
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target i386-unknown-linux -rtlib=platform --unwindlib=platform | FileCheck --check-prefix SIMD-ONLY2 %s
 // SIMD-ONLY2-NOT: lgomp
 // SIMD-ONLY2-NOT: lomp
 // SIMD-ONLY2-NOT: liomp
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -fopenmp=libgomp -target x86_64-unknown-linux -rtlib=platform \
+// RUN: -fopenmp=libgomp -target x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-GOMP-LD-64 %s
 // CHECK-GOMP-LD-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-GOMP-LD-64: "-lgomp" "-lrt"
 // CHECK-GOMP-LD-64: "-lpthread" "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -fopenmp -target i386-unknown-linux -rtlib=platform \
+// RUN: -fopenmp -target i386-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-IOMP5-LD-32 %s
 // CHECK-IOMP5-LD-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-IOMP5-LD-32: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
 // CHECK-IOMP5-LD-32: "-lpthread" "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -fopenmp -target x86_64-unknown-linux -rtlib=platform \
+// RUN: -fopenmp -target x86_64-unknown-linux -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-IOMP5-LD-64 %s
 // CHECK-IOMP5-LD-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-IOMP5-LD-64: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
@@ -67,7 +67,7 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -fopenmp -fopenmp=libgomp -target i386-unknown-linux \
-// RUN: -rtlib=platform \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-OVERRIDE-32 %s
 // CHECK-LD-OVERRIDE-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-OVERRIDE-32: "-lgomp" "-lrt"
@@ -75,14 +75,14 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // 

[PATCH] D159414: [Driver] Fixes for header / library paths on Haiku

2023-09-09 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added inline comments.



Comment at: clang/test/Driver/haiku.cpp:2
+// Check the C++ header path (libstdc++)
+// RUN: %clang++ --target=x86_64-unknown-haiku -### %s 2>&1 \
+// RUN:   --sysroot=%S/Inputs/haiku_x86_64_tree \

This test is broken for people who configure with a different default 
`CLANG_DEFAULT_CXX_STDLIB`. I think this test should add `--stdlib=libstdc++`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159414

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


[PATCH] D159414: [Driver] Fixes for header / library paths on Haiku

2023-09-09 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added inline comments.



Comment at: clang/test/Driver/haiku.cpp:2
+// Check the C++ header path (libstdc++)
+// RUN: %clang++ --target=x86_64-unknown-haiku -### %s 2>&1 \
+// RUN:   --sysroot=%S/Inputs/haiku_x86_64_tree \

brad wrote:
> abrachet wrote:
> > This test is broken for people who configure with a different default 
> > `CLANG_DEFAULT_CXX_STDLIB`. I think this test should add 
> > `--stdlib=libstdc++`
> > This test is broken for people who configure with a different default 
> > `CLANG_DEFAULT_CXX_STDLIB`. I think this test should add 
> > `--stdlib=libstdc++`
> 
> Ah, I wasn't aware of that. I made the test such assuming the driver uses a 
> default of libstdc++ on Haiku. I can add the flag.
I just made https://github.com/llvm/llvm-project/pull/65871, testing it now. 
But I think it should fix it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159414

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


[PATCH] D154520: [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added a comment.
This revision is now accepted and ready to land.

That works. Thanks a lot, @hnrklssn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154520

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


[PATCH] D154520: [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Alex Brachet 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 rG68f5d1be3d8f: [UTC] Adapt version matcher to glob 
CLANG_VENDOR (authored by hnrklssn, committed by abrachet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154520

Files:
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -1571,17 +1571,16 @@
 ]
 
 
-# The capture group is kept as is, followed by a {{.*}} glob
 METADATA_FILTERS = [
-r"(\w+ version )[\d.]+(?: \([^)]+\))?",
-r'(!DIFile\(filename: ".+", directory: )".+"',
+(r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", r"{{.*}}\2{{.*}}"), 
# preface with glob also, to capture optional CLANG_VENDOR
+(r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),
 ]
-METADATA_FILTERS_RE = [re.compile(s) for s in METADATA_FILTERS]
+METADATA_FILTERS_RE = [(re.compile(f),r) for (f,r) in METADATA_FILTERS]
 
 
 def filter_unstable_metadata(line):
-for f in METADATA_FILTERS_RE:
-line = f.sub(r"\1{{.*}}", line)
+for (f,replacement) in METADATA_FILTERS_RE:
+line = f.sub(replacement, line)
 return line
 
 
Index: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
===
--- 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
+++ 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
@@ -243,7 +243,7 @@
 !61 = !{!"branch_weights", i32 1, i32 1048575}
 !62 = distinct !DIAssignID()
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META7:![0-9]+]] = distinct !DISubprogram(name: "foo", scope: 
[[META1]], file: [[META1]], line: 1, type: [[META8:![0-9]+]], scopeLine: 1, 
flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition 
| DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META12:![0-9]+]])
Index: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
===
--- 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
+++ 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
@@ -250,13 +250,13 @@
 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(argmem: readwrite) }
 ; CHECK: attributes #[[ATTR3]] = { nounwind }
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META3:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
 ; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; CHECK: [[META5:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-; CHECK: [[META6:![0-9]+]] = !{!"clang version {{.*}}"}
+; CHECK: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 ; CHECK: [[DBG7]] = distinct !DISubprogram(name: "foo", scope: [[META1]], 

[PATCH] D155217: [clang-tidy][include-cleaner] Don't warn for the same symbol twice

2023-07-13 Thread Alex Brachet via Phabricator via cfe-commits
abrachet created this revision.
abrachet added reviewers: VitaNuo, hokein.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
abrachet requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Only one diagnostic per symbol is necessary, after that the diagnostics
can become overbearing.


https://reviews.llvm.org/D155217

Files:
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -15,3 +15,5 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" 
is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is 
directly included [misc-include-cleaner]
+int FooBarResult2 = foobar();
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
Index: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -106,7 +106,11 @@
   const SourceManager *SM = Result.SourceManager;
   const FileEntry *MainFile = SM->getFileEntryForID(SM->getMainFileID());
   llvm::DenseSet Used;
-  std::vector Missing;
+  using SymRef = include_cleaner::SymbolReference;
+  auto Cmp = [](const SymRef &Left, const SymRef &Right) {
+return Left.Target.name() < Right.Target.name();
+  };
+  std::map Missing{Cmp};
   llvm::SmallVector MainFileDecls;
   for (Decl *D : Result.Nodes.getNodeAs("top")->decls()) {
 if (!SM->isWrittenInMainFile(SM->getExpansionLoc(D->getLocation(
@@ -135,7 +139,7 @@
  if (!Satisfied && !Providers.empty() &&
  Ref.RT == include_cleaner::RefType::Explicit &&
  !shouldIgnore(Providers.front()))
-   Missing.push_back({Ref, Providers.front()});
+   Missing.try_emplace(Ref, Providers.front());
});
 
   std::vector Unused;
@@ -181,9 +185,9 @@
 
   tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
  FileStyle->IncludeStyle);
-  for (const auto &Inc : Missing) {
+  for (const auto &[SymRef, Header] : Missing) {
 std::string Spelling =
-include_cleaner::spellHeader({Inc.Missing, *HS, MainFile});
+include_cleaner::spellHeader({Header, *HS, MainFile});
 bool Angled = llvm::StringRef{Spelling}.starts_with("<");
 // We might suggest insertion of an existing include in edge cases, e.g.,
 // include is present in a PP-disabled region, or spelling of the header
@@ -192,9 +196,9 @@
 if (auto Replacement =
 HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"),
   Angled, tooling::IncludeDirective::Include))
-  diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
+  diag(SM->getSpellingLoc(SymRef.RefLocation),
"no header providing \"%0\" is directly included")
-  << Inc.SymRef.Target.name()
+  << SymRef.Target.name()
   << FixItHint::CreateInsertion(
  SM->getComposedLoc(SM->getMainFileID(),
 Replacement->getOffset()),


Index: clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -15,3 +15,5 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner]
+int FooBarResult2 = foobar();
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:
Index: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -106,7 +106,11 @@
   const SourceManager *SM = Result.SourceManager;
   const FileEntry *MainFile = SM->getFileEntryForID(SM->getMainFileID());
   llvm::DenseSet Used;
-  std::vector Missing;
+  using SymRef = include_cleaner::SymbolReference;
+  auto Cmp = [](const SymRef &Left, const SymRef &Right) {
+return Left.Target.name() < Right.Target.name();
+  };
+  std::map Missing{Cmp};
   llvm::SmallVector MainFileDecls;
  

[PATCH] D153622: [clang][Sema] Suggest static_cast in C++ code

2023-07-14 Thread Alex Brachet 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 rG3c0a136ce4b7: [clang][Sema] Suggest static_cast in C++ code 
(authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D153622?vs=535074&id=540454#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153622

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.mm


Index: clang/test/FixIt/format.mm
===
--- clang/test/FixIt/format.mm
+++ clang/test/FixIt/format.mm
@@ -9,22 +9,22 @@
 
   const wchar_t wchar_data = L'a';
   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unsigned short)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast(
 
   NSLog(@"%C", 0x260300);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'int'}}
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unsigned short)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast(
 
   typedef unsigned short unichar;
 
   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unichar)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast(
 
   NSLog(@"%C", 0x260300);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'int'}}
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast(
 
   NSLog(@"%C", 0.0); // expected-warning{{format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'double'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%f"
-  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
+  // CHECK-NOT: 
fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast(
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11184,9 +11184,9 @@
   // if necessary).
   SmallString<16> CastBuf;
   llvm::raw_svector_ostream CastFix(CastBuf);
-  CastFix << "(";
+  CastFix << (S.LangOpts.CPlusPlus ? "static_cast<" : "(");
   IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
-  CastFix << ")";
+  CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
 
   SmallVector Hints;
   if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly)
@@ -11197,7 +11197,7 @@
 SourceRange CastRange(CCast->getLParenLoc(), CCast->getRParenLoc());
 Hints.push_back(FixItHint::CreateReplacement(CastRange, 
CastFix.str()));
 
-  } else if (!requiresParensToAddCast(E)) {
+  } else if (!requiresParensToAddCast(E) && !S.LangOpts.CPlusPlus) {
 // If the expression has high enough precedence,
 // just write the C-style cast.
 Hints.push_back(
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -415,6 +415,8 @@
 source:1:6: note: candidate function not viable: no known conversion from 
'const char[4]' to 'int' for 2nd argument
 void func(int aa, int bb);
  ^~~
+- ``-Wformat`` cast fix-its will now suggest ``static_cast`` instead of 
C-style casts
+  for C++ code.
 
 Bug Fixes in This Version
 -


Index: clang/test/FixIt/format.mm
===
--- clang/test/FixIt/format.mm
+++ clang/test/FixIt/format.mm
@@ -9,22 +9,22 @@
 
   const wchar_t wchar_data = L'a';
   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unsigned short)"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast(
 
   NSLog(@"%C", 0x260300);  // expected-warning{{format specifies type 'unichar' (aka 'unsigned short') but the argument has type 'int'}}
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unsigned short

[PATCH] D153623: [clang][Sema] Add fixit for scoped enum format error

2023-07-14 Thread Alex Brachet 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 rG563a23c824db: [clang][Sema] Add fixit for scoped enum format 
error (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D153623?vs=538669&id=540455#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153623

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.cpp


Index: clang/test/FixIt/format.cpp
===
--- /dev/null
+++ clang/test/FixIt/format.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 
2>&1 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+
+namespace N {
+  enum class E { One };
+}
+
+void a() {
+  printf("%d", N::E::One); // expected-warning{{format specifies type 'int' 
but the argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:25-[[@LINE-2]]:25}:")"
+
+  printf("%hd", N::E::One);
+  // CHECK: "static_cast("
+
+  printf("%hu", N::E::One);
+  // CHECK: "static_cast("
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11077,12 +11077,15 @@
   assert(Match != ArgType::MatchPromotion);
   // Look through unscoped enums to their underlying type.
   bool IsEnum = false;
+  bool IsScopedEnum = false;
   if (auto EnumTy = ExprTy->getAs()) {
 if (EnumTy->isUnscopedEnumerationType()) {
   ExprTy = EnumTy->getDecl()->getIntegerType();
   // This controls whether we're talking about the underlying type or not,
   // which we only want to do when it's an unscoped enum.
   IsEnum = true;
+} else {
+  IsScopedEnum = true;
 }
   }
 
@@ -11148,7 +11151,7 @@
 
 CharSourceRange SpecRange = getSpecifierRange(StartSpecifier, 
SpecifierLen);
 
-if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) {
+if (IntendedTy == ExprTy && !ShouldNotPrintDirectly && !IsScopedEnum) {
   unsigned Diag;
   switch (Match) {
   case ArgType::Match:
@@ -11185,11 +11188,17 @@
   SmallString<16> CastBuf;
   llvm::raw_svector_ostream CastFix(CastBuf);
   CastFix << (S.LangOpts.CPlusPlus ? "static_cast<" : "(");
-  IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
+  if (IsScopedEnum) {
+CastFix << AT.getRepresentativeType(S.Context).getAsString(
+S.Context.getPrintingPolicy());
+  } else {
+IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
+  }
   CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
 
   SmallVector Hints;
-  if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly)
+  if ((!AT.matchesType(S.Context, IntendedTy) && !IsScopedEnum) ||
+  ShouldNotPrintDirectly)
 Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
 
   if (const CStyleCastExpr *CCast = dyn_cast(E)) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -417,6 +417,9 @@
  ^~~
 - ``-Wformat`` cast fix-its will now suggest ``static_cast`` instead of 
C-style casts
   for C++ code.
+- ``-Wformat`` will no longer suggest a no-op fix-it for fixing scoped enum 
format
+  warnings. Instead, it will suggest casting the enum object to the type 
specified
+  in the format string.
 
 Bug Fixes in This Version
 -


Index: clang/test/FixIt/format.cpp
===
--- /dev/null
+++ clang/test/FixIt/format.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 2>&1 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+
+namespace N {
+  enum class E { One };
+}
+
+void a() {
+  printf("%d", N::E::One); // expected-warning{{format specifies type 'int' but the argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:25-[[@LINE-2]]:25}:")"
+
+  printf("%hd", N::E::One);
+  // CHECK: "static_cast("
+
+  printf("%hu", N::E::One);
+  // CHECK: "static_cast("
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11077,12 +11077,15 @@
   assert(Match != ArgType::MatchPromotion);
   // Look through unscoped enums to their underlying type.
   bool IsEnum = false;
+  bool IsScopedEnum = false;
   if (auto En

[PATCH] D159130: [CMake] Add option to disable driver build in Fuchsia cache file

2023-09-05 Thread Alex Brachet via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
abrachet marked an inline comment as done.
Closed by commit rGc7cc756ce343: [CMake] Add option to disable driver build in 
Fuchsia cache file (authored by abrachet).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D159130?vs=554443&id=555869#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159130

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -31,7 +31,10 @@
 
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
-else()
+  set(FUCHSIA_DISABLE_DRIVER_BUILD ON)
+endif()
+
+if (NOT FUCHSIA_DISABLE_DRIVER_BUILD)
   set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
   set(LLVM_DRIVER_TARGET llvm-driver)
 endif()


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -31,7 +31,10 @@
 
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
-else()
+  set(FUCHSIA_DISABLE_DRIVER_BUILD ON)
+endif()
+
+if (NOT FUCHSIA_DISABLE_DRIVER_BUILD)
   set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
   set(LLVM_DRIVER_TARGET llvm-driver)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159130: [CMake] Add option to disable driver build in Fuchsia cache file

2023-09-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:34
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
-else()
+  set(FUCHSIA_DISABLE_DRIVER_BUILD On)
+endif()

phosek wrote:
> Nit: can you use `ON` for consistency?
Done in commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159130

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


  1   2   >