[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-01-13 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:17
+
+static const llvm::StringSet<> ValueTraits = {
+"alignment_of",

I'm guessing this list was obtained in some automatic way - could we document 
the process for generating it, so a future maintainer knows how to do it?



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:104
+
+static const llvm::StringSet<> TypeTraits = {
+"remove_cv",

Ditto



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:105-108
+"remove_cv",
+"remove_const",
+"remove_volatile",
+"add_cv",

Please keep alphabetical order.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:134-139
+static const internal::VariadicDynCastAllOfMatcher
+dependentScopeDeclRefExpr; // NOLINT(readability-identifier-naming)
+static const internal::VariadicDynCastAllOfMatcher
+dependentNameTypeLoc; // NOLINT(readability-identifier-naming)

Why do we need these matchers at global scope, if they are only used in the 
`registerMatchers` function?

Unless they are POD types, putting objects at global scope is bugprone since 
they are initialized before `main` in an unspecified order.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h:17
+namespace tidy {
+namespace modernize {
+

njames93 wrote:
> Eugene.Zelenko wrote:
> > tschuett wrote:
> > > Why do you refuse to use nested namespaces in `modernize` ?
> > I think this is done for legacy reasons. This should be done for all checks 
> > and `add_new_check.py`.
> Because the add_new_check script hasn't been updated since we went to c++17
Is the goal to update all existing checks to C++17 format?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp:38
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tinTemplate();
+

There should be a space in here, right? Same for the rest.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp:52
+
+// For macros we don't want any fixes to be emitted
+

As a user I find it a bit confusing that there is a warning, but no fix. Should 
we just disable the warning on macros entirely? 

Furthermore, the warning shows up at the call site, so if it's not possible to 
fix it will be very noisy for people to suppress it everywhere where the macro 
is used. Maybe add an option `IgnoreMacros` similar to how it's done for other 
checks? Alternatively, as a user I would like to be able to suppress the 
warning in line 54 once only instead of at the call site.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

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


[PATCH] D141666: [RISCV] Proper support of extensions Zicsr and Zifencei

2023-01-13 Thread Elena Lepilkina via Phabricator via cfe-commits
eklepilkina created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, jdoerfert, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, hiraditya, arichardson.
Herald added a project: All.
eklepilkina requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141666

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/riscv-default-features.c
  clang/test/Driver/riscv-gnutools.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/CodeGen/RISCV/get-register-noreserve.ll
  llvm/test/CodeGen/RISCV/readcyclecounter.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-stack-align.mir
  llvm/test/CodeGen/RISCV/rvv/scalar-stack-align.ll
  llvm/test/CodeGen/RISCV/rvv/vscale-power-of-two.ll
  llvm/test/CodeGen/RISCV/rvv/zvlsseg-zero-vl.ll
  llvm/test/CodeGen/RISCV/vlenb.ll
  llvm/test/MC/RISCV/Ztso.s
  llvm/test/MC/RISCV/csr-aliases.s
  llvm/test/MC/RISCV/deprecated-csr-names.s
  llvm/test/MC/RISCV/hypervisor-csr-names.s
  llvm/test/MC/RISCV/machine-csr-names.s
  llvm/test/MC/RISCV/rv32-hypervisor-csr-names.s
  llvm/test/MC/RISCV/rv32-machine-csr-names.s
  llvm/test/MC/RISCV/rv32-supervisor-csr-names.s
  llvm/test/MC/RISCV/rv32-user-csr-names.s
  llvm/test/MC/RISCV/rv32e-valid.s
  llvm/test/MC/RISCV/rv32i-aliases-valid.s
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32i-valid.s
  llvm/test/MC/RISCV/rv64-machine-csr-names.s
  llvm/test/MC/RISCV/rv64-user-csr-names.s
  llvm/test/MC/RISCV/rvf-user-csr-names.s
  llvm/test/MC/RISCV/rvi-aliases-valid.s
  llvm/test/MC/RISCV/rvk-user-csr-name.s
  llvm/test/MC/RISCV/supervisor-csr-names.s
  llvm/test/MC/RISCV/user-csr-names.s

Index: llvm/test/MC/RISCV/user-csr-names.s
===
--- llvm/test/MC/RISCV/user-csr-names.s
+++ llvm/test/MC/RISCV/user-csr-names.s
@@ -1,13 +1,13 @@
-# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -show-encoding \
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zicsr -riscv-no-aliases -show-encoding \
 # RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
-# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
-# RUN: | llvm-objdump -d - \
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zicsr < %s \
+# RUN: | llvm-objdump -d --mattr=+zicsr - \
 # RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
 #
-# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases -show-encoding \
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zicsr -riscv-no-aliases -show-encoding \
 # RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
-# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
-# RUN: | llvm-objdump -d - \
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zicsr < %s \
+# RUN: | llvm-objdump -d --mattr=+zicsr - \
 # RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
 
 ##
Index: llvm/test/MC/RISCV/supervisor-csr-names.s
===
--- llvm/test/MC/RISCV/supervisor-csr-names.s
+++ llvm/test/MC/RISCV/supervisor-csr-names.s
@@ -1,13 +1,13 @@
-# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -show-encoding \
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zicsr -riscv-no-aliases -show-encoding \
 # RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
-# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
-# RUN: | llvm-objdump -d - \
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zicsr < %s \
+# RUN: | llvm-objdump -d --mattr=+zicsr - \
 # RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
 #
-# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases -show-encoding \
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zicsr -riscv-no-aliases -show-encoding \
 # RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
-# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
-# RUN: | llvm-objdump -d - \
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zicsr < %s \
+# RUN: | llvm-objdump -d --mattr=+zicsr - \
 # RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
 
 ##
Index: llvm/test/MC/RISCV/rvk-user-csr-name.s
===
--- llvm/test/MC/RISCV/rvk-user-csr-name.s
+++ llvm/test/MC/RISCV/rvk-user-csr-name.s
@@ -1,13 +1,13 @@
-# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -mattr=+f -show-encoding \
+# RUN:

[clang] 7c4a70f - [Driver] Add crtfastmath.o on Solaris if appropriate

2023-01-13 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-01-13T10:08:33+01:00
New Revision: 7c4a70f8f6f37c0d22770fa60e079aaf8928a01c

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

LOG: [Driver] Add crtfastmath.o on Solaris if appropriate

`Flang :: Driver/fast_math.f90` `FAIL`s on Solaris because `crtfastmath.o`
is missing from the link line.

This patch adds it as appropriate.

Tested on `amd64-pc-solaris2.11`.

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

Added: 

clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o

clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o

clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o

clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o

Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index c75375ac95f7b..7cc872c717759 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -115,6 +115,8 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
+// Add crtfastmath.o if available and fast math is enabled.
+getToolChain().addFastMathRuntimeIfAvailable(Args, CmdArgs);
   }
 
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
 
b/clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 2193f35ac0545..2127ad5ded074 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -114,3 +114,57 @@
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
+
+// Check that crtfastmath.o is linked with -ffast-math.
+
+// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
+// CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC32: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
+
+// Check sparc-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
+// CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC64: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 32bi

[PATCH] D141596: [Driver] Add crtfastmath.o on Solaris if appropriate

2023-01-13 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c4a70f8f6f3: [Driver] Add crtfastmath.o on Solaris if 
appropriate (authored by ro).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141596

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  
clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtfastmath.o
  
clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9/crtfastmath.o
  
clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64/crtfastmath.o
  
clang/test/Driver/Inputs/solaris_x86_tree/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/crtfastmath.o
  clang/test/Driver/solaris-ld.c


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -114,3 +114,57 @@
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
+
+// Check that crtfastmath.o is linked with -ffast-math.
+
+// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
+// RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
+// CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC32: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
+
+// Check sparc-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
+// CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-SPARC64: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang --target=i386-pc-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X32 %s
+// RUN: %clang --target=i386-pc-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-X32 %s
+// CHECK-CRTFASTMATH-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-X32: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-X32-NOT: crtfastmath.o
+
+// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X64 %s
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s -ffast-math \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH-X64 %s
+// CHECK-CRTFASTMATH-X64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-CRTFASTMATH-X64: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtfastmath.o"
+// CHECK-NOCRTFASTMATH-X64-NOT: crtfastmath.o
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -115,6 +115,8 @@
 Args.MakeArgString(getToolChain().GetFilePath(values_xpg)));
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
+// Add crtfastmath.o if available and fast math is enabled.
+getToolChain().addFastMathRuntimeIfAvailable(Args, CmdArgs);
   }
 
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -114,3 +114,57 @@
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
 // CHECK-RELOCATABLE-NOT:

[PATCH] D141666: [RISCV] Proper support of extensions Zicsr and Zifencei

2023-01-13 Thread Elena Lepilkina via Phabricator via cfe-commits
eklepilkina added a comment.

We are interested in proper support for `Zicsr` and `Zifencei`. Could someone 
look at patch or explain why these extensions were included by default?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141666

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


[PATCH] D141598: [clang] Redefine some AVR specific macros

2023-01-13 Thread Ben Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16f9451b0761: [clang] Redefine some AVR specific macros 
(authored by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141598

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4319,6 +4319,22 @@
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
 
+// Begin avr tests 
+
+// RUN: %clang --target=avr -mmcu=atmega328 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR0
+// CHECK-AVR0: #define __AVR_ARCH__ 5
+// CHECK-AVR0: #define __AVR_ATmega328__ 1
+// CHECK-AVR0: #define __flash __attribute__((__address_space__(1)))
+// RUN: %clang --target=avr -mmcu=atmega2560 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR1
+// CHECK-AVR1: #define __AVR_ARCH__ 6
+// CHECK-AVR1: #define __AVR_ATmega2560__ 1
+// CHECK-AVR1: #define __flash  __attribute__((__address_space__(1)))
+// CHECK-AVR1: #define __flash1 __attribute__((__address_space__(2)))
+// CHECK-AVR1: #define __flash2 __attribute__((__address_space__(3)))
+// CHECK-AVR1: #define __flash3 __attribute__((__address_space__(4)))
+
 // Begin M68k tests 
 
 // RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -468,15 +468,15 @@
   }
 
   if (NumFlashBanks >= 1)
-Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+Builder.defineMacro("__flash", "__attribute__((__address_space__(1)))");
   if (NumFlashBanks >= 2)
-Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+Builder.defineMacro("__flash1", "__attribute__((__address_space__(2)))");
   if (NumFlashBanks >= 3)
-Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+Builder.defineMacro("__flash2", "__attribute__((__address_space__(3)))");
   if (NumFlashBanks >= 4)
-Builder.defineMacro("__flash3", "__attribute__((address_space(4)))");
+Builder.defineMacro("__flash3", "__attribute__((__address_space__(4)))");
   if (NumFlashBanks >= 5)
-Builder.defineMacro("__flash4", "__attribute__((address_space(5)))");
+Builder.defineMacro("__flash4", "__attribute__((__address_space__(5)))");
   if (NumFlashBanks >= 6)
-Builder.defineMacro("__flash5", "__attribute__((address_space(6)))");
+Builder.defineMacro("__flash5", "__attribute__((__address_space__(6)))");
 }


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4319,6 +4319,22 @@
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
 
+// Begin avr tests 
+
+// RUN: %clang --target=avr -mmcu=atmega328 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR0
+// CHECK-AVR0: #define __AVR_ARCH__ 5
+// CHECK-AVR0: #define __AVR_ATmega328__ 1
+// CHECK-AVR0: #define __flash __attribute__((__address_space__(1)))
+// RUN: %clang --target=avr -mmcu=atmega2560 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR1
+// CHECK-AVR1: #define __AVR_ARCH__ 6
+// CHECK-AVR1: #define __AVR_ATmega2560__ 1
+// CHECK-AVR1: #define __flash  __attribute__((__address_space__(1)))
+// CHECK-AVR1: #define __flash1 __attribute__((__address_space__(2)))
+// CHECK-AVR1: #define __flash2 __attribute__((__address_space__(3)))
+// CHECK-AVR1: #define __flash3 __attribute__((__address_space__(4)))
+
 // Begin M68k tests 
 
 // RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -468,15 +468,15 @@
   }
 
   if (NumFlashBanks >= 1)
-Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+Builder.defineMacro("__flash", "__attribute__((__address_space__(1)))");
   if (NumFlashBanks >= 2)
-Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+Builder.defineMacro("__flash1", "__attribute__((__address_space__(2)))");
   if (NumFlashBanks >= 3)
-Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+Builder.defineMacro("__flash2", "__attribute__((__address_space__(3)))");

[clang] 16f9451 - [clang] Redefine some AVR specific macros

2023-01-13 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2023-01-13T17:22:15+08:00
New Revision: 16f9451b07619cd84e0b88ff17ca2b27a2c1f9cc

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

LOG: [clang] Redefine some AVR specific macros

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

Reviewed By: aykevl, Miss_Grape

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

Added: 


Modified: 
clang/lib/Basic/Targets/AVR.cpp
clang/test/Preprocessor/predefined-arch-macros.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index f2e5d970f3210..3d662cc3ba74f 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -468,15 +468,15 @@ void AVRTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   }
 
   if (NumFlashBanks >= 1)
-Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
+Builder.defineMacro("__flash", "__attribute__((__address_space__(1)))");
   if (NumFlashBanks >= 2)
-Builder.defineMacro("__flash1", "__attribute__((address_space(2)))");
+Builder.defineMacro("__flash1", "__attribute__((__address_space__(2)))");
   if (NumFlashBanks >= 3)
-Builder.defineMacro("__flash2", "__attribute__((address_space(3)))");
+Builder.defineMacro("__flash2", "__attribute__((__address_space__(3)))");
   if (NumFlashBanks >= 4)
-Builder.defineMacro("__flash3", "__attribute__((address_space(4)))");
+Builder.defineMacro("__flash3", "__attribute__((__address_space__(4)))");
   if (NumFlashBanks >= 5)
-Builder.defineMacro("__flash4", "__attribute__((address_space(5)))");
+Builder.defineMacro("__flash4", "__attribute__((__address_space__(5)))");
   if (NumFlashBanks >= 6)
-Builder.defineMacro("__flash5", "__attribute__((address_space(6)))");
+Builder.defineMacro("__flash5", "__attribute__((__address_space__(6)))");
 }

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 68fa6e2c6feab..a78bac132db15 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -4319,6 +4319,22 @@
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
 
+// Begin avr tests 
+
+// RUN: %clang --target=avr -mmcu=atmega328 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR0
+// CHECK-AVR0: #define __AVR_ARCH__ 5
+// CHECK-AVR0: #define __AVR_ATmega328__ 1
+// CHECK-AVR0: #define __flash __attribute__((__address_space__(1)))
+// RUN: %clang --target=avr -mmcu=atmega2560 -E -dM %s -o - 2>&1 \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK-AVR1
+// CHECK-AVR1: #define __AVR_ARCH__ 6
+// CHECK-AVR1: #define __AVR_ATmega2560__ 1
+// CHECK-AVR1: #define __flash  __attribute__((__address_space__(1)))
+// CHECK-AVR1: #define __flash1 __attribute__((__address_space__(2)))
+// CHECK-AVR1: #define __flash2 __attribute__((__address_space__(3)))
+// CHECK-AVR1: #define __flash3 __attribute__((__address_space__(4)))
+
 // Begin M68k tests 
 
 // RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \



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


[PATCH] D136156: [Clang][Diagnostic] Add hidden-reinterpret-cast diagnostic warning

2023-01-13 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver abandoned this revision.
TWeaver added a comment.

Hi all,

thanks for your time and effort reviewing this patch.

I'm going to close this now due to the lack of interest in it's current form.

thanks again and happy coding,
Tom


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

https://reviews.llvm.org/D136156

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


[PATCH] D141230: [clang-format-diff.py] give clang-format-diff a job pool (10x speed)

2023-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141230#4048069 , @seanptmaher 
wrote:

> The use case I was using this with was running diff formatting of very large 
> diffs (automated mass refactors changing thousands of files) on the chromium 
> codebase -- I'm not sure how to "include" such a use case as you mentioned. I 
> could write a benchmark if you'd like?

I was thinking about trying out whatever you did when reviewing this patch, so 
it would be helpful if you could share the steps/commands you used. A benchmark 
is unnecessary, but having some tests would be great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141230

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


[PATCH] D141608: [include-cleaner] Don't consider the underlying type of Decltype MemberProvider as a use

2023-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

I am a little skeptical about this one. I think it's somewhat an obscure 
pattern, and probably warrants a use of the type when it can be deduced and the 
user code is accessing members (relying on the type more than an opaque 
manner). So what about waiting on this patch until we encounter examples in 
real world that require such a treatment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141608

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


[PATCH] D126365: [git-clang-format] Stop ignoring changes for files with space in path

2023-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a reviewer: rymiel.
owenpan added a comment.

We should get this patch landed. Can we use `Michael Kirk 
` as the author (see the same/similar 
patch at https://bugs.llvm.org/show_bug.cgi?id=28654) because @Eitot hasn't 
responded for quite some time now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126365

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


[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-13 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

When I run the new testcase
 clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
with ASAN binaries the test fails like

  FAIL: Clang :: SemaCXX/invalid-requirement-requires-expr.cpp (1 of 1)
   TEST 'Clang :: 
SemaCXX/invalid-requirement-requires-expr.cpp' FAILED 
  Script:
  --
  : 'RUN: at line 1';   
/repo/uabelho/main-github/llvm/build-all-bbisdk-asan/bin/clang -cc1 
-internal-isystem 
/repo/uabelho/main-github/llvm/build-all-bbisdk-asan/lib/clang/16/include 
-nostdsysteminc 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 -I/repo/uabelho/main-github/clang/test/SemaCXX -std=c++2a -verify
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics seen but not expected: 
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: stack nearly exhausted; compilation time may suffer, and crashes due 
to stack overflow are likely
  error: 'note' diagnostics seen but not expected: 
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: while checking the satisfaction of nested requirement requested here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: in instantiation of member function 'A<9660>::far' requested here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: while substituting template arguments into constraint expression here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: while checking the satisfaction of nested requirement requested here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: in instantiation of requirement here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: (skipping 1697 contexts in backtrace; use 
-ftemplate-backtrace-limit=0 to see all)
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: while substituting template arguments into constraint expression here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: while checking the satisfaction of nested requirement requested here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: in instantiation of requirement here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 18: while checking the satisfaction of nested requirement requested here
File 
/repo/uabelho/main-github/clang/test/SemaCXX/invalid-requirement-requires-expr.cpp
 Line 23: in instantiation of member function 'A<10001>::far' requested here
  12 errors generated.
  
  --
  
  
  
  Failed Tests (1):
Clang :: SemaCXX/invalid-requirement-requires-expr.cpp
  
  
  Testing Time: 0.16s
Failed: 1

Anyone else see this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D141572: [C++] [Coroutines] Deprecates the '-fcoroutines-ts' flag

2023-01-13 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D141572#4050492 , @ChuanqiXu wrote:

> @philnik when I run `ninja libcxx-generate-files` locally, it says `ninja: 
> error: unknown target 'libcxx-generate-files'`. The following off is my 
> configuring command:
>
>   cmake -G Ninja -S llvm -B build_libcxx_modules 
> -DLLVM_ENABLE_PROJECTS="clang"  -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" 
> -DCMAKE_BUILD_TYPE=Release
>
> Do you know if anything goes wrong?

It's probably because you're using the bootstrapping build. Since this invokes 
another CMake command internally to build libc++, the targets aren't available. 
It should work with `cmake -G Ninja -S runtimes -B <...> 
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"`.


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

https://reviews.llvm.org/D141572

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


[PATCH] D141538: [cmake] Fix path to LLVMConfig.cmake for multi-config builds

2023-01-13 Thread Sebastian Neubauer via Phabricator via cfe-commits
sebastian-ne added a comment.

The debian pre-checkin test is unfortunately quite unstable. I see the same 
failures in D141469  for example.
This looks good to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141538

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


[PATCH] D140415: [flang] stack arrays pass

2023-01-13 Thread Tom Eccles via Phabricator via cfe-commits
tblah updated this revision to Diff 488914.
tblah added a comment.

Updating patch context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140415

Files:
  clang/docs/tools/clang-formatted-files.txt
  flang/include/flang/Optimizer/Builder/MutableBox.h
  flang/include/flang/Optimizer/Dialect/FIRAttr.h
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/lib/Lower/Allocatable.cpp
  flang/lib/Optimizer/Builder/MutableBox.cpp
  flang/lib/Optimizer/Transforms/CMakeLists.txt
  flang/lib/Optimizer/Transforms/StackArrays.cpp
  flang/test/Lower/Intrinsics/c_loc.f90
  flang/test/Lower/Intrinsics/system_clock.f90
  flang/test/Transforms/stack-arrays.f90
  flang/test/Transforms/stack-arrays.fir

Index: flang/test/Transforms/stack-arrays.fir
===
--- /dev/null
+++ flang/test/Transforms/stack-arrays.fir
@@ -0,0 +1,220 @@
+// RUN: fir-opt --stack-arrays %s | FileCheck %s
+
+// Simplest transformation
+func.func @simple() {
+  %0 = fir.allocmem !fir.array<42xi32>
+  fir.freemem %0 : !fir.heap>
+  return
+}
+// CHECK: func.func @simple() {
+// CHECK-NEXT: fir.alloca !fir.array<42xi32>
+// CHECK-NEXT: return
+// CHECK-NEXT: }
+
+// Check fir.must_be_heap allocations are not moved
+func.func @must_be_heap() {
+  %0 = fir.allocmem !fir.array<42xi32> {fir.must_be_heap = true}
+  fir.freemem %0 : !fir.heap>
+  return
+}
+// CHECK:  func.func @must_be_heap() {
+// CHECK-NEXT:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32> {fir.must_be_heap = true}
+// CHECK-NEXT:   fir.freemem %[[ALLOC]] : !fir.heap>
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// Check the data-flow-analysis can detect cases where we aren't sure if memory
+// is freed by the end of the function
+func.func @dfa1(%arg0: !fir.ref> {fir.bindc_name = "cond"}) {
+  %7 = arith.constant 42 : index
+  %8 = fir.allocmem !fir.array, %7 {uniq_name = "_QFdfa1Earr.alloc"}
+  %9 = fir.load %arg0 : !fir.ref>
+  %10 = fir.convert %9 : (!fir.logical<4>) -> i1
+  fir.if %10 {
+fir.freemem %8 : !fir.heap>
+  } else {
+  }
+  return
+}
+// CHECK:  func.func @dfa1(%arg0: !fir.ref> {fir.bindc_name = "cond"}) {
+// CHECK-NEXT:   %c42 = arith.constant 42 : index
+// CHECK-NEXT:   %0 = fir.allocmem !fir.array, %c42 {uniq_name = "_QFdfa1Earr.alloc"}
+// CHECK-NEXT:   %1 = fir.load %arg0 : !fir.ref>
+// CHECK-NEXT:   %2 = fir.convert %1 : (!fir.logical<4>) -> i1
+// CHECK-NEXT:   fir.if %2 {
+// CHECK-NEXT: fir.freemem %0 : !fir.heap>
+// CHECK-NEXT:   } else {
+// CHECK-NEXT:   }
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// check the alloca is placed after all operands become available
+func.func @placement1() {
+  // do some stuff with other ssa values
+  %1 = arith.constant 1 : index
+  %2 = arith.constant 2 : index
+  %3 = arith.addi %1, %2 : index
+  // operand is now available
+  %4 = fir.allocmem !fir.array, %3
+  // ...
+  fir.freemem %4 : !fir.heap>
+  return
+}
+// CHECK:  func.func @placement1() {
+// CHECK-NEXT:   %[[ONE:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[TWO:.*]] = arith.constant 2 : index
+// CHECK-NEXT:   %[[ARG:.*]] = arith.addi %[[ONE]], %[[TWO]] : index
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array, %[[ARG]]
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// check that if there are no operands, then the alloca is placed early
+func.func @placement2() {
+  // do some stuff with other ssa values
+  %1 = arith.constant 1 : index
+  %2 = arith.constant 2 : index
+  %3 = arith.addi %1, %2 : index
+  %4 = fir.allocmem !fir.array<42xi32>
+  // ...
+  fir.freemem %4 : !fir.heap>
+  return
+}
+// CHECK:  func.func @placement2() {
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
+// CHECK-NEXT:   %[[ONE:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[TWO:.*]] = arith.constant 2 : index
+// CHECK-NEXT:   %[[SUM:.*]] = arith.addi %[[ONE]], %[[TWO]] : index
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// check that stack allocations which must be placed in loops use stacksave
+func.func @placement3() {
+  %c1 = arith.constant 1 : index
+  %c1_i32 = fir.convert %c1 : (index) -> i32
+  %c2 = arith.constant 2 : index
+  %c10 = arith.constant 10 : index
+  %0:2 = fir.do_loop %arg0 = %c1 to %c10 step %c1 iter_args(%arg1 = %c1_i32) -> (index, i32) {
+%3 = arith.addi %c1, %c2 : index
+// operand is now available
+%4 = fir.allocmem !fir.array, %3
+// ...
+fir.freemem %4 : !fir.heap>
+fir.result %3, %c1_i32 : index, i32
+  }
+  return
+}
+// CHECK:  func.func @placement3() {
+// CHECK-NEXT:   %[[C1:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[C1_I32:.*]] = fir.convert %[[C1]] : (index) -> i32
+// CHECK-NEXT:   %[[C2:.*]] = arith.constant 2 : index
+// CHECK-NEXT:   %[[C10:.*]] = arith.constant 10 : index
+// CHECK-NEXT:   fir.do_loop
+// CHECK-NEXT: %[[SUM:.*]] = arith.addi 

[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2023-01-13 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 488916.
4vtomat marked 8 inline comments as done.
4vtomat added a comment.

[NFC] Refactor the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s
  llvm/test/MC/RISCV/rvv/zvknh.s
  llvm/test/MC/RISCV/rvv/zvkns-invalid.s
  llvm/test/MC/RISCV/rvv/zvkns.s
  llvm/test/MC/RISCV/rvv/zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/zvksed.s
  llvm/test/MC/RISCV/rvv/zvksh.s

Index: llvm/test/MC/RISCV/rvv/zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvkns.s
@@ -0,0 +1,75 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkns  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zv

[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2023-01-13 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 488918.
4vtomat added a comment.

NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s
  llvm/test/MC/RISCV/rvv/zvknh.s
  llvm/test/MC/RISCV/rvv/zvkns-invalid.s
  llvm/test/MC/RISCV/rvv/zvkns.s
  llvm/test/MC/RISCV/rvv/zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/zvksed.s
  llvm/test/MC/RISCV/rvv/zvksh.s

Index: llvm/test/MC/RISCV/rvv/zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvkns.s
@@ -0,0 +1,75 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkns  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| llvm-obj

[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-13 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel accepted this revision.
rymiel added a comment.
This revision is now accepted and ready to land.

(This needs to run the updated dump script from D138446 
)

I'm not sure what the strict //benefit// of squishing the two options together 
is, but I support it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141654

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


[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2023-01-13 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 488924.
4vtomat added a comment.

NFC, refactoring the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s
  llvm/test/MC/RISCV/rvv/zvknh.s
  llvm/test/MC/RISCV/rvv/zvkns-invalid.s
  llvm/test/MC/RISCV/rvv/zvkns.s
  llvm/test/MC/RISCV/rvv/zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/zvksed.s
  llvm/test/MC/RISCV/rvv/zvksh.s

Index: llvm/test/MC/RISCV/rvv/zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvkns.s
@@ -0,0 +1,75 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkns  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \
+#

[PATCH] D141670: [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141670

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
  clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/Annotations.h"
@@ -432,6 +433,21 @@
   PI.getExporters(SM.getFileEntryForID(SM.getMainFileID()), FM).empty());
 }
 
+TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(// Line 1
+#include "export.h"
+  )cpp";
+  Inputs.ExtraFiles["export.h"] = R"cpp(
+#include  // IWYU pragma: export
+  )cpp";
+  Inputs.ExtraFiles["string"] = "";
+  Inputs.ExtraArgs = {"-isystem."};
+  TestAST Processed = build();
+  auto &FM = Processed.fileManager();
+  EXPECT_THAT(PI.getExporters(*tooling::stdlib::Header::named(""), FM),
+  testing::UnorderedElementsAre(FileNamed("export.h")));
+}
+
 TEST_F(PragmaIncludeTest, IWYUExportBlock) {
   Inputs.Code = R"cpp(// Line 1
#include "normal.h"
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/Annotations.h"
@@ -107,6 +108,23 @@
   UnorderedElementsAre(physicalHeader("exporter.h")));
 }
 
+TEST_F(FindHeadersTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "exporter.h"
+  )cpp";
+  Inputs.ExtraFiles["exporter.h"] = guard(R"cpp(
+#include  // IWYU pragma: export
+  )cpp");
+  Inputs.ExtraFiles["string"] = guard("");
+  Inputs.ExtraArgs.push_back("-isystem.");
+  buildAST();
+  tooling::stdlib::Symbol StdString =
+  *tooling::stdlib::Symbol::named("std::", "string");
+  EXPECT_THAT(
+  include_cleaner::findHeaders(StdString, AST->sourceManager(), &PI),
+  UnorderedElementsAre(physicalHeader("exporter.h"), StdString.header()));
+}
+
 TEST_F(FindHeadersTest, SelfContained) {
   Inputs.Code = R"cpp(
 #include "header.h"
Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 
 namespace clang::include_cleaner {
 namespace {
@@ -188,12 +189,18 @@
   SrcMgr::CharacteristicKind FileKind) override {
 FileID HashFID = SM.getFileID(HashLoc);
 int HashLine = SM.getLineNumber(HashFID, SM.getFileOffset(HashLoc));
-checkForExport(HashFID, HashLine, File ? &File->getFileEntry() : nullptr);
+std::optional StandardHeader;
+if (IsAngled)
+  StandardHeader =
+  tooling::stdlib::Header::named("<" + FileName.str() + ">");
+checkForExport(HashFID, HashLine, File ? &File->getFileEntry() : nullptr,
+   StandardHeader);
 checkForKeep(HashLine);
   }
 
   void checkForExport(FileID IncludingFile, int HashLine,
-  const FileEntry *IncludedHeader) {
+  const FileEntry *IncludedHeader,
+  std::optional StandardHeader) {
 if (ExportStack.empty())
   return;
 auto &Top = ExportStack.back();
@@ -205,6 +212,8 @@
   if (IncludedHeader)
 Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
 Top.Path);
+  if (StandardHeader)
+Out->StdIWYUExportBy[*StandardHeader].push_back(Top.Path);
   // main-file #include with export pragma should never be removed.
   if (Top.Se

[PATCH] D141671: Move around structs and definitions to prevent incomplete types.

2023-01-13 Thread Jens Massberg via Phabricator via cfe-commits
massberg created this revision.
massberg added a reviewer: ilya-biryukov.
Herald added a project: All.
massberg requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

C++20 is more strict when erroring out due to incomplete types.
Thus the code required some restructoring so that it complies in C++20.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141671

Files:
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h

Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -31,10 +31,6 @@
 using SymbolID = std::array;
 
 struct BaseRecordInfo;
-struct EnumInfo;
-struct FunctionInfo;
-struct Info;
-struct TypedefInfo;
 
 enum class InfoType {
   IT_default,
@@ -52,44 +48,13 @@
   CommentInfo(CommentInfo &&Other) = default;
   CommentInfo &operator=(CommentInfo &&Other) = default;
 
-  bool operator==(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI != SecondCI || Children.size() != Other.Children.size())
-  return false;
-
-return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
-  llvm::deref>{});
-  }
+  bool operator==(const CommentInfo &Other) const;
 
   // This operator is used to sort a vector of CommentInfos.
   // No specific order (attributes more important than others) is required. Any
   // sort is enough, the order is only needed to call std::unique after sorting
   // the vector.
-  bool operator<(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI < SecondCI)
-  return true;
-
-if (FirstCI == SecondCI) {
-  return std::lexicographical_compare(
-  Children.begin(), Children.end(), Other.Children.begin(),
-  Other.Children.end(), llvm::deref>());
-}
-
-return false;
-  }
+  bool operator<(const CommentInfo &Other) const;
 
   SmallString<16>
   Kind; // Kind of comment (FullComment, ParagraphComment, TextComment,
@@ -162,22 +127,6 @@
   llvm::SmallString<128> Path;
 };
 
-// Holds the children of a record or namespace.
-struct ScopeChildren {
-  // Namespaces and Records are references because they will be properly
-  // documented in their own info, while the entirety of Functions and Enums are
-  // included here because they should not have separate documentation from
-  // their scope.
-  //
-  // Namespaces are not syntactically valid as children of records, but making
-  // this general for all possible container types reduces code complexity.
-  std::vector Namespaces;
-  std::vector Records;
-  std::vector Functions;
-  std::vector Enums;
-  std::vector Typedefs;
-};
-
 // A base struct for TypeInfos
 struct TypeInfo {
   TypeInfo() = default;
@@ -327,16 +276,6 @@
   llvm::Expected getEnclosingScope();
 };
 
-// Info for namespaces.
-struct NamespaceInfo : public Info {
-  NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
-StringRef Path = StringRef())
-  : Info(InfoType::IT_namespace, USR, Name, Path) {}
-
-  void merge(NamespaceInfo &&I);
-
-  ScopeChildren Children;
-};
 
 // Info for symbols.
 struct SymbolInfo : public Info {
@@ -376,13 +315,99 @@
   std::optional Template;
 };
 
+// Information for a single possible value of an enumeration.
+struct EnumValueInfo {
+  explicit EnumValueInfo(StringRef Name = StringRef(),
+ StringRef Value = StringRef("0"),
+ StringRef ValueExpr = StringRef())
+  : Name(Name), Value(Value), ValueExpr(ValueExpr) {}
+
+  bool operator==(const EnumValueInfo &Other) const {
+return std::tie(Name, Value, ValueExpr) ==
+   std::tie(Other.Name, Other.Value, Other.ValueExpr);
+  }
+
+  SmallString<16> Name;
+
+  // The computed value of the enumeration constant. This could be the result of
+  // evaluating the ValueExpr, or it could be automatically generated according
+  // to C rules.
+  SmallString<16> Value;
+
+  // Stores the user-supplied initialization expression for this enumera

[PATCH] D141672: [RISCV] Support vector crypto extension ISA string and assembly

2023-01-13 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, jdoerfert, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, hiraditya, arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

LLVM implements the 0.1 draft specification:
https://github.com/riscv/riscv-crypto/releases/download/v20221220/riscv-crypto-spec-vector.pdf
, and current vector crypto extension version can be found in:
https://github.com/riscv/riscv-crypto.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141672

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s
  llvm/test/MC/RISCV/rvv/zvknh.s
  llvm/test/MC/RISCV/rvv/zvkns-invalid.s
  llvm/test/MC/RISCV/rvv/zvkns.s
  llvm/test/MC/RISCV/rvv/zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/zvksed.s
  llvm/test/MC/RISCV/rvv/zvksh.s

Index: llvm/test/MC/RISCV/rvv/zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/

[PATCH] D141671: Move around structs and definitions to prevent incomplete types.

2023-01-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a reviewer: kadircet.
ilya-biryukov added a subscriber: kadircet.
ilya-biryukov added a comment.

There is potentially a way to move less code by keeping all declarations at 
place and only moving bodies of definitions of constructors and destructors to 
the `.cpp` file.
Not sure what's preferable (less code moves vs more functions inline in the 
header), @kadircet do you have an opinion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

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


[PATCH] D141672: [RISCV] Support vector crypto extension ISA string and assembly

2023-01-13 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

Since there's some accidentally pushed code. The old revision is moved to this 
one, sorry..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141672

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


[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D140547#4050752 , @uabelho wrote:

> Anyone else see this?

I have not checked, but I would not be surprised if we hit the stack size 
limits with asan enabled
@usaxena95, maybe reduce the number of instantiations from `10001` to `1001` or 
`101`? It should not change the intention of the test and fix this failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D141459: [RISCV] Use Zvl*b as a lower bound for VScaleRange.

2023-01-13 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng 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/D141459/new/

https://reviews.llvm.org/D141459

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


[PATCH] D140668: [clang][Interp] Implement remaining bits for MaterializeTemporaryExprs

2023-01-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 488935.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D140668

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/cxx17.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -50,9 +50,6 @@
 static_assert(ints2.b == -30, "");
 static_assert(!ints2.c, "");
 
-#if __cplusplus >= 201703L
-// FIXME: In c++14, this uses a MaterializeTemporaryExpr,
-//   which the new interpreter doesn't support yet.
 constexpr Ints getInts() {
   return {64, 128, true};
 }
@@ -60,7 +57,6 @@
 static_assert(ints3.a == 64, "");
 static_assert(ints3.b == 128, "");
 static_assert(ints3.c, "");
-#endif
 
 constexpr Ints ints4 = {
   .a = 40 * 50,
@@ -88,9 +84,9 @@
   int a = 10;
   int b;
 };
-// FIXME: Broken in the new constant interpreter.
-//   Should be rejected, but without asan errors.
-//constexpr Ints2 ints2;
+constexpr Ints2 ints22; // expected-error {{without a user-provided default constructor}} \
+// expected-error {{must be initialized by a constant expression}} \
+// ref-error {{without a user-provided default constructor}}
 
 class C {
   public:
@@ -124,9 +120,6 @@
 }
 static_assert(getPointer()->a == 100, "");
 
-#if __cplusplus >= 201703L
-// FIXME: In c++14, this uses a MaterializeTemporaryExpr,
-//   which the new interpreter doesn't support yet.
 constexpr C RVOAndParams(const C *c) {
   return C();
 }
@@ -137,7 +130,6 @@
   return C();
 }
 constexpr C RVOAndParamsResult2 = RVOAndParams(12);
