Updated the revision of LLVM/Clang used by LLDB.
This takes two important changes:

- Calling blocks is now supported.  You need to
  cast their return values, but that works fine.

- We now can correctly run JIT-compiled
  expressions that use floating-point numbers.

Also, we have taken a fix that allows us to
ignore access control in Objective-C as in C++.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@152286 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h
index fe12047..ec92152 100644
--- a/include/lldb/Target/ObjCLanguageRuntime.h
+++ b/include/lldb/Target/ObjCLanguageRuntime.h
@@ -191,11 +191,30 @@
             return false;
     }
     
+    bool
+    HasNewLiteralsAndIndexing ()
+    {
+        if (m_has_new_literals_and_indexing == eLazyBoolCalculate)
+        {
+            if (CalculateHasNewLiteralsAndIndexing())
+                m_has_new_literals_and_indexing = eLazyBoolYes;
+            else
+                m_has_new_literals_and_indexing = eLazyBoolNo;
+        }
+        
+        return (m_has_new_literals_and_indexing == eLazyBoolYes);
+    }
+    
 protected:
     //------------------------------------------------------------------
     // Classes that inherit from ObjCLanguageRuntime can see and modify these
     //------------------------------------------------------------------
     ObjCLanguageRuntime(Process *process);
+    
+    virtual bool CalculateHasNewLiteralsAndIndexing()
+    {
+        return false;
+    }
 private:
     // We keep a map of <Class,Selector>->Implementation so we don't have to call the resolver
     // function over and over.
@@ -246,6 +265,7 @@
     typedef std::map<ClassAndSel,lldb::addr_t> MsgImplMap;
     MsgImplMap m_impl_cache;
     
+    LazyBool m_has_new_literals_and_indexing;
 protected:
     typedef std::map<lldb::addr_t,TypeAndOrName> ClassNameMap;
     typedef ClassNameMap::iterator ClassNameIterator;
diff --git a/scripts/build-llvm.pl b/scripts/build-llvm.pl
index 35d5108..4fd457b 100644
--- a/scripts/build-llvm.pl
+++ b/scripts/build-llvm.pl
@@ -21,8 +21,8 @@
 
 our $llvm_configuration = $ENV{LLVM_CONFIGURATION};
 
-our $llvm_revision = "151777";
-our $clang_revision = "151777";
+our $llvm_revision = "152265";
+our $clang_revision = "152265";
 
 our $SRCROOT = "$ENV{SRCROOT}";
 our $llvm_dstroot_zip = "$SRCROOT/llvm.zip";
@@ -52,6 +52,7 @@
 	"$llvm_configuration/lib/libclangAST.a",
 	"$llvm_configuration/lib/libclangBasic.a",
 	"$llvm_configuration/lib/libclangCodeGen.a",
+    "$llvm_configuration/lib/libclangEdit.a",
 	"$llvm_configuration/lib/libclangFrontend.a",
 	"$llvm_configuration/lib/libclangDriver.a",
 	"$llvm_configuration/lib/libclangIndex.a",
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 12b35f9..1f46ff0 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -2807,9 +2807,7 @@
         return NULL;
     }
 
-#ifdef EXPRESSION_PARSER_SUPPORTS_BLOCKS
     var_opaque_type = MaybePromoteToBlockPointerType (ast, var_opaque_type);
-#endif
     
     DWARFExpression &var_location_expr = var->LocationExpression();
     
diff --git a/source/Expression/ClangExpressionParser.cpp b/source/Expression/ClangExpressionParser.cpp
index 3119146..0df6a67 100644
--- a/source/Expression/ClangExpressionParser.cpp
+++ b/source/Expression/ClangExpressionParser.cpp
@@ -224,6 +224,10 @@
         break;
     }
     
+    m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
+    if (expr.DesiredResultType() == ClangExpression::eResultTypeId)
+        m_compiler->getLangOpts().DebuggerCastResultToId = true;
+    
     lldb::ProcessSP process_sp;
     if (exe_scope)
         process_sp = exe_scope->CalculateProcess();
@@ -237,6 +241,11 @@
                 m_compiler->getLangOpts().ObjCNonFragileABI = true;     // NOT i386
                 m_compiler->getLangOpts().ObjCNonFragileABI2 = true;    // NOT i386
             }
+            
+            if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
+            {
+                m_compiler->getLangOpts().DebuggerObjCLiteral = true;
+            }
         }
     }
 
@@ -244,10 +253,6 @@
     m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access
     m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name
     
