[clang] [clang][Sema][FMV] Add a note to the 'cannot become multiversioned' diagnostic (PR #124364)
https://github.com/labrinea approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/124364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Younan Zhang (zyn0217) Changes We used to always transform the pattern declaration for SizeOfPackExpr to ensure the constraint expression's profile produced the desired result. However, this approach failed to handle pack expansions when the pack referred to function parameters. In such cases, the function parameters were formerly expanded to 1 to avoid building Subst* nodes (see e6974daa7). That workaround caused us to transform a pack without a proper ArgumentPackSubstitutionIndex, leading to crashes when transforming the pattern. It turns out that profiling the pattern for partially substituted SizeOfPackExprs is unnecessary because their transformed forms are also profiled within the partial arguments. Fixes https://github.com/llvm/llvm-project/issues/124161 --- Full diff: https://github.com/llvm/llvm-project/pull/124533.diff 4 Files Affected: - (modified) clang/include/clang/AST/ExprCXX.h (-2) - (modified) clang/lib/AST/StmtProfile.cpp (+1-1) - (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (-17) - (modified) clang/test/SemaTemplate/concepts-out-of-line-def.cpp (+28) ``diff diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 4cec89c979f775..04529fa616d703 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -4326,8 +4326,6 @@ class SizeOfPackExpr final /// Retrieve the parameter pack. NamedDecl *getPack() const { return Pack; } - void setPack(NamedDecl *NewPack) { Pack = NewPack; } - /// Retrieve the length of the parameter pack. /// /// This routine may only be invoked when the expression is not diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index 0f1ebc68a4f762..089d91d2736459 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -2266,13 +2266,13 @@ void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { VisitExpr(S); - VisitDecl(S->getPack()); if (S->isPartiallySubstituted()) { auto Args = S->getPartialArguments(); ID.AddInteger(Args.size()); for (const auto &TA : Args) VisitTemplateArgument(TA); } else { +VisitDecl(S->getPack()); ID.AddInteger(0); } } diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 839c4e8a28220b..98bc630fb69cc5 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1747,23 +1747,6 @@ namespace { return inherited::TransformLambdaBody(E, Body); } -ExprResult TransformSizeOfPackExpr(SizeOfPackExpr *E) { - ExprResult Transformed = inherited::TransformSizeOfPackExpr(E); - if (!Transformed.isUsable()) -return Transformed; - auto *TransformedExpr = cast(Transformed.get()); - if (SemaRef.CodeSynthesisContexts.back().Kind == - Sema::CodeSynthesisContext::ConstraintNormalization && - TransformedExpr->getPack() == E->getPack()) { -Decl *NewPack = -TransformDecl(E->getPackLoc(), TransformedExpr->getPack()); -if (!NewPack) - return ExprError(); -TransformedExpr->setPack(cast(NewPack)); - } - return TransformedExpr; -} - ExprResult TransformRequiresExpr(RequiresExpr *E) { LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true); ExprResult TransReq = inherited::TransformRequiresExpr(E); diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp index 7cb5cfc10b9a7b..16779ba184296d 100644 --- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp +++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp @@ -720,6 +720,34 @@ template struct d { template struct c; template struct d; +namespace Regression_123441 { + +struct buf { + constexpr buf(auto&&... initList) requires (sizeof...(initList) <= 8); +}; + +constexpr buf::buf(auto&&... initList) requires (sizeof...(initList) <= 8) {} + +template +struct buffer { + constexpr buffer(auto&&... initList) requires (sizeof...(initList) <= 8); +}; + +template +constexpr buffer::buffer(auto&&... initList) requires (sizeof...(initList) <= 8) {} + +template +struct foo { // expected-note {{foo defined here}} + constexpr foo(auto&&... initList) +requires (sizeof...(initList) <= 8); +}; + +template +constexpr foo::foo(auto&&... initList) // expected-error {{does not match any declaration}} + requires (sizeof...(T) <= 8) {} + +} + } // namespace GH115098 namespace GH114685 { `` https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/124533 We used to always transform the pattern declaration for SizeOfPackExpr to ensure the constraint expression's profile produced the desired result. However, this approach failed to handle pack expansions when the pack referred to function parameters. In such cases, the function parameters were formerly expanded to 1 to avoid building Subst* nodes (see e6974daa7). That workaround caused us to transform a pack without a proper ArgumentPackSubstitutionIndex, leading to crashes when transforming the pattern. It turns out that profiling the pattern for partially substituted SizeOfPackExprs is unnecessary because their transformed forms are also profiled within the partial arguments. Fixes https://github.com/llvm/llvm-project/issues/124161 >From b195bfb253df84ea315eb92a59bbae2401b0248f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 27 Jan 2025 19:48:43 +0800 Subject: [PATCH] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr We used to always transform the pattern declaration for SizeOfPackExpr to ensure the constraint expression's profile produced the desired result. However, this approach failed to handle pack expansions when the pack referred to function parameters. In such cases, the function parameters were previously expanded to 1 to avoid building Subst* nodes (see e6974daa7). That workaround caused us to transform a pack without a proper ArgumentPackSubstitutionIndex, leading to crashes when transforming the pattern. It turns out that profiling the pattern for partially substituted SizeOfPackExprs is unnecessary because their transformed forms are already profiled within the partial arguments. Moreover, we always end up with a partially transformed SizeOfPackExpr for constraint comparison. --- clang/include/clang/AST/ExprCXX.h | 2 -- clang/lib/AST/StmtProfile.cpp | 2 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 17 --- .../SemaTemplate/concepts-out-of-line-def.cpp | 28 +++ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 4cec89c979f775..04529fa616d703 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -4326,8 +4326,6 @@ class SizeOfPackExpr final /// Retrieve the parameter pack. NamedDecl *getPack() const { return Pack; } - void setPack(NamedDecl *NewPack) { Pack = NewPack; } - /// Retrieve the length of the parameter pack. /// /// This routine may only be invoked when the expression is not diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index 0f1ebc68a4f762..089d91d2736459 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -2266,13 +2266,13 @@ void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { VisitExpr(S); - VisitDecl(S->getPack()); if (S->isPartiallySubstituted()) { auto Args = S->getPartialArguments(); ID.AddInteger(Args.size()); for (const auto &TA : Args) VisitTemplateArgument(TA); } else { +VisitDecl(S->getPack()); ID.AddInteger(0); } } diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 839c4e8a28220b..98bc630fb69cc5 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1747,23 +1747,6 @@ namespace { return inherited::TransformLambdaBody(E, Body); } -ExprResult TransformSizeOfPackExpr(SizeOfPackExpr *E) { - ExprResult Transformed = inherited::TransformSizeOfPackExpr(E); - if (!Transformed.isUsable()) -return Transformed; - auto *TransformedExpr = cast(Transformed.get()); - if (SemaRef.CodeSynthesisContexts.back().Kind == - Sema::CodeSynthesisContext::ConstraintNormalization && - TransformedExpr->getPack() == E->getPack()) { -Decl *NewPack = -TransformDecl(E->getPackLoc(), TransformedExpr->getPack()); -if (!NewPack) - return ExprError(); -TransformedExpr->setPack(cast(NewPack)); - } - return TransformedExpr; -} - ExprResult TransformRequiresExpr(RequiresExpr *E) { LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true); ExprResult TransReq = inherited::TransformRequiresExpr(E); diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp index 7cb5cfc10b9a7b..16779ba184296d 100644 --- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp +++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp @@ -720,6 +720,34 @@ template struct d { template struct c; template struct d; +namespace Regression_123441 { + +struct buf { + constexpr buf(au
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
@@ -720,6 +720,34 @@ template struct d { template struct c; template struct d; +namespace Regression_123441 { + +struct buf { + constexpr buf(auto&&... initList) requires (sizeof...(initList) <= 8); +}; + +constexpr buf::buf(auto&&... initList) requires (sizeof...(initList) <= 8) {} + +template +struct buffer { + constexpr buffer(auto&&... initList) requires (sizeof...(initList) <= 8); +}; + +template +constexpr buffer::buffer(auto&&... initList) requires (sizeof...(initList) <= 8) {} + +template +struct foo { // expected-note {{foo defined here}} + constexpr foo(auto&&... initList) +requires (sizeof...(initList) <= 8); +}; + +template +constexpr foo::foo(auto&&... initList) // expected-error {{does not match any declaration}} + requires (sizeof...(T) <= 8) {} + +} + } // namespace GH115098 namespace GH114685 { cor3ntin wrote: Did you meant to be nested in another namespace ? https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
https://github.com/cor3ntin approved this pull request. LGTM except for nits https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
@@ -720,6 +720,34 @@ template struct d { template struct c; template struct d; +namespace Regression_123441 { cor3ntin wrote: ```suggestion namespace GH123441 { ``` https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Treat `f(a)` as template function call (PR #124438)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/124438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)
zahiraam wrote: ping @Meinersbur and @alexey-bataev https://github.com/llvm/llvm-project/pull/119891 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Optimize CLC vector relational builtins (PR #124537)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/124537 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)
https://github.com/michael-jabbour-sonarsource edited https://github.com/llvm/llvm-project/pull/114240 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
zahiraam wrote: ping @mjklemm. https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] default clause replaced by otherwise clause in metadirective in OpenMP 5.2 (PR #124550)
https://github.com/ravurvi20 created https://github.com/llvm/llvm-project/pull/124550 This PR replaces the `default` clause with the `otherwise` clause for the `metadirective` in OpenMP. The `otherwise` clause serves as a fallback condition when no directive from the `when` clauses is selected. In the `when` clause, context selectors define traits that are evaluated to determine the directive to be applied. >From 6c3312653b9891125cf5d8678e575d4e5f15db69 Mon Sep 17 00:00:00 2001 From: Urvi Rav Date: Mon, 27 Jan 2025 08:12:15 -0600 Subject: [PATCH] default clause replaced by otherwise clause in metadirective --- .../clang/Basic/DiagnosticParseKinds.td | 4 clang/lib/Basic/OpenMPKinds.cpp | 2 ++ clang/lib/Parse/ParseOpenMP.cpp | 15 ++ clang/test/OpenMP/metadirective_ast_print.c | 20 +-- .../metadirective_device_arch_codegen.cpp | 2 +- .../metadirective_device_isa_codegen.cpp | 4 ++-- ...etadirective_device_isa_codegen_amdgcn.cpp | 4 ++-- .../metadirective_device_kind_codegen.c | 2 +- .../metadirective_device_kind_codegen.cpp | 2 +- clang/test/OpenMP/metadirective_empty.cpp | 4 ++-- .../metadirective_implementation_codegen.c| 12 +-- .../metadirective_implementation_codegen.cpp | 12 +-- clang/test/OpenMP/metadirective_messages.cpp | 11 ++ llvm/include/llvm/Frontend/OpenMP/OMP.td | 5 + 14 files changed, 64 insertions(+), 35 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 3309f59a981fc1..5b7cc463a7d08e 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1647,6 +1647,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"unknown clause '%0' in %1">; +def warn_omp_default_deprecated : Warning<"'default' clause for" + " 'metadirective' is deprecated; use 'otherwise' instead">, InGroup; def err_omp_requires_out_inout_depend_type : Error< "reserved locator 'omp_all_memory' requires 'out' or 'inout' " "dependency types">; diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index 62a13f01481b28..a093f7a3b260ff 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -246,6 +246,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str, case OMPC_uses_allocators: case OMPC_affinity: case OMPC_when: + case OMPC_otherwise: case OMPC_append_args: break; default: @@ -580,6 +581,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, case OMPC_uses_allocators: case OMPC_affinity: case OMPC_when: + case OMPC_otherwise: case OMPC_append_args: break; default: diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 89b83938f352df..673806ef28b9fc 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2743,6 +2743,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( OpenMPClauseKind CKind = Tok.isAnnotation() ? OMPC_unknown : getOpenMPClauseKind(PP.getSpelling(Tok)); + // Check if the clause is unrecognized. + if (CKind == OMPC_unknown) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; +return Directive; + } + if(CKind == OMPC_default) { +Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2769,6 +2778,12 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( return Directive; } } + if (CKind == OMPC_otherwise) { +// Check for 'otherwise' keyword. +if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->getName() == "otherwise") { +ConsumeToken(); // Consume 'otherwise' +} + } // Skip Directive for now. We will parse directive in the second iteration int paren = 0; while (Tok.isNot(tok::r_paren) || paren != 0) { diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c index d9ff7e76452160..28efaac5949427 100644 --- a/clang/test/OpenMP/metadirective_ast_print.c +++ b/clang/test/OpenMP/metadirective_ast_print.c @@ -15,18 +15,18 @@ void bar(void); #define N 10 void foo(void) { #pragma omp metadirective when(device = {kind(cpu)} \ - : parallel) default() + : parallel) otherwise() bar(); #pragma omp metadirective when(implementation =
[clang] [llvm] default clause replaced by otherwise clause in metadirective in OpenMP 5.2 (PR #124550)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/124550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Address false positives in misc-redundant-expression checker (PR #122841)
earnol wrote: All comments had been addressed, are there any additional suggestions? https://github.com/llvm/llvm-project/pull/122841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] only inherit the parent eval context inside of lambdas (PR #124426)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/124426 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] default clause replaced by otherwise clause in metadirective in OpenMP 5.2 (PR #124550)
https://github.com/ravurvi20 closed https://github.com/llvm/llvm-project/pull/124550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] default clause replaced by otherwise clause in metadirective in OpenMP 5.2 (PR #124550)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Urvi Rav (ravurvi20) Changes This PR replaces the `default` clause with the `otherwise` clause for the `metadirective` in OpenMP. The `otherwise` clause serves as a fallback condition when no directive from the `when` clauses is selected. In the `when` clause, context selectors define traits that are evaluated to determine the directive to be applied. --- Full diff: https://github.com/llvm/llvm-project/pull/124550.diff 14 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+4) - (modified) clang/lib/Basic/OpenMPKinds.cpp (+2) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+15) - (modified) clang/test/OpenMP/metadirective_ast_print.c (+10-10) - (modified) clang/test/OpenMP/metadirective_device_arch_codegen.cpp (+1-1) - (modified) clang/test/OpenMP/metadirective_device_isa_codegen.cpp (+2-2) - (modified) clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp (+2-2) - (modified) clang/test/OpenMP/metadirective_device_kind_codegen.c (+1-1) - (modified) clang/test/OpenMP/metadirective_device_kind_codegen.cpp (+1-1) - (modified) clang/test/OpenMP/metadirective_empty.cpp (+2-2) - (modified) clang/test/OpenMP/metadirective_implementation_codegen.c (+6-6) - (modified) clang/test/OpenMP/metadirective_implementation_codegen.cpp (+6-6) - (modified) clang/test/OpenMP/metadirective_messages.cpp (+7-4) - (modified) llvm/include/llvm/Frontend/OpenMP/OMP.td (+5) ``diff diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 3309f59a981fc1..5b7cc463a7d08e 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1647,6 +1647,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"unknown clause '%0' in %1">; +def warn_omp_default_deprecated : Warning<"'default' clause for" + " 'metadirective' is deprecated; use 'otherwise' instead">, InGroup; def err_omp_requires_out_inout_depend_type : Error< "reserved locator 'omp_all_memory' requires 'out' or 'inout' " "dependency types">; diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp index 62a13f01481b28..a093f7a3b260ff 100644 --- a/clang/lib/Basic/OpenMPKinds.cpp +++ b/clang/lib/Basic/OpenMPKinds.cpp @@ -246,6 +246,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str, case OMPC_uses_allocators: case OMPC_affinity: case OMPC_when: + case OMPC_otherwise: case OMPC_append_args: break; default: @@ -580,6 +581,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, case OMPC_uses_allocators: case OMPC_affinity: case OMPC_when: + case OMPC_otherwise: case OMPC_append_args: break; default: diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 89b83938f352df..673806ef28b9fc 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2743,6 +2743,15 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( OpenMPClauseKind CKind = Tok.isAnnotation() ? OMPC_unknown : getOpenMPClauseKind(PP.getSpelling(Tok)); + // Check if the clause is unrecognized. + if (CKind == OMPC_unknown) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; +return Directive; + } + if(CKind == OMPC_default) { +Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2769,6 +2778,12 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( return Directive; } } + if (CKind == OMPC_otherwise) { +// Check for 'otherwise' keyword. +if (Tok.is(tok::identifier) && Tok.getIdentifierInfo()->getName() == "otherwise") { +ConsumeToken(); // Consume 'otherwise' +} + } // Skip Directive for now. We will parse directive in the second iteration int paren = 0; while (Tok.isNot(tok::r_paren) || paren != 0) { diff --git a/clang/test/OpenMP/metadirective_ast_print.c b/clang/test/OpenMP/metadirective_ast_print.c index d9ff7e76452160..28efaac5949427 100644 --- a/clang/test/OpenMP/metadirective_ast_print.c +++ b/clang/test/OpenMP/metadirective_ast_print.c @@ -15,18 +15,18 @@ void bar(void); #define N 10 void foo(void) { #pragma omp metadirective when(device = {kind(cpu)} \ - : parallel) default() + : parallel) otherwise() bar(); #pragma omp metadirective when(implementation = {vendor(score(0)
[clang] [llvm] default clause replaced by otherwise clause in metadirective in OpenMP 5.2 (PR #124550)
https://github.com/ravurvi20 converted_to_draft https://github.com/llvm/llvm-project/pull/124550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] eaa5897 - [libclc] Optimize CLC vector is(un)ordered builtins (#124546)
Author: Fraser Cormack Date: 2025-01-27T14:41:40Z New Revision: eaa5897534cbd263d0cdbf780f72133c2fe8d8d4 URL: https://github.com/llvm/llvm-project/commit/eaa5897534cbd263d0cdbf780f72133c2fe8d8d4 DIFF: https://github.com/llvm/llvm-project/commit/eaa5897534cbd263d0cdbf780f72133c2fe8d8d4.diff LOG: [libclc] Optimize CLC vector is(un)ordered builtins (#124546) These are similar to 347fb208, but these builtins are expressed in terms of other builtins. The LLVM IR generated features the same fcmp ord/uno comparisons as before, but consistently in vector form. Added: Modified: libclc/clc/include/clc/relational/relational.h libclc/clc/lib/generic/relational/clc_isordered.cl libclc/clc/lib/generic/relational/clc_isunordered.cl Removed: diff --git a/libclc/clc/include/clc/relational/relational.h b/libclc/clc/include/clc/relational/relational.h index f32e7630203e4b..f269715cfc83c9 100644 --- a/libclc/clc/include/clc/relational/relational.h +++ b/libclc/clc/include/clc/relational/relational.h @@ -63,85 +63,6 @@ ARG_TYPE) \ _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, FUNCTION, ARG_TYPE) -#define _CLC_DEFINE_RELATIONAL_BINARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_NAME, \ - ARG0_TYPE, ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return BUILTIN_NAME(x, y); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo, y.lo), \ - FUNCTION(x.hi, y.hi)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC2(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo, y.lo), \ - FUNCTION(x.hi, y.hi)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC3(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC4(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2), \ - FUNCTION(x.s3, y.s3)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC8(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2), FUNCTION(x.s3, y.s3), \ - FUNCTION(x.s4, y.s4), FUNCTION(x.s5, y.s5), \ - FUNCTION(x.s6, y.s6), \ - FUNCTION(x.s7, y.s7)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC16(RET_TYPE, FUNCTION, ARG0_TYPE, \ -ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2), FUNCTION(x.s3, y.s3), \ - FUNCTION(x.s4, y.s4), FUNCTION(x.s5, y.s5), \ - FUNCTION(x.s6, y.s6), FUNCTION(x.s7, y.s7), \ - FUNCTION(x.s8, y.s8), FUNCTION(x.s9, y.s9), \ - FUNCTION(x.sa, y.sa), FUNCTION(x.sb, y.sb), \ - FUNCTION(x.sc, y.sc), FUNCTION(x.sd, y.sd), \ - FUNCTION(x.se, y.se), \ -
[libclc] [libclc] Optimize CLC vector is(un)ordered builtins (PR #124546)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/124546 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 54928a1 - [clang] __STDC_NO_THREADS__ is no longer necessary for VS 2022 1939 and above (#117149)
Author: Dipesh Sharma Date: 2025-01-27T09:30:53-05:00 New Revision: 54928a10c8dba7c07c6224c1ead5c02a335890e6 URL: https://github.com/llvm/llvm-project/commit/54928a10c8dba7c07c6224c1ead5c02a335890e6 DIFF: https://github.com/llvm/llvm-project/commit/54928a10c8dba7c07c6224c1ead5c02a335890e6.diff LOG: [clang] __STDC_NO_THREADS__ is no longer necessary for VS 2022 1939 and above (#117149) Since `__STDC_NO_THREADS__` is a reserved identifier, - If `MSVC version < 17.9` - C version < C11(201112L) - When `` is unavailable `!__has_include()` is `__has_include` is defined. Closes #115529 Added: clang/test/Preprocessor/deprecate-threads-macro-definition-msvc1939.c Modified: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/LangOptions.h clang/lib/Basic/Targets/OSTargets.cpp clang/test/Preprocessor/init-aarch64.c Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c60565a568234a..55a4a2e32383a6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -387,6 +387,7 @@ C Language Changes -- - Extend clang's to define ``LONG_LONG_*`` macros for Android's bionic. +- Macro ``__STDC_NO_THREADS__`` is no longer necessary for MSVC 2022 1939 and later. C2y Feature Support ^^^ diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 949c8f5d448bcf..114a5d34a008bd 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -144,6 +144,7 @@ class LangOptionsBase { MSVC2019_5 = 1925, MSVC2019_8 = 1928, MSVC2022_3 = 1933, +MSVC2022_9 = 1939, }; enum SYCLMajorVersion { diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp index bf10f9a725567d..8af6623e5cb15a 100644 --- a/clang/lib/Basic/Targets/OSTargets.cpp +++ b/clang/lib/Basic/Targets/OSTargets.cpp @@ -259,8 +259,10 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) { Builder.defineMacro("_KERNEL_MODE"); Builder.defineMacro("_INTEGRAL_MAX_BITS", "64"); - Builder.defineMacro("__STDC_NO_THREADS__"); - + // Define __STDC_NO_THREADS__ based on MSVC version, threads.h availability, + // and language standard. + if (!(Opts.isCompatibleWithMSVC(LangOptions::MSVC2022_9) && Opts.C11)) +Builder.defineMacro("__STDC_NO_THREADS__"); // Starting with VS 2022 17.1, MSVC predefines the below macro to inform // users of the execution character set defined at compile time. // The value given is the Windows Code Page Identifier: diff --git a/clang/test/Preprocessor/deprecate-threads-macro-definition-msvc1939.c b/clang/test/Preprocessor/deprecate-threads-macro-definition-msvc1939.c new file mode 100644 index 00..e197d8d403a3f5 --- /dev/null +++ b/clang/test/Preprocessor/deprecate-threads-macro-definition-msvc1939.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c89 -fms-compatibility-version=19.33 -ffreestanding < /dev/null | FileCheck -check-prefix=C89_MSVC33 %s +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c99 -fms-compatibility-version=19.33 -ffreestanding < /dev/null | FileCheck -check-prefix=C99_MSVC33 %s +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c11 -fms-compatibility-version=19.33 -ffreestanding < /dev/null | FileCheck -check-prefix=C11_MSVC33 %s +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c89 -fms-compatibility-version=19.39 -ffreestanding < /dev/null | FileCheck -check-prefix=C89_MSVC39 %s +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c99 -fms-compatibility-version=19.39 -ffreestanding < /dev/null | FileCheck -check-prefix=C99_MSVC39 %s +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c11 -fms-compatibility-version=19.39 -ffreestanding < /dev/null | FileCheck -check-prefix=C11_MSVC39 %s +// RUN: %clang_cc1 -E -dM -triple=arm64ec-windows-msvc -std=c11 -fms-compatibility-version=19.40 -ffreestanding < /dev/null | FileCheck -check-prefix=C11_MSVC40 %s + +// C89_MSVC33: #define __STDC_NO_THREADS__ 1 +// C99_MSVC33: #define __STDC_NO_THREADS__ 1 +// C11_MSVC33: #define __STDC_NO_THREADS__ 1 +// C89_MSVC39: #define __STDC_NO_THREADS__ 1 +// C99_MSVC39: #define __STDC_NO_THREADS__ 1 +// C11_MSVC39-NOT: #define __STDC_NO_THREADS__ +// C11_MSVC40-NOT: #define __STDC_NO_THREADS__ diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c index b5e77ba10c3472..5f47de4b49b699 100644 --- a/clang/test/Preprocessor/init-aarch64.c +++ b/clang/test/Preprocessor/init-aarch64.c @@ -772,7 +772,7 @@ // AARCH64-MSVC: #define __WINT_WIDTH__ 16 // AARCH64-MSVC: #define __aarch64__ 1 -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm64ec-windows-msvc < /dev/null | FileCheck -match-full-lines -check
[clang] [clang] Fix `gnu::init_priority` attribute handling for reserved values (PR #121577)
@@ -3324,6 +3324,9 @@ def err_attribute_argument_out_of_range : Error< def err_init_priority_object_attr : Error< "can only use 'init_priority' attribute on file-scope definitions " "of objects of class type">; +def warn_init_priority_reserved : Warning< AaronBallman wrote: Sorry, my fault for being unclear! :-) There are three attributes which all take a "priority" value with a reserved range: `init_priority`, `constructor`, and `destructor`. Currently, `init_priority` diagnoses use of reserved values, while `constructor` and `destructor` do not. I was wondering if we should make them consistent. However, I don't think that needs to be done in this patch (or something you need to do in a follow-up); I didn't realize they were *already* inconsistent today. https://github.com/llvm/llvm-project/pull/121577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix `gnu::init_priority` attribute handling for reserved values (PR #121577)
@@ -24,32 +24,35 @@ extern Two goo; extern Two coo[]; extern Two koo[]; +// unknown-system-no-diagnostics AaronBallman wrote: Can you also add a new `RUN` line like: ``` // RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -Wno-error=init-priority-reserved -verify %s ``` to verify that we get warnings rather than errors when we downgrade the diagnostic level? https://github.com/llvm/llvm-project/pull/121577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix `gnu::init_priority` attribute handling for reserved values (PR #121577)
https://github.com/AaronBallman commented: Aside from a minor testing nit, I think the only thing left is to add a release note to `clang/docs/ReleaseNotes.rst` so users know about the change. https://github.com/llvm/llvm-project/pull/121577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix immediate escalation of template function specializations. (PR #124404)
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/124404 >From fa548f2d75fbb6fde21ebbf937a93494e600a6e7 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Sat, 25 Jan 2025 13:17:27 +0100 Subject: [PATCH] [Clang] Fix immediate escalation. We record whether an expression is immediate escalating in the FunctionScope. However, that only happen when parsing or transforming an expression. This might not happen when transforming a non dependent expression. This patch fixes that by considering a function immediate when instantiated from an immediate function. --- clang/docs/ReleaseNotes.rst| 1 + clang/lib/AST/Decl.cpp | 4 .../test/SemaCXX/cxx2b-consteval-propagate.cpp | 18 ++ 3 files changed, 23 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e9fffddd507c66..1209ba3ec923d9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -991,6 +991,7 @@ Bug Fixes to C++ Support - Fixed assertions or false compiler diagnostics in the case of C++ modules for lambda functions or inline friend functions defined inside templates (#GH122493). - Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423) +- Fixed immediate escalation of non-dependent expressions. (#GH123405) Bug Fixes to AST Handling ^ diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 5ce03ce20d2841..4753b1727f0dd4 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3314,6 +3314,10 @@ bool FunctionDecl::isImmediateFunction() const { .getConstructor() ->isImmediateFunction(); + if (FunctionDecl *P = getTemplateInstantiationPattern(); + P && P->isImmediateFunction()) +return true; + if (const auto *MD = dyn_cast(this); MD && MD->isLambdaStaticInvoker()) return MD->getParent()->getLambdaCallOperator()->isImmediateFunction(); diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp index 3f3123eaee76b6..222d482f40aa5d 100644 --- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -528,3 +528,21 @@ D d(0); // expected-note {{in implicit initialization for inherited constructor // expected-error@-1 {{call to immediate function 'GH112677::D::SimpleCtor' is not a constant expression}} } + +namespace GH123405 { + +consteval void fn() {} + +template +constexpr int tfn(int) { +auto p = &fn; // expected-note {{'tfn' is an immediate function because its body evaluates the address of a consteval function 'fn'}} +return int(p); // expected-error {{cast from pointer to smaller type 'int' loses information}} +} + +int g() { + int a; // expected-note {{declared here}} + return tfn(a); // expected-error {{call to immediate function 'GH123405::tfn' is not a constant expression}}\ + // expected-note {{read of non-const variable 'a' is not allowed in a constant expression}} +} + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix immediate escalation of template function specializations. (PR #124404)
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/124404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 561132e - [Clang] Fix immediate escalation of template function specializations. (#124404)
Author: cor3ntin Date: 2025-01-27T15:50:51+01:00 New Revision: 561132e71b29d9b747dfda1509f715847852f77b URL: https://github.com/llvm/llvm-project/commit/561132e71b29d9b747dfda1509f715847852f77b DIFF: https://github.com/llvm/llvm-project/commit/561132e71b29d9b747dfda1509f715847852f77b.diff LOG: [Clang] Fix immediate escalation of template function specializations. (#124404) We record whether an expression is immediate escalating in the FunctionScope. However, that only happen when parsing or transforming an expression. This might not happen when transforming a non dependent expression. This patch fixes that by considering a function immediate when instantiated from an immediate function. Fixes #123405 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/AST/Decl.cpp clang/test/SemaCXX/cxx2b-consteval-propagate.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 55a4a2e32383a6..031c5d84e49f97 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1003,6 +1003,7 @@ Bug Fixes to C++ Support - Fixed assertions or false compiler diagnostics in the case of C++ modules for lambda functions or inline friend functions defined inside templates (#GH122493). - Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423) +- Fixed immediate escalation of non-dependent expressions. (#GH123405) - Fix type of expression when calling a template which returns an ``__array_rank`` querying a type depending on a template parameter. Now, such expression can be used with ``static_assert`` and ``constexpr``. (#GH123498) - Correctly determine the implicit constexprness of lambdas in dependent contexts. (#GH97958) (#GH114234) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 74bcb618f2950f..728556614e632f 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3314,6 +3314,10 @@ bool FunctionDecl::isImmediateFunction() const { .getConstructor() ->isImmediateFunction(); + if (FunctionDecl *P = getTemplateInstantiationPattern(); + P && P->isImmediateFunction()) +return true; + if (const auto *MD = dyn_cast(this); MD && MD->isLambdaStaticInvoker()) return MD->getParent()->getLambdaCallOperator()->isImmediateFunction(); diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp index 3f3123eaee76b6..222d482f40aa5d 100644 --- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -528,3 +528,21 @@ D d(0); // expected-note {{in implicit initialization for inherited constructor // expected-error@-1 {{call to immediate function 'GH112677::D::SimpleCtor' is not a constant expression}} } + +namespace GH123405 { + +consteval void fn() {} + +template +constexpr int tfn(int) { +auto p = &fn; // expected-note {{'tfn' is an immediate function because its body evaluates the address of a consteval function 'fn'}} +return int(p); // expected-error {{cast from pointer to smaller type 'int' loses information}} +} + +int g() { + int a; // expected-note {{declared here}} + return tfn(a); // expected-error {{call to immediate function 'GH123405::tfn' is not a constant expression}}\ + // expected-note {{read of non-const variable 'a' is not allowed in a constant expression}} +} + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] call HandleImmediateInvocation before checking for immediate escacalating expressions (PR #124414)
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/124414 >From 220988c7a2fb6873e22680e6131c91e563d7c2f3 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Sat, 25 Jan 2025 16:54:18 +0100 Subject: [PATCH 1/2] [Clang] call HandleImmediateInvocation before checking for immediate escacalating expressions HandleImmediateInvocation can call MarkExpressionAsImmediateEscalating and should always be called before CheckImmediateEscalatingFunctionDefinition. However, we were not doing that in `ActFunctionBody`. We simply move CheckImmediateEscalatingFunctionDefinition to PopExpressionEvaluationContext. Fixes #119046 --- clang/docs/ReleaseNotes.rst| 1 + clang/include/clang/Sema/Sema.h| 6 +++--- clang/lib/Sema/SemaDecl.cpp| 1 - clang/lib/Sema/SemaExpr.cpp| 3 +++ clang/test/CodeGenCXX/gh119046.cpp | 32 ++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 clang/test/CodeGenCXX/gh119046.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e9fffddd507c66..f52c304f316692 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -991,6 +991,7 @@ Bug Fixes to C++ Support - Fixed assertions or false compiler diagnostics in the case of C++ modules for lambda functions or inline friend functions defined inside templates (#GH122493). - Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423) +- Fix that some dependent immediate expressions did not cause immediate escalation (#GH119046) Bug Fixes to AST Handling ^ diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4d6e02fe2956e0..b3b24f04762717 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13136,10 +13136,10 @@ class Sema final : public SemaBase { ~SynthesizedFunctionScope() { if (PushedCodeSynthesisContext) S.popCodeSynthesisContext(); - if (auto *FD = dyn_cast(S.CurContext)) { + + if (auto *FD = dyn_cast(S.CurContext)) FD->setWillHaveBody(false); -S.CheckImmediateEscalatingFunctionDefinition(FD, S.getCurFunction()); - } + S.PopExpressionEvaluationContext(); S.PopFunctionScopeInfo(); } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ad49eac66e98e5..49f5d36383a881 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -16016,7 +16016,6 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (!FD->isDeletedAsWritten()) FD->setBody(Body); FD->setWillHaveBody(false); - CheckImmediateEscalatingFunctionDefinition(FD, FSI); if (getLangOpts().CPlusPlus14) { if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() && diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d5273d463d7c01..6c0710c12b78a2 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -17876,6 +17876,9 @@ void Sema::PopExpressionEvaluationContext() { WarnOnPendingNoDerefs(Rec); HandleImmediateInvocations(*this, Rec); + if (auto *FD = dyn_cast(CurContext); FD && getCurFunction()) +CheckImmediateEscalatingFunctionDefinition(FD, getCurFunction()); + // Warn on any volatile-qualified simple-assignments that are not discarded- // value expressions nor unevaluated operands (those cases get removed from // this list by CheckUnusedVolatileAssignment). diff --git a/clang/test/CodeGenCXX/gh119046.cpp b/clang/test/CodeGenCXX/gh119046.cpp new file mode 100644 index 00..cad76879f08624 --- /dev/null +++ b/clang/test/CodeGenCXX/gh119046.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -std=c++2a -triple x86_64-elf-gnu %s -emit-llvm -o - | FileCheck %s + +struct S { +consteval void operator()() {} +}; + +template +constexpr void dispatch(Fn fn) { +fn(); +} + +template +struct value_visitor { +constexpr void operator()() { visitor(); } +Visitor&& visitor; +}; + +template +constexpr auto make_dispatch() { +return dispatch>; +} + +template +constexpr void visit(Visitor&&) { +make_dispatch(); +} + +void f() { visit(S{}); } + +// CHECK: define {{.*}} @_Z1fv +// CHECK-NOT: define {{.*}} @_Z5visitI1SEvOT_ +// CHECK-NOT: define {{.*}} @_Z13make_dispatchI1SEDav >From 92bd92a10cd75a6c9feff803d837cffdb7b220b5 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Sun, 26 Jan 2025 13:58:49 +0100 Subject: [PATCH 2/2] Add additional test --- .../test/SemaCXX/cxx2b-consteval-propagate.cpp | 17 + 1 file changed, 17 insertions(+) diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp index 3f3123eaee76b6..1fb22e7cfa8e58 100644 --- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -528,3 +528,20 @@ D d(0); // e
[clang] [llvm] [Clang] [OpenMP] Add support for '#pragma omp stripe'. (PR #119891)
@@ -14477,6 +14485,268 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef Clauses, buildPreInits(Context, PreInits)); } +StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef Clauses, + Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc) { + ASTContext &Context = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + + const auto *SizesClause = + OMPExecutableDirective::getSingleClause(Clauses); + if (!SizesClause || llvm::is_contained(SizesClause->getSizesRefs(), nullptr)) +return StmtError(); + unsigned NumLoops = SizesClause->getNumSizes(); + + // Empty statement should only be possible if there already was an error. + if (!AStmt) +return StmtError(); + + // Verify and diagnose loop nest. + SmallVector LoopHelpers(NumLoops); + Stmt *Body = nullptr; + SmallVector, 4> OriginalInits; + if (!checkTransformableLoopNest(OMPD_stripe, AStmt, NumLoops, LoopHelpers, + Body, OriginalInits)) +return StmtError(); + + // Delay striping to when template is completely instantiated. + if (SemaRef.CurContext->isDependentContext()) +return OMPStripeDirective::Create(Context, StartLoc, EndLoc, Clauses, + NumLoops, AStmt, nullptr, nullptr); + + assert(LoopHelpers.size() == NumLoops && + "Expecting loop iteration space dimensionality to match number of " + "affected loops"); + assert(OriginalInits.size() == NumLoops && + "Expecting loop iteration space dimensionality to match number of " + "affected loops"); + + // Collect all affected loop statements. + SmallVector LoopStmts(NumLoops, nullptr); + collectLoopStmts(AStmt, LoopStmts); + + SmallVector PreInits; + CaptureVars CopyTransformer(SemaRef); + + // Create iteration variables for the generated loops. + SmallVector FloorIndVars; + SmallVector StripeIndVars; + FloorIndVars.resize(NumLoops); + StripeIndVars.resize(NumLoops); + for (unsigned I : llvm::seq(NumLoops)) { +OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers[I]; + +assert(LoopHelper.Counters.size() == 1 && + "Expect single-dimensional loop iteration space"); +auto *OrigCntVar = cast(LoopHelper.Counters.front()); +std::string OrigVarName = OrigCntVar->getNameInfo().getAsString(); +DeclRefExpr *IterVarRef = cast(LoopHelper.IterationVarRef); +QualType CntTy = IterVarRef->getType(); + +// Iteration variable for the stripe (i.e. outer) loop. +{ + std::string FloorCntName = + (Twine(".floor_") + llvm::utostr(I) + ".iv." + OrigVarName).str(); + VarDecl *FloorCntDecl = + buildVarDecl(SemaRef, {}, CntTy, FloorCntName, nullptr, OrigCntVar); + FloorIndVars[I] = FloorCntDecl; +} + +// Iteration variable for the stripe (i.e. inner) loop. +{ + std::string StripeCntName = + (Twine(".stripe_") + llvm::utostr(I) + ".iv." + OrigVarName).str(); + + // Reuse the iteration variable created by checkOpenMPLoop. It is also + // used by the expressions to derive the original iteration variable's + // value from the logical iteration number. + auto *StripeCntDecl = cast(IterVarRef->getDecl()); + StripeCntDecl->setDeclName( + &SemaRef.PP.getIdentifierTable().get(StripeCntName)); + StripeIndVars[I] = StripeCntDecl; +} + +addLoopPreInits(Context, LoopHelper, LoopStmts[I], OriginalInits[I], +PreInits); + } + + // Once the original iteration values are set, append the innermost body. + Stmt *Inner = Body; + + auto MakeDimStripeSize = [&](int I) -> Expr * { +Expr *DimStripeSizeExpr = SizesClause->getSizesRefs()[I]; +if (isa(DimStripeSizeExpr)) + return AssertSuccess(CopyTransformer.TransformExpr(DimStripeSizeExpr)); + +// When the stripe size is not a constant but a variable, it is possible to +// pass non-positive numbers. For instance: +// \code{c} +// int a = 0; +// #pragma omp stripe sizes(a) +// for (int i = 0; i < 42; ++i) +// body(i); +// \endcode +// Although there is no meaningful interpretation of the stripe size, the +// body should still be executed 42 times to avoid surprises. To preserve +// the invariant that every loop iteration is executed exactly once and not +// cause an infinite loop, apply a minimum stripe size of one. +// Build expr: +// \code{c} +// (TS <= 0) ? 1 : TS +// \endcode +QualType DimTy = DimStripeSizeExpr->getType(); +uint64_t DimWidth = Context.getTypeSize(DimTy); +IntegerLiteral *Zero = IntegerLiteral::Create( +Context, llvm::APInt::getZero(DimWidth), DimTy, {}); +IntegerLiteral *One = +IntegerLiteral::Create(Context, llvm::APInt(
[clang] Optimize -Wunsafe-buffer-usage. (PR #124554)
https://github.com/ivanaivanovska created https://github.com/llvm/llvm-project/pull/124554 Details of the optimization results will follow. >From 1bfe3f3fcf2385c67057a19baf9ddf3b14aeeb6d Mon Sep 17 00:00:00 2001 From: Ivana Ivanovska Date: Mon, 2 Dec 2024 14:17:06 + Subject: [PATCH] Optimize -Wunsafe-buffer-usage. --- .../Analyses/UnsafeBufferUsageGadgets.def | 41 +- clang/lib/Analysis/UnsafeBufferUsage.cpp | 1417 +++-- 2 files changed, 921 insertions(+), 537 deletions(-) diff --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def index 09fa510bc0472e..308964d54544da 100644 --- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def +++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def @@ -18,10 +18,14 @@ #define WARNING_GADGET(name) GADGET(name) #endif -/// A `WARNING_GADGET` subset, each of which may be enable/disable separately -/// with different flags -#ifndef WARNING_OPTIONAL_GADGET -#define WARNING_OPTIONAL_GADGET(name) WARNING_GADGET(name) +/// A `WARNING_GADGET` subset, accepts context as additional parameter. +#ifndef WARNING_OPTIONAL_GADGET_CTX +#define WARNING_OPTIONAL_GADGET_CTX(name) WARNING_GADGET(name) +#endif + +/// A `WARNING_GADGET` subset, accepts handler as additional parameter. +#ifndef WARNING_OPTIONAL_GADGET_HANDLER +#define WARNING_OPTIONAL_GADGET_HANDLER(name) WARNING_GADGET(name) #endif /// Safe gadgets correspond to code patterns that aren't unsafe but need to be @@ -31,27 +35,34 @@ #define FIXABLE_GADGET(name) GADGET(name) #endif +/// A subset of the safe gadgets that may return multiple results. +#ifndef FIXABLE_GADGET_MULTY_RES +#define FIXABLE_GADGET_MULTY_RES(name) GADGET(name) +#endif + WARNING_GADGET(Increment) WARNING_GADGET(Decrement) -WARNING_GADGET(ArraySubscript) WARNING_GADGET(PointerArithmetic) WARNING_GADGET(UnsafeBufferUsageAttr) -WARNING_GADGET(UnsafeBufferUsageCtorAttr) WARNING_GADGET(DataInvocation) -WARNING_OPTIONAL_GADGET(UnsafeLibcFunctionCall) -WARNING_OPTIONAL_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, arg1)` +WARNING_OPTIONAL_GADGET_CTX(ArraySubscript) +WARNING_OPTIONAL_GADGET_CTX(UnsafeBufferUsageCtorAttr) +WARNING_OPTIONAL_GADGET_HANDLER(UnsafeLibcFunctionCall) +WARNING_OPTIONAL_GADGET_HANDLER(SpanTwoParamConstructor) // Uses of `std::span(arg0, arg1)` FIXABLE_GADGET(ULCArraySubscript) // `DRE[any]` in an Unspecified Lvalue Context FIXABLE_GADGET(DerefSimplePtrArithFixable) FIXABLE_GADGET(PointerDereference) -FIXABLE_GADGET(UPCAddressofArraySubscript) // '&DRE[any]' in an Unspecified Pointer Context -FIXABLE_GADGET(UPCStandalonePointer) -FIXABLE_GADGET(UPCPreIncrement)// '++Ptr' in an Unspecified Pointer Context -FIXABLE_GADGET(UUCAddAssign)// 'Ptr += n' in an Unspecified Untyped Context -FIXABLE_GADGET(PtrToPtrAssignment) -FIXABLE_GADGET(CArrayToPtrAssignment) +FIXABLE_GADGET_MULTY_RES(UPCAddressofArraySubscript) // '&DRE[any]' in an Unspecified Pointer Context +FIXABLE_GADGET_MULTY_RES(UPCStandalonePointer) +FIXABLE_GADGET_MULTY_RES(UPCPreIncrement)// '++Ptr' in an Unspecified Pointer Context +FIXABLE_GADGET_MULTY_RES(UUCAddAssign)// 'Ptr += n' in an Unspecified Untyped Context +FIXABLE_GADGET_MULTY_RES(PtrToPtrAssignment) +FIXABLE_GADGET_MULTY_RES(CArrayToPtrAssignment) FIXABLE_GADGET(PointerInit) +#undef FIXABLE_GADGET_MULTY_RES #undef FIXABLE_GADGET #undef WARNING_GADGET -#undef WARNING_OPTIONAL_GADGET +#undef WARNING_OPTIONAL_GADGET_CTX +#undef WARNING_OPTIONAL_GADGET_HANDLER #undef GADGET diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp index c064aa30e8aedc..d99c942b2290e5 100644 --- a/clang/lib/Analysis/UnsafeBufferUsage.cpp +++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -8,30 +8,32 @@ #include "clang/Analysis/Analyses/UnsafeBufferUsage.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/ASTTypeTraits.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclCXX.h" #include "clang/AST/DynamicRecursiveASTVisitor.h" #include "clang/AST/Expr.h" #include "clang/AST/FormatString.h" +#include "clang/AST/ParentMapContext.h" #include "clang/AST/Stmt.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/Type.h" -#include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Basic/SourceLocation.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/APSInt.h" +#include "llvm/ADT/STLFunctionalExtras.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Casting.h" -#include #include #include +#include #include using namespace llvm; using namespace clang; -using namespace ast_matchers; #ifndef NDEBUG namespace { @@ -68,7 +70,7 @@ static std::string getDREAnces
[clang] [llvm] [NFC][DebugInfo] Rewrite more call-sites to insert with iterators (PR #124288)
https://github.com/OCHyams edited https://github.com/llvm/llvm-project/pull/124288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Enable vscale_range with +sme (PR #124466)
@@ -708,7 +708,7 @@ AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts) const { return std::pair( LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax); - if (hasFeature("sve")) + if (hasFeature("sve") || hasFeature("sme")) david-arm wrote: In this situation isn't it the case that SVE will only be available in streaming mode? I guess your reasoning here is that for normal functions (not streaming or streaming-compatible) the vscale_range attribute should be harmless, i.e. that it does not imply scalable vector support? https://github.com/llvm/llvm-project/pull/124466 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [NFC][DebugInfo] Rewrite more call-sites to insert with iterators (PR #124288)
@@ -823,7 +823,16 @@ static void updateScopeLine(Instruction *ActiveSuspend, if (!ActiveSuspend) return; - auto *Successor = ActiveSuspend->getNextNonDebugInstruction(); + // No subsequent instruction -> fallback to the location of ActiveSuspend. + if (!ActiveSuspend->getNextNonDebugInstruction()) { +if (auto DL = ActiveSuspend->getDebugLoc()) + if (SPToUpdate.getFile() == DL->getFile()) +SPToUpdate.setScopeLine(DL->getLine()); +return; + } + + BasicBlock::iterator Successor = OCHyams wrote: this doesn't break the `dyn_cast_or_null` below? https://github.com/llvm/llvm-project/pull/124288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [NFC][DebugInfo] Rewrite more call-sites to insert with iterators (PR #124288)
https://github.com/OCHyams approved this pull request. > parent-pointers can now be accessed from ilist nodes Feels a bit of a shame we're not using this right away, but LGTM + nits https://github.com/llvm/llvm-project/pull/124288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5c5bbff - [clang][ASTImporter] Import source location of explicit object parameter instead of copying it (#124305)
Author: Michael Buch Date: 2025-01-27T14:57:09Z New Revision: 5c5bbffe75caaaefdc68305e85a625a057b09159 URL: https://github.com/llvm/llvm-project/commit/5c5bbffe75caaaefdc68305e85a625a057b09159 DIFF: https://github.com/llvm/llvm-project/commit/5c5bbffe75caaaefdc68305e85a625a057b09159.diff LOG: [clang][ASTImporter] Import source location of explicit object parameter instead of copying it (#124305) We used to copy the `SourceLocation` instead of importing it, which isn't correct since the `SourceManager`'s of the source and target ASTContext might differ. Also adds test that confirms that we import the explicit object parameter location for `ParmVarDecl`s. This is how Clang determines whether a parameter `isExplicitObjectParamater`. The LLDB expression evaluator relies on this for calling "explicit object member functions". Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 0669aa1b809c34..be1a65a49622d3 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -4701,9 +4701,13 @@ ExpectedDecl ASTNodeImporter::VisitImplicitParamDecl(ImplicitParamDecl *D) { Error ASTNodeImporter::ImportDefaultArgOfParmVarDecl( const ParmVarDecl *FromParam, ParmVarDecl *ToParam) { + + if (auto LocOrErr = import(FromParam->getExplicitObjectParamThisLoc())) +ToParam->setExplicitObjectParameterLoc(*LocOrErr); + else +return LocOrErr.takeError(); + ToParam->setHasInheritedDefaultArg(FromParam->hasInheritedDefaultArg()); - ToParam->setExplicitObjectParameterLoc( - FromParam->getExplicitObjectParamThisLoc()); ToParam->setKNRPromoted(FromParam->isKNRPromoted()); if (FromParam->hasUninstantiatedDefaultArg()) { diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index 791248e7a394f1..e77860521335ed 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -3441,6 +3441,7 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportParmVarDecl) { ASSERT_TRUE(FromVar); ASSERT_TRUE(FromVar->hasUninstantiatedDefaultArg()); ASSERT_TRUE(FromVar->getUninstantiatedDefaultArg()); + ASSERT_FALSE(FromVar->isExplicitObjectParameter()); const auto *ToVar = Import(FromVar, Lang_CXX11); EXPECT_TRUE(ToVar); @@ -3448,6 +3449,25 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportParmVarDecl) { EXPECT_TRUE(ToVar->getUninstantiatedDefaultArg()); EXPECT_NE(FromVar->getUninstantiatedDefaultArg(), ToVar->getUninstantiatedDefaultArg()); + EXPECT_FALSE(ToVar->isExplicitObjectParameter()); +} + +TEST_P(ASTImporterOptionSpecificTestBase, ImportParmVarDecl_Explicit) { + const auto *Code = R"( +struct Wrapper { + void func(this Wrapper) {} +}; +)"; + Decl *FromTU = getTuDecl(Code, Lang_CXX23); + auto *FromVar = FirstDeclMatcher().match(FromTU, parmVarDecl()); + ASSERT_TRUE(FromVar); + ASSERT_TRUE(FromVar->isExplicitObjectParameter()); + + const auto *ToVar = Import(FromVar, Lang_CXX23); + EXPECT_TRUE(ToVar); + EXPECT_TRUE(ToVar->isExplicitObjectParameter()); + EXPECT_NE(ToVar->getExplicitObjectParamThisLoc(), +FromVar->getExplicitObjectParamThisLoc()); } TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentField) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Import source location of explicit object parameter instead of copying it (PR #124305)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/124305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add dump() support for lvalue APValues (PR #124476)
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/124476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)
https://github.com/Xazax-hun commented: Would it be possible to add a test or is it hard to reproduce? https://github.com/llvm/llvm-project/pull/124477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)
https://github.com/Xazax-hun edited https://github.com/llvm/llvm-project/pull/124477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)
https://github.com/steakhal commented: This change affects how an AST node is modeled. Consequently, it's a core change. As such a change, we should have a test. Overall, I really liked how thoroughly you described what caused the issue, and that helped to justify the fix. On that front, it looks great. Thank you for your contribution. https://github.com/llvm/llvm-project/pull/124477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/124477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)
@@ -124,24 +124,26 @@ void ExprEngine::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S, bool isContainerNull = state->isNull(collectionV).isConstrainedTrue(); - ExplodedNodeSet dstLocation; - evalLocation(dstLocation, S, elem, Pred, state, elementV, false); + ExplodedNodeSet NewPreds; // evalLocation may alter `Pred` + evalLocation(NewPreds, S, elem, Pred, state, elementV, false); - ExplodedNodeSet Tmp; - StmtNodeBuilder Bldr(Pred, Tmp, *currBldrCtx); + for (ExplodedNode *Pred : NewPreds) { steakhal wrote: I wish we wouldn't shadow `Pred` here. Maybe if we are iterating a collection called `NewPreds`, a variable `NewPred` would be a better, non-shadowing name. https://github.com/llvm/llvm-project/pull/124477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StrTable] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
durga4github wrote: LGTM overall. I work with these builtins only occasionally. So, let us wait for Artem's review. https://github.com/llvm/llvm-project/pull/122873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StaticAnalyzer] Fix state update in VisitObjCForCollectionStmt (PR #124477)
Xazax-hun wrote: > I would greatly appreciate if anyone can help me create a minimal reproducer. If we cannot find a way to trigger this with the existing checks, you could try to come up with a unit test like this: https://github.com/llvm/llvm-project/blob/main/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp https://github.com/llvm/llvm-project/pull/124477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 347fb20 - [libclc] Optimize CLC vector relational builtins (#124537)
Author: Fraser Cormack Date: 2025-01-27T13:25:37Z New Revision: 347fb208c1e390a4f108e566efc81bd945837307 URL: https://github.com/llvm/llvm-project/commit/347fb208c1e390a4f108e566efc81bd945837307 DIFF: https://github.com/llvm/llvm-project/commit/347fb208c1e390a4f108e566efc81bd945837307.diff LOG: [libclc] Optimize CLC vector relational builtins (#124537) Clang knows how to perform relational operations on OpenCL vectors, so we don't need to use the Clang builtins. The builtins we were using didn't support vector types, so we were previously scalarizing. This commit generates the same LLVM fcmp operations as before, just without the scalarization. Added: Modified: libclc/clc/include/clc/relational/relational.h libclc/clc/lib/generic/relational/clc_isequal.cl libclc/clc/lib/generic/relational/clc_isgreater.cl libclc/clc/lib/generic/relational/clc_isgreaterequal.cl libclc/clc/lib/generic/relational/clc_isless.cl libclc/clc/lib/generic/relational/clc_islessequal.cl libclc/clc/lib/generic/relational/clc_islessgreater.cl libclc/clc/lib/generic/relational/clc_isnotequal.cl Removed: diff --git a/libclc/clc/include/clc/relational/relational.h b/libclc/clc/include/clc/relational/relational.h index 54241b6493c8e7..f32e7630203e4b 100644 --- a/libclc/clc/include/clc/relational/relational.h +++ b/libclc/clc/include/clc/relational/relational.h @@ -142,4 +142,30 @@ _CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(RET_TYPE, FUNCTION, ARG0_TYPE, \ ARG1_TYPE) +#define _CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(RET_TYPE, RET_TYPE_VEC, FUNCTION, \ + ARG1_TYPE, ARG2_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##2 FUNCTION(ARG1_TYPE##2 x, \ + ARG2_TYPE##2 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##3 FUNCTION(ARG1_TYPE##3 x, \ + ARG2_TYPE##3 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##4 FUNCTION(ARG1_TYPE##4 x, \ + ARG2_TYPE##4 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##8 FUNCTION(ARG1_TYPE##8 x, \ + ARG2_TYPE##8 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##16 FUNCTION(ARG1_TYPE##16 x, \ + ARG2_TYPE##16 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } + #endif // __CLC_RELATIONAL_RELATIONAL_H__ diff --git a/libclc/clc/lib/generic/relational/clc_isequal.cl b/libclc/clc/lib/generic/relational/clc_isequal.cl index 7664df7767cb3f..053a237289fd60 100644 --- a/libclc/clc/lib/generic/relational/clc_isequal.cl +++ b/libclc/clc/lib/generic/relational/clc_isequal.cl @@ -1,44 +1,28 @@ #include +#include -#define _CLC_DEFINE_ISEQUAL(RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ -return (x == y); \ - } +#define _CLC_RELATIONAL_OP(X, Y) (X) == (Y) -_CLC_DEFINE_ISEQUAL(int, __clc_isequal, float, float) -_CLC_DEFINE_ISEQUAL(int2, __clc_isequal, float2, float2) -_CLC_DEFINE_ISEQUAL(int3, __clc_isequal, float3, float3) -_CLC_DEFINE_ISEQUAL(int4, __clc_isequal, float4, float4) -_CLC_DEFINE_ISEQUAL(int8, __clc_isequal, float8, float8) -_CLC_DEFINE_ISEQUAL(int16, __clc_isequal, float16, float16) +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isequal, float, float) #ifdef cl_khr_fp64 #pragma OPENCL EXTENSION cl_khr_fp64 : enable -// The scalar version of __clc_isequal(double) returns an int, but the vector -// versions return long. -_CLC_DEFINE_ISEQUAL(int, __clc_isequal, double, double) -_CLC_DEFINE_ISEQUAL(long2, __clc_ise
[libclc] [libclc] Optimize CLC vector relational builtins (PR #124537)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/124537 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #123604)
https://github.com/momchil-velikov updated https://github.com/llvm/llvm-project/pull/123604 >From e825bc0f660eb3dce41ee062d04e4e39bbac5d2a Mon Sep 17 00:00:00 2001 From: Momchil Velikov Date: Fri, 6 Dec 2024 13:09:23 + Subject: [PATCH] [AArch64] Refactor implementation of FP8 types (NFC) * The FP8 scalar type (`__mfp8`) was described as a vector type * The FP8 vector types were described/assumed to have integer element type (the element type ought to be `__mfp8`), * Add support for `m` type specifier (denoting `__mfp8`) in `DecodeTypeFromStr` and create SVE builtin prototypes using the specifier, instead of `int8_t`. [fixup] Add a comment about special case of mapping FP8 vectors to LLVM vector types --- .../clang/Basic/AArch64SVEACLETypes.def | 35 +-- clang/lib/AST/ASTContext.cpp | 30 +--- clang/lib/AST/ItaniumMangle.cpp | 2 +- clang/lib/AST/Type.cpp| 4 +-- clang/lib/CodeGen/CodeGenTypes.cpp| 22 +++- clang/lib/CodeGen/Targets/AArch64.cpp | 7 ++-- clang/utils/TableGen/SveEmitter.cpp | 4 +-- 7 files changed, 58 insertions(+), 46 deletions(-) diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 2dd2754e778d60..a408bb0c54057c 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -97,16 +107,6 @@ SVE_TYPE(Name, Id, SingletonId) #endif -#ifndef AARCH64_VECTOR_TYPE -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ - SVE_TYPE(Name, Id, SingletonId) -#endif - -#ifndef AARCH64_VECTOR_TYPE_MFLOAT -#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ - AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) -#endif - //===- Vector point types ---===// SVE_VECTOR_TYPE_INT("__SVInt8_t", "__SVInt8_t", SveInt8, SveInt8Ty, 16, 8, 1, true) @@ -125,8 +125,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +147,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2) // // x3 @@ -170,7 +169,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3) // // x4 @@ -192,7 +191,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4) SVE_PREDICATE_TYPE_ALL("__SVBool_t", "__SVBool_t", SveBool, SveBoolTy, 16, 1) SVE_PREDICATE_TYPE_ALL("__clang_svboolx2_t", "svboolx2_t",
[clang] [clang-refactor] Add Matcher Edit refactoring rule (PR #123782)
=?utf-8?b?0JjQs9C90LDRgiDQodC10YDQsw=?=, =?utf-8?b?0JjQs9C90LDRgiDQodC10YDQsw=?Message-ID: In-Reply-To: bartlettroscoe wrote: @IgnatSergeev, thanks for the detailed information on the clang-refactor testing infrastructure. We will try to run these tests and dig in deeper to see how the testing system works. > I could add every piece of code related to those Refactoring Actions and > tests here, and later remove them if needed. No need for unnecessary work. We just appreciate your willingness to help answer our questions 😊 I have been looking for other PRs that extend clang-refactor, but it is hard to find them. There is not even a GitHub Issue label `clang-refactor`, so it is hard to find PRs and Issues specific to that tool. (Unlike for the tools with labels [`clang-tidy`](https://github.com/llvm/llvm-project/labels/clang-tidy) and [`clang-format`](https://github.com/llvm/llvm-project/labels/clang-format).) > P. S. I'm using some Refactoring Engine terms here, if you are not sure, I > recommend reading these docs > [clang.llvm.org/docs/RefactoringEngine.html](https://clang.llvm.org/docs/RefactoringEngine.html) Thanks! We have been looking that over. Do you know why so few refactorings are supported in the `clang-refactor` tool or the [`clangd`](https://github.com/clangd/vscode-clangd/blob/master/README.md#refactoring) tool? For example, the `extract` function refactoring seems to only extracts a new function from a given range of code in a larger function. It does not seem refactor the larger original function to call the new extracted function (which is one of the most important parts of the classic ["Extract Method" refactoring](https://refactoring.guru/extract-method)). (We can't seem to find any examples of the usage of extract function. We determined this gap by experimentation.) It seems that LLMV/Clang LibTool could support an endless set of refactorings (due to arbitrary AST changes), but there seems to be very limited user-ready refactorings supported by tools in the llvm-project repo itself. I know that major companies are using LLVM/Clang LibTool to do large refctorings. Are these companies mostly just developing their own proprietary in-house refactoring tools based on LLVM/Clang LibTool? https://github.com/llvm/llvm-project/pull/123782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Import source location of explicit object parameter instead of copying it (PR #124305)
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/124305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)
Sirraide wrote: > What I'm asking is: is `-Wreturn-type` more susceptible to FPs than other > typical Clang warnings There definitely are cases where we currently can’t figure out that a function always returns if the control flow is very convoluted, e.g. #111509 has this horrible example ```c int foo(int x) { bool matched = false; do { if (matched) { label: return 0; } if (matched || x == 1) { matched = true; return 123; } if (matched || x == 2) { matched = true; return 456; } if (matched) { break; } goto label; } while(false); } ``` https://github.com/llvm/llvm-project/pull/123470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Optimize CLC vector is(un)ordered builtins (PR #124546)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/124546 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)
Sirraide wrote: > Is it implemented differently in Clang, The way `-Wreturn-type` is implemented in Clang is we build a CFG from the AST and then walk that to determine whether all paths return a value, if that’s what you’re asking. https://github.com/llvm/llvm-project/pull/123470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add BuiltinTemplates.td to generate code for builtin templates (PR #123736)
@@ -0,0 +1,23 @@ +//===--- BuiltinTemplates.td - Clang builtin template aliases ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +class BuiltinTemplate { + string Prototype = prototype; +} + +def __make_integer_seq : BuiltinTemplate< + "template class IntSeq, class T, T N>">; erichkeane wrote: I thought about this over the weekend. I really think that we want some sort of structures to define the template head here. The base needs a name, then we need a Type, an Non-Type, a Template-Template, and a Variadic (for now). But having us try to parse this is really going to be error prone and difficult to extend. https://github.com/llvm/llvm-project/pull/123736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add BuiltinTemplates.td to generate code for builtin templates (PR #123736)
@@ -0,0 +1,184 @@ +//=- ClangBuiltinsEmitter.cpp - Generate Clang builtin templates-*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This tablegen backend emits Clang's builtin templates. +// +//===--===// + +#include "TableGenBackends.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/TableGenBackend.h" + +using namespace llvm; + +std::string TemplateNameList; +std::string CreateBuiltinTemplateParameterList; + +namespace { +struct ParserState { + size_t UniqueCounter = 0; + size_t CurrentDepth = 0; + bool EmittedSizeTInfo = false; +}; + +std::pair +ParseTemplateParameterList(ParserState &PS, StringRef &TemplateParmList) { + auto Alphabetic = [](char c) { return std::isalpha(c); }; erichkeane wrote: > @erichkeane Do you have any better idea how to represent this? I could > represent as something like > > ``` > def __make_integer_seq : BuiltinTemplate, NTTP<"T", > "Ints", /*variadic*/true>], "IntSeq">, Class<"T">, NTTP<"T", "N">>; > ``` > > But that's really hard to read IMO. > > @Sirraide With an attribute we'd still have to verify that the parsed > template actually represents the template, since users would be able to > declare templates with an attribute, so we'd be back at square one AFAICT. It > would also mean introducing code into every single translation unit, which > would probably increase the startup time of clang. I REALLY don't want the whole compiler, but something like the above isn't too bad IMO. Perhaps the NTTP recursively takes a type template. WHILE that isn't super easy to read, it isn't all that bad, it is pretty much the template head. https://github.com/llvm/llvm-project/pull/123736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
https://github.com/mizvekov approved this pull request. LGTM, Thanks! https://github.com/llvm/llvm-project/pull/124533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] __STDC_NO_THREADS__ is no longer necessary for VS 2022 1939 and above (PR #117149)
https://github.com/AaronBallman approved this pull request. LGTM thank you for the fix! https://github.com/llvm/llvm-project/pull/117149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Track source deduction guide for alias template deduction guides (PR #123875)
https://github.com/erichkeane approved this pull request. I think we're best-effort on the tests by now... I don't see how we can do any better and still get value out of them. https://github.com/llvm/llvm-project/pull/123875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f95a8bd - [AArch64] Refactor implementation of FP8 types (NFC) (#123604)
Author: Momchil Velikov Date: 2025-01-27T14:31:41Z New Revision: f95a8bde3425ada0ef004186eb8ccda6e723241c URL: https://github.com/llvm/llvm-project/commit/f95a8bde3425ada0ef004186eb8ccda6e723241c DIFF: https://github.com/llvm/llvm-project/commit/f95a8bde3425ada0ef004186eb8ccda6e723241c.diff LOG: [AArch64] Refactor implementation of FP8 types (NFC) (#123604) - The FP8 scalar type (`__mfp8`) was described as a vector type - The FP8 vector types were described/assumed to have integer element type (the element type ought to be `__mfp8`) - Add support for `m` type specifier (denoting `__mfp8`) in `DecodeTypeFromStr` and create builtin function prototypes using that specifier, instead of `int8_t` Added: Modified: clang/include/clang/Basic/AArch64SVEACLETypes.def clang/lib/AST/ASTContext.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/Type.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/Targets/AArch64.cpp clang/utils/TableGen/SveEmitter.cpp Removed: diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 2dd2754e778d60..a408bb0c54057c 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, false) +#endif + #ifndef SVE_VECTOR_TYPE_FLOAT #define SVE_VECTOR_TYPE_FLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, true, false) @@ -97,16 +107,6 @@ SVE_TYPE(Name, Id, SingletonId) #endif -#ifndef AARCH64_VECTOR_TYPE -#define AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ - SVE_TYPE(Name, Id, SingletonId) -#endif - -#ifndef AARCH64_VECTOR_TYPE_MFLOAT -#define AARCH64_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ - AARCH64_VECTOR_TYPE(Name, MangledName, Id, SingletonId) -#endif - //===- Vector point types ---===// SVE_VECTOR_TYPE_INT("__SVInt8_t", "__SVInt8_t", SveInt8, SveInt8Ty, 16, 8, 1, true) @@ -125,8 +125,7 @@ SVE_VECTOR_TYPE_FLOAT("__SVFloat64_t", "__SVFloat64_t", SveFloat64, SveFloat64Ty SVE_VECTOR_TYPE_BFLOAT("__SVBfloat16_t", "__SVBfloat16_t", SveBFloat16, SveBFloat16Ty, 8, 16, 1) -// This is a 8 bits opaque type. -SVE_VECTOR_TYPE_INT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1, false) +SVE_VECTOR_TYPE_MFLOAT("__SVMfloat8_t", "__SVMfloat8_t", SveMFloat8, SveMFloat8Ty, 16, 8, 1) // // x2 @@ -148,7 +147,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x2_t", "svfloat64x2_t", SveFloat64x2, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x2_t", "svbfloat16x2_t", SveBFloat16x2, SveBFloat16x2Ty, 8, 16, 2) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x2_t", "svmfloat8x2_t", SveMFloat8x2, SveMFloat8x2Ty, 16, 8, 2) // // x3 @@ -170,7 +169,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x3_t", "svfloat64x3_t", SveFloat64x3, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x3_t", "svbfloat16x3_t", SveBFloat16x3, SveBFloat16x3Ty, 8, 16, 3) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x3_t", "svmfloat8x3_t", SveMFloat8x3, SveMFloat8x3Ty, 16, 8, 3) // // x4 @@ -192,7 +191,7 @@ SVE_VECTOR_TYPE_FLOAT("__clang_svfloat64x4_t", "svfloat64x4_t", SveFloat64x4, Sv SVE_VECTOR_TYPE_BFLOAT("__clang_svbfloat16x4_t", "svbfloat16x4_t", SveBFloat16x4, SveBFloat16x4Ty, 8, 16, 4) -SVE_VECTOR_TYPE_INT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4, false) +SVE_VECTOR_TYPE_MFLOAT("__clang_svmfloat8x4_t", "svmfloat8x4_t", SveMFloat8x4, SveMFloat8x4Ty, 16, 8, 4) SVE_PREDICATE_TYPE_ALL("__SVBool_t", "__SVBool_t", SveBool, SveBoolTy, 16, 1) SVE_PREDICATE_TYPE_ALL("__clang_svboolx2_t", "svboolx2_t", SveBoolx2, SveBoolx2Ty, 16, 2) @@ -200,15 +199,15 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t
[clang] [clang] __STDC_NO_THREADS__ is no longer necessary for VS 2022 1939 and above (PR #117149)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/117149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix immediate escalation of template function specializations. (PR #124404)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/124404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] __STDC_NO_THREADS__ is no longer necessary for VS 2022 1939 and above (PR #117149)
github-actions[bot] wrote: @dipeshs809 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/117149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
@@ -205,77 +262,134 @@ namespace { } #pragma omp end declare target -#pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}} +// expected-error@+1 {{'S' used in declare target directive is not a variable or a function name}} +#pragma omp declare target link(S) -#pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} -#pragma omp declare target to(x) to(x) // omp45-error {{'x' appears multiple times in clauses on the same declare target directive}} omp5-error {{'x' appears multiple times in clauses on the same declare target directive}} omp51-error {{'x' appears multiple times in clauses on the same declare target directive}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} -#pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}} +// expected-error@+1 {{'x' appears multiple times in clauses on the same declare target directive}} +#pragma omp declare target (x, x) +// omp52-error@+3 {{unexpected 'to' clause, use 'enter' instead}} +// omp52-error@+2 {{expected at least one 'enter', 'link' or 'indirect' clause}} +// omp45-to-51-clause-error@+1 {{'x' appears multiple times in clauses on the same declare target directive}} +#pragma omp declare target to(x) to(x) +// expected-error@+1 {{'x' must not appear in both clauses 'to' and 'link'}} +#pragma omp declare target link(x) void bazz() {} -#pragma omp declare target to(bazz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} host5-note 3{{marked as 'device_type(nohost)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} +// omp52-error@+4 {{unexpected 'to' clause, use 'enter' instead}} +// omp52-error@+3 {{expected at least one 'enter', 'link' or 'indirect' clause}} +// host5-note@+2 3 {{marked as 'device_type(nohost)' here}} +// omp45-error@+1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} +#pragma omp declare target to(bazz) device_type(nohost) void bazzz() {bazz();} -#pragma omp declare target to(bazzz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} -void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}} -void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}} -#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 3 {{marked as 'device_type(host)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} -void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is not available on host}} -#pragma omp declare target to(host2) // omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} -void device() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}} -#pragma omp declare target to(device) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} host5-note 2 {{marked as 'device_type(nohost)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} +// omp52-error@+3 {{unexpected 'to' clause, use 'enter' instead}} +// omp52-error@+2 {{expected at least one 'enter', 'link' or 'indirect' clause}} +// omp45-error@+1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} +#pragma omp declare target to(bazzz) device_type(nohost) +// host5-error@+1 {{function with 'device_type(nohost)' is not available on host}} +void any() {bazz();} +// host5-error@+1 {{function with 'device_type(nohost)' is not available on host}} +void host1() {bazz();} +// omp52-error@+4 {{unexpected 'to' clause, use 'enter' instead}} +// omp52-error@+3 {{expected at least one 'enter', 'link' or 'indirect' clause}} +// dev5-note@+2 3 {{marked as 'device_type(host)' here}} +// omp45-error@+1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} +#pragma omp declare target to(host1) device_type(host) +//host5-error@+1 {{function with 'device_type(nohost)' is not available on host}} +void host2() {bazz();} +// omp52-error@+2 {{unexpected 'to' clause, use 'enter' instead}} +// omp52-error@+1 {{expected
[clang] [AArch64] Refactor implementation of FP8 types (NFC) (PR #123604)
https://github.com/momchil-velikov closed https://github.com/llvm/llvm-project/pull/123604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)
thesamesam wrote: Thanks. I expect there'll be some fallout but you also get missed optimisation bugs out of that in some cases, so. > Another option would be to make this default to an error depending on the > language mode (e.g. only in C23 or later, and either unconditionally in C++ > or in e.g. C++17 or later etc.); I don’t have any actual data on this, but I > would imagine that most programs that actually have code that triggers this > warning are probably C99 or earlier. This unfortunately won't work when we change the default to C23 and so on. https://github.com/llvm/llvm-project/pull/123470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] call HandleImmediateInvocation before checking for immediate escacalating expressions (PR #124414)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/124414 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)
@@ -5692,7 +5692,10 @@ CGCallee CodeGenFunction::EmitCallee(const Expr *E) { // Resolve direct calls. } else if (auto DRE = dyn_cast(E)) { if (auto FD = dyn_cast(DRE->getDecl())) { - return EmitDirectCallee(*this, FD); + auto CalleeDecl = FD->hasAttr() +? GlobalDecl(FD, KernelReferenceKind::Stub) +: FD; + return EmitDirectCallee(*this, CalleeDecl); lalaniket8 wrote: I see, I can get the correct CalleePtr which is of type `llvm::Constant`, but I am not able to figure out how to convert the same into a `GlobalDecl` object. https://github.com/llvm/llvm-project/pull/115821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StrTable] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
durga4github wrote: > Ping! > > I've updated this to incorporate the changes in #123398 to the NVPTX.def file > this is replacing. > Thanks for this! https://github.com/llvm/llvm-project/pull/122873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ddbfe6f - [Sema] Fix __array_rank instantiation (#124491)
Author: Robert Dazi Date: 2025-01-27T12:43:37+01:00 New Revision: ddbfe6f7d2075a828fa9e8e5f5734bf881cda13a URL: https://github.com/llvm/llvm-project/commit/ddbfe6f7d2075a828fa9e8e5f5734bf881cda13a DIFF: https://github.com/llvm/llvm-project/commit/ddbfe6f7d2075a828fa9e8e5f5734bf881cda13a.diff LOG: [Sema] Fix __array_rank instantiation (#124491) The type being queried was left as a template type parameter, making the whole expression as dependent and thus not eligible to static_assert. Fixes #123498 Co-authored-by: v01dxyz Co-authored-by: cor3ntin Added: clang/test/SemaCXX/array-type-trait-with-template.cpp Modified: clang/docs/ReleaseNotes.rst clang/include/clang/AST/ExprCXX.h clang/lib/Sema/TreeTransform.h Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b63bd366cfe884..c60565a568234a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1002,6 +1002,8 @@ Bug Fixes to C++ Support - Fixed assertions or false compiler diagnostics in the case of C++ modules for lambda functions or inline friend functions defined inside templates (#GH122493). - Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423) +- Fix type of expression when calling a template which returns an ``__array_rank`` querying a type depending on a + template parameter. Now, such expression can be used with ``static_assert`` and ``constexpr``. (#GH123498) - Correctly determine the implicit constexprness of lambdas in dependent contexts. (#GH97958) (#GH114234) Bug Fixes to AST Handling diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index aa10945addf78f..2a130bc6da79a0 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -2847,8 +2847,8 @@ class TypeTraitExpr final /// /// Example: /// \code -/// __array_rank(int[10][20]) == 2 -/// __array_extent(int, 1)== 20 +/// __array_rank(int[10][20]) == 2 +/// __array_extent(int[10][20], 1) == 20 /// \endcode class ArrayTypeTraitExpr : public Expr { /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned. diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 12680843a434a0..f04adf7fdf8ad2 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -14947,9 +14947,6 @@ TreeTransform::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { SubExpr = getDerived().TransformExpr(E->getDimensionExpression()); if (SubExpr.isInvalid()) return ExprError(); - -if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression()) - return E; } return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T, diff --git a/clang/test/SemaCXX/array-type-trait-with-template.cpp b/clang/test/SemaCXX/array-type-trait-with-template.cpp new file mode 100644 index 00..942714ec5d55a5 --- /dev/null +++ b/clang/test/SemaCXX/array-type-trait-with-template.cpp @@ -0,0 +1,129 @@ +// RUN: %clang_cc1 -fsyntax-only %s +// RUN: %clang_cc1 -fsyntax-only -std=c++20 -DWITH_AUTO_FUNCTION_PARAMETER=1 %s + +// When __array_rank is used with a template type parameter, this test +// ensures clang considers the final expression could be used with +// static_assert/constexpr. +// +// Although array_extent was handled well, we add it as a precaution. + +template +using remove_reference_t = __remove_reference_t(T); + +template +constexpr int array_rank(T (&lhs)[N]) { + return __array_rank(T[N]); +} + +template + constexpr int array_extent(T (&lhs)[N]) { + return __array_extent(T[N], I); +} + +template +struct Rank { + using ArrayT = remove_reference_t; + + template + static constexpr int call(ArrayT (&lhs)[N]) { +return __array_rank(ArrayT[N]); + } +}; + +template +struct Extent { + using ArrayT = remove_reference_t; + + template + static constexpr int call(ArrayT (&lhs)[N]) { +return __array_extent(ArrayT[N], I); + } +}; + +#ifdef WITH_AUTO_FUNCTION_PARAMETER +template +constexpr int array_rank_auto(auto (&lhs)[N]) { + return __array_rank(remove_reference_t[N]); +} + +template +constexpr int array_extent_auto(auto (&lhs)[N]) { + return __array_extent(remove_reference_t[N], I); +} +#endif + +template +constexpr int array_rank_int(const int (&lhs)[N]) { + return __array_rank(const int[N]); +} + +template +constexpr int array_extent_int(const int (&lhs)[N]) { + return __array_extent(const int[N], I); +} + +template +constexpr int array_rank_int(const int (&lhs)[M][N]) { + return __array_rank(const int[M][N]); +} + +template +constexpr int array_extent_int(const int (&lhs)[M][N]) { + return __array_extent(const int[M][N], I); +} + +int main() { + constexpr int vec[] = {0, 1, 2, 1}; + constexpr int mat[4][4] = { +{1, 0, 0, 0}, +{0, 1, 0
[clang] [Sema] Fix __array_rank queried type at template instantiation (PR #124491)
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/124491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Fix __array_rank queried type at template instantiation (PR #124491)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `flang-aarch64-dylib` running on `linaro-flang-aarch64-dylib` while building `clang` at step 5 "build-unified-tree". Full details are available at: https://lab.llvm.org/buildbot/#/builders/50/builds/9446 Here is the relevant piece of the build log for the reference ``` Step 5 (build-unified-tree) failure: build (failure) ... 843.268 [2039/1/4782] Building CXX object tools/mlir/lib/Dialect/Linalg/Transforms/CMakeFiles/obj.MLIRLinalgTransforms.dir/BubbleUpExtractSlice.cpp.o 843.474 [2038/1/4783] Building CXX object tools/mlir/lib/Conversion/FuncToSPIRV/CMakeFiles/obj.MLIRFuncToSPIRV.dir/FuncToSPIRVPass.cpp.o 843.708 [2037/1/4784] Building CXX object tools/mlir/lib/Dialect/Transform/Transforms/CMakeFiles/obj.MLIRTransformDialectTransforms.dir/CheckUses.cpp.o 844.981 [2036/1/4785] Building CXX object tools/mlir/lib/CAPI/IR/CMakeFiles/obj.MLIRCAPIIR.dir/AffineMap.cpp.o 845.351 [2035/1/4786] Building CXX object tools/mlir/lib/CAPI/IR/CMakeFiles/obj.MLIRCAPIIR.dir/BuiltinAttributes.cpp.o 845.491 [2034/1/4787] Building CXX object tools/mlir/lib/CAPI/Transforms/CMakeFiles/obj.MLIRCAPITransforms.dir/Rewrite.cpp.o 849.704 [2033/1/4788] Building CXX object tools/mlir/test/lib/Conversion/VectorToSPIRV/CMakeFiles/MLIRTestVectorToSPIRV.dir/TestVectorReductionToSPIRVDotProd.cpp.o 849.810 [2032/1/4789] Building CXX object tools/mlir/tools/mlir-parser-fuzzer/bytecode/CMakeFiles/mlir-bytecode-parser-fuzzer.dir/DummyParserFuzzer.cpp.o 851.238 [2031/1/4790] Building CXX object tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestVisitors.cpp.o 864.120 [2030/1/4791] Building CXX object tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestVisitorsGeneric.cpp.o FAILED: tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestVisitorsGeneric.cpp.o /usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DMLIR_INCLUDE_TESTS -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/mlir/test/lib/IR -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/mlir/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/llvm/include -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/../Dialect/Test -I/home/tcwg-buildbot/worker/flang-aarch64-dylib/build/tools/mlir/test/lib/IR/../Dialect/Test -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Werror=mismatched-tags -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestVisitorsGeneric.cpp.o -MF tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestVisitorsGeneric.cpp.o.d -o tools/mlir/test/lib/IR/CMakeFiles/MLIRTestIR.dir/TestVisitorsGeneric.cpp.o -c /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/TestVisitorsGeneric.cpp In file included from /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/TestVisitorsGeneric.cpp:9: /home/tcwg-buildbot/worker/flang-aarch64-dylib/llvm-project/mlir/test/lib/IR/../Dialect/Test/TestOps.h:148:10: fatal error: 'TestOps.h.inc' file not found 148 | #include "TestOps.h.inc" | ^~~ 1 error generated. ninja: build stopped: subcommand failed. ``` https://github.com/llvm/llvm-project/pull/124491 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 14ffff3 - [clang] Add dump() support for lvalue APValues (#124476)
Author: Timm Baeder Date: 2025-01-27T11:54:06+01:00 New Revision: 14384740f484b382a1225f4bd01aeebfdc3f URL: https://github.com/llvm/llvm-project/commit/14384740f484b382a1225f4bd01aeebfdc3f DIFF: https://github.com/llvm/llvm-project/commit/14384740f484b382a1225f4bd01aeebfdc3f.diff LOG: [clang] Add dump() support for lvalue APValues (#124476) Add some lvalue information to the `dump()` output of lvalue APValues. Added: clang/test/AST/ast-dump-APValue-lvalue.cpp Modified: clang/lib/AST/TextNodeDumper.cpp clang/test/AST/ast-dump-APValue-todo.cpp Removed: diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 670641242cae2f..46ec553fc05f01 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -710,10 +710,36 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) { << GetApproxValue(Value.getComplexFloatImag()) << 'i'; } return; - case APValue::LValue: + case APValue::LValue: { (void)Context; -OS << "LValue "; +OS << "LValue Base="; +APValue::LValueBase B = Value.getLValueBase(); +if (B.isNull()) + OS << "null"; +else if (const auto *BE = B.dyn_cast()) { + OS << BE->getStmtClassName() << ' '; + dumpPointer(BE); +} else { + const auto *VDB = B.get(); + OS << VDB->getDeclKindName() << "Decl"; + dumpPointer(VDB); +} +OS << ", Null=" << Value.isNullPointer() + << ", Offset=" << Value.getLValueOffset().getQuantity() + << ", HasPath=" << Value.hasLValuePath(); +if (Value.hasLValuePath()) { + OS << ", PathLength=" << Value.getLValuePath().size(); + OS << ", Path=("; + llvm::ListSeparator Sep; + for (const auto &PathEntry : Value.getLValuePath()) { +// We're printing all entries as array indices because don't have the +// type information here to do anything else. +OS << Sep << PathEntry.getAsArrayIndex(); + } + OS << ")"; +} return; + } case APValue::Array: { unsigned ArraySize = Value.getArraySize(); unsigned NumInitializedElements = Value.getArrayInitializedElts(); diff --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp b/clang/test/AST/ast-dump-APValue-lvalue.cpp new file mode 100644 index 00..224caddb3eabe6 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp @@ -0,0 +1,50 @@ +// Test without serialization: +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN:-ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s +// +// Test with serialization: +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s +// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \ +// RUN: | sed -e "s/ //" -e "s/ imported//" \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +int i; +struct S { + int i; + int ii; +}; +S s; + +struct F { + char padding[12]; + S s; +}; +F f; + +void Test(int (&arr)[10]) { + constexpr int *pi = &i; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} pi 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=0, Path=() + + constexpr int *psi = &s.i; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} psi 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=1, Path=({{.*}}) + + constexpr int *psii = &s.ii; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} psii 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, HasPath=1, PathLength=1, Path=({{.*}}) + + constexpr int *pf = &f.s.ii; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} pf 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=16, HasPath=1, PathLength=2, Path=({{.*}}, {{.*}}) + + constexpr char *pc = &f.padding[2]; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} pc 'char *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, HasPath=1, PathLength=2, Path=({{.*}}, 2) + + constexpr const int *n = nullptr; + // CHECK:`-VarDecl {{.*}} col:{{.*}} n 'const int *const' constexpr cinit + // CHECK-NEXT: |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=() +} diff --git a/clang/test/AST/ast-dump-APValue-todo.cpp b/clang/test/AST/ast-dump-APValue-todo.cpp index 78cc9cf36c73c1..acaa82ba53b6fd 100644 --- a/clang/test/AST/ast-dump-APValue-todo.cpp +++ b/clang/test/AST/ast-dump-APValue-todo.cpp @@ -16,10 +16,6 @@ struct S { }; void Test() { - constexpr int
[libcxx] [libcxxabi] [libunwind] [llvm] [libc++] Enable -Wmissing-prototypes (PR #116261)
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/116261 >From 8dfd58d01909d9b275a28afdac287a5c2e5423b8 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Thu, 14 Nov 2024 18:30:39 +0100 Subject: [PATCH] [libc++] Enable -Wmissing-prototypes --- libcxx/include/fstream | 2 +- libcxx/src/charconv.cpp| 5 - libcxx/src/experimental/time_zone.cpp | 2 +- libcxx/src/experimental/tzdb.cpp | 3 +++ libcxx/src/filesystem/int128_builtins.cpp | 2 ++ libcxx/src/include/from_chars_floating_point.h | 4 ++-- libcxx/src/support/win32/compiler_rt_shims.cpp | 2 ++ libcxx/src/support/win32/locale_win32.cpp | 2 +- libcxxabi/src/cxa_personality.cpp | 5 + libcxxabi/src/private_typeinfo.cpp | 6 ++ libunwind/src/UnwindLevel1.c | 1 - libunwind/src/libunwind_ext.h | 1 + runtimes/cmake/Modules/WarningFlags.cmake | 1 + 13 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libcxx/include/fstream b/libcxx/include/fstream index f0e9425e0a53d9..4c126e724507af 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -226,7 +226,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) +#if _LIBCPP_STD_VER >= 23 && defined(_LIBCPP_WIN32API) _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept; #endif diff --git a/libcxx/src/charconv.cpp b/libcxx/src/charconv.cpp index 5e8cb7d97703b4..4621df05066997 100644 --- a/libcxx/src/charconv.cpp +++ b/libcxx/src/charconv.cpp @@ -18,9 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace __itoa { +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") +// These functions exist for ABI compatibility, so we don't ever want a declaration. _LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); } - _LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); } +_LIBCPP_DIAGNOSTIC_POP } // namespace __itoa diff --git a/libcxx/src/experimental/time_zone.cpp b/libcxx/src/experimental/time_zone.cpp index 764a89ab513c86..c5ba94321e07ce 100644 --- a/libcxx/src/experimental/time_zone.cpp +++ b/libcxx/src/experimental/time_zone.cpp @@ -711,7 +711,7 @@ __get_sys_info(sys_seconds __time, // Iff the "offsets" are the same '__current.__end' is replaced with // '__next.__end', which effectively merges the two objects in one object. The // function returns true if a merge occurred. -[[nodiscard]] bool __merge_continuation(sys_info& __current, const sys_info& __next) { +[[nodiscard]] static bool __merge_continuation(sys_info& __current, const sys_info& __next) { if (__current.end != __next.begin) return false; diff --git a/libcxx/src/experimental/tzdb.cpp b/libcxx/src/experimental/tzdb.cpp index f38f495c2d0bbe..a3861894a045d6 100644 --- a/libcxx/src/experimental/tzdb.cpp +++ b/libcxx/src/experimental/tzdb.cpp @@ -49,6 +49,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono { +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") // This function is weak so it can be overriden in the tests. The // declaration is in the test header test/support/test_tzdb.h _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { @@ -58,6 +60,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { # error "unknown path to the IANA Time Zone Database" #endif } +_LIBCPP_DIAGNOSTIC_POP //===--===// // Details diff --git a/libcxx/src/filesystem/int128_builtins.cpp b/libcxx/src/filesystem/int128_builtins.cpp index da6f39e7d78b60..e811b3e6f912db 100644 --- a/libcxx/src/filesystem/int128_builtins.cpp +++ b/libcxx/src/filesystem/int128_builtins.cpp @@ -16,6 +16,8 @@ #include <__config> #include +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") // See the FIXME above + #if _LIBCPP_HAS_INT128 extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t diff --git a/libcxx/src/include/from_chars_floating_point.h b/libcxx/src/include/from_chars_floating_point.h index 19eeeb28fb08d2..81d2180cc94805 100644 --- a/libcxx/src/include/from_chars_floating_point.h +++ b/libcxx/src/include/from_chars_floating_point.h @@ -193,7 +193,7 @@ struct __exponent_result { // __offset, 0, false. This allows using the results unconditionally, the // __present is important for the scientific notation, where the value is // mandatory. -__exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) { +static __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) { if (__offset + 1 < __n &&
[clang] [StrTable] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
https://github.com/durga4github edited https://github.com/llvm/llvm-project/pull/122873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Optimize CLC vector is(un)ordered builtins (PR #124546)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/124546 These are similar to 347fb208, but these builtins are expressed in terms of other builtins. The LLVM IR generated features the same fcmp ord/uno comparisons as before, but consistently in vector form. >From 7ceda5f4333133a0dd195d8d84bc30a08b5b9743 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 27 Jan 2025 13:59:49 + Subject: [PATCH] [libclc] Optimize CLC vector is(un)ordered builtins These are similar to 347fb208, but these builtins are expressed in terms of other builtins. The LLVM IR generated features the same fcmp ord/uno comparisons as before, but consistently in vector form. --- .../clc/include/clc/relational/relational.h | 79 --- .../lib/generic/relational/clc_isordered.cl | 22 +++--- .../lib/generic/relational/clc_isunordered.cl | 26 +++--- 3 files changed, 18 insertions(+), 109 deletions(-) diff --git a/libclc/clc/include/clc/relational/relational.h b/libclc/clc/include/clc/relational/relational.h index f32e7630203e4b..f269715cfc83c9 100644 --- a/libclc/clc/include/clc/relational/relational.h +++ b/libclc/clc/include/clc/relational/relational.h @@ -63,85 +63,6 @@ ARG_TYPE) \ _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, FUNCTION, ARG_TYPE) -#define _CLC_DEFINE_RELATIONAL_BINARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_NAME, \ - ARG0_TYPE, ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return BUILTIN_NAME(x, y); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo, y.lo), \ - FUNCTION(x.hi, y.hi)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC2(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo, y.lo), \ - FUNCTION(x.hi, y.hi)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC3(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC4(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2), \ - FUNCTION(x.s3, y.s3)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC8(RET_TYPE, FUNCTION, ARG0_TYPE, \ - ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2), FUNCTION(x.s3, y.s3), \ - FUNCTION(x.s4, y.s4), FUNCTION(x.s5, y.s5), \ - FUNCTION(x.s6, y.s6), \ - FUNCTION(x.s7, y.s7)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_BINARY_VEC16(RET_TYPE, FUNCTION, ARG0_TYPE, \ -ARG1_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE y) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0, y.s0), FUNCTION(x.s1, y.s1), \ - FUNCTION(x.s2, y.s2), FUNCTION(x.s3, y.s3), \ - FUNCTION(x.s4, y.s4), FUNCTION(x.s5, y.s5), \ - FUNCTION(x.s6, y.s6), FUNCTION(x.s7, y.s7), \ - FUNCTION(x.s8, y.s8), FUNCTION(x.s9, y.s9), \ - FUNCTION(x.sa, y.sa), FUNCTION(x.sb, y.sb), \ - FUNCTION(x.sc, y.sc), FUNCTION(x.sd, y.sd), \ -
[libclc] [libclc] Optimize CLC vector is(un)ordered builtins (PR #124546)
frasercrmck wrote: Apologies for the noise - these arguably should have been part of #124537. https://github.com/llvm/llvm-project/pull/124546 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)
Sirraide wrote: > I'm worried about the fallout and I have vague recollections of some early > work I did when I assumed we were making this change for the C99 enforcement > work Another option would be to make this default to an error depending on the language mode (e.g. only in C23 or later, and either unconditionally in C++ or in e.g. C++17 or later etc.); I don’t have any actual data on this, but I would imagine that most programs that actually have code that triggers this warning are probably C99 or earlier. https://github.com/llvm/llvm-project/pull/123470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
https://github.com/Meinersbur commented: Some nitpicks left. I will LGTM this after you applied them and nobody else has remarks. Converting all the lines to `@+` syntax would not have been necessary, only those you needed to change. I think it has become a lot more maintainable now. For prefix names, I have no better suggestion. I'd sign off using `// DEFINE:` as well, but don't require it. https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [Clang] Make `-Wreturn-type` default to an error in all language modes (PR #123470)
thesamesam wrote: > The way -Wreturn-type is implemented in Clang is we build a CFG from the AST > and then walk that to determine whether all paths return a value, if that’s > what you’re asking. What I'm asking is: isn't this more susceptible to FPs than other typical Clang warnings, and hence maybe shouldn't be an error? e.g. cases where some assert is made in the only caller so we know it can't happen, or it's a fixed value and that is wrongly not propagated. https://github.com/llvm/llvm-project/pull/123470 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)
zmodem wrote: Okay. I think most of my previous comments (except for "maybe the fix is to always ignore config files in clang-cl mode) still apply though. https://github.com/llvm/llvm-project/pull/111397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [StrTable] Mechanically convert NVPTX builtins to use TableGen (PR #122873)
@@ -0,0 +1,1078 @@ +//===--- BuiltinsNVPTX.td - NVPTX Builtin function defs -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file defines the PTX-specific builtin function database. +// +//===--===// + +include "clang/Basic/BuiltinsBase.td" + +class SMFeatures { + string Features; +} + +class SM newer_list> : SMFeatures { + let Features = !foldl(!strconcat("sm_", version), newer_list, f, newer, +!strconcat(f, "|", newer.Features)); +} + +let Features = "sm_100a" in def SM_100a : SMFeatures; + +def SM_100 : SM<"100", [SM_100a]>; + +let Features = "sm_90a" in def SM_90a : SMFeatures; + +def SM_90 : SM<"90", [SM_90a, SM_100]>; +def SM_89 : SM<"89", [SM_90]>; +def SM_87 : SM<"87", [SM_89]>; +def SM_86 : SM<"86", [SM_87]>; +def SM_80 : SM<"80", [SM_86]>; +def SM_75 : SM<"75", [SM_80]>; +def SM_72 : SM<"72", [SM_75]>; +def SM_70 : SM<"70", [SM_72]>; +def SM_62 : SM<"62", [SM_70]>; +def SM_61 : SM<"61", [SM_62]>; +def SM_60 : SM<"60", [SM_61]>; +def SM_53 : SM<"53", [SM_60]>; + +class PTXFeatures { + string Features; +} + +class PTX : PTXFeatures { + let Features = !strconcat("ptx", version, "|", newer.Features); +} + +let Features = "ptx86" in def PTX86 : PTXFeatures; + +def PTX85 : PTX<"85", PTX86>; +def PTX84 : PTX<"84", PTX85>; +def PTX83 : PTX<"83", PTX84>; +def PTX82 : PTX<"82", PTX83>; +def PTX81 : PTX<"81", PTX82>; +def PTX80 : PTX<"80", PTX81>; +def PTX78 : PTX<"78", PTX80>; +def PTX77 : PTX<"77", PTX78>; +def PTX76 : PTX<"76", PTX77>; +def PTX75 : PTX<"75", PTX76>; +def PTX74 : PTX<"74", PTX75>; +def PTX73 : PTX<"73", PTX74>; +def PTX72 : PTX<"72", PTX73>; +def PTX71 : PTX<"71", PTX72>; +def PTX70 : PTX<"70", PTX71>; +def PTX65 : PTX<"65", PTX70>; +def PTX64 : PTX<"64", PTX65>; +def PTX63 : PTX<"63", PTX64>; +def PTX62 : PTX<"62", PTX63>; +def PTX61 : PTX<"61", PTX62>; +def PTX60 : PTX<"60", PTX61>; +def PTX42 : PTX<"42", PTX60>; + +class NVPTXBuiltin : TargetBuiltin { + let Spellings = [NAME]; + let Prototype = prototype; +} + +class NVPTXBuiltinSM : NVPTXBuiltin { + let Features = sm.Features; +} + +class NVPTXBuiltinPTX : NVPTXBuiltin { + let Features = ptx.Features; +} + +class NVPTXBuiltinSMAndPTX : NVPTXBuiltin { + let Features = !strconcat("(", sm.Features, "),(", ptx.Features, ")"); +} + +// Special Registers + +let Attributes = [NoThrow, Const] in { + def __nvvm_read_ptx_sreg_tid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_tid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_tid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_tid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_ntid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ntid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ntid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ntid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_ctaid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ctaid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ctaid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_ctaid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_nctaid_x : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nctaid_y : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nctaid_z : NVPTXBuiltin<"int()">; + def __nvvm_read_ptx_sreg_nctaid_w : NVPTXBuiltin<"int()">; + + def __nvvm_read_ptx_sreg_clusterid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_clusterid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_clusterid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_clusterid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_nclusterid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_nclusterid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_nclusterid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_nclusterid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_cluster_ctaid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_ctaid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_ctaid_z : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_ctaid_w : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + + def __nvvm_read_ptx_sreg_cluster_nctaid_x : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_nctaid_y : NVPTXBuiltinSMAndPTX<"int()", SM_90, PTX78>; + def __nvvm_read_ptx_sreg_cluster_nctaid_z :
[clang] [clang-tools-extra] [flang] [clang] Extend diagnose_if to accept more detailed warning information, take 2 (PR #119712)
https://github.com/kadircet edited https://github.com/llvm/llvm-project/pull/119712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [flang] [clang] Extend diagnose_if to accept more detailed warning information, take 2 (PR #119712)
@@ -551,10 +547,12 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, // as well as disabling all messages which are currently mapped to Warning // (whether by default or downgraded from Error via e.g. -Wno-error or #pragma // diagnostic.) + // FIXME: Should -w be ignored for custom warnings without a group? kadircet wrote: sorry you're right, i forgot that this code path wasn't executed for custom diags at all before this patch. https://github.com/llvm/llvm-project/pull/119712 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [flang] [clang] Extend diagnose_if to accept more detailed warning information, take 2 (PR #119712)
https://github.com/kadircet approved this pull request. thanks! > This just exposes the same semantics as the tablegen files. alright, i guess I was missing this perspective. that makes sense now, thanks for the explanation! https://github.com/llvm/llvm-project/pull/119712 ___ 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)
cor3ntin wrote: @nfrmtk I'm so sorry this fell off my radar. Feel free pinging every week I believe this looks reasonable, it just needs an entry in clang/docs/ReleaseNotes.rst https://github.com/llvm/llvm-project/pull/105647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Optimize CLC vector relational builtins (PR #124537)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/124537 Clang knows how to perform relational operations on OpenCL vectors, so we don't need to use the Clang builtins. The builtins we were using didn't support vector types, so we were previously scalarizing. This commit generates the same LLVM fcmp operations as before, just without the scalarization. >From bc7ce5f3ab9e796475d017d8b169b916adc1e489 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Mon, 27 Jan 2025 12:35:51 + Subject: [PATCH] [libclc] Optimize CLC vector relational builtins Clang knows how to perform relational operations on OpenCL vectors, so we don't need to use the Clang builtins. The builtins we were using didn't support vector types, so we were previously scalarizing. This commit generates the same LLVM fcmp operations as before, just without the scalarization. --- .../clc/include/clc/relational/relational.h | 26 + .../clc/lib/generic/relational/clc_isequal.cl | 38 ++- .../lib/generic/relational/clc_isgreater.cl | 23 +++ .../generic/relational/clc_isgreaterequal.cl | 30 ++- .../clc/lib/generic/relational/clc_isless.cl | 31 ++- .../lib/generic/relational/clc_islessequal.cl | 24 .../generic/relational/clc_islessgreater.cl | 27 + .../lib/generic/relational/clc_isnotequal.cl | 21 -- 8 files changed, 90 insertions(+), 130 deletions(-) diff --git a/libclc/clc/include/clc/relational/relational.h b/libclc/clc/include/clc/relational/relational.h index 54241b6493c8e7..f32e7630203e4b 100644 --- a/libclc/clc/include/clc/relational/relational.h +++ b/libclc/clc/include/clc/relational/relational.h @@ -142,4 +142,30 @@ _CLC_DEFINE_RELATIONAL_BINARY_VEC_ALL(RET_TYPE, FUNCTION, ARG0_TYPE, \ ARG1_TYPE) +#define _CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(RET_TYPE, RET_TYPE_VEC, FUNCTION, \ + ARG1_TYPE, ARG2_TYPE) \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##2 FUNCTION(ARG1_TYPE##2 x, \ + ARG2_TYPE##2 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##3 FUNCTION(ARG1_TYPE##3 x, \ + ARG2_TYPE##3 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##4 FUNCTION(ARG1_TYPE##4 x, \ + ARG2_TYPE##4 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##8 FUNCTION(ARG1_TYPE##8 x, \ + ARG2_TYPE##8 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } \ + _CLC_DEF _CLC_OVERLOAD RET_TYPE_VEC##16 FUNCTION(ARG1_TYPE##16 x, \ + ARG2_TYPE##16 y) { \ +return _CLC_RELATIONAL_OP(x, y); \ + } + #endif // __CLC_RELATIONAL_RELATIONAL_H__ diff --git a/libclc/clc/lib/generic/relational/clc_isequal.cl b/libclc/clc/lib/generic/relational/clc_isequal.cl index 7664df7767cb3f..053a237289fd60 100644 --- a/libclc/clc/lib/generic/relational/clc_isequal.cl +++ b/libclc/clc/lib/generic/relational/clc_isequal.cl @@ -1,44 +1,28 @@ #include +#include -#define _CLC_DEFINE_ISEQUAL(RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \ -return (x == y); \ - } +#define _CLC_RELATIONAL_OP(X, Y) (X) == (Y) -_CLC_DEFINE_ISEQUAL(int, __clc_isequal, float, float) -_CLC_DEFINE_ISEQUAL(int2, __clc_isequal, float2, float2) -_CLC_DEFINE_ISEQUAL(int3, __clc_isequal, float3, float3) -_CLC_DEFINE_ISEQUAL(int4, __clc_isequal, float4, float4) -_CLC_DEFINE_ISEQUAL(int8, __clc_isequal, float8, float8) -_CLC_DEFINE_ISEQUAL(int16, __clc_isequal, float16, float16) +_CLC_DEFINE_SIMPLE_RELATIONAL_BINARY(int, int, __clc_isequal, float, float) #ifdef cl_khr_fp64
[libclc] [libclc] Optimize isfpclass-like CLC builtins (PR #124145)
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/124145 >From 0186cf20e0abb8c5bca9e830d2b6d4e425c7bcc9 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Thu, 23 Jan 2025 12:24:49 + Subject: [PATCH] [libclc] Optimize isfpclass-like CLC builtins Using __builtin_isfpclass helps us to avoid scalarization in the vector forms of __clc_is(finite|inf|nan|normal) (and thus their OpenCL counterparts). --- .../clc/include/clc/relational/relational.h | 82 ++- .../lib/generic/relational/clc_isfinite.cl| 15 +--- .../clc/lib/generic/relational/clc_isinf.cl | 8 +- .../clc/lib/generic/relational/clc_isnan.cl | 14 ++-- .../lib/generic/relational/clc_isnormal.cl| 15 +--- .../clc/lib/generic/relational/clc_signbit.cl | 51 +++- 6 files changed, 91 insertions(+), 94 deletions(-) diff --git a/libclc/clc/include/clc/relational/relational.h b/libclc/clc/include/clc/relational/relational.h index f32e7630203e4b..24771a219d87b5 100644 --- a/libclc/clc/include/clc/relational/relational.h +++ b/libclc/clc/include/clc/relational/relational.h @@ -6,63 +6,6 @@ * when the result is true. */ -#define _CLC_DEFINE_RELATIONAL_UNARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_NAME, \ -ARG_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ -return BUILTIN_NAME(x); \ - } - -#define _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE, FUNCTION, ARG_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.lo), FUNCTION(x.hi)} != \ - (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE, FUNCTION, ARG_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), \ - FUNCTION(x.s2)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE, FUNCTION, ARG_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ -return (RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), \ - FUNCTION(x.s2), \ - FUNCTION(x.s3)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE, FUNCTION, ARG_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ -return ( \ -RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), \ - FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5), \ - FUNCTION(x.s6), FUNCTION(x.s7)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE, FUNCTION, ARG_TYPE) \ - _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG_TYPE x) { \ -return ( \ -RET_TYPE)((RET_TYPE){FUNCTION(x.s0), FUNCTION(x.s1), FUNCTION(x.s2), \ - FUNCTION(x.s3), FUNCTION(x.s4), FUNCTION(x.s5), \ - FUNCTION(x.s6), FUNCTION(x.s7), FUNCTION(x.s8), \ - FUNCTION(x.s9), FUNCTION(x.sa), FUNCTION(x.sb), \ - FUNCTION(x.sc), FUNCTION(x.sd), FUNCTION(x.se), \ - FUNCTION(x.sf)} != (RET_TYPE)0); \ - } - -#define _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, FUNCTION, ARG_TYPE) \ - _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE##2, FUNCTION, ARG_TYPE##2) \ - _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE##3, FUNCTION, ARG_TYPE##3) \ - _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE##4, FUNCTION, ARG_TYPE##4) \ - _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE##8, FUNCTION, ARG_TYPE##8) \ - _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE##16, FUNCTION, ARG_TYPE##16) - -#define _CLC_DEFINE_RELATIONAL_UNARY(RET_TYPE, FUNCTION, BUILTIN_FUNCTION, \ - ARG_TYPE) \ - _CLC_DEFINE_RELATIONAL_UNARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_FUNCTION, \ - ARG_TYPE) \ - _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, FUNCTION, ARG_TYPE) - #define _CLC_DEFINE_RELATIONAL_BINARY_SCALAR(RET_TYPE, FUNCTION, BUILTIN_NAME, \ ARG0_TYPE, ARG1_TYPE) \ _CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG0_TYPE x, ARG1_TYPE
[clang] [AArch64][Clang] Update untyped sme intrinsics with fp8 variants (PR #124543)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (Lukacma) Changes This patch adds fp8 variants to the following untyped SME intrinsics based on [ACLE](https://github.com/ARM-software/acle/blob/main/main/acle.md): ``` svint8_t svread_hor_za8[_s8]_m(svint8_t zd, svbool_t pg, uint64_t tile, uint32_t slice) svint8_t svread_hor_za128[_s8]_m(svint8_t zd, svbool_t pg, uint64_t tile, uint32_t slice) void svwrite_hor_za8[_s8]_m(uint64_t tile, uint32_t slice, svbool_t pg, svint8_t zn) void svwrite_hor_za128[_s8]_m(uint64_t tile, uint32_t slice, svbool_t pg, svint8_t zn) svint8_t svluti2_lane_zt_s8(uint64_t zt, svuint8_t zn, uint64_t imm_idx) svint8x2_t svluti2_lane_zt_s8_x2(uint64_t zt, svuint8_t zn, svint8x4_t svluti2_lane_zt_s8_x4(uint64_t zt, svuint8_t zn, svint8_t svluti4_lane_zt_s8(uint64_t zt, svuint8_t zn, uint64_t imm_idx) svint16x4_t svluti4_lane_zt_s16_x4(uint64_t zt, svuint8_t zn, svint8x2_t svread_hor_za8_s8_vg2(uint64_t tile, uint32_t slice) svint8x4_t svread_hor_za8_s8_vg4(uint64_t tile, uint32_t slice) svint8x2_t svread_ver_za8_s8_vg2(uint64_t tile, uint32_t slice) svint8x4_t svread_ver_za8_s8_vg4(uint64_t tile, uint32_t slice) svint8x2_t svread_za8_s8_vg1x2(uint32_t slice) svint8x4_t svread_za8_s8_vg1x4(uint32_t slice) void svwrite_hor_za8[_s8]_vg2(uint64_t tile, uint32_t slice, svint8x2_t zn) void svwrite_hor_za8[_s8]_vg4(uint64_t tile, uint32_t slice, svint8x4_t zn) void svwrite_ver_za8[_s8]_vg2(uint64_t tile, uint32_t slice, svint8x2_t zn) void svwrite_ver_za8[_s8]_vg4(uint64_t tile, uint32_t slice, svint8x4_t zn) void svwrite_za8[_s8]_vg1x2(uint32_t slice, svint8x2_t zn) void svwrite_za8[_s8]_vg1x4(uint32_t slice, svint8x4_t zn) svuint8x2_t svsel[_u8_x2](svcount_t png, svuint8x2_t zn, svuint8x2_t zm) svuint8x4_t svsel[_u8_x4](svcount_t png, svuint8x4_t zn, svuint8x4_t zm) svint8x2_t svzip[_s8_x2](svint8x2_t zn) __arm_streaming; svint8x4_t svzip[_s8_x4](svint8x4_t zn) __arm_streaming; svint8x2_t svzipq[_s8_x2](svint8x2_t zn) __arm_streaming; svint8x4_t svzipq[_s8_x4](svint8x4_t zn) __arm_streaming; svint8x2_t svuzp[_s8_x2](svint8x2_t zn) __arm_streaming; svint8x4_t svuzp[_s8_x4](svint8x4_t zn) __arm_streaming; svint8x2_t svuzpq[_s8_x2](svint8x2_t zn) __arm_streaming; svint8_t svreadz_ver_za128_s8(uint64_t tile, uint32_t slice) svint8x2_t svreadz_hor_za8_s8_vg2(uint64_t tile, uint32_t slice) svint8x4_t svreadz_hor_za8_s8_vg4(uint64_t tile, uint32_t slice) svint8x2_t svreadz_ver_za8_s8_vg2(uint64_t tile, uint32_t slice) svint8x4_t svreadz_ver_za8_s8_vg4(uint64_t tile, uint32_t slice) svint8x2_t svreadz_za8_s8_vg1x2(uint32_t slice) svint8x4_t svreadz_za8_s8_vg1x4(uint32_t slice) svint8_t svreadz_ver_za128_s8(uint64_t tile, uint32_t slice) svuint8_t svrevd[_u8]_m(svuint8_t zd, svbool_t pg, svuint8_t zn); svuint8_t svrevd[_u8]_z(svbool_t pg, svuint8_t zn); svuint8_t svrevd[_u8]_x(svbool_t pg, svuint8_t zn); ``` --- Patch is 120.04 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/124543.diff 19 Files Affected: - (modified) clang/include/clang/Basic/arm_sme.td (+16-16) - (modified) clang/include/clang/Basic/arm_sve.td (+12-12) - (modified) clang/test/CodeGen/AArch64/sme-intrinsics/acle_sme_read.c (+134) - (modified) clang/test/CodeGen/AArch64/sme-intrinsics/acle_sme_write.c (+135) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti2_lane_zt.c (+13) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti2_lane_zt_x2.c (+14) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti2_lane_zt_x4.c (+14) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti4_lane_zt.c (+14) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti4_lane_zt_x2.c (+14) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_read.c (+83-1) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_selx2.c (+13) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_selx4.c (+57-43) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_uzpx2.c (+28) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_uzpx4.c (+28) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_zipx2.c (+28) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_zipx4.c (+28) - (modified) clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_write.c (+74-4) - (modified) clang/test/CodeGen/AArch64/sme2p1-intrinsics/acle_sme2p1_movaz.c (+136) - (modified) clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_revd.c (+42) ``diff diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 891ed9874bb3d0..51cab572ce357d 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -110,11 +110,11 @@ multiclass ZARead ch> } } -defm SVREAD_ZA8 : ZARead<"za8", "cUc", "aarch64_sme_read", [ImmCh
[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)
https://github.com/sivan-shani edited https://github.com/llvm/llvm-project/pull/118771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][Clang] Update untyped sme intrinsics with fp8 variants (PR #124543)
https://github.com/Lukacma edited https://github.com/llvm/llvm-project/pull/124543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][Clang] Update untyped sme intrinsics with fp8 variants (PR #124543)
github-actions[bot] wrote: :warning: undef deprecator found issues in your code. :warning: You can test this locally with the following command: ``bash git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' c4ef805b0bda16f734276086b0984583c2e21db6 a6d2a91865c001db4ed9d82b126cca7ab6b6395f clang/test/CodeGen/AArch64/sme-intrinsics/acle_sme_read.c clang/test/CodeGen/AArch64/sme-intrinsics/acle_sme_write.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti2_lane_zt.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti2_lane_zt_x2.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti2_lane_zt_x4.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti4_lane_zt.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_luti4_lane_zt_x2.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_read.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_selx2.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_selx4.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_uzpx2.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_uzpx4.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_zipx2.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_vector_zipx4.c clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_write.c clang/test/CodeGen/AArch64/sme2p1-intrinsics/acle_sme2p1_movaz.c clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_revd.c `` The following files introduce new uses of undef: - clang/test/CodeGen/AArch64/sve2-intrinsics/acle_sve2_revd.c [Undef](https://llvm.org/docs/LangRef.html#undefined-values) is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields `undef`. You should use `poison` values for placeholders instead. In tests, avoid using `undef` and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead. For example, this is considered a bad practice: ```llvm define void @fn() { ... br i1 undef, ... } ``` Please use the following instead: ```llvm define void @fn(i1 %cond) { ... br i1 %cond, ... } ``` Please refer to the [Undefined Behavior Manual](https://llvm.org/docs/UndefinedBehavior.html) for more information. https://github.com/llvm/llvm-project/pull/124543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/124533 >From b195bfb253df84ea315eb92a59bbae2401b0248f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 27 Jan 2025 19:48:43 +0800 Subject: [PATCH 1/2] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr We used to always transform the pattern declaration for SizeOfPackExpr to ensure the constraint expression's profile produced the desired result. However, this approach failed to handle pack expansions when the pack referred to function parameters. In such cases, the function parameters were previously expanded to 1 to avoid building Subst* nodes (see e6974daa7). That workaround caused us to transform a pack without a proper ArgumentPackSubstitutionIndex, leading to crashes when transforming the pattern. It turns out that profiling the pattern for partially substituted SizeOfPackExprs is unnecessary because their transformed forms are already profiled within the partial arguments. Moreover, we always end up with a partially transformed SizeOfPackExpr for constraint comparison. --- clang/include/clang/AST/ExprCXX.h | 2 -- clang/lib/AST/StmtProfile.cpp | 2 +- clang/lib/Sema/SemaTemplateInstantiate.cpp| 17 --- .../SemaTemplate/concepts-out-of-line-def.cpp | 28 +++ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 4cec89c979f775..04529fa616d703 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -4326,8 +4326,6 @@ class SizeOfPackExpr final /// Retrieve the parameter pack. NamedDecl *getPack() const { return Pack; } - void setPack(NamedDecl *NewPack) { Pack = NewPack; } - /// Retrieve the length of the parameter pack. /// /// This routine may only be invoked when the expression is not diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index 0f1ebc68a4f762..089d91d2736459 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -2266,13 +2266,13 @@ void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { VisitExpr(S); - VisitDecl(S->getPack()); if (S->isPartiallySubstituted()) { auto Args = S->getPartialArguments(); ID.AddInteger(Args.size()); for (const auto &TA : Args) VisitTemplateArgument(TA); } else { +VisitDecl(S->getPack()); ID.AddInteger(0); } } diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 839c4e8a28220b..98bc630fb69cc5 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1747,23 +1747,6 @@ namespace { return inherited::TransformLambdaBody(E, Body); } -ExprResult TransformSizeOfPackExpr(SizeOfPackExpr *E) { - ExprResult Transformed = inherited::TransformSizeOfPackExpr(E); - if (!Transformed.isUsable()) -return Transformed; - auto *TransformedExpr = cast(Transformed.get()); - if (SemaRef.CodeSynthesisContexts.back().Kind == - Sema::CodeSynthesisContext::ConstraintNormalization && - TransformedExpr->getPack() == E->getPack()) { -Decl *NewPack = -TransformDecl(E->getPackLoc(), TransformedExpr->getPack()); -if (!NewPack) - return ExprError(); -TransformedExpr->setPack(cast(NewPack)); - } - return TransformedExpr; -} - ExprResult TransformRequiresExpr(RequiresExpr *E) { LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true); ExprResult TransReq = inherited::TransformRequiresExpr(E); diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp index 7cb5cfc10b9a7b..16779ba184296d 100644 --- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp +++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp @@ -720,6 +720,34 @@ template struct d { template struct c; template struct d; +namespace Regression_123441 { + +struct buf { + constexpr buf(auto&&... initList) requires (sizeof...(initList) <= 8); +}; + +constexpr buf::buf(auto&&... initList) requires (sizeof...(initList) <= 8) {} + +template +struct buffer { + constexpr buffer(auto&&... initList) requires (sizeof...(initList) <= 8); +}; + +template +constexpr buffer::buffer(auto&&... initList) requires (sizeof...(initList) <= 8) {} + +template +struct foo { // expected-note {{foo defined here}} + constexpr foo(auto&&... initList) +requires (sizeof...(initList) <= 8); +}; + +template +constexpr foo::foo(auto&&... initList) // expected-error {{does not match any declaration}} + requires (sizeof...(T) <= 8) {} + +} + } // namespace GH115098 namespace GH114685 { >From ff5c63238be87f6f08ccdf914581ebd907b41328 Mon S
[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)
https://github.com/sivan-shani edited https://github.com/llvm/llvm-project/pull/118771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64][Clang] Update untyped sme intrinsics with fp8 variants (PR #124543)
https://github.com/Lukacma edited https://github.com/llvm/llvm-project/pull/124543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
@@ -68,15 +70,21 @@ int fun(int arg) { {} #pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}} {} +#ifndef OMP60 #pragma omp target map(mapper(ab) :vv) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}} +#endif {} +#ifndef OMP60 #pragma omp target map(mapper(ab) :arr[0:2])// expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}} +#endif {} -#pragma omp target map(mapper(aa) :vv) // expected-error {{missing map type}} +#ifndef OMP60 +#pragma omp target map(mapper(aa) :vv) // omp50-error {{missing map type}} omp51-error {{missing map type}} omp52-error {{missing map type}} omp51-simd-error {{missing map type}} {} -#pragma omp target map(mapper(aa) to:d) // expected-error {{mapper type must be of struct, union or class type}} omp52-error{{missing ',' after map type modifier}} +#endif +#pragma omp target map(mapper(aa) to:d) // expected-error {{mapper type must be of struct, union or class type}} omp52-error{{missing ',' after map type modifier}} omp60-error{{missing ',' after map type modifier}} omp60-simd-error{{missing ',' after map type modifier}} {} -#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0]) // omp52-error 4 {{missing ',' after map type modifier}} +#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0]) // omp52-error 4 {{missing ',' after map type modifier}} omp60-error 4 {{missing ',' after map type modifier}} omp60-simd-error 4 {{missing ',' after map type modifier}} Meinersbur wrote: ```suggestion // omp52-error@+3 4 {{missing ',' after map type modifier}} // omp60-error@+2 4 {{missing ',' after map type modifier}} // omp60-simd-error@+1 4 {{missing ',' after map type modifier}} #pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0]) ``` https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
@@ -124,4 +124,3 @@ target *S1 = &S; // CHECK-NEXT: #pragma omp declare target // CHECK-NEXT: target *S1 = &S; // CHECK-NEXT: #pragma omp end declare target - Meinersbur wrote: [nit] unrelated change https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
@@ -68,15 +70,21 @@ int fun(int arg) { {} #pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}} {} +#ifndef OMP60 #pragma omp target map(mapper(ab) :vv) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}} +#endif {} +#ifndef OMP60 #pragma omp target map(mapper(ab) :arr[0:2])// expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}} +#endif {} -#pragma omp target map(mapper(aa) :vv) // expected-error {{missing map type}} +#ifndef OMP60 +#pragma omp target map(mapper(aa) :vv) // omp50-error {{missing map type}} omp51-error {{missing map type}} omp52-error {{missing map type}} omp51-simd-error {{missing map type}} {} -#pragma omp target map(mapper(aa) to:d) // expected-error {{mapper type must be of struct, union or class type}} omp52-error{{missing ',' after map type modifier}} +#endif +#pragma omp target map(mapper(aa) to:d) // expected-error {{mapper type must be of struct, union or class type}} omp52-error{{missing ',' after map type modifier}} omp60-error{{missing ',' after map type modifier}} omp60-simd-error{{missing ',' after map type modifier}} Meinersbur wrote: ```suggestion // expected-error@+4 {{mapper type must be of struct, union or class type}} // omp52-error@+3 {{missing ',' after map type modifier}} // omp60-error@+2 {{missing ',' after map type modifier}} // omp60-simd-error@+1 {{missing ',' after map type modifier}} #pragma omp target map(mapper(aa) to:d) ``` https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
@@ -205,77 +262,134 @@ namespace { } #pragma omp end declare target -#pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}} +// expected-error@+1 {{'S' used in declare target directive is not a variable or a function name}} +#pragma omp declare target link(S) -#pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}} -#pragma omp declare target to(x) to(x) // omp45-error {{'x' appears multiple times in clauses on the same declare target directive}} omp5-error {{'x' appears multiple times in clauses on the same declare target directive}} omp51-error {{'x' appears multiple times in clauses on the same declare target directive}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}} -#pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}} +// expected-error@+1 {{'x' appears multiple times in clauses on the same declare target directive}} +#pragma omp declare target (x, x) +// omp52-error@+3 {{unexpected 'to' clause, use 'enter' instead}} +// omp52-error@+2 {{expected at least one 'enter', 'link' or 'indirect' clause}} +// omp45-to-51-clause-error@+1 {{'x' appears multiple times in clauses on the same declare target directive}} Meinersbur wrote: So much better 👍 https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)
https://github.com/Meinersbur edited https://github.com/llvm/llvm-project/pull/122108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits