[PATCH] D121753: [clang-format] Use a macro for non-C keywords
sstwcw via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 16 20:09:04 PDT 2022
sstwcw marked 5 inline comments as done.
sstwcw added inline comments.
================
Comment at: clang/lib/Format/FormatToken.h:947
+ /* C# */ \
+ KEYWORD(dollar, 0) \
+ KEYWORD(base, ATTR_CSHARP_KEYWORD) \
----------------
HazardyKnusperkeks wrote:
> Why not CSharp?
It was not in the original set for C# keywords. But since MyDeveloperDay also pointed it out I guess he simply forgot.
================
Comment at: clang/lib/Format/FormatToken.h:992-999
+ enum {
+ ATTR_JS_KEYWORD = 0x1,
+ ATTR_CSHARP_KEYWORD = 0x2,
+ };
+ unsigned getAttrs(const FormatToken &Tok) const {
+ auto At = KeywordAttr.find(Tok.Tok.getIdentifierInfo());
+ return At == KeywordAttr.end() ? 0u : At->second;
----------------
HazardyKnusperkeks wrote:
> No fan of DEFINE_LIKE_NAMES. More a fan of scoped::enums. ;)
It looks like I would have to use the `KeywordLanguage::` prefix throughout the macro list and also define an operator to combine categories for keywords that several languages have. Do you know of a simpler way? With the current enum, the DEFINE_LIKE_NAMES can't be used directly outside `AdditionalKeywords`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121753/new/
https://reviews.llvm.org/D121753
More information about the cfe-commits
mailing list