-#endif
 
 class Bar { // expected-note {{definition of 'Bar' is not complete}} \
 // ref-note {{definition of 'Bar' is not complete}}
@@ -158,16 +150,16 @@
   c.a = 10;
 
   // Assignment, not an initializer.
-  // c = C(); FIXME
+  c = C();
   c.a = 10;
 
 
   // Assignment, not an initializer.
-  //c = RVOAndParams(&c); FIXME
+  c = RVOAndParams(&c);
 
   return c.a;
 }
-static_assert(locals() == 10, "");
+static_assert(locals() == 100, "");
 
 namespace thisPointer {
   struct S {
@@ -234,10 +226,7 @@
 this->a; // expected-warning {{expression result unused}} \
  // ref-warning {{expression result unused}}
 get5();
-#if __cplusplus >= 201703L
-// FIXME: Enable once we support MaterializeConstantExpr properly.
 getInts();
-#endif
   }
 
   constexpr int m() const {
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -665,3 +665,27 @@
   // ref-note {{in call to 'IntMul}}
 };
 #endif
+
+namespace CompoundLiterals {
+  constexpr int get5() {
+return (int[]){1,2,3,4,5}[4];
+  }
+  static_assert(get5() == 5, "");
+
+  constexpr int get6(int f = (int[]){1,2,6}[2]) { // ref-note {{subexpression not valid in a constant expression}} \
+  // ref-note {{declared here}}
+return f;
+  }
+  static_assert(get6(6) == 6, "");
+  // FIXME: Who's right here?
+  static_assert(get6() == 6, ""); // ref-error {{not an integral constant expression}}
+
+#if __cplusplus >= 202002L
+  constexpr int get3() {
+int m;
+m = (int){3};
+return m;
+  }
+  static_assert(get3() == 3, "");
+#endif
+};
Index: clang/test/AST/Interp/cxx17.cpp
===
--- clang/test/AST/Interp/cxx17.cpp
+++ clang/test/AST/Interp/cxx17.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -std=c++17 -verify=ref %s
 
 // ref-no-diagnostics
+// expected-no-diagnostics
 
 struct F { int a; int b;};
 constexpr F getF() {
@@ -21,8 +22,7 @@
 
   return a + b;
 }
-// FIXME: This should work, but the MaterializeTemporaryExpr handling is not ready for it.
-static_assert(structRefs() == 15); // expected-error {{not an integral constant expression}}
+static_assert(structRefs() == 15);
 
 constexpr int structRefs2() {
   F f = getF();
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -88,6 +88,7 @@
   bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E);
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
+  bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
@@ -362,7 +363,10 @@
   BlockScope(ByteCodeExprGen *Ctx) : LocalScope(Ctx) {}
 
   void addExtended(const Scope::Local &Local) override {
-llvm_unr

[PATCH] D140668: [clang][Interp] Implement remaining bits for MaterializeTemporaryExprs

2023-01-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 488936.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D140668

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/cxx17.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -50,9 +50,6 @@
 static_assert(ints2.b == -30, "");
 static_assert(!ints2.c, "");
 
-#if __cplusplus >= 201703L
-// FIXME: In c++14, this uses a MaterializeTemporaryExpr,
-//   which the new interpreter doesn't support yet.
 constexpr Ints getInts() {
   return {64, 128, true};
 }
@@ -60,7 +57,6 @@
 static_assert(ints3.a == 64, "");
 static_assert(ints3.b == 128, "");
 static_assert(ints3.c, "");
-#endif
 
 constexpr Ints ints4 = {
   .a = 40 * 50,
@@ -88,9 +84,9 @@
   int a = 10;
   int b;
 };
-// FIXME: Broken in the new constant interpreter.
-//   Should be rejected, but without asan errors.
-//constexpr Ints2 ints2;
+constexpr Ints2 ints22; // expected-error {{without a user-provided default constructor}} \
+// expected-error {{must be initialized by a constant expression}} \
+// ref-error {{without a user-provided default constructor}}
 
 class C {
   public:
@@ -124,9 +120,6 @@
 }
 static_assert(getPointer()->a == 100, "");
 
-#if __cplusplus >= 201703L
-// FIXME: In c++14, this uses a MaterializeTemporaryExpr,
-//   which the new interpreter doesn't support yet.
 constexpr C RVOAndParams(const C *c) {
   return C();
 }
@@ -137,7 +130,6 @@
   return C();
 }
 constexpr C RVOAndParamsResult2 = RVOAndParams(12);
-#endif
 
 class Bar { // expected-note {{definition of 'Bar' is not complete}} \
 // ref-note {{definition of 'Bar' is not complete}}
@@ -158,16 +150,16 @@
   c.a = 10;
 
   // Assignment, not an initializer.
-  // c = C(); FIXME
+  c = C();
   c.a = 10;
 
 
   // Assignment, not an initializer.
-  //c = RVOAndParams(&c); FIXME
+  c = RVOAndParams(&c);
 
   return c.a;
 }
-static_assert(locals() == 10, "");
+static_assert(locals() == 100, "");
 
 namespace thisPointer {
   struct S {
@@ -234,10 +226,7 @@
 this->a; // expected-warning {{expression result unused}} \
  // ref-warning {{expression result unused}}
 get5();
-#if __cplusplus >= 201703L
-// FIXME: Enable once we support MaterializeConstantExpr properly.
 getInts();
-#endif
   }
 
   constexpr int m() const {
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -665,3 +665,38 @@
   // ref-note {{in call to 'IntMul}}
 };
 #endif
+
+namespace CompoundLiterals {
+  constexpr int get5() {
+return (int[]){1,2,3,4,5}[4];
+  }
+  static_assert(get5() == 5, "");
+
+  constexpr int get6(int f = (int[]){1,2,6}[2]) { // ref-note {{subexpression not valid in a constant expression}} \
+  // ref-note {{declared here}}
+return f;
+  }
+  static_assert(get6(6) == 6, "");
+  // FIXME: Who's right here?
+  static_assert(get6() == 6, ""); // ref-error {{not an integral constant expression}}
+
+  constexpr int x = (int){3};
+  static_assert(x == 3, "");
+#if __cplusplus >= 201402L
+  constexpr int getX() {
+int x = (int){3};
+x = (int){5};
+return x;
+  }
+  static_assert(getX() == 5, "");
+#endif
+
+#if __cplusplus >= 202002L
+  constexpr int get3() {
+int m;
+m = (int){3};
+return m;
+  }
+  static_assert(get3() == 3, "");
+#endif
+};
Index: clang/test/AST/Interp/cxx17.cpp
===
--- clang/test/AST/Interp/cxx17.cpp
+++ clang/test/AST/Interp/cxx17.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -std=c++17 -verify=ref %s
 
 // ref-no-diagnostics
+// expected-no-diagnostics
 
 struct F { int a; int b;};
 constexpr F getF() {
@@ -21,8 +22,7 @@
 
   return a + b;
 }
-// FIXME: This should work, but the MaterializeTemporaryExpr handling is not ready for it.
-static_assert(structRefs() == 15); // expected-error {{not an integral constant expression}}
+static_assert(structRefs() == 15);
 
 constexpr int structRefs2() {
   F f = getF();
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -88,6 +88,7 @@
   bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E);
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
+  bool VisitCompoundLiteralExpr(const CompoundLit

[PATCH] D135750: [clang][Interp] Track initialization state of local variables

2023-01-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D135750

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


[PATCH] D141670: [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:203
+  const FileEntry *IncludedHeader,
+  std::optional StandardHeader) {
 if (ExportStack.empty())

just saying `StandardHeader` here isn't really useful. what about changing 
signautre here to take a `include_cleaner::Header` instead, named 
`IncludedHeader` and switch over kind to add it to ExportBy map? I don't think 
there's any value in storing Exporters for `` both as a physical entry 
and a stdlib entry.



Comment at: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp:122
+  tooling::stdlib::Symbol StdString =
+  *tooling::stdlib::Symbol::named("std::", "string");
+  EXPECT_THAT(

nit: `tooling::stdlib::Header::named("")`



Comment at: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp:437
+TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(// Line 1
+#include "export.h"

drop the comment `Line 1`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141670

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


[PATCH] D141608: [include-cleaner] Don't consider the underlying type of Decltype MemberProvider as a use

2023-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D141608#4050739 , @kadircet wrote:

> I am a little skeptical about this one. I think it's somewhat an obscure 
> pattern, and probably warrants a use of the type when it can be deduced and 
> the user code is accessing members (relying on the type more than an opaque 
> manner). So what about waiting on this patch until we encounter examples in 
> real world that require such a treatment?

Sure, sounds good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141608

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


[PATCH] D141133: [clang-tidy] Implement CppCoreGuideline F.54

2023-01-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 488943.
ccotter added a comment.

- Finish stengthening CHECK-FIXES


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141133

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp
@@ -0,0 +1,92 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t
+
+struct Obj {
+  void lambdas_that_warn_default_capture_copy() {
+int local{};
+int local2{};
+
+auto explicit_this_capture = [=, this]() { };
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture = [this]() { };
+
+auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; };
+
+auto explicit_this_capture_local_ref = [=, this, &local]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref = [this, &local]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref2 = [=, &local, this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref2 = [&local, this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref3 = [=, &local, this, &local2]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref3 = [&local, this, &local2]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref4 = [=, &local, &local2, this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref4 = [&local, &local2, this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref_extra_whitespace = [=, &  local, &local2, this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:62: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref_extra_whitespace = [&  local, &local2, this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref_with_comment = [=, & /* byref */ local, &local2, this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:58: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref_with_comment = [& /* byref */ local, &local2, this]() { return (local+x) > 10; };
+
+auto implicit_this_capture = [=]() { return x > 10; };
+// CHECK-MESSAGES: :[[@LIN

[PATCH] D141133: [clang-tidy] Implement CppCoreGuideline F.54

2023-01-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked 2 inline comments as done.
ccotter added a comment.

Thanks for pointing that out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141133

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


[PATCH] D141133: [clang-tidy] Implement CppCoreGuideline F.54

2023-01-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

My latest update to the diff was the result of a rebase, then addressing the 
final comments. What I've been doing is something like

  git pull upstream main --rebase
  # make more edits
  git commit -am 
  arc diff --update D141133 upstream/main

I'm not sure if this is the best way to rebase phabs, but please let me know if 
there's a better way for phab to understand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141133

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


[PATCH] D141671: Move around structs and definitions to prevent incomplete types.

2023-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D141671#4050928 , @ilya-biryukov 
wrote:

> There is potentially a way to move less code by keeping all declarations at 
> place and only moving bodies of definitions of constructors and destructors 
> to the `.cpp` file.
> Not sure what's preferable (less code moves vs more functions inline in the 
> header), @kadircet do you have an opinion?

Having as few code in headers as possible is the general style guide in LLVM, 
so I'd rather err towards that and put definitions out-of-line as much as 
possible. Therefore if we can getaway by just moving definitions out-of-line, 
while keeping rest of the header ordering the same, let's go with that if it's 
feasible


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

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


[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-01-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 15 inline comments as done.
pmatos added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:4129
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+}

erichkeane wrote:
> Note that it seems this is likely not going to work correctly on template 
> type aliases!  You probably want to make sure that is acceptable to you.
Documentation says about Subject:

```
  // The things to which an attribute can appertain
  SubjectList Subjects;
```

Given this can be attached to function pointer types, is the subject then just 
Type ?



Comment at: clang/include/clang/Basic/AttrDocs.td:6855
+Clang supports the ``__funcref`` attribute for the WebAssembly target. 
+This attribute may be attached to a function pointer declaration, where it 
modifies 
+its underlying representation to be a WebAssembly ``funcref``.

erichkeane wrote:
> This says 'function pointer declaration', but you have it's subject as 
> Typedef?
That's a mistake due to how things worked in an earlier revision. Thanks for 
spotting. 



Comment at: clang/include/clang/Basic/TokenKinds.def:666
+// WebAssembly Type Extension
+KEYWORD(__funcref , KEYALL)
+

erichkeane wrote:
> aaron.ballman wrote:
> > pmatos wrote:
> > > aaron.ballman wrote:
> > > > Why is this a keyword in all language modes?
> > > I might have misread the docs but this keyword should be available for 
> > > both C and C++. Maybe I want `KEYC99 | KEYCXX` ?
> > I was thinking this keyword would only work for a web assembly target, so 
> > we'd likely want to add `KEYWEBASM` or something to the list like we have 
> > for `KEYALTIVEC`. But now I'm second-guessing that instinct and am 
> > wondering what behavior we want here.
> > 
> > 1) Parse the keyword in all language modes and for all targets, give an 
> > ignored attribute warning if the target isn't web assembly
> > 2) Parse the keyword in all language modes and for all targets, give a 
> > parse time diagnostic (error?) if the target isn't web assembly
> > 3) Only expose the keyword if the target is web assembly, otherwise it 
> > parses as an identifier and you get the usual parse errors
> > 
> > My original thinking was that we wanted #3, but on reflection both #1 and 
> > #2 seem reasonable to me. Do you have a preference? I think I prefer either 
> > 2 or 3 over 1 because this involves the type system (errors are usually a 
> > better approach in that case).
> I don't think #1 is acceptable for the keyword, we shouldn't ignore keywords 
> like we do attributes.  Doing an ignored warning in SemaDeclAttr.td for the 
> ATTRIBUTE is fine, but keyword form needs to be an error.
> 
> My preference is #2, an error if we encounter it during parsing and we're not 
> in WebAsm target.
Thanks for the comments, I have now updated this with an implementation of 
option 2 and added a diagnostic test.



Comment at: clang/lib/Basic/Targets/DirectX.h:45
 3, // hlsl_groupshared
+// Wasm address space values for this map are dummy
+20, // wasm_funcref

erichkeane wrote:
> Also apply to the rest of the targets.  Also, why is there only 1 added here? 
>  I thought we had 2 address spaces for Wasm?
Externref is a type in clang, doesn't need its own address space in clang, only 
when it's lowered to a opaque type in llvm it gets its own address space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D141307: [WIP] Add -f[no-]loop-versioning option

2023-01-13 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus updated this revision to Diff 488949.
Leporacanthicus added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/tools/bbc/bbc.cpp
  flang/tools/tco/tco.cpp

Index: flang/tools/tco/tco.cpp
===
--- flang/tools/tco/tco.cpp
+++ flang/tools/tco/tco.cpp
@@ -122,7 +122,7 @@
   fir::createDefaultFIRCodeGenPassPipeline(pm);
 } else {
   // Run tco with O2 by default.
-  fir::createMLIRToLLVMPassPipeline(pm, llvm::OptimizationLevel::O2);
+  fir::createMLIRToLLVMPassPipeline(pm, false, llvm::OptimizationLevel::O2);
 }
 fir::addLLVMDialectToLLVMPass(pm, out.os());
   }
Index: flang/tools/bbc/bbc.cpp
===
--- flang/tools/bbc/bbc.cpp
+++ flang/tools/bbc/bbc.cpp
@@ -273,7 +273,8 @@
 pm.addPass(std::make_unique());
 
 // Add O2 optimizer pass pipeline.
-fir::createDefaultFIROptimizerPassPipeline(pm, llvm::OptimizationLevel::O2);
+fir::createDefaultFIROptimizerPassPipeline(pm, false,
+   llvm::OptimizationLevel::O2);
   }
 
   if (mlir::succeeded(pm.run(mlirModule))) {
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -542,7 +542,7 @@
   pm.enableVerifier(/*verifyPasses=*/true);
 
   // Create the pass pipeline
-  fir::createMLIRToLLVMPassPipeline(pm, level);
+  fir::createMLIRToLLVMPassPipeline(pm, opts.LoopVersioning, level);
   mlir::applyPassManagerCLOptions(pm);
 
   // run the pass manager
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -126,6 +126,11 @@
clang::driver::options::OPT_fno_debug_pass_manager, false))
 opts.DebugPassManager = 1;
 
+  if (args.hasFlag(clang::driver::options::OPT_floop_versioning,
+   clang::driver::options::OPT_fno_loop_versioning, false)) {
+opts.LoopVersioning = 1;
+  }
+
   for (auto *a : args.filtered(clang::driver::options::OPT_fpass_plugin_EQ))
 opts.LLVMPassPlugins.push_back(a->getValue());
 
Index: flang/include/flang/Frontend/CodeGenOptions.def
===
--- flang/include/flang/Frontend/CodeGenOptions.def
+++ flang/include/flang/Frontend/CodeGenOptions.def
@@ -24,6 +24,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 
+CODEGENOPT(LoopVersioning, 1, 0) ///< PIC level of the LLVM module.
 CODEGENOPT(PICLevel, 2, 0) ///< PIC level of the LLVM module.
 CODEGENOPT(IsPIE, 1, 0) ///< PIE level is the same as PIC Level.
 
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -57,6 +57,12 @@
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});
+  Arg *loopVersioning =
+  Args.getLastArg(options::OPT_Ofast, options::OPT_floop_versioning,
+  options::OPT_fno_loop_versioning);
+  if (loopVersioning &&
+  !loopVersioning->getOption().matches(options::OPT_fno_loop_versioning))
+CmdArgs.push_back("-floop-versioning");
 }
 
 void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5054,6 +5054,11 @@
 def fno_automatic : Flag<["-"], "fno-automatic">, Group,
   HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">;
 
+def floop_versioning : Flag<["-"], "floop-versioning">, Group,
+  HelpText<"Attempt to version loops">;
+def fno_loop_versioning : Flag<["-"], "fno-loop-versioning">, Group,
+  HelpText<"Do not version loops (default)">;
+
 } // let Flags = [FC1Option, FlangOption, FlangOnlyOption]
 
 def J : JoinedOrSeparate<["-"], "J">,
___
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-01-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

> What happens with code like this
>
>   void foo(bar&& B) {
> std::move(B);
>   }

My new check does not flag this function, although it looks like another check 
flagged the move expression: `ignoring return value of function declared with 
const attribute [clang-diagnostic-unused-value]`. Guideline F.18 only says to 
flag functions where "the function body uses them without std::move." I think 
this could be improved with something like "the function body does not move 
construct or move assign the parameter, and does not pass the result of move() 
to another function which accepts rvalue references". I can open an issue on 
the CppCoreGuidelines repo to discuss this. On a related note, I believe 
there's another clang-tidy check that flags `move` on const values, so I could 
see clang-tidy similarly checking other "nonsense" move expressions such as 
this one (separate check).


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


Re: [PATCH] D92733: Fix PR25627 - false positive diagnostics involving implicit-captures in dependent lambda expressions.

2023-01-13 Thread Faisal Vali via cfe-commits
I'll try and look into it this weekend and have some sort of updated news
for you by monday?
Faisal Vali



On Thu, Jan 12, 2023 at 10:40 PM Shafik Yaghmour via Phabricator <
revi...@reviews.llvm.org> wrote:

> shafik added a comment.
>
> Is this PR still workable or does it need a major rework and should be
> abandoned?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D92733/new/
>
> https://reviews.llvm.org/D92733
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2023-01-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1293
   Actions.PushLambdaScope();
+  Actions.ActOnLambdaIntroducer(Intro, getCurScope());
 

aaron.ballman wrote:
> Typically, we call an `ActOn` method after having parsed the construct; in 
> this case, we're calling `ActOnLambdaIntroducer()` when it was parsed 
> elsewhere (this is the parsing code for after the introducer). So perhaps 
> this should be moved elsewhere or renamed?
ActOnLambdaExpressionAfterIntroducer?
We are actually acting on the lambda introducer, but it needs to be done in 
these scopes so it's why its there.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1381
+  SourceLocation MutableLoc;
+  LateParsedAttrList LateParsedAttrs(true);
+

aaron.ballman wrote:
> This isn't being used?
It used to be! Thanks for catching that



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1387-1393
+// However, because GNU attributes could refer to captured variables,
+// which only become visible after the mutable keyword is parsed
+// we delay the parsing of gnu attributes - by reusing the mechanism used
+// for C++ late method parsing. Note, __declspec attributes do not make
+// use of late parsing (expressions cannot appear in __declspec arguments),
+// so only GNU style attributes are affected here.
+MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attributes);

aaron.ballman wrote:
> The comment doesn't seem to match the code -- this isn't parsing into the 
> late parsed attribute list?
More dead code!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

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


[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D139705#4050216 , @v1nh1shungry 
wrote:

> If this patch is okay to land, could you please help me commit it? Thanks a 
> lot!

I'm happy to, what name and email address would you like used for patch 
attribution? Alternatively, it seems that you've had a few patches accepted in 
the project, so you could apply for commit access yourself if you'd like: 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[PATCH] D141620: clang/OpenCL: Make enqueued blocks inherit the parent attributes

2023-01-13 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:12488
+  // FIXME: The invoke isn't applying the right attributes either
+  llvm::AttrBuilder KernelAttrs(C, CGF.CurFn->getAttributes().getFnAttrs());
+  KernelAttrs.addAttribute("enqueued-block");

yaxunl wrote:
> arsenm wrote:
> > yaxunl wrote:
> > > The kernel should inherit attributes from the parent function since the 
> > > parent may have function attributes explicitly specified for itself only. 
> > > The kernel should take the default function attributes.
> > I was specifically try to get those, e.g. the attribute(target) example. Is 
> > there some way to specify attributes directly on a block?
> > I was specifically try to get those, e.g. the attribute(target) example. Is 
> > there some way to specify attributes directly on a block?
> 
> I don't think so https://godbolt.org/z/Pahv46dh6
It doesn't allow noinline or target, but does allow const so it seems to be 
specific attributes. I guess that means it should just use the defaults


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

https://reviews.llvm.org/D141620

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


[PATCH] D141133: [clang-tidy] Implement CppCoreGuideline F.54

2023-01-13 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

In D141133#4051068 , @ccotter wrote:

> My latest update to the diff was the result of a rebase, then addressing the 
> final comments. What I've been doing is something like
>
>   git pull upstream main --rebase
>   # make more edits
>   git commit -am 
>   arc diff --update D141133 upstream/main
>
> I'm not sure if this is the best way to rebase phabs, but please let me know 
> if there's a better way for phab to understand.

I just run `arc diff HEAD~` after rebase, and works just fine :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141133

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


[PATCH] D135658: demangle OptFunction trace names

2023-01-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r updated this revision to Diff 488959.
Trass3r added a comment.

I can only refer to my last comment, even in latest trunk that code is still 
active for the codegen passes.
But meanwhile I found the corresponding new code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135658

Files:
  clang/test/Driver/check-time-trace-sections.py
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/Passes/CMakeLists.txt
  llvm/lib/Passes/StandardInstrumentations.cpp

Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Analysis/CallGraphSCCPass.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/LegacyPassManager.h"
@@ -187,11 +188,11 @@
 }
 
 std::string getIRName(Any IR) {
-  if (any_cast(&IR))
-return "[module]";
+  if (const auto **M = any_cast(&IR))
+return (*M)->getModuleIdentifier();
 
   if (const auto **F = any_cast(&IR))
-return (*F)->getName().str();
+return demangle((*F)->getName().str());
 
   if (const auto **C = any_cast(&IR))
 return (*C)->getName();
Index: llvm/lib/Passes/CMakeLists.txt
===
--- llvm/lib/Passes/CMakeLists.txt
+++ llvm/lib/Passes/CMakeLists.txt
@@ -19,6 +19,7 @@
   CodeGen
   Core
   Coroutines
+  Demangle
   IPO
   InstCombine
   IRPrinter
Index: llvm/lib/IR/LegacyPassManager.cpp
===
--- llvm/lib/IR/LegacyPassManager.cpp
+++ llvm/lib/IR/LegacyPassManager.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/Demangle/Demangle.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
@@ -1408,7 +1409,8 @@
 FunctionSize = F.getInstructionCount();
   }
 
-  llvm::TimeTraceScope FunctionScope("OptFunction", F.getName());
+  llvm::TimeTraceScope FunctionScope(
+  "OptFunction", [&F]() { return demangle(F.getName().str()); });
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
 FunctionPass *FP = getContainedPass(Index);
Index: llvm/lib/IR/CMakeLists.txt
===
--- llvm/lib/IR/CMakeLists.txt
+++ llvm/lib/IR/CMakeLists.txt
@@ -77,6 +77,7 @@
 
   LINK_COMPONENTS
   BinaryFormat
+  Demangle
   Remarks
   Support
   TargetParser
Index: clang/test/Driver/check-time-trace-sections.py
===
--- clang/test/Driver/check-time-trace-sections.py
+++ clang/test/Driver/check-time-trace-sections.py
@@ -13,9 +13,12 @@
 
 log_contents = json.loads(sys.stdin.read())
 events = log_contents["traceEvents"]
-codegens = [event for event in events if event["name"] == "CodeGen Function"]
+
+instants  = [event for event in events if event["name"] == "InstantiateFunction"]
+codegens  = [event for event in events if event["name"] == "CodeGen Function"]
+opts  = [event for event in events if event["name"] == "OptFunction"]
 frontends = [event for event in events if event["name"] == "Frontend"]
-backends = [event for event in events if event["name"] == "Backend"]
+backends  = [event for event in events if event["name"] == "Backend"]
 
 beginning_of_time = log_contents["beginningOfTime"] / 100
 seconds_since_epoch = time.time()
@@ -32,3 +35,11 @@
 if not all([all([is_before(frontend, backend) for frontend in frontends])
 for backend in backends]):
 sys.exit("Not all Frontend section are before all Backend sections!")
+
+# Check that entries for foo exist and are in a demangled form.
+if not any(e for e in instants if "foo" in e["args"]["detail"]):
+sys.exit("Missing Instantiate entry for foo!")
+if not any(e for e in codegens if "foo" in e["args"]["detail"]):
+sys.exit("Missing CodeGen entry for foo!")
+if not any(e for e in opts if "foo" in e["args"]["detail"]):
+sys.exit("Missing Optimize entry for foo!")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141671: Move around structs and definitions to prevent incomplete types.

2023-01-13 Thread Jens Massberg via Phabricator via cfe-commits
massberg added a comment.



> Having as few code in headers as possible is the general style guide in LLVM, 
> so I'd rather err towards that and put definitions out-of-line as much as 
> possible. Therefore if we can getaway by just moving definitions out-of-line, 
> while keeping rest of the header ordering the same, let's go with that if 
> it's feasible

Thanks! I will check if I can get a version without reordering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

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


[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

2023-01-13 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

> I'm happy to, what name and email address would you like used for patch 
> attribution?

I'd like "v1nh1shungry" and "v1nh1shun...@outlook.com". Thank you!

> Alternatively, it seems that you've had a few patches accepted in the 
> project, so you could apply for commit access yourself if you'd like: 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

Cool! I'll give it a try. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[PATCH] D139705: [clang] fix zero-initialization fix-it for variable template

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D139705#4051178 , @v1nh1shungry 
wrote:

>> I'm happy to, what name and email address would you like used for patch 
>> attribution?
>
> I'd like "v1nh1shungry" and "v1nh1shun...@outlook.com". Thank you!
>
>> Alternatively, it seems that you've had a few patches accepted in the 
>> project, so you could apply for commit access yourself if you'd like: 
>> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access
>
> Cool! I'll give it a try. Thanks!

Great! I'll hold off on landing this, but let me know if you run into any 
troubles.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139705

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


[clang] eaa1f46 - [clang][NFC] Remove dependency on DataLayout::getPrefTypeAlignment

2023-01-13 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2023-01-13T13:19:19Z
New Revision: eaa1f46f11f523104be54de058e812c9d7059819

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

LOG: [clang][NFC] Remove dependency on DataLayout::getPrefTypeAlignment

Added: 


Modified: 
clang/include/clang/AST/CharUnits.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/include/clang/AST/CharUnits.h 
b/clang/include/clang/AST/CharUnits.h
index cd3dab00c69f8..ee0d402fc74af 100644
--- a/clang/include/clang/AST/CharUnits.h
+++ b/clang/include/clang/AST/CharUnits.h
@@ -64,6 +64,12 @@ namespace clang {
 return CharUnits(Quantity);
   }
 
+  /// fromAlign - Construct a CharUnits quantity from an llvm::Align
+  /// quantity.
+  static CharUnits fromAlign(llvm::Align Quantity) {
+return CharUnits(Quantity.value());
+  }
+
   // Compound assignment.
   CharUnits& operator+= (const CharUnits &Other) {
 Quantity += Other.Quantity;

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 41084956e1979..b8de9fb7224e0 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1148,8 +1148,8 @@ static Address 
CreateTempAllocaForCoercion(CodeGenFunction &CGF, llvm::Type *Ty,
CharUnits MinAlign,
const Twine &Name = "tmp") {
   // Don't use an alignment that's worse than what LLVM would prefer.
-  auto PrefAlign = CGF.CGM.getDataLayout().getPrefTypeAlignment(Ty);
-  CharUnits Align = std::max(MinAlign, CharUnits::fromQuantity(PrefAlign));
+  auto PrefAlign = CGF.CGM.getDataLayout().getPrefTypeAlign(Ty);
+  CharUnits Align = std::max(MinAlign, CharUnits::fromAlign(PrefAlign));
 
   return CGF.CreateTempAlloca(Ty, Align, Name + ".coerce");
 }
@@ -5161,15 +5161,14 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 
 llvm::Type *scalarType = RV.getScalarVal()->getType();
 auto scalarSize = CGM.getDataLayout().getTypeAllocSize(scalarType);
-auto scalarAlign = 
CGM.getDataLayout().getPrefTypeAlignment(scalarType);
+auto scalarAlign = CGM.getDataLayout().getPrefTypeAlign(scalarType);
 
 // Materialize to a temporary.
-addr =
-CreateTempAlloca(RV.getScalarVal()->getType(),
- CharUnits::fromQuantity(std::max(
- layout->getAlignment().value(), scalarAlign)),
- "tmp",
- /*ArraySize=*/nullptr, &AllocaAddr);
+addr = CreateTempAlloca(
+RV.getScalarVal()->getType(),
+CharUnits::fromAlign(std::max(layout->getAlignment(), 
scalarAlign)),
+"tmp",
+/*ArraySize=*/nullptr, &AllocaAddr);
 tempSize = EmitLifetimeStart(scalarSize, AllocaAddr.getPointer());
 
 Builder.CreateStore(RV.getScalarVal(), addr);

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 34974c63984e6..ad7871d7cc7f5 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -123,7 +123,7 @@ llvm::AllocaInst 
*CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
 Address CodeGenFunction::CreateDefaultAlignTempAlloca(llvm::Type *Ty,
   const Twine &Name) {
   CharUnits Align =
-  CharUnits::fromQuantity(CGM.getDataLayout().getPrefTypeAlignment(Ty));
+  CharUnits::fromAlign(CGM.getDataLayout().getPrefTypeAlign(Ty));
   return CreateTempAlloca(Ty, Align, Name);
 }
 

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index f1d7cc7108a8e..66f60585052a3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4850,10 +4850,10 @@ DominatingLLVMValue::save(CodeGenFunction &CGF, 
llvm::Value *value) {
   if (!needsSaving(value)) return saved_type(value, false);
 
   // Otherwise, we need an alloca.
-  auto align = CharUnits::fromQuantity(
-CGF.CGM.getDataLayout().getPrefTypeAlignment(value->getType()));
+  auto align = CharUnits::fromAlign(
+  CGF.CGM.getDataLayout().getPrefTypeAlign(value->getType()));
   Address alloca =
-CGF.CreateTempAlloca(value->getType(), align, "cond-cleanup.save");
+  CGF.CreateTempAlloca(value->getType(), align, "cond-cleanup.save");
   CGF.Builder.CreateStore(value, alloca);
 
   return saved_type(alloca.getPointer(), true);



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


[clang] 84e3fdc - Fix -Wlogical-op-parentheses warning inconsistency for const and constexpr values

2023-01-13 Thread Aaron Ballman via cfe-commits

Author: Takuya Shimizu
Date: 2023-01-13T08:21:41-05:00
New Revision: 84e3fdc019412adc09b18a49063e006bd6e7efaa

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

LOG: Fix -Wlogical-op-parentheses warning inconsistency for const and constexpr 
values

When using the && operator within a || operator, both Clang and GCC
produce a warning for potentially confusing operator precedence.
However, Clang avoids this warning for certain patterns, such as
a && b || 0 or a || b && 1, where the operator precedence of && and ||
does not change the result.

However, this behavior appears inconsistent when using the const or
constexpr qualifiers. For example:

bool t = true;
bool tt = true || false && t; // Warning: '&&' within '||'
const bool t = true;
bool tt = true || false && t; // No warning
const bool t = false;
bool tt = true || false && t; // Warning: '&&' within '||'

The second example does not produce a warning because
true || false && t matches the a || b && 1 pattern, while the third one
does not match any of them.

This behavior can lead to the lack of warnings for complicated
constexpr expressions. Clang should only suppress this warning when
literal values are placed in the place of t in the examples above.

This patch adds the literal-or-not check to fix the inconsistent
warnings for && within || when using const or constexpr.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/logical-op-parentheses.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c5626ac8fe272..632862aaa0237 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -450,6 +450,8 @@ Improvements to Clang's diagnostics
 - Clang now diagnoses overflow undefined behavior in a constant expression 
while
   evaluating a compound assignment with remainder as operand.
 - Add ``-Wreturn-local-addr``, a GCC alias for ``-Wreturn-stack-address``.
+- Clang now suppresses ``-Wlogical-op-parentheses`` on ``(x && a || b)`` and 
``(a || b && x)``
+  only when ``x`` is a string literal.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2e51ec7ad7e80..93eaed1a92b1b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15434,38 +15434,21 @@ EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, 
SourceLocation OpLoc,
 Bop->getSourceRange());
 }
 
-/// Returns true if the given expression can be evaluated as a constant
-/// 'true'.
-static bool EvaluatesAsTrue(Sema &S, Expr *E) {
-  bool Res;
-  return !E->isValueDependent() &&
- E->EvaluateAsBooleanCondition(Res, S.getASTContext()) && Res;
-}
-
-/// Returns true if the given expression can be evaluated as a constant
-/// 'false'.
-static bool EvaluatesAsFalse(Sema &S, Expr *E) {
-  bool Res;
-  return !E->isValueDependent() &&
- E->EvaluateAsBooleanCondition(Res, S.getASTContext()) && !Res;
-}
-
 /// Look for '&&' in the left hand of a '||' expr.
 static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc,
  Expr *LHSExpr, Expr *RHSExpr) {
   if (BinaryOperator *Bop = dyn_cast(LHSExpr)) {
 if (Bop->getOpcode() == BO_LAnd) {
-  // If it's "a && b || 0" don't warn since the precedence doesn't matter.
-  if (EvaluatesAsFalse(S, RHSExpr))
-return;
-  // If it's "1 && a || b" don't warn since the precedence doesn't matter.
-  if (!EvaluatesAsTrue(S, Bop->getLHS()))
+  // If it's "string_literal && a || b" don't warn since the precedence
+  // doesn't matter.
+  if (!isa(Bop->getLHS()->IgnoreParenImpCasts()))
 return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, Bop);
 } else if (Bop->getOpcode() == BO_LOr) {
   if (BinaryOperator *RBop = dyn_cast(Bop->getRHS())) {
-// If it's "a || b && 1 || c" we didn't warn earlier for
-// "a || b && 1", but warn now.
-if (RBop->getOpcode() == BO_LAnd && EvaluatesAsTrue(S, RBop->getRHS()))
+// If it's "a || b && string_literal || c" we didn't warn earlier for
+// "a || b && string_literal", but warn now.
+if (RBop->getOpcode() == BO_LAnd &&
+isa(RBop->getRHS()->IgnoreParenImpCasts()))
   return EmitDiagnosticForLogicalAndInLogicalOr(S, OpLoc, RBop);
   }
 }
@@ -15477,11 +15460,9 @@ static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, 
SourceLocation OpLoc,
  Expr *LHSExpr, Expr *RHSExpr) {
   if (BinaryOperator *Bop = dyn_cast(RHSExpr)) {
 if (Bop->getOpcode() == BO_LAnd) {
-  // If it's "0 || a && b" don't warn since the

[PATCH] D140860: [Diagnostics][NFC] Fix -Wlogical-op-parentheses warning inconsistency for const and constexpr values

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D140860#4050402 , @hazohelet wrote:

> I added the release note.
>
>> Also, do you need someone to commit on your behalf? If so, what name and 
>> email address would you like used for patch attribution?
>
> I don't have commit access. Would you please land this patch for me? Please 
> use "Takuya Shimizu " for the patch attribution.
> Thank you.

Thanks! I've landed on your behalf in 84e3fdc019412adc09b18a49063e006bd6e7efaa 
. (Closing 
manually as I forgot to add the Differential Revision tag to the commit 
message.)


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

https://reviews.llvm.org/D140860

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


[PATCH] D141681: [clang][Interp] Fix parameter map when re-visiting function

2023-01-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  'Params' is a member of the ByteCodeEmitter. We only added the
  parameters the first time  we saw the function, so subsequent visits
  didn't work if they had (and used) parameters.
  
  Just do the work everytime we see a function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141681

Files:
  clang/lib/AST/Interp/ByteCodeEmitter.cpp
  clang/test/AST/Interp/functions.cpp

Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -163,3 +163,8 @@
 return true;
   }
 };
+
+constexpr int nyd(int m);
+constexpr int doit() { return nyd(10); }
+constexpr int nyd(int m) { return m; }
+static_assert(doit() == 10);
Index: clang/lib/AST/Interp/ByteCodeEmitter.cpp
===
--- clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -21,51 +21,50 @@
 
 Expected
 ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
-  // Create a handle over the emitted code.
-  Function *Func = P.getFunction(FuncDecl);
-  if (!Func) {
-// Set up argument indices.
-unsigned ParamOffset = 0;
-SmallVector ParamTypes;
-llvm::DenseMap ParamDescriptors;
-
-// If the return is not a primitive, a pointer to the storage where the
-// value is initialized in is passed as the first argument. See 'RVO'
-// elsewhere in the code.
-QualType Ty = FuncDecl->getReturnType();
-bool HasRVO = false;
-if (!Ty->isVoidType() && !Ctx.classify(Ty)) {
-  HasRVO = true;
-  ParamTypes.push_back(PT_Ptr);
-  ParamOffset += align(primSize(PT_Ptr));
-}
+  // Set up argument indices.
+  unsigned ParamOffset = 0;
+  SmallVector ParamTypes;
+  llvm::DenseMap ParamDescriptors;
+
+  // If the return is not a primitive, a pointer to the storage where the
+  // value is initialized in is passed as the first argument. See 'RVO'
+  // elsewhere in the code.
+  QualType Ty = FuncDecl->getReturnType();
+  bool HasRVO = false;
+  if (!Ty->isVoidType() && !Ctx.classify(Ty)) {
+HasRVO = true;
+ParamTypes.push_back(PT_Ptr);
+ParamOffset += align(primSize(PT_Ptr));
+  }
 
-// If the function decl is a member decl, the next parameter is
-// the 'this' pointer. This parameter is pop()ed from the
-// InterpStack when calling the function.
-bool HasThisPointer = false;
-if (const auto *MD = dyn_cast(FuncDecl);
-MD && MD->isInstance()) {
-  HasThisPointer = true;
-  ParamTypes.push_back(PT_Ptr);
-  ParamOffset += align(primSize(PT_Ptr));
-}
+  // If the function decl is a member decl, the next parameter is
+  // the 'this' pointer. This parameter is pop()ed from the
+  // InterpStack when calling the function.
+  bool HasThisPointer = false;
+  if (const auto *MD = dyn_cast(FuncDecl);
+  MD && MD->isInstance()) {
+HasThisPointer = true;
+ParamTypes.push_back(PT_Ptr);
+ParamOffset += align(primSize(PT_Ptr));
+  }
 
-// Assign descriptors to all parameters.
-// Composite objects are lowered to pointers.
-for (const ParmVarDecl *PD : FuncDecl->parameters()) {
-  PrimType Ty = Ctx.classify(PD->getType()).value_or(PT_Ptr);
-  Descriptor *Desc = P.createDescriptor(PD, Ty);
-  ParamDescriptors.insert({ParamOffset, {Ty, Desc}});
-  Params.insert({PD, ParamOffset});
-  ParamOffset += align(primSize(Ty));
-  ParamTypes.push_back(Ty);
-}
+  // Assign descriptors to all parameters.
+  // Composite objects are lowered to pointers.
+  for (const ParmVarDecl *PD : FuncDecl->parameters()) {
+PrimType Ty = Ctx.classify(PD->getType()).value_or(PT_Ptr);
+Descriptor *Desc = P.createDescriptor(PD, Ty);
+ParamDescriptors.insert({ParamOffset, {Ty, Desc}});
+Params.insert({PD, ParamOffset});
+ParamOffset += align(primSize(Ty));
+ParamTypes.push_back(Ty);
+  }
 
+  // Create a handle over the emitted code.
+  Function *Func = P.getFunction(FuncDecl);
+  if (!Func)
 Func =
 P.createFunction(FuncDecl, ParamOffset, std::move(ParamTypes),
  std::move(ParamDescriptors), HasThisPointer, HasRVO);
-  }
 
   assert(Func);
   // For not-yet-defined functions, we only create a Function instance and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141310: [clang] add -Wcompare-function-pointers

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:451
+- Add ``-Wcompare-function-pointers`` to warn about comparisons that may have
+  their behavior change when using ``icf=all``.
 

aaron.ballman wrote:
> This makes it more clear this is an lld-specific change.
Changing this suggestion to: "that may have their behavior change when enabling 
the identical code folding optimization feature of some linkers."



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:565
+def CompareFunctionPointers : DiagGroup<"compare-function-pointers">;
 def OrderedCompareFunctionPointers : 
DiagGroup<"ordered-compare-function-pointers">;
 def PackedNonPod : DiagGroup<"packed-non-pod">;

Should `-Wcompare-function-pointers` enable 
`-Wordered-compare-function-pointers`? I think I would normally assume such a 
relationship as the ordered variant sounds like a subset of the unordered 
variant.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7006
+def warn_typecheck_comparison_of_function_pointers : Warning<
+  "comparison of function pointers (%0 and %1)">,
+  InGroup, DefaultIgnore;

adriandole wrote:
> aaron.ballman wrote:
> > adriandole wrote:
> > > aaron.ballman wrote:
> > > > cjdb wrote:
> > > > > This diagnostic feels very bare bones, and doesn't explain why the 
> > > > > user should care. It would be good to rephrase the message so that it 
> > > > > can incorporate some kind of reason too.
> > > > Agreed -- diagnostic wording is usually trying to tell the user what 
> > > > they did wrong to guide them how to fix it, but this reads more like 
> > > > the diagnostic explains what the code does. This one will be especially 
> > > > interesting because people would naturally expect that comparison to 
> > > > work per the standard. And if enabling ICF breaks that then ICF is 
> > > > non-conforming because it makes valid code silently invalid. I think 
> > > > this is an ICF bug (it may still be worth warning users about though 
> > > > because you can use newer Clang with an older lld and hit the issue 
> > > > even if lld addresses this issue).
> > > > 
> > > > CC @lhames @sbc100 @ruiu in to try to scare up an lld code owner to see 
> > > > if this is known and if there's something that can be done on the lld 
> > > > side to not break valid code.
> > > There's already an ICF option that doesn't break valid code: `-icf=safe`. 
> > > Only if you explicitly decide that you don't care about the results of 
> > > function pointer comparisons would you use `-icf=all`, which enables more 
> > > code folding to be done than the safe option.
> > Ohhh interesting, so it's probably known that `-icf=all` will break code 
> > because it's not conforming and thus isn't an lld bug at all. Do (most?) 
> > other linkers also have the same functionality as `-icf=all`? I'm trying to 
> > understand whether this should be added to clang at all as it seems like 
> > it's a warning for a very particular usage pattern (a specific linker with 
> > a specific option ), which make it more reasonable for clang-tidy instead 
> > of the compiler.
> ld.gold and mold have it (same name, `-icf=all`) as does MSVC (`/OPT:ICF`).
Thanks for the details, that makes this seem more reasonable in Clang itself 
IMO.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7007
+  "comparison of function pointers (%0 and %1)">,
+  InGroup, DefaultIgnore;
 def warn_typecheck_ordered_comparison_of_function_pointers : Warning<

aaron.ballman wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > cjdb wrote:
> > > > cjdb wrote:
> > > > > It's very rare that we set a warning to `DefaultIgnore`. What's the 
> > > > > motivation for this?
> > > > > This warning is disabled by default, since it's only relevant if ICF 
> > > > > is explicitly enabled.
> > > > 
> > > > I see why now. Perhaps this warning should be enabled by default when 
> > > > ICF is also enabled, and an error otherwise.
> > > The problem is: ICF is an lld thing, it's not a Clang thing; so Clang has 
> > > no idea if ICF will or won't be enabled.
> > Okay, that sounds like we can't make it an error to turn this warning on 
> > when ICF isn't enabled, but what about turning it on when the driver sees 
> > `-icf=all`? Or does that bypass `clang_cc1` altogether?
> The diagnostic serves no purpose unless the user is linking with `-icf=all`, 
> so agreed we can't enable this by default. We might be able to do something 
> by looking at linker flags passed through clang on to the driver, but it's 
> not going to be perfect (users can link manually without invoking through the 
> compiler, and I'm not certain what IDEs do when driving builds with Clang).
@MaskRay  -- do you think we should try to enable this diagnostic by default by 
looking at driver flags that will be passed to the linker, or does it seem more 
reasonable 

[PATCH] D141283: [clang] Improve diagnostic for "initializer-string for char array is too long"

2023-01-13 Thread Evan Smal via Phabricator via cfe-commits
evansmal added a comment.

Hi @shafik! Thanks for the review. I don't have commit access and am unsure 
what I should do to get this committed. Can you let me know what I need to do 
next?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141283

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


[PATCH] D140423: [WIP][clang] Add PrintingPolicy callback for identifying default template arguments

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> Add something like a bool IsDefaulted somewhere in Clang, e.g., in 
> TemplateArgument and consult it from the TypePrinter. This would be much 
> simpler but requires adding a field on one of the Clang types

I think this might be worth exploring as a cleaner solution to the problem. 
`TemplateArgument` has a union of structures for the various kinds of template 
arguments it represents 
(https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TemplateBase.h#L140).
 All of the structures in that union start with an `unsigned Kind` field to 
discriminate between the members. There are only 8 kinds currently 
(https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TemplateBase.h#L63),
 so we could turn `Kind` into a bit-field and then steal a bit for 
`IsDefaulted` without increasing memory overhead. Do you think that's a 
reasonable approach to try instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140423

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


[PATCH] D141620: clang/OpenCL: Make enqueued blocks inherit the parent attributes

2023-01-13 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:12488
+  // FIXME: The invoke isn't applying the right attributes either
+  llvm::AttrBuilder KernelAttrs(C, CGF.CurFn->getAttributes().getFnAttrs());
+  KernelAttrs.addAttribute("enqueued-block");

arsenm wrote:
> yaxunl wrote:
> > arsenm wrote:
> > > yaxunl wrote:
> > > > The kernel should inherit attributes from the parent function since the 
> > > > parent may have function attributes explicitly specified for itself 
> > > > only. The kernel should take the default function attributes.
> > > I was specifically try to get those, e.g. the attribute(target) example. 
> > > Is there some way to specify attributes directly on a block?
> > > I was specifically try to get those, e.g. the attribute(target) example. 
> > > Is there some way to specify attributes directly on a block?
> > 
> > I don't think so https://godbolt.org/z/Pahv46dh6
> It doesn't allow noinline or target, but does allow const so it seems to be 
> specific attributes. I guess that means it should just use the defaults
Something is inconsistent. If I apply the target attribute to the caller, it 
allows me to call the target builtin in the block. If I don't, it doesn't allow 
me to use it in the caller but does in the block. There's a missing diagnostic 
at least


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

https://reviews.llvm.org/D141620

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


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D131858#4050112 , @rsmith wrote:

> In D131858#3957630 , @arphaman 
> wrote:
>
>> This change has caused a failure in Clang's stage 2 CI on the green dragon 
>> Darwin CI: 
>> https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6390/console.
>>
>>   Assertion failed: (lvaluePath->getType() == elemTy && "Unexpected type 
>> reference!"), function readAPValue, file 
>> /Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build/tools/clang/include/clang/AST/AbstractBasicReader.inc,
>>  line 736.
>
> This assert is simply wrong, and I've removed it in 
> rG2009f2450532450a99c1a03d5e2c30f478121839 
>  -- that 
> change should be safe to cherry-pick into the release branch. It's possible 
> for the recomputation of the type after deserialization to result in a 
> different type than what we saw when serializing, because redeclarations of 
> the same entity can use the same type with different sugar -- or even 
> slightly different types in some cases, such as when an array bound is added 
> in a redeclaration. The dumps of the types provided by @steven_wu confirms 
> that we were just seeing a difference in type sugar in this case.
>
>>   Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block 
>> imbalance"), function ~BitstreamWriter, file 
>> /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/llvm/include/llvm/Bitstream/BitstreamWriter.h,
>>  line 119.
>
> Is this still happening? If so, this looks more serious, and will need 
> further investigation.
>
> Can we undo the workaround in https://reviews.llvm.org/D139956 and see if the 
> bot is now happy? Or can someone who was seeing problems before (@steven_wu?) 
> run a test?

Thank you for poking at this Richard! However, I think we still need to revert 
the functionality in this area unless we're able to make headway on 
https://github.com/llvm/llvm-project/issues/59271 and quickly. FWIW, I ran into 
this exact problem yesterday on my dev machine, so the overhead is still a 
present concern. If that's something you plan to work on, then I think it'd 
make sense for Erich to hold off on starting the revert work to give you a 
chance to improve this. But if nobody is actively working on it, we need to 
start pulling this back because the branch date is a bit over a week away (Jan 
24).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D141671: Move around structs and definitions to prevent incomplete types.

2023-01-13 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 488976.
massberg added a comment.

Clean up code and only mode definitions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

Files:
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h

Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -52,44 +52,13 @@
   CommentInfo(CommentInfo &&Other) = default;
   CommentInfo &operator=(CommentInfo &&Other) = default;
 
-  bool operator==(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI != SecondCI || Children.size() != Other.Children.size())
-  return false;
-
-return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
-  llvm::deref>{});
-  }
+  bool operator==(const CommentInfo &Other) const;
 
   // This operator is used to sort a vector of CommentInfos.
   // No specific order (attributes more important than others) is required. Any
   // sort is enough, the order is only needed to call std::unique after sorting
   // the vector.
-  bool operator<(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI < SecondCI)
-  return true;
-
-if (FirstCI == SecondCI) {
-  return std::lexicographical_compare(
-  Children.begin(), Children.end(), Other.Children.begin(),
-  Other.Children.end(), llvm::deref>());
-}
-
-return false;
-  }
+  bool operator<(const CommentInfo &Other) const;
 
   SmallString<16>
   Kind; // Kind of comment (FullComment, ParagraphComment, TextComment,
@@ -330,8 +299,7 @@
 // Info for namespaces.
 struct NamespaceInfo : public Info {
   NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
-StringRef Path = StringRef())
-  : Info(InfoType::IT_namespace, USR, Name, Path) {}
+StringRef Path = StringRef());
 
   void merge(NamespaceInfo &&I);
 
@@ -381,8 +349,7 @@
 // Info for types.
 struct RecordInfo : public SymbolInfo {
   RecordInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
- StringRef Path = StringRef())
-  : SymbolInfo(InfoType::IT_record, USR, Name, Path) {}
+ StringRef Path = StringRef());
 
   void merge(RecordInfo &&I);
 
