[PATCH] D121753: [clang-format] Use a macro for non-C keywords

sstwcw via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 16:25:49 PDT 2022


sstwcw added a comment.

Allow me another attempt in justifying this patch.

Using the macros, it is easier to see when a keyword is not classified as some language's keyword.  The author and reviewers didn't notice `final` and `dollar` being in only one place previously.  With the old way, when someone adds a new keyword he is also more likely to forget to include it in the sets.

In the commit message when I said the old way turned out to be error-prone, I did debug why some code doesn't get formatted right only to find I forgot to add a keyword in one of the places.

With the `isIdentifier` and `isKeyword` functions matching the sets separately, it is more likely one of them will get it wrong.  In the original `isCSharpKeyword` function, the check is wrong, it should be `!=`.

  CSharpExtraKeywords.find(Tok.Tok.getIdentifierInfo()) == CSharpExtraKeywords.end()


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