Skip to content

Commit 6476c97

Browse files
committed
Merge commit '9b1719efa063' from llvm.org/main into next
2 parents 9cff7e6 + 9b1719e commit 6476c97

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

lldb/include/lldb/lldb-private-types.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,18 @@ struct RegisterSet {
102102
/// A type-erased pair of llvm::dwarf::SourceLanguageName and version.
103103
struct SourceLanguage {
104104
SourceLanguage() = default;
105-
SourceLanguage(lldb::LanguageType language_type);
105+
explicit SourceLanguage(lldb::LanguageType language_type);
106+
106107
SourceLanguage(uint16_t name, uint32_t version)
107108
: name(name), version(version) {}
108-
SourceLanguage(std::optional<std::pair<uint16_t, uint32_t>> name_vers)
109+
110+
explicit SourceLanguage(
111+
std::optional<std::pair<uint16_t, uint32_t>> name_vers)
109112
: name(name_vers ? name_vers->first : 0),
110113
version(name_vers ? name_vers->second : 0) {}
111-
operator bool() const { return name > 0; }
114+
115+
explicit operator bool() const { return name > 0; }
116+
112117
lldb::LanguageType AsLanguageType() const;
113118
llvm::StringRef GetDescription() const;
114119
bool IsC() const;

lldb/source/Breakpoint/BreakpointLocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
251251
}
252252

253253
m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
254-
condition.GetText(), llvm::StringRef(), language,
254+
condition.GetText(), llvm::StringRef(), SourceLanguage{language},
255255
Expression::eResultTypeAny, EvaluateExpressionOptions(), nullptr,
256256
error));
257257
if (error.Fail()) {

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
9797
StackFrame *frame = m_exe_ctx.GetFramePtr();
9898

9999
// Either the language was explicitly specified, or we check the frame.
100-
lldb::LanguageType language = m_expr_options.language;
101-
if (language == lldb::eLanguageTypeUnknown && frame)
102-
language = frame->GuessLanguage().AsLanguageType();
100+
SourceLanguage language{m_expr_options.language};
101+
if (!language && frame)
102+
language = frame->GuessLanguage();
103103

104104
// Add a hint if object description was requested, but no description
105105
// function was implemented.
@@ -121,8 +121,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
121121
"^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
122122

123123
if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
124-
(language == lldb::eLanguageTypeSwift ||
125-
language == lldb::eLanguageTypeObjC) &&
124+
(language.AsLanguageType() == lldb::eLanguageTypeSwift ||
125+
language.IsObjC()) &&
126126
std::regex_match(output.data(), swift_class_regex)) {
127127

128128
result.AppendNote(
@@ -232,7 +232,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
232232

233233
// Second, try `expr` as a persistent variable.
234234
if (expr.starts_with("$"))
235-
if (auto *state = target.GetPersistentExpressionStateForLanguage(language))
235+
if (auto *state = target.GetPersistentExpressionStateForLanguage(
236+
language.AsLanguageType()))
236237
if (auto var_sp = state->GetVariable(expr))
237238
if (auto valobj_sp = var_sp->GetValueObject()) {
238239
dump_val_object(*valobj_sp);

lldb/source/Expression/UserExpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
246246
// language in the target's properties if specified, else default to the
247247
// langage for the frame.
248248
if (!language) {
249-
if (target->GetLanguage() != lldb::eLanguageTypeUnknown)
249+
if (target->GetLanguage())
250250
language = target->GetLanguage();
251251
else if (StackFrame *frame = exe_ctx.GetFramePtr())
252252
language = frame->GetLanguage();

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ lldb_private::Status ClangExpressionParser::DoPrepareForExecution(
15021502
LLDB_LOGF(log, "%s - Current expression language is %s\n", __FUNCTION__,
15031503
lang.GetDescription().data());
15041504
lldb::ProcessSP process_sp = exe_ctx.GetProcessSP();
1505-
if (process_sp && lang != lldb::eLanguageTypeUnknown) {
1505+
if (process_sp && lang) {
15061506
auto runtime = process_sp->GetLanguageRuntime(lang.AsLanguageType());
15071507
if (runtime)
15081508
runtime->GetIRPasses(custom_passes);

lldb/source/Target/StackFrame.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,18 +1405,18 @@ const char *StackFrame::GetDisplayFunctionName() {
14051405
SourceLanguage StackFrame::GetLanguage() {
14061406
CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
14071407
if (cu)
1408-
return cu->GetLanguage();
1408+
return SourceLanguage{cu->GetLanguage()};
14091409
return {};
14101410
}
14111411

14121412
SourceLanguage StackFrame::GuessLanguage() {
14131413
SourceLanguage lang_type = GetLanguage();
14141414

1415-
if (lang_type == eLanguageTypeUnknown) {
1415+
if (!lang_type) {
14161416
SymbolContext sc =
14171417
GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol);
14181418
if (sc.function)
1419-
lang_type = LanguageType(sc.function->GetMangled().GuessLanguage());
1419+
lang_type = SourceLanguage(sc.function->GetMangled().GuessLanguage());
14201420
else if (sc.symbol)
14211421
lang_type = SourceLanguage(sc.symbol->GetMangled().GuessLanguage());
14221422
}

lldb/source/Target/Target.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5228,7 +5228,7 @@ void TargetProperties::SetStandardErrorPath(llvm::StringRef path) {
52285228

52295229
SourceLanguage TargetProperties::GetLanguage() const {
52305230
const uint32_t idx = ePropertyLanguage;
5231-
return {GetPropertyAtIndexAs<LanguageType>(idx, {})};
5231+
return SourceLanguage{GetPropertyAtIndexAs<LanguageType>(idx, {})};
52325232
}
52335233

52345234
llvm::StringRef TargetProperties::GetExpressionPrefixContents() {

0 commit comments

Comments
 (0)