@@ -434,11 +401,9 @@
 };
 
 struct BaseRecordInfo : public RecordInfo {
-  BaseRecordInfo() : RecordInfo() {}
+  BaseRecordInfo();
   BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path, bool IsVirtual,
- AccessSpecifier Access, bool IsParent)
-  : RecordInfo(USR, Name, Path), IsVirtual(IsVirtual), Access(Access),
-IsParent(IsParent) {}
+ AccessSpecifier Access, bool IsParent);
 
   // Indicates if base corresponds to a virtual inheritance
   bool IsVirtual = false;
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -128,6 +128,41 @@
   }
 }
 
+bool CommentInfo::operator==(const CommentInfo &Other) const {
+  auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
+  SelfClosing, Explicit, AttrKeys, AttrValues, Args);
+  auto SecondCI =
+  std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
+   Other.ParamName, Other.CloseName, Other.SelfClosing,
+   Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
+
+  if (FirstCI != SecondCI || Children.size() != Other.Children.size())
+return false;
+
+  return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
+llvm::deref>{});
+}
+
+bool CommentInfo::operator<(const CommentInfo &Other) const {
+  auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
+  SelfClosing, Explicit, AttrKeys, AttrValues, Args);
+  auto SecondCI =
+  std::tie(Other.Kind, Other.Text, Other.Name,

[PATCH] D141671: Move definitions to prevent incomplete types.

2023-01-13 Thread Jens Massberg via Phabricator via cfe-commits
massberg added a comment.

I have updated the code. It turned out that much less code has to be moved than 
I initially thought. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

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


[PATCH] D141240: [SVE][Builtins] Add metadata to intrinsic calls for builtins that don't define the result of inactive lanes.

2023-01-13 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

Just a heads up that I'm likely to abandon this patch because as predicted 
implementing dedicated intrinsics is looking like the better design and most 
all the code generation plumbing is already present and so even the 
implementation is minimal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141240

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


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D131858#4051336 , @aaron.ballman 
wrote:

> In D131858#4050112 , @rsmith wrote:
>
>> In D131858#3957630 , @arphaman 
>> wrote:
>>
>>> This change has caused a failure in Clang's stage 2 CI on the green dragon 
>>> Darwin CI: 
>>> https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6390/console.
>>>
>>>   Assertion failed: (lvaluePath->getType() == elemTy && "Unexpected type 
>>> reference!"), function readAPValue, file 
>>> /Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build/tools/clang/include/clang/AST/AbstractBasicReader.inc,
>>>  line 736.
>>
>> This assert is simply wrong, and I've removed it in 
>> rG2009f2450532450a99c1a03d5e2c30f478121839 
>>  -- 
>> that change should be safe to cherry-pick into the release branch. It's 
>> possible for the recomputation of the type after deserialization to result 
>> in a different type than what we saw when serializing, because 
>> redeclarations of the same entity can use the same type with different sugar 
>> -- or even slightly different types in some cases, such as when an array 
>> bound is added in a redeclaration. The dumps of the types provided by 
>> @steven_wu confirms that we were just seeing a difference in type sugar in 
>> this case.
>>
>>>   Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block 
>>> imbalance"), function ~BitstreamWriter, file 
>>> /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/llvm/include/llvm/Bitstream/BitstreamWriter.h,
>>>  line 119.
>>
>> Is this still happening? If so, this looks more serious, and will need 
>> further investigation.
>>
>> Can we undo the workaround in https://reviews.llvm.org/D139956 and see if 
>> the bot is now happy? Or can someone who was seeing problems before 
>> (@steven_wu?) run a test?
>
> Thank you for poking at this Richard! However, I think we still need to 
> revert the functionality in this area unless we're able to make headway on 
> https://github.com/llvm/llvm-project/issues/59271 and quickly. FWIW, I ran 
> into this exact problem yesterday on my dev machine, so the overhead is still 
> a present concern. If that's something you plan to work on, then I think it'd 
> make sense for Erich to hold off on starting the revert work to give you a 
> chance to improve this. But if nobody is actively working on it, we need to 
> start pulling this back because the branch date is a bit over a week away 
> (Jan 24).

My understanding is that the submitter of that bug did sufficient analysis to 
determine that https://reviews.llvm.org/D136566 is the cause of his perf 
regression, having done an analysis the patch before and after.  The only 
reason to revert THIS patch (and the follow-ups, since this is a 'base patch' 
to the rest) is the report by @steven_wu .

SO, @steven_wu: Can ypu please, ASAP, try to reproduce your issue as Richard 
asked above? IF so, we only have to revert D136566 
, which should fix our performance issue. 
(that is, revert the workaround you submitted in 
https://reviews.llvm.org/D139956, then see if it works?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@arphaman I see you're part of the original report too, if you could try to 
revert the workaround and test it, it would be nice too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D131858#4051352 , @erichkeane 
wrote:

> In D131858#4051336 , @aaron.ballman 
> wrote:
>
>> In D131858#4050112 , @rsmith wrote:
>>
>>> In D131858#3957630 , @arphaman 
>>> wrote:
>>>
 This change has caused a failure in Clang's stage 2 CI on the green dragon 
 Darwin CI: 
 https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6390/console.

   Assertion failed: (lvaluePath->getType() == elemTy && "Unexpected type 
 reference!"), function readAPValue, file 
 /Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build/tools/clang/include/clang/AST/AbstractBasicReader.inc,
  line 736.
>>>
>>> This assert is simply wrong, and I've removed it in 
>>> rG2009f2450532450a99c1a03d5e2c30f478121839 
>>>  -- 
>>> that change should be safe to cherry-pick into the release branch. It's 
>>> possible for the recomputation of the type after deserialization to result 
>>> in a different type than what we saw when serializing, because 
>>> redeclarations of the same entity can use the same type with different 
>>> sugar -- or even slightly different types in some cases, such as when an 
>>> array bound is added in a redeclaration. The dumps of the types provided by 
>>> @steven_wu confirms that we were just seeing a difference in type sugar in 
>>> this case.
>>>
   Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block 
 imbalance"), function ~BitstreamWriter, file 
 /Users/buildslave/jenkins/workspace/clang-stage1-RA/llvm-project/llvm/include/llvm/Bitstream/BitstreamWriter.h,
  line 119.
>>>
>>> Is this still happening? If so, this looks more serious, and will need 
>>> further investigation.
>>>
>>> Can we undo the workaround in https://reviews.llvm.org/D139956 and see if 
>>> the bot is now happy? Or can someone who was seeing problems before 
>>> (@steven_wu?) run a test?
>>
>> Thank you for poking at this Richard! However, I think we still need to 
>> revert the functionality in this area unless we're able to make headway on 
>> https://github.com/llvm/llvm-project/issues/59271 and quickly. FWIW, I ran 
>> into this exact problem yesterday on my dev machine, so the overhead is 
>> still a present concern. If that's something you plan to work on, then I 
>> think it'd make sense for Erich to hold off on starting the revert work to 
>> give you a chance to improve this. But if nobody is actively working on it, 
>> we need to start pulling this back because the branch date is a bit over a 
>> week away (Jan 24).
>
> My understanding is that the submitter of that bug did sufficient analysis to 
> determine that https://reviews.llvm.org/D136566 is the cause of his perf 
> regression, having done an analysis the patch before and after.  The only 
> reason to revert THIS patch (and the follow-ups, since this is a 'base patch' 
> to the rest) is the report by @steven_wu .

A thank you for the extra information. I had missed that this was one 
before the perf issue.

> SO, @steven_wu: Can ypu please, ASAP, try to reproduce your issue as Richard 
> asked above? IF so, we only have to revert D136566 
> , which should fix our performance issue. 
> (that is, revert the workaround you submitted in 
> https://reviews.llvm.org/D139956, then see if it works?).

+1, but based on the link to the workaround and what Richard fixed, I'm 
optimistic we can keep this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D141547: Fix format for `case` in .proto files

2023-01-13 Thread Matt Kulukundis via Phabricator via cfe-commits
fowles updated this revision to Diff 488979.
fowles added a comment.

Move from lit test to unit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141547

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestProto.cpp


Index: clang/unittests/Format/FormatTestProto.cpp
===
--- clang/unittests/Format/FormatTestProto.cpp
+++ clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();


Index: clang/unittests/Format/FormatTestProto.cpp
===
--- clang/unittests/Format/FormatTestProto.cpp
+++ clang/unittests/Format/FormatTestProto.cpp
@@ -113,6 +113,13 @@
"}");
 }
 
+TEST_F(FormatTestProto, CaseAsFieldName) {
+  verifyFormat("message SomeMessage {\n"
+   "  required string case = 1;\n"
+   "  repeated int32 fizz = 2;\n"
+   "}");
+}
+
 TEST_F(FormatTestProto, UnderstandsReturns) {
   verifyFormat("rpc Search(SearchRequest) returns (SearchResponse);");
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -590,8 +590,9 @@
   [[fallthrough]];
 }
 case tok::kw_case:
-  if (Style.isVerilog() ||
+  if (Style.isProto() || Style.isVerilog() ||
   (Style.isJavaScript() && Line->MustBeDeclaration)) {
+// Proto: there are no switch/case statements
 // Verilog: Case labels don't have this word. We handle case
 // labels including default in TokenAnnotator.
 // JavaScript: A 'case: string' style field declaration.
@@ -1620,7 +1621,11 @@
 // e.g. "default void f() {}" in a Java interface.
 break;
   case tok::kw_case:
-// In Verilog switch is called case.
+// Proto: there are no switch/case statements.
+if (Style.isProto()) {
+  nextToken();
+  return;
+}
 if (Style.isVerilog()) {
   parseBlock();
   addUnwrappedLine();
@@ -2100,6 +2105,11 @@
   parseNew();
   break;
 case tok::kw_case:
+  // Proto: there are no switch/case statements.
+  if (Style.isProto()) {
+nextToken();
+return;
+  }
   // In Verilog switch is called case.
   if (Style.isVerilog()) {
 parseBlock();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: aaron.ballman.
erichkeane added a comment.

In D140547#4050936 , @ilya-biryukov 
wrote:

> In D140547#4050752 , @uabelho wrote:
>
>> Anyone else see this?
>
> I have not checked, but I would not be surprised if we hit the stack size 
> limits with asan enabled
> @usaxena95, maybe reduce the number of instantiations from `10001` to `1001` 
> or `101`? It should not change the intention of the test and fix this failure.

This is a regression that was noticed by @aaron.ballman even without ASAN, so 
this is something that needs doing ASAP.  The branch is happening around the 
24th, so this needs to be fixed by then.




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1366
   LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
-  return inherited::TransformRequiresExpr(E);
+  auto TransReq = inherited::TransformRequiresExpr(E);
+  if (TransReq.isInvalid())

'auto' isn't allowed here by coding standard, this needs to be ExprResult.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D140756: Add clang_CXXMethod_isExplicit to libclang

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from some minor things you can correct when landing.




Comment at: clang/bindings/python/clang/cindex.py:1550-1557
+class Foo {
+explicit Foo();
+explicit operator int();
+};
+
+This method will return 0 when given a cursor pointing to one of
+the former declarations and it will return 1 for a cursor pointing

You might want to add documentation about:
```
constexpr bool foo(int i) { return i % 2 == 0; }

struct S {
  explicit(foo(1)) S(); // IsExplicit returns false
  explicit(foo(2)) operator int(); // IsExplicit returns true
```
so it's not about the syntactic element of there being an `explicit`, it's 
about what it resolves to.



Comment at: clang/include/clang-c/Index.h:4364
+ *
+ * class Foo {
+ * explicit Foo();

Same doc suggestions around here as in the Python code.



Comment at: clang/tools/libclang/CIndex.cpp:8951-8957
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  const CXXConversionDecl *ConversionFunction =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+
+  return ((Constructor && Constructor->isExplicit()) ||
+  (ConversionFunction && ConversionFunction->isExplicit()));

Same logic, but spelled differently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140756

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


Re: r241356 - StmtIterator: Put stmt and decl group pointer into a union.

2023-01-13 Thread Amir Eghtedari via cfe-commits

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


Re: [PATCH] D6376: Fix JSON compilation database command unescaping.

2023-01-13 Thread Amir Eghtedari via cfe-commits

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


Re: [PATCH] D8149: Add hasUnderlyingType narrowing matcher for TypedefDecls, functionProtoType matcher for FunctionProtoType nodes, extend parameterCountIs to FunctionProtoType nodes

2023-01-13 Thread Amir Eghtedari via cfe-commits

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2023-01-13 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

The most recent versions of this patch contains squashed changes from these 
reviews:

- D139278  "[AArch64] Use string comparison 
for ArchInfo equality." This fixes the test failures with shared libraries, 
which were caused by each shared library ending up with it's own copy of the 
ArchInfo instances and hence breaking the equality-by-address.
- D139102  "[AArch64] Inline 
AArch64TargetParser.def"

The `ArchInfo` class is no longer non-copyable to satisfy C++20. The 
alternative of adding a constructor would have resulted in global constructor 
calls, which is not allowed in Support (the same presumably applies to the new 
TargetParser library).

I've tested locally with `LLVM_BUILD_LLVM_DYLIB=ON` + `LLVM_LINK_LLVM_DYLIB=ON` 
+ `CMAKE_CXX_STANDARD=20`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2023-01-13 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

Worth noting that this had to be reworked because both D127812 
 and D137838 
 went in since this was reverted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D140838: [clang] fix crash on generic lambda with lambda in decltype

2023-01-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a comment.

This fixes #57170 (59771 was closed as a dupe of that one). I think this LG, 
but I'd appreciate a second set of eyes on it as there have been plenty of 
changes in this area recently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140838

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


[PATCH] D141671: Move definitions to prevent incomplete types.

2023-01-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, LGTM! (btw, i know it's too late already, but in theory clangd has a 
code action called move definition out-of-line, could help with such 
refactorings in the future, if you didn't know already)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

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


[PATCH] D131052: [CMake] Allow setting the location of host tools with LLVM_NATIVE_TOOL_DIR

2023-01-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 488982.
mstorsjo added a comment.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, mgester, 
arpith-jacob, nicolasvasilache, antiagainst, shauheen, rriddle, mehdi_amini.
Herald added a reviewer: njames93.
Herald added a project: MLIR.

Factorized setup of building a separate host version of code generation tools 
into a macro, shared across existing users.

There are some minor nuance differences to how tool generation happened before, 
but it should probably not matter (and this is probably an improvement):

- Only look at the user setting variable (for pointing to a preexisting 
external tool executable) if LLVM_USE_HOST_TOOLS is set; if LLVM_USE_HOST_TOOLS 
isn't set, ignore the variable. (mlir-linalg-ods-gen already did it this way, 
the clang-tools-extra tools didn't.)
- Add a dependency on the target version of the executable, when building a 
native one - this makes sure to regenereate the native one when there are 
changes to the sources for that tool (according to other cmake comments in the 
code; the clang-tools-extra tools didn't do this before).

If wanted, I could split this up into two patches; one for refactoring the call 
sites and one for adding the new variable LLVM_NATIVE_TOOL_DIR - but I'm 
posting them as one single patch here for now, to hopefully get it reviewed 
quicker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131052

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/pseudo/include/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/TableGen.cmake
  llvm/tools/llvm-config/CMakeLists.txt
  mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt

Index: mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
===
--- mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
+++ mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
@@ -14,23 +14,13 @@
   MLIRParser
   )
 
-set(MLIR_LINALG_ODS_YAML_GEN mlir-linalg-ods-yaml-gen CACHE
-  STRING "Native mlir-linalg-ods-yaml-gen executable. Saves building one when cross-compiling.")
+setup_host_tool(mlir-linalg-ods-yaml-gen MLIR_LINALG_ODS_YAML_GEN MLIR_LINALG_ODS_YAML_GEN_EXE MLIR_LINALG_ODS_YAML_GEN_TARGET SCOPE PARENT_SCOPE)
 
-set(MLIR_LINALG_ODS_YAML_GEN_EXE ${MLIR_LINALG_ODS_YAML_GEN} PARENT_SCOPE)
-set(MLIR_LINALG_ODS_YAML_GEN_TARGET mlir-linalg-ods-yaml-gen PARENT_SCOPE)
+if(NOT ${MLIR_LINALG_ODS_YAML_GEN_EXE} STREQUAL "mlir-linalg-ods-yaml-gen")
+  add_custom_target(mlir-linalg-ods-yaml-gen-host DEPENDS ${MLIR_LINALG_ODS_YAML_GEN_EXE})
 
-if(LLVM_USE_HOST_TOOLS)
-  if (${MLIR_LINALG_ODS_YAML_GEN} STREQUAL "mlir-linalg-ods-yaml-gen")
-build_native_tool(mlir-linalg-ods-yaml-gen MLIR_LINALG_ODS_YAML_GEN_EXE DEPENDS mlir-linalg-ods-yaml-gen)
-set(MLIR_LINALG_ODS_YAML_GEN_EXE ${MLIR_LINALG_ODS_YAML_GEN_EXE} PARENT_SCOPE)
-
-add_custom_target(mlir-linalg-ods-yaml-gen-host DEPENDS ${MLIR_LINALG_ODS_YAML_GEN_EXE})
-set(MLIR_LINALG_ODS_YAML_GEN_TARGET mlir-linalg-ods-yaml-gen-host DEPENDS PARENT_SCOPE)
-
-if(NOT LLVM_BUILD_UTILS)
-  set_target_properties(mlir-linalg-ods-yaml-gen PROPERTIES EXCLUDE_FROM_ALL ON)
-endif()
+  if(NOT LLVM_BUILD_UTILS)
+set_target_properties(mlir-linalg-ods-yaml-gen PROPERTIES EXCLUDE_FROM_ALL ON)
   endif()
 endif()
 
Index: llvm/tools/llvm-config/CMakeLists.txt
===
--- llvm/tools/llvm-config/CMakeLists.txt
+++ llvm/tools/llvm-config/CMakeLists.txt
@@ -91,10 +91,18 @@
 # Add the dependency on the generation step.
 add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH})
 
-if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH)
-  build_native_tool(llvm-config LLVM_CONFIG_PATH)
-  set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "")
+if(CMAKE_CROSSCOMPILING)
+  if (LLVM_NATIVE_TOOL_DIR AND NOT LLVM_CONFIG_PATH)
+if (EXISTS "${LLVM_NATIVE_TOOL_DIR}/llvm-config${LLVM_HOST_EXECUTABLE_SUFFIX}")
+  set(LLVM_CONFIG_PATH "${LLVM_NATIVE_TOOL_DIR}/llvm-config${LLVM_HOST_EXECUTABLE_SUFFIX}")
+endif()
+  endif()
 
-  add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH})
-  add_dependencies(llvm-config NativeLLVMConfig)
+  if (NOT LLVM_CONFIG_PATH)
+build_native_tool(llvm-config LLVM_CONFIG_PATH)
+set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "")
+
+add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH})
+add_dependencies(llvm-config NativeLLVMConfig)
+  endif()
 endif()
