jj-marr wrote:
I'm still working on this. It seems like I broke the assertion tests. I'm
unsure why, but it should be fixed if I figure out a better way of evaluating
the macro.
https://github.com/llvm/llvm-project/pull/130458
___
cfe-commits mailing
https://github.com/jj-marr converted_to_draft
https://github.com/llvm/llvm-project/pull/130458
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
>From d06c5ab5c30e535893335af798df339b0e9c6878 Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval
---
.../clang/Basic/D
https://github.com/jj-marr created
https://github.com/llvm/llvm-project/pull/130458
Take this piece of code:
```cpp
#include
consteval int square(int x) {
int result = x * x;
assert(result == 42);
return result;
}
void test() {
auto val = square(2);
}
```
The assertion will fail, and
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
>From d61892d8546944000118ad0312886da75cd6509b Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval
---
.../clang/Basic/D
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus %s
+
+#ifdef __ASSERT_FUNCTION
+#undef __ASSERT_FUNCTION
+#endif
+extern "C" void __assert_fail(const char*, const char*, unsigned, const char*);
+
+#define assert(cond) \
+ ((cond) ? (void)0 : __assert_f
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
>From 0cba377eb8693657b7688cd1feb1cc9c5734f307 Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval
---
.../clang/Basic/D
https://github.com/jj-marr ready_for_review
https://github.com/llvm/llvm-project/pull/130458
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Arial,sans-s
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
>From 3b6d28e4f74c1fda73abe3b5972d5ac2a43576de Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval
---
clang/docs/Releas
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Arial,sans-s
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Arial,sans-s
@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info,
SourceLocation CallLoc,
Definition->hasAttr(
return true;
- if (Info.getLangOpts().CPlusPlus11) {
-const FunctionDecl *DiagDecl = Definition ? Defin
jj-marr wrote:
> LGTM modulo nit.
>
> Are you happy with the current state? @cor3ntin @Sirraide
Shouldn't CI be passing? I can't figure out why there are failures.
https://github.com/llvm/llvm-project/pull/130458
___
cfe-commits mailing list
cfe-comm
@@ -5975,9 +5975,15 @@ static bool CheckConstexprFunction(EvalInfo &Info,
SourceLocation CallLoc,
Definition->hasAttr(
return true;
- if (Info.getLangOpts().CPlusPlus11) {
-const FunctionDecl *DiagDecl = Definition ? Defin
@@ -5975,9 +5975,22 @@ static bool CheckConstexprFunction(EvalInfo &Info,
SourceLocation CallLoc,
Definition->hasAttr(
return true;
- if (Info.getLangOpts().CPlusPlus11) {
-const FunctionDecl *DiagDecl = Definition ? Defin
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Arial,sans-s
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
>From 64eb62576dc1ecf0e696f2448e410c2fd77575de Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval
---
clang/docs/Releas
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
>From 67984fbf0374fa40fd7b73431b17baddc301290f Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval
---
clang/docs/Releas
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/130458
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Arial,sans-s
jj-marr wrote:
> @jj-marr Thanks. Do you want us to merge that for you?
Is it something I can actually do myself?
https://github.com/llvm/llvm-project/pull/130458
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/m
jj-marr wrote:
OK, merge whenever.
https://github.com/llvm/llvm-project/pull/130458
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
jj-marr wrote:
Thinking more, this is not a good check at this time.
https://github.com/llvm/llvm-project/pull/140001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr closed
https://github.com/llvm/llvm-project/pull/140001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
jj-marr wrote:
`std::span` has a capability gap with a const reference to a `std::vector`
until C++26 as `std::span` cannot be constructed from an initializer list.
Should this be a C++26 check?
https://github.com/llvm/llvm-project/pull/140001
___
c
@@ -851,6 +851,19 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const
Function *F) {
if (F->isLambdaStaticInvoker())
return true;
+ // Diagnose failed assertions specially.
+ if (S.Current->getLocation(OpPC).isMacroID() &&
+ F->getDecl()->getIdentifier()) {
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/14
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
jj-marr wrote:
@vbvictor It makes sense to provide an autofix for `float`/`double`, since I
have never heard of them being anything other than IEEE754 32-bit binary floats
or IEEE754 64-bit binary floats respectively.
`char8_t` will always be `unsigned char` so a fix from `unsigned char` to
`
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/146970
>From 3ef4feb748551806c863529306fefb2bd914e5be Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Thu, 3 Jul 2025 17:17:06 -0400
Subject: [PATCH 1/6] AvoidFundamentalIntegerTypesCheck
---
.../AvoidFundamentalInteger
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/146970
>From 3ef4feb748551806c863529306fefb2bd914e5be Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Thu, 3 Jul 2025 17:17:06 -0400
Subject: [PATCH 1/8] AvoidFundamentalIntegerTypesCheck
---
.../AvoidFundamentalInteger
@@ -0,0 +1,181 @@
+//===--- AvoidFundamentalIntegerTypesCheck.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: Ap
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/146970
>From 3ef4feb748551806c863529306fefb2bd914e5be Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Thu, 3 Jul 2025 17:17:06 -0400
Subject: [PATCH 1/9] AvoidFundamentalIntegerTypesCheck
---
.../AvoidFundamentalInteger
jj-marr wrote:
I will add the `float` component of the check tomorrow.
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/146970
>From 3ef4feb748551806c863529306fefb2bd914e5be Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Thu, 3 Jul 2025 17:17:06 -0400
Subject: [PATCH 01/10] AvoidFundamentalIntegerTypesCheck
---
.../AvoidFundamentalInteg
https://github.com/jj-marr updated
https://github.com/llvm/llvm-project/pull/146970
>From 3ef4feb748551806c863529306fefb2bd914e5be Mon Sep 17 00:00:00 2001
From: JJ Marr
Date: Thu, 3 Jul 2025 17:17:06 -0400
Subject: [PATCH 01/14] AvoidFundamentalIntegerTypesCheck
---
.../AvoidFundamentalInteg
@@ -0,0 +1,43 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.h - clang-tidy ---*-
C++
+//-*-===//
jj-marr wrote:
Done.
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-com
@@ -0,0 +1,111 @@
+.. title:: clang-tidy - portability-avoid-platform-specific-fundamental-types
+
+portability-avoid-platform-specific-fundamental-types
+=
+
+Finds fundamental types and recommends using typedefs or fixed-width
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
jj-marr wrote:
> Have you looked at google-runtime-int? It should be doing the same thing
> (maybe small differences)
I haven't before now. I still think a new check is necessary.
`google-runtime-int` isn't as strict because it is coupled to the Google coding
guidelines. That means it doesn'
@@ -0,0 +1,43 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.h - clang-tidy ---*-
C++
+//-*-===//
jj-marr wrote:
This requires turning off `clang-format` since line 1 is too long.
https://github.com/llvm/llvm-project/pull/146970
___
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
jj-marr wrote:
> You could make a universal option to configure autofixes. Make
> semicolon-separated list of key-value pairs, e.g.
> `int=int32_t;float=float32_t;char=char8_t`. User could specify any type he
> wants, and remove/add fixes for `int`, `char` and so on.
>
> By default, we co
@@ -0,0 +1,246 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.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: Ap
https://github.com/jj-marr commented:
comments for myself
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/jj-marr edited
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,246 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.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: Ap
@@ -0,0 +1,260 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.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: Ap
jj-marr wrote:
> Please remove unnecessary comments that tell the same as code itself,
> speaking mostly about comments in `registerMatchers`. They mostly don't give
> any more information that matchers themselves.
To be honest, this is because I coded 98% of this with AI (except for the
`.rs
@@ -0,0 +1,52 @@
+//==-- AvoidPlatformSpecificFundamentalTypesCheck.h - clang-tidy -*- 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: Apa
https://github.com/jj-marr created
https://github.com/llvm/llvm-project/pull/146970
The fundamental types are widely recognized to be flawed because they're of
implementation-defined sizes without a common purpose.
For example, `long int` is a footgun since its 32 bits on Windows and 64 bits
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s
portability-avoid-platform-specific-fundamental-types %t --
-config="{CheckOptions: [{key:
portability-avoid-platform-specific-fundamental-types.WarnOnFloats, value:
true}]}" -header-filter=.* -- -std=c++23
+
+// Mock fixed-width
@@ -0,0 +1,190 @@
+.. title:: clang-tidy - portability-avoid-platform-specific-fundamental-types
+
+portability-avoid-platform-specific-fundamental-types
+=
+
+Finds fundamental types (e.g. `int`, `float`) and recommends using ty
@@ -0,0 +1,190 @@
+.. title:: clang-tidy - portability-avoid-platform-specific-fundamental-types
+
+portability-avoid-platform-specific-fundamental-types
+=
+
+Finds fundamental types (e.g. `int`, `float`) and recommends using ty
@@ -0,0 +1,190 @@
+.. title:: clang-tidy - portability-avoid-platform-specific-fundamental-types
+
+portability-avoid-platform-specific-fundamental-types
+=
+
+Finds fundamental types (e.g. `int`, `float`) and recommends using ty
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s
portability-avoid-platform-specific-fundamental-types %t --
-config="{CheckOptions: [{key:
portability-avoid-platform-specific-fundamental-types.WarnOnChars, value:
true}]}" -header-filter=.* -- -std=c++11
jj-marr
@@ -0,0 +1,100 @@
+// RUN: %check_clang_tidy %s
portability-avoid-platform-specific-fundamental-types %t --
-config="{CheckOptions: [{key:
portability-avoid-platform-specific-fundamental-types.WarnOnFloats, value:
true}]}" -header-filter=.* -- -std=c++23
+
+// Mock fixed-width
@@ -0,0 +1,190 @@
+.. title:: clang-tidy - portability-avoid-platform-specific-fundamental-types
+
+portability-avoid-platform-specific-fundamental-types
+=
+
+Finds fundamental types (e.g. `int`, `float`) and recommends using ty
@@ -0,0 +1,260 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.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: Ap
@@ -0,0 +1,54 @@
+// clang-format off
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.h - clang-tidy -*- 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
@@ -0,0 +1,54 @@
+// clang-format off
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.h - clang-tidy -*- C++
-*-===//
jj-marr wrote:
Done.
https://github.com/llvm/llvm-project/pull/146970
___
cfe-commits mailing
jj-marr wrote:
> Check makes sense to me! As a first iteration it's fine without autofix but I
> can imagine it will be hard for a codebase to enable this check given the
> large amount of things to fix. Maybe users can specify a mapping of wanted
> types via an option?
I'm planning for an au
@@ -0,0 +1,260 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.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: Ap
65 matches
Mail list logo