static void PrintAllLanguages(Stream &s, const char *prefix,
const char *suffix);
+ /// Prints to the specified stream 's' each language type that the
+ /// current target supports for expression evaluation.
+ ///
+ /// \param[out] s Stream to which the language types are written.
+ /// \param[in] prefix String that is prepended to the language type.
+ /// \param[in] suffix String that is appended to the language type.
+ static void PrintSupportedLanguagesForExpressions(Stream &s,
+ llvm::StringRef prefix,
+ llvm::StringRef suffix);
+
// return false from callback to stop iterating
static void ForAllLanguages(std::function<bool(lldb::LanguageType)> callback);
switch (short_option) {
case 'l':
language = Language::GetLanguageTypeFromString(option_arg);
- if (language == eLanguageTypeUnknown)
- error.SetErrorStringWithFormat(
- "unknown language type: '%s' for expression",
- option_arg.str().c_str());
+ if (language == eLanguageTypeUnknown) {
+ StreamString sstr;
+ sstr.Printf("unknown language type: '%s' for expression. "
+ "List of supported languages:\n",
+ option_arg.str().c_str());
+
+ Language::PrintSupportedLanguagesForExpressions(sstr, " ", "\n");
+ error.SetErrorString(sstr.GetString());
+ }
break;
case 'a': {
return language_names[eLanguageTypeUnknown].name;
}
+void Language::PrintSupportedLanguagesForExpressions(Stream &s,
+ llvm::StringRef prefix,
+ llvm::StringRef suffix) {
+ auto supported = Language::GetLanguagesSupportingTypeSystemsForExpressions();
+ for (size_t idx = 0; idx < num_languages; ++idx) {
+ auto const &lang = language_names[idx];
+ if (supported[lang.type])
+ s << prefix << lang.name << suffix;
+ }
+}
+
void Language::PrintAllLanguages(Stream &s, const char *prefix,
const char *suffix) {
for (uint32_t i = 1; i < num_languages; i++) {
@no_debug_info_test
def test_invalid_lang(self):
self.expect("expression -l foo --", error=True,
- substrs=["error: unknown language type: 'foo' for expression"])
+ substrs=["error: unknown language type: 'foo' for expression",
+ "List of supported languages:",
+ "c++", "c++11", "c++14"])
@no_debug_info_test
def test_invalid_all_thread(self):