[clang] [clang] Reject incomplete type arguments for __builtin_dump_struct (PR #72749)

2023-11-18 Thread Richard Smith via cfe-commits
@@ -713,6 +713,11 @@ static ExprResult SemaBuiltinDumpStruct(Sema &S, CallExpr *TheCall) { return ExprError(); } const RecordDecl *RD = PtrArgType->getPointeeType()->getAsRecordDecl(); + if (!RD->isCompleteDefinition()) { zygoloid wrote: You need to

[llvm] [clang] [clang-tools-extra] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

2023-11-22 Thread Richard Smith via cfe-commits
@@ -727,6 +729,44 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field, if (hadError || VerifyOnly) { // Do nothing } else if (Init < NumInits) { zygoloid wrote: Hm, right, we still call this with `Init >= NumInits` w

[clang] [clang][AST] Fix printing `TagDecl`s. (PR #69971)

2023-10-30 Thread Richard Smith via cfe-commits
zygoloid wrote: > At this point we either ignore the implicitly generated `TagDecl`, or we can > tweak the attribute printing, so that they are printed even if we only print > the declaration, though when I tried that 10 test cases failed, so I'm not > sure we want to pursue that solution. I

[clang] [clang] Implement constexpr bit_cast for vectors (PR #66894)

2023-10-30 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/66894 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix false positive -Wmissing-field-initializer for anonymous unions (PR #70829)

2023-10-31 Thread Richard Smith via cfe-commits
zygoloid wrote: Thanks for looking into this! I wonder if it would make sense to move the checking for this warning here, to the `else` case in line 725: https://github.com/llvm/llvm-project/blob/ac30780250875802d13450d17e6959f9e2ad3a70/clang/lib/Sema/SemaInit.cpp#L717-L734 That should remove

[clang] [clang] Skip tautological comparison if the comparison involves the 'size_t' type (PR #74427)

2023-12-13 Thread Richard Smith via cfe-commits
zygoloid wrote: I don't think this type-based approach is the right choice. It will lead to a lot of false negatives, and I'm especially concerned that this patch is also dropping warnings for comparisons that just happen to be the same type as `size_t` (eg, direct use of `unsigned long` or `u

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-27 Thread Richard Smith via cfe-commits
zygoloid wrote: I *think* the new map should be unnecessary: `FunctionTemplateDecl` and `VarTemplateDecl` already have a list of specializations that you can walk and check the point of instantiation and template specialization kind to see if there's a pending instantiation. If you want/need

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
zygoloid wrote: > > I _think_ the new map should be unnecessary: `FunctionTemplateDecl` and > > `VarTemplateDecl` already have a list of specializations that you can walk > > and check the point of instantiation and template specialization kind to > > see if there's a pending instantiation. >

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
@@ -6481,6 +6481,33 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) { PendingInstantiations.swap(delayedPCHInstantiations); } +// Instantiate all referenced specializations of the given function template +// definition. This make sure that function template that

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/73463 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks! https://github.com/llvm/llvm-project/pull/73463 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
@@ -4836,6 +4837,16 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot, assert(SemaRef.PendingLocalImplicitInstantiations.empty() && "There are local ones at end of translation unit!"); + // Build a record containing all of pending insta

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
@@ -181,6 +181,9 @@ class ExternalSemaSource : public ExternalASTSource { SmallVectorImpl > &Pending) {} + virtual void ReadPendingOfInstantiationsForConstexprEntity( zygoloid wrote: The "Of" here seems out of place; maybe remove it? You also

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
@@ -6481,6 +6481,33 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) { PendingInstantiations.swap(delayedPCHInstantiations); } +// Instantiate all referenced specializations of the given function template +// definition. This make sure that function template that

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
@@ -8718,6 +8731,18 @@ void ASTReader::ReadPendingInstantiations( PendingInstantiations.clear(); } +void ASTReader::ReadPendingOfInstantiationsForConstexprEntity( +const NamedDecl *D, llvm::SmallSetVector &Decls) { + for (auto *Redecl : D->redecls()) { +DeclID Id =

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-28 Thread Richard Smith via cfe-commits
@@ -6481,6 +6481,33 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) { PendingInstantiations.swap(delayedPCHInstantiations); } +// Instantiate all referenced specializations of the given function template +// definition. This make sure that function template that

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-29 Thread Richard Smith via cfe-commits
@@ -112,6 +112,9 @@ template constexpr int f(T t) { // expected-note {{'f' defined here}} return id(t); // expected-note {{'f' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}} } + + +

[clang] [Clang] Eagerly instantiate used constexpr function upon definition. (PR #73463)

2023-11-29 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thanks! I assume you'll also be looking at the variable case (perhaps as a separate commit)? https://github.com/llvm/llvm-project/pull/73463 ___ cfe-commits mailing list cfe-commits@lists.llvm.or

[llvm] [clang] [clang-tools-extra] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/75456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [llvm] [clang] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-03 Thread Richard Smith via cfe-commits
@@ -640,3 +640,36 @@ namespace PR46637 { template struct Y { T x; }; Y auto> y; // expected-error {{'auto' not allowed in template argument}} } + +namespace GH71015 { + +// Check that there is no error in case a templated function is recursive and +// has a placeholder ret

[clang-tools-extra] [llvm] [clang] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Looks good, thanks! https://github.com/llvm/llvm-project/pull/75456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema] Provide `-fno-/-fvisibility-global-new-delete` option (PR #75364)

2024-01-03 Thread Richard Smith via cfe-commits
zygoloid wrote: How about instead using `-fvisibility-global-new-delete=`? We want a mutually-exclusive set of options here, and we know we want more than two of them, and a flag with an argument value is the way we usually express that. Perhaps we can use values of `force-hidden`, `force-defa

[clang] [Sema] Provide `-fno-/-fvisibility-global-new-delete` option (PR #75364)

2024-01-03 Thread Richard Smith via cfe-commits
zygoloid wrote: To be clear: I didn't mean to suggest that `-fvisibility-global-new-delete=force-hidden` itself would be deprecated. I think supporting it would have low cost and it may be exactly what is desired in some cases, and the previous spelling [has quite a few uses](https://www.goog

[clang-tools-extra] [clang] [llvm] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-04 Thread Richard Smith via cfe-commits
@@ -640,3 +640,36 @@ namespace PR46637 { template struct Y { T x; }; Y auto> y; // expected-error {{'auto' not allowed in template argument}} } + +namespace GH71015 { + +// Check that there is no error in case a templated function is recursive and +// has a placeholder ret

[clang] 5086e05 - Repair tautological condition.

2022-06-29 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-06-29T13:08:40-07:00 New Revision: 5086e05bb0cdeef68b110336dba2fe229be95110 URL: https://github.com/llvm/llvm-project/commit/5086e05bb0cdeef68b110336dba2fe229be95110 DIFF: https://github.com/llvm/llvm-project/commit/5086e05bb0cdeef68b110336dba2fe229be95110.diff

[clang] dcea10c - Fix miscompile with [[no_unique_address]] struct fields.

2022-06-29 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-06-29T13:08:40-07:00 New Revision: dcea10c3c6ac963387e53f918c3616b64cb82e8d URL: https://github.com/llvm/llvm-project/commit/dcea10c3c6ac963387e53f918c3616b64cb82e8d DIFF: https://github.com/llvm/llvm-project/commit/dcea10c3c6ac963387e53f918c3616b64cb82e8d.diff

[clang] f1b0a4f - An expression should only contain an unexpanded parameter pack if it

2022-03-31 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-03-31T20:02:53-07:00 New Revision: f1b0a4fc540f986372f09768c325d505b75b414d URL: https://github.com/llvm/llvm-project/commit/f1b0a4fc540f986372f09768c325d505b75b414d DIFF: https://github.com/llvm/llvm-project/commit/f1b0a4fc540f986372f09768c325d505b75b414d.diff

[clang] 73b62f8 - Fix parsing of comma fold-expressions as the operand of a C-style cast.

2022-08-04 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-08-04T17:08:08-07:00 New Revision: 73b62f813550b602f189afc3a60b0b39ae89f16d URL: https://github.com/llvm/llvm-project/commit/73b62f813550b602f189afc3a60b0b39ae89f16d DIFF: https://github.com/llvm/llvm-project/commit/73b62f813550b602f189afc3a60b0b39ae89f16d.diff

[clang] 836e610 - Revert "[clang] Implement Change scope of lambda trailing-return-type"

2022-04-13 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-13T21:34:08-07:00 New Revision: 836e610d9332772ad4511e86ef126a200f1ab281 URL: https://github.com/llvm/llvm-project/commit/836e610d9332772ad4511e86ef126a200f1ab281 DIFF: https://github.com/llvm/llvm-project/commit/836e610d9332772ad4511e86ef126a200f1ab281.diff

[clang] 64c045e - Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.

2022-04-15 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-15T14:09:45-07:00 New Revision: 64c045e25b8471bbb572bd29159c294a82a86a25 URL: https://github.com/llvm/llvm-project/commit/64c045e25b8471bbb572bd29159c294a82a86a25 DIFF: https://github.com/llvm/llvm-project/commit/64c045e25b8471bbb572bd29159c294a82a86a25.diff

[clang] a571f82 - Update test to handle opaque pointers flag flip.

2022-04-15 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-15T14:51:30-07:00 New Revision: a571f82a50416b767fd3cce0fb5027bb5dfec58c URL: https://github.com/llvm/llvm-project/commit/a571f82a50416b767fd3cce0fb5027bb5dfec58c DIFF: https://github.com/llvm/llvm-project/commit/a571f82a50416b767fd3cce0fb5027bb5dfec58c.diff

[clang] fc30901 - Extend support for std::move etc to also cover std::as_const and

2022-04-15 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-15T16:31:39-07:00 New Revision: fc3090109643af8d2da9822d0f99c84742b9c877 URL: https://github.com/llvm/llvm-project/commit/fc3090109643af8d2da9822d0f99c84742b9c877 DIFF: https://github.com/llvm/llvm-project/commit/fc3090109643af8d2da9822d0f99c84742b9c877.diff

[clang] b27430f - Treat `std::move`, `forward`, etc. as builtins.

2022-04-17 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-17T13:26:16-07:00 New Revision: b27430f9f46b88bcd54d992debc8d72e131e1bd0 URL: https://github.com/llvm/llvm-project/commit/b27430f9f46b88bcd54d992debc8d72e131e1bd0 DIFF: https://github.com/llvm/llvm-project/commit/b27430f9f46b88bcd54d992debc8d72e131e1bd0.diff

[clang-tools-extra] 3eeca52 - Fix wrong signature for std::move and std::swap in test.

2022-04-17 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-17T19:25:20-07:00 New Revision: 3eeca524569744d2927fd13304ab5abb7217e108 URL: https://github.com/llvm/llvm-project/commit/3eeca524569744d2927fd13304ab5abb7217e108 DIFF: https://github.com/llvm/llvm-project/commit/3eeca524569744d2927fd13304ab5abb7217e108.diff

[clang] e43c93d - Don't treat 'T &forward(T&&)' as builtin.

2022-04-18 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-18T11:11:21-07:00 New Revision: e43c93dd63cca295ef26ab69cd305816a71d45fd URL: https://github.com/llvm/llvm-project/commit/e43c93dd63cca295ef26ab69cd305816a71d45fd DIFF: https://github.com/llvm/llvm-project/commit/e43c93dd63cca295ef26ab69cd305816a71d45fd.diff

[clang] 63814be - [modules] Merge variable template specializations.

2022-04-19 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-19T14:48:42-07:00 New Revision: 63814be4fa23ef9b36cf2d14388c7f6ba591d3b6 URL: https://github.com/llvm/llvm-project/commit/63814be4fa23ef9b36cf2d14388c7f6ba591d3b6 DIFF: https://github.com/llvm/llvm-project/commit/63814be4fa23ef9b36cf2d14388c7f6ba591d3b6.diff

[clang] 72315d0 - Treat `std::move`, `forward`, etc. as builtins.

2022-04-20 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-20T17:58:31-07:00 New Revision: 72315d02c432a0fe0acae9c96c69eac8d8e1a9f6 URL: https://github.com/llvm/llvm-project/commit/72315d02c432a0fe0acae9c96c69eac8d8e1a9f6 DIFF: https://github.com/llvm/llvm-project/commit/72315d02c432a0fe0acae9c96c69eac8d8e1a9f6.diff

[clang] f6a5ab6 - Use builtin recognition to detect std::move / std::forward.

2022-04-21 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-04-21T14:21:07-07:00 New Revision: f6a5ab6c8c316fa4f60e40030586e230920a63ea URL: https://github.com/llvm/llvm-project/commit/f6a5ab6c8c316fa4f60e40030586e230920a63ea DIFF: https://github.com/llvm/llvm-project/commit/f6a5ab6c8c316fa4f60e40030586e230920a63ea.diff

[clang] 30baa5d - PR45879: Fix assert when constant evaluating union assignment.

2022-02-02 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-02-02T17:02:47-08:00 New Revision: 30baa5d2a450d5e302d8cba3fc7a26a59d4b7ae1 URL: https://github.com/llvm/llvm-project/commit/30baa5d2a450d5e302d8cba3fc7a26a59d4b7ae1 DIFF: https://github.com/llvm/llvm-project/commit/30baa5d2a450d5e302d8cba3fc7a26a59d4b7ae1.diff

[clang] 19aa2db - [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-02 Thread Richard Smith via cfe-commits
Author: Devin Jeanpierre Date: 2022-02-02T17:42:20-08:00 New Revision: 19aa2db023c0128913da223d4fb02c474541ee22 URL: https://github.com/llvm/llvm-project/commit/19aa2db023c0128913da223d4fb02c474541ee22 DIFF: https://github.com/llvm/llvm-project/commit/19aa2db023c0128913da223d4fb02c474541ee22.di

[clang] dc8f4e1 - [cxx_status] Add a couple of Feb 2022 library papers that need compiler support.

2022-02-08 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-02-08T17:25:52-08:00 New Revision: dc8f4e118d92982ff5f6316fe7d541d120ebabd1 URL: https://github.com/llvm/llvm-project/commit/dc8f4e118d92982ff5f6316fe7d541d120ebabd1 DIFF: https://github.com/llvm/llvm-project/commit/dc8f4e118d92982ff5f6316fe7d541d120ebabd1.diff

[clang] 13b6f31 - Fix crash when deserializing a lambda expression in a decltype.

2022-02-15 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-02-15T17:56:45-08:00 New Revision: 13b6f31548784452990da6dba555af8d7a061958 URL: https://github.com/llvm/llvm-project/commit/13b6f31548784452990da6dba555af8d7a061958 DIFF: https://github.com/llvm/llvm-project/commit/13b6f31548784452990da6dba555af8d7a061958.diff

[clang] c7ecfad - Fix some places where PseudoObjectExpr handling assumed that a

2022-05-03 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-05-03T11:55:14-07:00 New Revision: c7ecfadf9beb936e5101db4362dd2935d415b04d URL: https://github.com/llvm/llvm-project/commit/c7ecfadf9beb936e5101db4362dd2935d415b04d DIFF: https://github.com/llvm/llvm-project/commit/c7ecfadf9beb936e5101db4362dd2935d415b04d.diff

[clang] c2572d8 - [docs] Add blank lines to help Sphinx parse nested bullets.

2022-05-05 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-05-05T15:58:26-07:00 New Revision: c2572d8b1fccffcc5dd7b900cf3c4cfa07df3b50 URL: https://github.com/llvm/llvm-project/commit/c2572d8b1fccffcc5dd7b900cf3c4cfa07df3b50 DIFF: https://github.com/llvm/llvm-project/commit/c2572d8b1fccffcc5dd7b900cf3c4cfa07df3b50.diff

[clang] f6c7493 - [docs] Fix uses of `foo` that should be ``foo`` throughout release notes.

2022-05-05 Thread Richard Smith via cfe-commits
Author: Richard Smith Date: 2022-05-05T16:04:19-07:00 New Revision: f6c74932b59619aa1a680caa7c4b78d4d29c2877 URL: https://github.com/llvm/llvm-project/commit/f6c74932b59619aa1a680caa7c4b78d4d29c2877 DIFF: https://github.com/llvm/llvm-project/commit/f6c74932b59619aa1a680caa7c4b78d4d29c2877.diff

[clang] [HLSL] Implement array temporary support (PR #79382)

2024-03-13 Thread Richard Smith via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() == DependentS

[clang] [codegen] Emit missing cleanups for stmt-expr and coro suspensions [take-2] (PR #85398)

2024-03-26 Thread Richard Smith via cfe-commits
@@ -2503,6 +2506,29 @@ Stmt *BlockExpr::getBody() { // Generic Expression Routines //===--===// +bool Expr::mayBranchOut() const { zygoloid wrote: Computing this seems a little expensive in

[clang] [clang][ExprConst] Fix second arg of __builtin_{clzg,ctzg} not always being evaluated (PR #86742)

2024-03-26 Thread Richard Smith via cfe-commits
@@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics + +constexpr int increment(int& x) { + x++; + return x; +} + +constexpr int test_clzg_0() { + int x = 0; + [[maybe_unused]] int unused = __builtin_clzg(0U, increment(x)); + return x; +}

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-27 Thread Richard Smith via cfe-commits
zygoloid wrote: I don't think we've established an explicit policy, and we've made ABI-breaking changes previously. I think we should avoid breaks within a major release version (don't backport this) to avoid giving packagers headaches: the ubsan runtime is installed in a versioned directory,

[clang] Resolve FIXME: Look at E, not M (PR #85541)

2024-03-29 Thread Richard Smith via cfe-commits
zygoloid wrote: IIRC the issue here is that in C++98, the MTE is in a "weird" place in the AST, because of the different rules governing how and when temporaries are formed. For example, for `const int &r = C().a[0];`, we'll form an MTE wrapping just the `C()` expression, converting it to an x

[clang] [BitInt] Expose a _BitInt literal suffix in C++ (PR #86586)

2024-04-01 Thread Richard Smith via cfe-commits
@@ -1117,19 +1118,37 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, if (isImaginary) break; // Cannot be repeated. isImaginary = true; continue; // Success. +case '_': + if (isFPConstant) +break; // Invalid for floats

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-05 Thread Richard Smith via cfe-commits
zygoloid wrote: > +1 for this, it will be the 95%/5% rule, you might think all cases of > (identifier) is a cast, but I'm pretty sure it won't be Specifically, what I suggested was: when disambiguating whether `(identifier)&...` or `(identifier)*...` is a cast vs a multiplication or bitwise a

[clang] [clang][test] Add test for incompatible cv-qualified reference types in conversion function template (PR #81950)

2024-03-05 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/81950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][test] Add test for incompatible cv-qualified reference types in conversion function template (PR #81950)

2024-03-06 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/81950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/75481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Generally this looks good to me, thanks. https://github.com/llvm/llvm-project/pull/75481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
@@ -4564,15 +4737,41 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) { case Qualifiers::OCL_None: // __block variables need to have the rhs evaluated first, plus // this should improve codegen just a little. -RHS = Visit(E->getRHS()); +Va

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
@@ -5571,11 +5571,50 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { break; } -RValue RV = EmitAnyExpr(E->getRHS()); +llvm::Value *Previous = nullptr; +RValue RV; +QualType SrcType = E->getRHS()->getType(); +// Chec

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
@@ -5571,11 +5571,50 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { break; } -RValue RV = EmitAnyExpr(E->getRHS()); +llvm::Value *Previous = nullptr; +RValue RV; +QualType SrcType = E->getRHS()->getType(); +// Chec

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
@@ -5571,11 +5571,50 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { break; } -RValue RV = EmitAnyExpr(E->getRHS()); +llvm::Value *Previous = nullptr; +RValue RV; +QualType SrcType = E->getRHS()->getType(); +// Chec

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
@@ -5571,11 +5571,50 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { break; } -RValue RV = EmitAnyExpr(E->getRHS()); +llvm::Value *Previous = nullptr; +RValue RV; +QualType SrcType = E->getRHS()->getType(); +// Chec

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
@@ -555,13 +555,11 @@ static void handleImplicitConversion(ImplicitConversionData *Data, ReportOptions Opts, ValueHandle Src, ValueHandle Dst) { SourceLocation Loc = Data->Loc.acquire(); - ErrorType E

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-08 Thread Richard Smith via cfe-commits
zygoloid wrote: > I'm not opposed to the changes, though I do find it somewhat strange to add > them to UBSan given that they're not undefined behavior (even though there's > precedent). This is adding checks to `-fsanitize=implicit-conversion`, which is not part of `-fsanitize=undefined`. It

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -555,13 +555,11 @@ static void handleImplicitConversion(ImplicitConversionData *Data, ReportOptions Opts, ValueHandle Src, ValueHandle Dst) { SourceLocation Loc = Data->Loc.acquire(); - ErrorType E

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Looks good to me. @AaronBallman Did you have remaining concerns here? https://github.com/llvm/llvm-project/pull/75481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/75481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [clang][UBSan] Add implicit conversion check for bitfields (PR #75481)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -5571,11 +5571,52 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { break; } -RValue RV = EmitAnyExpr(E->getRHS()); +llvm::Value *Previous = nullptr; +RValue RV; +QualType SrcType = E->getRHS()->getType(); +// Chec

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -26996,18 +26996,38 @@ class, structure, array, or other object. Arguments: "" -The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a -pointer to or into the ``object``. The second argument determines whether -``llvm.objectsize`` returns 0

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -1052,11 +1053,143 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// SubobjectFinder - A simple visitor to find the "sub-object" pointed to b

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -1052,11 +1053,143 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// SubobjectFinder - A simple visitor to find the "sub-object" pointed to b

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -1052,11 +1053,143 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// SubobjectFinder - A simple visitor to find the "sub-object" pointed to b

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -1052,11 +1053,143 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// SubobjectFinder - A simple visitor to find the "sub-object" pointed to b

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-11 Thread Richard Smith via cfe-commits
@@ -1052,11 +1053,143 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// SubobjectFinder - A simple visitor to find the "sub-object" pointed to b

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-12 Thread Richard Smith via cfe-commits
@@ -26996,18 +26996,38 @@ class, structure, array, or other object. Arguments: "" -The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a -pointer to or into the ``object``. The second argument determines whether -``llvm.objectsize`` returns 0

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-12 Thread Richard Smith via cfe-commits
@@ -26996,18 +26996,38 @@ class, structure, array, or other object. Arguments: "" -The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a -pointer to or into the ``object``. The second argument determines whether -``llvm.objectsize`` returns 0

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-12 Thread Richard Smith via cfe-commits
@@ -26996,18 +26996,38 @@ class, structure, array, or other object. Arguments: "" -The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a -pointer to or into the ``object``. The second argument determines whether -``llvm.objectsize`` returns 0

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-12 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/83204 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-03-12 Thread Richard Smith via cfe-commits
@@ -26996,18 +26996,38 @@ class, structure, array, or other object. Arguments: "" -The ``llvm.objectsize`` intrinsic takes four arguments. The first argument is a -pointer to or into the ``object``. The second argument determines whether -``llvm.objectsize`` returns 0

[clang] [HLSL] Implement array temporary support (PR #79382)

2024-03-12 Thread Richard Smith via cfe-commits
@@ -3173,41 +3174,46 @@ class ArrayType : public Type, public llvm::FoldingSetNode { return T->getTypeClass() == ConstantArray || T->getTypeClass() == VariableArray || T->getTypeClass() == IncompleteArray || - T->getTypeClass() == DependentS

[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

2024-02-23 Thread Richard Smith via cfe-commits
@@ -896,6 +896,12 @@ def Launder : Builtin { let Prototype = "void*(void*)"; } +def StartObjectLifeTime : Builtin { zygoloid wrote: Nit: lifetime is one word not two, so the `T` should not be capitalized. https://github.com/llvm/llvm-project/pull/82776 ___

[clang] [clang] Sequence C++20 Parenthesized List Init (PR #83476)

2024-02-29 Thread Richard Smith via cfe-commits
@@ -17626,6 +17626,25 @@ class SequenceChecker : public ConstEvaluatedExprVisitor { for (unsigned I = 0; I < Elts.size(); ++I) Tree.merge(Elts[I]); } + + void VisitCXXParenListInitExpr(const CXXParenListInitExpr *PLIE) { +// C++20 parenthesized list initializa

[clang] [clang] Sequence C++20 Parenthesized List Init (PR #83476)

2024-02-29 Thread Richard Smith via cfe-commits
@@ -17626,6 +17626,25 @@ class SequenceChecker : public ConstEvaluatedExprVisitor { for (unsigned I = 0; I < Elts.size(); ++I) Tree.merge(Elts[I]); } + + void VisitCXXParenListInitExpr(const CXXParenListInitExpr *PLIE) { +// C++20 parenthesized list initializa

[clang] [clang] Sequence C++20 Parenthesized List Init (PR #83476)

2024-02-29 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/83476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Sequence C++20 Parenthesized List Init (PR #83476)

2024-02-29 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks! [I'm not sure when I'll have time to circle back to this, so I'd be happy for someone else to finish the review and approve.] https://github.com/llvm/llvm-project/pull/83476 ___ cfe-commits mailing list

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", zygoloid wrote: Does `byte`

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -66,13 +72,17 @@ bool FormatToken::isSimpleTypeSpecifier() const { case tok::kw_decltype: case tok::kw__Atomic: return true; + case tok::identifier: +return IsCpp && std::binary_search(CppNonKeywordTypes.begin(), + CppNonKey

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
zygoloid wrote: Another possibility to consider for the original bug: `(single_identifier)` is almost certainly a cast, not redundant parentheses, unless `single_identifier` names a macro argument. So I wonder if that would be a better heuristic to use to fix the regression. https://github.co

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
zygoloid wrote: > > Another possibility to consider for the original bug: `(single_identifier)` > > is almost certainly a cast, not redundant parentheses, unless > > `single_identifier` names a macro argument. So I wonder if that would be a > > better heuristic to use to fix the regression. >

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
zygoloid wrote: > This patch does not only fix formatting of C-casting to a C++ standard type. > It correctly identifies (most of) such types and might have fixed other kinds > of bugs. Sure, this patch seems like a good change. But it does not fix #83400. https://github.com/llvm/llvm-project

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/83709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-04 Thread Richard Smith via cfe-commits
zygoloid wrote: > It does fix the example given. #83400 has 6 real-world examples. This patch fixes none of them. It also has a reduced testcase, which this patch does fix. But fixing the reduced testcase without fixing the real-world examples is not fixing the bug. https://github.com/llvm/l

[llvm] [clang] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #78526)

2024-01-30 Thread Richard Smith via cfe-commits
zygoloid wrote: It might be academic at this point, but for what it's worth, `__builtin_dynamic_object_size` is not a GCC builtin that clang copied, it's [a clang builtin](https://reviews.llvm.org/D56760) that GCC copied. https://github.com/llvm/llvm-project/pull/78526

[clang] [Clang] Convert __builtin_dynamic_object_size into a calculation (PR #80256)

2024-02-01 Thread Richard Smith via cfe-commits
@@ -1051,6 +1052,145 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// \p StructBaseExpr returns the base \p Expr with a structure or union type

[clang] [Clang] Convert __builtin_dynamic_object_size into a calculation (PR #80256)

2024-02-01 Thread Richard Smith via cfe-commits
@@ -1051,6 +1052,145 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +/// \p StructBaseExpr returns the base \p Expr with a structure or union type

<    6   7   8   9   10   11   12   13   14   15   >