Skip to content

[lldb] Avoid enum as unordered_map key in TypeSystemClang #2228

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9695,14 +9695,15 @@ GetSpecializedASTName(ScratchTypeSystemClang::IsolatedASTKind feature) {
}

TypeSystemClang &ScratchTypeSystemClang::GetIsolatedAST(
ScratchTypeSystemClang::IsolatedASTKind feature) {
ScratchTypeSystemClang::IsolatedASTKind feature_enum) {
int feature = static_cast<int>(feature_enum);
auto found_ast = m_isolated_asts.find(feature);
if (found_ast != m_isolated_asts.end())
return *found_ast->second;

// Couldn't find the requested sub-AST, so create it now.
std::unique_ptr<TypeSystemClang> new_ast;
new_ast.reset(new SpecializedScratchAST(GetSpecializedASTName(feature),
new_ast.reset(new SpecializedScratchAST(GetSpecializedASTName(feature_enum),
m_triple, CreateASTSource()));
m_isolated_asts[feature] = std::move(new_ast);
return *m_isolated_asts[feature];
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ class ScratchTypeSystemClang : public TypeSystemClang {
/// Map from IsolatedASTKind to their actual TypeSystemClang instance.
/// This map is lazily filled with sub-ASTs and should be accessed via
/// `GetSubAST` (which lazily fills this map).
std::unordered_map<IsolatedASTKind, std::unique_ptr<TypeSystemClang>>
std::unordered_map<int, std::unique_ptr<TypeSystemClang>>
m_isolated_asts;
};

Expand Down