Skip to content
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
11 changes: 8 additions & 3 deletions lldb/include/lldb/lldb-private-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,18 @@ struct RegisterSet {
/// A type-erased pair of llvm::dwarf::SourceLanguageName and version.
struct SourceLanguage {
SourceLanguage() = default;
SourceLanguage(lldb::LanguageType language_type);
explicit SourceLanguage(lldb::LanguageType language_type);

SourceLanguage(uint16_t name, uint32_t version)
: name(name), version(version) {}
SourceLanguage(std::optional<std::pair<uint16_t, uint32_t>> name_vers)

explicit SourceLanguage(
std::optional<std::pair<uint16_t, uint32_t>> name_vers)
: name(name_vers ? name_vers->first : 0),
version(name_vers ? name_vers->second : 0) {}
operator bool() const { return name > 0; }

explicit operator bool() const { return name > 0; }

lldb::LanguageType AsLanguageType() const;
llvm::StringRef GetDescription() const;
bool IsC() const;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Breakpoint/BreakpointLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
}

m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
condition.GetText(), llvm::StringRef(), language,
condition.GetText(), llvm::StringRef(), SourceLanguage{language},
Expression::eResultTypeAny, EvaluateExpressionOptions(), nullptr,
error));
if (error.Fail()) {
Expand Down
13 changes: 7 additions & 6 deletions lldb/source/Commands/CommandObjectDWIMPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
StackFrame *frame = m_exe_ctx.GetFramePtr();

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

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

if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
(language == lldb::eLanguageTypeSwift ||
language == lldb::eLanguageTypeObjC) &&
(language.AsLanguageType() == lldb::eLanguageTypeSwift ||
language.IsObjC()) &&
std::regex_match(output.data(), swift_class_regex)) {

result.AppendNote(
Expand Down Expand Up @@ -193,7 +193,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,

// Second, try `expr` as a persistent variable.
if (expr.starts_with("$"))
if (auto *state = target.GetPersistentExpressionStateForLanguage(language))
if (auto *state = target.GetPersistentExpressionStateForLanguage(
language.AsLanguageType()))
if (auto var_sp = state->GetVariable(expr))
if (auto valobj_sp = var_sp->GetValueObject()) {
dump_val_object(*valobj_sp);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Expression/UserExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ UserExpression::Evaluate(ExecutionContext &exe_ctx,
// language in the target's properties if specified, else default to the
// langage for the frame.
if (!language) {
if (target->GetLanguage() != lldb::eLanguageTypeUnknown)
if (target->GetLanguage())
language = target->GetLanguage();
else if (StackFrame *frame = exe_ctx.GetFramePtr())
language = frame->GetLanguage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ lldb_private::Status ClangExpressionParser::DoPrepareForExecution(
LLDB_LOGF(log, "%s - Current expression language is %s\n", __FUNCTION__,
lang.GetDescription().data());
lldb::ProcessSP process_sp = exe_ctx.GetProcessSP();
if (process_sp && lang != lldb::eLanguageTypeUnknown) {
if (process_sp && lang) {
auto runtime = process_sp->GetLanguageRuntime(lang.AsLanguageType());
if (runtime)
runtime->GetIRPasses(custom_passes);
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Target/StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,18 +1344,18 @@ const char *StackFrame::GetDisplayFunctionName() {
SourceLanguage StackFrame::GetLanguage() {
CompileUnit *cu = GetSymbolContext(eSymbolContextCompUnit).comp_unit;
if (cu)
return cu->GetLanguage();
return SourceLanguage{cu->GetLanguage()};
return {};
}

SourceLanguage StackFrame::GuessLanguage() {
SourceLanguage lang_type = GetLanguage();

if (lang_type == eLanguageTypeUnknown) {
if (!lang_type) {
SymbolContext sc =
GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol);
if (sc.function)
lang_type = LanguageType(sc.function->GetMangled().GuessLanguage());
lang_type = SourceLanguage(sc.function->GetMangled().GuessLanguage());
else if (sc.symbol)
lang_type = SourceLanguage(sc.symbol->GetMangled().GuessLanguage());
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4945,7 +4945,7 @@ void TargetProperties::SetStandardErrorPath(llvm::StringRef path) {

SourceLanguage TargetProperties::GetLanguage() const {
const uint32_t idx = ePropertyLanguage;
return {GetPropertyAtIndexAs<LanguageType>(idx, {})};
return SourceLanguage{GetPropertyAtIndexAs<LanguageType>(idx, {})};
}

llvm::StringRef TargetProperties::GetExpressionPrefixContents() {
Expand Down
Loading