[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-10 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 01/11] [C11] Implement WG14 N1285 (temporary lifetimes) Thi

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-10 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-10 Thread Aaron Ballman via cfe-commits
@@ -7653,8 +7653,11 @@ ExprResult Sema::TemporaryMaterializationConversion(Expr *E) { // In C++98, we don't want to implicitly create an xvalue. // FIXME: This means that AST consumers need to deal with "prvalues" that // denote materialized temporaries. Maybe we should

[clang] Initialize member variable; NFC (PR #135167)

2025-04-10 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/135167 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Initialize member variable; NFC (PR #135167)

2025-04-10 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/135167 This was found via a Coverity static analysis pass. There's no indication this was being used incorrectly in practice, but there are public interfaces which require `BR` to be non-null and valid, and `BR`

[clang] [Clang][Sema]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)

2025-04-09 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > > @AaronBallman @erichkeane Thank you for your comments. There's a question > > > here about whether to report an error or a warning here, and you're in a > > > divided opinion. My opinion is that it is better to use the error report > > > here. Because these are two mu

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
@@ -5585,6 +5585,18 @@ SourceRange EnumConstantDecl::getSourceRange() const { return SourceRange(getLocation(), End); } +bool EnumConstantDecl::isOutOfLine() const { + if (Decl::isOutOfLine()) +return true; + + // In C++, if the enumeration is out of line, the enumerat

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
@@ -151,3 +151,21 @@ class C { // expected-error {{unexpected ';' before ')'}} }; } + +#if __cplusplus >= 201103L +namespace GH23317 { +struct A { AaronBallman wrote: Yup, that still compiles without diagnosing. https://github.com/llvm

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
@@ -5585,6 +5585,18 @@ SourceRange EnumConstantDecl::getSourceRange() const { return SourceRange(getLocation(), End); } +bool EnumConstantDecl::isOutOfLine() const { + if (Decl::isOutOfLine()) +return true; + + // In C++, if the enumeration is out of line, the enumerat

[clang] [clang][docs] Fix example in likely/unlikely attr documentation (PR #126372)

2025-04-09 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Hmm, I think what this section is trying to demonstrate is that ‘_According > to the standard_, this is in the path of execution and therefore _supposed_ > to be considered unlikely, but we don’t do that’, so maybe it’d be better to > reword/expand the comment instead? T

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/134998 >From 6864d9e8c5d20830adbe6bf226943041ebacf5e1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 9 Apr 2025 08:35:40 -0400 Subject: [PATCH 1/2] No longer add enumeration constants to the wrong scope

[clang] Fix crash with align_value diagnostic reporting (PR #135013)

2025-04-09 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/135013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > > I thought CWG's preferred direction on this was to reject entirely? > > > > > > What do they wish to reject? Defining an enum in a different declaration > > context than its primary context? That seems odd. > > Do you have an idea of the CWG DR? We looked but couldn't

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
@@ -1523,7 +1523,10 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // Out-of-line definitions shouldn't be pushed into scope in C++, unless they // are function-local declarations. - if (getLangOpts().CPlusPlus && D->isOutOfLine() && !S->get

[clang] Fix crash with align_value diagnostic reporting (PR #135013)

2025-04-09 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/135013 >From 99190952174f334642ec237596969f9b0c846411 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 9 Apr 2025 09:51:49 -0400 Subject: [PATCH 1/2] Fix crash with align_value diagnostic reporting We were

[clang] Fix crash with align_value diagnostic reporting (PR #135013)

2025-04-09 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Note, I filed an issue about the duplicate diagnostics at https://github.com/llvm/llvm-project/issues/135012 https://github.com/llvm/llvm-project/pull/135013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/134998 Previously, the enumerators were being added both to the class context and to the namespace scope. e.g., we accepted this invalid code: ``` struct A { enum E : int; }; enum A::E : int { e1 = 100

[clang] [clang-tools-extra] [Clang] [Sema] Make -Wreturn-type an error by default (PR #131207)

2025-04-09 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman requested changes to this pull request. My primary concern remains the false positives with the analysis; that means we will be rejecting (a lot of) valid code. I just went through the bug database and resolved ~10 issues as duplicates of https://github.com/llvm

[clang] Reject invalid integer constants in unevaluated preprocessor operands (PR #134884)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/134884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reject invalid integer constants in unevaluated preprocessor operands (PR #134884)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/134884 >From 2661b9381e0a182fb53a81c8bf66cecd51c73b0f Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 8 Apr 2025 13:17:32 -0400 Subject: [PATCH 1/2] Reject invalid integer constants in unevaluated preproc

[clang] Reject invalid integer constants in unevaluated preprocessor operands (PR #134884)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/134884 Clang was previously accepting invalid code like: ``` #if 1 ? 1 : 9 #endif ``` because the integer constant (which is too large to fit into any standard or extended integer type) was

[clang] [clang] consistently quote expressions in diagnostics (PR #134769)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Please be sure to update https://github.com/llvm/llvm-project/blob/46d4c3b1f64dfbca2a029ff30434aaa5248fc190/clang/docs/InternalsManual.rst?plain=1#L227 as well so the new `%quoted` specifier is explicitly documented. https://github.com/llvm/llvm-proje

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/134617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM aside from an 80-col formatting nit, thank you for the fix! https://github.com/llvm/llvm-project/pull/134617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-08 Thread Aaron Ballman via cfe-commits
@@ -1031,6 +1031,8 @@ def err_mainlike_template_decl : Error<"%0 cannot be a template">; def err_main_returns_nonint : Error<"'main' must return 'int'">; def ext_main_returns_nonint : ExtWarn<"return type of 'main' is not 'int'">, InGroup; +def ext_main_no_return : Extensi

[clang] [llvm][Stmt]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)

2025-04-08 Thread Aaron Ballman via cfe-commits
@@ -3134,6 +3134,9 @@ def warn_function_attribute_ignored_in_stmt : Warning< "use '%0' on statements">, InGroup; +def err_musttail_conflicts_with_not_tail_called : Error< AaronBallman wrote: Can we reuse `err_musttail_mismatch` instead? https://github.co

[clang] [llvm][Stmt]:Fix musttail attribute on a function with not_tail_called attribute has no warning/error (PR #134465)

2025-04-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thank you for this! Please be sure to add a release note to `clang/docs/ReleaseNotes.rst` so user know about the fix. https://github.com/llvm/llvm-project/pull/134465 ___ cfe-commits mailing list cfe-commits@

[clang] [Clang][Sema] Fix -Whigher-precision-for-complex-division (PR #131477)

2025-04-08 Thread Aaron Ballman via cfe-commits
=?utf-8?q?Mészáros?= Gergely Message-ID: In-Reply-To: https://github.com/AaronBallman commented: The changes should come with a release note in `clang/docs/ReleaseNotes.rst` so users know about the fix. https://github.com/llvm/llvm-project/pull/131477

[clang] Add more tests for _Countof (PR #133333)

2025-04-08 Thread Aaron Ballman via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} AaronBallman wrote:

[clang] clang_EvalResult_getAsCXString impl (PR #134551)

2025-04-08 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > What are the ABI guarantees of libclang? Won't adding a new field to CXString > break compatibility? That's a great point, it would be an ABI breaking change and we don't want those in libclang: https://github.com/llvm/llvm-project/blob/25e08c0b9cafaab09af35ce6a03317ffd5

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -16232,7 +16232,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, // If the function implicitly returns zero (like 'main') or is naked, // don't complain about missing return statements. - if (FD->hasImplicitReturnZero() || FD->hasAttr()) +

[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][doc]: Merge entries with duplicate content. (PR #134089)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM! What do you think @erichkeane? https://github.com/llvm/llvm-project/pull/134089 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[clang] [clang][doc]: Merge entries with duplicate content. (PR #134089)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Ugh, the issue was on my end. I downloaded the changes, rebuilt the documentation... and skipped the step where I rebuild clang-tblgen. When I do things properly, it works (shocking, I know). https://github.com/llvm/llvm-project/pull/134089 _

[clang] [clang][doc]: Merge entries with duplicate content. (PR #134089)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/134089 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] clang_EvalResult_getAsCXString impl (PR #134551)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -52,6 +54,12 @@ typedef struct { * to `std::string::c_str()`. */ CINDEX_LINKAGE const char *clang_getCString(CXString string); +/** + * This function behaves the same as clang_getCString, except that it also + * returns the size through the length parameter. The length par

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,6 @@ +/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify -pedantic -Wno-strict-prototypes %s + */ + +int main() { AaronBallman wrote: You should also have a test where `main` does return a value to show that we silence the diagnostic, and another test

[clang] [clang][doc]: Merge entries with duplicate content. (PR #134089)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: This is what I'm getting (I applied the patch locally, re-ran clang-tblgen, then re-ran `make html` to make the docs): ![Screenshot 2025-04-07 083145](https://github.com/user-attachments/assets/4749dac5-2f53-479e-9253-7cd1cf2af00c) https://github.com/llvm/llvm-project/pull

[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -11399,6 +11400,22 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, return {}; } +QualType ASTContext::mergeTagTypes(QualType LHS, QualType RHS) { AaronBallman wrote: I'm following the naming convention already used by ot

[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,41 @@ class StmtComparer { }; } // namespace +static bool +CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, + const Decl *D1, const Decl *D2, + const Decl *Prim

[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Ping https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Ping https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -16232,7 +16232,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, // If the function implicitly returns zero (like 'main') or is naked, // don't complain about missing return statements. - if (FD->hasImplicitReturnZero() || FD->hasAttr()) +

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -1031,6 +1031,8 @@ def err_mainlike_template_decl : Error<"%0 cannot be a template">; def err_main_returns_nonint : Error<"'main' must return 'int'">; def ext_main_returns_nonint : ExtWarn<"return type of 'main' is not 'int'">, InGroup; +def ext_main_no_return : Extensi

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thank you for working on this! https://github.com/llvm/llvm-project/pull/134617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -9753,27 +9753,46 @@ def err_operator_new_delete_invalid_result_type : Error< def err_operator_new_delete_dependent_result_type : Error< "%0 cannot have a dependent return type; use %1 instead">; def err_operator_new_delete_too_few_parameters : Error< - "%0 must have at l

[clang] [PowerPC] Update altivec.h to use __inline__ for c89 compatibility (PR #134430)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Thank you for the quick fix to that issue! https://github.com/llvm/llvm-project/pull/134430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,6 @@ +/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify -pedantic -Wno-strict-prototypes %s AaronBallman wrote: Can you also add RUN lines for: `-Wmain-return-type` (enables diagnostic), `-pedantic -Wno-main-return-type` (disables diagnostic), and ``

[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/134617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > @DKLoehr @AaronBallman Did you see the revert? Thank you for the ping, I did not see the revert. Thanks for catching that and sorry for the disruption! Given that this disrupts both LLVM and libc++, I think that's plenty of signal that "on by default" isn't really the be

[clang] clang_EvalResult_getAsCXString impl (PR #134551)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: > 1 Is size_t appropriate here? I see some functions using unsigned, and some > using size_t. I think it's an appropriate type to use (`unsigned` would also be fine, but I tend to prefer `size_t` for this sort of use, personally). > 2 On this new fl

[clang] clang_EvalResult_getAsCXString impl (PR #134551)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -52,6 +54,7 @@ typedef struct { * to `std::string::c_str()`. */ CINDEX_LINKAGE const char *clang_getCString(CXString string); +CINDEX_LINKAGE const char *clang_getCString2(CXString string, size_t *length); AaronBallman wrote: We should document that `leng

[clang] clang_EvalResult_getAsCXString impl (PR #134551)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_C_CXSTRING_H #define LLVM_CLANG_C_CXSTRING_H +#include AaronBallman wrote: Better to put this at the end of the include list; that leaves less chance for those headers to accidentally transitively include stddef.h withou

[clang] clang_EvalResult_getAsCXString impl (PR #134551)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/134551 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -144,3 +177,13 @@ void test_compound_literals() { static_assert(_Countof((int[2]){}) == 2); static_assert(_Countof((int[]){1, 2, 3, 4}) == 4); } + +static int test_f1(); +static int test_f2(); // expected-warning {{never defined}} AaronBallman wrote:

[clang] Add more tests for _Countof (PR #133333)

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -121,10 +150,14 @@ void test_typedefs() { static_assert(_Countof(*x) == 12); } -void test_zero_size_arrays() { +void test_zero_size_arrays(int n) { int array[0]; // expected-warning {{zero size arrays are an extension}} static_assert(_Countof(array) == 0); static

[clang] [clang][doc]: Merge entries with duplicate content. (PR #134089)

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: I thought we decided to merge everything but the undocumented attributes? I'm still seeing `cf_returns_retained` that's distinct from `cf_returns_not_retained`, etc. https://github.com/llvm/llvm-project/pull/134089 ___ cfe-commits

[clang] Correctly diagnose incomplete arrays with static storage in C (PR #134374)

2025-04-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/134374 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 01/11] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Extending this functionality with transformers is optional and can be done > later in another PR, if someone is willing. Yes and no. If the goal is just to write checks, then clang-tidy is a good home for the functionality. But I had the impression that for some people th

[clang] [Clang] Improve subsumption. (PR #132849)

2025-04-05 Thread Aaron Ballman via cfe-commits
@@ -2001,3 +1932,258 @@ NormalizedConstraint::getFoldExpandedConstraint() const { "getFoldExpandedConstraint called on non-fold-expanded constraint."); return cast(Constraint); } + +// +// +// Subsumption ---

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-04-05 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2y -pedantic -Wall -Wno-comment -verify %s + +/* WG14 N3369: Clang 21 + * _Lengthof operator + * + * Adds an operator to get the length of an array. Note that WG14 N3469 renamed + * this operator to _Countof. + */ -

[clang] [Docs] Document freestanding requirements (PR #132232)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/132232 This adds some initial documentation about freestanding requirements for Clang. The most critical part of the documentation is spelling out that a conforming freestanding C Standard Library is required; Cl

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/133472 This feature largely models the same behavior as in C++11. It is technically a breaking change between C99 and C11, so the paper is not being backported to older language modes. One difference between C++

[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/131794 >From 22c4b9d7808df33d3e6a31b3456cd8b2e8a95bfa Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 18 Mar 2025 08:34:18 -0400 Subject: [PATCH 1/7] Suppress pedantic diagnostic for a file not ending in E

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Did WG14 considered some sort of macros for this feature? Otherwise I'd be > tempted to ask you to add something to `__has_feature`. I can see user > wanting to use `_Countof` when available and fallback to something else when > not. There is weak consensus to add `stdco

[clang] [Clang] Improve subsumption. (PR #132849)

2025-04-05 Thread Aaron Ballman via cfe-commits
@@ -170,102 +132,112 @@ struct alignas(ConstraintAlignment) FoldExpandedConstraint { const Expr *Pattern) : Kind(K), Constraint(std::move(C)), Pattern(Pattern) {}; - template - bool subsumes(const FoldExpandedConstraint &Other, -

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/3] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [llvm] Enable unnecessary-virtual-specifier by default (PR #133265)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/133265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thank you for this! It's heading in the right direction. Some things which are still missing are; * a release note in `clang/docs/ReleaseNotes.rst` so users know about the new suffix and macros. * test coverage * `clang/test/Lexer/` should get a tes

[clang] [Clang][NFC] Code cleanup in CGBuiltin.cpp (PR #132060)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/132060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Demote mixed enumeration arithmetic error to a warning (PR #131811)

2025-04-05 Thread Aaron Ballman via cfe-commits
@@ -1,9 +1,10 @@ -// RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -verify -triple %itanium_abi_triple +// RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -verify=both,expected +// RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -verify=both,nowarn -Wno-enum-enum-conversion --

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > So you want this to be a FEATURE in C2y and an EXTENSION in older language > > modes? > > Presumably yes. > > > And when we get the countof macro in a few months, this becomes unnecessary? > > Are most users going to include `stdcountof.h` ? > > My assumption is that

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/3] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133125 >From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 26 Mar 2025 12:54:29 -0400 Subject: [PATCH 1/9] [C2y] Implement WG14 N3369 and N3469 (_Countof) C2y ad

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > Hi, I tried to explain everything here: > > Thanks, I missed that! For RFCs it's preferable to use > [Discourse](https://discourse.llvm.org/c/clang/clang-tidy/71), as there is a > lot less traffic and can more easily catch the eyes of relevant people. I did > not see m

[clang] [C23] Fix compound literals within function prototype (PR #132097)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/132097 >From 7882bfbbe7ada59de91625c5f0365cec1fbe3c5b Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 19 Mar 2025 16:50:12 -0400 Subject: [PATCH 1/2] [C23] Fix compound literals within function prototype

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

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Is there a way to add test coverage for the changes? Also, this should come with a release note so users know about the fix. https://github.com/llvm/llvm-project/pull/121650 ___ cfe-commits mailing list cfe-c

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,20 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +add_clang_library(clangTidyCustomModule STATIC + CustomTidyModule.cpp + QueryCheck.cpp + + LINK_LIBS + clangTidy + clangTidyUtils + + DEPENDS + ClangDriverOptions + ) + +clang_target_link_libraries(clangTidyCust

[clang] [C23] Allow casting from a null pointer constant to nullptr_t (PR #133742)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/133742 C23 allows a cast of a null pointer constant to nullptr_t. e.g., (nullptr_t)0 or (nullptr_t)(void *)0. Fixes #133644 >From 5ad66ec7a9ea76a080ee34ddf0d68a19dbb9dec6 Mon Sep 17 00:00:00 2001 From: Aaron Bal

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,142 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s + +#define AQ __ptrauth

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,212 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c99 -Wno-dangling -emit-llvm -o - %s | FileCheck %s --check-prefix=C99 +// RUN: %clang_cc1 -std=c11 -Wno-dangling -emit-llvm -o - %s |

[clang] [Clang] add emit -Wignored-base-class-qualifiers diagnostic for cv-qualified base classes (PR #132116)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -298,6 +298,8 @@ Improvements to Clang's diagnostics - Improve the ``-Wundefined-func-template`` warning when a function template is not instantiated due to being unreachable in modules. +- Clang now emits a ``-Wignored-base-class-qualifiers`` diagnostic when a base clas

[clang] Improve diagnostic wording for invalid callback attribute uses (PR #134423)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/134423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] [Sema] Allow static assertions in the first part of a `for` loop in C (PR #134415)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/134415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -27,7 +27,7 @@ void testva (int n, ...) { va_start(ap,n); // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4 - // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4 + // CHECK: [[TMP:%[a-z0-9\.]+]] = alloca [4

[clang] Fix the signature for __builtin___clear_cache (PR #134376)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/134376 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Improve diagnostic wording for invalid callback attribute uses (PR #134423)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/134423 We were previously telling the user how many arguments were passed to the attribute rather than saying how many arguments were expected to be passed to the callback function. This rewords the diagnostic to

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -3035,11 +3035,14 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclaration( } ParsedAttributes DeclSpecAttrs(AttrFactory); - MaybeParseMicrosoftAttributes(DeclSpecAttrs); - // Hold late-parsed attributes so we can attach a Decl to them later. LateParsedA

[clang] [clang][doc]: Merge the contents of identical entries. (PR #134089)

2025-04-04 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Hi @AaronBallman, bothering you again. I have a doubt about the merge of the > following case: ![屏幕截图 2025-04-04 > 081652](https://private-user-images.githubusercontent.com/170909871/430177806-ce592ae1-b02a-45bf-aece-55e3a175a01f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -3035,11 +3035,14 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclaration( } ParsedAttributes DeclSpecAttrs(AttrFactory); - MaybeParseMicrosoftAttributes(DeclSpecAttrs); - // Hold late-parsed attributes so we can attach a Decl to them later. LateParsedA

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -71,6 +71,12 @@ namespace test_misplacement { [[]] union union_attr2; //expected-error{{misplaced attributes}} [[]] enum E2 { }; //expected-error{{misplaced attributes}} } +struct S1 { __attribute__((deprecated)) alignas(16) int x; }; // expected-none +class C1 { __attribut

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thanks for the fix! The changes should come with a release note in `clang/docs/ReleaseNotes.rst` so users know about the fix. https://github.com/llvm/llvm-project/pull/133107 ___ cfe-commits mailing list cfe-

[clang] Correctly diagnose incomplete arrays with static storage in C (PR #134374)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -3,16 +3,15 @@ -struct foo; // c-note 5 {{forward declaration of 'struct foo'}} \ +struct foo; // c-note 4 {{forward declaration of 'struct foo'}} \ cxx-note 3 {{forward declaration of 'foo'}} void b; // expected-error {{variable has incomplete type 'v

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -3035,11 +3035,14 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclaration( } ParsedAttributes DeclSpecAttrs(AttrFactory); - MaybeParseMicrosoftAttributes(DeclSpecAttrs); - // Hold late-parsed attributes so we can attach a Decl to them later. LateParsedA

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -296,6 +296,11 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes( goto Retry; } + case tok::kw_alignas: { +ParseAlignmentSpecifier(CXX11Attrs); AaronBallman wrote: I think this means we now quietly accept this code: https://godb

[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/133107 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Correctly diagnose incomplete arrays with static storage in C (PR #134374)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/134374 >From 753208a20b2a4caf6186fa647c4abfef546e5685 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 4 Apr 2025 08:29:55 -0400 Subject: [PATCH 1/2] Correctly diagnose incomplete arrays with static storage

[clang] [C23] Implement WG14 N3037 (PR #132939)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

  1   2   3   4   5   6   7   8   9   10   >