[clang] [clang] Fix OOB read in SemaSwift::validateSwiftFunctionName (PR #157139)

2025-09-08 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik approved this pull request. LGTM but we need a release note. https://github.com/llvm/llvm-project/pull/157139 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Allow attributes on first constructor argument in pre-C++11 (PR #157300)

2025-09-08 Thread Shafik Yaghmour via cfe-commits
@@ -6007,10 +6007,9 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide, // A C++11 attribute here signals that we have a constructor, and is an // attribute on the first constructor parameter. - if (getLangOpts().CPlusPlus11 && - isCXX11

[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)

2025-09-07 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Mostly minor comments https://github.com/llvm/llvm-project/pull/156075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Look through parens around reinterpret_cast to emit a warning (PR #157033)

2025-09-07 Thread Shafik Yaghmour via cfe-commits
@@ -167,6 +167,9 @@ void dereference_reinterpret_cast() { (void)reinterpret_cast(d); // expected-warning {{reinterpret_cast from 'double' to 'float &' has undefined behavior}} (void)*reinterpret_cast(&d); // expected-warning {{dereference of type 'float *' that was reint

[clang] [clang] Look through parens around reinterpret_cast to emit a warning (PR #157033)

2025-09-06 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Please add a release note. https://github.com/llvm/llvm-project/pull/157033 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Print 8 bit integers as 32 bit in Function::dump() (PR #156858)

2025-09-05 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > This only changes debugging output so there are no tests for it. So it looks like this output is only used for `dump()` functions, makes sense. https://github.com/llvm/llvm-project/pull/156858 ___ cfe-commits mailing list cfe-commits@l

[clang] [clang][bytecode] Print 8 bit integers as 32 bit in Function::dump() (PR #156858)

2025-09-04 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: I am a surprised there are not changed tests nor additional test given the problem description. It would seem we are avoiding output in a specific format. We should have a test in which the output would differ w/o this change. https://github.com/llvm/llvm-

[clang] [clang][bytecode] Reject final ltor casts on string literals (PR #156669)

2025-09-04 Thread Shafik Yaghmour via cfe-commits
shafik wrote: What is an Itor cast? https://github.com/llvm/llvm-project/pull/156669 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)

2025-09-04 Thread Shafik Yaghmour via cfe-commits
@@ -431,6 +435,30 @@ Expr *BuiltinTypeMethodBuilder::getResourceHandleExpr() { OK_Ordinary); } +template +BuiltinTypeMethodBuilder & +BuiltinTypeMethodBuilder::getResourceHandle(T ResourceRecord) { + ensureCompleteDecl(); + + Expr *Resour

[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)

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

[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)

2025-09-04 Thread Shafik Yaghmour via cfe-commits
@@ -676,6 +704,44 @@ BuiltinTypeDeclBuilder::addHandleConstructorFromImplicitBinding() { .finalize(); } +BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addCopyConstructor() { + if (Record->isCompleteDefinition()) +return *this; + + ASTContext &AST = SemaRef.getAS

[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)

2025-09-04 Thread Shafik Yaghmour via cfe-commits
@@ -676,6 +704,44 @@ BuiltinTypeDeclBuilder::addHandleConstructorFromImplicitBinding() { .finalize(); } +BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addCopyConstructor() { + if (Record->isCompleteDefinition()) +return *this; + + ASTContext &AST = SemaRef.getAS

[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)

2025-09-04 Thread Shafik Yaghmour via cfe-commits
@@ -431,6 +435,30 @@ Expr *BuiltinTypeMethodBuilder::getResourceHandleExpr() { OK_Ordinary); } +template +BuiltinTypeMethodBuilder & +BuiltinTypeMethodBuilder::getResourceHandle(T ResourceRecord) { + ensureCompleteDecl(); + + Expr *Resour

[clang] [clang-tools-extra] [clang] Improve nested name specifier AST representation (PR #147835)

2025-09-03 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This feels like a regression, unless you think the bug is elsewhere and the assert just catches it now: https://github.com/llvm/llvm-project/issues/156458#issuecomment-3246453958 https://github.com/llvm/llvm-project/pull/147835 ___ cfe-

[clang] [HLSL][NFC] Add assert to verify implicit binding resource attribute exists (PR #156094)

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

[clang] [Sema] Diagnose use of if/else-if condition variable inside else-if/else branch(s) (PR #156436)

2025-09-02 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wconditional-scope %s + +int *get_something(); +int *get_something_else(); +int *get_something_else_again(); + +int test() { + if (int *ptr = get_something()) { +return ptr[0] * ptr[0]; + } + else if (int *ptr2 = g

[clang] [Clang] Add template argument support for {con,de}structor attributes. (PR #151400)

2025-09-02 Thread Shafik Yaghmour via cfe-commits
shafik wrote: I don't have further comments, @erichkeane are you good? https://github.com/llvm/llvm-project/pull/151400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] correct error message when assigning to const reference captured in lambda (PR #105647)

2025-09-02 Thread Shafik Yaghmour via cfe-commits
@@ -194,6 +194,11 @@ namespace ModifyingCapture { [=] { n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}} }; +const int cn = 0; shafik wrote: I think we should have also tested a `constexpr` va

[clang] [HLSL] Global resource arrays element access (PR #152454)

2025-09-02 Thread Shafik Yaghmour via cfe-commits
@@ -84,6 +85,111 @@ void addRootSignature(llvm::dxbc::RootSignatureVersion RootSigVer, RootSignatureValMD->addOperand(MDVals); } +// Find array variable declaration from nested array subscript AST nodes +static const ValueDecl *getArrayDecl(const ArraySubscriptExpr *ASE) {

[clang] [llvm] Reland: [OpenMP][clang] 6.0: num_threads strict (part 3: codegen) (PR #155839)

2025-09-02 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This change is linked to the following regression: https://github.com/llvm/llvm-project/issues/156232 Please fix asap https://github.com/llvm/llvm-project/pull/155839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -986,6 +989,10 @@ def warn_module_conflict : Warning< InGroup; // C++20 modules +def err_module_decl_in_header +: Error<"module declaration must not come from an #include directive">; shafik wrote: I don't see a test that covers this or the next diag

[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -1775,10 +1775,18 @@ def ext_bit_int : Extension< } // end of Parse Issue category. let CategoryName = "Modules Issue" in { -def err_unexpected_module_decl : Error< - "module declaration can only appear at the top level">; +def err_invalid_module_or_import_directive : Erro

[clang] [HLSL][SPIRV] Add -fspv-use-unknown-image-format option (PR #155664)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -513,14 +513,65 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType( return nullptr; } +static unsigned +getImageFormat(const LangOptions &LangOpts, + const HLSLAttributedResourceType::Attributes &attributes, + llvm::Type *SampledType, Qual

[clang] [clang][x86] Ensure we use the shifted value bit width to check for out of bounds per-element shift amounts (PR #156019)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: I would have expected additional test coverage since this looks like it would change behavior for out of bound shift amounts. https://github.com/llvm/llvm-project/pull/156019 ___ cfe-commits mailing list cfe-commit

[clang] [clang] constexpr `__builtin_elementwise_{max, min}` (PR #153563)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -873,6 +875,27 @@ static_assert(__builtin_elementwise_min(1, 2) == 1); static_assert(__builtin_elementwise_min(-1, 1) == -1); static_assert(__builtin_elementwise_min(1U, 2U) == 1U); static_assert(__builtin_elementwise_min(~0U, 0U) == 0U); +static_assert(__builtin_fabs(__buil

[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr - allow SSE/AVX2/AVX512 pack intrinsics to be used in constexpr (PR #156003)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -11599,6 +11599,89 @@ static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO, return false; } +enum class PackKind { + SSWB, + USWB, + SSDW, + USDW +}; // 16→8 signed/unsigned; 32→16 signed/unsigned + +static bool evalPackBuiltin(const CallExpr *E, E

[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr - allow SSE/AVX2/AVX512 pack intrinsics to be used in constexpr (PR #156003)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -11599,6 +11599,89 @@ static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO, return false; } +enum class PackKind { + SSWB, + USWB, + SSDW, + USDW +}; // 16→8 signed/unsigned; 32→16 signed/unsigned + +static bool evalPackBuiltin(const CallExpr *E, E

[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr - allow SSE/AVX2/AVX512 pack intrinsics to be used in constexpr (PR #156003)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -11599,6 +11599,89 @@ static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO, return false; } +enum class PackKind { + SSWB, + USWB, + SSDW, + USDW +}; // 16→8 signed/unsigned; 32→16 signed/unsigned + +static bool evalPackBuiltin(const CallExpr *E, E

[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr - allow SSE/AVX2/AVX512 pack intrinsics to be used in constexpr (PR #156003)

2025-08-29 Thread Shafik Yaghmour via cfe-commits
@@ -11599,6 +11599,89 @@ static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO, return false; } +enum class PackKind { shafik wrote: Pack is such an overloaded word in C++, can we get something more specific, I don't have a good suggesti

[clang] [clang] Update typechecking of builtin elementwise ternary math operators (PR #155620)

2025-08-28 Thread Shafik Yaghmour via cfe-commits
@@ -15884,6 +15884,55 @@ static bool checkBuiltinVectorMathMixedEnums(Sema &S, Expr *LHS, Expr *RHS, return false; } +/// Check if all arguments have the same type. If the types don't match, emit an +/// error message and return true. Otherwise return false. +/// +/// For

[clang] [clang-tools-extra] [lldb] [clang] NFC: rename clang/include/clang/AST/Type.h to TypeBase.h (PR #155049)

2025-08-28 Thread Shafik Yaghmour via cfe-commits
shafik wrote: If they are including `Type.h` in files that only exist downstream that will force them to deal with this both times around, unless I am missing something. https://github.com/llvm/llvm-project/pull/155049 ___ cfe-commits mailing list cfe

[clang] [clang] fix regression parsing C enum which doesn't declare anything (PR #155904)

2025-08-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/155904 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang] NFC: change more places to use Type::getAsTagDecl and friends (PR #155313)

2025-08-28 Thread Shafik Yaghmour via cfe-commits
shafik wrote: I am not sure it makes sense to label such larger changes NFC, anything this large should have at least one review if not more. https://github.com/llvm/llvm-project/pull/155313 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http

[clang] [clang][bytecode] Reject dependent RequiresExprs (PR #155230)

2025-08-27 Thread Shafik Yaghmour via cfe-commits
shafik wrote: CC @zygoloid is clang correct to reject the example in this code? https://github.com/llvm/llvm-project/pull/155230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-08-27 Thread Shafik Yaghmour via cfe-commits
shafik wrote: @ahatanak it seems like trunk now return 4 for all cases: https://godbolt.org/z/ds4ofbv6d I will have to look into the first two cases to understand what is going on better https://github.com/llvm/llvm-project/pull/95474 ___ cfe-commi

[clang] [clang] Make sure EvalInfo pointer isn't null (PR #155563)

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

[clang] [clang][bytecode] Reject dependent RequiresExprs (PR #155230)

2025-08-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Do you know which clause causes clang to choose to reject this, looks like we are the only one: https://godbolt.org/z/KhfeP5W6d CC @hokein looks like came in w/ bd4662cd3f374 https://github.com/llvm/llvm-project/pull/155230 _

[clang] [lldb] [clang] remove IsDefaulted bit from TemplateArgument (PR #155120)

2025-08-25 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > This patch doesn't touch LLDB. If LLDB uses this bit, then LLDB also needs to > be updated in the same manner as we are updating DebugInfo here. If the change breaks LLDB then you should also fix that break as well. https://github.com/llvm/llvm-project/pull/155120 ___

[clang] [Clang][Codegen][NFC] Add nullptr check in fillOutputFields (PR #154623)

2025-08-25 Thread Shafik Yaghmour via cfe-commits
shafik wrote: Test failure does not look related, looks like a flaky test. https://github.com/llvm/llvm-project/pull/154623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode][NFC] Remove double initializer (PR #155150)

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

[clang] [Clang] Enable constexpr handling for builtin elementwise fshl/fshr (PR #153572)

2025-08-25 Thread Shafik Yaghmour via cfe-commits
@@ -961,3 +961,51 @@ static_assert(fmaDouble1[3] == 26.0); constexpr float fmaArray[] = {2.0f, 2.0f, 2.0f, 2.0f}; constexpr float fmaResult = __builtin_elementwise_fma(fmaArray[1], fmaArray[2], fmaArray[3]); static_assert(fmaResult == 6.0f, ""); + +static_assert(__builtin_elem

[clang] [Clang] Enable constexpr handling for builtin elementwise fshl/fshr (PR #153572)

2025-08-24 Thread Shafik Yaghmour via cfe-commits
@@ -961,3 +961,51 @@ static_assert(fmaDouble1[3] == 26.0); constexpr float fmaArray[] = {2.0f, 2.0f, 2.0f, 2.0f}; constexpr float fmaResult = __builtin_elementwise_fma(fmaArray[1], fmaArray[2], fmaArray[3]); static_assert(fmaResult == 6.0f, ""); + +static_assert(__builtin_elem

[clang] [clang][bytecode] Guard strcmp against differing element types (PR #154777)

2025-08-24 Thread Shafik Yaghmour via cfe-commits
@@ -338,3 +338,12 @@ static void *FooTable[1] = { } }; +int strcmp(const char *, const char *); // all-note {{passing argument to parameter here}} +#define S "\x01\x02\x03\x04\x05\x06\x07\x08" +const char _str[] = {S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7]}; +const u

[clang] [clang][bytecode] Implement ia32_select* builtins (PR #154758)

2025-08-24 Thread Shafik Yaghmour via cfe-commits
@@ -2778,6 +2778,40 @@ static bool interp__builtin_elementwise_fma(InterpState &S, CodePtr OpPC, return true; } +/// AVX512 predicated move: "Result = Mask[] ? LHS[] : RHS[]". +static bool interp__builtin_select(InterpState &S, CodePtr OpPC, +

[clang] [clang] Remove hasValue() check in `RecordExprEvaluator::VisitCXXConstructExpr()` (PR #154610)

2025-08-24 Thread Shafik Yaghmour via cfe-commits
@@ -11045,10 +11045,6 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E, bool ZeroInit = E->requiresZeroInitialization(); if (CheckTrivialDefaultConstructor(Info, E->getExprLoc(), FD, ZeroInit)) { -// If we've already performed zero-initiali

[clang] [Sema] Compare canonical conversion function (PR #154158)

2025-08-23 Thread Shafik Yaghmour via cfe-commits
@@ -4404,14 +4404,19 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, Result = CompareStandardConversionSequences(S, Loc, ICS1.Standard, ICS2.Standard); else if (ICS1.isUserDefined()) { +const Function

[clang] [clang] Enable constexpr handling for __builtin_elementwise_fma (PR #152919)

2025-08-23 Thread Shafik Yaghmour via cfe-commits
@@ -11874,6 +11874,28 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) { return Success(APValue(ResultElements.data(), ResultElements.size()), E); } + + case Builtin::BI__builtin_elementwise_fma: { +APValue SourceX, SourceY, SourceZ; +if (!Evaluate

[clang] [clang][bytecode][NFC] Use an anonymous union in Pointer (PR #154405)

2025-08-23 Thread Shafik Yaghmour via cfe-commits
@@ -163,12 +186,11 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { } if (isTypeidPointer()) { -TypeInfoLValue TypeInfo(PointeeStorage.Typeid.TypePtr); -return APValue( -APValue::LValueBase::getTypeInfo( -TypeInfo, QualType(Point

[clang] [clang][bytecode][NFC] Use an anonymous union in Pointer (PR #154405)

2025-08-23 Thread Shafik Yaghmour via cfe-commits
@@ -95,31 +93,23 @@ class Pointer { static constexpr unsigned RootPtrMark = ~0u; public: - Pointer() { -StorageKind = Storage::Int; -PointeeStorage.Int.Value = 0; -PointeeStorage.Int.Desc = nullptr; - } - Pointer(IntPointer &&IntPtr) : StorageKind(Storage::Int

[clang] [Clang][Codegen][NFC] Add nullptr check in fillOutputFields (PR #154623)

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

[clang] [clang][bytecode] Fix comparing pointers to union members (PR #154342)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -966,3 +966,15 @@ namespace AddressComparison { static_assert(&U2.a[0] != &U2.b[1]); static_assert(&U2.a[0] == &U2.b[1]); // both-error {{failed}} } + +#if __cplusplus >= 202002L +namespace UnionMemberOnePastEnd { + constexpr bool b() { +union { + int p; +

[clang] [clang][bytecode] Support pmul X86 builtins (PR #154275)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: I don't see any tests for this. https://github.com/llvm/llvm-project/pull/154275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [HLSL] Global resource arrays element access (PR #152454)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -84,6 +85,111 @@ void addRootSignature(llvm::dxbc::RootSignatureVersion RootSigVer, RootSignatureValMD->addOperand(MDVals); } +// Find array variable declaration from nested array subscript AST nodes +static const ValueDecl *getArrayDecl(const ArraySubscriptExpr *ASE) {

[clang] [HLSL] Global resource arrays element access (PR #152454)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -84,6 +85,111 @@ void addRootSignature(llvm::dxbc::RootSignatureVersion RootSigVer, RootSignatureValMD->addOperand(MDVals); } +// Find array variable declaration from nested array subscript AST nodes +static const ValueDecl *getArrayDecl(const ArraySubscriptExpr *ASE) {

[clang] [clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (PR #153601)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -2234,30 +2236,136 @@ static unsigned computePointerOffset(const ASTContext &ASTCtx, return Result; } +/// Does Ptr point to the last subobject? +static bool pointsToLastObject(const Pointer &Ptr) { + Pointer P = Ptr; + while (!P.isRoot()) { + +if (P.isArrayElement

[clang] [clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (PR #153601)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -2170,29 +2170,32 @@ static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC, return true; } -static unsigned computeFullDescSize(const ASTContext &ASTCtx, -const Descriptor *Desc) { - +static std::optional computeFullDescSize(

[clang] [clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (PR #153601)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -60,16 +60,18 @@ template class OptionScope final { public: /// Root constructor, compiling or discarding primitives. OptionScope(Compiler *Ctx, bool NewDiscardResult, - bool NewInitializing) + bool NewInitializing, bool NewToLValue) : C

[clang] [clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (PR #153601)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: I will come back to this https://github.com/llvm/llvm-project/pull/153601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (PR #153601)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -2234,30 +2236,136 @@ static unsigned computePointerOffset(const ASTContext &ASTCtx, return Result; } +/// Does Ptr point to the last subobject? +static bool pointsToLastObject(const Pointer &Ptr) { + Pointer P = Ptr; + while (!P.isRoot()) { + +if (P.isArrayElement

[clang] [clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (PR #153601)

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

[clang] [clang] constexpr integer `__builtin_elementwise_{max,min}` (PR #152294)

2025-08-22 Thread Shafik Yaghmour via cfe-commits
@@ -13548,7 +13583,24 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, APInt Result = LHS.isSigned() ? LHS.ssub_sat(RHS) : LHS.usub_sat(RHS); return Success(APSInt(Result, !LHS.isSigned()), E); } + case Builtin::BI__builtin_elementwise_max: { +A

[clang] [clang][bytecode] Fix a crash in Destroy op (PR #154695)

2025-08-21 Thread Shafik Yaghmour via cfe-commits
@@ -2437,9 +2437,17 @@ inline bool Destroy(InterpState &S, CodePtr OpPC, uint32_t I) { const Pointer &Ptr = S.Current->getLocalPointer(Local.Offset); if (Ptr.getLifetime() == Lifetime::Ended) { - auto *D = cast(Ptr.getFieldDesc()->asDecl()); - S.FFDiag(D->ge

[clang] [clang][bytecode] Fix a crash in Destroy op (PR #154695)

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

[clang] [clang][bytecode] Check for unknown size array pointers in InitField* (PR #154689)

2025-08-21 Thread Shafik Yaghmour via cfe-commits
@@ -1652,6 +1655,9 @@ bool InitFieldActivate(InterpState &S, CodePtr OpPC, uint32_t I) { const Pointer &Ptr = S.Stk.peek(); if (!CheckRange(S, OpPC, Ptr, CSK_Field)) return false; + if (!CheckArray(S, OpPC, Ptr)) shafik wrote: I feel like `CheckArray

[clang] [Clang][Codegen][NFC] Apply rule of three to some classes (PR #154671)

2025-08-20 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/154671 Static analysis flagged these classes as having implemented the destructor but not applying rule of three. This could lead to accidental misuse and so it makes sense to apply it. >From 41d7218a6586834482ea6

[clang] [Clang][NFC] Clarify some SourceManager related code (PR #153527)

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

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -3282,9 +3282,50 @@ static void CheckJumpOutOfSEHFinally(Sema &S, SourceLocation Loc, } } -StmtResult -Sema::ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope) { - Scope *S = CurScope->getContinueParent(); +Scope *FindLabeledBreakContinueScope(Sema &S, Scope

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -716,7 +732,8 @@ StmtResult Parser::ParseLabeledStatement(ParsedAttributes &Attrs, StmtVector Stmts; ParsedAttributes EmptyCXX11Attrs(AttrFactory); SubStmt = ParseStatementOrDeclarationAfterAttributes( - Stmts, StmtCtx, nullptr, EmptyCXX11Attrs, T

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -3282,9 +3282,50 @@ static void CheckJumpOutOfSEHFinally(Sema &S, SourceLocation Loc, } } -StmtResult -Sema::ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope) { - Scope *S = CurScope->getContinueParent(); +Scope *FindLabeledBreakContinueScope(Sema &S, Scope

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -679,11 +685,17 @@ static void DiagnoseLabelFollowedByDecl(Parser &P, const Stmt *SubStmt) { } } -StmtResult Parser::ParseLabeledStatement(ParsedAttributes &Attrs, - ParsedStmtContext StmtCtx) { +StmtResult +Parser::ParseLabeledSta

[clang] [clang-tools-extra] [clang] Improve nested name specifier AST representation (PR #147835)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
shafik wrote: Git bisect also blame this PR for: https://github.com/llvm/llvm-project/issues/154270 https://github.com/llvm/llvm-project/pull/147835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -215,6 +215,8 @@ def warn_c23_compat_case_range : Warning< DefaultIgnore, InGroup; def ext_c2y_case_range : Extension< "case ranges are a C2y extension">, InGroup; +def err_c2y_labeled_break_continue +: Error<"labeled %select{'break'|'continue'}0 is only supported in

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -3084,35 +3090,48 @@ class ContinueStmt : public Stmt { const_child_range children() const { return const_child_range(const_child_iterator(), const_child_iterator()); } + + static bool classof(const Stmt *T) { +StmtClass Class = T->getStmtClass(); +return Cl

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -3056,25 +3045,42 @@ class IndirectGotoStmt : public Stmt { } }; -/// ContinueStmt - This represents a continue. -class ContinueStmt : public Stmt { +/// Base class for BreakStmt and ContinueStmt. +class LoopControlStmt : public Stmt { + /// If this is a labeled break/co

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,147 @@ +// RUN: %clang_cc1 -std=c2y -verify -fsyntax-only -fblocks %s +// RUN: %clang_cc1 -std=c23 -verify -fsyntax-only -fblocks -fnamed-loops %s +// RUN: %clang_cc1 -x c++ -verify -fsyntax-only -fblocks -fnamed-loops %s + +void f1() { + l1: while (true) { +break

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

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

[clang] [clang-tools-extra] [Clang] [C2y] Implement N3355 ‘NamedLoops’ (PR #152870)

2025-08-19 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Adding my comments now b/c I am not sure when I will get back to review https://github.com/llvm/llvm-project/pull/152870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [Clang][Sema] Check the return value of DiagnoseClassNameShadow in ActOnEnumConstant (PR #143754)

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

[clang] [Clang][Sema] Check the return value of DiagnoseClassNameShadow in ActOnEnumConstant (PR #143754)

2025-08-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik updated https://github.com/llvm/llvm-project/pull/143754 >From 41e1b10a325aef9d7535b222e4c4ca909463d7fd Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Tue, 10 Jun 2025 18:56:12 -0700 Subject: [PATCH 1/3] [Clang][Sema] Check the return value of DiagnoseClassNameS

[clang] [Clang][Sema] Check the return value of DiagnoseClassNameShadow in ActOnEnumConstant (PR #143754)

2025-08-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik updated https://github.com/llvm/llvm-project/pull/143754 >From 41e1b10a325aef9d7535b222e4c4ca909463d7fd Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Tue, 10 Jun 2025 18:56:12 -0700 Subject: [PATCH 1/2] [Clang][Sema] Check the return value of DiagnoseClassNameS

[clang] [Clang][NFC] Avoid repeating copy of std::string in lambda implementation (PR #153863)

2025-08-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik updated https://github.com/llvm/llvm-project/pull/153863 >From f0c903995ffb19e02394601179f05082c132d037 Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Fri, 15 Aug 2025 12:43:25 -0700 Subject: [PATCH 1/2] [Clang][NFC] Avoid repeating copy of std::string in lambda

[clang] [Clang][NFC] Avoid repeating copy of std::string in lambda implementation (PR #153863)

2025-08-15 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153863 Static analysis flagged this code because it will cause unneeded copies of std::string. This fix is merely to use const auto & in the trailing return type. >From f0c903995ffb19e02394601179f05082c132d037 Mon Sep

[clang] [Clang][Bytecode][NFC] Move Result into APSInt constructor (PR #153664)

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

[clang] [Clang][Bytecode][NFS] Init Semantics non-static member of class Floating (PR #153671)

2025-08-15 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > > Static analysis flagged that the non-static member Semantics was not > > initialized by the default default constructor. Fix is to initialize it > > using in class member initialization. > > Yeah, this might be one better to mark as Intentional in the static analysis > tool;

[clang] [Clang][Webassembly] Remove unrachable code in ParseTypeQualifierListOpt (PR #153729)

2025-08-14 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153729 Static analysis flagged this goto as unreachable and indeed it is, so removing it. >From 98ea646f9fb4331f24cb3492338efa0eaca7763b Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Thu, 14 Aug 2025 19:02:51 -

[clang] [Clang][Sema] Add nullptr check in IsFunctionConversion (PR #153710)

2025-08-14 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153710 Static analysis flagged this code b/c ToFPT could be nullptr but we were not checking it even though in the previous if statement we did. It looks like this was a mistaken refactor from: https://github.com/llvm

[clang] [Clang][Bytecode][NFS] Init Semantics non-static member of class Floating (PR #153671)

2025-08-14 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153671 Static analysis flagged that the non-static member Semantics was not initialized by the default default constructor. Fix is to initialize it using in class member initialization. >From bd93d02c1d7d0ba27ad563a5e

[clang] [Clang][Bytecode][NFC] Move Result into APSInt constructor (PR #153664)

2025-08-14 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153664 Static analysis flagged this line because we are copying Result instead of moving it. >From 8361389ca73e9c70731ef9dd8c7b0fac1f06 Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Thu, 14 Aug 2025 13:05:4

[clang] [Clang][NFC] Clarify some SourceManager related code (PR #153527)

2025-08-14 Thread Shafik Yaghmour via cfe-commits
@@ -1095,6 +1095,8 @@ prepareAndFilterRanges(const SmallVectorImpl &Ranges, unsigned StartColumn = SM.getExpansionColumnNumber(Begin); unsigned EndColumn = SM.getExpansionColumnNumber(End); +assert(StartColumn && "StartColumn has a value of 0"); s

[clang] [clang][clang-scan-deps] Add named modules to format 'experimental-full' (PR #145221)

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

[clang] [clang][clang-scan-deps] Add named modules to format 'experimental-full' (PR #145221)

2025-08-13 Thread Shafik Yaghmour via cfe-commits
@@ -188,13 +192,23 @@ class FullDependencyConsumer : public DependencyConsumer { ContextHash = std::move(Hash); } + void handleProvidedAndRequiredStdCXXModules( + std::optional Provided, + std::vector Requires) override { +ModuleName = Provided ? Provided-

[clang] [clang][clang-scan-deps] Add named modules to format 'experimental-full' (PR #145221)

2025-08-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Apologies for t https://github.com/llvm/llvm-project/pull/145221 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][clang-scan-deps] Add named modules to format 'experimental-full' (PR #145221)

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

[clang] [Clang][NFC] Clarify some SourceManager related code (PR #153527)

2025-08-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153527 Static analysis flagged the columns - 1 code, it was correct but the assumption was not obvious. I document the assumption w/ assertions. While digging through related code I found getColumnNumber that looks wro

[clang] [analyzer] Remove trivially true condition (PR #152850)

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

[clang] [clang][bytecode][NFC] Fix ternary operators with known IsArray values (PR #152894)

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

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2025-08-08 Thread Shafik Yaghmour via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -95,6 +110,30 @@ class UnixAPIPortabilityChecker : public Checker< check::PreStmt > { } // end anonymous namespace +ProgramStateRef UnixAPIMisuseChecker::EnsurePtrNotNull( +SVal PtrVal, const Expr *PtrExpr,

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2025-08-08 Thread Shafik Yaghmour via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/83027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2025-08-08 Thread Shafik Yaghmour via cfe-commits
Alejandro =?utf-8?q?=C3=81lvarez_Ayll=C3=B3n?= Message-ID: In-Reply-To: https://github.com/shafik commented: Also why was the PR closed, it looks like it was landed. CC @steakhal @NagyDonat https://github.com/llvm/llvm-project/pull/83027 ___ cfe-co

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2025-08-08 Thread Shafik Yaghmour via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/83027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

  1   2   3   4   5   6   7   8   9   10   >