Author: gclayton
Date: Fri Apr  1 17:57:22 2016
New Revision: 265196

URL: http://llvm.org/viewvc/llvm-project?rev=265196&view=rev
Log:
Fixed an issue where if we have DWARF in an executable that has multiple 
languages where these languages use different type systems, you can end up 
trying to find the actualy definition for a forward declaration for a type, you 
will call:

TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext (const 
DWARFDeclContext &dwarf_decl_ctx);

The problem was we might be looking for a type "Foo", and find one from another 
langauge. Then the DWARFASTParserClang would try to make an AST type using a 
CompilerType that might return an empty. 

This fix makes sure that when we create a DWARFDeclContext from a DWARFDIE that 
the DWARFDeclContext we set the language of the DIE. Then when we go to find 
matches for DWARFDeclContext, we end up with bunch of DIEs. We check each 
DWARFDIE that we found by asking it for its language and making sure the 
language is compatible with the type system that we want to use. This keeps us 
from using the wrong types to resolve forward declarations.

<rdar://problem/25276165>


Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=265196&r1=265195&r2=265196&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Fri Apr  1 17:57:22 
2016
@@ -298,6 +298,7 @@ DWARFDIE::GetDWARFDeclContext (DWARFDecl
 {
     if (IsValid())
     {
+        dwarf_decl_ctx.SetLanguage(GetLanguage());
         m_die->GetDWARFDeclContext (GetDWARF(), GetCU(), dwarf_decl_ctx);
     }
     else

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h?rev=265196&r1=265195&r2=265196&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h Fri Apr  1 
17:57:22 2016
@@ -64,7 +64,8 @@ public:
     };
 
     DWARFDeclContext () :
-        m_entries()
+        m_entries(),
+        m_language(lldb::eLanguageTypeUnknown)
     {
     }
 
@@ -115,10 +116,23 @@ public:
         m_qualified_name.clear();
     }
 
+    lldb::LanguageType
+    GetLanguage() const
+    {
+        return m_language;
+    }
+
+    void
+    SetLanguage(lldb::LanguageType language)
+    {
+        m_language = language;
+    }
+
 protected:
     typedef std::vector<Entry> collection;
     collection m_entries;
     mutable std::string m_qualified_name;
+    lldb::LanguageType m_language;
 };
 
 #endif  // SymbolFileDWARF_DWARFDeclContext_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=265196&r1=265195&r2=265196&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Apr  1 
17:57:22 2016
@@ -3698,8 +3698,12 @@ SymbolFileDWARF::FindDefinitionTypeForDW
             }
             
             const size_t num_matches = die_offsets.size();
-            
-            
+
+            // Get the type system that we are looking to find a type for. We 
will use this
+            // to ensure any matches we find are in a language that this type 
system supports
+            const LanguageType language = dwarf_decl_ctx.GetLanguage();
+            TypeSystem *type_system = (language == eLanguageTypeUnknown) ? 
nullptr : GetTypeSystemForLanguage(language);
+
             if (num_matches)
             {
                 for (size_t i=0; i<num_matches; ++i)
@@ -3709,6 +3713,11 @@ SymbolFileDWARF::FindDefinitionTypeForDW
                     
                     if (type_die)
                     {
+                        // Make sure type_die's langauge matches the type 
system we are looking for.
+                        // We don't want to find a "Foo" type from Java if we 
are looking for a "Foo"
+                        // type for C, C++, ObjC, or ObjC++.
+                        if (type_system && 
!type_system->SupportsLanguage(type_die.GetLanguage()))
+                            continue;
                         bool try_resolving_type = false;
                         
                         // Don't try and resolve the DIE we are looking for 
with the DIE itself!


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to