[PATCH] D144217: [clang-tidy] Fix false-positive in readability-container-size-empty

2023-02-21 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

In D144217#4143554 , @PiotrZSL wrote:

> In D144217#4143540 , @carlosgalvezp 
> wrote:
>
>>> Perhaps, this can even be generalized to all types whose size() and empty() 
>>> are constexpr.
>
> Problem is that you can mark function constexpr, but it doesnt need to be 
> constexpr evaluated:
>
>   struct C
>   {
>   constexpr C(int v) : v(v) {}
>   constexpr int size() const { return v; };
>   constexpr bool empty() const { return v == 0; };
>   constexpr void setSize(int vv) { v = vv; };
>   int v;
>   };
>   
>   constexpr C value(6);
>   C non_const(6);
>
> I would need to check if it's constexpr evaluated, but here we don't evaluate 
> it. Alternative would be to check if method use only template arguments, but 
> then it could use other const static or something...
> This is why I decided to go with config. And still you may have other user 
> provided classes that does not have empty/size constexpr.

Ok, good point!




Comment at: 
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp:101
+  IgnoreComparisonForTypesRegexp(
+  Options.get("IgnoreComparisonForTypesRegexp", "^::std::array")) {}
+

I also realize that in other checks, this is typically implemented as a list 
(comma or semicolon-separated) instead of a regex. Would it make sense to do 
that here as well, for consistency? As a user I would also find it easier and 
more intuitive to type a list than to have to google how to create a list using 
regex :) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144217

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


[PATCH] D143666: [Clang] Fix clang_rt tests when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON

2023-02-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I missed this change so I apologize for late response, but can you elaborate on 
why this is needed? Clang first checks the name without architecture and if the 
file doesn't exist then it'll return the one with architecture unconditionally, 
see 
https://github.com/llvm/llvm-project/blob/d61a863050bb4afd22d08bbe53af1e24c0657aba/clang/lib/Driver/ToolChain.cpp#L545.
 Since there are no files inside 
https://github.com/llvm/llvm-project/tree/main/clang/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm,
 it should always return the path with architecture as was the case for the 
previous version. `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON` should play no role 
here since Clang tests are hermetic (as in they don't rely on runtimes being 
built).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143666

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


[PATCH] D143666: [Clang] Fix clang_rt tests when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON

2023-02-21 Thread Michael Platings via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd61a863050bb: [Clang] Fix clang_rt tests when 
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON (authored by michaelplatings).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143666

Files:
  clang/test/Driver/arm-compiler-rt.c
  clang/test/Driver/print-libgcc-file-name-clangrt.c

Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -4,13 +4,13 @@
 // RUN: --target=x86_64-pc-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
-// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+// CHECK-CLANGRT-X8664: libclang_rt.builtins{{(-x86_64)?}}.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=i386-pc-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
-// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a
+// CHECK-CLANGRT-I386: libclang_rt.builtins{{(-i386)?}}.a
 
 // Check whether alternate arch values map to the correct library.
 //
@@ -23,7 +23,7 @@
 // RUN: --target=arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM %s
-// CHECK-CLANGRT-ARM: libclang_rt.builtins-arm.a
+// CHECK-CLANGRT-ARM: libclang_rt.builtins{{(-arm)?}}.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=arm-linux-androideabi \
@@ -35,19 +35,19 @@
 // RUN: --target=arm-linux-gnueabihf \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARMHF %s
-// CHECK-CLANGRT-ARMHF: libclang_rt.builtins-armhf.a
+// CHECK-CLANGRT-ARMHF: libclang_rt.builtins{{(-armhf)?}}.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=arm-linux-gnueabi -mfloat-abi=hard \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-ABI %s
-// CHECK-CLANGRT-ARM-ABI: libclang_rt.builtins-armhf.a
+// CHECK-CLANGRT-ARM-ABI: libclang_rt.builtins{{(-armhf)?}}.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=armv7m-none-eabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
-// CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+// CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins{{(-armv7m)?}}.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=armv7m-vendor-none-eabi \
Index: clang/test/Driver/arm-compiler-rt.c
===
--- clang/test/Driver/arm-compiler-rt.c
+++ clang/test/Driver/arm-compiler-rt.c
@@ -2,47 +2,47 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-EABI
-// ARM-EABI: "-lclang_rt.builtins-arm"
+// ARM-EABI: "-lclang_rt.builtins{{(-arm)?}}"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins{{(-arm)?}}.a"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins{{(-armhf)?}}.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF
-// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins{{(-armhf)?}}.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=soft -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
-// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins{{(-arm)?}}.a"
 
 // RUN: %clang -target arm-windows-itanium \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_sub

[clang] d61a863 - [Clang] Fix clang_rt tests when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON

2023-02-21 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-02-22T07:45:16Z
New Revision: d61a863050bb4afd22d08bbe53af1e24c0657aba

URL: 
https://github.com/llvm/llvm-project/commit/d61a863050bb4afd22d08bbe53af1e24c0657aba
DIFF: 
https://github.com/llvm/llvm-project/commit/d61a863050bb4afd22d08bbe53af1e24c0657aba.diff

LOG: [Clang] Fix clang_rt tests when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON

If clang is part of a toolchain that can locate clang_rt libraries
outside its resource directory and these are built with
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON then the tests would fail because
the library names don't have the arch suffix. This change makes the arch
suffix optional.

Differential Revision: https://reviews.llvm.org/D143666

Added: 


Modified: 
clang/test/Driver/arm-compiler-rt.c
clang/test/Driver/print-libgcc-file-name-clangrt.c

Removed: 




diff  --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index a101396862c58..b31e210b0376f 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -2,47 +2,47 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-EABI
-// ARM-EABI: "-lclang_rt.builtins-arm"
+// ARM-EABI: "-lclang_rt.builtins{{(-arm)?}}"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins{{(-arm)?}}.a"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins{{(-armhf)?}}.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF
-// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins{{(-armhf)?}}.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=soft -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
-// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins{{(-arm)?}}.a"
 
 // RUN: %clang -target arm-windows-itanium \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-WINDOWS
-// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins-arm.lib"
+// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins{{(-arm)?}}.lib"
 
 // RUN: %clang -target arm-linux-androideabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-ANDROID
-// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins-arm-android.a"
+// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins{{(-arm-android)?}}.a"
 
 // RUN: %clang -target arm-linux-androideabi \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-ANDROIDHF
-// ARM-ANDROIDHF: "{{.*[/\\]}}libclang_rt.builtins-armhf-android.a"
+// ARM-ANDROIDHF: "{{.*[/\\]}}libclang_rt.builtins{{(-armhf-android)?}}.a"
 

diff  --git a/clang/test/Driver/print-libgcc-file-name-clangrt.c 
b/clang/test/Driver/print-libgcc-file-name-clangrt.c
index 5084c9966474f..6e6e73213c212 100644
--- a/clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ b/clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -4,13 +4,13 @@
 // RUN: --target=x86_64-pc-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
-// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+// CHECK-CLANGRT-X8664: libclang_rt.builtins{{(-x86_64)?}}.a
 
 // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
 // RUN: --target=i386-pc-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
-// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a
+// CHECK-CLANGRT-I386: libclang_rt.builtins{{(-i386)?}}.a
 
 // Check whether alternate arch values map to the correct library.
 //
@@ -23,7 +23,7 @@
 // RUN: --target=arm-linux-gnueabi \
 // RUN: -reso

[PATCH] D144537: [clang-format] Don't move qualifiers past pointers-to-member

2023-02-21 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel created this revision.
rymiel added a project: clang-format.
rymiel added reviewers: owenpan, MyDeveloperDay, HazardyKnusperkeks.
Herald added a project: All.
rymiel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, given a pointer-to-member type such as `Foo const Bar::*`,
clang-format would see the `const Bar::` part as a regular type name
with scope resolution operators, and with `QualifierAlignment: Right` it
would attempt to "fix" it, resulting in `Foo Bar::const *`, a syntax
error.

This patch no longer allows qualifiers to be moved across `::*`.

Fixes https://github.com/llvm/llvm-project/issues/60898


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144537

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -420,6 +420,16 @@
 
   // don't adjust macros
   verifyFormat("const INTPTR a;", "const INTPTR a;", Style);
+
+  // Pointers to members
+  verifyFormat("int S::*a;", Style);
+  verifyFormat("int const S::*a;", "const int S:: *a;", Style);
+  verifyFormat("int const S::*const a;", "const int S::* const a;", Style);
+  verifyFormat("int A::*const A::*p1;", Style);
+  verifyFormat("float (C::*p)(int);", Style);
+  verifyFormat("float (C::*const p)(int);", Style);
+  verifyFormat("float (C::*p)(int) const;", Style);
+  verifyFormat("float const (C::*p)(int);", "const float (C::*p)(int);", 
Style);
 }
 
 TEST_F(QualifierFixerTest, LeftQualifier) {
@@ -565,6 +575,16 @@
 
   // don't adjust macros
   verifyFormat("INTPTR const a;", "INTPTR const a;", Style);
+
+  // Pointers to members
+  verifyFormat("int S::*a;", Style);
+  verifyFormat("const int S::*a;", "int const S:: *a;", Style);
+  verifyFormat("const int S::*const a;", "int const S::* const a;", Style);
+  verifyFormat("int A::*const A::*p1;", Style);
+  verifyFormat("float (C::*p)(int);", Style);
+  verifyFormat("float (C::*const p)(int);", Style);
+  verifyFormat("float (C::*p)(int) const;", Style);
+  verifyFormat("const float (C::*p)(int);", "float const (C::*p)(int);", 
Style);
 }
 
 TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -280,8 +280,11 @@
 // The case  `const Foo &&` -> `Foo const &&`
 // The case  `const std::Foo &&` -> `std::Foo const &&`
 // The case  `const std::Foo &&` -> `std::Foo const &&`
-while (Next && Next->isOneOf(tok::identifier, tok::coloncolon))
+// However,  `const Bar::*` remains the same.
+while (Next && Next->isOneOf(tok::identifier, tok::coloncolon) &&
+   !Next->startsSequence(tok::coloncolon, tok::star)) {
   Next = Next->Next;
+}
 if (Next && Next->is(TT_TemplateOpener)) {
   Next = Next->MatchingParen;
   // Move to the end of any template class members e.g.


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -420,6 +420,16 @@
 
   // don't adjust macros
   verifyFormat("const INTPTR a;", "const INTPTR a;", Style);
+
+  // Pointers to members
+  verifyFormat("int S::*a;", Style);
+  verifyFormat("int const S::*a;", "const int S:: *a;", Style);
+  verifyFormat("int const S::*const a;", "const int S::* const a;", Style);
+  verifyFormat("int A::*const A::*p1;", Style);
+  verifyFormat("float (C::*p)(int);", Style);
+  verifyFormat("float (C::*const p)(int);", Style);
+  verifyFormat("float (C::*p)(int) const;", Style);
+  verifyFormat("float const (C::*p)(int);", "const float (C::*p)(int);", Style);
 }
 
 TEST_F(QualifierFixerTest, LeftQualifier) {
@@ -565,6 +575,16 @@
 
   // don't adjust macros
   verifyFormat("INTPTR const a;", "INTPTR const a;", Style);
+
+  // Pointers to members
+  verifyFormat("int S::*a;", Style);
+  verifyFormat("const int S::*a;", "int const S:: *a;", Style);
+  verifyFormat("const int S::*const a;", "int const S::* const a;", Style);
+  verifyFormat("int A::*const A::*p1;", Style);
+  verifyFormat("float (C::*p)(int);", Style);
+  verifyFormat("float (C::*const p)(int);", Style);
+  verifyFormat("float (C::*p)(int) const;", Style);
+  verifyFormat("const float (C::*p)(int);", "float const (C::*p)(int);", Style);
 }
 
 TEST_F(QualifierFixerTest, ConstVolatileQualifiersOrder) {
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/Quali

[PATCH] D144217: [clang-tidy] Fix false-positive in readability-container-size-empty

2023-02-21 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

In D144217#4143540 , @carlosgalvezp 
wrote:

>> Perhaps, this can even be generalized to all types whose size() and empty() 
>> are constexpr.

Problem is that you can mark function constexpr, but it doesnt need to be 
constexpr evaluated:

  struct C
  {
  constexpr C(int v) : v(v) {}
  constexpr int size() const { return v; };
  constexpr bool empty() const { return v == 0; };
  constexpr void setSize(int vv) { v = vv; };
  int v;
  };
  
  constexpr C value(6);
  C non_const(6);

I would need to check if it's constexpr evaluated, but here we don't evaluate 
it. Alternative would be to check if method use only template arguments, but 
then it could use other const static or something...
This is why I decided to go with config. And still you may have other user 
provided classes that does not have empty/size constexpr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144217

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


[PATCH] D144447: [Clang] Teach buildFMulAdd to peek through fneg to find fmul.

2023-02-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3738
-  assert(!(negMul && negAdd) && "Only one of negMul and negAdd should be 
set.");
-
   Value *MulOp0 = MulOp->getOperand(0);

kpn wrote:
> If I'm reading this right it looks like the assert() wasn't needed before. Do 
> we know why it was added in the first place?
I don't. I've added @lhames who wrote the code originally, but's been 10 years.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D17

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


[PATCH] D144217: [clang-tidy] Fix false-positive in readability-container-size-empty

2023-02-21 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Looks good in general, thanks for the fix! I have minor comments.

Also, I found the comment on the Github issue interesting:

> Perhaps, this can even be generalized to all types whose size() and empty() 
> are constexpr.

Would that be a more scalable approach than maintaining a list of classes to 
ignore?




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/container-size-empty.rst:30
+
+Excludes certain classes from the check using a regular expression of ERE
+syntax. If excluded, the check won't suggest replacing the comparison of

For better readability, please spell out this acronym.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp:721
 }
 
 struct TypedefSize {

Missing a test case to test that the option works as expected, e.g. set it to a 
non-default value.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp:758
+
+bool testArrayCompareToEmptye(const Array& value) {
+  return value == std::array();

Empty


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144217

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


[PATCH] D143840: [clang] Add the check of membership for the issue #58674 and improve the lookup process

2023-02-21 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 499374.

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

https://reviews.llvm.org/D143840

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/decl-ref-inheritance.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/test/CodeGenCXX/decl-ref-inheritance.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/decl-ref-inheritance.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: [[FOO:%.+]] = type { i32 }
+struct foo {
+  int val;
+};
+
+template  struct bar : T {
+};
+
+struct baz : bar {
+  // CHECK-LABEL: define{{.*}} i32 @_ZN3baz3getEv
+  // CHECK: {{%.+}} = getelementptr inbounds [[FOO]], ptr {{%.+}}, i32 0, i32 0
+  int get() {
+return val;
+  }
+};
+
+int qux() {
+  auto f = baz{};
+  return f.get();
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,20 +2698,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupInDependentTypes) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupInDependentTypes);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *B

[PATCH] D144510: [clang-tidy] improve readability-identifier-naming hungarian options test

2023-02-21 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp 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/D144510/new/

https://reviews.llvm.org/D144510

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


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2023-02-21 Thread Tim Neumann via Phabricator via cfe-commits
TimNN added a comment.
Herald added a subscriber: StephenFan.

The ThinLTO related breakage I mentioned above should be fixed as of 
https://github.com/llvm/llvm-project/commit/451799bb8261bde52bbfef226d019caf1d82aa42.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

Ok, all feedback should be addressed (thanks for the comment to consolidate 
into a single matcher) with appropriate options to relax the enforcement of the 
guideline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 499366.
ccotter added a comment.

- Include non-deduced template types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,328 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,NOSUBEXPR -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,UNNAMED -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,NONDEDUCED -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes, value: false}]}" -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template  struct remove_reference { typedef _Tp type; };
+template  struct remove_reference<_Tp&> { typedef _Tp type; };
+template  struct remove_reference<_Tp&&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void just_a_declaration(Obj&& o);
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LIN

[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:301
+  }
+  void never_moves(T&& t) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: rvalue reference parameter 't' 
is never moved from inside the function body 
[cppcoreguidelines-rvalue-reference-param-not-moved]

ccotter wrote:
> PiotrZSL wrote:
> > that's not always rvalue, if T would be for example int&, then this going 
> > to be lvalue...
> Looking at the rule enforcement, I might have overlooked one thing:
> 
>  > Flag all X&& parameters (where X is not a template type parameter name) 
> where the function body uses them without std::move.
> 
> I think this means this code should not be flagged, even if `T` is an object 
> which is cheap to move but expensive to copy (and not a reference to that 
> type). I would like for `AClassTemplate` to be flagged, but not 
> `AClassTemplate`, so let me look into this to see if I can 
> limit this to instantiations of the type, rather than looking at the template 
> definition itself.
Thinking about this more, the enforcement spec for F.18 does apply to the 
`SomeClass` example (shown below again), since `T` is not a deduced parameter 
in the context of the constructor. Indeed, it has generated a bit of discussion 
which I think is the specific point of the guideline to avoid confusion around 
the non-trivial but important concepts of rvalue references, universal 
references, move/forwards, etc (and, again, I think one would usually expect to 
see different specializations for `T` vs `T&` and/or disallowing one of 
`T`/`T&` to avoid confusion to the reader or even author).

```
template 
struct SomeClass {
SomeClass(T&&) { ... } // T is not deduced.
};
```

I can add an option (although I'm a little worried now as there will be 3 
options for this check, which seems like a bit much) for this with the default 
to adhere to the guideline as stated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 499363.
ccotter marked an inline comment as done.
ccotter added a comment.

- Finish combining into a single matcher
- Rename option and add docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,331 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,NOSUBEXPR -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowAnySubExpr, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,UNNAMED -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template  struct remove_reference { typedef _Tp type; };
+template  struct remove_reference<_Tp&> { typedef _Tp type; };
+template  struct remove_reference<_Tp&&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void just_a_declaration(Obj&& o);
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_unnamed(Obj&&) {}
+// CHECK-MESSAGES-UNNAMED: :[[@LINE-1]]:31: warning: rvalue reference parameter '' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+// CHECK-MESSAGES-CXX14: :[[@LINE-2]]:31: warning: rvalue reference parameter '' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_ca

[PATCH] D144533: [clang][driver] Do not emit default '-Tdata' for AVR devices

2023-02-21 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

Different AVR device families have different default linker scripts in avr-ld, 
but they have 95% similarity and look like as following, we can use 
`--defsym=__DATA_REGION_ORIGIN__` to decide the default data region range 
instead of current `-Tdata`.

  /* Script for ld -r: link without relocation */
  /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
 Copying and distribution of this script, with or without modification,
 are permitted in any medium without royalty provided the copyright
 notice and this notice are preserved.  */
  OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
  OUTPUT_ARCH(avr:6)
  __TEXT_REGION_ORIGIN__ = DEFINED(__TEXT_REGION_ORIGIN__) ? 
__TEXT_REGION_ORIGIN__ : 0;
  __DATA_REGION_ORIGIN__ = DEFINED(__DATA_REGION_ORIGIN__) ? 
__DATA_REGION_ORIGIN__ : 0x800200;
  __TEXT_REGION_LENGTH__ = DEFINED(__TEXT_REGION_LENGTH__) ? 
__TEXT_REGION_LENGTH__ : 1024K;
  __DATA_REGION_LENGTH__ = DEFINED(__DATA_REGION_LENGTH__) ? 
__DATA_REGION_LENGTH__ : 0xfe00;
  __EEPROM_REGION_LENGTH__ = DEFINED(__EEPROM_REGION_LENGTH__) ? 
__EEPROM_REGION_LENGTH__ : 64K;
  __FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? 
__FUSE_REGION_LENGTH__ : 1K;
  __LOCK_REGION_LENGTH__ = DEFINED(__LOCK_REGION_LENGTH__) ? 
__LOCK_REGION_LENGTH__ : 1K;
  __SIGNATURE_REGION_LENGTH__ = DEFINED(__SIGNATURE_REGION_LENGTH__) ? 
__SIGNATURE_REGION_LENGTH__ : 1K;
  __USER_SIGNATURE_REGION_LENGTH__ = DEFINED(__USER_SIGNATURE_REGION_LENGTH__) 
