[clang] [clang] Fix crash with -lstdc++ in -ccc-print-phases (PR #160047)

2025-09-22 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: This needs summary text, in particular a bit more of explanation of the problem and why these changes fixes it. https://github.com/llvm/llvm-project/pull/160047 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

[clang] [clang][test] Add test for comma operator rejection in preprocessor conditionals (PR #155570)

2025-09-22 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > @shafik was https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#3017 > resolved ? No, it is still active. It looks like [CWG1436](https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1436) is where the action will be moving forward. https://github.com/llvm/ll

[clang] [clang] Restrict -Wnrvo to C++ code only. (PR #157059)

2025-09-20 Thread Shafik Yaghmour via cfe-commits
Javier =?utf-8?q?Mu=C3=B1oz?= Kirschberg Message-ID: In-Reply-To: @@ -0,0 +1,41 @@ +// RUN: %clang -std=c23 -Wnrvo -Xclang -verify %s +// expected-no-diagnostics + +#include + +#define SIZE 20 + +typedef struct String_s { +char* buf; +size_t len; +} String; + + +void c

[clang] [clang][clang-scan-deps] Add LangOptions::AllowLiteralDigitSeparator to fix (#88896) (PR #158420)

2025-09-19 Thread Shafik Yaghmour via cfe-commits
@@ -1000,6 +1001,21 @@ int z = 128'78; EXPECT_STREQ("#include \n", Out.data()); } +TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralInPreprocessor) { + SmallVector Out; + SmallVector Tokens; + SmallVector Directives; + + StringRef Source = R"( +#if 1'2

[clang] [libcxx] [Clang] Allow __builtin_fma/fmaf/fmal to be used in a constant expression (PR #158048)

2025-09-19 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > > Is your suggestion to add tests with different rounding modes? > > Yes, but I think we need a conclusion on the design question before knowing > what such tests would look like. I agree, we need a rationale here. I hope some other more knowledgeable folks will weigh in soon

[clang] [clang][bytecode] Compile the definition, not the most recent decl (PR #158093)

2025-09-19 Thread Shafik Yaghmour via cfe-commits
@@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s +// RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple x86_64-linux-gnu -fexperimental-new-constant-interpreter | FileCheck %s shafik

[clang] [clang] diagnose invalid std::tuple_size sizes (PR #159677)

2025-09-18 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Can you please add a more complete description of the actual underlying problem something along the lines of what I added here: https://github.com/llvm/llvm-project/pull/159579#issuecomment-3310185185 It took me and others a bit to get the original problem

[clang] [clang][ExprConst] Allow mutation in `__builtin_constant_p`'s argument (PR #159599)

2025-09-18 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: I think I would feel more comfortable if there was a justification of why this is allowed. Looking at the [documentation](https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fconstant_005fp) they talk about "constant folding"

[clang] [clang][Sema] Reject negative tuple sizes (PR #159579)

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

[clang] [clang] NFC: introduce UnsignedOrNone as a replacement for std::optional (PR #134142)

2025-09-18 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This is linked to the following regression: https://github.com/llvm/llvm-project/issues/159563 https://github.com/llvm/llvm-project/pull/134142 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [clang][Sema] Reject negative tuple sizes (PR #159579)

2025-09-18 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: You mention `UnsignedOrNone` in the summary but that is not directly involved in the code you modify. It looks like it is used in `GetDecompositionElementCount` which uses `isTupleLike` but the connection is not obvious. https://github.com/llvm/llvm-projec

[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)

2025-09-17 Thread Shafik Yaghmour via cfe-commits
@@ -572,3 +571,19 @@ namespace VectorCast { #endif } #endif + +namespace ToPrimPtrs { + struct S { int foo () { return 0; } }; + auto ptr = __builtin_bit_cast(int *, ((__INTPTR_TYPE__) 0)); + auto nptr = __builtin_bit_cast(nullptr_t, ((__INTPTR_TYPE__)0)); + + constexpr au

[clang] [Clang] Permit implicit conversion from integral to boolean vectors (PR #158369)

2025-09-17 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s + +typedef _Bool bool; + +typedef __attribute__((ext_vector_type(8))) int v8i; +typedef __attribute__((ext_vector_type(8))) bool v8b; +typedef __attribute__((ext_vector_type(4))) float v4f; +typedef __att

[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

2025-09-16 Thread Shafik Yaghmour via cfe-commits
shafik wrote: This is linked to https://github.com/llvm/llvm-project/issues/159080 https://github.com/llvm/llvm-project/pull/68059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-16 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Thank you removing the extra changes, I have one more. It looks good but I would like someone who is more familiar with this area to take a look https://github.com/llvm/llvm-project/pull/158146 ___ cfe-commits mail

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-16 Thread Shafik Yaghmour via cfe-commits
@@ -3321,9 +3321,9 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc, } return D; } - shafik wrote: Please remove this newline https://github.com/llvm/llvm-project/pull/158146 ___ cfe-commits mailing l

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

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

[clang] [clang][bytecode] Pass initializer along in `evaluateAsInitializer()` (PR #158056)

2025-09-16 Thread Shafik Yaghmour via cfe-commits
@@ -49,14 +49,15 @@ EvaluationResult EvalEmitter::interpretExpr(const Expr *E, return std::move(this->EvalResult); } -EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD, +EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD, const Expr *Init,

[clang] [clang] fix range of empty enumeration without fixed underlying type (PR #106841)

2025-09-16 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > @frederick-vs-ja This is currently considered in [CWG > 2932](https://cplusplus.github.io/CWG/issues/2932.html). I will close this > until there is a decision. I am not sure when we will look at that again. We will be heading into handling NB comments, unless this comes up in

[clang] [Sema] Diagnose by-value copy constructors in template instantiations (PR #130866)

2025-09-15 Thread Shafik Yaghmour via cfe-commits
shafik wrote: @avikivity https://lists.isocpp.org/core/2025/03/17665.php https://github.com/llvm/llvm-project/pull/130866 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Use bytecode interpreter in EvaluateAsLValue (PR #158038)

2025-09-13 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: "abort when initalizing a global temporary" vaguely sounds like change in behavior but there is no test. https://github.com/llvm/llvm-project/pull/158038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http

[clang] [clang] fix partial ordering of NTTP packs (PR #134461)

2025-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -7085,18 +7102,24 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ? Context.getIntWidth(IntegerType) : Context.getTypeSize(IntegerType)); - SugaredConverted = TemplateArgum

[clang] [clang] fix partial ordering of NTTP packs (PR #134461)

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

[clang] [clang] fix partial ordering of NTTP packs (PR #134461)

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

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -3321,27 +3321,33 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc, } return D; } - static OMPAllocateDeclAttr::AllocatorTypeTy getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) { + // No allocator expression → Null mem alloc (matches existing

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-13 Thread Shafik Yaghmour via cfe-commits
@@ -3408,8 +3418,7 @@ applyOMPAllocateAttribute(Sema &S, VarDecl *VD, (Alignment->isTypeDependent() || Alignment->isValueDependent() || Alignment->isInstantiationDependent() || Alignment->containsUnexpandedParameterPack())) -// Apply later when we have a

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

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

[clang] [clang][bytecode] Check builtin carryops for dummy pointers (PR #157490)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -36,3 +36,10 @@ void test_builtin_os_log(void *buf, int i, const char *data) { constexpr int len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, data, data); static_assert(len > 0, "Expect len > 0"); } + +void addc_dummy() +{ + unsigned int a;

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3445,30 +3451,27 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPAllocateDirective( else llvm_unreachable("Unexpected clause on allocate directive"); } + // No forward-decl needed; just classify with null-guards. OMPAllocateDeclAttr::AllocatorTypeT

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3321,27 +3321,33 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc, } return D; } - static OMPAllocateDeclAttr::AllocatorTypeTy getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) { + // No allocator expression → Null mem alloc (matches existing

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3445,30 +3451,27 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPAllocateDirective( else llvm_unreachable("Unexpected clause on allocate directive"); } + // No forward-decl needed; just classify with null-guards. OMPAllocateDeclAttr::AllocatorTypeT

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3321,27 +3321,33 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc, } return D; } - static OMPAllocateDeclAttr::AllocatorTypeTy getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) { + // No allocator expression → Null mem alloc (matches existing

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3430,9 +3439,6 @@ SemaOpenMP::DeclGroupPtrTy SemaOpenMP::ActOnOpenMPAllocateDirective( Expr *Allocator = nullptr; if (Clauses.empty()) { // OpenMP 5.0, 2.11.3 allocate Directive, Restrictions. -// allocate directives that appear in a target region must specify

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3321,27 +3321,33 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc, } return D; } - static OMPAllocateDeclAttr::AllocatorTypeTy getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) { + // No allocator expression → Null mem alloc (matches existing

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
@@ -3321,27 +3321,33 @@ SemaOpenMP::CheckOMPThreadPrivateDecl(SourceLocation Loc, } return D; } - static OMPAllocateDeclAttr::AllocatorTypeTy getAllocatorKind(Sema &S, DSAStackTy *Stack, Expr *Allocator) { + // No allocator expression → Null mem alloc (matches existing

[clang] [flang] [clang][OpenMP] Diagnose invalid allocator in `#pragma omp allocate`; avoid null deref (PR #158146)

2025-09-12 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Thank you for you PR, there are a bunch of small issues and some questions that need replies. https://github.com/llvm/llvm-project/pull/158146 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.l

[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

  1   2   3   4   5   6   7   8   9   10   >