Index: llvm/cmake/modules/TableGen.cmake
===
--- llvm/cmake/modules/TableGen.cmake
+++ llvm/cmake/modules/TableGen.cma

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:4129
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+}

pmatos wrote:
> erichkeane wrote:
> > Note that it seems this is likely not going to work correctly on template 
> > type aliases!  You probably want to make sure that is acceptable to you.
> Documentation says about Subject:
> 
> ```
>   // The things to which an attribute can appertain
>   SubjectList Subjects;
> ```
> 
> Given this can be attached to function pointer types, is the subject then 
> just Type ?
IIRC, the list of subjects are the Decls and Stmt types that are possibly 
allowed.  I don't thnk it would be just 'Type' there.

As you have it, it is only allowed on TypedefNameDecl.

See the SubsetSubject's at the top of this file for some examples on how you 
could constrain a special matcher to only work on function pointer decls.



Comment at: clang/lib/Basic/Targets/DirectX.h:45
 3, // hlsl_groupshared
+// Wasm address space values for this map are dummy
+20, // wasm_funcref

pmatos wrote:
> erichkeane wrote:
> > Also apply to the rest of the targets.  Also, why is there only 1 added 
> > here?  I thought we had 2 address spaces for Wasm?
> Externref is a type in clang, doesn't need its own address space in clang, 
> only when it's lowered to a opaque type in llvm it gets its own address space.
Please fix the comment in my suggestion.

Also, your explanation doesn't make it clear to me why you added TWO entries to 
this list for other targets, but only 1 here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D140838: [clang] fix crash on generic lambda with lambda in decltype

2023-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I think that makes sense to me, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140838

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


[PATCH] D141666: [RISCV] Proper support of extensions Zicsr and Zifencei

2023-01-13 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Because they used to be part of I and then a later version of the RISC-V spec 
split them out in an incompatible way. GCC/binutils bit the bullet and split 
them out last(?) year but LLVM has yet to make that breaking change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141666

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


[PATCH] D141580: [clang] Don't consider a nullptr returned from ActOnTag() as a valid result in ParseClassSpecifier.

2023-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 488985.
hokein added a comment.

Check for the ActOnTemplatedFriendTag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141580

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx-undeclared-identifier.cpp
  clang/test/Parser/recovery.cpp
  clang/test/SemaCXX/invalid-template-params.cpp
  clang/test/SemaCXX/rdar42746401.cpp


Index: clang/test/SemaCXX/rdar42746401.cpp
===
--- clang/test/SemaCXX/rdar42746401.cpp
+++ clang/test/SemaCXX/rdar42746401.cpp
@@ -4,4 +4,4 @@
 class b;
 class c; // expected-note{{forward declaration}}
 
-::b<0> struct c::d // expected-error{{incomplete type}} expected-error{{cannot 
combine}} expected-error{{expected unqualified-id}}
+::b<0> struct c::d // expected-error{{incomplete type}} 
expected-error{{expected unqualified-id}}
Index: clang/test/SemaCXX/invalid-template-params.cpp
===
--- clang/test/SemaCXX/invalid-template-params.cpp
+++ clang/test/SemaCXX/invalid-template-params.cpp
@@ -15,9 +15,8 @@
 public:
   template' in 
template-parameter-list}}
-// expected-error@-3 {{declaration does not declare anything}}
+// expected-error@-1 {{expected ',' or '>' in 
template-parameter-list}}
+// expected-error@-2 {{declaration does not declare anything}}
   C0() : m(new S0) {} // expected-error {{expected '(' for function-style 
