Skip to content
Closed
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
26 changes: 17 additions & 9 deletions lldb/source/Commands/CommandObjectExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,26 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue(
const int short_option = GetDefinitions()[option_idx].short_option;

switch (short_option) {
case 'l':
case 'l': {
language = Language::GetLanguageTypeFromString(option_arg);
if (language == eLanguageTypeUnknown) {
StreamString sstr;
sstr.Printf("unknown language type: '%s' for expression. "
"List of supported languages:\n",
if (const LanguageSet supported_languages =
Language::GetLanguagesSupportingTypeSystemsForExpressions();
supported_languages[language])
break;

StreamString sstr;
if (language == eLanguageTypeUnknown)
sstr.Printf("unknown language '%s' for expression. ",
option_arg.str().c_str());
else
sstr.Printf("language '%s' is currently not supported for expression "
"evaluation. ",
option_arg.str().c_str());

Language::PrintSupportedLanguagesForExpressions(sstr, " ", "\n");
error = Status(sstr.GetString().str());
}
break;
sstr.PutCString("List of supported languages for expressions:\n");
Language::PrintSupportedLanguagesForExpressions(sstr, " ", "\n");
error = Status(sstr.GetString().str());
} break;

case 'a': {
bool success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test__calculator_mode(self):
)
# Now try it with a specific language:
self.expect(
"expression -l c -- 11 + 22",
"expression -l c++ -- 11 + 22",
"11 + 22 didn't get the expected result",
substrs=["33"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@ def test_invalid_lang(self):
"expression -l foo --",
error=True,
substrs=[
"error: unknown language type: 'foo' for expression",
"List of supported languages:",
"error: unknown language 'foo' for expression.",
"List of supported languages for expressions:",
"c++",
"c++11",
"c++14",
],
)

self.expect(
"expression -l c --",
error=True,
substrs=[
"error: language 'c' is currently not supported for expression evaluation.",
"List of supported languages for expressions:",
"c++",
"c++11",
"c++14",
Expand Down
Loading