Brought LLDB top-of-tree into sync with LLVM/Clang
top-of-tree.  Removed all local patches and llvm.zip.

The intent is that fron now on top-of-tree will
always build against LLVM/Clang top-of-tree, and
that problems building will be resolved as they
occur.  Stable release branches of LLDB can be
constructed as needed and linked to specific release
branches of LLVM/Clang.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/scripts/build-llvm.pl b/scripts/build-llvm.pl
index 41b802b..3be920e 100644
--- a/scripts/build-llvm.pl
+++ b/scripts/build-llvm.pl
@@ -21,11 +21,10 @@
 
 our $llvm_configuration = $ENV{LLVM_CONFIGURATION};
 
-our $llvm_revision = "152265";
-our $clang_revision = "152265";
+our $llvm_revision = "HEAD";
+our $clang_revision = "HEAD";
 
 our $SRCROOT = "$ENV{SRCROOT}";
-our $llvm_dstroot_zip = "$SRCROOT/llvm.zip";
 our @archs = split (/\s+/, $ENV{ARCHS});
 my $os_release = 11;
 
@@ -57,13 +56,10 @@
     "$llvm_configuration/lib/libclangEdit.a",
 	"$llvm_configuration/lib/libclangFrontend.a",
 	"$llvm_configuration/lib/libclangDriver.a",
-	"$llvm_configuration/lib/libclangIndex.a",
 	"$llvm_configuration/lib/libclangLex.a",
-	"$llvm_configuration/lib/libclangRewrite.a",
 	"$llvm_configuration/lib/libclangParse.a",
 	"$llvm_configuration/lib/libclangSema.a",
     "$llvm_configuration/lib/libclangSerialization.a",
-	"$llvm_configuration/lib/libEnhancedDisassembly.a",
 	"$llvm_configuration/lib/libLLVMAnalysis.a",
 	"$llvm_configuration/lib/libLLVMArchive.a",
 	"$llvm_configuration/lib/libLLVMARMAsmParser.a",
@@ -111,48 +107,6 @@
     print "Using existing llvm sources in: '$llvm_srcroot'\n";
     print "Using standard LLVM build directory:\n  SRC = '$llvm_srcroot'\n  DST = '$llvm_dstroot'\n";
 }
