[clang] [clang][Sema] Cleanup and optimize DiagnoseAssignmentEnum (PR #141471)

2025-05-28 Thread Shafik Yaghmour via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/shafik commented: Very nice change. How are you coming up w/ the target for your improvements? Is this something other folks could try and try and find some inspiration? https://github.com/llvm/llvm-project/pull/141471 _

[clang] [clang][Sema] Cleanup and optimize DiagnoseAssignmentEnum (PR #141471)

2025-05-28 Thread Shafik Yaghmour via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -1741,57 +1741,65 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, void Sema::DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr) { + + const auto *E

[clang] [clang][Sema] Cleanup and optimize DiagnoseAssignmentEnum (PR #141471)

2025-05-28 Thread Shafik Yaghmour via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/141471 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Reset ArgPackSubstIndex before rewriting CTAD template parameters (PR #141741)

2025-05-28 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Thank you for the quick fix! https://github.com/llvm/llvm-project/pull/141741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C2y] Handle FP-suffixes on prefixed octals (#141230) (PR #141695)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/141695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C2y] Handle FP-suffixes on prefixed octals (#141230) (PR #141695)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Can you provide the PR that brought in the change you are fixing? https://github.com/llvm/llvm-project/pull/141695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
@@ -972,6 +972,12 @@ class Sema final : public SemaBase { /// Calls \c Lexer::getLocForEndOfToken() SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + /// Calls \c Lexer::findNextToken() to find the next token, and if the + /// locations of bo

[clang] [clang] Correct FixIt ranges for unused capture warnings (PR #141148)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,250 @@ +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wunused-lambda-capture -Wno-unused-value -std=c++1z -fixit %t +// RUN: grep -v CHECK %t | FileCheck %s + + +#define MACRO_CAPTURE(...) __VA_ARGS__ +int main() { +int a = 0, b = 0, c = 0; +auto F0 = [a, &b]()

[clang] [clang][Lex][NFC] Reorder SrcMgr checks in CheckMacroName (PR #141483)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
@@ -373,8 +373,8 @@ bool Preprocessor::CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef, // Macro names with reserved identifiers are accepted if built-in or passed // through the command line (the later may be present if -dD was used to // generate the preproc

[clang] [Clang] Fix a regression introduced by #138518 (PR #141342)

2025-05-27 Thread Shafik Yaghmour via cfe-commits
@@ -14086,7 +14091,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { // The form of initialization (using parentheses or '=') is generally // insignificant, but does matter when the entity being initialized has a // class type. -

[clang] [clang] Fixed an assertion failure triggered when instantiating a template with an expr that references an invalid decl (PR #140905)

2025-05-21 Thread Shafik Yaghmour via cfe-commits
@@ -4552,6 +4552,9 @@ LocalInstantiationScope::findInstantiationOf(const Decl *D) { isa(D->getDeclContext())) return nullptr; + if (D->isInvalidDecl()) shafik wrote: Why can't we just check after `D = getCanonicalParmVarDecl(D);`? https://github.

[clang] Revert "[Clang] Fix missed initializer instantiation bug for variable templates" (PR #140930)

2025-05-21 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/140930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Do not diagnose unions with -Wdefault-const-init (PR #140725)

2025-05-20 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/140725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)

2025-05-20 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: It would also be nice to get a reduction for: https://github.com/llvm/llvm-project/issues/140632 and see if we can add a test for that if it looks significantly different from the other cases. https://github.com/llvm/llvm-project/pull/140699 ___

[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)

2025-05-20 Thread Shafik Yaghmour via cfe-commits
@@ -18,6 +18,16 @@ int init_arr(); template template template int Outer::Inner::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() }; int *p = Outer::Inner::arr; +//CHECK: @_ZN8GH1406221gIiEE = linkonce_odr constant %"struct.GH140622::S" zeroinitializer +namespace GH14062

[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)

2025-05-20 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/140699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Do not diagnose flexible array members with -Wdefault-const-init-field-unsafe (PR #140578)

2025-05-19 Thread Shafik Yaghmour via cfe-commits
@@ -85,3 +85,33 @@ void func() { static const int b; // zero-init-var-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \ cxx-error {{default initialization of an object of const type 'const int'}} } + +//

[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-05-19 Thread Shafik Yaghmour via cfe-commits
shafik wrote: @kripken somewhat reduced: ```cpp struct MyStruct { double m0{-.0}; int m1{-12345}; }; constexpr MyStruct default_val; auto compute_area(double l, const MyStruct &val = default_val) -> double { if (val.m1 == 1) return 2.0; return 0; } #include auto

[clang] [Clang] suggest headers on undeclared errors (#120388) (PR #140247)

2025-05-16 Thread Shafik Yaghmour via cfe-commits
@@ -26,14 +26,18 @@ void no_get_1() { auto [a0, a1] = A(); // expected-error {{decomposes into 3 elements}} auto [b0, b1] = B(); // expected-error {{decomposes into 3 elements}} } - auto [a0, a1, a2] = A(); // expected-error {{undeclared identifier 'get'}} expected-

[clang] [Clang][Lex][NFC] Assert getExternalSource() in updateOutOfDateIdentifier (PR #140137)

2025-05-16 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/140137 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][AST] Fix HandleLValueBase to deal with references (PR #140105)

2025-05-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/140105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Lex][NFC] Assert getExternalSource() in updateOutOfDateIdentifier (PR #140137)

2025-05-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/140137 Static analysis flagged the unconditional access of getExternalSource(). We don't initialize ExternalSource during construction but via setExternalSource(). If this is not set it will violate the invariant cover

[clang] [Clang][AST] Fix HandleLValueBase to deal with references (PR #140105)

2025-05-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik updated https://github.com/llvm/llvm-project/pull/140105 >From db49f866558acdba7235bed1e535192ce4a1d3dc Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Thu, 15 May 2025 10:03:06 -0700 Subject: [PATCH] [Clang][AST] Fix HandleLValueBase to deal with references Sinc

[clang] [Clang][AST] Fix HandleLValueBase to deal with references (PR #140105)

2025-05-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/140105 Since P2280R4 Unknown references and pointers was implemented, HandleLValueBase now has to deal with referneces: D.MostDerivedType->getAsCXXRecordDecl() will return a nullptr if D.MostDerivedType is a Reference

[clang] [clang] Save ShuffleVectorExpr args as ConstantExpr (PR #139709)

2025-05-14 Thread Shafik Yaghmour via cfe-commits
@@ -4566,9 +4566,11 @@ class ShuffleVectorExpr : public Expr { void setExprs(const ASTContext &C, ArrayRef Exprs); - llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const { + llvm::APSInt getShuffleMaskIdx(unsigned N) const { assert((N < NumExprs -

[clang] [Clang][NFC] Introduce no local variable to avoid use after move (PR #139784)

2025-05-14 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/139784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Introduce no local variable to avoid use after move (PR #139784)

2025-05-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/139784 Static analysis flagged the use of Left.size() because we just moved out of Left and that would be undefined behavior. Fix is to take the size and store it in a local variable instead. >From df92525e63ff7c8953c

[clang] [Clang][Sema] Disable checking invalid template id in initializer of primary variable template `std::format_kind` with libstdc++ (PR #139560)

2025-05-12 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Can you please describe the issue in the summary instead of just saying it fixes Also add details such as this is fixing an issue introduced by ... Also please as Erich asked, add a test too https://github.com/llvm/llvm-project/pull/139560 ___

[clang] Fix crash with invalid VLA in a type trait (PR #138543)

2025-05-09 Thread Shafik Yaghmour via cfe-commits
@@ -41,3 +41,17 @@ void func(int expr) { int array[sizeof(Ty) ? sizeof(Ty{}) : sizeof(int)]; int old_style_assert[expr ? Ty::one : Ty::Neg_one]; // We don't diagnose as a VLA until instantiation } + +namespace GH138444 { +struct S { // expected-note {{candidate con

[clang] [clang][OpenMP] Add error for large expr in collapse clause (PR #138592)

2025-05-09 Thread Shafik Yaghmour via cfe-commits
@@ -15901,6 +15901,13 @@ ExprResult SemaOpenMP::VerifyPositiveIntegerConstantInClause( << E->getSourceRange(); return ExprError(); } + + if (!Result.isRepresentableByInt64()) { shafik wrote: So these are always 64 bit integers? This: https://w

[clang] [clang][OpenMP] Add error for large expr in collapse clause (PR #138592)

2025-05-09 Thread Shafik Yaghmour via cfe-commits
@@ -11523,6 +11523,8 @@ def note_omp_collapse_ordered_expr : Note< "as specified in %select{'collapse'|'ordered'|'collapse' and 'ordered'}0 clause%select{||s}0">; def err_omp_negative_expression_in_clause : Error< "argument to '%0' clause must be a %select{non-negative|str

[clang] [Clang][NFC] Adding note on details that are not immediately obvious (PR #138349)

2025-05-09 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/138349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Handle invalid variable template specialization whose type depends on itself (PR #134522)

2025-05-09 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This was flagged in the following issue: https://github.com/llvm/llvm-project/issues/139067#issuecomment-2865530760 https://github.com/llvm/llvm-project/pull/134522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

[clang] [C++20] Fix crash with invalid concept requirement (PR #138877)

2025-05-07 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Does this also fix: https://github.com/llvm/llvm-project/issues/138823 https://github.com/llvm/llvm-project/pull/138877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/

[clang] [clang][Index] Add comment about out-of-line defaulted destructor (PR #138640)

2025-05-06 Thread Shafik Yaghmour via cfe-commits
@@ -44,6 +44,8 @@ class IndexingContext { public: IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer); + // Defaulted, but defined out of line to avoid a dependency on + // HeuristicResolver.h. shafik wrote: ```suggestion // Heur

[clang] [clang][Index] Add comment about out-of-line defaulted destructor (PR #138640)

2025-05-06 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. https://github.com/llvm/llvm-project/pull/138640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Index] Use HeuristicResolver in libIndex (PR #125153)

2025-05-05 Thread Shafik Yaghmour via cfe-commits
@@ -25,6 +26,17 @@ static bool isGeneratedDecl(const Decl *D) { return false; } +IndexingContext::IndexingContext(IndexingOptions IndexOpts, + IndexDataConsumer &DataConsumer) +: IndexOpts(IndexOpts), DataConsumer(DataConsumer) {} + +Index

[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-05-05 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. https://github.com/llvm/llvm-project/pull/137899 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-05-05 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > @shafik I have changed the commit message, can you please look again? I see the commit [238d737](https://github.com/llvm/llvm-project/pull/137899/commits/238d73776c85ed22386ac494f275261638cd40d3) which adds the improved summary but I don't see at the top of this page in the su

[clang] [Clang] Minimal support for availability attributes on partial specializations (PR #138426)

2025-05-05 Thread Shafik Yaghmour via cfe-commits
@@ -72,3 +72,58 @@ template struct B { template struct B; // expected-note {{requested here}} } // namespace GH58547 + + +namespace GH44496 { + template struct my_template { +using type = void; +}; + +template +struct [[deprecated("primary")]] deprecated { // #depreca

[clang] [Clang] Minimal support for availability attributes on partial specializations (PR #138426)

2025-05-05 Thread Shafik Yaghmour via cfe-commits
@@ -72,3 +72,58 @@ template struct B { template struct B; // expected-note {{requested here}} } // namespace GH58547 + + +namespace GH44496 { + template struct my_template { shafik wrote: ```suggestion template struct my_template { ``` https://github.com

[clang] [Clang][NFC] Use std::move for Detail in timeTraceMetadata (PR #138352)

2025-05-05 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/138352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Use std::move for Detail in timeTraceMetadata (PR #138352)

2025-05-02 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/138352 Static analysis flagged the use of Detail because we were not using std::move when returning values. Modified the returns to use std::move. >From f12ee9b85d6f457061b7976ef929e3547c510b06 Mon Sep 17 00:00:00 2001

[clang] [Clang][NFC] Adding note on details that are not immediately obvious (PR #138349)

2025-05-02 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/138349 This code was flagged by static analysis. It was a false positive but the reason why this code is valid is subtle and folks refactoring this code in the future could easily miss it. >From 48a5b4a859c78fbc369473

[clang] [Clang][NFC] Capture by ref to avoid copying std::string (PR #138231)

2025-05-02 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/138231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Capture by ref to avoid copying std::string (PR #138231)

2025-05-02 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > Makes sense, thanks. I just wonder why is BName an owning string? To me it > would make a lot more sense if it was a StringRef owned by the ASTContext. > WDYT? `FD->getASTContext().BuiltinInfo.getName(BId)` returns std::string by value, looking at the API it looks pretty purpo

[clang] [Clang][NFC] assert IFaceT in SemaObjC::HandleExprPropertyRefExpr (PR #138026)

2025-05-02 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/138026 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Capture by ref to avoid copying std::string (PR #138231)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/138231 Static analysis flagged capturing BName by value as opposed to by reference. Updated capture to be by reference. >From dc52a86f175be704bb571ce160b597a2f4011cac Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Dat

[clang] [clang][lex] Fix lexing malformed pragma within include directive (PR #138165)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Thank you for the fix, this needs a test and release note. Release notes for clang are in `clang/docs/ReleaseNotes.rst`. I am not sure what the right file for testing is though @AaronBallman https://github.com/llvm/llvm-project/pull/138165 ___

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -6561,18 +6561,28 @@ def ext_goto_into_protected_scope : ExtWarn< def warn_cxx98_compat_goto_into_protected_scope : Warning< "jump from this goto statement to its label is incompatible with C++98">, InGroup, DefaultIgnore; +def warn_cpp_compat_goto_into_protected_scope :

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wjump-bypasses-init %s +// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wc++-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify=good %s +// RUN: %clang_cc1 -fsyntax-only -verify=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wjump-bypasses-init (PR #138009)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wjump-bypasses-init %s +// RUN: %clang_cc1 -fsyntax-only -verify=c,both -Wc++-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify=good %s +// RUN: %clang_cc1 -fsyntax-only -verify=cxx,both -x c++ %s +// good-no-dia

[clang] [C] Add -Wduplicate-decl-specifier to -Wc++-compat (PR #138012)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wduplicate-decl-specifier %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wc++-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-duplicate-decl-specifier -Wc++-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify=goo

[clang] [Clang][NFC] Use std::move to avoid copy (PR #138073)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/138073 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Use const auto & to avoid copy (PR #138069)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/138069 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Explicitly delete copy ctor and assignment for CGAtomicOptionsRAII (PR #137275)

2025-05-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/137275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Use std::move to avoid copy (PR #138073)

2025-04-30 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/138073 Static analysis flagged this code for using copy when we could use std::move. Worth noting that CD.Message is a StringRef but Conflict.Message is std::string. Otherwise I would have used a temporary in place and

[clang] [Clang][NFC] assert IFaceT in SemaObjC::HandleExprPropertyRefExpr (PR #138026)

2025-04-30 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/138026 Static analysis flagged that we use IFaceT in HandleExprPropertyRefExpr without checking even though getInterfaceType() can return nullptr. The comments make it clear the assumption is that we will always have a

[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-04-30 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Can you add more details in the summary. Specifically your approach to fixing the issue. Something along the lines of "In GetFullTypeForDeclarator ... moved check ... b/c ..." https://github.com/llvm/llvm-project/pull/137899 ___

[clang] [clang][NFC] Avoid a duplicate variable in SemaExprCXX.cpp (PR #137464)

2025-04-29 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137464 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Const correctness fix for range based for loop (PR #137431)

2025-04-28 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/137431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Silence spurious -Wnontrivial-memcall warnings in C mode (PR #137429)

2025-04-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: This should have a release note. https://github.com/llvm/llvm-project/pull/137429 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Const correctness fix for range based for loop (PR #137431)

2025-04-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/137431 Static analysis flagged that we did not make const a item declaration b/c we did not modify it all during the loop. >From 6b1e4f4c170c3f15697209f385397f295d15d2db Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour

[clang] [Clang][NFC] Explicitly delete copy ctor and assignment for CGAtomicOptionsRAII (PR #137275)

2025-04-24 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/137275 Static analysis flagged CGAtomicOptionsRAII as having an explicit destructor but not having explicit copy ctor and assignment. Rule of three says we should. We are just using this as an RAII object, no need for

[clang] [C] Warn on uninitialized const objects (PR #137166)

2025-04-24 Thread Shafik Yaghmour via cfe-commits
@@ -6496,6 +6496,17 @@ static bool canPerformArrayCopy(const InitializedEntity &Entity) { return false; } +static const FieldDecl *getConstField(const RecordDecl *RD) { + for (const FieldDecl *FD : RD->fields()) { +QualType QT = FD->getType(); +if (QT.isConstQualif

[clang] [C] Warn on uninitialized const objects (PR #137166)

2025-04-24 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -fsyntax-only -verify=c,unsafe -Wdefault-const-init %s +// RUN: %clang_cc1 -fsyntax-only -verify=c,unsafe -Wc++-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify=unsafe %s +// RUN: %clang_cc1 -fsyntax-only -verify=c -Wdefault-const-init -Wno

[clang] [Clang][NFC] Move temp variable back into the source (PR #137095)

2025-04-24 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/137095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Use temporary instead of one use local variable when creating APValue (PR #137029)

2025-04-23 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/137029 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Use temporary instead of one use local variable when creating APValue (PR #137029)

2025-04-23 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/137029 Static analysis flagged this code b/c we should have been using std::move when passing by value since the value is not used anymore. In this case the simpler fix is just to use a temporary value as many of the o

[clang] [Clang] diagnose deleted/default redeclaration of defined friend functions (PR #136717)

2025-04-22 Thread Shafik Yaghmour via cfe-commits
@@ -274,26 +274,22 @@ void operators() { namespace gh135506 { struct a { - // FIXME: We currently don't diagnose these invalid redeclarations if the - // second declaration is defaulted or deleted. This probably needs to be - // handled in ParseCXXInlineMethodDef() after pa

[clang] [Clang] Remove use after move of lambda (PR #136728)

2025-04-22 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/136728 Static analysis flagged this use after move. It is undefined behavior and I don't see any possible performance gains here to attempt to do anything else but simply remove it. >From 693a1f38d9a28ef515ccb738bee62

[clang] [llvm] [Clang][C++23] Core language changes from P1467R9 extended floating-point types and standard names. (PR #78503)

2025-04-21 Thread Shafik Yaghmour via cfe-commits
@@ -9278,6 +9278,8 @@ def err_cast_pointer_to_non_pointer_int : Error< def err_nullptr_cast : Error< "cannot cast an object of type %select{'nullptr_t' to %1|%1 to 'nullptr_t'}0" >; +def err_invalid_implicit_floating_point_cast : Error< shafik wrote: I don't

[clang] [Clang][Sema] Fix the lambda call expression inside of a type alias declaration (PR #82310)

2025-04-21 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This crash looks linked to this PR: https://github.com/llvm/llvm-project/issues/136432 https://github.com/llvm/llvm-project/pull/82310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] [NFC][Clang] Introduce type aliases to replace use of auto in clang/lib/CodeGen/CGCall.cpp. (PR #135861)

2025-04-18 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/135861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][Clang] Introduce type aliases to replace use of auto in clang/lib/CodeGen/CGCall.cpp. (PR #135861)

2025-04-18 Thread Shafik Yaghmour via cfe-commits
@@ -712,8 +713,7 @@ CodeGenTypes::arrangeBlockFunctionDeclaration(const FunctionProtoType *proto, const CGFunctionInfo & CodeGenTypes::arrangeBuiltinFunctionCall(QualType resultType, const CallArgList &args) { - // FIXME: Kill copy. --

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-18 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: I am going to chime in, in support of both Aaron's and Erich's position here. This does not seem like an extension we want to support. So given the objections, we need at minimum an RFC and see how that goes. Maybe during that discussion a more compelling c

[clang] [Clang] [Sema] Fix a crash when a `friend` function is redefined as deleted (PR #135679)

2025-04-17 Thread Shafik Yaghmour via cfe-commits
@@ -271,3 +271,33 @@ void operators() { if (to_int_int) {} // expected-error {{attempt to use a deleted function: deleted (TO, operator bool)}} static_cast(to_int_int); // expected-error {{static_cast from 'TO' to 'bool' uses deleted function: deleted (TO, operator bool)}}

[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)

2025-04-17 Thread Shafik Yaghmour via cfe-commits
@@ -299,3 +299,18 @@ void test10() { for (auto[i, j, k] = arr; i < a; ++i) { } for (auto[i, j, k] = arr; i < a; ++arr[0]) { } }; + +extern void foo(int); shafik wrote: We normally wrap tests from bug reports in `namespace GH` where is the bug rep

[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)

2025-04-17 Thread Shafik Yaghmour via cfe-commits
@@ -299,3 +299,18 @@ void test10() { for (auto[i, j, k] = arr; i < a; ++i) { } for (auto[i, j, k] = arr; i < a; ++arr[0]) { } }; + +extern void foo(int); shafik wrote: Can we also get tests that show diagnostics for lambda cases as well. https://github.co

[clang] [clang] fix unresolved dependent template specialization mangling (PR #135111)

2025-04-17 Thread Shafik Yaghmour via cfe-commits
shafik wrote: CC @var-const https://github.com/llvm/llvm-project/pull/135111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] fix unresolved dependent template specialization mangling (PR #135111)

2025-04-17 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > https://godbolt.org/z/sY44dG6Ya is the reproducer. It is not super small but > still should give an idea as the stack is quite similar to stuff touched by > this PR. Did you open a bug report? Maybe w/ reduction is ends up the same as the one I just linked to. https://github.

[clang] [clang] fix unresolved dependent template specialization mangling (PR #135111)

2025-04-17 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This crash is also linked to this PR: https://github.com/llvm/llvm-project/issues/136119 https://github.com/llvm/llvm-project/pull/135111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)

2025-04-15 Thread Shafik Yaghmour via cfe-commits
@@ -3,6 +3,11 @@ // RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs -triple=x86_64-unknown-fuchsia %s // RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs -triple=x86_64-linux-android %s +// expected-n

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-15 Thread Shafik Yaghmour via cfe-commits
@@ -7,7 +7,7 @@ #define foo`bar /* expected-error {{whitespace required after macro name}} */ #define foo2!bar /* expected-warning {{whitespace recommended after macro name}} */ -#define foo3$bar /* expected-error {{'$' in identifier}} */ +#define foo3$bar /* expected-er

[clang] [clang] Add builtin_get_vtable_pointer and virtual_member_address (PR #135469)

2025-04-15 Thread Shafik Yaghmour via cfe-commits
@@ -5349,6 +5350,40 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return RValue::get(Result); } + case Builtin::BI__builtin_virtual_member_address: { +Address This = EmitLValue(E->getArg(0)).getAddress(); +APValue ConstMemF

[clang] [clang] Add builtin_get_vtable_pointer and virtual_member_address (PR #135469)

2025-04-15 Thread Shafik Yaghmour via cfe-commits
@@ -5349,6 +5350,40 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return RValue::get(Result); } + case Builtin::BI__builtin_virtual_member_address: { +Address This = EmitLValue(E->getArg(0)).getAddress(); +APValue ConstMemF

[clang] [Clang] Make enums trivially equality comparable (PR #133587)

2025-04-15 Thread Shafik Yaghmour via cfe-commits
@@ -5240,9 +5249,13 @@ static bool HasNonDeletedDefaultedEqualityComparison(Sema &S, static bool isTriviallyEqualityComparableType(Sema &S, QualType Type, SourceLocation KeyLoc) { QualType CanonicalType = Type.getCanonicalType(); if (CanonicalType->isIncompleteType() || C

[clang] [Clang] Make enums trivially equality comparable (PR #133587)

2025-04-15 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > > The summary should not merely link to an issue but describe the problem as > > well. Two reasons: > > ``` > > 1. for folks reading this in git log > > > > 2. The issue may not totally explain what is going on. > > ``` > > > > > > > > > > > > > > > >

[clang] [Clang][P1061] Fix invalid pack binding crash (PR #135129)

2025-04-10 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Thank you for the quick fix, I left a comment on the test which should be addressed in a follow up, unless I am missing something and the coverage is elsewhere already. https://github.com/llvm/llvm-project/pull/135129 ___

[clang] [Clang][P1061] Fix invalid pack binding crash (PR #135129)

2025-04-10 Thread Shafik Yaghmour via cfe-commits
@@ -3,9 +3,15 @@ // RUN: %clang_cc1 -std=c++23 -verify=cxx23,nontemplate -fsyntax-only -Wc++26-extensions %s void decompose_array() { - int arr[4] = {1, 2, 3, 6}; shafik wrote: We should have both cases tested, we want as wide test coverage as possible. S

[clang] [Clang][P1061] Fix invalid pack binding crash (PR #135129)

2025-04-10 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/135129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] [Sema] Document invariant in Sema::AddOverloadCandidate (PR #135256)

2025-04-10 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/135256 Static analysis flagged 1 - ArgIdx in Sema::AddOverloadCandidate for its potential to overflow. Turns out this is intentional since when PO == OverloadCandidateParamOrder::Reversed Args.size() is always two, so

[clang] [Clang] Make enums trivially equality comparable (PR #133587)

2025-04-09 Thread Shafik Yaghmour via cfe-commits
@@ -5240,9 +5249,13 @@ static bool HasNonDeletedDefaultedEqualityComparison(Sema &S, static bool isTriviallyEqualityComparableType(Sema &S, QualType Type, SourceLocation KeyLoc) { QualType CanonicalType = Type.getCanonicalType(); if (CanonicalType->isIncompleteType() || C

[clang] [Clang] Make enums trivially equality comparable (PR #133587)

2025-04-09 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: The summary should not merely link to an issue but describe the problem as well. Two reasons: 1) for folks reading this in git log 2) The issue may not totally explain what is going on. I actually did not get it at first b/c the issue talks about *char* and

[clang] [Clang] Add non static data member initializer for BindingDecl member Decomp (PR #134969)

2025-04-09 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik closed https://github.com/llvm/llvm-project/pull/134969 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [libcxx] [clang] fix diagnostic printing of expressions ignoring LangOpts (PR #134693)

2025-04-08 Thread Shafik Yaghmour via cfe-commits
@@ -7379,6 +7379,14 @@ class RecoveryExpr final : public Expr, friend class ASTStmtWriter; }; +/// Insertion operator for diagnostics. This allows sending +/// Expr into a diagnostic with <<. +inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB, +

[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-07 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: This makes sense to me but this is not my area. https://github.com/llvm/llvm-project/pull/134269 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-04-05 Thread Shafik Yaghmour via cfe-commits
@@ -1849,8 +1852,9 @@ TEST_F(StructuralEquivalenceCacheTest, ReturnStmtNonEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false);

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

2025-04-05 Thread Shafik Yaghmour via cfe-commits
@@ -1913,8 +1919,9 @@ TEST_F(StructuralEquivalenceCacheTest, Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); + get<0>(TU)-

[clang] [Lex][Clang] Add checking to HeaderMapImpl::getString to make it more robust (PR #131677)

2025-04-05 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > LGTM with nit addressed. Test coverage would be nice to add, but not strictly > required if this is purely a defensive measure (which it seems to be). Exactly. https://github.com/llvm/llvm-project/pull/131677 ___ cfe-commits mailing l

  1   2   3   4   5   6   7   8   9   10   >