// 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"
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"
);
}
// 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<Record *> 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";
}