-    m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients
-    if (expr.DesiredResultType() == ClangExpression::eResultTypeId)
-        m_compiler->getLangOpts().DebuggerCastResultToId = true;
-    
     // Set CodeGen options
     m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
     m_compiler->getCodeGenOpts().InstrumentFunctions = false;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 90fd352..84042b4 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -352,3 +352,21 @@
     
     return false;
 }
+
+bool
+AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing()
+{
+    if (!m_process)
+        return false;
+    
+    Target &target(m_process->GetTarget());
+    
+    static ConstString s_method_signature("-[NSDictionary objectForKeyedSubscript:]");
+    
+    SymbolContextList sc_list;
+    
+    if (target.GetImages().FindSymbolsWithNameAndType(s_method_signature, eSymbolTypeCode, sc_list))
+        return true;
+    else
+        return false;
+}
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
index bda16e2..3db7477 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
@@ -94,6 +94,9 @@
     // you can't make an instance of this generic runtime.
     
 protected:
+    virtual bool
+    CalculateHasNewLiteralsAndIndexing();
+    
     static bool
     AppleIsModuleObjCLibrary (const lldb::ModuleSP &module_sp);
 
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index e5e0473..ac03b17 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2217,6 +2217,17 @@
                 }
             }
             break;
+        case LoadCommandMain:
+            {
+                ConstString text_segment_name ("__TEXT");
+                uint64_t entryoffset = m_data.GetU64(&offset);
+                SectionSP text_segment_sp = GetSectionList()->FindSectionByName(text_segment_name);
+                if (text_segment_sp)
+                {
+                    done = true;
+                    start_address = text_segment_sp->GetFileAddress() + entryoffset;
+                }
+            }
 
         default:
             break;
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Target/ObjCLanguageRuntime.cpp
index 0076ff0..6d6caef 100644
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ b/source/Target/ObjCLanguageRuntime.cpp
@@ -27,7 +27,8 @@
 }
 
 ObjCLanguageRuntime::ObjCLanguageRuntime (Process *process) :
-    LanguageRuntime (process)
+    LanguageRuntime (process),
+    m_has_new_literals_and_indexing (eLazyBoolCalculate)
 {
 
 }
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 1d6cb93..4b462ee 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -724,13 +724,23 @@
                                 
                                 if (valobj_sp->IsPointerType ())
                                 {
-                                    if (no_synth_child == false
-                                        && 
-                                        ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(),
-                                                                         valobj_sp->GetClangType()) == eLanguageTypeObjC /* is ObjC pointer */
-                                        &&
-                                        ClangASTContext::IsPointerType(ClangASTType::GetPointeeType(valobj_sp->GetClangType())) == false /* is not double-ptr */)
+                                    bool is_objc_pointer = true;
+                                    
+                                    if (ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(), valobj_sp->GetClangType()) != eLanguageTypeObjC)
+                                        is_objc_pointer = false;
+                                    else if (!ClangASTContext::IsPointerType(valobj_sp->GetClangType()))
+                                        is_objc_pointer = false;
+
+                                    if (no_synth_child && is_objc_pointer)
                                     {
+                                        error.SetErrorStringWithFormat("\"(%s) %s\" is an Objective-C pointer, and cannot be subscripted",
+                                                                       valobj_sp->GetTypeName().AsCString("<invalid type>"),
+                                                                       var_expr_path_strm.GetString().c_str());
+                                        
+                                        return ValueObjectSP();
+                                    }
+                                    else if (is_objc_pointer)
+                                    {                                            
                                         // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children
                                         ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(eUseSyntheticFilter);
                                         if (synthetic.get() == NULL /* no synthetic */
diff --git a/test/lang/c/blocks/TestBlocks.py b/test/lang/c/blocks/TestBlocks.py
index fbcada4..32a4045 100644
--- a/test/lang/c/blocks/TestBlocks.py
+++ b/test/lang/c/blocks/TestBlocks.py
@@ -48,8 +48,6 @@
             substrs = ['stopped',
                        'stop reason = breakpoint'])
 
-    # <rdar://problem/10413887>
-    @unittest2.expectedFailure
     def expr(self):
         self.common_setup()
 
diff --git a/test/lang/objc/objc-new-syntax/Makefile b/test/lang/objc/objc-new-syntax/Makefile
new file mode 100644
index 0000000..ad3cb3f
--- /dev/null
+++ b/test/lang/objc/objc-new-syntax/Makefile
@@ -0,0 +1,7 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+
+include $(LEVEL)/Makefile.rules
+
+LDFLAGS += -framework Foundation
diff --git a/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py b/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py
new file mode 100644
index 0000000..8c33a95
--- /dev/null
+++ b/test/lang/objc/objc-new-syntax/TestObjCNewSyntax.py
@@ -0,0 +1,124 @@
+"""Test that the Objective-C syntax for dictionary/array literals and indexing works"""
+
+import os, time
+import unittest2
+import lldb
+import platform
+
+from distutils.version import StrictVersion
+
+from lldbtest import *
+
+class ObjCNewSyntaxTestCase(TestBase):
+
+    mydir = os.path.join("lang", "objc", "objc-new-syntax")
+
+    def test_expr_with_dsym(self):
+        self.buildDsym()
+        self.expr()
+
+    def test_expr_with_dwarf(self):
+        self.buildDwarf()
+        self.expr()
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break inside main().
+        self.line = line_number('main.m', '// Set breakpoint 0 here.')
+
+    def applies(self):
+        if platform.system() != "Darwin":
+            return False
+        if StrictVersion('12.0.0') > platform.release():
+            return False
+
+        return True
+
+    def common_setup(self):
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Break inside the foo function which takes a bar_ptr argument.
+        self.expect("breakpoint set -f main.m -l %d" % self.line, BREAKPOINT_CREATED,
+            startstr = "Breakpoint created")
+
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # The stop reason of the thread should be breakpoint.
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['stopped',
+                       'stop reason = breakpoint'])
+
+        # The breakpoint should have a hit count of 1.
+        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
+
+    def expr(self):
+        if not self.applies():
+            return
+
+        print "Hello!"
+
+        self.common_setup()
+
+        self.expect("expr -o -- immutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["foo"])
+
+        self.expect("expr -o -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["foo"])
+
+        self.expect("expr -o -- mutable_array[0] = @\"bar\"", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["bar"])
+
+        self.expect("expr -o -- mutable_array[0]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["bar"])
+
+        self.expect("expr -o -- immutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["value"])
+
+        self.expect("expr -o -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["value"])
+
+        self.expect("expr -o -- mutable_dictionary[@\"key\"] = @\"object\"", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["object"])
+
+        self.expect("expr -o -- mutable_dictionary[@\"key\"]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["object"])
+
+        self.expect("expr -o -- @[ @\"foo\", @\"bar\" ]", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSArray", "foo", "bar"])
+
+        self.expect("expr -o -- @{ @\"key\" : @\"object\" }", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSDictionary", "key", "object"])
+
+        self.expect("expr -o -- @'a'", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSNumber", str(ord('a'))])
+
+        self.expect("expr -o -- @1", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSNumber", "1"])
+
+        self.expect("expr -o -- @1l", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSNumber", "1"])
+
+        self.expect("expr -o -- @1ul", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSNumber", "1"])
+
+        self.expect("expr -o -- @1ll", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSNumber", "1"])
+
+        self.expect("expr -o -- @1ull", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["NSNumber", "1"])
+
+        #<rdar://problem/10924364>
+        #self.expect("expr -o -- @123.45", VARIABLES_DISPLAYED_CORRECTLY,
+        #    substrs = ["NSNumber", "123.45"])
+        #self.expect("expr -o -- @123.45f", VARIABLES_DISPLAYED_CORRECTLY,
+        #    substrs = ["NSNumber", "123.45"])
+
+            
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()
diff --git a/test/lang/objc/objc-new-syntax/main.m b/test/lang/objc/objc-new-syntax/main.m
new file mode 100644
index 0000000..8b4073e
--- /dev/null
+++ b/test/lang/objc/objc-new-syntax/main.m
@@ -0,0 +1,19 @@
+#import <Foundation/Foundation.h>
+
+int main()
+{
+    @autoreleasepool
+    {
+        // NSArrays
+        NSArray *immutable_array = @[ @"foo", @"bar" ];
+        NSMutableArray *mutable_array = [NSMutableArray arrayWithCapacity:2];
+        [mutable_array addObjectsFromArray:immutable_array];
+        
+        // NSDictionaries
+        NSDictionary *immutable_dictionary = @{ @"key" : @"value" };
+        NSMutableDictionary *mutable_dictionary = [NSMutableDictionary dictionaryWithCapacity:1];
+        [mutable_dictionary addEntriesFromDictionary:immutable_dictionary];
+
+        NSLog(@"Stop here"); // Set breakpoint 0 here.
+    }
+}