[Lldb-commits] [lldb] r157208 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp test/lang/cpp/this/TestCPPThis.py

Sean Callanan scallanan at apple.com
Mon May 21 14:29:52 PDT 2012


Author: spyffe
Date: Mon May 21 16:29:52 2012
New Revision: 157208

URL: http://llvm.org/viewvc/llvm-project?rev=157208&view=rev
Log:
Fixed a nasty bug where JIT expressions didn't work
when stopped in a const method.  Also updated our
testsuite to ensure that JIT is forced in this case.

Modified:
    lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/test/lang/cpp/this/TestCPPThis.py

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=157208&r1=157207&r2=157208&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon May 21 16:29:52 2012
@@ -809,6 +809,10 @@
     ///     during parsing, in which case we don't know its type; hence the
     ///     default.
     ///
+    /// @param[in] object_pointer
+    ///     The type expected is an object type.  This means we will ignore
+    ///     constness of the pointer target.
+    ///
     /// @return
     ///     The LLDB Variable found, or NULL if none was found.
     //------------------------------------------------------------------
@@ -816,7 +820,7 @@
     FindVariableInScope (StackFrame &frame,
                          const ConstString &name,
                          TypeFromUser *type = NULL,
-                         bool ignore_const = false);
+                         bool object_pointer = false);
     
     //------------------------------------------------------------------
     /// Given a target, find a data symbol that has the given name.

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=157208&r1=157207&r2=157208&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon May 21 16:29:52 2012
@@ -1221,12 +1221,12 @@
         return false;
     }
     
-    const bool ignore_const = true;
+    const bool object_pointer = true;
     
     VariableSP object_ptr_var = FindVariableInScope (*frame,
                                                      object_name, 
                                                      (suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type),
-                                                     ignore_const);
+                                                     object_pointer);
     
     if (!object_ptr_var)
     {
@@ -2175,7 +2175,7 @@
     StackFrame &frame,
     const ConstString &name,
     TypeFromUser *type,
-    bool ignore_const
+    bool object_pointer
 )
 {    
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
@@ -2198,19 +2198,41 @@
 
     if (var_sp && type)
     {
-        if (type->GetASTContext() == var_sp->GetType()->GetClangAST())
+        TypeFromUser candidate_type(var_sp->GetType()->GetClangFullType(),
+                                    var_sp->GetType()->GetClangAST());
+        
+        if (candidate_type.GetASTContext() != type->GetASTContext())
         {
-            if (!ClangASTContext::AreTypesSame(type->GetASTContext(), 
-                                               type->GetOpaqueQualType(), 
-                                               var_sp->GetType()->GetClangFullType(), 
-                                               ignore_const))
+            if (log)
+                log->PutCString("Skipping a candidate variable because of different AST contexts");
+            return lldb::VariableSP();
+        }
+        
+        if (object_pointer)
+        {
+            clang::QualType desired_qual_type = clang::QualType::getFromOpaquePtr(type->GetOpaqueQualType());
+            clang::QualType candidate_qual_type = clang::QualType::getFromOpaquePtr(candidate_type.GetOpaqueQualType());
+            
+            const clang::PointerType *desired_ptr_type = desired_qual_type->getAs<clang::PointerType>();
+            const clang::PointerType *candidate_ptr_type = candidate_qual_type->getAs<clang::PointerType>();
+            
+            if (!desired_ptr_type || !candidate_ptr_type)
+                return lldb::VariableSP();
+            
+            clang::QualType desired_target_type = desired_ptr_type->getPointeeType().getUnqualifiedType();
+            clang::QualType candidate_target_type = candidate_ptr_type->getPointeeType().getUnqualifiedType();
+            
+            if (!ClangASTContext::AreTypesSame(type->GetASTContext(),
+                                               desired_target_type.getAsOpaquePtr(),
+                                               candidate_target_type.getAsOpaquePtr()))
                 return lldb::VariableSP();
         }
         else
         {
-            if (log)
-                log->PutCString("Skipping a candidate variable because of different AST contexts");
-            return lldb::VariableSP();
+            if (!ClangASTContext::AreTypesSame(type->GetASTContext(),
+                                               type->GetOpaqueQualType(), 
+                                               var_sp->GetType()->GetClangFullType()))
+                return lldb::VariableSP();
         }
     }
 

Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/this/TestCPPThis.py?rev=157208&r1=157207&r2=157208&view=diff
==============================================================================
--- lldb/trunk/test/lang/cpp/this/TestCPPThis.py (original)
+++ lldb/trunk/test/lang/cpp/this/TestCPPThis.py Mon May 21 16:29:52 2012
@@ -53,7 +53,7 @@
         self.expect("expression -- m_a = 2",
                     startstr = "(int) $1 = 2")
         
-        self.expect("expression -- m_a", 
+        self.expect("expression -- (int)getpid(); m_a", 
                     startstr = "(int) $2 = 2")
 
         self.runCmd("process continue")





More information about the lldb-commits mailing list