From 0324fd2d83ba5f60949f71f33aad97327c7b87ab Mon Sep 17 00:00:00 2001 From: Emanuele Rocca Date: Sat, 4 Jan 2025 09:12:52 +0100 Subject: [PATCH] [Clang] Fix build with GCC 14 on ARM Origin: backport, https://github.com/llvm/llvm-project/pull/78704/commits/078c18de832328f743fb6e Bug-Debian: https://bugs.debian.org/1077068 Forwarded: not-needed Last-Update: 2024-08-29 Backport to LLVM 17 of a patch by Nikita Popov merged in the upstream main branch. The patch fixes a build issue on arm64 with GCC 14. The additional changes to the for loop in ClangAttrEmitter.cpp have been taken from the main branch and are needed for the HasArgs boolean. Gbp-Pq: Name arm64-clang-gcc-14.patch --- clang/include/clang/Basic/TokenKinds.def | 2 +- clang/include/clang/Basic/TokenKinds.h | 2 +- clang/utils/TableGen/ClangAttrEmitter.cpp | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index ef0dad0f2d..4c3965ca24 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -753,7 +753,7 @@ KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL) // Keywords defined by Attr.td. #ifndef KEYWORD_ATTRIBUTE -#define KEYWORD_ATTRIBUTE(X) KEYWORD(X, KEYALL) +#define KEYWORD_ATTRIBUTE(X, HASARG, EMPTY) KEYWORD(EMPTY ## X, KEYALL) #endif #include "clang/Basic/AttrTokenKinds.inc" diff --git a/clang/include/clang/Basic/TokenKinds.h b/clang/include/clang/Basic/TokenKinds.h index e4857405bc..988696b6d9 100644 --- a/clang/include/clang/Basic/TokenKinds.h +++ b/clang/include/clang/Basic/TokenKinds.h @@ -109,7 +109,7 @@ bool isPragmaAnnotation(TokenKind K); inline constexpr bool isRegularKeywordAttribute(TokenKind K) { return (false -#define KEYWORD_ATTRIBUTE(X) || (K == tok::kw_##X) +#define KEYWORD_ATTRIBUTE(X, HASARG, EMPTY) || (K == tok::kw_##X) #include "clang/Basic/AttrTokenKinds.inc" ); } diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index b5813c6abc..3394e4d859 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3423,14 +3423,14 @@ void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) { // Assume for now that the same token is not used in multiple regular // keyword attributes. for (auto *R : Records.getAllDerivedDefinitions("Attr")) - for (const auto &S : GetFlattenedSpellings(*R)) - if (isRegularKeywordAttribute(S)) { - if (!R->getValueAsListOfDefs("Args").empty()) - PrintError(R->getLoc(), - "RegularKeyword attributes with arguments are not " - "yet supported"); + for (const auto &S : GetFlattenedSpellings(*R)) { + if (!isRegularKeywordAttribute(S)) + continue; + std::vector Args = R->getValueAsListOfDefs("Args"); + bool HasArgs = llvm::any_of(Args, [](const Record *Arg) { return !Arg->getValueAsBit("Fake"); }); OS << "KEYWORD_ATTRIBUTE(" - << S.getSpellingRecord().getValueAsString("Name") << ")\n"; + << S.getSpellingRecord().getValueAsString("Name") << ", " + << (HasArgs ? "true" : "false") << ", )\n"; } OS << "#undef KEYWORD_ATTRIBUTE\n"; } -- 2.30.2