cast or type construction}}
// expected-error@-1 {{expected expression}}
   S0 *m; // expected-error {{expected member name or ';' after 
declaration specifiers}}
Index: clang/test/Parser/recovery.cpp
===
--- clang/test/Parser/recovery.cpp
+++ clang/test/Parser/recovery.cpp
@@ -212,6 +212,6 @@
 enum ::, enum ::; // expected-error 2 {{expected identifier}}
 struct ::__super, struct ::__super; // expected-error 2 {{expected 
identifier}} expected-error 2 {{expected '::' after '__super'}}
 struct ::template foo, struct ::template bar; // expected-error 2 {{expected 
identifier}} expected-error 2 {{declaration of anonymous struct must be a 
definition}} expected-warning {{declaration does not declare anything}}
-struct ::foo struct::; // expected-error {{no struct named 'foo' in the global 
namespace}} expected-error {{expected identifier}} expected-error {{declaration 
of anonymous struct must be a definition}}
+struct ::foo struct::; // expected-error {{no struct named 'foo' in the global 
namespace}} expected-error {{expected identifier}}
 class :: : {} a;  // expected-error {{expected identifier}} expected-error 
{{expected class name}}
 }
Index: clang/test/Parser/cxx-undeclared-identifier.cpp
===
--- clang/test/Parser/cxx-undeclared-identifier.cpp
+++ clang/test/Parser/cxx-undeclared-identifier.cpp
@@ -15,5 +15,5 @@
 // PR7180
 int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}}
 
-class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \
- // expected-error {{expected ';' after class}}
+class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}}
+ // expected-error {{expected unqualified-id}}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2034,11 +2034,13 @@
 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
 /*DiagnoseEmptyAttrs=*/true);
 
