Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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: 7 additions & 4 deletions lldb/source/Commands/CommandObjectExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,21 @@ 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) {

if (const LanguageSet supported_languages =
Language::GetLanguagesSupportingTypeSystemsForExpressions();
!supported_languages[language]) {
StreamString sstr;
sstr.Printf("unknown language type: '%s' for expression. "
sstr.Printf("invalid language '%s' for expression. "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to clarify what invalid means in this context?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in latest commit

"List of supported languages:\n",
option_arg.str().c_str());

Language::PrintSupportedLanguagesForExpressions(sstr, " ", "\n");
error = Status(sstr.GetString().str());
}
break;
} 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,7 +10,19 @@ def test_invalid_lang(self):
"expression -l foo --",
error=True,
substrs=[
"error: unknown language type: 'foo' for expression",
"error: invalid language 'foo' for expression.",
"List of supported languages:",
"c++",
"c++11",
"c++14",
],
)

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