[Lldb-commits] [lldb] r156948 - in /lldb/trunk/source: Expression/ASTResultSynthesizer.cpp Expression/ClangExpressionParser.cpp Symbol/ClangASTType.cpp

Sean Callanan scallanan at apple.com
Wed May 16 14:03:38 PDT 2012


Author: spyffe
Date: Wed May 16 16:03:38 2012
New Revision: 156948

URL: http://llvm.org/viewvc/llvm-project?rev=156948&view=rev
Log:
Enabled C++11 in the expression parser.  auto and
various other syntactic sugar work.  Lambdas do
not due to some problems relocating code containing
lambdas.  Rvalue references work when returned from
expressions, but need more testing.

Modified:
    lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
    lldb/trunk/source/Expression/ClangExpressionParser.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp

Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=156948&r1=156947&r2=156948&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original)
+++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Wed May 16 16:03:38 2012
@@ -260,6 +260,21 @@
         // No auxiliary variable necessary; expression returns void
         return true;
     
+    // In C++11, last_expr can be a LValueToRvalue implicit cast.  Strip that off if that's the
+    // case.
+    
+    do {
+        ImplicitCastExpr *implicit_cast = dyn_cast<ImplicitCastExpr>(last_expr);
+        
+        if (!implicit_cast)
+            break;
+        
+        if (!implicit_cast->getCastKind() == CK_LValueToRValue)
+            break;
+        
+        last_expr = implicit_cast->getSubExpr();
+    } while (0);
+    
     // is_lvalue is used to record whether the expression returns an assignable Lvalue or an
     // Rvalue.  This is relevant because they are handled differently.
     //
@@ -354,7 +369,7 @@
                 
         ExprResult address_of_expr = m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr);
         
-        m_sema->AddInitializerToDecl(result_decl, address_of_expr.take(), true, true);
+        m_sema->AddInitializerToDecl(result_decl, address_of_expr.take(), true, false);
     }
     else
     {
@@ -373,7 +388,7 @@
         if (!result_decl)
             return false;
         
-        m_sema->AddInitializerToDecl(result_decl, last_expr, true, true);
+        m_sema->AddInitializerToDecl(result_decl, last_expr, true, false);
     }
     
     DC->addDecl(result_decl);

Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=156948&r1=156947&r2=156948&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed May 16 16:03:38 2012
@@ -215,12 +215,14 @@
         break;
     case lldb::eLanguageTypeC_plus_plus:
         m_compiler->getLangOpts().CPlusPlus = true;
+        m_compiler->getLangOpts().CPlusPlus0x = true;
         break;
     case lldb::eLanguageTypeObjC_plus_plus:
     default:
         m_compiler->getLangOpts().ObjC1 = true;
         m_compiler->getLangOpts().ObjC2 = true;
         m_compiler->getLangOpts().CPlusPlus = true;
+        m_compiler->getLangOpts().CPlusPlus0x = true;
         break;
     }
     

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=156948&r1=156947&r2=156948&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed May 16 16:03:38 2012
@@ -577,6 +577,8 @@
     case clang::Type::Typedef:
             return ClangASTType::GetFormat(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
 
+    case clang::Type::Auto:
+            return ClangASTType::GetFormat(llvm::cast<clang::AutoType>(qual_type)->desugar().getAsOpaquePtr());
     case clang::Type::DependentSizedArray:
     case clang::Type::DependentSizedExtVector:
     case clang::Type::UnresolvedUsing:
@@ -586,7 +588,6 @@
     case clang::Type::TemplateTypeParm:
     case clang::Type::SubstTemplateTypeParm:
     case clang::Type::SubstTemplateTypeParmPack:
-    case clang::Type::Auto:
     case clang::Type::InjectedClassName:
     case clang::Type::DependentName:
     case clang::Type::DependentTemplateSpecialization:





More information about the lldb-commits mailing list