-TagOrTempResult = Actions.ActOnTemplatedFriendTag(
-getCurScope(), DS.getFriendSpecLoc(), TagType, StartLoc, SS, Name,
-NameLoc, attrs,
-MultiTemplateParamsArg(TemplateParams ? &(*TemplateParams)[0] : 
nullptr,
-   TemplateParams ? TemplateParams->size() : 0));
+if (auto *FT = Actions.ActOnTemplatedFriendTag(
+getCurScope(), DS.getFriendSpecLoc(), TagType, StartLoc, SS, Name,
+NameLoc, attrs,
+MultiTemplateParamsArg(
+TemplateParams ? &(*TemplateParams)[0] : nullptr,
+TemplateParams ? TemplateParams->size() : 0)))
+  TagOrTempResult = FT;
   } else {
 if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
   ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
@@ -2066,14 +2068,15 @@
 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
 
 // Declaration or definition of a class type
-TagOrTempResult = Actions.ActOnTag(
-getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
-DS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
-SourceLocation(), false, clang::TypeResult(),
-DS

[PATCH] D141580: [clang] Don't consider a nullptr returned from ActOnTag() as a valid result in ParseClassSpecifier.

2023-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:2069-2078
+if (auto *TagDecl = Actions.ActOnTag(
+getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, 
AS,
+DS.getModulePrivateSpecLoc(), TParams, Owned, IsDependent,
+SourceLocation(), false, clang::TypeResult(),
+DSC == DeclSpecContext::DSC_type_specifier,
+DSC == DeclSpecContext::DSC_template_param ||
+DSC == DeclSpecContext::DSC_template_type_arg,

hokein wrote:
> aaron.ballman wrote:
> > I think this is the wrong approach to fixing the issue. None of the other 
> > assignments to `TagOrTempResult` test for nullptr first, such as: 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2037
> >  and 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2029.
> > 
> > An `ActionResult` can be both valid/invalid *and* usable/unusable (and a 
> > `DeclResult` is a kind of `ActionResult`). When it's assigned *any pointer 
> > value* (including nullptr), it's a valid `ActionResult` but it's not a 
> > usable `ActionResult` 
> > (https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Sema/Ownership.h#L166).
> > 
> > I think the correct fix is to find the places assuming a valid 
> > `ActionResult` means a nonnull pointer from `get()`, such as 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2121
> >  and switch them over to looking for a usable `ActionResult` instead.
> Thanks for the comment!
> 
> > None of the other assignments to TagOrTempResult test for nullptr first
> 
> I think the problem here is:
> - most of the `ActOn*` methods return a `DeclResult` (and inside these method 
> implementations, they return an Invalid `DeclResult` if the Decl is nullptr), 
> so `TagOrTempResult = Actions.ActOn*` is a fine pattern.
> - Only two exceptions `ActOnTagDecl` and `ActOnTemplatedFriendTag`, they 
> return a `Decl*`, so the `TagOrTempResult = Action.ActOn*` is a very 
> suspicious pattern. (IMO, they're not intentional, likely bugs).
> 
> > such as: 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2037
> >  and 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2029.
> 
> The first one is the other exception; the second one is not 
> (ActOnExplicitInstantiation returns a `DeclResult`).
> 
> > I think the correct fix is to find the places assuming a valid ActionResult 
> > means a nonnull pointer from get(), such as 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2121
> >  and switch them over to looking for a usable ActionResult instead.
> 
> This is one of the solutions. But instead of justifying every places of 
> DeclResult, I think we should fix the two exception places (by adding the 
> nullptr check in
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2037
>  and 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDeclCXX.cpp#L2069),
>  what do you think?
I have updated the patch to check nullptr for ActOnTemplatedFriendTag as well. 
Let me know what you think (I'm also happy to do the change).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141580

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


[PATCH] D141690: [clang] fix consteval ctor code generation assert

2023-01-13 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google created this revision.
Herald added a project: All.
luken-google requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes GH#53983.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141690

Files:
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1334,7 +1334,8 @@
 void CodeGenFunction::EmitAggregateStore(llvm::Value *Val, Address Dest,
  bool DestIsVolatile) {
   // Prefer scalar stores to first-class aggregate stores.
-  if (llvm::StructType *STy = dyn_cast(Val->getType())) {
+  llvm::StructType *STy = dyn_cast(Val->getType());
+  if (STy && 
STy->isLayoutIdentical(cast(Dest.getElementType( {
 for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
   Address EltPtr = Builder.CreateStructGEP(Dest, i);
   llvm::Value *Elt = Builder.CreateExtractValue(Val, i);


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1334,7 +1334,8 @@
 void CodeGenFunction::EmitAggregateStore(llvm::Value *Val, Address Dest,
  bool DestIsVolatile) {
   // Prefer scalar stores to first-class aggregate stores.
-  if (llvm::StructType *STy = dyn_cast(Val->getType())) {
+  llvm::StructType *STy = dyn_cast(Val->getType());
+  if (STy && STy->isLayoutIdentical(cast(Dest.getElementType( {
 for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
   Address EltPtr = Builder.CreateStructGEP(Dest, i);
   llvm::Value *Elt = Builder.CreateExtractValue(Val, i);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Note, I just did the revert of the workaround myself here: 
498bf3424d011235d420e02e80e135fae646d537 


I won't see the failure on 
https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/ until Tuesday, but 
if it DOES fail like reported above, I'll continue on the effort to revert this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D141671: Move definitions to prevent incomplete types.

2023-01-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.

LGTM! Looks much cleaner now, BTW.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

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


[PATCH] D141690: [clang] fix consteval ctor code generation assert

2023-01-13 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google added a comment.

See: https://github.com/llvm/llvm-project/issues/53983

I can add a release note and some testing, but wanted feedback that this was 
the right approach. The problem is when generating code for the constructor for 
the `bar` element inside of `MyStruct`, `Dest` has an elementType of `Base`, 
but `Builder.CreateStructGEP` assumes the `{i8, i8}` layout implied by `Base`. 
which causes an assert trying to emit code for the second element. So, I've 
added logic to make sure the layout of `STy` and `Dest` are identical, which 
fixes the assert but doesn't break any of the existing testing around aggregate 
stores.

AFAICT the AST and lowering all looks correct, and this is an issue in code 
generation. But this is a new area of clang for me so I'd welcome suggestions 
about if there is a better fix or if the fix should be in a different place. 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141690

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


[clang] bf5c17e - [clang][NFC] Remove dependency on DataLayout::getPrefTypeAlignment

2023-01-13 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2023-01-13T15:01:29Z
New Revision: bf5c17ed0f402f603782d28264dab1157994c43d

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

LOG: [clang][NFC] Remove dependency on DataLayout::getPrefTypeAlignment

Added: 


Modified: 
clang/include/clang/AST/CharUnits.h
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
clang/lib/CodeGen/CGVTT.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ConstantInitBuilder.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/CodeGen/SwiftCallingConv.cpp
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CharUnits.h 
b/clang/include/clang/AST/CharUnits.h
index ee0d402fc74a..c06354451dfb 100644
--- a/clang/include/clang/AST/CharUnits.h
+++ b/clang/include/clang/AST/CharUnits.h
@@ -64,9 +64,9 @@ namespace clang {
 return CharUnits(Quantity);
   }
 
-  /// fromAlign - Construct a CharUnits quantity from an llvm::Align
+  /// fromQuantity - Construct a CharUnits quantity from an llvm::Align
   /// quantity.
-  static CharUnits fromAlign(llvm::Align Quantity) {
+  static CharUnits fromQuantity(llvm::Align Quantity) {
 return CharUnits(Quantity.value());
   }
 

diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 1a4be440c53d..6e4a0dbf2335 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -522,7 +522,7 @@ static void initializeForBlockHeader(CodeGenModule &CGM, 
CGBlockInfo &info,
   for (auto *I : Helper->getCustomFieldTypes()) /* custom fields */ {
 // TargetOpenCLBlockHelp needs to make sure the struct is packed.
 // If necessary, add padding fields to the custom fields.
-unsigned Align = CGM.getDataLayout().getABITypeAlignment(I);
+unsigned Align = CGM.getDataLayout().getABITypeAlign(I).value();
 if (BlockAlign < Align)
   BlockAlign = Align;
 assert(Offset % Align == 0);
@@ -2672,7 +2672,7 @@ const BlockByrefInfo 
&CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
 size = varOffset;
 
   // Conversely, we might have to prevent LLVM from inserting padding.
-  } else if (CGM.getDataLayout().getABITypeAlignment(varTy) >
+  } else if (CGM.getDataLayout().getABITypeAlign(varTy) >
  uint64_t(varAlign.getQuantity())) {
 packed = true;
   }

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b8de9fb7224e..276d91fa2758 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1149,7 +1149,7 @@ static Address 
CreateTempAllocaForCoercion(CodeGenFunction &CGF, llvm::Type *Ty,
const Twine &Name = "tmp") {
   // Don't use an alignment that's worse than what LLVM would prefer.
   auto PrefAlign = CGF.CGM.getDataLayout().getPrefTypeAlign(Ty);
-  CharUnits Align = std::max(MinAlign, CharUnits::fromAlign(PrefAlign));
+  CharUnits Align = std::max(MinAlign, CharUnits::fromQuantity(PrefAlign));
 
   return CGF.CreateTempAlloca(Ty, Align, Name + ".coerce");
 }
@@ -5166,7 +5166,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 // Materialize to a temporary.
 addr = CreateTempAlloca(
 RV.getScalarVal()->getType(),
-CharUnits::fromAlign(std::max(layout->getAlignment(), 
scalarAlign)),
+CharUnits::fromQuantity(std::max(layout->getAlignment(), 
scalarAlign)),
 "tmp",
 /*ArraySize=*/nullptr, &AllocaAddr);
 tempSize = EmitLifetimeStart(scalarSize, AllocaAddr.getPointer());

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index ad7871d7cc7f..ca665dbe7d0a 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -123,7 +123,7 @@ llvm::AllocaInst 
*CodeGenFunction::CreateTempAlloca(llvm::Type *Ty,
 Address CodeGenFunction::CreateDefaultAlignTempAlloca(llvm::Type *Ty,
   const Twine &Name) {
   CharUnits Align =
-  CharUnits::fromAlign(CGM.getDataLayout().getPrefTypeAlign(Ty));
+  CharUnits::fromQuantity(CGM.getDataLayout().getPrefTypeAlign(Ty));
   return CreateTempAlloca(Ty, Align, Name);
 }
 

diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 7dc105215e7d..8e74f0295301 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++

[PATCH] D141690: [clang] fix consteval ctor code generation assert

2023-01-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The change seems reasonable. Could you add a test with a crasher repro and some 
validation of the generated IR?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141690

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


[PATCH] D138792: [AArch64] Improve TargetParser API

2023-01-13 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas accepted this revision.
pratlucas added a comment.

LGTM with a tiny nit. Feel free to fix it when landing the changes.




Comment at: llvm/include/llvm/TargetParser/AArch64TargetParser.h:164-166
+  CPUFeatures CPUFeature;  // ?
+  StringRef DependentFeatures; // ?
+  unsigned FmvPriority;// ?

Minor nit: can you replace the `// ?` comments with a single TODO to 
document those better? It'd look a bit less confusing for others reading this 
in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138792

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


[PATCH] D140838: [clang] fix crash on generic lambda with lambda in decltype

2023-01-13 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

Thanks for reviewing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140838

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


[PATCH] D141670: [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 488995.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141670

Files:
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
  clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -432,6 +433,21 @@
   PI.getExporters(SM.getFileEntryForID(SM.getMainFileID()), FM).empty());
 }
 
+TEST_F(PragmaIncludeTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "export.h"
+  )cpp";
+  Inputs.ExtraFiles["export.h"] = R"cpp(
+#include  // IWYU pragma: export
+  )cpp";
+  Inputs.ExtraFiles["string"] = "";
+  Inputs.ExtraArgs = {"-isystem."};
+  TestAST Processed = build();
+  auto &FM = Processed.fileManager();
+  EXPECT_THAT(PI.getExporters(*tooling::stdlib::Header::named(""), FM),
+  testing::UnorderedElementsAre(FileNamed("export.h")));
+}
+
 TEST_F(PragmaIncludeTest, IWYUExportBlock) {
   Inputs.Code = R"cpp(// Line 1
#include "normal.h"
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -107,6 +108,23 @@
   UnorderedElementsAre(physicalHeader("exporter.h")));
 }
 
+TEST_F(FindHeadersTest, IWYUExportForStandardHeaders) {
+  Inputs.Code = R"cpp(
+#include "exporter.h"
+  )cpp";
+  Inputs.ExtraFiles["exporter.h"] = guard(R"cpp(
+#include  // IWYU pragma: export
+  )cpp");
+  Inputs.ExtraFiles["string"] = guard("");
+  Inputs.ExtraArgs.push_back("-isystem.");
+  buildAST();
+  tooling::stdlib::Symbol StdString =
+  *tooling::stdlib::Symbol::named("std::", "string");
+  EXPECT_THAT(
+  include_cleaner::findHeaders(StdString, AST->sourceManager(), &PI),
+  UnorderedElementsAre(physicalHeader("exporter.h"), StdString.header()));
+}
+
 TEST_F(FindHeadersTest, SelfContained) {
   Inputs.Code = R"cpp(
 #include "header.h"
Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Inclusions/HeaderAnalysis.h"
+#include "clang/Tooling/Inclusions/StandardLibrary.h"
 
 namespace clang::include_cleaner {
 namespace {
@@ -188,12 +189,18 @@
   SrcMgr::CharacteristicKind FileKind) override {
 FileID HashFID = SM.getFileID(HashLoc);
 int HashLine = SM.getLineNumber(HashFID, SM.getFileOffset(HashLoc));
-checkForExport(HashFID, HashLine, File ? &File->getFileEntry() : nullptr);
+Header IncludedHeader = File ? &File->getFileEntry() : nullptr;
+if (IsAngled)
+  if (auto StandardHeader =
+  tooling::stdlib::Header::named("<" + FileName.str() + ">")) {
+IncludedHeader = *StandardHeader;
+  }
+checkForExport(HashFID, HashLine, std::move(IncludedHeader));
 checkForKeep(HashLine);
   }
 
   void checkForExport(FileID IncludingFile, int HashLine,
-  const FileEntry *IncludedHeader) {
+  Header IncludedHeader) {
 if (ExportStack.empty())
   return;
 auto &Top = ExportStack.back();
@@ -202,9 +209,14 @@
 // Make sure current include is covered by the export pragma.
 if ((Top.Block && HashLine > Top.SeenAtLine) ||
 Top.SeenAtLine == HashLine) {
-  if (IncludedHeader)
-Out->IWYUExportBy[IncludedHeader->getUniqueID()].push_back(
-Top.Path);
+  if (IncludedHeader.kind() == Header::Standard)
+Out->StdIWYUExp

[PATCH] D141670: [include-cleaner] FindHeaders respects IWYU export pragma for standard headers.

2023-01-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:203
+  const FileEntry *IncludedHeader,
+  std::optional StandardHeader) {
 if (ExportStack.empty())

kadircet wrote:
> just saying `StandardHeader` here isn't really useful. what about changing 
> signautre here to take a `include_cleaner::Header` instead, named 
> `IncludedHeader` and switch over kind to add it to ExportBy map? I don't 
> think there's any value in storing Exporters for `` both as a 
> physical entry and a stdlib entry.
Ah, nice idea! thanks.



Comment at: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp:122
+  tooling::stdlib::Symbol StdString =
+  *tooling::stdlib::Symbol::named("std::", "string");
+  EXPECT_THAT(

kadircet wrote:
> nit: `tooling::stdlib::Header::named("")`
We need this `tooling::stdlib::Symbol` here, `include_cleaner::findHeaders` 
accepts a `SymbolLocation`, `SymbolLocation` is construct from a 
`tooling::stdlib::Symbol`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141670

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


[PATCH] D135750: [clang][Interp] Track initialization state of local variables

2023-01-13 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 488996.

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

https://reviews.llvm.org/D135750

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Descriptor.h
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpFrame.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  clang/lib/AST/Interp/Program.cpp
  clang/lib/AST/Interp/Program.h
  clang/test/AST/Interp/cxx20.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/Interp/loops.cpp

Index: clang/test/AST/Interp/loops.cpp
===
--- clang/test/AST/Interp/loops.cpp
+++ clang/test/AST/Interp/loops.cpp
@@ -5,6 +5,7 @@
 
 // ref-no-diagnostics
 // expected-no-diagnostics
+// expected-cpp20-no-diagnostics
 
 namespace WhileLoop {
   constexpr int f() {
@@ -165,8 +166,6 @@
   static_assert(f5(true) == 8, "");
   static_assert(f5(false) == 5, "");
 
-  /// FIXME: This should be accepted in C++20 but is currently being rejected
-  ///   because the variable declaration doesn't have an initializier.
 #if __cplusplus >= 202002L
   constexpr int f6() {
 int i;
@@ -176,7 +175,7 @@
 } while (true);
 return i;
   }
-  static_assert(f6() == 5, ""); // expected-cpp20-error {{not an integral constant}}
+  static_assert(f6() == 5, "");
 #endif
 
 #if 0
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -407,8 +407,7 @@
 return 1;
   }
   static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'uninit()'}} \
-   // expected-error {{not an integral constant expression}}
+   // ref-note {{in call to 'uninit()'}}
 
   constexpr int OverFlow() { // ref-error {{never produces a constant expression}}
 int a = INT_MAX;
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -56,33 +56,51 @@
 }
 static_assert(pointerAssign2() == 12, "");
 
-
 constexpr int unInitLocal() {
   int a;
-  return a; // ref-note{{read of uninitialized object}}
+  return a; // ref-note {{read of uninitialized object}} \
+// expected-note {{read of object outside its lifetime}}
+// FIXME: ^^^ Wrong diagnostic.
 }
-static_assert(unInitLocal() == 0, ""); // expected-error {{not an integral constant expression}} \
-   // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'unInitLocal()'}}
-
-/// TODO: The example above is correctly rejected by the new constexpr
-///   interpreter, but for the wrong reasons. We don't reject it because
-///   it is an uninitialized read, we reject it simply because
-///   the local variable does not have an initializer.
-///
-///   The code below should be accepted but is also being rejected
-///   right now.
-#if 0
+static_assert(unInitLocal() == 0, ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'unInitLocal()'}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'unInitLocal()'}} \
+
 constexpr int initializedLocal() {
   int a;
-  int b;
-
   a = 20;
   return a;
 }
 static_assert(initializedLocal() == 20);
 
-/// Similar here, but the uninitialized local is passed as a function parameter.
+constexpr int initializedLocal2() {
+  int a[2];
+  return *a; // expected-note {{read of object outside its lifetime}} \
+ // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+}
+static_assert(initializedLocal2() == 20); // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to}} \
+  // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to}}
+
+
+struct Int { int a; };
+constexpr int initializedLocal3() {
+  Int i;
+  return i.a; // expected-note {{read of object outside its lifetime}} \
+  // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+}
+static_assert(initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
+  // ex

[clang] 18b0d2c - [analyzer] Fix a FIXME. NFCI

2023-01-13 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2023-01-13T16:15:16+01:00
New Revision: 18b0d2c5d9762070f7c579f2e7ecaa105db7

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

LOG: [analyzer] Fix a FIXME. NFCI

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp 
b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
index 94287b7992dd9..5227766a4a405 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -35,10 +35,7 @@ using namespace ento;
 
 bool CheckerManager::hasPathSensitiveCheckers() const {
   const auto IfAnyAreNonEmpty = [](const auto &... Callbacks) -> bool {
-bool Result = false;
-// FIXME: Use fold expressions in C++17.
-LLVM_ATTRIBUTE_UNUSED int Unused[]{0, (Result |= !Callbacks.empty())...};
-return Result;
+return (!Callbacks.empty() || ...);
   };
   return IfAnyAreNonEmpty(
   StmtCheckers, PreObjCMessageCheckers, ObjCMessageNilCheckers,



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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 488999.
pmatos added a comment.

Fix tests after changing name mangling and error messages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function &F) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree &DT = getAnalysis().getDomTree();
@@ -96,6 +100,7 @@
 AU.addRequired();
 AU.setPreservesCFG();
   }
+
 };
 
 } // end anonymous namespace
@@ -111,6 +116,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_E

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

2023-01-13 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:3-35
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {

njames93 wrote:
> You can just declare these methods and the base struct, no need to do 
> anything fancy in here and put definitions in there
Ah, I picked a different test to copy/paste from which does define them 😛. Will 
fix.


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


[clang-tools-extra] e435f56 - [include-cleaner] Remove a stale FIXME.

2023-01-13 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-01-13T16:26:27+01:00
New Revision: e435f56815435422a63f5e9e9aad6959428e96c2

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

LOG: [include-cleaner] Remove a stale FIXME.

This FIXME was addressed in 0e545816a9e582af29ea4b9441fea8ed376cf52a.

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index 6a5594e3d6d35..f317b0dc2d07b 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -91,8 +91,6 @@ class ASTWalker : public RecursiveASTVisitor {
 // usage of the base type of the MemberExpr, so that e.g. code
 // `returnFoo().bar` can keep #include "foo.h" (rather than inserting
 // "bar.h" for the underlying base type `Bar`).
-//
-// FIXME: support dependent types, e.g., "std::vector().size()".
 QualType Type = E->getBase()->IgnoreImpCasts()->getType();
 report(E->getMemberLoc(), getMemberProvider(Type), RefType::Implicit);
 return true;



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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-01-13 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 489005.
pmatos added a comment.

Rename test that still had tables in its name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function &F) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree &DT = getAnalysis().getDomTree();
@@ -96,6 +100,7 @@
 AU.addRequired();
 AU.setPreservesCFG();
   }
+
 };
 
 } // end anonymous namespace
@@ -111,6 +116,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(&getWebAssemblyTargetMachine()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext 

[PATCH] D141694: [clang-format] SortUsingDeclarations support lexicographic order

2023-01-13 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght created this revision.
Backl1ght added reviewers: MyDeveloperDay, rymiel.
Backl1ght added a project: clang-format.
Herald added a project: All.
Backl1ght requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

fix https://github.com/llvm/llvm-project/issues/59930


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141694

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UsingDeclarationsSorter.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/UsingDeclarationsSorterTest.cpp

Index: clang/unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- clang/unittests/Format/UsingDeclarationsSorterTest.cpp
+++ clang/unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -41,88 +41,162 @@
 };
 
 TEST_F(UsingDeclarationsSorterTest, SwapsTwoConsecutiveUsingDeclarations) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(FormatStyle::SUD_LexicographicNumeric, Style.SortUsingDeclarations);
   EXPECT_EQ("using a;\n"
 "using b;",
 sortUsingDeclarations("using a;\n"
-  "using b;"));
+  "using b;",
+  Style));
   EXPECT_EQ("using a;\n"
 "using aa;",
 sortUsingDeclarations("using aa;\n"
-  "using a;"));
+  "using a;",
+  Style));
   EXPECT_EQ("using a;\n"
 "using ::a;",
 sortUsingDeclarations("using a;\n"
-  "using ::a;"));
+  "using ::a;",
+  Style));
 
   EXPECT_EQ("using a::bcd;\n"
 "using a::cd;",
 sortUsingDeclarations("using a::cd;\n"
-  "using a::bcd;"));
+  "using a::bcd;",
+  Style));
 
   EXPECT_EQ("using a;\n"
 "using a::a;",
 sortUsingDeclarations("using a::a;\n"
-  "using a;"));
+  "using a;",
+  Style));
 
   EXPECT_EQ("using a::ba::aa;\n"
 "using a::bb::ccc;",
 sortUsingDeclarations("using a::bb::ccc;\n"
-  "using a::ba::aa;"));
+  "using a::ba::aa;",
+  Style));
 
   EXPECT_EQ("using a;\n"
 "using typename a;",
 sortUsingDeclarations("using typename a;\n"
-  "using a;"));
+  "using a;",
+  Style));
 
   EXPECT_EQ("using typename z;\n"
 "using typenamea;",
 sortUsingDeclarations("using typenamea;\n"
-  "using typename z;"));
+  "using typename z;",
+  Style));
 
   EXPECT_EQ("using a, b;\n"
 "using aa;",
 sortUsingDeclarations("using aa;\n"
-  "using a, b;"));
+  "using a, b;",
+  Style));
+
+  Style.SortUsingDeclarations = FormatStyle::SUD_Lexicographic;
+  EXPECT_EQ("using a;\n"
+"using b;",
+sortUsingDeclarations("using a;\n"
+  "using b;",
+  Style));
+  EXPECT_EQ("using a;\n"
+"using aa;",
+sortUsingDeclarations("using aa;\n"
+  "using a;",
+  Style));
+  EXPECT_EQ("using a;\n"
+"using ::a;",
+sortUsingDeclarations("using a;\n"
+  "using ::a;",
+  Style));
+
+  EXPECT_EQ("using a::bcd;\n"
+"using a::cd;",
+sortUsingDeclarations("using a::cd;\n"
+  "using a::bcd;",
+  Style));
+
+  EXPECT_EQ("using a;\n"
+"using a::a;",
+sortUsingDeclarations("using a::a;\n"
+  "using a;",
+  Style));
+
+  EXPECT_EQ("using a::ba::aa;\n"
+"using a::bb::ccc;",
+sortUsingDeclarations("using a::bb::ccc;\n"
+  "using a::ba::aa;",
+  Style));
+
+  EXPECT_EQ("using a;\n"
+"using typename a;",
+sortUsingDeclarations("using typename a;\n"
+  "using a;",
+  Style));
+
+  EXPECT_EQ("using typename z;\n"
+"using ty

[PATCH] D141690: [clang] fix consteval ctor code generation assert

2023-01-13 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a subscriber: jyknight.
ilya-biryukov added a comment.

Sorry, didn't see your comment when submitting mine.

I think the offending code is clearly wrong here and adding the 
`isLayoutIdentical` seems like the right thing to do.

This looks like a small change and I'm happy to LGTM this myself.
However, I also have very little experience with codegen, you might want to 
find someone more experienced with it to have a more informed look. @jyknight 
maybe?




Comment at: clang/lib/CodeGen/CGCall.cpp:1338
+  llvm::StructType *STy = dyn_cast(Val->getType());
+  if (STy && 
STy->isLayoutIdentical(cast(Dest.getElementType( {
 for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {

Is it guaranteed that `Dest.getElementType()` is never something other than 
`StructType`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141690

___
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-01-13 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:3-35
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {

ccotter wrote:
> njames93 wrote:
> > You can just declare these methods and the base struct, no need to do 
> > anything fancy in here and put definitions in there
> Ah, I picked a different test to copy/paste from which does define them 😛. 
> Will fix.
Note, I think all but one existing checks end up defining a more thorough 
definition of remove_reference:

```
 git grep 'struct remove_ref' | sed -r 's/:.*//' | sort | uniq -c | sort -n
   1 modernize/use-transparent-functors.cpp
   2 cppcoreguidelines/rvalue-reference-param-not-moved.cpp
   3 bugprone/Inputs/unchecked-optional-access/absl/types/optional.h
   3 bugprone/forwarding-reference-overload.cpp
   3 misc/throw-by-value-catch-by-reference.cpp
   3 misc/unconventional-assign-operator.cpp
   3 modernize/use-emplace.cpp
   3 performance/for-range-copy.cpp
   3 performance/move-constructor-init.cpp
   4 bugprone/move-forwarding-reference.cpp
   4 bugprone/use-after-move.cpp
   4 performance/move-const-arg-const-ref.cpp
   4 performance/move-const-arg-trivially-copyable.cpp
   4 performance/move-const-arg.cpp
```


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-01-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 489007.
ccotter added a comment.

- two more tests
- Minimize test


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,222 @@
+// RUN: %check_clang_tidy -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  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]]:24: warning: rvalue reference parameter 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]]:20: warning: rvalue reference parameter 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]]:33: warning: rvalue reference parameter 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]]:25: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:35: warning: rvalue reference parameter 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]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = [&o]() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = [&o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [&o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = [&o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:25: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+// Negative tests - below functions d

[clang-tools-extra] f88c6b9 - Move definitions to prevent incomplete types.

2023-01-13 Thread Jens Massberg via cfe-commits

Author: Jens Massberg
Date: 2023-01-13T16:44:49+01:00
New Revision: f88c6b9166f885e7089cb15095e38868aaba04da

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

LOG: Move definitions to prevent incomplete types.

C++20 is more strict when erroring out due to incomplete types.
Thus the code required some restructoring so that it complies in C++20.

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

Added: 


Modified: 
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h

Removed: 




diff  --git a/clang-tools-extra/clang-doc/Representation.cpp 
b/clang-tools-extra/clang-doc/Representation.cpp
index c1279997813a8..31bb07d04b35d 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -128,6 +128,41 @@ mergeInfos(std::vector> &Values) {
   }
 }
 
+bool CommentInfo::operator==(const CommentInfo &Other) const {
+  auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
+  SelfClosing, Explicit, AttrKeys, AttrValues, Args);
+  auto SecondCI =
+  std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
+   Other.ParamName, Other.CloseName, Other.SelfClosing,
+   Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
+
+  if (FirstCI != SecondCI || Children.size() != Other.Children.size())
+return false;
+
+  return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
+llvm::deref>{});
+}
+
+bool CommentInfo::operator<(const CommentInfo &Other) const {
+  auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
+  SelfClosing, Explicit, AttrKeys, AttrValues, Args);
+  auto SecondCI =
+  std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
+   Other.ParamName, Other.CloseName, Other.SelfClosing,
+   Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
+
+  if (FirstCI < SecondCI)
+return true;
+
+  if (FirstCI == SecondCI) {
+return std::lexicographical_compare(
+Children.begin(), Children.end(), Other.Children.begin(),
+Other.Children.end(), llvm::deref>());
+  }
+
+  return false;
+}
+
 static llvm::SmallString<64>
 calculateRelativeFilePath(const InfoType &Type, const StringRef &Path,
   const StringRef &Name, const StringRef &CurrentPath) 
{
@@ -220,6 +255,9 @@ void SymbolInfo::merge(SymbolInfo &&Other) {
   mergeBase(std::move(Other));
 }
 
+NamespaceInfo::NamespaceInfo(SymbolID USR, StringRef Name, StringRef Path)
+  : Info(InfoType::IT_namespace, USR, Name, Path) {}
+
 void NamespaceInfo::merge(NamespaceInfo &&Other) {
   assert(mergeable(Other));
   // Reduce children if necessary.
@@ -231,6 +269,9 @@ void NamespaceInfo::merge(NamespaceInfo &&Other) {
   mergeBase(std::move(Other));
 }
 
+RecordInfo::RecordInfo(SymbolID USR, StringRef Name, StringRef Path)
+: SymbolInfo(InfoType::IT_record, USR, Name, Path) {}
+
 void RecordInfo::merge(RecordInfo &&Other) {
   assert(mergeable(Other));
   if (!TagType)
@@ -289,6 +330,14 @@ void TypedefInfo::merge(TypedefInfo &&Other) {
   SymbolInfo::merge(std::move(Other));
 }
 
+BaseRecordInfo::BaseRecordInfo() : RecordInfo() {}
+
+BaseRecordInfo::BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path,
+   bool IsVirtual, AccessSpecifier Access,
+   bool IsParent)
+: RecordInfo(USR, Name, Path), IsVirtual(IsVirtual), Access(Access),
+  IsParent(IsParent) {}
+
 llvm::SmallString<16> Info::extractName() const {
   if (!Name.empty())
 return Name;

diff  --git a/clang-tools-extra/clang-doc/Representation.h 
b/clang-tools-extra/clang-doc/Representation.h
index 564488ceb027f..15e1abf858aaa 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -52,44 +52,13 @@ struct CommentInfo {
   CommentInfo(CommentInfo &&Other) = default;
   CommentInfo &operator=(CommentInfo &&Other) = default;
 
-  bool operator==(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI != SecondCI || Children.size() != Other.Children.size())
-  return false;
-
-return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
-  llvm::deref>{});

[PATCH] D141671: Move definitions to prevent incomplete types.

2023-01-13 Thread Jens Massberg 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 rGf88c6b9166f8: Move definitions to prevent incomplete types. 
(authored by massberg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141671

Files:
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h

Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -52,44 +52,13 @@
   CommentInfo(CommentInfo &&Other) = default;
   CommentInfo &operator=(CommentInfo &&Other) = default;
 
-  bool operator==(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI != SecondCI || Children.size() != Other.Children.size())
-  return false;
-
-return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
-  llvm::deref>{});
-  }
+  bool operator==(const CommentInfo &Other) const;
 
   // This operator is used to sort a vector of CommentInfos.
   // No specific order (attributes more important than others) is required. Any
   // sort is enough, the order is only needed to call std::unique after sorting
   // the vector.
-  bool operator<(const CommentInfo &Other) const {
-auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
-SelfClosing, Explicit, AttrKeys, AttrValues, Args);
-auto SecondCI =
-std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
- Other.ParamName, Other.CloseName, Other.SelfClosing,
- Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
-
-if (FirstCI < SecondCI)
-  return true;
-
-if (FirstCI == SecondCI) {
-  return std::lexicographical_compare(
-  Children.begin(), Children.end(), Other.Children.begin(),
-  Other.Children.end(), llvm::deref>());
-}
-
-return false;
-  }
+  bool operator<(const CommentInfo &Other) const;
 
   SmallString<16>
   Kind; // Kind of comment (FullComment, ParagraphComment, TextComment,
@@ -330,8 +299,7 @@
 // Info for namespaces.
 struct NamespaceInfo : public Info {
   NamespaceInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
-StringRef Path = StringRef())
-  : Info(InfoType::IT_namespace, USR, Name, Path) {}
+StringRef Path = StringRef());
 
   void merge(NamespaceInfo &&I);
 
@@ -381,8 +349,7 @@
 // Info for types.
 struct RecordInfo : public SymbolInfo {
   RecordInfo(SymbolID USR = SymbolID(), StringRef Name = StringRef(),
- StringRef Path = StringRef())
-  : SymbolInfo(InfoType::IT_record, USR, Name, Path) {}
+ StringRef Path = StringRef());
 
   void merge(RecordInfo &&I);
 
@@ -434,11 +401,9 @@
 };
 
 struct BaseRecordInfo : public RecordInfo {
-  BaseRecordInfo() : RecordInfo() {}
+  BaseRecordInfo();
   BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path, bool IsVirtual,
- AccessSpecifier Access, bool IsParent)
-  : RecordInfo(USR, Name, Path), IsVirtual(IsVirtual), Access(Access),
-IsParent(IsParent) {}
+ AccessSpecifier Access, bool IsParent);
 
   // Indicates if base corresponds to a virtual inheritance
   bool IsVirtual = false;
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -128,6 +128,41 @@
   }
 }
 
+bool CommentInfo::operator==(const CommentInfo &Other) const {
+  auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
+  SelfClosing, Explicit, AttrKeys, AttrValues, Args);
+  auto SecondCI =
+  std::tie(Other.Kind, Other.Text, Other.Name, Other.Direction,
+   Other.ParamName, Other.CloseName, Other.SelfClosing,
+   Other.Explicit, Other.AttrKeys, Other.AttrValues, Other.Args);
+
+  if (FirstCI != SecondCI || Children.size() != Other.Children.size())
+return false;
+
+  return std::equal(Children.begin(), Children.end(), Other.Children.begin(),
+llvm::deref>{});
+}
+
+bool CommentInfo::operator<(const CommentInfo &Other) const {
+  auto FirstCI = std::tie(Kind, Text, Name, Direction, ParamName, CloseName,
+  Self

  1   2   3   >