[clang-tools-extra] [clang-doc] Migrate away from PointerUnion::{is,get} (NFC) (PR #120872)

2024-12-22 Thread Nikita Popov via cfe-commits

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


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


[clang] Mechanically port bulk of x86 builtins to TableGen (PR #120831)

2024-12-22 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

> > A long way from an expert on OpenCL, but it seems to not even have the 
> > concept of `long long`, and `long` is defined as a 64-bit type (and just 
> > optional for embedded stuff)?
> > 
> > https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/scalarDataTypes.html
> 
> Thanks for the confirmation! Does OpenCL supports Windows? IIRC, long is 
> 32-bit on Windows.

Yeah, it's definitely different on windows in C/C++.  My impression is that 
opencl long is definitively 64 bit, and thats kind of why Oi exists -- to map 
that to `long long` outside of opencl where it would be ambiguous otherwise.

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


[clang] Mechanically port bulk of x86 builtins to TableGen (PR #120831)

2024-12-22 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

> When I was still involved in X86 my recollection was we primarily used LLi. 
> It looks like there was a large replacement of LLi with Oi here 
> fa8cd7691ac28d07f6a127ed26f0dbe49699bd59.

Yeah, this patch makes me think the change to `Oi` here is ultimately correct, 
and focuses types on the correct 64-bit integer type in the different languages.



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


[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

2024-12-22 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk created 
https://github.com/llvm/llvm-project/pull/120925

Fixes #120875


>From bce88b1bb464438828fc177c978ad2b99957530f Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 23 Dec 2024 02:35:07 +0200
Subject: [PATCH] [Clang] raise extension warning for unknown namespaced
 attributes

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/include/clang/Basic/DiagnosticCommonKinds.td |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp|  2 ++
 .../CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp|  4 ++--
 clang/test/CXX/module/module.interface/p3.cpp  |  2 +-
 clang/test/Lexer/cxx2a-spaceship.cpp   |  2 +-
 clang/test/OpenMP/openmp_attribute_parsing.cpp |  2 +-
 clang/test/Parser/c2x-attributes.c |  2 +-
 clang/test/Parser/cxx0x-attributes.cpp |  2 +-
 clang/test/Sema/patchable-function-entry-attr.cpp  |  2 +-
 clang/test/Sema/unknown-attributes.c   | 10 ++
 clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp  |  4 ++--
 12 files changed, 26 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/Sema/unknown-attributes.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..e2cf90aecf3666 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -552,6 +552,8 @@ Attribute Changes in Clang
 - Clang now permits the usage of the placement new operator in 
``[[msvc::constexpr]]``
   context outside of the std namespace. (#GH74924)
 
+- Clang now raises warnings for unknown namespaced attributes only in pedantic 
mode (#GH120875).
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index f4a155bb00bb37..85653429aa5332 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -179,6 +179,8 @@ def err_opencl_unknown_type_specifier : Error<
 
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
+def ext_unknown_attribute_ignored : Extension<
+  "unknown attribute %0 ignored">, InGroup;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">,
   InGroup;
 def err_keyword_not_supported_on_target : Error<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bb4d33560b93b8..9b1ffebe0804a5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6548,6 +6548,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
? (unsigned)diag::err_keyword_not_supported_on_target
: AL.isDeclspecAttribute()
? (unsigned)diag::warn_unhandled_ms_attribute_ignored
+   : AL.getScopeName()
+   ? (unsigned)diag::ext_unknown_attribute_ignored
: (unsigned)diag::warn_unknown_attribute_ignored)
 << AL << AL.getRange();
 return;
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
index 192fa126109873..c7e66649fb7b22 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
@@ -12,5 +12,5 @@
 [[using clang:]] extern int n; // ok
 [[using blah: clang::optnone]] extern int n; // expected-error {{attribute 
with scope specifier cannot follow}} expected-warning {{only applies to 
functions}}
 
-[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown 
attribute}}
-[[using unknown_ns: something]] extern int n; // expected-warning {{unknown 
attribute}}
+[[using clang: unknown_attr]] extern int n;
+[[using unknown_ns: something]] extern int n;
diff --git a/clang/test/CXX/module/module.interface/p3.cpp 
b/clang/test/CXX/module/module.interface/p3.cpp
index 32819b2dccb11d..3cde92c1a2cf34 100644
--- a/clang/test/CXX/module/module.interface/p3.cpp
+++ b/clang/test/CXX/module/module.interface/p3.cpp
@@ -40,7 +40,7 @@ export { // No diagnostic after P2615R1 DR
   extern "C++" {} // No diagnostic after P2615R1 DR
 }
 export [[]]; // No diagnostic after P2615R1 DR
-export [[example::attr]]; // expected-warning {{unknown attribute 'attr'}}
+export [[example::attr]]; // expected-error {{unknown attribute 'attr'}}
 
 // [...] shall not declare a name with internal linkage
 export static int a; // expected-error {{declaration of 'a' with internal 
linkage cannot be exported}}
diff --git a/clang/test/Lexer/cxx2a-spaceship.cpp 
b/clang/test/Lexer/cxx2a-spaceship.cpp
index 2163a0bf190f90..505f2f47c8ffb8 100644
--- a/clang/test/Lexer/cxx2a-spaceship.cpp
+++ b/clang/test/Lexer/cxx2a-spaceship.cpp
@@ -61,7 +61,7 @@ static_assert(__builtin_strcmp(b, "<=>") == 0);
 // CXX20: preprocess8: <=>=
 
 #define ID(x) x
-[[some_vendor::some_attribu

[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

2024-12-22 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-modules

Author: Oleksandr T. (a-tarasyuk)


Changes

Fixes #120875


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


12 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (+2) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+2) 
- (modified) clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp (+2-2) 
- (modified) clang/test/CXX/module/module.interface/p3.cpp (+1-1) 
- (modified) clang/test/Lexer/cxx2a-spaceship.cpp (+1-1) 
- (modified) clang/test/OpenMP/openmp_attribute_parsing.cpp (+1-1) 
- (modified) clang/test/Parser/c2x-attributes.c (+1-1) 
- (modified) clang/test/Parser/cxx0x-attributes.cpp (+1-1) 
- (modified) clang/test/Sema/patchable-function-entry-attr.cpp (+1-1) 
- (added) clang/test/Sema/unknown-attributes.c (+10) 
- (modified) clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp (+2-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..e2cf90aecf3666 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -552,6 +552,8 @@ Attribute Changes in Clang
 - Clang now permits the usage of the placement new operator in 
``[[msvc::constexpr]]``
   context outside of the std namespace. (#GH74924)
 
+- Clang now raises warnings for unknown namespaced attributes only in pedantic 
mode (#GH120875).
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index f4a155bb00bb37..85653429aa5332 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -179,6 +179,8 @@ def err_opencl_unknown_type_specifier : Error<
 
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
+def ext_unknown_attribute_ignored : Extension<
+  "unknown attribute %0 ignored">, InGroup;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">,
   InGroup;
 def err_keyword_not_supported_on_target : Error<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bb4d33560b93b8..9b1ffebe0804a5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6548,6 +6548,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
? (unsigned)diag::err_keyword_not_supported_on_target
: AL.isDeclspecAttribute()
? (unsigned)diag::warn_unhandled_ms_attribute_ignored
+   : AL.getScopeName()
+   ? (unsigned)diag::ext_unknown_attribute_ignored
: (unsigned)diag::warn_unknown_attribute_ignored)
 << AL << AL.getRange();
 return;
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
index 192fa126109873..c7e66649fb7b22 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
@@ -12,5 +12,5 @@
 [[using clang:]] extern int n; // ok
 [[using blah: clang::optnone]] extern int n; // expected-error {{attribute 
with scope specifier cannot follow}} expected-warning {{only applies to 
functions}}
 
-[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown 
attribute}}
-[[using unknown_ns: something]] extern int n; // expected-warning {{unknown 
attribute}}
+[[using clang: unknown_attr]] extern int n;
+[[using unknown_ns: something]] extern int n;
diff --git a/clang/test/CXX/module/module.interface/p3.cpp 
b/clang/test/CXX/module/module.interface/p3.cpp
index 32819b2dccb11d..3cde92c1a2cf34 100644
--- a/clang/test/CXX/module/module.interface/p3.cpp
+++ b/clang/test/CXX/module/module.interface/p3.cpp
@@ -40,7 +40,7 @@ export { // No diagnostic after P2615R1 DR
   extern "C++" {} // No diagnostic after P2615R1 DR
 }
 export [[]]; // No diagnostic after P2615R1 DR
-export [[example::attr]]; // expected-warning {{unknown attribute 'attr'}}
+export [[example::attr]]; // expected-error {{unknown attribute 'attr'}}
 
 // [...] shall not declare a name with internal linkage
 export static int a; // expected-error {{declaration of 'a' with internal 
linkage cannot be exported}}
diff --git a/clang/test/Lexer/cxx2a-spaceship.cpp 
b/clang/test/Lexer/cxx2a-spaceship.cpp
index 2163a0bf190f90..505f2f47c8ffb8 100644
--- a/clang/test/Lexer/cxx2a-spaceship.cpp
+++ b/clang/test/Lexer/cxx2a-spaceship.cpp
@@ -61,7 +61,7 @@ static_assert(__builtin_strcmp(b, "<=>") == 0);
 // CXX20: preprocess8: <=>=
 
 #define ID(x) x
