[Lldb-commits] [lldb] 96d814a - [lldb] Remove ClangExpressionDeclMap::ResolveUnknownTypes
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 19 03:45:01 PST 2019
Author: Raphael Isemann
Date: 2019-11-19T12:44:27+01:00
New Revision: 96d814a5fe0a333bc53f52e8f290d1ac009c85fe
URL: https://github.com/llvm/llvm-project/commit/96d814a5fe0a333bc53f52e8f290d1ac009c85fe
DIFF: https://github.com/llvm/llvm-project/commit/96d814a5fe0a333bc53f52e8f290d1ac009c85fe.diff
LOG: [lldb] Remove ClangExpressionDeclMap::ResolveUnknownTypes
Summary:
This is some really shady code. It's supposed to kick in after an expression already failed and then try to look
up "unknown types" that for some undocumented reason can't be resolved during/before parsing. Beside the
fact that we never mark any type as `EVUnknownType` in either swift-lldb or lldb (which means this code is unreachable),
this code doesn't even make the expression evaluation succeed if if would ever be executed but instead seems
to try to load more debug info that maybe any following expression evaluations might succeed.
This patch removes ClangExpressionDeclMap::ResolveUnknownTypes and the related data structures/checks/calls.
Reviewers: davide
Reviewed By: davide
Subscribers: aprantl, abidh, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70388
Added:
Modified:
lldb/include/lldb/Expression/ExpressionVariable.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h
index 08c987270bfe..c20c2301bb54 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -98,9 +98,7 @@ class ExpressionVariable
EVTypeIsReference = 1 << 6, ///< The original type of this variable is a
///reference, so materialize the value rather
///than the location
- EVUnknownType = 1 << 7, ///< This is a symbol of unknown type, and the type
- ///must be resolved after parsing is complete
- EVBareRegister = 1 << 8 ///< This variable is a direct reference to $pc or
+ EVBareRegister = 1 << 7 ///< This variable is a direct reference to $pc or
///some other entity.
};
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index f4457fc1b740..35a50c8fed16 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1769,80 +1769,6 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
}
}
-bool ClangExpressionDeclMap::ResolveUnknownTypes() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
-
- ClangASTContextForExpressions *scratch_ast_context =
- static_cast<ClangASTContextForExpressions *>(
- target->GetScratchClangASTContext());
-
- for (size_t index = 0, num_entities = m_found_entities.GetSize();
- index < num_entities; ++index) {
- ExpressionVariableSP entity = m_found_entities.GetVariableAtIndex(index);
-
- ClangExpressionVariable::ParserVars *parser_vars =
- llvm::cast<ClangExpressionVariable>(entity.get())
- ->GetParserVars(GetParserID());
-
- if (entity->m_flags & ClangExpressionVariable::EVUnknownType) {
- const NamedDecl *named_decl = parser_vars->m_named_decl;
- const VarDecl *var_decl = dyn_cast<VarDecl>(named_decl);
-
- if (!var_decl) {
- LLDB_LOGF(log, "Entity of unknown type does not have a VarDecl");
- return false;
- }
-
- if (log) {
- ASTDumper ast_dumper(const_cast<VarDecl *>(var_decl));
- LLDB_LOGF(log, "Variable of unknown type now has Decl %s",
- ast_dumper.GetCString());
- }
-
- QualType var_type = var_decl->getType();
- TypeFromParser parser_type(
- var_type.getAsOpaquePtr(),
- ClangASTContext::GetASTContext(&var_decl->getASTContext()));
-
- lldb::opaque_compiler_type_t copied_type = nullptr;
- if (m_ast_importer_sp) {
- copied_type = m_ast_importer_sp->CopyType(
- scratch_ast_context->getASTContext(), &var_decl->getASTContext(),
- var_type.getAsOpaquePtr());
- } else if (HasMerger()) {
- copied_type = CopyTypeWithMerger(
- var_decl->getASTContext(),
- scratch_ast_context->GetMergerUnchecked(), var_type)
- .getAsOpaquePtr();
- } else {
- lldbassert(0 && "No mechanism to copy a resolved unknown type!");
- return false;
- }
-
- if (!copied_type) {
- LLDB_LOGF(log, "ClangExpressionDeclMap::ResolveUnknownType - Couldn't "
- "import the type for a variable");
-
- return (bool)lldb::ExpressionVariableSP();
- }
-
- TypeFromUser user_type(copied_type, scratch_ast_context);
-
- // parser_vars->m_lldb_value.SetContext(Value::eContextTypeClangType,
- // user_type.GetOpaqueQualType());
- parser_vars->m_lldb_value.SetCompilerType(user_type);
- parser_vars->m_parser_type = parser_type;
-
- entity->SetCompilerType(user_type);
-
- entity->m_flags &= ~(ClangExpressionVariable::EVUnknownType);
- }
- }
-
- return true;
-}
-
void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
const RegisterInfo *reg_info,
unsigned int current_id) {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 152549f8dd56..060067c35725 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -98,13 +98,6 @@ class ClangExpressionDeclMap : public ClangASTSource {
void InstallCodeGenerator(clang::ASTConsumer *code_gen);
- /// [Used by ClangExpressionParser] For each variable that had an unknown
- /// type at the beginning of parsing, determine its final type now.
- ///
- /// \return
- /// True on success; false otherwise.
- bool ResolveUnknownTypes();
-
/// Disable the state needed for parsing and IR transformation.
void DidParse();
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 73d1e9023b5f..664938c9613e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1033,15 +1033,6 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
m_pp_callbacks->getErrorString());
}
- if (!num_errors) {
- if (type_system_helper->DeclMap() &&
- !type_system_helper->DeclMap()->ResolveUnknownTypes()) {
- diagnostic_manager.Printf(eDiagnosticSeverityError,
- "Couldn't infer the type of a variable");
- num_errors++;
- }
- }
-
if (!num_errors) {
type_system_helper->CommitPersistentDecls();
}
More information about the lldb-commits
mailing list