Removed the m_decl_objects map from ClangASTContext.

m_decl_objects is problematic because it assumes that each VarDecl has a unique
variable associated with it.  This is not the case in inline contexts.

Also the information in this map can be reconstructed very easily without
maintaining the map.  The rest of the testsuite passes with this cange, and I've
added a testcase covering the inline contexts affected by this.

<rdar://problem/26278502>

llvm-svn: 270474
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 593440c..e1d012b 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -557,12 +557,6 @@
     //----------------------------------------------------------------------
     // CompilerDecl override functions
     //----------------------------------------------------------------------
-    lldb::VariableSP
-    DeclGetVariable (void *opaque_decl) override;
-
-    void
-    DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override;
-    
     ConstString
     DeclGetName (void *opaque_decl) override;
 
@@ -1218,7 +1212,6 @@
     uint32_t                                        m_pointer_byte_size;
     bool                                            m_ast_owned;
     bool                                            m_can_evaluate_expressions;
-    std::map<void *, std::shared_ptr<void>>         m_decl_objects;
     // clang-format on
 private:
     //------------------------------------------------------------------
diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h b/lldb/include/lldb/Symbol/CompilerDecl.h
index b749e79..19654ab 100644
--- a/lldb/include/lldb/Symbol/CompilerDecl.h
+++ b/lldb/include/lldb/Symbol/CompilerDecl.h
@@ -65,12 +65,6 @@
     IsClang () const;
 
     //----------------------------------------------------------------------
-    // Object linked to the decl
-    //----------------------------------------------------------------------
-    lldb::VariableSP
-    GetAsVariable ();
-
-    //----------------------------------------------------------------------
     // Accessors
     //----------------------------------------------------------------------
     
diff --git a/lldb/include/lldb/Symbol/GoASTContext.h b/lldb/include/lldb/Symbol/GoASTContext.h
index d37ddfa..ec0203b 100644
--- a/lldb/include/lldb/Symbol/GoASTContext.h
+++ b/lldb/include/lldb/Symbol/GoASTContext.h
@@ -85,17 +85,6 @@
         return ConstString();
     }
 
-    lldb::VariableSP
-    DeclGetVariable (void *opaque_decl) override
-    {
-        return lldb::VariableSP();
-    }
-
-    void
-    DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) override
-    {
-    }
-
     //----------------------------------------------------------------------
     // CompilerDeclContext functions
     //----------------------------------------------------------------------
diff --git a/lldb/include/lldb/Symbol/JavaASTContext.h b/lldb/include/lldb/Symbol/JavaASTContext.h
index 707b929..7d5a376 100644
--- a/lldb/include/lldb/Symbol/JavaASTContext.h
+++ b/lldb/include/lldb/Symbol/JavaASTContext.h
@@ -70,12 +70,6 @@
     ConstString
     DeclGetName(void *opaque_decl) override;
 
-    lldb::VariableSP
-    DeclGetVariable(void *opaque_decl) override;
-
-    void
-    DeclLinkToObject(void *opaque_decl, std::shared_ptr<void> object) override;
-
     //----------------------------------------------------------------------
     // CompilerDeclContext functions
     //----------------------------------------------------------------------
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 2fc7d13..6b0e73d 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -127,12 +127,6 @@
     virtual ConstString
     DeclGetMangledName (void *opaque_decl);
 
-    virtual lldb::VariableSP
-    DeclGetVariable (void *opaque_decl) = 0;
-
-    virtual void
-    DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object) = 0;
-
     virtual CompilerDeclContext
     DeclGetDeclContext (void *opaque_decl);
 
diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py b/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
new file mode 100644
index 0000000..f08c0dc
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/c/inlines/TestRedefinitionsInInlines.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])
diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c b/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c
new file mode 100644
index 0000000..1bf4cda
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+void test1(int) __attribute__ ((always_inline));
+void test2(int) __attribute__ ((always_inline));
+
+void test2(int b) {
+    printf("test2(%d)\n", b); //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["42"])
+}
+
+void test1(int a) {
+    printf("test1(%d)\n",  a);
+    test2(a+1);//% self.dbg.HandleCommand("step")
+               //% self.expect("expression b", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["24"])
+}
+
+int main() {
+    test2(42);
+    test1(23);
+}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index a0d33f7..7aeff6e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1260,7 +1260,16 @@
                 bool variable_found = false;
                 for (CompilerDecl decl : found_decls)
                 {
-                    var = decl.GetAsVariable();
+                    for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi)
+                    {
+                        VariableSP candidate_var = vars->GetVariableAtIndex(vi);
+                        if (candidate_var->GetDecl() == decl)
+                        {
+                            var = candidate_var;
+                            break;
+                        }
+                    }
+
                     if (var)
                     {
                         variable_found = true;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 2c7914a..4580890 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3607,6 +3607,14 @@
         m_decl_to_die[decl].insert(die.GetDIE());
         return decl;
     }
+    
+    if (DWARFDIE abstract_origin_die = die.GetReferencedDIE(DW_AT_abstract_origin))
+    {
+        clang::Decl *decl = GetClangDeclForDIE(abstract_origin_die);
+        m_die_to_decl[die.GetDIE()] = decl;
+        m_decl_to_die[decl].insert(die.GetDIE());
+        return decl;
+    }
 
     clang::Decl *decl = nullptr;
     switch (die.Tag())
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index 44683e7..84116ce 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -9595,24 +9595,6 @@
 //----------------------------------------------------------------------
 // CompilerDecl override functions
 //----------------------------------------------------------------------
-lldb::VariableSP
-ClangASTContext::DeclGetVariable (void *opaque_decl)
-{
-    if (llvm::dyn_cast<clang::VarDecl>((clang::Decl *)opaque_decl))
-    {
-        auto decl_search_it = m_decl_objects.find(opaque_decl);
-        if (decl_search_it != m_decl_objects.end())
-            return std::static_pointer_cast<Variable>(decl_search_it->second);
-    }
-    return VariableSP();
-}
-
-void
-ClangASTContext::DeclLinkToObject (void *opaque_decl, std::shared_ptr<void> object)
-{
-    if (m_decl_objects.find(opaque_decl) == m_decl_objects.end())
-        m_decl_objects.insert(std::make_pair(opaque_decl, object));
-}
 
 ConstString
 ClangASTContext::DeclGetName (void *opaque_decl)
diff --git a/lldb/source/Symbol/CompilerDecl.cpp b/lldb/source/Symbol/CompilerDecl.cpp
index 42e5fb0..98eef06 100644
--- a/lldb/source/Symbol/CompilerDecl.cpp
+++ b/lldb/source/Symbol/CompilerDecl.cpp
@@ -31,12 +31,6 @@
     return m_type_system->DeclGetMangledName(m_opaque_decl);
 }
 
-lldb::VariableSP
-CompilerDecl::GetAsVariable ()
-{
-    return m_type_system->DeclGetVariable(m_opaque_decl);
-}
-
 CompilerDeclContext
 CompilerDecl::GetDeclContext() const
 {
diff --git a/lldb/source/Symbol/JavaASTContext.cpp b/lldb/source/Symbol/JavaASTContext.cpp
index c0cc007..45cda8d 100644
--- a/lldb/source/Symbol/JavaASTContext.cpp
+++ b/lldb/source/Symbol/JavaASTContext.cpp
@@ -535,17 +535,6 @@
     return ConstString();
 }
 
-lldb::VariableSP
-JavaASTContext::DeclGetVariable(void *opaque_decl)
-{
-    return lldb::VariableSP();
-}
-
-void
-JavaASTContext::DeclLinkToObject(void *opaque_decl, std::shared_ptr<void> object)
-{
-}
-
 std::vector<CompilerDecl>
 JavaASTContext::DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, const bool ignore_imported_decls)
 {
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 29fe4bb..7bac02d 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -252,15 +252,8 @@
 CompilerDecl
 Variable::GetDecl ()
 {
-    CompilerDecl decl;
     Type *type = GetType();
-    if (type)
-    {
-        decl = type->GetSymbolFile()->GetDeclForUID(GetID());
-        if (decl)
-            decl.GetTypeSystem()->DeclLinkToObject(decl.GetOpaqueDecl(), shared_from_this());
-    }
-    return decl;
+    return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
 }
 
 void