forked from OSchip/llvm-project
[lldb][NFC] Refactor ClangUserExpression::UpdateLanguageForExpr
The UpdateLanguageForExpr should only update the language, but over time it started to do also do different things related to the generation of the expression source code. This patch refactors all the source code generation part into its own function. llvm-svn: 367922
This commit is contained in:
parent
1707735fa4
commit
5eb87cf30f
|
@ -378,10 +378,21 @@ static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) {
|
|||
}
|
||||
}
|
||||
|
||||
void ClangUserExpression::UpdateLanguageForExpr(
|
||||
void ClangUserExpression::UpdateLanguageForExpr() {
|
||||
m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
|
||||
if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel)
|
||||
return;
|
||||
if (m_in_cplusplus_method)
|
||||
m_expr_lang = lldb::eLanguageTypeC_plus_plus;
|
||||
else if (m_in_objectivec_method)
|
||||
m_expr_lang = lldb::eLanguageTypeObjC;
|
||||
else
|
||||
m_expr_lang = lldb::eLanguageTypeC;
|
||||
}
|
||||
|
||||
void ClangUserExpression::CreateSourceCode(
|
||||
DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
|
||||
std::vector<std::string> modules_to_import, bool for_completion) {
|
||||
m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
|
||||
|
||||
std::string prefix = m_expr_prefix;
|
||||
|
||||
|
@ -392,13 +403,6 @@ void ClangUserExpression::UpdateLanguageForExpr(
|
|||
ClangExpressionSourceCode::CreateWrapped(prefix.c_str(),
|
||||
m_expr_text.c_str()));
|
||||
|
||||
if (m_in_cplusplus_method)
|
||||
m_expr_lang = lldb::eLanguageTypeC_plus_plus;
|
||||
else if (m_in_objectivec_method)
|
||||
m_expr_lang = lldb::eLanguageTypeObjC;
|
||||
else
|
||||
m_expr_lang = lldb::eLanguageTypeC;
|
||||
|
||||
if (!source_code->GetText(m_transformed_text, m_expr_lang,
|
||||
m_in_static_method, exe_ctx, !m_ctx_obj,
|
||||
for_completion, modules_to_import)) {
|
||||
|
@ -506,8 +510,8 @@ bool ClangUserExpression::PrepareForParsing(
|
|||
LLDB_LOG(log, "List of imported modules in expression: {0}",
|
||||
llvm::make_range(used_modules.begin(), used_modules.end()));
|
||||
|
||||
UpdateLanguageForExpr(diagnostic_manager, exe_ctx, used_modules,
|
||||
for_completion);
|
||||
UpdateLanguageForExpr();
|
||||
CreateSourceCode(diagnostic_manager, exe_ctx, used_modules, for_completion);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,10 +176,11 @@ private:
|
|||
DiagnosticManager &diagnostic_manager) override;
|
||||
|
||||
std::vector<std::string> GetModulesToImport(ExecutionContext &exe_ctx);
|
||||
void UpdateLanguageForExpr(DiagnosticManager &diagnostic_manager,
|
||||
void CreateSourceCode(DiagnosticManager &diagnostic_manager,
|
||||
ExecutionContext &exe_ctx,
|
||||
std::vector<std::string> modules_to_import,
|
||||
bool for_completion);
|
||||
void UpdateLanguageForExpr();
|
||||
bool SetupPersistentState(DiagnosticManager &diagnostic_manager,
|
||||
ExecutionContext &exe_ctx);
|
||||
bool PrepareForParsing(DiagnosticManager &diagnostic_manager,
|
||||
|
|
Loading…
Reference in New Issue