-elsif (-e $llvm_dstroot_zip)
-{
-    # Check for an old llvm source install (not the minimal zip based 
-    # install by looking for a .svn file in the llvm directory
-    chomp(my $llvm_zip_md5 = `md5 -q '$llvm_dstroot_zip'`);
-    my $llvm_zip_md5_file = "$ENV{SRCROOT}/llvm/$llvm_zip_md5";
-    if (!-e "$llvm_zip_md5_file")
-    {
-        print "Updating LLVM to use checkpoint from: '$llvm_dstroot_zip'...\n";
-        if (-d "$ENV{SRCROOT}/llvm")
-        {
-            do_command ("cd '$ENV{SRCROOT}' && rm -rf llvm", "removing old llvm repository", 1);            
-        }
-		do_command ("cd '$ENV{SRCROOT}' && unzip -q llvm.zip && touch '$llvm_zip_md5_file'", "expanding llvm.zip", 1);
-        
-    }
-    my $arch_idx = 0;
-        
-    if (!-d "${llvm_dstroot}")
-    {
-        do_command ("mkdir -p '${llvm_dstroot}'", "Creating directory '${llvm_dstroot}'", 1);
-    }
-        
-    foreach my $arch (@archs)
-    {
-        my $llvm_dstroot_arch = "${llvm_dstroot}/${arch}";
-        # Check for our symlink to our .a file
-        if (!-l "$llvm_dstroot_arch/$llvm_clang_basename")
-        {
-            # Symlink doesn't exist, make sure it isn't a normal file
-            if (-e "$llvm_dstroot_arch/$llvm_clang_basename")
-            {
-                # the .a file is a normal file which means it can't be from the 
-                # zip file, we must remove the previous arch directory
-                do_command ("rm -rf '$llvm_dstroot_arch'", "Removing old '$llvm_dstroot_arch' directory", 1);
-            }            
-            # Create a symlink to the .a file from the zip file
-            do_command ("cd '$llvm_dstroot' ; ln -s $ENV{SRCROOT}/llvm/$arch", "making llvm archive symlink", 1);
-        }
-    }
-    exit 0;
-}
 else
 {
     print "Checking out llvm sources from revision $llvm_revision...\n";
diff --git a/scripts/clang.amalgamated.diff b/scripts/clang.amalgamated.diff
deleted file mode 100644
index c412477..0000000
--- a/scripts/clang.amalgamated.diff
+++ /dev/null
@@ -1,1936 +0,0 @@
-Index: include/clang/Basic/StmtNodes.td
-===================================================================
---- include/clang/Basic/StmtNodes.td	(revision 152265)
-+++ include/clang/Basic/StmtNodes.td	(working copy)
-@@ -133,7 +133,7 @@
- 
- // Obj-C Expressions.
- def ObjCStringLiteral : DStmt<Expr>;
--def ObjCNumericLiteral : DStmt<Expr>;
-+def ObjCBoxedExpr : DStmt<Expr>;
- def ObjCArrayLiteral : DStmt<Expr>;
- def ObjCDictionaryLiteral : DStmt<Expr>;
- def ObjCEncodeExpr : DStmt<Expr>;
-Index: include/clang/Basic/DiagnosticSemaKinds.td
-===================================================================
---- include/clang/Basic/DiagnosticSemaKinds.td	(revision 152265)
-+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
-@@ -1489,6 +1489,12 @@
-   "NSNumber must be available to use Objective-C literals">;
- def err_invalid_nsnumber_type : Error<
-   "%0 is not a valid literal type for NSNumber">;
-+def err_undeclared_nsstring : Error<
-+  "cannot box a string value because NSString has not been declared">;
-+def err_objc_illegal_boxed_expression_type : Error<
-+  "illegal type %0 used in a boxed expression">;
-+def err_objc_incomplete_boxed_expression_type : Error<
-+  "incomplete type %0 used in a boxed expression">;
- def err_undeclared_nsarray : Error<
-   "NSArray must be available to use Objective-C array literals">;
- def err_undeclared_nsdictionary : Error<
-Index: include/clang/Sema/Sema.h
-===================================================================
---- include/clang/Sema/Sema.h	(revision 152265)
-+++ include/clang/Sema/Sema.h	(working copy)
-@@ -519,9 +519,21 @@
-   /// \brief The declaration of the Objective-C NSNumber class.
-   ObjCInterfaceDecl *NSNumberDecl;
-   
-+  /// \brief Pointer to NSNumber type (NSNumber *).
-+  QualType NSNumberPointer;
-+  
-   /// \brief The Objective-C NSNumber methods used to create NSNumber literals.
-   ObjCMethodDecl *NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods];
-   
-+  /// \brief The declaration of the Objective-C NSString class.
-+  ObjCInterfaceDecl *NSStringDecl;
-+
-+  /// \brief Pointer to NSString type (NSString *).
-+  QualType NSStringPointer;
-+  
-+  /// \brief The declaration of the stringWithUTF8String: method.
-+  ObjCMethodDecl *StringWithUTF8StringMethod;
-+
-   /// \brief The declaration of the Objective-C NSArray class.
-   ObjCInterfaceDecl *NSArrayDecl;
- 
-@@ -3708,7 +3720,7 @@
-     
-   ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S);
-   
--  /// BuildObjCNumericLiteral - builds an ObjCNumericLiteral AST node for the
-+  /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
-   /// numeric literal expression. Type of the expression will be "NSNumber *"
-   /// or "id" if NSNumber is unavailable.
-   ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number);
-@@ -3716,6 +3728,13 @@
-                                   bool Value);
-   ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements);
-   
-+  // BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
-+  // '@' prefixed parenthesized expression. The type of the expression will
-+  // either be "NSNumber *" or "NSString *" depending on the type of
-+  // ValueType, which is allowed to be a built-in numeric type or
-+  // "char *" or "const char *".
-+  ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr);
-+  
-   ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr,
-                                           Expr *IndexExpr,
-                                           ObjCMethodDecl *getterMethod,
-Index: include/clang/AST/ASTImporter.h
-===================================================================
---- include/clang/AST/ASTImporter.h	(revision 152265)
-+++ include/clang/AST/ASTImporter.h	(working copy)
-@@ -271,7 +271,8 @@
-     
-     /// \brief Determine whether the given types are structurally
-     /// equivalent.
--    bool IsStructurallyEquivalent(QualType From, QualType To);    
-+    bool IsStructurallyEquivalent(QualType From, QualType To,
-+                                  bool Complain = true);
-   };
- }
- 
-Index: include/clang/AST/Type.h
-===================================================================
---- include/clang/AST/Type.h	(revision 152265)
-+++ include/clang/AST/Type.h	(working copy)
-@@ -1714,9 +1714,9 @@
-   friend class ASTWriter;
- };
- 
--template <> inline const TypedefType *Type::getAs() const {
--  return dyn_cast<TypedefType>(this);
--}
-+/// \brief This will check for a TypedefType by removing any existing sugar
-+/// until it reaches a TypedefType or a non-sugared type.
-+template <> const TypedefType *Type::getAs() const;
- 
- // We can do canonical leaf types faster, because we don't have to
- // worry about preserving child type decoration.
-Index: include/clang/AST/RecursiveASTVisitor.h
-===================================================================
---- include/clang/AST/RecursiveASTVisitor.h	(revision 152265)
-+++ include/clang/AST/RecursiveASTVisitor.h	(working copy)
-@@ -2106,7 +2106,7 @@
- DEF_TRAVERSE_STMT(ImaginaryLiteral, { })
- DEF_TRAVERSE_STMT(StringLiteral, { })
- DEF_TRAVERSE_STMT(ObjCStringLiteral, { })
--DEF_TRAVERSE_STMT(ObjCNumericLiteral, { })
-+DEF_TRAVERSE_STMT(ObjCBoxedExpr, { })
- DEF_TRAVERSE_STMT(ObjCArrayLiteral, { })
- DEF_TRAVERSE_STMT(ObjCDictionaryLiteral, { })
-   
-Index: include/clang/AST/ExprObjC.h
-===================================================================
---- include/clang/AST/ExprObjC.h	(revision 152265)
-+++ include/clang/AST/ExprObjC.h	(working copy)
-@@ -86,43 +86,45 @@
-   child_range children() { return child_range(); }
- };
- 
--/// ObjCNumericLiteral - used for objective-c numeric literals;
--/// as in: @42 or @true (c++/objc++) or @__yes (c/objc)
--class ObjCNumericLiteral : public Expr {
--  /// Number - expression AST node for the numeric literal
--  Stmt *Number;
--  ObjCMethodDecl *ObjCNumericLiteralMethod;
--  SourceLocation AtLoc;
-+/// ObjCBoxedExpr - used for generalized expression boxing.
-+/// as in: @(strdup("hello world")) or @(random())
-+/// Also used for boxing non-parenthesized numeric literals;
-+/// as in: @42 or @true (c++/objc++) or @__yes (c/objc).
-+class ObjCBoxedExpr : public Expr {
-+  Stmt *SubExpr;
-+  ObjCMethodDecl *BoxingMethod;
-+  SourceRange Range;
- public:
--  ObjCNumericLiteral(Stmt *NL, QualType T, ObjCMethodDecl *method,
--                     SourceLocation L)
--  : Expr(ObjCNumericLiteralClass, T, VK_RValue, OK_Ordinary, 
--         false, false, false, false), Number(NL), 
--    ObjCNumericLiteralMethod(method), AtLoc(L) {}
--  explicit ObjCNumericLiteral(EmptyShell Empty)
--  : Expr(ObjCNumericLiteralClass, Empty) {}
-+  ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method,
-+                     SourceRange R)
-+  : Expr(ObjCBoxedExprClass, T, VK_RValue, OK_Ordinary, 
-+         E->isTypeDependent(), E->isValueDependent(), 
-+         E->isInstantiationDependent(), E->containsUnexpandedParameterPack()), 
-+         SubExpr(E), BoxingMethod(method), Range(R) {}
-+  explicit ObjCBoxedExpr(EmptyShell Empty)
-+  : Expr(ObjCBoxedExprClass, Empty) {}
-   
--  Expr *getNumber() { return cast<Expr>(Number); }
--  const Expr *getNumber() const { return cast<Expr>(Number); }
-+  Expr *getSubExpr() { return cast<Expr>(SubExpr); }
-+  const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
-   
--  ObjCMethodDecl *getObjCNumericLiteralMethod() const {
--    return ObjCNumericLiteralMethod; 
-+  ObjCMethodDecl *getBoxingMethod() const {
-+    return BoxingMethod; 
-   }
--    
--  SourceLocation getAtLoc() const { return AtLoc; }
-   
-+  SourceLocation getAtLoc() const { return Range.getBegin(); }
-+  
-   SourceRange getSourceRange() const {
--    return SourceRange(AtLoc, Number->getSourceRange().getEnd());
-+    return Range;
-   }
--
-+  
-   static bool classof(const Stmt *T) {
--      return T->getStmtClass() == ObjCNumericLiteralClass;
-+    return T->getStmtClass() == ObjCBoxedExprClass;
-   }
--  static bool classof(const ObjCNumericLiteral *) { return true; }
-+  static bool classof(const ObjCBoxedExpr *) { return true; }
-   
-   // Iterators
--  child_range children() { return child_range(&Number, &Number+1); }
--    
-+  child_range children() { return child_range(&SubExpr, &SubExpr+1); }
-+  
-   friend class ASTStmtReader;
- };
- 
-Index: include/clang/AST/NSAPI.h
-===================================================================
---- include/clang/AST/NSAPI.h	(revision 152265)
-+++ include/clang/AST/NSAPI.h	(working copy)
-@@ -125,10 +125,19 @@
- 
-   /// \brief Determine the appropriate NSNumber factory method kind for a
-   /// literal of the given type.
--  static llvm::Optional<NSNumberLiteralMethodKind>
--      getNSNumberFactoryMethodKind(QualType T);
-+  llvm::Optional<NSNumberLiteralMethodKind>
-+      getNSNumberFactoryMethodKind(QualType T) const;
- 
-+  /// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
-+  bool isObjCBOOLType(QualType T) const;
-+  /// \brief Returns true if \param T is a typedef of "NSInteger" in objective-c.
-+  bool isObjCNSIntegerType(QualType T) const;
-+  /// \brief Returns true if \param T is a typedef of "NSUInteger" in objective-c.
-+  bool isObjCNSUIntegerType(QualType T) const;
-+
- private:
-+  bool isObjCTypedef(QualType T, StringRef name, IdentifierInfo *&II) const;
-+
-   ASTContext &Ctx;
- 
-   mutable IdentifierInfo *ClassIds[NumClassIds];
-@@ -144,6 +153,8 @@
-   /// \brief The Objective-C NSNumber selectors used to create NSNumber literals.
-   mutable Selector NSNumberClassSelectors[NumNSNumberLiteralMethods];
-   mutable Selector NSNumberInstanceSelectors[NumNSNumberLiteralMethods];
-+
-+  mutable IdentifierInfo *BOOLId, *NSIntegerId, *NSUIntegerId;
- };
- 
- }  // end namespace clang
-Index: include/clang/Parse/Parser.h
-===================================================================
---- include/clang/Parse/Parser.h	(revision 152265)
-+++ include/clang/Parse/Parser.h	(working copy)
-@@ -1497,6 +1497,7 @@
-   ExprResult ParseObjCBooleanLiteral(SourceLocation AtLoc, bool ArgValue);
-   ExprResult ParseObjCArrayLiteral(SourceLocation AtLoc);
-   ExprResult ParseObjCDictionaryLiteral(SourceLocation AtLoc);
-+  ExprResult ParseObjCBoxedExpr(SourceLocation AtLoc);
-   ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc);
-   ExprResult ParseObjCSelectorExpression(SourceLocation AtLoc);
-   ExprResult ParseObjCProtocolExpression(SourceLocation AtLoc);
-Index: include/clang/Serialization/ASTBitCodes.h
-===================================================================
---- include/clang/Serialization/ASTBitCodes.h	(revision 152265)
-+++ include/clang/Serialization/ASTBitCodes.h	(working copy)
-@@ -1066,7 +1066,7 @@
-       /// \brief An ObjCStringLiteral record.
-       EXPR_OBJC_STRING_LITERAL,
- 
--      EXPR_OBJC_NUMERIC_LITERAL,
-+      EXPR_OBJC_BOXED_EXPRESSION,
-       EXPR_OBJC_ARRAY_LITERAL,
-       EXPR_OBJC_DICTIONARY_LITERAL,
- 
-Index: docs/LanguageExtensions.html
-===================================================================
---- docs/LanguageExtensions.html	(revision 152265)
-+++ docs/LanguageExtensions.html	(working copy)
-@@ -87,7 +87,7 @@
-     <li><a href="#objc_instancetype">Related result types</a></li>
-     <li><a href="#objc_arc">Automatic reference counting</a></li>
-     <li><a href="#objc_fixed_enum">Enumerations with a fixed underlying type</a></li>
--  </ul>
-+ </ul>
- </li>
- <li><a href="#overloading-in-c">Function Overloading in C</a></li>
- <li><a href="#complex-list-init">Initializer lists for complex numbers in C</a></li>
-Index: tools/libclang/IndexBody.cpp
-===================================================================
---- tools/libclang/IndexBody.cpp	(revision 152265)
-+++ tools/libclang/IndexBody.cpp	(working copy)
-@@ -90,13 +90,13 @@
-     return true;
-   }
- 
--  bool VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
--    if (ObjCMethodDecl *MD = E->getObjCNumericLiteralMethod())
-+  bool VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
-+    if (ObjCMethodDecl *MD = E->getBoxingMethod())
-       IndexCtx.handleReference(MD, E->getLocStart(),
-                                Parent, ParentDC, E, CXIdxEntityRef_Implicit);
-     return true;
-   }
--
-+  
-   bool VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
-     if (ObjCMethodDecl *MD = E->getDictWithObjectsMethod())
-       IndexCtx.handleReference(MD, E->getLocStart(),
-Index: tools/libclang/CXCursor.cpp
-===================================================================
---- tools/libclang/CXCursor.cpp	(revision 152265)
-+++ tools/libclang/CXCursor.cpp	(working copy)
-@@ -229,7 +229,7 @@
-   case Stmt::VAArgExprClass:
-   case Stmt::ObjCArrayLiteralClass:
-   case Stmt::ObjCDictionaryLiteralClass:
--  case Stmt::ObjCNumericLiteralClass:
-+  case Stmt::ObjCBoxedExprClass:
-   case Stmt::ObjCSubscriptRefExprClass:
-     K = CXCursor_UnexposedExpr;
-     break;
-Index: lib/Rewrite/RewriteModernObjC.cpp
-===================================================================
---- lib/Rewrite/RewriteModernObjC.cpp	(revision 152265)
-+++ lib/Rewrite/RewriteModernObjC.cpp	(working copy)
-@@ -309,6 +309,10 @@
-     Stmt *RewriteAtSelector(ObjCSelectorExpr *Exp);
-     Stmt *RewriteMessageExpr(ObjCMessageExpr *Exp);
-     Stmt *RewriteObjCStringLiteral(ObjCStringLiteral *Exp);
-+    Stmt *RewriteObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Exp);
-+    Stmt *RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp);
-+    Stmt *RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp);
-+    Stmt *RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral *Exp);
-     Stmt *RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp);
-     void RewriteTryReturnStmts(Stmt *S);
-     void RewriteSyncReturnStmts(Stmt *S, std::string buf);
-@@ -2587,6 +2591,435 @@
-   return cast;
- }
- 
-+Stmt *RewriteModernObjC::RewriteObjCBoolLiteralExpr(ObjCBoolLiteralExpr *Exp) {
-+  unsigned IntSize =
-+    static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
-+  
-+  Expr *FlagExp = IntegerLiteral::Create(*Context, 
-+                                         llvm::APInt(IntSize, Exp->getValue()), 
-+                                         Context->IntTy, Exp->getLocation());
-+  CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Context->ObjCBuiltinBoolTy,
-+                                            CK_BitCast, FlagExp);
-+  ParenExpr *PE = new (Context) ParenExpr(Exp->getLocation(), Exp->getExprLoc(), 
-+                                          cast);
-+  ReplaceStmt(Exp, PE);
-+  return PE;
-+}
-+
-+Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) {
-+  // synthesize declaration of helper functions needed in this routine.
-+  if (!SelGetUidFunctionDecl)
-+    SynthSelGetUidFunctionDecl();
-+  // use objc_msgSend() for all.
-+  if (!MsgSendFunctionDecl)
-+    SynthMsgSendFunctionDecl();
-+  if (!GetClassFunctionDecl)
-+    SynthGetClassFunctionDecl();
-+  
-+  FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
-+  SourceLocation StartLoc = Exp->getLocStart();
-+  SourceLocation EndLoc = Exp->getLocEnd();
-+  
-+  // Synthesize a call to objc_msgSend().
-+  SmallVector<Expr*, 4> MsgExprs;
-+  SmallVector<Expr*, 4> ClsExprs;
-+  QualType argType = Context->getPointerType(Context->CharTy);
-+  
-+  // Create a call to objc_getClass("<BoxingClass>"). It will be the 1st argument.
-+  ObjCMethodDecl *BoxingMethod = Exp->getBoxingMethod();
-+  ObjCInterfaceDecl *BoxingClass = BoxingMethod->getClassInterface();
-+  
-+  IdentifierInfo *clsName = BoxingClass->getIdentifier();
-+  ClsExprs.push_back(StringLiteral::Create(*Context,
-+                                           clsName->getName(),
-+                                           StringLiteral::Ascii, false,
-+                                           argType, SourceLocation()));
-+  CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
-+                                               &ClsExprs[0],
-+                                               ClsExprs.size(), 
-+                                               StartLoc, EndLoc);
-+  MsgExprs.push_back(Cls);
-+  
-+  // Create a call to sel_registerName("<BoxingMethod>:"), etc.
-+  // it will be the 2nd argument.
-+  SmallVector<Expr*, 4> SelExprs;
-+  SelExprs.push_back(StringLiteral::Create(*Context,
-+                                           BoxingMethod->getSelector().getAsString(),
-+                                           StringLiteral::Ascii, false,
-+                                           argType, SourceLocation()));
-+  CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
-+                                                  &SelExprs[0], SelExprs.size(),
-+                                                  StartLoc, EndLoc);
-+  MsgExprs.push_back(SelExp);
-+  
-+  // User provided sub-expression is the 3rd, and last, argument.
-+  Expr *subExpr  = Exp->getSubExpr();
-+  if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(subExpr)) {
-+    QualType type = ICE->getType();
-+    const Expr *SubExpr = ICE->IgnoreParenImpCasts();
-+    CastKind CK = CK_BitCast;
-+    if (SubExpr->getType()->isIntegralType(*Context) && type->isBooleanType())
-+      CK = CK_IntegralToBoolean;
-+    subExpr = NoTypeInfoCStyleCastExpr(Context, type, CK, subExpr);
-+  }
-+  MsgExprs.push_back(subExpr);
-+  
-+  SmallVector<QualType, 4> ArgTypes;
-+  ArgTypes.push_back(Context->getObjCIdType());
-+  ArgTypes.push_back(Context->getObjCSelType());
-+  for (ObjCMethodDecl::param_iterator PI = BoxingMethod->param_begin(),
-+       E = BoxingMethod->param_end(); PI != E; ++PI)
-+    ArgTypes.push_back((*PI)->getType());
-+  
-+  QualType returnType = Exp->getType();
-+  // Get the type, we will need to reference it in a couple spots.
-+  QualType msgSendType = MsgSendFlavor->getType();
-+  
-+  // Create a reference to the objc_msgSend() declaration.
-+  DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
-+                                               VK_LValue, SourceLocation());
-+  
-+  CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
-+                                            Context->getPointerType(Context->VoidTy),
-+                                            CK_BitCast, DRE);
-+  
-+  // Now do the "normal" pointer to function cast.
-+  QualType castType =
-+  getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
-+                        BoxingMethod->isVariadic());
-+  castType = Context->getPointerType(castType);
-+  cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
-+                                  cast);
-+  
-+  // Don't forget the parens to enforce the proper binding.
-+  ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
-+  
-+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
-+  CallExpr *CE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
-+                                        MsgExprs.size(),
-+                                        FT->getResultType(), VK_RValue,
-+                                        EndLoc);
-+  ReplaceStmt(Exp, CE);
-+  return CE;
-+}
-+
-+Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) {
-+  // synthesize declaration of helper functions needed in this routine.
-+  if (!SelGetUidFunctionDecl)
-+    SynthSelGetUidFunctionDecl();
-+  // use objc_msgSend() for all.
-+  if (!MsgSendFunctionDecl)
-+    SynthMsgSendFunctionDecl();
-+  if (!GetClassFunctionDecl)
-+    SynthGetClassFunctionDecl();
-+  
-+  FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
-+  SourceLocation StartLoc = Exp->getLocStart();
-+  SourceLocation EndLoc = Exp->getLocEnd();
-+  
-+  // Build the expression: __NSContainer_literal(int, ...).arr
-+  QualType IntQT = Context->IntTy;
-+  QualType NSArrayFType =
-+    getSimpleFunctionType(Context->VoidTy, &IntQT, 1, true);
-+  std::string NSArrayFName("__NSContainer_literal");
-+  FunctionDecl *NSArrayFD = SynthBlockInitFunctionDecl(NSArrayFName);
-+  DeclRefExpr *NSArrayDRE = 
-+    new (Context) DeclRefExpr(NSArrayFD, NSArrayFType, VK_RValue,
-+                              SourceLocation());
-+
-+  SmallVector<Expr*, 16> InitExprs;
-+  unsigned NumElements = Exp->getNumElements();
-+  unsigned UnsignedIntSize = 
-+    static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
-+  Expr *count = IntegerLiteral::Create(*Context,
-+                                       llvm::APInt(UnsignedIntSize, NumElements),
-+                                       Context->UnsignedIntTy, SourceLocation());
-+  InitExprs.push_back(count);
-+  for (unsigned i = 0; i < NumElements; i++)
-+    InitExprs.push_back(Exp->getElement(i));
-+  Expr *NSArrayCallExpr = 
-+    new (Context) CallExpr(*Context, NSArrayDRE, &InitExprs[0], InitExprs.size(),
-+                           NSArrayFType, VK_LValue, SourceLocation());
-+  
-+  FieldDecl *ARRFD = FieldDecl::Create(*Context, 0, SourceLocation(),
-+                                    SourceLocation(),
-+                                    &Context->Idents.get("arr"),
-+                                    Context->getPointerType(Context->VoidPtrTy), 0,
-+                                    /*BitWidth=*/0, /*Mutable=*/true,
-+                                    /*HasInit=*/false);
-+  MemberExpr *ArrayLiteralME = 
-+    new (Context) MemberExpr(NSArrayCallExpr, false, ARRFD, 
-+                             SourceLocation(),
-+                             ARRFD->getType(), VK_LValue,
-+                             OK_Ordinary);
-+  QualType ConstIdT = Context->getObjCIdType().withConst();
-+  CStyleCastExpr * ArrayLiteralObjects = 
-+    NoTypeInfoCStyleCastExpr(Context, 
-+                             Context->getPointerType(ConstIdT),
-+                             CK_BitCast,
-+                             ArrayLiteralME);
-+  
-+  // Synthesize a call to objc_msgSend().
-+  SmallVector<Expr*, 32> MsgExprs;
-+  SmallVector<Expr*, 4> ClsExprs;
-+  QualType argType = Context->getPointerType(Context->CharTy);
-+  QualType expType = Exp->getType();
-+  
-+  // Create a call to objc_getClass("NSArray"). It will be th 1st argument.
-+  ObjCInterfaceDecl *Class = 
-+    expType->getPointeeType()->getAs<ObjCObjectType>()->getInterface();
-+  
-+  IdentifierInfo *clsName = Class->getIdentifier();
-+  ClsExprs.push_back(StringLiteral::Create(*Context,
-+                                           clsName->getName(),
-+                                           StringLiteral::Ascii, false,
-+                                           argType, SourceLocation()));
-+  CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
-+                                               &ClsExprs[0],
-+                                               ClsExprs.size(), 
-+                                               StartLoc, EndLoc);
-+  MsgExprs.push_back(Cls);
-+  
-+  // Create a call to sel_registerName("arrayWithObjects:count:").
-+  // it will be the 2nd argument.
-+  SmallVector<Expr*, 4> SelExprs;
-+  ObjCMethodDecl *ArrayMethod = Exp->getArrayWithObjectsMethod();
-+  SelExprs.push_back(StringLiteral::Create(*Context,
-+                                           ArrayMethod->getSelector().getAsString(),
-+                                           StringLiteral::Ascii, false,
-+                                           argType, SourceLocation()));
-+  CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
-+                                                  &SelExprs[0], SelExprs.size(),
-+                                                  StartLoc, EndLoc);
-+  MsgExprs.push_back(SelExp);
-+  
-+  // (const id [])objects
-+  MsgExprs.push_back(ArrayLiteralObjects);
-+  
-+  // (NSUInteger)cnt
-+  Expr *cnt = IntegerLiteral::Create(*Context,
-+                                     llvm::APInt(UnsignedIntSize, NumElements),
-+                                     Context->UnsignedIntTy, SourceLocation());
-+  MsgExprs.push_back(cnt);
-+  
-+  
-+  SmallVector<QualType, 4> ArgTypes;
-+  ArgTypes.push_back(Context->getObjCIdType());
-+  ArgTypes.push_back(Context->getObjCSelType());
-+  for (ObjCMethodDecl::param_iterator PI = ArrayMethod->param_begin(),
-+       E = ArrayMethod->param_end(); PI != E; ++PI)
-+    ArgTypes.push_back((*PI)->getType());
-+  
-+  QualType returnType = Exp->getType();
-+  // Get the type, we will need to reference it in a couple spots.
-+  QualType msgSendType = MsgSendFlavor->getType();
-+  
-+  // Create a reference to the objc_msgSend() declaration.
-+  DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
-+                                               VK_LValue, SourceLocation());
-+  
-+  CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
-+                                            Context->getPointerType(Context->VoidTy),
-+                                            CK_BitCast, DRE);
-+  
-+  // Now do the "normal" pointer to function cast.
-+  QualType castType =
-+  getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
-+                        ArrayMethod->isVariadic());
-+  castType = Context->getPointerType(castType);
-+  cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
-+                                  cast);
-+  
-+  // Don't forget the parens to enforce the proper binding.
-+  ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
-+  
-+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
-+  CallExpr *CE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
-+                                        MsgExprs.size(),
-+                                        FT->getResultType(), VK_RValue,
-+                                        EndLoc);
-+  ReplaceStmt(Exp, CE);
-+  return CE;
-+}
-+
-+Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral *Exp) {
-+  // synthesize declaration of helper functions needed in this routine.
-+  if (!SelGetUidFunctionDecl)
-+    SynthSelGetUidFunctionDecl();
-+  // use objc_msgSend() for all.
-+  if (!MsgSendFunctionDecl)
-+    SynthMsgSendFunctionDecl();
-+  if (!GetClassFunctionDecl)
-+    SynthGetClassFunctionDecl();
-+  
-+  FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
-+  SourceLocation StartLoc = Exp->getLocStart();
-+  SourceLocation EndLoc = Exp->getLocEnd();
-+  
-+  // Build the expression: __NSContainer_literal(int, ...).arr
-+  QualType IntQT = Context->IntTy;
-+  QualType NSDictFType =
-+    getSimpleFunctionType(Context->VoidTy, &IntQT, 1, true);
-+  std::string NSDictFName("__NSContainer_literal");
-+  FunctionDecl *NSDictFD = SynthBlockInitFunctionDecl(NSDictFName);
-+  DeclRefExpr *NSDictDRE = 
-+    new (Context) DeclRefExpr(NSDictFD, NSDictFType, VK_RValue,
-+                              SourceLocation());
-+  
-+  SmallVector<Expr*, 16> KeyExprs;
-+  SmallVector<Expr*, 16> ValueExprs;
-+  
-+  unsigned NumElements = Exp->getNumElements();
-+  unsigned UnsignedIntSize = 
-+    static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
-+  Expr *count = IntegerLiteral::Create(*Context,
-+                                       llvm::APInt(UnsignedIntSize, NumElements),
-+                                       Context->UnsignedIntTy, SourceLocation());
-+  KeyExprs.push_back(count);
-+  ValueExprs.push_back(count);
-+  for (unsigned i = 0; i < NumElements; i++) {
-+    ObjCDictionaryElement Element = Exp->getKeyValueElement(i);
-+    KeyExprs.push_back(Element.Key);
-+    ValueExprs.push_back(Element.Value);
-+  }
-+  
-+  // (const id [])objects
-+  Expr *NSValueCallExpr = 
-+    new (Context) CallExpr(*Context, NSDictDRE, &ValueExprs[0], ValueExprs.size(),
-+                           NSDictFType, VK_LValue, SourceLocation());
-+  
-+  FieldDecl *ARRFD = FieldDecl::Create(*Context, 0, SourceLocation(),
-+                                       SourceLocation(),
-+                                       &Context->Idents.get("arr"),
-+                                       Context->getPointerType(Context->VoidPtrTy), 0,
-+                                       /*BitWidth=*/0, /*Mutable=*/true,
-+                                       /*HasInit=*/false);
-+  MemberExpr *DictLiteralValueME = 
-+    new (Context) MemberExpr(NSValueCallExpr, false, ARRFD, 
-+                             SourceLocation(),
-+                             ARRFD->getType(), VK_LValue,
-+                             OK_Ordinary);
-+  QualType ConstIdT = Context->getObjCIdType().withConst();
-+  CStyleCastExpr * DictValueObjects = 
-+    NoTypeInfoCStyleCastExpr(Context, 
-+                             Context->getPointerType(ConstIdT),
-+                             CK_BitCast,
-+                             DictLiteralValueME);
-+  // (const id <NSCopying> [])keys
-+  Expr *NSKeyCallExpr = 
-+    new (Context) CallExpr(*Context, NSDictDRE, &KeyExprs[0], KeyExprs.size(),
-+                           NSDictFType, VK_LValue, SourceLocation());
-+  
-+  MemberExpr *DictLiteralKeyME = 
-+    new (Context) MemberExpr(NSKeyCallExpr, false, ARRFD, 
-+                             SourceLocation(),
-+                             ARRFD->getType(), VK_LValue,
-+                             OK_Ordinary);
-+  
-+  CStyleCastExpr * DictKeyObjects = 
-+    NoTypeInfoCStyleCastExpr(Context, 
-+                             Context->getPointerType(ConstIdT),
-+                             CK_BitCast,
-+                             DictLiteralKeyME);
-+  
-+  
-+  
-+  // Synthesize a call to objc_msgSend().
-+  SmallVector<Expr*, 32> MsgExprs;
-+  SmallVector<Expr*, 4> ClsExprs;
-+  QualType argType = Context->getPointerType(Context->CharTy);
-+  QualType expType = Exp->getType();
-+  
-+  // Create a call to objc_getClass("NSArray"). It will be th 1st argument.
-+  ObjCInterfaceDecl *Class = 
-+  expType->getPointeeType()->getAs<ObjCObjectType>()->getInterface();
-+  
-+  IdentifierInfo *clsName = Class->getIdentifier();
-+  ClsExprs.push_back(StringLiteral::Create(*Context,
-+                                           clsName->getName(),
-+                                           StringLiteral::Ascii, false,
-+                                           argType, SourceLocation()));
-+  CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
-+                                               &ClsExprs[0],
-+                                               ClsExprs.size(), 
-+                                               StartLoc, EndLoc);
-+  MsgExprs.push_back(Cls);
-+  
-+  // Create a call to sel_registerName("arrayWithObjects:count:").
-+  // it will be the 2nd argument.
-+  SmallVector<Expr*, 4> SelExprs;
-+  ObjCMethodDecl *DictMethod = Exp->getDictWithObjectsMethod();
-+  SelExprs.push_back(StringLiteral::Create(*Context,
-+                                           DictMethod->getSelector().getAsString(),
-+                                           StringLiteral::Ascii, false,
-+                                           argType, SourceLocation()));
-+  CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
-+                                                  &SelExprs[0], SelExprs.size(),
-+                                                  StartLoc, EndLoc);
-+  MsgExprs.push_back(SelExp);
-+  
-+  // (const id [])objects
-+  MsgExprs.push_back(DictValueObjects);
-+  
-+  // (const id <NSCopying> [])keys
-+  MsgExprs.push_back(DictKeyObjects);
-+  
-+  // (NSUInteger)cnt
-+  Expr *cnt = IntegerLiteral::Create(*Context,
-+                                     llvm::APInt(UnsignedIntSize, NumElements),
-+                                     Context->UnsignedIntTy, SourceLocation());
-+  MsgExprs.push_back(cnt);
-+  
-+  
-+  SmallVector<QualType, 8> ArgTypes;
-+  ArgTypes.push_back(Context->getObjCIdType());
-+  ArgTypes.push_back(Context->getObjCSelType());
-+  for (ObjCMethodDecl::param_iterator PI = DictMethod->param_begin(),
-+       E = DictMethod->param_end(); PI != E; ++PI) {
-+    QualType T = (*PI)->getType();
-+    if (const PointerType* PT = T->getAs<PointerType>()) {
-+      QualType PointeeTy = PT->getPointeeType();
-+      convertToUnqualifiedObjCType(PointeeTy);
-+      T = Context->getPointerType(PointeeTy);
-+    }
-+    ArgTypes.push_back(T);
-+  }
-+  
-+  QualType returnType = Exp->getType();
-+  // Get the type, we will need to reference it in a couple spots.
-+  QualType msgSendType = MsgSendFlavor->getType();
-+  
-+  // Create a reference to the objc_msgSend() declaration.
-+  DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
-+                                               VK_LValue, SourceLocation());
-+  
-+  CastExpr *cast = NoTypeInfoCStyleCastExpr(Context,
-+                                            Context->getPointerType(Context->VoidTy),
-+                                            CK_BitCast, DRE);
-+  
-+  // Now do the "normal" pointer to function cast.
-+  QualType castType =
-+  getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
-+                        DictMethod->isVariadic());
-+  castType = Context->getPointerType(castType);
-+  cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
-+                                  cast);
-+  
-+  // Don't forget the parens to enforce the proper binding.
-+  ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
-+  
-+  const FunctionType *FT = msgSendType->getAs<FunctionType>();
-+  CallExpr *CE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
-+                                        MsgExprs.size(),
-+                                        FT->getResultType(), VK_RValue,
-+                                        EndLoc);
-+  ReplaceStmt(Exp, CE);
-+  return CE;
-+}
-+
-+// struct __rw_objc_super { 
-+//   struct objc_object *object; struct objc_object *superClass; 
-+// };
- // struct objc_super { struct objc_object *receiver; struct objc_class *super; };
- QualType RewriteModernObjC::getSuperStructType() {
-   if (!SuperStructDecl) {
-@@ -4801,6 +5234,19 @@
- 
-   if (ObjCStringLiteral *AtString = dyn_cast<ObjCStringLiteral>(S))
-     return RewriteObjCStringLiteral(AtString);
-+  
-+  if (ObjCBoolLiteralExpr *BoolLitExpr = dyn_cast<ObjCBoolLiteralExpr>(S))
-+    return RewriteObjCBoolLiteralExpr(BoolLitExpr);
-+  
-+  if (ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(S))
-+    return RewriteObjCBoxedExpr(BoxedExpr);
-+  
-+  if (ObjCArrayLiteral *ArrayLitExpr = dyn_cast<ObjCArrayLiteral>(S))
-+    return RewriteObjCArrayLiteralExpr(ArrayLitExpr);
-+  
-+  if (ObjCDictionaryLiteral *DictionaryLitExpr = 
-+        dyn_cast<ObjCDictionaryLiteral>(S))
-+    return RewriteObjCDictionaryLiteralExpr(DictionaryLitExpr);
- 
-   if (ObjCMessageExpr *MessExpr = dyn_cast<ObjCMessageExpr>(S)) {
- #if 0
-Index: lib/Sema/TreeTransform.h
-===================================================================
---- lib/Sema/TreeTransform.h	(revision 152265)
-+++ lib/Sema/TreeTransform.h	(working copy)
-@@ -2211,6 +2211,14 @@
-                                                 RParenLoc);
-   }
- 
-+  /// \brief Build a new Objective-C boxed expression.
-+  ///
-+  /// By default, performs semantic analysis to build the new expression.
-+  /// Subclasses may override this routine to provide different behavior.
-+  ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
-+    return getSema().BuildObjCBoxedExpr(SR, ValueExpr);
-+  }
-+  
-   /// \brief Build a new Objective-C array literal.
-   ///
-   /// By default, performs semantic analysis to build the new expression.
-@@ -8298,8 +8306,16 @@
- 
- template<typename Derived>
- ExprResult
--TreeTransform<Derived>::TransformObjCNumericLiteral(ObjCNumericLiteral *E) {
--  return SemaRef.MaybeBindToTemporary(E);
-+TreeTransform<Derived>::TransformObjCBoxedExpr(ObjCBoxedExpr *E) {
-+  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
-+  if (SubExpr.isInvalid())
-+    return ExprError();
-+
-+  if (!getDerived().AlwaysRebuild() &&
-+      SubExpr.get() == E->getSubExpr())
-+    return SemaRef.Owned(E);
-+
-+  return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
- }
- 
- template<typename Derived>
-Index: lib/Sema/SemaExprCXX.cpp
-===================================================================
---- lib/Sema/SemaExprCXX.cpp	(revision 152265)
-+++ lib/Sema/SemaExprCXX.cpp	(working copy)
-@@ -4469,8 +4469,8 @@
-       ObjCMethodDecl *D = 0;
-       if (ObjCMessageExpr *Send = dyn_cast<ObjCMessageExpr>(E)) {
-         D = Send->getMethodDecl();
--      } else if (ObjCNumericLiteral *NumLit = dyn_cast<ObjCNumericLiteral>(E)) {
--        D = NumLit->getObjCNumericLiteralMethod();
-+      } else if (ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(E)) {
-+        D = BoxedExpr->getBoxingMethod();
-       } else if (ObjCArrayLiteral *ArrayLit = dyn_cast<ObjCArrayLiteral>(E)) {
-         D = ArrayLit->getArrayWithObjectsMethod();
-       } else if (ObjCDictionaryLiteral *DictLit
-@@ -4529,6 +4529,17 @@
-   if (RD->isInvalidDecl() || RD->isDependentContext())
-     return Owned(E);
- 
-+  if (!RD->getDefinition()) {
-+    if (RD->hasExternalLexicalStorage()) {
-+      ExternalASTSource *ext_source = RD->getASTContext().getExternalSource();
-+      if (ext_source)
-+        ext_source->CompleteType(RD);
-+    }
-+  }
-+
-+  if (!RD->getDefinition())
-+    return Owned(E);
-+
-   bool IsDecltype = ExprEvalContexts.back().IsDecltype;
-   CXXDestructorDecl *Destructor = IsDecltype ? 0 : LookupDestructor(RD);
- 
-Index: lib/Sema/SemaExceptionSpec.cpp
-===================================================================
---- lib/Sema/SemaExceptionSpec.cpp	(revision 152265)
-+++ lib/Sema/SemaExceptionSpec.cpp	(working copy)
-@@ -726,4 +726,4 @@
-                                   New->getLocation());
- }
- 
--} // end namespace clang
-+}
-Index: lib/Sema/SemaChecking.cpp
-===================================================================
---- lib/Sema/SemaChecking.cpp	(revision 152265)
-+++ lib/Sema/SemaChecking.cpp	(working copy)
-@@ -4416,12 +4416,16 @@
- 
-   // Don't consider sizes resulting from macro expansions or template argument
-   // substitution to form C89 tail-padded arrays.
--  ConstantArrayTypeLoc TL =
--    cast<ConstantArrayTypeLoc>(FD->getTypeSourceInfo()->getTypeLoc());
--  const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
--  if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
--    return false;
- 
-+  TypeSourceInfo *TInfo = FD->getTypeSourceInfo();
-+  if (TInfo) {
-+    ConstantArrayTypeLoc TL =
-+      cast<ConstantArrayTypeLoc>(TInfo->getTypeLoc());
-+    const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
-+    if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
-+      return false;
-+  }
-+
-   const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
-   if (!RD) return false;
-   if (RD->isUnion()) return false;
-Index: lib/Sema/SemaExprObjC.cpp
-===================================================================
---- lib/Sema/SemaExprObjC.cpp	(revision 152265)
-+++ lib/Sema/SemaExprObjC.cpp	(working copy)
-@@ -111,7 +111,7 @@
-       Ty = Context.getObjCIdType();
-     }
-   } else {
--    IdentifierInfo *NSIdent = &Context.Idents.get("NSString");
-+    IdentifierInfo *NSIdent = NSAPIObj->getNSClassId(NSAPI::ClassId_NSString);
-     NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
-                                      LookupOrdinaryName);
-     if (ObjCInterfaceDecl *StrIF = dyn_cast_or_null<ObjCInterfaceDecl>(IF)) {
-@@ -143,41 +143,70 @@
- /// \brief Retrieve the NSNumber factory method that should be used to create
- /// an Objective-C literal for the given type.
- static ObjCMethodDecl *getNSNumberFactoryMethod(Sema &S, SourceLocation Loc,
--                                                QualType T, QualType ReturnType,
--                                                SourceRange Range) {
-+                                                QualType NumberType,
-+                                                bool isLiteral = false,
-+                                                SourceRange R = SourceRange()) {
-   llvm::Optional<NSAPI::NSNumberLiteralMethodKind> Kind 
--    = S.NSAPIObj->getNSNumberFactoryMethodKind(T);
-+    = S.NSAPIObj->getNSNumberFactoryMethodKind(NumberType);
-   
-   if (!Kind) {
--    S.Diag(Loc, diag::err_invalid_nsnumber_type)
--      << T << Range;
-+    if (isLiteral) {
-+      S.Diag(Loc, diag::err_invalid_nsnumber_type)
-+        << NumberType << R;
-+    }
-     return 0;
-   }
--    
-+  
-   // If we already looked up this method, we're done.
-   if (S.NSNumberLiteralMethods[*Kind])
-     return S.NSNumberLiteralMethods[*Kind];
-   
-   Selector Sel = S.NSAPIObj->getNSNumberLiteralSelector(*Kind,
-                                                         /*Instance=*/false);
-+
-+  ASTContext &CX = S.Context;
-   
-+  // Look up the NSNumber class, if we haven't done so already. It's cached
-+  // in the Sema instance.
-+  if (!S.NSNumberDecl) {
-+    IdentifierInfo *NSNumberId = S.NSAPIObj->getNSClassId(NSAPI::ClassId_NSNumber);
-+    if (S.getLangOptions().DebuggerObjCLiteral) {
-+      // Create a stub definition of NSNumber.
-+      S.NSNumberDecl =  ObjCInterfaceDecl::Create (CX,
-+                                                   CX.getTranslationUnitDecl(),
-+                                                   SourceLocation(),  NSNumberId,
-+                                                   0, SourceLocation());
-+    } else {
-+      // Otherwise, require a declaration of NSNumber.
-+      NamedDecl *IF = S.LookupSingleName(S.TUScope, NSNumberId,
-+                                         Loc, Sema::LookupOrdinaryName);
-+      S.NSNumberDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
-+      if (!S.NSNumberDecl || !S.NSNumberDecl->hasDefinition()) {
-+        S.Diag(Loc, diag::err_undeclared_nsnumber);
-+        return 0;
-+      }
-+    }
-+    
-+    // generate the pointer to NSNumber type.
-+    S.NSNumberPointer = CX.getObjCObjectPointerType(CX.getObjCInterfaceType(S.NSNumberDecl));
-+  }
-+  
-   // Look for the appropriate method within NSNumber.
-   ObjCMethodDecl *Method = S.NSNumberDecl->lookupClassMethod(Sel);;
-   if (!Method && S.getLangOptions().DebuggerObjCLiteral) {
-+    // create a stub definition this NSNumber factory method.
-     TypeSourceInfo *ResultTInfo = 0;
--    Method = ObjCMethodDecl::Create(S.Context, SourceLocation(), SourceLocation(), Sel,
--                           ReturnType,
--                           ResultTInfo,
--                           S.Context.getTranslationUnitDecl(),
--                           false /*Instance*/, false/*isVariadic*/,
--                           /*isSynthesized=*/false,
--                           /*isImplicitlyDeclared=*/true, /*isDefined=*/false,
--                           ObjCMethodDecl::Required,
--                           false);
-+    Method = ObjCMethodDecl::Create(CX, SourceLocation(), SourceLocation(), Sel,
-+                                    S.NSNumberPointer, ResultTInfo, S.NSNumberDecl,
-+                                    /*isInstance=*/false, /*isVariadic=*/false,
-+                                    /*isSynthesized=*/false,
-+                                    /*isImplicitlyDeclared=*/true,
-+                                    /*isDefined=*/false, ObjCMethodDecl::Required,
-+                                    /*HasRelatedResultType=*/false);
-     ParmVarDecl *value = ParmVarDecl::Create(S.Context, Method,
-                                              SourceLocation(), SourceLocation(),
--                                             &S.Context.Idents.get("value"),
--                                             T, /*TInfo=*/0, SC_None, SC_None, 0);
-+                                             &CX.Idents.get("value"),
-+                                             NumberType, /*TInfo=*/0, SC_None, SC_None, 0);
-     Method->setMethodParams(S.Context, value, ArrayRef<SourceLocation>());
-   }
- 
-@@ -202,29 +231,9 @@
-   return Method;
- }
- 
--/// BuildObjCNumericLiteral - builds an ObjCNumericLiteral AST node for the
--/// numeric literal expression. Type of the expression will be "NSNumber *"
--/// or "id" if NSNumber is unavailable.
-+/// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
-+/// numeric literal expression. Type of the expression will be "NSNumber *".
- ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) {
--  // Look up the NSNumber class, if we haven't done so already.
--  if (!NSNumberDecl) {
--    NamedDecl *IF = LookupSingleName(TUScope,
--                                NSAPIObj->getNSClassId(NSAPI::ClassId_NSNumber),
--                                AtLoc, LookupOrdinaryName);
--    NSNumberDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
--    
--    if (!NSNumberDecl && getLangOptions().DebuggerObjCLiteral)
--      NSNumberDecl =  ObjCInterfaceDecl::Create (Context,
--                        Context.getTranslationUnitDecl(),
--                        SourceLocation(), 
--                        NSAPIObj->getNSClassId(NSAPI::ClassId_NSNumber),
--                        0, SourceLocation());
--    if (!NSNumberDecl) {
--      Diag(AtLoc, diag::err_undeclared_nsnumber);
--      return ExprError();
--    }
--  }
--  
-   // Determine the type of the literal.
-   QualType NumberType = Number->getType();
-   if (CharacterLiteral *Char = dyn_cast<CharacterLiteral>(Number)) {
-@@ -249,29 +258,29 @@
-     }
-   }
-   
--  ObjCMethodDecl *Method = 0;
-   // Look for the appropriate method within NSNumber.
-   // Construct the literal.
--  QualType Ty
--    = Context.getObjCObjectPointerType(
--                                    Context.getObjCInterfaceType(NSNumberDecl));
--  Method  = getNSNumberFactoryMethod(*this, AtLoc, 
--                                     NumberType, Ty, 
--                                     Number->getSourceRange());
--
-+  SourceRange NR(Number->getSourceRange());
-+  ObjCMethodDecl *Method = getNSNumberFactoryMethod(*this, AtLoc, NumberType,
-+                                                    true, NR);
-   if (!Method)
-     return ExprError();
- 
-   // Convert the number to the type that the parameter expects.
--  QualType ElementT = Method->param_begin()[0]->getType();
--  ExprResult ConvertedNumber = PerformImplicitConversion(Number, ElementT,
--                                                         AA_Sending);
-+  ParmVarDecl *ParamDecl = Method->param_begin()[0];
-+  InitializedEntity Entity = InitializedEntity::InitializeParameter(Context,
-+                                                                    ParamDecl);
-+  ExprResult ConvertedNumber = PerformCopyInitialization(Entity,
-+                                                         SourceLocation(),
-+                                                         Owned(Number));
-   if (ConvertedNumber.isInvalid())
-     return ExprError();
-   Number = ConvertedNumber.get();
-   
-+  // Use the effective source range of the literal, including the leading '@'.
-   return MaybeBindToTemporary(
--           new (Context) ObjCNumericLiteral(Number, Ty, Method, AtLoc));
-+           new (Context) ObjCBoxedExpr(Number, NSNumberPointer, Method,
-+                                       SourceRange(AtLoc, NR.getEnd())));
- }
- 
- ExprResult Sema::ActOnObjCBoolLiteral(SourceLocation AtLoc, 
-@@ -385,6 +394,154 @@
-            Element->getLocStart(), Element);
- }
- 
-+ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) {
-+  if (ValueExpr->isTypeDependent()) {
-+    ObjCBoxedExpr *BoxedExpr = 
-+      new (Context) ObjCBoxedExpr(ValueExpr, Context.DependentTy, NULL, SR);
-+    return Owned(BoxedExpr);
-+  }
-+  ObjCMethodDecl *BoxingMethod = NULL;
-+  QualType BoxedType;
-+  // Convert the expression to an RValue, so we can check for pointer types...
-+  ExprResult RValue = DefaultFunctionArrayLvalueConversion(ValueExpr);
-+  if (RValue.isInvalid()) {
-+    return ExprError();
-+  }
-+  ValueExpr = RValue.get();
-+  QualType ValueType(ValueExpr->getType());
-+  if (const PointerType *PT = ValueType->getAs<PointerType>()) {
-+    QualType PointeeType = PT->getPointeeType();
-+    if (Context.hasSameUnqualifiedType(PointeeType, Context.CharTy)) {
-+      IdentifierInfo *NSStringId =
-+        NSAPIObj->getNSClassId(NSAPI::ClassId_NSString);
-+      if (getLangOptions().DebuggerObjCLiteral) {
-+        // Support boxed expressions in the debugger w/o NSString declaration.
-+        NSStringDecl = ObjCInterfaceDecl::Create(Context,
-+                                                 Context.getTranslationUnitDecl(),
-+                                                 SourceLocation(), NSStringId,
-+                                                 0, SourceLocation());
-+      }
-+      else {
-+        NamedDecl *Decl = LookupSingleName(TUScope, NSStringId,
-+                                           SR.getBegin(), LookupOrdinaryName);
-+        NSStringDecl = dyn_cast_or_null<ObjCInterfaceDecl>(Decl);
-+
-+        if (!NSStringDecl || !NSStringDecl->hasDefinition()) {
-+          Diag(SR.getBegin(), diag::err_undeclared_nsstring);
-+          return ExprError();
-+        }
-+      }
-+      assert(NSStringDecl && "NSStringDecl should not be NULL");
-+      NSStringPointer =
-+        Context.getObjCObjectPointerType(Context.getObjCInterfaceType(NSStringDecl));
-+      
-+      if (!StringWithUTF8StringMethod) {
-+        IdentifierInfo *II = &Context.Idents.get("stringWithUTF8String");
-+        Selector stringWithUTF8String = Context.Selectors.getUnarySelector(II);
-+
-+        // Look for the appropriate method within NSString.
-+        StringWithUTF8StringMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String);
-+        if (!StringWithUTF8StringMethod && getLangOptions().DebuggerObjCLiteral) {
-+          // Debugger needs to work even if NSString hasn't been defined.
-+          TypeSourceInfo *ResultTInfo = 0;
-+          ObjCMethodDecl *M =
-+            ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(),
-+                                   stringWithUTF8String, NSStringPointer,
-+                                   ResultTInfo, NSStringDecl,
-+                                   /*isInstance=*/false, /*isVariadic=*/false,
-+                                   /*isSynthesized=*/false,
-+                                   /*isImplicitlyDeclared=*/true,
-+                                   /*isDefined=*/false,
-+                                   ObjCMethodDecl::Required,
-+                                   /*HasRelatedResultType=*/false);
-+          ParmVarDecl *value =
-+            ParmVarDecl::Create(Context, M,
-+                                SourceLocation(), SourceLocation(),
-+                                &Context.Idents.get("value"),
-+                                Context.getPointerType(Context.CharTy.withConst()),
-+                                /*TInfo=*/0,
-+                                SC_None, SC_None, 0);
-+          M->setMethodParams(Context, value, ArrayRef<SourceLocation>());
-+          StringWithUTF8StringMethod = M;
-+        }
-+        assert(StringWithUTF8StringMethod &&
-+               "StringWithUTF8StringMethod should not be NULL");
-+      }
-+      
-+      BoxingMethod = StringWithUTF8StringMethod;
-+      BoxedType = NSStringPointer;
-+    }
-+  } else if (ValueType->isBuiltinType()) {
-+    // The other types we support are numeric, char and BOOL/bool. We could also
-+    // provide limited support for structure types, such as NSRange, NSRect, and
-+    // NSSize. See NSValue (NSValueGeometryExtensions) in <Foundation/NSGeometry.h>
-+    // for more details.
-+
-+    // Check for a top-level character literal.
-+    if (const CharacterLiteral *Char =
-+        dyn_cast<CharacterLiteral>(ValueExpr->IgnoreParens())) {
-+      // In C, character literals have type 'int'. That's not the type we want
-+      // to use to determine the Objective-c literal kind.
-+      switch (Char->getKind()) {
-+      case CharacterLiteral::Ascii:
-+        ValueType = Context.CharTy;
-+        break;
-+        
-+      case CharacterLiteral::Wide:
-+        ValueType = Context.getWCharType();
-+        break;
-+        
-+      case CharacterLiteral::UTF16:
-+        ValueType = Context.Char16Ty;
-+        break;
-+        
-+      case CharacterLiteral::UTF32:
-+        ValueType = Context.Char32Ty;
-+        break;
-+      }
-+    }
-+    
-+    // FIXME:  Do I need to do anything special with BoolTy expressions?
-+    
-+    // Look for the appropriate method within NSNumber.
-+    BoxingMethod = getNSNumberFactoryMethod(*this, SR.getBegin(), ValueType);
-+    BoxedType = NSNumberPointer;
-+
-+  } else if (const EnumType *ET = ValueType->getAs<EnumType>()) {
-+    if (!ET->getDecl()->isComplete()) {
-+      Diag(SR.getBegin(), diag::err_objc_incomplete_boxed_expression_type)
-+        << ValueType << ValueExpr->getSourceRange();
-+      return ExprError();
-+    }
-+
-+    BoxingMethod = getNSNumberFactoryMethod(*this, SR.getBegin(),
-+                                            ET->getDecl()->getIntegerType());
-+    BoxedType = NSNumberPointer;
-+  }
-+
-+  if (!BoxingMethod) {
-+    Diag(SR.getBegin(), diag::err_objc_illegal_boxed_expression_type)
-+      << ValueType << ValueExpr->getSourceRange();
-+    return ExprError();
-+  }
-+  
-+  // Convert the expression to the type that the parameter requires.
-+  ParmVarDecl *ParamDecl = BoxingMethod->param_begin()[0];
-+  InitializedEntity Entity = InitializedEntity::InitializeParameter(Context,
-+                                                                    ParamDecl);
-+  ExprResult ConvertedValueExpr = PerformCopyInitialization(Entity,
-+                                                            SourceLocation(),
-+                                                            Owned(ValueExpr));
-+  if (ConvertedValueExpr.isInvalid())
-+    return ExprError();
-+  ValueExpr = ConvertedValueExpr.get();
-+  
-+  ObjCBoxedExpr *BoxedExpr = 
-+    new (Context) ObjCBoxedExpr(ValueExpr, BoxedType,
-+                                      BoxingMethod, SR);
-+  return MaybeBindToTemporary(BoxedExpr);
-+}
-+
- ExprResult Sema::BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr,
-                                         Expr *IndexExpr,
-                                         ObjCMethodDecl *getterMethod,
-@@ -417,21 +574,22 @@
- ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) {
-   // Look up the NSArray class, if we haven't done so already.
-   if (!NSArrayDecl) {
--    NamedDecl *IF = LookupSingleName(TUScope,
--                                 NSAPIObj->getNSClassId(NSAPI::ClassId_NSArray),
--                                 SR.getBegin(),
--                                 LookupOrdinaryName);
--    NSArrayDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
--    if (!NSArrayDecl && getLangOptions().DebuggerObjCLiteral)
-+    if (getLangOptions().DebuggerObjCLiteral) {
-       NSArrayDecl =  ObjCInterfaceDecl::Create (Context,
-                             Context.getTranslationUnitDecl(),
-                             SourceLocation(),
-                             NSAPIObj->getNSClassId(NSAPI::ClassId_NSArray),
-                             0, SourceLocation());
--
--    if (!NSArrayDecl) {
--      Diag(SR.getBegin(), diag::err_undeclared_nsarray);
--      return ExprError();
-+    } else {
-+      NamedDecl *IF = LookupSingleName(TUScope,
-+                                   NSAPIObj->getNSClassId(NSAPI::ClassId_NSArray),
-+                                   SR.getBegin(),
-+                                   LookupOrdinaryName);
-+      NSArrayDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
-+      if (!NSArrayDecl) {
-+        Diag(SR.getBegin(), diag::err_undeclared_nsarray);
-+        return ExprError();
-+      }
-     }
-   }
-   
-Index: lib/Sema/Sema.cpp
-===================================================================
---- lib/Sema/Sema.cpp	(revision 152265)
-+++ lib/Sema/Sema.cpp	(working copy)
-@@ -90,7 +90,9 @@
-     PackContext(0), MSStructPragmaOn(false), VisContext(0),
-     ExprNeedsCleanups(false), LateTemplateParser(0), OpaqueParser(0),
-     IdResolver(pp), StdInitializerList(0), CXXTypeInfoDecl(0), MSVCGuidDecl(0),
--    NSNumberDecl(0), NSArrayDecl(0), ArrayWithObjectsMethod(0), 
-+    NSNumberDecl(0),
-+    NSStringDecl(0), StringWithUTF8StringMethod(0),
-+    NSArrayDecl(0), ArrayWithObjectsMethod(0), 
-     NSDictionaryDecl(0), DictionaryWithObjectsMethod(0),
-     GlobalNewDeleteDeclared(false), 
-     ObjCShouldCallSuperDealloc(false),
-Index: lib/AST/DeclObjC.cpp
-===================================================================
---- lib/AST/DeclObjC.cpp	(revision 152265)
-+++ lib/AST/DeclObjC.cpp	(working copy)
-@@ -330,6 +330,10 @@
-     LoadExternalDefinition();
- 
-   while (ClassDecl != NULL) {
-+    // FIXME: Should make sure no callers ever do this.
-+    if (!ClassDecl->hasDefinition())
-+      return 0;
-+        
-     if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
-       return MethodDecl;
- 
-Index: lib/AST/ASTImporter.cpp
-===================================================================
---- lib/AST/ASTImporter.cpp	(revision 152265)
-+++ lib/AST/ASTImporter.cpp	(working copy)
-@@ -119,7 +119,8 @@
-     bool ImportTemplateArguments(const TemplateArgument *FromArgs,
-                                  unsigned NumFromArgs,
-                                SmallVectorImpl<TemplateArgument> &ToArgs);
--    bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord);
-+    bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord,
-+                           bool Complain = true);
-     bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord);
-     bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To);
-     Decl *VisitDecl(Decl *D);
-@@ -201,12 +202,16 @@
-     /// \brief Whether we're being strict about the spelling of types when 
-     /// unifying two types.
-     bool StrictTypeSpelling;
--    
-+
-+    /// \brief Whether to complain about failures.
-+    bool Complain;
-+
-     StructuralEquivalenceContext(ASTContext &C1, ASTContext &C2,
-                llvm::DenseSet<std::pair<Decl *, Decl *> > &NonEquivalentDecls,
--                                 bool StrictTypeSpelling = false)
-+                                 bool StrictTypeSpelling = false,
-+                                 bool Complain = true)
-       : C1(C1), C2(C2), NonEquivalentDecls(NonEquivalentDecls),
--        StrictTypeSpelling(StrictTypeSpelling) { }
-+        StrictTypeSpelling(StrictTypeSpelling), Complain(Complain) { }
- 
-     /// \brief Determine whether the two declarations are structurally
-     /// equivalent.
-@@ -223,10 +228,16 @@
-     
-   public:
-     DiagnosticBuilder Diag1(SourceLocation Loc, unsigned DiagID) {
-+      if (!Complain)
-+        return DiagnosticBuilder(DiagnosticBuilder::Suppress);
-+
-       return C1.getDiagnostics().Report(Loc, DiagID);
-     }
- 
-     DiagnosticBuilder Diag2(SourceLocation Loc, unsigned DiagID) {
-+      if (!Complain)
-+        return DiagnosticBuilder(DiagnosticBuilder::Suppress);
-+      
-       return C2.getDiagnostics().Report(Loc, DiagID);
-     }
-   };
-@@ -2050,10 +2061,12 @@
- }
- 
- bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord, 
--                                        RecordDecl *ToRecord) {
-+                                        RecordDecl *ToRecord,
-+                                        bool Complain) {
-   StructuralEquivalenceContext Ctx(Importer.getFromContext(),
-                                    Importer.getToContext(),
--                                   Importer.getNonEquivalentDecls());
-+                                   Importer.getNonEquivalentDecls(),
-+                                   false, Complain);
-   return Ctx.IsStructurallyEquivalent(FromRecord, ToRecord);
- }
- 
-@@ -2333,7 +2346,7 @@
- 
-   // We may already have a record of the same name; try to find and match it.
-   RecordDecl *AdoptDecl = 0;
--  if (!DC->isFunctionOrMethod() && SearchName) {
-+  if (!DC->isFunctionOrMethod()) {
-     SmallVector<NamedDecl *, 4> ConflictingDecls;
-     llvm::SmallVector<NamedDecl *, 2> FoundDecls;
-     DC->localUncachedLookup(SearchName, FoundDecls);
-@@ -2349,26 +2362,32 @@
-       
-       if (RecordDecl *FoundRecord = dyn_cast<RecordDecl>(Found)) {
-         if (RecordDecl *FoundDef = FoundRecord->getDefinition()) {
--          if (!D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
-+          if ((SearchName && !D->isCompleteDefinition()) ||
-+              (D->isCompleteDefinition() &&
-+               D->isAnonymousStructOrUnion()
-+                 == FoundDef->isAnonymousStructOrUnion() &&
-+               IsStructuralMatch(D, FoundDef, SearchName))) {
-             // The record types structurally match, or the "from" translation
-             // unit only had a forward declaration anyway; call it the same
-             // function.
-             // FIXME: For C++, we should also merge methods here.
-             return Importer.Imported(D, FoundDef);
-           }
--        } else {
-+        } else if (!D->isCompleteDefinition()) {
-           // We have a forward declaration of this type, so adopt that forward
-           // declaration rather than building a new one.
-           AdoptDecl = FoundRecord;
-           continue;
--        }          
-+        } else if (!SearchName) {
-+          continue;
-+        }
-       }
-       
-       ConflictingDecls.push_back(FoundDecls[I]);
-     }
-     
--    if (!ConflictingDecls.empty()) {
--      Name = Importer.HandleNameConflict(Name, DC, IDNS,
-+    if (!ConflictingDecls.empty() && SearchName) {
-+      Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
-                                          ConflictingDecls.data(), 
-                                          ConflictingDecls.size());
-     }
-@@ -2393,6 +2412,8 @@
-     D2->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
-     D2->setLexicalDeclContext(LexicalDC);
-     LexicalDC->addDeclInternal(D2);
-+    if (D->isAnonymousStructOrUnion())
-+      D2->setAnonymousStructOrUnion(true);
-   }
-   
-   Importer.Imported(D, D2);
-@@ -2631,12 +2652,17 @@
-   DC->localUncachedLookup(Name, FoundDecls);
-   for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
-     if (FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecls[I])) {
--      if (Importer.IsStructurallyEquivalent(D->getType(), 
--                                            FoundField->getType())) {
-+      if (Importer.IsStructurallyEquivalent(D->getType(),
-+                                            FoundField->getType(),
-+                                            Name)) {
-         Importer.Imported(D, FoundField);
-         return FoundField;
-       }
--      
-+
-+      // If there are more anonymous fields to check, continue.
-+      if (!Name && I < N-1)
-+        continue;
-+
-       Importer.ToDiag(Loc, diag::err_odr_field_type_inconsistent)
-         << Name << D->getType() << FoundField->getType();
-       Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
-@@ -4662,12 +4688,14 @@
-   return To;
- }
- 
--bool ASTImporter::IsStructurallyEquivalent(QualType From, QualType To) {
-+bool ASTImporter::IsStructurallyEquivalent(QualType From, QualType To,
-+                                           bool Complain) {
-   llvm::DenseMap<const Type *, const Type *>::iterator Pos
-    = ImportedTypes.find(From.getTypePtr());
-   if (Pos != ImportedTypes.end() && ToContext.hasSameType(Import(From), To))
-     return true;
-       
--  StructuralEquivalenceContext Ctx(FromContext, ToContext, NonEquivalentDecls);
-+  StructuralEquivalenceContext Ctx(FromContext, ToContext, NonEquivalentDecls,
-+                                   false, Complain);
-   return Ctx.IsStructurallyEquivalent(From, To);
- }
-Index: lib/AST/NSAPI.cpp
-===================================================================
---- lib/AST/NSAPI.cpp	(revision 152265)
-+++ lib/AST/NSAPI.cpp	(working copy)
-@@ -13,7 +13,7 @@
- using namespace clang;
- 
- NSAPI::NSAPI(ASTContext &ctx)
--  : Ctx(ctx), ClassIds() {
-+  : Ctx(ctx), ClassIds(), BOOLId(0), NSIntegerId(0), NSUIntegerId(0) {
- }
- 
- IdentifierInfo *NSAPI::getNSClassId(NSClassIdKindKind K) const {
-@@ -250,11 +250,22 @@
- }
- 
- llvm::Optional<NSAPI::NSNumberLiteralMethodKind>
--NSAPI::getNSNumberFactoryMethodKind(QualType T) {
-+NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
-   const BuiltinType *BT = T->getAs<BuiltinType>();
-   if (!BT)
-     return llvm::Optional<NSAPI::NSNumberLiteralMethodKind>();
--  
-+
-+  const TypedefType *TDT = T->getAs<TypedefType>();
-+  if (TDT) {
-+    QualType TDTTy = QualType(TDT, 0);
-+    if (isObjCBOOLType(TDTTy))
-+      return NSAPI::NSNumberWithBool;
-+    if (isObjCNSIntegerType(TDTTy))
-+      return NSAPI::NSNumberWithInteger;
-+    if (isObjCNSUIntegerType(TDTTy))
-+      return NSAPI::NSNumberWithUnsignedInteger;
-+  }
-+
-   switch (BT->getKind()) {
-   case BuiltinType::Char_S:
-   case BuiltinType::SChar:
-@@ -309,3 +320,35 @@
-   
-   return llvm::Optional<NSAPI::NSNumberLiteralMethodKind>();
- }
-+
-+/// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
-+bool NSAPI::isObjCBOOLType(QualType T) const {
-+  return isObjCTypedef(T, "BOOL", BOOLId);
-+}
-+/// \brief Returns true if \param T is a typedef of "NSInteger" in objective-c.
-+bool NSAPI::isObjCNSIntegerType(QualType T) const {
-+  return isObjCTypedef(T, "NSInteger", NSIntegerId);
-+}
-+/// \brief Returns true if \param T is a typedef of "NSUInteger" in objective-c.
-+bool NSAPI::isObjCNSUIntegerType(QualType T) const {
-+  return isObjCTypedef(T, "NSUInteger", NSUIntegerId);
-+}
-+
-+bool NSAPI::isObjCTypedef(QualType T,
-+                          StringRef name, IdentifierInfo *&II) const {
-+  if (!Ctx.getLangOptions().ObjC1)
-+    return false;
-+  if (T.isNull())
-+    return false;
-+
-+  if (!II)
-+    II = &Ctx.Idents.get(name);
-+
-+  while (const TypedefType *TDT = T->getAs<TypedefType>()) {
-+    if (TDT->getDecl()->getDeclName().getAsIdentifierInfo() == II)
-+      return true;
-+    T = TDT->desugar();
-+  }
-+
-+  return false;
-+}
-Index: lib/AST/DeclPrinter.cpp
-===================================================================
---- lib/AST/DeclPrinter.cpp	(revision 152265)
-+++ lib/AST/DeclPrinter.cpp	(working copy)
-@@ -114,6 +114,8 @@
-       BaseType = FTy->getResultType();
-     else if (const VectorType *VTy = BaseType->getAs<VectorType>())
-       BaseType = VTy->getElementType();
-+    else if (const ReferenceType *RTy = BaseType->getAs<ReferenceType>())
-+      BaseType = RTy->getPointeeType();
-     else
-       llvm_unreachable("Unknown declarator!");
-   }
-Index: lib/AST/Type.cpp
-===================================================================
---- lib/AST/Type.cpp	(revision 152265)
-+++ lib/AST/Type.cpp	(working copy)
-@@ -288,6 +288,28 @@
-   return T;
- }
- 
-+/// \brief This will check for a TypedefType by removing any existing sugar
-+/// until it reaches a TypedefType or a non-sugared type.
-+template <> const TypedefType *Type::getAs() const {
-+  const Type *Cur = this;
-+
-+  while (true) {
-+    if (const TypedefType *TDT = dyn_cast<TypedefType>(Cur))
-+      return TDT;
-+    switch (Cur->getTypeClass()) {
-+#define ABSTRACT_TYPE(Class, Parent)
-+#define TYPE(Class, Parent) \
-+    case Class: { \
-+      const Class##Type *Ty = cast<Class##Type>(Cur); \
-+      if (!Ty->isSugared()) return 0; \
-+      Cur = Ty->desugar().getTypePtr(); \
-+      break; \
-+    }
-+#include "clang/AST/TypeNodes.def"
-+    }
-+  }
-+}
-+
- /// getUnqualifiedDesugaredType - Pull any qualifiers and syntactic
- /// sugar off the given type.  This should produce an object of the
- /// same dynamic type as the canonical type.
-Index: lib/AST/RecordLayoutBuilder.cpp
-===================================================================
---- lib/AST/RecordLayoutBuilder.cpp	(revision 152265)
-+++ lib/AST/RecordLayoutBuilder.cpp	(working copy)
-@@ -2313,6 +2313,8 @@
- ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
-                           const ObjCImplementationDecl *Impl) const {
-   // Retrieve the definition
-+  if (D->hasExternalLexicalStorage() && !D->getDefinition())
-+    getExternalSource()->CompleteType(const_cast<ObjCInterfaceDecl*>(D));
-   D = D->getDefinition();
-   assert(D && D->isThisDeclarationADefinition() && "Invalid interface decl!");
- 
-Index: lib/AST/ExprConstant.cpp
-===================================================================
---- lib/AST/ExprConstant.cpp	(revision 152265)
-+++ lib/AST/ExprConstant.cpp	(working copy)
-@@ -3054,7 +3054,7 @@
-   bool VisitUnaryAddrOf(const UnaryOperator *E);
-   bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
-       { return Success(E); }
--  bool VisitObjCNumericLiteral(const ObjCNumericLiteral *E)
-+  bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E)
-       { return Success(E); }    
-   bool VisitAddrLabelExpr(const AddrLabelExpr *E)
-       { return Success(E); }
-@@ -4210,7 +4210,7 @@
- /// character of a string literal.
- template<typename LValue>
- static bool EvaluateBuiltinConstantPForLValue(const LValue &LV) {
--  const Expr *E = LV.getLValueBase().dyn_cast<const Expr*>();
-+  const Expr *E = LV.getLValueBase().template dyn_cast<const Expr*>();
-   return E && isa<StringLiteral>(E) && LV.getLValueOffset().isZero();
- }
- 
-@@ -6259,7 +6259,7 @@
-   case Expr::CXXDependentScopeMemberExprClass:
-   case Expr::UnresolvedMemberExprClass:
-   case Expr::ObjCStringLiteralClass:
--  case Expr::ObjCNumericLiteralClass:
-+  case Expr::ObjCBoxedExprClass:
-   case Expr::ObjCArrayLiteralClass:
-   case Expr::ObjCDictionaryLiteralClass:
-   case Expr::ObjCEncodeExprClass:
-Index: lib/AST/ItaniumMangle.cpp
-===================================================================
---- lib/AST/ItaniumMangle.cpp	(revision 152265)
-+++ lib/AST/ItaniumMangle.cpp	(working copy)
-@@ -2374,7 +2374,7 @@
-   case Expr::ObjCProtocolExprClass:
-   case Expr::ObjCSelectorExprClass:
-   case Expr::ObjCStringLiteralClass:
--  case Expr::ObjCNumericLiteralClass:
-+  case Expr::ObjCBoxedExprClass:
-   case Expr::ObjCArrayLiteralClass:
-   case Expr::ObjCDictionaryLiteralClass:
-   case Expr::ObjCSubscriptRefExprClass:
-Index: lib/AST/StmtPrinter.cpp
-===================================================================
---- lib/AST/StmtPrinter.cpp	(revision 152265)
-+++ lib/AST/StmtPrinter.cpp	(working copy)
-@@ -1679,9 +1679,9 @@
-   VisitStringLiteral(Node->getString());
- }
- 
--void StmtPrinter::VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
-+void StmtPrinter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
-   OS << "@";
--  Visit(E->getNumber());
-+  Visit(E->getSubExpr());
- }
- 
- void StmtPrinter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
-Index: lib/AST/DeclBase.cpp
-===================================================================
---- lib/AST/DeclBase.cpp	(revision 152265)
-+++ lib/AST/DeclBase.cpp	(working copy)
-@@ -1153,14 +1153,14 @@
-   
-   // If there's no external storage, just perform a normal lookup and copy
-   // the results.
--  if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage()) {
-+  if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) {
-     lookup_result LookupResults = lookup(Name);
-     Results.insert(Results.end(), LookupResults.first, LookupResults.second);
-     return;
-   }
- 
-   // If we have a lookup table, check there first. Maybe we'll get lucky.
--  if (LookupPtr) {
-+  if (LookupPtr && Name) {
-     StoredDeclsMap::iterator Pos = LookupPtr->find(Name);
-     if (Pos != LookupPtr->end()) {
-       Results.insert(Results.end(), 
-Index: lib/AST/StmtProfile.cpp
-===================================================================
---- lib/AST/StmtProfile.cpp	(revision 152265)
-+++ lib/AST/StmtProfile.cpp	(working copy)
-@@ -982,7 +982,7 @@
-   VisitExpr(S);
- }
- 
--void StmtProfiler::VisitObjCNumericLiteral(const ObjCNumericLiteral *E) {
-+void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
-   VisitExpr(E);
- }
- 
-Index: lib/AST/Expr.cpp
-===================================================================
---- lib/AST/Expr.cpp	(revision 152265)
-+++ lib/AST/Expr.cpp	(working copy)
-@@ -2100,7 +2100,7 @@
-   case ObjCArrayLiteralClass:
-   case ObjCBoolLiteralExprClass:
-   case ObjCDictionaryLiteralClass:
--  case ObjCNumericLiteralClass:
-+  case ObjCBoxedExprClass:
-     return CT_Can;
- 
-     // Many other things have subexpressions, so we have to test those.
-Index: lib/AST/ExprClassification.cpp
-===================================================================
---- lib/AST/ExprClassification.cpp	(revision 152265)
-+++ lib/AST/ExprClassification.cpp	(working copy)
-@@ -158,7 +158,7 @@
-   case Expr::ObjCSelectorExprClass:
-   case Expr::ObjCProtocolExprClass:
-   case Expr::ObjCStringLiteralClass:
--  case Expr::ObjCNumericLiteralClass:
-+  case Expr::ObjCBoxedExprClass:
-   case Expr::ObjCArrayLiteralClass:
-   case Expr::ObjCDictionaryLiteralClass:
-   case Expr::ObjCBoolLiteralExprClass:
-Index: lib/Lex/PPMacroExpansion.cpp
-===================================================================
---- lib/Lex/PPMacroExpansion.cpp	(revision 152265)
-+++ lib/Lex/PPMacroExpansion.cpp	(working copy)
-@@ -634,6 +634,7 @@
-            .Case("objc_subscripting", LangOpts.ObjCNonFragileABI)
-            .Case("objc_array_literals", LangOpts.ObjC2)
-            .Case("objc_dictionary_literals", LangOpts.ObjC2)
-+           .Case("objc_boxed_expressions", LangOpts.ObjC2)
-            .Case("arc_cf_code_audited", true)
-            // C11 features
-            .Case("c_alignas", LangOpts.C11)
-Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
-===================================================================
---- lib/StaticAnalyzer/Core/ExprEngine.cpp	(revision 152265)
-+++ lib/StaticAnalyzer/Core/ExprEngine.cpp	(working copy)
-@@ -590,7 +590,7 @@
-     case Stmt::ObjCIsaExprClass:
-     case Stmt::ObjCProtocolExprClass:
-     case Stmt::ObjCSelectorExprClass:
--    case Expr::ObjCNumericLiteralClass:
-+    case Expr::ObjCBoxedExprClass:
-     case Stmt::ParenListExprClass:
-     case Stmt::PredefinedExprClass:
-     case Stmt::ShuffleVectorExprClass:
-Index: lib/CodeGen/CGExprScalar.cpp
-===================================================================
---- lib/CodeGen/CGExprScalar.cpp	(revision 152265)
-+++ lib/CodeGen/CGExprScalar.cpp	(working copy)
-@@ -531,8 +531,8 @@
-   Value *VisitObjCStringLiteral(const ObjCStringLiteral *E) {
-     return CGF.EmitObjCStringLiteral(E);
-   }
--  Value *VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
--    return CGF.EmitObjCNumericLiteral(E);
-+  Value *VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
-+    return CGF.EmitObjCBoxedExpr(E);
-   }
-   Value *VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
-     return CGF.EmitObjCArrayLiteral(E);
-Index: lib/CodeGen/CGObjC.cpp
-===================================================================
---- lib/CodeGen/CGObjC.cpp	(revision 152265)
-+++ lib/CodeGen/CGObjC.cpp	(working copy)
-@@ -51,35 +51,36 @@
-   return llvm::ConstantExpr::getBitCast(C, ConvertType(E->getType()));
- }
- 
--/// EmitObjCNumericLiteral - This routine generates code for
--/// the appropriate +[NSNumber numberWith<Type>:] method.
-+/// EmitObjCBoxedExpr - This routine generates code to call
-+/// the appropriate expression boxing method. This will either be
-+/// one of +[NSNumber numberWith<Type>:], or +[NSString stringWithUTF8String:].
- ///
--llvm::Value *CodeGenFunction::EmitObjCNumericLiteral(const ObjCNumericLiteral *E) {
-+llvm::Value *
-+CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) {
-   // Generate the correct selector for this literal's concrete type.
--  const Expr *NL = E->getNumber();
-+  const Expr *SubExpr = E->getSubExpr();
-   // Get the method.
--  const ObjCMethodDecl *Method = E->getObjCNumericLiteralMethod();
--  assert(Method && "NSNumber method is null");
--  Selector Sel = Method->getSelector();
-+  const ObjCMethodDecl *BoxingMethod = E->getBoxingMethod();
-+  assert(BoxingMethod && "BoxingMethod is null");
-+  assert(BoxingMethod->isClassMethod() && "BoxingMethod must be a class method");
-+  Selector Sel = BoxingMethod->getSelector();
-   
-   // Generate a reference to the class pointer, which will be the receiver.
--  QualType ResultType = E->getType(); // should be NSNumber *
--  const ObjCObjectPointerType *InterfacePointerType = 
--    ResultType->getAsObjCInterfacePointerType();
--  ObjCInterfaceDecl *NSNumberDecl = 
--    InterfacePointerType->getObjectType()->getInterface();
-+  // Assumes that the method was introduced in the class that should be
-+  // messaged (avoids pulling it out of the result type).
-   CGObjCRuntime &Runtime = CGM.getObjCRuntime();
--  llvm::Value *Receiver = Runtime.GetClass(Builder, NSNumberDecl);
--
--  const ParmVarDecl *argDecl = *Method->param_begin();
-+  const ObjCInterfaceDecl *ClassDecl = BoxingMethod->getClassInterface();
-+  llvm::Value *Receiver = Runtime.GetClass(Builder, ClassDecl);
-+  
-+  const ParmVarDecl *argDecl = *BoxingMethod->param_begin();
-   QualType ArgQT = argDecl->getType().getUnqualifiedType();
--  RValue RV = EmitAnyExpr(NL);
-+  RValue RV = EmitAnyExpr(SubExpr);
-   CallArgList Args;
-   Args.add(RV, ArgQT);
--
-+  
-   RValue result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), 
--                                              ResultType, Sel, Receiver, Args, 
--                                              NSNumberDecl, Method);
-+                                              BoxingMethod->getResultType(), Sel, Receiver, Args, 
-+                                              ClassDecl, BoxingMethod);
-   return Builder.CreateBitCast(result.getScalarVal(), 
-                                ConvertType(E->getType()));
- }
-Index: lib/CodeGen/CodeGenTypes.cpp
-===================================================================
---- lib/CodeGen/CodeGenTypes.cpp	(revision 152265)
-+++ lib/CodeGen/CodeGenTypes.cpp	(working copy)
-@@ -133,6 +133,14 @@
-   // when a class is translated, even though they aren't embedded by-value into
-   // the class.
-   if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
-+    if (!CRD->hasDefinition() && CRD->hasExternalLexicalStorage()) {
-+      ExternalASTSource *EAS = CRD->getASTContext().getExternalSource();
-+      if (!EAS)
-+        return false;
-+      EAS->CompleteType(const_cast<CXXRecordDecl*>(CRD));
-+      if (!CRD->hasDefinition())
-+        return false;
-+    }
-     for (CXXRecordDecl::base_class_const_iterator I = CRD->bases_begin(),
-          E = CRD->bases_end(); I != E; ++I)
-       if (!isSafeToConvert(I->getType()->getAs<RecordType>()->getDecl(),
-Index: lib/CodeGen/CodeGenFunction.h
-===================================================================
---- lib/CodeGen/CodeGenFunction.h	(revision 152265)
-+++ lib/CodeGen/CodeGenFunction.h	(working copy)
-@@ -2238,7 +2238,7 @@
- 
-   llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);
-   llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
--  llvm::Value *EmitObjCNumericLiteral(const ObjCNumericLiteral *E);
-+  llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E);
-   llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E);
-   llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E);
-   llvm::Value *EmitObjCCollectionLiteral(const Expr *E,
-Index: lib/Parse/ParseObjc.cpp
-===================================================================
---- lib/Parse/ParseObjc.cpp	(revision 152265)
-+++ lib/Parse/ParseObjc.cpp	(working copy)
-@@ -2067,6 +2067,10 @@
-     // Objective-C dictionary literal
-     return ParsePostfixExpressionSuffix(ParseObjCDictionaryLiteral(AtLoc));
-           
-+  case tok::l_paren:
-+    // Objective-C boxed expression
-+    return ParsePostfixExpressionSuffix(ParseObjCBoxedExpr(AtLoc));
-+          
-   default:
-     if (Tok.getIdentifierInfo() == 0)
-       return ExprError(Diag(AtLoc, diag::err_unexpected_at));
-@@ -2581,6 +2585,31 @@
-   return Owned(Actions.BuildObjCNumericLiteral(AtLoc, Lit.take()));
- }
- 
-+/// ParseObjCBoxedExpr -
-+/// objc-box-expression:
-+///       @( assignment-expression )
-+ExprResult
-+Parser::ParseObjCBoxedExpr(SourceLocation AtLoc) {
-+  if (Tok.isNot(tok::l_paren))
-+    return ExprError(Diag(Tok, diag::err_expected_lparen_after) << "@");
-+
-+  BalancedDelimiterTracker T(*this, tok::l_paren);
-+  T.consumeOpen();
-+  ExprResult ValueExpr(ParseAssignmentExpression());
-+  if (T.consumeClose())
-+    return ExprError();
-+
-+  if (ValueExpr.isInvalid())
-+    return ExprError();
-+  
-+  // Wrap the sub-expression in a parenthesized expression, to distinguish
-+  // a boxed expression from a literal.
-+  SourceLocation LPLoc = T.getOpenLocation(), RPLoc = T.getCloseLocation();
-+  ValueExpr = Actions.ActOnParenExpr(LPLoc, RPLoc, ValueExpr.take());
-+  return Owned(Actions.BuildObjCBoxedExpr(SourceRange(AtLoc, RPLoc),
-+                                          ValueExpr.take()));
-+}
-+
- ExprResult Parser::ParseObjCArrayLiteral(SourceLocation AtLoc) {
-   ExprVector ElementExprs(Actions);                   // array elements.
-   ConsumeBracket(); // consume the l_square.
-Index: lib/Serialization/ASTReaderStmt.cpp
-===================================================================
---- lib/Serialization/ASTReaderStmt.cpp	(revision 152265)
-+++ lib/Serialization/ASTReaderStmt.cpp	(working copy)
-@@ -823,12 +823,12 @@
-   E->setAtLoc(ReadSourceLocation(Record, Idx));
- }
- 
--void ASTStmtReader::VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
-+void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
-   VisitExpr(E);
-   // could be one of several IntegerLiteral, FloatLiteral, etc.
--  E->Number = Reader.ReadSubStmt();
--  E->ObjCNumericLiteralMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
--  E->AtLoc = ReadSourceLocation(Record, Idx);
-+  E->SubExpr = Reader.ReadSubStmt();
-+  E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
-+  E->Range = ReadSourceRange(Record, Idx);
- }
- 
- void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
-@@ -1893,8 +1893,8 @@
-     case EXPR_OBJC_STRING_LITERAL:
-       S = new (Context) ObjCStringLiteral(Empty);
-       break;
--    case EXPR_OBJC_NUMERIC_LITERAL:
--      S = new (Context) ObjCNumericLiteral(Empty);
-+    case EXPR_OBJC_BOXED_EXPRESSION:
-+      S = new (Context) ObjCBoxedExpr(Empty);
-       break;
-     case EXPR_OBJC_ARRAY_LITERAL:
-       S = ObjCArrayLiteral::CreateEmpty(Context,
-Index: lib/Serialization/ASTWriter.cpp
-===================================================================
---- lib/Serialization/ASTWriter.cpp	(revision 152265)
-+++ lib/Serialization/ASTWriter.cpp	(working copy)
-@@ -696,7 +696,7 @@
-   RECORD(EXPR_BLOCK_DECL_REF);
-   RECORD(EXPR_GENERIC_SELECTION);
-   RECORD(EXPR_OBJC_STRING_LITERAL);
--  RECORD(EXPR_OBJC_NUMERIC_LITERAL);
-+  RECORD(EXPR_OBJC_BOXED_EXPRESSION);
-   RECORD(EXPR_OBJC_ARRAY_LITERAL);
-   RECORD(EXPR_OBJC_DICTIONARY_LITERAL);
-   RECORD(EXPR_OBJC_ENCODE);
-Index: lib/Serialization/ASTWriterStmt.cpp
-===================================================================
---- lib/Serialization/ASTWriterStmt.cpp	(revision 152265)
-+++ lib/Serialization/ASTWriterStmt.cpp	(working copy)
-@@ -783,12 +783,12 @@
-   Code = serialization::EXPR_OBJC_STRING_LITERAL;
- }
- 
--void ASTStmtWriter::VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
-+void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
-   VisitExpr(E);
--  Writer.AddStmt(E->getNumber());
--  Writer.AddDeclRef(E->getObjCNumericLiteralMethod(), Record);
--  Writer.AddSourceLocation(E->getAtLoc(), Record);
--  Code = serialization::EXPR_OBJC_NUMERIC_LITERAL;
-+  Writer.AddStmt(E->getSubExpr());
-+  Writer.AddDeclRef(E->getBoxingMethod(), Record);
-+  Writer.AddSourceRange(E->getSourceRange(), Record);
-+  Code = serialization::EXPR_OBJC_BOXED_EXPRESSION;
- }
- 
- void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
diff --git a/scripts/clang.utfroutines.diff b/scripts/clang.utfroutines.diff
deleted file mode 100644
index de134ef..0000000
--- a/scripts/clang.utfroutines.diff
+++ /dev/null
@@ -1,12 +0,0 @@
-Index: include/clang/Basic/ConvertUTF.h
-===================================================================
---- include/clang/Basic/ConvertUTF.h	(revision 152265)
-+++ include/clang/Basic/ConvertUTF.h	(working copy)
-@@ -135,6 +135,7 @@
-   const UTF8** sourceStart, const UTF8* sourceEnd,
-   UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
- 
-+#define CLANG_NEEDS_THESE_ONE_DAY // LLDB wants these functions
- #ifdef CLANG_NEEDS_THESE_ONE_DAY
- ConversionResult ConvertUTF16toUTF8 (
-   const UTF16** sourceStart, const UTF16* sourceEnd,
diff --git a/scripts/llvm.amalgamated.diff b/scripts/llvm.amalgamated.diff
deleted file mode 100644
index 2a34f28..0000000
--- a/scripts/llvm.amalgamated.diff
+++ /dev/null
@@ -1,1543 +0,0 @@
-Index: include/llvm/ADT/PointerUnion.h
-===================================================================
---- include/llvm/ADT/PointerUnion.h	(revision 152265)
-+++ include/llvm/ADT/PointerUnion.h	(working copy)
-@@ -266,7 +266,7 @@
-         ::llvm::PointerUnionTypeSelector<PT1, T, IsInnerUnion,
-           ::llvm::PointerUnionTypeSelector<PT2, T, IsInnerUnion, IsPT3 >
-                                                                    >::Return Ty;
--      return Ty(Val).is<T>();
-+      return Ty(Val).template is<T>();
-     }
-     
-     /// get<T>() - Return the value of the specified pointer type. If the
-@@ -279,7 +279,7 @@
-         ::llvm::PointerUnionTypeSelector<PT1, T, IsInnerUnion,
-           ::llvm::PointerUnionTypeSelector<PT2, T, IsInnerUnion, IsPT3 >
-                                                                    >::Return Ty;
--      return Ty(Val).get<T>();
-+      return Ty(Val).template get<T>();
-     }
-     
-     /// dyn_cast<T>() - If the current value is of the specified pointer type,
-Index: include/llvm/ADT/IntervalMap.h
-===================================================================
---- include/llvm/ADT/IntervalMap.h	(revision 152265)
-+++ include/llvm/ADT/IntervalMap.h	(working copy)
-@@ -1977,7 +1977,7 @@
-     CurSize[Nodes] = CurSize[NewNode];
-     Node[Nodes] = Node[NewNode];
-     CurSize[NewNode] = 0;
--    Node[NewNode] = this->map->newNode<NodeT>();
-+    Node[NewNode] = this->map->template newNode<NodeT>();
-     ++Nodes;
-   }
- 
-Index: utils/TableGen/X86RecognizableInstr.cpp
-===================================================================
---- utils/TableGen/X86RecognizableInstr.cpp	(revision 152265)
-+++ utils/TableGen/X86RecognizableInstr.cpp	(working copy)
-@@ -405,13 +405,13 @@
-     return FILTER_STRONG;
-     
-     
--  // Filter out artificial instructions
-+  // Filter out artificial instructions but leave in the LOCK_PREFIX so it is
-+  // printed as a separate "instruction".
-     
-   if (Name.find("_Int") != Name.npos       ||
-       Name.find("Int_") != Name.npos       ||
-       Name.find("_NOREX") != Name.npos     ||
--      Name.find("2SDL") != Name.npos       ||
--      Name == "LOCK_PREFIX")
-+      Name.find("2SDL") != Name.npos)
-     return FILTER_STRONG;
- 
-   // Filter out instructions with segment override prefixes.
-Index: lib/Target/ARM/ARMJITInfo.cpp
-===================================================================
---- lib/Target/ARM/ARMJITInfo.cpp	(revision 152265)
-+++ lib/Target/ARM/ARMJITInfo.cpp	(working copy)
-@@ -61,7 +61,7 @@
-     // concerned, so we can't just preserve the callee saved regs.
-     "stmdb sp!, {r0, r1, r2, r3, lr}\n"
- #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
--    "fstmfdd sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
-+    "vstmdb sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
- #endif
-     // The LR contains the address of the stub function on entry.
-     // pass it as the argument to the C part of the callback
-@@ -85,7 +85,7 @@
-     //
- #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
-     // Restore VFP caller-saved registers.
--    "fldmfdd sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
-+    "vldmia sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
- #endif
-     //
-     //      We need to exchange the values in slots 0 and 1 so we can
-Index: lib/Target/ARM/ARMInstrNEON.td
-===================================================================
---- lib/Target/ARM/ARMInstrNEON.td	(revision 152265)
-+++ lib/Target/ARM/ARMInstrNEON.td	(working copy)
-@@ -4795,12 +4795,12 @@
- 
- // Vector Swap
- def  VSWPd    : N2VX<0b11, 0b11, 0b00, 0b10, 0b00000, 0, 0,
--                     (outs DPR:$Vd, DPR:$Vd1), (ins DPR:$Vm, DPR:$Vm1),
--                     NoItinerary, "vswp", "$Vd, $Vd1", "$Vm = $Vd, $Vm1 = $Vd1",
-+                     (outs DPR:$Vd, DPR:$Vm), (ins DPR:$in1, DPR:$in2),
-+                     NoItinerary, "vswp", "$Vd, $Vm", "$in1 = $Vd, $in2 = $Vm",
-                      []>;
- def  VSWPq    : N2VX<0b11, 0b11, 0b00, 0b10, 0b00000, 1, 0,
--                     (outs QPR:$Vd, QPR:$Vd1), (ins QPR:$Vm, QPR:$Vm1),
--                     NoItinerary, "vswp", "$Vd, $Vd1", "$Vm = $Vd, $Vm1 = $Vd1",
-+                     (outs QPR:$Vd, QPR:$Vm), (ins QPR:$in1, QPR:$in2),
-+                     NoItinerary, "vswp", "$Vd, $Vm", "$in1 = $Vd, $in2 = $Vm",
-                      []>;
- 
- // Vector Move Operations.
-Index: lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
-===================================================================
---- lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp	(revision 152265)
-+++ lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp	(working copy)
-@@ -212,12 +212,12 @@
-   } else {
-     assert(Op.isExpr() && "unknown operand kind in printOperand");
-     // If a symbolic branch target was added as a constant expression then print
--    // that address in hex.
-+    // that address in hex. And only print 32 unsigned bits for the address.
-     const MCConstantExpr *BranchTarget = dyn_cast<MCConstantExpr>(Op.getExpr());
-     int64_t Address;
-     if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) {
-       O << "0x";
--      O.write_hex(Address);
-+      O.write_hex((uint32_t)Address);
-     }
-     else {
-       // Otherwise, just print the expression.
-Index: lib/Target/ARM/ARMInstrThumb2.td
-===================================================================
---- lib/Target/ARM/ARMInstrThumb2.td	(revision 152265)
-+++ lib/Target/ARM/ARMInstrThumb2.td	(working copy)
-@@ -3198,6 +3198,7 @@
-   let Inst{13} = target{17};
-   let Inst{21-16} = target{16-11};
-   let Inst{10-0} = target{10-0};
-+  let DecoderMethod = "DecodeT2BInstruction";
- }
- 
- let isNotDuplicable = 1, isIndirectBranch = 1 in {
-Index: lib/Target/ARM/ARMInstrThumb.td
-===================================================================
---- lib/Target/ARM/ARMInstrThumb.td	(revision 152265)
-+++ lib/Target/ARM/ARMInstrThumb.td	(working copy)
-@@ -413,11 +413,11 @@
-                   "bl${p}\t$func",
-                   [(ARMtcall tglobaladdr:$func)]>,
-              Requires<[IsThumb, IsNotIOS]> {
--    bits<22> func;
--    let Inst{26} = func{21};
-+    bits<24> func;
-+    let Inst{26} = func{23};
-     let Inst{25-16} = func{20-11};
--    let Inst{13} = 1;
--    let Inst{11} = 1;
-+    let Inst{13} = func{22};
-+    let Inst{11} = func{21};
-     let Inst{10-0} = func{10-0};
-   }
- 
-@@ -427,10 +427,11 @@
-                    "blx${p}\t$func",
-                    [(ARMcall tglobaladdr:$func)]>,
-               Requires<[IsThumb, HasV5T, IsNotIOS]> {
--    bits<21> func;
-+    bits<24> func;
-+    let Inst{26} = func{23};
-     let Inst{25-16} = func{20-11};
--    let Inst{13} = 1;
--    let Inst{11} = 1;
-+    let Inst{13} = func{22};
-+    let Inst{11} = func{21};
-     let Inst{10-1} = func{10-1};
-     let Inst{0} = 0; // func{0} is assumed zero
-   }
-Index: lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
-===================================================================
---- lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp	(revision 152265)
-+++ lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp	(working copy)
-@@ -397,39 +397,65 @@
-     return swapped;
-   }
-   case ARM::fixup_arm_thumb_bl: {
--    // The value doesn't encode the low bit (always zero) and is offset by
--    // four. The value is encoded into disjoint bit positions in the destination
--    // opcode. x = unchanged, I = immediate value bit, S = sign extension bit
--    //
--    //   BL:  xxxxxSIIIIIIIIII xxxxxIIIIIIIIIII
--    //
--    // Note that the halfwords are stored high first, low second; so we need
--    // to transpose the fixup value here to map properly.
--    unsigned isNeg = (int64_t(Value - 4) < 0) ? 1 : 0;
--    uint32_t Binary = 0;
--    Value = 0x3fffff & ((Value - 4) >> 1);
--    Binary  = (Value & 0x7ff) << 16;    // Low imm11 value.
--    Binary |= (Value & 0x1ffc00) >> 11; // High imm10 value.
--    Binary |= isNeg << 10;              // Sign bit.
--    return Binary;
-+     // The value doesn't encode the low bit (always zero) and is offset by
-+     // four. The 32-bit immediate value is encoded as
-+     //   imm32 = SignExtend(S:I1:I2:imm10:imm11:0)
-+     // where I1 = NOT(J1 ^ S) and I2 = NOT(J2 ^ S).
-+     // The value is encoded into disjoint bit positions in the destination
-+     // opcode. x = unchanged, I = immediate value bit, S = sign extension bit,
-+     // J = either J1 or J2 bit
-+     //
-+     //   BL:  xxxxxSIIIIIIIIII xxJxJIIIIIIIIIII
-+     //
-+     // Note that the halfwords are stored high first, low second; so we need
-+     // to transpose the fixup value here to map properly.
-+     uint32_t offset = (Value - 4) >> 1;
-+     uint32_t signBit = (offset & 0x800000) >> 23;
-+     uint32_t I1Bit = (offset & 0x400000) >> 22;
-+     uint32_t J1Bit = (I1Bit ^ 0x1) ^ signBit;
-+     uint32_t I2Bit = (offset & 0x200000) >> 21;
-+     uint32_t J2Bit = (I2Bit ^ 0x1) ^ signBit;
-+     uint32_t imm10Bits = (offset & 0x1FF800) >> 11;
-+     uint32_t imm11Bits = (offset & 0x000007FF);
-+ 
-+     uint32_t Binary = 0;
-+     uint32_t firstHalf = (((uint16_t)signBit << 10) | (uint16_t)imm10Bits);
-+     uint32_t secondHalf = (((uint16_t)J1Bit << 13) | ((uint16_t)J2Bit << 11) |
-+                           (uint16_t)imm11Bits);
-+     Binary |= secondHalf << 16;
-+     Binary |= firstHalf;
-+     return Binary;
-+
-   }
-   case ARM::fixup_arm_thumb_blx: {
--    // The value doesn't encode the low two bits (always zero) and is offset by
--    // four (see fixup_arm_thumb_cp). The value is encoded into disjoint bit
--    // positions in the destination opcode. x = unchanged, I = immediate value
--    // bit, S = sign extension bit, 0 = zero.
--    //
--    //   BLX: xxxxxSIIIIIIIIII xxxxxIIIIIIIIII0
--    //
--    // Note that the halfwords are stored high first, low second; so we need
--    // to transpose the fixup value here to map properly.
--    unsigned isNeg = (int64_t(Value-4) < 0) ? 1 : 0;
--    uint32_t Binary = 0;
--    Value = 0xfffff & ((Value - 2) >> 2);
--    Binary  = (Value & 0x3ff) << 17;    // Low imm10L value.
--    Binary |= (Value & 0xffc00) >> 10;  // High imm10H value.
--    Binary |= isNeg << 10;              // Sign bit.
--    return Binary;
-+     // The value doesn't encode the low two bits (always zero) and is offset by
-+     // four (see fixup_arm_thumb_cp). The 32-bit immediate value is encoded as
-+     //   imm32 = SignExtend(S:I1:I2:imm10H:imm10L:00)
-+     // where I1 = NOT(J1 ^ S) and I2 = NOT(J2 ^ S).
-+     // The value is encoded into disjoint bit positions in the destination 
-+     // opcode. x = unchanged, I = immediate value bit, S = sign extension bit, 
-+     // J = either J1 or J2 bit, 0 = zero.
-+     //
-+     //   BLX: xxxxxSIIIIIIIIII xxJxJIIIIIIIIII0
-+     //
-+     // Note that the halfwords are stored high first, low second; so we need
-+     // to transpose the fixup value here to map properly.
-+     uint32_t offset = (Value - 2) >> 2;
-+     uint32_t signBit = (offset & 0x400000) >> 22;
-+     uint32_t I1Bit = (offset & 0x200000) >> 21;
-+     uint32_t J1Bit = (I1Bit ^ 0x1) ^ signBit;
-+     uint32_t I2Bit = (offset & 0x100000) >> 20;
-+     uint32_t J2Bit = (I2Bit ^ 0x1) ^ signBit;
-+     uint32_t imm10HBits = (offset & 0xFFC00) >> 10;
-+     uint32_t imm10LBits = (offset & 0x3FF);
-+ 
-+     uint32_t Binary = 0;
-+     uint32_t firstHalf = (((uint16_t)signBit << 10) | (uint16_t)imm10HBits);
-+     uint32_t secondHalf = (((uint16_t)J1Bit << 13) | ((uint16_t)J2Bit << 11) | 
-+                           ((uint16_t)imm10LBits) << 1);
-+     Binary |= secondHalf << 16;
-+     Binary |= firstHalf;
-+     return Binary;
-   }
-   case ARM::fixup_arm_thumb_cp:
-     // Offset by 4, and don't encode the low two bits. Two bytes of that
-Index: lib/Target/ARM/Disassembler/ARMDisassembler.cpp
-===================================================================
---- lib/Target/ARM/Disassembler/ARMDisassembler.cpp	(revision 152265)
-+++ lib/Target/ARM/Disassembler/ARMDisassembler.cpp	(working copy)
-@@ -182,6 +182,8 @@
-                                uint64_t Address, const void *Decoder);
- static DecodeStatus DecodeAddrMode7Operand(llvm::MCInst &Inst, unsigned Val,
-                                uint64_t Address, const void *Decoder);
-+static DecodeStatus DecodeT2BInstruction(MCInst &Inst, unsigned Insn,
-+                               uint64_t Address, const void *Decoder);
- static DecodeStatus DecodeBranchImmInstruction(llvm::MCInst &Inst,unsigned Insn,
-                                uint64_t Address, const void *Decoder);
- static DecodeStatus DecodeAddrMode6Operand(llvm::MCInst &Inst, unsigned Val,
-@@ -1945,6 +1947,21 @@
- }
- 
- static DecodeStatus
-+DecodeT2BInstruction(MCInst &Inst, unsigned Insn,
-+                     uint64_t Address, const void *Decoder) {
-+  DecodeStatus S = MCDisassembler::Success;
-+  unsigned imm = (fieldFromInstruction32(Insn, 0, 11) << 0) |
-+                 (fieldFromInstruction32(Insn, 11, 1) << 18) |
-+                 (fieldFromInstruction32(Insn, 13, 1) << 17) |
-+                 (fieldFromInstruction32(Insn, 16, 6) << 11) |
-+                 (fieldFromInstruction32(Insn, 26, 1) << 19);
-+  if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<20>(imm<<1) + 4,
-+                                true, 4, Inst, Decoder))
-+    Inst.addOperand(MCOperand::CreateImm(SignExtend32<20>(imm << 1)));
-+  return S;
-+}
-+
-+static DecodeStatus
- DecodeBranchImmInstruction(llvm::MCInst &Inst, unsigned Insn,
-                            uint64_t Address, const void *Decoder) {
-   DecodeStatus S = MCDisassembler::Success;
-@@ -2177,6 +2194,8 @@
-     case ARM::VLD2b8wb_register:
-     case ARM::VLD2b16wb_register:
-     case ARM::VLD2b32wb_register:
-+      Inst.addOperand(MCOperand::CreateImm(0));
-+      break;
-     case ARM::VLD3d8_UPD:
-     case ARM::VLD3d16_UPD:
-     case ARM::VLD3d32_UPD:
-@@ -2245,6 +2264,16 @@
-         !Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
-       return MCDisassembler::Fail;
-     break;
-+  case ARM::VLD2d8wb_fixed:
-+  case ARM::VLD2d16wb_fixed:
-+  case ARM::VLD2d32wb_fixed:
-+  case ARM::VLD2b8wb_fixed:
-+  case ARM::VLD2b16wb_fixed:
-+  case ARM::VLD2b32wb_fixed:
-+  case ARM::VLD2q8wb_fixed:
-+  case ARM::VLD2q16wb_fixed:
-+  case ARM::VLD2q32wb_fixed:
-+    break;
-   }
- 
-   return S;
-@@ -2313,6 +2342,10 @@
-     case ARM::VST2b8wb_register:
-     case ARM::VST2b16wb_register:
-     case ARM::VST2b32wb_register:
-+      if (Rm == 0xF)
-+        return MCDisassembler::Fail;
-+      Inst.addOperand(MCOperand::CreateImm(0));
-+      break;
-     case ARM::VST3d8_UPD:
-     case ARM::VST3d16_UPD:
-     case ARM::VST3d32_UPD:
-@@ -2354,6 +2387,23 @@
-     case ARM::VST1q16wb_fixed:
-     case ARM::VST1q32wb_fixed:
-     case ARM::VST1q64wb_fixed:
-+    case ARM::VST1d8Twb_fixed:
-+    case ARM::VST1d16Twb_fixed:
-+    case ARM::VST1d32Twb_fixed:
-+    case ARM::VST1d64Twb_fixed:
-+    case ARM::VST1d8Qwb_fixed:
-+    case ARM::VST1d16Qwb_fixed:
-+    case ARM::VST1d32Qwb_fixed:
-+    case ARM::VST1d64Qwb_fixed:
-+    case ARM::VST2d8wb_fixed:
-+    case ARM::VST2d16wb_fixed:
-+    case ARM::VST2d32wb_fixed:
-+    case ARM::VST2q8wb_fixed:
-+    case ARM::VST2q16wb_fixed:
-+    case ARM::VST2q32wb_fixed:
-+    case ARM::VST2b8wb_fixed:
-+    case ARM::VST2b16wb_fixed:
-+    case ARM::VST2b32wb_fixed:
-       break;
-   }
- 
-@@ -2555,7 +2605,6 @@
-   unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
-   unsigned align = fieldFromInstruction32(Insn, 4, 1);
-   unsigned size = 1 << fieldFromInstruction32(Insn, 6, 2);
--  unsigned pred = fieldFromInstruction32(Insn, 22, 4);
-   align *= 2*size;
- 
-   switch (Inst.getOpcode()) {
-@@ -2586,16 +2635,11 @@
-     return MCDisassembler::Fail;
-   Inst.addOperand(MCOperand::CreateImm(align));
- 
--  if (Rm == 0xD)
--    Inst.addOperand(MCOperand::CreateReg(0));
--  else if (Rm != 0xF) {
-+  if (Rm != 0xD && Rm != 0xF) {
-     if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
-       return MCDisassembler::Fail;
-   }
- 
--  if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
--    return MCDisassembler::Fail;
--
-   return S;
- }
- 
-@@ -2837,19 +2881,25 @@
- 
- static DecodeStatus DecodeThumbBROperand(llvm::MCInst &Inst, unsigned Val,
-                                  uint64_t Address, const void *Decoder) {
--  Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
-+   if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<12>(Val<<1) + 4,
-+                                 true, 2, Inst, Decoder))
-+     Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
-   return MCDisassembler::Success;
- }
- 
- static DecodeStatus DecodeT2BROperand(llvm::MCInst &Inst, unsigned Val,
-                                  uint64_t Address, const void *Decoder) {
--  Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
-+   if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<21>(Val) + 4,
-+                                 true, 4, Inst, Decoder))
-+     Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
-   return MCDisassembler::Success;
- }
- 
- static DecodeStatus DecodeThumbCmpBROperand(llvm::MCInst &Inst, unsigned Val,
-                                  uint64_t Address, const void *Decoder) {
--  Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
-+   if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<7>(Val<<1) + 4,
-+                                 true, 2, Inst, Decoder))
-+     Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
-   return MCDisassembler::Success;
- }
- 
-@@ -3162,10 +3212,25 @@
- 
- static DecodeStatus DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Val,
-                                  uint64_t Address, const void *Decoder) {
-+  // Val is passed in as S:J1:J2:imm10H:imm10L:’0’
-+  // Note only one trailing zero not two.  Also the J1 and J2 values are from
-+  // the encoded instruction.  So here change to I1 and I2 values via:
-+  // I1 = NOT(J1 EOR S);
-+  // I2 = NOT(J2 EOR S);
-+  // and build the imm32 with two trailing zeros as documented:
-+  // imm32 = SignExtend(S:I1:I2:imm10H:imm10L:’00’, 32);
-+  unsigned S = (Val >> 23) & 1;
-+  unsigned J1 = (Val >> 22) & 1;
-+  unsigned J2 = (Val >> 21) & 1;
-+  unsigned I1 = !(J1 ^ S);
-+  unsigned I2 = !(J2 ^ S);
-+  unsigned tmp = (Val & ~0x600000) | (I1 << 22) | (I2 << 21);
-+  int imm32 = SignExtend32<25>(tmp << 1);
-+
-   if (!tryAddingSymbolicOperand(Address,
--                                (Address & ~2u) + SignExtend32<22>(Val << 1) + 4,
-+                                (Address & ~2u) + imm32 + 4,
-                                 true, 4, Inst, Decoder))
--    Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
-+    Inst.addOperand(MCOperand::CreateImm(imm32));
-   return MCDisassembler::Success;
- }
- 
-@@ -3271,15 +3336,32 @@
- static DecodeStatus
- DecodeThumbBCCTargetOperand(llvm::MCInst &Inst, unsigned Val,
-                             uint64_t Address, const void *Decoder){
--  Inst.addOperand(MCOperand::CreateImm(Val << 1));
-+  if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<8>(Val<<1) + 4,
-+                                true, 2, Inst, Decoder))
-+    Inst.addOperand(MCOperand::CreateImm(SignExtend32<8>(Val << 1)));
-   return MCDisassembler::Success;
- }
- 
- static DecodeStatus DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
-                                        uint64_t Address, const void *Decoder){
--  if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<22>(Val<<1) + 4,
-+  // Val is passed in as S:J1:J2:imm10:imm11
-+  // Note no trailing zero after imm11.  Also the J1 and J2 values are from
-+  // the encoded instruction.  So here change to I1 and I2 values via:
-+  // I1 = NOT(J1 EOR S);
-+  // I2 = NOT(J2 EOR S);
-+  // and build the imm32 with one trailing zero as documented:
-+  // imm32 = SignExtend(S:I1:I2:imm10:imm11:’0’, 32);
-+  unsigned S = (Val >> 23) & 1;
-+  unsigned J1 = (Val >> 22) & 1;
-+  unsigned J2 = (Val >> 21) & 1;
-+  unsigned I1 = !(J1 ^ S);
-+  unsigned I2 = !(J2 ^ S);
-+  unsigned tmp = (Val & ~0x600000) | (I1 << 22) | (I2 << 21);
-+  int imm32 = SignExtend32<25>(tmp << 1);
-+
-+  if (!tryAddingSymbolicOperand(Address, Address + imm32 + 4,
-                                 true, 4, Inst, Decoder))
--    Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
-+    Inst.addOperand(MCOperand::CreateImm(imm32));
-   return MCDisassembler::Success;
- }
- 
-Index: lib/Target/X86/Disassembler/X86Disassembler.cpp
-===================================================================
---- lib/Target/X86/Disassembler/X86Disassembler.cpp	(revision 152265)
-+++ lib/Target/X86/Disassembler/X86Disassembler.cpp	(working copy)
-@@ -322,7 +322,12 @@
- 
-   OperandType type = (OperandType)operand.type;
- 
-+  bool isBranch = false;
-+  uint64_t pcrel = 0;
-   if (type == TYPE_RELv) {
-+    isBranch = true;
-+    pcrel = insn.startLocation +
-+            insn.immediateOffset + insn.immediateSize;
-     switch (insn.displacementSize) {
-     default:
-       break;
-@@ -373,8 +378,6 @@
-     }
-   }
- 
--  bool isBranch = false;
--  uint64_t pcrel = 0;
-   switch (type) {
-   case TYPE_XMM128:
-     mcInst.addOperand(MCOperand::CreateReg(X86::XMM0 + (immediate >> 4)));
-Index: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c
-===================================================================
---- lib/Target/X86/Disassembler/X86DisassemblerDecoder.c	(revision 152265)
-+++ lib/Target/X86/Disassembler/X86DisassemblerDecoder.c	(working copy)
-@@ -312,6 +312,13 @@
-     
-     if (consumeByte(insn, &byte))
-       return -1;
-+
-+    // If the the first byte is a LOCK prefix break and let it be disassembled
-+    // as a lock "instruction", by creating an <MCInst #xxxx LOCK_PREFIX>.
-+    // FIXME there is currently no way to get the disassembler to print the
-+    // lock prefix if it is not the first byte.
-+    if (insn->readerCursor - 1 == insn->startLocation && byte == 0xf0)
-+      break;
-     
-     switch (byte) {
-     case 0xf0:  /* LOCK */
-Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
-===================================================================
---- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp	(revision 152265)
-+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp	(working copy)
-@@ -24,7 +24,8 @@
- bool RuntimeDyldMachO::
- resolveRelocation(uint8_t *LocalAddress,
-                   uint64_t FinalAddress,
--                  uint64_t Value,
-+                  uint64_t FinalSource1,
-+                  uint64_t FinalSource2,
-                   bool isPCRel,
-                   unsigned Type,
-                   unsigned Size,
-@@ -32,10 +33,20 @@
-   // This just dispatches to the proper target specific routine.
-   switch (CPUType) {
-   default: llvm_unreachable("Unsupported CPU type!");
-+  case mach::CTM_i386:
-+    return resolveI386Relocation(LocalAddress,
-+                                 FinalAddress,
-+                                 FinalSource1,
-+                                 FinalSource2,
-+                                 isPCRel,
-+                                 Type,
-+                                 Size,
-+                                 Addend);
-   case mach::CTM_x86_64:
-     return resolveX86_64Relocation(LocalAddress,
-                                    FinalAddress,
--                                   (uintptr_t)Value,
-+                                   FinalSource1,
-+                                   FinalSource2,
-                                    isPCRel,
-                                    Type,
-                                    Size,
-@@ -43,7 +54,8 @@
-   case mach::CTM_ARM:
-     return resolveARMRelocation(LocalAddress,
-                                 FinalAddress,
--                                (uintptr_t)Value,
-+                                FinalSource1,
-+                                FinalSource2,
-                                 isPCRel,
-                                 Type,
-                                 Size,
-@@ -52,19 +64,52 @@
- }
- 
- bool RuntimeDyldMachO::
-+resolveI386Relocation(uint8_t *LocalAddress,
-+                      uint64_t FinalAddress,
-+                      uint64_t FinalSource1,
-+                      uint64_t FinalSource2,
-+                      bool isPCRel,
-+                      unsigned Type,
-+                      unsigned Size,
-+                      int64_t Addend) {
-+  int64_t ValueToWrite = Addend;
-+
-+  switch (Type) {
-+  default:
-+    llvm_unreachable("Invalid relocation type!");
-+  case macho::RIT_Vanilla:
-+    ValueToWrite += FinalSource1;
-+    break;
-+  case macho::RIT_Difference:
-+  case macho::RIT_Generic_LocalDifference:
-+  case macho::RIT_Generic_PreboundLazyPointer:
-+    ValueToWrite += FinalSource1;
-+    ValueToWrite -= FinalSource2;
-+    break;
-+  }
-+
-+  if (isPCRel)
-+    ValueToWrite -= FinalAddress + 4; // see resolveX86_64Relocation
-+
-+  uint8_t *p = LocalAddress;
-+  for (unsigned i = 0; i < Size; ++i) {
-+    *p++ = (uint8_t)(ValueToWrite & 0xff);
-+    ValueToWrite >>= 8;
-+  }
-+
-+  return false;
-+}
-+
-+bool RuntimeDyldMachO::
- resolveX86_64Relocation(uint8_t *LocalAddress,
-                         uint64_t FinalAddress,
--                        uint64_t Value,
-+                        uint64_t FinalSource1,
-+                        uint64_t FinalSource2,
-                         bool isPCRel,
-                         unsigned Type,
-                         unsigned Size,
-                         int64_t Addend) {
--  // If the relocation is PC-relative, the value to be encoded is the
--  // pointer difference.
--  if (isPCRel)
--    // FIXME: It seems this value needs to be adjusted by 4 for an effective PC
--    // address. Is that expected? Only for branches, perhaps?
--    Value -= FinalAddress + 4;
-+  int64_t ValueToWrite = Addend;
- 
-   switch(Type) {
-   default:
-@@ -74,41 +119,53 @@
-   case macho::RIT_X86_64_Signed4:
-   case macho::RIT_X86_64_Signed:
-   case macho::RIT_X86_64_Unsigned:
--  case macho::RIT_X86_64_Branch: {
--    Value += Addend;
--    // Mask in the target value a byte at a time (we don't have an alignment
--    // guarantee for the target address, so this is safest).
--    uint8_t *p = (uint8_t*)LocalAddress;
--    for (unsigned i = 0; i < Size; ++i) {
--      *p++ = (uint8_t)Value;
--      Value >>= 8;
--    }
--    return false;
--  }
-+  case macho::RIT_X86_64_Branch:
-+    ValueToWrite += FinalSource1;
-+    break;
-   case macho::RIT_X86_64_GOTLoad:
-   case macho::RIT_X86_64_GOT:
-   case macho::RIT_X86_64_Subtractor:
-   case macho::RIT_X86_64_TLV:
-     return Error("Relocation type not implemented yet!");
-   }
-+
-+  // If the relocation is PC-relative, the value to be encoded is the
-+  // pointer difference.
-+  if (isPCRel)
-+    // FIXME: It seems this value needs to be adjusted by 4 for an effective PC
-+    // address. Is that expected? Only for branches, perhaps?
-+    ValueToWrite -= FinalAddress + 4;
-+
-+  // Mask in the target value a byte at a time (we don't have an alignment
-+  // guarantee for the target address, so this is safest).
-+  uint8_t *p = (uint8_t*)LocalAddress;
-+  for (unsigned i = 0; i < Size; ++i) {
-+    *p++ = (uint8_t)(ValueToWrite & 0xff);
-+    ValueToWrite >>= 8;
-+  }
-+
-+  return false;
- }
- 
- bool RuntimeDyldMachO::
- resolveARMRelocation(uint8_t *LocalAddress,
-                      uint64_t FinalAddress,
--                     uint64_t Value,
-+                     uint64_t FinalSource1,
-+                     uint64_t FinalSource2,
-                      bool isPCRel,
-                      unsigned Type,
-                      unsigned Size,
-                      int64_t Addend) {
-+  int64_t ValueToWrite = Addend;
-+
-   // If the relocation is PC-relative, the value to be encoded is the
-   // pointer difference.
-   if (isPCRel) {
--    Value -= FinalAddress;
-+    ValueToWrite -= FinalAddress;
-     // ARM PCRel relocations have an effective-PC offset of two instructions
-     // (four bytes in Thumb mode, 8 bytes in ARM mode).
-     // FIXME: For now, assume ARM mode.
--    Value -= 8;
-+    ValueToWrite -= 8;
-   }
- 
-   switch(Type) {
-@@ -119,8 +176,8 @@
-     // guarantee for the target address, so this is safest).
-     uint8_t *p = (uint8_t*)LocalAddress;
-     for (unsigned i = 0; i < Size; ++i) {
--      *p++ = (uint8_t)Value;
--      Value >>= 8;
-+      *p++ = (uint8_t)(ValueToWrite & 0xff);
-+      ValueToWrite >>= 8;
-     }
-     break;
-   }
-@@ -129,15 +186,15 @@
-     // 32-bit aligned, so we can do it all at once.
-     uint32_t *p = (uint32_t*)LocalAddress;
-     // The low two bits of the value are not encoded.
--    Value >>= 2;
-+    ValueToWrite >>= 2;
-     // Mask the value to 24 bits.
--    Value &= 0xffffff;
-+    ValueToWrite &= 0xffffff;
-     // FIXME: If the destination is a Thumb function (and the instruction
-     // is a non-predicated BL instruction), we need to change it to a BLX
-     // instruction instead.
- 
-     // Insert the value into the instruction.
--    *p = (*p & ~0xffffff) | Value;
-+    *p = (*p & ~0xffffff) | ValueToWrite;
-     break;
-   }
-   case macho::RIT_ARM_ThumbBranch22Bit:
-@@ -153,6 +210,29 @@
-   return false;
- }
- 
-+static bool
-+ResolveSectionAndOffset(const MachOObject *Obj,
-+                        SmallVectorImpl<unsigned> &SectionMap,
-+                        const MachOObject::LoadCommandInfo *SegmentLCI,
-+                        InMemoryStruct<macho::SegmentLoadCommand> &SegmentLC,
-+                        uint64_t Address,
-+                        unsigned &SectionID,
-+                        uint64_t &Offset)
-+{
-+  for (unsigned SI = 0, SE = SegmentLC->NumSections; SI < SE; ++SI) {
-+    InMemoryStruct<macho::Section> CandidateSection;
-+    Obj->ReadSection(*SegmentLCI, SI, CandidateSection);
-+    if (Address >= CandidateSection->Address &&
-+        Address < CandidateSection->Address + CandidateSection->Size) {
-+      SectionID = SectionMap[SI];
-+      Offset = Address - CandidateSection->Address;
-+      return true;
-+    }
-+  }
-+
-+  return false;
-+}
-+
- bool RuntimeDyldMachO::
- loadSegment32(const MachOObject *Obj,
-               const MachOObject::LoadCommandInfo *SegmentLCI,
-@@ -210,6 +290,7 @@
- 
-   // Process the relocations for each section we're loading.
-   Relocations.grow(Relocations.size() + SegmentLC->NumSections);
-+  RelocationSources.grow(RelocationSources.size() + SegmentLC->NumSections);
-   for (unsigned SectNum = 0; SectNum != SegmentLC->NumSections; ++SectNum) {
-     InMemoryStruct<macho::Section> Sect;
-     Obj->ReadSection(*SegmentLCI, SectNum, Sect);
-@@ -218,51 +299,135 @@
-     for (unsigned j = 0; j != Sect->NumRelocationTableEntries; ++j) {
-       InMemoryStruct<macho::RelocationEntry> RE;
-       Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE);
--      if (RE->Word0 & macho::RF_Scattered)
--        return Error("NOT YET IMPLEMENTED: scattered relocations.");
--      // Word0 of the relocation is the offset into the section where the
--      // relocation should be applied. We need to translate that into an
--      // offset into a function since that's our atom.
--      uint32_t Offset = RE->Word0;
--      bool isExtern = (RE->Word1 >> 27) & 1;
--
--      // FIXME: Get the relocation addend from the target address.
--      // FIXME: VERY imporant for internal relocations.
--
--      // Figure out the source symbol of the relocation. If isExtern is true,
--      // this relocation references the symbol table, otherwise it references
--      // a section in the same object, numbered from 1 through NumSections
--      // (SectionBases is [0, NumSections-1]).
--      uint32_t SourceNum = RE->Word1 & 0xffffff; // 24-bit value
--      if (!isExtern) {
--        assert(SourceNum > 0 && "Invalid relocation section number!");
--        unsigned SectionID = SectionMap[SourceNum - 1];
-+      if (RE->Word0 & macho::RF_Scattered) {
-+        // The lower 24 bits of Word0 of the scattered relocation is the offset
-+        // into the section where the relocation should be applied, i.e., the
-+        // current section.
-+        uint32_t OffsetInTarget = RE->Word0 & 0x00ffffff;
-         unsigned TargetID = SectionMap[SectNum];
--        DEBUG(dbgs() << "Internal relocation at Section #"
--                     << TargetID << " + " << Offset
--                     << " from Section #"
--                     << SectionID << " (Word1: "
--                     << format("0x%x", RE->Word1) << ")\n");
--
--        // Store the relocation information. It will get resolved when
--        // the section addresses are assigned.
--        Relocations[SectionID].push_back(RelocationEntry(TargetID,
--                                                         Offset,
--                                                         RE->Word1,
--                                                         0 /*Addend*/));
-+        // Word1 of the scattered relocation is a file offset which needs to
-+        // be resolved into Section+Offset form.  This gives the address of the
-+        // source.
-+        unsigned Source1ID;
-+        uint64_t Source1Offset;
-+        if (!ResolveSectionAndOffset(Obj,
-+                                     SectionMap,
-+                                     SegmentLCI,
-+                                     SegmentLC,
-+                                     RE->Word1,
-+                                     Source1ID,
-+                                     Source1Offset))
-+          return Error("couldn't find scattered relocation value in sections");
-+        // This relocation may have a paired relocation entry. If it does, set
-+        // the source/offset information for it correctly.
-+        unsigned Source2ID = SectionOffset::NoSectionID;
-+        uint64_t Source2Offset = 0;
-+        if (j + 1 < Sect->NumRelocationTableEntries) {
-+          InMemoryStruct<macho::RelocationEntry> PairRE;
-+          Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j+1, PairRE);
-+          if ((PairRE->Word0 & macho::RF_Scattered) &&
-+              ((PairRE->Word0 & 0x0f000000) >> 24) == macho::RIT_Pair) {
-+            if (!ResolveSectionAndOffset(Obj,
-+                                         SectionMap,
-+                                         SegmentLCI,
-+                                         SegmentLC,
-+                                         PairRE->Word1,
-+                                         Source2ID,
-+                                         Source2Offset))
-+              return Error("couldn't find scattered relocation value in sections");
-+            ++j;
-+          }
-+        }
-+        if (Source2ID == SectionOffset::NoSectionID)
-+          DEBUG(dbgs() << "Scattered relocation at Section #"
-+                       << TargetID << " + " << OffsetInTarget
-+                       << " from Section #" << Source1ID
-+                       << "+" << Source1Offset
-+                       << " (Word0: "
-+                       << format("0x%x", RE->Word0) << ")\n");
-+        else
-+          DEBUG(dbgs() << "Scattered relocation at Section #"
-+                       << TargetID << " + " << OffsetInTarget
-+                       << " from Section #" << Source1ID
-+                       << "+" << Source1Offset
-+                       << " and Section #" << Source2ID
-+                       << "+" << Source2Offset
-+                       << " (Word0: "
-+                       << format("0x%x", RE->Word0) << ")\n");
-+        uint32_t RelocationIndex = Relocations[TargetID].size();
-+        // FIXME: Get the relocation addend from the target address.
-+        // FIXME: VERY imporant for internal relocations.
-+        RelocationEntry TranslatedRE(OffsetInTarget,
-+                                     Source1ID,
-+                                     Source1Offset,
-+                                     Source2ID,
-+                                     Source2Offset,
-+                                     RE->Word1,
-+                                     0 /*Addend*/);
-+        Relocations[TargetID].push_back(TranslatedRE);
-+        RelocationSources[Source1ID].push_back(RelocationSource(TargetID,
-+                                                                RelocationIndex,
-+                                                                0));
-+        if (Source2ID != SectionOffset::NoSectionID)
-+          RelocationSources[Source2ID].push_back(RelocationSource(TargetID,
-+                                                                  RelocationIndex,
-+                                                                  1));
-       } else {
--        StringRef SourceName = SymbolNames[SourceNum];
--
--        // Now store the relocation information. Associate it with the source
--        // symbol. Just add it to the unresolved list and let the general
--        // path post-load resolve it if we know where the symbol is.
--        UnresolvedRelocations[SourceName].push_back(RelocationEntry(SectNum,
--                                                                    Offset,
--                                                                    RE->Word1,
--                                                                 0 /*Addend*/));
--        DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << Offset
--              << " from '" << SourceName << "(Word1: "
--              << format("0x%x", RE->Word1) << ")\n");
-+        // Word0 of the relocation is the offset into the section where the
-+        // relocation should be applied, i.e., the current section. We need
-+        // to translate that into an offset into a function since that's our atom.
-+        uint32_t OffsetInTarget = RE->Word0;
-+        bool isExtern = (RE->Word1 >> 27) & 1;
-+  
-+        // FIXME: Get the relocation addend from the target address.
-+        // FIXME: VERY imporant for internal relocations.
-+  
-+        // Figure out the source symbol of the relocation. If isExtern is true,
-+        // this relocation references the symbol table, otherwise it references
-+        // a section in the same object, numbered from 1 through NumSections
-+        // (SectionBases is [0, NumSections-1]).
-+        uint32_t SourceNum_OneBased = RE->Word1 & 0xffffff; // 24-bit value
-+        if (!isExtern) {
-+          assert(SourceNum_OneBased > 0 && "Invalid relocation section number!");
-+          unsigned SourceID = SectionMap[SourceNum_OneBased - 1];
-+          unsigned TargetID = SectionMap[SectNum];
-+          DEBUG(dbgs() << "Internal relocation at Section #"
-+                       << TargetID << " + " << OffsetInTarget
-+                       << " from Section #"
-+                       << SourceID << " (Word1: "
-+                       << format("0x%x", RE->Word1) << ")\n");
-+  
-+          // Store the relocation information. It will get resolved when
-+          // the section addresses are assigned.
-+          uint32_t RelocationIndex = Relocations[TargetID].size();
-+          Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+                                                          SourceID,
-+                                                          SectionOffset::NoSectionID,
-+                                                          RE->Word1,
-+                                                          0 /*Addend*/));
-+          RelocationSources[SourceID].push_back(RelocationSource(TargetID,
-+                                                                 RelocationIndex,
-+                                                                 0));
-+        } else {
-+          StringRef SourceName = SymbolNames[SourceNum_OneBased];
-+  
-+          // Now store the relocation information. Associate it with the source
-+          // symbol. Just add it to the unresolved list and let the general
-+          // path post-load resolve it if we know where the symbol is.
-+          unsigned TargetID = SectionMap[SectNum];
-+          uint32_t RelocationIndex = Relocations[TargetID].size();
-+          Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+                                                          SectionOffset::UnresolvedSourceID,
-+                                                          SectionOffset::NoSectionID,
-+                                                          RE->Word1,
-+                                                          0 /*Addend*/));
-+          UnresolvedRelocations[SourceName].push_back(RelocationSource(TargetID,
-+                                                                       RelocationIndex,
-+                                                                       0));
-+          DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << OffsetInTarget
-+                << " from '" << SourceName << "' (Word1: "
-+                << format("0x%x", RE->Word1) << ")\n");
-+        }
-       }
-     }
-   }
-@@ -332,6 +497,7 @@
- 
-   // Process the relocations for each section we're loading.
-   Relocations.grow(Relocations.size() + Segment64LC->NumSections);
-+  RelocationSources.grow(RelocationSources.size() + Segment64LC->NumSections);
-   for (unsigned SectNum = 0; SectNum != Segment64LC->NumSections; ++SectNum) {
-     InMemoryStruct<macho::Section64> Sect;
-     Obj->ReadSection64(*SegmentLCI, SectNum, Sect);
-@@ -341,11 +507,11 @@
-       InMemoryStruct<macho::RelocationEntry> RE;
-       Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE);
-       if (RE->Word0 & macho::RF_Scattered)
--        return Error("NOT YET IMPLEMENTED: scattered relocations.");
-+        return Error("scattered relocations don't exist on 64-bit platforms");
-       // Word0 of the relocation is the offset into the section where the
-       // relocation should be applied. We need to translate that into an
-       // offset into a function since that's our atom.
--      uint32_t Offset = RE->Word0;
-+      uint32_t OffsetInTarget = RE->Word0;
-       bool isExtern = (RE->Word1 >> 27) & 1;
- 
-       // FIXME: Get the relocation addend from the target address.
-@@ -355,34 +521,45 @@
-       // this relocation references the symbol table, otherwise it references
-       // a section in the same object, numbered from 1 through NumSections
-       // (SectionBases is [0, NumSections-1]).
--      uint32_t SourceNum = RE->Word1 & 0xffffff; // 24-bit value
-+      uint32_t SourceNum_OneBased = RE->Word1 & 0xffffff; // 24-bit value
-       if (!isExtern) {
--        assert(SourceNum > 0 && "Invalid relocation section number!");
--        unsigned SectionID = SectionMap[SourceNum - 1];
-+        assert(SourceNum_OneBased > 0 && "Invalid relocation section number!");
-+        unsigned SourceID = SectionMap[SourceNum_OneBased - 1];
-         unsigned TargetID = SectionMap[SectNum];
-         DEBUG(dbgs() << "Internal relocation at Section #"
--                     << TargetID << " + " << Offset
-+                     << TargetID << " + " << OffsetInTarget
-                      << " from Section #"
--                     << SectionID << " (Word1: "
-+                     << SourceID << " (Word1: "
-                      << format("0x%x", RE->Word1) << ")\n");
- 
-         // Store the relocation information. It will get resolved when
-         // the section addresses are assigned.
--        Relocations[SectionID].push_back(RelocationEntry(TargetID,
--                                                         Offset,
--                                                         RE->Word1,
--                                                         0 /*Addend*/));
-+        uint32_t RelocationIndex = Relocations[TargetID].size();
-+        Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+                                                        SourceID,
-+                                                        SectionOffset::NoSectionID,
-+                                                        RE->Word1,
-+                                                        0 /*Addend*/));
-+        RelocationSources[SourceID].push_back(RelocationSource(TargetID,
-+                                                               RelocationIndex,
-+                                                               0));
-       } else {
--        StringRef SourceName = SymbolNames[SourceNum];
-+        StringRef SourceName = SymbolNames[SourceNum_OneBased];
- 
-         // Now store the relocation information. Associate it with the source
-         // symbol. Just add it to the unresolved list and let the general
-         // path post-load resolve it if we know where the symbol is.
--        UnresolvedRelocations[SourceName].push_back(RelocationEntry(SectNum,
--                                                                    Offset,
--                                                                    RE->Word1,
--                                                                 0 /*Addend*/));
--        DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << Offset
-+        unsigned TargetID = SectionMap[SectNum];
-+        uint32_t RelocationIndex = Relocations[TargetID].size();
-+        Relocations[TargetID].push_back(RelocationEntry(OffsetInTarget,
-+                                                        SectionOffset::UnresolvedSourceID,
-+                                                        SectionOffset::NoSectionID,
-+                                                        RE->Word1,
-+                                                        0 /*Addend*/));
-+        UnresolvedRelocations[SourceName].push_back(RelocationSource(TargetID,
-+                                                                     RelocationIndex,
-+                                                                     0));
-+        DEBUG(dbgs() << "Relocation at Section #" << SectNum << " + " << OffsetInTarget
-               << " from '" << SourceName << "(Word1: "
-               << format("0x%x", RE->Word1) << ")\n");
-       }
-@@ -468,18 +645,22 @@
-   if (Loc == SymbolTable.end())
-     return;
- 
--  RelocationList &Relocs = UnresolvedRelocations[Name];
-+  RelocationSourceList &SourcesForSymbol = UnresolvedRelocations[Name];
-   DEBUG(dbgs() << "Resolving symbol '" << Name << "'\n");
--  for (int i = 0, e = Relocs.size(); i != e; ++i) {
--    // Change the relocation to be section relative rather than symbol
--    // relative and move it to the resolved relocation list.
--    RelocationEntry Entry = Relocs[i];
--    Entry.Addend += Loc->second.second;
--    Relocations[Loc->second.first].push_back(Entry);
-+  for (int i = 0, e = SourcesForSymbol.size(); i != e; ++i) {
-+    // Find the relocation entry corresponding to this source and fill
-+    // in its source information with the resolved information from this
-+    // symbol.
-+    RelocationSource &Source = SourcesForSymbol[i];
-+    RelocationEntry &Entry = Relocations[Source.SectionID][Source.Index];
-+    Entry.Sources[Source.SourceIdx].Offset = Loc->second.second;
-+    Entry.Sources[Source.SourceIdx].ID = Loc->second.first;
-+    // Now create a relocation source in the pointed-to section.
-+    RelocationSources[Loc->second.first].push_back(Source);
-   }
-   // FIXME: Keep a worklist of the relocations we've added so that we can
-   // resolve more selectively later.
--  Relocs.clear();
-+  SourcesForSymbol.clear();
- }
- 
- bool RuntimeDyldMachO::loadObject(MemoryBuffer *InputBuffer) {
-@@ -575,6 +756,56 @@
-   return false;
- }
- 
-+bool RuntimeDyldMachO::resolveRelocationEntry(unsigned SectionID,
-+                                              RelocationEntry &RE)
-+{
-+  uint8_t *Target = (uint8_t*)Sections[SectionID].base() + RE.Offset;
-+  uint64_t FinalTarget = SectionLoadAddress[SectionID] + RE.Offset;
-+
-+  uint64_t FinalSource1 = 0;
-+  uint64_t FinalSource2 = 0;
-+
-+  if (RE.Sources[0].ID == SectionOffset::UnresolvedSourceID ||
-+      RE.Sources[1].ID == SectionOffset::UnresolvedSourceID)
-+    return false;
-+
-+  FinalSource1 = SectionLoadAddress[RE.Sources[0].ID] + RE.Sources[0].Offset;
-+  if (RE.Sources[1].ID != SectionOffset::NoSectionID)
-+    FinalSource2 = SectionLoadAddress[RE.Sources[1].ID] + RE.Sources[1].Offset;
-+
-+  bool isPCRel = RE.isPCRel();
-+  unsigned Type = RE.type();
-+  unsigned Size = RE.length();
-+
-+  if (RE.Sources[1].ID == SectionOffset::NoSectionID)
-+    DEBUG(dbgs() << "Resolving relocation at Section #" << SectionID
-+          << " + " << RE.Offset << " (" << format("%p", Target) << ")"
-+          << " from Section #" << RE.Sources[0].ID << "+" << RE.Sources[0].Offset
-+          << " (" << format("0x%llx", FinalSource1) << ")"
-+          << " (" << (isPCRel ? "pcrel" : "absolute")
-+          << ", type: " << Type << ", Size: " << Size << ", Addend: "
-+          << RE.Addend << ").\n");
-+  else
-+    DEBUG(dbgs() << "Resolving relocation at Section #" << SectionID
-+          << " + " << RE.Offset << " (" << format("%p", Target) << ")"
-+          << " from Section #" << RE.Sources[0].ID << "+" << RE.Sources[0].Offset
-+          << " (" << format("0x%llx", FinalSource1) << ")"
-+          << " and Section #" << RE.Sources[1].ID << "+" << RE.Sources[1].Offset
-+          << " (" << format("0x%llx", FinalSource2) << ")"
-+          << " (" << (isPCRel ? "pcrel" : "absolute")
-+          << ", type: " << Type << ", Size: " << Size << ", Addend: "
-+          << RE.Addend << ").\n");
-+
-+  return resolveRelocation(Target,
-+                           FinalTarget,
-+                           FinalSource1,
-+                           FinalSource2,
-+                           isPCRel,
-+                           Type,
-+                           Size,
-+                           RE.Addend);
-+}
-+
- // Assign an address to a symbol name and resolve all the relocations
- // associated with it.
- void RuntimeDyldMachO::reassignSectionAddress(unsigned SectionID,
-@@ -590,30 +821,17 @@
- 
-   SectionLoadAddress[SectionID] = Addr;
- 
--  RelocationList &Relocs = Relocations[SectionID];
--  for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
--    RelocationEntry &RE = Relocs[i];
--    uint8_t *Target = (uint8_t*)Sections[RE.SectionID].base() + RE.Offset;
--    uint64_t FinalTarget = (uint64_t)SectionLoadAddress[RE.SectionID] + RE.Offset;
--    bool isPCRel = (RE.Data >> 24) & 1;
--    unsigned Type = (RE.Data >> 28) & 0xf;
--    unsigned Size = 1 << ((RE.Data >> 25) & 3);
--
--    DEBUG(dbgs() << "Resolving relocation at Section #" << RE.SectionID
--          << " + " << RE.Offset << " (" << format("%p", Target) << ")"
--          << " from Section #" << SectionID << " (" << format("%p", Addr) << ")"
--          << "(" << (isPCRel ? "pcrel" : "absolute")
--          << ", type: " << Type << ", Size: " << Size << ", Addend: "
--          << RE.Addend << ").\n");
--
--    resolveRelocation(Target,
--                      FinalTarget,
--                      Addr,
--                      isPCRel,
--                      Type,
--                      Size,
--                      RE.Addend);
-+  RelocationList &RelocsForSection = Relocations[SectionID];
-+  for (unsigned i = 0, e = RelocsForSection.size(); i != e; ++i) {
-+    RelocationEntry &RE = RelocsForSection[i];
-+    resolveRelocationEntry(SectionID, RE);
-   }
-+  RelocationSourceList &SourcesForSection = RelocationSources[SectionID];
-+  for (unsigned i = 0, e = SourcesForSection.size(); i != e; ++i) {
-+    RelocationSource &R = SourcesForSection[i];
-+    RelocationEntry &RE = Relocations[R.SectionID][R.Index];
-+    resolveRelocationEntry(R.SectionID, RE);
-+  }
- }
- 
- bool RuntimeDyldMachO::isKnownFormat(const MemoryBuffer *InputBuffer) {
-Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
-===================================================================
---- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h	(revision 152265)
-+++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h	(working copy)
-@@ -26,48 +26,183 @@
- namespace llvm {
- class RuntimeDyldMachO : public RuntimeDyldImpl {
- 
--  // For each symbol, keep a list of relocations based on it. Anytime
--  // its address is reassigned (the JIT re-compiled the function, e.g.),
--  // the relocations get re-resolved.
--  // The symbol (or section) the relocation is sourced from is the Key
--  // in the relocation list where it's stored.
-+  // For each section, keep a list of relocatable pieces of data that
-+  // reside in it.  If the section moves, or the sections whose
-+  // locations the data depends on move, re-resolve the relocations
-+  // based on that movement.
-+  //
-+  // RelocationEntry structures correspond to one or two Mach-O
-+  // relocation_info or scattered_relocation_info structures --
-+  // usually one, but two iff the original has a paired structure
-+  // following it.
-+  //
-+  // To facilitate updating a relocation when its sources move, we
-+  // also keep RelocationSource structures associated with the sections
-+  // whose location the data depends on.
-+
-+  // FIXME: Use SymbolLoc for this instead.  Where should the enum live?
-+  struct SectionOffset {
-+    uint64_t    Offset;     // Offset of the location into its section.
-+    unsigned    ID;         // The section the location is contained in.
-+
-+    enum {
-+      NoSectionID        = 0xffff0000,
-+      UnresolvedSourceID = 0xffffffff
-+    };
-+  };
-+
-   struct RelocationEntry {
--    unsigned    SectionID;  // Section the relocation is contained in.
--    uint64_t    Offset;     // Offset into the section for the relocation.
--    uint32_t    Data;       // Second word of the raw macho relocation entry.
--    int64_t     Addend;     // Addend encoded in the instruction itself, if any,
--                            // plus the offset into the source section for
--                            // the symbol once the relocation is resolvable.
-+    SectionOffset Sources[2]; // The section/offset pairs this relocation
-+                              // refers to.
-+                              // If the original Mach-O relocation entries used
-+                              // relocation_info, this data is computed from
-+                              // r_symbolnum and the offsets are locked to 0.
-+                              // (The only offset is determined by the addend.)
-+                              // If the original Mach-O relocation entries used
-+                              // scattered_relocation_info, this data, including
-+                              // offsets, is computed by looking r_value up in
-+                              // the section table.
- 
--    RelocationEntry(unsigned id, uint64_t offset, uint32_t data, int64_t addend)
--      : SectionID(id), Offset(offset), Data(data), Addend(addend) {}
-+    uint64_t      Offset;     // The offset of the data to be relocated.
-+                              // We don't use a SectionOffset because this
-+                              // RelocationEntry is already associated with the
-+                              // proper Section.
-+
-+    int64_t       Addend;     // Addend encoded in the instruction itself, if any,
-+                              // plus the offset into the source section for
-+                              // the symbol once the relocation is resolvable.
-+
-+    uint32_t      Data;       // If the original Mach-O relocation entry was a
-+                              // relocation_info, the bitfield { r_symbolnum,
-+                              // r_pcrel, r_length, r_extern, r_type }.
-+                              // If the original Mach-O relocation entry was a
-+                              // scattered_relocation_info, the bitfield
-+                              // { r_address, r_type, r_length, r_pcrel,
-+                              // r_scattered }.
-+
-+    bool          Scattered;  // True iff this relocation is scattered.
-+
-+    bool isPCRel()
-+    {
-+      if (Scattered)
-+        return (Data & 0x40000000) >> 30;
-+      else
-+        return (Data & 0x01000000) >> 24;
-+    }
-+
-+    uint8_t type()
-+    {
-+      if (Scattered)
-+        return (Data & 0x0f000000) >> 24;
-+      else
-+        return (Data & 0xf0000000) >> 28;
-+    }
-+
-+    // Returns the decoded version of the length field
-+    uint8_t length()
-+    {
-+      if (Scattered)
-+        return 1 << ((Data & 0x30000000) >> 28);
-+      else
-+        return 1 << ((Data & 0x0e000000) >> 25);
-+    }
-+
-+    // Used with an ordinary relocation entry, where the source_offsets are not
-+    // known yet.
-+    RelocationEntry(uint64_t offset,      // See the Offset field.
-+                    unsigned source_id0,  // The section ID for the first source.
-+                    unsigned source_id1,  // The section ID for the second source.
-+                    uint32_t data,        // See the Data field.
-+                    int64_t addend)       // See the Addend field.
-+      : Offset(offset),
-+        Addend(addend),
-+        Data(data),
-+        Scattered(false) {
-+      Sources[0].ID = source_id0;
-+      Sources[0].Offset = 0;
-+      Sources[1].ID = source_id1;
-+      Sources[1].Offset = 0;
-+    }
-+  
-+    // Used with a scattered relocation entry, where the source_offsets can be
-+    // derived from the value.
-+    RelocationEntry(uint64_t offset,      // See the Offset field.
-+                    unsigned source_id0,  // The section ID for the first source.
-+                    uint64_t source_off0, // The offset for the first source.
-+                    unsigned source_id1,  // The section ID for the second source.
-+                    uint64_t source_off1, // The offset for the second source.
-+                    uint32_t data,        // See the Data field.
-+                    int64_t addend)       // See the Addend field.
-+      : Offset(offset),
-+        Addend(addend),
-+        Data(data), 
-+        Scattered(true) {
-+      Sources[0].ID = source_id0;
-+      Sources[0].Offset = source_off0;
-+      Sources[1].ID = source_id1;
-+      Sources[1].Offset = source_off1;
-+    }
-   };
-   typedef SmallVector<RelocationEntry, 4> RelocationList;
--  // Relocations to sections already loaded. Indexed by SectionID which is the
--  // source of the address. The target where the address will be writen is
--  // SectionID/Offset in the relocation itself.
-+
-+  // For each section, keep a list of sources that are used by relocations in
-+  // other sections.  Whenever a relocation gets created, create one or two
-+  // corresponding relocation sources.  Whenever relocations are re-resolved
-+  // for a section, also re-resolve the relocations corresponding to that
-+  // section's relocation targets.
-+  struct RelocationSource {
-+    unsigned    SectionID;      // Section whose RelocationList contains the relocation.
-+    uint32_t    Index : 24;     // Index of the RelocatonEntry in that RelocationList.
-+    uint8_t     SourceIdx : 1;  // Index of this source in the RelocationEntry's Sources.
-+
-+    RelocationSource(unsigned id,
-+                     uint32_t index,
-+                     uint8_t source_idx)
-+      : SectionID(id),
-+        Index(index),
-+        SourceIdx(source_idx) {}
-+  };
-+  typedef SmallVector<RelocationSource, 4> RelocationSourceList;
-+
-+  // Relocations which refer to already-loaded section. Indexed by SectionID
-+  // which is the section containing the relocatable data.
-   IndexedMap<RelocationList> Relocations;
-+  // Targets corresponding to Relocations.
-+  IndexedMap<RelocationSourceList> RelocationSources;
-   // Relocations to symbols that are not yet resolved. Must be external
-   // relocations by definition. Indexed by symbol name.
--  StringMap<RelocationList> UnresolvedRelocations;
-+  StringMap<RelocationSourceList> UnresolvedRelocations;
- 
-+  bool resolveRelocationEntry(unsigned SectionID,
-+                              RelocationEntry &RE);
-   bool resolveRelocation(uint8_t *LocalAddress,
-                          uint64_t FinalAddress,
--                         uint64_t Value,
-+                         uint64_t FinalSource1,
-+                         uint64_t FinalSource2,
-                          bool isPCRel,
-                          unsigned Type,
-                          unsigned Size,
-                          int64_t Addend);
-+  bool resolveI386Relocation(uint8_t *LocalAddress,
-+                             uint64_t FinalAddress,
-+                             uint64_t FinalSource1,
-+                             uint64_t FinalSource2,
-+                             bool isPCRel,
-+                             unsigned Type,
-+                             unsigned Size,
-+                             int64_t Addend);
-   bool resolveX86_64Relocation(uint8_t *LocalAddress,
-                                uint64_t FinalAddress,
--                               uint64_t Value,
-+                               uint64_t FinalSource1,
-+                               uint64_t FinalSource2,
-                                bool isPCRel,
-                                unsigned Type,
-                                unsigned Size,
-                                int64_t Addend);
-   bool resolveARMRelocation(uint8_t *LocalAddress,
-                             uint64_t FinalAddress,
--                            uint64_t Value,
-+                            uint64_t FinalSource1,
-+                            uint64_t FinalSource2,
-                             bool isPCRel,
-                             unsigned Type,
-                             unsigned Size,
-Index: lib/MC/MCDisassembler/Disassembler.cpp
-===================================================================
---- lib/MC/MCDisassembler/Disassembler.cpp	(revision 152265)
-+++ lib/MC/MCDisassembler/Disassembler.cpp	(working copy)
-@@ -15,7 +15,9 @@
- #include "llvm/MC/MCDisassembler.h"
- #include "llvm/MC/MCInst.h"
- #include "llvm/MC/MCInstPrinter.h"
-+#include "llvm/MC/MCInstrInfo.h"
- #include "llvm/MC/MCRegisterInfo.h"
-+#include "llvm/MC/MCSubtargetInfo.h"
- #include "llvm/Support/MemoryObject.h"
- #include "llvm/Support/TargetRegistry.h"
- #include "llvm/Support/TargetSelect.h"
-@@ -86,7 +88,7 @@
-   LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,
-                                                 GetOpInfo, SymbolLookUp,
-                                                 TheTarget, MAI, MRI,
--                                                Ctx, DisAsm, IP);
-+                                                STI, Ctx, DisAsm, IP);
-   assert(DC && "Allocation failure!");
- 
-   return DC;
-Index: lib/MC/MCDisassembler/Disassembler.h
-===================================================================
---- lib/MC/MCDisassembler/Disassembler.h	(revision 152265)
-+++ lib/MC/MCDisassembler/Disassembler.h	(working copy)
-@@ -29,6 +29,7 @@
- class MCDisassembler;
- class MCInstPrinter; 
- class MCRegisterInfo;
-+class MCSubtargetInfo;
- class Target;
- 
- //
-@@ -61,6 +62,8 @@
-   llvm::OwningPtr<const llvm::MCAsmInfo> MAI;
-   // The register information for the target architecture.
-   llvm::OwningPtr<const llvm::MCRegisterInfo> MRI;
-+  // The subtarget information for the target architecture.
-+  llvm::OwningPtr<const llvm::MCSubtargetInfo> MSI;
-   // The assembly context for creating symbols and MCExprs.
-   llvm::OwningPtr<const llvm::MCContext> Ctx;
-   // The disassembler for the target architecture.
-@@ -78,6 +81,7 @@
-                     LLVMSymbolLookupCallback symbolLookUp,
-                     const Target *theTarget, const MCAsmInfo *mAI,
-                     const MCRegisterInfo *mRI,
-+                    const MCSubtargetInfo *mSI,
-                     llvm::MCContext *ctx, const MCDisassembler *disAsm,
-                     MCInstPrinter *iP) : TripleName(tripleName),
-                     DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo),
-@@ -85,6 +89,7 @@
-                     CommentStream(CommentsToEmit) {
-     MAI.reset(mAI);
-     MRI.reset(mRI);
-+    MSI.reset(mSI);
-     Ctx.reset(ctx);
-     DisAsm.reset(disAsm);
-     IP.reset(iP);
-Index: tools/llvm-nm/llvm-nm.cpp
-===================================================================
---- tools/llvm-nm/llvm-nm.cpp	(revision 152265)
-+++ tools/llvm-nm/llvm-nm.cpp	(working copy)
-@@ -204,9 +204,9 @@ static void SortAndPrintSymbolList() {
-       strcpy(SymbolSizeStr, "        ");
- 
-     if (i->Address != object::UnknownAddressOrSize)
--      format("%08"PRIx64, i->Address).print(SymbolAddrStr, sizeof(SymbolAddrStr));
-+      format("%08" PRIx64, i->Address).print(SymbolAddrStr, sizeof(SymbolAddrStr));
-     if (i->Size != object::UnknownAddressOrSize)
--      format("%08"PRIx64, i->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr));
-+      format("%08" PRIx64, i->Size).print(SymbolSizeStr, sizeof(SymbolSizeStr));
- 
-     if (OutputFormat == posix) {
-       outs() << i->Name << " " << i->TypeChar << " "
-Index: lib/DebugInfo/DWARFFormValue.cpp
-===================================================================
---- lib/DebugInfo/DWARFFormValue.cpp	(revision 152265)
-+++ lib/DebugInfo/DWARFFormValue.cpp	(working copy)
-@@ -348,7 +348,7 @@ DWARFFormValue::dump(raw_ostream &OS, const DWARFC
-   }
- 
-   if (cu_relative_offset)
--    OS << format(" => {0x%8.8"PRIx64"}", (uvalue + (cu ? cu->getOffset() : 0)));
-+    OS << format(" => {0x%8.8" PRIx64 "}", (uvalue + (cu ? cu->getOffset() : 0)));
- }
- 
- const char*
-Index: tools/llvm-objdump/llvm-objdump.cpp
-===================================================================
---- tools/llvm-objdump/llvm-objdump.cpp	(revision 152265)
-+++ tools/llvm-objdump/llvm-objdump.cpp	(working copy)
-@@ -300,7 +300,7 @@ static void DisassembleObject(const ObjectFile *Ob
- 
-         if (DisAsm->getInstruction(Inst, Size, memoryObject, Index,
-                                    DebugOut, nulls())) {
--          outs() << format("%8"PRIx64":\t", SectionAddr + Index);
-+          outs() << format("%8" PRIx64":\t", SectionAddr + Index);
-           DumpBytes(StringRef(Bytes.data() + Index, Size));
-           IP->printInst(&Inst, outs(), "");
-           outs() << "\n";
-@@ -327,7 +327,7 @@ static void DisassembleObject(const ObjectFile *Ob
-           if (error(rel_cur->getTypeName(name))) goto skip_print_rel;
-           if (error(rel_cur->getValueString(val))) goto skip_print_rel;
- 
--          outs() << format("\t\t\t%8"PRIx64": ", SectionAddr + addr) << name << "\t"
-+          outs() << format("\t\t\t%8" PRIx64 ": ", SectionAddr + addr) << name << "\t"
-                  << val << "\n";
- 
-         skip_print_rel:
-@@ -388,7 +388,7 @@ static void PrintSectionHeaders(const ObjectFile *
-     if (error(si->isBSS(BSS))) return;
-     std::string Type = (std::string(Text ? "TEXT " : "") +
-                         (Data ? "DATA " : "") + (BSS ? "BSS" : ""));
--    outs() << format("%3d %-13s %09"PRIx64" %017"PRIx64" %s\n", i, Name.str().c_str(), Size,
-+    outs() << format("%3d %-13s %09" PRIx64 " %017" PRIx64 " %s\n", i, Name.str().c_str(), Size,
-                      Address, Type.c_str());
-     ++i;
-   }
-@@ -411,7 +411,7 @@ static void PrintSectionContents(const ObjectFile
- 
-     // Dump out the content as hex and printable ascii characters.
-     for (std::size_t addr = 0, end = Contents.size(); addr < end; addr += 16) {
--      outs() << format(" %04"PRIx64" ", BaseAddr + addr);
-+      outs() << format(" %04" PRIx64 " ", BaseAddr + addr);
-       // Dump line of hex.
-       for (std::size_t i = 0; i < 16; ++i) {
-         if (i != 0 && i % 4 == 0)
-@@ -519,7 +519,7 @@ static void PrintSymbolTable(const ObjectFile *o)
-       else if (Type == SymbolRef::ST_Function)
-         FileFunc = 'F';
- 
--      outs() << format("%08"PRIx64, Address) << " "
-+      outs() << format("%08" PRIx64, Address) << " "
-              << GlobLoc // Local -> 'l', Global -> 'g', Neither -> ' '
-              << (Weak ? 'w' : ' ') // Weak?
-              << ' ' // Constructor. Not supported yet.
-@@ -539,7 +539,7 @@ static void PrintSymbolTable(const ObjectFile *o)
-         outs() << SectionName;
-       }
-       outs() << '\t'
--             << format("%08"PRIx64" ", Size)
-+             << format("%08" PRIx64 " ", Size)
-              << Name
-              << '\n';
-     }
-Index: tools/bugpoint/ToolRunner.cpp
-===================================================================
---- tools/bugpoint/ToolRunner.cpp	(revision 152265)
-+++ tools/bugpoint/ToolRunner.cpp	(working copy)
-@@ -128,7 +128,7 @@ static int RunProgramRemotelyWithTimeout(const sys
-       ErrorFile.close();
-     }
- 
--    errs() << OS;
-+    errs() << OS.str();
-   }
- 
-   return ReturnCode;
-Index: tools/llvm-readobj/llvm-readobj.cpp
-===================================================================
---- tools/llvm-readobj/llvm-readobj.cpp	(revision 152265)
-+++ tools/llvm-readobj/llvm-readobj.cpp	(working copy)
-@@ -95,9 +95,9 @@ void DumpSymbol(const SymbolRef &sym) {
-     // format() can't handle StringRefs
-     outs() << format("  %-32s", Name.str().c_str())
-            << format("  %-4s", GetTypeStr(Type))
--           << format("  %16"PRIx64, Address)
--           << format("  %16"PRIx64, Size)
--           << format("  %16"PRIx64, FileOffset)
-+           << format("  %16" PRIx64, Address)
-+           << format("  %16" PRIx64, Size)
-+           << format("  %16" PRIx64, FileOffset)
-            << "  " << GetFlagStr(Flags)
-            << "\n";
- }