[Lldb-commits] [lldb] r269095 - In some cases, type lookup has to deal with situations where it cannot reconstruct a compile unit or a function, but it still has a valid symbol - and it can use that in order to figure out the preferential language for lookups

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Tue May 10 11:16:33 PDT 2016


Author: enrico
Date: Tue May 10 13:16:33 2016
New Revision: 269095

URL: http://llvm.org/viewvc/llvm-project?rev=269095&view=rev
Log:
In some cases, type lookup has to deal with situations where it cannot reconstruct a compile unit or a function, but it still has a valid symbol - and it can use that in order to figure out the preferential language for lookups

This is not the right thing for all clients (notably the expression parser), so put it in type lookup specific code

Fixes rdar://problem/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=269095&r1=269094&r2=269095&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue May 10 13:16:33 2016
@@ -34,6 +34,7 @@
 #include "lldb/Interpreter/OptionValueBoolean.h"
 #include "lldb/Interpreter/OptionValueLanguage.h"
 #include "lldb/Interpreter/OptionValueString.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/StackFrame.h"
@@ -3209,6 +3210,27 @@ CommandObjectTypeFilterAdd::CommandOptio
 class CommandObjectTypeLookup : public CommandObjectRaw
 {
 protected:
+    // this function is allowed to do a more aggressive job at guessing languages than the expression parser
+    // is comfortable with - so leave the original call alone and add one that is specific to type lookup
+    lldb::LanguageType
+    GuessLanguage (StackFrame *frame)
+    {
+        lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown;
+
+        if (!frame)
+            return lang_type;
+        
+        lang_type = frame->GuessLanguage();
+        if (lang_type != lldb::eLanguageTypeUnknown)
+            return lang_type;
+        
+        Symbol *s = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
+        if (s)
+            lang_type = s->GetMangled().GuessLanguage();
+
+        return lang_type;
+    }
+    
     class CommandOptions : public OptionGroup
     {
     public:
@@ -3403,7 +3425,7 @@ 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 = frame->GuessLanguage();
+            LanguageType lang = GuessLanguage(frame);
             if (lang != eLanguageTypeUnknown)
             {
                 std::sort(languages.begin(),




More information about the lldb-commits mailing list