[clang] [Clang][Sema] Ensure that the selected candidate for a member function explicit specialization is more constrained than all others (PR #101721)

2024-08-02 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Changes to the algorithm for selecting the most constrained function look correct. It's not clear to me whether it's correct to stop calling `CheckMemberSpecialization` for member templates, though -- do we still do the necessary checks somewhere else?

[clang] [Clang][Sema] Ensure that the selected candidate for a member function explicit specialization is more constrained than all others (PR #101721)

2024-08-02 Thread Richard Smith via cfe-commits
@@ -7964,8 +7964,9 @@ NamedDecl *Sema::ActOnVariableDeclarator( D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous)); } else { // If this is an explicit specialization of a static data member, check it. -if (IsMemberSpecialization &&

[clang] [Clang][Sema] Ensure that the selected candidate for a member function explicit specialization is more constrained than all others (PR #101721)

2024-08-02 Thread Richard Smith via cfe-commits
@@ -10465,7 +10466,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , DeclContext *DC, Previous)) NewFD->setInvalidDecl(); } -} else if (isMemberSpecialization && isa(NewFD)) { +} else if

[clang] [Clang][Sema] Ensure that the selected candidate for a member function explicit specialization is more constrained than all others (PR #101721)

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

[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

2024-07-31 Thread Richard Smith via cfe-commits
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult ) { Priority); } +bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) { + assert(Tok.is(tok::coloncolon)); + Sema::DisableTypoCorrectionRAII DTC(Actions); +

[clang] [clang][CUDA] Add 'noconvergent' function and statement attribute (PR #100637)

2024-07-31 Thread Richard Smith via cfe-commits
zygoloid wrote: > Please also update the documentation for the attribute and the release notes. It looks like you may have overlooked the request to add release notes for this new feature. https://github.com/llvm/llvm-project/pull/100637 ___

[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

2024-07-30 Thread Richard Smith via cfe-commits
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult ) { Priority); } +bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) { + assert(Tok.is(tok::coloncolon)); + Sema::DisableTypoCorrectionRAII DTC(Actions); +

[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

2024-07-30 Thread Richard Smith via cfe-commits
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult ) { Priority); } +bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) { + assert(Tok.is(tok::coloncolon)); + Sema::DisableTypoCorrectionRAII DTC(Actions); +

[clang] [C] Disable use of NRVO (PR #101038)

2024-07-30 Thread Richard Smith via cfe-commits
zygoloid wrote: I think `__attribute__((cleanup))` on a variable should disable NRVO on that variable, in both C and in C++. [GCC's behavior](https://godbolt.org/z/Psbbr83ET) is to ignore the `cleanup` attribute entirely if NRVO is applied to the variable, which seems like a flawed approach,

[clang] [C] Disable use of NRVO (PR #101038)

2024-07-29 Thread Richard Smith via cfe-commits
zygoloid wrote: > Typically, the absence of a statement must be interpreted as a lack of a > guarantee. In this case, however, I would argue it is more plausible to infer > that the ABI authors did not consider the possibility of passing a pointer to > aliased memory for the return value, and

[clang] [C] Disable use of NRVO (PR #101038)

2024-07-29 Thread Richard Smith via cfe-commits
zygoloid wrote: > Richard, I'm sorry to contradict you, but Aaron is correct to guess that this > is ABI-affecting: ABIs should and sometimes do specify whether an indirect > return address is allowed to be aliased. My claim was narrowly that the choice to perform or not perform NRVO for an

[clang] [C] Disable use of NRVO (PR #101038)

2024-07-29 Thread Richard Smith via cfe-commits
zygoloid wrote: NRVO vs not-NRVO is not an ABI difference, just a behavior difference -- it doesn't change the calling convention, and different choices here are link-compatible (in C++ we can make different choices for different emissions of the same inline function even). This is also not

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -5399,11 +5434,85 @@ static QualType GetImplicitObjectParameterType(ASTContext , return Context.getLValueReferenceType(RawType); } +static TemplateDeductionResult FinishTemplateArgumentDeduction( +Sema , FunctionTemplateDecl *FTD, int ArgIdx, QualType P, QualType A,

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -30,98 +30,27 @@ class basic_string_view { constexpr basic_string_view =(const basic_string_view &) {} }; -template -constexpr bool operator<(basic_string_view, basic_string_view) { - return {}; -} -template -constexpr bool operator<(type_identity_t>, -

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -5399,11 +5434,85 @@ static QualType GetImplicitObjectParameterType(ASTContext , return Context.getLValueReferenceType(RawType); } +static TemplateDeductionResult FinishTemplateArgumentDeduction( +Sema , FunctionTemplateDecl *FTD, int ArgIdx, QualType P, QualType A,

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -859,8 +861,10 @@ class PackDeductionScope { // by this pack expansion, then clear out the deduction. DeducedFromEarlierParameter = !Deduced[Index].isNull(); DeducedPack Pack(Index); -Pack.Saved = Deduced[Index]; -Deduced[Index] = TemplateArgument(); +

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -5399,11 +5434,85 @@ static QualType GetImplicitObjectParameterType(ASTContext , return Context.getLValueReferenceType(RawType); } +static TemplateDeductionResult FinishTemplateArgumentDeduction( +Sema , FunctionTemplateDecl *FTD, int ArgIdx, QualType P, QualType A,

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -5346,7 +5346,6 @@ static EvalStmtResult EvaluateStmt(StmtResult , EvalInfo , const Expr *RetExpr = cast(S)->getRetValue(); FullExpressionRAII Scope(Info); if (RetExpr && RetExpr->isValueDependent()) { - EvaluateDependentExpr(RetExpr, Info);

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
@@ -5425,34 +5534,112 @@ static bool isAtLeastAsSpecializedAs(Sema , SourceLocation Loc, // the partial ordering is done: TemplateDeductionInfo Info(Loc); switch (TPOC) { - case TPOC_Call: + case TPOC_Call: { if (DeduceTemplateArguments(S, TemplateParams,

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

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

[clang] [clang-tools-extra] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-26 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks! https://github.com/llvm/llvm-project/pull/100692 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Richard Smith via cfe-commits
@@ -6848,6 +6848,14 @@ CXXRecordMembersNamed(StringRef Name, Sema , QualType Ty) { return Results; } +QualType Sema::getTypeMember(QualType Type, StringRef Name) { + auto Results = CXXRecordMembersNamed(Name, *this, Type); + assert(Results.size() <= 1); + if

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Richard Smith via cfe-commits
@@ -3058,6 +3058,133 @@ void Sema::NoteAllFoundTemplates(TemplateName Name) { } } +static QualType commonTypeImpl(Sema , TemplateName BaseTemplate, + SourceLocation TemplateLoc, + ArrayRef Ts) { + auto

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: How much of a performance difference are you measuring with this change? https://github.com/llvm/llvm-project/pull/99473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

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

[clang] [clang] Allow 'convergent' to be a statement attribute (PR #100637)

2024-07-25 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Seems logical and useful to me. This PR will need more tests: specifically, please make sure you have test coverage for the diagnostic, and for LLVM IR generation for both convergent calls and convergent inline asm. Please also update the documentation

[clang] [clang][DebugInfo] Don't mark structured bindings as artificial (PR #100355)

2024-07-24 Thread Richard Smith via cfe-commits
zygoloid wrote: It looks like this is working for all other kinds of structured binding because `EmitDeclare(BindingDecl*, ...)` emits a proper `DILocalVariable` for them. But it skips `BindingDecl`s that have a holding variable for some reason. Perhaps a cleaner approach would be to make it

[clang] Fix assertion failure during conversion function overload resolution. (PR #98671)

2024-07-24 Thread Richard Smith via cfe-commits
@@ -5824,12 +5824,23 @@ FunctionDecl *Sema::getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2) { assert(!FD1->getDescribedTemplate() && !FD2->getDescribedTemplate() && "not for function templates"); -

[clang] Fix assertion failure during conversion function overload resolution. (PR #98671)

2024-07-24 Thread Richard Smith via cfe-commits
zygoloid wrote: Hmm. See https://lists.isocpp.org/core/2024/06/15952.php -- I think we should never be comparing constraints between functions whose signatures aren't otherwise the same, and in particular we should never compare the constraints of a conversion function template against the

[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)

2024-07-24 Thread Richard Smith via cfe-commits
@@ -10339,24 +10339,53 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult ) { if (Previous.empty()) { // Nowhere to look anyway. } else if (FunctionDecl *Function = dyn_cast(Member)) { +SmallVector Candidates; +bool Ambiguous = false; for

[clang] [NVPTX] Restore old va_list builtin type (PR #100438)

2024-07-24 Thread Richard Smith via cfe-commits
zygoloid wrote: Are we also missing the test coverage that would have caught the regression? https://github.com/llvm/llvm-project/pull/100438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][headers] Including stddef.h always redefines NULL (PR #99727)

2024-07-22 Thread Richard Smith via cfe-commits
@@ -49,7 +48,24 @@ #define __need_rsize_t #endif #define __need_wchar_t +#if !defined(__STDDEF_H) || __has_feature(modules) +/* + * __stddef_null.h is special when building without modules: if __need_NULL is + * set, then it will unconditionally redefine NULL. To avoid

[clang] [clang][headers] Including stddef.h always redefines NULL (PR #99727)

2024-07-22 Thread Richard Smith via cfe-commits
@@ -49,7 +48,24 @@ #define __need_rsize_t #endif #define __need_wchar_t +#if !defined(__STDDEF_H) || __has_feature(modules) +/* + * __stddef_null.h is special when building without modules: if __need_NULL is + * set, then it will unconditionally redefine NULL. To avoid

[clang] [clang][headers] Including stddef.h always redefines NULL (PR #99727)

2024-07-22 Thread Richard Smith via cfe-commits
@@ -49,7 +48,24 @@ #define __need_rsize_t #endif #define __need_wchar_t +#if !defined(__STDDEF_H) || __has_feature(modules) +/* + * __stddef_null.h is special when building without modules: if __need_NULL is + * set, then it will unconditionally redefine NULL. To avoid

[clang] [clang][headers] Including stddef.h always redefines NULL (PR #99727)

2024-07-19 Thread Richard Smith via cfe-commits
@@ -49,7 +48,25 @@ #define __need_rsize_t #endif #define __need_wchar_t +#if !defined(__STDDEF_H) && !__building_module(_Builtin_stddef) zygoloid wrote: I'm not sure that the second condition here makes any difference: I'd think the only way we could get

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Richard Smith via cfe-commits
zygoloid wrote: As noted in one of the inline comments, it doesn't seem good to be losing a diagnostic for ill-formed code. But this all makes sense to me as a step to make our behavior more consistent. I wonder if it'd make sense to make our folding behavior stricter by default as a

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

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

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Richard Smith via cfe-commits
@@ -2849,19 +2849,23 @@ static bool handleIntIntBinOp(EvalInfo , const BinaryOperator *E, if (SA != RHS) { Info.CCEDiag(E, diag::note_constexpr_large_shift) << RHS << E->getType() << LHS.getBitWidth(); + if (!Info.noteUndefinedBehavior()) +

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Richard Smith via cfe-commits
@@ -200,14 +200,7 @@ namespace LongInt { }; enum shiftof { -X = (1<<-29), // all-error {{expression is not an integral constant expression}} \ - // all-note {{negative shift count -29}} - -X2 = (-1<<29), // cxx17-error {{expression is not an integral

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Richard Smith via cfe-commits
@@ -142,7 +142,7 @@ constexpr int arb(int n) { // expected-note {{declared here}} expected-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} } constexpr long Overflow[(1 << 30) << 2]{}; // expected-warning {{requires 34

[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

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

[clang] Fix compatibility version in test (PR #97128)

2024-06-28 Thread Richard Smith via cfe-commits
https://github.com/zygoloid created https://github.com/llvm/llvm-project/pull/97128 The mangling compatibility being tested here changed between Clang 17 and 18, not between 16 and 17, so change the "old" version to 17. As requested by @ahatanak in [post-commit

[clang] [C11] Generic selection expressions and qualified rvalues (PR #96913)

2024-06-27 Thread Richard Smith via cfe-commits
zygoloid wrote: > Discussion on the WG14 reflectors suggested that the qualifiers should still > be stripped from the type of the controlling expression; the standard should > be corrected to make this more clear. Does WG14 think we're right to produce a qualified rvalue in this case? Another

[clang] Add documentation for `__builtin_object_size`. (PR #96573)

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

[clang] Add documentation for `__builtin_object_size`. (PR #96573)

2024-06-26 Thread Richard Smith via cfe-commits
zygoloid wrote: > I have a question about the "sub-object" part. Do we attempt to discover the > sub-object past any casting? Good question. I'm going to merge this PR, so I've filed #96737 for this ongoing discussion. https://github.com/llvm/llvm-project/pull/96573

[clang] Fix codegen of consteval functions returning an empty class, and related issues (PR #93115)

2024-06-25 Thread Richard Smith via cfe-commits
@@ -1336,75 +1336,56 @@ static llvm::Value *CreateCoercedLoad(Address Src, llvm::Type *Ty, return CGF.Builder.CreateLoad(Tmp); } -// Function to store a first-class aggregate into memory. We prefer to -// store the elements rather than the aggregate to be more friendly to

[clang] [clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854) (PR #96301)

2024-06-25 Thread Richard Smith via cfe-commits
@@ -1392,7 +1392,8 @@ class CXXRecordDecl : public RecordDecl { bool allowConstDefaultInit() const { return !data().HasUninitializedFields || !(data().HasDefaultedDefaultConstructor || - needsImplicitDefaultConstructor()); +

[clang] Fix codegen of consteval functions returning an empty class, and related issues (PR #93115)

2024-06-25 Thread Richard Smith via cfe-commits
@@ -4772,7 +4772,8 @@ class CodeGenFunction : public CodeGenTypeCache { /// Build all the stores needed to initialize an aggregate at Dest with the /// value Val. zygoloid wrote: This comment looks out of date.

[clang] Fix codegen of consteval functions returning an empty class, and related issues (PR #93115)

2024-06-25 Thread Richard Smith via cfe-commits
@@ -1336,75 +1336,56 @@ static llvm::Value *CreateCoercedLoad(Address Src, llvm::Type *Ty, return CGF.Builder.CreateLoad(Tmp); } -// Function to store a first-class aggregate into memory. We prefer to -// store the elements rather than the aggregate to be more friendly to

[clang] Fix codegen of consteval functions returning an empty class, and related issues (PR #93115)

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

[clang] Fix codegen of consteval functions returning an empty class, and related issues (PR #93115)

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

[clang] Add documentation for `__builtin_object_size`. (PR #96573)

2024-06-25 Thread Richard Smith via cfe-commits
https://github.com/zygoloid updated https://github.com/llvm/llvm-project/pull/96573 >From 3394d999888087535db9ede87668829eddc33ac7 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 24 Jun 2024 15:52:18 -0700 Subject: [PATCH 1/2] Add documentation for `__builtin_object_size`. Explicitly

[clang] Add documentation for `__builtin_object_size`. (PR #96573)

2024-06-25 Thread Richard Smith via cfe-commits
@@ -5368,16 +5368,85 @@ The ``#pragma comment(lib, ...)`` directive is supported on all ELF targets. The second parameter is the library name (without the traditional Unix prefix of ``lib``). This allows you to provide an implicit link of dependent libraries. -Evaluating

[clang] Add documentation for `__builtin_object_size`. (PR #96573)

2024-06-24 Thread Richard Smith via cfe-commits
https://github.com/zygoloid created https://github.com/llvm/llvm-project/pull/96573 Explicitly describe how the Clang builtin works, given that it's not exactly the same as GCC's builtin of the same name -- but is drop-in compatible. Fixes #95635. >From

[clang] [clang] Allow class with anonymous union member to be const-default-constructible even if a union member has a default member initializer (#95854) (PR #96301)

2024-06-21 Thread Richard Smith via cfe-commits
@@ -1392,7 +1392,8 @@ class CXXRecordDecl : public RecordDecl { bool allowConstDefaultInit() const { return !data().HasUninitializedFields || !(data().HasDefaultedDefaultConstructor || - needsImplicitDefaultConstructor()); +

[clang] [Clang] Fix parsing of reversible type traits in template arguments (PR #95969)

2024-06-20 Thread Richard Smith via cfe-commits
@@ -141,3 +141,15 @@ namespace r360308_regression { return a == b; } } + +namespace GH95598 { +template +struct __is_pointer {}; +// expected-warning@-1 {{keyword '__is_pointer' will be made available as an identifier for the remainder of the translation unit}}

[clang] [Clang] Fix parsing of reversible type traits in template arguments (PR #95969)

2024-06-18 Thread Richard Smith via cfe-commits
@@ -141,3 +141,15 @@ namespace r360308_regression { return a == b; } } + +namespace GH95598 { +template +struct __is_pointer {}; +// expected-warning@-1 {{keyword '__is_pointer' will be made available as an identifier for the remainder of the translation unit}}

[clang] [Clang] Fix parsing of reversible type traits in template arguments (PR #95969)

2024-06-18 Thread Richard Smith via cfe-commits
@@ -141,3 +141,15 @@ namespace r360308_regression { return a == b; } } + +namespace GH95598 { +template +struct __is_pointer {}; +// expected-warning@-1 {{keyword '__is_pointer' will be made available as an identifier for the remainder of the translation unit}}

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
zygoloid wrote: Perhaps we can start by supplying `CheckForModifiableLvalue` with extra information about *why* we're doing the check. The current diagnostic we get for incrementing a non-modifiable lvalue: ```console :2:3: error: cannot assign to variable 'n' with const-qualified type 'const

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
@@ -13273,6 +13273,23 @@ enum { ConstUnknown, // Keep as last element }; +static void MaybeSuggestDerefFixIt(Sema , const Expr *E, SourceLocation Loc) { + ExprResult Deref; + Expr *TE = const_cast(E); + { +Sema::TentativeAnalysisScope Trap(S); +Deref =

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
@@ -65,8 +65,10 @@ void test4(void) { void test5(int *X, float *P) { (float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} + // expected-note@-1 {{add '*' to dereference it}} zygoloid wrote: This is a

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s + +struct S { + void f() { +++this; // expected-error {{expression is not assignable}} +// expected-note@-1 {{add '*' to dereference it}} + } + + void g() const { +++this; // expected-error

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
@@ -13273,6 +13273,23 @@ enum { ConstUnknown, // Keep as last element }; +static void MaybeSuggestDerefFixIt(Sema , const Expr *E, SourceLocation Loc) { + ExprResult Deref; + Expr *TE = const_cast(E); + { +Sema::TentativeAnalysisScope Trap(S); +Deref =

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
@@ -65,8 +65,10 @@ void test4(void) { void test5(int *X, float *P) { (float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}} + // expected-note@-1 {{add '*' to dereference it}} #define FOO ((float*) X) FOO = P; //

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s + +struct S { + void f() { +++this; // expected-error {{expression is not assignable}} +// expected-note@-1 {{add '*' to dereference it}} zygoloid wrote: This is a bad diagnostic

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-17 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: I have some significant concerns about the approach of this PR. It seems to be producing notes that in a lot of cases suggest doing something that doesn't make sense or won't compile, and tentatively building a `*p` expression is unsafe. Can we revert

[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

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

[clang] [Clang] allow `` `@$ `` in raw string delimiters in C++26 (PR #93216)

2024-06-11 Thread Richard Smith via cfe-commits
@@ -2261,8 +2261,17 @@ bool Lexer::LexRawStringLiteral(Token , const char *CurPtr, unsigned PrefixLen = 0; - while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) + while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) { ++PrefixLen; +

[clang] Pass LangOpts from CompilerInstance to DependencyScanningWorker (PR #93753)

2024-06-05 Thread Richard Smith via cfe-commits
zygoloid wrote: > > I guess the general question is - is it acceptable to have the Scanner > > operating in a language standard different than the passed in language mode > > and different than the compiler language standard? > > I think that is acceptable. It is kinda hacky, but the lexer

[clang] [Sema] Fix handling of fields with initializers in nested anonymous unions. (PR #91692)

2024-06-03 Thread Richard Smith via cfe-commits
@@ -77,3 +77,38 @@ namespace use_self { int fib(int n) { return FibTree{n}.v; } } + +namespace nested_union { + union Test1 { +union { + int inner { 42 }; +}; +int outer; + }; + static_assert(Test1{}.inner == 42, ""); + struct Test2 { +union { +

[clang] [Sema] Fix handling of fields with initializers in nested anonymous unions. (PR #91692)

2024-06-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Looks good to me too. https://github.com/llvm/llvm-project/pull/91692 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema] Fix handling of fields with initializers in nested anonymous unions. (PR #91692)

2024-06-03 Thread Richard Smith via cfe-commits
@@ -77,3 +77,38 @@ namespace use_self { int fib(int n) { return FibTree{n}.v; } } + +namespace nested_union { + union Test1 { +union { + int inner { 42 }; +}; +int outer; + }; + static_assert(Test1{}.inner == 42, ""); + struct Test2 { +union { +

[clang] [Sema] Fix handling of fields with initializers in nested anonymous unions. (PR #91692)

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

[clang] [Clang] allow `` `@$ `` in raw string delimiters in C++26 (PR #93216)

2024-05-28 Thread Richard Smith via cfe-commits
@@ -152,16 +151,17 @@ LLVM_READONLY inline bool isHexDigit(unsigned char c) { /// Note that '_' is both a punctuation character and an identifier character! LLVM_READONLY inline bool isPunctuation(unsigned char c) { using namespace charinfo; - return (InfoTable[c] &

[clang] [clang codegen] Delete unnecessary GEP cleanup code. (PR #90303)

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

[clang] Fix codegen of consteval functions returning an empty class. (PR #93115)

2024-05-22 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Looks good. Do we also need to worry about overwriting tail padding here? https://github.com/llvm/llvm-project/pull/93115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang] Implement CWG2351 `void{}` (PR #78060)

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

[clang] [clang] Implement provisional wording for CWG2398 regarding packs (PR #90820)

2024-05-16 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: I think we should go ahead with this. The behavior here is subtle but I think it does make sense, and we're in the process of proposing this change to WG21. https://github.com/llvm/llvm-project/pull/90820 ___

[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-05-15 Thread Richard Smith via cfe-commits
zygoloid wrote: > The immediate deprecation causes a few issues On the one hand: waiting to deprecate something that we know we're going to deprecate usually doesn't help anyone. We delay getting the message out to our users, we sometimes forget to do it for the next release, and at best it

[clang] [Clang] Add attribute for consteval builtins; Declare constexpr builtins as constexpr in C++ (PR #91894)

2024-05-13 Thread Richard Smith via cfe-commits
@@ -14,13 +14,18 @@ void __builtin_va_copy(double d); // expected-error@+2 {{cannot redeclare builtin function '__builtin_va_end'}} // expected-note@+1 {{'__builtin_va_end' is a builtin with type}} void __builtin_va_end(__builtin_va_list); -// RUN: %clang_cc1 %s -fsyntax-only

[clang] [Clang][Sema] Fix malformed AST for anonymous class access in template. (PR #90842)

2024-05-13 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Nothing further on my side, LGTM https://github.com/llvm/llvm-project/pull/90842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-12 Thread Richard Smith via cfe-commits
zygoloid wrote: > I'd like to proposal a separate PR for static analyzer. #91879 WDYT? That sounds good to me. https://github.com/llvm/llvm-project/pull/87933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Analyzer][CFG] Correctly handle rebuilt default arg and default init expression (PR #91879)

2024-05-12 Thread Richard Smith via cfe-commits
@@ -2433,6 +2429,30 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt *S) { return B; } +CFGBlock *CFGBuilder::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Arg, + AddStmtChoice asc) { + if (Arg->hasRewrittenInit()) { +if

[clang] [Analyzer][CFG] Correctly handle rebuilt default arg and default init expression (PR #91879)

2024-05-12 Thread Richard Smith via cfe-commits
@@ -2433,6 +2429,30 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt *S) { return B; } +CFGBlock *CFGBuilder::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Arg, + AddStmtChoice asc) { + if (Arg->hasRewrittenInit()) { +if

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Looks great! I think it'd be good to understand what's happening with the static analyzer test, and update the comment to explain. But given that this is fixing a conformance / wrong code bug, I don't think we should block this PR on

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
@@ -711,6 +711,26 @@ void InitListChecker::FillInEmptyInitForField(unsigned Init, FieldDecl *Field, if (VerifyOnly) return; + // Enter a lifetime extension context, then we can support lifetime + // extension of temporary created by aggregate

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
@@ -206,13 +206,10 @@ namespace cwg1814 { // cwg1814: yes #endif } -namespace cwg1815 { // cwg1815: no +namespace cwg1815 { // cwg1815: yes zygoloid wrote: A test for constant evaluation would be nice here too. Maybe: ```c++ struct C { const int = 0; };

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
@@ -10698,7 +10698,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/1815.html;>1815 CD4 Lifetime extension in aggregate initialization -No +Clang 19 zygoloid wrote: ```suggestion Clang 19 ``` We use

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
@@ -122,7 +122,7 @@ void aggregateWithReferences() { clang_analyzer_dump(viaReference.ry); // expected-warning-re {{_extended_object{Composite, viaReference, S{{[0-9]+}}} }} // clang does not currently implement extending lifetime of object bound to reference members of

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
@@ -269,6 +269,26 @@ void init_capture_init_list() { // CHECK: } } +void check_dr1815() { // dr1815: yes +#if __cplusplus >= 201402L + + struct A { +int & = 0; +~A() {} + }; + + struct B { +A & = A{}; +~B() {} + }; + + // CHECK: void

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
@@ -8194,25 +8216,18 @@ void Sema::checkInitializerLifetime(const InitializedEntity , } switch (shouldLifetimeExtendThroughPath(Path)) { + case PathLifetimeKind::ShouldExtend: zygoloid wrote: Do we need separate `ShouldExtend` and `Extend`

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

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

[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)

2024-05-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks for working on this. https://github.com/llvm/llvm-project/pull/87933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix malformed AST for anonymous class access in template. (PR #90842)

2024-05-02 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Another possibility to consider: when [transforming a member access](https://github.com/llvm/llvm-project/blob/ff210b94d449de8ebe1f32cf0d7763ba63b27b39/clang/lib/Sema/TreeTransform.h#L11950), strip off any implicit member accesses from the base expression

[clang] [SemaCXX] Implement CWG2351 `void{}` (PR #78060)

2024-04-29 Thread Richard Smith via cfe-commits
zygoloid wrote: > Note that the AST for the expression `T{}` looks like: > > ``` > // using T = int; > CXXFunctionalCastExpr 'T':'int' functional cast to T > `-InitListExpr 'T':'int' > // using T = const int; > CXXFunctionalCastExpr 'int' functional cast to T > `-InitListExpr 'int' > // using

[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-23 Thread Richard Smith via cfe-commits
@@ -8343,58 +8343,52 @@ bool Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, // C++1z [temp.arg.template]p3: (DR 150) // A template-argument matches a template template-parameter P when P // is at least as specialized as the template-argument A.

[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-19 Thread Richard Smith via cfe-commits
zygoloid wrote: > Unfortunately with this patch I'm still seeing the same > source-location-exhausted error. Can you try applying #89428 as well? I think we would need both in order to prune the module map from the serialized SLocEntries. https://github.com/llvm/llvm-project/pull/89005

[clang] [clang][modules] Only avoid pruning module maps when asked to (PR #89428)

2024-04-19 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thank you! https://github.com/llvm/llvm-project/pull/89428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-17 Thread Richard Smith via cfe-commits
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef HeaderSearch::LookupSubframeworkHeader( // File Info Management. //===--===// +static bool +headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI, +

[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader creates extra HeaderFileInfo, breaks PCM reuse (PR #89005)

2024-04-17 Thread Richard Smith via cfe-commits
@@ -1313,6 +1313,14 @@ OptionalFileEntryRef HeaderSearch::LookupSubframeworkHeader( // File Info Management. //===--===// +static bool +headerFileInfoModuleBitsMatchRole(const HeaderFileInfo *HFI, +

  1   2   3   4   5   6   7   8   9   10   >