[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Looking at diagnostics in the test you add, I wonder why don't we issue them, 
and especially the fixit, when we parse bit-field declaration. Why waiting 
until assignment happens?

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


[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

> Looking at diagnostics in the test you add, I wonder why don't we issue them, 
> and especially the fixit, when we parse bit-field declaration. Why waiting 
> until assignment happens?

Yeah, it's super frustrating to me that we do that - I did _consider_ making 
them early but I really didn't want to simultaneously change that behavior and 
add a feature, and I thought making just preferred_type warnings early would be 
especially insane :D

GCC at least does warn on declaration, I'm not sure if there is a deliberate 
and historical reason that we delay notification, or if it is just happenstance.

I'd be onboard with making it a declaration warning in future.

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


[clang] [clang] Add test for CWG794 "Base-derived conversion in member type of pointer-to-member conversion" (PR #121660)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/121660

This patch adds a test for 
[CWG794](https://cplusplus.github.io/CWG/issues/794.html), which is an NB 
comment closed as NAD. Author was asked to bring a paper to Evolution, which 
never happened. So we test for the absence of base-derived conversion in 
pointer-to-member conversion.

>From 1bb31bab73fb9ee38e947fd5f0350730db8a259e Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 4 Jan 2025 21:52:15 +0300
Subject: [PATCH] [clang] Add test for CWG794 "Base-derived conversion in
 member type of pointer-to-member conversion"

---
 clang/test/CXX/drs/cwg7xx.cpp | 12 
 clang/www/cxx_dr_status.html  |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/cwg7xx.cpp b/clang/test/CXX/drs/cwg7xx.cpp
index 507eb8fb714350..842d172d379005 100644
--- a/clang/test/CXX/drs/cwg7xx.cpp
+++ b/clang/test/CXX/drs/cwg7xx.cpp
@@ -337,3 +337,15 @@ template 
 void h(int i = 0, T ...args, int j = 1) {}
 #endif
 }
+
+namespace cwg794 { // cwg794: 2.7
+struct B {};
+struct D : B {};
+struct X {
+  D d;
+};
+struct Y : X {};
+B Y::*pm = &X::d;
+// expected-error@-1 {{cannot initialize a variable of type 'B Y::*' with an 
rvalue of type 'D cwg794::X::*': different classes ('Y' vs 'cwg794::X')}}
+// FIXME: why diagnostic says just `Y` and not `cwg794::Y`, like `cwg794::X`?
+} // namespace cwg794
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..98766b71d42845 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -4775,7 +4775,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/794.html";>794
 NAD
 Base-derived conversion in member type of pointer-to-member 
conversion
-Unknown
+Clang 2.7
   
   
 https://cplusplus.github.io/CWG/issues/795.html";>795

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


[clang] [clang] Add test for CWG794 "Base-derived conversion in member type of pointer-to-member conversion" (PR #121660)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch adds a test for 
[CWG794](https://cplusplus.github.io/CWG/issues/794.html), which is an NB 
comment closed as NAD. Author was asked to bring a paper to Evolution, which 
never happened. So we test for the absence of base-derived conversion in 
pointer-to-member conversion.

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


2 Files Affected:

- (modified) clang/test/CXX/drs/cwg7xx.cpp (+12) 
- (modified) clang/www/cxx_dr_status.html (+1-1) 


``diff
diff --git a/clang/test/CXX/drs/cwg7xx.cpp b/clang/test/CXX/drs/cwg7xx.cpp
index 507eb8fb714350..842d172d379005 100644
--- a/clang/test/CXX/drs/cwg7xx.cpp
+++ b/clang/test/CXX/drs/cwg7xx.cpp
@@ -337,3 +337,15 @@ template 
 void h(int i = 0, T ...args, int j = 1) {}
 #endif
 }
+
+namespace cwg794 { // cwg794: 2.7
+struct B {};
+struct D : B {};
+struct X {
+  D d;
+};
+struct Y : X {};
+B Y::*pm = &X::d;
+// expected-error@-1 {{cannot initialize a variable of type 'B Y::*' with an 
rvalue of type 'D cwg794::X::*': different classes ('Y' vs 'cwg794::X')}}
+// FIXME: why diagnostic says just `Y` and not `cwg794::Y`, like `cwg794::X`?
+} // namespace cwg794
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..98766b71d42845 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -4775,7 +4775,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/794.html";>794
 NAD
 Base-derived conversion in member type of pointer-to-member 
conversion
-Unknown
+Clang 2.7
   
   
 https://cplusplus.github.io/CWG/issues/795.html";>795

``




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


