[PATCH] D156045: [clang][Interp] Enable existing source_location tests

2023-09-09 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

@tbaeder Now it's working correctly. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156045

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


[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-09-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 556339.
tbaeder marked 4 inline comments as done.

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

https://reviews.llvm.org/D156400

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/class-layout.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/SemaCXX/class-layout.cpp
  clang/test/SemaCXX/offsetof-0x.cpp
  clang/test/SemaCXX/offsetof.cpp

Index: clang/test/SemaCXX/offsetof.cpp
===
--- clang/test/SemaCXX/offsetof.cpp
+++ clang/test/SemaCXX/offsetof.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98 -fexperimental-new-constant-interpreter
 
 struct NonPOD {
   virtual void f();
Index: clang/test/SemaCXX/offsetof-0x.cpp
===
--- clang/test/SemaCXX/offsetof-0x.cpp
+++ clang/test/SemaCXX/offsetof-0x.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof -fexperimental-new-constant-interpreter
 
 struct NonPOD {
   virtual void f();
Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -14,6 +14,25 @@
 // RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
 // RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
 
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-apple-darwin%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-scei-ps4%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-sie-ps5 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+
+
+
+
 // expected-no-diagnostics
 
 #if !defined(__MVS__) && !defined(_AIX)
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -933,6 +933,7 @@
 (s

[PATCH] D157911: clang: Add __builtin_exp10* and use new llvm.exp10 intrinsic

2023-09-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 556343.
arsenm added a comment.

Release notes


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

https://reviews.llvm.org/D157911

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGenOpenCL/builtins-f16.cl

Index: clang/test/CodeGenOpenCL/builtins-f16.cl
===
--- clang/test/CodeGenOpenCL/builtins-f16.cl
+++ clang/test/CodeGenOpenCL/builtins-f16.cl
@@ -24,6 +24,9 @@
   // CHECK: call half @llvm.exp2.f16(half %h0)
   res = __builtin_exp2f16(h0);
 
+  // CHECK: call half @llvm.exp10.f16(half %h0)
+  res = __builtin_exp10f16(h0);
+
   // CHECK: call half @llvm.floor.f16(half %h0)
   res = __builtin_floorf16(h0);
 
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -318,6 +318,17 @@
 // HAS_ERRNO: declare x86_fp80 @exp2l(x86_fp80 noundef) [[NOT_READNONE]]
 // HAS_ERRNO: declare fp128 @exp2f128(fp128 noundef) [[NOT_READNONE]]
 
+__builtin_exp10(f);   __builtin_exp10f(f);  __builtin_exp10l(f); __builtin_exp10f128(f);
+
+// NO__ERRNO: declare double @llvm.exp10.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.exp10.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.exp10.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare fp128 @llvm.exp10.f128(fp128) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare double @exp10(double noundef) [[NOT_READNONE]]
+// HAS_ERRNO: declare float @exp10f(float noundef) [[NOT_READNONE]]
+// HAS_ERRNO: declare x86_fp80 @exp10l(x86_fp80 noundef) [[NOT_READNONE]]
+// HAS_ERRNO: declare fp128 @exp10f128(fp128 noundef) [[NOT_READNONE]]
+
 __builtin_expm1(f);  __builtin_expm1f(f); __builtin_expm1l(f); __builtin_expm1f128(f);
 
 // NO__ERRNO: declare double @expm1(double noundef) [[READNONE]]
Index: clang/test/CodeGen/constrained-math-builtins.c
===
--- clang/test/CodeGen/constrained-math-builtins.c
+++ clang/test/CodeGen/constrained-math-builtins.c
@@ -64,6 +64,13 @@
 // CHECK: call x86_fp80 @llvm.experimental.constrained.exp2.f80(x86_fp80 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
 // CHECK: call fp128 @llvm.experimental.constrained.exp2.f128(fp128 %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
 
+  __builtin_exp10(f);   __builtin_exp10f(f);  __builtin_exp10l(f); __builtin_exp10f128(f);
+
+// CHECK: call double @exp10(double noundef %{{.*}})
+// CHECK: call float @exp10f(float noundef %{{.*}})
+// CHECK: call x86_fp80 @exp10l(x86_fp80 noundef %{{.*}})
+// CHECK: call fp128 @exp10f128(fp128 noundef %{{.*}})
+
   __builtin_floor(f);  __builtin_floorf(f); __builtin_floorl(f); __builtin_floorf128(f);
 
 // CHECK: call double @llvm.experimental.constrained.floor.f64(double %{{.*}}, metadata !"fpexcept.strict")
@@ -223,6 +230,11 @@
 // CHECK: declare x86_fp80 @llvm.experimental.constrained.exp2.f80(x86_fp80, metadata, metadata)
 // CHECK: declare fp128 @llvm.experimental.constrained.exp2.f128(fp128, metadata, metadata)
 
+// CHECK: declare double @exp10(double noundef)
+// CHECK: declare float @exp10f(float noundef)
+// CHECK: declare x86_fp80 @exp10l(x86_fp80 noundef)
+// CHECK: declare fp128 @exp10f128(fp128 noundef)
+
 // CHECK: declare double @llvm.experimental.constrained.floor.f64(double, metadata)
 // CHECK: declare float @llvm.experimental.constrained.floor.f32(float, metadata)
 // CHECK: declare x86_fp80 @llvm.experimental.constrained.floor.f80(x86_fp80, metadata)
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2433,7 +2433,16 @@
   return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
Intrinsic::exp2,
Intrinsic::experimental_constrained_exp2));
-
+case Builtin::BI__builtin_exp10:
+case Builtin::BI__builtin_exp10f:
+case Builtin::BI__builtin_exp10f16:
+case Builtin::BI__builtin_exp10l:
+case Builtin::BI__builtin_exp10f128: {
+  // TODO: strictfp support
+  if (Builder.getIsFPConstrained())
+break;
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10));
+}
 case Builtin::BIfabs:
 case Builtin::BIfabsf:
 case Builtin::BIfabsl:
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -245,6 +245,11 @@
 BUILTIN(__builtin_exp2f16, "hh"  , "Fne")
 BUILTIN(__builtin_ex

[clang] [Driver] Replace usage of -Bshareable linker flag with -shared (PR #65842)

2023-09-09 Thread Brad Smith via cfe-commits

https://github.com/brad0 created 
https://github.com/llvm/llvm-project/pull/65842:

The two flags mean the same thing for the bfd / lld linkers so just use the 
same flag consistently everywhere.

>From 42f0ede652ebf38cb21fb07549e3dfcbbd43f3d1 Mon Sep 17 00:00:00 2001
From: Brad Smith 
Date: Sat, 9 Sep 2023 03:43:57 -0400
Subject: [PATCH] [Driver] Replace usage of -Bshareable linker flag with
 -shared

The two flags mean the same thing for the bfd / lld linkers so just
use the same flag consistently everywhere.
---
 clang/lib/Driver/ToolChains/DragonFly.cpp |  2 +-
 clang/lib/Driver/ToolChains/FreeBSD.cpp   |  2 +-
 clang/lib/Driver/ToolChains/NetBSD.cpp|  2 +-
 clang/test/Driver/netbsd.c| 12 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 6f46864105e9c0c..900be9e305c902a 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -69,7 +69,7 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 if (Args.hasArg(options::OPT_shared))
-  CmdArgs.push_back("-Bshareable");
+  CmdArgs.push_back("-shared");
 else if (!Args.hasArg(options::OPT_r)) {
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/usr/libexec/ld-elf.so.2");
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index b6e025aac29b046..4c46861bbbd74ef 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -161,7 +161,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 if (Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-Bshareable");
+  CmdArgs.push_back("-shared");
 } else if (!Args.hasArg(options::OPT_r)) {
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/libexec/ld-elf.so.1");
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index ceabb06c14105b3..1ec8f1b7da4c662 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -139,7 +139,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 if (Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-Bshareable");
+  CmdArgs.push_back("-shared");
 } else if (!Args.hasArg(options::OPT_r)) {
   Args.AddAllArgs(CmdArgs, options::OPT_pie);
   CmdArgs.push_back("-dynamic-linker");
diff --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 4daa35a4a7f94fc..67c048c6e91515f 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -116,20 +116,20 @@
 
 // STATIC: ld{{.*}}" "--eh-frame-hdr"
 // STATIC-NOT: "-pie"
-// STATIC-NOT: "-Bshareable"
+// STATIC-NOT: "-shared"
 // STATIC: "-dynamic-linker" "/libexec/ld.elf_so"
 // STATIC-NOT: "-pie"
-// STATIC-NOT: "-Bshareable"
+// STATIC-NOT: "-shared"
 // STATIC: "{{.*}}/usr/lib{{/|}}crt0.o"
 // STATIC: "{{.*}}/usr/lib{{/|}}crti.o" 
"{{.*}}/usr/lib{{/|}}crtbegin.o"
 // STATIC: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // STATIC-PIE: ld{{.*}}" "--eh-frame-hdr"
 // STATIC-PIE-NOT: "-dynamic-linker" "/libexec/ld.elf_so"
-// STATIC-PIE-NOT: "-Bshareable"
+// STATIC-PIE-NOT: "-shared"
 // STATIC-PIE: "-pie"
 // STATIC-PIE-NOT: "-dynamic-linker" "/libexec/ld.elf_so"
-// STATIC-PIE-NOT: "-Bshareable"
+// STATIC-PIE-NOT: "-shared"
 // STATIC-PIE: "{{.*}}/usr/lib{{/|}}crt0.o"
 // STATIC-PIE: "{{.*}}/usr/lib{{/|}}crti.o" 
"{{.*}}/usr/lib{{/|}}crtbeginS.o"
 // STATIC-PIE: "{{.*}}/usr/lib{{/|}}crtendS.o" 
"{{.*}}/usr/lib{{/|}}crtn.o"
@@ -142,9 +142,9 @@
 // SHARED: "{{.*}}/usr/lib{{/|}}crtendS.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // PIE: ld{{.*}}" "--eh-frame-hdr"
-// PIE-NOT: "-Bshareable"
+// PIE-NOT: "-shared"
 // PIE: "-pie" "-dynamic-linker" "/libexec/ld.elf_so"
-// PIE-NOT: "-Bshareable"
+// PIE-NOT: "-shared"
 // PIE: "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
 // PIE: "{{.*}}/usr/lib{{/|}}crtbeginS.o"
 // PIE: "{{.*}}/usr/lib{{/|}}crtendS.o"

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


[clang] [Driver] Replace usage of -Bshareable linker flag with -shared (PR #65842)

2023-09-09 Thread Brad Smith via cfe-commits

https://github.com/brad0 review_requested 
https://github.com/llvm/llvm-project/pull/65842
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Replace usage of -Bshareable linker flag with -shared (PR #65842)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65842
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Replace usage of -Bshareable linker flag with -shared (PR #65842)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65842
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Replace usage of -Bshareable linker flag with -shared (PR #65842)

2023-09-09 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

The two flags mean the same thing for the bfd / lld linkers so just use the 
same flag consistently everywhere.
--
Full diff: https://github.com/llvm/llvm-project/pull/65842.diff

4 Files Affected:

- (modified) clang/lib/Driver/ToolChains/DragonFly.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/FreeBSD.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/NetBSD.cpp (+1-1) 
- (modified) clang/test/Driver/netbsd.c (+6-6) 



diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp 
b/clang/lib/Driver/ToolChains/DragonFly.cpp
index 6f46864105e9c0c..900be9e305c902a 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -69,7 +69,7 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 if (Args.hasArg(options::OPT_shared))
-  CmdArgs.push_back("-Bshareable");
+  CmdArgs.push_back("-shared");
 else if (!Args.hasArg(options::OPT_r)) {
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/usr/libexec/ld-elf.so.2");
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index b6e025aac29b046..4c46861bbbd74ef 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -161,7 +161,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 if (Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-Bshareable");
+  CmdArgs.push_back("-shared");
 } else if (!Args.hasArg(options::OPT_r)) {
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/libexec/ld-elf.so.1");
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index ceabb06c14105b3..1ec8f1b7da4c662 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -139,7 +139,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 if (Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-Bshareable");
+  CmdArgs.push_back("-shared");
 } else if (!Args.hasArg(options::OPT_r)) {
   Args.AddAllArgs(CmdArgs, options::OPT_pie);
   CmdArgs.push_back("-dynamic-linker");
diff --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 4daa35a4a7f94fc..67c048c6e91515f 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -116,20 +116,20 @@
 
 // STATIC: ld{{.*}}" "--eh-frame-hdr"
 // STATIC-NOT: "-pie"
-// STATIC-NOT: "-Bshareable"
+// STATIC-NOT: "-shared"
 // STATIC: "-dynamic-linker" "/libexec/ld.elf_so"
 // STATIC-NOT: "-pie"
-// STATIC-NOT: "-Bshareable"
+// STATIC-NOT: "-shared"
 // STATIC: "{{.*}}/usr/lib{{/|}}crt0.o"
 // STATIC: "{{.*}}/usr/lib{{/|}}crti.o" 
"{{.*}}/usr/lib{{/|}}crtbegin.o"
 // STATIC: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // STATIC-PIE: ld{{.*}}" "--eh-frame-hdr"
 // STATIC-PIE-NOT: "-dynamic-linker" "/libexec/ld.elf_so"
-// STATIC-PIE-NOT: "-Bshareable"
+// STATIC-PIE-NOT: "-shared"
 // STATIC-PIE: "-pie"
 // STATIC-PIE-NOT: "-dynamic-linker" "/libexec/ld.elf_so"
-// STATIC-PIE-NOT: "-Bshareable"
+// STATIC-PIE-NOT: "-shared"
 // STATIC-PIE: "{{.*}}/usr/lib{{/|}}crt0.o"
 // STATIC-PIE: "{{.*}}/usr/lib{{/|}}crti.o" 
"{{.*}}/usr/lib{{/|}}crtbeginS.o"
 // STATIC-PIE: "{{.*}}/usr/lib{{/|}}crtendS.o" 
"{{.*}}/usr/lib{{/|}}crtn.o"
@@ -142,9 +142,9 @@
 // SHARED: "{{.*}}/usr/lib{{/|}}crtendS.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // PIE: ld{{.*}}" "--eh-frame-hdr"
-// PIE-NOT: "-Bshareable"
+// PIE-NOT: "-shared"
 // PIE: "-pie" "-dynamic-linker" "/libexec/ld.elf_so"
-// PIE-NOT: "-Bshareable"
+// PIE-NOT: "-shared"
 // PIE: "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
 // PIE: "{{.*}}/usr/lib{{/|}}crtbeginS.o"
 // PIE: "{{.*}}/usr/lib{{/|}}crtendS.o"




https://github.com/llvm/llvm-project/pull/65842
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139277: [clangd] Use all query-driver arguments in cache key

2023-09-09 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

This was superseded by D146941 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139277

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


[PATCH] D159138: [clang][Sema] Fix format size estimator's handling of %o, %x, %X with alternative form

2023-09-09 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet marked 4 inline comments as done.
hazohelet added a comment.

Thanks for the review!




Comment at: clang/docs/ReleaseNotes.rst:125
 * ``-Woverriding-t-option`` is renamed to ``-Woverriding-option``.
 * ``-Winterrupt-service-routine`` is renamed to ``-Wexcessive-regsave`` as a 
generalization
 

serge-sans-paille wrote:
> ??
I'm not seeing any diff around here, so perhaps you were seeing some 
Phabricator bug?



Comment at: clang/test/Sema/warn-fortify-source.c:100-102
+  __builtin_snprintf(buf, 2, "%#x", n);
+  __builtin_snprintf(buf, 2, "%#X", n);
+  __builtin_snprintf(buf, 2, "%#o", n);

nickdesaulniers wrote:
> hazohelet wrote:
> > nickdesaulniers wrote:
> > > Note that GCC -Wformat-truncation can warn on some of these.
> > > 
> > > https://godbolt.org/z/jE3axWe1W
> > > 
> > > Looks like the diagnostic keeps an up and lower bounds on the estimated 
> > > format string expansion.
> > > 
> > > Trunk for Clang also warns for these, so is this change a regression? Or 
> > > are both GCC and Clang (trunk) incorrect?
> > Clang trunk is saying something factually incorrect because it says the 
> > output `will always be truncated`, when in fact `__builtin_snprintf(buf, 2, 
> > "%#x", n);` doesn't trigger truncation if `n` is zero.
> > 
> > GCC is correct but is more conservative than clang's `ALWAYS be truncated` 
> > diagnostics.
> > GCC's warning message is `... directive output MAY BE truncated` .
> > GCC doesn't warn on it when `n` is known to be zero. 
> > (https://godbolt.org/z/E51a3Pfhr)
> > 
> > GCC's behavior makes sense here because the truncation does happen whenever 
> > `n` is not zero. If the user knows `n` is zero then they have no reason to 
> > use `%#x` specifier.
> > So, I think it makes sense to assume `n` is not zero and emit diagnostics, 
> > but it definitely needs diagnostics rewording like `is likely to be 
> > truncated`.
> I see; thanks for the explanation. Sorry for the code review delay; I missed 
> this comment in my inbox.
As a future plan, I think it's generally good to follow GCC's behavior 
regarding this format warning considering GCC's high smartness on it.
I want to emit some warning here like GCC does because users are highly likely 
to expect non-zero value to be printed, but I think it's reasonable to defer it 
for now because it's not ideal to add a new warning flag when we are 
considering changing this warning's flag from `Wfortify-source` to 
`Wformat-truncation`


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

https://reviews.llvm.org/D159138

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


[PATCH] D157526: [clang][Sema] Remove irrelevant diagnostics from constraint satisfaction failure

2023-09-09 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

When I first ran `git clang-format` locally, it somehow forced 4-space indent.
After starting to use clang-format from the trunk, I haven't seen the 
suspicious behavior locally, but the CI format check failure might be caused by 
that.
The format seems okay as-is, so I'll push this change without addressing the CI 
clang-format failure.


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

https://reviews.llvm.org/D157526

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


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr review_requested 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr review_requested 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr review_requested 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/65844:

This adds `IntegralAP` backing the two new primtypes `IntAP` (unsinged 
arbitrary-precision int) and `IntAPS` (same but signed).

We use this for `int128` support (which isn't available on all host systems we 
support AFAIK) and I think we can also use this for `_BitInt` later.

>From 4e49f66c7bc814510f2dc923129eab8bcca5eca0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sat, 9 Sep 2023 10:34:26 +0200
Subject: [PATCH] [clang][Interp] Add IntegralAP for arbitrary-precision
 integers

---
 clang/lib/AST/Interp/ByteCodeExprGen.cpp |  11 +-
 clang/lib/AST/Interp/Context.cpp |   6 +-
 clang/lib/AST/Interp/Descriptor.cpp  |   9 +
 clang/lib/AST/Interp/EvalEmitter.cpp |   1 +
 clang/lib/AST/Interp/Integral.h  |   4 +
 clang/lib/AST/Interp/IntegralAP.h| 253 +++
 clang/lib/AST/Interp/Interp.h|  21 +-
 clang/lib/AST/Interp/InterpStack.h   |   5 +
 clang/lib/AST/Interp/Opcodes.td  |   8 +-
 clang/lib/AST/Interp/PrimType.cpp|   1 +
 clang/lib/AST/Interp/PrimType.h  |  13 ++
 clang/test/AST/Interp/literals.cpp   |  24 +++
 12 files changed, 343 insertions(+), 13 deletions(-)
 create mode 100644 clang/lib/AST/Interp/IntegralAP.h

diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 17cf15d8676eb86..ec2ece71b301382 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -171,14 +171,17 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 return this->discard(SubExpr);
 std::optional FromT = classify(SubExpr->getType());
 std::optional ToT = classify(CE->getType());
+
 if (!FromT || !ToT)
   return false;
 
 if (!this->visit(SubExpr))
   return false;
 
-if (FromT == ToT)
+if (FromT == ToT) {
+  assert(ToT != PT_IntAP && ToT != PT_IntAPS);
   return true;
+}
 
 return this->emitCast(*FromT, *ToT, CE);
   }
@@ -1548,6 +1551,9 @@ bool 
ByteCodeExprGen::visitZeroInitializer(QualType QT,
 return this->emitZeroSint64(E);
   case PT_Uint64:
 return this->emitZeroUint64(E);
+  case PT_IntAP:
+  case PT_IntAPS:
+assert(false);
   case PT_Ptr:
 return this->emitNullPtr(E);
   case PT_FnPtr:
@@ -1787,6 +1793,9 @@ bool ByteCodeExprGen::emitConst(T Value, 
PrimType Ty, const Expr *E) {
 return this->emitConstSint64(Value, E);
   case PT_Uint64:
 return this->emitConstUint64(Value, E);
+  case PT_IntAP:
+  case PT_IntAPS:
+assert(false);
   case PT_Bool:
 return this->emitConstBool(Value, E);
   case PT_Ptr:
diff --git a/clang/lib/AST/Interp/Context.cpp b/clang/lib/AST/Interp/Context.cpp
index 1a732b6c1a092ac..ed2b23514e86665 100644
--- a/clang/lib/AST/Interp/Context.cpp
+++ b/clang/lib/AST/Interp/Context.cpp
@@ -102,7 +102,8 @@ std::optional Context::classify(QualType T) const 
{
 case 8:
   return PT_Sint8;
 default:
-  return std::nullopt;
+  return PT_IntAPS;
+  // return std::nullopt;
 }
   }
 
@@ -117,7 +118,8 @@ std::optional Context::classify(QualType T) const 
{
 case 8:
   return PT_Uint8;
 default:
-  return std::nullopt;
+  return PT_IntAP;
+  // return std::nullopt;
 }
   }
 
diff --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index db49a569eff33ea..4ecb7466998e705 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -10,6 +10,7 @@
 #include "Boolean.h"
 #include "Floating.h"
 #include "FunctionPointer.h"
+#include "IntegralAP.h"
 #include "Pointer.h"
 #include "PrimType.h"
 #include "Record.h"
@@ -182,6 +183,10 @@ static BlockCtorFn getCtorPrim(PrimType Type) {
   // constructor called.
   if (Type == PT_Float)
 return ctorTy::T>;
+  if (Type == PT_IntAP)
+return ctorTy::T>;
+  if (Type == PT_IntAPS)
+return ctorTy::T>;
 
   COMPOSITE_TYPE_SWITCH(Type, return ctorTy, return nullptr);
 }
@@ -191,6 +196,10 @@ static BlockDtorFn getDtorPrim(PrimType Type) {
   // destructor called, since they might allocate memory.
   if (Type == PT_Float)
 return dtorTy::T>;
+  if (Type == PT_IntAP)
+return dtorTy::T>;
+  if (Type == PT_IntAPS)
+return dtorTy::T>;
 
   COMPOSITE_TYPE_SWITCH(Type, return dtorTy, return nullptr);
 }
diff --git a/clang/lib/AST/Interp/EvalEmitter.cpp 
b/clang/lib/AST/Interp/EvalEmitter.cpp
index d26ee8e40a437b9..c9332d8b2364fa1 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -8,6 +8,7 @@
 
 #include "EvalEmitter.h"
 #include "Context.h"
+#include "IntegralAP.h"
 #include "Interp.h"
 #include "Opcode.h"
 #include "Program.h"
diff --git a/clang/lib/AST/Interp/Integral.h b/clang/lib/AST/Interp/Integral.h
index 8d5edbb5b764eda..20c632cbac3f096 100644
--- a/clang/lib/AST/Interp/Integral.h
+++ b/clang/lib/AST/Interp/Inte

[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr review_requested 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr review_requested 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

This adds `IntegralAP` backing the two new primtypes `IntAP` (unsinged 
arbitrary-precision int) and `IntAPS` (same but signed).

We use this for `int128` support (which isn't available on all host systems we 
support AFAIK) and I think we can also use this for `_BitInt` later.
--

Patch is 20.14 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/65844.diff

12 Files Affected:

- (modified) clang/lib/AST/Interp/ByteCodeExprGen.cpp (+10-1) 
- (modified) clang/lib/AST/Interp/Context.cpp (+4-2) 
- (modified) clang/lib/AST/Interp/Descriptor.cpp (+9) 
- (modified) clang/lib/AST/Interp/EvalEmitter.cpp (+1) 
- (modified) clang/lib/AST/Interp/Integral.h (+4) 
- (added) clang/lib/AST/Interp/IntegralAP.h (+253) 
- (modified) clang/lib/AST/Interp/Interp.h (+14-7) 
- (modified) clang/lib/AST/Interp/InterpStack.h (+5) 
- (modified) clang/lib/AST/Interp/Opcodes.td (+5-3) 
- (modified) clang/lib/AST/Interp/PrimType.cpp (+1) 
- (modified) clang/lib/AST/Interp/PrimType.h (+13) 
- (modified) clang/test/AST/Interp/literals.cpp (+24) 



diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 17cf15d8676eb8..ec2ece71b30138 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -171,14 +171,17 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 return this->discard(SubExpr);
 std::optional FromT = classify(SubExpr->getType());
 std::optional ToT = classify(CE->getType());
+
 if (!FromT || !ToT)
   return false;
 
 if (!this->visit(SubExpr))
   return false;
 
-if (FromT == ToT)
+if (FromT == ToT) {
+  assert(ToT != PT_IntAP && ToT != PT_IntAPS);
   return true;
+}
 
 return this->emitCast(*FromT, *ToT, CE);
   }
@@ -1548,6 +1551,9 @@ bool 
ByteCodeExprGen::visitZeroInitializer(QualType QT,
 return this->emitZeroSint64(E);
   case PT_Uint64:
 return this->emitZeroUint64(E);
+  case PT_IntAP:
+  case PT_IntAPS:
+assert(false);
   case PT_Ptr:
 return this->emitNullPtr(E);
   case PT_FnPtr:
@@ -1787,6 +1793,9 @@ bool ByteCodeExprGen::emitConst(T Value, 
PrimType Ty, const Expr *E) {
 return this->emitConstSint64(Value, E);
   case PT_Uint64:
 return this->emitConstUint64(Value, E);
+  case PT_IntAP:
+  case PT_IntAPS:
+assert(false);
   case PT_Bool:
 return this->emitConstBool(Value, E);
   case PT_Ptr:
diff --git a/clang/lib/AST/Interp/Context.cpp b/clang/lib/AST/Interp/Context.cpp
index 1a732b6c1a092a..ed2b23514e8666 100644
--- a/clang/lib/AST/Interp/Context.cpp
+++ b/clang/lib/AST/Interp/Context.cpp
@@ -102,7 +102,8 @@ std::optional Context::classify(QualType T) const 
{
 case 8:
   return PT_Sint8;
 default:
-  return std::nullopt;
+  return PT_IntAPS;
+  // return std::nullopt;
 }
   }
 
@@ -117,7 +118,8 @@ std::optional Context::classify(QualType T) const 
{
 case 8:
   return PT_Uint8;
 default:
-  return std::nullopt;
+  return PT_IntAP;
+  // return std::nullopt;
 }
   }
 
diff --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index db49a569eff33e..4ecb7466998e70 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -10,6 +10,7 @@
 #include "Boolean.h"
 #include "Floating.h"
 #include "FunctionPointer.h"
+#include "IntegralAP.h"
 #include "Pointer.h"
 #include "PrimType.h"
 #include "Record.h"
@@ -182,6 +183,10 @@ static BlockCtorFn getCtorPrim(PrimType Type) {
   // constructor called.
   if (Type == PT_Float)
 return ctorTy::T>;
+  if (Type == PT_IntAP)
+return ctorTy::T>;
+  if (Type == PT_IntAPS)
+return ctorTy::T>;
 
   COMPOSITE_TYPE_SWITCH(Type, return ctorTy, return nullptr);
 }
@@ -191,6 +196,10 @@ static BlockDtorFn getDtorPrim(PrimType Type) {
   // destructor called, since they might allocate memory.
   if (Type == PT_Float)
 return dtorTy::T>;
+  if (Type == PT_IntAP)
+return dtorTy::T>;
+  if (Type == PT_IntAPS)
+return dtorTy::T>;
 
   COMPOSITE_TYPE_SWITCH(Type, return dtorTy, return nullptr);
 }
diff --git a/clang/lib/AST/Interp/EvalEmitter.cpp 
b/clang/lib/AST/Interp/EvalEmitter.cpp
index d26ee8e40a437b..c9332d8b2364fa 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -8,6 +8,7 @@
 
 #include "EvalEmitter.h"
 #include "Context.h"
+#include "IntegralAP.h"
 #include "Interp.h"
 #include "Opcode.h"
 #include "Program.h"
diff --git a/clang/lib/AST/Interp/Integral.h b/clang/lib/AST/Interp/Integral.h
index 8d5edbb5b764ed..20c632cbac3f09 100644
--- a/clang/lib/AST/Interp/Integral.h
+++ b/clang/lib/AST/Interp/Integral.h
@@ -29,6 +29,8 @@ namespace interp {
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
+template  class IntegralAP;
+
 // Helper structure to select the representation.
 template  struct Repr;
 template

[clang] 39db3b0 - [clang][Interp][NFC] Remove unused Integral::from() overload

2023-09-09 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-09-09T11:07:55+02:00
New Revision: 39db3b097a9b41bf5798209916cc54eecef40eee

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

LOG: [clang][Interp][NFC] Remove unused Integral::from() overload

Added: 


Modified: 
clang/lib/AST/Interp/Integral.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Integral.h b/clang/lib/AST/Interp/Integral.h
index 8d5edbb5b764eda..72285cabcbbf8ce 100644
--- a/clang/lib/AST/Interp/Integral.h
+++ b/clang/lib/AST/Interp/Integral.h
@@ -165,13 +165,6 @@ template  class Integral final 
{
 return Integral(Value.V);
   }
 
-  template  static Integral from(Integral<0, SrcSign> Value) {
-if constexpr (SrcSign)
-  return Integral(Value.V.getSExtValue());
-else
-  return Integral(Value.V.getZExtValue());
-  }
-
   static Integral zero() { return from(0); }
 
   template  static Integral from(T Value, unsigned NumBits) {



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


[clang] 38c7230 - [clang][Interp][NFC] Remove unused Boolean::from() overload

2023-09-09 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-09-09T11:07:55+02:00
New Revision: 38c723064530fa3b2e6960e601b6905529b4a32e

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

LOG: [clang][Interp][NFC] Remove unused Boolean::from() overload

Added: 


Modified: 
clang/lib/AST/Interp/Boolean.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Boolean.h b/clang/lib/AST/Interp/Boolean.h
index 579842ce46aa04e..6f0fe26ace68807 100644
--- a/clang/lib/AST/Interp/Boolean.h
+++ b/clang/lib/AST/Interp/Boolean.h
@@ -100,11 +100,6 @@ class Boolean final {
 return Boolean(!Value.isZero());
   }
 
-  template 
-  static Boolean from(Integral<0, SrcSign> Value) {
-return Boolean(!Value.isZero());
-  }
-
   static Boolean zero() { return from(false); }
 
   template 



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


[clang] 211f7dd - [clang][Interp][NFC] Tiny indentation fix

2023-09-09 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-09-09T11:07:55+02:00
New Revision: 211f7ddbe14b4486084882b02e70352b944f6286

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

LOG: [clang][Interp][NFC] Tiny indentation fix

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 17cf15d8676eb86..62575ce0d84b8f8 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -167,8 +167,8 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr 
*CE) {
 
   case CK_IntegralToBoolean:
   case CK_IntegralCast: {
-  if (DiscardResult)
-return this->discard(SubExpr);
+if (DiscardResult)
+  return this->discard(SubExpr);
 std::optional FromT = classify(SubExpr->getType());
 std::optional ToT = classify(CE->getType());
 if (!FromT || !ToT)



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


[clang] 2744d9b - [clang][Interp][NFC] Use delegate() vor ParenExprs

2023-09-09 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-09-09T11:07:56+02:00
New Revision: 2744d9b649f79a3f1021164e73b3a4d729cd1963

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

LOG: [clang][Interp][NFC] Use delegate() vor ParenExprs

Now what we have delegate() we can use it here.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 62575ce0d84b8f8..6a492c4c907cde0 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -222,13 +222,8 @@ bool ByteCodeExprGen::VisitFloatingLiteral(const 
FloatingLiteral *E) {
 }
 
 template 
-bool ByteCodeExprGen::VisitParenExpr(const ParenExpr *PE) {
-  const Expr *SubExpr = PE->getSubExpr();
-
-  if (DiscardResult)
-return this->discard(SubExpr);
-
-  return this->visit(SubExpr);
+bool ByteCodeExprGen::VisitParenExpr(const ParenExpr *E) {
+  return this->delegate(E->getSubExpr());
 }
 
 template 



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


[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-09-09 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks


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

https://reviews.llvm.org/D156400

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


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread Yueh-Ting Chen via cfe-commits

https://github.com/eopXD updated 
https://github.com/llvm/llvm-project/pull/65778:

>From 91e607dd38475ceae604c794e40bd1721aa7dae4 Mon Sep 17 00:00:00 2001
From: eopXD 
Date: Fri, 8 Sep 2023 09:59:25 -0700
Subject: [PATCH] [Clang][RISCV] Use Decl for checkRVVTypeSupport

Using ValueDecl will cause error for OpenMP. Decl should do the work.
---
 clang/include/clang/Sema/Sema.h  |  2 +-
 clang/lib/Sema/SemaChecking.cpp  |  2 +-
 clang/lib/Sema/SemaDecl.cpp  |  2 +-
 clang/test/SemaOpenMP/riscv-vector-with-openmp.c | 12 
 4 files changed, 15 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/SemaOpenMP/riscv-vector-with-openmp.c

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4fd0e6bd5982a71..5c7207062741b52 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13726,7 +13726,7 @@ class Sema final {
   bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
   bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
  CallExpr *TheCall);
-  void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D);
+  void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D);
   bool CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
  unsigned BuiltinID, CallExpr 
*TheCall);
   bool CheckWebAssemblyBuiltinFunctionCall(const TargetInfo &TI,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3932d9cd07d9864..3b4ac613da76aa8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5514,7 +5514,7 @@ bool Sema::CheckWebAssemblyBuiltinFunctionCall(const 
TargetInfo &TI,
   return false;
 }
 
-void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
+void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D) {
   const TargetInfo &TI = Context.getTargetInfo();
   // (ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at
   // least zve64x
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d6e090ee496eb30..37060f668b7acf3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8866,7 +8866,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
   }
 
   if (T->isRVVType())
-checkRVVTypeSupport(T, NewVD->getLocation(), cast(CurContext));
+checkRVVTypeSupport(T, NewVD->getLocation(), cast(CurContext));
 }
 
 /// Perform semantic checking on a newly-created variable
diff --git a/clang/test/SemaOpenMP/riscv-vector-with-openmp.c 
b/clang/test/SemaOpenMP/riscv-vector-with-openmp.c
new file mode 100644
index 000..5dae3eb9ce0b0a2
--- /dev/null
+++ b/clang/test/SemaOpenMP/riscv-vector-with-openmp.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -fsyntax-only \
+// RUN: -verify -fopenmp %s
+// REQUIRES: riscv-registered-target
+
+// expected-no-diagnostics
+
+void foo() {
+  #pragma omp parallel
+  {
+__rvv_int32m1_t i32m1;
+  }
+}

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


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread Yueh-Ting Chen via cfe-commits

https://github.com/eopXD resolved 
https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread Yueh-Ting Chen via cfe-commits

https://github.com/eopXD review_requested 
https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread Yueh-Ting Chen via cfe-commits

https://github.com/eopXD resolved 
https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

Using ValueDecl will cause error for OpenMP. Decl should do the work.
--
Full diff: https://github.com/llvm/llvm-project/pull/65778.diff

4 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (added) clang/test/SemaOpenMP/riscv-vector-with-openmp.c (+12) 



diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4fd0e6bd5982a71..5c7207062741b52 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13726,7 +13726,7 @@ class Sema final {
   bool CheckRISCVLMUL(CallExpr *TheCall, unsigned ArgNum);
   bool CheckRISCVBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
  CallExpr *TheCall);
-  void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D);
+  void checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D);
   bool CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
  unsigned BuiltinID, CallExpr 
*TheCall);
   bool CheckWebAssemblyBuiltinFunctionCall(const TargetInfo &TI,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3932d9cd07d9864..3b4ac613da76aa8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5514,7 +5514,7 @@ bool Sema::CheckWebAssemblyBuiltinFunctionCall(const 
TargetInfo &TI,
   return false;
 }
 
-void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
+void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D) {
   const TargetInfo &TI = Context.getTargetInfo();
   // (ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at
   // least zve64x
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d6e090ee496eb30..37060f668b7acf3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8866,7 +8866,7 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
   }
 
   if (T->isRVVType())
-checkRVVTypeSupport(T, NewVD->getLocation(), cast(CurContext));
+checkRVVTypeSupport(T, NewVD->getLocation(), cast(CurContext));
 }
 
 /// Perform semantic checking on a newly-created variable
diff --git a/clang/test/SemaOpenMP/riscv-vector-with-openmp.c 
b/clang/test/SemaOpenMP/riscv-vector-with-openmp.c
new file mode 100644
index 000..5dae3eb9ce0b0a2
--- /dev/null
+++ b/clang/test/SemaOpenMP/riscv-vector-with-openmp.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -fsyntax-only \
+// RUN: -verify -fopenmp %s
+// REQUIRES: riscv-registered-target
+
+// expected-no-diagnostics
+
+void foo() {
+  #pragma omp parallel
+  {
+__rvv_int32m1_t i32m1;
+  }
+}




https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Allow mixed scalar type constraints for inline asm (PR #65465)

2023-09-09 Thread via cfe-commits

https://github.com/cor3ntin labeled 
https://github.com/llvm/llvm-project/pull/65465
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Allow mixed scalar type constraints for inline asm (PR #65465)

2023-09-09 Thread via cfe-commits

https://github.com/cor3ntin unlabeled 
https://github.com/llvm/llvm-project/pull/65465
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-09 Thread via cfe-commits

https://github.com/cor3ntin unlabeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-09 Thread via cfe-commits

https://github.com/cor3ntin labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-09 Thread Guray Ozen via cfe-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

grypp wrote:

> Technically, SYCL provides a more abstract memory management with 
> sycl::buffer and sycl::accessor defining an implicit asynchronous task graph. 
> The allocation details are left to the implementation, asynchronous or 
> synchronous allocation is left to the implementers.

I haven't touched SYCL much, thanks for the explanation. Creating a task graph 
implicitly sounds interesting. In this case, SYCL users are ware of asynchrony 
while writing their program. In CUDA (or HIP), users choose sync or async 
execution. 

> Here the lower-level synchronous USM memory management API of SYCL is used 
> instead, similar to CUDA/HIP memory management.

Yes that's correct. I don't think there is an USM that can do allocation 
asynchronously. 

> So, should the async allocation in the example be synchronous instead?

Yes, I think this is the correct behaviour. We can disallow `host_shared` and 
`async` on the Op. 

Here are the possible IRs: 

```
// Valid
%memref = gpu.alloc host_shared (): memref<3x3xi64>

// Valid
%memref = gpu.alloc (): memref<3x3xi64>

// Invalid, USM managers don't allocate async  
%memref, %asyncToken = gpu.alloc async [%0] host_shared (): memref<3x3xi64>

// Valid, only for CUDA. Afaik, SYCL or HIP cannot do that
%memref, %asyncToken = gpu.alloc async [%0] (): memref<3x3xi64>
```

https://github.com/llvm/llvm-project/pull/65539
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-09 Thread Guray Ozen via cfe-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

grypp wrote:

> Technically, SYCL provides a more abstract memory management with 
> sycl::buffer and sycl::accessor defining an implicit asynchronous task graph. 
> The allocation details are left to the implementation, asynchronous or 
> synchronous allocation is left to the implementers.

I haven't touched SYCL much, thanks for the explanation. Creating a task graph 
implicitly sounds interesting. In this case, SYCL users are ware of asynchrony 
while writing their program. In CUDA (or HIP), users choose sync or async 
execution. 

> Here the lower-level synchronous USM memory management API of SYCL is used 
> instead, similar to CUDA/HIP memory management.

Yes that's correct. I don't think there is an USM that can do allocation 
asynchronously. 

> So, should the async allocation in the example be synchronous instead?

Yes, I think this is the correct behaviour. We can disallow `host_shared` and 
`async` on the Op. 

Here are the possible IRs: 

```
// Valid
%memref = gpu.alloc host_shared (): memref<3x3xi64>

// Valid
%memref = gpu.alloc (): memref<3x3xi64>

// Invalid, USM managers don't allocate async  
%memref, %asyncToken = gpu.alloc async [%0] host_shared (): memref<3x3xi64>

// Valid, only for CUDA. Afaik, SYCL or HIP cannot do that
%memref, %asyncToken = gpu.alloc async [%0] (): memref<3x3xi64>
```

https://github.com/llvm/llvm-project/pull/65539
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.

LG

https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-09 Thread Aaron Ballman via cfe-commits


@@ -49,6 +49,28 @@ ABI Changes in This Version
 - Following the SystemV ABI for x86-64, ``__int128`` arguments will no longer
   be split between a register and a stack slot.
 
+AST Dumping Potentially Breaking Changes

AaronBallman wrote:

Fantastic release note!!

https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-09 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-09 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LGTM, thank you!

https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks resolved 
https://github.com/llvm/llvm-project/pull/65808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks updated 
https://github.com/llvm/llvm-project/pull/65808:

From d0415b4436a11e649fbeae53b8060f70bae03254 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= 
Date: Fri, 8 Sep 2023 13:07:09 +0200
Subject: [PATCH 1/2] [clang-format] BreakBeforeNoexceptSpecifier option added

---
 clang/docs/ClangFormatStyleOptions.rst | 48 ++
 clang/docs/ReleaseNotes.rst|  1 +
 clang/include/clang/Format/Format.h| 43 +++
 clang/lib/Format/Format.cpp| 14 +++
 clang/lib/Format/TokenAnnotator.cpp| 11 +
 clang/unittests/Format/ConfigParseTest.cpp |  8 
 clang/unittests/Format/FormatTest.cpp  | 46 +
 7 files changed, 171 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index df27f6166d37105..51e4b2661a9ea84 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1108,6 +1108,54 @@ the configuration (without a prefix: ``Auto``).
 int d,
 int e);
 
+.. _AllowBreakBeforeNoexceptSpecifier:
+
+**AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) 
:versionbadge:`clang-format 18` :ref:`¶ `
+  Controls if there could be a line break before a ``noexcept`` specifier.
+
+  Possible values:
+
+  * ``BBNSS_Never`` (in configuration: ``Never``)
+No line break allowed.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2) noexcept(
+  noexcept(baz(arg1)) &&
+  noexcept(baz(arg2)));
+
+  * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
+For a simple ``noexcept`` there is no line break allowed, but when we
+have a condition it is.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+  * ``BBNSS_Always`` (in configuration: ``Always``)
+Line breaks are allowed. Bute note that because of the associtated
+penalties ``clang-format`` often prefers not to break before the
+``noexcept``.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+
+
 .. _AllowShortBlocksOnASingleLine:
 
 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) 
:versionbadge:`clang-format 3.5` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28a6ec0acd409b0..5c1f7ae54ffe09d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -374,6 +374,7 @@ AST Matchers
 
 clang-format
 
+- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7ebde3c174d2640..51c17bb214b678b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -593,6 +593,47 @@ struct FormatStyle {
   /// \version 3.3
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Different ways to break before a noexcept specifier.
+  enum BreakBeforeNoexceptSpecifierStyle : int8_t {
+/// No line break allowed.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2) noexcept(
+///   noexcept(baz(arg1)) &&
+///   noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Never,
+/// For a simple ``noexcept`` there is no line break allowed, but when we
+/// have a condition it is.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_OnlyWithParen,
+/// Line breaks are allowed. Bute note that because of the associtated
+/// penalties ``clang-format`` often prefers not to break before the
+/// ``noexcept``.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Always,
+  };
+
+  /// Controls if there could be a line break before a ``noexcept`` specifier.
+  /// \version 18
+  BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
+
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle : int8_t {
@@ -4576,6 +4617,8 @@ struct FormatStyle {
AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNe

[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread via cfe-commits
=?utf-8?q?Björn_Schäpers?= 


https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread via cfe-commits
=?utf-8?q?Björn_Schäpers?= 


https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread via cfe-commits
=?utf-8?q?Björn_Schäpers?= 


llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

It really bugs me that it breaks to
``` c++
...) noexcept(
noexcept(condition)...
```

This is a fix for people like me.
--
Full diff: https://github.com/llvm/llvm-project/pull/65808.diff

7 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+48) 
- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/include/clang/Format/Format.h (+43) 
- (modified) clang/lib/Format/Format.cpp (+14) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+11) 
- (modified) clang/unittests/Format/ConfigParseTest.cpp (+8) 
- (modified) clang/unittests/Format/FormatTest.cpp (+46) 



diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index df27f6166d37105..51e4b2661a9ea84 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1108,6 +1108,54 @@ the configuration (without a prefix: ``Auto``).
 int d,
 int e);
 
+.. _AllowBreakBeforeNoexceptSpecifier:
+
+**AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) 
:versionbadge:`clang-format 18` :ref:`¶ `
+  Controls if there could be a line break before a ``noexcept`` specifier.
+
+  Possible values:
+
+  * ``BBNSS_Never`` (in configuration: ``Never``)
+No line break allowed.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2) noexcept(
+  noexcept(baz(arg1)) &&
+  noexcept(baz(arg2)));
+
+  * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
+For a simple ``noexcept`` there is no line break allowed, but when we
+have a condition it is.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+  * ``BBNSS_Always`` (in configuration: ``Always``)
+Line breaks are allowed. Bute note that because of the associtated
+penalties ``clang-format`` often prefers not to break before the
+``noexcept``.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+
+
 .. _AllowShortBlocksOnASingleLine:
 
 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) 
:versionbadge:`clang-format 3.5` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28a6ec0acd409b0..5c1f7ae54ffe09d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -374,6 +374,7 @@ AST Matchers
 
 clang-format
 
+- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7ebde3c174d2640..e0444966b3eabc7 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -593,6 +593,47 @@ struct FormatStyle {
   /// \version 3.3
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Different ways to break before a noexcept specifier.
+  enum BreakBeforeNoexceptSpecifierStyle : int8_t {
+/// No line break allowed.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2) noexcept(
+///   noexcept(baz(arg1)) &&
+///   noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Never,
+/// For a simple ``noexcept`` there is no line break allowed, but when we
+/// have a condition it is.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_OnlyWithParen,
+/// Line breaks are allowed. But note that because of the associated
+/// penalties ``clang-format`` often prefers not to break before the
+/// ``noexcept``.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Always,
+  };
+
+  /// Controls if there could be a line break before a ``noexcept`` specifier.
+  /// \version 18
+  BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
+
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle : int8_t {
@@ -4576,6 +4617,8 @@ struct FormatStyle {
AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclarationOn

[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread via cfe-commits
=?utf-8?q?Björn_Schäpers?= 


llvmbot wrote:

@llvm/pr-subscribers-clang-format


Changes

It really bugs me that it breaks to
``` c++
...) noexcept(
noexcept(condition)...
```

This is a fix for people like me.
--
Full diff: https://github.com/llvm/llvm-project/pull/65808.diff

7 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+48) 
- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/include/clang/Format/Format.h (+43) 
- (modified) clang/lib/Format/Format.cpp (+14) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+11) 
- (modified) clang/unittests/Format/ConfigParseTest.cpp (+8) 
- (modified) clang/unittests/Format/FormatTest.cpp (+46) 



diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index df27f6166d37105..51e4b2661a9ea84 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1108,6 +1108,54 @@ the configuration (without a prefix: ``Auto``).
 int d,
 int e);
 
+.. _AllowBreakBeforeNoexceptSpecifier:
+
+**AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) 
:versionbadge:`clang-format 18` :ref:`¶ `
+  Controls if there could be a line break before a ``noexcept`` specifier.
+
+  Possible values:
+
+  * ``BBNSS_Never`` (in configuration: ``Never``)
+No line break allowed.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2) noexcept(
+  noexcept(baz(arg1)) &&
+  noexcept(baz(arg2)));
+
+  * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
+For a simple ``noexcept`` there is no line break allowed, but when we
+have a condition it is.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+  * ``BBNSS_Always`` (in configuration: ``Always``)
+Line breaks are allowed. Bute note that because of the associtated
+penalties ``clang-format`` often prefers not to break before the
+``noexcept``.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+
+
 .. _AllowShortBlocksOnASingleLine:
 
 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) 
:versionbadge:`clang-format 3.5` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28a6ec0acd409b0..5c1f7ae54ffe09d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -374,6 +374,7 @@ AST Matchers
 
 clang-format
 
+- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7ebde3c174d2640..e0444966b3eabc7 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -593,6 +593,47 @@ struct FormatStyle {
   /// \version 3.3
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Different ways to break before a noexcept specifier.
+  enum BreakBeforeNoexceptSpecifierStyle : int8_t {
+/// No line break allowed.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2) noexcept(
+///   noexcept(baz(arg1)) &&
+///   noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Never,
+/// For a simple ``noexcept`` there is no line break allowed, but when we
+/// have a condition it is.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_OnlyWithParen,
+/// Line breaks are allowed. But note that because of the associated
+/// penalties ``clang-format`` often prefers not to break before the
+/// ``noexcept``.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Always,
+  };
+
+  /// Controls if there could be a line break before a ``noexcept`` specifier.
+  /// \version 18
+  BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
+
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle : int8_t {
@@ -4576,6 +4617,8 @@ struct FormatStyle {
AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclar

[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread via cfe-commits


@@ -117,7 +118,8 @@ std::optional Context::classify(QualType T) const 
{
 case 8:
   return PT_Uint8;
 default:
-  return std::nullopt;
+  return PT_IntAP;
+  // return std::nullopt;

yronglin wrote:

Can this comment be remove?

https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Interp] Add IntegralAP for arbitrary-precision integers (PR #65844)

2023-09-09 Thread Timm Baeder via cfe-commits


@@ -117,7 +118,8 @@ std::optional Context::classify(QualType T) const 
{
 case 8:
   return PT_Uint8;
 default:
-  return std::nullopt;
+  return PT_IntAP;
+  // return std::nullopt;

tbaederr wrote:

Yes. There are a few such comments left in the patch I think.

https://github.com/llvm/llvm-project/pull/65844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] add define2 pp directive (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/kelbon review_requested 
https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] add define2 pp directive (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/kelbon review_requested 
https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] add define2 pp directive (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/kelbon created 
https://github.com/llvm/llvm-project/pull/65851:

Add 'define2' directive, which works as 'define', but allows recursive macros

Motivation:

 * There are huge amount of code, which uses code generation/ boiler plate 
macros /misused terrible templates which is basically 'for each token' or 
somehow may be solved with this new feature
1. Nlohmann json:
https://github.com/nlohmann/json/blob/836b7beca4b62e2a99465edef44066b7401fd704/include/nlohmann/detail/macro_scope.hpp#L320

2. boost preprocessor:
https://github.com/boostorg/preprocessor/blob/develop/include/boost/preprocessor/seq/detail/limits/split_1024.hpp

3. boost pfr:
(codegen)
https://github.com/boostorg/pfr/blob/develop/include/boost/pfr/detail/core17_generated.hpp

4. data_parallel_vector:
https://github.com/kelbon/AnyAny/blob/4b056be2b6cbcfa1a407f7ee75279af414e390e4/include/anyany/noexport/data_parallel_vector_details.hpp#L62



* Its easily may be used for what 'magic enum' do, in many cases it can replace 
reflection ( because many who want reflection actually just want to create a 
JSON schema without specifying names twice )

* C++20 adds `__VA_OPT__`, which is designed for recursive macros, but there 
are no such thing in C++!
  

Examples: 

  fold

```C++

#define2 $fold_right(op, head, ...) ( head __VA_OPT__(op $fold_right(op, 
__VA_ARGS__)) )
#define2 $fold_left(op, head, ...) ( __VA_OPT__($fold_left(op, __VA_ARGS__) op) 
head )

static_assert($fold_right(+, 1, 2, 3) == 6);
// error: static assertion failed due to requirement '4) + 3) + 2) + 1) == 
4'
static_assert($fold_left(+, 1, 2, 3, 4) == 4);

```



  reverse token stream

```C++

#define2 $reverse(head, ...) __VA_OPT__($reverse(__VA_ARGS__) , ) head

// works as expected
constexpr int A[] = { $reverse($reverse($reverse(1, 2, 3))) };
constexpr int B[] = { 3, 2, 1 };
static_assert(A[0] == B[0] && A[1] == B[1] && A[2] == B[2]);

```



  transform token stream ( literaly for each )

```C++

#define2 $transform(macro, head, ...) macro(head) __VA_OPT__($transform(macro, 
__VA_ARGS__))

#define $to_string(tok) #tok,

constexpr const char* names[] = {
  $transform($to_string, a, b)
#undef $to_string
};
static_assert(names[0][0] == 'a' && names[1][0] == 'b');

```



  calculate count of tokens


```C++

#define2 TOKCOUNT_IMPL(head, ...) (1 __VA_OPT__(+ TOKCOUNT_IMPL(__VA_ARGS__)))
// works for zero args too
#define $tok_count(...) (0 __VA_OPT__(+ TOKCOUNT_IMPL(__VA_ARGS__)) )

static_assert($tok_count() == 0);
static_assert($tok_count(1, 2, (4, 5, 6)) == 3);

```



  boost pfr without code generation

```C++

// placeholders for actual calculations
template
consteval int aggregate_size() { return 3; }
constexpr int tie(auto&... args) { return sizeof...(args); }

#define2 $try_expand(value, head, ...)  
  \
if constexpr (aggregate_size() == $tok_count(+1, __VA_ARGS__)) 
{ \
  auto [head __VA_OPT__(,) __VA_ARGS__] = value;
  \
  return tie(head __VA_OPT__(,) __VA_ARGS__);   
  \
}   
  \
__VA_OPT__($try_expand(value, __VA_ARGS__))

constexpr auto magic_get(auto aggregate) {
  $try_expand(aggregate, _3, _2, _1);
}

struct abc { int a, b, c; };
static_assert(magic_get(abc{}) == 3);

```

Here magic get expands to (screenshot from clangd builded with this patch)

![image](https://github.com/llvm/llvm-project/assets/58717435/d65c2f4f-12c7-48da-b03e-147791692c64)





  infinite recursion macro:

```C++
#define2 A A
// produces 'error: unknown type name 'A'' (expanded to 'A')
// A
```
![image](https://github.com/llvm/llvm-project/assets/58717435/9cc388a1-ecd8-4577-856f-313c1166)




>From 2f807b312baef8c6038c2452b84232acb6d6d2c2 Mon Sep 17 00:00:00 2001
From: Kelbon Nik 
Date: Sat, 9 Sep 2023 17:51:15 +0400
Subject: [PATCH] add define2 pp directive

---
 clang/include/clang/Basic/TokenKinds.def |  1 +
 clang/include/clang/Lex/MacroInfo.h  | 19 +--
 clang/include/clang/Lex/Preprocessor.h   |  2 +-
 clang/lib/Basic/IdentifierTable.cpp  |  2 ++
 clang/lib/Format/WhitespaceManager.cpp   |  2 +-
 clang/lib/Lex/MacroInfo.cpp  |  3 ++-
 clang/lib/Lex/PPDirectives.cpp   | 16 +++-
 7 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 45ebc200b168986..f059d809823ab42 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -115,6 +115,7 @@ PPKEYWORD(__include_macros)
 
 // C99 6.10.3 - Macro Replacement.
 PPKEYWORD(define)
+PPKEYWORD(define2)
 PPKEYWORD(undef)
 
 // C99 6.10.4 - Line Control.
diff --git a/clang/include/clang/Lex/MacroInfo.h 
b/clang/include/clang/Lex/MacroInfo.h
index 00c1c3866bbd9ca..4f0c8e987610e50 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/incl

[clang] [Clang][RISCV] Use Decl for checkRVVTypeSupport (PR #65778)

2023-09-09 Thread Yueh-Ting Chen via cfe-commits

eopXD wrote:

@jrtc27 Anymore comments before merging this?

https://github.com/llvm/llvm-project/pull/65778
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] add define2 pp directive (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] add define2 pp directive (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] add define2 pp directive (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extension: allow recursive macros (PR #65851)

2023-09-09 Thread via cfe-commits

https://github.com/kelbon edited https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extension: allow recursive macros (PR #65851)

2023-09-09 Thread via cfe-commits

cor3ntin wrote:

Compiler extensions are best proposed through a RFC, ie a discourse post here:

https://discourse.llvm.org/c/clang/6

Explaining the motivation for the feature, which the pr description already 
does a good job.

There are questions about the name, theorically this is an identifier that c 
and c++ committees may want to use in the future.

You should also consider whether this needs extensions flags and extension 
warnings.

Is this something you plan to propose to other compilers? Standardization?

It does sound like an interesting feature though, and the implementation appear 
reasonable.


https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c23d65b - [clang] NFCI: Use `FileEntryRef` in `ModuleMapParser`

2023-09-09 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-09-09T09:12:35-07:00
New Revision: c23d65b90fb7fb07cb12e2d70d0c34376b8fcdad

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

LOG: [clang] NFCI: Use `FileEntryRef` in `ModuleMapParser`

Added: 


Modified: 
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 8f3f234036d26c0..05f30dd2eaa373f 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -721,7 +721,7 @@ class ModuleMap {
   ///that caused us to load this module map file, if any.
   ///
   /// \returns true if an error occurred, false otherwise.
-  bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
+  bool parseModuleMapFile(FileEntryRef File, bool IsSystem,
   DirectoryEntryRef HomeDir, FileID ID = FileID(),
   unsigned *Offset = nullptr,
   SourceLocation ExternModuleLoc = SourceLocation());

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ec7cb583b6f810c..699cd9ae03adc51 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1660,8 +1660,8 @@ bool HeaderSearch::findUsableModuleForFrameworkHeader(
   return true;
 }
 
-static const FileEntry *getPrivateModuleMap(FileEntryRef File,
-FileManager &FileMgr) {
+static OptionalFileEntryRef getPrivateModuleMap(FileEntryRef File,
+FileManager &FileMgr) {
   StringRef Filename = llvm::sys::path::filename(File.getName());
   SmallString<128>  PrivateFilename(File.getDir().getName());
   if (Filename == "module.map")
@@ -1669,10 +1669,8 @@ static const FileEntry *getPrivateModuleMap(FileEntryRef 
File,
   else if (Filename == "module.modulemap")
 llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
   else
-return nullptr;
-  if (auto File = FileMgr.getFile(PrivateFilename))
-return *File;
-  return nullptr;
+return std::nullopt;
+  return FileMgr.getOptionalFileRef(PrivateFilename);
 }
 
 bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
@@ -1738,8 +1736,8 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, 
bool IsSystem,
   }
 
   // Try to load a corresponding private module map.
-  if (const FileEntry *PMMFile = getPrivateModuleMap(File, FileMgr)) {
-if (ModMap.parseModuleMapFile(PMMFile, IsSystem, Dir)) {
+  if (OptionalFileEntryRef PMMFile = getPrivateModuleMap(File, FileMgr)) {
+if (ModMap.parseModuleMapFile(*PMMFile, IsSystem, Dir)) {
   LoadedModuleMaps[File] = false;
   return LMM_InvalidModuleMap;
 }

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index f8b767e1b5eb804..7a759a2039d158c 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1490,7 +1490,7 @@ namespace clang {
 ModuleMap ⤅
 
 /// The current module map file.
-const FileEntry *ModuleMapFile;
+FileEntryRef ModuleMapFile;
 
 /// Source location of most recent parsed module declaration
 SourceLocation CurrModuleDeclLoc;
@@ -1562,7 +1562,7 @@ namespace clang {
   public:
 explicit ModuleMapParser(Lexer &L, SourceManager &SourceMgr,
  const TargetInfo *Target, DiagnosticsEngine 
&Diags,
- ModuleMap &Map, const FileEntry *ModuleMapFile,
+ ModuleMap &Map, FileEntryRef ModuleMapFile,
  DirectoryEntryRef Directory, bool IsSystem)
 : L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),
   ModuleMapFile(ModuleMapFile), Directory(Directory),
@@ -2095,7 +2095,7 @@ void ModuleMapParser::parseModuleDecl() {
 ActiveModule->NoUndeclaredIncludes = true;
   ActiveModule->Directory = Directory;
 
-  StringRef MapFileName(ModuleMapFile->getName());
+  StringRef MapFileName(ModuleMapFile.getName());
   if (MapFileName.endswith("module.private.modulemap") ||
   MapFileName.endswith("module_private.map")) {
 ActiveModule->ModuleMapIsPrivate = true;
@@ -3077,7 +3077,7 @@ bool ModuleMapParser::parseModuleMapFile() {
   } while (true);
 }
 
-bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem,
+bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
DirectoryEntryRef Dir, FileID ID,
unsigned *Offset,
SourceLocation ExternModuleLoc) {



___
cfe-commits mailing list

[clang] 37b0889 - [clang] NFCI: Use `FileEntryRef` in `ModuleMap`

2023-09-09 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-09-09T09:12:35-07:00
New Revision: 37b08892fc1ada83f09b4630190f8fb7346923cd

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

LOG: [clang] NFCI: Use `FileEntryRef` in `ModuleMap`

Added: 


Modified: 
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/ModuleMap.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 05f30dd2eaa373f..a25a790e544e238 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -194,7 +194,7 @@ class ModuleMap {
 }
   };
 
-  using AdditionalModMapsSet = llvm::SmallPtrSet;
+  using AdditionalModMapsSet = llvm::SmallPtrSet;
 
 private:
   friend class ModuleMapParser;
@@ -653,7 +653,7 @@ class ModuleMap {
 return &I->second;
   }
 
-  void addAdditionalModuleMapFile(const Module *M, const FileEntry *ModuleMap);
+  void addAdditionalModuleMapFile(const Module *M, FileEntryRef ModuleMap);
 
   /// Resolve all of the unresolved exports in the given module.
   ///

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 7a759a2039d158c..39af2e8df106a66 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1339,7 +1339,7 @@ 
ModuleMap::canonicalizeModuleMapPath(SmallVectorImpl &Path) {
 }
 
 void ModuleMap::addAdditionalModuleMapFile(const Module *M,
-   const FileEntry *ModuleMap) {
+   FileEntryRef ModuleMap) {
   AdditionalModMaps[M].insert(ModuleMap);
 }
 

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 576da09095002b0..0cfecddc198db5a 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4096,13 +4096,13 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, 
ModuleFile &F,
 // Check any additional module map files (e.g. module.private.modulemap)
 // that are not in the pcm.
 if (auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
-  for (const FileEntry *ModMap : *AdditionalModuleMaps) {
+  for (FileEntryRef ModMap : *AdditionalModuleMaps) {
 // Remove files that match
 // Note: SmallPtrSet::erase is really remove
 if (!AdditionalStoredMaps.erase(ModMap)) {
   if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
 Diag(diag::err_module_
diff erent_modmap)
-  << F.ModuleName << /*new*/0 << ModMap->getName();
+  << F.ModuleName << /*new*/0 << ModMap.getName();
   return OutOfDate;
 }
   }



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


[clang] ef99617 - [clang] NFCI: Use `FileEntryRef` in `diagnoseFrameworkInclude()`

2023-09-09 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-09-09T09:12:35-07:00
New Revision: ef996175a7d38f7b4a0b60264dc861ab36376a47

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

LOG: [clang] NFCI: Use `FileEntryRef` in `diagnoseFrameworkInclude()`

Added: 


Modified: 
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index f5f4bbf85fa92c2..ec7cb583b6f810c 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -818,7 +818,7 @@ static bool isFrameworkStylePath(StringRef Path, bool 
&IsPrivateHeader,
 static void
 diagnoseFrameworkInclude(DiagnosticsEngine &Diags, SourceLocation IncludeLoc,
  StringRef Includer, StringRef IncludeFilename,
- const FileEntry *IncludeFE, bool isAngled = false,
+ FileEntryRef IncludeFE, bool isAngled = false,
  bool FoundByHeaderMap = false) {
   bool IsIncluderPrivateHeader = false;
   SmallString<128> FromFramework, ToFramework;
@@ -828,7 +828,7 @@ diagnoseFrameworkInclude(DiagnosticsEngine &Diags, 
SourceLocation IncludeLoc,
 return;
   bool IsIncludeePrivateHeader = false;
   bool IsIncludeeInFramework =
-  isFrameworkStylePath(IncludeFE->getName(), IsIncludeePrivateHeader,
+  isFrameworkStylePath(IncludeFE.getName(), IsIncludeePrivateHeader,
ToFramework, ToIncludeSpelling);
 
   if (!isAngled && !FoundByHeaderMap) {
@@ -965,7 +965,7 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
 if (First) {
   diagnoseFrameworkInclude(Diags, IncludeLoc,
IncluderAndDir.second.getName(), Filename,
-   &FE->getFileEntry());
+   *FE);
   return FE;
 }
 
@@ -1119,9 +1119,9 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
 
 bool FoundByHeaderMap = !IsMapped ? false : *IsMapped;
 if (!Includers.empty())
-  diagnoseFrameworkInclude(
-  Diags, IncludeLoc, Includers.front().second.getName(), Filename,
-  &File->getFileEntry(), isAngled, FoundByHeaderMap);
+  diagnoseFrameworkInclude(Diags, IncludeLoc,
+   Includers.front().second.getName(), Filename,
+   *File, isAngled, FoundByHeaderMap);
 
 // Remember this location for the next lookup we do.
 cacheLookupSuccess(CacheLookup, It, IncludeLoc);



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


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

2023-09-09 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti updated this revision to Diff 556348.
5chmidti added a comment.

addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -66,6 +66,11 @@
 Code completion
 ^^^
 
+Code actions
+
+
+- The extract variable tweak gained support for extracting lambda expressions to a variable.
+
 Signature help
 ^^
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,10 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+
+template 
+void sink(T) {}
+
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,10 +135,85 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas: partially selected
+  sink([] [[ (){} ]] );
+  sink([ [[ ]( ]] )[[{}]]);
+  sink([ [[ ](){} ]] );
+
+  // lambdas: captures
+  int x = 0;
+  [ [[=]] ](){};
+  [ [[&]] ](){};
+  [ [[x]] ](){};
+  [ [[&x]] ](){};
+  [y = [[x]] ](){};
+  [ [[y = x]] ](){};
+
+  // lambdas: default args, cannot extract into function-local scope
+  [](int x = [[10]]){};
+  [](auto h = [[ [i = [](){}](){} ]]) {};
+
+  // lambdas: default args
+  // Extracting from capture initializers is usually fine,
+  // but not if the capture itself is nested inside a default argument
+  [](auto h = [i = [[ [](){} ]]](){}) {};
+  [](auto h = [i = [[ 42 ]]](){}) {};
+
+  // lambdas: scope
+  if (int a = 1)
+if ([[ [&](){ return a + 1; } ]]() == 4)
+  a = a + 1;
+
+  for (int c = 0; [[ [&]() { return c < b; } ]](); ++c) {
+  }
+  for (int c = 0; [[ [&]() { return c < b; } () ]]; ++c) {
+  }
+
+  // lambdas: scope with structured binding
+  struct Coordinates {
+int x{};
+int y{};
+  };
+  Coordinates c{};
+  if (const auto [x, y] = c; x > y)
+auto f = [[ [&]() { return x + y; } ]];
+
+  // lambdas: referencing outside variables that block extraction
+  //  in trailing return type or in a decltype used
+  //  by a parameter
+  if (int a = 1)
+if ([[ []() -> decltype(a) { return 1; } ]] () == 4)
+  a = a + 1;
+  if (int a = 1)
+if ([[ [](int x = decltype(a){}) { return 1; } ]] () == 4)
+  a = a + 1;
+  if (int a = 1)
+if ([[ [](decltype(a) x) { return 1; } ]] (42) == 4)
+  a = a + 1;
 }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
 
+  ExtraArgs = {"-std=c++20"};
+  const char *UnavailableCasesCXX20 = R"cpp(
+template 
+concept Constraint = requires (T t) { true; };
+void foo() {
+  // lambdas: referencing outside variables that block extraction
+  //  in requires clause or defaulted explicit template parameters
+  if (int a = 1)
+if ([[ [](auto b) requires (Constraint && Constraint) { return true; } ]] (a))
+  a = a + 1;
+
+  if (int a = 1)
+if ([[ [](T b) { return true; } ]] (a))
+  a = a + 1;
+}
+  )cpp";
+  EXPECT_UNAVAILABLE(UnavailableCasesCXX20);
+  ExtraArgs.clear();
+
   // vector of pairs of input and output strings
   std::vector> InputOutputs = {
   // extraction from variable declaration/assignment
@@ -282,6 +361,219 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + placeholder + S(5);
  })cpp"},
+  // lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([[ [](){ return 42; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = [](){ return 42; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([x = [[40 + 2]] ](){ return 42; });
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = 40 + 2; f([x = placeholder ](){ return 42; });
+}
+)cpp"},
+  {R"cpp(auto foo(int VarA) {
+  return [VarA]() {
+return [[ [VarA, VarC 

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

2023-09-09 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti updated this revision to Diff 556349.
5chmidti added a comment.

Fixup to last revision change:

- do not block the partial selection of lambdas

There is no reason to block the partial selection of lambdas. Other expressions 
can be partially selected as well and still offer an extraction:

  4[[0 +]] 2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst

Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -66,6 +66,11 @@
 Code completion
 ^^^
 
+Code actions
+
+
+- The extract variable tweak gained support for extracting lambda expressions to a variable.
+
 Signature help
 ^^
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,7 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,10 +132,80 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas: captures
+  int x = 0;
+  [ [[=]] ](){};
+  [ [[&]] ](){};
+  [ [[x]] ](){};
+  [ [[&x]] ](){};
+  [y = [[x]] ](){};
+  [ [[y = x]] ](){};
+
+  // lambdas: default args, cannot extract into function-local scope
+  [](int x = [[10]]){};
+  [](auto h = [[ [i = [](){}](){} ]]) {};
+
+  // lambdas: default args
+  // Extracting from capture initializers is usually fine,
+  // but not if the capture itself is nested inside a default argument
+  [](auto h = [i = [[ [](){} ]]](){}) {};
+  [](auto h = [i = [[ 42 ]]](){}) {};
+
+  // lambdas: scope
+  if (int a = 1)
+if ([[ [&](){ return a + 1; } ]]() == 4)
+  a = a + 1;
+
+  for (int c = 0; [[ [&]() { return c < b; } ]](); ++c) {
+  }
+  for (int c = 0; [[ [&]() { return c < b; } () ]]; ++c) {
+  }
+
+  // lambdas: scope with structured binding
+  struct Coordinates {
+int x{};
+int y{};
+  };
+  Coordinates c{};
+  if (const auto [x, y] = c; x > y)
+auto f = [[ [&]() { return x + y; } ]];
+
+  // lambdas: referencing outside variables that block extraction
+  //  in trailing return type or in a decltype used
+  //  by a parameter
+  if (int a = 1)
+if ([[ []() -> decltype(a) { return 1; } ]] () == 4)
+  a = a + 1;
+  if (int a = 1)
+if ([[ [](int x = decltype(a){}) { return 1; } ]] () == 4)
+  a = a + 1;
+  if (int a = 1)
+if ([[ [](decltype(a) x) { return 1; } ]] (42) == 4)
+  a = a + 1;
 }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
 
+  ExtraArgs = {"-std=c++20"};
+  const char *UnavailableCasesCXX20 = R"cpp(
+template 
+concept Constraint = requires (T t) { true; };
+void foo() {
+  // lambdas: referencing outside variables that block extraction
+  //  in requires clause or defaulted explicit template parameters
+  if (int a = 1)
+if ([[ [](auto b) requires (Constraint && Constraint) { return true; } ]] (a))
+  a = a + 1;
+
+  if (int a = 1)
+if ([[ [](T b) { return true; } ]] (a))
+  a = a + 1;
+}
+  )cpp";
+  EXPECT_UNAVAILABLE(UnavailableCasesCXX20);
+  ExtraArgs.clear();
+
   // vector of pairs of input and output strings
   std::vector> InputOutputs = {
   // extraction from variable declaration/assignment
@@ -282,6 +353,219 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + placeholder + S(5);
  })cpp"},
+  // lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([[ [](){ return 42; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = [](){ return 42; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([x = [[40 + 2]] ](){ return 42; });
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = 40 + 2; f([x = placeholder ](){ return 42; });
+}
+)cpp"},
+  {R"cpp(auto foo(int VarA) {
+  return [V

[PATCH] D157911: clang: Add __builtin_exp10* and use new llvm.exp10 intrinsic

2023-09-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D157911

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


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

2023-09-09 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti marked an inline comment as done.
5chmidti added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:187
+// Allow expressions, but only allow completely selected lambda
+// expressions or unselected lambda expressions that are the parent of
+// the originally selected node, not partially selected lambda

nridge wrote:
> nridge wrote:
> > 5chmidti wrote:
> > > nridge wrote:
> > > > I think it's worth adding to the comment *why* we allow unselected 
> > > > lambda expressions (to allow extracting from capture initializers), as 
> > > > it's not obvious
> > > I changed the previous return of `!isa(Stmt) || 
> > > InsertionPoint->Selected != SelectionTree::Partial;` to a simple `return 
> > > true;`. None of my partial selection tests fail and I can't think of a 
> > > case where the lambda would be partially selected.
> > Hmm, so what actually happens in these testcases?
> > 
> > ```
> >   // lambdas: partially selected
> >   [][[(){}]];
> >   []()[[{}]];
> >   [ [[ ](){}]];
> > ```
> I checked, and in these cases we disallow the extraction 
> [here](https://searchfox.org/llvm/rev/c2bee1ed26a3355d164c92f1eb70ebf88804560d/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp#426-432)
>  before we get to creating an `ExtractionContext`.
> 
> If the testcases are modified as follows:
> 
> ```
> template  void sink(T) {}
> ...
> void f() {
>   // lambdas: partially selected
>   sink([][[(){}]]);
>   sink([]()[[{}]]);
>   sink([ [[ ](){}]]);
> }
> ```
> 
> now they fail, unless the check for partial selection here is restored.
As stated in the update comment, I see no reason why we actually block partial 
selection of lambdas. It's okay to extract from the initializer of a capture 
(one of your comments above):
```
int foo();

void bar() {
  [x = [[foo()]] ]() {};
}
```
The tests in ln 138-143 (titled `lambdas: captures`) check that we don't 
extract the wrong things from lambda captures.
Do you see a way that extracting from a lambda capture or any kind of partial 
selection could be problematic?

To answer the question anyway:
`Hmm, so what actually happens in these testcases?`
The original diff had a sink that I probably removed because the tests would 
succeed even without the sink. However, those tests then tested a different 
condition and never hit the check for partial selection.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

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


[clang] Extension: allow recursive macros (PR #65851)

2023-09-09 Thread via cfe-commits

kelbon wrote:



> There are questions about the name, theorically this is an identifier that c 
> and c++ committees may want to use in the future.

Yes, the name define2 is a placeholder, but the more I look at it, the more it 
looks appropriate

> Is this something you plan to propose to other compilers? Standardization?

I dont think standard committee will consider the proposal without reference 
implementation(if its not a modules ofc)) and, in case of preprocessor, usage 
in 'real world'

> You should also consider whether this needs extensions flags and extension 
> warnings.
> missing unit tests

i will research how to do it in llvm



https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 98e6deb - [clang][tools] Use `FileEntryRef` in `include_cleaner::Header`

2023-09-09 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-09-09T09:54:13-07:00
New Revision: 98e6deb62cefaa7d5c67081bd5b72ad26bada46e

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

LOG: [clang][tools] Use `FileEntryRef` in `include_cleaner::Header`

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
clang-tools-extra/include-cleaner/lib/Analysis.cpp
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
clang-tools-extra/include-cleaner/lib/Record.cpp
clang-tools-extra/include-cleaner/lib/Types.cpp
clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
clang-tools-extra/include-cleaner/unittests/IncludeSpellerTest.cpp
clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
clang-tools-extra/include-cleaner/unittests/TypesTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 8e460cb38826eb1..fed19bdcc291436 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -101,7 +101,7 @@ bool IncludeCleanerCheck::shouldIgnore(const 
include_cleaner::Header &H) {
 case include_cleaner::Header::Verbatim:
   return R.match(H.verbatim());
 case include_cleaner::Header::Physical:
-  return R.match(H.physical()->tryGetRealPathName());
+  return R.match(H.physical().getFileEntry().tryGetRealPathName());
 }
 llvm_unreachable("Unknown Header kind.");
   });
@@ -145,7 +145,7 @@ void IncludeCleanerCheck::check(const 
MatchFinder::MatchResult &Result) {
  for (const include_cleaner::Header &H : Providers) {
if (H.kind() == include_cleaner::Header::Physical &&
(H.physical() == MainFile ||
-H.physical()->getDir() == ResourceDir)) {
+H.physical().getDir() == ResourceDir)) {
  Satisfied = true;
  continue;
}

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index a6e01eb72821d22..d3ee7591edf09d8 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -410,7 +410,7 @@ IncludeCleanerFindings 
computeIncludeCleanerFindings(ParsedAST &AST) {
 for (const auto &H : Providers) {
   if (H.kind() == include_cleaner::Header::Physical &&
   (H.physical() == MainFile || H.physical() == PreamblePatch ||
-   H.physical()->getLastRef().getDir() == ResourceDir)) {
+   H.physical().getDir() == ResourceDir)) {
 Satisfied = true;
 continue;
   }

diff  --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp 
b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
index 48c9c3f576640dc..b90bab70c4d90a8 100644
--- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -167,7 +167,8 @@ TEST(IncludeCleaner, ComputeMissingHeaders) {
   size_t End = llvm::cantFail(positionToOffset(MainFile.code(), Range.end));
   syntax::FileRange BRange{SM.getMainFileID(), static_cast(Start),
static_cast(End)};
-  include_cleaner::Header Header{*SM.getFileManager().getFile("b.h")};
+  include_cleaner::Header Header{
+  *SM.getFileManager().getOptionalFileRef("b.h")};
   MissingIncludeDiagInfo BInfo{B, BRange, {Header}};
   EXPECT_THAT(Findings.MissingIncludes, ElementsAre(BInfo));
 }
@@ -474,8 +475,8 @@ TEST(IncludeCleaner, IsPreferredProvider) {
   auto &IncludeDef2 = AST.getIncludeStructure().MainFileIncludes[2];
 
   auto &FM = AST.getSourceManager().getFileManager();
-  auto *DeclH = &FM.getOptionalFileRef("decl.h")->getFileEntry();
-  auto *DefH = &FM.getOptionalFileRef("def.h")->getFileEntry();
+  auto DeclH = *FM.getOptionalFileRef("decl.h");
+  auto DefH = *FM.getOptionalFileRef("def.h");
 
   auto Includes = convertIncludes(AST);
   std::vector Providers = {

diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
index 08bc1dbdfad42aa..2e0b462ce16df10 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h
+++ b/cla

[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-09 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay approved this pull request.


https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-09 Thread Fangrui Song via cfe-commits

MaskRay wrote:

Thank you for the change! `ninja check-llvm check-clang check-clang-tools 
check-flang check-mlir check-lld check-polly` parses.

> The GoogleTest code also uses a different code style (Google C++ style 
> instead of LLVM style). Shall I reformat the entire GoogleTest code base?

I think we should just use the upstream style.

https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] eea232d - [clang][tools] Remove path separator assumption

2023-09-09 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-09-09T11:38:32-07:00
New Revision: eea232da827abae1a4fd71a0fb1f4d239d7b2f6a

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

LOG: [clang][tools] Remove path separator assumption

After 98e6deb6 the 'HeadersForSymbolTest.IWYUTransitiveExportWithPrivate' test 
in 'ClangIncludeCleanerTest' started failing. This is most likely because 
`FileEntryRef::getName()` now starts with ".\" on Windows, whereas 
`FileEntry::getName()` did not. This commit fixes assumption of forward slash 
separators.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp 
b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index 0f91ad57f0c51d3..06e5e1812ba7218 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -50,8 +50,7 @@ llvm::SmallVector 
ranked(llvm::SmallVector> Headers) {
 // name.
 llvm::StringRef basename(llvm::StringRef Header) {
   Header = Header.trim("<>\"");
-  if (auto LastSlash = Header.rfind('/'); LastSlash != Header.npos)
-Header = Header.drop_front(LastSlash + 1);
+  Header = llvm::sys::path::filename(Header);
   // Drop everything after first `.` (dot).
   // foo.h -> foo
   // foo.cu.h -> foo



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


[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

2023-09-09 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 556355.
iana added a comment.

- Drop the -verify off the new tests so that I can get the full errors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159064

Files:
  clang/lib/Basic/Module.cpp
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/__stddef_nullptr_t.h
  clang/lib/Headers/module.modulemap
  clang/test/Headers/stdarg.c
  clang/test/Headers/stdargneeds.c
  clang/test/Headers/stddef.c
  clang/test/Headers/stddefneeds.c
  clang/test/Modules/Inputs/System/usr/include/complex.h
  clang/test/Modules/Inputs/System/usr/include/inttypes.h
  clang/test/Modules/Inputs/System/usr/include/math.h
  clang/test/Modules/Inputs/System/usr/include/module.map
  clang/test/Modules/Inputs/System/usr/include/stdint.h
  clang/test/Modules/compiler_builtins.m
  clang/test/Modules/stddef.c
  clang/test/Modules/stddef.m

Index: clang/test/Modules/stddef.m
===
--- clang/test/Modules/stddef.m
+++ clang/test/Modules/stddef.m
@@ -4,4 +4,6 @@
 
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I %S/Inputs/StdDef %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/StdDef %s
 // expected-no-diagnostics
Index: clang/test/Modules/stddef.c
===
--- clang/test/Modules/stddef.c
+++ clang/test/Modules/stddef.c
@@ -1,12 +1,24 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify -fno-modules-error-recovery
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify=no-stddef-module -fno-modules-error-recovery
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -fno-modules-error-recovery
 
 #include "ptrdiff_t.h"
 
 ptrdiff_t pdt;
 
-size_t st; // expected-error {{missing '#include "include_again.h"'; 'size_t' must be declared before it is used}}
-// expected-note@__stddef_size_t.h:* {{here}}
+// When builtin headers join system modules, stddef.h and its sub-headers have no
+// header guards, and so are seen last by include_again.h, which takes all of their
+// declarations including size_t even though size_t.h previously declared it.
+// When builtin headers don't join the system modules and instead get their own
+// modules, none of the stddef.h declarations go in the StdDef test module. size_t
+// is then declared in both StdDef.SizeT and _Builtin_stddef.size_t. For the
+// purposes of this test it doesn't matter which one gets reported, just as long
+// as it isn't other.h or include_again.h.
+size_t st; // no-stddef-module-error {{missing '#include "include_again.h"'; 'size_t' must be declared before it is used}} \
+  yes-stddef-module-error {{missing '#include "size_t.h"'; 'size_t' must be declared before it is used}}
+// no-stddef-module-note@__stddef_size_t.h:* {{here}}
+// yes-stddef-module-note@size_t.h:* {{here}}
 
 #include "include_again.h"
 
Index: clang/test/Modules/compiler_builtins.m
===
--- clang/test/Modules/compiler_builtins.m
+++ clang/test/Modules/compiler_builtins.m
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
-// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -internal-isystem %S/Inputs/System/usr/include -verify
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -internal-isystem %S/Inputs/System/usr/include -verify
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -DNO_SYSTEM_MODULES -verify
 // expected-no-diagnostics
 
 #ifdef __SSE__
@@ -11,3 +11,19 @@
 #ifdef __AVX2__
 @import _Builtin_intrinsics.intel.avx2;
 #endif
+
+#ifndef NO_SYSTEM_MODULES
+@import _Builtin_float;
+@import _Builtin_inttypes;
+@import _Builtin_iso646;
+@import _Builtin_limits;
+@import _Builtin_stdalign;
+@import _Builtin_stdarg;
+@import _Builtin_stdatomic;
+@import _Builtin_stdbool;
+@import _Builtin_stddef;
+@import _Builtin_stdint;
+@import _Builtin_stdnoreturn;
+@import _Builtin_tgmath;
+@import 

[clang] Extension: allow recursive macros (PR #65851)

2023-09-09 Thread Emilia Kond via cfe-commits

rymiel wrote:

How would you deal with the issue of infinite loops? The following program:

```cpp
#define2 boom(X) boom(X)

boom(0)
```

Will continue to infinitely(?) consume memory until it is killed, either by the 
user or due to running out of memory on the system

https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

2023-09-09 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 556356.
iana added a comment.

- Drop the -verify off the stddef tests so that I can get the full errors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159064

Files:
  clang/lib/Basic/Module.cpp
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/__stddef_nullptr_t.h
  clang/lib/Headers/module.modulemap
  clang/test/Headers/stdarg.c
  clang/test/Headers/stdargneeds.c
  clang/test/Headers/stddef.c
  clang/test/Headers/stddefneeds.c
  clang/test/Modules/Inputs/System/usr/include/complex.h
  clang/test/Modules/Inputs/System/usr/include/inttypes.h
  clang/test/Modules/Inputs/System/usr/include/math.h
  clang/test/Modules/Inputs/System/usr/include/module.map
  clang/test/Modules/Inputs/System/usr/include/stdint.h
  clang/test/Modules/compiler_builtins.m
  clang/test/Modules/stddef.c
  clang/test/Modules/stddef.m

Index: clang/test/Modules/stddef.m
===
--- clang/test/Modules/stddef.m
+++ clang/test/Modules/stddef.m
@@ -3,5 +3,7 @@
 size_t getSize(void);
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I %S/Inputs/StdDef %s -verify
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I %S/Inputs/StdDef %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/StdDef %s
 // expected-no-diagnostics
Index: clang/test/Modules/stddef.c
===
--- clang/test/Modules/stddef.c
+++ clang/test/Modules/stddef.c
@@ -1,12 +1,24 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify -fno-modules-error-recovery
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -fno-modules-error-recovery
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -fno-modules-error-recovery
 
 #include "ptrdiff_t.h"
 
 ptrdiff_t pdt;
 
-size_t st; // expected-error {{missing '#include "include_again.h"'; 'size_t' must be declared before it is used}}
-// expected-note@__stddef_size_t.h:* {{here}}
+// When builtin headers join system modules, stddef.h and its sub-headers have no
+// header guards, and so are seen last by include_again.h, which takes all of their
+// declarations including size_t even though size_t.h previously declared it.
+// When builtin headers don't join the system modules and instead get their own
+// modules, none of the stddef.h declarations go in the StdDef test module. size_t
+// is then declared in both StdDef.SizeT and _Builtin_stddef.size_t. For the
+// purposes of this test it doesn't matter which one gets reported, just as long
+// as it isn't other.h or include_again.h.
+size_t st; // no-stddef-module-error {{missing '#include "include_again.h"'; 'size_t' must be declared before it is used}} \
+  yes-stddef-module-error {{missing '#include "size_t.h"'; 'size_t' must be declared before it is used}}
+// no-stddef-module-note@__stddef_size_t.h:* {{here}}
+// yes-stddef-module-note@size_t.h:* {{here}}
 
 #include "include_again.h"
 
Index: clang/test/Modules/compiler_builtins.m
===
--- clang/test/Modules/compiler_builtins.m
+++ clang/test/Modules/compiler_builtins.m
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
-// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -internal-isystem %S/Inputs/System/usr/include -verify
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -internal-isystem %S/Inputs/System/usr/include -verify
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -DNO_SYSTEM_MODULES -verify
 // expected-no-diagnostics
 
 #ifdef __SSE__
@@ -11,3 +11,19 @@
 #ifdef __AVX2__
 @import _Builtin_intrinsics.intel.avx2;
 #endif
+
+#ifndef NO_SYSTEM_MODULES
+@import _Builtin_float;
+@import _Builtin_inttypes;
+@import _Builtin_iso646;
+@import _Builtin_limits;
+@import _Builtin_stdalign;
+@import _Builtin_stdarg;
+@import _Builtin_stdatomic;
+@import

[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-09 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 review_requested 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-09 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

", where the aka will be skipped" in the commit message still doesn't make 
sense to me , otherwise lgtm

https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-09 Thread Jessica Clarke via cfe-commits

jrtc27 wrote:

> ", where the aka will be skipped" in the commit message still doesn't make 
> sense to me , otherwise lgtm

Comments in Clang's ASTDiagnostic use "aka" and "aka clause" synonymously, 
referring to the parenthesised clause in `'foo' (aka 'bar')` that is sometimes 
printed in diagnostics. That clause is never printed if `foo` and `bar` are the 
same string, even if `foo` is sugared.

https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6a08cf1 - clang: Add __builtin_exp10* and use new llvm.exp10 intrinsic

2023-09-09 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-09-09T23:14:12+03:00
New Revision: 6a08cf12d9cbc960159bf40e47078a882ca510ce

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

LOG: clang: Add __builtin_exp10* and use new llvm.exp10 intrinsic

https://reviews.llvm.org/D157911

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/constrained-math-builtins.c
clang/test/CodeGen/math-builtins.c
clang/test/CodeGenOpenCL/builtins-f16.cl

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5c2c5cf4fb2c349..fe857941171fa3d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -377,6 +377,9 @@ Floating Point Support in Clang
   semantics. If ``math-errno`` is disabled in the current TU, clang will
   re-enable ``math-errno`` in the presense of
   ``#pragma float_control(precise,on)``.
+- Add ``__builtin_exp10``, ``__builtin_exp10f``,
+  ``__builtin_exp10f16``, ``__builtin_exp10l`` and
+  ``__builtin_exp10f128`` builtins.
 
 AST Matchers
 

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index f5374537a0242c7..586dcf05170eb58 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -245,6 +245,11 @@ BUILTIN(__builtin_exp2f, "ff"  , "Fne")
 BUILTIN(__builtin_exp2f16, "hh"  , "Fne")
 BUILTIN(__builtin_exp2l, "LdLd", "Fne")
 BUILTIN(__builtin_exp2f128, "LLdLLd"  , "Fne")
+BUILTIN(__builtin_exp10 , "dd"  , "Fne")
+BUILTIN(__builtin_exp10f, "ff"  , "Fne")
+BUILTIN(__builtin_exp10f16, "hh"  , "Fne")
+BUILTIN(__builtin_exp10l, "LdLd", "Fne")
+BUILTIN(__builtin_exp10f128, "LLdLLd"  , "Fne")
 BUILTIN(__builtin_expm1 , "dd", "Fne")
 BUILTIN(__builtin_expm1f, "ff", "Fne")
 BUILTIN(__builtin_expm1l, "LdLd", "Fne")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5f9199d7cadee24..df0c4cc6354d0f2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2433,7 +2433,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
Intrinsic::exp2,
Intrinsic::experimental_constrained_exp2));
-
+case Builtin::BI__builtin_exp10:
+case Builtin::BI__builtin_exp10f:
+case Builtin::BI__builtin_exp10f16:
+case Builtin::BI__builtin_exp10l:
+case Builtin::BI__builtin_exp10f128: {
+  // TODO: strictfp support
+  if (Builder.getIsFPConstrained())
+break;
+  return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::exp10));
+}
 case Builtin::BIfabs:
 case Builtin::BIfabsf:
 case Builtin::BIfabsl:

diff  --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index 88ae8f58a7e20e5..981cc3ac36bd907 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -64,6 +64,13 @@ void foo(double *d, float f, float *fp, long double *l, int 
*i, const char *c, _
 // CHECK: call x86_fp80 @llvm.experimental.constrained.exp2.f80(x86_fp80 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
 // CHECK: call fp128 @llvm.experimental.constrained.exp2.f128(fp128 %{{.*}}, 
metadata !"round.tonearest", metadata !"fpexcept.strict")
 
+  __builtin_exp10(f);   __builtin_exp10f(f);  __builtin_exp10l(f); 
__builtin_exp10f128(f);
+
+// CHECK: call double @exp10(double noundef %{{.*}})
+// CHECK: call float @exp10f(float noundef %{{.*}})
+// CHECK: call x86_fp80 @exp10l(x86_fp80 noundef %{{.*}})
+// CHECK: call fp128 @exp10f128(fp128 noundef %{{.*}})
+
   __builtin_floor(f);  __builtin_floorf(f); __builtin_floorl(f); 
__builtin_floorf128(f);
 
 // CHECK: call double @llvm.experimental.constrained.floor.f64(double %{{.*}}, 
metadata !"fpexcept.strict")
@@ -223,6 +230,11 @@ void foo(double *d, float f, float *fp, long double *l, 
int *i, const char *c, _
 // CHECK: declare x86_fp80 @llvm.experimental.constrained.exp2.f80(x86_fp80, 
metadata, metadata)
 // CHECK: declare fp128 @llvm.experimental.constrained.exp2.f128(fp128, 
metadata, metadata)
 
+// CHECK: declare double @exp10(double noundef)
+// CHECK: declare float @exp10f(float noundef)
+// CHECK: declare x86_fp80 @exp10l(x86_fp80 noundef)
+// CHECK: declare fp128 @exp10f128(fp128 noundef)
+
 // CHECK: declare double @llvm.experimental.constrained.floor.f64(double, 
metadata)
 // CHECK: declare float @llvm.experimental.constrained.floor.f32(float, 
metadata)
 // CHECK: declare x86_fp80 @llvm.experimental.constrained.floor.f8

[PATCH] D157911: clang: Add __builtin_exp10* and use new llvm.exp10 intrinsic

2023-09-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

6a08cf12d9cbc960159bf40e47078a882ca510ce 



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

https://reviews.llvm.org/D157911

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


[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks updated 
https://github.com/llvm/llvm-project/pull/65808:

From 3d3b20f66212f86bd46853432f1be31e5977df83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= 
Date: Fri, 8 Sep 2023 13:07:09 +0200
Subject: [PATCH] [clang-format] BreakBeforeNoexceptSpecifier option added

---
 clang/docs/ClangFormatStyleOptions.rst | 48 ++
 clang/docs/ReleaseNotes.rst|  1 +
 clang/include/clang/Format/Format.h| 43 +++
 clang/lib/Format/Format.cpp| 14 +++
 clang/lib/Format/TokenAnnotator.cpp| 11 +
 clang/unittests/Format/ConfigParseTest.cpp |  8 
 clang/unittests/Format/FormatTest.cpp  | 46 +
 7 files changed, 171 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index df27f6166d37105..44bffa41d1cde95 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1108,6 +1108,54 @@ the configuration (without a prefix: ``Auto``).
 int d,
 int e);
 
+.. _AllowBreakBeforeNoexceptSpecifier:
+
+**AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) 
:versionbadge:`clang-format 18` :ref:`¶ `
+  Controls if there could be a line break before a ``noexcept`` specifier.
+
+  Possible values:
+
+  * ``BBNSS_Never`` (in configuration: ``Never``)
+No line break allowed.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2) noexcept(
+  noexcept(baz(arg1)) &&
+  noexcept(baz(arg2)));
+
+  * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
+For a simple ``noexcept`` there is no line break allowed, but when we
+have a condition it is.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+  * ``BBNSS_Always`` (in configuration: ``Always``)
+Line breaks are allowed. But note that because of the associated
+penalties ``clang-format`` often prefers not to break before the
+``noexcept``.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+
+
 .. _AllowShortBlocksOnASingleLine:
 
 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) 
:versionbadge:`clang-format 3.5` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28a6ec0acd409b0..5c1f7ae54ffe09d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -374,6 +374,7 @@ AST Matchers
 
 clang-format
 
+- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7ebde3c174d2640..e0444966b3eabc7 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -593,6 +593,47 @@ struct FormatStyle {
   /// \version 3.3
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Different ways to break before a noexcept specifier.
+  enum BreakBeforeNoexceptSpecifierStyle : int8_t {
+/// No line break allowed.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2) noexcept(
+///   noexcept(baz(arg1)) &&
+///   noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Never,
+/// For a simple ``noexcept`` there is no line break allowed, but when we
+/// have a condition it is.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_OnlyWithParen,
+/// Line breaks are allowed. But note that because of the associated
+/// penalties ``clang-format`` often prefers not to break before the
+/// ``noexcept``.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Always,
+  };
+
+  /// Controls if there could be a line break before a ``noexcept`` specifier.
+  /// \version 18
+  BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
+
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle : int8_t {
@@ -4576,6 +4617,8 @@ struct FormatStyle {
AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &

[clang] 84e3fdf - [clang-format] BreakBeforeNoexceptSpecifier option added (#65808)

2023-09-09 Thread via cfe-commits

Author: Björn Schäpers
Date: 2023-09-09T22:31:58+02:00
New Revision: 84e3fdfc65232a4c940c2c3c9a2a8fe6c9b7806d

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

LOG: [clang-format] BreakBeforeNoexceptSpecifier option added (#65808)

It really bugs me that it breaks to
``` c++
...) noexcept(
noexcept(condition)...
```

This is a fix for people like me.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index df27f6166d37105..44bffa41d1cde95 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1108,6 +1108,54 @@ the configuration (without a prefix: ``Auto``).
 int d,
 int e);
 
+.. _AllowBreakBeforeNoexceptSpecifier:
+
+**AllowBreakBeforeNoexceptSpecifier** (``BreakBeforeNoexceptSpecifierStyle``) 
:versionbadge:`clang-format 18` :ref:`¶ `
+  Controls if there could be a line break before a ``noexcept`` specifier.
+
+  Possible values:
+
+  * ``BBNSS_Never`` (in configuration: ``Never``)
+No line break allowed.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2) noexcept(
+  noexcept(baz(arg1)) &&
+  noexcept(baz(arg2)));
+
+  * ``BBNSS_OnlyWithParen`` (in configuration: ``OnlyWithParen``)
+For a simple ``noexcept`` there is no line break allowed, but when we
+have a condition it is.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+  * ``BBNSS_Always`` (in configuration: ``Always``)
+Line breaks are allowed. But note that because of the associated
+penalties ``clang-format`` often prefers not to break before the
+``noexcept``.
+
+.. code-block:: c++
+
+  void foo(int arg1,
+   double arg2) noexcept;
+
+  void bar(int arg1, double arg2)
+  noexcept(noexcept(baz(arg1)) &&
+   noexcept(baz(arg2)));
+
+
+
 .. _AllowShortBlocksOnASingleLine:
 
 **AllowShortBlocksOnASingleLine** (``ShortBlockStyle``) 
:versionbadge:`clang-format 3.5` :ref:`¶ `

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fe857941171fa3d..cc8b2c3808933cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -389,6 +389,7 @@ AST Matchers
 
 clang-format
 
+- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7ebde3c174d2640..e0444966b3eabc7 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -593,6 +593,47 @@ struct FormatStyle {
   /// \version 3.3
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Different ways to break before a noexcept specifier.
+  enum BreakBeforeNoexceptSpecifierStyle : int8_t {
+/// No line break allowed.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2) noexcept(
+///   noexcept(baz(arg1)) &&
+///   noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Never,
+/// For a simple ``noexcept`` there is no line break allowed, but when we
+/// have a condition it is.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_OnlyWithParen,
+/// Line breaks are allowed. But note that because of the associated
+/// penalties ``clang-format`` often prefers not to break before the
+/// ``noexcept``.
+/// \code
+///   void foo(int arg1,
+///double arg2) noexcept;
+///
+///   void bar(int arg1, double arg2)
+///   noexcept(noexcept(baz(arg1)) &&
+///noexcept(baz(arg2)));
+/// \endcode
+BBNSS_Always,
+  };
+
+  /// Controls if there could be a line break before a ``noexcept`` specifier.
+  /// \version 18
+  BreakBeforeNoexceptSpecifierStyle AllowBreakBeforeNoexceptSpecifier;
+
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle : int8_t {
@@ -4576,6

[clang] [clang-format] BreakBeforeNoexceptSpecifier option added (PR #65808)

2023-09-09 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks closed 
https://github.com/llvm/llvm-project/pull/65808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][TSA] Consider cleanup functions for thread safety analysis (PR #65462)

2023-09-09 Thread Aaron Puchert via cfe-commits
Timm =?utf-8?q?Bäder?= 


aaronpuchert wrote:

We still have until the end of September to finish the review on Phabricator. I 
would suggest that we keep the review there until we have to move. Here I can't 
see the difference to the last version that I reviewed.

https://github.com/llvm/llvm-project/pull/65462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extension: allow recursive macros (PR #65851)

2023-09-09 Thread via cfe-commits

kelbon wrote:

> How would you deal with the issue of infinite loops? The following program:
> 
> ```c++
> #define2 boom(X) boom(X)
> 
> boom(0)
> ```
> 
> Will continue to infinitely(?) consume memory until it is killed, either by 
> the user or due to running out of memory on the system

As fo other similar things like templates/inheriting/includes must be recursion 
depth limit, but in this case "MacroInfo" required to be 40 bytes(and code dont 
says for what, but i expect some runtime sized structs etc), so now i think how 
to do it better

https://github.com/llvm/llvm-project/pull/65851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Properly indent lines inside Verilog case structure (PR #65861)

2023-09-09 Thread via cfe-commits

https://github.com/sstwcw created 
https://github.com/llvm/llvm-project/pull/65861:

When a statement following a case label had to be broken into multiple lines, 
the continuation parts were not indented correctly.

Old:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

New:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

Verilog case labels and the following statements are on the same unwrapped line 
due to the difficulty of identifying them.  So there was a rule in 
`getNewLineColumn` to add a level of indentation to the part following the case 
label.  However, in case the line had to be broken again, the code at the end 
of the function would see that the line was already broken with the 
continuation part indented, so it would not indent it more.  Now 
`State.FirstIndent` is changed as well for the part following the case label, 
so the logic for determining when to add a continuation indentation works.

>From c1982d451e6ca8e3cf1269677aabe984000f6801 Mon Sep 17 00:00:00 2001
From: sstwcw 
Date: Sat, 9 Sep 2023 20:35:33 +
Subject: [PATCH] [clang-format] Properly indent lines inside Verilog case
 structure

When a statement following a case label had to be broken into multiple
lines, the continuation parts were not indented correctly.

Old:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

New:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

Verilog case labels and the following statements are on the same
unwrapped line due to the difficulty of identifying them.  So there was
a rule in `getNewLineColumn` to add a level of indentation to the part
following the case label.  However, in case the line had to be broken
again, the code at the end of the function would see that the line was
already broken with the continuation part indented, so it would not
indent it more.  Now `State.FirstIndent` is changed as well for the part
following the case label, so the logic for determining when to add a
continuation indentation works.
---
 clang/lib/Format/ContinuationIndenter.cpp| 22 ++---
 clang/unittests/Format/FormatTestVerilog.cpp | 47 
 2 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ac62dab1b07cdca..ec21c181772fa81 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1204,12 +1204,13 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
 CurrentState.Indent + Style.ContinuationIndentWidth);
   }
 
-  // After a goto label. Usually labels are on separate lines. However
-  // for Verilog the labels may be only recognized by the annotator and
-  // thus are on the same line as the current token.
-  if ((Style.isVerilog() && Keywords.isVerilogEndOfLabel(Previous)) ||
-  (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
-   State.Line->First->is(tok::kw_enum))) {
+  // Indentation of the statement following a Verilog case label is taken care
+  // of in moveStateToNextToken.
+  if (Style.isVerilog() && Keywords.isVerilogEndOfLabel(Previous))
+return State.FirstIndent;
+
+  if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
+  State.Line->First->is(tok::kw_enum)) {
 return (Style.IndentWidth * State.Line->First->IndentLevel) +
Style.IndentWidth;
   }
@@ -1599,6 +1600,15 @@ unsigned 
ContinuationIndenter::moveStateToNextToken(LineState &State,
 
   State.Column += Current.ColumnWidth;
   State.NextToken = State.NextToken->Next;
+  // Verilog case labels are are on the same unwrapped lines as the statements
+  // that follow.  TokenAnnotator identifies them and sets MustBreakBefore.
+  // Indentation is taken care of here.  A case label can only have 1 statement
+  // in Verilog, so we don't have to worry about lines that follow.
+  if (Style.isVerilog() && State.NextToken &&
+  State.NextToken->MustBreakBefore &&
+  Keywords.isVerilogEndOfLabel(Current)) {
+State.FirstIndent += Style.IndentWidth;
+  }
 
   unsigned Penalty =
   handleEndOfLine(Current, State, DryRun, AllowBreak, Newline);
diff --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index 9b090aa74f714d1..7161312126ea6ed 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -312,6 +312,53 @@ TEST_F(FormatTestVerilog, Case) {
   verifyFormat("default:\n"
"  x = '{x: x, default: 9};\n",
Style);
+  // When the line following the case label needs to be indented, the
+  // continuation should be indented correctly.
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result = //\n"
+   "10'b0

[clang] [clang-format] Properly indent lines inside Verilog case structure (PR #65861)

2023-09-09 Thread via cfe-commits

https://github.com/sstwcw review_requested 
https://github.com/llvm/llvm-project/pull/65861
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Properly indent lines inside Verilog case structure (PR #65861)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65861
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Properly indent lines inside Verilog case structure (PR #65861)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65861
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Properly indent lines inside Verilog case structure (PR #65861)

2023-09-09 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

When a statement following a case label had to be broken into multiple lines, 
the continuation parts were not indented correctly.

Old:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

New:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

Verilog case labels and the following statements are on the same unwrapped line 
due to the difficulty of identifying them.  So there was a rule in 
`getNewLineColumn` to add a level of indentation to the part following the case 
label.  However, in case the line had to be broken again, the code at the end 
of the function would see that the line was already broken with the 
continuation part indented, so it would not indent it more.  Now 
`State.FirstIndent` is changed as well for the part following the case label, 
so the logic for determining when to add a continuation indentation works.
--
Full diff: https://github.com/llvm/llvm-project/pull/65861.diff

2 Files Affected:

- (modified) clang/lib/Format/ContinuationIndenter.cpp (+16-6) 
- (modified) clang/unittests/Format/FormatTestVerilog.cpp (+47) 



diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ac62dab1b07cdca..ec21c181772fa81 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1204,12 +1204,13 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
 CurrentState.Indent + Style.ContinuationIndentWidth);
   }
 
-  // After a goto label. Usually labels are on separate lines. However
-  // for Verilog the labels may be only recognized by the annotator and
-  // thus are on the same line as the current token.
-  if ((Style.isVerilog() && Keywords.isVerilogEndOfLabel(Previous)) ||
-  (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
-   State.Line->First->is(tok::kw_enum))) {
+  // Indentation of the statement following a Verilog case label is taken care
+  // of in moveStateToNextToken.
+  if (Style.isVerilog() && Keywords.isVerilogEndOfLabel(Previous))
+return State.FirstIndent;
+
+  if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
+  State.Line->First->is(tok::kw_enum)) {
 return (Style.IndentWidth * State.Line->First->IndentLevel) +
Style.IndentWidth;
   }
@@ -1599,6 +1600,15 @@ unsigned 
ContinuationIndenter::moveStateToNextToken(LineState &State,
 
   State.Column += Current.ColumnWidth;
   State.NextToken = State.NextToken->Next;
+  // Verilog case labels are are on the same unwrapped lines as the statements
+  // that follow.  TokenAnnotator identifies them and sets MustBreakBefore.
+  // Indentation is taken care of here.  A case label can only have 1 statement
+  // in Verilog, so we don't have to worry about lines that follow.
+  if (Style.isVerilog() && State.NextToken &&
+  State.NextToken->MustBreakBefore &&
+  Keywords.isVerilogEndOfLabel(Current)) {
+State.FirstIndent += Style.IndentWidth;
+  }
 
   unsigned Penalty =
   handleEndOfLine(Current, State, DryRun, AllowBreak, Newline);
diff --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index 9b090aa74f714d1..7161312126ea6ed 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -312,6 +312,53 @@ TEST_F(FormatTestVerilog, Case) {
   verifyFormat("default:\n"
"  x = '{x: x, default: 9};\n",
Style);
+  // When the line following the case label needs to be indented, the
+  // continuation should be indented correctly.
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result = //\n"
+   "10'b01;\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0, //\n"
+   "  16'd1:\n"
+   "result = //\n"
+   "10'b01;\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result = (10'b01 + //\n"
+   "  10'b01 + //\n"
+   "  10'b01);\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result =  //\n"
+   "(10'b01 + //\n"
+   " 10'b01 + //\n"
+   " 10'b01);\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result =  //\n"
+   "longfunction( //\n"
+   "arg);\n"
+   "endcase");
+  Style = getDefaultStyle();
+  Style.ContinuationIndentWidth = 1;
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+ 

[clang] [clang-format] Properly indent lines inside Verilog case structure (PR #65861)

2023-09-09 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang-format


Changes

When a statement following a case label had to be broken into multiple lines, 
the continuation parts were not indented correctly.

Old:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

New:

```Verilog
case (data)
  16'd0:
result = // break here
10'b01;
endcase
```

Verilog case labels and the following statements are on the same unwrapped line 
due to the difficulty of identifying them.  So there was a rule in 
`getNewLineColumn` to add a level of indentation to the part following the case 
label.  However, in case the line had to be broken again, the code at the end 
of the function would see that the line was already broken with the 
continuation part indented, so it would not indent it more.  Now 
`State.FirstIndent` is changed as well for the part following the case label, 
so the logic for determining when to add a continuation indentation works.
--
Full diff: https://github.com/llvm/llvm-project/pull/65861.diff

2 Files Affected:

- (modified) clang/lib/Format/ContinuationIndenter.cpp (+16-6) 
- (modified) clang/unittests/Format/FormatTestVerilog.cpp (+47) 



diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ac62dab1b07cdca..ec21c181772fa81 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1204,12 +1204,13 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
 CurrentState.Indent + Style.ContinuationIndentWidth);
   }
 
-  // After a goto label. Usually labels are on separate lines. However
-  // for Verilog the labels may be only recognized by the annotator and
-  // thus are on the same line as the current token.
-  if ((Style.isVerilog() && Keywords.isVerilogEndOfLabel(Previous)) ||
-  (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
-   State.Line->First->is(tok::kw_enum))) {
+  // Indentation of the statement following a Verilog case label is taken care
+  // of in moveStateToNextToken.
+  if (Style.isVerilog() && Keywords.isVerilogEndOfLabel(Previous))
+return State.FirstIndent;
+
+  if (Style.BreakBeforeBraces == FormatStyle::BS_Whitesmiths &&
+  State.Line->First->is(tok::kw_enum)) {
 return (Style.IndentWidth * State.Line->First->IndentLevel) +
Style.IndentWidth;
   }
@@ -1599,6 +1600,15 @@ unsigned 
ContinuationIndenter::moveStateToNextToken(LineState &State,
 
   State.Column += Current.ColumnWidth;
   State.NextToken = State.NextToken->Next;
+  // Verilog case labels are are on the same unwrapped lines as the statements
+  // that follow.  TokenAnnotator identifies them and sets MustBreakBefore.
+  // Indentation is taken care of here.  A case label can only have 1 statement
+  // in Verilog, so we don't have to worry about lines that follow.
+  if (Style.isVerilog() && State.NextToken &&
+  State.NextToken->MustBreakBefore &&
+  Keywords.isVerilogEndOfLabel(Current)) {
+State.FirstIndent += Style.IndentWidth;
+  }
 
   unsigned Penalty =
   handleEndOfLine(Current, State, DryRun, AllowBreak, Newline);
diff --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index 9b090aa74f714d1..7161312126ea6ed 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -312,6 +312,53 @@ TEST_F(FormatTestVerilog, Case) {
   verifyFormat("default:\n"
"  x = '{x: x, default: 9};\n",
Style);
+  // When the line following the case label needs to be indented, the
+  // continuation should be indented correctly.
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result = //\n"
+   "10'b01;\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0, //\n"
+   "  16'd1:\n"
+   "result = //\n"
+   "10'b01;\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result = (10'b01 + //\n"
+   "  10'b01 + //\n"
+   "  10'b01);\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result =  //\n"
+   "(10'b01 + //\n"
+   " 10'b01 + //\n"
+   " 10'b01);\n"
+   "endcase");
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+   "result =  //\n"
+   "longfunction( //\n"
+   "arg);\n"
+   "endcase");
+  Style = getDefaultStyle();
+  Style.ContinuationIndentWidth = 1;
+  verifyFormat("case (data)\n"
+   "  16'd0:\n"
+  

[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-09 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph approved this pull request.

Agree with @MaskRay for the style: we should minimize the diff with upstream as 
much as possible!

https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread Shilei Tian via cfe-commits

https://github.com/shiltian review_requested 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread Shilei Tian via cfe-commits

https://github.com/shiltian created 
https://github.com/llvm/llvm-project/pull/65862:

The front end doesn't create captured region for unroll directive. This leads to
a crash when `-fopenmp-simd` is used, as reported in #63570.

Fix #63570.


>From 7ba55161a5d24e9d67c00696bca9e4d06b907689 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sat, 9 Sep 2023 17:30:17 -0400
Subject: [PATCH] [Clang][OpenMP] Emit unroll directive w/o captured region

The front end doesn't create captured region for unroll directive. This leads to
a crash when `-fopenmp-simd` is used, as reported in #63570.

Fix #63570.
---
 clang/lib/CodeGen/CGStmtOpenMP.cpp |  3 ++-
 clang/test/OpenMP/bug63570.c   | 10 ++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/OpenMP/bug63570.c

diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 6eca0a5ccab41d7..a4e80a4a9e1fd75 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -8064,7 +8064,8 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective(
   D.getDirectiveKind() == OMPD_critical ||
   D.getDirectiveKind() == OMPD_section ||
   D.getDirectiveKind() == OMPD_master ||
-  D.getDirectiveKind() == OMPD_masked) {
+  D.getDirectiveKind() == OMPD_masked ||
+  D.getDirectiveKind() == OMPD_unroll) {
 EmitStmt(D.getAssociatedStmt());
   } else {
 auto LPCRegion =
diff --git a/clang/test/OpenMP/bug63570.c b/clang/test/OpenMP/bug63570.c
new file mode 100644
index 000..f61a2ee49b388d0
--- /dev/null
+++ b/clang/test/OpenMP/bug63570.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-apple-darwin10 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple x86_64-apple-darwin10 %s
+// expected-no-diagnostics
+
+void f(float *a, float *b) {
+#pragma omp unroll
+  for (int i = 0; i < 128; i++) {
+a[i] = b[i];
+  }
+}

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


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread Shilei Tian via cfe-commits

https://github.com/shiltian review_requested 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread Shilei Tian via cfe-commits

https://github.com/shiltian review_requested 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

The front end doesn't create captured region for unroll directive. This leads to
a crash when `-fopenmp-simd` is used, as reported in #63570.

Fix #63570.

--
Full diff: https://github.com/llvm/llvm-project/pull/65862.diff

2 Files Affected:

- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+2-1) 
- (added) clang/test/OpenMP/bug63570.c (+10) 



diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 6eca0a5ccab41d7..a4e80a4a9e1fd75 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -8064,7 +8064,8 @@ void CodeGenFunction::EmitSimpleOMPExecutableDirective(
   D.getDirectiveKind() == OMPD_critical ||
   D.getDirectiveKind() == OMPD_section ||
   D.getDirectiveKind() == OMPD_master ||
-  D.getDirectiveKind() == OMPD_masked) {
+  D.getDirectiveKind() == OMPD_masked ||
+  D.getDirectiveKind() == OMPD_unroll) {
 EmitStmt(D.getAssociatedStmt());
   } else {
 auto LPCRegion =
diff --git a/clang/test/OpenMP/bug63570.c b/clang/test/OpenMP/bug63570.c
new file mode 100644
index 000..f61a2ee49b388d0
--- /dev/null
+++ b/clang/test/OpenMP/bug63570.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-apple-darwin10 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c -triple x86_64-apple-darwin10 %s
+// expected-no-diagnostics
+
+void f(float *a, float *b) {
+#pragma omp unroll
+  for (int i = 0; i < 128; i++) {
+a[i] = b[i];
+  }
+}




https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured region (PR #65862)

2023-09-09 Thread Shilei Tian via cfe-commits

https://github.com/shiltian edited 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP] Emit unroll directive w/o captured stmt (PR #65862)

2023-09-09 Thread Shilei Tian via cfe-commits

https://github.com/shiltian edited 
https://github.com/llvm/llvm-project/pull/65862
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Implement [[msvc::no_unique_address]] (PR #65675)

2023-09-09 Thread via cfe-commits

cor3ntin wrote:

We should consider whether we want to support __msvc_no_unique_address__ or 
similar
https://github.com/llvm/llvm-project/issues/61196 

https://github.com/llvm/llvm-project/pull/65675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >