[PATCH] D131007: [NFCI] Refactor how KeywordStatus is calculated

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 2 11:47:40 PDT 2022


erichkeane created this revision.
erichkeane added reviewers: aaron.ballman, tahonermann, shafik, Codesbyusman.
Herald added a project: All.
erichkeane requested review of this revision.

The getKeywordStatus function is a horrible mess of inter-dependent 'if'
 statements that depend significantly on the ORDER of the checks.  This
 patch removes the dependency on order by checking each set-flag only
 once.

It does this by looping through each of the set bits, and checks each
 individual flag for its effect, then combines them at the end.

This might slow down startup performance slightly, as there are only a
few hundred keywords, and a vast majority will only get checked 1x
still.

This patch ALSO removes the KEYWORD_CONCEPTS flag, because it has since
become synonymous with C++20.


https://reviews.llvm.org/D131007

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Basic/IdentifierTable.cpp
  clang/test/Lexer/keywords_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131007.449366.patch
Type: text/x-patch
Size: 12765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220802/94aee0a4/attachment-0001.bin>


More information about the cfe-commits mailing list