[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> and I thought making just preferred_type warnings early would be especially 
> insane :D

I don't necessarily agree. `preferred_type` is a relatively new thing, so we 
can try doing something new here.

> [edit: I just realized even that might need to be an option because I can 
> imagine someone, somewhere, depending on -Werror and not hitting this by luck]

I don't believe we need to be concerned about forward compatibility for 
`-Werror` users. They should know they signed themselves up for pain, and we're 
not going to compromise our QoI because of that.

In any case, this PR is step in the right direction, so I don't want to block 
its progress.

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


[clang] [clang-format] Add `TT_CompoundRequirementLBrace` for better annotation (PR #121539)

2025-01-04 Thread Owen Pan via cfe-commits

owenca wrote:

> This is a good fix but I think it might not be addressing the whole issue. 
> This isn't a problem with just _compound-requirement_, it's the case for 
> _simple-requirement_s too.

This patch fixes compound requirements as mentioned in the commit message and 
reported in the GitHub issue. Can you open a new issue for the simple 
requirement bug you noticed? I'll have a look and see if it can be fixed in a 
similar way.

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


[clang] [Clang][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/121650

This patch uses `__builtin_bit_cast` as workaround to make MS UCRT's 
non-conforming functions `` usable for ``.

Fixes #45552.

>From 0366072ca42ec9773897daabf7946eb37c631623 Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Sat, 4 Jan 2025 23:53:05 +0800
Subject: [PATCH] [Clang][Headers] Workaround for UCRT's `` in
 ``

This patch uses `__builtin_bit_cast` as workaround to make MS UCRT's
non-conforming functions `` usable for ``.
---
 clang/lib/Headers/tgmath.h | 453 -
 1 file changed, 245 insertions(+), 208 deletions(-)

diff --git a/clang/lib/Headers/tgmath.h b/clang/lib/Headers/tgmath.h
index 7acf18b9dd3578..e236be92f35c6c 100644
--- a/clang/lib/Headers/tgmath.h
+++ b/clang/lib/Headers/tgmath.h
@@ -28,6 +28,30 @@
 #define _TG_ATTRSp __attribute__((__overloadable__))
 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
 
+// https://github.com/llvm/llvm-project/issues/45552
+// workaround for MS UCRT's 
+#if defined(_VCRUNTIME_H) && defined(_C_COMPLEX_T)
+#define __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H 1
+#else
+#define __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H 0
+#endif
+
+#if __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H
+#define _TG_FROM_FCOMPLEX(__z) __builtin_bit_cast(float _Complex, (__z))
+#define _TG_FROM_DCOMPLEX(__z) __builtin_bit_cast(double _Complex, (__z))
+#define _TG_FROM_LCOMPLEX(__z) __builtin_bit_cast(long double _Complex, (__z))
+#define _TG_TO_FCOMPLEX(__z) __builtin_bit_cast(_Fcomplex, (__z))
+#define _TG_TO_DCOMPLEX(__z) __builtin_bit_cast(_Dcomplex, (__z))
+#define _TG_TO_LCOMPLEX(__z) __builtin_bit_cast(_Lcomplex, (__z))
+#else
+#define _TG_FROM_FCOMPLEX(__z) (__z)
+#define _TG_FROM_DCOMPLEX(__z) (__z)
+#define _TG_FROM_LCOMPLEX(__z) (__z)
+#define _TG_TO_FCOMPLEX(__z) (__z)
+#define _TG_TO_DCOMPLEX(__z) (__z)
+#define _TG_TO_LCOMPLEX(__z) (__z)
+#endif
+
 // promotion
 
 typedef void _Argument_type_is_not_arithmetic;
@@ -67,17 +91,17 @@ static long double
 _TG_ATTRS
 __tg_acos(long double __x) {return acosl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_acos(float _Complex __x) {return cacosf(__x);}
+static float _Complex _TG_ATTRS __tg_acos(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(cacosf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_acos(double _Complex __x) {return cacos(__x);}
+static double _Complex _TG_ATTRS __tg_acos(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(cacos(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_acos(long double _Complex __x) {return cacosl(__x);}
+static long double _Complex _TG_ATTRS __tg_acos(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(cacosl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef acos
 #define acos(__x) __tg_acos(__tg_promote1((__x))(__x))
@@ -96,17 +120,17 @@ static long double
 _TG_ATTRS
 __tg_asin(long double __x) {return asinl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_asin(float _Complex __x) {return casinf(__x);}
+static float _Complex _TG_ATTRS __tg_asin(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(casinf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_asin(double _Complex __x) {return casin(__x);}
+static double _Complex _TG_ATTRS __tg_asin(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(casin(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_asin(long double _Complex __x) {return casinl(__x);}
+static long double _Complex _TG_ATTRS __tg_asin(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(casinl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef asin
 #define asin(__x) __tg_asin(__tg_promote1((__x))(__x))
@@ -125,17 +149,17 @@ static long double
 _TG_ATTRS
 __tg_atan(long double __x) {return atanl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_atan(float _Complex __x) {return catanf(__x);}
+static float _Complex _TG_ATTRS __tg_atan(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(catanf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_atan(double _Complex __x) {return catan(__x);}
+static double _Complex _TG_ATTRS __tg_atan(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(catan(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_atan(long double _Complex __x) {return catanl(__x);}
+static long double _Complex _TG_ATTRS __tg_atan(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(catanl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef atan
 #define atan(__x) __tg_atan(__tg_promote1((__x))(__x))
@@ -154,17 +178,17 @@ static long double
 _TG_ATTRS
 __tg_acosh(long double __x) {return acoshl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_acosh(float _Complex __x) {return cacoshf(__x);}
+static float _Complex _TG_ATTRS __tg_acosh(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(cacoshf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _C

[clang] [Clang][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: A. Jiang (frederick-vs-ja)


Changes

This patch uses `__builtin_bit_cast` as workaround to make MS UCRT's 
non-conforming functions `` usable for ``.

Fixes #45552.

---

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


1 Files Affected:

- (modified) clang/lib/Headers/tgmath.h (+245-208) 


``diff
diff --git a/clang/lib/Headers/tgmath.h b/clang/lib/Headers/tgmath.h
index 7acf18b9dd3578..e236be92f35c6c 100644
--- a/clang/lib/Headers/tgmath.h
+++ b/clang/lib/Headers/tgmath.h
@@ -28,6 +28,30 @@
 #define _TG_ATTRSp __attribute__((__overloadable__))
 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
 
+// https://github.com/llvm/llvm-project/issues/45552
+// workaround for MS UCRT's 
+#if defined(_VCRUNTIME_H) && defined(_C_COMPLEX_T)
+#define __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H 1
+#else
+#define __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H 0
+#endif
+
+#if __CLANG_TGMATH_H_USES_UCRT_COMPLEX_H
+#define _TG_FROM_FCOMPLEX(__z) __builtin_bit_cast(float _Complex, (__z))
+#define _TG_FROM_DCOMPLEX(__z) __builtin_bit_cast(double _Complex, (__z))
+#define _TG_FROM_LCOMPLEX(__z) __builtin_bit_cast(long double _Complex, (__z))
+#define _TG_TO_FCOMPLEX(__z) __builtin_bit_cast(_Fcomplex, (__z))
+#define _TG_TO_DCOMPLEX(__z) __builtin_bit_cast(_Dcomplex, (__z))
+#define _TG_TO_LCOMPLEX(__z) __builtin_bit_cast(_Lcomplex, (__z))
+#else
+#define _TG_FROM_FCOMPLEX(__z) (__z)
+#define _TG_FROM_DCOMPLEX(__z) (__z)
+#define _TG_FROM_LCOMPLEX(__z) (__z)
+#define _TG_TO_FCOMPLEX(__z) (__z)
+#define _TG_TO_DCOMPLEX(__z) (__z)
+#define _TG_TO_LCOMPLEX(__z) (__z)
+#endif
+
 // promotion
 
 typedef void _Argument_type_is_not_arithmetic;
@@ -67,17 +91,17 @@ static long double
 _TG_ATTRS
 __tg_acos(long double __x) {return acosl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_acos(float _Complex __x) {return cacosf(__x);}
+static float _Complex _TG_ATTRS __tg_acos(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(cacosf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_acos(double _Complex __x) {return cacos(__x);}
+static double _Complex _TG_ATTRS __tg_acos(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(cacos(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_acos(long double _Complex __x) {return cacosl(__x);}
+static long double _Complex _TG_ATTRS __tg_acos(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(cacosl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef acos
 #define acos(__x) __tg_acos(__tg_promote1((__x))(__x))
@@ -96,17 +120,17 @@ static long double
 _TG_ATTRS
 __tg_asin(long double __x) {return asinl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_asin(float _Complex __x) {return casinf(__x);}
+static float _Complex _TG_ATTRS __tg_asin(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(casinf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_asin(double _Complex __x) {return casin(__x);}
+static double _Complex _TG_ATTRS __tg_asin(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(casin(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_asin(long double _Complex __x) {return casinl(__x);}
+static long double _Complex _TG_ATTRS __tg_asin(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(casinl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef asin
 #define asin(__x) __tg_asin(__tg_promote1((__x))(__x))
@@ -125,17 +149,17 @@ static long double
 _TG_ATTRS
 __tg_atan(long double __x) {return atanl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_atan(float _Complex __x) {return catanf(__x);}
+static float _Complex _TG_ATTRS __tg_atan(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(catanf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_atan(double _Complex __x) {return catan(__x);}
+static double _Complex _TG_ATTRS __tg_atan(double _Complex __x) {
+  return _TG_FROM_DCOMPLEX(catan(_TG_TO_DCOMPLEX(__x)));
+}
 
-static long double _Complex
-_TG_ATTRS
-__tg_atan(long double _Complex __x) {return catanl(__x);}
+static long double _Complex _TG_ATTRS __tg_atan(long double _Complex __x) {
+  return _TG_FROM_LCOMPLEX(catanl(_TG_TO_LCOMPLEX(__x)));
+}
 
 #undef atan
 #define atan(__x) __tg_atan(__tg_promote1((__x))(__x))
@@ -154,17 +178,17 @@ static long double
 _TG_ATTRS
 __tg_acosh(long double __x) {return acoshl(__x);}
 
-static float _Complex
-_TG_ATTRS
-__tg_acosh(float _Complex __x) {return cacoshf(__x);}
+static float _Complex _TG_ATTRS __tg_acosh(float _Complex __x) {
+  return _TG_FROM_FCOMPLEX(cacoshf(_TG_TO_FCOMPLEX(__x)));
+}
 
-static double _Complex
-_TG_ATTRS
-__tg_acosh(double _Complex __x) {return cacosh(__x);}
+static double _Complex _TG_ATTRS __tg_acosh(double _Complex __x) {
+  return _TG_FROM_D

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

> > and I thought making just preferred_type warnings early would be especially 
> > insane :D
> 
> I don't necessarily agree. `preferred_type` is a relatively new thing, so we 
> can try doing something new here.
> 

Yeah, but the implementation is essentially identical, so I would literally 
just be implementing it for preferred type and explicitly ignoring *actual* 
enums :D

> > [edit: I just realized even that might need to be an option because I can 
> > imagine someone, somewhere, depending on -Werror and not hitting this by 
> > luck]
> 
> I don't believe we need to be concerned about forward compatibility for 
> `-Werror` users. They should know they signed themselves up for pain, and 
> we're not going to compromise our QoI because of that.

Yeah, I was also trying to think of cases where this might not trigger a 
warning/error currently, because there's an explicit warning path for assigning 
a constant and (while too lazy to godbolt right now) imagine it being possible 
to have

```cpp
enum class Enum {
  A, B, C, D
};

struct S {
  Enum e: 1; // I'm a rockstar developer and "know" that I'll only ever assign 
A or B here
}
...
  S s;
  if (x)
s.e = Enum::A;
  else
s.e = Enum::B;
```

and not trip an error/warning?
 
> In any case, this PR is step in the right direction, so I don't want to block 
> its progress.

Cheers, I can file a follow on "warn on declaration" bug/PR

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


[clang] [clang-format][NFC] Add missing config tests for List of Strings (PR #121451)

2025-01-04 Thread Owen Pan via cfe-commits

owenca wrote:

> these tests are so inconsistent but I guess it's not that critical

See the added commit message.

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


[clang] [clang-format][NFC] Add missing config tests for List of Strings (PR #121451)

2025-01-04 Thread Owen Pan via cfe-commits

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


[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

> (while too lazy to godbolt right now)

Given I basically wrote the entire example, I thought I would just do the 
godbolting, and lo

```cpp
enum class Enum {
  A, B, C, D
};

struct S {
  Enum e: 1; // I'm a rockstar developer and "know" that I'll only ever assign 
A or B here
};
void f(bool x) {
  S s;
  if (x)
s.e = Enum::A;
  else
s.e = Enum::B;
}
```

Compiles cleanly with `-Wbitfield-width -Wbitfield-enum-conversion`: 
https://godbolt.org/z/a1fErxv74

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


[clang] [llvm] [llvm][NFC] Rework Timer.cpp globals to ensure valid lifetimes (PR #121663)

2025-01-04 Thread via cfe-commits

https://github.com/macurtis-amd created 
https://github.com/llvm/llvm-project/pull/121663

This is intended to help with flang `-ftime-report` support:
- #107270.

With this change, I was able to cherry-pick #107270, uncomment 
`llvm::TimePassesIsEnabled = true;` and compile with `-ftime-report`.

I also noticed that `clang/lib/Driver/OffloadBundler.cpp` was statically 
constructing a `TimerGroup` and changed it to lazily construct via 
ManagedStatic.


>From a46e7a4f158abb0cbc128bd466229e3a195332eb Mon Sep 17 00:00:00 2001
From: Matthew Curtis 
Date: Sat, 4 Jan 2025 13:38:57 -0600
Subject: [PATCH 1/2] [llvm][NFC] Rework Timer.cpp globals to ensure valid
 lifetimes

---
 llvm/include/llvm/Support/Timer.h |   6 +
 llvm/lib/Support/Timer.cpp| 248 +++---
 2 files changed, 166 insertions(+), 88 deletions(-)

diff --git a/llvm/include/llvm/Support/Timer.h 
b/llvm/include/llvm/Support/Timer.h
index 1a32832b6c6536..c05389332b8045 100644
--- a/llvm/include/llvm/Support/Timer.h
+++ b/llvm/include/llvm/Support/Timer.h
@@ -12,6 +12,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/Mutex.h"
 #include 
 #include 
 #include 
@@ -19,6 +20,7 @@
 
 namespace llvm {
 
+class TimerGlobals;
 class TimerGroup;
 class raw_ostream;
 
@@ -196,6 +198,10 @@ class TimerGroup {
   TimerGroup(const TimerGroup &TG) = delete;
   void operator=(const TimerGroup &TG) = delete;
 
+  friend class TimerGlobals;
+  explicit TimerGroup(StringRef Name, StringRef Description,
+  sys::SmartMutex &lock);
+
 public:
   explicit TimerGroup(StringRef Name, StringRef Description);
 
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 634f27f57b00a2..5c0b5943d31f7d 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -38,63 +38,40 @@
 
 using namespace llvm;
 
-// This ugly hack is brought to you courtesy of constructor/destructor ordering
-// being unspecified by C++.  Basically the problem is that a Statistic object
-// gets destroyed, which ends up calling 'GetLibSupportInfoOutputFile()'
-// (below), which calls this function.  LibSupportInfoOutputFilename used to be
-// a global variable, but sometimes it would get destroyed before the 
Statistic,
-// causing havoc to ensue.  We "fix" this by creating the string the first time
-// it is needed and never destroying it.
-static ManagedStatic LibSupportInfoOutputFilename;
-static std::string &getLibSupportInfoOutputFilename() {
-  return *LibSupportInfoOutputFilename;
+//===--===//
+// Forward declarations for Managed Timer Globals (mtg) getters.
+//
+// Globals have been placed at the end of the file to restrict direct
+// access. Use of getters also has the benefit of making it a bit more explicit
+// that a global is being used.
+//===--===//
+namespace {
+class Name2PairMap;
 }
 
-static ManagedStatic > TimerLock;
-
-/// Allows llvm::Timer to emit signposts when supported.
-static ManagedStatic Signposts;
-
-namespace {
-struct CreateTrackSpace {
-  static void *call() {
-return new cl::opt("track-memory",
- cl::desc("Enable -time-passes memory "
-  "tracking (this may be slow)"),
- cl::Hidden);
-  }
-};
-static ManagedStatic, CreateTrackSpace> TrackSpace;
-struct CreateInfoOutputFilename {
-  static void *call() {
-return new cl::opt(
-"info-output-file", cl::value_desc("filename"),
-cl::desc("File to append -stats and -timer output to"), cl::Hidden,
-cl::location(getLibSupportInfoOutputFilename()));
-  }
-};
-static ManagedStatic, CreateInfoOutputFilename>
-InfoOutputFilename;
-struct CreateSortTimers {
-  static void *call() {
-return new cl::opt(
-"sort-timers",
-cl::desc("In the report, sort the timers in each group "
- "in wall clock time order"),
-cl::init(true), cl::Hidden);
-  }
-};
-ManagedStatic, CreateSortTimers> SortTimers;
-} // namespace
+namespace mtg {
+static std::string &LibSupportInfoOutputFilename();
+static const std::string &InfoOutputFilename();
+static bool TrackSpace();
+static bool SortTimers();
+static SignpostEmitter &Signposts();
+static sys::SmartMutex &TimerLock();
+static TimerGroup &DefaultTimerGroup();
+static TimerGroup *claimDefaultTimerGroup();
+static Name2PairMap &NamedGroupedTimers();
+} // namespace mtg
 
+//===--===//
+//
+//===--===//
 void llvm::initTimerOptions() {
-  *TrackSpace;
-  *InfoOutputFilename;
-  *SortTimers;
+  mtg::TrackSpace();
+  mtg::InfoOutputFilename();
+  mtg::SortTimers();
 }
 
 std::unique_ptr llvm::CreateInfoOutputFil

[clang] [llvm] [llvm][NFC] Rework Timer.cpp globals to ensure valid lifetimes (PR #121663)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: None (macurtis-amd)


Changes

This is intended to help with flang `-ftime-report` support:
- #107270.

With this change, I was able to cherry-pick #107270, uncomment 
`llvm::TimePassesIsEnabled = true;` and compile with `-ftime-report`.

I also noticed that `clang/lib/Driver/OffloadBundler.cpp` was statically 
constructing a `TimerGroup` and changed it to lazily construct via 
ManagedStatic.


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


3 Files Affected:

- (modified) clang/lib/Driver/OffloadBundler.cpp (+16-7) 
- (modified) llvm/include/llvm/Support/Timer.h (+6) 
- (modified) llvm/lib/Support/Timer.cpp (+160-88) 


``diff
diff --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 87d7303d938c90..2d6bdff0393be5 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MD5.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -63,9 +64,17 @@ using namespace llvm;
 using namespace llvm::object;
 using namespace clang;
 
-static llvm::TimerGroup
-ClangOffloadBundlerTimerGroup("Clang Offload Bundler Timer Group",
-  "Timer group for clang offload bundler");
+namespace {
+struct CreateClangOffloadBundlerTimerGroup {
+  static void *call() {
+return new TimerGroup("Clang Offload Bundler Timer Group",
+  "Timer group for clang offload bundler");
+  }
+};
+} // namespace
+static llvm::ManagedStatic
+ClangOffloadBundlerTimerGroup;
 
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
@@ -987,7 +996,7 @@ CompressedOffloadBundle::compress(llvm::compression::Params 
P,
  "Compression not supported");
 
   llvm::Timer HashTimer("Hash Calculation Timer", "Hash calculation time",
-ClangOffloadBundlerTimerGroup);
+*ClangOffloadBundlerTimerGroup);
   if (Verbose)
 HashTimer.startTimer();
   llvm::MD5 Hash;
@@ -1004,7 +1013,7 @@ 
CompressedOffloadBundle::compress(llvm::compression::Params P,
   Input.getBuffer().size());
 
   llvm::Timer CompressTimer("Compression Timer", "Compression time",
-ClangOffloadBundlerTimerGroup);
+*ClangOffloadBundlerTimerGroup);
   if (Verbose)
 CompressTimer.startTimer();
   llvm::compression::compress(P, BufferUint8, CompressedBuffer);
@@ -1119,7 +1128,7 @@ CompressedOffloadBundle::decompress(const 
llvm::MemoryBuffer &Input,
  "Unknown compressing method");
 
   llvm::Timer DecompressTimer("Decompression Timer", "Decompression time",
-  ClangOffloadBundlerTimerGroup);
+  *ClangOffloadBundlerTimerGroup);
   if (Verbose)
 DecompressTimer.startTimer();
 
@@ -1141,7 +1150,7 @@ CompressedOffloadBundle::decompress(const 
llvm::MemoryBuffer &Input,
 // Recalculate MD5 hash for integrity check
 llvm::Timer HashRecalcTimer("Hash Recalculation Timer",
 "Hash recalculation time",
-ClangOffloadBundlerTimerGroup);
+*ClangOffloadBundlerTimerGroup);
 HashRecalcTimer.startTimer();
 llvm::MD5 Hash;
 llvm::MD5::MD5Result Result;
diff --git a/llvm/include/llvm/Support/Timer.h 
b/llvm/include/llvm/Support/Timer.h
index 1a32832b6c6536..c05389332b8045 100644
--- a/llvm/include/llvm/Support/Timer.h
+++ b/llvm/include/llvm/Support/Timer.h
@@ -12,6 +12,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/Mutex.h"
 #include 
 #include 
 #include 
@@ -19,6 +20,7 @@
 
 namespace llvm {
 
+class TimerGlobals;
 class TimerGroup;
 class raw_ostream;
 
@@ -196,6 +198,10 @@ class TimerGroup {
   TimerGroup(const TimerGroup &TG) = delete;
   void operator=(const TimerGroup &TG) = delete;
 
+  friend class TimerGlobals;
+  explicit TimerGroup(StringRef Name, StringRef Description,
+  sys::SmartMutex &lock);
+
 public:
   explicit TimerGroup(StringRef Name, StringRef Description);
 
diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index 634f27f57b00a2..5c0b5943d31f7d 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -38,63 +38,40 @@
 
 using namespace llvm;
 
-// This ugly hack is brought to you courtesy of constructor/destructor ordering
-// being unspecified by C++.  Basically the problem is that a Statistic object
-// gets destroyed, which ends up calling 'GetLibSupportInfoOutputFile()'
-// (below), which calls this function.  L

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

2025-01-04 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][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread A. Jiang via cfe-commits


@@ -28,6 +28,30 @@
 #define _TG_ATTRSp __attribute__((__overloadable__))
 #define _TG_ATTRS __attribute__((__overloadable__, __always_inline__))
 
+// https://github.com/llvm/llvm-project/issues/45552
+// workaround for MS UCRT's 
+#if defined(_VCRUNTIME_H) && defined(_C_COMPLEX_T)

frederick-vs-ja wrote:

This doesn't seem to be a favorite approach for detecting whether MS UCRT's 
`` is used. But I'm not aware of any conventional way (the 
`_COMPLEX` guard looks possible).

Also, I've verified the changes with Clang 18 installed with VS 2022, but 
perhaps a test in the LLVM repo is desired.

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


[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/116785

>From 5f260726253e78a00d2dff02c22837ce02b49075 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Tue, 19 Nov 2024 11:55:11 +0100
Subject: [PATCH 1/5] [Clang] Consider preferred_type in bitfield warnings
 (#116760)

Very simply extends the bitfield sema checks for assignment to fields
with a preferred type specified to consider the preferred type if the
decl storage type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different
storage requirements we may not warn in all possible cases, but that's
a scenario for which the warnings are much more complex and confusing.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   9 +-
 clang/lib/Sema/SemaChecking.cpp   |  23 +-
 .../Sema/bitfield-preferred-type-sizing.c | 108 +
 .../bitfield-preferred-type-sizing.cpp| 413 ++
 4 files changed, 546 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Sema/bitfield-preferred-type-sizing.c
 create mode 100644 clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..254284e950c7e5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,18 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)
+  << ED;
+}
   }
 
   // Compute the required bitwidth. If the enum has negative values, we 
need
@@ -10530,9 +10541,13 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
   if (BitsNeeded > FieldWidth) {
 Expr *WidthExpr = Bitfield->getBitWidth();
 S.Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
-<< Bitfield << ED;
+<< Bitfield << Pref

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2025-01-04 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/116785

>From 5f260726253e78a00d2dff02c22837ce02b49075 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Tue, 19 Nov 2024 11:55:11 +0100
Subject: [PATCH 1/6] [Clang] Consider preferred_type in bitfield warnings
 (#116760)

Very simply extends the bitfield sema checks for assignment to fields
with a preferred type specified to consider the preferred type if the
decl storage type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different
storage requirements we may not warn in all possible cases, but that's
a scenario for which the warnings are much more complex and confusing.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   9 +-
 clang/lib/Sema/SemaChecking.cpp   |  23 +-
 .../Sema/bitfield-preferred-type-sizing.c | 108 +
 .../bitfield-preferred-type-sizing.cpp| 413 ++
 4 files changed, 546 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Sema/bitfield-preferred-type-sizing.c
 create mode 100644 clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..254284e950c7e5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,18 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)
+  << ED;
+}
   }
 
   // Compute the required bitwidth. If the enum has negative values, we 
need
@@ -10530,9 +10541,13 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
   if (BitsNeeded > FieldWidth) {
 Expr *WidthExpr = Bitfield->getBitWidth();
 S.Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
-<< Bitfield << ED;
+<< Bitfield << Pref

[clang] [clang] Add test for CWG170 "Pointer-to-member conversions" (PR #121667)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch adds test for 
[CWG170](https://cplusplus.github.io/CWG/issues/170.html). The resolution adds 
explicit undefined behavior, so I think the best we can do is to put the test 
into constexpr evaluator. Change to [expr.static.cast] is not tested, because 
it was a drive-by fix that removed an impossible case (I confirmed it using 
minutes). Minutes mention several times a comprehensive paper in this design 
space which no one seem to remember. I believe it's 
[P0149R0](https://wg21.link/p0149r0) "Generalised member pointers".

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


2 Files Affected:

- (modified) clang/test/CXX/drs/cwg1xx.cpp (+20) 
- (modified) clang/www/cxx_dr_status.html (+1-1) 


``diff
diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..0110c711d6dd89 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -1074,6 +1074,26 @@ namespace cwg169 { // cwg169: yes
   };
 }
 
+namespace cwg170 { // cwg170: 3.1
+#if __cplusplus >= 201103L
+struct A {};
+struct B : A { int i; };
+struct C : A {};
+struct D : C {};
+
+constexpr int f(int A::*) { return 0; }
+constexpr int g(int C::*) { return 0; }
+constexpr int h(int D::*) { return 0; }
+
+constexpr auto p = static_cast(&B::i);
+constexpr auto q = f(p);
+constexpr auto r = g(p);
+// since-cxx11-error@-1 {{constexpr variable 'r' must be initialized by a 
constant expression}}
+constexpr auto s = h(p);
+// since-cxx11-error@-1 {{constexpr variable 's' must be initialized by a 
constant expression}}
+#endif
+} // namespace cwg170
+
 namespace { // cwg171: 3.4
   int cwg171a;
 }
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..935411e778b251 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1065,7 +1065,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/170.html";>170
 DRWP
 Pointer-to-member conversions
-Unknown
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/171.html";>171

``




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


[clang] [clang] Add test for CWG170 "Pointer-to-member conversions" (PR #121667)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/121667

This patch adds test for 
[CWG170](https://cplusplus.github.io/CWG/issues/170.html). The resolution adds 
explicit undefined behavior, so I think the best we can do is to put the test 
into constexpr evaluator. Change to [expr.static.cast] is not tested, because 
it was a drive-by fix that removed an impossible case (I confirmed it using 
minutes). Minutes mention several times a comprehensive paper in this design 
space which no one seem to remember. I believe it's 
[P0149R0](https://wg21.link/p0149r0) "Generalised member pointers".

>From ec44a719b7b2dc2e9ac13e1d4d18e7d93337ca69 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 5 Jan 2025 00:08:34 +0300
Subject: [PATCH] [clang] Add test for CWG170 "Pointer-to-member conversions"

---
 clang/test/CXX/drs/cwg1xx.cpp | 20 
 clang/www/cxx_dr_status.html  |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..0110c711d6dd89 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -1074,6 +1074,26 @@ namespace cwg169 { // cwg169: yes
   };
 }
 
+namespace cwg170 { // cwg170: 3.1
+#if __cplusplus >= 201103L
+struct A {};
+struct B : A { int i; };
+struct C : A {};
+struct D : C {};
+
+constexpr int f(int A::*) { return 0; }
+constexpr int g(int C::*) { return 0; }
+constexpr int h(int D::*) { return 0; }
+
+constexpr auto p = static_cast(&B::i);
+constexpr auto q = f(p);
+constexpr auto r = g(p);
+// since-cxx11-error@-1 {{constexpr variable 'r' must be initialized by a 
constant expression}}
+constexpr auto s = h(p);
+// since-cxx11-error@-1 {{constexpr variable 's' must be initialized by a 
constant expression}}
+#endif
+} // namespace cwg170
+
 namespace { // cwg171: 3.4
   int cwg171a;
 }
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..935411e778b251 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1065,7 +1065,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/170.html";>170
 DRWP
 Pointer-to-member conversions
-Unknown
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/171.html";>171

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


[clang] [clang] Add test for CWG190 "Layout-compatible POD-struct types" (PR #121668)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch adds test for 
[CWG190](https://cplusplus.github.io/CWG/issues/190.html), leveraging 
`__is_layout_compatible` intrinsic added for C++20 `std::is_layout_compatible`. 
I conservatively set the status to Clang 19, as it's the first release that 
implemented said intrinsic.

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


2 Files Affected:

- (modified) clang/test/CXX/drs/cwg1xx.cpp (+19-2) 
- (modified) clang/www/cxx_dr_status.html (+1-1) 


``diff
diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..939de6dee06d38 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -1314,8 +1314,25 @@ namespace cwg188 { // cwg188: yes
   static_assert(sizeof(0, c) == 10, "");
 }
 
-// cwg190 FIXME: add codegen test for tbaa
-//  or implement C++20 std::is_layout_compatible and test it this 
way
+namespace cwg190 { // cwg190: 19
+struct A {
+  int a;
+  static double x;
+  int b;
+  void y();
+  int c;
+};
+
+struct B {
+  int a;
+  void y();
+  int b;
+  static double x;
+  int c;
+};
+
+static_assert(__is_layout_compatible(A, B), "");
+} // namespace cwg190
 
 int cwg191_j;
 namespace cwg191 { // cwg191: yes
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..ca216272147a5f 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1185,7 +1185,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/190.html";>190
 TC1
 Layout-compatible POD-struct types
-Unknown
+Clang 19
   
   
 https://cplusplus.github.io/CWG/issues/191.html";>191

``




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


[clang] [clang] Add test for CWG190 "Layout-compatible POD-struct types" (PR #121668)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/121668

This patch adds test for 
[CWG190](https://cplusplus.github.io/CWG/issues/190.html), leveraging 
`__is_layout_compatible` intrinsic added for C++20 `std::is_layout_compatible`. 
I conservatively set the status to Clang 19, as it's the first release that 
implemented said intrinsic.

>From 90eb2d7b1a6a7c96bde1e0e63b804ee070e15e90 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 5 Jan 2025 00:35:38 +0300
Subject: [PATCH] [clang] Add test for CWG190 "Layout-compatible POD-struct
 types"

---
 clang/test/CXX/drs/cwg1xx.cpp | 21 +++--
 clang/www/cxx_dr_status.html  |  2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..939de6dee06d38 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -1314,8 +1314,25 @@ namespace cwg188 { // cwg188: yes
   static_assert(sizeof(0, c) == 10, "");
 }
 
-// cwg190 FIXME: add codegen test for tbaa
-//  or implement C++20 std::is_layout_compatible and test it this 
way
+namespace cwg190 { // cwg190: 19
+struct A {
+  int a;
+  static double x;
+  int b;
+  void y();
+  int c;
+};
+
+struct B {
+  int a;
+  void y();
+  int b;
+  static double x;
+  int c;
+};
+
+static_assert(__is_layout_compatible(A, B), "");
+} // namespace cwg190
 
 int cwg191_j;
 namespace cwg191 { // cwg191: yes
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..ca216272147a5f 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1185,7 +1185,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/190.html";>190
 TC1
 Layout-compatible POD-struct types
-Unknown
+Clang 19
   
   
 https://cplusplus.github.io/CWG/issues/191.html";>191

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


[clang] [clang-format][NFC] Add missing config tests for List of Strings (PR #121451)

2025-01-04 Thread Owen Pan via cfe-commits

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


[clang] 66f16e6 - [clang-format][NFC] Add missing config tests for List of Strings (#121451)

2025-01-04 Thread via cfe-commits

Author: Owen Pan
Date: 2025-01-04T16:14:25-08:00
New Revision: 66f16e682f84551552099a45e608fa260b14e3ab

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

LOG: [clang-format][NFC] Add missing config tests for List of Strings (#121451)

Also, simplify the existing test for NamespaceMacros. Like the options
tested by the added tests, it's also a list of arbitrary strings and
initialized to an empty list. (The other existing tests for list of
strings either are initialized to a list of one or more strings or
require specific strings.)

Added: 


Modified: 
clang/unittests/Format/ConfigParseTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/ConfigParseTest.cpp 
b/clang/unittests/Format/ConfigParseTest.cpp
index 9c38dbbc51f0a1..1f0beafaad7f74 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -144,6 +144,9 @@ TEST(ConfigParseTest, GetsCorrectBasedOnStyle) {
   EXPECT_EQ(0, parseConfiguration(TEXT, &Style).value());  
\
   EXPECT_EQ(VALUE, Style.FIELD) << "Unexpected value after parsing!"
 
+#define CHECK_PARSE_LIST(FIELD)
\
+  CHECK_PARSE(#FIELD ": [foo]", FIELD, std::vector{"foo"})
+
 #define CHECK_PARSE_NESTED_VALUE(TEXT, STRUCT, FIELD, VALUE)   
\
   EXPECT_NE(VALUE, Style.STRUCT.FIELD) << "Initial value already the same!";   
\
   EXPECT_EQ(0, parseConfiguration(#STRUCT ":\n  " TEXT, &Style).value());  
\
@@ -906,11 +909,15 @@ TEST(ConfigParseTest, ParsesConfiguration) {
   CHECK_PARSE("StatementMacros: [QUNUSED, QT_REQUIRE_VERSION]", 
StatementMacros,
   std::vector({"QUNUSED", "QT_REQUIRE_VERSION"}));
 
-  Style.NamespaceMacros.clear();
-  CHECK_PARSE("NamespaceMacros: [TESTSUITE]", NamespaceMacros,
-  std::vector{"TESTSUITE"});
-  CHECK_PARSE("NamespaceMacros: [TESTSUITE, SUITE]", NamespaceMacros,
-  std::vector({"TESTSUITE", "SUITE"}));
+  CHECK_PARSE_LIST(JavaImportGroups);
+  CHECK_PARSE_LIST(Macros);
+  CHECK_PARSE_LIST(NamespaceMacros);
+  CHECK_PARSE_LIST(ObjCPropertyAttributeOrder);
+  CHECK_PARSE_LIST(TableGenBreakingDAGArgOperators);
+  CHECK_PARSE_LIST(TemplateNames);
+  CHECK_PARSE_LIST(TypeNames);
+  CHECK_PARSE_LIST(TypenameMacros);
+  CHECK_PARSE_LIST(VariableTemplates);
 
   Style.WhitespaceSensitiveMacros.clear();
   CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",



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


[clang] [clang-format][NFC] Replace SmallVectorImpl with ArrayRef (PR #121621)

2025-01-04 Thread Owen Pan via cfe-commits

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


[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-04 Thread Dale Kim via cfe-commits


@@ -68,15 +66,18 @@ void test_builtin_elementwise_add_sat(float f1, float f2, 
double d1, double d2,
   long long int i2, si8 vi1, si8 vi2,
   unsigned u1, unsigned u2, u4 vu1, u4 vu2,
   _BitInt(31) bi1, _BitInt(31) bi2,
-  unsigned _BitInt(55) bu1, unsigned 
_BitInt(55) bu2) {
+  unsigned _BitInt(55) bu1, unsigned 
_BitInt(55) bu2,
+  char c1, char c2, unsigned char uc1,
+  unsigned char uc2, short s1, short s2,
+  unsigned short us1, unsigned short us2) {
   // CHECK:  [[I1:%.+]] = load i64, ptr %i1.addr, align 8
   // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8
   // CHECK-NEXT: call i64 @llvm.sadd.sat.i64(i64 [[I1]], i64 [[I2]])
   i1 = __builtin_elementwise_add_sat(i1, i2);
 
   // CHECK:  [[I1:%.+]] = load i64, ptr %i1.addr, align 8
   // CHECK-NEXT: call i64 @llvm.sadd.sat.i64(i64 [[I1]], i64 10)
-  i1 = __builtin_elementwise_add_sat(i1, 10);
+  i1 = __builtin_elementwise_add_sat(i1, (long long int)10);

unpacklo wrote:

Maybe `INT64_C(10)` from the stdint.h header instead?

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


[clang] [Clang][Headers] Workaround for UCRT's `` in `` (PR #121650)

2025-01-04 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja edited 
https://github.com/llvm/llvm-project/pull/121650
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Amr Hesham (AmrDeveloper)


Changes

Add the `hasDependentName` matcher to match the name of 
`DependentScopeDeclRefExpr`

Example: `dependentScopeDeclRefExpr(hasDependentName("name"))`

Fixes: #121610

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


5 Files Affected:

- (modified) clang/docs/LibASTMatchersReference.html (+13) 
- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+11) 
- (modified) clang/lib/ASTMatchers/Dynamic/Registry.cpp (+1) 
- (modified) clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (+15) 


``diff
diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index fc557888013254..6a03aeb5eec2a1 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -3449,6 +3449,19 @@ Narrowing Matchers
 
 
 
+MatcherDependentScopeDeclRefExpr>hasDependentNamestd::string 
N
+Matches the 
dependent name of a dependent scope decl ref expr.
+
+Matches the dependent name of a dependent scope decl ref expr
+
+Given:
+
+  template CXXDependentScopeMemberExpr>memberHasSameNameAsBoundNodestd::string
 BindingID
 Matches template-dependent, but known, 
member names against an already-bound
 node
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5e75fc447636e0..4ef69ca4c743ed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1116,6 +1116,8 @@ AST Matchers
 
 - Add ``dependentTemplateSpecializationType`` matcher to match a dependent 
template specialization type.
 
+- Add ``hasDependentName`` matcher to match the dependent name of a dependent 
scope decl ref expr.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index dd0fedb2cda2d4..6828fc6da1d5cf 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3257,6 +3257,17 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, 
memberHasSameNameAsBoundNode,
   });
 }
 
+/// Matches the dependent name of a dependent scope decl ref expr
+///
+/// Given:
+/// \code
+///  template  class X : T { void f() { T::v; } };
+/// \endcode
+/// \c dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
+AST_MATCHER_P(DependentScopeDeclRefExpr, hasDependentName, std::string, N) {
+  return Node.getDeclName().getAsString() == N;
+}
+
 /// Matches C++ classes that are directly or indirectly derived from a class
 /// matching \c Base, or Objective-C classes that directly or indirectly
 /// subclass a class matching \c Base.
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 97e6bbc093fe46..336d3a14f79559 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -314,6 +314,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasDeducedType);
   REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDefinition);
+  REGISTER_MATCHER(hasDependentName);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDirectBase);
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 056b7c7b571ef4..4278e3d4fe5959 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2235,6 +2235,21 @@ TEST_P(ASTMatchersTest, 
ArgumentCountIs_CXXConstructExpr) {
  Constructor1Arg));
 }
 
+TEST_P(ASTMatchersTest, hasDependentName_DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Fix this test to work with delayed template parsing.
+return;
+  }
+
+  EXPECT_TRUE(matches("template  class X : T { void f() { T::v; } };",
+  dependentScopeDeclRefExpr(hasDependentName("v";
+
+  EXPECT_TRUE(
+  matches("template  struct S { static T Foo; };"
+  "template  void declToImport() { (void)S::Foo; }",
+  dependentScopeDeclRefExpr(hasDependentName("Foo";
+}
+
 TEST(ASTMatchersTest, NamesMember_CXXDependentScopeMemberExpr) {
 
   // Member functions:

``




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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/121656

Add the `hasDependentName` matcher to match the name of 
`DependentScopeDeclRefExpr`

Example: `dependentScopeDeclRefExpr(hasDependentName("name"))`

Fixes: #121610

>From 4cd48886384570e0e5bb0b712f4fd45f8decd27e Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 4 Jan 2025 17:36:05 +0100
Subject: [PATCH] [Clang][ASTMatcher] Add a matcher for the name of a
 DependentScopeDeclRefExpr

---
 clang/docs/LibASTMatchersReference.html   | 13 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 11 +++
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  | 15 +++
 5 files changed, 42 insertions(+)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index fc557888013254..6a03aeb5eec2a1 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -3449,6 +3449,19 @@ Narrowing Matchers
 
 
 
+MatcherDependentScopeDeclRefExpr>hasDependentNamestd::string 
N
+Matches the 
dependent name of a dependent scope decl ref expr.
+
+Matches the dependent name of a dependent scope decl ref expr
+
+Given:
+
+  template CXXDependentScopeMemberExpr>memberHasSameNameAsBoundNodestd::string
 BindingID
 Matches template-dependent, but known, 
member names against an already-bound
 node
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5e75fc447636e0..4ef69ca4c743ed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1116,6 +1116,8 @@ AST Matchers
 
 - Add ``dependentTemplateSpecializationType`` matcher to match a dependent 
template specialization type.
 
+- Add ``hasDependentName`` matcher to match the dependent name of a dependent 
scope decl ref expr.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index dd0fedb2cda2d4..6828fc6da1d5cf 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3257,6 +3257,17 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, 
memberHasSameNameAsBoundNode,
   });
 }
 
+/// Matches the dependent name of a dependent scope decl ref expr
+///
+/// Given:
+/// \code
+///  template  class X : T { void f() { T::v; } };
+/// \endcode
+/// \c dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
+AST_MATCHER_P(DependentScopeDeclRefExpr, hasDependentName, std::string, N) {
+  return Node.getDeclName().getAsString() == N;
+}
+
 /// Matches C++ classes that are directly or indirectly derived from a class
 /// matching \c Base, or Objective-C classes that directly or indirectly
 /// subclass a class matching \c Base.
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 97e6bbc093fe46..336d3a14f79559 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -314,6 +314,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasDeducedType);
   REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDefinition);
+  REGISTER_MATCHER(hasDependentName);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDirectBase);
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 056b7c7b571ef4..4278e3d4fe5959 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2235,6 +2235,21 @@ TEST_P(ASTMatchersTest, 
ArgumentCountIs_CXXConstructExpr) {
  Constructor1Arg));
 }
 
+TEST_P(ASTMatchersTest, hasDependentName_DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Fix this test to work with delayed template parsing.
+return;
+  }
+
+  EXPECT_TRUE(matches("template  class X : T { void f() { T::v; } };",
+  dependentScopeDeclRefExpr(hasDependentName("v";
+
+  EXPECT_TRUE(
+  matches("template  struct S { static T Foo; };"
+  "template  void declToImport() { (void)S::Foo; }",
+  dependentScopeDeclRefExpr(hasDependentName("Foo";
+}
+
 TEST(ASTMatchersTest, NamesMember_CXXDependentScopeMemberExpr) {
 
   // Member functions:

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

[clang] 7a76110 - [HLSL][SPIR-V] implement SV_GroupID semantic lowering (#121521)

2025-01-04 Thread via cfe-commits

Author: Zhengxing li
Date: 2025-01-04T14:02:39-08:00
New Revision: 7a761100960c0c9e2b2fa8a9ee233b137270bd73

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

LOG: [HLSL][SPIR-V] implement SV_GroupID semantic lowering (#121521)

The HLSL SV_GroupID semantic attribute is lowered into
@llvm.spv.group.id intrinsic in LLVM IR for SPIR-V target.

In the SPIR-V backend, this is now translated to a `WorkgroupId` builtin
variable.

Fixes #118700 which's a follow-up work to #70120

Added: 
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/SV_GroupID.ll

Modified: 
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGHLSLRuntime.h
clang/test/CodeGenHLSL/semantics/SV_GroupID.hlsl
llvm/include/llvm/IR/IntrinsicsSPIRV.td
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index c354e58e15f4bb..5679bd71581795 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -395,7 +395,7 @@ llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> 
&B,
 return buildVectorInput(B, GroupThreadIDIntrinsic, Ty);
   }
   if (D.hasAttr()) {
-llvm::Function *GroupIDIntrinsic = 
CGM.getIntrinsic(Intrinsic::dx_group_id);
+llvm::Function *GroupIDIntrinsic = CGM.getIntrinsic(getGroupIdIntrinsic());
 return buildVectorInput(B, GroupIDIntrinsic, Ty);
   }
   assert(false && "Unhandled parameter attribute");

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index edb87f9d5efdf9..3d5724118611cb 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -87,6 +87,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(Radians, radians)
   GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
   GENERATE_HLSL_INTRINSIC_FUNCTION(GroupThreadId, thread_id_in_group)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(GroupId, group_id)
   GENERATE_HLSL_INTRINSIC_FUNCTION(FDot, fdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)

diff  --git a/clang/test/CodeGenHLSL/semantics/SV_GroupID.hlsl 
b/clang/test/CodeGenHLSL/semantics/SV_GroupID.hlsl
index 5e09f0fe06d4e6..3aa054afc90451 100644
--- a/clang/test/CodeGenHLSL/semantics/SV_GroupID.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/SV_GroupID.hlsl
@@ -1,32 +1,36 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-DXIL -DTARGET=dx
+// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -x hlsl -emit-llvm 
-finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-SPIRV -DTARGET=spv
 
-// Make sure SV_GroupID translated into dx.group.id.
+// Make sure SV_GroupID translated into dx.group.id for directx target and 
spv.group.id for spirv target.
 
-// CHECK:  define void @foo()
-// CHECK:  %[[#ID:]] = call i32 @llvm.dx.group.id(i32 0)
-// CHECK:  call void @{{.*}}foo{{.*}}(i32 %[[#ID]])
+// CHECK:   define void @foo()
+// CHECK:   %[[#ID:]] = call i32 @llvm.[[TARGET]].group.id(i32 0)
+// CHECK-DXIL:   call void @{{.*}}foo{{.*}}(i32 %[[#ID]])
+// CHECK-SPIRV:  call spir_func void @{{.*}}foo{{.*}}(i32 %[[#ID]])
 [shader("compute")]
 [numthreads(8,8,1)]
 void foo(uint Idx : SV_GroupID) {}
 
-// CHECK:  define void @bar()
-// CHECK:  %[[#ID_X:]] = call i32 @llvm.dx.group.id(i32 0)
-// CHECK:  %[[#ID_X_:]] = insertelement <2 x i32> poison, i32 %[[#ID_X]], i64 0
-// CHECK:  %[[#ID_Y:]] = call i32 @llvm.dx.group.id(i32 1)
-// CHECK:  %[[#ID_XY:]] = insertelement <2 x i32> %[[#ID_X_]], i32 %[[#ID_Y]], 
i64 1
-// CHECK:  call void @{{.*}}bar{{.*}}(<2 x i32> %[[#ID_XY]])
+// CHECK:   define void @bar()
+// CHECK:   %[[#ID_X:]] = call i32 @llvm.[[TARGET]].group.id(i32 0)
+// CHECK:   %[[#ID_X_:]] = insertelement <2 x i32> poison, i32 %[[#ID_X]], 
i64 0
+// CHECK:   %[[#ID_Y:]] = call i32 @llvm.[[TARGET]].group.id(i32 1)
+// CHECK:   %[[#ID_XY:]] = insertelement <2 x i32> %[[#ID_X_]], i32 
%[[#ID_Y]], i64 1
+// CHECK-DXIL:  call void @{{.*}}bar{{.*}}(<2 x i32> %[[#ID_XY]])
+// CHECK-SPIRV:  call spir_func void @{{.*}}bar{{.*}}(<2 x i32> %[[#ID_XY]])
 [shader("compute")]
 [numthreads(8,8,1)]
 void bar(uint2 Idx : SV_GroupID) {}
 
 // CHECK:  define void @test()
-// CHECK:  %[[#ID_X:]] = call i32 @llvm.dx.group.id(i32 0)
+// CHECK:  %[[#ID_X:]] = call i32 @llvm.[[TARGET]].group.id(i32 0)
 // CHECK:  %[[#ID_X_:]] = insertelement <3 x i32> poison, i32 %[[#ID_X]], i64 0
-// CHECK:  %[

[clang] [llvm] [HLSL][SPIR-V] implement SV_GroupID semantic lowering (PR #121521)

2025-01-04 Thread Zhengxing li via cfe-commits

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


[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

2025-01-04 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/117428

>From 3e25d7ef2e223942298078dace8979905956d05c Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Fri, 22 Nov 2024 17:53:24 +0100
Subject: [PATCH 1/7] Add an off-by-default warning to complain about MSVC
 bitfield padding

---
 clang/include/clang/Basic/DiagnosticGroups.td |   1 +
 .../clang/Basic/DiagnosticSemaKinds.td|   6 +
 clang/lib/Sema/SemaDecl.cpp   |  27 ++-
 .../SemaCXX/ms_struct-bitfield-padding.cpp| 180 ++
 4 files changed, 212 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaCXX/ms_struct-bitfield-padding.cpp

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..57bdda4b8f8b47 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -631,6 +631,7 @@ def Packed : DiagGroup<"packed", [PackedNonPod]>;
 def PaddedBitField : DiagGroup<"padded-bitfield">;
 def Padded : DiagGroup<"padded", [PaddedBitField]>;
 def UnalignedAccess : DiagGroup<"unaligned-access">;
+def MSBitfieldCompatibility : DiagGroup<"ms-bitfield-packing-compatibility">;
 
 def PessimizingMove : DiagGroup<"pessimizing-move">;
 def ReturnStdMove : DiagGroup<"return-std-move">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index eb05a6a77978af..aa13e3438d3739 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6418,6 +6418,12 @@ def warn_signed_bitfield_enum_conversion : Warning<
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def warn_ms_bitfield_mismatched_storage_packing : Warning<
+  "bit-field %0 of type %1 has a different storage size (%2 vs %3 bytes) than 
the "
+  "preceding bit-field and may not be packed under MSVC ABI">,
+  InGroup, DefaultIgnore;
+def note_ms_bitfield_mismatched_storage_size_previous : Note<
+  "preceding bit-field %0 declared here with type %1">;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 74b0e5ad23bd48..18aeca3b34f659 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -19001,9 +19001,9 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, 
Decl *EnclosingDecl,
 
   // Verify that all the fields are okay.
   SmallVector RecFields;
-
+  std::optional PreviousField;
   for (ArrayRef::iterator i = Fields.begin(), end = Fields.end();
-   i != end; ++i) {
+   i != end; PreviousField = cast(*i), ++i) {
 FieldDecl *FD = cast(*i);
 
 // Get the type for the field.
@@ -19213,6 +19213,29 @@ void Sema::ActOnFields(Scope *S, SourceLocation 
RecLoc, Decl *EnclosingDecl,
 
 if (Record && FD->getType().isVolatileQualified())
   Record->setHasVolatileMember(true);
+auto IsNonDependentBitField = [](const FieldDecl *FD) {
+  if (!FD->isBitField())
+return false;
+  if (FD->getType()->isDependentType())
+return false;
+  return true;
+};
+
+if (Record && PreviousField && IsNonDependentBitField(FD) &&
+IsNonDependentBitField(*PreviousField)) {
+  unsigned FDStorageSize =
+  Context.getTypeSizeInChars(FD->getType()).getQuantity();
+  unsigned PreviousFieldStorageSize =
+  
Context.getTypeSizeInChars((*PreviousField)->getType()).getQuantity();
+  if (FDStorageSize != PreviousFieldStorageSize) {
+Diag(FD->getLocation(),
+ diag::warn_ms_bitfield_mismatched_storage_packing)
+<< FD << FD->getType() << FDStorageSize << 
PreviousFieldStorageSize;
+Diag((*PreviousField)->getLocation(),
+ diag::note_ms_bitfield_mismatched_storage_size_previous)
+<< *PreviousField << (*PreviousField)->getType();
+  }
+}
 // Keep track of the number of named members.
 if (FD->getIdentifier())
   ++NumNamedMembers;
diff --git a/clang/test/SemaCXX/ms_struct-bitfield-padding.cpp 
b/clang/test/SemaCXX/ms_struct-bitfield-padding.cpp
new file mode 100644
index 00..001086de5bbd10
--- /dev/null
+++ b/clang/test/SemaCXX/ms_struct-bitfield-padding.cpp
@@ -0,0 +1,180 @@
+
+// RUN: %clang_cc1 -fsyntax-only -Wms-bitfield-packing-compatibility -verify 
-triple armv8 -std=c++23 %s
+// RUN: %clang_cc1 -fsyntax-only -DMS_BITFIELDS -mms-bitfields 
-verify=msbitfields -triple armv8-apple-macos10.15 -std=c++23 %s
+
+// msbitfields-no-diagnostics
+
+enum Enum1 { Enum1_A, Enum1_B };
+enum Enum2 { Enum2_A, Enum2_B };
+
+enum class EnumU32_1 : unsigned { A, B };
+enum class EnumU32_2 : unsigned { A, B };
+enum class EnumU64 : unsigned long long { A, B };
+enum class EnumI32 : int { A, B };
+enum class EnumU8 : unsigned char { A, B };

[clang] [Clang] Add GCC's __builtin_stack_address() to Clang. (PR #121332)

2025-01-04 Thread via cfe-commits

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


[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2025-01-04 Thread Chris Cotter via cfe-commits

https://github.com/ccotter updated 
https://github.com/llvm/llvm-project/pull/114244

>From fd914cc82688b122654d2d7ada72007541b197c0 Mon Sep 17 00:00:00 2001
From: Chris Cotter 
Date: Wed, 30 Oct 2024 10:54:49 -0400
Subject: [PATCH 1/6] Add bugprone-sprintf-overlap

---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  1 +
 .../bugprone/UndefinedSprintfOverlapCheck.cpp | 93 +++
 .../bugprone/UndefinedSprintfOverlapCheck.h   | 36 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 ++
 .../bugprone/undefined-sprintf-overlap.rst| 23 +
 .../docs/clang-tidy/checks/list.rst   |  3 +-
 .../bugprone/undefined-sprintf-overlap.cpp| 59 
 8 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/undefined-sprintf-overlap.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/undefined-sprintf-overlap.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 33ac65e715ce81..ac3a08c80d7ae6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -86,6 +86,7 @@
 #include "TooSmallLoopVariableCheck.h"
 #include "UncheckedOptionalAccessCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
+#include "UndefinedSprintfOverlapCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnhandledExceptionAtNewCheck.h"
 #include "UnhandledSelfAssignmentCheck.h"
@@ -248,6 +249,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-unchecked-optional-access");
 CheckFactories.registerCheck(
 "bugprone-undefined-memory-manipulation");
+CheckFactories.registerCheck(
+"bugprone-undefined-sprintf-overlap");
 CheckFactories.registerCheck(
 "bugprone-undelegated-constructor");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index b0a2318acc0597..2403ed665fd5c7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -81,6 +81,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   TooSmallLoopVariableCheck.cpp
   UncheckedOptionalAccessCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
+  UndefinedSprintfOverlapCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnhandledExceptionAtNewCheck.cpp
   UnhandledSelfAssignmentCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp
new file mode 100644
index 00..301b6bce0dbbad
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp
@@ -0,0 +1,93 @@
+//===--- UndefinedSprintfOverlapCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UndefinedSprintfOverlapCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+AST_MATCHER_P(CallExpr, hasAnyOtherArgument,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  for (const auto *Arg : llvm::drop_begin(Node.arguments())) {
+ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
+  *Builder = std::move(Result);
+  return true;
+}
+  }
+  return false;
+}
+
+AST_MATCHER_P(IntegerLiteral, hasSameValueAs, std::string, ID) {
+  return Builder->removeBindings(
+  [this, &Node](const ast_matchers::internal::BoundNodesMap &Nodes) {
+const auto &BN = Nodes.getNode(ID);
+if (const auto *Lit = BN.get()) {
+  return Lit->getValue() != Node.getValue();
+}
+return true;
+  });
+}
+
+UndefinedSprintfOverlapCheck::UndefinedSprintfOverlapCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SprintfRegex(Options.get("SprintfFunction", "(::std)?::(sn?printf)")) {}
+
+void UndefinedSprintfOverlapCheck::registerMatchers(MatchFinder *Finder) {
+  auto FirstArg = declRefExpr(to(varDecl().bind("firstArg")));
+  auto OtherRefToArg = declRefExpr(to(varDecl(equalsBoundNode("firstArg"
+   .bind("overlappingArg");
+  Finder->addM

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2025-01-04 Thread Chris Cotter via cfe-commits

https://github.com/ccotter updated 
https://github.com/llvm/llvm-project/pull/114244

>From fd914cc82688b122654d2d7ada72007541b197c0 Mon Sep 17 00:00:00 2001
From: Chris Cotter 
Date: Wed, 30 Oct 2024 10:54:49 -0400
Subject: [PATCH 1/8] Add bugprone-sprintf-overlap

---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  1 +
 .../bugprone/UndefinedSprintfOverlapCheck.cpp | 93 +++
 .../bugprone/UndefinedSprintfOverlapCheck.h   | 36 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 ++
 .../bugprone/undefined-sprintf-overlap.rst| 23 +
 .../docs/clang-tidy/checks/list.rst   |  3 +-
 .../bugprone/undefined-sprintf-overlap.cpp| 59 
 8 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/undefined-sprintf-overlap.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/undefined-sprintf-overlap.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 33ac65e715ce81..ac3a08c80d7ae6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -86,6 +86,7 @@
 #include "TooSmallLoopVariableCheck.h"
 #include "UncheckedOptionalAccessCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
+#include "UndefinedSprintfOverlapCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnhandledExceptionAtNewCheck.h"
 #include "UnhandledSelfAssignmentCheck.h"
@@ -248,6 +249,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-unchecked-optional-access");
 CheckFactories.registerCheck(
 "bugprone-undefined-memory-manipulation");
+CheckFactories.registerCheck(
+"bugprone-undefined-sprintf-overlap");
 CheckFactories.registerCheck(
 "bugprone-undelegated-constructor");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index b0a2318acc0597..2403ed665fd5c7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -81,6 +81,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   TooSmallLoopVariableCheck.cpp
   UncheckedOptionalAccessCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
+  UndefinedSprintfOverlapCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnhandledExceptionAtNewCheck.cpp
   UnhandledSelfAssignmentCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp
new file mode 100644
index 00..301b6bce0dbbad
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/UndefinedSprintfOverlapCheck.cpp
@@ -0,0 +1,93 @@
+//===--- UndefinedSprintfOverlapCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UndefinedSprintfOverlapCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+AST_MATCHER_P(CallExpr, hasAnyOtherArgument,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  for (const auto *Arg : llvm::drop_begin(Node.arguments())) {
+ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
+if (InnerMatcher.matches(*Arg, Finder, &Result)) {
+  *Builder = std::move(Result);
+  return true;
+}
+  }
+  return false;
+}
+
+AST_MATCHER_P(IntegerLiteral, hasSameValueAs, std::string, ID) {
+  return Builder->removeBindings(
+  [this, &Node](const ast_matchers::internal::BoundNodesMap &Nodes) {
+const auto &BN = Nodes.getNode(ID);
+if (const auto *Lit = BN.get()) {
+  return Lit->getValue() != Node.getValue();
+}
+return true;
+  });
+}
+
+UndefinedSprintfOverlapCheck::UndefinedSprintfOverlapCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SprintfRegex(Options.get("SprintfFunction", "(::std)?::(sn?printf)")) {}
+
+void UndefinedSprintfOverlapCheck::registerMatchers(MatchFinder *Finder) {
+  auto FirstArg = declRefExpr(to(varDecl().bind("firstArg")));
+  auto OtherRefToArg = declRefExpr(to(varDecl(equalsBoundNode("firstArg"
+   .bind("overlappingArg");
+  Finder->addM

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-04 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Thanks so much for the review! I'll keep an eye on that PR, and there’s some 
post-work to do: 1. Cleanup 2. Adaptation for lambdas

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


[clang] 96eced6 - [Clang] Implement CWG2369 "Ordering between constraints and substitution" (#102857)

2025-01-04 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-01-05T10:50:52+08:00
New Revision: 96eced624e0f120155256033fdcb8342e7e58d6e

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

LOG: [Clang] Implement CWG2369 "Ordering between constraints and substitution" 
(#102857)

This patch partially implements CWG2369 for non-lambda-constrained
functions.

Lambdas are left intact at this point because we need extra work to
correctly instantiate captures before the function instantiation.

As a premise of CWG2369, this patch also implements CWG2770 to ensure
the function parameters are instantiated on demand.

Closes https://github.com/llvm/llvm-project/issues/54440

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateDeductionGuide.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/drs/cwg23xx.cpp
clang/test/CXX/drs/cwg26xx.cpp
clang/test/CXX/drs/cwg27xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp

clang/test/CXX/temp/temp.constr/temp.constr.atomic/constrant-satisfaction-conversions.cpp
clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
clang/test/SemaCXX/cxx20-ctad-type-alias.cpp
clang/test/SemaCXX/cxx23-assume.cpp
clang/test/SemaCXX/cxx2c-fold-exprs.cpp
clang/test/SemaCXX/lambda-unevaluated.cpp
clang/test/SemaTemplate/concepts-recursive-inst.cpp
clang/test/SemaTemplate/cxx2a-constraint-exprs.cpp
clang/test/SemaTemplate/deduction-guide.cpp
clang/test/SemaTemplate/nested-implicit-deduction-guides.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ee7ea48cc983c..af59b7f38c71aa 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13055,6 +13055,7 @@ class Sema final : public SemaBase {
   ///
   /// \param SkipForSpecialization when specified, any template specializations
   /// in a traversal would be ignored.
+  ///
   /// \param ForDefaultArgumentSubstitution indicates we should continue 
looking
   /// when encountering a specialized member function template, rather than
   /// returning immediately.
@@ -13066,6 +13067,17 @@ class Sema final : public SemaBase {
   bool SkipForSpecialization = false,
   bool ForDefaultArgumentSubstitution = false);
 
+  /// Apart from storing the result to \p Result, this behaves the same as
+  /// another overload.
+  void getTemplateInstantiationArgs(
+  MultiLevelTemplateArgumentList &Result, const NamedDecl *D,
+  const DeclContext *DC = nullptr, bool Final = false,
+  std::optional> Innermost = std::nullopt,
+  bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
+  bool ForConstraintInstantiation = false,
+  bool SkipForSpecialization = false,
+  bool ForDefaultArgumentSubstitution = false);
+
   /// RAII object to handle the state changes required to synthesize
   /// a function body.
   class SynthesizedFunctionScope {
@@ -13335,7 +13347,7 @@ class Sema final : public SemaBase {
   ExprResult
   SubstConstraintExpr(Expr *E,
   const MultiLevelTemplateArgumentList &TemplateArgs);
-  // Unlike the above, this does not evaluates constraints.
+  // Unlike the above, this does not evaluate constraints.
   ExprResult SubstConstraintExprWithoutSatisfaction(
   Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
 
@@ -14456,10 +14468,10 @@ class Sema final : public SemaBase {
   const MultiLevelTemplateArgumentList &TemplateArgs,
   SourceRange TemplateIDRange);
 
-  bool CheckInstantiatedFunctionTemplateConstraints(
-  SourceLocation PointOfInstantiation, FunctionDecl *Decl,
-  ArrayRef TemplateArgs,
-  ConstraintSatisfaction &Satisfaction);
+  bool CheckFunctionTemplateConstraints(SourceLocation PointOfInstantiation,
+FunctionDecl *Decl,
+ArrayRef 
TemplateArgs,
+ConstraintSatisfaction &Satisfaction);
 
   /// \brief Emit diagnostics explaining why a constraint expression was deemed
   /// unsatisfied.

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 9800f75f676aaf..59a0575ca98036 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -522,6 +522,12 @@ enum class TemplateSubstitutionKind : char {
 llvm::PointerUnion *
 findInstantiationOf(const Decl *D);
 
+/// Similar to \p findInstantiationOf(), but it wouldn't assert if the
+/// instantiation was

[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2025-01-04 Thread Chris Cotter via cfe-commits

ccotter wrote:

> 1. How common is this bug?

In one of our internal codebases, a sample of about 1500 files found just over 
2% of the files had this bug. As we migrated platforms/standard libraries, the 
behavior which was previously correct (by chance) changed to be incorrect.

> 2. What happens in practice at runtime?

In practice, the formatted string can be incorrect (but no crash etc). One 
example is https://godbolt.org/z/3GdnPrsYj

```
char buf[10];
sprintf(buf, "%s", "12");
sprintf(buf, "%s%s", "34", buf);
printf("/%s/\n", buf); // 3434
```

> 3. What are existing ways of detecting this, if any?

None to my knowledge. After finding a couple occurrences of this bug 
internally, I realized clang-query/clang-tidy could easily catch this.

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


[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-04 Thread Younan Zhang via cfe-commits

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


[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2025-01-04 Thread Chris Cotter via cfe-commits


@@ -0,0 +1,23 @@
+.. title:: clang-tidy - bugprone-undefined-sprintf-overlap
+
+bugprone-undefined-sprintf-overlap

ccotter wrote:

I like this better. I'll change this.

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


[clang-tools-extra] Add bugprone-undefined-sprintf-overlap (PR #114244)

2025-01-04 Thread Chris Cotter via cfe-commits

ccotter wrote:

Thanks both @nicovank @5chmidti for the overlapping reviews. I got sidetracked, 
but am coming back to hopefully finish this up.

Re: supporting more use cases, I found nearly all bugs in our codebase were of 
the simple form `sprintf(a, "", ..., a, ...)` with a simple DeclRefExpr. None 
were of the form `sprintf(a[0][0], "", ..., a[0][0], ...)` (at least, none that 
I couple find with a more naive `grep` and visual inspection), or anything else 
suggested above. And, since matching on other expressions more generically like 
more deeply nested arrays or `(buf+10)` led to more complex matchers, I opted 
for the simpler cases my check can find in its current form.

Let me look at `utils::areStatementsIdentical` to see if this could help expand 
the forms that the tool can find.

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


[clang] 04610b9 - [clang-format][NFC] Replace SmallVectorImpl with ArrayRef (#121621)

2025-01-04 Thread via cfe-commits

Author: Owen Pan
Date: 2025-01-04T16:19:46-08:00
New Revision: 04610b901f41c4abec169b9a38f1b0a2fde976c1

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

LOG: [clang-format][NFC] Replace SmallVectorImpl with ArrayRef (#121621)

Added: 


Modified: 
clang/lib/Format/AffectedRangeManager.cpp
clang/lib/Format/AffectedRangeManager.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h

Removed: 




diff  --git a/clang/lib/Format/AffectedRangeManager.cpp 
b/clang/lib/Format/AffectedRangeManager.cpp
index bf124d73e89e71..67108f35401915 100644
--- a/clang/lib/Format/AffectedRangeManager.cpp
+++ b/clang/lib/Format/AffectedRangeManager.cpp
@@ -21,8 +21,8 @@ namespace format {
 
 bool AffectedRangeManager::computeAffectedLines(
 SmallVectorImpl &Lines) {
-  SmallVectorImpl::iterator I = Lines.begin();
-  SmallVectorImpl::iterator E = Lines.end();
+  ArrayRef::iterator I = Lines.begin();
+  ArrayRef::iterator E = Lines.end();
   bool SomeLineAffected = false;
   const AnnotatedLine *PreviousLine = nullptr;
   while (I != E) {
@@ -34,7 +34,7 @@ bool AffectedRangeManager::computeAffectedLines(
 // if any token within the directive is affected.
 if (Line->InPPDirective) {
   FormatToken *Last = Line->Last;
-  SmallVectorImpl::iterator PPEnd = I + 1;
+  const auto *PPEnd = I + 1;
   while (PPEnd != E && !(*PPEnd)->First->HasUnescapedNewline) {
 Last = (*PPEnd)->Last;
 ++PPEnd;
@@ -89,8 +89,8 @@ bool AffectedRangeManager::affectsLeadingEmptyLines(const 
FormatToken &Tok) {
 }
 
 void AffectedRangeManager::markAllAsAffected(
-SmallVectorImpl::iterator I,
-SmallVectorImpl::iterator E) {
+ArrayRef::iterator I,
+ArrayRef::iterator E) {
   while (I != E) {
 (*I)->Affected = true;
 markAllAsAffected((*I)->Children.begin(), (*I)->Children.end());

diff  --git a/clang/lib/Format/AffectedRangeManager.h 
b/clang/lib/Format/AffectedRangeManager.h
index add16bdd7a7c3d..eef056fdf06338 100644
--- a/clang/lib/Format/AffectedRangeManager.h
+++ b/clang/lib/Format/AffectedRangeManager.h
@@ -47,8 +47,8 @@ class AffectedRangeManager {
   bool affectsLeadingEmptyLines(const FormatToken &Tok);
 
   // Marks all lines between I and E as well as all their children as affected.
-  void markAllAsAffected(SmallVectorImpl::iterator I,
- SmallVectorImpl::iterator E);
+  void markAllAsAffected(ArrayRef::iterator I,
+ ArrayRef::iterator E);
 
   // Determines whether 'Line' is affected by the SourceRanges given as input.
   // Returns \c true if line or one if its children is affected.

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index e51d7ac2e5b6c4..fc60c5ec5eebc1 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3085,8 +3085,8 @@ static bool affectsRange(ArrayRef Ranges, 
unsigned Start,
 // its current line.
 // If `Cursor` is not on any #include, `Index` will be UINT_MAX.
 static std::pair
-FindCursorIndex(const SmallVectorImpl &Includes,
-const SmallVectorImpl &Indices, unsigned Cursor) {
+FindCursorIndex(const ArrayRef &Includes,
+const ArrayRef &Indices, unsigned Cursor) {
   unsigned CursorIndex = UINT_MAX;
   unsigned OffsetToEOL = 0;
   for (int i = 0, e = Includes.size(); i != e; ++i) {
@@ -3135,7 +3135,7 @@ std::string replaceCRLF(const std::string &Code) {
 // provided and put on a deleted #include, it will be moved to the remaining
 // #include in the duplicate #includes.
 static void sortCppIncludes(const FormatStyle &Style,
-const SmallVectorImpl &Includes,
+const ArrayRef &Includes,
 ArrayRef Ranges, StringRef 
FileName,
 StringRef Code, tooling::Replacements &Replaces,
 unsigned *Cursor) {
@@ -3378,7 +3378,7 @@ static unsigned findJavaImportGroup(const FormatStyle 
&Style,
 // import group, a newline is inserted, and within each import group, a
 // lexicographic sort based on ASCII value is performed.
 static void sortJavaImports(const FormatStyle &Style,
-const SmallVectorImpl 
&Imports,
+const ArrayRef &Imports,
 ArrayRef Ranges, StringRef 
FileName,
 StringRef Code, tooling::Replacements &Replaces) {
   unsigned ImportsBeginOffset = Imports.front().Offset;

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 0f8d4940d4369a..a1d7eeadec4416 100644
---

[clang] 44b83e8 - [clang-format] Add TT_AfterPPDirective for better annotation (#121622)

2025-01-04 Thread via cfe-commits

Author: Owen Pan
Date: 2025-01-04T16:22:54-08:00
New Revision: 44b83e81b5a48d543bf718907f00a21179ec03a4

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

LOG: [clang-format] Add TT_AfterPPDirective for better annotation (#121622)

For now, we only need to annotate the token after #error or #warning.

Fixes #117706.

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 8917049cefb865..0fd3a49c71f9d1 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -25,6 +25,7 @@ namespace clang {
 namespace format {
 
 #define LIST_TOKEN_TYPES   
\
+  TYPE(AfterPPDirective)   
\
   TYPE(ArrayInitializerLSquare)
\
   TYPE(ArraySubscriptLSquare)  
\
   TYPE(AttributeColon) 
\

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index b0f570966a63f3..fad375733ef845 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4941,6 +4941,10 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 Right.is(TT_ModulePartitionColon)) {
   return true;
 }
+
+if (Right.is(TT_AfterPPDirective))
+  return true;
+
 // No space between import foo:bar but keep a space between import :bar;
 if (Left.is(tok::identifier) && Right.is(TT_ModulePartitionColon))
   return false;

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 5375eef90c579e..46fd566ae221ee 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1030,6 +1030,12 @@ void UnwrappedLineParser::parsePPDirective() {
   case tok::pp_pragma:
 parsePPPragma();
 break;
+  case tok::pp_error:
+  case tok::pp_warning:
+nextToken();
+if (!eof() && Style.isCpp())
+  FormatTok->setFinalizedType(TT_AfterPPDirective);
+[[fallthrough]];
   default:
 parsePPUnknown();
 break;
@@ -1209,9 +1215,8 @@ void UnwrappedLineParser::parsePPPragma() {
 }
 
 void UnwrappedLineParser::parsePPUnknown() {
-  do {
+  while (!eof())
 nextToken();
-  } while (!eof());
   if (Style.IndentPPDirectives != FormatStyle::PPDIS_None)
 Line->Level += PPBranchLevel + 1;
   addUnwrappedLine();

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index d61b9adf4f58c6..875feff3d54202 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3635,6 +3635,13 @@ TEST_F(TokenAnnotatorTest, SwitchInMacroArgument) {
   EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_FunctionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, AfterPPDirective) {
+  auto Tokens = annotate("#error -- My error message");
+
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::minusminus, TT_AfterPPDirective);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang



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


[clang] [clang] Add test for CWG190 "Layout-compatible POD-struct types" (PR #121668)

2025-01-04 Thread via cfe-commits

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

saying clang 19 is very weird as this probably  always worked, but lgtm 
otherwise

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


[clang] c1ea05e - [clang-format] Don't break short macro call followed by l_paren (#121626)

2025-01-04 Thread via cfe-commits

Author: Owen Pan
Date: 2025-01-04T16:24:41-08:00
New Revision: c1ea05eaf0fbe4b539952689dbf9f0df716c72e7

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

LOG: [clang-format] Don't break short macro call followed by l_paren (#121626)

Fixes #105658.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 46fd566ae221ee..39aa37af480c9f 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2044,7 +2044,9 @@ void UnwrappedLineParser::parseStructuralElement(
 ? FormatTok->NewlinesBefore > 0
 : CommentsBeforeNextToken.front()->NewlinesBefore > 0;
 
-if (FollowedByNewline && (Text.size() >= 5 || FunctionLike) &&
+if (FollowedByNewline &&
+(Text.size() >= 5 ||
+ (FunctionLike && FormatTok->isNot(tok::l_paren))) &&
 tokenCanStartNewLine(*FormatTok) && Text == Text.upper()) {
   if (PreviousToken->isNot(TT_UntouchableMacroFunc))
 
PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestandingMacro);

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 44b9dba2498900..4d48bcacddead8 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5887,6 +5887,11 @@ TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {
   verifyFormat("SOME_WEIRD_LOG_MACRO << SomeThing;", "SOME_WEIRD_LOG_MACRO\n"
  "<< SomeThing;");
 
+  verifyFormat("(()->)(foo);",
+   "(()->)\n"
+   "(foo);",
+   getLLVMStyleWithColumns(60));
+
   verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), "
"(n, buffers))",
getChromiumStyle(FormatStyle::LK_Cpp));



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


[clang] [clang-format] Don't break short macro call followed by l_paren (PR #121626)

2025-01-04 Thread Owen Pan via cfe-commits

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


[clang] [clang-format] Add TT_AfterPPDirective for better annotation (PR #121622)

2025-01-04 Thread Owen Pan via cfe-commits

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2025-01-04 Thread via cfe-commits

goldsteinn wrote:

ping @ideasman42  or @lukel97 

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


[clang] [clang-format] Add `TT_CompoundRequirementLBrace` for better annotation (PR #121539)

2025-01-04 Thread Emilia Kond via cfe-commits

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

#121675

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


[clang] Bulk port 64-bit x86 builtins to TableGen (PR #121043)

2025-01-04 Thread Chandler Carruth via cfe-commits

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


[clang] a774adb - Bulk port 64-bit x86 builtins to TableGen (#121043)

2025-01-04 Thread via cfe-commits

Author: Chandler Carruth
Date: 2025-01-04T17:52:19-08:00
New Revision: a774adb017256ceae85ec92ce5148ed47e517540

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

LOG: Bulk port 64-bit x86 builtins to TableGen (#121043)

This PR follows https://github.com/llvm/llvm-project/pull/120831 for
x86-64.

Similar to that PR, this does a very mechanical port of X86 builtins to
TableGen. There is a *lot* of improvement available here to use TableGen
more effectively and collapse repeated structures. But those can now be
follow-up PRs that restructure *within* the `.td` file.

The current structure produces a file that exactly matches the original
X-macros except for the differences outlined in
https://github.com/llvm/llvm-project/pull/120831:

- Horizontal whitespace
- `long long` types now use `long long` outside of OpenCL, but switch to
  `long` in OpenCL where relevant.

Otherwise, only the order of builtins change, and no tests regress.

Added: 
clang/include/clang/Basic/BuiltinsX86Base.td
clang/include/clang/Basic/BuiltinsX86_64.td

Modified: 
clang/include/clang/Basic/BuiltinsX86.td
clang/include/clang/Basic/CMakeLists.txt
clang/include/clang/Basic/TargetBuiltins.h
clang/lib/Basic/Targets/X86.cpp

Removed: 
clang/include/clang/Basic/BuiltinsX86_64.def



diff  --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index 73678bc868bfda..18fc10eb85c027 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -10,23 +10,7 @@
 //
 
//===--===//
 
-include "clang/Basic/BuiltinsBase.td"
-
-class X86Builtin : TargetBuiltin {
-  let Spellings = ["__builtin_ia32_" # NAME];
-  let Prototype = prototype;
-  let EnableOpenCLLong = 1;
-}
-
-class X86NoPrefixBuiltin : TargetBuiltin {
-  let Spellings = [NAME];
-  let Prototype = prototype;
-}
-
-class X86LibBuiltin : TargetLibBuiltin {
-  let Spellings = [NAME];
-  let Prototype = prototype;
-}
+include "clang/Basic/BuiltinsX86Base.td"
 
 def rdpmc : X86Builtin<"unsigned long long int(int)">;
 def rdtsc : X86Builtin<"unsigned long long int()">;

diff  --git a/clang/include/clang/Basic/BuiltinsX86Base.td 
b/clang/include/clang/Basic/BuiltinsX86Base.td
new file mode 100644
index 00..aca39c204516ae
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsX86Base.td
@@ -0,0 +1,29 @@
+//===--- BuiltinsX86Base.td - X86 Builtin function classes --*- 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
+//
+//===--===//
+//
+// This file defines the X86-specific builtin function classes.
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class X86Builtin : TargetBuiltin {
+  let Spellings = ["__builtin_ia32_" # NAME];
+  let Prototype = prototype;
+  let EnableOpenCLLong = 1;
+}
+
+class X86NoPrefixBuiltin : TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+}
+
+class X86LibBuiltin : TargetLibBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+}

diff  --git a/clang/include/clang/Basic/BuiltinsX86_64.def 
b/clang/include/clang/Basic/BuiltinsX86_64.def
deleted file mode 100644
index 57928a14b3b399..00
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ /dev/null
@@ -1,253 +0,0 @@
-//===--- BuiltinsX86_64.def - X86-64 Builtin function database --*- 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
-//
-//===--===//
-//
-// This file defines the X86-64-specific builtin function database. Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
-#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
-#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", INTRIN_H, 
ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_BitScanReverse64, "UcUNi*ULLi", "nh", 

[clang] Bulk port 64-bit x86 builtins to TableGen (PR #121043)

2025-01-04 Thread Chandler Carruth via cfe-commits

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits


@@ -3449,6 +3449,19 @@ Narrowing Matchers
 
 
 
+MatcherDependentScopeDeclRefExpr>hasDependentNamestd::string 
N
+Matches the 
dependent name of a dependent scope decl ref expr.

HighCommander4 wrote:

nit: "of a DependentScopeDeclRefExpr" would read better to me

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits


@@ -1116,6 +1116,8 @@ AST Matchers
 
 - Add ``dependentTemplateSpecializationType`` matcher to match a dependent 
template specialization type.
 
+- Add ``hasDependentName`` matcher to match the dependent name of a dependent 
scope decl ref expr.

HighCommander4 wrote:

likewise here, "of a DependentScopeDeclRefExpr"

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits


@@ -2235,6 +2235,21 @@ TEST_P(ASTMatchersTest, 
ArgumentCountIs_CXXConstructExpr) {
  Constructor1Arg));
 }
 
+TEST_P(ASTMatchersTest, hasDependentName_DependentScopeDeclRefExpr) {

HighCommander4 wrote:

nit: looking at other tests in this file, the test names start with a capital 
letter (e.g. `HasSize_CXX`) even if the matcher they are testing starts with 
lowercase (e.g. `hasSize`)

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits


@@ -3257,6 +3257,17 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, 
memberHasSameNameAsBoundNode,
   });
 }
 
+/// Matches the dependent name of a dependent scope decl ref expr

HighCommander4 wrote:

likewise here, "of a DependentScopeDeclRefExpr"

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits


@@ -2235,6 +2235,21 @@ TEST_P(ASTMatchersTest, 
ArgumentCountIs_CXXConstructExpr) {
  Constructor1Arg));
 }
 
+TEST_P(ASTMatchersTest, hasDependentName_DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Fix this test to work with delayed template parsing.
+return;
+  }
+
+  EXPECT_TRUE(matches("template  class X : T { void f() { T::v; } };",
+  dependentScopeDeclRefExpr(hasDependentName("v";
+
+  EXPECT_TRUE(

HighCommander4 wrote:

It would be nice to have a test case where the dependent name refers to a 
function (specifically a static member function, since I think that will get a 
`DependentScopeDeclRefExpr` rather than a `CXXDepdendentScopeMemberExpr`).

Come to think of it, this applies for the test for `dependentScopeDeclRefExpr` 
itself.

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits

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

Thanks for implementing this!

The patch looks pretty good, I just have some minor comments and a suggestion 
for a new test case.

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-04 Thread Nathan Ridge via cfe-commits

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


[clang] [Clang] Add GCC's __builtin_stack_address() to Clang. (PR #121332)

2025-01-04 Thread via cfe-commits

https://github.com/aalhwc updated 
https://github.com/llvm/llvm-project/pull/121332

>From f247c1ab9fa89ca09476ed0a398a4c4385e75193 Mon Sep 17 00:00:00 2001
From: aalhwc 
Date: Mon, 30 Dec 2024 05:03:59 -0500
Subject: [PATCH 1/2] [Clang] Add GCC's __builtin_stack_address() to Clang
 (#82632).

This new builtin returns the value of the stack pointer register,
mirroring GCC's __builtin_stack_address(). This implementation initially
supports only the x86 and x86_64 architectures. Support for other
architectures can be added in future patches.
---
 clang/include/clang/Basic/Builtins.td |   6 +
 clang/lib/CodeGen/CGBuiltin.cpp   | 163 --
 clang/test/CodeGen/builtin-stackaddress.c |  13 ++
 3 files changed, 107 insertions(+), 75 deletions(-)
 create mode 100644 clang/test/CodeGen/builtin-stackaddress.c

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index b5b47ae2746011..69aed2e6b2f0ca 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -899,6 +899,12 @@ def FrameAddress : Builtin {
   let Prototype = "void*(_Constant unsigned int)";
 }
 
+def StackAddress : Builtin {
+  let Spellings = ["__builtin_stack_address"];
+  let Attributes = [NoThrow];
+  let Prototype = "void*()";
+}
+
 def ClearCache : Builtin {
   let Spellings = ["__builtin___clear_cache"];
   let Attributes = [NoThrow];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4d4b7428abd505..263d77d8e10ecd 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2764,6 +2764,81 @@ static RValue 
EmitHipStdParUnsupportedBuiltin(CodeGenFunction *CGF,
   return RValue::get(CGF->Builder.CreateCall(UBF, Args));
 }
 
+enum SpecialRegisterAccessKind {
+  NormalRead,
+  VolatileRead,
+  Write,
+};
+
+// Generates the IR for the read/write special register builtin,
+// ValueType is the type of the value that is to be written or read,
+// RegisterType is the type of the register being written to or read from.
+static Value *EmitSpecialRegisterBuiltin(CodeGenFunction &CGF,
+ const CallExpr *E,
+ llvm::Type *RegisterType,
+ llvm::Type *ValueType,
+ SpecialRegisterAccessKind AccessKind,
+ StringRef SysReg = "") {
+  // write and register intrinsics only support 32, 64 and 128 bit operations.
+  assert((RegisterType->isIntegerTy(32) || RegisterType->isIntegerTy(64) ||
+  RegisterType->isIntegerTy(128)) &&
+ "Unsupported size for register.");
+
+  CodeGen::CGBuilderTy &Builder = CGF.Builder;
+  CodeGen::CodeGenModule &CGM = CGF.CGM;
+  LLVMContext &Context = CGM.getLLVMContext();
+
+  if (SysReg.empty()) {
+const Expr *SysRegStrExpr = E->getArg(0)->IgnoreParenCasts();
+SysReg = cast(SysRegStrExpr)->getString();
+  }
+
+  llvm::Metadata *Ops[] = {llvm::MDString::get(Context, SysReg)};
+  llvm::MDNode *RegName = llvm::MDNode::get(Context, Ops);
+  llvm::Value *Metadata = llvm::MetadataAsValue::get(Context, RegName);
+
+  llvm::Type *Types[] = {RegisterType};
+
+  bool MixedTypes = RegisterType->isIntegerTy(64) && 
ValueType->isIntegerTy(32);
+  assert(!(RegisterType->isIntegerTy(32) && ValueType->isIntegerTy(64)) &&
+ "Can't fit 64-bit value in 32-bit register");
+
+  if (AccessKind != Write) {
+assert(AccessKind == NormalRead || AccessKind == VolatileRead);
+llvm::Function *F = CGM.getIntrinsic(
+AccessKind == VolatileRead ? llvm::Intrinsic::read_volatile_register
+   : llvm::Intrinsic::read_register,
+Types);
+llvm::Value *Call = Builder.CreateCall(F, Metadata);
+
+if (MixedTypes)
+  // Read into 64 bit register and then truncate result to 32 bit.
+  return Builder.CreateTrunc(Call, ValueType);
+
+if (ValueType->isPointerTy())
+  // Have i32/i64 result (Call) but want to return a VoidPtrTy (i8*).
+  return Builder.CreateIntToPtr(Call, ValueType);
+
+return Call;
+  }
+
+  llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::write_register, Types);
+  llvm::Value *ArgValue = CGF.EmitScalarExpr(E->getArg(1));
+  if (MixedTypes) {
+// Extend 32 bit write value to 64 bit to pass to write.
+ArgValue = Builder.CreateZExt(ArgValue, RegisterType);
+return Builder.CreateCall(F, {Metadata, ArgValue});
+  }
+
+  if (ValueType->isPointerTy()) {
+// Have VoidPtrTy ArgValue but want to return an i32/i64.
+ArgValue = Builder.CreatePtrToInt(ArgValue, RegisterType);
+return Builder.CreateCall(F, {Metadata, ArgValue});
+  }
+
+  return Builder.CreateCall(F, {Metadata, ArgValue});
+}
+
 RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned 
BuiltinID,
 const CallExpr *E,
  

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

2025-01-04 Thread Chandler Carruth via cfe-commits

https://github.com/chandlerc closed 
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)

2025-01-04 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

Thanks, merging! I've put the script here for posterity: 
https://gist.github.com/chandlerc/de807ea073beac351f87c660e1d4b7a0

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)

2025-01-04 Thread Chandler Carruth via cfe-commits

https://github.com/chandlerc edited 
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] Bulk port 64-bit x86 builtins to TableGen (PR #121043)

2025-01-04 Thread Chandler Carruth via cfe-commits

https://github.com/chandlerc updated 
https://github.com/llvm/llvm-project/pull/121043

>From 3314a7d9b2ab582769ce4b4438d24d31c280d9f8 Mon Sep 17 00:00:00 2001
From: Chandler Carruth 
Date: Tue, 24 Dec 2024 08:41:49 +
Subject: [PATCH] Bulk port 64-bit x86 builtins to TableGen

This PR follows #120831 (the PR contains both, only review the last
commit here as the other commit will be reviewed on the other PR).

Similar to that PR, this does a very mechanical port of X86 builtins to
TableGen. There is a *lot* of improvement available here to use TableGen
more effectively and collapse repeated structures. But those can now be
follow-up PRs that restructure *within* the `.td` file.

The current structure produces a file that exactly matches the original
X-macros except for the differences outlined in #120831:

- Horizontal whitespace
- `long long` types now use `long long` outside of OpenCL, but switch to
  `long` in OpenCL for the core `__builtin_ia32_...` builtins.

Otherwise, only the order of builtins change, and no tests regress.
---
 clang/include/clang/Basic/BuiltinsX86.td |  18 +-
 clang/include/clang/Basic/BuiltinsX86Base.td |  29 ++
 clang/include/clang/Basic/BuiltinsX86_64.def | 253 --
 clang/include/clang/Basic/BuiltinsX86_64.td  | 485 +++
 clang/include/clang/Basic/CMakeLists.txt |   4 +
 clang/include/clang/Basic/TargetBuiltins.h   |   2 +-
 clang/lib/Basic/Targets/X86.cpp  |   2 +-
 7 files changed, 521 insertions(+), 272 deletions(-)
 create mode 100644 clang/include/clang/Basic/BuiltinsX86Base.td
 delete mode 100644 clang/include/clang/Basic/BuiltinsX86_64.def
 create mode 100644 clang/include/clang/Basic/BuiltinsX86_64.td

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index 73678bc868bfda..18fc10eb85c027 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -10,23 +10,7 @@
 //
 
//===--===//
 
-include "clang/Basic/BuiltinsBase.td"
-
-class X86Builtin : TargetBuiltin {
-  let Spellings = ["__builtin_ia32_" # NAME];
-  let Prototype = prototype;
-  let EnableOpenCLLong = 1;
-}
-
-class X86NoPrefixBuiltin : TargetBuiltin {
-  let Spellings = [NAME];
-  let Prototype = prototype;
-}
-
-class X86LibBuiltin : TargetLibBuiltin {
-  let Spellings = [NAME];
-  let Prototype = prototype;
-}
+include "clang/Basic/BuiltinsX86Base.td"
 
 def rdpmc : X86Builtin<"unsigned long long int(int)">;
 def rdtsc : X86Builtin<"unsigned long long int()">;
diff --git a/clang/include/clang/Basic/BuiltinsX86Base.td 
b/clang/include/clang/Basic/BuiltinsX86Base.td
new file mode 100644
index 00..aca39c204516ae
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsX86Base.td
@@ -0,0 +1,29 @@
+//===--- BuiltinsX86Base.td - X86 Builtin function classes --*- 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
+//
+//===--===//
+//
+// This file defines the X86-specific builtin function classes.
+//
+//===--===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class X86Builtin : TargetBuiltin {
+  let Spellings = ["__builtin_ia32_" # NAME];
+  let Prototype = prototype;
+  let EnableOpenCLLong = 1;
+}
+
+class X86NoPrefixBuiltin : TargetBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+}
+
+class X86LibBuiltin : TargetLibBuiltin {
+  let Spellings = [NAME];
+  let Prototype = prototype;
+}
diff --git a/clang/include/clang/Basic/BuiltinsX86_64.def 
b/clang/include/clang/Basic/BuiltinsX86_64.def
deleted file mode 100644
index 57928a14b3b399..00
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ /dev/null
@@ -1,253 +0,0 @@
-//===--- BuiltinsX86_64.def - X86-64 Builtin function database --*- 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
-//
-//===--===//
-//
-// This file defines the X86-64-specific builtin function database. Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-// The format of this database matches clang/Basic/Builtins.def.
-
-#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
-#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-#if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
-#  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) 
BU

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

2025-01-04 Thread Chandler Carruth via cfe-commits


@@ -108,9 +109,15 @@ class PrototypeParser {
 } else if (T.consume_back("&")) {
   ParseType(T);
   Type += "&";
+} else if (T.consume_front("long long")) {

chandlerc wrote:

Sure, I use the Fish shell and have a bunch of command line tools that help 
with this installed:

- https://github.com/BurntSushi/ripgrep as `rg`, nicer form of `grep`
- https://github.com/chmln/sd as `sd`, nicer form of `sed` for line-based regex 
search and replace

Combined, they let me write a `diff` command like:

```fish
diff -u (rg -I '^(TARGET|BUILTIN)' BuiltinsX86.def BuiltinsX86.inc | sd 
'^BUILTIN\((.*)\)' 'TARGET_BUILTIN($1, "")' | sd ' +' ' ' | sd ',([X"])' ', $1' 
| sort | psub)  (rg '^TARGET' 
dev/tools/clang/include/clang/Basic/BuiltinsX86.inc | sort | psub)
```

Here `BuiltinsX86.def` and `BuiltinsX86.inc` are copies of the `.def` and 
`.inc` from before this PR, and `dev/tools/.../BuiltinsX86.inc` is the `.inc` 
produced in my development build.

All the uses of `sd` on the original `.def` and `.inc` files are to process 
away weird whitespace artifacts, and the use of `BUILTIN` instead of 
`TARGET_BUILTIN` in four places.

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] Bulk port 64-bit x86 builtins to TableGen (PR #121043)

2025-01-04 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

Updated to rebase on top-of-tree with #120831 merged. Re-ran all the scripts to 
verify things.

Using a variation on the command from my 
[comment](https://github.com/llvm/llvm-project/pull/120831#discussion_r1903059479)
 on the other PR:

```fish
diff -u (rg '^TARGET' BuiltinsX86_64.def | sd ' +' ' ' | sd ',([X"])' ', $1' | 
sort | psub)  (rg '^TARGET' 
dev/tools/clang/include/clang/Basic/BuiltinsX86_64.inc | sort | psub)
```

I got the following diffs due to `LLi` becoming `Oi`, which again seem pretty 
reasonable: https://gist.github.com/chandlerc/03a29633e2e2726ec0fec33fd8e4e8ac

I guess let me know if I need to special case `usermsr` to exclude it from 
OpenCL?

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


[clang] [clang] Canonicalize absolute paths in dependency file (PR #117458)

2025-01-04 Thread via cfe-commits

xtexChooser wrote:

Ahhh wait, if the original path is also printed, Make may see them as broken. I 
don't know what to do now, oops.

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


[clang] da2a9ed - [clang] Update C++ DR status page (#121642)

2025-01-04 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-01-04T18:53:01+04:00
New Revision: da2a9ede81a88bea0bba28a543441197772e4727

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

LOG: [clang] Update C++ DR status page (#121642)

This patch brings our C++ DR status page up to date with WG21 updates.

[CWG1223](https://cplusplus.github.io/CWG/issues/1223.html) "Syntactic
disambiguation and _trailing-return-types_" is resolved by
[P2915R0](https://wg21.link/p2915r0) "Proposed resolution for CWG1223".
Both the test and the paper were written by @cor3ntin, so I presume no
updates are needed.

[CWG2819](https://cplusplus.github.io/CWG/issues/2819.html) "Cast from
null pointer value in a constant expression" was revisited and marked as
not a DR, so I updated the test to ensure that the example is not
accepted in C++23 and earlier modes. CC @offsetof.

Tentantive resolutions to the following issues were simply promoted to
actual resolutions, so tests don't require any meaningful changes:
- [CWG2913](https://cplusplus.github.io/CWG/issues/2913.html) "Grammar
for deduction-guide has requires-clause in the wrong position"
(@zyn0217)
- [CWG2915](https://cplusplus.github.io/CWG/issues/2915.html) "Explicit
object parameters of type void" (@MitalAshok)
- [CWG2922](https://cplusplus.github.io/CWG/issues/2922.html) "constexpr
placement-new is too permissive" (@cor3ntin)

As a drive-by fix, I updated the `make_cxx_dr_status` script to
accommodate for `C++23 onwards` and `C++26 onwards` statuses, which are
useful for Core issues that are not DRs.

Added: 


Modified: 
clang/test/CXX/drs/cwg12xx.cpp
clang/test/CXX/drs/cwg28xx.cpp
clang/test/CXX/drs/cwg29xx.cpp
clang/www/cxx_dr_status.html
clang/www/make_cxx_dr_status

Removed: 




diff  --git a/clang/test/CXX/drs/cwg12xx.cpp b/clang/test/CXX/drs/cwg12xx.cpp
index cdfbc6d6726581..951c71a9832de1 100644
--- a/clang/test/CXX/drs/cwg12xx.cpp
+++ b/clang/test/CXX/drs/cwg12xx.cpp
@@ -32,7 +32,7 @@ namespace cwg1213 { // cwg1213: 7
 }
 
 #if __cplusplus >= 201103L
-namespace cwg1223 { // cwg1223: 17 drafting 2023-05-12
+namespace cwg1223 { // cwg1223: 17
 struct M;
 template 
 struct V;

diff  --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp
index ff625a4a985bcc..40e2b25eedde09 100644
--- a/clang/test/CXX/drs/cwg28xx.cpp
+++ b/clang/test/CXX/drs/cwg28xx.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s
-// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected,since-cxx20 %s
-// RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23 %s
+// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors 
-verify=expected,cxx11-23,since-cxx20 %s
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,cxx11-23,since-cxx20,since-cxx23 %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23,since-cxx26 %s
 
 
@@ -47,12 +47,17 @@ void f() {
 #endif
 } // namespace cwg2813
 
-namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01
-
-#if __cpp_constexpr >= 202306L
+namespace cwg2819 { // cwg2819: 19 c++26
+#if __cplusplus >= 201103L
+  // CWG 2024-04-19: This issue is not a DR.
   constexpr void* p = nullptr;
-  constexpr int* q = static_cast(p);
-  static_assert(q == nullptr);
+  constexpr int* q = static_cast(p); // #cwg2819-q
+  // cxx11-23-error@-1 {{constexpr variable 'q' must be initialized by a 
constant expression}}
+  //   cxx11-23-note@-2 {{cast from 'void *' is not allowed in a constant 
expression}}
+  static_assert(q == nullptr, "");
+  // cxx11-23-error@-1 {{static assertion expression is not an integral 
constant expression}}
+  //   cxx11-23-note@-2 {{initializer of 'q' is not a constant expression}}
+  //   cxx11-23-note@#cwg2819-q {{declared here}}
 #endif
 }
 

diff  --git a/clang/test/CXX/drs/cwg29xx.cpp b/clang/test/CXX/drs/cwg29xx.cpp
index 9629bdd41a2a56..2aa52ad98ada85 100644
--- a/clang/test/CXX/drs/cwg29xx.cpp
+++ b/clang/test/CXX/drs/cwg29xx.cpp
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected %s
 
-namespace cwg2913 { // cwg2913: 20 tentatively ready 2024-08-16
+namespace cwg2913 { // cwg2913: 20
 
 #if __cplusplus >= 202002L
 
@@ -26,7 +26,7 @@ R(T, T) requires true -> R

[clang] [clang] Update C++ DR status page (PR #121642)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

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


[clang] 0093450 - [clang-format] Add `TT_CompoundRequirementLBrace` for better annotation (#121539)

2025-01-04 Thread via cfe-commits

Author: Owen Pan
Date: 2025-01-04T20:51:00-08:00
New Revision: 00934505d44e28f3c1d5739d6369648e87f10cf5

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

LOG: [clang-format] Add `TT_CompoundRequirementLBrace` for better annotation 
(#121539)

Also, add `ST_CompoundRequirement` to help annotating */&/&& in compound
requirement expressions as `TT_BinaryOperator`.

Fixes #121471.

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/TokenAnnotator.h
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 0fd3a49c71f9d1..d97b6522f1fefa 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -45,6 +45,7 @@ namespace format {
   TYPE(CastRParen) 
\
   TYPE(ClassLBrace)
\
   TYPE(ClassRBrace)
\
+  TYPE(CompoundRequirementLBrace)  
\
   /* ternary ?: expression */  
\
   TYPE(ConditionalExpr)
\
   /* the condition in an if statement */   
\

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index fad375733ef845..945174ca9c5861 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -143,6 +143,8 @@ class AnnotatingParser {
 case TT_StructLBrace:
 case TT_UnionLBrace:
   return ST_Class;
+case TT_CompoundRequirementLBrace:
+  return ST_CompoundRequirement;
 default:
   return ST_Other;
 }
@@ -2076,7 +2078,7 @@ class AnnotatingParser {
 TT_RecordLBrace, TT_StructLBrace, TT_UnionLBrace, 
TT_RequiresClause,
 TT_RequiresClauseInARequiresExpression, TT_RequiresExpression,
 TT_RequiresExpressionLParen, TT_RequiresExpressionLBrace,
-TT_BracedListLBrace)) {
+TT_CompoundRequirementLBrace, TT_BracedListLBrace)) {
   CurrentToken->setType(TT_Unknown);
 }
 CurrentToken->Role.reset();
@@ -3100,6 +3102,9 @@ class AnnotatingParser {
   }
 }
 
+if (!Scopes.empty() && Scopes.back() == ST_CompoundRequirement)
+  return TT_BinaryOperator;
+
 return TT_PointerOrReference;
   }
 

diff  --git a/clang/lib/Format/TokenAnnotator.h 
b/clang/lib/Format/TokenAnnotator.h
index 9117ca3f9fb7b5..1a250e94d97c50 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/lib/Format/TokenAnnotator.h
@@ -40,6 +40,8 @@ enum ScopeType {
   ST_ChildBlock,
   // Contained in class declaration/definition.
   ST_Class,
+  // Contained in compound requirement.
+  ST_CompoundRequirement,
   // Contained within other scope block (function, loop, if/else, etc).
   ST_Other,
 };

diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 2fe4ebd4ff8ebf..ec65fea6ec3df9 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -535,7 +535,7 @@ class LineJoiner {
   // Try to merge records.
   if (TheLine->Last->is(TT_EnumLBrace)) {
 ShouldMerge = Style.AllowShortEnumsOnASingleLine;
-  } else if (TheLine->Last->is(TT_RequiresExpressionLBrace)) {
+  } else if (TheLine->Last->is(TT_CompoundRequirementLBrace)) {
 ShouldMerge = Style.AllowShortCompoundRequirementOnASingleLine;
   } else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
 // NOTE: We use AfterClass (whereas AfterStruct exists) for both 
classes

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 39aa37af480c9f..317717241c17cd 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -392,7 +392,7 @@ bool UnwrappedLineParser::parseLevel(const FormatToken 
*OpeningBrace,
   break;
 case tok::l_brace:
   if (InRequiresExpression) {
-FormatTok->setFinalizedType(TT_RequiresExpressionLBrace);
+FormatTok->setFinalizedType(TT_CompoundRequirementLBrace);
   } else if (FormatTok->Previous &&
  FormatTok->Previous->ClosesRequiresClause) {
 // We need the 'default' case here to correctly parse a function
@@ -1705,7 +1705,8 @@ void UnwrappedLineParser::parseStructuralElement(
   }
 
   for (const bool InRequiresExpression =
-   OpeningBrace && Op

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-04 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot4` while building 
`clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/169/builds/7054


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 88095 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 
FAIL: LLVM :: ExecutionEngine/JITLink/x86-64/MachO_weak_references.s (50787 of 
88095)
 TEST 'LLVM :: 
ExecutionEngine/JITLink/x86-64/MachO_weak_references.s' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: rm -rf 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
 && mkdir -p 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
+ rm -rf 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
+ mkdir -p 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp
RUN: at line 2: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-mc 
-triple=x86_64-apple-macosx10.9 -filetype=obj -o 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-mc 
-triple=x86_64-apple-macosx10.9 -filetype=obj -o 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
RUN: at line 3: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-jitlink
 -noexec -check-name=jitlink-check-bar-present -abs bar=0x1 
-check=/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
+ 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-jitlink
 -noexec -check-name=jitlink-check-bar-present -abs bar=0x1 
-check=/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_weak_references.s
 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/MachO_weak_references.s.tmp/macho_weak_refs.o
RUN: at line 4: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-jitlink
 -noexec -check-name=jitlink-check-bar-absent 
-check=/home/b/sanitize

[clang] [clang-format] Add `TT_CompoundRequirementLBrace` for better annotation (PR #121539)

2025-01-04 Thread Owen Pan via cfe-commits

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2025-01-04 Thread Campbell Barton via cfe-commits

ideasman42 wrote:

Checking again and am still considering this patch too spesific/incomplete, 
checking vc's diff calls to git - they are considerably more involved than in 
this PR, meaning this PR will likely require follow up commits to fix problems 
_(see `vc-diff-internal`, inlined below for reference, it deals with EOL 
conversion, added files, coding systems... things this PR doesn't really 
handle)._

Attached a patch that allows for formatting line-ranges, the line range 
generation must be implemented externally.

- The `clang-format-modified-fn` customizable function is used to return a list 
of "modified" line ranges, this can be set by 3rd party packages - VC 
implementation independent.
- This function simply returns a  list of integer pairs (line ranges).
- An error is raised if the function isn't set.

Patch files:

- Patch on the main branch
  
[pr-112792-update.diff.txt](https://github.com/user-attachments/files/18309256/pr-112792-update.diff.txt)
- The whole file (for convenience).
  
[clang-format.el.update.txt](https://github.com/user-attachments/files/18309260/clang-format.el.update.txt)

- The git/diff logic extracted into a separate file - which would not be 
applied to the LLVM project, just use for testing.
  
[clang-format-git-vc-diff.el.txt](https://github.com/user-attachments/files/18309263/clang-format-git-vc-diff.el.txt)

-

As mentioned earlier, calling diff can be quite involved if all corner cases 
are properly handled.
```
(defun vc-diff-internal (async vc-fileset rev1 rev2 &optional verbose buffer)
  "Report diffs between revisions REV1 and REV2 of a fileset in VC-FILESET.
ASYNC non-nil means run the backend's commands asynchronously if possible.
VC-FILESET should have the format described in `vc-deduce-fileset'.
Output goes to the buffer BUFFER, which defaults to *vc-diff*.
BUFFER, if non-nil, should be a buffer or a buffer name.
Return t if the buffer had changes, nil otherwise."
  (unless buffer
(setq buffer "*vc-diff*"))
  (let* ((files (cadr vc-fileset))
 (messages (cons (format "Finding changes in %s..."
 (vc-delistify files))
 (format "No changes between %s and %s"
 (or rev1 "working revision")
 (or rev2 "workfile"
 ;; Set coding system based on the first file.  It's a kluge,
 ;; but the only way to set it for each file included would
 ;; be to call the back end separately for each file.
 (coding-system-for-read
  ;; Force the EOL conversion to be -unix, in case the files
  ;; to be compared have DOS EOLs.  In that case, EOL
  ;; conversion will produce a patch file that will either
  ;; fail to apply, or will change the EOL format of some of
  ;; the lines in the patched file.
  (coding-system-change-eol-conversion
   (if files (vc-coding-system-for-diff (car files)) 'undecided)
   'unix))
 (orig-diff-buffer-clone
  (if revert-buffer-in-progress-p
  (clone-buffer
   (generate-new-buffer-name " *vc-diff-clone*") nil
;; On MS-Windows and MS-DOS, Diff is likely to produce DOS-style
;; EOLs, which will look ugly if (car files) happens to have Unix
;; EOLs.  But for Git, we must force Unix EOLs in the diffs, since
;; Git always produces Unix EOLs in the parts that didn't come
;; from the file, and wants to see any CR characters when applying
;; patches.
(if (and (memq system-type '(windows-nt ms-dos))
 (not (eq (car vc-fileset) 'Git)))
(setq coding-system-for-read
  (coding-system-change-eol-conversion coding-system-for-read
   'dos)))
(vc-setup-buffer buffer)
(message "%s" (car messages))
;; Many backends don't handle well the case of a file that has been
;; added but not yet committed to the repo (notably CVS and Subversion).
;; Do that work here so the backends don't have to futz with it.  --ESR
;;
;; Actually most backends (including CVS) have options to control the
;; behavior since which one is better depends on the user and on the
;; situation).  Worse yet: this code does not handle the case where
;; `file' is a directory which contains added files.
;; I made it conditional on vc-diff-added-files but it should probably
;; just be removed (or copied/moved to specific backends).  --Stef.
(when vc-diff-added-files
  (let ((filtered '())
process-file-side-effects)
(dolist (file files)
  (if (or (file-directory-p file)
  (not (string= (vc-working-revision file) "0")))
  (push file filtered)
;; This file is added but not yet committed;
;; there is no repository version to diff against.
(if (or rev1 rev2)
(error "No revision

[clang] [libclang] Add API to query more information about base classes. (PR #120300)

2025-01-04 Thread Trevor Laughlin via cfe-commits

trelau wrote:

For what it's worth, to get around my issue in 
https://github.com/llvm/llvm-project/issues/121502 I followed your same pattern 
here and added a ```get_methods()``` function to Python (and a new libclang 
function ```clang_visitCXXMethods```) to access the class methods.

Looking at 
[CXXRecordDecl](https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html),
 perhaps the following might all be useful to add to the libclang API 
(including Python):
- methods()
- fields()
- ctors()?
- friends()?

For my purposes of parsing C++ headers and generating Python bindings via 
pybind11, this bases PR plus adding the ```get_methods()``` function would make 
things much easier (ctors and friends seem like more "nice to have" and ctors 
seem to come through in "methods" anyway and can be determined by the cursor 
kind property).

Adding ```get_methods``` was basically copy/pasting your work (see libclang 
function 
[here](https://github.com/llvm/llvm-project/issues/121502#issuecomment-2571512174)).

I'll open a PR for the ```get_methods()``` addition (and maybe I'll try the 
others if they work as I imagine them to).

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


[clang] 267ab1c - [clang] Add test for CWG190 "Layout-compatible POD-struct types" (#121668)

2025-01-04 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-01-05T10:29:31+04:00
New Revision: 267ab1cf574bd51d67f3f88c1c4f28a44fca2c8a

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

LOG: [clang] Add test for CWG190 "Layout-compatible POD-struct types" (#121668)

This patch adds test for
[CWG190](https://cplusplus.github.io/CWG/issues/190.html), leveraging
`__is_layout_compatible` intrinsic added for C++20
`std::is_layout_compatible`. I conservatively set the status to Clang
19, as it's the first release that implemented said intrinsic.

Added: 


Modified: 
clang/test/CXX/drs/cwg1xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..939de6dee06d38 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -1314,8 +1314,25 @@ namespace cwg188 { // cwg188: yes
   static_assert(sizeof(0, c) == 10, "");
 }
 
-// cwg190 FIXME: add codegen test for tbaa
-//  or implement C++20 std::is_layout_compatible and test it this 
way
+namespace cwg190 { // cwg190: 19
+struct A {
+  int a;
+  static double x;
+  int b;
+  void y();
+  int c;
+};
+
+struct B {
+  int a;
+  void y();
+  int b;
+  static double x;
+  int c;
+};
+
+static_assert(__is_layout_compatible(A, B), "");
+} // namespace cwg190
 
 int cwg191_j;
 namespace cwg191 { // cwg191: yes

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 6f42d10e4c187c..335442c6e605f8 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1185,7 +1185,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/190.html";>190
 TC1
 Layout-compatible POD-struct types
-Unknown
+Clang 19
   
   
 https://cplusplus.github.io/CWG/issues/191.html";>191



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


[clang] [clang] Add test for CWG190 "Layout-compatible POD-struct types" (PR #121668)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/121668
___
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)

2025-01-04 Thread Chandler Carruth via cfe-commits


@@ -108,9 +109,15 @@ class PrototypeParser {
 } else if (T.consume_back("&")) {
   ParseType(T);
   Type += "&";
+} else if (T.consume_front("long long")) {

chandlerc wrote:

Ok, PR updated with an explicit opt-in for OpenCL `long` type support.

Somehow, I hadn't considered how easily this would address an unrelated part: 
the occurance in intrinsic header builtins. That just fell out of this. Sorry 
for pushing back earlier, but all my ideas were much more complex than this 
ended up being.

With this tiny change to the `.td` file in the second commit here, the diff of 
things switching from `LLi` to `Oi` becomes very small and looks pretty 
compelling: https://gist.github.com/chandlerc/4395df8d838cd1a110ecc2170e67adc4

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] Bulk port 64-bit x86 builtins to TableGen (PR #121043)

2025-01-04 Thread Phoebe Wang via cfe-commits

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

LGTM, thanks!

https://github.com/llvm/llvm-project/pull/121043
___
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)

2025-01-04 Thread Phoebe Wang via cfe-commits


@@ -108,9 +109,15 @@ class PrototypeParser {
 } else if (T.consume_back("&")) {
   ParseType(T);
   Type += "&";
+} else if (T.consume_front("long long")) {

phoebewang wrote:

Thanks for the information!

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] Update C++ DR status page (PR #121642)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/121642

This patch brings our C++ DR status page up to date with WG21 updates.

[CWG1223](https://cplusplus.github.io/CWG/issues/1223.html) "Syntactic 
disambiguation and _trailing-return-types_" is resolved by 
[P2915R0](https://wg21.link/p2915r0) "Proposed resolution for CWG1223". Both 
the test and the paper were written by @cor3ntin, so I presume no updates are 
needed.

[CWG2819](https://cplusplus.github.io/CWG/issues/2819.html) "Cast from null 
pointer value in a constant expression" was revisited and marked as not a DR, 
so I updated the test to ensure that the example is not accepted in C++23 and 
earlier modes. CC @offsetof.

Tentantive resolutions to the following issues were simply promoted to actual 
resolutions, so tests doesn't require any meaningful changes:
- [CWG2913](https://cplusplus.github.io/CWG/issues/2913.html) "Grammar for 
deduction-guide has requires-clause in the wrong position" (@zyn0217)
- [CWG2915](https://cplusplus.github.io/CWG/issues/2915.html) "Explicit object 
parameters of type void" (@MitalAshok)
- [CWG2922](https://cplusplus.github.io/CWG/issues/2922.html) "constexpr 
placement-new is too permissive" (@cor3ntin)

As a drive-by fix, I updated the `make_cxx_dr_status` script to accommodate for 
`C++23 onwards` and `C++26 onwards` statuses, which are useful for Core issues 
that are not DRs.

>From 3ede83c6b02674e042b191477cdd04b5ac922ae8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 4 Jan 2025 14:47:00 +0300
Subject: [PATCH] [clang] Update C++ DR status page

---
 clang/test/CXX/drs/cwg12xx.cpp |   2 +-
 clang/test/CXX/drs/cwg28xx.cpp |  25 +-
 clang/test/CXX/drs/cwg29xx.cpp |   6 +-
 clang/www/cxx_dr_status.html   | 534 -
 clang/www/make_cxx_dr_status   |   6 +
 5 files changed, 413 insertions(+), 160 deletions(-)

diff --git a/clang/test/CXX/drs/cwg12xx.cpp b/clang/test/CXX/drs/cwg12xx.cpp
index cdfbc6d6726581..951c71a9832de1 100644
--- a/clang/test/CXX/drs/cwg12xx.cpp
+++ b/clang/test/CXX/drs/cwg12xx.cpp
@@ -32,7 +32,7 @@ namespace cwg1213 { // cwg1213: 7
 }
 
 #if __cplusplus >= 201103L
-namespace cwg1223 { // cwg1223: 17 drafting 2023-05-12
+namespace cwg1223 { // cwg1223: 17
 struct M;
 template 
 struct V;
diff --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp
index ff625a4a985bcc..40e2b25eedde09 100644
--- a/clang/test/CXX/drs/cwg28xx.cpp
+++ b/clang/test/CXX/drs/cwg28xx.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s
-// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected,since-cxx20 %s
-// RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23 %s
+// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors 
-verify=expected,cxx11-23,since-cxx20 %s
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,cxx11-23,since-cxx20,since-cxx23 %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23,since-cxx26 %s
 
 
@@ -47,12 +47,17 @@ void f() {
 #endif
 } // namespace cwg2813
 
-namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01
-
-#if __cpp_constexpr >= 202306L
+namespace cwg2819 { // cwg2819: 19 c++26
+#if __cplusplus >= 201103L
+  // CWG 2024-04-19: This issue is not a DR.
   constexpr void* p = nullptr;
-  constexpr int* q = static_cast(p);
-  static_assert(q == nullptr);
+  constexpr int* q = static_cast(p); // #cwg2819-q
+  // cxx11-23-error@-1 {{constexpr variable 'q' must be initialized by a 
constant expression}}
+  //   cxx11-23-note@-2 {{cast from 'void *' is not allowed in a constant 
expression}}
+  static_assert(q == nullptr, "");
+  // cxx11-23-error@-1 {{static assertion expression is not an integral 
constant expression}}
+  //   cxx11-23-note@-2 {{initializer of 'q' is not a constant expression}}
+  //   cxx11-23-note@#cwg2819-q {{declared here}}
 #endif
 }
 
diff --git a/clang/test/CXX/drs/cwg29xx.cpp b/clang/test/CXX/drs/cwg29xx.cpp
index 9629bdd41a2a56..2aa52ad98ada85 100644
--- a/clang/test/CXX/drs/cwg29xx.cpp
+++ b/clang/test/CXX/drs/cwg29xx.cpp
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected %s
 
-namespace cwg2913 { // cwg2913: 20 tentatively ready 2024-08-16
+namespace cwg2913 { // cwg2913: 20
 
 #if __cplusplus >= 202002L
 
@@ -26,7 +26,7 @@ R(T, T) requires true -> R; // expected-error {{expected 
function body after
 
 } // namespace cw

[clang] [clang] Update C++ DR status page (PR #121642)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch brings our C++ DR status page up to date with WG21 updates.

[CWG1223](https://cplusplus.github.io/CWG/issues/1223.html) "Syntactic 
disambiguation and _trailing-return-types_" is resolved by 
[P2915R0](https://wg21.link/p2915r0) "Proposed resolution for CWG1223". Both 
the test and the paper were written by @cor3ntin, so I presume no 
updates are needed.

[CWG2819](https://cplusplus.github.io/CWG/issues/2819.html) "Cast from null 
pointer value in a constant expression" was revisited and marked as not a DR, 
so I updated the test to ensure that the example is not accepted in C++23 and 
earlier modes. CC @offsetof.

Tentantive resolutions to the following issues were simply promoted to actual 
resolutions, so tests doesn't require any meaningful changes:
- [CWG2913](https://cplusplus.github.io/CWG/issues/2913.html) "Grammar for 
deduction-guide has requires-clause in the wrong position" (@zyn0217)
- [CWG2915](https://cplusplus.github.io/CWG/issues/2915.html) "Explicit object 
parameters of type void" (@MitalAshok)
- [CWG2922](https://cplusplus.github.io/CWG/issues/2922.html) "constexpr 
placement-new is too permissive" (@cor3ntin)

As a drive-by fix, I updated the `make_cxx_dr_status` script to accommodate for 
`C++23 onwards` and `C++26 onwards` statuses, which are useful for Core issues 
that are not DRs.

---

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


5 Files Affected:

- (modified) clang/test/CXX/drs/cwg12xx.cpp (+1-1) 
- (modified) clang/test/CXX/drs/cwg28xx.cpp (+15-10) 
- (modified) clang/test/CXX/drs/cwg29xx.cpp (+3-3) 
- (modified) clang/www/cxx_dr_status.html (+388-146) 
- (modified) clang/www/make_cxx_dr_status (+6) 


``diff
diff --git a/clang/test/CXX/drs/cwg12xx.cpp b/clang/test/CXX/drs/cwg12xx.cpp
index cdfbc6d6726581..951c71a9832de1 100644
--- a/clang/test/CXX/drs/cwg12xx.cpp
+++ b/clang/test/CXX/drs/cwg12xx.cpp
@@ -32,7 +32,7 @@ namespace cwg1213 { // cwg1213: 7
 }
 
 #if __cplusplus >= 201103L
-namespace cwg1223 { // cwg1223: 17 drafting 2023-05-12
+namespace cwg1223 { // cwg1223: 17
 struct M;
 template 
 struct V;
diff --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp
index ff625a4a985bcc..40e2b25eedde09 100644
--- a/clang/test/CXX/drs/cwg28xx.cpp
+++ b/clang/test/CXX/drs/cwg28xx.cpp
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s
-// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected %s
-// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected,since-cxx20 %s
-// RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23 %s
+// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected,cxx11-23 %s
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors 
-verify=expected,cxx11-23,since-cxx20 %s
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors 
-verify=expected,cxx11-23,since-cxx20,since-cxx23 %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors 
-verify=expected,since-cxx20,since-cxx23,since-cxx26 %s
 
 
@@ -47,12 +47,17 @@ void f() {
 #endif
 } // namespace cwg2813
 
-namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01
-
-#if __cpp_constexpr >= 202306L
+namespace cwg2819 { // cwg2819: 19 c++26
+#if __cplusplus >= 201103L
+  // CWG 2024-04-19: This issue is not a DR.
   constexpr void* p = nullptr;
-  constexpr int* q = static_cast(p);
-  static_assert(q == nullptr);
+  constexpr int* q = static_cast(p); // #cwg2819-q
+  // cxx11-23-error@-1 {{constexpr variable 'q' must be initialized by a 
constant expression}}
+  //   cxx11-23-note@-2 {{cast from 'void *' is not allowed in a constant 
expression}}
+  static_assert(q == nullptr, "");
+  // cxx11-23-error@-1 {{static assertion expression is not an integral 
constant expression}}
+  //   cxx11-23-note@-2 {{initializer of 'q' is not a constant expression}}
+  //   cxx11-23-note@#cwg2819-q {{declared here}}
 #endif
 }
 
diff --git a/clang/test/CXX/drs/cwg29xx.cpp b/clang/test/CXX/drs/cwg29xx.cpp
index 9629bdd41a2a56..2aa52ad98ada85 100644
--- a/clang/test/CXX/drs/cwg29xx.cpp
+++ b/clang/test/CXX/drs/cwg29xx.cpp
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected %s
 // RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected %s
 
-namespace cwg2913 { // cwg2913: 20 tentatively ready 2024-08-16
+namespace cwg2913 { // cwg2913: 20
 
 #if __cplusplus >= 202002L
 
@@ -26,7 +26,7 @@ R(T, T) requires true -> R; // expected-error {{expected 
function body after
 
 } // namespace cwg2913
 
-namespace cwg2915 { // cwg2915: 20 tentat

[clang] [clang] Update C++ DR status page (PR #121642)

2025-01-04 Thread Vlad Serebrennikov via cfe-commits

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


[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 Thread via cfe-commits

https://github.com/xtexChooser updated 
https://github.com/llvm/llvm-project/pull/121638

>From 2f8c1bc688475ac74ec2af8f954918102d2f612a Mon Sep 17 00:00:00 2001
From: xtex 
Date: Sat, 4 Jan 2025 19:19:47 +0800
Subject: [PATCH] Revert "[clang] Canonicalize absolute paths in dependency
 file (#117458)"

This reverts commit ca2ab74838c41a4146835b5bcc91ce4732273f7d.
---
 clang/include/clang/Frontend/Utils.h  |  1 -
 clang/lib/Frontend/DependencyFile.cpp | 20 +++
 clang/test/Frontend/dependency-gen-symlink.c  |  2 +-
 .../dependency-gen-windows-duplicates.c   |  2 +-
 clang/test/VFS/external-names.c   |  2 +-
 5 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 8ed17179c9824b..604e42067a3f1e 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -120,7 +120,6 @@ class DependencyFileGenerator : public DependencyCollector {
 private:
   void outputDependencyFile(DiagnosticsEngine &Diags);
 
-  llvm::IntrusiveRefCntPtr FS;
   std::string OutputFile;
   std::vector Targets;
   bool IncludeSystemHeaders;
diff --git a/clang/lib/Frontend/DependencyFile.cpp 
b/clang/lib/Frontend/DependencyFile.cpp
index 8a36d835d82b3f..15fa7de35df973 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -23,10 +23,8 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
-#include 
 
 using namespace clang;
 
@@ -238,7 +236,6 @@ void 
DependencyFileGenerator::attachToPreprocessor(Preprocessor &PP) {
 PP.SetSuppressIncludeNotFoundError(true);
 
   DependencyCollector::attachToPreprocessor(PP);
-  FS = PP.getFileManager().getVirtualFileSystemPtr();
 }
 
 bool DependencyFileGenerator::sawDependency(StringRef Filename, bool 
FromModule,
@@ -315,22 +312,11 @@ void 
DependencyFileGenerator::finishedMainFile(DiagnosticsEngine &Diags) {
 /// https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx for NMake info,
 /// 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
 /// for Windows file-naming info.
-static void printFilename(raw_ostream &OS, llvm::vfs::FileSystem *FS,
-  StringRef Filename,
+static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
   // Convert filename to platform native path
   llvm::SmallString<256> NativePath;
   llvm::sys::path::native(Filename.str(), NativePath);
-  // Resolve absolute path. Make and Ninja canonicalize paths
-  // without checking for symbolic links in the path, for performance concerns.
-  // If there is something like `/bin/../lib64` -> `/usr/lib64`
-  // (where `/bin` links to `/usr/bin`), Make will see them as `/lib64`.
-  if (FS != nullptr && llvm::sys::path::is_absolute(NativePath)) {
-llvm::SmallString<256> NativePathTmp = NativePath;
-std::error_code EC = FS->getRealPath(NativePathTmp, NativePath);
-if (EC)
-  NativePath = NativePathTmp;
-  }
 
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
@@ -414,7 +400,7 @@ void 
DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) {
   Columns = 2;
 }
 OS << ' ';
-printFilename(OS, FS.get(), File, OutputFormat);
+PrintFilename(OS, File, OutputFormat);
 Columns += N + 1;
   }
   OS << '\n';
@@ -425,7 +411,7 @@ void 
DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) {
 for (auto I = Files.begin(), E = Files.end(); I != E; ++I) {
   if (Index++ == InputFileIndex)
 continue;
-  printFilename(OS, FS.get(), *I, OutputFormat);
+  PrintFilename(OS, *I, OutputFormat);
   OS << ":\n";
 }
   }
diff --git a/clang/test/Frontend/dependency-gen-symlink.c 
b/clang/test/Frontend/dependency-gen-symlink.c
index 15664a46b90c85..2fa339ad2abf24 100644
--- a/clang/test/Frontend/dependency-gen-symlink.c
+++ b/clang/test/Frontend/dependency-gen-symlink.c
@@ -15,7 +15,7 @@
 // CHECK: dependency-gen-symlink.c.o
 // CHECK: dependency-gen-symlink.c
 // CHECK: a/header.h
-// CHECK-NOT: b/header.h
+// CHECK: b/header.h
 // CHECK-NOT: with-header-guard.h
 #include "a/header.h"
 #include "b/header.h"
diff --git a/clang/test/Frontend/dependency-gen-windows-duplicates.c 
b/clang/test/Frontend/dependency-gen-windows-duplicates.c
index 0ecc23226fb9c8..abd351377dc333 100644
--- a/clang/test/Frontend/dependency-gen-windows-duplicates.c
+++ b/clang/test/Frontend/dependency-gen-windows-duplicates.c
@@ -9,7 +9,7 @@
 // RUN: %clang -MD -MF - %t.dir/test.c -fsyntax-only -I %t.dir/subdir | 
FileCheck %s
 // CHECK: test.o:
 // CHECK-NEXT: \test.c
-// CHECK-NEXT: \subdir\x.h
+// CHECK-NEXT: \SubDir\X.h
 // File x.h mu

[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 Thread via cfe-commits

xtexChooser wrote:

( a fix for clang-format was applied manually despite git-revert

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


[clang] [llvm] [AMDGPU][True16][MC] true16 for v_alignbyte_b32 (PR #119750)

2025-01-04 Thread Matt Arsenault via cfe-commits


@@ -2353,8 +2353,8 @@ def int_amdgcn_writelane :
   [IntrNoMem, IntrConvergent, IntrWillReturn, IntrNoCallback, IntrNoFree]
 >;
 
-def int_amdgcn_alignbyte : ClangBuiltin<"__builtin_amdgcn_alignbyte">,
-  DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+def int_amdgcn_alignbyte : DefaultAttrsIntrinsic<[llvm_i32_ty],
+  [llvm_i32_ty, llvm_i32_ty, llvm_anyint_ty],

arsenm wrote:

But what is the actual issue? Anything talking about the assembler and SP3 
don't really matter with respect to the intrinsic 

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


[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-04 Thread via cfe-commits

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

So, I'll will approve that we need to land the issue resolution in Clang 20, 
but we need to make sure we cleanup `getTemplateInstantiationArgs` soon :)

Thanks for working through this non-trivial PR!

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


[clang] [clang] Update C++ DR status page (PR #121642)

2025-01-04 Thread via cfe-commits

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


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


[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2025-01-04 Thread Зишан Мирза via cfe-commits

https://github.com/zimirza updated 
https://github.com/llvm/llvm-project/pull/110366

From 24d7d3997bacf06a9add1ab3193d8d0adf2032ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Thu, 26 Dec 2024 08:29:03 +0500
Subject: [PATCH 01/46] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

Closes #107445
---
 .../StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc | 6 ++
 clang/test/Analysis/cert/env34-c.c   | 9 -
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index fefe846b6911f7..9c34d3636c8488 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -76,6 +76,10 @@ class InvalidPtrChecker
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   {{CDM::CLibrary, {"asctime"}, 1},
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"ctime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"localtime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   };
 
   // The private members of this checker corresponding to commandline options
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672f..aca22f869b5291 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -220,6 +220,10 @@ SYMBOL(and, None, )
 SYMBOL(and_eq, None, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime_s, None, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime_s, None, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime_s, None, )
 SYMBOL(asin, None, )
 SYMBOL(asinf, None, )
 SYMBOL(asinh, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index c1927180d33976..7a08a5d3beee7a 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -618,6 +618,12 @@ SYMBOL(as_writable_bytes, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime, None, )
+SYMBOL(ctime, std::, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime, None, )
+SYMBOL(localtime, std::, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime, None, )
 SYMBOL(asin, std::, )
 SYMBOL(asin, None, )
 SYMBOL(asin, None, )
diff --git a/clang/test/Analysis/cert/env34-c.c 
b/clang/test/Analysis/cert/env34-c.c
index d307f0d8f4bb01..66ba0be4a67bba 100644
--- a/clang/test/Analysis/cert/env34-c.c
+++ b/clang/test/Analysis/cert/env34-c.c
@@ -15,7 +15,14 @@ lconv *localeconv(void);
 
 typedef struct {
 } tm;
-char *asctime(const tm *timeptr);
+char *asctime(const tm *timeptr)
+;
+typedef struct {
+} tm;
+char *ctime(const tm *timeptr);
+typedef struct {
+} tm;
+struct tm *localtime(struct tm *tm);
 
 int strcmp(const char*, const char*);
 extern void foo(char *e);

From 6d6f95fc0e25a4e0e0b2ee83b8c60e03fd45674e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Sat, 28 Sep 2024 17:20:00 +0200
Subject: [PATCH 02/46] [clang-tidy] add times to clang-tidy

add `ctime` and `localtime` to unsafe functions check function
---
 clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 604a7cac0e4903..f058e5ae40680f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -50,6 +50,8 @@ static StringRef getReplacementFor(StringRef FunctionName,
 StringRef AnnexKReplacementFunction =
 StringSwitch(FunctionName)
 .Cases("asctime", "asctime_r", "asctime_s")
+.Cases("ctime", "ctime_r")
+.Cases("localtime", "localtime_r")
 .Case("gets", "gets_s")
 .Default({});
 if (!AnnexKReplacementFunction.empty())

From f60bbe61c02f91f287c5e8024ce03e137685ffee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Thu, 26 Dec 2024 08:30:17 +0500
Subject: [PATCH 03/46] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

add changes to release notes
---
 clang-tools-extra/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index fabd0cc78ac6

[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2025-01-04 Thread Зишан Мирза via cfe-commits

https://github.com/zimirza updated 
https://github.com/llvm/llvm-project/pull/110366

From 193e93c52e6a523366470aa45088b434eb5628ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Thu, 26 Dec 2024 08:29:03 +0500
Subject: [PATCH 01/46] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

Closes #107445
---
 .../StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc | 6 ++
 clang/test/Analysis/cert/env34-c.c   | 9 -
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index fefe846b6911f7..9c34d3636c8488 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -76,6 +76,10 @@ class InvalidPtrChecker
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   {{CDM::CLibrary, {"asctime"}, 1},
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"ctime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"localtime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   };
 
   // The private members of this checker corresponding to commandline options
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672f..aca22f869b5291 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -220,6 +220,10 @@ SYMBOL(and, None, )
 SYMBOL(and_eq, None, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime_s, None, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime_s, None, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime_s, None, )
 SYMBOL(asin, None, )
 SYMBOL(asinf, None, )
 SYMBOL(asinh, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index c1927180d33976..7a08a5d3beee7a 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -618,6 +618,12 @@ SYMBOL(as_writable_bytes, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime, None, )
+SYMBOL(ctime, std::, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime, None, )
+SYMBOL(localtime, std::, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime, None, )
 SYMBOL(asin, std::, )
 SYMBOL(asin, None, )
 SYMBOL(asin, None, )
diff --git a/clang/test/Analysis/cert/env34-c.c 
b/clang/test/Analysis/cert/env34-c.c
index d307f0d8f4bb01..66ba0be4a67bba 100644
--- a/clang/test/Analysis/cert/env34-c.c
+++ b/clang/test/Analysis/cert/env34-c.c
@@ -15,7 +15,14 @@ lconv *localeconv(void);
 
 typedef struct {
 } tm;
-char *asctime(const tm *timeptr);
+char *asctime(const tm *timeptr)
+;
+typedef struct {
+} tm;
+char *ctime(const tm *timeptr);
+typedef struct {
+} tm;
+struct tm *localtime(struct tm *tm);
 
 int strcmp(const char*, const char*);
 extern void foo(char *e);

From e4d339092a9509e7825a8661a76e74cdeac9f0db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Sat, 28 Sep 2024 17:20:00 +0200
Subject: [PATCH 02/46] [clang-tidy] add times to clang-tidy

add `ctime` and `localtime` to unsafe functions check function
---
 clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 604a7cac0e4903..f058e5ae40680f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -50,6 +50,8 @@ static StringRef getReplacementFor(StringRef FunctionName,
 StringRef AnnexKReplacementFunction =
 StringSwitch(FunctionName)
 .Cases("asctime", "asctime_r", "asctime_s")
+.Cases("ctime", "ctime_r")
+.Cases("localtime", "localtime_r")
 .Case("gets", "gets_s")
 .Default({});
 if (!AnnexKReplacementFunction.empty())

From 9f6f3aa985b198b19670a4f5cdee7b118b680b23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Thu, 26 Dec 2024 08:30:17 +0500
Subject: [PATCH 03/46] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

add changes to release notes
---
 clang-tools-extra/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 1fd9b6077be5

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

2025-01-04 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-debian-cpp20` 
running on `clang-debian-cpp20` while building `clang` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/108/builds/7722


Here is the relevant piece of the build log for the reference

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM :: 
ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s' FAILED 

Exit Code: 134

Command Output (stderr):
--
RUN: at line 1: rm -rf 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
 && mkdir -p 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
+ rm -rf 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
+ mkdir -p 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
RUN: at line 2: 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
-triple=riscv64 -position-independent -filetype=obj  -o 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
+ /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
-triple=riscv64 -position-independent -filetype=obj -o 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
RUN: at line 4: 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
-noexec  -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 4096 
 -abs external_func=0x1 -abs external_data=0x2  -check 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
+ /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
-noexec -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 4096 -abs 
external_func=0x1 -abs external_data=0x2 -check 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
RUN: at line 10: 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
-triple=riscv64 -position-independent -filetype=obj  -mattr=+relax -o 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
+ /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
-triple=riscv64 -position-independent -filetype=obj -mattr=+relax -o 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
RUN: at line 12: 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
-noexec  -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 4096 
 -abs external_func=0x1 -abs external_data=0x2  -check 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
+ /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
-noexec -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 4096 -abs 
external_func=0x1 -abs external_data=0x2 -check 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
llvm-jitlink: 
/vol/worker/clang-debian-c

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

2025-01-04 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

> LLVM Buildbot has detected a new failure on builder `clang-debian-cpp20` 
> running on `clang-debian-cpp20` while building `clang` at step 6 
> "test-build-unified-tree-check-all".
> 
> Full details are available at: 
> https://lab.llvm.org/buildbot/#/builders/108/builds/7722
> 
> 
> Here is the relevant piece of the build log for the 
> reference
> 
> ```
> Step 6 (test-build-unified-tree-check-all) failure: test (failure)
>  TEST 'LLVM :: 
> ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s' FAILED 
> 
> Exit Code: 134
> 
> Command Output (stderr):
> --
> RUN: at line 1: rm -rf 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
>  && mkdir -p 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
> + rm -rf 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
> + mkdir -p 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp
> RUN: at line 2: 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
> -triple=riscv64 -position-independent -filetype=obj  -o 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
> + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
> -triple=riscv64 -position-independent -filetype=obj -o 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
> RUN: at line 4: 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
> -noexec  -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 
> 4096  -abs external_func=0x1 -abs external_data=0x2  -check 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
> + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
> -noexec -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 4096 
> -abs external_func=0x1 -abs external_data=0x2 -check 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
> RUN: at line 10: 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
> -triple=riscv64 -position-independent -filetype=obj  -mattr=+relax -o 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
> + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc 
> -triple=riscv64 -position-independent -filetype=obj -mattr=+relax -o 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
> RUN: at line 12: 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
> -noexec  -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 
> 4096  -abs external_func=0x1 -abs external_data=0x2  -check 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
>  
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/ExecutionEngine/JITLink/RISCV/Output/ELF_riscv64_got_plt_reloc.s.tmp/elf_riscv64_got_plt_reloc.o
> + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-jitlink 
> -noexec -slab-allocate 100Kb -slab-address 0xfff0 -slab-page-size 4096 
> -abs external_func=0x1 -abs external_data=0x2 -check 
> /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_riscv64_got_plt_reloc.s
>  
> /vol/worker/clang-debian-cpp20/clang-debian-

[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 Thread via cfe-commits

https://github.com/xtexChooser created 
https://github.com/llvm/llvm-project/pull/121638

Reverts llvm/llvm-project#117458

https://github.com/llvm/llvm-project/pull/117458#issuecomment-2568804774

>From fba92539ccef36eeac3eb3258af172911835e710 Mon Sep 17 00:00:00 2001
From: xtex 
Date: Sat, 4 Jan 2025 19:19:47 +0800
Subject: [PATCH] Revert "[clang] Canonicalize absolute paths in dependency
 file (#117458)"

This reverts commit ca2ab74838c41a4146835b5bcc91ce4732273f7d.
---
 clang/include/clang/Frontend/Utils.h  |  1 -
 clang/lib/Frontend/DependencyFile.cpp | 22 ---
 clang/test/Frontend/dependency-gen-symlink.c  |  2 +-
 .../dependency-gen-windows-duplicates.c   |  2 +-
 clang/test/VFS/external-names.c   |  2 +-
 5 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 8ed17179c9824b..604e42067a3f1e 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -120,7 +120,6 @@ class DependencyFileGenerator : public DependencyCollector {
 private:
   void outputDependencyFile(DiagnosticsEngine &Diags);
 
-  llvm::IntrusiveRefCntPtr FS;
   std::string OutputFile;
   std::vector Targets;
   bool IncludeSystemHeaders;
diff --git a/clang/lib/Frontend/DependencyFile.cpp 
b/clang/lib/Frontend/DependencyFile.cpp
index 8a36d835d82b3f..528eae2c5283ea 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -10,11 +10,11 @@
 //
 
//===--===//
 
+#include "clang/Frontend/Utils.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
 #include "clang/Lex/DirectoryLookup.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PPCallbacks.h"
@@ -23,10 +23,8 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
-#include 
 
 using namespace clang;
 
@@ -238,7 +236,6 @@ void 
DependencyFileGenerator::attachToPreprocessor(Preprocessor &PP) {
 PP.SetSuppressIncludeNotFoundError(true);
 
   DependencyCollector::attachToPreprocessor(PP);
-  FS = PP.getFileManager().getVirtualFileSystemPtr();
 }
 
 bool DependencyFileGenerator::sawDependency(StringRef Filename, bool 
FromModule,
@@ -315,22 +312,11 @@ void 
DependencyFileGenerator::finishedMainFile(DiagnosticsEngine &Diags) {
 /// https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx for NMake info,
 /// 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
 /// for Windows file-naming info.
-static void printFilename(raw_ostream &OS, llvm::vfs::FileSystem *FS,
-  StringRef Filename,
+static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
   // Convert filename to platform native path
   llvm::SmallString<256> NativePath;
   llvm::sys::path::native(Filename.str(), NativePath);
-  // Resolve absolute path. Make and Ninja canonicalize paths
-  // without checking for symbolic links in the path, for performance concerns.
-  // If there is something like `/bin/../lib64` -> `/usr/lib64`
-  // (where `/bin` links to `/usr/bin`), Make will see them as `/lib64`.
-  if (FS != nullptr && llvm::sys::path::is_absolute(NativePath)) {
-llvm::SmallString<256> NativePathTmp = NativePath;
-std::error_code EC = FS->getRealPath(NativePathTmp, NativePath);
-if (EC)
-  NativePath = NativePathTmp;
-  }
 
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
@@ -414,7 +400,7 @@ void 
DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) {
   Columns = 2;
 }
 OS << ' ';
-printFilename(OS, FS.get(), File, OutputFormat);
+PrintFilename(OS, File, OutputFormat);
 Columns += N + 1;
   }
   OS << '\n';
@@ -425,7 +411,7 @@ void 
DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) {
 for (auto I = Files.begin(), E = Files.end(); I != E; ++I) {
   if (Index++ == InputFileIndex)
 continue;
-  printFilename(OS, FS.get(), *I, OutputFormat);
+  PrintFilename(OS, *I, OutputFormat);
   OS << ":\n";
 }
   }
diff --git a/clang/test/Frontend/dependency-gen-symlink.c 
b/clang/test/Frontend/dependency-gen-symlink.c
index 15664a46b90c85..2fa339ad2abf24 100644
--- a/clang/test/Frontend/dependency-gen-symlink.c
+++ b/clang/test/Frontend/dependency-gen-symlink.c
@@ -15,7 +15,7 @@
 // CHECK: dependency-gen-symlink.c.o
 // CHECK: dependency-gen-symlink.c
 // CHECK: a/header.h
-// CHECK-NOT: b/header.h
+// CHECK: b/header.h
 // CHECK-NOT: wit

[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: xtex (xtexChooser)


Changes

Reverts llvm/llvm-project#117458

https://github.com/llvm/llvm-project/pull/117458#issuecomment-2568804774

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


5 Files Affected:

- (modified) clang/include/clang/Frontend/Utils.h (-1) 
- (modified) clang/lib/Frontend/DependencyFile.cpp (+4-18) 
- (modified) clang/test/Frontend/dependency-gen-symlink.c (+1-1) 
- (modified) clang/test/Frontend/dependency-gen-windows-duplicates.c (+1-1) 
- (modified) clang/test/VFS/external-names.c (+1-1) 


``diff
diff --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 8ed17179c9824b..604e42067a3f1e 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -120,7 +120,6 @@ class DependencyFileGenerator : public DependencyCollector {
 private:
   void outputDependencyFile(DiagnosticsEngine &Diags);
 
-  llvm::IntrusiveRefCntPtr FS;
   std::string OutputFile;
   std::vector Targets;
   bool IncludeSystemHeaders;
diff --git a/clang/lib/Frontend/DependencyFile.cpp 
b/clang/lib/Frontend/DependencyFile.cpp
index 8a36d835d82b3f..528eae2c5283ea 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -10,11 +10,11 @@
 //
 
//===--===//
 
+#include "clang/Frontend/Utils.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/Utils.h"
 #include "clang/Lex/DirectoryLookup.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PPCallbacks.h"
@@ -23,10 +23,8 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
-#include 
 
 using namespace clang;
 
@@ -238,7 +236,6 @@ void 
DependencyFileGenerator::attachToPreprocessor(Preprocessor &PP) {
 PP.SetSuppressIncludeNotFoundError(true);
 
   DependencyCollector::attachToPreprocessor(PP);
-  FS = PP.getFileManager().getVirtualFileSystemPtr();
 }
 
 bool DependencyFileGenerator::sawDependency(StringRef Filename, bool 
FromModule,
@@ -315,22 +312,11 @@ void 
DependencyFileGenerator::finishedMainFile(DiagnosticsEngine &Diags) {
 /// https://msdn.microsoft.com/en-us/library/dd9y37ha.aspx for NMake info,
 /// 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
 /// for Windows file-naming info.
-static void printFilename(raw_ostream &OS, llvm::vfs::FileSystem *FS,
-  StringRef Filename,
+static void PrintFilename(raw_ostream &OS, StringRef Filename,
   DependencyOutputFormat OutputFormat) {
   // Convert filename to platform native path
   llvm::SmallString<256> NativePath;
   llvm::sys::path::native(Filename.str(), NativePath);
-  // Resolve absolute path. Make and Ninja canonicalize paths
-  // without checking for symbolic links in the path, for performance concerns.
-  // If there is something like `/bin/../lib64` -> `/usr/lib64`
-  // (where `/bin` links to `/usr/bin`), Make will see them as `/lib64`.
-  if (FS != nullptr && llvm::sys::path::is_absolute(NativePath)) {
-llvm::SmallString<256> NativePathTmp = NativePath;
-std::error_code EC = FS->getRealPath(NativePathTmp, NativePath);
-if (EC)
-  NativePath = NativePathTmp;
-  }
 
   if (OutputFormat == DependencyOutputFormat::NMake) {
 // Add quotes if needed. These are the characters listed as "special" to
@@ -414,7 +400,7 @@ void 
DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) {
   Columns = 2;
 }
 OS << ' ';
-printFilename(OS, FS.get(), File, OutputFormat);
+PrintFilename(OS, File, OutputFormat);
 Columns += N + 1;
   }
   OS << '\n';
@@ -425,7 +411,7 @@ void 
DependencyFileGenerator::outputDependencyFile(llvm::raw_ostream &OS) {
 for (auto I = Files.begin(), E = Files.end(); I != E; ++I) {
   if (Index++ == InputFileIndex)
 continue;
-  printFilename(OS, FS.get(), *I, OutputFormat);
+  PrintFilename(OS, *I, OutputFormat);
   OS << ":\n";
 }
   }
diff --git a/clang/test/Frontend/dependency-gen-symlink.c 
b/clang/test/Frontend/dependency-gen-symlink.c
index 15664a46b90c85..2fa339ad2abf24 100644
--- a/clang/test/Frontend/dependency-gen-symlink.c
+++ b/clang/test/Frontend/dependency-gen-symlink.c
@@ -15,7 +15,7 @@
 // CHECK: dependency-gen-symlink.c.o
 // CHECK: dependency-gen-symlink.c
 // CHECK: a/header.h
-// CHECK-NOT: b/header.h
+// CHECK: b/header.h
 // CHECK-NOT: with-header-guard.h
 #include "a/header.h"
 #include "b/header.h"
diff --git a/clang/test/Frontend/dependency-gen-windows-duplicates.c 
b/clang/test/Frontend/dependency-gen-windows-duplicates.c
index 0ecc23226fb9

[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 Thread via cfe-commits

xtexChooser wrote:

@kadircet

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


[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 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 95db1116c5718004e0bd7c3b79d39987fdbbff32 
fba92539ccef36eeac3eb3258af172911835e710 --extensions c,h,cpp -- 
clang/include/clang/Frontend/Utils.h clang/lib/Frontend/DependencyFile.cpp 
clang/test/Frontend/dependency-gen-symlink.c 
clang/test/Frontend/dependency-gen-windows-duplicates.c 
clang/test/VFS/external-names.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Frontend/DependencyFile.cpp 
b/clang/lib/Frontend/DependencyFile.cpp
index 528eae2c52..15fa7de35d 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -10,11 +10,11 @@
 //
 
//===--===//
 
-#include "clang/Frontend/Utils.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Lex/DirectoryLookup.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PPCallbacks.h"

``




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


[clang] Revert "[clang] Canonicalize absolute paths in dependency file" (PR #121638)

2025-01-04 Thread via cfe-commits

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


[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2025-01-04 Thread Зишан Мирза via cfe-commits

https://github.com/zimirza updated 
https://github.com/llvm/llvm-project/pull/110366

From 193e93c52e6a523366470aa45088b434eb5628ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Thu, 26 Dec 2024 08:29:03 +0500
Subject: [PATCH 01/47] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

Closes #107445
---
 .../StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc   | 4 
 clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc | 6 ++
 clang/test/Analysis/cert/env34-c.c   | 9 -
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index fefe846b6911f7..9c34d3636c8488 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -76,6 +76,10 @@ class InvalidPtrChecker
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   {{CDM::CLibrary, {"asctime"}, 1},
&InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"ctime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
+  {{CDM::CLibrary, {"localtime"}, 1},
+   &InvalidPtrChecker::postPreviousReturnInvalidatingCall},
   };
 
   // The private members of this checker corresponding to commandline options
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672f..aca22f869b5291 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -220,6 +220,10 @@ SYMBOL(and, None, )
 SYMBOL(and_eq, None, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime_s, None, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime_s, None, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime_s, None, )
 SYMBOL(asin, None, )
 SYMBOL(asinf, None, )
 SYMBOL(asinh, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index c1927180d33976..7a08a5d3beee7a 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -618,6 +618,12 @@ SYMBOL(as_writable_bytes, std::, )
 SYMBOL(asctime, std::, )
 SYMBOL(asctime, None, )
 SYMBOL(asctime, None, )
+SYMBOL(ctime, std::, )
+SYMBOL(ctime, None, )
+SYMBOL(ctime, None, )
+SYMBOL(localtime, std::, )
+SYMBOL(localtime, None, )
+SYMBOL(localtime, None, )
 SYMBOL(asin, std::, )
 SYMBOL(asin, None, )
 SYMBOL(asin, None, )
diff --git a/clang/test/Analysis/cert/env34-c.c 
b/clang/test/Analysis/cert/env34-c.c
index d307f0d8f4bb01..66ba0be4a67bba 100644
--- a/clang/test/Analysis/cert/env34-c.c
+++ b/clang/test/Analysis/cert/env34-c.c
@@ -15,7 +15,14 @@ lconv *localeconv(void);
 
 typedef struct {
 } tm;
-char *asctime(const tm *timeptr);
+char *asctime(const tm *timeptr)
+;
+typedef struct {
+} tm;
+char *ctime(const tm *timeptr);
+typedef struct {
+} tm;
+struct tm *localtime(struct tm *tm);
 
 int strcmp(const char*, const char*);
 extern void foo(char *e);

From e4d339092a9509e7825a8661a76e74cdeac9f0db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Sat, 28 Sep 2024 17:20:00 +0200
Subject: [PATCH 02/47] [clang-tidy] add times to clang-tidy

add `ctime` and `localtime` to unsafe functions check function
---
 clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index 604a7cac0e4903..f058e5ae40680f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -50,6 +50,8 @@ static StringRef getReplacementFor(StringRef FunctionName,
 StringRef AnnexKReplacementFunction =
 StringSwitch(FunctionName)
 .Cases("asctime", "asctime_r", "asctime_s")
+.Cases("ctime", "ctime_r")
+.Cases("localtime", "localtime_r")
 .Case("gets", "gets_s")
 .Default({});
 if (!AnnexKReplacementFunction.empty())

From 9f6f3aa985b198b19670a4f5cdee7b118b680b23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=97=D0=B8=D1=88=D0=B0=D0=BD=20=D0=9C=D0=B8=D1=80=D0=B7?=
 =?UTF-8?q?=D0=B0?= 
Date: Thu, 26 Dec 2024 08:30:17 +0500
Subject: [PATCH 03/47] [clang-tidy] add `ctime` and `localtime` to
 `clang-tidy`

add changes to release notes
---
 clang-tools-extra/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 1fd9b6077be5

[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2025-01-04 Thread via cfe-commits
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,Zishan Mirza ,Zishan
 Mirza 
Message-ID:
In-Reply-To: 



@@ -187,6 +189,13 @@ Changes in existing checks
   ` check to improve detection of
   branch clones by now detecting duplicate inner and outer if statements.
 
+- New unsafe functions checks :doc:`bugprone-unsafe-functions

EugeneZelenko wrote:

Check was added in other pull request.

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


[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2025-01-04 Thread via cfe-commits
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw==?=,Zishan Mirza ,Zishan
 Mirza 
Message-ID:
In-Reply-To: 



@@ -112,6 +112,8 @@ Improvements to clang-tidy
   the configuration options of the `Clang Static Analyzer Checks
   `_.
 
+- Added `ctime` and `localtime` to clang-tidy.

EugeneZelenko wrote:

This was mentioned in section about changes in existing checks.

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


[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)

2025-01-04 Thread via cfe-commits
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,Zishan Mirza ,Zishan
 Mirza 
Message-ID:
In-Reply-To: 



@@ -143,6 +139,10 @@ Changes in existing checks
   `bsl::optional` and `bdlb::NullableValue` from
   _.
 
+- Improved :doc:`bugprone-unsafe-functions
+  ` by adding ``ctime`` and

EugeneZelenko wrote:

Since entry for `bugprone-unsafe-functions` already exist, they should be 
combined. See `readability-enum-initial-value` entry as example.

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


  1   2   >