[Lldb-commits] [lldb] r249864 - Don't blindly use C for eLanguageTypeUnknown when getting a scratch TypeSystem.

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 9 11:01:10 PDT 2015


Author: spyffe
Date: Fri Oct  9 13:01:10 2015
New Revision: 249864

URL: http://llvm.org/viewvc/llvm-project?rev=249864&view=rev
Log:
Don't blindly use C for eLanguageTypeUnknown when getting a scratch TypeSystem.
Instead check what languages are supported for expressions; use C if available,
but otherwise pick one of the supported languages.
This can be overridden using the target settings.

<rdar://problem/22290878>

Modified:
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=249864&r1=249863&r2=249864&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Oct  9 13:01:10 2015
@@ -1901,7 +1901,26 @@ Target::GetScratchTypeSystemForLanguage
     if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all assembly code
         || language == eLanguageTypeUnknown)
     {
-        language = eLanguageTypeC;
+        std::set<lldb::LanguageType> languages_for_types;
+        std::set<lldb::LanguageType> languages_for_expressions;
+        
+        Language::GetLanguagesSupportingTypeSystems(languages_for_types, languages_for_expressions);
+        
+        if (languages_for_expressions.count(eLanguageTypeC))
+        {
+            language = eLanguageTypeC; // LLDB's default.  Override by setting the target language.
+        }
+        else
+        {
+            if (languages_for_expressions.empty())
+            {
+                return nullptr;
+            }
+            else
+            {
+                language = *languages_for_expressions.begin();
+            }
+        }
     }
 
     return m_scratch_type_system_map.GetTypeSystemForLanguage(language, this, create_on_demand);




More information about the lldb-commits mailing list