-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb] Re-use clang's keyword enable/disable mechanism in CPlusPlusNameParser.cpp #164284
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
e1175e6
0275d00
f221e49
7af1e87
e03585e
8e0c1a7
2c7391f
af4a46f
6a80842
b836bc6
3acac96
72e9d76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -719,9 +719,8 @@ CPlusPlusNameParser::ParseFullNameImpl() { | |
| } | ||
| start_position.Remove(); | ||
| return result; | ||
| } else { | ||
| return std::nullopt; | ||
| } | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| llvm::StringRef CPlusPlusNameParser::GetTextForRange(const Range &range) { | ||
|
|
@@ -755,12 +754,19 @@ static const clang::LangOptions &GetLangOptions() { | |
| return g_options; | ||
| } | ||
|
|
||
| static const llvm::StringMap<tok::TokenKind> &GetKeywordsMap() { | ||
| static llvm::StringMap<tok::TokenKind> g_map{ | ||
| #define KEYWORD(Name, Flags) {llvm::StringRef(#Name), tok::kw_##Name}, | ||
| static const llvm::StringMap<tok::TokenKind> GetKeywordsMap() { | ||
| using namespace clang; | ||
| llvm::StringMap<tok::TokenKind> g_map; | ||
|
|
||
| auto LangOpts = GetLangOptions(); | ||
|
|
||
| KeywordStatus AddResult; | ||
| #define KEYWORD(NAME, FLAGS) \ | ||
| AddResult = getKeywordStatus(LangOpts, FLAGS); \ | ||
| if (AddResult != KS_Disabled) \ | ||
| g_map[llvm::StringRef(#NAME)] = tok::kw_##NAME; | ||
| #include "clang/Basic/TokenKinds.def" | ||
| #undef KEYWORD | ||
| }; | ||
| return g_map; | ||
| } | ||
|
|
||
|
|
@@ -769,7 +775,7 @@ void CPlusPlusNameParser::ExtractTokens() { | |
| return; | ||
| clang::Lexer lexer(clang::SourceLocation(), GetLangOptions(), m_text.data(), | ||
| m_text.data(), m_text.data() + m_text.size()); | ||
| const auto &kw_map = GetKeywordsMap(); | ||
| const auto kw_map = GetKeywordsMap(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit unfortunate we have to reconstruct this Why can't we construct the map statically? The
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll see if I can measure it. I doubt it's noticeable for interactive use but it might add up in scripts
At the moment they don't but I think that's a bug so I didn't add the call_once wrapper to it. I think they ought to depend on the active stack frame. For example: Along the same lines, if you have a C++20 frame call an OpenCL frame, this (admittedly contrived) example |
||
| clang::Token token; | ||
| for (lexer.LexFromRawLexer(token); !token.is(clang::tok::eof); | ||
| lexer.LexFromRawLexer(token)) { | ||
|
|
||
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.
very minor nit, but could we move this
using namespacedown to just before the macro. Just so it gives the reader some indication that we may be using it for theincludemachineryThere 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.
Done