? __USER_SIGNATURE_REGION_LENGTH__ : 1K;
  MEMORY
  {
text   (rx)   : ORIGIN = __TEXT_REGION_ORIGIN__, LENGTH = 
__TEXT_REGION_LENGTH__
data   (rw!x) : ORIGIN = __DATA_REGION_ORIGIN__, LENGTH = 
__DATA_REGION_LENGTH__
eeprom (rw!x) : ORIGIN = 0x81, LENGTH = __EEPROM_REGION_LENGTH__
fuse  (rw!x) : ORIGIN = 0x82, LENGTH = __FUSE_REGION_LENGTH__
lock  (rw!x) : ORIGIN = 0x83, LENGTH = __LOCK_REGION_LENGTH__
signature (rw!x) : ORIGIN = 0x84, LENGTH = __SIGNATURE_REGION_LENGTH__
user_signatures (rw!x) : ORIGIN = 0x85, LENGTH = 
__USER_SIGNATURE_REGION_LENGTH__
  }
  SECTIONS
  {
/* Read-only sections, merged into text segment: */
.hash0 : { *(.hash)   }
.dynsym  0 : { *(.dynsym) }
.dynstr  0 : { *(.dynstr) }
.gnu.version 0 : { *(.gnu.version)}
.gnu.version_d 0 : { *(.gnu.version_d)}
.gnu.version_r 0 : { *(.gnu.version_r)}
.rel.init0 : { *(.rel.init)   }
.rela.init   0 : { *(.rela.init)  }
.rel.text0 :
  {
*(.rel.text)
  }
.rela.text   0 :
  {
*(.rela.text)
  }
.rel.fini0 : { *(.rel.fini)   }
.rela.fini   0 : { *(.rela.fini)  }
.rel.rodata  0 :
  {
*(.rel.rodata)
  }
.rela.rodata 0 :
  {
*(.rela.rodata)
  }
.rel.data0 :
  {
*(.rel.data)
  }
.rela.data   0 :
  {
*(.rela.data)
  }
.rel.ctors   0 : { *(.rel.ctors)  }
.rela.ctors  0 : { *(.rela.ctors) }
.rel.dtors   0 : { *(.rel.dtors)  }
.rela.dtors  0 : { *(.rela.dtors) }
.rel.got 0 : { *(.rel.got)}
.rela.got0 : { *(.rela.got)   }
.rel.bss 0 : { *(.rel.bss)}
.rela.bss0 : { *(.rela.bss)   }
.rel.plt 0 : { *(.rel.plt)}
.rela.plt0 : { *(.rela.plt)   }
/* Internal text space or external memory.  */
.text 0 :
{
  *(.vectors)
  KEEP(*(.vectors))
  /* For data that needs to reside in the lower 64k of progmem.  */
  /* PR 13812: Placing the trampolines here gives a better chance
 that they will be in range of the code that uses them.  */
  /* The jump trampolines for the 16-bit limited relocs will reside here.  
*/
  *(.trampolines)
  /* avr-libc expects these data to reside in lower 64K. */
  /* For future tablejump instruction arrays for 3 byte pc devices.
 We don't relax jump/call instructions within these sections.  */
  *(.jumptables)
  /* For code that needs to reside in the lower 128k progmem.  */
  *(.lowtext)
  KEEP(SORT(*)(.ctors))
  KEEP(SORT(*)(.dtors))
  /* From this point on, we don't bother about wether the insns are
 below or above the 16 bits boundary.  */
  *(.init0)  /* Start here after reset.  */
  KEEP (*(.init0))
  *(.init1)
  KEEP (*(.init1))
  *(.init2)  /* Clear __zero_reg__, set up stack pointer.  */
  KEEP (*(.init2))
  *(.init3)
  KEEP (*(.init3))
  *(.init4)  /* Initialize data and BSS.  */
  KEEP (*(.init4))
  *(.init5)
  KEEP (*(.init5))
  *(.init6)  /* C++ constructors.  */
  KEEP (*(.init6))
  *(.init7)
  KEEP (*(.init7))
  *(.init8)
  KEEP (*(.init8))
  *(.init9)  /* Call main().  */
  KEEP (*(.init9))
  *(.tex

[PATCH] D144533: [clang][driver] Do not emit default '-Tdata' for AVR devices

2023-02-21 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: aykevl, MaskRay.
Herald added subscribers: Jim, dylanmckay.
Herald added a project: All.
benshi001 requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan.
Herald added a project: clang.

Different AVR devices have different data regions. Current clang
driver emits a default '-Tdata' option to the linker. This way
works fine if there is no user specified linker script, but it
will make conflicts if there is one.

A better solution for deciding the default data region in the
default linker script of gnu avr-ld is emiting
"--defsym=__DATA_REGION_ORIGIN__=..." instead.

Fixes https://github.com/llvm/llvm-project/issues/60362


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144533

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -1,44 +1,44 @@
 // RUN: %clang -### --target=avr -mmcu=at90s2313 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKA %s
-// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lat90s2313" {{.*}} "--end-group" "-mavr2"
+// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800060" "--start-group" {{.*}} "-lat90s2313" 
{{.*}} "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKB %s
-// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" "--start-group" {{.*}} 
"-lat90s8515" {{.*}} "--end-group" "-mavr2"
+// LINKB: {{".*ld.*"}} {{.*}} "--defsym=__DATA_REGION_ORIGIN__=0x800060" 
"--start-group" {{.*}} "-lat90s8515" {{.*}} "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKC %s
-// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" "--start-group" {{.*}} "-lattiny13" {{.*}} "--end-group" 
"-mavr25"
+// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800060" "--start-group" {{.*}} "-lattiny13" 
{{.*}} "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=attiny44 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKD %s
-// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lattiny44" {{.*}} "--end-group" "-mavr25"
+// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800060" "--start-group" {{.*}} "-lattiny44" 
{{.*}} "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=atmega103 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKE %s
-// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-latmega103" {{.*}} "--end-group" "-mavr31"
+// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800060" "--start-group" {{.*}} "-latmega103" 
{{.*}} "--end-group" "-mavr31"
 
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKF %s
-// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega8u2" {{.*}} "--end-group" "-mavr35"
+// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800100" "--start-group" {{.*}} "-latmega8u2" 
{{.*}} "--end-group" "-mavr35"
 
 // RUN: %clang -### --target=avr -mmcu=atmega48pa --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKG %s
-// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega48pa" {{.*}} "--end-group" "-mavr4"
+// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800100" "--start-group" {{.*}} 
"-latmega48pa" {{.*}} "--end-group" "-mavr4"
 
 // RUN: %clang -### --target=avr -mmcu=atmega328 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega328" {{.*}} "--end-group" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} 
"--defsym=__DATA_REGION_ORIGIN__=0x800100" "--start-group" {{.*}} "-latmega328" 
{{.*}} "--end-group" "-mavr5"
 
 // RUN: %clang -### --target=avr -mmcu=atmega1281 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKI %s
-// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" 
"--start-group" {{.*}} "-latmega1281" {{.*}} "--end-group" "-mavr51"
+// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} 
"

[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-21 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:222
+  tooling::addExpandedResponseFiles(Cmd, Command.Directory, Tokenizer, *FS);
+  tooling::addTargetAndModeForProgramName(Cmd, Cmd.front());
   auto &OptTable = clang::driver::getDriverOptTable();

DmitryPolukhin wrote:
> nridge wrote:
> > DmitryPolukhin wrote:
> > > nridge wrote:
> > > > nridge wrote:
> > > > > The target needs to be added **after** the call to 
> > > > > `SystemIncludeExtractor` later in this function (this is what D138546 
> > > > > is trying to fix). The reason is that `SystemIncludeExtractor` 
> > > > > includes any `--target` flag in the compiler driver being queried for 
> > > > > system includes, which may be gcc, which does not support `--target`.
> > > > (I guess we could make that change separately in D138546, but if we're 
> > > > changing the place where the `--target` is added in this patch, I 
> > > > figure we might as well move it directly to the desired place.)
> > > I think there are order problems here:
> > > - we need `--driver-mode=cl` injected here to make check on line #229 
> > > work as expected
> > > - if we don't inject it driver mode here, command line edits won't see 
> > > the change; see how I modified test 
> > > clangd/unittests/CompileCommandsTests.cpp line #203, with D138546 edits 
> > > were not applied properly to driver mode
> > > 
> > > I'll double check how it works on Windows but I expect that moving it 
> > > after SystemIncludeExtractor will break proper driver mode detection.
> > > I think there are order problems here:
> > > - we need `--driver-mode=cl` injected here to make check on line #229 
> > > work as expected
> > 
> > Looking at the [line in 
> > question](https://searchfox.org/llvm/rev/0cbb8ec030e23c0e13331b5d54155def8c901b36/clang-tools-extra/clangd/CompileCommands.cpp#213),
> >  it calls `driver::getDriverMode()` which [falls back on extracting the 
> > driver 
> > mode](https://searchfox.org/llvm/rev/0cbb8ec030e23c0e13331b5d54155def8c901b36/clang/lib/Driver/Driver.cpp#6407)
> >  from the program name anyways -- so I think that should be fine.
> > 
> > > - if we don't inject it driver mode here, command line edits won't see 
> > > the change; see how I modified test 
> > > clangd/unittests/CompileCommandsTests.cpp line #203, with D138546 edits 
> > > were not applied properly to driver mode
> > 
> > I'm not following the motivation for this test. Is there any real-world use 
> > case which requires the command line edits seeing the `--driver-mode` 
> > parameter?
> > I'm not following the motivation for this test. Is there any real-world use 
> > case which requires the command line edits seeing the `--driver-mode` 
> > parameter?
> 
> @nridge, it will break existing behaviour when user was able to remove these 
> inserted options like this `CompileFlags: {Remove: ['--driver-mode=*', 
> '--target=*']}`. If I move call of `addTargetAndModeForProgramName` after 
> `SystemIncludeExtractor`r, inserted options will stay in list. User may only 
> override it with `CompileFlags.Compiler` but it will override all compilers. 
> I don't know is it real problem or not so if you think I should still move it 
> after `SystemIncludeExtractor`, I'll do it.
> @nridge, it will break existing behaviour when user was able to remove these 
> inserted options like this `CompileFlags: {Remove: ['--driver-mode=*', 
> '--target=*']}`.

Thanks. I'll leave the final word to @kadircet here but in my opinion, being 
able to remove those flags via `Remove` is not important; as you say, the user 
can change the `Compiler` to influence the driver mode if needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D142569: [OpenMP] Introduce kernel environment

2023-02-21 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

Pass two benchmarks: XSBench and RSBench.
The patch will break the old plugins as well. I'm wondering we might want to 
land it after D142820 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

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


[PATCH] D142569: [OpenMP] Introduce kernel environment

2023-02-21 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 2 inline comments as done.
tianshilei1992 added inline comments.



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:583
+  if (!KernelEnvOrError)
+return KernelEnvOrError.takeError();
+

jdoerfert wrote:
> We used to default to SPMD w/o a _exec_mode. Unsure if this will cause 
> problems. I am inclined to allow missing _kernel_env as well and use SPMD 
> then.
Now we need the global variable to call `target_init` at runtime, so missing it 
sounds like a bug. I'm not sure if we would optimize the symbol out, but I 
kinda doubt it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

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


[PATCH] D142569: [OpenMP] Introduce kernel environment

2023-02-21 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 499355.
tianshilei1992 added a comment.

rebase, update tests, fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/Headers/amdgcn_openmp_device_math_c.c
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/libomptarget/DeviceRTL/CMakeLists.txt
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/include/Interface.h
  openmp/libomptarget/DeviceRTL/include/State.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/Debug.cpp
  openmp/libomptarget/DeviceRTL/src/Kernel.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp
  openmp/libomptarget/include/DeviceEnvironment.h
  openmp/libomptarget/include/Environment.h
  openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins/cuda/src/rtl.cpp

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked 2 inline comments as done.
ccotter added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp:103-125
+  StatementMatcher MoveCallMatcher = callExpr(
+  anyOf(callee(functionDecl(hasName("::std::move"))),
+callee(unresolvedLookupExpr(hasAnyDeclaration(
+namedDecl(hasUnderlyingDecl(hasName("::std::move"))),
+  argumentCountIs(1), hasArgument(0, moveArgumentOf(StrictMode, Param)));
+
+  SmallVector Matches;

PiotrZSL wrote:
> ```
> unless(hasDescendant(callExpr(
>   anyOf(callee(functionDecl(hasName("::std::move"))),
> callee(unresolvedLookupExpr(hasAnyDeclaration(
> namedDecl(hasUnderlyingDecl(hasName("::std::move"))),
>   argumentCountIs(1), hasArgument(0, moveArgumentOf(StrictMode, Param)
> ```
> 
> any here you could also check lambdas, if you want to ignore copies, but not 
> should why you should do that, but you can always bind this to "move", or 
> implement lambda checking as matcher 
> unless(hasAncestor(lambdaExpr(isCapturedByCopy
> 
> Simply as you have some tests already, try pack as much as you can into 
> registerMatchers, because once you split this across multiple submatches in 
> diffrent functions, then it could be hard to maintain.
Good call. Single matcher expr is cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 499350.
ccotter added a comment.

- Use bool
- Combine into a single matcher


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,323 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,STRICT -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,UNNAMED -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: false}]}" -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template  struct remove_reference { typedef _Tp type; };
+template  struct remove_reference<_Tp&> { typedef _Tp type; };
+template  struct remove_reference<_Tp&&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_unnamed(Obj&&) {}
+// CHECK-MESSAGES-UNNAMED: :[[@LINE-1]]:31: warning: rvalue reference parameter '' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parame

[PATCH] D144035: [llvm] Ensure SCEV does not replace aliases with their aliasees

2023-02-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D144035#4143030 , @pcc wrote:

> Passes shouldn't be replacing aliases with aliasees in general, see D66606 
> . The right fix is to fix SCEV to not do 
> that.

Updated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144035

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


[PATCH] D144035: [hwasan] Ensure SCEV does not replace aliases with their aliasees

2023-02-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 499349.
leonardchan retitled this revision from "[hwasan] Ensure hwasan aliases do not 
have ODR linkage" to "[hwasan] Ensure SCEV does not replace aliases with their 
aliasees".
leonardchan edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144035

Files:
  clang/test/CodeGenCXX/pr60668.cpp
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/no-follow-alias.ll


Index: llvm/test/Analysis/ScalarEvolution/no-follow-alias.ll
===
--- /dev/null
+++ llvm/test/Analysis/ScalarEvolution/no-follow-alias.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by 
utils/update_analyze_test_checks.py
+; RUN: opt -passes='print' -disable-output %s 2>&1 | 
FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+@glob.private = private constant [32 x i32] zeroinitializer
+@glob = linkonce_odr hidden alias [32 x i32], inttoptr (i64 add (i64 ptrtoint 
(ptr @glob.private to i64), i64 1234) to ptr)
+
+define hidden void @func(i64 %idx) local_unnamed_addr {
+; CHECK-LABEL: 'func'
+; CHECK-NEXT:  Classifying expressions for: @func
+; CHECK-NEXT:%arrayidx = getelementptr inbounds [32 x i32], ptr @glob, i64 
0, i64 %idx
+; CHECK-NEXT:--> ((4 * %idx) + @glob) U: [0,-1) S: 
[-9223372036854775808,9223372036854775807)
+; CHECK-NEXT:  Determining loop execution counts for: @func
+;
+  %arrayidx = getelementptr inbounds [32 x i32], ptr @glob, i64 0, i64 %idx
+  ret void
+}
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7449,10 +7449,6 @@
   } else if (ConstantInt *CI = dyn_cast(V))
 return getConstant(CI);
   else if (GlobalAlias *GA = dyn_cast(V)) {
-if (!GA->isInterposable()) {
-  Ops.push_back(GA->getAliasee());
-  return nullptr;
-}
 return getUnknown(V);
   } else if (!isa(V))
 return getUnknown(V);
@@ -7639,7 +7635,7 @@
   } else if (ConstantInt *CI = dyn_cast(V))
 return getConstant(CI);
   else if (GlobalAlias *GA = dyn_cast(V))
-return GA->isInterposable() ? getUnknown(V) : getSCEV(GA->getAliasee());
+return getUnknown(V);
   else if (!isa(V))
 return getUnknown(V);
 
Index: clang/test/CodeGenCXX/pr60668.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr60668.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang --target=aarch64-unknown-linux-gnu -O1 -fvisibility=hidden \
+// RUN:   -fsanitize=hwaddress -fsanitize=undefined -std=c++17 -fno-exceptions 
\
+// RUN:   -fno-rtti -c %s -S -o - | FileCheck %s
+
+struct AndroidSizeClassConfig {
+  static constexpr unsigned Classes[] = {
+  0x00020, 0x00030, 0x00040, 0x00050, 0x00060, 0x00070, 0x00090, 0x000b0,
+  0x000c0, 0x000e0, 0x00120, 0x00160, 0x001c0, 0x00250, 0x00320, 0x00450,
+  0x00670, 0x00830, 0x00a10, 0x00c30, 0x01010, 0x01210, 0x01bd0, 0x02210,
+  0x02d90, 0x03790, 0x04010, 0x04810, 0x05a10, 0x07310, 0x08210, 0x10010,
+  };
+};
+
+static const unsigned NumClasses =
+sizeof(AndroidSizeClassConfig::Classes) / 
sizeof(AndroidSizeClassConfig::Classes[0]);
+
+void func(unsigned);
+
+void printMap() {
+  for (unsigned I = 0; I < NumClasses; I++) {
+func(AndroidSizeClassConfig::Classes[I]);
+  }
+}
+
+// CHECK-LABEL: _Z8printMapv
+// CHECK:adrpx{{.*}}, 
:pg_hi21_nc:_ZN22AndroidSizeClassConfig7ClassesE
+// CHECK:movkx{{.*}}, 
#:prel_g3:_ZN22AndroidSizeClassConfig7ClassesE+4294967296
+// CHECK:add x{{.*}}, x19, 
:lo12:_ZN22AndroidSizeClassConfig7ClassesE


Index: llvm/test/Analysis/ScalarEvolution/no-follow-alias.ll
===
--- /dev/null
+++ llvm/test/Analysis/ScalarEvolution/no-follow-alias.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt -passes='print' -disable-output %s 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+@glob.private = private constant [32 x i32] zeroinitializer
+@glob = linkonce_odr hidden alias [32 x i32], inttoptr (i64 add (i64 ptrtoint (ptr @glob.private to i64), i64 1234) to ptr)
+
+define hidden void @func(i64 %idx) local_unnamed_addr {
+; CHECK-LABEL: 'func'
+; CHECK-NEXT:  Classifying expressions for: @func
+; CHECK-NEXT:%arrayidx = getelementptr inbounds [32 x i32], ptr @glob, i64 0, i64 %idx
+; CHECK-NEXT:--> ((4 * %idx) + @glob) U: [0,-1) S: [-9223372036854775808,9223372036854775807)
+; CHECK-NEXT:  Determining loop execution counts for: @func
+;
+  %arrayidx = getelementptr inbounds 

[PATCH] D141899: [IR][X86] Remove X86AMX type in LLVM IR instead of target extension

2023-02-21 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

In D141899#4065375 , @nikic wrote:

> In D141899#4061237 , @zixuan-wu 
> wrote:
>
>> With considering 
>> https://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility I 
>> think we need make consensus to choose one option from following 2 options.
>>
>> 1. Remove X86amx type in IR totally. (what I am doing now)
>> 2. Without removing X86amx type in IR, just upgrade the x86amx type to 
>> target extension and also upgrade bitcast llvm instruction to 
>> intrinsic(required). It also includes changing the testcase to target 
>> extension type.
>
> I believe the right option is:
>
> 3. Remove x86_amx type from the (in-memory) IR representation, but support an 
> auto-upgrade for bitcode only.
>
> We do need bitcode auto-upgrade support as a matter of policy, and we 
> shouldn't support both type representation at the same time, that would 
> defeat the point of the change.
>
> In D141899#4061174 , @LuoYuanke 
> wrote:
>
>> I think target extension type is nice, if it is introduced 2 years ago I 
>> would vote for it. However my concern is the compatibility issue as I 
>> explained. We need to be compatible to the IR that built by previous 
>> compiler, and be compatible to the 3rd party software that based on the 
>> x86_amx type. I can't predict more risks for now if we replace an LLVM IR 
>> type, but I believe there is big risk hidden.
>
> Due to bitcode auto-upgrade, compatibility with old IR is retained. As long 
> as we avoid some of the API changes here, the impact on downstream code 
> should be fairly minimal. (Though as already pointed out, downstream impact 
> generally doesn't figure into LLVM design decisions anyway.)

Deal. And because I am on busy for a long time and it is also better to let 
intel guy handle x86-related feature, I am happy with the patch being 
commandeered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141899

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


[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Pete Steinfeld via Phabricator via cfe-commits
PeteSteinfeld added a comment.



> @PeteSteinfeld, I think vzakhari's most recent commit 
> 
>  fixes this.

Thanks, @ elmcdonough, and @vzakhari!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Ethan Luis McDonough via Phabricator via cfe-commits
elmcdonough added a comment.

In D143301#4143241 , @PeteSteinfeld 
wrote:

> In D143301#4143108 , @vzakhari 
> wrote:
>
>> The new tests fail to link:
>
> That is, these new tests cause check-flang to fail.  @elmcdonough, can you 
> please fix things so that check-flang no longer fails?

Thank you for pointing this out, @vzakhari.

@PeteSteinfeld, I think vzakhari's most recent commit 

 fixes this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h:32-33
+private:
+  const unsigned StrictMode : 1;
+  const unsigned IgnoreUnnamedParams : 1;
+};

PiotrZSL wrote:
> use bool here, or it could cause some issues, you wont save anything by using 
> bits. class alignment is already 8.
> problem is that you read bools but in storeOptions you store ints, and when 
> dump-config will be used it will show 1/0 not true/false.
> 
Ah, I happened to see ArgumentCommentCheck.h which seems to be lone check that 
uses bits...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Pete Steinfeld via Phabricator via cfe-commits
PeteSteinfeld added a comment.

In D143301#4143108 , @vzakhari wrote:

> The new tests fail to link:

That is, these new tests cause check-flang to fail.  @elmcdonough, can you 
please fix things so that check-flang no longer fails?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

Simplified matchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D144074: [clangd] Hide inlay hints when using a macro as a calling argument that with a param comment

2023-02-21 Thread Younan Zhang via Phabricator via cfe-commits
zyounan added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144074

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 499341.
ccotter marked 4 inline comments as done.
ccotter added a comment.

- Simplify matcher


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,323 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: false},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,STRICT -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: true}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,UNNAMED -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: true},{key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams, value: false}]}" -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template  struct remove_reference { typedef _Tp type; };
+template  struct remove_reference<_Tp&> { typedef _Tp type; };
+template  struct remove_reference<_Tp&&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_unnamed(Obj&&) {}
+// CHECK-MESSAGES-UNNAMED: :[[@LINE-1]]:31: warning: rvalue reference parameter '' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalu

[PATCH] D143840: [clang] Add the check of membership for the issue #58674 and improve the lookup process

2023-02-21 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 499339.
lime edited the summary of this revision.
lime added a comment.

Updated as suggested. I will do a stage-2 build before landing the patch to 
confirm whether it would case another crash, and it takes time.


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

https://reviews.llvm.org/D143840

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/decl-ref-inheritance.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/test/CodeGenCXX/decl-ref-inheritance.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/decl-ref-inheritance.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: [[FOO:%.+]] = type { i32 }
+struct foo {
+  int val;
+};
+
+template  struct bar : T {
+};
+
+struct baz : bar {
+  // CHECK-LABEL: define{{.*}} i32 @_ZN3baz3getEv
+  // CHECK: {{%.+}} = getelementptr inbounds [[FOO]], ptr {{%.+}}, i32 0, i32 0
+  int get() {
+return val;
+  }
+};
+
+int qux() {
+  auto f = baz{};
+  return f.get();
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2698,20 +2698,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupInDependentTypes) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
   

[PATCH] D144320: [Clang][OpenMP] Update tests using update_cc_test_checks.py

2023-02-21 Thread Shilei Tian 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 rG270f533e8b0c: [Clang][OpenMP] Update tests using 
update_cc_test_checks.py (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144320

Files:
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp

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


[PATCH] D144320: [Clang][OpenMP] Update tests using update_cc_test_checks.py

2023-02-21 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 499337.
tianshilei1992 added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144320

Files:
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp

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


[PATCH] D144296: [clang-format] Rewrite how indent is reduced for compacted namespaces

2023-02-21 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 499330.
rymiel added a comment.

Inline and remove LevelIndentTracker::skipLine


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144296

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4431,6 +4431,46 @@
"int k; }} // namespace out::mid",
Style));
 
+  verifyFormat("namespace A { namespace B { namespace C {\n"
+   "  int i;\n"
+   "}}} // namespace A::B::C\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   "namespace A { namespace B {\n"
+   "namespace C {\n"
+   "  int i;\n"
+   "}} // namespace B::C\n"
+   "} // namespace A\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   Style);
+
+  verifyFormat("namespace A { namespace B { namespace C {\n"
+   "#ifdef FOO\n"
+   "  int i;\n"
+   "#endif\n"
+   "}}} // namespace A::B::C\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   "namespace A { namespace B {\n"
+   "namespace C {\n"
+   "#ifdef FOO\n"
+   "  int i;\n"
+   "#endif\n"
+   "}} // namespace B::C\n"
+   "} // namespace A\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   Style);
+
   Style.NamespaceIndentation = FormatStyle::NI_Inner;
   EXPECT_EQ("namespace out { namespace in {\n"
 "  int i;\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -59,7 +59,8 @@
 Offset = getIndentOffset(*Line.First);
 // Update the indent level cache size so that we can rely on it
 // having the right size in adjustToUnmodifiedline.
-skipLine(Line, /*UnknownIndent=*/true);
+if (Line.Level >= IndentForLevel.size())
+  IndentForLevel.resize(Line.Level + 1, -1);
 if (Style.IndentPPDirectives != FormatStyle::PPDIS_None &&
 (Line.InPPDirective ||
  (Style.IndentPPDirectives == FormatStyle::PPDIS_BeforeHash &&
@@ -80,13 +81,6 @@
   Indent = Line.Level * Style.IndentWidth + Style.ContinuationIndentWidth;
   }
 
-  /// Update the indent state given that \p Line indent should be
-  /// skipped.
-  void skipLine(const AnnotatedLine &Line, bool UnknownIndent = false) {
-if (Line.Level >= IndentForLevel.size())
-  IndentForLevel.resize(Line.Level + 1, UnknownIndent ? -1 : Indent);
-  }
-
   /// Update the level indent to adapt to the given \p Line.
   ///
   /// When a line is not formatted, we move the subsequent lines on the same
@@ -366,20 +360,27 @@
 // instead of TheLine->First.
 
 if (Style.CompactNamespaces) {
-  if (auto nsToken = TheLine->First->getNamespaceToken()) {
-int i = 0;
-unsigned closingLine = TheLine->MatchingClosingBlockLineIndex - 1;
-for (; I + 1 + i != E &&
-   nsToken->TokenText == getNamespaceTokenText(I[i + 1]) &&
-   closingLine == I[i + 1]->MatchingClosingBlockLineIndex &&
-   I[i + 1]->Last->TotalLength < Limit;
- i++, --closingLine) {
-  // No extra indent for compacted namespaces.
-  IndentTracker.skipLine(*I[i + 1]);
+  if (const auto *NSToken = TheLine->First->getNamespaceToken()) {
+int J = 1;
+assert(TheLine->MatchingClosingBlockLineIndex > 0);
+for (auto ClosingLineIndex = TheLine->MatchingClosingBlockLineIndex - 1;
+ I + J != E && NSToken->TokenText == getNamespaceTokenText(I[J]) &&
+ ClosingLineIndex == I[J]->MatchingClosingBlockLineIndex &&
+ I[J]->Last->TotalLength < Limit;
+ ++J, --ClosingLineIndex) {
+  Limit -= I[J]->Last->TotalLength;
 
-  Limit -= I[i + 1]->Last->TotalLength;
+  // Reduce indent level for bodies of namespaces which were compacted,
+  // but only if their content was indented in the first place.
+  auto *ClosingLine = AnnotatedLines.begin() + ClosingLineIndex + 1;
+  auto OutdentBy = I[J]->Level - TheLine->Level;
+  for (auto *CompactedLine = I + J; CompactedLine <= ClosingLine;
+   ++CompactedLine) {
+if (!(*CompactedLine)->InPPDirective)
+  

[PATCH] D144320: [Clang][OpenMP] Update tests using update_cc_test_checks.py

2023-02-21 Thread Shilei Tian 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 rG61faf261506f: [Clang][OpenMP] Update tests using 
update_cc_test_checks.py (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144320

Files:
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp

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


[PATCH] D144296: [clang-format] Rewrite how indent is reduced for compacted namespaces

2023-02-21 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:387
+if (!(*compactedLine)->InPPDirective)
+  (*compactedLine)->Level-= dedentBy;
+  }

owenpan wrote:
> Did git-clang-format miss this?
Nope, I forgot to amend the change!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144296

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


[PATCH] D144296: [clang-format] Rewrite how indent is reduced for compacted namespaces

2023-02-21 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 499328.
rymiel marked 7 inline comments as done.
rymiel added a comment.

Apply suggestions and add extra test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144296

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4431,6 +4431,46 @@
"int k; }} // namespace out::mid",
Style));
 
+  verifyFormat("namespace A { namespace B { namespace C {\n"
+   "  int i;\n"
+   "}}} // namespace A::B::C\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   "namespace A { namespace B {\n"
+   "namespace C {\n"
+   "  int i;\n"
+   "}} // namespace B::C\n"
+   "} // namespace A\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   Style);
+
+  verifyFormat("namespace A { namespace B { namespace C {\n"
+   "#ifdef FOO\n"
+   "  int i;\n"
+   "#endif\n"
+   "}}} // namespace A::B::C\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   "namespace A { namespace B {\n"
+   "namespace C {\n"
+   "#ifdef FOO\n"
+   "  int i;\n"
+   "#endif\n"
+   "}} // namespace B::C\n"
+   "} // namespace A\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   Style);
+
   Style.NamespaceIndentation = FormatStyle::NI_Inner;
   EXPECT_EQ("namespace out { namespace in {\n"
 "  int i;\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -366,20 +366,27 @@
 // instead of TheLine->First.
 
 if (Style.CompactNamespaces) {
-  if (auto nsToken = TheLine->First->getNamespaceToken()) {
-int i = 0;
-unsigned closingLine = TheLine->MatchingClosingBlockLineIndex - 1;
-for (; I + 1 + i != E &&
-   nsToken->TokenText == getNamespaceTokenText(I[i + 1]) &&
-   closingLine == I[i + 1]->MatchingClosingBlockLineIndex &&
-   I[i + 1]->Last->TotalLength < Limit;
- i++, --closingLine) {
-  // No extra indent for compacted namespaces.
-  IndentTracker.skipLine(*I[i + 1]);
+  if (const auto *NSToken = TheLine->First->getNamespaceToken()) {
+int J = 1;
+assert(TheLine->MatchingClosingBlockLineIndex > 0);
+for (auto ClosingLineIndex = TheLine->MatchingClosingBlockLineIndex - 
1;
+ I + J != E && NSToken->TokenText == getNamespaceTokenText(I[J]) &&
+ ClosingLineIndex == I[J]->MatchingClosingBlockLineIndex &&
+ I[J]->Last->TotalLength < Limit;
+ ++J, --ClosingLineIndex) {
+  Limit -= I[J]->Last->TotalLength;
 
-  Limit -= I[i + 1]->Last->TotalLength;
+  // Reduce indent level for bodies of namespaces which were compacted,
+  // but only if their content was indented in the first place.
+  auto *ClosingLine = AnnotatedLines.begin() + ClosingLineIndex + 1;
+  auto OutdentBy = I[J]->Level - TheLine->Level;
+  for (auto *CompactedLine = I + J; CompactedLine <= ClosingLine;
+   ++CompactedLine) {
+if (!(*CompactedLine)->InPPDirective)
+  (*CompactedLine)->Level -= OutdentBy;
+  }
 }
-return i;
+return J - 1;
   }
 
   if (auto nsToken = getMatchingNamespaceToken(TheLine, AnnotatedLines)) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4431,6 +4431,46 @@
"int k; }} // namespace out::mid",
Style));
 
+  verifyFormat("namespace A { namespace B { namespace C {\n"
+   "  int i;\n"
+   "}}} // namespace A::B::C\n"
+   "int main() {\n"
+   "  if (true)\n"
+   "return 0;\n"
+   "}",
+   "namespace A { namespace B {\n"
+   "namespace C {\n"
+   "  int i;\n"
+   "}} // namespace B::C\n"
+   "} // namespace A\n"
+   "int main() {\n"
+   "

[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Slava Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

The new tests fail to link:

  flang-new: warning: The warning option '-Wextra' is not supported
  /usr/bin/ld: cannot find -lFortran_main
  /usr/bin/ld: cannot find -lFortranRuntime
  /usr/bin/ld: cannot find -lFortranDecimal

Is the linking really necessary?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[PATCH] D136515: [builtins] Add __builtin_assume_separate_storage.

2023-02-21 Thread David Goldblatt via Phabricator via cfe-commits
davidtgoldblatt added a comment.

Summarizing a brief offline discussion: I think it's probably fine to just get 
rid of the SemaChecking changes entirely; type-checking here is done by the 
generalized builtin-handling code. I'll do the change if there's no objection.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136515

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


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-02-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I completely agree with @steakhal, these should be note tags:

- The "visitor way" is to reverse-engineer the exploded graph after the fact.
- The "slightly more sophisticated visitor way" is have checker callbacks leave 
extra hints in the graph to assist reverse engineering, which is what you 
appear to be trying to do.
- The "note tag" way is to simply capture that information from inside checker 
callbacks in the form of lambda captures. It eliminates the need to think about 
how to store the information in the state (it's stored in the program point 
instead), or how to structure it.

I also completely agree with @steakhal that the intermediate notes are 
valuable. In the motivating example, ideally both `strtol` and `getenv` need a 
note ("taint propagated here" and "taint originated here" respectively).

The challenging part with note tags is how do you figure out whether your bug 
report is taint-related. The traditional solution is to check the `BugType` but 
in this case an indeterminate amount of checkers may emit taint-related 
reports. I think now's a good time to include a "generic data map"-like data 
structure in `PathSensitiveBugReport` objects, so that checkers could put some 
data there during `emitReport()`, which can be picked up by note tags and 
potentially mutated in the process. For example, you can introduce a set of 
tracked tainted symbols there, which will be pre-populated by the checker with 
the final tainted symbol, then every time a note tag discovers that a symbol in 
the set becomes a target of taint propagation, it removes the symbol from the 
set and replaces it with the symbols from which its taint originated, so that 
later note tags would react on these new symbols instead.


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

https://reviews.llvm.org/D144269

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


[PATCH] D144136: Add a "remark" to report on array accesses

2023-02-21 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 499321.
void added a comment.

Report when there's a non-constant access:

array_access_report.c:32:17: remark: accessing fixed sized array 'int[16]' by 
'index' [-Rarray-bounds]

  report_size(p->array, index);
  ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144136

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -16236,8 +16236,22 @@
 return;
 
   Expr::EvalResult Result;
-  if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects))
+  if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects)) {
+if (!IsUnboundedArray) {
+  SmallString<128> sizeString;
+  llvm::raw_svector_ostream OS(sizeString);
+
+  OS << "'";
+  IndexExpr->printPretty(OS, nullptr, getPrintingPolicy());
+  OS << "'";
+
+  Context.getDiagnostics().Report(
+  BaseExpr->getBeginLoc(), diag::remark_array_access)
+  << 0 << ArrayTy->desugar() << OS.str();
+}
+
 return;
+  }
 
   llvm::APSInt index = Result.Val.getInt();
   if (IndexNegated) {
@@ -16352,6 +16366,10 @@
 else if (size.getBitWidth() < index.getBitWidth())
   size = size.zext(index.getBitWidth());
 
+Context.getDiagnostics().Report(
+BaseExpr->getBeginLoc(), diag::remark_array_access)
+<< 0 << ArrayTy->desugar() << toString(index, 10, true);
+
 // For array subscripting the index must be less than size, but for pointer
 // arithmetic also allow the index (offset) to be equal to size since
 // computing the next address after the end of the array is legal and
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9450,6 +9450,10 @@
 def note_array_declared_here : Note<
   "array %0 declared here">;
 
+def remark_array_access : Remark<
+  "accessing %select{fixed|dynamic}0 sized array %1 by %2">,
+  InGroup;
+
 def warn_inconsistent_array_form : Warning<
   "argument %0 of type %1 with mismatched bound">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1304,6 +1304,9 @@
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
 def MisExpect : DiagGroup<"misexpect">;
 
+// Array bounds remarks.
+def ArrayBoundsRemarks : DiagGroup<"array-bounds">;
+
 // AddressSanitizer frontend instrumentation remarks.
 def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;
 


Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -16236,8 +16236,22 @@
 return;
 
   Expr::EvalResult Result;
-  if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects))
+  if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects)) {
+if (!IsUnboundedArray) {
+  SmallString<128> sizeString;
+  llvm::raw_svector_ostream OS(sizeString);
+
+  OS << "'";
+  IndexExpr->printPretty(OS, nullptr, getPrintingPolicy());
+  OS << "'";
+
+  Context.getDiagnostics().Report(
+  BaseExpr->getBeginLoc(), diag::remark_array_access)
+  << 0 << ArrayTy->desugar() << OS.str();
+}
+
 return;
+  }
 
   llvm::APSInt index = Result.Val.getInt();
   if (IndexNegated) {
@@ -16352,6 +16366,10 @@
 else if (size.getBitWidth() < index.getBitWidth())
   size = size.zext(index.getBitWidth());
 
+Context.getDiagnostics().Report(
+BaseExpr->getBeginLoc(), diag::remark_array_access)
+<< 0 << ArrayTy->desugar() << toString(index, 10, true);
+
 // For array subscripting the index must be less than size, but for pointer
 // arithmetic also allow the index (offset) to be equal to size since
 // computing the next address after the end of the array is legal and
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9450,6 +9450,10 @@
 def note_array_declared_here : Note<
   "array %0 declared here">;
 
+def remark_array_access : Remark<
+  "accessing %select{fixed|dynamic}0 sized array %1 by %2">,
+  InGroup;
+
 def warn_inconsistent_array_form : Warning<
   "argument %0 of type %1 with misma

[PATCH] D144035: [hwasan] Ensure hwasan aliases do not have ODR linkage

2023-02-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc requested changes to this revision.
pcc added a comment.
This revision now requires changes to proceed.

Passes shouldn't be replacing aliases with aliasees in general, see D66606 
. The right fix is to fix SCEV to not do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144035

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


[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-02-21 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc marked an inline comment as done.
bryanpkc added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8874
   case SVETypeFlags::EltTyBool64:
+  case SVETypeFlags::EltTyBool128:
 return Builder.getInt1Ty();

kmclaughlin wrote:
> Is it necessary to add an `EltTypeBool128`? I think the EmitSVEPredicateCast 
> call in EmitSMELd1St1 is creating a vector based on the memory element type 
> and not the predicate type?
You are right, `EltTypeBool128` is not used right now; I can remove it. When we 
started working on the pre-ACLE intrinsics in our downstream compiler, we were 
planning to add something like `svptrue_b128`, even though the hardware `PTRUE` 
instruction doesn't support the Q size specifier. It is still not clear to me 
how the ACLE wants users to create a predicate vector for a call to a `_za128` 
intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127910

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


[libunwind] 141471a - [runtimes] Remove unused functions from Handle{Libcxx,Libunwind}Flags.cmake

2023-02-21 Thread Nikolas Klauser via cfe-commits

Author: Nikolas Klauser
Date: 2023-02-22T00:38:44+01:00
New Revision: 141471a0cbf2d029899b29baf1a54a238f6067f9

URL: 
https://github.com/llvm/llvm-project/commit/141471a0cbf2d029899b29baf1a54a238f6067f9
DIFF: 
https://github.com/llvm/llvm-project/commit/141471a0cbf2d029899b29baf1a54a238f6067f9.diff

LOG: [runtimes] Remove unused functions from Handle{Libcxx,Libunwind}Flags.cmake

Reviewed By: phosek, #libunwind, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D144400

Added: 


Modified: 
libcxx/cmake/Modules/HandleLibcxxFlags.cmake
libunwind/cmake/Modules/HandleLibunwindFlags.cmake

Removed: 




diff  --git a/libcxx/cmake/Modules/HandleLibcxxFlags.cmake 
b/libcxx/cmake/Modules/HandleLibcxxFlags.cmake
index ec1434184f82c..ffd859e4b1f22 100644
--- a/libcxx/cmake/Modules/HandleLibcxxFlags.cmake
+++ b/libcxx/cmake/Modules/HandleLibcxxFlags.cmake
@@ -36,31 +36,6 @@ macro(add_flags_if_supported)
   endforeach()
 endmacro()
 
-# Add a list of flags to 'LIBCXX_COMPILE_FLAGS'.
-macro(add_compile_flags)
-  foreach(f ${ARGN})
-list(APPEND LIBCXX_COMPILE_FLAGS ${f})
-  endforeach()
-endmacro()
-
-# If 'condition' is true then add the specified list of flags to
-# 'LIBCXX_COMPILE_FLAGS'
-macro(add_compile_flags_if condition)
-  if (${condition})
-add_compile_flags(${ARGN})
-  endif()
-endmacro()
-
-# For each specified flag, add that flag to 'LIBCXX_COMPILE_FLAGS' if the
-# flag is supported by the C++ compiler.
-macro(add_compile_flags_if_supported)
-  foreach(flag ${ARGN})
-  mangle_name("${flag}" flagname)
-  check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
-  add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
-  endforeach()
-endmacro()
-
 # Add a list of flags to 'LIBCXX_LINK_FLAGS'.
 macro(add_link_flags)
   foreach(f ${ARGN})
@@ -68,24 +43,6 @@ macro(add_link_flags)
   endforeach()
 endmacro()
 
-# If 'condition' is true then add the specified list of flags to
-# 'LIBCXX_LINK_FLAGS'
-macro(add_link_flags_if condition)
-  if (${condition})
-add_link_flags(${ARGN})
-  endif()
-endmacro()
-
-# For each specified flag, add that flag to 'LIBCXX_LINK_FLAGS' if the
-# flag is supported by the C++ compiler.
-macro(add_link_flags_if_supported)
-  foreach(flag ${ARGN})
-mangle_name("${flag}" flagname)
-check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
-add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
-  endforeach()
-endmacro()
-
 # Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
 macro(add_library_flags)
   foreach(lib ${ARGN})

diff  --git a/libunwind/cmake/Modules/HandleLibunwindFlags.cmake 
b/libunwind/cmake/Modules/HandleLibunwindFlags.cmake
index 5fa765afd1ef3..94c676338821c 100644
--- a/libunwind/cmake/Modules/HandleLibunwindFlags.cmake
+++ b/libunwind/cmake/Modules/HandleLibunwindFlags.cmake
@@ -10,33 +10,6 @@ include(HandleFlags)
 
 unset(add_flag_if_supported)
 
-# Add a specified list of flags to both 'LIBUNWIND_COMPILE_FLAGS' and
-# 'LIBUNWIND_LINK_FLAGS'.
-macro(add_flags)
-  foreach(value ${ARGN})
-list(APPEND LIBUNWIND_COMPILE_FLAGS ${value})
-list(APPEND LIBUNWIND_LINK_FLAGS ${value})
-  endforeach()
-endmacro()
-
-# If the specified 'condition' is true then add a list of flags to both
-# 'LIBUNWIND_COMPILE_FLAGS' and 'LIBUNWIND_LINK_FLAGS'.
-macro(add_flags_if condition)
-  if (${condition})
-add_flags(${ARGN})
-  endif()
-endmacro()
-
-# Add each flag in the list to LIBUNWIND_COMPILE_FLAGS and LIBUNWIND_LINK_FLAGS
-# if that flag is supported by the current compiler.
-macro(add_flags_if_supported)
-  foreach(flag ${ARGN})
-  mangle_name("${flag}" flagname)
-  check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")
-  add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})
-  endforeach()
-endmacro()
-
 # Add a list of flags to 'LIBUNWIND_COMPILE_FLAGS'.
 macro(add_compile_flags)
   foreach(f ${ARGN})
@@ -77,16 +50,6 @@ macro(add_c_flags_if condition)
   endif()
 endmacro()
 
-# For each specified flag, add that flag to 'LIBUNWIND_C_FLAGS' if the
-# flag is supported by the C compiler.
-macro(add_c_compile_flags_if_supported)
-  foreach(flag ${ARGN})
-  mangle_name("${flag}" flagname)
-  check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG")
-  add_c_flags_if(C_SUPPORTS_${flagname}_FLAG ${flag})
-  endforeach()
-endmacro()
-
 # Add a list of flags to 'LIBUNWIND_CXX_FLAGS'.
 macro(add_cxx_flags)
   foreach(f ${ARGN})



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


[PATCH] D135495: [clang-tidy] handle exceptions properly `ExceptionAnalyzer`

2023-02-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

Thanks!


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

https://reviews.llvm.org/D135495

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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2023-02-21 Thread Ethan Stewart via Phabricator via cfe-commits
estewart08 added a comment.
Herald added a subscriber: steakhal.
Herald added a reviewer: NoQ.
Herald added a project: All.

In D74144#2308856 , @ABataev wrote:

> In D74144#2308796 , @cchen wrote:
>
>> In D74144#2307494 , @ABataev wrote:
>>
>>> In D74144#2307454 , @cchen wrote:
>>>
 @ABataev, the below test is extracted from Sollve test suite and Clang now 
 emit:

   test.c:17:35: error: subscripted value is not an array or pointer
   #pragma omp target update to( (([N][N])foo)[1:M] )
 ^
   test.c:17:5: error: expected at least one 'to' clause or 'from' clause 
 specified to '#pragma omp target update'
   #pragma omp target update to( (([N][N])foo)[1:M] )

 This error message came from the `ActOnOMPArraySectionExpr` which is 
 called inside `ParsePostfixExpressionSuffix`. The issue is that the base 
 expression in `ActOnOMPArraySectionExpr` looks like:

   ParenExpr 0x122859be0 '' lvalue
   `-OMPArrayShapingExpr 0x122859b98 '' lvalue
 |-IntegerLiteral 0x122859b38 'int' 5
 |-IntegerLiteral 0x122859b58 'int' 5
 `-DeclRefExpr 0x122859b78 'int *' lvalue Var 0x1228599d0 'foo' 'int *'

 which is not a base that we would expect in an array section expr. I've 
 tried relaxing the base type check in `ActOnOMPArraySectionExpr` but not 
 sure it's the way to go. (or should I just extract the DeclReExpr from 
 ArrayShapingExpr before calling `ActOnOMPArraySectionExpr`?)

   #define N 5
   #define M 3
   
   int main(void) {
   int tmp[N][N];
   for(int i=0; i>>>   for(int j=0; j>>>   tmp[i][j] = N*i + j;
   
   int *foo = &tmp[0][0];
   
   // This compiles just fine
   //#pragma omp target update to( ([N][N])foo )
   
   // This is rejected by the compiler
   #pragma omp target update to( (([N][N])foo)[1:M] )
   }
>>>
>>> I don't think it is allowed by the standard.
>>>
>>> According to the standard, The shape-operator can appear only in clauses 
>>> where it is explicitly allowed.
>>> In this case, array shaping is used as a base expression of array section 
>>> (or subscript) expression, which does not meet the standard. Tje array 
>>> sjaping operation is not used in clause, instead it is used as a base 
>>> subexpression of another expression.
>>
>> In OpenMP 5.0 [2.12.6, target update construct, Restrictions, C/C++, p.1] 
>> The list items that appear in the to or from clauses may use shape-operators.
>> Also, in the array shaping section in https://github.com/OpenMP/Examples, 
>> the example is also illustrated with the same usage:
>>
>>   ...
>>   S-17 // update boundary points (two columns of 2D array) on the host
>>   S-18 // pointer is shaped to 2D array using the shape-operator
>>   S-19 #pragma omp target update from( (([nx][ny+2])a)[0:nx][1], 
>> (([nx][ny+2])a)[0:nx][ny] )
>>   ...
>
> Then just need to fix it, if examples document has this example.

Was this ever followed up on and fixed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144

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


[PATCH] D143210: [PowerPC] Include vector bool and pixel when emitting lax warning

2023-02-21 Thread Maryam Moghadas via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02a71b05fc67: [PowerPC] Include vector bool and pixel when 
emitting lax warning (authored by maryammo).

Changed prior to commit:
  https://reviews.llvm.org/D143210?vs=494413&id=499296#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143210

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/SystemZ/zvector2.c

Index: clang/test/CodeGen/SystemZ/zvector2.c
===
--- clang/test/CodeGen/SystemZ/zvector2.c
+++ clang/test/CodeGen/SystemZ/zvector2.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z14 -fzvector \
-// RUN:  -O -emit-llvm -o - -W -Wall -Werror %s | FileCheck %s
+// RUN:  -O -emit-llvm -o - -W -Wall -Werror -Wno-error=deprecate-lax-vec-conv-all %s | FileCheck %s
 
 volatile vector float ff, ff2;
 volatile vector bool int bi;
Index: clang/test/CodeGen/SystemZ/zvector.c
===
--- clang/test/CodeGen/SystemZ/zvector.c
+++ clang/test/CodeGen/SystemZ/zvector.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z13 -fzvector -emit-llvm -o - -W -Wall -Werror %s | opt -S -passes=mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple s390x-linux-gnu -target-cpu z13 -fzvector \
+// RUN: -emit-llvm -o - -W -Wall -Werror -Wno-error=deprecate-lax-vec-conv-all \
+// RUN: %s | opt -S -passes=mem2reg | FileCheck %s
 
 volatile vector signed char sc, sc2;
 volatile vector unsigned char uc, uc2;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1770,7 +1770,7 @@
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
   if (S.isLaxVectorConversion(FromType, ToType) &&
   S.anyAltivecTypes(FromType, ToType) &&
-  !S.areSameVectorElemTypes(FromType, ToType) &&
+  !S.Context.areCompatibleVectorTypes(FromType, ToType) &&
   !InOverloadResolution && !CStyle) {
 S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
 << FromType << ToType;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7987,30 +7987,24 @@
  "expected at least one type to be a vector here");
 
   bool IsSrcTyAltivec =
-  SrcTy->isVectorType() && (SrcTy->castAs()->getVectorKind() ==
-VectorType::AltiVecVector);
+  SrcTy->isVectorType() && ((SrcTy->castAs()->getVectorKind() ==
+ VectorType::AltiVecVector) ||
+(SrcTy->castAs()->getVectorKind() ==
+ VectorType::AltiVecBool) ||
+(SrcTy->castAs()->getVectorKind() ==
+ VectorType::AltiVecPixel));
+
   bool IsDestTyAltivec = DestTy->isVectorType() &&
- (DestTy->castAs()->getVectorKind() ==
-  VectorType::AltiVecVector);
+ ((DestTy->castAs()->getVectorKind() ==
+   VectorType::AltiVecVector) ||
+  (DestTy->castAs()->getVectorKind() ==
+   VectorType::AltiVecBool) ||
+  (DestTy->castAs()->getVectorKind() ==
+   VectorType::AltiVecPixel));
 
   return (IsSrcTyAltivec || IsDestTyAltivec);
 }
 
-// This returns true if both vectors have the same element type.
-bool Sema::areSameVectorElemTypes(QualType SrcTy, QualType DestTy) {
-  assert((DestTy->isVectorType() || SrcTy->isVectorType()) &&
- "expected at least one type to be a vector here");
-
-  uint64_t SrcLen, DestLen;
-  QualType SrcEltTy, DestEltTy;
-  if (!breakDownVectorType(SrcTy, SrcLen, SrcEltTy))
-return false;
-  if (!breakDownVectorType(DestTy, DestLen, DestEltTy))
-return false;
-
-  return (SrcEltTy == DestEltTy);
-}
-
 /// Are the two types lax-compatible vector types?  That is, given
 /// that one of them is a vector, do they have equal storage sizes,
 /// where the storage size is the number of elements times the element
@@ -9848,7 +9842,7 @@
 // change, so if we are converting between vector types where
 // at least one is an Altivec vector, emit a warning.
 if (anyAltivecTypes(RHSType, LHSType) &&
-!areSameVectorElemTypes(RHSType, LHSType))
+!Context.areCompatibleVectorTypes(RHSType, LHSType))
   Diag(RHS.get()->getExprLoc(), di

[clang] 02a71b0 - [PowerPC] Include vector bool and pixel when emitting lax warning

2023-02-21 Thread Maryam Moghadas via cfe-commits

Author: Maryam Moghadas
Date: 2023-02-21T22:26:18Z
New Revision: 02a71b05fc67326d8ea336aa8ef934de0575be39

URL: 
https://github.com/llvm/llvm-project/commit/02a71b05fc67326d8ea336aa8ef934de0575be39
DIFF: 
https://github.com/llvm/llvm-project/commit/02a71b05fc67326d8ea336aa8ef934de0575be39.diff

LOG: [PowerPC] Include vector bool and pixel when emitting lax warning

This patch is to fix some missing lax-vector-conversion warnings including
cases that involve vector bool and vector pixel, also to fix the vector
compatibility check for the warnings.

Differential Revision: https://reviews.llvm.org/D143210

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CodeGen/SystemZ/zvector.c
clang/test/CodeGen/SystemZ/zvector2.c

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 176d92ae6fb1b..ecc031ce116e6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12620,7 +12620,6 @@ class Sema final {
   bool areVectorTypesSameSize(QualType srcType, QualType destType);
   bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType);
   bool isLaxVectorConversion(QualType srcType, QualType destType);
-  bool areSameVectorElemTypes(QualType srcType, QualType destType);
   bool anyAltivecTypes(QualType srcType, QualType destType);
 
   /// type checking declaration initializers (C99 6.7.8)

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 12c02e531da3e..af88d460137ae 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7987,30 +7987,24 @@ bool Sema::anyAltivecTypes(QualType SrcTy, QualType 
DestTy) {
  "expected at least one type to be a vector here");
 
   bool IsSrcTyAltivec =
-  SrcTy->isVectorType() && (SrcTy->castAs()->getVectorKind() ==
-VectorType::AltiVecVector);
+  SrcTy->isVectorType() && ((SrcTy->castAs()->getVectorKind() 
==
+ VectorType::AltiVecVector) ||
+(SrcTy->castAs()->getVectorKind() 
==
+ VectorType::AltiVecBool) ||
+(SrcTy->castAs()->getVectorKind() 
==
+ VectorType::AltiVecPixel));
+
   bool IsDestTyAltivec = DestTy->isVectorType() &&
- (DestTy->castAs()->getVectorKind() ==
-  VectorType::AltiVecVector);
+ ((DestTy->castAs()->getVectorKind() ==
+   VectorType::AltiVecVector) ||
+  (DestTy->castAs()->getVectorKind() ==
+   VectorType::AltiVecBool) ||
+  (DestTy->castAs()->getVectorKind() ==
+   VectorType::AltiVecPixel));
 
   return (IsSrcTyAltivec || IsDestTyAltivec);
 }
 
-// This returns true if both vectors have the same element type.
-bool Sema::areSameVectorElemTypes(QualType SrcTy, QualType DestTy) {
-  assert((DestTy->isVectorType() || SrcTy->isVectorType()) &&
- "expected at least one type to be a vector here");
-
-  uint64_t SrcLen, DestLen;
-  QualType SrcEltTy, DestEltTy;
-  if (!breakDownVectorType(SrcTy, SrcLen, SrcEltTy))
-return false;
-  if (!breakDownVectorType(DestTy, DestLen, DestEltTy))
-return false;
-
-  return (SrcEltTy == DestEltTy);
-}
-
 /// Are the two types lax-compatible vector types?  That is, given
 /// that one of them is a vector, do they have equal storage sizes,
 /// where the storage size is the number of elements times the element
@@ -9848,7 +9842,7 @@ Sema::CheckAssignmentConstraints(QualType LHSType, 
ExprResult &RHS,
 // change, so if we are converting between vector types where
 // at least one is an Altivec vector, emit a warning.
 if (anyAltivecTypes(RHSType, LHSType) &&
-!areSameVectorElemTypes(RHSType, LHSType))
+!Context.areCompatibleVectorTypes(RHSType, LHSType))
   Diag(RHS.get()->getExprLoc(), diag::warn_deprecated_lax_vec_conv_all)
   << RHSType << LHSType;
 Kind = CK_BitCast;
@@ -9864,7 +9858,9 @@ Sema::CheckAssignmentConstraints(QualType LHSType, 
ExprResult &RHS,
   const VectorType *VecType = RHSType->getAs();
   if (VecType && VecType->getNumElements() == 1 &&
   isLaxVectorConversion(RHSType, LHSType)) {
-if (VecType->getVectorKind() == VectorType::AltiVecVector)
+if (VecType->getVectorKind() == VectorType::AltiVecVector ||
+VecType->getVectorKind() == VectorType::AltiVecBool ||
+VecType->getVectorKind() == VectorType::AltiVecPixel)
   Diag(RHS.get()->getExprLoc(), diag::warn_deprecated_lax_vec_conv_all)
   << RHSType << LHSType;
 ExprResult *VecExpr = &RHS;
@

[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Ethan Luis McDonough 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 rGce3a1c59e180: [flang] Handle unsupported warning flags 
(authored by elmcdonough).

Changed prior to commit:
  https://reviews.llvm.org/D143301?vs=499259&id=499295#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/docs/FlangDriver.md
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/w-arg-unsupported.f90
  flang/test/Driver/werror-all.f90
  flang/test/Driver/wextra-ok.f90

Index: flang/test/Driver/wextra-ok.f90
===
--- /dev/null
+++ flang/test/Driver/wextra-ok.f90
@@ -0,0 +1,11 @@
+! Ensure that supplying -Wextra into flang-new does not raise error
+! The first check should be changed if -Wextra is implemented
+
+! RUN: %flang -std=f2018 -Wextra %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK
+! RUN: not %flang -std=f2018 -Wblah -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG
+
+! CHECK-OK: The warning option '-Wextra' is not supported
+! WRONG: Only `-Werror` is supported currently.
+
+program wextra_ok
+end program wextra_ok
Index: flang/test/Driver/werror-all.f90
===
--- /dev/null
+++ flang/test/Driver/werror-all.f90
@@ -0,0 +1,13 @@
+! Ensures that -Werror is read regardless of whether or not other -W
+! flags are present in the CLI args
+
+! RUN: not %flang -std=f2018 -Werror -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG
+! RUN: %flang -std=f2018 -Wextra -Wall %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK
+
+! WRONG: Semantic errors in
+! CHECK-OK: FORALL index variable
+
+program werror_check_all
+  integer :: a(3)
+  forall (j=1:n) a(i) = 1
+end program werror_check_all
Index: flang/test/Driver/w-arg-unsupported.f90
===
--- /dev/null
+++ flang/test/Driver/w-arg-unsupported.f90
@@ -0,0 +1,37 @@
+! RUN: %flang -std=f2018 -Wextra -Waliasing -Wampersand -Warray-bounds -Wc-binding-type \
+! RUN:-Wcharacter-truncation -Wconversion -Wdo-subscript -Wfunction-elimination \
+! RUN:-Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only \
+! RUN:-Wintrinsics-std -Wline-truncation -Wno-align-commons -Wno-overwrite-recursive \
+! RUN:-Wno-tabs -Wreal-q-constant -Wsurprising -Wunderflow -Wunused-parameter \
+! RUN:-Wrealloc-lhs -Wrealloc-lhs-all -Wfrontend-loop-interchange -Wtarget-lifetime %s \
+! RUN:2>&1 | FileCheck %s
+
+! CHECK: The warning option '-Wextra' is not supported
+! CHECK-NEXT: The warning option '-Waliasing' is not supported
+! CHECK-NEXT: The warning option '-Wampersand' is not supported
+! CHECK-NEXT: The warning option '-Warray-bounds' is not supported
+! CHECK-NEXT: The warning option '-Wc-binding-type' is not supported
+! CHECK-NEXT: The warning option '-Wcharacter-truncation' is not supported
+! CHECK-NEXT: The warning option '-Wconversion' is not supported
+! CHECK-NEXT: The warning option '-Wdo-subscript' is not supported
+! CHECK-NEXT: The warning option '-Wfunction-elimination' is not supported
+! CHECK-NEXT: The warning option '-Wimplicit-interface' is not supported
+! CHECK-NEXT: The warning option '-Wimplicit-procedure' is not supported
+! CHECK-NEXT: The warning option '-Wintrinsic-shadow' is not supported
+! CHECK-NEXT: The warning option '-Wuse-without-only' is not supported
+! CHECK-NEXT: The warning option '-Wintrinsics-std' is not supported
+! CHECK-NEXT: The warning option '-Wline-truncation' is not supported
+! CHECK-NEXT: The warning option '-Wno-align-commons' is not supported
+! CHECK-NEXT: The warning option '-Wno-overwrite-recursive' is not supported
+! CHECK-NEXT: The warning option '-Wno-tabs' is not supported
+! CHECK-NEXT: The warning option '-Wreal-q-constant' is not supported
+! CHECK-NEXT: The warning option '-Wsurprising' is not supported
+! CHECK-NEXT: The warning option '-Wunderflow' is not supported
+! CHECK-NEXT: The warning option '-Wunused-parameter' is not supported
+! CHECK-NEXT: The warning option '-Wrealloc-lhs' is not supported
+! CHECK-NEXT: The warning option '-Wrealloc-lhs-all' is not supported
+! CHECK-NEXT: The warning option '-Wfrontend-loop-interchange' is not supported
+! CHECK-NEXT: The warning option '-Wtarget-lifetime' is not supported
+
+program m
+end program
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -610,14 +610,17 @@
   // TODO: Currently throws a Diagnostic for anything other than -W,
   // this has to 

[clang] ce3a1c5 - [flang] Handle unsupported warning flags

2023-02-21 Thread Ethan Luis McDonough via cfe-commits

Author: Ethan Luis McDonough
Date: 2023-02-21T16:14:19-06:00
New Revision: ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491

URL: 
https://github.com/llvm/llvm-project/commit/ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491
DIFF: 
https://github.com/llvm/llvm-project/commit/ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491.diff

LOG: [flang] Handle unsupported warning flags

This PR makes flang emit a warning when the user passes an unsupported gfortran 
warning flag in as a CLI arg.  This PR also checks each `-W` argument instead 
of just looking at the last one passed in.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D143301

Added: 
flang/test/Driver/w-arg-unsupported.f90
flang/test/Driver/werror-all.f90
flang/test/Driver/wextra-ok.f90

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/docs/FlangDriver.md
flang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 35325de4a34a4..77fb1e00585a0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -113,6 +113,9 @@ def warn_drv_unsupported_option_for_target : Warning<
 def warn_drv_unsupported_option_for_flang : Warning<
   "the argument '%0' is not supported for option '%1'. Mapping to '%1%2'">,
   InGroup;
+def warn_drv_unsupported_diag_option_for_flang : Warning<
+  "The warning option '-%0' is not supported">,
+  InGroup;
 
 def err_drv_invalid_thread_model_for_target : Error<
   "invalid thread model '%0' in '%1' for this target">;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a26af0af2c946..a25854daf6a1b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -235,6 +235,10 @@ def clang_ignored_f_Group : OptionGroup<"">,
 def clang_ignored_m_Group : OptionGroup<"">,
   Group, Flags<[Ignored]>;
 
+// Unsupported flang groups
+def flang_ignored_w_Group : OptionGroup<"">,
+  Group, Flags<[FlangOnlyOption, Ignored]>;
+
 // Group for clang options in the process of deprecation.
 // Please include the version that deprecated the flag as comment to allow
 // easier garbage collection.
@@ -4871,6 +4875,10 @@ multiclass BooleanFFlag {
   def fno_#NAME : Flag<["-"], "fno-"#name>;
 }
 
+multiclass FlangIgnoredDiagOpt {
+  def unsupported_warning_w#NAME : Flag<["-", "--"], "W"#name>, 
Group;
+}
+
 defm : BooleanFFlag<"keep-inline-functions">, 
Group;
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group;
@@ -5030,6 +5038,36 @@ defm second_underscore : 
BooleanFFlag<"second-underscore">, Group, Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
 
+// -W  options unsupported by the flang compiler
+// If any of these options are passed into flang's compiler driver,
+// a warning will be raised and the argument will be claimed
+defm : FlangIgnoredDiagOpt<"extra">;
+defm : FlangIgnoredDiagOpt<"aliasing">;
+defm : FlangIgnoredDiagOpt<"ampersand">;
+defm : FlangIgnoredDiagOpt<"array-bounds">;
+defm : FlangIgnoredDiagOpt<"c-binding-type">;
+defm : FlangIgnoredDiagOpt<"character-truncation">;
+defm : FlangIgnoredDiagOpt<"conversion">;
+defm : FlangIgnoredDiagOpt<"do-subscript">;
+defm : FlangIgnoredDiagOpt<"function-elimination">;
+defm : FlangIgnoredDiagOpt<"implicit-interface">;
+defm : FlangIgnoredDiagOpt<"implicit-procedure">;
+defm : FlangIgnoredDiagOpt<"intrinsic-shadow">;
+defm : FlangIgnoredDiagOpt<"use-without-only">;
+defm : FlangIgnoredDiagOpt<"intrinsics-std">;
+defm : FlangIgnoredDiagOpt<"line-truncation">;
+defm : FlangIgnoredDiagOpt<"no-align-commons">;
+defm : FlangIgnoredDiagOpt<"no-overwrite-recursive">;
+defm : FlangIgnoredDiagOpt<"no-tabs">;
+defm : FlangIgnoredDiagOpt<"real-q-constant">;
+defm : FlangIgnoredDiagOpt<"surprising">;
+defm : FlangIgnoredDiagOpt<"underflow">;
+defm : FlangIgnoredDiagOpt<"unused-parameter">;
+defm : FlangIgnoredDiagOpt<"realloc-lhs">;
+defm : FlangIgnoredDiagOpt<"realloc-lhs-all">;
+defm : FlangIgnoredDiagOpt<"frontend-loop-interchange">;
+defm : FlangIgnoredDiagOpt<"target-lifetime">;
+
 // C++ SYCL options
 def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>,
   Group, HelpText<"Enables SYCL kernels compilation for device">;

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index cd3907c099481..b50d2c5c4f8d2 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -329,6 +329,13 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
 A->render(Args, CmdArgs);
   }
 
+  // Remove any unsupported gfortran diagnostic options
+  for (const Arg *A : Args.filtered(options::OPT_flang_ignored_w_Group)) {
+

[PATCH] D96007: [AArch64] Enable stack clash protection for AArch64 linux in clang

2023-02-21 Thread Ed Maste via Phabricator via cfe-commits
emaste added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3090
 
   if (!EffectiveTriple.isOSLinux())
 return;

Why is this limited to `isOSLinux()` only?


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

https://reviews.llvm.org/D96007

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


[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for seeing this through! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

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


[PATCH] D144293: [PowerPC] Fix the implicit casting for the emulated intrinsics

2023-02-21 Thread Maryam Moghadas 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 rGee815ff2ce8d: [PowerPC] Fix the implicit casting for the 
emulated intrinsics (authored by maryammo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144293

Files:
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/test/CodeGen/PowerPC/ppc-smmintrin.c


Index: clang/test/CodeGen/PowerPC/ppc-smmintrin.c
===
--- clang/test/CodeGen/PowerPC/ppc-smmintrin.c
+++ clang/test/CodeGen/PowerPC/ppc-smmintrin.c
@@ -73,7 +73,7 @@
 
 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blend_epi16(<2 x 
i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 
noundef signext %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
-// CHECK: call <16 x i8> @vec_splats(signed char)(i8 noundef signext 
%[[TRUNC]])
+// CHECK: call <16 x i8> @vec_splats(unsigned char)(i8 noundef zeroext 
%[[TRUNC]])
 // CHECK: call <16 x i8> @llvm.ppc.altivec.vgbbd(<16 x i8> %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[PACK:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_unpackh(signed char 
vector[16])
 // CHECK: store <8 x i16> %[[PACK]], ptr %{{[0-9a-zA-Z_.]+}}, align 16
@@ -232,8 +232,8 @@
 test_round() {
   _mm_round_ps(mn1, 0);
   _mm_round_ss(mn1, mn2, 0);
-  _mm_round_pd(mn1, 0);
-  _mm_round_sd(mn1, mn2, 0);
+  _mm_round_pd(md1, 0);
+  _mm_round_sd(md1, md2, 0);
 }
 
 // CHECK-LABEL: @test_round
Index: clang/lib/Headers/ppc_wrappers/smmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/smmintrin.h
+++ clang/lib/Headers/ppc_wrappers/smmintrin.h
@@ -305,9 +305,9 @@
 extern __inline __m128i
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) {
-  __v16qi __charmask = vec_splats((signed char)__imm8);
+  __v16qu __charmask = vec_splats((unsigned char)__imm8);
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__
   __shortmask = vec_reve(__shortmask);
 #endif
Index: clang/lib/Headers/ppc_wrappers/emmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/emmintrin.h
+++ clang/lib/Headers/ppc_wrappers/emmintrin.h
@@ -46,6 +46,7 @@
 
 /* SSE2 */
 typedef __vector double __v2df;
+typedef __vector float __v4f;
 typedef __vector long long __v2di;
 typedef __vector unsigned long long __v2du;
 typedef __vector int __v4si;
@@ -951,7 +952,7 @@
 _mm_cvtpi32_pd(__m64 __A) {
   __v4si __temp;
   __v2di __tmp2;
-  __v2df __result;
+  __v4f __result;
 
   __temp = (__v4si)vec_splats(__A);
   __tmp2 = (__v2di)vec_unpackl(__temp);


Index: clang/test/CodeGen/PowerPC/ppc-smmintrin.c
===
--- clang/test/CodeGen/PowerPC/ppc-smmintrin.c
+++ clang/test/CodeGen/PowerPC/ppc-smmintrin.c
@@ -73,7 +73,7 @@
 
 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blend_epi16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
-// CHECK: call <16 x i8> @vec_splats(signed char)(i8 noundef signext %[[TRUNC]])
+// CHECK: call <16 x i8> @vec_splats(unsigned char)(i8 noundef zeroext %[[TRUNC]])
 // CHECK: call <16 x i8> @llvm.ppc.altivec.vgbbd(<16 x i8> %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[PACK:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_unpackh(signed char vector[16])
 // CHECK: store <8 x i16> %[[PACK]], ptr %{{[0-9a-zA-Z_.]+}}, align 16
@@ -232,8 +232,8 @@
 test_round() {
   _mm_round_ps(mn1, 0);
   _mm_round_ss(mn1, mn2, 0);
-  _mm_round_pd(mn1, 0);
-  _mm_round_sd(mn1, mn2, 0);
+  _mm_round_pd(md1, 0);
+  _mm_round_sd(md1, md2, 0);
 }
 
 // CHECK-LABEL: @test_round
Index: clang/lib/Headers/ppc_wrappers/smmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/smmintrin.h
+++ clang/lib/Headers/ppc_wrappers/smmintrin.h
@@ -305,9 +305,9 @@
 extern __inline __m128i
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) {
-  __v16qi __charmask = vec_splats((signed char)__imm8);
+  __v16qu __charmask = vec_splats((unsigned char)__imm8);
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__
   __shortmask = vec_reve(__shortmask);
 #endif
Index: clang/lib/Headers/ppc_wrappers/emmintrin.h
===

[clang] ee815ff - [PowerPC] Fix the implicit casting for the emulated intrinsics

2023-02-21 Thread Maryam Moghadas via cfe-commits

Author: Maryam Moghadas
Date: 2023-02-21T15:44:57-06:00
New Revision: ee815ff2ce8d0782cf04f5cad1d4038207f661cf

URL: 
https://github.com/llvm/llvm-project/commit/ee815ff2ce8d0782cf04f5cad1d4038207f661cf
DIFF: 
https://github.com/llvm/llvm-project/commit/ee815ff2ce8d0782cf04f5cad1d4038207f661cf.diff

LOG: [PowerPC] Fix the implicit casting for the emulated intrinsics

This patch is to fix some implicit castings for emulated intrinsics
so that there are no lax-vector-conversions errors and warnings.

Reviewed By: nemanjai, #powerpc

Differential Revision: https://reviews.llvm.org/D144293

Added: 


Modified: 
clang/lib/Headers/ppc_wrappers/emmintrin.h
clang/lib/Headers/ppc_wrappers/smmintrin.h
clang/test/CodeGen/PowerPC/ppc-smmintrin.c

Removed: 




diff  --git a/clang/lib/Headers/ppc_wrappers/emmintrin.h 
b/clang/lib/Headers/ppc_wrappers/emmintrin.h
index 0814ea5593bad..fc18ab9d43b15 100644
--- a/clang/lib/Headers/ppc_wrappers/emmintrin.h
+++ b/clang/lib/Headers/ppc_wrappers/emmintrin.h
@@ -46,6 +46,7 @@
 
 /* SSE2 */
 typedef __vector double __v2df;
+typedef __vector float __v4f;
 typedef __vector long long __v2di;
 typedef __vector unsigned long long __v2du;
 typedef __vector int __v4si;
@@ -951,7 +952,7 @@ extern __inline __m128d
 _mm_cvtpi32_pd(__m64 __A) {
   __v4si __temp;
   __v2di __tmp2;
-  __v2df __result;
+  __v4f __result;
 
   __temp = (__v4si)vec_splats(__A);
   __tmp2 = (__v2di)vec_unpackl(__temp);

diff  --git a/clang/lib/Headers/ppc_wrappers/smmintrin.h 
b/clang/lib/Headers/ppc_wrappers/smmintrin.h
index 6fe6d2a157a59..349b395c4f00b 100644
--- a/clang/lib/Headers/ppc_wrappers/smmintrin.h
+++ b/clang/lib/Headers/ppc_wrappers/smmintrin.h
@@ -305,9 +305,9 @@ extern __inline int
 extern __inline __m128i
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) {
-  __v16qi __charmask = vec_splats((signed char)__imm8);
+  __v16qu __charmask = vec_splats((unsigned char)__imm8);
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__
   __shortmask = vec_reve(__shortmask);
 #endif

diff  --git a/clang/test/CodeGen/PowerPC/ppc-smmintrin.c 
b/clang/test/CodeGen/PowerPC/ppc-smmintrin.c
index 5033526fd3369..220b65c1ce164 100644
--- a/clang/test/CodeGen/PowerPC/ppc-smmintrin.c
+++ b/clang/test/CodeGen/PowerPC/ppc-smmintrin.c
@@ -73,7 +73,7 @@ test_blend() {
 
 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blend_epi16(<2 x 
i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 
noundef signext %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
-// CHECK: call <16 x i8> @vec_splats(signed char)(i8 noundef signext 
%[[TRUNC]])
+// CHECK: call <16 x i8> @vec_splats(unsigned char)(i8 noundef zeroext 
%[[TRUNC]])
 // CHECK: call <16 x i8> @llvm.ppc.altivec.vgbbd(<16 x i8> %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[PACK:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_unpackh(signed char 
vector[16])
 // CHECK: store <8 x i16> %[[PACK]], ptr %{{[0-9a-zA-Z_.]+}}, align 16
@@ -232,8 +232,8 @@ void __attribute__((noinline))
 test_round() {
   _mm_round_ps(mn1, 0);
   _mm_round_ss(mn1, mn2, 0);
-  _mm_round_pd(mn1, 0);
-  _mm_round_sd(mn1, mn2, 0);
+  _mm_round_pd(md1, 0);
+  _mm_round_sd(md1, md2, 0);
 }
 
 // CHECK-LABEL: @test_round



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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-21 Thread Mark Danial via Phabricator via cfe-commits
madanial added a comment.

Thanks for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140795

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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-21 Thread Mark Danial via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1360bfb05b31: [Flang] Add user option 
-funderscoring/-fnounderscoring to control trailing… (authored by madanial).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140795

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90
  flang/test/Fir/external-mangling.fir

Index: flang/test/Fir/external-mangling.fir
===
--- flang/test/Fir/external-mangling.fir
+++ flang/test/Fir/external-mangling.fir
@@ -1,6 +1,9 @@
-// RUN: fir-opt --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
+// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
 
 func.func @_QPfoo() {
   %c0 = arith.constant 0 : index
@@ -21,24 +24,43 @@
 func.func private @_QPbar(!fir.ref)
 func.func private @_QPbar2(!fir.ref)
 
-// CHECK: func @foo_
-// CHECK: %{{.*}} = fir.address_of(@a_) : !fir.ref>
-// CHECK: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
-// CHECK: fir.call @bar_
-// CHECK: fir.call @bar2_
-// CHECK: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: func private @bar_(!fir.ref)
-
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
-// LLVMIR: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
-// LLVMIR: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
-
-// LLVMIR: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
-// LLVMIR: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
-// LLVMIR: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
-// LLVMIR: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+// CHECK-UNDER: func @foo_
+// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref>
+// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-UNDER: fir.call @bar_
+// CHECK-UNDER: fir.call @bar2_
+// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: func private @bar_(!fir.ref)
+
+// CHECK-NOUNDER: func @foo(
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref>
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-NOUNDER: fir.call @bar(
+// CHECK-NOUNDER: fir.call @bar2(
+// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: func private @bar(!fir.ref)
+
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
+// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr>
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-NOUNDER: llvm.call @bar2(%{{.*}}) : (!llvm.ptr)

[clang] 1360bfb - [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-21 Thread Mark Danial via cfe-commits

Author: Mark Danial
Date: 2023-02-21T16:34:26-05:00
New Revision: 1360bfb05b3153ad93a7e866f0ac6860d94337a2

URL: 
https://github.com/llvm/llvm-project/commit/1360bfb05b3153ad93a7e866f0ac6860d94337a2
DIFF: 
https://github.com/llvm/llvm-project/commit/1360bfb05b3153ad93a7e866f0ac6860d94337a2.diff

LOG: [Flang] Add user option -funderscoring/-fnounderscoring to control 
trailing underscore added to external names

This patch adds user option -funderscoring/-fnounderscoring  to control the 
trailing underscore being appended to external names (e.g. procedure names, 
common block names). The option in gfortran is documented in 
https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html.

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D140795

Added: 
flang/test/Driver/underscoring.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/CodeGenOptions.def
flang/include/flang/Optimizer/Transforms/Passes.h
flang/include/flang/Optimizer/Transforms/Passes.td
flang/include/flang/Tools/CLOptions.inc
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
flang/test/Fir/external-mangling.fir

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f84522c741561..a26af0af2c946 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5028,7 +5028,6 @@ defm recursive : BooleanFFlag<"recursive">, 
Group;
 defm repack_arrays : BooleanFFlag<"repack-arrays">, Group;
 defm second_underscore : BooleanFFlag<"second-underscore">, 
Group;
 defm sign_zero : BooleanFFlag<"sign-zero">, Group;
-defm underscoring : BooleanFFlag<"underscoring">, Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
 
 // C++ SYCL options
@@ -5103,6 +5102,7 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that 
backslash in string in
 defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym 
of .NEQV.">;
 defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable 
logical abbreviations">;
 defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing 
allowed unless overridden by IMPLICIT statements">;
+defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing 
underscore to external names">;
 
 def fno_automatic : Flag<["-"], "fno-automatic">, Group,
   HelpText<"Implies the SAVE attribute for non-automatic local objects in 
subprograms unless RECURSIVE">;

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 8d9fae58ce50e..cd3907c099481 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -56,7 +56,8 @@ void Flang::addOtherOptions(const ArgList &Args, 
ArgStringList &CmdArgs) const {
   {options::OPT_module_dir, options::OPT_fdebug_module_writer,
options::OPT_fintrinsic_modules_path, options::OPT_pedantic,
options::OPT_std_EQ, options::OPT_W_Joined,
-   options::OPT_fconvert_EQ, options::OPT_fpass_plugin_EQ});
+   options::OPT_fconvert_EQ, options::OPT_fpass_plugin_EQ,
+   options::OPT_funderscoring, options::OPT_fno_underscoring});
 
   Arg *stackArrays =
   Args.getLastArg(options::OPT_Ofast, options::OPT_fstack_arrays,

diff  --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flang/Frontend/CodeGenOptions.def
index 0de2360fd95be..7f50442af6d09 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -28,6 +28,7 @@ CODEGENOPT(PICLevel, 2, 0) ///< PIC level of the LLVM module.
 CODEGENOPT(IsPIE, 1, 0) ///< PIE level is the same as PIC Level.
 CODEGENOPT(StackArrays, 1, 0) ///< -fstack-arrays (enable the stack-arrays 
pass)
 
+CODEGENOPT(Underscoring, 1, 1)
 ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, llvm::Reloc::PIC_) 
///< Name of the relocation model to use.
 
 #undef CODEGENOPT

diff  --git a/flang/include/flang/Optimizer/Transforms/Passes.h 
b/flang/include/flang/Optimizer/Transforms/Passes.h
index efe55cecce30b..55f000f067b52 100644
--- a/flang/include/flang/Optimizer/Transforms/Passes.h
+++ b/flang/include/flang/Optimizer/Transforms/Passes.h
@@ -52,6 +52,8 @@ createArrayValueCopyPass(fir::ArrayValueCopyOptions options = 
{});
 std::unique_ptr createFirToCfgPass();
 std::unique_ptr createCharacterConversionPass();
 std::unique_ptr createExternalNameConversionPass();
+std::unique_ptr
+createExternalNameConversionPass(bool appendUnderscore);
 std::unique_ptr createMemDataFlowOptPass();
 std::unique_ptr crea

[PATCH] D144035: [hwasan] Ensure hwasan aliases do not have ODR linkage

2023-02-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144035

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


[PATCH] D74970: [OpenMP] Refactor the analysis in checkMapClauseBaseExpression using StmtVisitor class.

2023-02-21 Thread Ethan Stewart via Phabricator via cfe-commits
estewart08 added inline comments.
Herald added subscribers: sstefan1, yaxunl.
Herald added a project: All.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15450
   }
+  bool VisitCXXThisExpr(CXXThisExpr *CTE) { return true; }
+  bool VisitStmt(Stmt *) {

cchen wrote:
> ABataev wrote:
> > Do you really need this function?
> Removed the function.
Was this function intended to be removed? As far as I can tell it was not and 
it seems to be the source of an issue I am having:

expected addressable lvalue in 'map' clause


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74970

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


[PATCH] D144516: [Flang] Add user option -funderscoring/-fnounderscoring

2023-02-21 Thread Mark Danial via Phabricator via cfe-commits
madanial created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: mehdi_amini.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
madanial requested review of this revision.
Herald added subscribers: cfe-commits, jdoerfert, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144516

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90
  flang/test/Fir/external-mangling.fir

Index: flang/test/Fir/external-mangling.fir
===
--- flang/test/Fir/external-mangling.fir
+++ flang/test/Fir/external-mangling.fir
@@ -1,6 +1,9 @@
-// RUN: fir-opt --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
+// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
 
 func.func @_QPfoo() {
   %c0 = arith.constant 0 : index
@@ -21,24 +24,43 @@
 func.func private @_QPbar(!fir.ref)
 func.func private @_QPbar2(!fir.ref)
 
-// CHECK: func @foo_
-// CHECK: %{{.*}} = fir.address_of(@a_) : !fir.ref>
-// CHECK: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
-// CHECK: fir.call @bar_
-// CHECK: fir.call @bar2_
-// CHECK: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: func private @bar_(!fir.ref)
-
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
-// LLVMIR: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
-// LLVMIR: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
-
-// LLVMIR: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
-// LLVMIR: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
-// LLVMIR: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
-// LLVMIR: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+// CHECK-UNDER: func @foo_
+// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref>
+// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-UNDER: fir.call @bar_
+// CHECK-UNDER: fir.call @bar2_
+// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: func private @bar_(!fir.ref)
+
+// CHECK-NOUNDER: func @foo(
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref>
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-NOUNDER: fir.call @bar(
+// CHECK-NOUNDER: fir.call @bar2(
+// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: func private @bar(!fir.ref)
+
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
+// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr>
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-NOUNDER: 

[PATCH] D144136: Add a "remark" to report on array accesses

2023-02-21 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D144136#4137143 , @kees wrote:

> Here's a test-case. I'd expect 6 remarks from building this:
>
>   /* Build with -Wall -O2 -fstrict-flex-arrays=3 -fsanitize=bounds 
> -Rarray-bounds */
>   #include 
>   #include 
>   #include 
>   #include 
>   
>   #define report_size(p, index)  do {\
>   const size_t bdos = __builtin_dynamic_object_size(p, 1); \
>   \
>   if (__builtin_constant_p(bdos)) { \
>   if (bdos == SIZE_MAX) { \
>   printf(#p " has unknowable size\n"); \
>   } else { \
>   printf(#p " has a fixed size: %zu\n", bdos); \
>   } \
>   } else { \
>   printf(#p " has a dynamic size: %zu\n", bdos); \
>   } \
>   printf(#p "[" #index "] assignment: %d\n", (p)[index] = 15); \
>   } while (0)
>   
>   struct fixed {
>   unsigned long flags;
>   size_t foo;
>   int array[16];
>   };
>   
>   /* should emit "fixed" */
>   void do_fixed(struct fixed *p, int index)
>   {
>   report_size(p->array, 0);
>   report_size(p->array, index);
>   }
>   
>   struct flex {
>   unsigned long flags;
>   size_t foo;
>   int array[];
>   };
>   
>   /* should emit "dynamic" */
>   void do_dynamic(unsigned char count, int index)
>   {
>   /* malloc() is marked with __attribute__((alloc_size(1))) */
>   struct flex *p = malloc(sizeof(*p) + count * sizeof(*p->array));
>   report_size(p->array, 0);
>   report_size(p->array, index);
>   free(p);
>   }
>   
>   /* should emit "unknowable" */
>   void do_unknown(struct flex *p, int index)
>   {
>   report_size(p->array, 0);
>   report_size(p->array, index);
>   }
>
> Currently, it only emits once for the compile-time known index with a 
> compile-time known array size:
>
>   array.c:31:17: remark: accessing fixed sized array 'int[16]' by 0 
> [-Rarray-bounds]  
>   report_size(p->array, 0);   
> ^ 

Right. I'll be working on the rest of these soon. Probably the FAM's will be 
next followed by the "dynamic" size, as that's trickier due to lack of support 
in Clang for some of the required features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144136

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


[PATCH] D144293: [PowerPC] Fix the implicit casting for the emulated intrinsics

2023-02-21 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo updated this revision to Diff 499273.
maryammo added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144293

Files:
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/test/CodeGen/PowerPC/ppc-smmintrin.c


Index: clang/test/CodeGen/PowerPC/ppc-smmintrin.c
===
--- clang/test/CodeGen/PowerPC/ppc-smmintrin.c
+++ clang/test/CodeGen/PowerPC/ppc-smmintrin.c
@@ -73,7 +73,7 @@
 
 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blend_epi16(<2 x 
i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 
noundef signext %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
-// CHECK: call <16 x i8> @vec_splats(signed char)(i8 noundef signext 
%[[TRUNC]])
+// CHECK: call <16 x i8> @vec_splats(unsigned char)(i8 noundef zeroext 
%[[TRUNC]])
 // CHECK: call <16 x i8> @llvm.ppc.altivec.vgbbd(<16 x i8> %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[PACK:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_unpackh(signed char 
vector[16])
 // CHECK: store <8 x i16> %[[PACK]], ptr %{{[0-9a-zA-Z_.]+}}, align 16
@@ -232,8 +232,8 @@
 test_round() {
   _mm_round_ps(mn1, 0);
   _mm_round_ss(mn1, mn2, 0);
-  _mm_round_pd(mn1, 0);
-  _mm_round_sd(mn1, mn2, 0);
+  _mm_round_pd(md1, 0);
+  _mm_round_sd(md1, md2, 0);
 }
 
 // CHECK-LABEL: @test_round
Index: clang/lib/Headers/ppc_wrappers/smmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/smmintrin.h
+++ clang/lib/Headers/ppc_wrappers/smmintrin.h
@@ -305,9 +305,9 @@
 extern __inline __m128i
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) {
-  __v16qi __charmask = vec_splats((signed char)__imm8);
+  __v16qu __charmask = vec_splats((unsigned char)__imm8);
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__
   __shortmask = vec_reve(__shortmask);
 #endif
Index: clang/lib/Headers/ppc_wrappers/emmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/emmintrin.h
+++ clang/lib/Headers/ppc_wrappers/emmintrin.h
@@ -46,6 +46,7 @@
 
 /* SSE2 */
 typedef __vector double __v2df;
+typedef __vector float __v4f;
 typedef __vector long long __v2di;
 typedef __vector unsigned long long __v2du;
 typedef __vector int __v4si;
@@ -951,7 +952,7 @@
 _mm_cvtpi32_pd(__m64 __A) {
   __v4si __temp;
   __v2di __tmp2;
-  __v2df __result;
+  __v4f __result;
 
   __temp = (__v4si)vec_splats(__A);
   __tmp2 = (__v2di)vec_unpackl(__temp);


Index: clang/test/CodeGen/PowerPC/ppc-smmintrin.c
===
--- clang/test/CodeGen/PowerPC/ppc-smmintrin.c
+++ clang/test/CodeGen/PowerPC/ppc-smmintrin.c
@@ -73,7 +73,7 @@
 
 // CHECK-LABEL: define available_externally <2 x i64> @_mm_blend_epi16(<2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, <2 x i64> noundef %{{[0-9a-zA-Z_.]+}}, i32 noundef signext %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[TRUNC:[0-9a-zA-Z_.]+]] = trunc i32 %{{[0-9a-zA-Z_.]+}} to i8
-// CHECK: call <16 x i8> @vec_splats(signed char)(i8 noundef signext %[[TRUNC]])
+// CHECK: call <16 x i8> @vec_splats(unsigned char)(i8 noundef zeroext %[[TRUNC]])
 // CHECK: call <16 x i8> @llvm.ppc.altivec.vgbbd(<16 x i8> %{{[0-9a-zA-Z_.]+}})
 // CHECK: %[[PACK:[0-9a-zA-Z_.]+]] = call <8 x i16> @vec_unpackh(signed char vector[16])
 // CHECK: store <8 x i16> %[[PACK]], ptr %{{[0-9a-zA-Z_.]+}}, align 16
@@ -232,8 +232,8 @@
 test_round() {
   _mm_round_ps(mn1, 0);
   _mm_round_ss(mn1, mn2, 0);
-  _mm_round_pd(mn1, 0);
-  _mm_round_sd(mn1, mn2, 0);
+  _mm_round_pd(md1, 0);
+  _mm_round_sd(md1, md2, 0);
 }
 
 // CHECK-LABEL: @test_round
Index: clang/lib/Headers/ppc_wrappers/smmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/smmintrin.h
+++ clang/lib/Headers/ppc_wrappers/smmintrin.h
@@ -305,9 +305,9 @@
 extern __inline __m128i
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) {
-  __v16qi __charmask = vec_splats((signed char)__imm8);
+  __v16qu __charmask = vec_splats((unsigned char)__imm8);
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__
   __shortmask = vec_reve(__shortmask);
 #endif
Index: clang/lib/Headers/ppc_wrappers/emmintrin.h
===
--- clang/lib/Headers/ppc_wrappers/emmintrin.h
+++ clang/lib/Headers/ppc_wrappers/emmintrin.h
@

[PATCH] D144293: [PowerPC] Fix the implicit casting for the emulated intrinsics

2023-02-21 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo added inline comments.



Comment at: clang/lib/Headers/ppc_wrappers/smmintrin.h:310
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__

amyk wrote:
> Potentially silly question, but is it intentionally for that mask for be 
> signed?
In altivec header, `vec_unpackh` 's parameter is either `signed char` or `bool 
char`,  so we need explicit casting since `__charmask` is `unsigned char`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144293

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


[PATCH] D144334: [Clang] Add C++2b attribute [[assume(expression)]]

2023-02-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D144334#4142462 , @Izaron wrote:

> In D144334#4141646 , @erichkeane 
> wrote:
>
>> I'm on the fence as to whether we want to implement this feature at all.  As 
>> was discussed extensively during the EWG meetings on this: multiple 
>> implementers are against this attribute for a variety of reasons, and at 
>> least 1 other implementer has stated they might 'implementer veto' this.
>
> I don't quite understand how it works. The feature has been approved for 
> C++2b, but it should have not been approved if there were concerns from 
> implementers.

Agreed, (IMO) it should not have been approved given how many implementer 
concerns were expressed. But what goes into the standard is whatever gains 
consensus in the committee, so the committee occasionally runs the risk of 
voting in something that won't be implemented. We try to avoid it whenever 
possible, but it still happens with some regularity.

> But it seems like not the case with the `assume` attribute. Could you please 
> elaborate: if you decide to not implement this feature, you will kind of 
> revoke the proposal or just deliberately do not support a part of C++2b in 
> Clang?

To me, it's not clear whether we will or won't implement this particular 
attribute at the moment. Because Clang aims for compatibility with both GCC and 
MSVC, I'd like Clang to be the *last* to implement this attribute so we know 
exactly what we're signing up for in terms of compatibility requirements. We 
were bitten by `no_unique_address` and it's sporadic adoption and we do not 
want to get into the same situation with `assumes` because (as with 
`no_unique_address`) this attribute *cannot be ignored* (it can trigger 
template instantiations and other things that impact ABI, so a correct program 
with the attribute might not remain correct without the attribute). So that's 
not a "no, we'll never do it!" kind of situation so much as a "we're proceeding 
with extreme caution" situation. If every other C++ implementation supports 
this attribute, I see no reason why Clang wouldn't as well. But if either MSVC 
or GCC elect not to implement this attribute, we should understand why and 
decide our implementation strategy accordingly.

In terms of C++2b, we (the Clang community) have no more chances to change 
things. A national body comment was filed to consider removing the feature from 
C++2b or altering it to be acceptable to implementers with concerns and WG21 
rejected the comment, so about the only other option left is for companies who 
are members of a WG21 national body to vote NO on the C++2b DIS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144334

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


[PATCH] D144334: [Clang] Add C++2b attribute [[assume(expression)]]

2023-02-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CGStmt.cpp:723-727
+case attr::Assume: {
+  llvm::Value *ArgValue = EmitScalarExpr(cast(A)->getCond());
+  llvm::Function *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
+  Builder.CreateCall(FnAssume, ArgValue);
+  break;

Izaron wrote:
> cor3ntin wrote:
> > I'm not familiar with codegen. what makes the expression non-evaluated here?
> The LLVM docs says it: 
> https://llvm.org/docs/LangRef.html#llvm-assume-intrinsic
> > No code is generated for this intrinsic, and instructions that contribute 
> > only to the provided condition are not used for code generation
> The `ArgValue` and `FnAssume` are the instructions to be discarded according 
> to this sentence.
> 
> I guess they do it via dead code elimination (at any optimization level).
So interestingly, with __builtin_assume, we have some code that checks for 
side-effects (https://godbolt.org/z/fo73TvY68) and just doesn't emit the assume 
at all into IR.  I believe we are not able to do that (as side-effects don't 
prevent attribute-assume from having 'an effect'), so additional work needs to 
happen to make sure an example like the above has those side effects removed, 
but considered by the backend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144334

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


[PATCH] D144334: [Clang] Add C++2b attribute [[assume(expression)]]

2023-02-21 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron marked an inline comment as done.
Izaron added a comment.

In D144334#4142490 , @erichkeane 
wrote:

> Just deliberately not support a part of C++2b.  Implementers have veto'ed 
> features in the past exactly that way.

That's sad. Let's at least write some warning on the `cxx_status.html` like "we 
aren't gonna implement it".




Comment at: clang/lib/CodeGen/CGStmt.cpp:723-727
+case attr::Assume: {
+  llvm::Value *ArgValue = EmitScalarExpr(cast(A)->getCond());
+  llvm::Function *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
+  Builder.CreateCall(FnAssume, ArgValue);
+  break;

cor3ntin wrote:
> I'm not familiar with codegen. what makes the expression non-evaluated here?
The LLVM docs says it: https://llvm.org/docs/LangRef.html#llvm-assume-intrinsic
> No code is generated for this intrinsic, and instructions that contribute 
> only to the provided condition are not used for code generation
The `ArgValue` and `FnAssume` are the instructions to be discarded according to 
this sentence.

I guess they do it via dead code elimination (at any optimization level).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144334

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


[clang] cfca5f4 - [Driver][FreeBSD] Fix DWARF test after 2a2c0fd96757871f4e8052624000c208cc574fdf

2023-02-21 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-02-21T14:54:23-05:00
New Revision: cfca5f4d0c36d7560930df37b3a4a9cc85521529

URL: 
https://github.com/llvm/llvm-project/commit/cfca5f4d0c36d7560930df37b3a4a9cc85521529
DIFF: 
https://github.com/llvm/llvm-project/commit/cfca5f4d0c36d7560930df37b3a4a9cc85521529.diff

LOG: [Driver][FreeBSD] Fix DWARF test after 
2a2c0fd96757871f4e8052624000c208cc574fdf

The default DWARF version without a FreeBSD version specified is 4.

Added: 


Modified: 
clang/test/CodeGen/dwarf-version.c

Removed: 




diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 0a6fa4768026..d307eb3f101f 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -12,7 +12,7 @@
 // RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s 
-isysroot %t | FileCheck %s --check-prefix=VER2
 
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
-// RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
+// RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
 // RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VER2
 // RUN: %clang -target i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 



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


[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-21 Thread Ethan Luis McDonough via Phabricator via cfe-commits
elmcdonough updated this revision to Diff 499259.
elmcdonough marked 3 inline comments as done.
elmcdonough added a comment.

Comment edit + exhuastive testing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/docs/FlangDriver.md
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/w-arg-unsupported.f90
  flang/test/Driver/werror-all.f90
  flang/test/Driver/wextra-ok.f90

Index: flang/test/Driver/wextra-ok.f90
===
--- /dev/null
+++ flang/test/Driver/wextra-ok.f90
@@ -0,0 +1,11 @@
+! Ensure that supplying -Wextra into flang-new does not raise error
+! The first check should be changed if -Wextra is implemented
+
+! RUN: %flang -std=f2018 -Wextra %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK
+! RUN: not %flang -std=f2018 -Wblah -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG
+
+! CHECK-OK: The warning option '-Wextra' is not supported
+! WRONG: Only `-Werror` is supported currently.
+
+program wextra_ok
+end program wextra_ok
Index: flang/test/Driver/werror-all.f90
===
--- /dev/null
+++ flang/test/Driver/werror-all.f90
@@ -0,0 +1,13 @@
+! Ensures that -Werror is read regardless of whether or not other -W
+! flags are present in the CLI args
+
+! RUN: not %flang -std=f2018 -Werror -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG
+! RUN: %flang -std=f2018 -Wextra -Wall %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK
+
+! WRONG: Semantic errors in
+! CHECK-OK: FORALL index variable
+
+program werror_check_all
+  integer :: a(3)
+  forall (j=1:n) a(i) = 1
+end program werror_check_all
Index: flang/test/Driver/w-arg-unsupported.f90
===
--- /dev/null
+++ flang/test/Driver/w-arg-unsupported.f90
@@ -0,0 +1,37 @@
+! RUN: %flang -std=f2018 -Wextra -Waliasing -Wampersand -Warray-bounds -Wc-binding-type \
+! RUN:-Wcharacter-truncation -Wconversion -Wdo-subscript -Wfunction-elimination \
+! RUN:-Wimplicit-interface -Wimplicit-procedure -Wintrinsic-shadow -Wuse-without-only \
+! RUN:-Wintrinsics-std -Wline-truncation -Wno-align-commons -Wno-overwrite-recursive \
+! RUN:-Wno-tabs -Wreal-q-constant -Wsurprising -Wunderflow -Wunused-parameter \
+! RUN:-Wrealloc-lhs -Wrealloc-lhs-all -Wfrontend-loop-interchange -Wtarget-lifetime %s \
+! RUN:2>&1 | FileCheck %s
+
+! CHECK: The warning option '-Wextra' is not supported
+! CHECK-NEXT: The warning option '-Waliasing' is not supported
+! CHECK-NEXT: The warning option '-Wampersand' is not supported
+! CHECK-NEXT: The warning option '-Warray-bounds' is not supported
+! CHECK-NEXT: The warning option '-Wc-binding-type' is not supported
+! CHECK-NEXT: The warning option '-Wcharacter-truncation' is not supported
+! CHECK-NEXT: The warning option '-Wconversion' is not supported
+! CHECK-NEXT: The warning option '-Wdo-subscript' is not supported
+! CHECK-NEXT: The warning option '-Wfunction-elimination' is not supported
+! CHECK-NEXT: The warning option '-Wimplicit-interface' is not supported
+! CHECK-NEXT: The warning option '-Wimplicit-procedure' is not supported
+! CHECK-NEXT: The warning option '-Wintrinsic-shadow' is not supported
+! CHECK-NEXT: The warning option '-Wuse-without-only' is not supported
+! CHECK-NEXT: The warning option '-Wintrinsics-std' is not supported
+! CHECK-NEXT: The warning option '-Wline-truncation' is not supported
+! CHECK-NEXT: The warning option '-Wno-align-commons' is not supported
+! CHECK-NEXT: The warning option '-Wno-overwrite-recursive' is not supported
+! CHECK-NEXT: The warning option '-Wno-tabs' is not supported
+! CHECK-NEXT: The warning option '-Wreal-q-constant' is not supported
+! CHECK-NEXT: The warning option '-Wsurprising' is not supported
+! CHECK-NEXT: The warning option '-Wunderflow' is not supported
+! CHECK-NEXT: The warning option '-Wunused-parameter' is not supported
+! CHECK-NEXT: The warning option '-Wrealloc-lhs' is not supported
+! CHECK-NEXT: The warning option '-Wrealloc-lhs-all' is not supported
+! CHECK-NEXT: The warning option '-Wfrontend-loop-interchange' is not supported
+! CHECK-NEXT: The warning option '-Wtarget-lifetime' is not supported
+
+program m
+end program
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -604,14 +604,17 @@
   // TODO: Currently throws a Diagnostic for anything other than -W,
   // this has to change when other -W's are supported.
   if (args.hasArg(clang::driver::options::OPT_W_Joined)) {
-if (args.getLastArgValue(clang::driver::options::OPT_

[PATCH] D144334: [Clang] Add C++2b attribute [[assume(expression)]]

2023-02-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D144334#4142462 , @Izaron wrote:

> In D144334#4141646 , @erichkeane 
> wrote:
>
>> I'm on the fence as to whether we want to implement this feature at all.  As 
>> was discussed extensively during the EWG meetings on this: multiple 
>> implementers are against this attribute for a variety of reasons, and at 
>> least 1 other implementer has stated they might 'implementer veto' this.
>
> I don't quite understand how it works. The feature has been approved for 
> C++2b, but it should have not been approved if there were concerns from 
> implementers.

You're preaching to the choir on that one.  Two of the implementers (including 
our code owner, and MSVC reps) stated a distinct dislike for this, and that 
they were considering implementer veto on it.

> A friend of mine got his proposal rejected because MSVC said they are unable 
> to support the new feature.

"Unable to support" and "dont want to support" are different, but EWG is 
nothing if not consistently inconsistent.

> But it seems like not the case with the `assume` attribute. Could you please 
> elaborate: if you decide to not implement this feature, you will kind of 
> revoke the proposal or just deliberately do not support a part of C++2b in 
> Clang?

Just deliberately not support a part of C++2b.  Implementers have veto'ed 
features in the past exactly that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144334

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


[PATCH] D144334: [Clang] Add C++2b attribute [[assume(expression)]]

2023-02-21 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

In D144334#4141646 , @erichkeane 
wrote:

> I'm on the fence as to whether we want to implement this feature at all.  As 
> was discussed extensively during the EWG meetings on this: multiple 
> implementers are against this attribute for a variety of reasons, and at 
> least 1 other implementer has stated they might 'implementer veto' this.

I don't quite understand how it works. The feature has been approved for C++2b, 
but it should have not been approved if there were concerns from implementers.

A friend of mine got his proposal rejected because MSVC said they are unable to 
support the new feature.

But it seems like not the case with the `assume` attribute. Could you please 
elaborate: if you decide to not implement this feature, you will kind of revoke 
the proposal or just deliberately do not support a part of C++2b in Clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144334

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


[PATCH] D144293: [PowerPC] Fix the implicit casting for the emulated intrinsics

2023-02-21 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: clang/lib/Headers/ppc_wrappers/emmintrin.h:57
 typedef __vector unsigned char __v16qu;
+typedef __vector float __v2f;
 

nemanjai wrote:
> The name `__v2f` seems strange since `__vector float` is a vector of 4 
> `float` values. Should this be `__v4f`?
nit: Could we also put this to where we put the `double`?



Comment at: clang/lib/Headers/ppc_wrappers/smmintrin.h:310
   __charmask = vec_gb(__charmask);
-  __v8hu __shortmask = (__v8hu)vec_unpackh(__charmask);
+  __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask);
 #ifdef __BIG_ENDIAN__

Potentially silly question, but is it intentionally for that mask for be signed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144293

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


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-02-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek 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/D144509/new/

https://reviews.llvm.org/D144509

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


[PATCH] D144431: [clang-tidy] Fix readability-identifer-naming Hungarian CString options

2023-02-21 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/identifier-naming/hungarian-notation2/.clang-tidy:115
 value:  On
-  - key:
readability-identifier-naming.HungarianNotation.Options.TreatStructAsClass
-value:  false
+  - key:
readability-identifier-naming.HungarianNotation.General.TreatStructAsClass
+value:  true

Sorry, maybe I wasn't clear. Isn't this line meant to stay, since this is what 
the patch is fixing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144431

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


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-02-21 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra accepted this revision.
sivachandra added a comment.
Herald added subscribers: sstefan1, JDevlieghere.

OK for libc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-02-21 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: bollu, tstellar, mehdi_amini, MaskRay, ChuanqiXu, 
to268, kparzysz, thieta, tschuett, mgorny, stellaraccident, mizvekov, ldionne, 
jdoerfert, phosek.
Herald added subscribers: libc-commits, libcxx-commits, Moerafaat, zero9178, 
Enna1, bzcheeseman, ayermolo, sdasgup3, wenzhicui, wrengr, cota, teijeong, 
rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, jvesely, Joonsoo, 
liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, 
thopre, whisperity.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: NoQ.
Herald added projects: libunwind, libc-project, Flang, All.
Herald added a reviewer: libunwind.
Mordante added reviewers: libc++ vendors, clang-vendors.
Mordante published this revision for review.
Herald added subscribers: llvm-commits, openmp-commits, lldb-commits, 
Sanitizers, cfe-commits, yota9, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc++abi, 
MLIR, LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.

This partly undoes D137724 .

This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193

Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144509

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/lib/crt/CMakeLists.txt
  flang/CMakeLists.txt
  flang/lib/Decimal/CMakeLists.txt
  flang/runtime/CMakeLists.txt
  libc/CMakeLists.txt
  libc/examples/hello_world/CMakeLists.txt
  libclc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/tools/debugserver/CMakeLists.txt
  llvm-libgcc/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/docs/CMake.rst
  llvm/docs/GettingStarted.rst
  llvm/docs/ReleaseNotes.rst
  mlir/CMakeLists.txt
  mlir/examples/standalone/CMakeLists.txt
  openmp/CMakeLists.txt
  openmp/cmake/DetectTestCompiler/CMakeLists.txt
  openmp/docs/SupportAndFAQ.rst
  openmp/libompd/src/CMakeLists.txt
  openmp/libomptarget/plugins/remote/src/CMakeLists.txt
  openmp/runtime/cmake/LibompCheckLinkerFlag.cmake
  openmp/tools/Modules/FindOpenMPTarget.cmake
  openmp/tools/Modules/README.rst
  polly/CMakeLists.txt
  pstl/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -1,12 +1,5 @@
 # This file handles building LLVM runtime sub-projects.
-cmake_minimum_required(VERSION 3.13.4)
-if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
-  message(WARNING
-"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
-"minimum version of CMake required to build LLVM will become 3.20.0, and "
-"using an older CMake will become an error. Please upgrade your CMake to "
-"at least 3.20.0 now to avoid issues in the future!")
-endif()
+cmake_minimum_required(VERSION 3.20.0)
 project(Runtimes C CXX ASM)
 
 # Add path for custom and the LLVM build's modules to the CMake module path.
Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 #
 #===--===##
-cmake_minimum_required(VERSION 3.13.4)
+cmake_minimum_required(VERSION 3.20.0)
 
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -1,14 +1,7 @@
 # Check if this is a in tree build.
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
-  cmake_minimum_required(VERSION 3.13.4)
-  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
-message(WARNING
-  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
-  "minimum version of CMake required to build LLVM will become 3.20.0, and "
-  "using an older CMake will become an error. Please upgrade your CMake to "
-  "at least 3.20.0 now to avoid issues in the future!")
-  endif()
+  cmake_minimum_required(VERSION 3.20.0)
   set(POLLY_STANDALONE_BUILD TRUE)
 endif()
 
Index: openmp/tools/Modules/README.rst
===
--- openmp/tools/Modules/README.r

[PATCH] D144510: [clang-tidy] improve readability-identifier-naming hungarian options test

2023-02-21 Thread Alexis Murzeau via Phabricator via cfe-commits
amurzeau created this revision.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
amurzeau requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang-tools-extra.

Adjust identifier-naming-hungarian-notation-cfgfile test with
changes for all configs in .clang-tidy to ensure they are really taken
into account.

This is done this way:

- Set all HungarianNotation.* options to `cust` prefix + their default value.
- Set TreatStructAsClass to true as it defaults to false.
- Because of the TreatStructAsClass change, add a test to check that structs 
are really checked the same way as classes (see `struct StructCase`).

Also, `TreatStructAsClass` was wrongly named in the test's .clang-tidy file
and was fixed (it is in `General`, not in `Options`).

Depends on D144431 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144510

Files:
  
clang-tools-extra/test/clang-tidy/checkers/readability/Inputs/identifier-naming/hungarian-notation2/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
@@ -57,159 +57,159 @@
 public:
   static int ClassMemberCase;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for class member 'ClassMemberCase' [readability-identifier-naming]
-  // CHECK-FIXES: {{^}}  static int iClassMemberCase;
+  // CHECK-FIXES: {{^}}  static int custiClassMemberCase;
 
   char const ConstantMemberCase = 0;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: invalid case style for constant member 'ConstantMemberCase' [readability-identifier-naming]
-  // CHECK-FIXES: {{^}}  char const cConstantMemberCase = 0;
+  // CHECK-FIXES: {{^}}  char const custcConstantMemberCase = 0;
 
   void MyFunc1(const int ConstantParameterCase);
   // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for constant parameter 'ConstantParameterCase' [readability-identifier-naming]
-  // CHECK-FIXES: {{^}}  void MyFunc1(const int iConstantParameterCase);
+  // CHECK-FIXES: {{^}}  void MyFunc1(const int custiConstantParameterCase);
 
   void MyFunc2(const int* ConstantPointerParameterCase);
   // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: invalid case style for pointer parameter 'ConstantPointerParameterCase' [readability-identifier-naming]
-  // CHECK-FIXES: {{^}}  void MyFunc2(const int* piConstantPointerParameterCase);
+  // CHECK-FIXES: {{^}}  void MyFunc2(const int* custpcustiConstantPointerParameterCase);
 
   static constexpr int ConstexprVariableCase = 123;
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: invalid case style for constexpr variable 'ConstexprVariableCase' [readability-identifier-naming]
-  // CHECK-FIXES: {{^}}  static constexpr int iConstexprVariableCase = 123;
+  // CHECK-FIXES: {{^}}  static constexpr int custiConstexprVariableCase = 123;
 };
 
 const int GlobalConstantCase = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: invalid case style for global constant 'GlobalConstantCase' [readability-identifier-naming]
-// CHECK-FIXES: {{^}}const int iGlobalConstantCase = 0;
+// CHECK-FIXES: {{^}}const int custiGlobalConstantCase = 0;
 
 const int* GlobalConstantPointerCase = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for global pointer 'GlobalConstantPointerCase' [readability-identifier-naming]
-// CHECK-FIXES: {{^}}const int* piGlobalConstantPointerCase = nullptr;
+// CHECK-FIXES: {{^}}const int* custpcustiGlobalConstantPointerCase = nullptr;
 
 int* GlobalPointerCase = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for global pointer 'GlobalPointerCase' [readability-identifier-naming]
-// CHECK-FIXES: {{^}}int* piGlobalPointerCase = nullptr;
+// CHECK-FIXES: {{^}}int* custpcustiGlobalPointerCase = nullptr;
 
 int GlobalVariableCase = 0;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'GlobalVariableCase' [readability-identifier-naming]
-// CHECK-FIXES: {{^}}int iGlobalVariableCase = 0;
+// CHECK-FIXES: {{^}}int custiGlobalVariableCase = 0;
 
 void Func1(){
   int const LocalConstantCase = 3;
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for local constant 'LocalConstantCase' [readability-identifier-naming]
-  // CHECK-FIXES: {{^}}  int const iLocalConstantCase = 3;
+  // CHECK-FIXES: {{^}}  int const custiLocalConstantCase = 3;
 
   unsigned const ConstantCase = 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for local constant 'ConstantCase' [readability-identifier-naming]
-  // CHE

[PATCH] D144320: [Clang][OpenMP] Update tests using update_cc_test_checks.py

2023-02-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

LG, assuming the bots are happy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144320

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


[clang] 5d585c9 - [PowerPC] Use member function to determine PowerPC Secure PLT

2023-02-21 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-02-21T14:08:25-05:00
New Revision: 5d585c9dd07d0df4d450e2b1ba61fb17a5153aac

URL: 
https://github.com/llvm/llvm-project/commit/5d585c9dd07d0df4d450e2b1ba61fb17a5153aac
DIFF: 
https://github.com/llvm/llvm-project/commit/5d585c9dd07d0df4d450e2b1ba61fb17a5153aac.diff

LOG: [PowerPC] Use member function to determine PowerPC Secure PLT

Add a member function isPPC32SecurePlt() to determine whether Secure
PLT is used by the target 32-bit PowerPC operating environment.

Reviewed By: dim, maskray

Differential Revision: https://reviews.llvm.org/D14

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/PPC.cpp
llvm/include/llvm/TargetParser/Triple.h
llvm/lib/Target/PowerPC/PPCSubtarget.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp 
b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
index b02e3b73aa5e1..e19bcc026b0f1 100644
--- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -119,8 +119,7 @@ ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver 
&D, const llvm::Tripl
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
-  Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+  if (Triple.isPPC32SecurePlt())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;

diff  --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 59513fa2f2062..9910bb2a1f149 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -890,6 +890,15 @@ class Triple {
 getOS() == Triple::OpenBSD || isMusl()));
   }
 
+  /// Tests whether the target 32-bit PowerPC uses Secure PLT.
+  bool isPPC32SecurePlt() const {
+return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
+((getOS() == Triple::FreeBSD &&
+  (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
+ getOS() == Triple::NetBSD || getOS() == Triple::OpenBSD ||
+ isMusl()));
+  }
+
   /// Tests whether the target is 32-bit RISC-V.
   bool isRISCV32() const { return getArch() == Triple::riscv32; }
 

diff  --git a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp 
b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
index e32a2ed9dee7c..49400eefe4a94 100644
--- a/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ b/llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -106,9 +106,7 @@ void PPCSubtarget::initSubtargetFeatures(StringRef CPU, 
StringRef TuneCPU,
   if (IsPPC64 && has64BitSupport())
 Use64BitRegs = true;
 
-  if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
-  TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
-  TargetTriple.isMusl())
+  if (TargetTriple.isPPC32SecurePlt())
 IsSecurePlt = true;
 
   if (HasSPE && IsPPC64)



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


[PATCH] D144341: [Driver][FreeBSD] Correct driver behavior if a triple is provided without a version

2023-02-21 Thread Brad Smith 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 rG2a2c0fd96757: [Driver][FreeBSD] Correct driver behavior if a 
triple is provided without a… (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144341

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/FreeBSD.h
  clang/test/Driver/constructors.c
  clang/test/Driver/freebsd.c
  clang/test/Driver/freebsd.cpp

Index: clang/test/Driver/freebsd.cpp
===
--- clang/test/Driver/freebsd.cpp
+++ clang/test/Driver/freebsd.cpp
@@ -2,11 +2,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
-// RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NINE %s
 // CHECK-DEFAULT: "-lc++" "-lm"
 // CHECK-TEN: "-lc++" "-lm"
-// CHECK-NINE: "-lstdc++" "-lm"
 
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-DEFAULT %s
@@ -14,12 +11,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
 // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
-// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
 // CHECK-PG-DEFAULT: "-lc++" "-lm"
 // CHECK-PG-FOURTEEN: "-lc++" "-lm"
 // CHECK-PG-TEN: "-lc++_p" "-lm_p"
-// CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
 
 // Test include paths with a sysroot.
 // RUN: %clangxx %s -### -fsyntax-only 2>&1 \
Index: clang/test/Driver/freebsd.c
===
--- clang/test/Driver/freebsd.c
+++ clang/test/Driver/freebsd.c
@@ -7,18 +7,18 @@
 // CHECK-ARM64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
 //
 // RUN: %clang \
-// RUN:   --target=powerpc-pc-freebsd8 %s\
+// RUN:   --target=powerpc-pc-freebsd %s\
 // RUN:   --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC %s
-// CHECK-PPC: "-cc1" "-triple" "powerpc-pc-freebsd8"
+// CHECK-PPC: "-cc1" "-triple" "powerpc-pc-freebsd"
 // CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
 //
 // RUN: %clang \
-// RUN:   --target=powerpc64-pc-freebsd8 %s  \
+// RUN:   --target=powerpc64-pc-freebsd %s  \
 // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC64 %s
-// CHECK-PPC64: "-cc1" "-triple" "powerpc64-pc-freebsd8"
+// CHECK-PPC64: "-cc1" "-triple" "powerpc64-pc-freebsd"
 // CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-PPC64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
 
@@ -33,13 +33,13 @@
 //
 // Check that -m32 properly adjusts the toolchain flags.
 //
-// RUN: %clang --target=x86_64-pc-freebsd8 -m32 %s \
+// RUN: %clang --target=x86_64-pc-freebsd -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32 %s
-// CHECK-LIB32: "-cc1" "-triple" "i386-pc-freebsd8"
+// CHECK-LIB32: "-cc1" "-triple" "i386-pc-freebsd"
 // CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
 //
-// RUN: %clang --target=x86_64-pc-freebsd8 -m32 %s 2>&1 \
+// RUN: %clang --target=x86_64-pc-freebsd -m32 %s 2>&1 \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIB32PATHS %s
 // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
@@ -81,19 +81,14 @@
 // CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv"
 //
 // Check that the new linker flags are passed to FreeBSD
-// RUN: %clang --target=x86_64-pc-freebsd8 -m32 %s \
-// RUN:   --sysroot=%S/Inputs/multiarch_free

[PATCH] D144444: [PowerPC] Use member function to determine PowerPC Secure PLT

2023-02-21 Thread Brad Smith 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 rG5d585c9dd07d: [PowerPC] Use member function to determine 
PowerPC Secure PLT (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D14

Files:
  clang/lib/Driver/ToolChains/Arch/PPC.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp


Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -106,9 +106,7 @@
   if (IsPPC64 && has64BitSupport())
 Use64BitRegs = true;
 
-  if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
-  TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
-  TargetTriple.isMusl())
+  if (TargetTriple.isPPC32SecurePlt())
 IsSecurePlt = true;
 
   if (HasSPE && IsPPC64)
Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -890,6 +890,15 @@
 getOS() == Triple::OpenBSD || isMusl()));
   }
 
+  /// Tests whether the target 32-bit PowerPC uses Secure PLT.
+  bool isPPC32SecurePlt() const {
+return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
+((getOS() == Triple::FreeBSD &&
+  (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
+ getOS() == Triple::NetBSD || getOS() == Triple::OpenBSD ||
+ isMusl()));
+  }
+
   /// Tests whether the target is 32-bit RISC-V.
   bool isRISCV32() const { return getArch() == Triple::riscv32; }
 
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -119,8 +119,7 @@
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
-  Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+  if (Triple.isPPC32SecurePlt())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;


Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -106,9 +106,7 @@
   if (IsPPC64 && has64BitSupport())
 Use64BitRegs = true;
 
-  if ((TargetTriple.isOSFreeBSD() && TargetTriple.getOSMajorVersion() >= 13) ||
-  TargetTriple.isOSNetBSD() || TargetTriple.isOSOpenBSD() ||
-  TargetTriple.isMusl())
+  if (TargetTriple.isPPC32SecurePlt())
 IsSecurePlt = true;
 
   if (HasSPE && IsPPC64)
Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -890,6 +890,15 @@
 getOS() == Triple::OpenBSD || isMusl()));
   }
 
+  /// Tests whether the target 32-bit PowerPC uses Secure PLT.
+  bool isPPC32SecurePlt() const {
+return ((getArch() == Triple::ppc || getArch() == Triple::ppcle) &&
+((getOS() == Triple::FreeBSD &&
+  (getOSMajorVersion() >= 13 || getOSVersion().empty())) ||
+ getOS() == Triple::NetBSD || getOS() == Triple::OpenBSD ||
+ isMusl()));
+  }
+
   /// Tests whether the target is 32-bit RISC-V.
   bool isRISCV32() const { return getArch() == Triple::riscv32; }
 
Index: clang/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- clang/lib/Driver/ToolChains/Arch/PPC.cpp
+++ clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -119,8 +119,7 @@
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
-  Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+  if (Triple.isPPC32SecurePlt())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143670: Stop claiming we support [[carries_dependency]]

2023-02-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D143670#4142351 , @aaron.ballman 
wrote:

> In D143670#4133677 , @rsmith wrote:
>
>> Until or unless a C++ DR permits us to define 
>> `__has_cpp_attribute(carries_dependency)` to any value other than `200809L`, 
>> we have a conformance requirement to macro-expand this to that value. 
>> CWG2695 only adds a note, so it changes nothing in this regard.
>
> We don't yet have a C++ DR for this, but we do have EWG direction that such a 
> DR is needed. At the end of the day, our behavior in Clang is inconsistent 
> and this patch fixes that inconsistency. 
> `__has_cpp_attribute(no_unique_address)` returns `0` on some targets for 
> Clang already today. That cannot change without the risk of silently breaking 
> ABI for users. This is why EWG is moving in the direction of making the value 
> returned by the feature test macro be a matter of QoI. So in terms of 
> behaving consistently, we're faced with a choice: potentially break users by 
> returning nonzero for `no_unique_address` or stop returning nonzero for 
> `carries_dependency`. GCC has always returned 0 for `carries_dependency`. 
> Returning 0 makes Clang consistent with GCC for this specific attribute and 
> makes Clang consistent with itself in terms of standard attributes.
>
>> Similarly, we have a conformance requirement to emit a diagnostic on invalid 
>> uses of the attribute, and per our policy for `-pedantic`, we should produce 
>> an error for invalid uses under `-pedantic-errors` and not reject valid uses 
>> in that mode. So I think we still need all of the functionality that this 
>> patch removes for conformance reasons, for now at least. Maybe WG21 would be 
>> receptive to a paper making support of `[[carries_dependency]]` optional.
>
> The behavior of `-pedantic-errors` is an interesting point. We *conform* with 
> an "attribute ignored" diagnostic as far as the standard is concerned (so 
> there's no problem about conformance requirements) but it doesn't meet our 
> usual behavior of giving an error in `-pedantic-errors` mode. We have quite a 
> few other instances of missing pedantic errors and it'd be nice to not make 
> that worse. However, given that we are missing plenty of other pedantic error 
> diagnostics, I'm not certain that observation changes a whole lot in practice.
>
>> Conformance aside, the meaning of `[[carries_dependency]]` on a particular 
>> platform is an ABI requirement. On every platform that we support, the psABI 
>> does not specify any different handling for `[[carries_dependency]]` 
>> functions, so we *are* implementing the attribute completely and correctly 
>> on those targets, it just happens to be vacuous. If there were a target that 
>> defined a different ABI rule, or was anticipated to add such a different ABI 
>> rule (eg, due to some future PowerPC or ARM ABI change), then it would make 
>> sense to stop claiming support on those platforms until we implemented the 
>> behavior (I have the behavior of `[[no_unique_address]]` on MS ABI in mind 
>> here particularly). But I think it's not helpful to users to say we don't 
>> support it because it doesn't happen to make a difference on the current 
>> target, just it's not helpful to say we don't support 
>> `[[no_unique_address]]` just because it doesn't affect struct layout on a 
>> particular target, or -- more to the point -- it wouldn't be helpful to say 
>> we don't support `consume` memory ordering just because we don't get any 
>> benefit from it on the current target compared to `acquire` (and as a 
>> result, we lower `consume` to `acquire`). I think it's much better to let 
>> people unconditionally add `[[carries_dependency]]` (or 
>> `[[no_unique_address]]`, or to use `consume`) when they mean it; that way, 
>> if they compile their code on both Clang and some other compiler that 
>> supports a target where the attribute does something, then they'll get the 
>> behavior they asked for. We shouldn't be encouraging people to wrap uses of 
>> standard attributes in macros.
>
> Errr, I have exactly the opposite opinion as you on this. I do not think it 
> helps users to claim vacuous support for an attribute -- that's a response 
> only a compiler writer/committee member could appreciate. In my experience, 
> users want to know "does the attribute do what it says on the tin" not "can 
> the compiler trivially claim conformance". `[[carries_dependency]]` is an 
> optimization hint; that we don't attempt to even pass the information along 
> to the backend to try to vary optimization behavior means we're not doing 
> what the attribute says on the tin. And given that standard attributes are 
> inherently not portable nor backwards compatible, I think it's very 
> reasonable to encourage people to wrap their use in macros.
>
> Otherwise, what's the point to `__has_cpp_attribute` returning *anything* for 
> a standard attribute? Use

[clang] 2a2c0fd - [Driver][FreeBSD] Correct driver behavior if a triple is provided without a version

2023-02-21 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-02-21T14:08:26-05:00
New Revision: 2a2c0fd96757871f4e8052624000c208cc574fdf

URL: 
https://github.com/llvm/llvm-project/commit/2a2c0fd96757871f4e8052624000c208cc574fdf
DIFF: 
https://github.com/llvm/llvm-project/commit/2a2c0fd96757871f4e8052624000c208cc574fdf.diff

LOG: [Driver][FreeBSD] Correct driver behavior if a triple is provided without 
a version

While looking at other usage of getOSMajorVersion() I noticed if a version 
number is not
included in the FreeBSD triple it won't include the --hash-style=both linker 
option or
not disable the use of .init_array. Without a version should be the latest.

FreeBSD 8 and 9 are no longer supported. So simplify things with the version 
handling
as well.

Reviewed By: dim

Differential Revision: https://reviews.llvm.org/D144341

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/test/Driver/constructors.c
clang/test/Driver/freebsd.c
clang/test/Driver/freebsd.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 0252c89be629a..307d1e78b99b1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -2386,9 +2386,7 @@ class X86_64ABIInfo : public ABIInfo {
   return false;
 
 const llvm::Triple &Triple = getTarget().getTriple();
-if (Triple.isOSDarwin() || Triple.isPS())
-  return false;
-if (Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 10)
+if (Triple.isOSDarwin() || Triple.isPS() || Triple.isOSFreeBSD())
   return false;
 return true;
   }

diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 6653cd2017fbe..f3c60a405883f 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -176,10 +176,8 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("/libexec/ld-elf.so.1");
 }
 const llvm::Triple &T = ToolChain.getTriple();
-if (T.getOSMajorVersion() >= 9) {
-  if (Arch == llvm::Triple::arm || Arch == llvm::Triple::sparc || 
T.isX86())
-CmdArgs.push_back("--hash-style=both");
-}
+if (Arch == llvm::Triple::arm || Arch == llvm::Triple::sparc || T.isX86())
+  CmdArgs.push_back("--hash-style=both");
 CmdArgs.push_back("--enable-new-dtags");
   }
 
@@ -396,17 +394,11 @@ FreeBSD::FreeBSD(const Driver &D, const llvm::Triple 
&Triple,
 getFilePaths().push_back(concat(getDriver().SysRoot, "/usr/lib"));
 }
 
-ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
-  unsigned Major = getTriple().getOSMajorVersion();
-  if (Major >= 10 || Major == 0)
-return ToolChain::CST_Libcxx;
-  return ToolChain::CST_Libstdcxx;
-}
-
 unsigned FreeBSD::GetDefaultDwarfVersion() const {
-  if (getTriple().getOSMajorVersion() < 12)
-return 2;
-  return 4;
+  unsigned Major = getTriple().getOSMajorVersion();
+  if (Major >= 12 || Major == 0)
+return 4;
+  return 2;
 }
 
 void FreeBSD::AddClangSystemIncludeArgs(
@@ -550,8 +542,9 @@ SanitizerMask FreeBSD::getSupportedSanitizers() const {
 void FreeBSD::addClangTargetOptions(const ArgList &DriverArgs,
 ArgStringList &CC1Args,
 Action::OffloadKind) const {
+  unsigned Major = getTriple().getOSMajorVersion();
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array,
-  getTriple().getOSMajorVersion() >= 12))
+  (Major >= 12 || Major == 0)))
 CC1Args.push_back("-fno-use-init-array");
 }

diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.h 
b/clang/lib/Driver/ToolChains/FreeBSD.h
index 18832dad98847..b12814a444c40 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.h
+++ b/clang/lib/Driver/ToolChains/FreeBSD.h
@@ -61,7 +61,14 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
-  CXXStdlibType GetDefaultCXXStdlibType() const override;
+
+  RuntimeLibType GetDefaultRuntimeLibType() const override {
+return ToolChain::RLT_CompilerRT;
+  }
+  CXXStdlibType GetDefaultCXXStdlibType() const override {
+return ToolChain::CST_Libcxx;
+  }
+
   void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
  llvm::opt::ArgStringList &CC1Args) const override;
   void

diff  --git a/clang/test/Driver/constructors.c 
b/clang/test/Driver/constructors.c
index 1561bc47ec4f4..f844e80a5450f 100644
--- a/clang/test/Driver/constructors.c
+++ b/clang/test/Driver/constructors.c
@@ -84,7 +84,11 @@
 // RUN: %clang -### %s -fsyntax-only 2>&1   

[PATCH] D144320: [Clang][OpenMP] Update tests using update_cc_test_checks.py

2023-02-21 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 499241.
tianshilei1992 added a comment.

remove hash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144320

Files:
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp

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


[PATCH] D143670: Stop claiming we support [[carries_dependency]]

2023-02-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

In D143670#4133677 , @rsmith wrote:

> Until or unless a C++ DR permits us to define 
> `__has_cpp_attribute(carries_dependency)` to any value other than `200809L`, 
> we have a conformance requirement to macro-expand this to that value. CWG2695 
> only adds a note, so it changes nothing in this regard.

We don't yet have a C++ DR for this, but we do have EWG direction that such a 
DR is needed. At the end of the day, our behavior in Clang is inconsistent and 
this patch fixes that inconsistency. `__has_cpp_attribute(no_unique_address)` 
returns `0` on some targets for Clang already today. That cannot change without 
the risk of silently breaking ABI for users. This is why EWG is moving in the 
direction of making the value returned by the feature test macro be a matter of 
QoI. So in terms of behaving consistently, we're faced with a choice: 
potentially break users by returning nonzero for `no_unique_address` or stop 
returning nonzero for `carries_dependency`. GCC has always returned 0 for 
`carries_dependency`. Returning 0 makes Clang consistent with GCC for this 
specific attribute and makes Clang consistent with itself in terms of standard 
attributes.

> Similarly, we have a conformance requirement to emit a diagnostic on invalid 
> uses of the attribute, and per our policy for `-pedantic`, we should produce 
> an error for invalid uses under `-pedantic-errors` and not reject valid uses 
> in that mode. So I think we still need all of the functionality that this 
> patch removes for conformance reasons, for now at least. Maybe WG21 would be 
> receptive to a paper making support of `[[carries_dependency]]` optional.

The behavior of `-pedantic-errors` is an interesting point. We *conform* with 
an "attribute ignored" diagnostic as far as the standard is concerned (so 
there's no problem about conformance requirements) but it doesn't meet our 
usual behavior of giving an error in `-pedantic-errors` mode. We have quite a 
few other instances of missing pedantic errors and it'd be nice to not make 
that worse. However, given that we are missing plenty of other pedantic error 
diagnostics, I'm not certain that observation changes a whole lot in practice.

> Conformance aside, the meaning of `[[carries_dependency]]` on a particular 
> platform is an ABI requirement. On every platform that we support, the psABI 
> does not specify any different handling for `[[carries_dependency]]` 
> functions, so we *are* implementing the attribute completely and correctly on 
> those targets, it just happens to be vacuous. If there were a target that 
> defined a different ABI rule, or was anticipated to add such a different ABI 
> rule (eg, due to some future PowerPC or ARM ABI change), then it would make 
> sense to stop claiming support on those platforms until we implemented the 
> behavior (I have the behavior of `[[no_unique_address]]` on MS ABI in mind 
> here particularly). But I think it's not helpful to users to say we don't 
> support it because it doesn't happen to make a difference on the current 
> target, just it's not helpful to say we don't support `[[no_unique_address]]` 
> just because it doesn't affect struct layout on a particular target, or -- 
> more to the point -- it wouldn't be helpful to say we don't support `consume` 
> memory ordering just because we don't get any benefit from it on the current 
> target compared to `acquire` (and as a result, we lower `consume` to 
> `acquire`). I think it's much better to let people unconditionally add 
> `[[carries_dependency]]` (or `[[no_unique_address]]`, or to use `consume`) 
> when they mean it; that way, if they compile their code on both Clang and 
> some other compiler that supports a target where the attribute does 
> something, then they'll get the behavior they asked for. We shouldn't be 
> encouraging people to wrap uses of standard attributes in macros.

Errr, I have exactly the opposite opinion as you on this. I do not think it 
helps users to claim vacuous support for an attribute -- that's a response only 
a compiler writer/committee member could appreciate. In my experience, users 
want to know "does the attribute do what it says on the tin" not "can the 
compiler trivially claim conformance". `[[carries_dependency]]` is an 
optimization hint; that we don't attempt to even pass the information along to 
the backend to try to vary optimization behavior means we're not doing what the 
attribute says on the tin. And given that standard attributes are inherently 
not portable nor backwards compatible, I think it's very reasonable to 
encourage people to wrap their use in macros.

Otherwise, what's the point to `__has_cpp_attribute` returning *anything* for a 
standard attribute? Users can check `__cplusplus` instead if the only answer 
they need to get from the feature test macro is "what version of the standard 
are you u

[PATCH] D143306: [Driver] Default to -fno-openmp-implicit-rpath

2023-02-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4218-4223
 defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath",
   LangOpts<"OpenMP">,
-  DefaultTrue,
+  DefaultFalse,
   PosFlag,
   NegFlag,
   BothFlags<[NoArgumentUnused]>>;

yaxunl wrote:
> I am wondering whether this option can be aliased to `--offload-add-rpath`, 
> which seems to have the same purpose. (https://reviews.llvm.org/D136854)
It can be aliased to `--[no-]offload-add-rpath`, but I think it probably makes 
sense to drop this option completely. This patch as-is is useful for 
backporting into 16.x.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143306

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


[PATCH] D142569: [OpenMP] Introduce kernel environment

2023-02-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG




Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:3917
+
+  Twine DynamicEnvironmenttName = KernelName + "_dynamic_environment";
+  Constant *DynamicEnvironmentInitializer =

Typo: `tt`



Comment at: 
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp:583
+  if (!KernelEnvOrError)
+return KernelEnvOrError.takeError();
+

We used to default to SPMD w/o a _exec_mode. Unsure if this will cause 
problems. I am inclined to allow missing _kernel_env as well and use SPMD then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

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


[PATCH] D144431: [clang-tidy] Fix readability-identifer-naming Hungarian CString options

2023-02-21 Thread Alexis Murzeau via Phabricator via cfe-commits
amurzeau updated this revision to Diff 499239.
amurzeau added a comment.

Add a release note for this fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144431

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -169,6 +169,10 @@
   ` check.
   Global options of the same name should be used instead.
 
+- Fixed reading `HungarianNotation.CString.*` options in
+  :doc:`readability-identifier-naming
+  ` check.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -472,7 +472,7 @@
 Buffer.append(CStr.first);
 StringRef Val = Options.get(Buffer, "");
 if (!Val.empty())
-  HNOption.CString[CStr.first] = Val.str();
+  HNOption.CString[CStr.second] = Val.str();
   }
 
   Buffer = {Section, "PrimitiveType."};


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -169,6 +169,10 @@
   ` check.
   Global options of the same name should be used instead.
 
+- Fixed reading `HungarianNotation.CString.*` options in
+  :doc:`readability-identifier-naming
+  ` check.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -472,7 +472,7 @@
 Buffer.append(CStr.first);
 StringRef Val = Options.get(Buffer, "");
 if (!Val.empty())
-  HNOption.CString[CStr.first] = Val.str();
+  HNOption.CString[CStr.second] = Val.str();
   }
 
   Buffer = {Section, "PrimitiveType."};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143509: Move the BySpelling map to IncludeStructure.

2023-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Headers.cpp:303
+  llvm::SmallVector Includes;
+  auto It = MainFileIncludesBySpelling.find(Spelling);
+  if (It == MainFileIncludesBySpelling.end())

nit:
```
llvm::SmallVector Includes;
for (auto Idx : MainFileIncludesBySpelling.lookup(Spelling))
  Includes.push_back(&MainFileIncludes[Idx]);
return Includes;
```



Comment at: clang-tools-extra/clangd/Headers.h:167
+  // Spelling should include brackets or quotes, e.g. .
+  llvm::SmallVector
+  mainFileIncludesWithSpelling(llvm::StringRef Spelling) const {

kadircet wrote:
> we're still returning just the `HeaderID`, the suggestion was to return 
> `llvm::SmallVector` so that applications can work with other 
> information available in the `Inclusion`. we also won't have any requirements 
> around include being resolved that way. the application should figure out 
> what to do if `HeaderID` is missing.
> 
> also can you move this function body to source file instead?
almost, but not right. we're returning copies of `Inclusion`s here, not 
pointers to `Inclusion`s inside the main file. the suggested signature was 
`llvm::SmallVector` any reason for returning by value? 



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:516
+ Includes.mainFileIncludesWithSpelling(H.verbatim())) {
+  std::optional HeaderOpt = Inc.HeaderID;
+  if (HeaderOpt.has_value()) {

nit:
```
if(!Inc.HeaderID.has_value())
  continue;
Used.insert(static_cast(*Inc.HeaderID));
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143509

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


[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-02-21 Thread Jacob Young via Phabricator via cfe-commits
jacobly added a comment.

Jacob Young 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143233

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


[PATCH] D141757: [clangd] allow extracting to variable for complete lambda expressions

2023-02-21 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti added a comment.

You're right, I'll incorporate the logic for lambdas into `FindDeclRefsVisitor` 
and change the docs/comments/commit message to reflect this. I will try to 
think of more edge cases to test as well. Though I'll be busy until mid march 
with uni, so there will be no new revisions until then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

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


[PATCH] D144431: [clang-tidy] Fix readability-identifer-naming Hungarian CString options

2023-02-21 Thread Alexis Murzeau via Phabricator via cfe-commits
amurzeau updated this revision to Diff 499235.
amurzeau edited the summary of this revision.
amurzeau added a comment.

Remove test changes, I will make a different patch for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144431

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp


Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -472,7 +472,7 @@
 Buffer.append(CStr.first);
 StringRef Val = Options.get(Buffer, "");
 if (!Val.empty())
-  HNOption.CString[CStr.first] = Val.str();
+  HNOption.CString[CStr.second] = Val.str();
   }
 
   Buffer = {Section, "PrimitiveType."};


Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -472,7 +472,7 @@
 Buffer.append(CStr.first);
 StringRef Val = Options.get(Buffer, "");
 if (!Val.empty())
-  HNOption.CString[CStr.first] = Val.str();
+  HNOption.CString[CStr.second] = Val.str();
   }
 
   Buffer = {Section, "PrimitiveType."};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-21 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

We thought a bit about what it would take to link a constructor declaration DIE 
to the various definitions (e.g., via a `DW_AT_LLVM_complete_ctor_linkage_name` 
or `DW_AT_LLVM_complete_ctor_ref`). The issue with this is that it would mess 
with type uniquing. E.g., what if two different CUs each had a constructor 
declaration but differed only in which definitions they linked to? LLDB would 
have to support the case where two constructor DIEs for the same type point to 
different definitions depending on how they were used in the corresponding 
object files.

One could instead have some new attribute on the various constructor 
definitions specifying which constructor type it is, and then implement 
@pavel's suggestion of attaching multiple `asm` labels to the 
`CXXConstructorDecl`. To support that in LLDB we'd have to do a lookup in the 
DWARF index and filter appropriately. But it's unclear to me whether this is 
much better than the proposed patch (in terms of simplicity). I pinged the 
libcxx people regarding their policy of using abi-tags on structures/namespaces

Some more findings on the Clang side: a very naive way to support multiple 
`asm` labels is to adjust the `ManglingContext::mangleName` to be aware of 
multiple `asm` labels and pick the correct one based on the `GlobalDecl` we're 
mangling. But we'd need to somehow match `CtorType` to the `AsmLabelAttr` in 
question. Which is possibly doable by encoding the `CtorType` into the label. 
E.g., `asm("C2")` (?) Though that seems tacky


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

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


[PATCH] D135495: [clang-tidy] handle exceptions properly `ExceptionAnalyzer`

2023-02-21 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:66
+   CXXBasePath &) {
+if (BS->getType()->getAsCXXRecordDecl() == BaseClass &&
+BS->getAccessSpecifier() == AS_public) {

xazax.hun wrote:
> Will this work with typedefs and other sugar or do you need to get the 
> canonical type here? I do not see test coverage for that scenario.
In this specific case it will work because `getAsCXXRecordDecl()` comes from 
the `CanProxyBase` utility class, which already canonicalizes the type, but I 
agree that it's not intuitive and unreadable. 

I also modified the current test cases to have aliases.


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

https://reviews.llvm.org/D135495

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


[PATCH] D135495: [clang-tidy] handle exceptions properly `ExceptionAnalyzer`

2023-02-21 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs updated this revision to Diff 499234.
isuckatcs marked an inline comment as done.
isuckatcs added a comment.

Addressed comments


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

https://reviews.llvm.org/D135495

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -101,6 +101,126 @@
   }
 }
 
+void throw_catch_pointer_c() noexcept {
+  try {
+int a = 1;
+throw &a;
+  } catch(const int *) {}
+}
+
+void throw_catch_pointer_v() noexcept {
+  try {
+int a = 1;
+throw &a;
+  } catch(volatile int *) {}
+}
+
+void throw_catch_pointer_cv() noexcept {
+  try {
+int a = 1;
+throw &a;
+  } catch(const volatile int *) {}
+}
+
+void throw_catch_multi_ptr_1() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_catch_multi_ptr_1' which should not throw exceptions
+  try {
+char **p = 0;
+throw p;
+  } catch (const char **) {
+  }
+}
+
+void throw_catch_multi_ptr_2() noexcept {
+  try {
+char **p = 0;
+throw p;
+  } catch (const char *const *) {
+  }
+}
+
+void throw_catch_multi_ptr_3() noexcept {
+  try {
+char **p = 0;
+throw p;
+  } catch (volatile char *const *) {
+  }
+}
+
+void throw_catch_multi_ptr_4() noexcept {
+  try {
+char **p = 0;
+throw p;
+  } catch (volatile const char *const *) {
+  }
+}
+
+// FIXME: In this case 'a' is convertible to the handler and should be caught
+// but in reality it's thrown. Note that clang doesn't report a warning for 
+// this either.
+void throw_catch_multi_ptr_5() noexcept {
+  try {
+double *a[2][3];
+throw a;
+  } catch (double *(*)[3]) {
+  }
+}
+
+
+void throw_c_catch_pointer() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_c_catch_pointer' which should not throw exceptions
+  try {
+int a = 1;
+const int *p = &a;
+throw p;
+  } catch(int *) {}
+}
+
+void throw_c_catch_pointer_v() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_c_catch_pointer_v' which should not throw exceptions
+  try {
+int a = 1;
+const int *p = &a;
+throw p;
+  } catch(volatile int *) {}
+}
+
+void throw_v_catch_pointer() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_v_catch_pointer' which should not throw exceptions
+  try {
+int a = 1;
+volatile int *p = &a;
+throw p;
+  } catch(int *) {}
+}
+
+void throw_v_catch_pointer_c() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_v_catch_pointer_c' which should not throw exceptions
+  try {
+int a = 1;
+volatile int *p = &a;
+throw p;
+  } catch(const int *) {}
+}
+
+void throw_cv_catch_pointer_c() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_cv_catch_pointer_c' which should not throw exceptions
+  try {
+int a = 1;
+const volatile int *p = &a;
+throw p;
+  } catch(const int *) {}
+}
+
+void throw_cv_catch_pointer_v() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_cv_catch_pointer_v' which should not throw exceptions
+  try {
+int a = 1;
+const volatile int *p = &a;
+throw p;
+  } catch(volatile int *) {}
+}
+
 class base {};
 class derived: public base {};
 
@@ -112,6 +232,173 @@
   }
 }
 
+void throw_derived_alias_catch_base() noexcept {
+  using alias = derived;
+
+  try {
+throw alias();
+  } catch(base &) {
+  }
+}
+
+void throw_derived_catch_base_alias() noexcept {
+  using alias = base;
+
+  try {
+throw derived();
+  } catch(alias &) {
+  }
+}
+
+void throw_derived_catch_base_ptr_c() noexcept {
+  try {
+derived d;
+throw &d; 
+  } catch(const base *) {
+  }
+}
+
+void throw_derived_catch_base_ptr() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ptr' which should not throw exceptions
+  try {
+derived d;
+const derived *p = &d;
+throw p; 
+  } catch(base *) {
+  }
+}
+
+class A {};
+class B : A {};
+
+// The following alias hell is deliberately created for testing.
+using aliasedA = A;
+class C : protected aliasedA {};
+
+typedef aliasedA moreAliasedA;
+class D : public moreAliasedA {};
+
+using moreMoreAliasedA = moreAliasedA;
+using aliasedD = D;
+class E : public moreMoreAliasedA, public aliasedD {};
+
+void throw_derived_catch_base_private() noexcept {

[PATCH] D144454: Add builtin for llvm set rounding

2023-02-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

New builtins should be documented in the user manual.

There are standard pragmas for changing the rounding mode, right?  What's the 
interaction between the ability to set this dynamically with a builtin call and 
those pragmas?




Comment at: clang/test/CodeGen/builtins.c:283
+  res = __builtin_flt_rounds_set(1);
+  // CHECK: call void @llvm.set.rounding(
 }

Just for completeness, please test that this gets the result of the expression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144454

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


[PATCH] D144444: [PowerPC] Use member function to determine PowerPC Secure PLT

2023-02-21 Thread Dimitry Andric via Phabricator via cfe-commits
dim accepted this revision.
dim added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D14

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


[PATCH] D144456: [clangd] Publish diagnostics with stale preambles

2023-02-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 499224.
kadircet marked 7 inline comments as done.
kadircet added a comment.

- Notify preamble peer before building an AST, to concurrently build fresh 
preamble & AST.
- Refactoring for tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144456

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -8,6 +8,8 @@
 
 #include "Annotations.h"
 #include "ClangdServer.h"
+#include "Compiler.h"
+#include "Config.h"
 #include "Diagnostics.h"
 #include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
@@ -21,7 +23,6 @@
 #include "support/Path.h"
 #include "support/TestTracer.h"
 #include "support/Threading.h"
-#include "support/ThreadsafeFS.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/FunctionExtras.h"
@@ -31,19 +32,23 @@
 #include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
 namespace {
 
+using ::testing::_;
 using ::testing::AllOf;
 using ::testing::AnyOf;
 using ::testing::Contains;
@@ -1194,6 +1199,118 @@
   EXPECT_EQ(PreamblePublishCount, 2);
 }
 
+TEST_F(TUSchedulerTests, PublishWithStalePreamble) {
+  // Callbacks that blocks the preamble thread after the first preamble is
+  // built and stores preamble/main-file versions for diagnostics released.
+  class BlockPreambleThread : public ParsingCallbacks {
+  public:
+using DiagsCB = std::function;
+BlockPreambleThread(Notification &UnblockPreamble, DiagsCB CB)
+: UnblockPreamble(UnblockPreamble), CB(std::move(CB)) {}
+
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &, ASTContext &Ctx,
+   Preprocessor &, const CanonicalIncludes &) override {
+  if (BuildBefore)
+ASSERT_TRUE(UnblockPreamble.wait(timeoutSeconds(5)))
+<< "Expected notification";
+  BuildBefore = true;
+}
+
+void onMainAST(PathRef File, ParsedAST &AST, PublishFn Publish) override {
+  CB(AST);
+}
+
+void onFailedAST(PathRef File, llvm::StringRef Version,
+ std::vector Diags, PublishFn Publish) override {
+  ADD_FAILURE() << "Received failed ast for: " << File << " with version "
+<< Version << '\n';
+}
+
+  private:
+bool BuildBefore = false;
+Notification &UnblockPreamble;
+std::function CB;
+  };
+
+  // Helpers for issuing blocking update requests on a TUScheduler, whose
+  // onMainAST callback would call onDiagnostics.
+  class DiagCollector {
+  public:
+void onDiagnostics(ParsedAST &AST) {
+  std::scoped_lock Lock(DiagMu);
+  DiagVersions.emplace_back(
+  std::make_pair(AST.preambleVersion()->str(), AST.version().str()));
+  DiagsReceived.notify_all();
+}
+
+std::pair
+waitForNewDiags(TUScheduler &S, PathRef File, ParseInputs PI) {
+  std::unique_lock Lock(DiagMu);
+  // Perform the update under the lock to make sure it isn't handled until
+  // we're waiting for it.
+  S.update(File, std::move(PI), WantDiagnostics::Auto);
+  size_t OldSize = DiagVersions.size();
+  bool ReceivedDiags = DiagsReceived.wait_for(
+  Lock, std::chrono::seconds(5),
+  [this, OldSize] { return OldSize + 1 == DiagVersions.size(); });
+  if (!ReceivedDiags) {
+ADD_FAILURE() << "Timed out waiting for diags";
+return {"invalid", "version"};
+  }
+  return DiagVersions.back();
+}
+
+std::vector> diagVersions() {
+  std::scoped_lock Lock(DiagMu);
+  return DiagVersions;
+}
+
+  private:
+std::condition_variable DiagsReceived;
+std::mutex DiagMu;
+std::vector>
+DiagVersions;
+  };
+
+  Config Cfg;
+  Cfg.Diagnostics.AllowStalePreamble = true;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+
+  DiagCollector Collector;
+  Notification UnblockPreamble;
+  auto DiagCallbacks = std::make_unique(
+  UnblockPreamble,
+  [&Collector](ParsedAST &AST) { Collector.onDiagnostics(AST); });
+  TUScheduler S(CDB, optsForTest(), std::move(DiagCallbacks));
+  Path File = testPath("foo.cpp");
+  auto BlockForDiags = [&](ParseInputs PI) {
+return Collector.waitForNewDiags(S, File, std::move(PI));
+  };
+
+  // Build first preamble.
+  auto PI = getInputs(File, "");
+  PI.Version = PI.Contents = "1";
+  ASSERT_THAT(BlockForDiags(PI), testing::Pair("1", "1"));
+
+  // Now preamble thr

  1   2   >