[clang] [OpenACC][CIR] Start work to lower 'loop' (PR #137972)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp -- clang/test/CIR/CodeGenOpenACC/loop.cpp clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp clang/lib/Sema/SemaOpenACC.cpp clang/test/CIR/CodeGenOpenACC/openacc-not-implemented.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp index f26096f70..0c4c6371f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp @@ -19,7 +19,6 @@ #include "mlir/Dialect/OpenACC/OpenACC.h" - using namespace clang; using namespace clang::CIRGen; using namespace cir; `` https://github.com/llvm/llvm-project/pull/137972 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
emaxx-google wrote: > It is not clear to me why this is a specifically a problem when called from > `Profile(...)` can you elaborate a bit more in the summary. I've added a bit more details - it's basically the fact that the "get most recent" operation triggered the load of new nodes from the PCM file. If all this happens while a hash for another node is calculated in `Profile()`, it means we're modifying the hash map while doing another operation with it. At least that's the current theory, based on debugging the "deviating" executions of the compiler and seeing the `getMostRecentNonInjectedDecl()` call and the deserialization all during the `FoldingSet::NodeEquals()` function call. > Does `getMostRecentCXXRecordDecl(...)` require a comment that documents this > behavior so that future users do not fall into the same issue? Sure, I've added a comment. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenACC][CIR] Start work to lower 'loop' (PR #137972)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Erich Keane (erichkeane) Changes As can be seen by the comment, this ends up being a construct that is going to be quite a lot of work in the future to make sure we properly identify the upperbound, lowerbound, and step. For now, we just treat the 'loop' as container so that we can put the 'for' loop into it. In the future, we'll have to teach the OpenACC dialect how to derive the upperbound, lowerbound, and step from the cir.for loop. Additionally, we'll probably have to add a few more options to it so that we can give it the recipes it needs to determine these for random access iterators. For Integer and Pointer values, these should already be known. --- Full diff: https://github.com/llvm/llvm-project/pull/137972.diff 4 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp (+90-3) - (modified) clang/lib/Sema/SemaOpenACC.cpp (+2-2) - (added) clang/test/CIR/CodeGenOpenACC/loop.cpp (+33) - (modified) clang/test/CIR/CodeGenOpenACC/openacc-not-implemented.cpp (-6) ``diff diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp index b01ff85607939..f26096f708f99 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACCLoop.cpp @@ -13,10 +13,13 @@ #include "CIRGenBuilder.h" #include "CIRGenFunction.h" #include "CIRGenOpenACCClause.h" -#include "mlir/Dialect/OpenACC/OpenACC.h" + #include "clang/AST/OpenACCClause.h" #include "clang/AST/StmtOpenACC.h" +#include "mlir/Dialect/OpenACC/OpenACC.h" + + using namespace clang; using namespace clang::CIRGen; using namespace cir; @@ -24,6 +27,90 @@ using namespace mlir::acc; mlir::LogicalResult CIRGenFunction::emitOpenACCLoopConstruct(const OpenACCLoopConstruct &s) { - cgm.errorNYI(s.getSourceRange(), "OpenACC Loop Construct"); - return mlir::failure(); + mlir::Location start = getLoc(s.getSourceRange().getBegin()); + mlir::Location end = getLoc(s.getSourceRange().getEnd()); + llvm::SmallVector retTy; + llvm::SmallVector operands; + auto op = builder.create(start, retTy, operands); + + // TODO(OpenACC): In the future we are going to need to come up with a + // transformation here that can teach the acc.loop how to figure out the + // 'lowerbound', 'upperbound', and 'step'. + // + // -'upperbound' should fortunately be pretty easy as it should be + // in the initialization section of the cir.for loop. In Sema, we limit to + // just the forms 'Var = init', `Type Var = init`, or `Var = init` (where it + // is an operator= call)`. However, as those are all necessary to emit for + // the init section of the for loop, they should be inside the initial + // cir.scope. + // + // -'upperbound' should be somewhat easy to determine. Sema is limiting this + // to: ==, <, >, !=, <=, >= builtin operators, the overloaded 'comparison' + // operations, and member-call expressions. + // + // For the builtin comparison operators, we can pretty well deduce based on + // the comparison what the 'end' object is going to be, and the inclusive + // nature of it. + // + // For the overloaded operators, Sema will ensure that at least one side of + // the operator is the init variable, so we can deduce the comparison there + // too. The standard places no real bounds on WHAT the comparison operators do + // for a `RandomAccessIterator` however, so we'll have to just 'assume' they + // do the right thing? Note that this might be incrementing by a different + // 'object', not an integral, so it isn't really clear to me what we can do to + // determine the other side. + // + // Member-call expressions are the difficult ones. I don't think there is + // anything we can deduce from this to determine the 'end', so we might end up + // having to go back to Sema and make this ill-formed. + // + // HOWEVER: What ACC dialect REALLY cares about is the tripcount, which you + // cannot get (in the case of `RandomAccessIterator`) from JUST 'upperbound' + // and 'lowerbound'. We will likely have to provide a 'recipe' equivilent to + // `std::distance` instead. In the case of integer/pointers, it is fairly + // simple to find: it is just the mathematical subtraction. Howver, in the + // case of `RandomAccessIterator`, we have to enable the use of `operator-`. + // FORTUNATELY the standard requires this to work correctly for + // `RandomAccessIterator`, so we don't have to implement a `std::distance` + // that loops through, like we would for a forward/etc iterator. + // + // 'step': Sema is currently allowing builtin ++,--, +=, -=, *=, /=, and = + // operators. Additionally, it allows the equivilent for the operator-call, as + // well as member-call. + // + // For builtin operators, we perhaps should refine the assignment here. It + // doesn't reallly help us know the 'step' count at all, but we could perhaps + // do one more step
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); emaxx-google wrote: Yes, but this suggestion seems not needed because this `getCanonicalDecl()` call is already made inside the `Profile()` method: https://github.com/llvm/llvm-project/blob/e8ae77947154e10dbc05cbb95ec9e10d3b0be13e/clang/lib/AST/Type.cpp#L5279 https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenACC][CIR] Start work to lower 'loop' (PR #137972)
https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/137972 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,29 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +AST_MATCHER(clang::TypeLoc, isInImplicitTemplateInstantiation) { + const auto IsImplicitTemplateInstantiation = [](const auto *Node) { +return (Node != nullptr) && + (Node->getTemplateSpecializationKind() == TSK_ImplicitInstantiation); + }; + + auto ParentNodes = Finder->getASTContext().getParents(Node); + while (!ParentNodes.empty()) { +const auto &ParentNode = ParentNodes[0]; vbvictor wrote: ditto https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
https://github.com/emaxx-google edited https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
@@ -235,7 +237,8 @@ Changes in existing checks - Improved :doc:`bugprone-unsafe-functions ` check to allow specifying - additional functions to match. + additional functions to match. Added `ctime` and `localtime` + to unsafe functions check in clang-tidy. EugeneZelenko wrote: ```suggestion to unsafe functions list. ``` Entire section is about Clang-Tidy and this particular entry is about check. https://github.com/llvm/llvm-project/pull/110366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
https://github.com/vbvictor edited https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,29 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +AST_MATCHER(clang::TypeLoc, isInImplicitTemplateInstantiation) { + const auto IsImplicitTemplateInstantiation = [](const auto *Node) { +return (Node != nullptr) && + (Node->getTemplateSpecializationKind() == TSK_ImplicitInstantiation); + }; + + auto ParentNodes = Finder->getASTContext().getParents(Node); vbvictor wrote: Please use explicit type instead of `auto` unless type is spelled statement. https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,30 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +bool isWithinImplicitTemplateInstantiation(const TypeLoc *MatchedTypeLoc, vbvictor wrote: Maybe previous devs did not cover all cases, so you didn't have to delete and check-messages https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
https://github.com/zimirza updated https://github.com/llvm/llvm-project/pull/110366 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); erichkeane wrote: Hmm... then I'm surprised that this patch is needed at all for the purposes of non-determinism. `getMostRecentCXXRecordDecl()->getCanonicalDecl()` will get the same declaration as `getCXXRecordDecl()->getCanonicalDecl()`. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)
https://github.com/gedare updated https://github.com/llvm/llvm-project/pull/108332 >From 8846ff045f969b258554c3cfb72161e9f61dda19 Mon Sep 17 00:00:00 2001 From: Gedare Bloom Date: Thu, 20 Jun 2024 17:35:39 -0600 Subject: [PATCH 1/2] Format: add AlignAfterControlStatement Introduce new style option to allow overriding the breaking after the opening parenthesis for control statements (if/for/while/switch). Fixes #67738. Fixes #79176. Fixes #80123. --- clang/include/clang/Format/Format.h| 17 ++ clang/lib/Format/ContinuationIndenter.cpp | 69 +++-- clang/lib/Format/Format.cpp| 13 + clang/lib/Format/TokenAnnotator.cpp| 8 +- clang/unittests/Format/ConfigParseTest.cpp | 8 + clang/unittests/Format/FormatTest.cpp | 298 + 6 files changed, 391 insertions(+), 22 deletions(-) diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index f6ceef08b46da..274a9e4ee272a 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -62,6 +62,22 @@ struct FormatStyle { /// \version 3.3 int AccessModifierOffset; + /// Different styles for breaking the parenthesis after a control statement + /// (``if/switch/while/for ...``). + /// \version 21 + enum BreakAfterControlStatementStyle : int8_t { +/// Use the default behavior. +BACSS_Default, +/// Force break after the left parenthesis of a control statement only +/// when the expression exceeds the column limit, and align on the +/// ``ContinuationIndentWidth``. +BACSS_MultiLine, +/// Do not force a break after the control statment. +BACSS_No, + }; + + BreakAfterControlStatementStyle AlignAfterControlStatement; + /// Different styles for aligning after open brackets. enum BracketAlignmentStyle : int8_t { /// Align parameters on the open bracket, e.g.: @@ -5283,6 +5299,7 @@ struct FormatStyle { bool operator==(const FormatStyle &R) const { return AccessModifierOffset == R.AccessModifierOffset && AlignAfterOpenBracket == R.AlignAfterOpenBracket && + AlignAfterControlStatement == R.AlignAfterControlStatement && AlignArrayOfStructures == R.AlignArrayOfStructures && AlignConsecutiveAssignments == R.AlignConsecutiveAssignments && AlignConsecutiveBitFields == R.AlignConsecutiveBitFields && diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 55e1d1ceb55b7..f4e48b7e37d54 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -814,6 +814,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // parenthesis by disallowing any further line breaks if there is no line // break after the opening parenthesis. Don't break if it doesn't conserve // columns. + auto IsOtherConditional = [&](const FormatToken &Tok) { +return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) || + (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous && +Tok.Previous->is(tok::kw_for)); + }; auto IsOpeningBracket = [&](const FormatToken &Tok) { auto IsStartOfBracedList = [&]() { return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) && @@ -825,26 +830,36 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, } if (!Tok.Previous) return true; -if (Tok.Previous->isIf()) - return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak; -return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, - tok::kw_switch) && - !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await)); +if (Tok.Previous->isIf()) { + /* For backward compatibility, use AlignAfterOpenBracket + * in case AlignAfterControlStatement is not initialized */ + return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine || + (Style.AlignAfterControlStatement == FormatStyle::BACSS_Default && + Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak); +} +if (IsOtherConditional(*Tok.Previous)) + return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine; +if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak || +Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) { + return !Tok.Previous->is(TT_CastRParen) && + !(Style.isJavaScript() && Tok.is(Keywords.kw_await)); +} +return false; }; auto IsFunctionCallParen = [](const FormatToken &Tok) { return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous && Tok.Previous->is(tok::identifier); }; - auto IsInTemplateString = [this](const FormatToken &Tok) { + auto IsInTemplateString = [this](const FormatToken &Tok, bool NestBlocks) { if (!Style.isJavaScrip
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,Zishan Mirza ,Zishan Mirza ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan Message-ID: In-Reply-To: https://github.com/zimirza ready_for_review https://github.com/llvm/llvm-project/pull/110366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [IR] Do not store Function inside BlockAddress (PR #137958)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/137958 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); emaxx-google wrote: The issue is transient - the reproducibility rate on the reproducer (https://pastebin.com/6aL6rmBe) is only 1%. Also it's not the pointer we have here that's problematic, but rather the fact of extra AST node loading inside the `FoldingSet` hash calculation operation. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)
https://github.com/sarnex edited https://github.com/llvm/llvm-project/pull/137882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)
https://github.com/sarnex edited https://github.com/llvm/llvm-project/pull/137882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
AaronBallman wrote: > > > LGTM! Do you need me to land the changes on your behalf? > > > > > > Yup, I don't have access yet > > I'll push the changes once precommit CI goes green. Thank you for the > improvement! FYI: it looks like precommit CI found a failure with one of the tests https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
=?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=, =?utf-8?b?0JfQuNGI0LDQvSDQnNC40YDQtw=?=,Zishan Mirza ,Zishan Mirza ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan ,zishan Message-ID: In-Reply-To: zimirza wrote: `localtime_s` was removed from https://github.com/llvm/llvm-project/pull/110363, and will be added to a new pull request and `ctime_s` has not been merged yet (https://github.com/llvm/llvm-project/pull/110676). It might be a good wait before merging this pull request. https://github.com/llvm/llvm-project/pull/110366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 75f040a - [libclc] Clean up unnecessary #undef __CLC_BODYs (#137959)
Author: Fraser Cormack Date: 2025-04-30T16:13:04+01:00 New Revision: 75f040ab3e119e0ee87963ec9d2a01b1e6d4039e URL: https://github.com/llvm/llvm-project/commit/75f040ab3e119e0ee87963ec9d2a01b1e6d4039e DIFF: https://github.com/llvm/llvm-project/commit/75f040ab3e119e0ee87963ec9d2a01b1e6d4039e.diff LOG: [libclc] Clean up unnecessary #undef __CLC_BODYs (#137959) This macro is automatically undefined by the various gentype-like helpers. Added: Modified: libclc/clc/include/clc/common/clc_degrees.h libclc/clc/include/clc/common/clc_radians.h libclc/clc/include/clc/common/clc_sign.h libclc/clc/include/clc/common/clc_smoothstep.h libclc/clc/include/clc/integer/clc_add_sat.h libclc/clc/include/clc/integer/clc_clz.h libclc/clc/include/clc/integer/clc_ctz.h libclc/clc/include/clc/integer/clc_hadd.h libclc/clc/include/clc/integer/clc_mad24.h libclc/clc/include/clc/integer/clc_mad_sat.h libclc/clc/include/clc/integer/clc_mul24.h libclc/clc/include/clc/integer/clc_mul_hi.h libclc/clc/include/clc/integer/clc_rhadd.h libclc/clc/include/clc/integer/clc_rotate.h libclc/clc/include/clc/integer/clc_sub_sat.h libclc/clc/include/clc/internal/math/clc_sw_fma.h libclc/clc/include/clc/math/clc_acos.h libclc/clc/include/clc/math/clc_acosh.h libclc/clc/include/clc/math/clc_acospi.h libclc/clc/include/clc/math/clc_asin.h libclc/clc/include/clc/math/clc_asinh.h libclc/clc/include/clc/math/clc_asinpi.h libclc/clc/include/clc/math/clc_atan.h libclc/clc/include/clc/math/clc_atan2.h libclc/clc/include/clc/math/clc_atan2pi.h libclc/clc/include/clc/math/clc_atanh.h libclc/clc/include/clc/math/clc_atanpi.h libclc/clc/include/clc/math/clc_cbrt.inc libclc/clc/include/clc/math/clc_ceil.h libclc/clc/include/clc/math/clc_copysign.h libclc/clc/include/clc/math/clc_cosh.h libclc/clc/include/clc/math/clc_cospi.h libclc/clc/include/clc/math/clc_exp.h libclc/clc/include/clc/math/clc_exp10.h libclc/clc/include/clc/math/clc_exp2.h libclc/clc/include/clc/math/clc_exp_helper.h libclc/clc/include/clc/math/clc_expm1.h libclc/clc/include/clc/math/clc_fabs.h libclc/clc/include/clc/math/clc_fdim.h libclc/clc/include/clc/math/clc_floor.h libclc/clc/include/clc/math/clc_fma.h libclc/clc/include/clc/math/clc_fmax.h libclc/clc/include/clc/math/clc_fmin.h libclc/clc/include/clc/math/clc_fmod.h libclc/clc/include/clc/math/clc_fract.h libclc/clc/include/clc/math/clc_frexp.h libclc/clc/include/clc/math/clc_hypot.h libclc/clc/include/clc/math/clc_lgamma.h libclc/clc/include/clc/math/clc_lgamma_r.h libclc/clc/include/clc/math/clc_log.h libclc/clc/include/clc/math/clc_log10.h libclc/clc/include/clc/math/clc_log1p.h libclc/clc/include/clc/math/clc_log2.h libclc/clc/include/clc/math/clc_mad.h libclc/clc/include/clc/math/clc_modf.h libclc/clc/include/clc/math/clc_nan.h libclc/clc/include/clc/math/clc_native_cos.h libclc/clc/include/clc/math/clc_native_divide.h libclc/clc/include/clc/math/clc_native_exp.h libclc/clc/include/clc/math/clc_native_exp10.h libclc/clc/include/clc/math/clc_native_exp2.h libclc/clc/include/clc/math/clc_native_log.h libclc/clc/include/clc/math/clc_native_log10.h libclc/clc/include/clc/math/clc_native_log2.h libclc/clc/include/clc/math/clc_native_powr.h libclc/clc/include/clc/math/clc_native_recip.h libclc/clc/include/clc/math/clc_native_rsqrt.h libclc/clc/include/clc/math/clc_native_sin.h libclc/clc/include/clc/math/clc_native_sqrt.h libclc/clc/include/clc/math/clc_native_tan.h libclc/clc/include/clc/math/clc_nextafter.h libclc/clc/include/clc/math/clc_pow.h libclc/clc/include/clc/math/clc_pown.h libclc/clc/include/clc/math/clc_powr.h libclc/clc/include/clc/math/clc_remainder.h libclc/clc/include/clc/math/clc_remquo.h libclc/clc/include/clc/math/clc_rint.h libclc/clc/include/clc/math/clc_rootn.h libclc/clc/include/clc/math/clc_round.h libclc/clc/include/clc/math/clc_rsqrt.h libclc/clc/include/clc/math/clc_sincos_helpers.h libclc/clc/include/clc/math/clc_sinh.h libclc/clc/include/clc/math/clc_sinpi.h libclc/clc/include/clc/math/clc_sqrt.h libclc/clc/include/clc/math/clc_tanh.h libclc/clc/include/clc/math/clc_tanpi.h libclc/clc/include/clc/math/clc_tgamma.h libclc/clc/include/clc/math/clc_trunc.h libclc/clc/include/clc/relational/clc_bitselect.h libclc/clc/include/clc/relational/clc_isfinite.h libclc/clc/include/clc/relational/clc_isgreater.h libclc/clc/include/clc/relational/clc_isgreaterequal.h libclc/clc/include/clc/relational/clc_isless.h libclc/clc/include/clc/relational/clc_islessequal.h libclc/clc/include/clc/relational/clc_islessgreater.h libclc/clc/include/clc/relational/clc_isnormal.h libclc/clc/include/clc/relational/clc_isnotequal.h libclc/clc
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
https://github.com/erichkeane approved this pull request. I'm still not sure I understand the problem this is solving, but I also don't see any harm in it, so I'm leaning towards accept here. Aaron can be the final approval though. https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Clean up unnecessary #undef __CLC_BODYs (PR #137959)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/137959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang AST] move mangling API to namespace clang to allow calls from swift-frontend (PR #137884)
https://github.com/AaronBallman approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/137932 3-component vector type is supported for them per OpenCL spec. >From cafb374de8d77c82fa450b732a122663090f6e34 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Wed, 30 Apr 2025 00:44:50 -0700 Subject: [PATCH] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch 3-component vector type is supported for them per OpenCL spec. --- libclc/generic/include/clc/async/gentype.inc | 44 1 file changed, 44 insertions(+) diff --git a/libclc/generic/include/clc/async/gentype.inc b/libclc/generic/include/clc/async/gentype.inc index 1114883e1ad35..e023c8bbd97d2 100644 --- a/libclc/generic/include/clc/async/gentype.inc +++ b/libclc/generic/include/clc/async/gentype.inc @@ -14,6 +14,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE char3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE char4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -34,6 +38,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE uchar3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE uchar4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -54,6 +62,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE short3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE short4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -74,6 +86,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE ushort3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE ushort4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -94,6 +110,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE int3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE int4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -114,6 +134,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE uint3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE uint4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -134,6 +158,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE float3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE float4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -154,6 +182,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE long3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE long4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -174,6 +206,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE ulong3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE ulong4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -197,6 +233,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE double3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE double4 #include __CLC_BODY #undef __CLC_GENTYPE @@ -222,6 +262,10 @@ #include __CLC_BODY #undef __CLC_GENTYPE +#define __CLC_GENTYPE half3 +#include __CLC_BODY +#undef __CLC_GENTYPE + #define __CLC_GENTYPE half4 #include __CLC_BODY #undef __CLC_GENTYPE ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)
@@ -19,6 +21,7 @@ template class Expected; template class IntrusiveRefCntPtr; class Module; class MemoryBufferRef; +extern cl::opt ClPGOColdFuncAttr; fanju110 wrote: I think you're right, I'll just put it back in BackendUtil.cpp. I'm going to leave this experiment out of flang for now. My next step is to work on the other options in PGO that are not implemented yet https://github.com/llvm/llvm-project/pull/136098 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); + + if (Condition_NoVariants && Condition_NoContext) { +// Emit the NoVariants (if then, for the NoVariants) block. +CGF->EmitBlock(ThenNoVariantsBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + +CGF->EmitBlock(ElseNoVariantsBlock); +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoContextBlock, + ElseBlock, 0); +// Emit the NoContext (else if, for the NoContext) block. +CGF->EmitBlock(ThenNoContextBlock); +Stmt *ThenNoContextStmt = AssociatedStmt; +transformCallInStmt(ThenNoContextStmt, true); +CGF->EmitStmt(ThenNoContextStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoVariants) { +// Emit the NoVariants (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoContext) { +// Emit the NoContext (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, true); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + } + + // Emit the else block. + CGF->EmitBlock(ElseBlock); + Stmt *ElseStmt = AssociatedStmt; + if (auto *CaptStmt = dyn_cast(ElseStmt)) { +CapturedDecl *CDecl = CaptStmt->getCapturedDecl(); +replaceWithNewTraitsOrDire
[clang] [C] Add diagnostic + attr for unterminated strings (PR #137829)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Add diagnostic + attr for unterminated strings (PR #137829)
@@ -5024,3 +5024,9 @@ def OpenACCRoutineDecl :InheritableAttr { void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; }]; } + +def NonString : InheritableAttr { + let Spellings = [GCC<"nonstring">]; erichkeane wrote: No interest in doing a 'clang' spelling for this as well? This seems reasonably valuable enough I would expect `clang::` to be ok too. https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Remove FEM_Indeterminable (PR #137247)
nico wrote: > What is the warning? => #137247 https://github.com/llvm/llvm-project/pull/137247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, alexey-bataev wrote: Try to add tests with classes, which evaluate to boolean, and create immediate class instance and see, that the destructors are called correctly https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -0,0 +1,364 @@ +// expected-no-diagnostics alexey-bataev wrote: The tests with classes and function members are required, as well as classes, used in conditions https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); + + if (Condition_NoVariants && Condition_NoContext) { +// Emit the NoVariants (if then, for the NoVariants) block. +CGF->EmitBlock(ThenNoVariantsBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + +CGF->EmitBlock(ElseNoVariantsBlock); +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoContextBlock, + ElseBlock, 0); +// Emit the NoContext (else if, for the NoContext) block. +CGF->EmitBlock(ThenNoContextBlock); +Stmt *ThenNoContextStmt = AssociatedStmt; +transformCallInStmt(ThenNoContextStmt, true); +CGF->EmitStmt(ThenNoContextStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoVariants) { +// Emit the NoVariants (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoContext) { +// Emit the NoContext (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, true); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + } alexey-bataev wrote: Same code, which differs only by boolean flag https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.ll
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -10554,6 +10687,8 @@ SemaOpenMP::ActOnOpenMPDispatchDirective(ArrayRef Clauses, return StmtError(); Stmt *S = cast(AStmt)->getCapturedStmt(); + if (isa(S)) +S = cast(S)->getCapturedStmt(); alexey-bataev wrote: ```suggestion if (auto *CS = dyn_cast(S)) S = CS->getCapturedStmt(); ``` https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); + + if (Condition_NoVariants && Condition_NoContext) { +// Emit the NoVariants (if then, for the NoVariants) block. +CGF->EmitBlock(ThenNoVariantsBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + +CGF->EmitBlock(ElseNoVariantsBlock); +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoContextBlock, + ElseBlock, 0); +// Emit the NoContext (else if, for the NoContext) block. +CGF->EmitBlock(ThenNoContextBlock); +Stmt *ThenNoContextStmt = AssociatedStmt; +transformCallInStmt(ThenNoContextStmt, true); +CGF->EmitStmt(ThenNoContextStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoVariants) { +// Emit the NoVariants (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, false); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + + } else if (Condition_NoContext) { +// Emit the NoContext (then) block. +CGF->EmitBlock(ThenBlock); +Stmt *ThenStmt = AssociatedStmt; +ElseCall = transformCallInStmt(ThenStmt, true); +CGF->EmitStmt(ThenStmt); +CGF->Builder.CreateBr(MergeBlock); + } + + // Emit the else block. + CGF->EmitBlock(ElseBlock); + Stmt *ElseStmt = AssociatedStmt; + if (auto *CaptStmt = dyn_cast(ElseStmt)) { +CapturedDecl *CDecl = CaptStmt->getCapturedDecl(); +replaceWithNewTraitsOrDire
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4280,6 +4282,15 @@ getTargetRegionParams(Sema &SemaRef) { return Params; } +static SmallVector +getDispatchRegionParams(Sema &SemaRef) { + ASTContext &Context = SemaRef.getASTContext(); + SmallVector Params; + + Params.push_back(std::make_pair(StringRef(), QualType())); alexey-bataev wrote: ```suggestion Params.emplace_back(StringRef(), QualType()); ``` https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + +// emitIfElse is used for the following conditions: +// +// NoVariants = 0 && NoContext = 1 +// if (Condition_NoContext) { +// foo_variant2(); // Present in AnnotationAttr +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 0 +// if (Condition_NoVariants) { +// foo(); +// } else { +// foo_variant(); +// } +// +// NoVariants = 1 && NoContext = 1 +// if (Condition_NoVariants) { // ==> label if.then.NoVariants +// foo(); +// } else { // ==> label else.NoVariants +// if (Condition_NoContext) { // ==> label if.then.NoContext +// foo_variant2(); // Present in AnnotationAttr +// } else { // ==> label else +// foo_variant(); +// } +// } +// +static void emitIfElse(CodeGenFunction *CGF, Stmt *AssociatedStmt, + Expr *Condition_NoVariants, Expr *Condition_NoContext) { + llvm::BasicBlock *ThenBlock = CGF->createBasicBlock("if.then"); + llvm::BasicBlock *ElseBlock = CGF->createBasicBlock("if.else"); + llvm::BasicBlock *MergeBlock = CGF->createBasicBlock("if.end"); + llvm::BasicBlock *ThenNoVariantsBlock = nullptr; + llvm::BasicBlock *ElseNoVariantsBlock = nullptr; + llvm::BasicBlock *ThenNoContextBlock = nullptr; + Expr *ElseCall = nullptr; + + if (Condition_NoVariants && Condition_NoContext) { +ThenNoVariantsBlock = CGF->createBasicBlock("if.then.NoVariants"); +ElseNoVariantsBlock = CGF->createBasicBlock("else.NoVariants"); +ThenNoContextBlock = CGF->createBasicBlock("if.then.NoContext"); + +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenNoVariantsBlock, + ElseNoVariantsBlock, 0); + + } else if (Condition_NoVariants) +CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); + else +CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); alexey-bataev wrote: ```suggestion } else if (Condition_NoVariants) { CGF->EmitBranchOnBoolExpr(Condition_NoVariants, ThenBlock, ElseBlock, 0); } else { CGF->EmitBranchOnBoolExpr(Condition_NoContext, ThenBlock, ElseBlock, 0); } ``` https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #131838)
@@ -4529,6 +4529,191 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) { emitMaster(*this, S); } +static Expr *replaceWithNewTraitsOrDirectCall(CapturedDecl *CDecl, + Expr *NewExpr) { + Expr *CurrentCallExpr = nullptr; + Stmt *CallExprStmt = CDecl->getBody(); + + if (BinaryOperator *BinaryCopyOpr = dyn_cast(CallExprStmt)) { +CurrentCallExpr = BinaryCopyOpr->getRHS(); +BinaryCopyOpr->setRHS(NewExpr); + } else { +CurrentCallExpr = dyn_cast(CallExprStmt); +CDecl->setBody(NewExpr); + } + + return CurrentCallExpr; +} + +static Expr *transformCallInStmt(Stmt *StmtP, bool NoContext = false) { + Expr *CurrentExpr = nullptr; + if (auto *CptStmt = dyn_cast(StmtP)) { +CapturedDecl *CDecl = CptStmt->getCapturedDecl(); + +CallExpr *NewCallExpr = nullptr; +for (const auto *attr : CDecl->attrs()) { + if (NoContext) { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoContextAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } else { +if (const auto *annotateAttr = +llvm::dyn_cast(attr); +annotateAttr && annotateAttr->getAnnotation() == "NoVariantsAttr") { + NewCallExpr = llvm::dyn_cast(*annotateAttr->args_begin()); +} + } +} + +CurrentExpr = replaceWithNewTraitsOrDirectCall(CDecl, NewCallExpr); + } + return CurrentExpr; +} + alexey-bataev wrote: I still think these functions should not be needed, if something is required, it should be build in Sema and stored in AST. If you need to replace some AST values by some LVM IR values, use OpaqueValue nodes, which can be replaced in codegen by special RAIIs. https://github.com/llvm/llvm-project/pull/131838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
@@ -912,6 +912,11 @@ class BlockAddress final : public Constant { /// block must be embedded into a function. static BlockAddress *get(BasicBlock *BB); + /// Return a BlockAddress for the specified basic block, which may not be + /// part of a function. The specified type must match the type of the function + /// the block will be inserted into. + static BlockAddress *get(Type *Ty, BasicBlock *BB); nikic wrote: I'd say "no unless it's actually needed". We should avoid creating blockaddresses for non-inserted blocks if possible. https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 >From c476948593a80ed31765cdd711a626e4e03930ab Mon Sep 17 00:00:00 2001 From: hulxv Date: Tue, 25 Mar 2025 22:56:51 +0200 Subject: [PATCH 1/8] [include-cleaner] rename enabled flags to `disable-*` --- .../include-cleaner/test/tool.cpp | 4 ++-- .../include-cleaner/tool/IncludeCleaner.cpp | 20 +-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp index d72d2317ce2b1..8b723a5bf40e2 100644 --- a/clang-tools-extra/include-cleaner/test/tool.cpp +++ b/clang-tools-extra/include-cleaner/test/tool.cpp @@ -6,11 +6,11 @@ int x = foo(); // CHANGE: - "foobar.h" // CHANGE-NEXT: + "foo.h" -// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s +// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s // INSERT-NOT: - "foobar.h" // INSERT: + "foo.h" -// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s +// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s // REMOVE: - "foobar.h" // REMOVE-NOT: + "foo.h" diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 1d9458ffc4d32..472611073f732 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -91,16 +91,16 @@ cl::opt Edit{ cl::cat(IncludeCleaner), }; -cl::opt Insert{ -"insert", -cl::desc("Allow header insertions"), -cl::init(true), +cl::opt DisableInsert{ +"disable-insert", +cl::desc("DIsable header insertions"), +cl::init(false), cl::cat(IncludeCleaner), }; -cl::opt Remove{ -"remove", -cl::desc("Allow header removals"), -cl::init(true), +cl::opt DisableRemove{ +"disable-remove", +cl::desc("Disable header removals"), +cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) +if (DisableInsert) Results.Missing.clear(); -if (!Remove) +if (DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From e2f78ab69f656313fc87b004506abc1deb096189 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 18 Apr 2025 08:59:03 +0200 Subject: [PATCH 2/8] [include-cleaner] return `--remove` and `--insert` to be in deprecation period --- .../include-cleaner/tool/IncludeCleaner.cpp | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 472611073f732..7a07d09ce277d 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -90,10 +90,21 @@ cl::opt Edit{ cl::desc("Apply edits to analyzed source files"), cl::cat(IncludeCleaner), }; - +cl::opt Insert{ +"insert", +cl::desc("Allow header insertions"), +cl::init(true), +cl::cat(IncludeCleaner), +}; +cl::opt Remove{ +"remove", +cl::desc("Allow header removals"), +cl::init(true), +cl::cat(IncludeCleaner), +}; cl::opt DisableInsert{ "disable-insert", -cl::desc("DIsable header insertions"), +cl::desc("Disable header insertions"), cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +194,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (DisableInsert) +if (!Insert || DisableInsert) Results.Missing.clear(); -if (DisableRemove) +if (!Remove || DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From b7dd110307c0ba467022775398b9bd2ab66517f5 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 25 Apr 2025 19:30:55 +0300 Subject: [PATCH 3/8] [clang-tools-extra] add note for deprecation of `-remove` and `-insert` --- clang-tools-extra/docs/ReleaseNotes.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 72aa05eb4dcd1..8b39fa09e2839 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/Releas
[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode { } void Profile(llvm::FoldingSetNodeID &ID) { -Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl()); +Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()); erichkeane wrote: Is the problem that we run this profile in the 'middle' of a TU and the most recent decl changes by the end? If so, this makes sense. That said, I'd expect this to be the above suggestion in case this member pointer type has a redeclaration that perhaps changes what the actual referenced decl is. ```suggestion Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()->getCanonicalDecl()); ``` https://github.com/llvm/llvm-project/pull/137910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
@@ -183,9 +195,26 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) + +if (!Insert) { + llvm::errs() + << "[WARNING] -insert is deprecated in favor of `-disable-insert`. " + "The old flag was confusing since it suggested that inserts " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + +if (!Remove) { + llvm::errs() + << "[WARNING] -remove is deprecated in favor of `-disable-remove`. " + "The old flag was confusing since it suggested that removes " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + AaronBallman wrote: Oh shoot, then nope, ignore this suggestion. :-) https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
hulxv wrote: I think all is fine now https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
@@ -183,9 +195,26 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) + +if (!Insert) { + llvm::errs() + << "warning: `-insert=0` is deprecated in favor of `-disable-insert`. " + "The old flag was confusing since it suggested that inserts " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + +if (!Remove) { + llvm::errs() + << "warning: `-remove=0` is deprecated in favor of `-disable-remove`. " + "The old flag was confusing since it suggested that removes " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} AaronBallman wrote: Two changes still missing here: 1) Change backticks around the command syntax into single quotes 2) Remove the link to the GitHub issue https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 01e0296 - [clang] Temporarily silence noisy warning for FPEvalMethod
Author: Nico Weber Date: 2025-04-30T09:39:19-04:00 New Revision: 01e029602a8ae860852ad2dd8c6ea347c9200066 URL: https://github.com/llvm/llvm-project/commit/01e029602a8ae860852ad2dd8c6ea347c9200066 DIFF: https://github.com/llvm/llvm-project/commit/01e029602a8ae860852ad2dd8c6ea347c9200066.diff LOG: [clang] Temporarily silence noisy warning for FPEvalMethod See https://github.com/llvm/llvm-project/issues/137600#issuecomment-2842011513 Added: Modified: clang/include/clang/Basic/LangOptions.def Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 85ca523c44157..1258a349ebf00 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -347,7 +347,17 @@ BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contracti COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point") BENIGN_LANGOPT(RoundingMath, 1, false, "Do not assume default floating-point rounding behavior") BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Default, "FP Exception Behavior Mode type") + +#if defined(__clang__) +// FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" +#endif BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic") +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + ENUM_LANGOPT(Float16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for Float16 arithmetic") ENUM_LANGOPT(BFloat16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for BFloat16 arithmetic") LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [IR] Do not store Function inside BlockAddress (PR #137958)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/137958 >From 2d3db51939ec6ca2dfb2e327bce0f33bd2532ff9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 30 Apr 2025 13:00:19 +0200 Subject: [PATCH 1/2] [IR] Do not store Function inside BlockAddress Currently BlockAddresses store both the Function and the BasicBlock they reference, and the BlockAddress is part of the use list of both the Function and BasicBlock. This is quite awkward, because this is not really a use of the function itself (and walks of function uses generally skip block addresses for that reason). This also has weird implications on function RAUW (as that will replace the function in block addresses in a way that generally doesn't make sense), and causes other peculiar issues, like the ability to have multiple block addresses for one block (with different functions). Instead, I believe it makes more sense to specify only the basic block and let the function be implied by the BB parent. This does mean that we may have block addresses without a function (if the BB is not inserted), but this should only happen during IR construction. --- clang/lib/CodeGen/CodeGenFunction.cpp | 2 +- llvm/include/llvm/IR/Constants.h | 15 +++-- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp| 4 -- llvm/lib/IR/Constants.cpp | 56 +++ llvm/lib/IR/Function.cpp | 10 +--- llvm/lib/IR/LLVMContextImpl.h | 3 +- llvm/lib/Transforms/IPO/Attributor.cpp| 11 llvm/lib/Transforms/IPO/GlobalOpt.cpp | 24 +--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp| 6 +- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 5 +- llvm/lib/Transforms/IPO/PartialInlining.cpp | 7 --- llvm/lib/Transforms/IPO/SCCP.cpp | 9 ++- ...e-functions-blockaddress-wrong-function.ll | 4 +- .../reduce-functions-blockaddress.ll | 9 ++- .../llvm-reduce/deltas/ReduceFunctions.cpp| 2 +- llvm/tools/llvm-reduce/deltas/Utils.cpp | 6 -- llvm/tools/llvm-reduce/deltas/Utils.h | 1 - 18 files changed, 52 insertions(+), 124 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 4d29ceace646f..d773cdd505ff4 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2286,7 +2286,7 @@ llvm::BlockAddress *CodeGenFunction::GetAddrOfLabel(const LabelDecl *L) { // Make sure the indirect branch includes all of the address-taken blocks. IndirectBranch->addDestination(BB); - return llvm::BlockAddress::get(CurFn, BB); + return llvm::BlockAddress::get(CurFn->getType(), BB); } llvm::BasicBlock *CodeGenFunction::GetIndirectGotoBlock() { diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index a50217078d0ed..4525d8a6ed1e2 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -893,9 +893,9 @@ class ConstantTargetNone final : public ConstantData { class BlockAddress final : public Constant { friend class Constant; - constexpr static IntrusiveOperandsAllocMarker AllocMarker{2}; + constexpr static IntrusiveOperandsAllocMarker AllocMarker{1}; - BlockAddress(Function *F, BasicBlock *BB); + BlockAddress(Type *Ty, BasicBlock *BB); void *operator new(size_t S) { return User::operator new(S, AllocMarker); } @@ -912,6 +912,11 @@ class BlockAddress final : public Constant { /// block must be embedded into a function. static BlockAddress *get(BasicBlock *BB); + /// Return a BlockAddress for the specified basic block, which may not be + /// part of a function. The specified type must match the type of the function + /// the block will be inserted into. + static BlockAddress *get(Type *Ty, BasicBlock *BB); + /// Lookup an existing \c BlockAddress constant for the given BasicBlock. /// /// \returns 0 if \c !BB->hasAddressTaken(), otherwise the \c BlockAddress. @@ -920,8 +925,8 @@ class BlockAddress final : public Constant { /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - Function *getFunction() const { return (Function *)Op<0>().get(); } - BasicBlock *getBasicBlock() const { return (BasicBlock *)Op<1>().get(); } + BasicBlock *getBasicBlock() const { return (BasicBlock *)Op<0>().get(); } + Function *getFunction() const { return getBasicBlock()->getParent(); } /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { @@ -931,7 +936,7 @@ class BlockAddress final : public Constant { template <> struct OperandTraits -: public FixedNumOperandTraits {}; +: public FixedNumOperandTraits {}; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/Bit
[clang] [C] Modify -Wdefault-const-init (PR #137961)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137961 >From d331697715977eca37197f25bac31b4724ffefee Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 30 Apr 2025 08:57:48 -0400 Subject: [PATCH 1/2] [C] Modify -Wdefault-const-init Post-commit review feedback on https://github.com/llvm/llvm-project/pull/137166 raised a concern from the Linux kernel about wanting to silence the new diagnostic when the uninitialized object is a const member of a structure. These members can be initialized later if the containing object is non-const, such as through a call to memset, for example. This splits the diagnostic groups into: -Wc++-compat -Wdefault-const-init -Wdefault-const-init-field -Wdefault-const-init-var -Wdefault-const-init-unsafe -Wdefault-const-init-field-unsafe -Wdefault-const-init-var-unsafe --- clang/docs/ReleaseNotes.rst | 16 + clang/include/clang/Basic/DiagnosticGroups.td | 12 +-- .../clang/Basic/DiagnosticSemaKinds.td| 18 ++ clang/lib/Sema/Sema.cpp | 2 +- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/lib/Sema/SemaInit.cpp | 6 ++-- clang/test/Sema/warn-default-const-init.c | 33 --- 7 files changed, 51 insertions(+), 38 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index bc68bb8b70b3d..4fb606afc0f14 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -141,12 +141,16 @@ C Language Changes function type in Microsoft compatibility mode. #GH124869 - Clang now allows ``restrict`` qualifier for array types with pointer elements (#GH92847). - Clang now diagnoses ``const``-qualified object definitions without an - initializer. If the object is zero-initialized, it will be diagnosed under - the new warning ``-Wdefault-const-init`` (which is grouped under - ``-Wc++-compat`` because this construct is not compatible with C++). If the - object is left uninitialized, it will be diagnosed unsed the new warning - ``-Wdefault-const-init-unsafe`` (which is grouped under - ``-Wdefault-const-init``). #GH19297 + initializer. If the object is a variable or field which is zero-initialized, + it will be diagnosed under the new warning ``-Wdefault-const-init-var`` or + ``-Wdefault-const-init-field``, respectively. Similarly, if the variable or + field is not zero-initialized, it will be diagnosed under the new diagnostic + ``-Wdefault-const-init-var-unsafe`` or ``-Wdefault-const-init-field-unsafe``, + respectively. The unsafe diagnostic variants are grouped under a new + diagnostic ``-Wdefault-const-init-unsafe``, which itself is grouped under the + new diagnostic ``-Wdefault-const-init``. Finally, ``-Wdefault-const-init`` is + grouped under ``-Wc++-compat`` because these constructs are not compatible + with C++. #GH19297 - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index fc1ce197ef134..3835cd7251488 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -157,8 +157,16 @@ def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; def HiddenCppDecl : DiagGroup<"c++-hidden-decl">; -def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">; -def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>; +def DefaultConstInitFieldUnsafe : DiagGroup<"default-const-init-field-unsafe">; +def DefaultConstInitVarUnsafe : DiagGroup<"default-const-init-var-unsafe">; +def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe", + [DefaultConstInitFieldUnsafe, +DefaultConstInitVarUnsafe]>; +def DefaultConstInitField : DiagGroup<"default-const-init-field">; +def DefaultConstInitVar : DiagGroup<"default-const-init-var">; +def DefaultConstInit : DiagGroup<"default-const-init", + [DefaultConstInitField, DefaultConstInitVar, + DefaultConstInitUnsafe]>; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast", [ImplicitEnumEnumCast]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index ad5bf26be2590..90a7cac9df29e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8206,14 +8206,20 @@ def err_address_space_qualified_delete : Error< def note_default_init_const_
[clang] [clang][bytecode] Only print ptr/reference types via toAPValue() (PR #137965)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values. --- Full diff: https://github.com/llvm/llvm-project/pull/137965.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpFrame.cpp (+12-1) - (modified) clang/test/AST/ByteCode/constexpr-frame-describe.cpp (+1-2) ``diff diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp index 1a6e271c78d6f..e4bd4a6ba7656 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.cpp +++ b/clang/lib/AST/ByteCode/InterpFrame.cpp @@ -107,7 +107,18 @@ void InterpFrame::destroy(unsigned Idx) { template static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx, QualType Ty) { - V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty); + if constexpr (std::is_same_v) { +if (Ty->isPointerOrReferenceType()) + V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty); +else { + if (std::optional RValue = V.toRValue(ASTCtx, Ty)) +RValue->printPretty(OS, ASTCtx, Ty); + else +OS << "..."; +} + } else { +V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty); + } } static bool shouldSkipInBacktrace(const Function *F) { diff --git a/clang/test/AST/ByteCode/constexpr-frame-describe.cpp b/clang/test/AST/ByteCode/constexpr-frame-describe.cpp index d875d8730b7d6..1b19a7af0663b 100644 --- a/clang/test/AST/ByteCode/constexpr-frame-describe.cpp +++ b/clang/test/AST/ByteCode/constexpr-frame-describe.cpp @@ -79,8 +79,7 @@ static_assert(bar.fail1()); // both-error {{constant expression}} \ static_assert(bar.fail2()); // both-error {{constant expression}} \ // both-note {{in call to 'bar.fail2()'}} static_assert(bar.fail3(3, 4UL, bar, &bar)); // both-error {{constant expression}} \ - // expected-note {{in call to 'bar.fail3, const Bar *>(3, 4, &bar, &bar)'}} \ - // ref-note {{in call to 'bar.fail3, const Bar *>(3, 4, {}, &bar)'}} + // both-note {{in call to 'bar.fail3, const Bar *>(3, 4, {}, &bar)'}} `` https://github.com/llvm/llvm-project/pull/137965 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 >From c476948593a80ed31765cdd711a626e4e03930ab Mon Sep 17 00:00:00 2001 From: hulxv Date: Tue, 25 Mar 2025 22:56:51 +0200 Subject: [PATCH 01/11] [include-cleaner] rename enabled flags to `disable-*` --- .../include-cleaner/test/tool.cpp | 4 ++-- .../include-cleaner/tool/IncludeCleaner.cpp | 20 +-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp index d72d2317ce2b1..8b723a5bf40e2 100644 --- a/clang-tools-extra/include-cleaner/test/tool.cpp +++ b/clang-tools-extra/include-cleaner/test/tool.cpp @@ -6,11 +6,11 @@ int x = foo(); // CHANGE: - "foobar.h" // CHANGE-NEXT: + "foo.h" -// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s +// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s // INSERT-NOT: - "foobar.h" // INSERT: + "foo.h" -// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s +// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s // REMOVE: - "foobar.h" // REMOVE-NOT: + "foo.h" diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 1d9458ffc4d32..472611073f732 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -91,16 +91,16 @@ cl::opt Edit{ cl::cat(IncludeCleaner), }; -cl::opt Insert{ -"insert", -cl::desc("Allow header insertions"), -cl::init(true), +cl::opt DisableInsert{ +"disable-insert", +cl::desc("DIsable header insertions"), +cl::init(false), cl::cat(IncludeCleaner), }; -cl::opt Remove{ -"remove", -cl::desc("Allow header removals"), -cl::init(true), +cl::opt DisableRemove{ +"disable-remove", +cl::desc("Disable header removals"), +cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) +if (DisableInsert) Results.Missing.clear(); -if (!Remove) +if (DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From e2f78ab69f656313fc87b004506abc1deb096189 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 18 Apr 2025 08:59:03 +0200 Subject: [PATCH 02/11] [include-cleaner] return `--remove` and `--insert` to be in deprecation period --- .../include-cleaner/tool/IncludeCleaner.cpp | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 472611073f732..7a07d09ce277d 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -90,10 +90,21 @@ cl::opt Edit{ cl::desc("Apply edits to analyzed source files"), cl::cat(IncludeCleaner), }; - +cl::opt Insert{ +"insert", +cl::desc("Allow header insertions"), +cl::init(true), +cl::cat(IncludeCleaner), +}; +cl::opt Remove{ +"remove", +cl::desc("Allow header removals"), +cl::init(true), +cl::cat(IncludeCleaner), +}; cl::opt DisableInsert{ "disable-insert", -cl::desc("DIsable header insertions"), +cl::desc("Disable header insertions"), cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +194,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (DisableInsert) +if (!Insert || DisableInsert) Results.Missing.clear(); -if (DisableRemove) +if (!Remove || DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From b7dd110307c0ba467022775398b9bd2ab66517f5 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 25 Apr 2025 19:30:55 +0300 Subject: [PATCH 03/11] [clang-tools-extra] add note for deprecation of `-remove` and `-insert` --- clang-tools-extra/docs/ReleaseNotes.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 72aa05eb4dcd1..8b39fa09e2839 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 >From c476948593a80ed31765cdd711a626e4e03930ab Mon Sep 17 00:00:00 2001 From: hulxv Date: Tue, 25 Mar 2025 22:56:51 +0200 Subject: [PATCH 01/10] [include-cleaner] rename enabled flags to `disable-*` --- .../include-cleaner/test/tool.cpp | 4 ++-- .../include-cleaner/tool/IncludeCleaner.cpp | 20 +-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp index d72d2317ce2b1..8b723a5bf40e2 100644 --- a/clang-tools-extra/include-cleaner/test/tool.cpp +++ b/clang-tools-extra/include-cleaner/test/tool.cpp @@ -6,11 +6,11 @@ int x = foo(); // CHANGE: - "foobar.h" // CHANGE-NEXT: + "foo.h" -// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s +// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s // INSERT-NOT: - "foobar.h" // INSERT: + "foo.h" -// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s +// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s // REMOVE: - "foobar.h" // REMOVE-NOT: + "foo.h" diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 1d9458ffc4d32..472611073f732 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -91,16 +91,16 @@ cl::opt Edit{ cl::cat(IncludeCleaner), }; -cl::opt Insert{ -"insert", -cl::desc("Allow header insertions"), -cl::init(true), +cl::opt DisableInsert{ +"disable-insert", +cl::desc("DIsable header insertions"), +cl::init(false), cl::cat(IncludeCleaner), }; -cl::opt Remove{ -"remove", -cl::desc("Allow header removals"), -cl::init(true), +cl::opt DisableRemove{ +"disable-remove", +cl::desc("Disable header removals"), +cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) +if (DisableInsert) Results.Missing.clear(); -if (!Remove) +if (DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From e2f78ab69f656313fc87b004506abc1deb096189 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 18 Apr 2025 08:59:03 +0200 Subject: [PATCH 02/10] [include-cleaner] return `--remove` and `--insert` to be in deprecation period --- .../include-cleaner/tool/IncludeCleaner.cpp | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 472611073f732..7a07d09ce277d 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -90,10 +90,21 @@ cl::opt Edit{ cl::desc("Apply edits to analyzed source files"), cl::cat(IncludeCleaner), }; - +cl::opt Insert{ +"insert", +cl::desc("Allow header insertions"), +cl::init(true), +cl::cat(IncludeCleaner), +}; +cl::opt Remove{ +"remove", +cl::desc("Allow header removals"), +cl::init(true), +cl::cat(IncludeCleaner), +}; cl::opt DisableInsert{ "disable-insert", -cl::desc("DIsable header insertions"), +cl::desc("Disable header insertions"), cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +194,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (DisableInsert) +if (!Insert || DisableInsert) Results.Missing.clear(); -if (DisableRemove) +if (!Remove || DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From b7dd110307c0ba467022775398b9bd2ab66517f5 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 25 Apr 2025 19:30:55 +0300 Subject: [PATCH 03/10] [clang-tools-extra] add note for deprecation of `-remove` and `-insert` --- clang-tools-extra/docs/ReleaseNotes.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 72aa05eb4dcd1..8b39fa09e2839 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,30 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +bool isWithinImplicitTemplateInstantiation(const TypeLoc *MatchedTypeLoc, stmuench wrote: I tried to implement it this way at first but unfortunately the `hasAncestor` matcher seems to not work correctly for matched `TypeLoc`s. The reason for that is not clear to me at all. That's why I added a manual implementation as workaround. https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/hulxv updated https://github.com/llvm/llvm-project/pull/132991 >From c476948593a80ed31765cdd711a626e4e03930ab Mon Sep 17 00:00:00 2001 From: hulxv Date: Tue, 25 Mar 2025 22:56:51 +0200 Subject: [PATCH 1/9] [include-cleaner] rename enabled flags to `disable-*` --- .../include-cleaner/test/tool.cpp | 4 ++-- .../include-cleaner/tool/IncludeCleaner.cpp | 20 +-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp index d72d2317ce2b1..8b723a5bf40e2 100644 --- a/clang-tools-extra/include-cleaner/test/tool.cpp +++ b/clang-tools-extra/include-cleaner/test/tool.cpp @@ -6,11 +6,11 @@ int x = foo(); // CHANGE: - "foobar.h" // CHANGE-NEXT: + "foo.h" -// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s +// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s // INSERT-NOT: - "foobar.h" // INSERT: + "foo.h" -// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s +// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s // REMOVE: - "foobar.h" // REMOVE-NOT: + "foo.h" diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 1d9458ffc4d32..472611073f732 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -91,16 +91,16 @@ cl::opt Edit{ cl::cat(IncludeCleaner), }; -cl::opt Insert{ -"insert", -cl::desc("Allow header insertions"), -cl::init(true), +cl::opt DisableInsert{ +"disable-insert", +cl::desc("DIsable header insertions"), +cl::init(false), cl::cat(IncludeCleaner), }; -cl::opt Remove{ -"remove", -cl::desc("Allow header removals"), -cl::init(true), +cl::opt DisableRemove{ +"disable-remove", +cl::desc("Disable header removals"), +cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) +if (DisableInsert) Results.Missing.clear(); -if (!Remove) +if (DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From e2f78ab69f656313fc87b004506abc1deb096189 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 18 Apr 2025 08:59:03 +0200 Subject: [PATCH 2/9] [include-cleaner] return `--remove` and `--insert` to be in deprecation period --- .../include-cleaner/tool/IncludeCleaner.cpp | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp index 472611073f732..7a07d09ce277d 100644 --- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp +++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp @@ -90,10 +90,21 @@ cl::opt Edit{ cl::desc("Apply edits to analyzed source files"), cl::cat(IncludeCleaner), }; - +cl::opt Insert{ +"insert", +cl::desc("Allow header insertions"), +cl::init(true), +cl::cat(IncludeCleaner), +}; +cl::opt Remove{ +"remove", +cl::desc("Allow header removals"), +cl::init(true), +cl::cat(IncludeCleaner), +}; cl::opt DisableInsert{ "disable-insert", -cl::desc("DIsable header insertions"), +cl::desc("Disable header insertions"), cl::init(false), cl::cat(IncludeCleaner), }; @@ -183,9 +194,9 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (DisableInsert) +if (!Insert || DisableInsert) Results.Missing.clear(); -if (DisableRemove) +if (!Remove || DisableRemove) Results.Unused.clear(); std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath)); >From b7dd110307c0ba467022775398b9bd2ab66517f5 Mon Sep 17 00:00:00 2001 From: hulxv Date: Fri, 25 Apr 2025 19:30:55 +0300 Subject: [PATCH 3/9] [clang-tools-extra] add note for deprecation of `-remove` and `-insert` --- clang-tools-extra/docs/ReleaseNotes.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 72aa05eb4dcd1..8b39fa09e2839 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/Releas
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
hulxv wrote: @AaronBallman Do you think we need to work on something in CommandLine to make the deprecation of commands easier and standardised for all tools? https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
@@ -39,6 +39,30 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +bool isWithinImplicitTemplateInstantiation(const TypeLoc *MatchedTypeLoc, stmuench wrote: > Could you please elaborate what is this function for? I deleted its call in > `not(isWithinImplicitTemplateInstantiation(...))` and all tests passed. I > suggest we can delete this function or add tests cases to cover added > behavior. If I remove this function on my side, the unit tests start to fail since diagnostics get emitted then for implicit template instantiations. https://github.com/llvm/llvm-project/pull/132924 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Mark constructors with invalid initializers as invalid (PR #137773)
@@ -2,16 +2,20 @@ // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++11 %s -class A { +class A { + // expected-note@-1 {{candidate constructor}} +#if __cplusplus >= 201103L // C++11 or later + // expected-note@-3 {{candidate constructor}} +#endif int m; public: A() : A::m(17) { } // expected-error {{member initializer 'm' does not name a non-static data member or base class}} - A(int); + A(int); // expected-note {{candidate constructor}} }; class B : public A { public: - B() : A(), m(1), n(3.14) { } + B() : A(), m(1), n(3.14) { } // expected-error {{no matching constructor for initialization of 'A'}} tbaederr wrote: I guess not, unless invalid constructors were to take part in lookup later when calling `A()`. https://github.com/llvm/llvm-project/pull/137773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Only print ptr/reference types via toAPValue() (PR #137965)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/137965 Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values. Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
https://github.com/AaronBallman approved this pull request. LGTM! Do you need me to land the changes on your behalf? https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
AaronBallman wrote: > @AaronBallman Do you think we need to work on something in CommandLine to > make the deprecation of commands easier and standardised for all tools? It might be nice, but isn't a requirement for this patch. We don't deprecate command line options too often, so it may not be worth the effort. https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c2a62af - [clang] Another Wpreferred-type-bitfield-enum-conversion suppression fix!
Author: Nico Weber Date: 2025-04-30T10:08:45-04:00 New Revision: c2a62af2a51d58183bcd72ee8a86c37ddd526758 URL: https://github.com/llvm/llvm-project/commit/c2a62af2a51d58183bcd72ee8a86c37ddd526758 DIFF: https://github.com/llvm/llvm-project/commit/c2a62af2a51d58183bcd72ee8a86c37ddd526758.diff LOG: [clang] Another Wpreferred-type-bitfield-enum-conversion suppression fix! If a compiler does not know `__has_warning`, it will of course complain if it's used on the same line as the check for its presence. Put the use in a separate line. Should help e.g. https://lab.llvm.org/buildbot/#/builders/123/builds/18503 Added: Modified: clang/include/clang/Basic/LangOptions.def clang/include/clang/Basic/LangOptions.h Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index ecf7a35f7746d..bc68f95079dc7 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -348,15 +348,19 @@ COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating p BENIGN_LANGOPT(RoundingMath, 1, false, "Do not assume default floating-point rounding behavior") BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Default, "FP Exception Behavior Mode type") -#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") +#if defined(__clang__) && defined(__has_warning) +#if __has_warning("-Wpreferred-type-bitfield-enum-conversion") // FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" #endif +#endif BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic") -#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") +#if defined(__clang__) && defined(__has_warning) +#if __has_warning("-Wpreferred-type-bitfield-enum-conversion") #pragma clang diagnostic pop #endif +#endif ENUM_LANGOPT(Float16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for Float16 arithmetic") ENUM_LANGOPT(BFloat16ExcessPrecision, ExcessPrecisionKind, 2, FPP_Standard, "Intermediate truncation behavior for BFloat16 arithmetic") diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index 73c4a9e4a0876..40debd961f752 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -78,15 +78,19 @@ class LangOptionsBase { LangOptionsBase() = default; -#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") +#if defined(__clang__) && defined( __has_warning) +#if __has_warning("-Wpreferred-type-bitfield-enum-conversion") // FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" +#endif #endif LangOptionsBase(const LangOptionsBase&) = default; LangOptionsBase& operator=(const LangOptionsBase&) = default; -#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") +#if defined(__clang__) && defined( __has_warning) +#if __has_warning("-Wpreferred-type-bitfield-enum-conversion") #pragma clang diagnostic pop +#endif #endif enum GCMode { NonGC, GCOnly, HybridGC }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL][RootSignature] Define and integrate rootsig clang attr and decl (PR #137690)
@@ -949,6 +950,23 @@ void SemaHLSL::emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, << NewFnName << FixItHint::CreateReplacement(FullRange, OS.str()); } +void SemaHLSL::handleRootSignatureAttr(Decl *D, const ParsedAttr &AL) { + if (AL.getNumArgs() != 1) { +Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; +return; + } + llvm-beanz wrote: We should only allow the attribute to appear more than once if it is the same root signature. Mismatching root signature attributes should be an error (err_disallowed_duplicate_attribute), and duplicate but identical attributes a warning (warn_duplicate_attribute_exact). https://github.com/llvm/llvm-project/pull/137690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PowerPC] frontend get target feature from backend with cpu name (PR #137670)
https://github.com/diggerlin updated https://github.com/llvm/llvm-project/pull/137670 >From 97f10e6a0fb4c158359e79e24650f8fdf4d23ef2 Mon Sep 17 00:00:00 2001 From: zhijian Date: Fri, 25 Apr 2025 13:09:47 + Subject: [PATCH 1/3] implement getting target features from backend for clang frontend --- clang/lib/Basic/Targets/PPC.cpp | 150 +- .../cxx11-thread-local-reference.cpp | 2 +- .../Driver/aix-shared-lib-tls-model-opt.c | 7 +- .../Driver/aix-small-local-exec-dynamic-tls.c | 15 +- clang/test/Driver/ppc-crbits.cpp | 4 - clang/test/Driver/ppc-isa-features.cpp| 22 +-- llvm/include/llvm/MC/MCSubtargetInfo.h| 32 +++- .../llvm/TargetParser/PPCTargetParser.h | 5 + llvm/lib/MC/MCSubtargetInfo.cpp | 32 +++- llvm/lib/Target/PowerPC/PPC.td| 4 +- llvm/lib/TargetParser/CMakeLists.txt | 8 + llvm/lib/TargetParser/PPCTargetParser.cpp | 26 +++ llvm/utils/TableGen/SubtargetEmitter.cpp | 52 -- 13 files changed, 159 insertions(+), 200 deletions(-) diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp index 425ad68bb9098..2a1024be1d537 100644 --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/MacroBuilder.h" #include "clang/Basic/TargetBuiltins.h" #include "llvm/TargetParser/PPCTargetParser.h" +#include using namespace clang; using namespace clang::targets; @@ -516,130 +517,15 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, bool PPCTargetInfo::initFeatureMap( llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const { - Features["altivec"] = llvm::StringSwitch(CPU) -.Case("7400", true) -.Case("g4", true) -.Case("7450", true) -.Case("g4+", true) -.Case("970", true) -.Case("g5", true) -.Case("pwr6", true) -.Case("pwr7", true) -.Case("pwr8", true) -.Case("pwr9", true) -.Case("ppc64", true) -.Case("ppc64le", true) -.Default(false); - - Features["power9-vector"] = (CPU == "pwr9"); - Features["crypto"] = llvm::StringSwitch(CPU) - .Case("ppc64le", true) - .Case("pwr9", true) - .Case("pwr8", true) - .Default(false); - Features["power8-vector"] = llvm::StringSwitch(CPU) - .Case("ppc64le", true) - .Case("pwr9", true) - .Case("pwr8", true) - .Default(false); - Features["bpermd"] = llvm::StringSwitch(CPU) - .Case("ppc64le", true) - .Case("pwr9", true) - .Case("pwr8", true) - .Case("pwr7", true) - .Default(false); - Features["extdiv"] = llvm::StringSwitch(CPU) - .Case("ppc64le", true) - .Case("pwr9", true) - .Case("pwr8", true) - .Case("pwr7", true) - .Default(false); - Features["direct-move"] = llvm::StringSwitch(CPU) -.Case("ppc64le", true) -.Case("pwr9", true) -.Case("pwr8", true) -.Default(false); - Features["crbits"] = llvm::StringSwitch(CPU) -.Case("ppc64le", true) -.Case("pwr9", true) -.Case("pwr8", true) -.Default(false); - Features["vsx"] = llvm::StringSwitch(CPU) -.Case("ppc64le", true) -.Case("pwr9", true) -.Case("pwr8", true) -.Case("pwr7", true) -.Default(false); - Features["htm"] = llvm::StringSwitch(CPU) -.Case("ppc64le", true) -.Case("pwr9", true) -.Case("pwr8", true) -.Default(false); - - // ROP Protect is off by default. - Features["rop-protect"] = false; - // Privileged instructions are off by default. - Features["privileged"] = false; - if (getTriple().isOSAIX()) { -// The code generated by the -maix-small-local-[exec|dynamic]-tls option is -// turned off by default. -Features["aix-small-local-exec-tls"] = false; -Features["aix-small-local-dyna
[clang] Ensure bit-fields storing FPEvalMethodKind are wide enough to do so (PR #136515)
nico wrote: > After landing #116760 After landing #116785, right? https://github.com/llvm/llvm-project/pull/136515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Add diagnostic + attr for unterminated strings (PR #137829)
@@ -5024,3 +5024,9 @@ def OpenACCRoutineDecl :InheritableAttr { void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; }]; } + +def NonString : InheritableAttr { + let Spellings = [GCC<"nonstring">]; AaronBallman wrote: We don't typically do that. `GCC` spelling gets `__attribute__((foo))` and `[[gnu::foo]]` while the `Clang` spelling gets you `__attribute__((foo))` and `[[clang::foo]]`, so we usually go with `Clang` when Clang is the first to implement the attribute, and `GCC` when GCC is the first to implement, and only do both spellings in the very unlikely and terrible situation where the semantics are different between the two spellings. We do have `ClangGCC` spelling used by the sanitizers and that suggests we might want to change our policy, but that's orthogonal to this PR. https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)
@@ -183,9 +195,26 @@ class Action : public clang::ASTFrontendAction { auto Results = analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI, getCompilerInstance().getPreprocessor(), HeaderFilter); -if (!Insert) + +if (!Insert) { + llvm::errs() + << "[WARNING] -insert is deprecated in favor of `-disable-insert`. " + "The old flag was confusing since it suggested that inserts " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + +if (!Remove) { + llvm::errs() + << "[WARNING] -remove is deprecated in favor of `-disable-remove`. " + "The old flag was confusing since it suggested that removes " + "were disabled by default, when they were actually enabled. " + "See https://github.com/llvm/llvm-project/issues/132983\n";; +} + hulxv wrote: That will make the user need to `-remove=0` to use `-disable-remove` because `-remove` is true by default. Do you find that correct? https://github.com/llvm/llvm-project/pull/132991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Remove FEM_Indeterminable (PR #137661)
zahiraam wrote: > > > > > > @zahiraam @AaronBallman a different option would be to add a signed > > > > > > vs unsigned storage option to the `OPTION` and > > > > > > `BENIGN_ENUM_LANGOPT` macros so we can store negative enumerations > > > > > > safely > > > > > > > > > > > > > > > I think I would prefer this solution. We need to be able to set the > > > > > evaluation method to a value (-1) when it can't be known from the > > > > > target or when the value of `ffp-eval-method` is inconsistent with > > > > > the target. > > > > > > > > > > > > Could we shift all the values, so `FEM_Indeterminable` is `0`? > > > > > > > > > I don't think so. In practice on Linux systems, they use > > > `__FLT_EVAL_METHOD__` to control the type of `float_t` and `double_t`. > > > Things like this: > > > > > > Oh shoot, I forgot this was tied to `__FLT_EVAL_METHOD__` > > As far as I can make out this isn't an automatic mapping, so we can always > just set it correctly, but more importantly, I cannot see how it is not > currently broken - loading FEM_Indeterminate should not (in principle) be > sign extending. > > How do I get clang into the FEM_Indeterminate mode? As far as I can make out, > we currently have a single test for `__FLT_EVAL_METHOD__ == -1` and it does > not get run/checked See issue https://github.com/llvm/llvm-project/issues/137600 https://github.com/llvm/llvm-project/pull/137661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream TernaryOp (PR #137184)
https://github.com/erichkeane approved this pull request. I'm happy once Andy is. https://github.com/llvm/llvm-project/pull/137184 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)
ravurvi20 wrote: Thankyou. Updated OpenMPSupport.rst file. https://github.com/llvm/llvm-project/pull/128640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Clean up unnecessary #undef __CLC_BODYs (PR #137959)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/137959 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Modify -Wdefault-const-init (PR #137961)
@@ -1,28 +1,23 @@ -// RUN: %clang_cc1 -fsyntax-only -verify=c,unsafe -Wdefault-const-init %s -// RUN: %clang_cc1 -fsyntax-only -verify=c,unsafe -Wc++-compat %s -// RUN: %clang_cc1 -fsyntax-only -verify=unsafe %s -// RUN: %clang_cc1 -fsyntax-only -verify=c -Wdefault-const-init -Wno-default-const-init-unsafe %s -// RUN: %clang_cc1 -fsyntax-only -verify=good -Wno-default-const-init-unsafe %s -// RUN: %clang_cc1 -fsyntax-only -verify=cxx -x c++ %s -// good-no-diagnostics + Fznamznon wrote: An empty line in the beginning is kind of strange ```suggestion ``` https://github.com/llvm/llvm-project/pull/137961 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
@@ -912,6 +912,11 @@ class BlockAddress final : public Constant { /// block must be embedded into a function. static BlockAddress *get(BasicBlock *BB); + /// Return a BlockAddress for the specified basic block, which may not be + /// part of a function. The specified type must match the type of the function + /// the block will be inserted into. + static BlockAddress *get(Type *Ty, BasicBlock *BB); dtcxzyw wrote: Should we also add a corresponding helper for SandboxIR? It is the only way to create a blockaddress if it has not been inserted. https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix crash when an attribute is applied to pragma attribute/pragma dump (PR #137880)
https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/137880 >From be6d7e3fcf4ef53bdf0dce7ff1b541f9de33c81f Mon Sep 17 00:00:00 2001 From: erichkeane Date: Tue, 29 Apr 2025 14:32:32 -0700 Subject: [PATCH 1/2] Fix crash when an attribute is applied to pragma attribute/pragma dump These two don't result in a statement, so the attempt to apply the attributes to them was crashing. This patch correctly prohibits the use of attributes on these clauses. Fixes: #137861 --- clang/lib/Parse/ParseStmt.cpp | 4 clang/test/Parser/gh137861.cpp | 33 + 2 files changed, 37 insertions(+) create mode 100644 clang/test/Parser/gh137861.cpp diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 4e801f4ef890f..97924f093240f 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -526,10 +526,14 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes( return ParsePragmaLoopHint(Stmts, StmtCtx, TrailingElseLoc, CXX11Attrs); case tok::annot_pragma_dump: +ProhibitAttributes(CXX11Attrs); +ProhibitAttributes(GNUAttrs); HandlePragmaDump(); return StmtEmpty(); case tok::annot_pragma_attribute: +ProhibitAttributes(CXX11Attrs); +ProhibitAttributes(GNUAttrs); HandlePragmaAttribute(); return StmtEmpty(); } diff --git a/clang/test/Parser/gh137861.cpp b/clang/test/Parser/gh137861.cpp new file mode 100644 index 0..9354aef919650 --- /dev/null +++ b/clang/test/Parser/gh137861.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -verify + +void foo() { + // expected-error@+1{{an attribute list cannot appear here}} +__attribute__((aligned(64))) +#pragma clang attribute push(__attribute__((uninitialized)), apply_to = any(variable(is_local))) +{ + int f; +} +#pragma clang attribute pop +} + +void foo2() { + // expected-error@+1{{an attribute list cannot appear here}} +__attribute__((aligned(64))) +#pragma clang __debug dump foo +} + +void foo3() { + // expected-error@+1{{an attribute list cannot appear here}} + [[nodiscard]] +#pragma clang attribute push(__attribute__((uninitialized)), apply_to = any(variable(is_local))) +{ + int f; +} +#pragma clang attribute pop +} + +void foo4() { + // expected-error@+1{{an attribute list cannot appear here}} + [[nodiscard]] +#pragma clang __debug dump foo +} >From 5411b1fb7ea982898b29bdfbe59faaab390e7bb9 Mon Sep 17 00:00:00 2001 From: erichkeane Date: Wed, 30 Apr 2025 06:26:27 -0700 Subject: [PATCH 2/2] add release note --- clang/docs/ReleaseNotes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3105d8b481560..8f6a191c6a375 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -471,6 +471,9 @@ Bug Fixes in This Version evaluation. The crashes were happening during diagnostics emission due to unimplemented statement printer. (#GH132641) - Fixed visibility calculation for template functions. (#GH103477) +- Fixed a bug where an attribute before a ``pragma clang attribute`` or + ``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses + the invalid attribute location appropriately. (#GH137861) Bug Fixes to Compiler Builtins ^^ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix crash when an attribute is applied to pragma attribute/pragma dump (PR #137880)
@@ -526,10 +526,14 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes( return ParsePragmaLoopHint(Stmts, StmtCtx, TrailingElseLoc, CXX11Attrs); case tok::annot_pragma_dump: +ProhibitAttributes(CXX11Attrs); erichkeane wrote: No, both of those successfully produce a `statement` out of this, so they won't assert. So any attributes you try to apply will either be valid, or fail because they don't apply to a statement. The difference in these two is that they don't result in either an error OR a valid statement. https://github.com/llvm/llvm-project/pull/137880 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
@@ -912,6 +912,11 @@ class BlockAddress final : public Constant { /// block must be embedded into a function. static BlockAddress *get(BasicBlock *BB); + /// Return a BlockAddress for the specified basic block, which may not be + /// part of a function. The specified type must match the type of the function + /// the block will be inserted into. + static BlockAddress *get(Type *Ty, BasicBlock *BB); arsenm wrote: I think block address should be explicitly disallowed for unparented blocks https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1a14ef1 - [clang] Temporarily silence noisy warning for FPEvalMethod in another place
Author: Nico Weber Date: 2025-04-30T09:53:14-04:00 New Revision: 1a14ef1c89bf4632bf25a959142770f190dcaaf1 URL: https://github.com/llvm/llvm-project/commit/1a14ef1c89bf4632bf25a959142770f190dcaaf1 DIFF: https://github.com/llvm/llvm-project/commit/1a14ef1c89bf4632bf25a959142770f190dcaaf1.diff LOG: [clang] Temporarily silence noisy warning for FPEvalMethod in another place When adding an explicit default copy ctor and assignment operator, clang emits the diag there, instead of for the class. That's narrow enough that we can suppress the warning there too. With this, it only files building a single file (CompilerInvocation.cpp). See https://github.com/llvm/llvm-project/issues/137600#issuecomment-2842011513 Added: Modified: clang/include/clang/Basic/LangOptions.h Removed: diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index bbebf7af9ede3..ae25c09f837b7 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -76,6 +76,19 @@ class LangOptionsBase { using RoundingMode = llvm::RoundingMode; using CFBranchLabelSchemeKind = clang::CFBranchLabelSchemeKind; + LangOptionsBase() = default; + +#if defined(__clang__) +// FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" +#endif + LangOptionsBase(const LangOptionsBase&) = default; + LangOptionsBase& operator=(const LangOptionsBase&) = default; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + enum GCMode { NonGC, GCOnly, HybridGC }; enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
@@ -1688,8 +1688,7 @@ class LLVMContextImpl { StringMap> CDSConstants; - DenseMap, BlockAddress *> - BlockAddresses; + DenseMap BlockAddresses; arsenm wrote: I'm working on moving this out of the LLVMContext https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Do not store Function inside BlockAddress (PR #137958)
@@ -920,8 +925,8 @@ class BlockAddress final : public Constant { /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - Function *getFunction() const { return (Function *)Op<0>().get(); } - BasicBlock *getBasicBlock() const { return (BasicBlock *)Op<1>().get(); } + BasicBlock *getBasicBlock() const { return (BasicBlock *)Op<0>().get(); } arsenm wrote: `cast` or `static_cast`? https://github.com/llvm/llvm-project/pull/137958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] Run finalize linkage pass for all targets (PR #134260)
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/134260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL][AMDGPU] OpenCL Kernel stubs should be assigned alwaysinline attribute (PR #137769)
arsenm wrote: > Why do you think it is an internal function? I thought it's an externally > callable stub. Yes at construction, but in the real optimization pipeline it will be internalized https://github.com/llvm/llvm-project/pull/137769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1b7d8b2 - [clang] prevent -Wunknown-warning-option with older clangs
Author: Nico Weber Date: 2025-04-30T09:56:52-04:00 New Revision: 1b7d8b2ee66672c5226f2a8d6b72b025070d9ede URL: https://github.com/llvm/llvm-project/commit/1b7d8b2ee66672c5226f2a8d6b72b025070d9ede DIFF: https://github.com/llvm/llvm-project/commit/1b7d8b2ee66672c5226f2a8d6b72b025070d9ede.diff LOG: [clang] prevent -Wunknown-warning-option with older clangs Added: Modified: clang/include/clang/Basic/LangOptions.def clang/include/clang/Basic/LangOptions.h Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 1258a349ebf00..ecf7a35f7746d 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -348,13 +348,13 @@ COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating p BENIGN_LANGOPT(RoundingMath, 1, false, "Do not assume default floating-point rounding behavior") BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Default, "FP Exception Behavior Mode type") -#if defined(__clang__) +#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") // FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" #endif BENIGN_ENUM_LANGOPT(FPEvalMethod, FPEvalMethodKind, 3, FEM_UnsetOnCommandLine, "FP type used for floating point arithmetic") -#if defined(__clang__) +#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") #pragma clang diagnostic pop #endif diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h index ae25c09f837b7..73c4a9e4a0876 100644 --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -78,14 +78,14 @@ class LangOptionsBase { LangOptionsBase() = default; -#if defined(__clang__) +#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") // FIXME: Remove this once the warning is fixed, https://llvm.org/PR137600 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpreferred-type-bitfield-enum-conversion" #endif LangOptionsBase(const LangOptionsBase&) = default; LangOptionsBase& operator=(const LangOptionsBase&) = default; -#if defined(__clang__) +#if defined(__clang__) && defined( __has_warning ) && __has_warning("-Wpreferred-type-bitfield-enum-conversion") #pragma clang diagnostic pop #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [clang-tidy] add `ctime` and `localtime` to `clang-tidy` (PR #110366)
https://github.com/zimirza updated https://github.com/llvm/llvm-project/pull/110366 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support — https://githubstatus.com";>GitHub Status — https://twitter.com/githubstatus";>@githubstatus ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
wenju-he wrote: close this PR. Original intention of disabling opt -O3 on downstream project was changed. https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)
https://github.com/wenju-he closed https://github.com/llvm/llvm-project/pull/130882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [TargetParser] Fix flaky installs of generated headers (PR #137853)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on `as-worker-93` while building `clang,llvm` at step 7 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2814 Here is the relevant piece of the build log for the reference ``` Step 7 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM-Unit :: Support/./SupportTests.exe/90/95' FAILED Script(shard): -- GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-17788-90-95.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=90 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe -- Script: -- C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath -- C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values: 0 RC Which is: -2 C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success. error number: 13 error message: permission denied C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160 Expected equality of these values: 0 RC Which is: -2 C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163 fs::remove(Twine(LongPath)): did not return errc::success. error number: 13 error message: permission denied ``` https://github.com/llvm/llvm-project/pull/137853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add v3 variants of async_work_group_copy/async_work_group_strided_copy/prefetch (PR #137932)
wenju-he wrote: @frasercrmck please help to review, thanks https://github.com/llvm/llvm-project/pull/137932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (PR #137949)
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/137949 This is needed for forced unwind, for some testcases in libunwind/libcxxabi. This adds an aarch64 case for extracting the LanguageHandler and HandlerData fields from unwind info, in UnwindCursor::getInfoFromSEH, corresponding to the existing case for x86_64. This uses the struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA; this only became available in WinSDK 10.0.19041.0 and mingw-w64 v11.0 (or a mingw-w64 git snapshot after April 2023). (This is only a build-time requirement though; the format for the unwind data has been fixed since the start of Windows 10 on ARM64, so this doesn't impose any runtime requirement.) From 8a03c40961c30bc7a73d4bb841e1811722d2f23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 18 Apr 2023 15:02:54 +0300 Subject: [PATCH] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata This is needed for forced unwind. This adds an aarch64 case for extracting the LanguageHandler and HandlerData fields from unwind info, in UnwindCursor::getInfoFromSEH, corresponding to the existing case for x86_64. This uses the struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA; this only became available in WinSDK 10.0.19041.0 and mingw-w64 v11.0 (or a mingw-w64 git snapshot after April 2023). (This is only a build-time requirement though; the format for the unwind data has been fixed since the start of Windows 10 on ARM64, so this doesn't impose any runtime requirement.) --- libunwind/src/UnwindCursor.hpp | 46 ++ 1 file changed, 46 insertions(+) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..5c1d77ebeddaf 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -2018,6 +2018,52 @@ bool UnwindCursor::getInfoFromSEH(pint_t pc) { _info.handler = 0; } } +#elif defined(_LIBUNWIND_TARGET_AARCH64) + if (unwindEntry->Flag != 0) { // Packed unwind info +_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + // Packed unwind info doesn't have an exception handler. + _info.lsda = 0; + _info.handler = 0; +} + } else { +IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *xdata = +reinterpret_cast( +base + unwindEntry->UnwindData); +_info.end_ip = _info.start_ip + xdata->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + if (xdata->ExceptionDataPresent) { +uint32_t offset = 1; // The main xdata +uint32_t codeWords = xdata->CodeWords; +uint32_t epilogScopes = xdata->EpilogCount; +if (xdata->EpilogCount == 0 && xdata->CodeWords == 0) { + uint32_t extensionWord = reinterpret_cast(xdata)[1]; + codeWords = (extensionWord >> 16) & 0xff; + epilogScopes = extensionWord & 0x; + offset++; +} +if (!xdata->EpilogInHeader) + offset += epilogScopes; +offset += codeWords; +uint32_t *exceptionHandlerInfo = +reinterpret_cast(xdata) + offset; +_dispContext.HandlerData = &exceptionHandlerInfo[1]; +_dispContext.LanguageHandler = reinterpret_cast( +base + exceptionHandlerInfo[0]); +_info.lsda = reinterpret_cast(_dispContext.HandlerData); +if (_dispContext.LanguageHandler) + _info.handler = + reinterpret_cast(__libunwind_seh_personality); +else + _info.handler = 0; + } else { +_info.lsda = 0; +_info.handler = 0; + } +} + } #endif setLastPC(pc); return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (PR #137949)
llvmbot wrote: @llvm/pr-subscribers-libunwind Author: Martin Storsjö (mstorsjo) Changes This is needed for forced unwind, for some testcases in libunwind/libcxxabi. This adds an aarch64 case for extracting the LanguageHandler and HandlerData fields from unwind info, in UnwindCursor::getInfoFromSEH, corresponding to the existing case for x86_64. This uses the struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA; this only became available in WinSDK 10.0.19041.0 and mingw-w64 v11.0 (or a mingw-w64 git snapshot after April 2023). (This is only a build-time requirement though; the format for the unwind data has been fixed since the start of Windows 10 on ARM64, so this doesn't impose any runtime requirement.) --- Full diff: https://github.com/llvm/llvm-project/pull/137949.diff 1 Files Affected: - (modified) libunwind/src/UnwindCursor.hpp (+46) ``diff diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..5c1d77ebeddaf 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -2018,6 +2018,52 @@ bool UnwindCursor::getInfoFromSEH(pint_t pc) { _info.handler = 0; } } +#elif defined(_LIBUNWIND_TARGET_AARCH64) + if (unwindEntry->Flag != 0) { // Packed unwind info +_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + // Packed unwind info doesn't have an exception handler. + _info.lsda = 0; + _info.handler = 0; +} + } else { +IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *xdata = +reinterpret_cast( +base + unwindEntry->UnwindData); +_info.end_ip = _info.start_ip + xdata->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + if (xdata->ExceptionDataPresent) { +uint32_t offset = 1; // The main xdata +uint32_t codeWords = xdata->CodeWords; +uint32_t epilogScopes = xdata->EpilogCount; +if (xdata->EpilogCount == 0 && xdata->CodeWords == 0) { + uint32_t extensionWord = reinterpret_cast(xdata)[1]; + codeWords = (extensionWord >> 16) & 0xff; + epilogScopes = extensionWord & 0x; + offset++; +} +if (!xdata->EpilogInHeader) + offset += epilogScopes; +offset += codeWords; +uint32_t *exceptionHandlerInfo = +reinterpret_cast(xdata) + offset; +_dispContext.HandlerData = &exceptionHandlerInfo[1]; +_dispContext.LanguageHandler = reinterpret_cast( +base + exceptionHandlerInfo[0]); +_info.lsda = reinterpret_cast(_dispContext.HandlerData); +if (_dispContext.LanguageHandler) + _info.handler = + reinterpret_cast(__libunwind_seh_personality); +else + _info.handler = 0; + } else { +_info.lsda = 0; +_info.handler = 0; + } +} + } #endif setLastPC(pc); return true; `` https://github.com/llvm/llvm-project/pull/137949 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] [SEH] Implement parsing of ARM pdata/xdata (PR #137950)
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/137950 This is generally very similar to the aarch64 case. Contrary to aarch64, the public headers don't contain any definition of a struct for interpreting this data, so we provide our own. From 8a03c40961c30bc7a73d4bb841e1811722d2f23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 18 Apr 2023 15:02:54 +0300 Subject: [PATCH 1/2] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata This is needed for forced unwind. This adds an aarch64 case for extracting the LanguageHandler and HandlerData fields from unwind info, in UnwindCursor::getInfoFromSEH, corresponding to the existing case for x86_64. This uses the struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA; this only became available in WinSDK 10.0.19041.0 and mingw-w64 v11.0 (or a mingw-w64 git snapshot after April 2023). (This is only a build-time requirement though; the format for the unwind data has been fixed since the start of Windows 10 on ARM64, so this doesn't impose any runtime requirement.) --- libunwind/src/UnwindCursor.hpp | 46 ++ 1 file changed, 46 insertions(+) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..5c1d77ebeddaf 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -2018,6 +2018,52 @@ bool UnwindCursor::getInfoFromSEH(pint_t pc) { _info.handler = 0; } } +#elif defined(_LIBUNWIND_TARGET_AARCH64) + if (unwindEntry->Flag != 0) { // Packed unwind info +_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + // Packed unwind info doesn't have an exception handler. + _info.lsda = 0; + _info.handler = 0; +} + } else { +IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *xdata = +reinterpret_cast( +base + unwindEntry->UnwindData); +_info.end_ip = _info.start_ip + xdata->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + if (xdata->ExceptionDataPresent) { +uint32_t offset = 1; // The main xdata +uint32_t codeWords = xdata->CodeWords; +uint32_t epilogScopes = xdata->EpilogCount; +if (xdata->EpilogCount == 0 && xdata->CodeWords == 0) { + uint32_t extensionWord = reinterpret_cast(xdata)[1]; + codeWords = (extensionWord >> 16) & 0xff; + epilogScopes = extensionWord & 0x; + offset++; +} +if (!xdata->EpilogInHeader) + offset += epilogScopes; +offset += codeWords; +uint32_t *exceptionHandlerInfo = +reinterpret_cast(xdata) + offset; +_dispContext.HandlerData = &exceptionHandlerInfo[1]; +_dispContext.LanguageHandler = reinterpret_cast( +base + exceptionHandlerInfo[0]); +_info.lsda = reinterpret_cast(_dispContext.HandlerData); +if (_dispContext.LanguageHandler) + _info.handler = + reinterpret_cast(__libunwind_seh_personality); +else + _info.handler = 0; + } else { +_info.lsda = 0; +_info.handler = 0; + } +} + } #endif setLastPC(pc); return true; From 7254f7c4d8b07420c873b6729fac273f71efe38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 18 Apr 2023 23:28:20 +0300 Subject: [PATCH 2/2] [libunwind] [SEH] Implement parsing of ARM pdata/xdata This is generally very similar to the aarch64 case. Contrary to aarch64, the public headers don't contain any definition of a struct for interpreting this data, so we provide our own. --- libunwind/src/UnwindCursor.hpp | 58 ++ 1 file changed, 58 insertions(+) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 5c1d77ebeddaf..1cbed2d6f93b9 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -83,6 +83,19 @@ struct UNWIND_INFO { uint16_t UnwindCodes[2]; }; +union UNWIND_INFO_ARM { + DWORD HeaderData; + struct { +DWORD FunctionLength : 18; +DWORD Version : 2; +DWORD ExceptionDataPresent : 1; +DWORD EpilogInHeader : 1; +DWORD FunctionFragment : 1; +DWORD EpilogCount : 5; +DWORD CodeWords : 4; + } s; +}; + extern "C" _Unwind_Reason_Code __libunwind_seh_personality( int, _Unwind_Action, uint64_t, _Unwind_Exception *, struct _Unwind_Context *); @@ -2064,6 +2077,51 @@ bool UnwindCursor::getInfoFromSEH(pint_t pc) { } } } +#elif defined(_LIBUNWIND_TARGET_ARM) + if (unwindEntry->Flag != 0) { // Packed unwind info +_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 2; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + // Packed unwind info doesn't have an exception handler. + _i
[libunwind] [libunwind] [SEH] Implement parsing of ARM pdata/xdata (PR #137950)
Martin =?utf-8?q?Storsjö?= Message-ID: In-Reply-To: llvmbot wrote: @llvm/pr-subscribers-libunwind Author: Martin Storsjö (mstorsjo) Changes This is generally very similar to the aarch64 case. Contrary to aarch64, the public headers don't contain any definition of a struct for interpreting this data, so we provide our own. --- Full diff: https://github.com/llvm/llvm-project/pull/137950.diff 1 Files Affected: - (modified) libunwind/src/UnwindCursor.hpp (+104) ``diff diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index ca9927edc9990..1cbed2d6f93b9 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -83,6 +83,19 @@ struct UNWIND_INFO { uint16_t UnwindCodes[2]; }; +union UNWIND_INFO_ARM { + DWORD HeaderData; + struct { +DWORD FunctionLength : 18; +DWORD Version : 2; +DWORD ExceptionDataPresent : 1; +DWORD EpilogInHeader : 1; +DWORD FunctionFragment : 1; +DWORD EpilogCount : 5; +DWORD CodeWords : 4; + } s; +}; + extern "C" _Unwind_Reason_Code __libunwind_seh_personality( int, _Unwind_Action, uint64_t, _Unwind_Exception *, struct _Unwind_Context *); @@ -2018,6 +2031,97 @@ bool UnwindCursor::getInfoFromSEH(pint_t pc) { _info.handler = 0; } } +#elif defined(_LIBUNWIND_TARGET_AARCH64) + if (unwindEntry->Flag != 0) { // Packed unwind info +_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + // Packed unwind info doesn't have an exception handler. + _info.lsda = 0; + _info.handler = 0; +} + } else { +IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *xdata = +reinterpret_cast( +base + unwindEntry->UnwindData); +_info.end_ip = _info.start_ip + xdata->FunctionLength * 4; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + if (xdata->ExceptionDataPresent) { +uint32_t offset = 1; // The main xdata +uint32_t codeWords = xdata->CodeWords; +uint32_t epilogScopes = xdata->EpilogCount; +if (xdata->EpilogCount == 0 && xdata->CodeWords == 0) { + uint32_t extensionWord = reinterpret_cast(xdata)[1]; + codeWords = (extensionWord >> 16) & 0xff; + epilogScopes = extensionWord & 0x; + offset++; +} +if (!xdata->EpilogInHeader) + offset += epilogScopes; +offset += codeWords; +uint32_t *exceptionHandlerInfo = +reinterpret_cast(xdata) + offset; +_dispContext.HandlerData = &exceptionHandlerInfo[1]; +_dispContext.LanguageHandler = reinterpret_cast( +base + exceptionHandlerInfo[0]); +_info.lsda = reinterpret_cast(_dispContext.HandlerData); +if (_dispContext.LanguageHandler) + _info.handler = + reinterpret_cast(__libunwind_seh_personality); +else + _info.handler = 0; + } else { +_info.lsda = 0; +_info.handler = 0; + } +} + } +#elif defined(_LIBUNWIND_TARGET_ARM) + if (unwindEntry->Flag != 0) { // Packed unwind info +_info.end_ip = _info.start_ip + unwindEntry->FunctionLength * 2; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + // Packed unwind info doesn't have an exception handler. + _info.lsda = 0; + _info.handler = 0; +} + } else { +UNWIND_INFO_ARM *xdata = +reinterpret_cast(base + unwindEntry->UnwindData); +_info.end_ip = _info.start_ip + xdata->s.FunctionLength * 2; +// Only fill in the handler and LSDA if they're stale. +if (pc != getLastPC()) { + if (xdata->s.ExceptionDataPresent) { +uint32_t offset = 1; // The main xdata +uint32_t codeWords = xdata->s.CodeWords; +uint32_t epilogScopes = xdata->s.EpilogCount; +if (xdata->s.EpilogCount == 0 && xdata->s.CodeWords == 0) { + uint32_t extensionWord = reinterpret_cast(xdata)[1]; + codeWords = (extensionWord >> 16) & 0xff; + epilogScopes = extensionWord & 0x; + offset++; +} +if (!xdata->s.EpilogInHeader) + offset += epilogScopes; +offset += codeWords; +uint32_t *exceptionHandlerInfo = +reinterpret_cast(xdata) + offset; +_dispContext.HandlerData = &exceptionHandlerInfo[1]; +_dispContext.LanguageHandler = reinterpret_cast( +base + exceptionHandlerInfo[0]); +_info.lsda = reinterpret_cast(_dispContext.HandlerData); +if (_dispContext.LanguageHandler) + _info.handler = + reinterpret_cast(__libunwind_seh_personality); +else + _info.handler = 0; + } else { +_info.lsda = 0; +_info.handler = 0; + } +} + } #endif setLastPC(pc); return true; `` https://github.com/llvm/llvm-proje
[libunwind] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (PR #137951)
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/137951 The CRT __C_specific_handler function uses this for restoring registers before calling the filter function. This fixes the libunwind/libcxxabi forced unwind testcases on ARM and AArch64. From 27b7d0e7946fd030b7a8f0026a6732b51017ce62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 18 Apr 2023 15:47:13 +0300 Subject: [PATCH] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function The CRT __C_specific_handler function uses this for restoring registers before calling the filter function. This fixes the libunwind/libcxxabi forced unwind testcases on ARM and AArch64. --- libunwind/src/Unwind-seh.cpp | 5 + 1 file changed, 5 insertions(+) diff --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp index b2bb119ed6d29..f6525af07e25f 100644 --- a/libunwind/src/Unwind-seh.cpp +++ b/libunwind/src/Unwind-seh.cpp @@ -212,6 +212,11 @@ __libunwind_seh_personality(int version, _Unwind_Action state, ms_exc.ExceptionInformation[2] = state; DISPATCHER_CONTEXT *disp_ctx = __unw_seh_get_disp_ctx((unw_cursor_t *)context); +#if defined(__aarch64__) + disp_ctx->NonVolatileRegisters = (PBYTE)&disp_ctx->ContextRecord->X19; +#elif defined(__arm__) + disp_ctx->NonVolatileRegisters = (PBYTE)&disp_ctx->ContextRecord->R4; +#endif _LIBUNWIND_TRACE_UNWINDING("__libunwind_seh_personality() calling " "LanguageHandler %p(%p, %p, %p, %p)", (void *)disp_ctx->LanguageHandler, (void *)&ms_exc, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] [SEH] Implement parsing of ARM pdata/xdata (PR #137950)
mstorsjo wrote: This goes on top of #137949. https://github.com/llvm/llvm-project/pull/137950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (PR #137951)
mstorsjo wrote: Together with #137949 and #137950, this makes `check-cxxabi` and `check-unwind` pass on aarch64 and arm. https://github.com/llvm/llvm-project/pull/137951 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (PR #137951)
llvmbot wrote: @llvm/pr-subscribers-libunwind Author: Martin Storsjö (mstorsjo) Changes The CRT __C_specific_handler function uses this for restoring registers before calling the filter function. This fixes the libunwind/libcxxabi forced unwind testcases on ARM and AArch64. --- Full diff: https://github.com/llvm/llvm-project/pull/137951.diff 1 Files Affected: - (modified) libunwind/src/Unwind-seh.cpp (+5) ``diff diff --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp index b2bb119ed6d29..f6525af07e25f 100644 --- a/libunwind/src/Unwind-seh.cpp +++ b/libunwind/src/Unwind-seh.cpp @@ -212,6 +212,11 @@ __libunwind_seh_personality(int version, _Unwind_Action state, ms_exc.ExceptionInformation[2] = state; DISPATCHER_CONTEXT *disp_ctx = __unw_seh_get_disp_ctx((unw_cursor_t *)context); +#if defined(__aarch64__) + disp_ctx->NonVolatileRegisters = (PBYTE)&disp_ctx->ContextRecord->X19; +#elif defined(__arm__) + disp_ctx->NonVolatileRegisters = (PBYTE)&disp_ctx->ContextRecord->R4; +#endif _LIBUNWIND_TRACE_UNWINDING("__libunwind_seh_personality() calling " "LanguageHandler %p(%p, %p, %p, %p)", (void *)disp_ctx->LanguageHandler, (void *)&ms_exc, `` https://github.com/llvm/llvm-project/pull/137951 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f2b8539 - [C2y] Correctly handle 0 in the preprocessor (#137844)
Author: Aaron Ballman Date: 2025-04-30T06:55:20-04:00 New Revision: f2b8539803ea5887a9653d26cdcacaabd536ae1c URL: https://github.com/llvm/llvm-project/commit/f2b8539803ea5887a9653d26cdcacaabd536ae1c DIFF: https://github.com/llvm/llvm-project/commit/f2b8539803ea5887a9653d26cdcacaabd536ae1c.diff LOG: [C2y] Correctly handle 0 in the preprocessor (#137844) We do not diagnose 0 as a deprecated octal literal outside of the preprocessor. This fixes a bug where we were accidentally diagnosing 0 from a preprocessor conditional, however. No release note because this is fixing an issue with a new change. Added: Modified: clang/lib/Lex/LiteralSupport.cpp clang/test/C/C2y/n3353.c Removed: diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..75ad977d64b24 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -1420,7 +1420,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { } // Parse a potential octal literal prefix. - bool SawOctalPrefix = false; + bool SawOctalPrefix = false, IsSingleZero = false; if ((c1 == 'O' || c1 == 'o') && (s[1] >= '0' && s[1] <= '7')) { unsigned DiagId; if (LangOpts.C2y) @@ -1438,7 +1438,8 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { auto _ = llvm::make_scope_exit([&] { // If we still have an octal value but we did not see an octal prefix, // diagnose as being an obsolescent feature starting in C2y. -if (radix == 8 && LangOpts.C2y && !SawOctalPrefix && !hadError) +if (radix == 8 && LangOpts.C2y && !SawOctalPrefix && !hadError && +!IsSingleZero) Diags.Report(TokLoc, diag::warn_unprefixed_octal_deprecated); }); @@ -1453,6 +1454,8 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) { // anything, we leave the digit start where it was. if (s != PossibleNewDigitStart) DigitsBegin = PossibleNewDigitStart; + else +IsSingleZero = (s == ThisTokEnd); // Is the only thing we've seen a 0? if (s == ThisTokEnd) return; // Done, simple octal number like 01234 diff --git a/clang/test/C/C2y/n3353.c b/clang/test/C/C2y/n3353.c index fb7f9439ac21b..a616228f1bad0 100644 --- a/clang/test/C/C2y/n3353.c +++ b/clang/test/C/C2y/n3353.c @@ -46,6 +46,10 @@ static const void *ptr = 0o0; /* ext-warning {{octal integer literals are a C2y // 0 by itself is not deprecated, of course. int k = 0; +// Test a preprocessor use of 0 by itself, which is also not deprecated. +#if 0 +#endif + // Make sure there are no surprises with auto and type deduction. Promotion // turns this into an 'int', and 'constexpr' implies 'const'. constexpr auto l = 0o1234567; /* ext-warning {{octal integer literals are a C2y extension}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C2y] Correctly handle 0 in the preprocessor (PR #137844)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/137844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Mark constructors with invalid initializers as invalid (PR #137773)
@@ -2,16 +2,20 @@ // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++11 %s -class A { +class A { + // expected-note@-1 {{candidate constructor}} +#if __cplusplus >= 201103L // C++11 or later + // expected-note@-3 {{candidate constructor}} +#endif int m; public: A() : A::m(17) { } // expected-error {{member initializer 'm' does not name a non-static data member or base class}} - A(int); + A(int); // expected-note {{candidate constructor}} }; class B : public A { public: - B() : A(), m(1), n(3.14) { } + B() : A(), m(1), n(3.14) { } // expected-error {{no matching constructor for initialization of 'A'}} AaronBallman wrote: Oof, yeah, this diagnostic is confusing because it sure looks like there's a matching constructor for `A`. https://github.com/llvm/llvm-project/pull/137773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)
https://github.com/ravurvi20 updated https://github.com/llvm/llvm-project/pull/128640 >From 6ebd5991788608fbd104ea9c23230912044462d3 Mon Sep 17 00:00:00 2001 From: Urvi Rav Date: Tue, 25 Feb 2025 00:49:07 -0600 Subject: [PATCH 1/7] default clause replaced by otherwise clause for metadirective --- .../clang/Basic/DiagnosticParseKinds.td | 4 ++ clang/lib/Parse/ParseOpenMP.cpp | 20 ++ clang/test/OpenMP/metadirective_messages.cpp | 61 +-- 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index c513dab810d1f..4b8449e9ee9b6 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1657,6 +1657,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/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 42e6aac681c1c..3b86847e937a2 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2759,6 +2759,19 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( OpenMPClauseKind CKind = Tok.isAnnotation() ? OMPC_unknown : getOpenMPClauseKind(PP.getSpelling(Tok)); + // Check if the clause is unrecognized. + if (getLangOpts().OpenMP < 52 && + (CKind == OMPC_unknown || CKind == OMPC_otherwise)) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; + } + if (getLangOpts().OpenMP >= 52 && CKind == OMPC_unknown) { +Diag(Tok, diag::err_omp_unknown_clause) +<< PP.getSpelling(Tok) << "metadirective"; + } + if (CKind == OMPC_default && getLangOpts().OpenMP >= 52) { +Diag(Tok, diag::warn_omp_default_deprecated); + } SourceLocation Loc = ConsumeToken(); // Parse '('. @@ -2785,6 +2798,13 @@ 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_messages.cpp b/clang/test/OpenMP/metadirective_messages.cpp index 7fce9fa446058..40ea37845fdff 100644 --- a/clang/test/OpenMP/metadirective_messages.cpp +++ b/clang/test/OpenMP/metadirective_messages.cpp @@ -2,21 +2,48 @@ // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions -fcxx-exceptions %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized + void foo() { -#pragma omp metadirective // expected-error {{expected expression}} - ; -#pragma omp metadirective when() // expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} expected-warning {{expected identifier or string literal describing a context set; set skipped}} expected-note {{context set options are: 'construct' 'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}} - ; -#pragma omp metadirective when(device{}) // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} expected-warning {{expected identifier or string literal describing a context selector; selector skipped}} expected-note {{context selector options are: 'kind' 'arch' 'isa'}} expected-note {{the ignored selector spans until here}} expected-error {{expected valid context selector in when clause}} expected-error {{expected expression}} - ; -#pragma omp metadirective when(device{arch(nvptx)}) // expected-error {{missing ':' in when clause}} expected-error {{expected expression}} expected-warning {{expected '=' after the context set name "device"; '=' assumed}} - ; -#pragma omp metadirective when(device{arch(nvptx)}: ) default() // expected-warning {{expected '=' after the context set name "device"; '=' assumed}} - ; -#pragma omp metadirective when(device
[clang-tools-extra] [clang-tidy] do not diagnose array types within implicit instantiations of a template (PR #132924)
https://github.com/stmuench updated https://github.com/llvm/llvm-project/pull/132924 >From fb9f0c3db8609645588692eecc294407f48c1c34 Mon Sep 17 00:00:00 2001 From: stmuench Date: Tue, 25 Mar 2025 12:38:53 +0100 Subject: [PATCH] [clang-tidy] do not diagn. array types in implicit templ. instantiations So far, the clang-tidy check `modernize-avoid-c-arrays` also diagnosed array types for type template parameters even though no actual array type got written there but it got deduced to one. In such case, there is nothing a developer can do at that location to fix the diagnostic. Since actually, the location where the template got instantiated would have to be adjusted. And this is in most cases some totally distant code where implementers of a template do not have access to. Also adding suppressions to the declaration of the template is not an option since that would clutter the code unnecessarily and is in many cases also simply not possible. Hence, we propose to not diagnose any occurrence of an array type in an implicit instantiation of a template but rather at the point where template arguments involve array types. --- .../modernize/AvoidCArraysCheck.cpp | 60 +- clang-tools-extra/docs/ReleaseNotes.rst | 4 + .../avoid-c-arrays-ignores-strings.cpp| 12 ++ .../checkers/modernize/avoid-c-arrays.cpp | 192 ++ 4 files changed, 262 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp index 0804aa76d953c..57cbba87f4c02 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp @@ -39,6 +39,29 @@ AST_MATCHER(clang::ParmVarDecl, isArgvOfMain) { return FD ? FD->isMain() : false; } +AST_MATCHER(clang::TypeLoc, isInImplicitTemplateInstantiation) { + const auto IsImplicitTemplateInstantiation = [](const auto *Node) { +return (Node != nullptr) && + (Node->getTemplateSpecializationKind() == TSK_ImplicitInstantiation); + }; + + auto ParentNodes = Finder->getASTContext().getParents(Node); + while (!ParentNodes.empty()) { +const auto &ParentNode = ParentNodes[0]; +if (IsImplicitTemplateInstantiation( +ParentNode.template get()) || +IsImplicitTemplateInstantiation( +ParentNode.template get()) || +IsImplicitTemplateInstantiation( +ParentNode.template get())) { + return true; +} +ParentNodes = Finder->getASTContext().getParents(ParentNode); + } + + return false; +} + } // namespace AvoidCArraysCheck::AvoidCArraysCheck(StringRef Name, ClangTidyContext *Context) @@ -66,22 +89,45 @@ void AvoidCArraysCheck::registerMatchers(MatchFinder *Finder) { hasParent(varDecl(isExternC())), hasParent(fieldDecl( hasParent(recordDecl(isExternCContext(), - hasAncestor(functionDecl(isExternC(), + hasAncestor(functionDecl(isExternC())), + isInImplicitTemplateInstantiation())), std::move(IgnoreStringArrayIfNeededMatcher)) .bind("typeloc"), this); + + Finder->addMatcher(templateArgumentLoc(hasTypeLoc(hasType(arrayType( + .bind("template_arg_with_array_type_loc"), + this); } void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) { - const auto *ArrayType = Result.Nodes.getNodeAs("typeloc"); + TypeLoc ArrayTypeLoc{}; + + if (const auto *MatchedTypeLoc = Result.Nodes.getNodeAs("typeloc"); + MatchedTypeLoc != nullptr) { +ArrayTypeLoc = *MatchedTypeLoc; + } + + if (const auto *TemplateArgLoc = Result.Nodes.getNodeAs( + "template_arg_with_array_type_loc"); + TemplateArgLoc != nullptr && + TemplateArgLoc->getTypeSourceInfo() != nullptr) { +ArrayTypeLoc = TemplateArgLoc->getTypeSourceInfo()->getTypeLoc(); + } + + // check whether an actual array type got matched (see checks above) + if (ArrayTypeLoc.isNull()) { +return; + } + const bool IsInParam = Result.Nodes.getNodeAs("param_decl") != nullptr; - const bool IsVLA = ArrayType->getTypePtr()->isVariableArrayType(); + const bool IsVLA = ArrayTypeLoc.getTypePtr()->isVariableArrayType(); enum class RecommendType { Array, Vector, Span }; llvm::SmallVector RecommendTypes{}; if (IsVLA) { RecommendTypes.push_back("'std::vector'"); - } else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) { + } else if (ArrayTypeLoc.getTypePtr()->isIncompleteArrayType() && IsInParam) { // in function parameter, we also don't know the size of // IncompleteArrayType. if (Result.Context->getLangOpts().CPlusPlus20) @@ -93,9 +139,11 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {