[Lldb-commits] [lldb] r279784 - 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

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 25 15:11:01 PDT 2016


Author: enrico
Date: Thu Aug 25 17:11:01 2016
New Revision: 279784

URL: http://llvm.org/viewvc/llvm-project?rev=279784&view=rev
Log:
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


Modified:
    lldb/trunk/source/Commands/CommandObjectType.cpp

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=279784&r1=279783&r2=279784&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Aug 25 17:11:01 2016
@@ -3427,6 +3427,7 @@ public:
         std::vector<Language*> 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);
             }
         }
         




More information about the lldb-commits mailing list