-[[some_vendor::some_attribute( // expected-warning {{unknown attribute}}
+[[some_vendor::some_attribute(
 preprocess1: ID(<)ID(=>),
 preprocess2: ID(<=)ID(>),
 preprocess3: ID(<)ID(=)ID(>),
diff --git a/clang/test/OpenMP/openmp_attribute

[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/120920

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)

2024-12-22 Thread via cfe-commits

dyung wrote:

> I think I've addressed most of the review comments here at this point.
> 
> But maybe most excitingly, I think the latest version may dodge the issues 
> that have cropped up with MSVC -- both LoongArch and X86 fixes have been 
> incorporated that hopefully help. @dyung -- if you can try it out, let me 
> know.

Sure, I can test it. Just to confirm, what branch/commit should I be testing?



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


[clang] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics (PR #120927)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Phoebe Wang (phoebewang)


Changes

Found during review #120766

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


4 Files Affected:

- (modified) clang/lib/Headers/avx10_2_512convertintrin.h (+2-2) 
- (modified) clang/lib/Headers/avx10_2convertintrin.h (+2-2) 
- (modified) clang/test/CodeGen/X86/avx10_2_512convert-builtins.c (+2-2) 
- (modified) clang/test/CodeGen/X86/avx10_2convert-builtins.c (+2-2) 


``diff
diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h 
b/clang/lib/Headers/avx10_2_512convertintrin.h
index a34e135fa30473..60a5b1ef4548d8 100644
--- a/clang/lib/Headers/avx10_2_512convertintrin.h
+++ b/clang/lib/Headers/avx10_2_512convertintrin.h
@@ -308,13 +308,13 @@ static __inline __m512h __DEFAULT_FN_ATTRS512 
_mm512_cvtpbf8_ph(__m256i __A) {
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask16 __U, __m256i __A) {
+_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_mask_slli_epi16((__m512i)__S, __U, _mm512_cvtepi8_epi16(__A), 8));
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_maskz_cvtpbf8_ph(__mmask16 __U, __m256i __A) {
+_mm512_maskz_cvtpbf8_ph(__mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_slli_epi16(_mm512_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index 134adb2850c8de..efe8477cbbf9be 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -580,13 +580,13 @@ static __inline__ __m256h __DEFAULT_FN_ATTRS256 
_mm256_cvtpbf8_ph(__m128i __A) {
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask8 __U, __m128i __A) {
+_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_mask_slli_epi16((__m256i)__S, __U, _mm256_cvtepi8_epi16(__A), 8));
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvtpbf8_ph(__mmask8 __U, __m128i __A) {
+_mm256_maskz_cvtpbf8_ph(__mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_slli_epi16(_mm256_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
index e71cc0c9ad6b02..6662e0cbf8a913 100644
--- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
@@ -299,7 +299,7 @@ __m512h test_mm512_cvtpbf8_ph(__m256i A) {
   return _mm512_cvtpbf8_ph(A);
 }
 
-__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, __m256i A) {
+__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_mask_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: @llvm.x86.avx512.pslli.w.512
@@ -308,7 +308,7 @@ __m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, 
__m256i A) {
   return _mm512_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m512h test_mm512_maskz_cvtpbf8_ph(__mmask16 M, __m256i A) {
+__m512h test_mm512_maskz_cvtpbf8_ph(__mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
diff --git a/clang/test/CodeGen/X86/avx10_2convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2convert-builtins.c
index 8086c1b5d33993..7121b28719c077 100644
--- a/clang/test/CodeGen/X86/avx10_2convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2convert-builtins.c
@@ -593,7 +593,7 @@ __m128h test_mm_cvtpbf8_ph(__m128i A) {
   return _mm_cvtpbf8_ph(A);
 }
 
-__m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask8 M, __m128i A) {
+__m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask16 M, __m128i A) {
   // CHECK-LABEL: @test_mm_mask_cvtpbf8_ph
   // CHECK: sext <8 x i8> %{{.*}} to <8 x i16>
   // CHECK: @llvm.x86.sse2.pslli.w
@@ -602,7 +602,7 @@ __m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask8 M, 
__m128i A) {
   return _mm_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m128h test_mm_maskz_cvtpbf8_ph(__mmask8 M, __m128i A) {
+__m128h test_mm_maskz_cvtpbf8_ph(__mmask16 M, __m128i A) {
   // CHECK-LABEL: @test_mm_maskz_cvtpbf8_ph
   // CHECK: sext <8 x i8> %{{.*}} to <8 x i16>
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}

``




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


[clang] [clang] constexpr built-in reduce min/max function. (PR #120866)

2024-12-22 Thread via cfe-commits

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


[clang] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics (PR #120927)

2024-12-22 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/120927

>From 608ce20a7b3b8fdd7b65c7afc8f2de7ad271369c Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Mon, 23 Dec 2024 09:05:06 +0800
Subject: [PATCH] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics

Found during review #120766
---
 clang/lib/Headers/avx10_2_512convertintrin.h | 4 ++--
 clang/lib/Headers/avx10_2convertintrin.h | 4 ++--
 clang/test/CodeGen/X86/avx10_2_512convert-builtins.c | 4 ++--
 clang/test/CodeGen/X86/avx10_2convert-builtins.c | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h 
b/clang/lib/Headers/avx10_2_512convertintrin.h
index a34e135fa30473..60a5b1ef4548d8 100644
--- a/clang/lib/Headers/avx10_2_512convertintrin.h
+++ b/clang/lib/Headers/avx10_2_512convertintrin.h
@@ -308,13 +308,13 @@ static __inline __m512h __DEFAULT_FN_ATTRS512 
_mm512_cvtpbf8_ph(__m256i __A) {
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask16 __U, __m256i __A) {
+_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_mask_slli_epi16((__m512i)__S, __U, _mm512_cvtepi8_epi16(__A), 8));
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_maskz_cvtpbf8_ph(__mmask16 __U, __m256i __A) {
+_mm512_maskz_cvtpbf8_ph(__mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_slli_epi16(_mm512_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index 134adb2850c8de..efe8477cbbf9be 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -580,13 +580,13 @@ static __inline__ __m256h __DEFAULT_FN_ATTRS256 
_mm256_cvtpbf8_ph(__m128i __A) {
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask8 __U, __m128i __A) {
+_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_mask_slli_epi16((__m256i)__S, __U, _mm256_cvtepi8_epi16(__A), 8));
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvtpbf8_ph(__mmask8 __U, __m128i __A) {
+_mm256_maskz_cvtpbf8_ph(__mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_slli_epi16(_mm256_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
index e71cc0c9ad6b02..6662e0cbf8a913 100644
--- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
@@ -299,7 +299,7 @@ __m512h test_mm512_cvtpbf8_ph(__m256i A) {
   return _mm512_cvtpbf8_ph(A);
 }
 
-__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, __m256i A) {
+__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_mask_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: @llvm.x86.avx512.pslli.w.512
@@ -308,7 +308,7 @@ __m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, 
__m256i A) {
   return _mm512_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m512h test_mm512_maskz_cvtpbf8_ph(__mmask16 M, __m256i A) {
+__m512h test_mm512_maskz_cvtpbf8_ph(__mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
diff --git a/clang/test/CodeGen/X86/avx10_2convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2convert-builtins.c
index 8086c1b5d33993..7121b28719c077 100644
--- a/clang/test/CodeGen/X86/avx10_2convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2convert-builtins.c
@@ -593,7 +593,7 @@ __m128h test_mm_cvtpbf8_ph(__m128i A) {
   return _mm_cvtpbf8_ph(A);
 }
 
-__m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask8 M, __m128i A) {
+__m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask16 M, __m128i A) {
   // CHECK-LABEL: @test_mm_mask_cvtpbf8_ph
   // CHECK: sext <8 x i8> %{{.*}} to <8 x i16>
   // CHECK: @llvm.x86.sse2.pslli.w
@@ -602,7 +602,7 @@ __m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask8 M, 
__m128i A) {
   return _mm_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m128h test_mm_maskz_cvtpbf8_ph(__mmask8 M, __m128i A) {
+__m128h test_mm_maskz_cvtpbf8_ph(__mmask16 M, __m128i A) {
   // CHECK-LABEL: @test_mm_maskz_cvtpbf8_ph
   // CHECK: sext <8 x i8> %{{.*}} to <8 x i16>
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}

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


[clang] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics (PR #120927)

2024-12-22 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/120927

>From 2b9cde28c2093556d006b5ff0103137f52a7a751 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Mon, 23 Dec 2024 09:05:06 +0800
Subject: [PATCH] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics

Found during review #120766
---
 clang/lib/Headers/avx10_2_512convertintrin.h | 4 ++--
 clang/lib/Headers/avx10_2convertintrin.h | 4 ++--
 clang/test/CodeGen/X86/avx10_2_512convert-builtins.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h 
b/clang/lib/Headers/avx10_2_512convertintrin.h
index a34e135fa30473..60a5b1ef4548d8 100644
--- a/clang/lib/Headers/avx10_2_512convertintrin.h
+++ b/clang/lib/Headers/avx10_2_512convertintrin.h
@@ -308,13 +308,13 @@ static __inline __m512h __DEFAULT_FN_ATTRS512 
_mm512_cvtpbf8_ph(__m256i __A) {
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask16 __U, __m256i __A) {
+_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_mask_slli_epi16((__m512i)__S, __U, _mm512_cvtepi8_epi16(__A), 8));
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_maskz_cvtpbf8_ph(__mmask16 __U, __m256i __A) {
+_mm512_maskz_cvtpbf8_ph(__mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_slli_epi16(_mm512_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index 134adb2850c8de..efe8477cbbf9be 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -580,13 +580,13 @@ static __inline__ __m256h __DEFAULT_FN_ATTRS256 
_mm256_cvtpbf8_ph(__m128i __A) {
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask8 __U, __m128i __A) {
+_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_mask_slli_epi16((__m256i)__S, __U, _mm256_cvtepi8_epi16(__A), 8));
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvtpbf8_ph(__mmask8 __U, __m128i __A) {
+_mm256_maskz_cvtpbf8_ph(__mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_slli_epi16(_mm256_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
index e71cc0c9ad6b02..6662e0cbf8a913 100644
--- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
@@ -299,7 +299,7 @@ __m512h test_mm512_cvtpbf8_ph(__m256i A) {
   return _mm512_cvtpbf8_ph(A);
 }
 
-__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, __m256i A) {
+__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_mask_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: @llvm.x86.avx512.pslli.w.512
@@ -308,7 +308,7 @@ __m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, 
__m256i A) {
   return _mm512_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m512h test_mm512_maskz_cvtpbf8_ph(__mmask16 M, __m256i A) {
+__m512h test_mm512_maskz_cvtpbf8_ph(__mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/120920

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Introduce SingleByteCoverage tests (w/yaml2obj) (PR #113114)

2024-12-22 Thread Jessica Paquette via cfe-commits

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

I don't see any problem with this change.

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


[clang] [Coverage] Introduce the type `CounterPair` for RegionCounterMap. NFC. (PR #112724)

2024-12-22 Thread Jessica Paquette via cfe-commits


@@ -1869,7 +1871,10 @@ void CodeGenFunction::EmitAutoVarInit(const 
AutoVarEmission &emission) {
   // If we are at an unreachable point, we don't need to emit the initializer
   // unless it contains a label.
   if (!HaveInsertPoint()) {
-if (!Init || !ContainsLabel(Init)) return;
+if (!Init || !ContainsLabel(Init)) {
+  PGO.markStmtMaybeUsed(Init);

ornata wrote:

Should it be removed then?

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


[clang] [Coverage] Introduce the type `CounterPair` for RegionCounterMap. NFC. (PR #112724)

2024-12-22 Thread Jessica Paquette via cfe-commits


@@ -1728,6 +1730,7 @@ bool CodeGenFunction::ConstantFoldsToSimpleInteger(const 
Expr *Cond,
   if (!AllowLabels && CodeGenFunction::ContainsLabel(Cond))
 return false;  // Contains a label.
 
+  PGO.markStmtMaybeUsed(Cond);

ornata wrote:

OK gotcha

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


[clang] [Coverage] Introduce the type `CounterPair` for RegionCounterMap. NFC. (PR #112724)

2024-12-22 Thread Jessica Paquette via cfe-commits


@@ -362,6 +362,8 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const 
VarDecl &D,
 return GV;
   }
 
+  PGO.markStmtMaybeUsed(D.getInit()); // FIXME: Too lazy

ornata wrote:

OK gotcha

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


[clang] [compiler-rt] [llvm] Single byte coverage with branch coverage (PR #113115)

2024-12-22 Thread NAKAMURA Takumi via cfe-commits

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


[clang] [llvm] [openmp] [OpenMP] Use generic IR for the OpenMP DeviceRTL (PR #119091)

2024-12-22 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/119091

>From 767d34a0469aa67c2c47a35bc9bff29d20ae1222 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Sat, 7 Dec 2024 13:47:23 -0600
Subject: [PATCH] [OpenMP] Use generic IR for the OpenMP DeviceRTL

Summary:
We previously built this for every single architecture to deal with
incompatibility. This patch updates it to use the 'generic' IR that
`libc` and other projects use. Who knows if this will have any
side-effects, probably worth testing more but it passes the tests I
expect to pass on my side.

update with comment

release notes

fix
---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  3 +-
 clang/lib/Driver/ToolChains/Cuda.cpp  |  1 -
 ...t-nvptx-sm_52.bc => libomptarget-nvptx.bc} |  0
 ...t-nvptx-sm_52.bc => libomptarget-nvptx.bc} |  0
 clang/test/Driver/openmp-offload-gpu.c|  4 +-
 offload/DeviceRTL/CMakeLists.txt  | 76 
 offload/DeviceRTL/src/Reduction.cpp   | 91 ++-
 openmp/docs/ReleaseNotes.rst  |  6 ++
 9 files changed, 75 insertions(+), 109 deletions(-)
 rename clang/test/Driver/Inputs/libomptarget/{libomptarget-nvptx-sm_52.bc => 
libomptarget-nvptx.bc} (100%)
 rename 
clang/test/Driver/Inputs/libomptarget/subdir/{libomptarget-nvptx-sm_52.bc => 
libomptarget-nvptx.bc} (100%)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..ba5aafe25cc934 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1250,6 +1250,9 @@ OpenMP Support
 - Added support for 'omp assume' directive.
 - Added support for 'omp scope' directive.
 - Added support for allocator-modifier in 'allocate' clause.
+- Changed the OpenMP DeviceRTL to use 'generic' IR. The
+  ``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
+  always build support for AMDGPU and NVPTX targets.
 
 Improvements
 
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 47df650e5b9486..e606a7d3d44199 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2837,8 +2837,7 @@ void tools::addOpenMPDeviceRTL(const Driver &D,
 : options::OPT_libomptarget_nvptx_bc_path_EQ;
 
   StringRef ArchPrefix = Triple.isAMDGCN() ? "amdgpu" : "nvptx";
-  std::string LibOmpTargetName =
-  ("libomptarget-" + ArchPrefix + "-" + BitcodeSuffix + ".bc").str();
+  std::string LibOmpTargetName = ("libomptarget-" + ArchPrefix + ".bc").str();
 
   // First check whether user specifies bc library
   if (const Arg *A = DriverArgs.getLastArg(LibomptargetBCPathOpt)) {
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 102794829795da..214f1e5d83478f 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -851,7 +851,6 @@ void CudaToolChain::addClangTargetOptions(
   HostTC.addClangTargetOptions(DriverArgs, CC1Args, DeviceOffloadingKind);
 
   StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
-  assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
   assert((DeviceOffloadingKind == Action::OFK_OpenMP ||
   DeviceOffloadingKind == Action::OFK_Cuda) &&
  "Only OpenMP or CUDA offloading kinds are supported for NVIDIA 
GPUs.");
diff --git a/clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc 
b/clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx.bc
similarity index 100%
rename from clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc
rename to clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx.bc
diff --git 
a/clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc 
b/clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx.bc
similarity index 100%
rename from 
clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc
rename to clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx.bc
diff --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index f6e2245dcdbc05..74bd2a6aeee468 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -90,8 +90,8 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefix=CHK-ENV-BCLIB %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-test.bc
-// CHK-BCLIB-DIR: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget{{/|}}libomptarget-nvptx-sm_52.bc
-// CHK-ENV-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}subdir{{/|}}libomptarget-nvptx-sm_52.bc
+// CHK-BCLIB-DIR: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget{{/|}}libomptarget-nvptx.bc
+//

[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

2024-12-22 Thread Naman Dixit via cfe-commits

namandixit wrote:

Hi, is it possible to add a separate warning for unknown prefixes (as requested 
in the issue)? Enabling `-Wpedantic` is usually considered a best practice, and 
mixing useful warnings (unknown attribute) and less useful ones (unknown 
attribute prefix) will only drive people to either disable the pedantic mode or 
disable the warning altogether (which is something that can already be done).

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


[clang] [NFC][Driver] Simplify linking of ubsan_standalone_cxx (PR #120938)

2024-12-22 Thread Vitaly Buka via cfe-commits

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


[clang] [Driver] Simplify linking of ubsan_standalone_cxx (PR #120938)

2024-12-22 Thread Vitaly Buka via cfe-commits

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


[clang] [NFC][Driver] Simplify linking of ubsan_standalone_cxx (PR #120938)

2024-12-22 Thread Vitaly Buka via cfe-commits

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


[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)

2024-12-22 Thread via cfe-commits

dyung wrote:

> > Sure, I can test it. Just to confirm, what branch/commit should I be 
> > testing?
> 
> This PR has everything in it so you can just test it. There are 3 commits on 
> this branch that won't land here (they're under review in their own PRs), but 
> I've got them all here so you can just test this PR.

Unfortunely it still looks like there are a bunch of failures. They do look 
different from before though. I've uploaded the test log here: 
https://www.dropbox.com/scl/fi/d6e334heik4wp2dlztlq8/log_test.35a7fd79c471cdebd416ba711dbae6970e0e8550.zip?rlkey=kdkeo4897mw3642f9jyn4cmd0&dl=0

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


[clang] [llvm] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 updated https://github.com/llvm/llvm-project/pull/120904

From f36a48a92999cb791bf79b79adddaa73cab6f135 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 00:35:30 +0800
Subject: [PATCH 1/7] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f2cfa7f49f62f9..fa9751cc8a7d92 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -2474,6 +2477,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2831,8 +2837,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there

From 3cdd6fddfbdbf5a27fa2c6cf3c26c57435c78b70 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 01:55:15 +0800
Subject: [PATCH 2/7] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index fa9751cc8a7d92..ccf18bbdea84e0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,7 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+// TODO: Add new Type modifiers
 SmallVector castIdentifiers{"__type_identity_t",
   "remove_reference_t"};
 

From ae3dbe95fc9eaa4c5a6a59ad71cd6db845f68509 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 02:06:59 +0800
Subject: [PATCH 3/7] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index ccf18bbdea84e0..8b19e18a3d7ef5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -17,6 +17,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "format-token-annotator"

From 78dcb7c5615c8e7524c6de11d3233690a6b09534 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Sun, 22 Dec 2024 16:40:00 +
Subject: [PATCH 4/7] [VectorCombine] foldShuffleToIdentity - add debug message
 for match

Helps with debugging to show to that the fold found the match.
---
 llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp 
b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index b7956e037ad4b1..61f9b83b5c697c 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2376,6 +2376,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) 
{
   if (NumVisited <= 1)
 return false;
 
+  LLVM_DEBUG(dbgs() << "Found a superfluous identity shuffle: " << I << "\n");
+
   // If we got this far, we know the shuffles are superfluous and can be
   // removed. Scan through again and generate the new tr

[clang] [llvm] [RISCV] Add support of Sdext, Sdtrig extentions (PR #120936)

2024-12-22 Thread Shao-Ce SUN via cfe-commits

https://github.com/sunshaoce created 
https://github.com/llvm/llvm-project/pull/120936

`Sdext` and `Sdtrig` are RISC-V extensions related to debugging.

The full specification can be found at
https://github.com/riscv/riscv-debug-spec/releases/download/1.0.0-rc4/riscv-debug-specification.pdf

>From 4a44a8551cc8e2c790bec2b6b4300e002216bfc0 Mon Sep 17 00:00:00 2001
From: Shao-Ce SUN 
Date: Mon, 23 Dec 2024 14:54:06 +0800
Subject: [PATCH] [RISCV] Add support of Sdext,Sdtrig extention

The full specification can be found at
https://github.com/riscv/riscv-debug-spec/releases/download/1.0.0-rc4/riscv-debug-specification.pdf
---
 .../Driver/print-supported-extensions-riscv.c |  2 +
 .../test/Preprocessor/riscv-target-features.c | 18 
 llvm/docs/RISCVUsage.rst  |  3 ++
 llvm/docs/ReleaseNotes.md |  1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|  6 +++
 llvm/lib/Target/RISCV/RISCVSystemOperands.td  |  3 ++
 llvm/test/CodeGen/RISCV/attributes.ll |  4 ++
 llvm/test/CodeGen/RISCV/features-info.ll  |  2 +
 llvm/test/MC/RISCV/attribute-arch.s   |  6 +++
 llvm/test/MC/RISCV/machine-csr-names.s| 42 +++
 .../TargetParser/RISCVISAInfoTest.cpp |  2 +
 11 files changed, 89 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8344c1aa399737..df18835e6f3a2a 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -185,6 +185,8 @@
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
+// CHECK-NEXT: sdext1.0   'Sdext' (External debugger)
+// CHECK-NEXT: sdtrig   1.0   'Sdtrig' (Debugger triggers)
 // CHECK-NEXT: smctr1.0   'Smctr' (Control Transfer 
Records Machine Level)
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index e376821a5517c2..c2197711352757 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -182,6 +182,8 @@
 
 // Experimental extensions
 
+// CHECK-NOT: __riscv_sdext{{.*$}}
+// CHECK-NOT: __riscv_sdtrig{{.*$}}
 // CHECK-NOT: __riscv_smctr{{.*$}}
 // CHECK-NOT: __riscv_smmpm{{.*$}}
 // CHECK-NOT: __riscv_smnpm{{.*$}}
@@ -1795,6 +1797,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SUPM-EXT %s
 // CHECK-SUPM-EXT: __riscv_supm 100{{$}}
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN:   -march=rv32i_sdext1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDEXT-EXT %s
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN:   -march=rv64i_sdext1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDEXT-EXT %s
+// CHECK-SDEXT-EXT: __riscv_sdext 100{{$}}
+
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN:   -march=rv32i_sdtrig1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDTRIG-EXT %s
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN:   -march=rv64i_sdtrig1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDTRIG-EXT %s
+// CHECK-SDTRIG-EXT: __riscv_sdtrig 100{{$}}
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN:   -march=rv32i_smctr1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMCTR-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index f6a0dd4bf2383c..9fc6755376ede2 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -326,6 +326,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zvbc32e``, ``experimental-zvkgs``
   LLVM implements the `0.7 release specification 
`__.
 
+``experimental-sdext``, ``experimental-sdtrig``
+  LLVM implements the `1.0-rc4 specification 
`__.
+
 ``experimental-smctr``, ``experimental-ssctr``
   LLVM implements the `1.0-rc3 specification 
`__.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 2835ace34bff83..5a030894

[clang] [llvm] [RISCV] Add support of Sdext, Sdtrig extentions (PR #120936)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: Shao-Ce SUN (sunshaoce)


Changes

`Sdext` and `Sdtrig` are RISC-V extensions related to debugging.

The full specification can be found at
https://github.com/riscv/riscv-debug-spec/releases/download/1.0.0-rc4/riscv-debug-specification.pdf

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


11 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+2) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+18) 
- (modified) llvm/docs/RISCVUsage.rst (+3) 
- (modified) llvm/docs/ReleaseNotes.md (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+6) 
- (modified) llvm/lib/Target/RISCV/RISCVSystemOperands.td (+3) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/CodeGen/RISCV/features-info.ll (+2) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+6) 
- (modified) llvm/test/MC/RISCV/machine-csr-names.s (+42) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+2) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8344c1aa399737..df18835e6f3a2a 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -185,6 +185,8 @@
 // CHECK-NEXT: zalasr   0.1   'Zalasr' (Load-Acquire and 
Store-Release Instructions)
 // CHECK-NEXT: zvbc32e  0.7   'Zvbc32e' (Vector Carryless 
Multiplication with 32-bits elements)
 // CHECK-NEXT: zvkgs0.7   'Zvkgs' (Vector-Scalar GCM 
instructions for Cryptography)
+// CHECK-NEXT: sdext1.0   'Sdext' (External debugger)
+// CHECK-NEXT: sdtrig   1.0   'Sdtrig' (Debugger triggers)
 // CHECK-NEXT: smctr1.0   'Smctr' (Control Transfer 
Records Machine Level)
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index e376821a5517c2..c2197711352757 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -182,6 +182,8 @@
 
 // Experimental extensions
 
+// CHECK-NOT: __riscv_sdext{{.*$}}
+// CHECK-NOT: __riscv_sdtrig{{.*$}}
 // CHECK-NOT: __riscv_smctr{{.*$}}
 // CHECK-NOT: __riscv_smmpm{{.*$}}
 // CHECK-NOT: __riscv_smnpm{{.*$}}
@@ -1795,6 +1797,22 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SUPM-EXT %s
 // CHECK-SUPM-EXT: __riscv_supm 100{{$}}
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN:   -march=rv32i_sdext1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDEXT-EXT %s
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN:   -march=rv64i_sdext1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDEXT-EXT %s
+// CHECK-SDEXT-EXT: __riscv_sdext 100{{$}}
+
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN:   -march=rv32i_sdtrig1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDTRIG-EXT %s
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN:   -march=rv64i_sdtrig1p0 -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SDTRIG-EXT %s
+// CHECK-SDTRIG-EXT: __riscv_sdtrig 100{{$}}
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN:   -march=rv32i_smctr1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SMCTR-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index f6a0dd4bf2383c..9fc6755376ede2 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -326,6 +326,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zvbc32e``, ``experimental-zvkgs``
   LLVM implements the `0.7 release specification 
`__.
 
+``experimental-sdext``, ``experimental-sdtrig``
+  LLVM implements the `1.0-rc4 specification 
`__.
+
 ``experimental-smctr``, ``experimental-ssctr``
   LLVM implements the `1.0-rc3 specification 
`__.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 2835ace34bff83..5a0308944435dc 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -226,6 +226,7 @@ Changes to the RISC-V Backend
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load 
Store Multiple)
   exten

[clang] [llvm] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff db2307d2d7f650aa8f0d9ba727abfe83a32bc3bf 
8b1d1162378e7a11902b92a44bfdd75001ea6239 --extensions cpp -- 
clang/lib/Format/TokenAnnotator.cpp 
clang/unittests/Format/TokenAnnotatorTest.cpp 
llvm/lib/Target/X86/X86ISelLowering.cpp 
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index da9860c7cd..3f44b8c185 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -42,7 +42,7 @@ namespace {
 
 // TODO: Add new Type modifiers
 llvm::SmallVector castIdentifiers{"__type_identity_t",
-  "remove_reference_t"};
+   "remove_reference_t"};
 
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
@@ -2481,9 +2481,10 @@ private:
 Current.setType(TT_StringInConcatenation);
   }
 } else if (Style.isCpp() && Current.is(tok::kw_using)) {
-  if (Current.Next && Current.Next->Next && Current.Next->Next->Next)
+  if (Current.Next && Current.Next->Next && Current.Next->Next->Next) {
 if (Current.Next->Next->Next->isTypeName(LangOpts))
   castIdentifiers.push_back(Current.Next->TokenText);
+  }
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2842,9 +2843,11 @@ private:
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
 if (ParensAreType && !ParensCouldEndDecl) {
-  if (BeforeRParen->is(TT_TemplateCloser) ) {
-if (determineUnaryOperatorByUsage(*AfterRParen)) return true;
-if (AfterRParen->isOneOf(tok::plus, tok::minus, tok::star, 
tok::exclaim, tok::amp)) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+if (determineUnaryOperatorByUsage(*AfterRParen))
+  return true;
+if (AfterRParen->isOneOf(tok::plus, tok::minus, tok::star, 
tok::exclaim,
+ tok::amp)) {
   auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
   for (auto &name : castIdentifiers)
 if (Prev->TokenText == name)

``




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


[clang] [llvm] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 updated https://github.com/llvm/llvm-project/pull/120904

From f36a48a92999cb791bf79b79adddaa73cab6f135 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 00:35:30 +0800
Subject: [PATCH 1/8] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f2cfa7f49f62f9..fa9751cc8a7d92 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -2474,6 +2477,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2831,8 +2837,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there

From 3cdd6fddfbdbf5a27fa2c6cf3c26c57435c78b70 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 01:55:15 +0800
Subject: [PATCH 2/8] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index fa9751cc8a7d92..ccf18bbdea84e0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,7 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+// TODO: Add new Type modifiers
 SmallVector castIdentifiers{"__type_identity_t",
   "remove_reference_t"};
 

From ae3dbe95fc9eaa4c5a6a59ad71cd6db845f68509 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 02:06:59 +0800
Subject: [PATCH 3/8] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index ccf18bbdea84e0..8b19e18a3d7ef5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -17,6 +17,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "format-token-annotator"

From 78dcb7c5615c8e7524c6de11d3233690a6b09534 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Sun, 22 Dec 2024 16:40:00 +
Subject: [PATCH 4/8] [VectorCombine] foldShuffleToIdentity - add debug message
 for match

Helps with debugging to show to that the fold found the match.
---
 llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp 
b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index b7956e037ad4b1..61f9b83b5c697c 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2376,6 +2376,8 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) 
{
   if (NumVisited <= 1)
 return false;
 
+  LLVM_DEBUG(dbgs() << "Found a superfluous identity shuffle: " << I << "\n");
+
   // If we got this far, we know the shuffles are superfluous and can be
   // removed. Scan through again and generate the new tr

[clang] 4b35dd5 - [Serialization] Try to clean up PendingUndeducedFunctionDecls when

2024-12-22 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2024-12-23T15:14:38+08:00
New Revision: 4b35dd57b88a59b169c3471cbc398113d3bf98e8

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

LOG: [Serialization] Try to clean up PendingUndeducedFunctionDecls when
PendingUndeducedFunctionDecls is not empty

Close https://github.com/llvm/llvm-project/issues/120277

This turns out to be a simple oversight initially. See the analysis in
https://github.com/llvm/llvm-project/commit/ba1e84fb8f45e102f40f409fcfe9b420fbf9fb70
for the wider background.

Added: 
clang/test/Modules/pr120277.cppm

Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 15160b0751f83b..fccd79bf745203 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10642,7 +10642,8 @@ void ASTReader::FinishedDeserializing() {
 // We do this now rather than in finishPendingActions because we want to
 // be able to walk the complete redeclaration chains of the updated decls.
 while (!PendingExceptionSpecUpdates.empty() ||
-   !PendingDeducedTypeUpdates.empty()) {
+   !PendingDeducedTypeUpdates.empty() ||
+   !PendingUndeducedFunctionDecls.empty()) {
   auto ESUpdates = std::move(PendingExceptionSpecUpdates);
   PendingExceptionSpecUpdates.clear();
   for (auto Update : ESUpdates) {

diff  --git a/clang/test/Modules/pr120277.cppm 
b/clang/test/Modules/pr120277.cppm
new file mode 100644
index 00..a4f55ef113b2cd
--- /dev/null
+++ b/clang/test/Modules/pr120277.cppm
@@ -0,0 +1,58 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface -o %t/c.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/d.cppm -emit-module-interface -o %t/d.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 %t/d.pcm -emit-llvm -o %t/d.ll \
+// RUN: -fprebuilt-module-path=%t
+// RUN: cat %t/d.ll | FileCheck %t/d.cppm
+
+//--- a.cppm
+export module a;
+
+export template
+struct a {
+   static auto f() {
+   }
+};
+
+//--- b.cppm
+export module b;
+
+import a;
+
+void b() {
+   a<0> t;
+}
+
+//--- c.cppm
+export module c;
+
+import a;
+
+void c() {
+   a<0>::f();
+}
+
+//--- d.cppm
+export module d;
+
+import a;
+import b;
+import c;
+
+struct d {
+   static void g() {
+   a<0>::f();
+   a<1>::f();
+   }
+};
+
+// fine enough to check it won't crash
+// CHECK: define



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


[clang] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)

2024-12-22 Thread Antonio Frighetto via cfe-commits

https://github.com/antoniofrighetto updated 
https://github.com/llvm/llvm-project/pull/120783

>From 81c1e35fc28f43c2f23df328244de0528f4bf1d0 Mon Sep 17 00:00:00 2001
From: Antonio Frighetto 
Date: Fri, 20 Dec 2024 19:30:59 +0100
Subject: [PATCH 1/2] [IR][ModRef] Introduce `errno` memory location

Model C/C++ `errno` macro by adding a corresponding `errno`
memory location kind to the IR. Preliminary work to separate
`errno` writes from other memory accesses, to the benefit of
alias analyses and optimization correctness.

Previous discussion: 
https://discourse.llvm.org/t/rfc-modelling-errno-memory-effects/82972.
---
 llvm/include/llvm/AsmParser/LLToken.h |  2 ++
 llvm/include/llvm/IR/Function.h   |  4 +++
 llvm/include/llvm/IR/InstrTypes.h |  4 +++
 llvm/include/llvm/Support/ModRef.h| 19 +++-
 llvm/lib/AsmParser/LLLexer.cpp|  1 +
 llvm/lib/AsmParser/LLParser.cpp   |  7 -
 llvm/lib/IR/Attributes.cpp|  3 ++
 llvm/lib/IR/Function.cpp  |  8 +
 llvm/lib/IR/Instructions.cpp  |  8 +
 llvm/lib/Support/ModRef.cpp   |  3 ++
 .../test/Assembler/memory-attribute-errors.ll |  6 ++--
 llvm/test/Assembler/memory-attribute.ll   | 12 
 .../Transforms/FunctionAttrs/argmemonly.ll| 22 +++---
 .../Transforms/FunctionAttrs/nocapture.ll | 30 +--
 .../FunctionAttrs/read-write-scc.ll   |  4 +--
 .../Transforms/FunctionAttrs/readattrs.ll |  2 +-
 .../Transforms/FunctionAttrs/writeonly.ll |  4 +--
 .../InferFunctionAttrs/norecurse_debug.ll |  2 +-
 .../cfi-nounwind-direct-call.ll   |  2 +-
 .../Transforms/SCCP/ipscp-drop-argmemonly.ll  | 12 
 llvm/unittests/Support/ModRefTest.cpp |  4 +--
 21 files changed, 113 insertions(+), 46 deletions(-)

diff --git a/llvm/include/llvm/AsmParser/LLToken.h 
b/llvm/include/llvm/AsmParser/LLToken.h
index 178c911120b4ce..ac0887f8e5fb52 100644
--- a/llvm/include/llvm/AsmParser/LLToken.h
+++ b/llvm/include/llvm/AsmParser/LLToken.h
@@ -201,11 +201,13 @@ enum Kind {
   kw_readwrite,
   kw_argmem,
   kw_inaccessiblemem,
+  kw_errnomem,
 
   // Legacy memory attributes:
   kw_argmemonly,
   kw_inaccessiblememonly,
   kw_inaccessiblemem_or_argmemonly,
+  kw_errnomemonly,
 
   // nofpclass attribute:
   kw_all,
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index e7afcbd31420c1..bb8e6d5a7e38ec 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -575,6 +575,10 @@ class LLVM_ABI Function : public GlobalObject, public 
ilist_node {
   bool onlyAccessesInaccessibleMemory() const;
   void setOnlyAccessesInaccessibleMemory();
 
+  /// Determine if the function may only access errno memory.
+  bool onlyAccessesErrnoMemory() const;
+  void setOnlyAccessesErrnoMemory();
+
   /// Determine if the function may only access memory that is
   ///  either inaccessible from the IR or pointed to by its arguments.
   bool onlyAccessesInaccessibleMemOrArgMem() const;
diff --git a/llvm/include/llvm/IR/InstrTypes.h 
b/llvm/include/llvm/IR/InstrTypes.h
index e6332a16df7d5f..ba9a5c21467ec4 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1907,6 +1907,10 @@ class CallBase : public Instruction {
   bool onlyAccessesInaccessibleMemory() const;
   void setOnlyAccessesInaccessibleMemory();
 
+  /// Determine if the function may only access errno memory.
+  bool onlyAccessesErrnoMemory() const;
+  void setOnlyAccessesErrnoMemory();
+
   /// Determine if the function may only access memory that is
   /// either inaccessible from the IR or pointed to by its arguments.
   bool onlyAccessesInaccessibleMemOrArgMem() const;
diff --git a/llvm/include/llvm/Support/ModRef.h 
b/llvm/include/llvm/Support/ModRef.h
index 5a9d80c87ae27a..b5071246d36c2f 100644
--- a/llvm/include/llvm/Support/ModRef.h
+++ b/llvm/include/llvm/Support/ModRef.h
@@ -61,8 +61,10 @@ enum class IRMemLocation {
   ArgMem = 0,
   /// Memory that is inaccessible via LLVM IR.
   InaccessibleMem = 1,
+  /// Errno memory.
+  ErrnoMem = 2,
   /// Any other memory.
-  Other = 2,
+  Other = 3,
 
   /// Helpers to iterate all locations in the MemoryEffectsBase class.
   First = ArgMem,
@@ -139,6 +141,11 @@ template  class MemoryEffectsBase {
 return MemoryEffectsBase(Location::InaccessibleMem, MR);
   }
 
+  /// Create MemoryEffectsBase that can only access errno memory.
+  static MemoryEffectsBase errnoMemOnly(ModRefInfo MR = ModRefInfo::ModRef) {
+return MemoryEffectsBase(Location::ErrnoMem, MR);
+  }
+
   /// Create MemoryEffectsBase that can only access inaccessible or argument
   /// memory.
   static MemoryEffectsBase
@@ -207,11 +214,21 @@ template  class MemoryEffectsBase {
 return isModOrRefSet(getModRef(Location::ArgMem));
   }
 
+  /// Whether this function may access errno memory.
+  bool doesAccessErrno

[clang] [Driver] Simplify linking of ubsan_standalone_cxx (PR #120938)

2024-12-22 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/120938

None

>From 1b260afe040e879e2202004ff8e33634666f586f Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Sun, 22 Dec 2024 23:48:48 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 47df650e5b9486..e33fa443b3a0ec 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1561,8 +1561,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
   StaticRuntimes.push_back("ubsan_minimal");
 } else {
   StaticRuntimes.push_back("ubsan_standalone");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("ubsan_standalone_cxx");
 }
   }
   if (SanArgs.needsSafeStackRt()) {
@@ -1572,11 +1570,13 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
   if (!(SanArgs.needsSharedRt() && SanArgs.needsUbsanRt())) {
 if (SanArgs.needsCfiRt())
   StaticRuntimes.push_back("cfi");
-if (SanArgs.needsCfiDiagRt()) {
+if (SanArgs.needsCfiDiagRt())
   StaticRuntimes.push_back("cfi_diag");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("ubsan_standalone_cxx");
-}
+  }
+  if (SanArgs.linkCXXRuntimes() && !SanArgs.requiresMinimalRuntime() &&
+  ((!SanArgs.needsSharedRt() && SanArgs.needsUbsanRt()) ||
+   SanArgs.needsCfiDiagRt())) {
+StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
   if (SanArgs.needsStatsRt()) {
 NonWholeStaticRuntimes.push_back("stats");

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


[clang] [Driver] Simplify linking of ubsan_standalone_cxx (PR #120938)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)


Changes



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


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+6-6) 


``diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 47df650e5b9486..e33fa443b3a0ec 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1561,8 +1561,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
   StaticRuntimes.push_back("ubsan_minimal");
 } else {
   StaticRuntimes.push_back("ubsan_standalone");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("ubsan_standalone_cxx");
 }
   }
   if (SanArgs.needsSafeStackRt()) {
@@ -1572,11 +1570,13 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
   if (!(SanArgs.needsSharedRt() && SanArgs.needsUbsanRt())) {
 if (SanArgs.needsCfiRt())
   StaticRuntimes.push_back("cfi");
-if (SanArgs.needsCfiDiagRt()) {
+if (SanArgs.needsCfiDiagRt())
   StaticRuntimes.push_back("cfi_diag");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("ubsan_standalone_cxx");
-}
+  }
+  if (SanArgs.linkCXXRuntimes() && !SanArgs.requiresMinimalRuntime() &&
+  ((!SanArgs.needsSharedRt() && SanArgs.needsUbsanRt()) ||
+   SanArgs.needsCfiDiagRt())) {
+StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
   if (SanArgs.needsStatsRt()) {
 NonWholeStaticRuntimes.push_back("stats");

``




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


[clang] [Driver] Simplify linking of ubsan_standalone_cxx (PR #120938)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Vitaly Buka (vitalybuka)


Changes



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


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+6-6) 


``diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 47df650e5b9486..e33fa443b3a0ec 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1561,8 +1561,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
   StaticRuntimes.push_back("ubsan_minimal");
 } else {
   StaticRuntimes.push_back("ubsan_standalone");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("ubsan_standalone_cxx");
 }
   }
   if (SanArgs.needsSafeStackRt()) {
@@ -1572,11 +1570,13 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
   if (!(SanArgs.needsSharedRt() && SanArgs.needsUbsanRt())) {
 if (SanArgs.needsCfiRt())
   StaticRuntimes.push_back("cfi");
-if (SanArgs.needsCfiDiagRt()) {
+if (SanArgs.needsCfiDiagRt())
   StaticRuntimes.push_back("cfi_diag");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("ubsan_standalone_cxx");
-}
+  }
+  if (SanArgs.linkCXXRuntimes() && !SanArgs.requiresMinimalRuntime() &&
+  ((!SanArgs.needsSharedRt() && SanArgs.needsUbsanRt()) ||
+   SanArgs.needsCfiDiagRt())) {
+StaticRuntimes.push_back("ubsan_standalone_cxx");
   }
   if (SanArgs.needsStatsRt()) {
 NonWholeStaticRuntimes.push_back("stats");

``




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


[clang] [X86][AVX10.2] Add comments for the avx10_2convertintrin.h file (PR #120766)

2024-12-22 Thread Phoebe Wang via cfe-commits
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= 
Message-ID:
In-Reply-To: 



@@ -24,573 +24,3369 @@
   __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"),
\
  __min_vector_width__(256)))
 
+// clang-format off
+
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///
+/// dst[MAX:127] := 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __A
+///A 128-bit vector of [4 x float].
+/// \param __B
+///A 128-bit vector of [4 x float].
+/// \returns
+///A 128-bit vector of [8 x half]. Lower elements correspond to the
+///(converted) elements from \a __B; higher order elements correspond to 
the
+///(converted) elements from \a __A.
 static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtx2ps_ph(__m128 __A,
__m128 __B) {
   return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask(
   (__v4sf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)(-1));
 }
 
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements. Merging mask \a __U is used to determine if 
given
+///element should be taken from \a __W instead.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF __U[i]
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///ELSE
+///dst.fp16[i] := __W.fp16[i]
+///FI
+///
+/// dst[MAX:127] := 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __W
+///A 128-bit vector of [8 x half].
+/// \param __U
+///A 8-bit merging mask.
+/// \param __A
+///A 128-bit vector of [4 x float].
+/// \param __B
+///A 128-bit vector of [4 x float].
+/// \returns
+///A 128-bit vector of [8 x half]. Lower elements correspond to the
+///(converted) elements from \a __B; higher order elements correspond to 
the
+///(converted) elements from \a __A. If corresponding mask bit is not set, 
then
+///element from \a __W is taken instead.
 static __inline__ __m128h __DEFAULT_FN_ATTRS128
 _mm_mask_cvtx2ps_ph(__m128h __W, __mmask8 __U, __m128 __A, __m128 __B) {
   return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask(
   (__v4sf)__A, (__v4sf)__B, (__v8hf)__W, (__mmask8)__U);
 }
 
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements. Zeroing mask \a __U is used to determine if 
given
+///element should be zeroed instead.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF __U[i]
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///ELSE
+///dst.fp16[i] := 0
+///FI
+/// ENDFOR
+///
+/// dst[MAX:127] := 0
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __U
+///A 8-bit zeroing mask.
+/// \param __A
+///A 128-bit vector of [4 x float].
+/// \param __B
+///A 128-bit vector of [4 x float].
+/// \returns
+///A 128-bit vector of [8 x half]. Lower elements correspond to the
+///(converted) elements from \a __B; higher order elements correspond to 
the
+///(converted) elements from \a __A. If corresponding mask bit is not set,
+///then zero is taken instead.
 static __inline__ __m128h __DEFAULT_FN_ATTRS128
 _mm_maskz_cvtx2ps_ph(__mmask8 __U, __m128 __A, __m128 __B) {
   return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask(
   (__v4sf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U);
 }
 
+/// Convert two 256-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 256-bit vector
+///containing FP16 elements.
+///
+/// \code{.operation}
+/// FOR i := 0 to 15 
+///IF i < 8

[clang] [X86][AVX10.2] Add comments for the avx10_2convertintrin.h file (PR #120766)

2024-12-22 Thread Phoebe Wang via cfe-commits
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= ,
=?utf-8?q?Mikołaj_Piróg?= 
Message-ID:
In-Reply-To: 



@@ -24,573 +24,3369 @@
   __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"),
\
  __min_vector_width__(256)))
 
+// clang-format off
+
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///
+/// dst[MAX:127] := 0

phoebewang wrote:

Move it out of `FOR`.

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/120920

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/120920

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Introduce SingleByteCoverage tests (w/yaml2obj) (PR #113114)

2024-12-22 Thread NAKAMURA Takumi via cfe-commits

chapuni wrote:

@ornata Thanks. I'll merge this possibly tomorrow unless objections.

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

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


[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 updated https://github.com/llvm/llvm-project/pull/120904

From f36a48a92999cb791bf79b79adddaa73cab6f135 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 00:35:30 +0800
Subject: [PATCH 1/2] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f2cfa7f49f62f9..fa9751cc8a7d92 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -2474,6 +2477,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2831,8 +2837,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there

From 3cdd6fddfbdbf5a27fa2c6cf3c26c57435c78b70 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 01:55:15 +0800
Subject: [PATCH 2/2] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index fa9751cc8a7d92..ccf18bbdea84e0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,7 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+// TODO: Add new Type modifiers
 SmallVector castIdentifiers{"__type_identity_t",
   "remove_reference_t"};
 

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


[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-22 Thread via cfe-commits

https://github.com/4m4n-x-B4w4ne updated 
https://github.com/llvm/llvm-project/pull/120087

>From 03f536888ddc5b7be2514c2d880c6d3119b7f4ee Mon Sep 17 00:00:00 2001
From: 4m4n-x-B4w4ne <125849251+4m4n-x-b4w...@users.noreply.github.com>
Date: Mon, 16 Dec 2024 19:43:42 +0530
Subject: [PATCH 01/32] Update ImplicitBoolConversionCheck.cpp

Added new options in ImplicitBoolConversionCheck CheckConversionToBool and 
CheckConversionFromBool.
---
 .../readability/ImplicitBoolConversionCheck.cpp   | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index f9fd1d903e231e..517a5d2b982751 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -258,14 +258,17 @@ ImplicitBoolConversionCheck::ImplicitBoolConversionCheck(
 : ClangTidyCheck(Name, Context),
   AllowIntegerConditions(Options.get("AllowIntegerConditions", false)),
   AllowPointerConditions(Options.get("AllowPointerConditions", false)),
-  UseUpperCaseLiteralSuffix(
-  Options.get("UseUpperCaseLiteralSuffix", false)) {}
+  UseUpperCaseLiteralSuffix(Options.get("UseUpperCaseLiteralSuffix", 
false)),
+  CheckConversionsToBool(Options.get("CheckConversionsToBool",true)),
+  CheckConversionsFromBool(Options.get("CheckConversionsFromBool",true)) {}
 
 void ImplicitBoolConversionCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "AllowIntegerConditions", AllowIntegerConditions);
   Options.store(Opts, "AllowPointerConditions", AllowPointerConditions);
   Options.store(Opts, "UseUpperCaseLiteralSuffix", UseUpperCaseLiteralSuffix);
+  Options.store(Opts,"CheckConversionsToBool",CheckConversionsToBool);
+  Options.store(Opts,"CheckConversionsFromBool",CheckConversionsFromBool);
 }
 
 void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
@@ -358,14 +361,14 @@ void 
ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
 void ImplicitBoolConversionCheck::check(
 const MatchFinder::MatchResult &Result) {
 
-  if (const auto *CastToBool =
-  Result.Nodes.getNodeAs("implicitCastToBool")) {
+  if (CheckConversionsToBool && (const auto *CastToBool =
+  Result.Nodes.getNodeAs("implicitCastToBool"))) {
 const auto *Parent = Result.Nodes.getNodeAs("parentStmt");
 return handleCastToBool(CastToBool, Parent, *Result.Context);
   }
 
-  if (const auto *CastFromBool =
-  Result.Nodes.getNodeAs("implicitCastFromBool")) {
+  if (CheckConversionsFromBool && (const auto *CastFromBool =
+  Result.Nodes.getNodeAs("implicitCastFromBool"))) {
 const auto *NextImplicitCast =
 Result.Nodes.getNodeAs("furtherImplicitCast");
 return handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);

>From 16c7c95939b4c0c38ebccbbc6cd1da3739244a24 Mon Sep 17 00:00:00 2001
From: 4m4n-x-B4w4ne <125849251+4m4n-x-b4w...@users.noreply.github.com>
Date: Mon, 16 Dec 2024 19:45:37 +0530
Subject: [PATCH 02/32] Update ImplicitBoolConversionCheck.h

Added CheckConversionToBool and CheckConversionFromBool Options in the header
---
 .../clang-tidy/readability/ImplicitBoolConversionCheck.h| 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
index 5947f7316e67cc..b0c3c2943e649c 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
@@ -37,6 +37,8 @@ class ImplicitBoolConversionCheck : public ClangTidyCheck {
   const bool AllowIntegerConditions;
   const bool AllowPointerConditions;
   const bool UseUpperCaseLiteralSuffix;
+  const bool CheckConversionsToBool;
+  const bool CheckConversionsFromBool;
 };
 
 } // namespace clang::tidy::readability

>From 0d6fae8b08a4a365c9295ac8a96de2aba9974c98 Mon Sep 17 00:00:00 2001
From: 4m4n-x-B4w4ne <125849251+4m4n-x-b4w...@users.noreply.github.com>
Date: Mon, 16 Dec 2024 19:48:48 +0530
Subject: [PATCH 03/32] Create implicit-bool-conversion-check.cpp

Added new test to check the new options added in the 
ImplicitBoolConversionCheck.cpp
---
 .../implicit-bool-conversion-check.cpp| 92 +++
 1 file changed, 92 insertions(+)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-check.cpp

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-check.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-check.cpp
new file mode 100644
index 00..506769d5a57322
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers

[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 updated https://github.com/llvm/llvm-project/pull/120904

From f36a48a92999cb791bf79b79adddaa73cab6f135 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 00:35:30 +0800
Subject: [PATCH 1/3] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f2cfa7f49f62f9..fa9751cc8a7d92 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -2474,6 +2477,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2831,8 +2837,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there

From 3cdd6fddfbdbf5a27fa2c6cf3c26c57435c78b70 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 01:55:15 +0800
Subject: [PATCH 2/3] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index fa9751cc8a7d92..ccf18bbdea84e0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,7 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+// TODO: Add new Type modifiers
 SmallVector castIdentifiers{"__type_identity_t",
   "remove_reference_t"};
 

From ae3dbe95fc9eaa4c5a6a59ad71cd6db845f68509 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 02:06:59 +0800
Subject: [PATCH 3/3] [Clang] Repair the functionrParenEndsCast to make
 incorrect judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index ccf18bbdea84e0..8b19e18a3d7ef5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -17,6 +17,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "format-token-annotator"

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


[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-22 Thread via cfe-commits




4m4n-x-B4w4ne wrote:

I have written check file for all permutations of configuration of the options 
and also for the more comprehensive test cases as instructed with clean PR 
build.
Done Thanks.
@5chmidti  Can you please review it?

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


[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 updated https://github.com/llvm/llvm-project/pull/120904

From f36a48a92999cb791bf79b79adddaa73cab6f135 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Mon, 23 Dec 2024 00:35:30 +0800
Subject: [PATCH] [Clang] Repair the functionrParenEndsCast to make incorrect
 judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index f2cfa7f49f62f9..fa9751cc8a7d92 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -38,6 +38,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -2474,6 +2477,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2831,8 +2837,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there

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


[clang] [clang][ObjectiveC] Fix Parsing the `::` Optional Scope Specifier (PR #119908)

2024-12-22 Thread Fangrui Song via cfe-commits

MaskRay wrote:

(https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it/74223
 the convention is to disable github's hide-email feature)

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


[clang] [X86][AVX10.2] Add comments for the avx10_2convertintrin.h file (PR #120766)

2024-12-22 Thread Mikołaj Piróg via cfe-commits


@@ -24,573 +24,3369 @@
   __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"),
\
  __min_vector_width__(256)))
 
+//clang-format off
+
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///
+/// dst[MAX:127] := 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __A
+///A 128-bit vector of [4 x float].
+/// \param __B
+///A 128-bit vector of [4 x float].
+/// \returns
+///A 128-bit vector of [8 x fp16]. Lower elements correspond to the
+///(converted) elements from \a __B; higher order elements correspond to 
the
+///(converted) elements from \a __A.
 static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtx2ps_ph(__m128 __A,
__m128 __B) {
   return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask(
   (__v4sf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)(-1));
 }
 
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements. Merging mask \a __U is used to determine if 
given
+///element should be taken from \a __W instead.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF __U[i]
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///ELSE
+///dst.fp16[i] := __W.fp16[i]
+///FI
+///
+/// dst[MAX:127] := 0
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __W
+///A 128-bit vector of [8 x fp16].
+/// \param __U
+///A 8-bit merging mask.
+/// \param __A
+///A 128-bit vector of [4 x float].
+/// \param __B
+///A 128-bit vector of [4 x float].
+/// \returns
+///A 128-bit vector of [8 x fp16]. Lower elements correspond to the
+///(converted) elements from \a __B; higher order elements correspond to 
the
+///(converted) elements from \a __A. If corresponding mask bit is not set, 
then
+///element from \a __W is taken instead.
 static __inline__ __m128h __DEFAULT_FN_ATTRS128
 _mm_mask_cvtx2ps_ph(__m128h __W, __mmask8 __U, __m128 __A, __m128 __B) {
   return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask(
   (__v4sf)__A, (__v4sf)__B, (__v8hf)__W, (__mmask8)__U);
 }
 
+/// Convert two 128-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 128-bit vector
+///containing FP16 elements. Zeroing mask \a __U is used to determine if 
given
+///element should be zeroed instead.
+///
+/// \code{.operation}
+/// FOR i := 0 to 7
+///IF __U[i]
+///IF i < 4
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4])
+///FI
+///ELSE
+///dst.fp16[i] := 0
+///FI
+/// ENDFOR
+///
+/// dst[MAX:127] := 0
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __U
+///A 8-bit zeroing mask.
+/// \param __A
+///A 128-bit vector of [4 x float].
+/// \param __B
+///A 128-bit vector of [4 x float].
+/// \returns
+///A 128-bit vector of [8 x fp16]. Lower elements correspond to the
+///(converted) elements from \a __B; higher order elements correspond to 
the
+///(converted) elements from \a __A. If corresponding mask bit is not set,
+///then zero is taken instead.
 static __inline__ __m128h __DEFAULT_FN_ATTRS128
 _mm_maskz_cvtx2ps_ph(__mmask8 __U, __m128 __A, __m128 __B) {
   return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask(
   (__v4sf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U);
 }
 
+/// Convert two 256-bit vectors, \a __A and \a __B, containing packed
+///single-precision (32-bit) floating-point elements to a 256-bit vector
+///containing FP16 elements.
+///
+/// \code{.operation}
+/// FOR i := 0 to 15 
+///IF i < 8
+///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
+///ELSE
+///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 8])
+///FI
+/// ENDFOR
+///
+/// dst[MAX:256] := 0
+/// \endcode
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
+///
+/// \param __A
+///A 256-bit vector of [8 x fl

[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/120920

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

2024-12-22 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 44514316bd5ef656076b6baaf6bccb298d98f0ea 
bce88b1bb464438828fc177c978ad2b99957530f --extensions c,cpp -- 
clang/test/Sema/unknown-attributes.c clang/lib/Sema/SemaDeclAttr.cpp 
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp 
clang/test/CXX/module/module.interface/p3.cpp 
clang/test/Lexer/cxx2a-spaceship.cpp 
clang/test/OpenMP/openmp_attribute_parsing.cpp 
clang/test/Parser/c2x-attributes.c clang/test/Parser/cxx0x-attributes.cpp 
clang/test/Sema/patchable-function-entry-attr.cpp 
clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 9b1ffebe08..520508a2c9 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6548,9 +6548,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
? (unsigned)diag::err_keyword_not_supported_on_target
: AL.isDeclspecAttribute()
? (unsigned)diag::warn_unhandled_ms_attribute_ignored
-   : AL.getScopeName()
-   ? (unsigned)diag::ext_unknown_attribute_ignored
-   : (unsigned)diag::warn_unknown_attribute_ignored)
+   : AL.getScopeName() ? (unsigned)diag::ext_unknown_attribute_ignored
+   : 
(unsigned)diag::warn_unknown_attribute_ignored)
 << AL << AL.getRange();
 return;
   }

``




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


[clang] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics (PR #120927)

2024-12-22 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/120927

Found during review #120766

>From 13176bdf116f54aee7ffed4b22cace39776c6515 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Mon, 23 Dec 2024 09:05:06 +0800
Subject: [PATCH] [X86][AVX10.2] Fix wrong mask bits in cvtpbf8_ph intrinsics

Found during review #120766
---
 clang/lib/Headers/avx10_2_512convertintrin.h | 4 ++--
 clang/lib/Headers/avx10_2convertintrin.h | 4 ++--
 clang/test/CodeGen/X86/avx10_2_512convert-builtins.c | 4 ++--
 clang/test/CodeGen/X86/avx10_2convert-builtins.c | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Headers/avx10_2_512convertintrin.h 
b/clang/lib/Headers/avx10_2_512convertintrin.h
index a34e135fa30473..60a5b1ef4548d8 100644
--- a/clang/lib/Headers/avx10_2_512convertintrin.h
+++ b/clang/lib/Headers/avx10_2_512convertintrin.h
@@ -308,13 +308,13 @@ static __inline __m512h __DEFAULT_FN_ATTRS512 
_mm512_cvtpbf8_ph(__m256i __A) {
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask16 __U, __m256i __A) {
+_mm512_mask_cvtpbf8_ph(__m512h __S, __mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_mask_slli_epi16((__m512i)__S, __U, _mm512_cvtepi8_epi16(__A), 8));
 }
 
 static __inline __m512h __DEFAULT_FN_ATTRS512
-_mm512_maskz_cvtpbf8_ph(__mmask16 __U, __m256i __A) {
+_mm512_maskz_cvtpbf8_ph(__mmask32 __U, __m256i __A) {
   return _mm512_castsi512_ph(
   _mm512_slli_epi16(_mm512_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index 134adb2850c8de..efe8477cbbf9be 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -580,13 +580,13 @@ static __inline__ __m256h __DEFAULT_FN_ATTRS256 
_mm256_cvtpbf8_ph(__m128i __A) {
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask8 __U, __m128i __A) {
+_mm256_mask_cvtpbf8_ph(__m256h __S, __mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_mask_slli_epi16((__m256i)__S, __U, _mm256_cvtepi8_epi16(__A), 8));
 }
 
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
-_mm256_maskz_cvtpbf8_ph(__mmask8 __U, __m128i __A) {
+_mm256_maskz_cvtpbf8_ph(__mmask16 __U, __m128i __A) {
   return _mm256_castsi256_ph(
   _mm256_slli_epi16(_mm256_maskz_cvtepi8_epi16(__U, __A), 8));
 }
diff --git a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
index e71cc0c9ad6b02..6662e0cbf8a913 100644
--- a/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2_512convert-builtins.c
@@ -299,7 +299,7 @@ __m512h test_mm512_cvtpbf8_ph(__m256i A) {
   return _mm512_cvtpbf8_ph(A);
 }
 
-__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, __m256i A) {
+__m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_mask_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: @llvm.x86.avx512.pslli.w.512
@@ -308,7 +308,7 @@ __m512h test_mm512_mask_cvtpbf8_ph(__m512h S, __mmask16 M, 
__m256i A) {
   return _mm512_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m512h test_mm512_maskz_cvtpbf8_ph(__mmask16 M, __m256i A) {
+__m512h test_mm512_maskz_cvtpbf8_ph(__mmask32 M, __m256i A) {
   // CHECK-LABEL: @test_mm512_maskz_cvtpbf8_ph
   // CHECK: sext <32 x i8> %{{.*}} to <32 x i16>
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
diff --git a/clang/test/CodeGen/X86/avx10_2convert-builtins.c 
b/clang/test/CodeGen/X86/avx10_2convert-builtins.c
index 8086c1b5d33993..7121b28719c077 100644
--- a/clang/test/CodeGen/X86/avx10_2convert-builtins.c
+++ b/clang/test/CodeGen/X86/avx10_2convert-builtins.c
@@ -593,7 +593,7 @@ __m128h test_mm_cvtpbf8_ph(__m128i A) {
   return _mm_cvtpbf8_ph(A);
 }
 
-__m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask8 M, __m128i A) {
+__m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask16 M, __m128i A) {
   // CHECK-LABEL: @test_mm_mask_cvtpbf8_ph
   // CHECK: sext <8 x i8> %{{.*}} to <8 x i16>
   // CHECK: @llvm.x86.sse2.pslli.w
@@ -602,7 +602,7 @@ __m128h test_mm_mask_cvtpbf8_ph(__m128h S, __mmask8 M, 
__m128i A) {
   return _mm_mask_cvtpbf8_ph(S, M, A);
 }
 
-__m128h test_mm_maskz_cvtpbf8_ph(__mmask8 M, __m128i A) {
+__m128h test_mm_maskz_cvtpbf8_ph(__mmask16 M, __m128i A) {
   // CHECK-LABEL: @test_mm_maskz_cvtpbf8_ph
   // CHECK: sext <8 x i8> %{{.*}} to <8 x i16>
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}

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


[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-22 Thread via cfe-commits


@@ -319,10 +319,11 @@ Changes in existing checks
   diagnostic.
 
 - Improved :doc:`readability-implicit-bool-conversion
-  ` check
-  by adding the option `UseUpperCaseLiteralSuffix` to select the
-  case of the literal suffix in fixes and fixing false positive for implicit
-  conversion of comparison result in C23.
+  ` check by adding the
+  option `UseUpperCaseLiteralSuffix` to select the case of the literal suffix 
in 
+  fixes and fixing false positive for implicit conversion of comparison result 
in 
+  C23 , and by adding the option `CheckConversionsToBool` or 

EugeneZelenko wrote:

```suggestion
  C23, and by adding the option `CheckConversionsToBool` or 
```

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


[clang] dd577c0 - [clang] constexpr built-in reduce min/max function. (#120866)

2024-12-22 Thread via cfe-commits

Author: c8ef
Date: 2024-12-23T09:06:38+08:00
New Revision: dd577c05ad0d382b444da01b6a1f56f8c2c15e07

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

LOG: [clang] constexpr built-in reduce min/max function. (#120866)

Part of #51787.

This patch adds constexpr support for the built-in reduce min/max
function.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.td
clang/lib/AST/ExprConstant.cpp
clang/test/Sema/constant_builtins_vector.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 3d4f68b818bce7..cc5f1d4ddf4477 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -736,9 +736,10 @@ at the end to the next power of 2.
 
 These reductions support both fixed-sized and scalable vector types.
 
-The integer reduction intrinsics, including ``__builtin_reduce_add``,
-``__builtin_reduce_mul``, ``__builtin_reduce_and``, ``__builtin_reduce_or``,
-and ``__builtin_reduce_xor``, can be called in a ``constexpr`` context.
+The integer reduction intrinsics, including ``__builtin_reduce_max``,
+``__builtin_reduce_min``, ``__builtin_reduce_add``, ``__builtin_reduce_mul``,
+``__builtin_reduce_and``, ``__builtin_reduce_or``, and 
``__builtin_reduce_xor``,
+can be called in a ``constexpr`` context.
 
 Example:
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..8b984ecaefecaf 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -421,7 +421,8 @@ Non-comprehensive list of changes in this release
   ``__builtin_reduce_mul``, ``__builtin_reduce_and``, ``__builtin_reduce_or``,
   ``__builtin_reduce_xor``, ``__builtin_elementwise_popcount``,
   ``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``,
-  ``__builtin_elementwise_sub_sat``.
+  ``__builtin_elementwise_sub_sat``, ``__builtin_reduce_min`` (For integral 
element type),
+  ``__builtin_reduce_max`` (For integral element type).
 
 - Clang now rejects ``_BitInt`` matrix element types if the bit width is less 
than ``CHAR_WIDTH`` or
   not a power of two, matching preexisting behaviour for vector types.

diff  --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index d64a66fc9d9cf7..b5b47ae2746011 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1462,13 +1462,13 @@ def ElementwiseSubSat : Builtin {
 
 def ReduceMax : Builtin {
   let Spellings = ["__builtin_reduce_max"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 
 def ReduceMin : Builtin {
   let Spellings = ["__builtin_reduce_min"];
-  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
 

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 89c515e6392764..dd75dca647540a 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -13604,7 +13604,9 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
   case Builtin::BI__builtin_reduce_mul:
   case Builtin::BI__builtin_reduce_and:
   case Builtin::BI__builtin_reduce_or:
-  case Builtin::BI__builtin_reduce_xor: {
+  case Builtin::BI__builtin_reduce_xor:
+  case Builtin::BI__builtin_reduce_min:
+  case Builtin::BI__builtin_reduce_max: {
 APValue Source;
 if (!EvaluateAsRValue(Info, E->getArg(0), Source))
   return false;
@@ -13641,6 +13643,14 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 Reduced ^= Source.getVectorElt(EltNum).getInt();
 break;
   }
+  case Builtin::BI__builtin_reduce_min: {
+Reduced = std::min(Reduced, Source.getVectorElt(EltNum).getInt());
+break;
+  }
+  case Builtin::BI__builtin_reduce_max: {
+Reduced = std::max(Reduced, Source.getVectorElt(EltNum).getInt());
+break;
+  }
   }
 }
 

diff  --git a/clang/test/Sema/constant_builtins_vector.cpp 
b/clang/test/Sema/constant_builtins_vector.cpp
index b2f56e5a87ab1a..8659fa9e46612d 100644
--- a/clang/test/Sema/constant_builtins_vector.cpp
+++ b/clang/test/Sema/constant_builtins_vector.cpp
@@ -798,6 +798,21 @@ static_assert(__builtin_reduce_xor((vector4long){(long 
long)0xL,
 static_assert(__builtin_reduce_xor((vector4uint){0xU, 0xU, 
0xU, 0xU}) == 0xU);
 static_assert(__builtin_reduce_xor((vector4ulong){0xUL, 
0xUL, 0xUL, 0xUL}

[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Richard Li via cfe-commits

https://github.com/chomosuke updated 
https://github.com/llvm/llvm-project/pull/118569

>From efc17a803c9c22543de7d5f9e960a7267ade1f2e Mon Sep 17 00:00:00 2001
From: chomosuke 
Date: Wed, 4 Dec 2024 14:42:24 +
Subject: [PATCH 1/2] [clangd][clang-tidy] Make clangd run
 `format::cleanupAroundReplacements()` for all code actions just as clang-tidy
 does

---
 clang-tools-extra/clang-tidy/ClangTidy.cpp| 22 ++--
 clang-tools-extra/clangd/Diagnostics.cpp  | 35 -
 .../clangd/unittests/DiagnosticsTests.cpp | 51 ---
 .../include/clang/Tooling/Core/Replacement.h  |  4 ++
 clang/lib/Tooling/Core/Replacement.cpp| 16 +-
 5 files changed, 99 insertions(+), 29 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 9c8c93c5d16c72..82331c724eaaf2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -149,26 +149,12 @@ class ErrorReporter {
Repl.getLength(), 
Repl.getReplacementText());
 auto &Entry = FileReplacements[R.getFilePath()];
 Replacements &Replacements = Entry.Replaces;
-llvm::Error Err = Replacements.add(R);
+llvm::Error Err = Replacements.addOrMerge(R);
 if (Err) {
   // FIXME: Implement better conflict handling.
-  llvm::errs() << "Trying to resolve conflict: "
-   << llvm::toString(std::move(Err)) << "\n";
-  unsigned NewOffset =
-  Replacements.getShiftedCodePosition(R.getOffset());
-  unsigned NewLength = Replacements.getShiftedCodePosition(
-   R.getOffset() + R.getLength()) -
-   NewOffset;
-  if (NewLength == R.getLength()) {
-R = Replacement(R.getFilePath(), NewOffset, NewLength,
-R.getReplacementText());
-Replacements = Replacements.merge(tooling::Replacements(R));
-CanBeApplied = true;
-++AppliedFixes;
-  } else {
-llvm::errs()
-<< "Can't resolve conflict, skipping the replacement.\n";
-  }
+  llvm::errs()
+  << "Can't resolve conflict, skipping the replacement: "
+  << llvm::toString(std::move(Err)) << '\n';
 } else {
   CanBeApplied = true;
   ++AppliedFixes;
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index a59d1e7ac84096..60c6ac7256b58c 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
+#include "clang/Format/Format.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -741,7 +742,7 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level 
DiagLevel,
   return false;
 // Copy as we may modify the ranges.
 auto FixIts = Info.getFixItHints().vec();
-llvm::SmallVector Edits;
+auto Replacements = std::make_optional();
 for (auto &FixIt : FixIts) {
   // Allow fixits within a single macro-arg expansion to be applied.
   // This can be incorrect if the argument is expanded multiple times in
@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level 
DiagLevel,
 return false;
   if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+
+  auto R = tooling::Replacement(SM, FixIt.RemoveRange, FixIt.CodeToInsert,
+*LangOpts);
+  auto Err = Replacements->addOrMerge(R);
+  if (Err) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Err)));
+Replacements = std::nullopt;
+break;
+  }
+}
+
+llvm::SmallVector Edits;
+
+if (Replacements) {
+  StringRef Code = SM.getBufferData(SM.getMainFileID());
+  auto Repl = format::cleanupAroundReplacements(Code, *Replacements,
+format::getNoStyle());
+  if (!Repl) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Repl.takeError(;
+Replacements = std::nullopt;
+  } else {
+auto Es = replacementsToEdits(Code, *Repl);
+Edits.append(Es.begin(), Es.end());
+  }
+}
+if (!Replacements) {
+  for (auto &FixIt : FixIts) {
+Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+  }
 }
 
 llvm::SmallString<64> Message;
diff --git a/clang-tools-extra/clangd/unitte

[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)

2024-12-22 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

> > I think I've addressed most of the review comments here at this point.
> > But maybe most excitingly, I think the latest version may dodge the issues 
> > that have cropped up with MSVC -- both LoongArch and X86 fixes have been 
> > incorporated that hopefully help. @dyung -- if you can try it out, let me 
> > know.
> 
> Sure, I can test it. Just to confirm, what branch/commit should I be testing?

This PR has everything in it so you can just test it. There are 3 commits on 
this branch that won't land here (they're under review in their own PRs), but 
I've got them all here so you can just test this PR.

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


[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-22 Thread via cfe-commits

https://github.com/4m4n-x-B4w4ne updated 
https://github.com/llvm/llvm-project/pull/120087

>From 03f536888ddc5b7be2514c2d880c6d3119b7f4ee Mon Sep 17 00:00:00 2001
From: 4m4n-x-B4w4ne <125849251+4m4n-x-b4w...@users.noreply.github.com>
Date: Mon, 16 Dec 2024 19:43:42 +0530
Subject: [PATCH 01/33] Update ImplicitBoolConversionCheck.cpp

Added new options in ImplicitBoolConversionCheck CheckConversionToBool and 
CheckConversionFromBool.
---
 .../readability/ImplicitBoolConversionCheck.cpp   | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index f9fd1d903e231e..517a5d2b982751 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -258,14 +258,17 @@ ImplicitBoolConversionCheck::ImplicitBoolConversionCheck(
 : ClangTidyCheck(Name, Context),
   AllowIntegerConditions(Options.get("AllowIntegerConditions", false)),
   AllowPointerConditions(Options.get("AllowPointerConditions", false)),
-  UseUpperCaseLiteralSuffix(
-  Options.get("UseUpperCaseLiteralSuffix", false)) {}
+  UseUpperCaseLiteralSuffix(Options.get("UseUpperCaseLiteralSuffix", 
false)),
+  CheckConversionsToBool(Options.get("CheckConversionsToBool",true)),
+  CheckConversionsFromBool(Options.get("CheckConversionsFromBool",true)) {}
 
 void ImplicitBoolConversionCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "AllowIntegerConditions", AllowIntegerConditions);
   Options.store(Opts, "AllowPointerConditions", AllowPointerConditions);
   Options.store(Opts, "UseUpperCaseLiteralSuffix", UseUpperCaseLiteralSuffix);
+  Options.store(Opts,"CheckConversionsToBool",CheckConversionsToBool);
+  Options.store(Opts,"CheckConversionsFromBool",CheckConversionsFromBool);
 }
 
 void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
@@ -358,14 +361,14 @@ void 
ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
 void ImplicitBoolConversionCheck::check(
 const MatchFinder::MatchResult &Result) {
 
-  if (const auto *CastToBool =
-  Result.Nodes.getNodeAs("implicitCastToBool")) {
+  if (CheckConversionsToBool && (const auto *CastToBool =
+  Result.Nodes.getNodeAs("implicitCastToBool"))) {
 const auto *Parent = Result.Nodes.getNodeAs("parentStmt");
 return handleCastToBool(CastToBool, Parent, *Result.Context);
   }
 
-  if (const auto *CastFromBool =
-  Result.Nodes.getNodeAs("implicitCastFromBool")) {
+  if (CheckConversionsFromBool && (const auto *CastFromBool =
+  Result.Nodes.getNodeAs("implicitCastFromBool"))) {
 const auto *NextImplicitCast =
 Result.Nodes.getNodeAs("furtherImplicitCast");
 return handleCastFromBool(CastFromBool, NextImplicitCast, *Result.Context);

>From 16c7c95939b4c0c38ebccbbc6cd1da3739244a24 Mon Sep 17 00:00:00 2001
From: 4m4n-x-B4w4ne <125849251+4m4n-x-b4w...@users.noreply.github.com>
Date: Mon, 16 Dec 2024 19:45:37 +0530
Subject: [PATCH 02/33] Update ImplicitBoolConversionCheck.h

Added CheckConversionToBool and CheckConversionFromBool Options in the header
---
 .../clang-tidy/readability/ImplicitBoolConversionCheck.h| 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
index 5947f7316e67cc..b0c3c2943e649c 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h
@@ -37,6 +37,8 @@ class ImplicitBoolConversionCheck : public ClangTidyCheck {
   const bool AllowIntegerConditions;
   const bool AllowPointerConditions;
   const bool UseUpperCaseLiteralSuffix;
+  const bool CheckConversionsToBool;
+  const bool CheckConversionsFromBool;
 };
 
 } // namespace clang::tidy::readability

>From 0d6fae8b08a4a365c9295ac8a96de2aba9974c98 Mon Sep 17 00:00:00 2001
From: 4m4n-x-B4w4ne <125849251+4m4n-x-b4w...@users.noreply.github.com>
Date: Mon, 16 Dec 2024 19:48:48 +0530
Subject: [PATCH 03/33] Create implicit-bool-conversion-check.cpp

Added new test to check the new options added in the 
ImplicitBoolConversionCheck.cpp
---
 .../implicit-bool-conversion-check.cpp| 92 +++
 1 file changed, 92 insertions(+)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-check.cpp

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-check.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion-check.cpp
new file mode 100644
index 00..506769d5a57322
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers

[clang-tools-extra] Added options to readability-implicit-bool-conversion (PR #120087)

2024-12-22 Thread via cfe-commits


@@ -319,10 +319,11 @@ Changes in existing checks
   diagnostic.
 
 - Improved :doc:`readability-implicit-bool-conversion
-  ` check
-  by adding the option `UseUpperCaseLiteralSuffix` to select the
-  case of the literal suffix in fixes and fixing false positive for implicit
-  conversion of comparison result in C23.
+  ` check by adding the
+  option `UseUpperCaseLiteralSuffix` to select the case of the literal suffix 
in 
+  fixes and fixing false positive for implicit conversion of comparison result 
in 
+  C23 , and by adding the option `CheckConversionsToBool` or 

4m4n-x-B4w4ne wrote:

Done Thanks.

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/120920

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Re-land "support outgoing calls in call hierarchy" (PR #117673)

2024-12-22 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> > @kadircet perhaps you might be able to pick up this review?
> > Or, in the absence of a full review, your opinion on the directional 
> > question in [this comment](https://reviews.llvm.org/D93829#4654786) would 
> > be appreciated as well:
> > > how would you feel about proceeding with the patch in its current state, 
> > > with the memory usage increase brought down from 8.2% to 2.5% thanks to 
> > > the combination of the simple lookup optimization + RefKind filtering, 
> > > and leaving the "deep lookup optimization" to be explored in a future 
> > > change?
> 
> I'd definitely prefer the one we discussed in the original review, but I 
> don't think perfect needs to be enemy of the good, we can surely optimize 
> data structures here going forward if needed.

I filed https://github.com/clangd/clangd/issues/2264 as a follow-up to track 
implementation of the "deep lookup optimization".

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-22 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120591

>From 9a0d5d44f70477403a33d2feb3f5518b0d078a66 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:35:35 +0300
Subject: [PATCH 1/2] [Clang][Sema] Process warnings conditionally

There are a few functions that emit warnings
related to positional arguments in format strings.
These functions use `getLocationOfByte()` which has O(n)
complexity and may lead to silent hang of compilation in some cases.
But such warnings is not widely used and actually don't emit
if user didn't pass the appropriate `-W...` flag, so
if the flag is not passed dont make the call
to `EmitFormatDiagnostic` for such diags.

Fix #120462
---
 clang/lib/Sema/SemaChecking.cpp | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e703a62ff9cf18..f5c42eba51c252 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6591,27 +6591,33 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_invalid_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_zero_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {

>From 7928effc17882139e548adbfe88a52d56f844d3b Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:50:04 +0300
Subject: [PATCH 2/2] [clang][Sema] Fix code style

---
 clang/lib/Sema/SemaChecking.cpp | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f5c42eba51c252..9a05181405cde5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6591,18 +6591,20 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
 
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-getLocationOfByte(startPos),
-/*IsStringLocation*/true,
-getSpecifierRange(startPos, posLen));
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
   }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsi

[clang] [llvm] [ConstantRange] Estimate tighter lower (upper) bounds for masked binary and (or) (PR #120352)

2024-12-22 Thread Stephen Senran Zhang via cfe-commits


@@ -1520,15 +1520,101 @@ ConstantRange ConstantRange::binaryNot() const {
   return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
 }
 
+/// Estimate the 'bit-masked AND' operation's lower bound.
+///
+/// E.g., given two ranges as follows (single quotes are separators and
+/// have no meaning here),
+///
+///   LHS = [10'001'010,  ; LLo
+///  10'100'000]  ; LHi
+///   RHS = [10'111'010,  ; RLo
+///  10'111'100]  ; RHi
+///
+/// we know that the higher 2 bits of the result is always '10'; and note that
+/// there's at least one bit is 1 in LHS[3:6] (since the range is continuous),
+/// and all bits in RHS[3:6] are 1, so we know the lower bound of the result is
+/// 10'001'000.
+///
+/// The algorithm is as follows,
+/// 1. we first calculate a mask to mask out the higher common bits by
+///   Mask = (LLo ^ LHi) | (LLo ^ LHi) | (LLo ^ RLo);
+///   Mask = set all non-leading-zero bits to 1 for Mask;
+/// 2. find the bit field with at least 1 in LHS (i.e., bit 3:6 in the example)
+///after applying the mask, with
+///   StartBit = BitWidth - (LLo & Mask).clz() - 1;
+///   EndBit = BitWidth - (LHi & Mask).clz();
+/// 3. check if all bits in [StartBit:EndBit] in RHS are 1, and all bits of
+///RLo and RHi in [StartBit:BitWidth] are same, and if so, the lower bound
+///can be updated to
+///   LowerBound = LLo & Keep;
+///where Keep is a mask to mask out trailing bits (the lower 3 bits in the
+///example);
+/// 4. repeat the step 2 and 3 with LHS and RHS swapped, and update the lower
+///bound with the larger one.
+static APInt estimateBitMaskedAndLowerBound(const ConstantRange &LHS,
+const ConstantRange &RHS) {
+  auto BitWidth = LHS.getBitWidth();
+  // If either is full set or unsigned wrapped, then the range must contain '0'
+  // which leads the lower bound to 0.
+  if ((LHS.isFullSet() || RHS.isFullSet()) ||
+  (LHS.isWrappedSet() || RHS.isWrappedSet()))
+return APInt::getZero(BitWidth);
+
+  auto LLo = LHS.getLower();
+  auto LHi = LHS.getUpper() - 1;
+  auto RLo = RHS.getLower();
+  auto RHi = RHS.getUpper() - 1;
+
+  // Calculate the mask that mask out the higher common bits.
+  auto Mask = (LLo ^ LHi) | (RLo ^ RHi) | (LLo ^ RLo);
+  unsigned LeadingZeros = Mask.countLeadingZeros();
+  Mask.setLowBits(BitWidth - LeadingZeros);
+
+  auto estimateBound =
+  [BitWidth, &Mask](const APInt &ALo, const APInt &AHi, const APInt &BLo,
+const APInt &BHi) -> std::optional {
+unsigned LeadingZeros = (ALo & Mask).countLeadingZeros();
+if (LeadingZeros == BitWidth)
+  return std::nullopt;
+
+unsigned StartBit = BitWidth - LeadingZeros - 1;

zsrkmyn wrote:

Great point! Actually we can do so by slightly extend the `StartBit` to lower 
bits if extended bits in B are all ones.

E.g., given

```
CR_A: [01101110,
   01110001]
CR_B: {0110}
```

the lower bound is `01101000` by the current algorithm (`StartBit` is 3, 
counting from 0), but we notice that the bits 2 and 1 are also 1 in range B, so 
we can extend the `StartBit` to 1. And the lower bound becomes `01101110`.

This can be done by some easy change. I'ma refine and update the PR.

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


[clang] [Clang][Driver][Test] Created test for unsupported driver options (PR #120900)

2024-12-22 Thread via cfe-commits

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


[clang] [Clang][Driver][Test] Created test for unsupported driver options (PR #120900)

2024-12-22 Thread via cfe-commits

https://github.com/GeorgeKA created 
https://github.com/llvm/llvm-project/pull/120900

Created generate_unsupported_in_drivermode.py which generates a Lit regression 
test file that validates that options are only exposed to intended driver modes.

The options and driver modes are parsed from Options.td, whose path should be 
provided on the command line. See
clang/include/clang/Driver/Options.td

The path to the TableGen executable can optionally be provided. Otherwise, the 
script will search for it.

--

Notes:
  - This is currently in draft stage. Still need to validate clang-dxc & 
clang-cl error messages
  - This current patch is not being submitted with the Lit test that the script 
generates, given there are unsupported driver options that currently exist that 
trigger test failure. I think it would be appropriate to make adjustments to 
those options in a separate git issue given the docs suggest to have patches 
address isolated changes.

>From faf8597dbb58a08991e11e9c4b9a0aad2f0b4234 Mon Sep 17 00:00:00 2001
From: GeorgeKA 
Date: Sun, 22 Dec 2024 09:42:36 -0500
Subject: [PATCH] [Clang][Driver][Test] Created test for unsupported driver
 options

Created generate_unsupported_in_drivermode.py which generates a Lit
regression test file that validates that options are only exposed to
intended driver modes.

The options and driver modes are parsed from Options.td, whose path
should be provided on the command line. See
clang/include/clang/Driver/Options.td

The path to the TableGen executable can optionally be provided.
Otherwise, the script will search for it.
---
 .../generate_unsupported_in_drivermode.py | 249 ++
 1 file changed, 249 insertions(+)
 create mode 100644 clang/utils/generate_unsupported_in_drivermode.py

diff --git a/clang/utils/generate_unsupported_in_drivermode.py 
b/clang/utils/generate_unsupported_in_drivermode.py
new file mode 100644
index 00..f32c2c7c5a0d7c
--- /dev/null
+++ b/clang/utils/generate_unsupported_in_drivermode.py
@@ -0,0 +1,249 @@
+#!/usr/bin/env python3
+
+""" generate_unsupported_in_drivermode.py
+
+usage: python generate_unsupported_in_drivermode.py /Options.td 
[/llvm-tblgen]
+
+This script generates a Lit regression test file that validates that options
+are only exposed to intended driver modes.
+
+The options and driver modes are parsed from Options.td, whose path should be
+provided on the command line. See clang/include/clang/Driver/Options.td
+
+The path to the TableGen executable can optionally be provided. Otherwise, the
+script will search for it.
+
+Logic:
+1) For each option, (records of class "Option"), and for each driver, (records 
of class "OptionVisibility")
+a. if the option's "Visibility" field includes the driver flavour, skip 
processing this option for this driver
+b. if the option is part of an option group, (the record has the "Group" 
property),
+   and the group's "Visibility" field includes the driver flavor, skip 
processing this option for this driver
+c. otherwise this option is not supported by this driver flavor, and this 
pairing is saved for testing
+2) For each unsupported pairing, generate a Lit RUN line, and a CHECK line to 
parse for expected output. Ex: "error: unknown argument"
+"""
+
+import sys
+import shutil
+import os
+import json
+import subprocess
+from pathlib import Path
+
+LLVM_TABLEGEN = "llvm-tblgen"
+LIT_TEST_PATH = "../test/Driver/Inputs/unsupported-driver-options-check.ll"
+INCLUDE_PATH = "../../llvm/include"
+PREFIX = "CHECK-"
+
+# Strings used in Options.td for various driver flavours
+OPTION_CC1AS = "CC1AsOption"
+OPTION_CC1 = "CC1Option"
+OPTION_CL = "CLOption"
+OPTION_DXC = "DXCOption"
+OPTION_DEFAULT = "DefaultVis"
+OPTION_FC1 = "FC1Option"
+OPTION_FLANG = "FlangOption"
+
+# Error messages output from each driver
+ERROR_MSG_CC1AS = ": error: unknown argument"
+ERROR_MSG_CC1 = "error: unknown argument"
+ERROR_MSG_CL = "" # TODO
+ERROR_MSG_DXC = "" # TODO
+ERROR_MSG_DEFAULT = "clang: error: unknown argument"
+ERROR_MSG_FC1 = "error: unknown argument"
+ERROR_MSG_FLANG = "flang: error: unknown argument"
+
+# Lit CHECK prefixes
+CHECK_PREFIX_CC1AS = PREFIX + OPTION_CC1AS
+CHECK_PREFIX_CC1 = PREFIX + OPTION_CC1
+CHECK_PREFIX_CL = PREFIX + OPTION_CL
+CHECK_PREFIX_DXC = PREFIX + OPTION_DXC
+CHECK_PREFIX_DEFAULT = PREFIX + OPTION_DEFAULT
+CHECK_PREFIX_FC1 = PREFIX + OPTION_FC1
+CHECK_PREFIX_FLANG = PREFIX + OPTION_FLANG
+
+LIT_TEST_NOTE = ("; NOTE: This lit test was automatically generated to 
validate " +
+ "unintentionally exposed arguments to various driver 
flavours.\n"
+ "; NOTE: To make changes, see " + 
Path(__file__).resolve().as_posix()
+ + " from which it was generated.\n\n")
+
+def print_usage():
+""" Print valid usage of this script
+"""
+sys.exit( "usage: python " + sys.argv[0] + " /Options.td 
[/llvm-tblgen]" )
+
+def find_file(file_name, search_path):
+""" Find the given file name under a 

[clang] [Clang][Driver][Test] Created test for unsupported driver options (PR #120900)

2024-12-22 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
342fa15a44721799c9314c58df0d803f13f9d805...faf8597dbb58a08991e11e9c4b9a0aad2f0b4234
 clang/utils/generate_unsupported_in_drivermode.py
``





View the diff from darker here.


``diff
--- generate_unsupported_in_drivermode.py   2024-12-22 14:42:36.00 +
+++ generate_unsupported_in_drivermode.py   2024-12-22 15:02:21.191490 +
@@ -44,12 +44,12 @@
 OPTION_FLANG = "FlangOption"
 
 # Error messages output from each driver
 ERROR_MSG_CC1AS = ": error: unknown argument"
 ERROR_MSG_CC1 = "error: unknown argument"
-ERROR_MSG_CL = "" # TODO
-ERROR_MSG_DXC = "" # TODO
+ERROR_MSG_CL = ""  # TODO
+ERROR_MSG_DXC = ""  # TODO
 ERROR_MSG_DEFAULT = "clang: error: unknown argument"
 ERROR_MSG_FC1 = "error: unknown argument"
 ERROR_MSG_FLANG = "flang: error: unknown argument"
 
 # Lit CHECK prefixes
@@ -59,51 +59,56 @@
 CHECK_PREFIX_DXC = PREFIX + OPTION_DXC
 CHECK_PREFIX_DEFAULT = PREFIX + OPTION_DEFAULT
 CHECK_PREFIX_FC1 = PREFIX + OPTION_FC1
 CHECK_PREFIX_FLANG = PREFIX + OPTION_FLANG
 
-LIT_TEST_NOTE = ("; NOTE: This lit test was automatically generated to 
validate " +
- "unintentionally exposed arguments to various driver 
flavours.\n"
- "; NOTE: To make changes, see " + 
Path(__file__).resolve().as_posix()
- + " from which it was generated.\n\n")
+LIT_TEST_NOTE = (
+"; NOTE: This lit test was automatically generated to validate "
++ "unintentionally exposed arguments to various driver flavours.\n"
+"; NOTE: To make changes, see "
++ Path(__file__).resolve().as_posix()
++ " from which it was generated.\n\n"
+)
+
 
 def print_usage():
-""" Print valid usage of this script
-"""
-sys.exit( "usage: python " + sys.argv[0] + " /Options.td 
[/llvm-tblgen]" )
+"""Print valid usage of this script"""
+sys.exit("usage: python " + sys.argv[0] + " /Options.td 
[/llvm-tblgen]")
+
 
 def find_file(file_name, search_path):
-""" Find the given file name under a search path
-"""
+"""Find the given file name under a search path"""
 result = []
 
 for root, dir, files in os.walk(search_path):
 if file_name in files:
 result.append(os.path.join(root, file_name))
 return result
 
+
 def is_valid_file(path, expected_name):
-""" Is a file valid
+"""Is a file valid
 Check if a given path is to a file, and if it matches the expected file 
name
 """
 if path.is_file() and path.name == expected_name:
 return True
 else:
 return False
 
+
 def find_tablegen():
-""" Validate the TableGen executable
-"""
+"""Validate the TableGen executable"""
 result = shutil.which(LLVM_TABLEGEN)
 if result is None:
 sys.exit("Unable to find " + LLVM_TABLEGEN + ".\nExiting")
 else:
 print("TableGen found: " + result)
 return result
 
+
 def find_groups(group_sequence, options_json, option):
-""" Find the groups for a given option
+"""Find the groups for a given option
 Note that groups can themselves be part of groups, hence the recursion
 """
 group_json = options_json[option]["Group"]
 
 if group_json is None:
@@ -116,14 +121,15 @@
 
 group_sequence.append(group_json["def"])
 return find_groups(group_sequence, options_json, option)
 
 
-class UnsupportedDriverOption():
+class UnsupportedDriverOption:
 def __init__(self, driver, option):
 self.driver = driver
 self.option = option
+
 
 # Validate the number of arguments have been passed
 argc = len(sys.argv)
 if argc < 2 or argc > 3:
 print_usage()
@@ -165,12 +171,21 @@
 tablegen = tablegen_input_path.resolve().as_posix()
 else:
 tablegen = find_tablegen()
 
 # Run TableGen to convert Options.td to json
-options_json_str = subprocess.run([ tablegen, "-I", os.path.join(current_path, 
INCLUDE_PATH), options_td, "-dump-json"], stdout=subprocess.PIPE)
-options_json = json.loads(options_json_str.stdout.decode('utf-8'))
+options_json_str = subprocess.run(
+[
+tablegen,
+"-I",
+os.path.join(current_path, INCLUDE_PATH),
+options_td,
+"-dump-json",
+],
+stdout=subprocess.PIPE,
+)
+options_json = json.loads(options_json_str.stdout.decode("utf-8"))
 
 # Gather list of driver flavours
 for i in options_json["!instanceof"]["OptionVisibility"]:
 driver_sequence.append(i)
 
@@ -206,15 +221,25 @@
 lit_file.write(LIT_TEST_NOTE)
 
 for i in unsupported_sequence:
 if i.driver == OPTION_CC1AS:
 lit_file.write(
-"; RUN: not clang -cc1as -" + i.option + " -help 2>&1 
| FileCheck -check-prefix=" + CHECK_PREFIX_CC1AS + " %s\n")
+"; RUN: not clang -cc1as -

[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 created https://github.com/llvm/llvm-project/pull/120904

Try to fix issue: https://github.com/llvm/llvm-project/issues/120148
I'm a newbie, please give me some suggestions for modification.
Especially I use a global array "castIdentifiers", I feel that this 
implementation is not good, but I don't know how to modify it.

From fcfc6b540c86f8e8740771f3b938f6558e04aee0 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Sun, 22 Dec 2024 23:19:03 +0800
Subject: [PATCH] [Clang] Repair the functionrParenEndsCast to make incorrect
 judgments in template variable cases

---
 clang/lib/Format/TokenAnnotator.cpp | 88 +++--
 1 file changed, 57 insertions(+), 31 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index bc5239209f3aab..14db6e9116ab2e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -17,6 +17,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "format-token-annotator"
@@ -38,6 +40,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -492,7 +497,8 @@ class AnnotatingParser {
 ProbablyFunctionType && CurrentToken->Next &&
 (CurrentToken->Next->is(tok::l_paren) ||
  (CurrentToken->Next->is(tok::l_square) &&
-  Line.MustBeDeclaration))) {
+  (Line.MustBeDeclaration ||
+   (PrevNonComment && PrevNonComment->isTypeName(LangOpts)) {
   OpeningParen.setType(OpeningParen.Next->is(tok::caret)
? TT_ObjCBlockLParen
: TT_FunctionTypeLParen);
@@ -2403,7 +2409,8 @@ class AnnotatingParser {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);
 } else if (Current.is(tok::arrow) && Current.Previous &&
-   Current.Previous->is(tok::r_brace)) {
+   Current.Previous->is(tok::r_brace) &&
+   Current.Previous->is(BK_Block)) {
   // Concept implicit conversion constraint needs to be treated like
   // a trailing return type  ... } -> .
   Current.setType(TT_TrailingReturnArrow);
@@ -2472,6 +2479,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2829,8 +2839,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there
@@ -3901,6 +3921,11 @@ bool TokenAnnotator::mustBreakForReturnType(const 
AnnotatedLine &Line) const {
 }
 
 void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const 
{
+  if (Line.Computed)
+return;
+
+  Line.Computed = true;
+
   for (AnnotatedLine *ChildLine : Line.Children)
 calculateFormattingInformation(*ChildLine);
 
@@ -6105,6 +6130,35 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
   return false;
   }
 
+  // We can break before an r_brace if there was a break after the matching
+  // l_brace, which is tracked by BreakBeforeClosingBrace, or if we are in a
+  // block-indented initialization list.
+  if (Right.is(tok::r_brace)) {
+return Right.MatchingParen && (Right.MatchingParen->is(BK_Block) ||
+   (Right.isBlockIndentedInitRBrace(Style)));
+  }
+
+  // We only break before r_paren if we're in a block indented context.
+  if (Right.is(tok::r_paren)) {
+if (Style.AlignAfterOpenBr

[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: 执着 (dty2)


Changes

Try to fix issue: https://github.com/llvm/llvm-project/issues/120148
I'm a newbie, please give me some suggestions for modification.
Especially I use a global array "castIdentifiers", I feel that this 
implementation is not good, but I don't know how to modify it.

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


1 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+57-31) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index bc5239209f3aab..14db6e9116ab2e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -17,6 +17,8 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 
 #define DEBUG_TYPE "format-token-annotator"
@@ -38,6 +40,9 @@ static bool mustBreakAfterAttributes(const FormatToken &Tok,
 
 namespace {
 
+SmallVector castIdentifiers{"__type_identity_t",
+  "remove_reference_t"};
+
 /// Returns \c true if the line starts with a token that can start a statement
 /// with an initializer.
 static bool startsWithInitStatement(const AnnotatedLine &Line) {
@@ -492,7 +497,8 @@ class AnnotatingParser {
 ProbablyFunctionType && CurrentToken->Next &&
 (CurrentToken->Next->is(tok::l_paren) ||
  (CurrentToken->Next->is(tok::l_square) &&
-  Line.MustBeDeclaration))) {
+  (Line.MustBeDeclaration ||
+   (PrevNonComment && PrevNonComment->isTypeName(LangOpts)) {
   OpeningParen.setType(OpeningParen.Next->is(tok::caret)
? TT_ObjCBlockLParen
: TT_FunctionTypeLParen);
@@ -2403,7 +2409,8 @@ class AnnotatingParser {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);
 } else if (Current.is(tok::arrow) && Current.Previous &&
-   Current.Previous->is(tok::r_brace)) {
+   Current.Previous->is(tok::r_brace) &&
+   Current.Previous->is(BK_Block)) {
   // Concept implicit conversion constraint needs to be treated like
   // a trailing return type  ... } -> .
   Current.setType(TT_TrailingReturnArrow);
@@ -2472,6 +2479,9 @@ class AnnotatingParser {
   Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
 Current.setType(TT_StringInConcatenation);
   }
+} else if (Current.is(tok::kw_using)) {
+  if (Current.Next->Next->Next->isTypeName(LangOpts))
+castIdentifiers.push_back(Current.Next->TokenText);
 } else if (Current.is(tok::l_paren)) {
   if (lParenStartsCppCast(Current))
 Current.setType(TT_CppCastLParen);
@@ -2829,8 +2839,18 @@ class AnnotatingParser {
 IsQualifiedPointerOrReference(BeforeRParen, LangOpts);
 bool ParensCouldEndDecl =
 AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, 
tok::greater);
-if (ParensAreType && !ParensCouldEndDecl)
+if (ParensAreType && !ParensCouldEndDecl) {
+  if (BeforeRParen->is(TT_TemplateCloser)) {
+auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
+if (Prev) {
+  for (auto &name : castIdentifiers)
+if (Prev->TokenText == name)
+  return true;
+  return false;
+}
+  }
   return true;
+}
 
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there
@@ -3901,6 +3921,11 @@ bool TokenAnnotator::mustBreakForReturnType(const 
AnnotatedLine &Line) const {
 }
 
 void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const 
{
+  if (Line.Computed)
+return;
+
+  Line.Computed = true;
+
   for (AnnotatedLine *ChildLine : Line.Children)
 calculateFormattingInformation(*ChildLine);
 
@@ -6105,6 +6130,35 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
   return false;
   }
 
+  // We can break before an r_brace if there was a break after the matching
+  // l_brace, which is tracked by BreakBeforeClosingBrace, or if we are in a
+  // block-indented initialization list.
+  if (Right.is(tok::r_brace)) {
+return Right.MatchingParen && (Right.MatchingParen->is(BK_Block) ||
+   (Right.isBlockIndentedInitRBrace(Style)));
+  }
+
+  // We only break before r_paren if we're in a block indented context.
+  if (Right.is(tok::r_paren)) {
+if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent ||
+!Right.MatchingParen) {
+  return false;
+}
+auto Next = Right.Next;
+if (Next && Next->is(tok::r_paren))
+  Next = Next->Next;
+if (Next && Nex

[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

2024-12-22 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk created 
https://github.com/llvm/llvm-project/pull/120896

Fixes #92847

---

> Types other than pointer types whose referenced type is an object type and 
> (possibly multi-dimensional) array types with such pointer types as element 
> type shall not be restrict-qualified.

>From 295df258043ef5a87ae603eedd308b863bad7b59 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 22 Dec 2024 15:14:30 +0200
Subject: [PATCH] [Clang] allow restrict qualifier for array types with pointer
 types as element types

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/Sema/SemaType.cpp |  4 +++-
 clang/test/Sema/types.c | 10 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..52daea9b8eb2b6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -332,6 +332,7 @@ C Language Changes
 --
 
 - Extend clang's  to define ``LONG_LONG_*`` macros for Android's 
bionic.
+- Clang now allows ``restrict`` qualifier for array types with pointer 
elements (#GH92847).
 
 C2y Feature Support
 ^^^
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 83464c50b4b238..e84daeee679a57 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1595,12 +1595,14 @@ QualType Sema::BuildQualifiedType(QualType T, 
SourceLocation Loc,
 QualType ProblemTy;
 
 if (T->isAnyPointerType() || T->isReferenceType() ||
-T->isMemberPointerType()) {
+T->isMemberPointerType() || T->isArrayType()) {
   QualType EltTy;
   if (T->isObjCObjectPointerType())
 EltTy = T;
   else if (const MemberPointerType *PTy = T->getAs())
 EltTy = PTy->getPointeeType();
+  else if (T->isArrayType())
+EltTy = Context.getBaseElementType(T);
   else
 EltTy = T->getPointeeType();
 
diff --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c
index e0a6ba4f0691b9..4c90634b7ce284 100644
--- a/clang/test/Sema/types.c
+++ b/clang/test/Sema/types.c
@@ -9,20 +9,20 @@ typedef int (*T)[2];
 restrict T x;
 
 typedef int *S[2];
-restrict S y; // expected-error {{restrict requires a pointer or reference 
('S' (aka 'int *[2]') is invalid)}}
-
-
+restrict S y;
 
 // int128_t is available.
 int a(void) {
   __int128_t s;
   __uint128_t t;
-}
+} // expected-warning {{non-void function does not return a value}}
+
 // but not a keyword
 int b(void) {
   int __int128_t;
   int __uint128_t;
-}
+} // expected-warning {{non-void function does not return a value}}
+
 // __int128 is a keyword
 int c(void) {
   __int128 i;

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


[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)


Changes

Fixes #92847

---

> Types other than pointer types whose referenced type is an object type and 
(possibly multi-dimensional) array types with such pointer types as element 
type shall not be restrict-qualified.

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaType.cpp (+3-1) 
- (modified) clang/test/Sema/types.c (+5-5) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..52daea9b8eb2b6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -332,6 +332,7 @@ C Language Changes
 --
 
 - Extend clang's  to define ``LONG_LONG_*`` macros for Android's 
bionic.
+- Clang now allows ``restrict`` qualifier for array types with pointer 
elements (#GH92847).
 
 C2y Feature Support
 ^^^
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 83464c50b4b238..e84daeee679a57 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1595,12 +1595,14 @@ QualType Sema::BuildQualifiedType(QualType T, 
SourceLocation Loc,
 QualType ProblemTy;
 
 if (T->isAnyPointerType() || T->isReferenceType() ||
-T->isMemberPointerType()) {
+T->isMemberPointerType() || T->isArrayType()) {
   QualType EltTy;
   if (T->isObjCObjectPointerType())
 EltTy = T;
   else if (const MemberPointerType *PTy = T->getAs())
 EltTy = PTy->getPointeeType();
+  else if (T->isArrayType())
+EltTy = Context.getBaseElementType(T);
   else
 EltTy = T->getPointeeType();
 
diff --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c
index e0a6ba4f0691b9..4c90634b7ce284 100644
--- a/clang/test/Sema/types.c
+++ b/clang/test/Sema/types.c
@@ -9,20 +9,20 @@ typedef int (*T)[2];
 restrict T x;
 
 typedef int *S[2];
-restrict S y; // expected-error {{restrict requires a pointer or reference 
('S' (aka 'int *[2]') is invalid)}}
-
-
+restrict S y;
 
 // int128_t is available.
 int a(void) {
   __int128_t s;
   __uint128_t t;
-}
+} // expected-warning {{non-void function does not return a value}}
+
 // but not a keyword
 int b(void) {
   int __int128_t;
   int __uint128_t;
-}
+} // expected-warning {{non-void function does not return a value}}
+
 // __int128 is a keyword
 int c(void) {
   __int128 i;

``




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


[clang] [clang] constexpr built-in reduce min/max function. (PR #120866)

2024-12-22 Thread Simon Pilgrim via cfe-commits

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

LGTM - cheers

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


[clang-tools-extra] [clangd] Augment code completion results with documentation from the index. (PR #120099)

2024-12-22 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 requested changes to this pull request.

Thanks, this patch generally looks great.

It would be nice to have a couple of test cases exercising the behaviour with 
overloaded methods when overload bundling is enabled 
(`CodeCompleteOptions::BundleOverloads` is set to true):
  * if we have an overload set where multiple methods have documentation, we 
pick an unspecified one of them 
([here](https://searchfox.org/llvm/rev/e8f1902cca2aeaa23db6080fe33fbc67ed203350/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp#2005)
 is an existing assertion for that, in a test case exercising the non-header 
scenario)
  * if we have an overload set where some but not all methods have 
documentation, we pick one that does (rather than one that doesn't)

I think the code already does the right thing and should pass these testcases, 
but it's good to verify and have test coverage for them.

(The template issue discussed in the previous two comments can be left to a 
follow-up PR to investigate and improve on.)

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


[clang-tools-extra] [clangd] Augment code completion results with documentation from the index. (PR #120099)

2024-12-22 Thread Nathan Ridge via cfe-commits


@@ -1863,14 +1863,41 @@ class CodeCompleteFlow {
 CodeCompleteResult Output;
 
 // Convert the results to final form, assembling the expensive strings.
+// If necessary, search the index for documentation comments.
+LookupRequest Req;
+llvm::DenseMap SymbolToCompletion;
 for (auto &C : Scored) {
   Output.Completions.push_back(toCodeCompletion(C.first));
   Output.Completions.back().Score = C.second;
   Output.Completions.back().CompletionTokenRange = ReplacedRange;
+  if (Opts.Index && !Output.Completions.back().Documentation) {
+for (auto &Cand : C.first) {
+  if (Cand.SemaResult &&
+  Cand.SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
+auto ID = clangd::getSymbolID(Cand.SemaResult->getDeclaration());
+if (!ID)
+  continue;
+Req.IDs.insert(ID);
+SymbolToCompletion[ID] = Output.Completions.size() - 1;
+  }
+}
+  }
 }
 Output.HasMore = Incomplete;
 Output.Context = CCContextKind;
 Output.CompletionRange = ReplacedRange;
+
+// Look up documentation from the index.
+if (Opts.Index) {
+  Opts.Index->lookup(Req, [&](const Symbol &S) {
+auto &C = Output.Completions[SymbolToCompletion.at(S.ID)];
+if (S.Documentation.empty())

HighCommander4 wrote:

nit: this early-return can be moved to before the lookup in `SymbolToCompletion`

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


[clang-tools-extra] [clangd] Augment code completion results with documentation from the index. (PR #120099)

2024-12-22 Thread Nathan Ridge via cfe-commits


@@ -1101,6 +1101,42 @@ int x = foo^
   Contains(AllOf(named("foo"), doc("This comment should be retained!";
 }
 
+TEST(CompletionTest, CommentsOnMembers) {

HighCommander4 wrote:

nit: call this `CommentsOnMembersFromHeader`

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


[clang-tools-extra] [clangd] Augment code completion results with documentation from the index. (PR #120099)

2024-12-22 Thread Nathan Ridge via cfe-commits

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Nhat Nguyen  (changkhothuychung)


Changes



---

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


14 Files Affected:

- (added) libcxx/include/__ranges/concat_view.h (+624) 
- (added) libcxx/test/std/ranges/range.adaptors/range.concat/adaptor.pass.cpp 
(+71) 
- (added) libcxx/test/std/ranges/range.adaptors/range.concat/begin.pass.cpp 
(+38) 
- (added) libcxx/test/std/ranges/range.adaptors/range.concat/ctad.pass.cpp 
(+54) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/ctor.default.pass.cpp (+81) 
- (added) libcxx/test/std/ranges/range.adaptors/range.concat/ctor.view.pass.cpp 
(+70) 
- (added) libcxx/test/std/ranges/range.adaptors/range.concat/end.pass.cpp (+99) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/compare.pass.cpp 
(+76) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/decrement.pass.cpp 
(+89) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/deref.pass.cpp 
(+56) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/increment.pass.cpp 
(+84) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/iter_move.pass.cpp 
(+74) 
- (added) 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/iter_swap.pass.cpp 
(+79) 
- (added) libcxx/test/std/ranges/range.adaptors/range.concat/types.h (+44) 


``diff
diff --git a/libcxx/include/__ranges/concat_view.h 
b/libcxx/include/__ranges/concat_view.h
new file mode 100644
index 00..9d17aae65ecaf5
--- /dev/null
+++ b/libcxx/include/__ranges/concat_view.h
@@ -0,0 +1,624 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_CONCAT_VIEW_H
+#define _LIBCPP___RANGES_CONCAT_VIEW_H
+
+#include <__algorithm/ranges_find_if.h>
+#include <__assert>
+#include <__concepts/constructible.h>
+#include <__concepts/copyable.h>
+#include <__concepts/derived_from.h>
+#include <__concepts/equality_comparable.h>
+#include <__config>
+#include <__functional/bind_back.h>
+#include <__functional/invoke.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/default_sentinel.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iter_swap.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/next.h>
+#include <__memory/addressof.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/movable_box.h>
+#include <__ranges/non_propagating_cache.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/is_nothrow_constructible.h>
+#include <__type_traits/is_nothrow_convertible.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
+#include 
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+namespace ranges {
+
+template 
+struct extract_last : extract_last {};
+
+template 
+struct extract_last {
+  using type = T;
+};
+
+template 
+struct derived_from_pack {
+  constexpr static bool value =
+  derived_from_pack<_T, typename extract_last<_Ts...>::type>::value && 
derived_from_pack<_Ts...>::value;
+};
+
+template 
+struct derived_from_pack<_T, _IterCategory> {
+  constexpr static bool value = derived_from<_T, _IterCategory>;
+};
+
+template 
+struct last_view : last_view {};
+
+template 
+struct last_view {
+  using type = View;
+};
+
+template 
+concept concat_indirectly_readable_impl = requires(const It it) {
+  { *it } -> convertible_to;
+  { ranges::iter_move(it) } -> convertible_to;
+};
+
+template 
+using concat_reference_t = common_reference_t...>;
+
+template 
+using concat_value_t = common_type_t...>;
+
+template 
+using concat_rvalue_reference_t = 
common_reference_t...>;
+
+template 
+concept concat_indirectly_readable =
+common_reference_with&&, concat_value_t&> 
&&
+common_reference_with&&, 
concat_rvalue_reference_t&&> &&
+common_reference_with&&, 
concat_value_t const&> &&
+(concat_indirectly_readable_impl, 
concat_rvalue_reference_t, iterator_t> &&
+ ...);
+
+template 
+concept concatable = requires { // exposition only
+  typename concat_reference_t;
+  typename concat_value_t;
+  typename concat_rvalue_reference_t;
+} 

[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

https://github.com/changkhothuychung created 
https://github.com/llvm/llvm-project/pull/120920

None

error: too big or took too long to generate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff c5492e3c65e40cdcab9771b692f9ad437c65aa04 
11ec4bc42c734c5f55047d5c5bd5ed9bcd8c6e01 --extensions cpp,h -- 
libcxx/include/__ranges/concat_view.h 
libcxx/test/std/ranges/range.adaptors/range.concat/adaptor.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/begin.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/ctad.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/ctor.default.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/ctor.view.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/end.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/compare.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/decrement.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/deref.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/increment.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/iter_move.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/iterator/iter_swap.pass.cpp 
libcxx/test/std/ranges/range.adaptors/range.concat/types.h
``





View the diff from clang-format here.


``diff
diff --git a/libcxx/include/__ranges/concat_view.h 
b/libcxx/include/__ranges/concat_view.h
index 9d17aae65e..708917365a 100644
--- a/libcxx/include/__ranges/concat_view.h
+++ b/libcxx/include/__ranges/concat_view.h
@@ -602,9 +602,8 @@ namespace views {
 namespace __concat {
 struct __fn {
   template 
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Views... 
views) const
-  noexcept(noexcept(concat_view(std::forward<_Views>(views)...)))
-  -> decltype(concat_view(std::forward<_Views>(views)...)) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Views... 
views) const noexcept(
+  noexcept(concat_view(std::forward<_Views>(views)...))) -> 
decltype(concat_view(std::forward<_Views>(views)...)) {
 return concat_view(std::forward<_Views>(views)...);
   }
 };
diff --git 
a/libcxx/test/std/ranges/range.adaptors/range.concat/ctor.default.pass.cpp 
b/libcxx/test/std/ranges/range.adaptors/range.concat/ctor.default.pass.cpp
index b11a82f537..f758d5a931 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.concat/ctor.default.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.concat/ctor.default.pass.cpp
@@ -54,9 +54,7 @@ constexpr bool test() {
   }
 
   // Check cases where the default constructor isn't provided
-  {
-
static_assert(!std::is_default_constructible_v>);
-  }
+  { 
static_assert(!std::is_default_constructible_v>); }
 
   // Check noexcept-ness
   {

``




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


[clang] [clang-tools-extra] [libcxx] [llvm] [libcxx] implement views::concat (PR #120920)

2024-12-22 Thread Nhat Nguyen via cfe-commits

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


[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread Owen Pan via cfe-commits

owenca wrote:

You need to add a unit test.

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


[clang] [BoundsSafety][Doc] Add BoundsSafetyAdoptionGuide.rst (PR #120674)

2024-12-22 Thread Yeoul Na via cfe-commits

rapidsna wrote:

> Given the number of small changes that need to be made, I think it's worth 
> mentioning that fix-its exist and how their fixes can be applied, since 
> that's not always obvious when building in the terminal. Perhaps we also want 
> to mention that we'd appreciate reports of snippets that compile without 
> errors but are optimised to unconditional traps?

Sounds good. Let's add those in a follow up since we also need to add debugger 
support.

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


[clang-tools-extra] [clangd] Do not show `aParam` parameter hint for argument spelled `param` (PR #119162)

2024-12-22 Thread Chris B via cfe-commits

https://github.com/llvm-beanz commented:

I think this gets really complicated really quickly. The `a` prefix for 
arguments seems like a coding style derived from Hungarian Notation, and I 
guess I could see an argument for having an option to disregard variable 
prefixes when matching the hints, but it probably should be optional, and it 
should be flexible enough to handle common coding styles (like Hungarian 
Notation).

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits


@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level 
DiagLevel,
 return false;
   if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+
+  auto R = tooling::Replacement(SM, FixIt.RemoveRange, FixIt.CodeToInsert,
+*LangOpts);
+  auto Err = Replacements->addOrMerge(R);
+  if (Err) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Err)));
+Replacements = std::nullopt;
+break;
+  }
+}
+
+llvm::SmallVector Edits;
+
+if (Replacements) {
+  StringRef Code = SM.getBufferData(SM.getMainFileID());
+  auto Repl = format::cleanupAroundReplacements(Code, *Replacements,
+format::getNoStyle());

llvm-beanz wrote:

nit:
```suggestion
  Expected Repl = format::cleanupAroundReplacements(
  Code, *Replacements, format::getNoStyle());
```
LLVM's style guide discourages auto when the type isn't clear from context.
see: 
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits


@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level 
DiagLevel,
 return false;
   if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+
+  auto R = tooling::Replacement(SM, FixIt.RemoveRange, FixIt.CodeToInsert,
+*LangOpts);
+  auto Err = Replacements->addOrMerge(R);
+  if (Err) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Err)));
+Replacements = std::nullopt;
+break;
+  }
+}
+
+llvm::SmallVector Edits;
+
+if (Replacements) {
+  StringRef Code = SM.getBufferData(SM.getMainFileID());
+  auto Repl = format::cleanupAroundReplacements(Code, *Replacements,
+format::getNoStyle());
+  if (!Repl) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Repl.takeError(;
+Replacements = std::nullopt;
+  } else {
+auto Es = replacementsToEdits(Code, *Repl);
+Edits.append(Es.begin(), Es.end());
+  }
+}
+if (!Replacements) {
+  for (auto &FixIt : FixIts) {
+Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+  }

llvm-beanz wrote:

nit:
```suggestion
  for (auto &FixIt : FixIts)
Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
```
see: 
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits


@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level 
DiagLevel,
 return false;
   if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+
+  auto R = tooling::Replacement(SM, FixIt.RemoveRange, FixIt.CodeToInsert,
+*LangOpts);
+  auto Err = Replacements->addOrMerge(R);
+  if (Err) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Err)));
+Replacements = std::nullopt;
+break;
+  }
+}
+
+llvm::SmallVector Edits;
+
+if (Replacements) {
+  StringRef Code = SM.getBufferData(SM.getMainFileID());
+  auto Repl = format::cleanupAroundReplacements(Code, *Replacements,
+format::getNoStyle());
+  if (!Repl) {
+log("Skipping formatting the replacement due to conflict: {0}",
+llvm::toString(std::move(Repl.takeError(;
+Replacements = std::nullopt;
+  } else {
+auto Es = replacementsToEdits(Code, *Repl);

llvm-beanz wrote:

nit:
```suggestion
std::vector Es = replacementsToEdits(Code, *Repl);
```
see: 
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits

https://github.com/llvm-beanz approved this pull request.

This mostly looks good to me. I have a few style nits to use more idomatic 
patterns and conform better to LLVM coding standards.

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits


@@ -761,7 +762,37 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level 
DiagLevel,
 return false;
   if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, SM, *LangOpts));
+
+  auto R = tooling::Replacement(SM, FixIt.RemoveRange, FixIt.CodeToInsert,
+*LangOpts);
+  auto Err = Replacements->addOrMerge(R);
+  if (Err) {

llvm-beanz wrote:

```suggestion
  if (llvm:::Error Err = Replacements->addOrMerge(R)) {
```

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits


@@ -149,26 +149,12 @@ class ErrorReporter {
Repl.getLength(), 
Repl.getReplacementText());
 auto &Entry = FileReplacements[R.getFilePath()];
 Replacements &Replacements = Entry.Replaces;
-llvm::Error Err = Replacements.add(R);
+llvm::Error Err = Replacements.addOrMerge(R);
 if (Err) {

llvm-beanz wrote:

nit: I know this was pre-existing, but this is a more idomatic way to use 
llvm::Error.
```suggestion
if (llvm::Error Err = Replacements.addOrMerge(R)) {
```

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


[clang] [clang-tools-extra] [clangd] Make clangd run `format::cleanupAroundReplacements()` for all code actions just as clang-tidy does (PR #118569)

2024-12-22 Thread Chris B via cfe-commits


@@ -342,6 +342,20 @@ llvm::Error Replacements::add(const Replacement &R) {
   return llvm::Error::success();
 }
 
+llvm::Error Replacements::addOrMerge(const Replacement &R) {
+  auto Err = add(R);
+  if (Err) {

llvm-beanz wrote:

nit: You could rewrite this as:
```suggestion
  if (llvm::Error Err = add(R)) {
```

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


[clang-tools-extra] a4f5e90 - [clang-tidy][NFC][doc] mention some range algorithms do not work for `vector` in C++20 (#120774)

2024-12-22 Thread via cfe-commits

Author: Congcong Cai
Date: 2024-12-23T00:07:57+08:00
New Revision: a4f5e90e319e8bf36ed421a0445218ff17d4de03

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

LOG: [clang-tidy][NFC][doc] mention some range algorithms do not work for 
`vector` in C++20 (#120774)

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst 
b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
index 1ce866ca1f66a0..912b42b33f9194 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-ranges.rst
@@ -104,6 +104,9 @@ Calls to the following std library algorithms are checked:
 ``std::unique``,
 ``std::upper_bound``.
 
+Note: some range algorithms for ``vector`` require C++23 because it uses
+proxy iterators.
+
 Reverse Iteration
 -
 



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


[clang-tools-extra] [clang-tidy][NFC][doc] mention some range algorithms do not work for `vector` in C++20 (PR #120774)

2024-12-22 Thread Congcong Cai via cfe-commits

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


[clang] [Clang][Driver][Test] Created test for unsupported driver options (PR #120900)

2024-12-22 Thread Mészáros Gergely via cfe-commits

Maetveis wrote:

Hi,Thanks for working on this issue. I wanted to preface this by feel free to 
ignore this during the holidays, zero pressure. I like to interact with the 
community in my free time, but that obviously does not need to extend to 
everyone :).

What kind of failures are you seeing in the generated test? There shouldn't be 
any afaict if the script works correctly, as Options.td IS the source where the 
parsing code for the various drivers are generated from. Are you perhaps 
missing the case where there is no visibility specified at all and it should be 
assumed to be `DefaultVisibility`, i.e. the gcc compatible clang driver?

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


[clang] [flang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120897)

2024-12-22 Thread via cfe-commits

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


[clang] [flang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120897)

2024-12-22 Thread via cfe-commits

dty2 wrote:

Sorry, this is my mistake. The commit of this PR is too messy. I will resubmit 
a PR.

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


[clang] [flang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120897)

2024-12-22 Thread via cfe-commits

https://github.com/dty2 created https://github.com/llvm/llvm-project/pull/120897

Try to fix issue: https://github.com/llvm/llvm-project/issues/120148
I'm a newbie, please give me some suggestions for modification.
Especially I use a global array "castIdentifiers", I feel that this 
implementation is not good, but I don't know how to modify it.

From 2d5d3107444d244cf5fa2c75cb69000e3c6ca081 Mon Sep 17 00:00:00 2001
From: hunter <284050...@qq.com>
Date: Tue, 26 Nov 2024 02:18:10 +0800
Subject: [PATCH 01/13] [flang]Add new intrinsic function backtrace and
 complete the TODO of abort

---
 .../flang/Optimizer/Builder/IntrinsicCall.h   |  1 +
 .../flang/Optimizer/Builder/Runtime/Stop.h|  3 +++
 flang/include/flang/Runtime/stop.h|  1 +
 flang/lib/Evaluate/intrinsics.cpp |  1 +
 flang/lib/Optimizer/Builder/IntrinsicCall.cpp |  7 +++
 flang/lib/Optimizer/Builder/Runtime/Stop.cpp  |  7 +++
 flang/runtime/stop.cpp| 21 ++-
 flang/test/Lower/Intrinsics/backtrace.f90 | 10 +
 8 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Lower/Intrinsics/backtrace.f90

diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h 
b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index e83d1a42e34133..7f4b9ebf1d1c21 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -196,6 +196,7 @@ struct IntrinsicLibrary {
   fir::ExtendedValue genAssociated(mlir::Type,
llvm::ArrayRef);
   mlir::Value genAtand(mlir::Type, llvm::ArrayRef);
+  void genBacktrace(llvm::ArrayRef);
   fir::ExtendedValue genBesselJn(mlir::Type,
  llvm::ArrayRef);
   fir::ExtendedValue genBesselYn(mlir::Type,
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Stop.h 
b/flang/include/flang/Optimizer/Builder/Runtime/Stop.h
index 6f764badf6f3a8..be73c021e3 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/Stop.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/Stop.h
@@ -30,6 +30,9 @@ void genExit(fir::FirOpBuilder &, mlir::Location, mlir::Value 
status);
 /// Generate call to ABORT intrinsic runtime routine.
 void genAbort(fir::FirOpBuilder &, mlir::Location);
 
+/// Generate call to BACKTRACE intrinsic runtime routine.
+void genBacktrace(fir::FirOpBuilder &builder, mlir::Location loc);
+
 /// Generate call to crash the program with an error message when detecting
 /// an invalid situation at runtime.
 void genReportFatalUserError(fir::FirOpBuilder &, mlir::Location,
diff --git a/flang/include/flang/Runtime/stop.h 
b/flang/include/flang/Runtime/stop.h
index f7c4ffe7403e8e..d442f72bfe1fa4 100644
--- a/flang/include/flang/Runtime/stop.h
+++ b/flang/include/flang/Runtime/stop.h
@@ -29,6 +29,7 @@ NORETURN void RTNAME(ProgramEndStatement)(NO_ARGUMENTS);
 // Extensions
 NORETURN void RTNAME(Exit)(int status DEFAULT_VALUE(EXIT_SUCCESS));
 NORETURN void RTNAME(Abort)(NO_ARGUMENTS);
+void RTNAME(Backtrace)(NO_ARGUMENTS);
 
 // Crash with an error message when the program dynamically violates a Fortran
 // constraint.
diff --git a/flang/lib/Evaluate/intrinsics.cpp 
b/flang/lib/Evaluate/intrinsics.cpp
index 1e27c0ae4216c5..599a7d0124b800 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1333,6 +1333,7 @@ static const IntrinsicInterface intrinsicSubroutine[]{
 {"stat", AnyInt, Rank::scalar, Optionality::optional,
 common::Intent::Out}},
 {}, Rank::elemental, IntrinsicClass::atomicSubroutine},
+{"backtrace", {}, {}, Rank::elemental, IntrinsicClass::pureSubroutine},
 {"co_broadcast",
 {{"a", AnyData, Rank::anyOrAssumedRank, Optionality::required,
  common::Intent::InOut},
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp 
b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index a2b327f45c6939..c748c6583a5ce9 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -150,6 +150,7 @@ static constexpr IntrinsicHandler handlers[]{
 {"atan2pi", &I::genAtanpi},
 {"atand", &I::genAtand},
 {"atanpi", &I::genAtanpi},
+{"backtrace", &I::genBacktrace},
 {"bessel_jn",
  &I::genBesselJn,
  {{{"n1", asValue}, {"n2", asValue}, {"x", asValue}}},
@@ -2681,6 +2682,12 @@ IntrinsicLibrary::genBesselJn(mlir::Type resultType,
   }
 }
 
+// Backtrace
+void IntrinsicLibrary::genBacktrace(llvm::ArrayRef args) {
+  assert(args.size() == 0);
+  fir::runtime::genBacktrace(builder, loc);
+}
+
 // BESSEL_YN
 fir::ExtendedValue
 IntrinsicLibrary::genBesselYn(mlir::Type resultType,
diff --git a/flang/lib/Optimizer/Builder/Runtime/Stop.cpp 
b/flang/lib/Optimizer/Builder/Runtime/Stop.cpp
index 411181cc6dd1ca..541e5f3b5d11a8 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Stop.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Stop.cpp
@@

[clang] Factor common code for quoting a builtin name (PR #120835)

2024-12-22 Thread Carlo Cabrera via cfe-commits

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


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


[clang] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)

2024-12-22 Thread Owen Pan via cfe-commits

https://github.com/owenca requested changes to this pull request.

Please run `ninja FormatTests` before submitting the patch. It fails a few unit 
tests before crashing.

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


[clang-tools-extra] b68a952 - [clang-doc] Migrate away from PointerUnion::{is,get} (NFC) (#120872)

2024-12-22 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-12-22T01:30:08-08:00
New Revision: b68a952ae1c06b78790eab758574d992159e33b8

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

LOG: [clang-doc] Migrate away from PointerUnion::{is,get} (NFC) (#120872)

Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

Added: 


Modified: 
clang-tools-extra/clang-doc/Serialize.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/Serialize.cpp 
b/clang-tools-extra/clang-doc/Serialize.cpp
index 93efdd44f45898..f737fc75135a19 100644
--- a/clang-tools-extra/clang-doc/Serialize.cpp
+++ b/clang-tools-extra/clang-doc/Serialize.cpp
@@ -696,13 +696,11 @@ emitInfo(const RecordDecl *D, const FullComment *FC, int 
LineNumber,
 
 // What this is a specialization of.
 auto SpecOf = CTSD->getSpecializedTemplateOrPartial();
-if (SpecOf.is()) {
-  Specialization.SpecializationOf =
-  getUSRForDecl(SpecOf.get());
-} else if (SpecOf.is()) {
-  Specialization.SpecializationOf =
-  getUSRForDecl(SpecOf.get());
-}
+if (auto *CTD = dyn_cast(SpecOf))
+  Specialization.SpecializationOf = getUSRForDecl(CTD);
+else if (auto *CTPSD =
+ dyn_cast(SpecOf))
+  Specialization.SpecializationOf = getUSRForDecl(CTPSD);
 
 // Parameters to the specilization. For partial specializations, get the
 // parameters "as written" from the ClassTemplatePartialSpecializationDecl



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


[clang-tools-extra] [clang-doc] Migrate away from PointerUnion::{is,get} (NFC) (PR #120872)

2024-12-22 Thread Kazu Hirata via cfe-commits

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


[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)

2024-12-22 Thread Chandler Carruth via cfe-commits


@@ -68,23 +70,144 @@ enum ID {
   FirstTSBuiltin
 };
 
+// The info used to represent each builtin.
 struct Info {
-  llvm::StringLiteral Name;
-  const char *Type, *Attributes;
-  const char *Features;
+  // Rather than store pointers to the string literals describing these four
+  // aspects of builtins, we store offsets into a common string table.
+  struct StrOffsets {
+llvm::StringTable::Offset Name;
+llvm::StringTable::Offset Type;
+llvm::StringTable::Offset Attributes;
+llvm::StringTable::Offset Features;
+  } Offsets;
+
   HeaderDesc Header;
   LanguageID Langs;
 };
 
+// A constexpr function to construct an infos array from X-macros.
+//
+// The input array uses the same data structure, but the offsets are actually
+// _lengths_ when input. This is all we can compute from the X-macro approach 
to
+// builtins. This function will convert these lengths into actual offsets to a
+// string table built up through sequentially appending strings with the given
+// lengths.
+template 
+static constexpr std::array MakeInfos(std::array Infos) {
+  // Translate lengths to offsets. We start past the initial empty string at
+  // offset zero.
+  unsigned Offset = 1;
+  for (auto &I : Infos) {

chandlerc wrote:

Sure, switched.

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


[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)

2024-12-22 Thread Chandler Carruth via cfe-commits


@@ -100,10 +244,17 @@ class Context {
 
   /// Return the identifier name for the specified builtin,
   /// e.g. "__builtin_abs".
-  llvm::StringRef getName(unsigned ID) const { return getRecord(ID).Name; }
+  std::string getName(unsigned ID) const;
+
+  /// Return the identifier name for the specified builtin inside single quotes
+  /// for a diagnostic, e.g. "'__builtin_abs'".
+  std::string getQuotedName(unsigned ID) const;

chandlerc wrote:

Sure, sent #120835 to you.

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


  1   2   >