From ce8b743d59eff6ca590c428254d06a0da3754bbc Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 25 Aug 2016 22:11:01 +0000 Subject: [PATCH] Add a notification message in 'type lookup' when the current language doesn't yield results and one has to go across multiple languages to scan for types Fixes rdar://22422313 llvm-svn: 279784 --- lldb/source/Commands/CommandObjectType.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 36a1131..259e041 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -3427,6 +3427,7 @@ public: std::vector languages; bool is_global_search = false; + LanguageType guessed_language = lldb::eLanguageTypeUnknown; if ( (is_global_search = (m_command_options.m_language == eLanguageTypeUnknown)) ) { @@ -3443,23 +3444,25 @@ public: // so the cost of the sort is going to be dwarfed by the actual lookup anyway if (StackFrame* frame = m_exe_ctx.GetFramePtr()) { - LanguageType lang = GuessLanguage(frame); - if (lang != eLanguageTypeUnknown) + guessed_language = GuessLanguage(frame); + if (guessed_language != eLanguageTypeUnknown) { std::sort(languages.begin(), languages.end(), - [lang] (Language* lang1, - Language* lang2) -> bool { + [guessed_language] (Language* lang1, + Language* lang2) -> bool { if (!lang1 || !lang2) return false; LanguageType lt1 = lang1->GetLanguageType(); LanguageType lt2 = lang2->GetLanguageType(); - if (lt1 == lang) return true; // make the selected frame's language come first - if (lt2 == lang) return false; // make the selected frame's language come first + if (lt1 == guessed_language) return true; // make the selected frame's language come first + if (lt2 == guessed_language) return false; // make the selected frame's language come first return (lt1 < lt2); // normal comparison otherwise }); } } + bool is_first_language = true; + for (Language* language : languages) { if (!language) @@ -3479,9 +3482,16 @@ public: } } } - // this is "type lookup SomeName" and we did find a match, so get out - if (any_found && is_global_search) - break; + } + // this is "type lookup SomeName" and we did find a match, so get out + if (any_found && is_global_search) + break; + else if (is_first_language && is_global_search && guessed_language != lldb::eLanguageTypeUnknown) + { + is_first_language = false; + result.GetOutputStream().Printf("no type was found in the current language %s matching '%s'; performing a global search across all languages\n", + Language::GetNameForLanguageType(guessed_language), + name_of_type); } } -- 2.7.4