-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Refactor clang's keyword enable/disable mechanism to allow lldb to re-use it #165323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dsandersllvm
merged 4 commits into
llvm:main
from
dsandersllvm:lldb-parse-identifiers-keywords-clang-only
Nov 5, 2025
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8e0c1a7
[clang] Refactor clang's keyword enable/disable mechanism to allow ll…
dsandersllvm 2c7391f
fixup: formatting
dsandersllvm af4a46f
fixup: Move getKeywordStatus's comment to the header
dsandersllvm 6a80842
fixup: Restore comment for TokenKey
dsandersllvm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,57 +77,6 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts, | |
| // Language Keyword Implementation | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // Constants for TokenKinds.def | ||
| namespace { | ||
|
|
||
| enum TokenKey : unsigned { | ||
| KEYC99 = 0x1, | ||
| KEYCXX = 0x2, | ||
| KEYCXX11 = 0x4, | ||
| KEYGNU = 0x8, | ||
| KEYMS = 0x10, | ||
| BOOLSUPPORT = 0x20, | ||
| KEYALTIVEC = 0x40, | ||
| KEYNOCXX = 0x80, | ||
| KEYBORLAND = 0x100, | ||
| KEYOPENCLC = 0x200, | ||
| KEYC23 = 0x400, | ||
| KEYNOMS18 = 0x800, | ||
| KEYNOOPENCL = 0x1000, | ||
| WCHARSUPPORT = 0x2000, | ||
| HALFSUPPORT = 0x4000, | ||
| CHAR8SUPPORT = 0x8000, | ||
| KEYOBJC = 0x10000, | ||
| KEYZVECTOR = 0x20000, | ||
| KEYCOROUTINES = 0x40000, | ||
| KEYMODULES = 0x80000, | ||
| KEYCXX20 = 0x100000, | ||
| KEYOPENCLCXX = 0x200000, | ||
| KEYMSCOMPAT = 0x400000, | ||
| KEYSYCL = 0x800000, | ||
| KEYCUDA = 0x1000000, | ||
| KEYZOS = 0x2000000, | ||
| KEYNOZOS = 0x4000000, | ||
| KEYHLSL = 0x8000000, | ||
| KEYFIXEDPOINT = 0x10000000, | ||
| KEYMAX = KEYFIXEDPOINT, // The maximum key | ||
| KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20, | ||
| KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL & | ||
| ~KEYNOZOS // KEYNOMS18, KEYNOOPENCL, KEYNOZOS are excluded. | ||
| }; | ||
|
|
||
| /// How a keyword is treated in the selected standard. This enum is ordered | ||
| /// intentionally so that the value that 'wins' is the most 'permissive'. | ||
| enum KeywordStatus { | ||
| KS_Unknown, // Not yet calculated. Used when figuring out the status. | ||
| KS_Disabled, // Disabled | ||
| KS_Future, // Is a keyword in future standard | ||
| KS_Extension, // Is an extension | ||
| KS_Enabled, // Enabled | ||
| }; | ||
|
|
||
| } // namespace | ||
|
|
||
| // This works on a single TokenKey flag and checks the LangOpts to get the | ||
| // KeywordStatus based exclusively on this flag, so that it can be merged in | ||
| // getKeywordStatus. Most should be enabled/disabled, but some might imply | ||
|
|
@@ -222,7 +171,7 @@ static KeywordStatus getKeywordStatusHelper(const LangOptions &LangOpts, | |
|
|
||
| /// Translates flags as specified in TokenKinds.def into keyword status | ||
| /// in the given language standard. | ||
|
||
| static KeywordStatus getKeywordStatus(const LangOptions &LangOpts, | ||
| KeywordStatus clang::getKeywordStatus(const LangOptions &LangOpts, | ||
| unsigned Flags) { | ||
| // KEYALL means always enabled, so special case this one. | ||
| if (Flags == KEYALL) return KS_Enabled; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth retaining this comment? It gives us "some" indication that
TokenKinds.defand this enum are connected.,There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it used to be on the anonymous namespace for TokenKind and KeywordStatus, I've restored it on TokenKind only because KeywordStatus is only used by the code that uses TokenKinds.def not TokenKinds.def itself