Author: Oleksandr T. Date: 2025-05-22T11:24:12-07:00 New Revision: 00f40e3c1ac3163dd92ed7f5a0779775ed190596
URL: https://github.com/llvm/llvm-project/commit/00f40e3c1ac3163dd92ed7f5a0779775ed190596 DIFF: https://github.com/llvm/llvm-project/commit/00f40e3c1ac3163dd92ed7f5a0779775ed190596.diff LOG: [Clang] Add missing macro undefs in AttributeSpellingList emitter (#141090) Fixes https://github.com/llvm/llvm-project/pull/140629#issuecomment-2901568992 --- This patch adds `#undef ATTR_NAME` and `#undef ATTR_SCOPE_NAME` to the end of the generated `AttributeSpellingList.inc` file to prevent macro redefinition warnings Added: Modified: clang/lib/Basic/Attributes.cpp clang/utils/TableGen/ClangAttrEmitter.cpp Removed: ################################################################################ diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp index c2f3120aed5d0..ebc86a5adf7a7 100644 --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -233,13 +233,11 @@ unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const { static constexpr const char *AttrSpellingList[] = { #include "clang/Basic/AttributeSpellingList.inc" }; -#undef ATTR_NAME -#define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME, +#define ATTR_SCOPE_NAME(SCOPE_NAME) SCOPE_NAME, static constexpr const char *AttrScopeSpellingList[] = { #include "clang/Basic/AttributeSpellingList.inc" }; -#undef ATTR_SCOPE_SCOPE std::optional<std::string> AttributeCommonInfo::getCorrectedFullName(const TargetInfo &Target, diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index f6c5c84602762..21d76c12a3cce 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -4146,14 +4146,18 @@ void EmitAttributeSpellingList(const RecordKeeper &Records, raw_ostream &OS) { OS << "ATTR_NAME(\"" << AttrName << "\")\n"; } OS << "\n"; + OS << "#undef ATTR_NAME" << "\n"; + OS << "\n"; - OS << "#ifndef ATTR_SCOPE_SCOPE" << "\n"; - OS << "#define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME" << "\n"; + OS << "#ifndef ATTR_SCOPE_NAME" << "\n"; + OS << "#define ATTR_SCOPE_NAME(SCOPE_NAME) SCOPE_NAME" << "\n"; OS << "#endif" << "\n" << "\n"; for (const auto &AttrScopeName : AttrScopeSpellingList) { - OS << "ATTR_SCOPE_SCOPE(\"" << AttrScopeName << "\")\n"; + OS << "ATTR_SCOPE_NAME(\"" << AttrScopeName << "\")\n"; } OS << "\n"; + OS << "#undef ATTR_SCOPE_NAME" << "\n"; + OS << "\n"; } static bool isArgVariadic(const Record &R, StringRef AttrName) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits