[PATCH] D121753: [clang-format] Use a macro for non-C keywords
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 17 12:59:54 PDT 2022
HazardyKnusperkeks added inline comments.
================
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;
----------------
sstwcw wrote:
> 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`.
You can always drop the `class` and are back at integers.
================
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:
> sstwcw wrote:
> > 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`.
> You can always drop the `class` and are back at integers.
> With the current enum, the DEFINE_LIKE_NAMES can't be used directly outside `AdditionalKeywords`.
This one I don't understand? They are public and can be used, can't they? And the type I can get with `decltype`.
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