Skip to content

Commit 00f40e3

Browse files
authored
[Clang] Add missing macro undefs in AttributeSpellingList emitter (#141090)
Fixes #140629 (comment) --- 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
1 parent f07fc38 commit 00f40e3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

clang/lib/Basic/Attributes.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,11 @@ unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
233233
static constexpr const char *AttrSpellingList[] = {
234234
#include "clang/Basic/AttributeSpellingList.inc"
235235
};
236-
#undef ATTR_NAME
237236

238-
#define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME,
237+
#define ATTR_SCOPE_NAME(SCOPE_NAME) SCOPE_NAME,
239238
static constexpr const char *AttrScopeSpellingList[] = {
240239
#include "clang/Basic/AttributeSpellingList.inc"
241240
};
242-
#undef ATTR_SCOPE_SCOPE
243241

244242
std::optional<std::string>
245243
AttributeCommonInfo::getCorrectedFullName(const TargetInfo &Target,

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,14 +4146,18 @@ void EmitAttributeSpellingList(const RecordKeeper &Records, raw_ostream &OS) {
41464146
OS << "ATTR_NAME(\"" << AttrName << "\")\n";
41474147
}
41484148
OS << "\n";
4149+
OS << "#undef ATTR_NAME" << "\n";
4150+
OS << "\n";
41494151

4150-
OS << "#ifndef ATTR_SCOPE_SCOPE" << "\n";
4151-
OS << "#define ATTR_SCOPE_SCOPE(SCOPE_NAME) SCOPE_NAME" << "\n";
4152+
OS << "#ifndef ATTR_SCOPE_NAME" << "\n";
4153+
OS << "#define ATTR_SCOPE_NAME(SCOPE_NAME) SCOPE_NAME" << "\n";
41524154
OS << "#endif" << "\n" << "\n";
41534155
for (const auto &AttrScopeName : AttrScopeSpellingList) {
4154-
OS << "ATTR_SCOPE_SCOPE(\"" << AttrScopeName << "\")\n";
4156+
OS << "ATTR_SCOPE_NAME(\"" << AttrScopeName << "\")\n";
41554157
}
41564158
OS << "\n";
4159+
OS << "#undef ATTR_SCOPE_NAME" << "\n";
4160+
OS << "\n";
41574161
}
41584162

41594163
static bool isArgVariadic(const Record &R, StringRef AttrName) {

0 commit comments

Comments
 (0)