Skip to content

[Clang] Add missing macro undefs in AttributeSpellingList emitter #141090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions clang/lib/Basic/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions clang/utils/TableGen/ClangAttrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down