Update aosp/master Clang for rebase to r222490.

Change-Id: Ic557ac55e97fbf6ee08771c7b7c3594777b0aefd
diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m
index 7815103..6a7cf76 100644
--- a/test/ARCMT/checking.m
+++ b/test/ARCMT/checking.m
@@ -182,7 +182,7 @@
     ;
     id x; // expected-note {{jump bypasses initialization of retaining variable}}
 
-  case 1: // expected-error {{switch case is in protected scope}}
+  case 1: // expected-error {{cannot jump}}
     x = 0;
     break;
   }
@@ -304,7 +304,7 @@
 
 // rdar://9504750
 void rdar9504750(id p) {
-  RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}}
+  RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} 
 }
 
 // rdar://8939557
diff --git a/test/ARCMT/objcmt-boxing.m b/test/ARCMT/objcmt-boxing.m
index 2ad65a1..c4b6f42 100644
--- a/test/ARCMT/objcmt-boxing.m
+++ b/test/ARCMT/objcmt-boxing.m
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify
+// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify
 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
 
@@ -68,6 +68,7 @@
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
 + (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;
 + (id)stringWithCString:(const char *)bytes;
+- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString;
 @end
 
 enum MyEnm {
@@ -99,4 +100,8 @@
 
   static const char strarr[] = "coolbox";
   s = [NSString stringWithUTF8String:strarr];
+  // rdar://18080352
+  const char *utf8Bytes = "blah";
+  NSString *string1 = [NSString stringWithUTF8String:utf8Bytes];
+  NSString *string2 = [[NSString alloc] initWithUTF8String:utf8Bytes];
 }
diff --git a/test/ARCMT/objcmt-boxing.m.result b/test/ARCMT/objcmt-boxing.m.result
index f101989..59fdb88 100644
--- a/test/ARCMT/objcmt-boxing.m.result
+++ b/test/ARCMT/objcmt-boxing.m.result
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify
+// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify
 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result
 
@@ -68,6 +68,7 @@
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
 + (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;
 + (id)stringWithCString:(const char *)bytes;
+- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString;
 @end
 
 enum MyEnm {
@@ -99,4 +100,8 @@
 
   static const char strarr[] = "coolbox";
   s = @(strarr);
+  // rdar://18080352
+  const char *utf8Bytes = "blah";
+  NSString *string1 = @(utf8Bytes);
+  NSString *string2 = @(utf8Bytes);
 }
diff --git a/test/ARCMT/objcmt-ns-macros.m b/test/ARCMT/objcmt-ns-macros.m
index 1bf55d8..1d5583b 100644
--- a/test/ARCMT/objcmt-ns-macros.m
+++ b/test/ARCMT/objcmt-ns-macros.m
@@ -3,8 +3,17 @@
 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
 
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
 typedef long NSInteger;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
 typedef unsigned long NSUInteger;
+typedef unsigned long long uint64_t;
 
 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
 #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
@@ -294,3 +303,63 @@
     NSWindowToolbarButton,
     NSWindowDocumentIconButton
 };
+
+// rdar://18262255
+typedef enum : NSUInteger {
+   ThingOne,
+   ThingTwo,
+   ThingThree,
+} Thing;
+
+// rdar://18498539
+typedef enum {
+    one = 1
+} NumericEnum;
+
+typedef enum {
+    Two = 2
+}NumericEnum2;
+
+typedef enum {
+    Three = 3
+}
+NumericEnum3;
+
+typedef enum {
+    Four = 4
+}
+
+  NumericEnum4;
+
+// rdar://18532199
+enum
+{
+  UI8one = 1
+};
+typedef int8_t MyEnumeratedType;
+
+
+enum {
+  UI16One = 0,
+  UI16Two = 0x1,
+  UI16three = 0x8,
+  UI16Four = 0x100
+};
+typedef int16_t UI16;
+
+enum {
+    UI32ViewAutoresizingNone                 = 0,
+    UI32ViewAutoresizingFlexibleLeftMargin,
+    UI32ViewAutoresizingFlexibleWidth,
+    UI32ViewAutoresizingFlexibleRightMargin,
+    UI32ViewAutoresizingFlexibleTopMargin,
+    UI32ViewAutoresizingFlexibleHeight,
+    UI32ViewAutoresizingFlexibleBottomMargin
+};
+typedef uint32_t UI32TableViewCellStyle;
+
+enum
+{
+        UIU8one = 1
+};
+typedef uint8_t UI8Type;
diff --git a/test/ARCMT/objcmt-ns-macros.m.result b/test/ARCMT/objcmt-ns-macros.m.result
index 0b640ac..9087065 100644
--- a/test/ARCMT/objcmt-ns-macros.m.result
+++ b/test/ARCMT/objcmt-ns-macros.m.result
@@ -3,13 +3,25 @@
 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
 
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
 typedef long NSInteger;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
 typedef unsigned long NSUInteger;
+typedef unsigned long long uint64_t;
 
 #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
 #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
 #define DEPRECATED  __attribute__((deprecated))
 
+#ifndef NS_ENUM
+#import <Foundation/Foundation.h>
+#endif
 typedef NS_ENUM(NSInteger, wibble) {
   blah,
   blarg
@@ -31,7 +43,7 @@
     UIViewAnimationTransitionFlipFromRight,
     UIViewAnimationTransitionCurlUp,
     UIViewAnimationTransitionCurlDown,
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UITableView) {
     UIViewOne   = 0,
@@ -41,7 +53,7 @@
     UIViewFive  = 1 << 3,
     UIViewSix   = 1 << 4,
     UIViewSeven = 1 << 5
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UI) {
   UIOne = 0,
@@ -55,7 +67,7 @@
   UIP2Two = 0x1,
   UIP2three = 0x8,
   UIP2Four = 0x100
-} ;
+};
 
 enum {
   UNOne,
@@ -73,7 +85,7 @@
     NSTickMarkAbove = 1,
     NSTickMarkLeft = NSTickMarkAbove,
     NSTickMarkRight = NSTickMarkBelow
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UITableStyle) {
     UIViewNone         = 0x0,
@@ -144,7 +156,7 @@
   UIP0Three = 2,
   UIP0Four = 10,
   UIP0Last = 0x100
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UIP_3) {
   UIPZero = 0x0,
@@ -152,7 +164,7 @@
   UIPTwo = 0x2,
   UIP10 = 0x10,
   UIPHundred = 0x100
-} ;
+};
 
 typedef NS_ENUM(NSInteger, UIP4_3) {
   UIP4Zero = 0x0,
@@ -160,14 +172,14 @@
   UIP4Two = 0x2,
   UIP410 = 0x10,
   UIP4Hundred = 100
-} ;
+};
 
 typedef NS_OPTIONS(NSUInteger, UIP5_3) {
   UIP5Zero = 0x0,
   UIP5Two = 0x2,
   UIP510 = 0x3,
   UIP5Hundred = 0x4
-} ;
+};
 
 typedef NS_ENUM(NSInteger, UIP6_3) {
   UIP6Zero = 0x0,
@@ -175,7 +187,7 @@
   UIP6Two = 0x2,
   UIP610 = 10,
   UIP6Hundred = 0x100
-} ;
+};
 
 typedef NS_ENUM(NSInteger, UIP7_3) {
   UIP7Zero = 0x0,
@@ -183,7 +195,7 @@
   UIP7Two = 0x2,
   UIP710 = 10,
   UIP7Hundred = 100
-} ;
+};
 
 
 typedef NS_ENUM(NSInteger, UIP8_3) {
@@ -194,7 +206,7 @@
   Random4 = 0x3444444,
   Random5 = 0xbadbeef,
   Random6
-} ;
+};
 
 // rdar://15200602
 #define NS_AVAILABLE_MAC(X)  __attribute__((availability(macosx,introduced=X)))
@@ -277,3 +289,56 @@
 };
 
 // standard window buttons
+
+// rdar://18262255
+typedef enum : NSUInteger {
+   ThingOne,
+   ThingTwo,
+   ThingThree,
+} Thing;
+
+// rdar://18498539
+typedef NS_ENUM(NSInteger, NumericEnum) {
+    one = 1
+};
+
+typedef NS_ENUM(NSInteger, NumericEnum2) {
+    Two = 2
+};
+
+typedef NS_ENUM(NSInteger, NumericEnum3) {
+    Three = 3
+};
+
+typedef NS_OPTIONS(NSUInteger, NumericEnum4) {
+    Four = 4
+};
+
+// rdar://18532199
+typedef NS_ENUM(int8_t, MyEnumeratedType)
+{
+  UI8one = 1
+};
+
+
+typedef NS_OPTIONS(uint16_t, UI16) {
+  UI16One = 0,
+  UI16Two = 0x1,
+  UI16three = 0x8,
+  UI16Four = 0x100
+};
+
+typedef NS_ENUM(uint32_t, UI32TableViewCellStyle) {
+    UI32ViewAutoresizingNone                 = 0,
+    UI32ViewAutoresizingFlexibleLeftMargin,
+    UI32ViewAutoresizingFlexibleWidth,
+    UI32ViewAutoresizingFlexibleRightMargin,
+    UI32ViewAutoresizingFlexibleTopMargin,
+    UI32ViewAutoresizingFlexibleHeight,
+    UI32ViewAutoresizingFlexibleBottomMargin
+};
+
+typedef NS_ENUM(uint8_t, UI8Type)
+{
+        UIU8one = 1
+};
diff --git a/test/ARCMT/objcmt-property-dot-syntax.m b/test/ARCMT/objcmt-property-dot-syntax.m
new file mode 100644
index 0000000..42aade5
--- /dev/null
+++ b/test/ARCMT/objcmt-property-dot-syntax.m
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
+
+// rdar://18498572
+@interface NSObject @end
+
+@interface P : NSObject
+{
+  P* obj;
+  int i1, i2, i3;
+}
+@property int count;
+@property (copy) P* PropertyReturnsPObj;
+- (P*) MethodReturnsPObj;
+@end
+
+P* fun();
+
+@implementation P
+- (int) Meth : (P*)array {
+  [obj setCount : 100];
+
+  [(P*)0 setCount : [array count]];
+
+  [[obj PropertyReturnsPObj] setCount : [array count]];
+
+  [obj setCount : (i1+i2*i3 - 100)];
+
+  return [obj count] -
+         [(P*)0 count] + [array count] +
+         [fun() count] - 
+         [[obj PropertyReturnsPObj] count] +
+         [self->obj count];
+}
+
+- (P*) MethodReturnsPObj { return 0; }
+@end
diff --git a/test/ARCMT/objcmt-property-dot-syntax.m.result b/test/ARCMT/objcmt-property-dot-syntax.m.result
new file mode 100644
index 0000000..88006e9
--- /dev/null
+++ b/test/ARCMT/objcmt-property-dot-syntax.m.result
@@ -0,0 +1,39 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result
+
+// rdar://18498572
+@interface NSObject @end
+
+@interface P : NSObject
+{
+  P* obj;
+  int i1, i2, i3;
+}
+@property int count;
+@property (copy) P* PropertyReturnsPObj;
+- (P*) MethodReturnsPObj;
+@end
+
+P* fun();
+
+@implementation P
+- (int) Meth : (P*)array {
+  obj.count = 100;
+
+  ((P*)0).count = array.count;
+
+  obj.PropertyReturnsPObj.count = array.count;
+
+  obj.count = (i1+i2*i3 - 100);
+
+  return obj.count -
+         ((P*)0).count + array.count +
+         fun().count - 
+         obj.PropertyReturnsPObj.count +
+         self->obj.count;
+}
+
+- (P*) MethodReturnsPObj { return 0; }
+@end
diff --git a/test/ARCMT/objcmt-undefined-ns-macros.m b/test/ARCMT/objcmt-undefined-ns-macros.m
new file mode 100644
index 0000000..2e1fa51
--- /dev/null
+++ b/test/ARCMT/objcmt-undefined-ns-macros.m
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+// rdar://18498550
+
+typedef long NSInteger;
+enum {
+    UIViewNone         = 0x0,
+    UIViewMargin       = 0x1,
+    UIViewWidth        = 0x2,
+    UIViewRightMargin  = 0x3,
+    UIViewBottomMargin = 0xbadbeef
+};
+typedef NSInteger UITableStyle;
+
+
+typedef
+  enum { two = 1 } NumericEnum2;
+
+typedef enum { three = 1 } NumericEnum3;
+
+typedef enum { four = 1 } NumericEnum4;
+
diff --git a/test/ARCMT/objcmt-undefined-ns-macros.m.result b/test/ARCMT/objcmt-undefined-ns-macros.m.result
new file mode 100644
index 0000000..866e4d0
--- /dev/null
+++ b/test/ARCMT/objcmt-undefined-ns-macros.m.result
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+// rdar://18498550
+
+typedef long NSInteger;
+#ifndef NS_ENUM
+@import Foundation;
+#endif
+typedef NS_OPTIONS(NSUInteger, UITableStyle) {
+    UIViewNone         = 0x0,
+    UIViewMargin       = 0x1,
+    UIViewWidth        = 0x2,
+    UIViewRightMargin  = 0x3,
+    UIViewBottomMargin = 0xbadbeef
+};
+
+
+typedef
+  NS_ENUM(NSInteger, NumericEnum2) { two = 1 };
+
+typedef NS_ENUM(NSInteger, NumericEnum3) { three = 1 };
+
+typedef NS_ENUM(NSInteger, NumericEnum4) { four = 1 };
+
diff --git a/test/Analysis/Inputs/Models/modeledFunction.model b/test/Analysis/Inputs/Models/modeledFunction.model
new file mode 100644
index 0000000..3aff5fc
--- /dev/null
+++ b/test/Analysis/Inputs/Models/modeledFunction.model
@@ -0,0 +1,3 @@
+void modelled(intptr p) {
+ ++*p;
+}
\ No newline at end of file
diff --git a/test/Analysis/Inputs/Models/notzero.model b/test/Analysis/Inputs/Models/notzero.model
new file mode 100644
index 0000000..2616102
--- /dev/null
+++ b/test/Analysis/Inputs/Models/notzero.model
@@ -0,0 +1,3 @@
+bool notzero(int i) {
+ return i != 0;
+}
\ No newline at end of file
diff --git a/test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h b/test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h
new file mode 100644
index 0000000..b290ffe
--- /dev/null
+++ b/test/Analysis/Inputs/system-header-simulator-for-pthread-lock.h
@@ -0,0 +1,28 @@
+// Like the compiler, the static analyzer treats some functions differently if
+// they come from a system header -- for example, pthread_mutex* functions
+// should not invalidate regions of their arguments.
+#pragma clang system_header
+
+typedef struct {
+	void	*foo;
+} pthread_mutex_t;
+
+typedef struct {
+	void	*foo;
+} pthread_mutexattr_t;
+
+typedef struct {
+	void	*foo;
+} lck_grp_t;
+
+typedef pthread_mutex_t lck_mtx_t;
+
+extern int pthread_mutex_lock(pthread_mutex_t *);
+extern int pthread_mutex_unlock(pthread_mutex_t *);
+extern int pthread_mutex_trylock(pthread_mutex_t *);
+extern int pthread_mutex_destroy(pthread_mutex_t *);
+extern int pthread_mutex_init(pthread_mutex_t  *mutex, const pthread_mutexattr_t *mutexattr);
+extern int lck_mtx_lock(lck_mtx_t *);
+extern int lck_mtx_unlock(lck_mtx_t *);
+extern int lck_mtx_try_lock(lck_mtx_t *);
+extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp);
diff --git a/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp b/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
index 5a596d4..fca02aa 100644
--- a/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
+++ b/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
 
 #include "Inputs/system-header-simulator-for-malloc.h"
 
diff --git a/test/Analysis/Malloc+NewDelete_intersections.cpp b/test/Analysis/Malloc+NewDelete_intersections.cpp
index 3106636..d10020d 100644
--- a/test/Analysis/Malloc+NewDelete_intersections.cpp
+++ b/test/Analysis/Malloc+NewDelete_intersections.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -verify %s
 
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
diff --git a/test/Analysis/NSContainers.m b/test/Analysis/NSContainers.m
index 4b34926..402ce2c 100644
--- a/test/Analysis/NSContainers.m
+++ b/test/Analysis/NSContainers.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1  -Wno-objc-literal-conversion -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
 
 void clang_analyzer_eval(int);
 
diff --git a/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp b/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
index b606f23..49358f6 100644
--- a/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
+++ b/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
 // expected-no-diagnostics
 
 typedef __typeof(sizeof(int)) size_t;
diff --git a/test/Analysis/NewDelete-checker-test.cpp b/test/Analysis/NewDelete-checker-test.cpp
index 855b05d..84176c9 100644
--- a/test/Analysis/NewDelete-checker-test.cpp
+++ b/test/Analysis/NewDelete-checker-test.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s
 #include "Inputs/system-header-simulator-cxx.h"
 
 typedef __typeof__(sizeof(int)) size_t;
diff --git a/test/Analysis/NewDelete-custom.cpp b/test/Analysis/NewDelete-custom.cpp
index c64bfce..d368889 100644
--- a/test/Analysis/NewDelete-custom.cpp
+++ b/test/Analysis/NewDelete-custom.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s
 #include "Inputs/system-header-simulator-cxx.h"
 
 #ifndef LEAKS
diff --git a/test/Analysis/NewDelete-intersections.mm b/test/Analysis/NewDelete-intersections.mm
index 9024ed5..886df12 100644
--- a/test/Analysis/NewDelete-intersections.mm
+++ b/test/Analysis/NewDelete-intersections.mm
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s
 #include "Inputs/system-header-simulator-cxx.h"
 #include "Inputs/system-header-simulator-objc.h"
 
diff --git a/test/Analysis/NewDelete-variadic.cpp b/test/Analysis/NewDelete-variadic.cpp
index 62a7d17..f9ef079 100644
--- a/test/Analysis/NewDelete-variadic.cpp
+++ b/test/Analysis/NewDelete-variadic.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
 // expected-no-diagnostics
 
 namespace std {
diff --git a/test/Analysis/NewDeleteLeaks-PR18394.cpp b/test/Analysis/NewDeleteLeaks-PR18394.cpp
index dfd9456..d0d7037 100644
--- a/test/Analysis/NewDeleteLeaks-PR18394.cpp
+++ b/test/Analysis/NewDeleteLeaks-PR18394.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyze -analyzer-checker=core,alpha.cplusplus.NewDeleteLeaks -verify %s
+// RUN: %clang_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
 // expected-no-diagnostics
 
 class A {
diff --git a/test/Analysis/NewDeleteLeaks-PR19102.cpp b/test/Analysis/NewDeleteLeaks-PR19102.cpp
new file mode 100644
index 0000000..b141301
--- /dev/null
+++ b/test/Analysis/NewDeleteLeaks-PR19102.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
+
+class A0 {};
+
+class A1 {
+public:
+  A1(int);
+};
+
+struct S{
+  int i;
+};
+
+class A2 {
+public:
+  A2();
+  A2(S);
+  A2(int*);
+  A2(S*);
+  A2(S&, int);
+  A2(int, S**);
+};
+
+void test() {
+  new int; // expected-warning@+1 {{Potential memory leak}}
+  new A0; // expected-warning@+1 {{Potential memory leak}}
+  new A1(0); // expected-warning@+1 {{Potential memory leak}}
+  new A2; // expected-warning@+1 {{Potential memory leak}}
+  S s;
+  s.i = 1;
+  S* ps = new S;
+  new A2(s); // expected-warning@+1 {{Potential memory leak}}
+  new A2(&(s.i)); // expected-warning@+1 {{Potential memory leak}}
+  new A2(ps); // no warning
+  new A2(*ps, 1); // no warning
+  new A2(1, &ps); // no warning
+
+  // Tests to ensure that leaks are reported for consumed news no matter what the arguments are.
+  A2 *a2p1 = new A2; // expected-warning@+1 {{Potential leak of memory}}
+  A2 *a2p2 = new A2(ps); // expected-warning@+1 {{Potential leak of memory}}
+  A2 *a2p3 = new A2(*ps, 1); // expected-warning@+1 {{Potential leak of memory}}
+  A2 *a2p4 = new A2(1, &ps); // expected-warning@+1 {{Potential leak of memory}}
+}
diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c
index 69d281a..824aa7c 100644
--- a/test/Analysis/bstring.c
+++ b/test/Analysis/bstring.c
@@ -257,6 +257,45 @@
   mempcpy(a, 0, 0); // no-warning
 }
 
+void mempcpy14() {
+  int src[] = {1, 2, 3, 4};
+  int dst[5] = {0};
+  int *p;
+
+  p = mempcpy(dst, src, 4 * sizeof(int));
+
+  clang_analyzer_eval(p == &dst[4]); // expected-warning{{TRUE}}
+}
+
+struct st {
+  int i;
+  int j;
+};
+
+void mempcpy15() {
+  struct st s1 = {0};
+  struct st s2;
+  struct st *p1;
+  struct st *p2;
+
+  p1 = (&s2) + 1;
+  p2 = mempcpy(&s2, &s1, sizeof(struct st));
+
+  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+}
+
+void mempcpy16() {
+  struct st s1[10] = {{0}};
+  struct st s2[10];
+  struct st *p1;
+  struct st *p2;
+
+  p1 = (&s2[0]) + 5;
+  p2 = mempcpy(&s2[0], &s1[0], 5 * sizeof(struct st));
+
+  clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
+}
+
 void mempcpy_unknown_size_warn (size_t n) {
   char a[4];
   void *result = mempcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}}
diff --git a/test/Analysis/builtin-functions.cpp b/test/Analysis/builtin-functions.cpp
index 72d5ad2..d3afab5 100644
--- a/test/Analysis/builtin-functions.cpp
+++ b/test/Analysis/builtin-functions.cpp
@@ -22,3 +22,31 @@
 
   clang_analyzer_eval(i == 0); // expected-warning{{TRUE}}
 }
+
+void test_assume_aligned_1(char *p) {
+  char *q;
+
+  q = (char*) __builtin_assume_aligned(p, 16);
+  clang_analyzer_eval(p == q); // expected-warning{{TRUE}}
+}
+
+void test_assume_aligned_2(char *p) {
+  char *q;
+
+  q = (char*) __builtin_assume_aligned(p, 16, 8);
+  clang_analyzer_eval(p == q); // expected-warning{{TRUE}}
+}
+
+void test_assume_aligned_3(char *p) {
+  void *q;
+
+  q = __builtin_assume_aligned(p, 16, 8);
+  clang_analyzer_eval(p == q); // expected-warning{{TRUE}}
+}
+
+void test_assume_aligned_4(char *p) {
+  char *q;
+
+  q = (char*) __builtin_assume_aligned(p + 1, 16);
+  clang_analyzer_eval(p == q); // expected-warning{{FALSE}}
+}
diff --git a/test/Analysis/cfg.cpp b/test/Analysis/cfg.cpp
index 65060b1..28cc440 100644
--- a/test/Analysis/cfg.cpp
+++ b/test/Analysis/cfg.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -std=c++11 %s > %t 2>&1
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 // CHECK-LABEL: void checkWrap(int i)
@@ -377,6 +377,61 @@
 }
 
 
+// CHECK-LABEL: void test_lifetime_extended_temporaries()
+// CHECK: [B1]
+struct LifetimeExtend { LifetimeExtend(int); ~LifetimeExtend(); };
+struct Aggregate { const LifetimeExtend a; const LifetimeExtend b; };
+struct AggregateRef { const LifetimeExtend &a; const LifetimeExtend &b; };
+void test_lifetime_extended_temporaries() {
+  // CHECK: LifetimeExtend(1);
+  // CHECK-NEXT: : 1
+  // CHECK-NEXT: ~LifetimeExtend()
+  // CHECK-NOT: ~LifetimeExtend()
+  {
+    const LifetimeExtend &l = LifetimeExtend(1);
+    1;
+  }
+  // CHECK: LifetimeExtend(2)
+  // CHECK-NEXT: ~LifetimeExtend()
+  // CHECK-NEXT: : 2
+  // CHECK-NOT: ~LifetimeExtend()
+  {
+    // No life-time extension.
+    const int &l = (LifetimeExtend(2), 2);
+    2;
+  }
+  // CHECK: LifetimeExtend(3)
+  // CHECK-NEXT: : 3
+  // CHECK-NEXT: ~LifetimeExtend()
+  // CHECK-NOT: ~LifetimeExtend()
+  {
+    // The last one is lifetime extended.
+    const LifetimeExtend &l = (3, LifetimeExtend(3));
+    3;
+  }
+  // CHECK: LifetimeExtend(4)
+  // CHECK-NEXT: ~LifetimeExtend()
+  // CHECK-NEXT: ~LifetimeExtend()
+  // CHECK-NEXT: : 4
+  // CHECK-NOT: ~LifetimeExtend()
+  {
+    Aggregate a{LifetimeExtend(4), LifetimeExtend(4)};
+    4;
+  }
+  // CHECK: LifetimeExtend(5)
+  // CHECK-NEXT: : 5
+  // FIXME: We want to emit the destructors of the lifetime
+  // extended variables here.
+  // CHECK-NOT: ~LifetimeExtend()
+  {
+    AggregateRef a{LifetimeExtend(5), LifetimeExtend(5)};
+    5;
+  }
+  // FIXME: Add tests for lifetime extension via subobject
+  // references (LifetimeExtend().some_member).
+}
+
+
 // CHECK-LABEL: int *PR18472()
 // CHECK: [B2 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B1
diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c
index 5b2c2a1..da8e8bd 100644
--- a/test/Analysis/dead-stores.c
+++ b/test/Analysis/dead-stores.c
@@ -11,7 +11,7 @@
  char *c = (char*)b; // no-warning
  char *d = b+1; // expected-warning {{never read}} expected-warning{{unused variable 'd'}}
  printf("%s", c); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
- // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+ // expected-note{{include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
 }
 
 int f();
diff --git a/test/Analysis/disable-all-checks.c b/test/Analysis/disable-all-checks.c
new file mode 100644
index 0000000..461e6d9
--- /dev/null
+++ b/test/Analysis/disable-all-checks.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-disable-all-checks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-disable-all-checks -analyzer-checker=core -analyzer-store=region -verify %s
+// RUN: %clang --analyze -Xanalyzer -analyzer-disable-all-checks -Xclang -verify %s
+// RUN: not %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-disable-checker -verify %s 2>&1 | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: use -analyzer-disable-all-checks to disable all static analyzer checkers
+int buggy() {
+  int x = 0;
+  return 5/x; // no warning
+}
\ No newline at end of file
diff --git a/test/Analysis/exercise-ps.c b/test/Analysis/exercise-ps.c
index 675dd4e..03b6874 100644
--- a/test/Analysis/exercise-ps.c
+++ b/test/Analysis/exercise-ps.c
@@ -19,5 +19,5 @@
   F12_typedef* x;
   x = f2_helper();
   memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \
-  // expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
+  // expected-note{{include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
 }
diff --git a/test/Analysis/identical-expressions.cpp b/test/Analysis/identical-expressions.cpp
index 85e3322..46dd562 100644
--- a/test/Analysis/identical-expressions.cpp
+++ b/test/Analysis/identical-expressions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.IdenticalExpr -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.IdenticalExpr -w -verify %s
 
 /* Only one expected warning per function allowed at the very end. */
 
@@ -1511,3 +1511,22 @@
   else if (x++) // no-warning
     ;
 }
+
+void test_warn_wchar() {
+  const wchar_t * a = 0 ? L"Warning" : L"Warning"; // expected-warning {{identical expressions on both sides of ':' in conditional expression}}
+}
+void test_nowarn_wchar() {
+  const wchar_t * a = 0 ? L"No" : L"Warning";
+}
+
+void test_nowarn_long() {
+  int a = 0, b = 0;
+  long c;
+  if (0) {
+    b -= a;
+    c = 0;
+  } else { // no-warning
+    b -= a;
+    c = 0LL;
+  }
+}
diff --git a/test/Analysis/logical-ops.c b/test/Analysis/logical-ops.c
index afaa2f1..0b63bc9 100644
--- a/test/Analysis/logical-ops.c
+++ b/test/Analysis/logical-ops.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -Wno-pointer-bool-conversion -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
 
 void clang_analyzer_eval(int);
 
diff --git a/test/Analysis/malloc-protoype.c b/test/Analysis/malloc-protoype.c
new file mode 100644
index 0000000..f056f0f
--- /dev/null
+++ b/test/Analysis/malloc-protoype.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -w -analyze -analyzer-checker=core,unix.Malloc -verify %s
+// expected-no-diagnostics
+
+// Test that strange prototypes doesn't crash the analyzer
+
+void malloc(int i);
+void valloc(int i);
+
+void test1()
+{
+  malloc(1);
+}
+
+void test2()
+{
+  valloc(1);
+}
diff --git a/test/Analysis/malloc-sizeof.cpp b/test/Analysis/malloc-sizeof.cpp
new file mode 100644
index 0000000..8589975
--- /dev/null
+++ b/test/Analysis/malloc-sizeof.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.MallocSizeof -verify %s
+
+#include <stddef.h>
+
+void *malloc(size_t size);
+void *calloc(size_t nmemb, size_t size);
+void *realloc(void *ptr, size_t size);
+void free(void *ptr);
+
+struct A {};
+struct B {};
+
+void foo(unsigned int unsignedInt, unsigned int readSize) {
+  // Sanity check the checker is working as expected.
+  A* a = static_cast<A*>(malloc(sizeof(int))); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'int'}}
+  free(a);
+}
+
+void bar() {
+  A *x = static_cast<A*>(calloc(10, sizeof(void*))); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'void *'}}
+  // sizeof(void*) is compatible with any pointer.
+  A **y = static_cast<A**>(calloc(10, sizeof(void*))); // no-warning
+  free(x);
+  free(y);
+}
+
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 6da9604..ad7393b 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -118,19 +118,6 @@
   return __extension__ (__m128i)(__v2di){ __q0, __q1 };
 }
 
-// Zero-sized VLAs.
-void check_zero_sized_VLA(int x) {
-  if (x)
-    return;
-
-  int vla[x]; // expected-warning{{Declared variable-length array (VLA) has zero size}}
-}
-
-void check_uninit_sized_VLA() {
-  int x;
-  int vla[x]; // expected-warning{{Declared variable-length array (VLA) uses a garbage value as its size}}
-}
-
 // sizeof(void)
 // - Tests a regression reported in PR 3211: http://llvm.org/bugs/show_bug.cgi?id=3211
 void handle_sizeof_void(unsigned flag) {
diff --git a/test/Analysis/model-file.cpp b/test/Analysis/model-file.cpp
new file mode 100644
index 0000000..24d6e93
--- /dev/null
+++ b/test/Analysis/model-file.cpp
@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config faux-bodies=true,model-path=%S/Inputs/Models -analyzer-output=plist-multi-file -verify %s -o %t
+// RUN: FileCheck --input-file=%t %s
+
+typedef int* intptr;
+
+// This function is modeled and the p pointer is dereferenced in the model
+// function and there is no function definition available. The modeled
+// function can use any types that are available in the original translation
+// unit, for example intptr in this case.
+void modeledFunction(intptr p);
+
+// This function is modeled and returns true if the parameter is not zero
+// and there is no function definition available.
+bool notzero(int i);
+
+// This functions is not modeled and there is no function definition.
+// available
+bool notzero_notmodeled(int i);
+
+int main() {
+  // There is a nullpointer dereference inside this function.
+  modeledFunction(0);
+
+  int p = 0;
+  if (notzero(p)) {
+   // It is known that p != 0 because of the information provided by the
+   // model of the notzero function.
+    int j = 5 / p;
+  }
+
+  if (notzero_notmodeled(p)) {
+   // There is no information about the value of p, because
+   // notzero_notmodeled is not modeled and the function definition
+   // is not available.
+    int j = 5 / p; // expected-warning {{Division by zero}}
+  }
+
+  return 0;
+}
+
+// CHECK:  <key>diagnostics</key>
+// CHECK-NEXT:  <array>
+// CHECK-NEXT:  <dict>
+// CHECK-NEXT:   <key>path</key>
+// CHECK-NEXT:   <array>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>control</string>
+// CHECK-NEXT:     <key>edges</key>
+// CHECK-NEXT:      <array>
+// CHECK-NEXT:       <dict>
+// CHECK-NEXT:        <key>start</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>22</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>22</integer>
+// CHECK-NEXT:           <key>col</key><integer>17</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:        <key>end</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>24</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>24</integer>
+// CHECK-NEXT:           <key>col</key><integer>5</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:       </dict>
+// CHECK-NEXT:      </array>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>event</string>
+// CHECK-NEXT:     <key>location</key>
+// CHECK-NEXT:     <dict>
+// CHECK-NEXT:      <key>line</key><integer>24</integer>
+// CHECK-NEXT:      <key>col</key><integer>3</integer>
+// CHECK-NEXT:      <key>file</key><integer>0</integer>
+// CHECK-NEXT:     </dict>
+// CHECK-NEXT:     <key>ranges</key>
+// CHECK-NEXT:     <array>
+// CHECK-NEXT:       <array>
+// CHECK-NEXT:        <dict>
+// CHECK-NEXT:         <key>line</key><integer>24</integer>
+// CHECK-NEXT:         <key>col</key><integer>3</integer>
+// CHECK-NEXT:         <key>file</key><integer>0</integer>
+// CHECK-NEXT:        </dict>
+// CHECK-NEXT:        <dict>
+// CHECK-NEXT:         <key>line</key><integer>24</integer>
+// CHECK-NEXT:         <key>col</key><integer>7</integer>
+// CHECK-NEXT:         <key>file</key><integer>0</integer>
+// CHECK-NEXT:        </dict>
+// CHECK-NEXT:       </array>
+// CHECK-NEXT:     </array>
+// CHECK-NEXT:     <key>depth</key><integer>0</integer>
+// CHECK-NEXT:     <key>extended_message</key>
+// CHECK-NEXT:     <string>&apos;p&apos; initialized to 0</string>
+// CHECK-NEXT:     <key>message</key>
+// CHECK-NEXT:     <string>&apos;p&apos; initialized to 0</string>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>control</string>
+// CHECK-NEXT:     <key>edges</key>
+// CHECK-NEXT:      <array>
+// CHECK-NEXT:       <dict>
+// CHECK-NEXT:        <key>start</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>24</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>24</integer>
+// CHECK-NEXT:           <key>col</key><integer>5</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:        <key>end</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>25</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>25</integer>
+// CHECK-NEXT:           <key>col</key><integer>4</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:       </dict>
+// CHECK-NEXT:      </array>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>control</string>
+// CHECK-NEXT:     <key>edges</key>
+// CHECK-NEXT:      <array>
+// CHECK-NEXT:       <dict>
+// CHECK-NEXT:        <key>start</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>25</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>25</integer>
+// CHECK-NEXT:           <key>col</key><integer>4</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:        <key>end</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>4</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:       </dict>
+// CHECK-NEXT:      </array>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>control</string>
+// CHECK-NEXT:     <key>edges</key>
+// CHECK-NEXT:      <array>
+// CHECK-NEXT:       <dict>
+// CHECK-NEXT:        <key>start</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>3</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>4</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:        <key>end</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>7</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>24</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:       </dict>
+// CHECK-NEXT:      </array>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>control</string>
+// CHECK-NEXT:     <key>edges</key>
+// CHECK-NEXT:      <array>
+// CHECK-NEXT:       <dict>
+// CHECK-NEXT:        <key>start</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>7</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>31</integer>
+// CHECK-NEXT:           <key>col</key><integer>24</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:        <key>end</key>
+// CHECK-NEXT:         <array>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>35</integer>
+// CHECK-NEXT:           <key>col</key><integer>15</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:          <dict>
+// CHECK-NEXT:           <key>line</key><integer>35</integer>
+// CHECK-NEXT:           <key>col</key><integer>15</integer>
+// CHECK-NEXT:           <key>file</key><integer>0</integer>
+// CHECK-NEXT:          </dict>
+// CHECK-NEXT:         </array>
+// CHECK-NEXT:       </dict>
+// CHECK-NEXT:      </array>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:    <dict>
+// CHECK-NEXT:     <key>kind</key><string>event</string>
+// CHECK-NEXT:     <key>location</key>
+// CHECK-NEXT:     <dict>
+// CHECK-NEXT:      <key>line</key><integer>35</integer>
+// CHECK-NEXT:      <key>col</key><integer>15</integer>
+// CHECK-NEXT:      <key>file</key><integer>0</integer>
+// CHECK-NEXT:     </dict>
+// CHECK-NEXT:     <key>ranges</key>
+// CHECK-NEXT:     <array>
+// CHECK-NEXT:       <array>
+// CHECK-NEXT:        <dict>
+// CHECK-NEXT:         <key>line</key><integer>35</integer>
+// CHECK-NEXT:         <key>col</key><integer>13</integer>
+// CHECK-NEXT:         <key>file</key><integer>0</integer>
+// CHECK-NEXT:        </dict>
+// CHECK-NEXT:        <dict>
+// CHECK-NEXT:         <key>line</key><integer>35</integer>
+// CHECK-NEXT:         <key>col</key><integer>17</integer>
+// CHECK-NEXT:         <key>file</key><integer>0</integer>
+// CHECK-NEXT:        </dict>
+// CHECK-NEXT:       </array>
+// CHECK-NEXT:     </array>
+// CHECK-NEXT:     <key>depth</key><integer>0</integer>
+// CHECK-NEXT:     <key>extended_message</key>
+// CHECK-NEXT:     <string>Division by zero</string>
+// CHECK-NEXT:     <key>message</key>
+// CHECK-NEXT:     <string>Division by zero</string>
+// CHECK-NEXT:    </dict>
+// CHECK-NEXT:   </array>
+// CHECK-NEXT:   <key>description</key><string>Division by zero</string>
+// CHECK-NEXT:   <key>category</key><string>Logic error</string>
+// CHECK-NEXT:   <key>type</key><string>Division by zero</string>
+// CHECK-NEXT:  <key>issue_context_kind</key><string>function</string>
+// CHECK-NEXT:  <key>issue_context</key><string>main</string>
+// CHECK-NEXT:  <key>issue_hash</key><string>15</string>
+// CHECK-NEXT:  <key>location</key>
+// CHECK-NEXT:  <dict>
+// CHECK-NEXT:   <key>line</key><integer>35</integer>
+// CHECK-NEXT:   <key>col</key><integer>15</integer>
+// CHECK-NEXT:   <key>file</key><integer>0</integer>
+// CHECK-NEXT:  </dict>
+// CHECK-NEXT:  </dict>
+// CHECK-NEXT: </array>
\ No newline at end of file
diff --git a/test/Analysis/nonnull.m b/test/Analysis/nonnull.m
index 0cea80b..c21360d 100644
--- a/test/Analysis/nonnull.m
+++ b/test/Analysis/nonnull.m
@@ -75,3 +75,121 @@
   rdar16153464_check(inner); // no-warning
   rdar16153464_check(0); // expected-warning{{nonnull}}
 }
+
+// Multiple attributes, the basic case
+void multipleAttributes_1(char *p, char *q) __attribute((nonnull(1))) __attribute((nonnull(2)));
+
+void testMultiple_1(void) {
+  char c;
+  multipleAttributes_1(&c, &c); // no-warning
+}
+
+void testMultiple_2(void) {
+  char c;
+  multipleAttributes_1(0, &c); // expected-warning{{nonnull}}
+}
+
+void testMultiple_3(void) {
+  char c;
+  multipleAttributes_1(&c, 0); // expected-warning{{nonnull}}
+}
+
+void testMultiple_4(void) {
+  multipleAttributes_1(0, 0);// expected-warning{{nonnull}}
+}
+
+// Multiple attributes, multiple prototypes
+void multipleAttributes_2(char *p, char *q) __attribute((nonnull(1)));
+void multipleAttributes_2(char *p, char *q) __attribute((nonnull(2)));
+
+void testMultiple_5(void) {
+  char c;
+  multipleAttributes_2(0, &c);// expected-warning{{nonnull}}
+}
+
+void testMultiple_6(void) {
+  char c;
+  multipleAttributes_2(&c, 0);// expected-warning{{nonnull}}
+}
+
+void testMultiple_7(void) {
+  multipleAttributes_2(0, 0);// expected-warning{{nonnull}}
+}
+
+// Multiple attributes, same index
+void multipleAttributes_3(char *p, char *q) __attribute((nonnull(1))) __attribute((nonnull(1)));
+
+void testMultiple_8(void) {
+  char c;
+  multipleAttributes_3(0, &c); // expected-warning{{nonnull}}
+}
+
+void testMultiple_9(void) {
+  char c;
+  multipleAttributes_3(&c, 0); // no-warning
+}
+
+// Multiple attributes, the middle argument is missing an attribute
+void multipleAttributes_4(char *p, char *q, char *r) __attribute((nonnull(1))) __attribute((nonnull(3)));
+
+void testMultiple_10(void) {
+  char c;
+  multipleAttributes_4(0, &c, &c); // expected-warning{{nonnull}}
+}
+
+void testMultiple_11(void) {
+  char c;
+  multipleAttributes_4(&c, 0, &c); // no-warning
+}
+
+void testMultiple_12(void) {
+  char c;
+  multipleAttributes_4(&c, &c, 0); // expected-warning{{nonnull}}
+}
+
+
+// Multiple attributes, when the last is without index
+void multipleAttributes_all_1(char *p, char *q) __attribute((nonnull(1))) __attribute((nonnull));
+
+void testMultiple_13(void) {
+  char c;
+  multipleAttributes_all_1(0, &c); // expected-warning{{nonnull}}
+}
+
+void testMultiple_14(void) {
+  char c;
+  multipleAttributes_all_1(&c, 0); // expected-warning{{nonnull}}
+}
+
+// Multiple attributes, when the first is without index
+void multipleAttributes_all_2(char *p, char *q) __attribute((nonnull)) __attribute((nonnull(2)));
+
+void testMultiple_15(void) {
+  char c;
+  multipleAttributes_all_2(0, &c); // expected-warning{{nonnull}}
+}
+
+void testMultiple_16(void) {
+  char c;
+  multipleAttributes_all_2(&c, 0); // expected-warning{{nonnull}}
+}
+
+void testVararg(int k, void *p) {
+  extern void testVararg_check(int, ...) __attribute__((nonnull));
+  void *n = 0;
+  testVararg_check(0);
+  testVararg_check(1, p);
+  if (k == 1)
+    testVararg_check(1, n); // expected-warning{{nonnull}}
+  testVararg_check(2, p, p);
+  if (k == 2)
+    testVararg_check(2, n, p); // expected-warning{{nonnull}}
+  if (k == 3)
+    testVararg_check(2, p, n); // expected-warning{{nonnull}}
+}
+
+void testNotPtr() {
+  struct S { int a; int b; int c; } s = {};
+  extern void testNotPtr_check(struct S, int) __attribute__((nonnull(1, 2)));
+  testNotPtr_check(s, 0);
+}
diff --git a/test/Analysis/objc-boxing.m b/test/Analysis/objc-boxing.m
index c23192e..73386f4 100644
--- a/test/Analysis/objc-boxing.m
+++ b/test/Analysis/objc-boxing.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,osx.cocoa.NonNilReturnValue,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -Wno-objc-literal-conversion -analyze -analyzer-checker=core,unix.Malloc,osx.cocoa.NonNilReturnValue,debug.ExprInspection -analyzer-store=region -verify %s
 
 void clang_analyzer_eval(int);
 
diff --git a/test/Analysis/pthreadlock.c b/test/Analysis/pthreadlock.c
index 2a59e0f..a6e29e7 100644
--- a/test/Analysis/pthreadlock.c
+++ b/test/Analysis/pthreadlock.c
@@ -2,31 +2,10 @@
 
 // Tests performing normal locking patterns and wrong locking orders
 
-typedef struct {
-	void	*foo;
-} pthread_mutex_t;
-
-typedef struct {
-	void	*foo;
-} pthread_mutexattr_t;
-
-typedef struct {
-	void	*foo;
-} lck_grp_t;
-
-typedef pthread_mutex_t lck_mtx_t;
-
-extern int pthread_mutex_lock(pthread_mutex_t *);
-extern int pthread_mutex_unlock(pthread_mutex_t *);
-extern int pthread_mutex_trylock(pthread_mutex_t *);
-extern int pthread_mutex_destroy(pthread_mutex_t *);
-extern int pthread_mutex_init(pthread_mutex_t  *mutex, const pthread_mutexattr_t *mutexattr);
-extern int lck_mtx_lock(lck_mtx_t *);
-extern int lck_mtx_unlock(lck_mtx_t *);
-extern int lck_mtx_try_lock(lck_mtx_t *);
-extern void lck_mtx_destroy(lck_mtx_t *lck, lck_grp_t *grp);
+#include "Inputs/system-header-simulator-for-pthread-lock.h"
 
 pthread_mutex_t mtx1, mtx2;
+pthread_mutex_t *pmtx;
 lck_mtx_t lck1, lck2;
 lck_grp_t grp1;
 
@@ -184,6 +163,21 @@
 }
 
 void
+ok21(void) {
+  pthread_mutex_lock(pmtx);    // no-warning
+  pthread_mutex_unlock(pmtx);  // no-warning
+}
+
+void
+ok22(void) {
+  pthread_mutex_lock(pmtx);    // no-warning
+  pthread_mutex_unlock(pmtx);  // no-warning
+  pthread_mutex_lock(pmtx);    // no-warning
+  pthread_mutex_unlock(pmtx);  // no-warning
+}
+
+
+void
 bad1(void)
 {
 	pthread_mutex_lock(&mtx1);	// no-warning
diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp
index 5fb33d3..491c68e 100644
--- a/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -324,7 +324,7 @@
 // CHECK:   [B3]
 // CHECK:     1: [B5.8] && [B4.5]
 // CHECK:     2: [B5.3]([B3.1])
-// CHECK:     T: (Temp Dtor) [B5.8] && ...
+// CHECK:     T: (Temp Dtor) [B4.2]
 // CHECK:     Preds (2): B4 B5
 // CHECK:     Succs (2): B2 B1
 // CHECK:   [B4]
@@ -354,7 +354,7 @@
 // CHECK:   [B7]
 // CHECK:     1: [B9.5] && [B8.5]
 // CHECK:     2: bool a = A() && B();
-// CHECK:     T: (Temp Dtor) [B9.5] && ...
+// CHECK:     T: (Temp Dtor) [B8.2]
 // CHECK:     Preds (2): B8 B9
 // CHECK:     Succs (2): B6 B5
 // CHECK:   [B8]
@@ -390,9 +390,9 @@
 // CHECK:   [B3]
 // CHECK:     1: [B5.8] || [B4.5]
 // CHECK:     2: [B5.3]([B3.1])
-// CHECK:     T: (Temp Dtor) [B5.8] || ...
+// CHECK:     T: (Temp Dtor) [B4.2]
 // CHECK:     Preds (2): B4 B5
-// CHECK:     Succs (2): B1 B2
+// CHECK:     Succs (2): B2 B1
 // CHECK:   [B4]
 // CHECK:     1: B() (CXXConstructExpr, class B)
 // CHECK:     2: [B4.1] (BindTemporary)
@@ -420,9 +420,9 @@
 // CHECK:   [B7]
 // CHECK:     1: [B9.5] || [B8.5]
 // CHECK:     2: bool a = A() || B();
-// CHECK:     T: (Temp Dtor) [B9.5] || ...
+// CHECK:     T: (Temp Dtor) [B8.2]
 // CHECK:     Preds (2): B8 B9
-// CHECK:     Succs (2): B5 B6
+// CHECK:     Succs (2): B6 B5
 // CHECK:   [B8]
 // CHECK:     1: B() (CXXConstructExpr, class B)
 // CHECK:     2: [B8.1] (BindTemporary)
@@ -492,9 +492,9 @@
 // CHECK:     3: [B7.2]
 // CHECK:     4: [B7.3] (CXXConstructExpr, class A)
 // CHECK:     5: A a = B() ? A() : A(B());
-// CHECK:     T: (Temp Dtor) [B10.5] ? ... : ...
+// CHECK:     T: (Temp Dtor) [B9.2]
 // CHECK:     Preds (2): B8 B9
-// CHECK:     Succs (2): B5 B6
+// CHECK:     Succs (2): B6 B5
 // CHECK:   [B8]
 // CHECK:     1: A() (CXXConstructExpr, class A)
 // CHECK:     2: [B8.1] (BindTemporary)
@@ -533,7 +533,6 @@
 // CHECK:     Succs (2): B8 B9
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (1): B1
-// CHECK:  C() : b_(true)
 // CHECK:   [B2 (ENTRY)]
 // CHECK:     Succs (1): B1
 // CHECK:   [B1]
@@ -543,12 +542,10 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (1): B1
-// CHECK:  ~C()
 // CHECK:   [B1 (ENTRY)]
 // CHECK:     Succs (1): B0
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (1): B1
-// CHECK:  operator bool()
 // CHECK:   [B2 (ENTRY)]
 // CHECK:     Succs (1): B1
 // CHECK:   [B1]
@@ -560,7 +557,6 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (1): B1
-// CHECK:  D() : b_(true)
 // CHECK:   [B2 (ENTRY)]
 // CHECK:     Succs (1): B1
 // CHECK:   [B1]
@@ -570,7 +566,6 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (1): B1
-// CHECK:  operator bool()
 // CHECK:   [B2 (ENTRY)]
 // CHECK:     Succs (1): B1
 // CHECK:   [B1]
@@ -582,7 +577,6 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (1): B1
-// CHECK:  int test_cond_unnamed_custom_destructor()
 // CHECK:   [B4 (ENTRY)]
 // CHECK:     Succs (1): B3
 // CHECK:   [B1]
@@ -607,7 +601,6 @@
 // CHECK:     Succs (2): B2 B1
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (2): B1 B2
-// CHECK:  int test_cond_named_custom_destructor()
 // CHECK:   [B5 (ENTRY)]
 // CHECK:     Succs (1): B4
 // CHECK:   [B1]
@@ -642,7 +635,6 @@
 // CHECK:     Succs (2): B3 B2
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (3): B1 B2 B3
-// CHECK:  int test_cond_unnamed_auto_destructor()
 // CHECK:   [B4 (ENTRY)]
 // CHECK:     Succs (1): B3
 // CHECK:   [B1]
@@ -665,7 +657,6 @@
 // CHECK:     Succs (2): B2 B1
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (2): B1 B2
-// CHECK:  int test_cond_named_auto_destructor()
 // CHECK:   [B4 (ENTRY)]
 // CHECK:     Succs (1): B3
 // CHECK:   [B1]
@@ -718,9 +709,9 @@
 // CHECK:     2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     3: [B4.2]
 // CHECK:     4: [B7.3]([B4.3])
-// CHECK:     T: (Temp Dtor) [B7.8] ? ... : ...
+// CHECK:     T: (Temp Dtor) [B6.2]
 // CHECK:     Preds (2): B5 B6
-// CHECK:     Succs (2): B2 B3
+// CHECK:     Succs (2): B3 B2
 // CHECK:   [B5]
 // CHECK:     1: A() (CXXConstructExpr, class A)
 // CHECK:     2: [B5.1] (BindTemporary)
@@ -775,9 +766,9 @@
 // CHECK:     2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     3: [B10.2]
 // CHECK:     4: const A &a = B() ? A() : A(B());
-// CHECK:     T: (Temp Dtor) [B13.5] ? ... : ...
+// CHECK:     T: (Temp Dtor) [B12.2]
 // CHECK:     Preds (2): B11 B12
-// CHECK:     Succs (2): B8 B9
+// CHECK:     Succs (2): B9 B8
 // CHECK:   [B11]
 // CHECK:     1: A() (CXXConstructExpr, class A)
 // CHECK:     2: [B11.1] (BindTemporary)
@@ -819,9 +810,8 @@
 // CHECK:   [B8 (ENTRY)]
 // CHECK:     Succs (1): B7
 // CHECK:   [B1]
-// CHECK:     1: ~A() (Temporary object destructor)
-// CHECK:     2: int b;
-// CHECK:     3: [B4.5].~A() (Implicit destructor)
+// CHECK:     1: int b;
+// CHECK:     2: [B4.5].~A() (Implicit destructor)
 // CHECK:     Preds (2): B2 B3
 // CHECK:     Succs (1): B0
 // CHECK:   [B2]
@@ -839,9 +829,9 @@
 // CHECK:     3: [B4.2]
 // CHECK:     4: [B4.3] (CXXConstructExpr, class A)
 // CHECK:     5: A a = A() ?: A();
-// CHECK:     T: (Temp Dtor) [B7.5] ? ... : ...
+// CHECK:     T: (Temp Dtor) [B6.2]
 // CHECK:     Preds (2): B5 B6
-// CHECK:     Succs (2): B2 B3
+// CHECK:     Succs (2): B3 B2
 // CHECK:   [B5]
 // CHECK:     1: [B7.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     2: [B5.1]
@@ -872,9 +862,8 @@
 // CHECK:   [B13 (ENTRY)]
 // CHECK:     Succs (1): B12
 // CHECK:   [B1]
-// CHECK:     1: ~A() (Temporary object destructor)
-// CHECK:     2: int b;
-// CHECK:     3: [B9.4].~A() (Implicit destructor)
+// CHECK:     1: int b;
+// CHECK:     2: [B9.4].~A() (Implicit destructor)
 // CHECK:     Preds (2): B2 B3
 // CHECK:     Succs (1): B0
 // CHECK:   [B2]
@@ -887,15 +876,15 @@
 // CHECK:     Preds (1): B4
 // CHECK:     Succs (1): B1
 // CHECK:   [B4]
-// CHECK:     1: [B7.5] ?: [B6.6]
+// CHECK:     1: [B7.4] ?: [B6.6]
 // CHECK:     2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     3: [B4.2]
-// CHECK:     4: [B7.3]([B4.3])
-// CHECK:     T: (Temp Dtor) [B7.8] ? ... : ...
+// CHECK:     4: [B7.2]([B4.3])
+// CHECK:     T: (Temp Dtor) [B6.2]
 // CHECK:     Preds (2): B5 B6
-// CHECK:     Succs (2): B2 B3
+// CHECK:     Succs (2): B3 B2
 // CHECK:   [B5]
-// CHECK:     1: [B7.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK:     1: [B7.4] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     2: [B5.1]
 // CHECK:     3: [B5.2] (CXXConstructExpr, class A)
 // CHECK:     4: [B5.3] (BindTemporary)
@@ -911,16 +900,15 @@
 // CHECK:     Preds (1): B7
 // CHECK:     Succs (1): B4
 // CHECK:   [B7]
-// CHECK:     1: ~A() (Temporary object destructor)
-// CHECK:     2: foo
-// CHECK:     3: [B7.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
-// CHECK:     4: A() (CXXConstructExpr, class A)
-// CHECK:     5: [B7.4] (BindTemporary)
-// CHECK:     6: [B7.5].operator bool
-// CHECK:     7: [B7.5]
-// CHECK:     8: [B7.7] (ImplicitCastExpr, UserDefinedConversion, _Bool)
-// CHECK:     T: [B7.8] ? ... : ...
-// CHECK:     Preds (2): B9 B8
+// CHECK:     1: foo
+// CHECK:     2: [B7.1] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK:     3: A() (CXXConstructExpr, class A)
+// CHECK:     4: [B7.3] (BindTemporary)
+// CHECK:     5: [B7.4].operator bool
+// CHECK:     6: [B7.4]
+// CHECK:     7: [B7.6] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK:     T: [B7.7] ? ... : ...
+// CHECK:     Preds (2): B8 B9
 // CHECK:     Succs (2): B5 B6
 // CHECK:   [B8]
 // CHECK:     1: ~A() (Temporary object destructor)
@@ -931,9 +919,9 @@
 // CHECK:     2: [B9.1] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     3: [B9.2]
 // CHECK:     4: const A &a = A() ?: A();
-// CHECK:     T: (Temp Dtor) [B12.5] ? ... : ...
+// CHECK:     T: (Temp Dtor) [B11.2]
 // CHECK:     Preds (2): B10 B11
-// CHECK:     Succs (2): B7 B8
+// CHECK:     Succs (2): B8 B7
 // CHECK:   [B10]
 // CHECK:     1: [B12.2] (ImplicitCastExpr, NoOp, const class A)
 // CHECK:     2: [B10.1]
@@ -1089,6 +1077,7 @@
 // CHECK:     Succs (1): B2
 // CHECK:   [B1]
 // CHECK:     1: int b;
+// CHECK:     Preds (1): B2(Unreachable)
 // CHECK:     Succs (1): B0
 // CHECK:   [B2 (NORETURN)]
 // CHECK:     1: int a;
@@ -1105,6 +1094,7 @@
 // CHECK:     Succs (1): B2
 // CHECK:   [B1]
 // CHECK:     1: int b;
+// CHECK:     Preds (1): B2(Unreachable)
 // CHECK:     Succs (1): B0
 // CHECK:   [B2 (NORETURN)]
 // CHECK:     1: int a;
@@ -1117,7 +1107,6 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (2): B1 B2
-// CHECK:  int testConsistencyNestedSimple(bool value)
 // CHECK:   [B9 (ENTRY)]
 // CHECK:     Succs (1): B8
 // CHECK:   [B1]
@@ -1132,7 +1121,7 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B3]
 // CHECK:     T: if [B5.1]
-// CHECK:     Preds (1): B5
+// CHECK:     Preds (2): B4(Unreachable) B5
 // CHECK:     Succs (2): B2 B1
 // CHECK:   [B4 (NORETURN)]
 // CHECK:     1: ~NoReturn() (Temporary object destructor)
@@ -1140,9 +1129,9 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B5]
 // CHECK:     1: [B7.3] || [B6.7]
-// CHECK:     T: (Temp Dtor) [B7.3] || ...
+// CHECK:     T: (Temp Dtor) [B6.4]
 // CHECK:     Preds (2): B6 B7
-// CHECK:     Succs (2): B3 B4
+// CHECK:     Succs (2): B4 B3
 // CHECK:   [B6]
 // CHECK:     1: check
 // CHECK:     2: [B6.1] (ImplicitCastExpr, FunctionToPointerDecay, _Bool (*)(const class NoReturn &))
@@ -1168,7 +1157,6 @@
 // CHECK:     Succs (2): B7 B1
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (3): B1 B2 B4
-// CHECK:  int testConsistencyNestedComplex(bool value)
 // CHECK:   [B10 (ENTRY)]
 // CHECK:     Succs (1): B9
 // CHECK:   [B1]
@@ -1183,7 +1171,7 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B3]
 // CHECK:     T: if [B5.1]
-// CHECK:     Preds (1): B5
+// CHECK:     Preds (2): B4(Unreachable) B5
 // CHECK:     Succs (2): B2 B1
 // CHECK:   [B4 (NORETURN)]
 // CHECK:     1: ~NoReturn() (Temporary object destructor)
@@ -1191,9 +1179,9 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B5]
 // CHECK:     1: [B8.3] || [B7.3] || [B6.7]
-// CHECK:     T: (Temp Dtor) [B8.3] || [B7.3] || ...
+// CHECK:     T: (Temp Dtor) [B6.4]
 // CHECK:     Preds (3): B6 B7 B8
-// CHECK:     Succs (2): B3 B4
+// CHECK:     Succs (2): B4 B3
 // CHECK:   [B6]
 // CHECK:     1: check
 // CHECK:     2: [B6.1] (ImplicitCastExpr, FunctionToPointerDecay, _Bool (*)(const class NoReturn &))
@@ -1226,7 +1214,6 @@
 // CHECK:     Succs (2): B8 B1
 // CHECK:   [B0 (EXIT)]
 // CHECK:     Preds (3): B1 B2 B4
-// CHECK:  int testConsistencyNestedNormalReturn(bool value)
 // CHECK:   [B10 (ENTRY)]
 // CHECK:     Succs (1): B9
 // CHECK:   [B1]
@@ -1241,7 +1228,7 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B3]
 // CHECK:     T: if [B5.1]
-// CHECK:     Preds (1): B5
+// CHECK:     Preds (2): B4(Unreachable) B5
 // CHECK:     Succs (2): B2 B1
 // CHECK:   [B4 (NORETURN)]
 // CHECK:     1: ~NoReturn() (Temporary object destructor)
@@ -1249,9 +1236,9 @@
 // CHECK:     Succs (1): B0
 // CHECK:   [B5]
 // CHECK:     1: [B8.3] || [B7.2] || [B6.7]
-// CHECK:     T: (Temp Dtor) [B8.3] || [B7.2] || ...
+// CHECK:     T: (Temp Dtor) [B6.4]
 // CHECK:     Preds (3): B6 B7 B8
-// CHECK:     Succs (2): B3 B4
+// CHECK:     Succs (2): B4 B3
 // CHECK:   [B6]
 // CHECK:     1: check
 // CHECK:     2: [B6.1] (ImplicitCastExpr, FunctionToPointerDecay, _Bool (*)(const class NoReturn &))
diff --git a/test/Analysis/temporaries.cpp b/test/Analysis/temporaries.cpp
index c57d984..6e47633 100644
--- a/test/Analysis/temporaries.cpp
+++ b/test/Analysis/temporaries.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++03 %s
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++11 %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true %s 
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true %s -std=c++11
 
 extern bool clang_analyzer_eval(bool);
+extern bool clang_analyzer_warnIfReached();
 
 struct Trivial {
   Trivial(int x) : value(x) {}
@@ -111,13 +112,13 @@
 }
 
 namespace destructors {
-  void testPR16664andPR18159Crash() {
-    struct Dtor {
-      ~Dtor();
-    };
-    extern bool coin();
-    extern bool check(const Dtor &);
+  struct Dtor {
+    ~Dtor();
+  };
+  extern bool coin();
+  extern bool check(const Dtor &);
 
+  void testPR16664andPR18159Crash() {
     // Regression test: we used to assert here when tmp dtors are enabled.
     // PR16664 and PR18159
     if (coin() && (coin() || coin() || check(Dtor()))) {
@@ -193,8 +194,7 @@
                 (i == 4 || i == 4 ||
                  compute(i == 5 && (i == 4 || check(NoReturnDtor()))))) ||
         i != 4) {
-      // FIXME: This shouldn't cause a warning.
-      clang_analyzer_eval(true);  // expected-warning{{TRUE}}
+      clang_analyzer_eval(true);  // no warning, unreachable code
     }
   }
 
@@ -211,8 +211,7 @@
   void testConsistencyNestedComplex(bool value) {
     if (value) {
       if (!value || !value || check(NoReturnDtor())) {
-        // FIXME: This shouldn't cause a warning.
-        clang_analyzer_eval(true); // expected-warning{{TRUE}}
+        clang_analyzer_eval(true);  // no warning, unreachable code
       }
     }
   }
@@ -225,6 +224,120 @@
       }
     }
   }
+  // PR16664 and PR18159
+  void testConsistencyNestedComplexMidBranch(bool value) {
+    if (value) {
+      if (!value || !value || check(NoReturnDtor()) || value) {
+        clang_analyzer_eval(true);  // no warning, unreachable code
+      }
+    }
+  }
+
+  // PR16664 and PR18159
+  void testConsistencyNestedComplexNestedBranch(bool value) {
+    if (value) {
+      if (!value || (!value || check(NoReturnDtor()) || value)) {
+        clang_analyzer_eval(true);  // no warning, unreachable code
+      }
+    }
+  }
+
+  // PR16664 and PR18159
+  void testConsistencyNestedVariableModification(bool value) {
+    bool other = true;
+    if (value) {
+      if (!other || !value || (other = false) || check(NoReturnDtor()) ||
+          !other) {
+        clang_analyzer_eval(true);  // no warning, unreachable code
+      }
+    }
+  }
+
+  void testTernaryNoReturnTrueBranch(bool value) {
+    if (value) {
+      bool b = value && (value ? check(NoReturnDtor()) : true);
+      clang_analyzer_eval(true);  // no warning, unreachable code
+    }
+  }
+  void testTernaryNoReturnFalseBranch(bool value) {
+    if (value) {
+      bool b = !value && !value ? true : check(NoReturnDtor());
+      clang_analyzer_eval(true);  // no warning, unreachable code
+    }
+  }
+  void testTernaryIgnoreNoreturnBranch(bool value) {
+    if (value) {
+      bool b = !value && !value ? check(NoReturnDtor()) : true;
+      clang_analyzer_eval(true);  // expected-warning{{TRUE}}
+    }
+  }
+  void testTernaryTrueBranchReached(bool value) {
+    value ? clang_analyzer_warnIfReached() : // expected-warning{{REACHABLE}}
+            check(NoReturnDtor());
+  }
+  void testTernaryFalseBranchReached(bool value) {
+    value ? check(NoReturnDtor()) :
+            clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  }
+
+  void testLoop() {
+    for (int i = 0; i < 10; ++i) {
+      if (i < 3 && (i >= 2 || check(NoReturnDtor()))) {
+        clang_analyzer_eval(true);  // no warning, unreachable code
+      }
+    }
+  }
+
+  bool testRecursiveFrames(bool isInner) {
+    if (isInner ||
+        (clang_analyzer_warnIfReached(), false) || // expected-warning{{REACHABLE}}
+        check(NoReturnDtor()) ||
+        testRecursiveFrames(true)) {
+      clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+    }
+  }
+  void testRecursiveFramesStart() { testRecursiveFrames(false); }
+
+  void testLambdas() {
+    // This is the test we would like to write:
+    // []() { check(NoReturnDtor()); } != nullptr || check(Dtor());
+    // But currently the analyzer stops when it encounters a lambda:
+    [] {};
+    // The CFG for this now looks correct, but we still do not reach the line
+    // below.
+    clang_analyzer_warnIfReached(); // FIXME: Should warn.
+  }
+
+  void testGnuExpressionStatements(int v) {
+    ({ ++v; v == 10 || check(NoReturnDtor()); v == 42; }) || v == 23;
+    clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+
+    ({ ++v; check(NoReturnDtor()); v == 42; }) || v == 23;
+    clang_analyzer_warnIfReached();  // no warning, unreachable code
+  }
+
+  void testGnuExpressionStatementsDestructionPoint(int v) {
+    // In normal context, the temporary destructor runs at the end of the full
+    // statement, thus the last statement is reached.
+    (++v, check(NoReturnDtor()), v == 42),
+        clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+
+    // GNU expression statements execute temporary destructors within the
+    // blocks, thus the last statement is not reached.
+    ({ ++v; check(NoReturnDtor()); v == 42; }),
+        clang_analyzer_warnIfReached();  // no warning, unreachable code
+  }
+
+  void testMultipleTemporaries(bool value) {
+    if (value) {
+      // FIXME: Find a way to verify construction order.
+      // ~Dtor should run before ~NoReturnDtor() because construction order is
+      // guaranteed by comma operator.
+      if (!value || check((NoReturnDtor(), Dtor())) || value) {
+        clang_analyzer_eval(true);  // no warning, unreachable code
+      }
+    }
+  }
 
   void testBinaryOperatorShortcut(bool value) {
     if (value) {
@@ -234,6 +347,78 @@
     }
   }
 
+  void testIfAtEndOfLoop() {
+    int y = 0;
+    while (true) {
+      if (y > 0) {
+        clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+      }
+      ++y;
+      // Test that the CFG gets hooked up correctly when temporary destructors
+      // are handled after a statically known branch condition.
+      if (true) (void)0; else (void)check(NoReturnDtor());
+    }
+  }
+
+  void testTernaryAtEndOfLoop() {
+    int y = 0;
+    while (true) {
+      if (y > 0) {
+        clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+      }
+      ++y;
+      // Test that the CFG gets hooked up correctly when temporary destructors
+      // are handled after a statically known branch condition.
+      true ? (void)0 : (void)check(NoReturnDtor());
+    }
+  }
+
+  void testNoReturnInComplexCondition() {
+    check(Dtor()) &&
+        (check(NoReturnDtor()) || check(NoReturnDtor())) && check(Dtor());
+    clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  }
+
+  void testSequencingOfConditionalTempDtors(bool b) {
+    b || (check(Dtor()), check(NoReturnDtor()));
+    clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  }
+
+  void testSequencingOfConditionalTempDtors2(bool b) {
+    (b || check(Dtor())), check(NoReturnDtor());
+    clang_analyzer_warnIfReached();  // no warning, unreachable code
+  }
+
+  void testSequencingOfConditionalTempDtorsWithinBinaryOperators(bool b) {
+    b || (check(Dtor()) + check(NoReturnDtor()));
+    clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  }
+
+  void f(Dtor d = Dtor());
+  void testDefaultParameters() {
+    f();
+  }
+
+  struct DefaultParam {
+    DefaultParam(int, const Dtor& d = Dtor());
+    ~DefaultParam();
+  };
+  void testDefaultParamConstructorsInLoops() {
+    while (true) {
+      // FIXME: This exact pattern triggers the temporary cleanup logic
+      // to fail when adding a 'clean' state.
+      DefaultParam(42);
+      DefaultParam(42);
+    }
+  }
+  void testDefaultParamConstructorsInTernariesInLoops(bool value) {
+    while (true) {
+      // FIXME: This exact pattern triggers the temporary cleanup logic
+      // to visit the bind-temporary logic with a state that already has that
+      // temporary marked as executed.
+      value ? DefaultParam(42) : DefaultParam(42);
+    }
+  }
 #endif // TEMPORARY_DTORS
 }
 
diff --git a/test/Analysis/unix-api.c b/test/Analysis/unix-api.c
new file mode 100644
index 0000000..86c702d
--- /dev/null
+++ b/test/Analysis/unix-api.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -verify %s
+
+#ifndef O_RDONLY
+#define O_RDONLY 0
+#endif
+
+#ifndef NULL
+#define NULL ((void*) 0)
+#endif
+
+int open(const char *, int, ...);
+int close(int fildes);
+
+void open_1(const char *path) {
+  int fd;
+  fd = open(path, O_RDONLY); // no-warning
+  if (fd > -1)
+    close(fd);
+}
+
+void open_2(const char *path) {
+  int fd;
+  int mode = 0x0;
+  fd = open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' with more than three arguments}}
+  if (fd > -1)
+    close(fd);
+}
+
+void open_3(const char *path) {
+  int fd;
+  fd = open(path, O_RDONLY, NULL); // expected-warning{{Third argument to 'open' is not an integer}}
+  if (fd > -1)
+    close(fd);
+}
+
+void open_4(const char *path) {
+  int fd;
+  fd = open(path, O_RDONLY, ""); // expected-warning{{Third argument to 'open' is not an integer}}
+  if (fd > -1)
+    close(fd);
+}
+
+void open_5(const char *path) {
+  int fd;
+  struct {
+    int val;
+  } st = {0};
+  fd = open(path, O_RDONLY, st); // expected-warning{{Third argument to 'open' is not an integer}}
+  if (fd > -1)
+    close(fd);
+}
+
+void open_6(const char *path) {
+  int fd;
+  struct {
+    int val;
+  } st = {0};
+  fd = open(path, O_RDONLY, st.val); // no-warning
+  if (fd > -1)
+    close(fd);
+}
+
+void open_7(const char *path) {
+  int fd;
+  fd = open(path, O_RDONLY, &open); // expected-warning{{Third argument to 'open' is not an integer}}
+  if (fd > -1)
+    close(fd);
+}
+
+void open_8(const char *path) {
+  int fd;
+  fd = open(path, O_RDONLY, 0.0f); // expected-warning{{Third argument to 'open' is not an integer}}
+  if (fd > -1)
+    close(fd);
+}
diff --git a/test/Analysis/virtualcall.cpp b/test/Analysis/virtualcall.cpp
index c3319b0..8ce1d41 100644
--- a/test/Analysis/virtualcall.cpp
+++ b/test/Analysis/virtualcall.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
 
 class A {
 public:
@@ -46,10 +46,31 @@
   f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
 }
 
+class D : public B {
+public:
+  D() {
+    foo(); // no-warning
+  }
+  ~D() { bar(); }
+  int foo() final;
+  void bar() final { foo(); } // no-warning
+};
+
+class E final : public B {
+public:
+  E() {
+    foo(); // no-warning
+  }
+  ~E() { bar(); }
+  int foo() override;
+};
+
 int main() {
   A *a;
   B *b;
   C *c;
+  D *d;
+  E *e;
 }
 
 #include "virtualcall.h"
diff --git a/test/Analysis/vla.c b/test/Analysis/vla.c
new file mode 100644
index 0000000..f94bea9
--- /dev/null
+++ b/test/Analysis/vla.c
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+
+// Zero-sized VLAs.
+void check_zero_sized_VLA(int x) {
+  if (x)
+    return;
+
+  int vla[x]; // expected-warning{{Declared variable-length array (VLA) has zero size}}
+}
+
+void check_uninit_sized_VLA() {
+  int x;
+  int vla[x]; // expected-warning{{Declared variable-length array (VLA) uses a garbage value as its size}}
+}
+
+// Negative VLAs.
+static void vla_allocate_signed(int x) {
+  int vla[x]; // expected-warning{{Declared variable-length array (VLA) has negative size}}
+}
+
+static void vla_allocate_unsigned(unsigned int x) {
+  int vla[x]; // no-warning
+}
+
+void check_negative_sized_VLA_1() {
+  vla_allocate_signed(-1);
+}
+
+void check_negative_sized_VLA_2() {
+  vla_allocate_unsigned(-1);
+}
+
+void check_negative_sized_VLA_3() {
+  int x = -1;
+  int vla[x]; // expected-warning{{Declared variable-length array (VLA) has negative size}}
+}
+
+void check_negative_sized_VLA_4() {
+  unsigned int x = -1;
+  int vla[x]; // no-warning
+}
+
+void check_negative_sized_VLA_5() {
+  signed char x = -1;
+  int vla[x]; // expected-warning{{Declared variable-length array (VLA) has negative size}}
+}
+
+void check_negative_sized_VLA_6() {
+  unsigned char x = -1;
+  int vla[x]; // no-warning
+}
+
+void check_negative_sized_VLA_7() {
+  signed char x = -1;
+  int vla[x + 2]; // no-warning
+}
+
+void check_negative_sized_VLA_8() {
+  signed char x = 1;
+  int vla[x - 2]; // expected-warning{{Declared variable-length array (VLA) has negative size}}
+}
+
+void check_negative_sized_VLA_9() {
+  int x = 1;
+  int vla[x]; // no-warning
+}
+
+static void check_negative_sized_VLA_10_sub(int x)
+{
+  int vla[x]; // expected-warning{{Declared variable-length array (VLA) has negative size}}
+}
+
+void check_negative_sized_VLA_10(int x) {
+  if (x < 0)
+    check_negative_sized_VLA_10_sub(x);
+}
+
+static void check_negative_sized_VLA_11_sub(int x)
+{
+  int vla[x]; // no-warning
+}
+
+void check_negative_sized_VLA_11(int x) {
+  if (x > 0)
+    check_negative_sized_VLA_11_sub(x);
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index fe80df4..591a927 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -26,15 +26,27 @@
 
 list(APPEND CLANG_TEST_DEPS
   clang clang-headers
-  c-index-test diagtool arcmt-test c-arcmt-test
   clang-check clang-format
+  c-index-test diagtool
   clang-tblgen
   )
 
+if (CLANG_ENABLE_ARCMT)
+  list(APPEND CLANG_TEST_DEPS
+    arcmt-test
+    c-arcmt-test
+  )
+endif ()
+
 if (ENABLE_CLANG_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
     clang-interpreter
     PrintFunctionNames
+    )
+endif ()
+
+if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES)
+  list(APPEND CLANG_TEST_DEPS
     SampleAnalyzerPlugin
     )
 endif ()
diff --git a/test/CXX/class/class.mem/p2.cpp b/test/CXX/class/class.mem/p2.cpp
index 4aa4a5c..d45c038 100644
--- a/test/CXX/class/class.mem/p2.cpp
+++ b/test/CXX/class/class.mem/p2.cpp
@@ -56,3 +56,33 @@
 
   template struct A2<int>;
 }
+
+namespace PR12629 {
+  struct S {
+    static int (f)() throw();
+    static int ((((((g))))() throw(U)));
+    int (*h)() noexcept(false);
+    static int (&i)() noexcept(true);
+    static int (*j)() throw(U); // expected-error {{unknown type name 'U'}}
+    static int (k)() throw(U);
+
+    struct U {};
+  };
+  static_assert(noexcept(S::f()), "");
+  static_assert(!noexcept(S::g()), "");
+  static_assert(!noexcept(S().h()), "");
+  static_assert(noexcept(S::i()), "");
+}
+
+namespace PR12688 {
+  struct S {
+    // FIXME: Producing one error saying this can't have the same name
+    //        as the class because it's not a constructor, then producing
+    //        another error saying this can't have a return type because
+    //        it is a constructor, is redundant and inconsistent.
+    nonsense S() throw (more_nonsense); // \
+    // expected-error {{'nonsense'}} \
+    // expected-error {{has the same name as its class}} \
+    // expected-error {{constructor cannot have a return type}}
+  };
+}
diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
index 3bbbf9e..a27cea8 100644
--- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
+++ b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
@@ -21,8 +21,7 @@
 template <typename T> class X {};
 template <> class [[deprecated]] X<int> {}; // expected-note {{'X<int>' has been explicitly marked deprecated here}}
 X<char> x1;
-// FIXME: The diagnostic here could be much better by mentioning X<int>.
-X<int> x2; // expected-warning {{'X' is deprecated}}
+X<int> x2; // expected-warning {{'X<int>' is deprecated}}
 
 template <typename T> class [[deprecated]] X2 {};
 template <> class X2<int> {};
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index 08fefdc..35dbec9 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -71,7 +71,7 @@
 template <typename T> constexpr T ft(T t) { return t; }
 template <typename T> T gt(T t) { return t; }
 struct S {
-  template<typename T> constexpr T f(); // expected-warning {{C++1y}}
+  template<typename T> constexpr T f(); // expected-warning {{C++14}}
   template <typename T>
   T g() const; // expected-note-re {{candidate template ignored: could not match 'T (){{( __attribute__\(\(thiscall\)\))?}} const' against 'char (){{( __attribute__\(\(thiscall\)\))?}}'}}
 };
@@ -82,7 +82,7 @@
 template <> constexpr char ft(char nl); // expected-error {{constexpr declaration of 'ft<char>' follows non-constexpr declaration}}
 template <> constexpr int gt(int nl) { return nl; }
 template <> notlit S::f() const { return notlit(); }
-template <> constexpr int S::g() { return 0; } // expected-note {{previous}} expected-warning {{C++1y}}
+template <> constexpr int S::g() { return 0; } // expected-note {{previous}} expected-warning {{C++14}}
 template <> int S::g() const; // expected-error {{non-constexpr declaration of 'g<int>' follows constexpr declaration}}
 // specializations can drop the 'constexpr' but not the implied 'const'.
 template <> char S::g() { return 0; } // expected-error {{no function template matches}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index 780a420..448351b 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -21,7 +21,7 @@
 struct S {
   virtual int ImplicitlyVirtual() const = 0; // expected-note {{overridden virtual function}}
 };
-struct SS : S { 
+struct SS : S {
   int ImplicitlyVirtual() const;
 };
 
@@ -62,7 +62,7 @@
   constexpr T &operator=(const T&) = default;
 #ifndef CXX1Y
   // expected-error@-2 {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
-  // expected-warning@-3 {{C++1y}}
+  // expected-warning@-3 {{C++14}}
 #else
   // expected-error@-5 {{defaulted definition of copy assignment operator is not constexpr}}
 #endif
@@ -161,21 +161,21 @@
 constexpr int VarDecl() {
   int a = 0;
 #ifndef CXX1Y
-  // expected-error@-2 {{variable declaration in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
 #endif
   return 0;
 }
 constexpr int ConstexprVarDecl() {
   constexpr int a = 0;
 #ifndef CXX1Y
-  // expected-error@-2 {{variable declaration in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
 #endif
   return 0;
 }
 constexpr int VarWithCtorDecl() {
   Literal a;
 #ifndef CXX1Y
-  // expected-error@-2 {{variable declaration in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
 #endif
   return 0;
 }
@@ -183,7 +183,7 @@
 constexpr NonLiteral &ExternNonLiteralVarDecl() {
   extern NonLiteral nl;
 #ifndef CXX1Y
-  // expected-error@-2 {{variable declaration in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}}
 #endif
   return nl;
 }
@@ -191,28 +191,28 @@
 constexpr int FuncDecl() {
   constexpr int ForwardDecl(int);
 #ifndef CXX1Y
-  // expected-error@-2 {{use of this statement in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{use of this statement in a constexpr function is a C++14 extension}}
 #endif
   return ForwardDecl(42);
 }
 constexpr int ClassDecl1() {
   typedef struct { } S1;
 #ifndef CXX1Y
-  // expected-error@-2 {{type definition in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}}
 #endif
   return 0;
 }
 constexpr int ClassDecl2() {
   using S2 = struct { };
 #ifndef CXX1Y
-  // expected-error@-2 {{type definition in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}}
 #endif
   return 0;
 }
 constexpr int ClassDecl3() {
   struct S3 { };
 #ifndef CXX1Y
-  // expected-error@-2 {{type definition in a constexpr function is a C++1y extension}}
+  // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}}
 #endif
   return 0;
 }
@@ -245,11 +245,11 @@
 
 namespace rdar13584715 {
   typedef __PTRDIFF_TYPE__ ptrdiff_t;
-  
+
   template<typename T> struct X {
     static T value() {};
   };
-  
+
   void foo(ptrdiff_t id) {
     switch (id) {
     case reinterpret_cast<ptrdiff_t>(&X<long>::value):  // expected-error{{case value is not a constant expression}} \
@@ -269,7 +269,7 @@
   constexpr int abs(int x) {
     if (x < 0)
 #ifndef CXX1Y
-      // expected-error@-2 {{C++1y}}
+      // expected-error@-2 {{C++14}}
 #endif
       x = -x;
     return x;
@@ -295,7 +295,7 @@
     return r;
   }
 #ifndef CXX1Y
-    // expected-error@-5 {{C++1y}}
+    // expected-error@-5 {{C++14}}
     // expected-error@-5 {{statement not allowed}}
 #endif
 }
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
index 708c259..9c1cab5 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
@@ -92,37 +92,37 @@
   constexpr V(int(&)[2]) {
     constexpr int a = 0;
 #ifndef CXX1Y
-    // expected-error@-2 {{variable declaration in a constexpr constructor is a C++1y extension}}
+    // expected-error@-2 {{variable declaration in a constexpr constructor is a C++14 extension}}
 #endif
   }
   constexpr V(int(&)[3]) {
     constexpr int ForwardDecl(int);
 #ifndef CXX1Y
-    // expected-error@-2 {{use of this statement in a constexpr constructor is a C++1y extension}}
+    // expected-error@-2 {{use of this statement in a constexpr constructor is a C++14 extension}}
 #endif
   }
   constexpr V(int(&)[4]) {
     typedef struct { } S1;
 #ifndef CXX1Y
-    // expected-error@-2 {{type definition in a constexpr constructor is a C++1y extension}}
+    // expected-error@-2 {{type definition in a constexpr constructor is a C++14 extension}}
 #endif
   }
   constexpr V(int(&)[5]) {
     using S2 = struct { };
 #ifndef CXX1Y
-    // expected-error@-2 {{type definition in a constexpr constructor is a C++1y extension}}
+    // expected-error@-2 {{type definition in a constexpr constructor is a C++14 extension}}
 #endif
   }
   constexpr V(int(&)[6]) {
     struct S3 { };
 #ifndef CXX1Y
-    // expected-error@-2 {{type definition in a constexpr constructor is a C++1y extension}}
+    // expected-error@-2 {{type definition in a constexpr constructor is a C++14 extension}}
 #endif
   }
   constexpr V(int(&)[7]) {
     return;
 #ifndef CXX1Y
-    // expected-error@-2 {{use of this statement in a constexpr constructor is a C++1y extension}}
+    // expected-error@-2 {{use of this statement in a constexpr constructor is a C++14 extension}}
 #endif
   }
 };
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
index 5e40f69..4897323 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
@@ -102,7 +102,7 @@
 template<typename T>
 struct Y {
   constexpr Y() {}
-  constexpr int get() { return T(); } // expected-warning {{C++1y}}
+  constexpr int get() { return T(); } // expected-warning {{C++14}}
 };
 struct Z { operator int(); };
 
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
index 40aa600..21e4a23 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
@@ -3,13 +3,13 @@
 using size_t = decltype(sizeof(int));
 
 struct S {
-  constexpr int f(); // expected-warning {{C++1y}}
+  constexpr int f(); // expected-warning {{C++14}}
   constexpr int g() const;
-  constexpr int h(); // expected-warning {{C++1y}}
+  constexpr int h(); // expected-warning {{C++14}}
   int h();
   static constexpr int Sf();
   /*static*/ constexpr void *operator new(size_t) noexcept;
-  template<typename T> constexpr T tm(); // expected-warning {{C++1y}}
+  template<typename T> constexpr T tm(); // expected-warning {{C++14}}
   template<typename T> static constexpr T ts();
 };
 
@@ -26,12 +26,12 @@
 }
 
 constexpr int S::f() const { return 0; }
-constexpr int S::g() { return 1; } // expected-warning {{C++1y}}
-constexpr int S::h() { return 0; } // expected-warning {{C++1y}}
+constexpr int S::g() { return 1; } // expected-warning {{C++14}}
+constexpr int S::h() { return 0; } // expected-warning {{C++14}}
 int S::h() { return 0; }
 constexpr int S::Sf() { return 2; }
 constexpr void *S::operator new(size_t) noexcept { return 0; }
-template<typename T> constexpr T S::tm() { return T(); } // expected-warning {{C++1y}}
+template<typename T> constexpr T S::tm() { return T(); } // expected-warning {{C++14}}
 template<typename T> constexpr T S::ts() { return T(); }
 
 namespace std_example {
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
index 2412a14..5f102e7 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
@@ -17,7 +17,7 @@
 
 // A variable declaration which uses the constexpr specifier shall have an
 // initializer and shall be initialized by a constant expression.
-constexpr int ni1; // expected-error {{default initialization of an object of const type 'const int'}}
+constexpr int ni1; // expected-error {{default initialization of an object of const type 'const int'}} expected-note {{add an explicit initializer to initialize 'ni1'}}
 constexpr struct C { C(); } ni2; // expected-error {{cannot have non-literal type 'const struct C'}} expected-note 3{{has no constexpr constructors}}
 constexpr double &ni3; // expected-error {{declaration of reference variable 'ni3' requires an initializer}}
 
@@ -34,4 +34,4 @@
   int x, y;
 };
 constexpr pixel ur = { 1294, 1024 }; // ok
-constexpr pixel origin;              // expected-error {{default initialization of an object of const type 'const pixel' requires a user-provided default constructor}}
+constexpr pixel origin;              // expected-error {{default initialization of an object of const type 'const pixel' without a user-provided default constructor}} expected-note {{add an explicit initializer to initialize 'origin'}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
index cc44f74..865abb0 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
@@ -44,7 +44,7 @@
 
   void f() {
     int n = 42;
-    goto foo; // expected-error {{goto into protected scope}}
+    goto foo; // expected-error {{cannot jump}}
     using T = int[n]; // expected-note {{bypasses initialization of VLA type alias}}
   foo: ;
   }
diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
index b9a1bc5..8187619 100644
--- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
+++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
@@ -36,7 +36,7 @@
 constexpr S3 s3a = S3(0);
 constexpr S3 s3b = s3a;
 constexpr S3 s3c = S3();
-constexpr S3 s3d; // expected-error {{default initialization of an object of const type 'const S3' requires a user-provided default constructor}}
+constexpr S3 s3d; // expected-error {{default initialization of an object of const type 'const S3' without a user-provided default constructor}} expected-note{{add an explicit initializer to initialize 's3d'}}
 
 struct S4 {
   S4() = default;
@@ -119,6 +119,6 @@
   };
 
   void f() {
-    const B b; // expected-error {{default initialization of an object of const type 'const PR13492::B' requires a user-provided default constructor}}
+    const B b; // expected-error {{default initialization of an object of const type 'const PR13492::B' without a user-provided default constructor}} expected-note {{add an explicit initializer to initialize 'b'}}
   }
 }
diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp
new file mode 100644
index 0000000..ff5d3de
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+// expected-no-diagnostics
+
+using size_t = decltype(sizeof(0));
+template<typename T> struct check;
+template<size_t N> struct check<const char[N]> {};
+
+constexpr bool startswith(const char *p, const char *q) {
+  return !*q || (*p == *q && startswith(p + 1, q + 1));
+}
+constexpr bool contains(const char *p, const char *q) {
+  return *p && (startswith(p, q) || contains(p + 1, q));
+}
+
+void foo() {
+  check<decltype(__func__)>();
+  static_assert(contains(__func__, "foo"), "");
+}
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
index 971e0c1..d7ffd07 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp
@@ -4,7 +4,7 @@
   typedef decltype(sizeof(int)) size_t;
 
   template <typename E>
-  struct initializer_list // expected-note 2{{candidate}}
+  struct initializer_list
   {
     const E *p;
     size_t n;
@@ -112,15 +112,16 @@
 }
 
 namespace rdar13395022 {
-  struct MoveOnly {
-    MoveOnly(MoveOnly&&);
+  struct MoveOnly { // expected-note {{candidate}}
+    MoveOnly(MoveOnly&&); // expected-note 2{{copy constructor is implicitly deleted because}} expected-note {{candidate}}
   };
 
   void test(MoveOnly mo) {
-    // FIXME: These diagnostics are poor.
-    auto &&list1 = {mo}; // expected-error{{no viable conversion}}
-    MoveOnly (&&list2)[1] = {mo}; // expected-error{{no viable conversion}}
+    auto &&list1 = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} expected-note {{in initialization of temporary of type 'std::initializer_list}}
+    MoveOnly (&&list2)[1] = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} expected-note {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]'}}
     std::initializer_list<MoveOnly> &&list3 = {};
-    MoveOnly (&&list4)[1] = {}; // expected-error{{uninitialized}}
+    MoveOnly (&&list4)[1] = {}; // expected-error {{no matching constructor}}
+    // expected-note@-1 {{in implicit initialization of array element 0 with omitted initializer}}
+    // expected-note@-2 {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]' created to list-initialize this reference}}
   }
 }
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
index 4ba75ef..f86b24e 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -Wbind-to-temporary-copy -verify %s
 
 // C++03 requires that we check for a copy constructor when binding a
 // reference to a temporary, since we are allowed to make a copy, Even
diff --git a/test/CXX/dcl.decl/dcl.init/p6.cpp b/test/CXX/dcl.decl/dcl.init/p6.cpp
index 514fd0c..76b7e76 100644
--- a/test/CXX/dcl.decl/dcl.init/p6.cpp
+++ b/test/CXX/dcl.decl/dcl.init/p6.cpp
@@ -10,15 +10,15 @@
 struct HasUserDefault { HasUserDefault(); };
 
 void test_const_default_init() {
-  const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' requires a user-provided default constructor}}
+  const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' without a user-provided default constructor}} expected-note {{add an explicit initializer to initialize 'x1'}}
   const HasUserDefault x2;
-  const int x3; // expected-error{{default initialization of an object of const type 'const int'}}
+  const int x3; // expected-error{{default initialization of an object of const type 'const int'}} expected-note{{add an explicit initializer to initialize 'x3'}}
 }
 
 // rdar://8501008
 struct s0 {};
 struct s1 { static const s0 foo; };
-const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' requires a user-provided default constructor}}
+const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' without a user-provided default constructor}} expected-note {{add an explicit initializer to initialize 'foo'}}
 
 template<typename T>
 struct s2 {
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
index 19a5f23..93c246b 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
@@ -46,3 +46,30 @@
 template<typename T>
 void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}
 
+void f4i(int ... x); // expected-error{{type 'int' of function parameter pack does not contain any unexpanded parameter packs}}
+void f4i0(int ...);
+
+namespace array_type {
+template<typename T>
+void a(T[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}
+
+template<typename T>
+void b(T[] ...);
+
+template<typename T>
+void c(T ... []); // expected-error{{type 'T []' of function parameter pack does not contain any unexpanded parameter packs}}
+
+template<typename T>
+void d(T ... x[]); // expected-error{{type 'T []' of function parameter pack does not contain any unexpanded parameter packs}}
+
+void ai(int[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}
+void bi(int[] ...);
+void ci(int ... []); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}}
+void di(int ... x[]); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}}
+}
+
+// FIXME: Expand for function and member pointer types.
+
+
+
+
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
index bc249b5..ac9344d 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template<typename T> struct identity;
 template<typename ...Types> struct tuple;
@@ -22,7 +21,7 @@
 template<typename T, typename ...Types>
 struct X0 {
   typedef identity<T(Types...)> function_pack_1;
-  typedef identity<T(Types......)> variadic_function_pack_1;
+  typedef identity<T(Types......)> variadic_function_pack_1; // expected-warning {{varargs}} expected-note {{pack}} expected-note {{insert ','}}
   typedef identity<T(T...)> variadic_1;
   typedef tuple<T(Types, ...)...> template_arg_expansion_1;
 };
diff --git a/test/CXX/drs/dr0xx.cpp b/test/CXX/drs/dr0xx.cpp
index 29e1720..011b420 100644
--- a/test/CXX/drs/dr0xx.cpp
+++ b/test/CXX/drs/dr0xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr1 { // dr1: no
   namespace X { extern "C" void dr1_f(int a = 1); }
@@ -822,7 +823,7 @@
 namespace dr73 { // dr73: no
   // The resolution to dr73 is unworkable. Consider:
   int a, b;
-  static_assert(&a + 1 != &b, "");
+  static_assert(&a + 1 != &b, ""); // expected-error {{not an integral constant expression}}
 }
 #endif
 
@@ -852,7 +853,7 @@
 namespace dr78 { // dr78: sup ????
   // Under DR78, this is valid, because 'k' has static storage duration, so is
   // zero-initialized.
-  const int k; // expected-error {{default initialization of an object of const}}
+  const int k; // expected-error {{default initialization of an object of const}} expected-note{{add an explicit initializer to initialize 'k'}}
 }
 
 // dr79: na
@@ -1051,18 +1052,18 @@
   void test(int n) {
     switch (n) {
       try { // expected-note 2{{bypasses}}
-        case 0: // expected-error {{protected}}
+        case 0: // expected-error {{cannot jump}}
         x:
           throw n;
       } catch (...) { // expected-note 2{{bypasses}}
-        case 1: // expected-error {{protected}}
+        case 1: // expected-error {{cannot jump}}
         y:
           throw n;
       }
       case 2:
-        goto x; // expected-error {{protected}}
+        goto x; // expected-error {{cannot jump}}
       case 3:
-        goto y; // expected-error {{protected}}
+        goto y; // expected-error {{cannot jump}}
     }
   }
 }
diff --git a/test/CXX/drs/dr10xx.cpp b/test/CXX/drs/dr10xx.cpp
index 64c71b2..733621d 100644
--- a/test/CXX/drs/dr10xx.cpp
+++ b/test/CXX/drs/dr10xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // expected-no-diagnostics
 
diff --git a/test/CXX/drs/dr13xx.cpp b/test/CXX/drs/dr13xx.cpp
index 5827291..29b39cb 100644
--- a/test/CXX/drs/dr13xx.cpp
+++ b/test/CXX/drs/dr13xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr1346 { // dr1346: 3.5
   auto a(1); // expected-error 0-1{{extension}}
diff --git a/test/CXX/drs/dr14xx.cpp b/test/CXX/drs/dr14xx.cpp
index 8de1b8d..e931924 100644
--- a/test/CXX/drs/dr14xx.cpp
+++ b/test/CXX/drs/dr14xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-no-diagnostics
diff --git a/test/CXX/drs/dr15xx.cpp b/test/CXX/drs/dr15xx.cpp
index 66618c1..a9df026 100644
--- a/test/CXX/drs/dr15xx.cpp
+++ b/test/CXX/drs/dr15xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // expected-no-diagnostics
 
diff --git a/test/CXX/drs/dr1xx.cpp b/test/CXX/drs/dr1xx.cpp
index 6aff43c..89d0d84 100644
--- a/test/CXX/drs/dr1xx.cpp
+++ b/test/CXX/drs/dr1xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr100 { // dr100: yes
   template<const char *> struct A {}; // expected-note {{declared here}}
diff --git a/test/CXX/drs/dr2xx.cpp b/test/CXX/drs/dr2xx.cpp
index bb9af9f..e4e7554 100644
--- a/test/CXX/drs/dr2xx.cpp
+++ b/test/CXX/drs/dr2xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -195,8 +196,8 @@
 // dr220: na
 
 namespace dr221 { // dr221: yes
-  struct A {
-    A &operator=(int&);
+  struct A { // expected-note 2-4{{candidate}}
+    A &operator=(int&); // expected-note 2{{candidate}}
     A &operator+=(int&);
     static A &operator=(A&, double&); // expected-error {{cannot be a static member}}
     static A &operator+=(A&, double&); // expected-error {{cannot be a static member}}
@@ -209,9 +210,9 @@
   void test(A a, int n, char c, float f) {
     a = n;
     a += n;
-    a = c;
+    a = c; // expected-error {{no viable}}
     a += c;
-    a = f;
+    a = f; // expected-error {{no viable}}
     a += f;
   }
 }
@@ -466,7 +467,7 @@
   A a2 = b; // expected-error {{ambiguous}}
 }
 
-namespace dr244 { // dr244: 3.5
+namespace dr244 { // dr244: partial
   struct B {}; struct D : B {}; // expected-note {{here}}
 
   D D_object;
@@ -484,6 +485,28 @@
     B_ptr->dr244::~B(); // expected-error {{refers to a member in namespace}}
     B_ptr->dr244::~B_alias(); // expected-error {{refers to a member in namespace}}
   }
+
+  namespace N {
+    template<typename T> struct E {};
+    typedef E<int> F;
+  }
+  void g(N::F f) {
+    typedef N::F G;
+    f.~G();
+    f.G::~E();
+    f.G::~F(); // expected-error {{expected the class name after '~' to name a destructor}}
+    f.G::~G();
+    // This is technically ill-formed; E is looked up in 'N::' and names the
+    // class template, not the injected-class-name of the class. But that's
+    // probably a bug in the standard.
+    f.N::F::~E();
+    // This is valid; we look up the second F in the same scope in which we
+    // found the first one, that is, 'N::'.
+    f.N::F::~F(); // FIXME: expected-error {{expected the class name after '~' to name a destructor}}
+    // This is technically ill-formed; G is looked up in 'N::' and is not found;
+    // as above, this is probably a bug in the standard.
+    f.N::F::~G();
+  }
 }
 
 namespace dr245 { // dr245: yes
@@ -499,7 +522,7 @@
       throw 0;
 X: ;
     } catch (int) {
-      goto X; // expected-error {{protected scope}}
+      goto X; // expected-error {{cannot jump}}
     }
   };
 }
diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp
index 53fc20e..59deaca 100644
--- a/test/CXX/drs/dr3xx.cpp
+++ b/test/CXX/drs/dr3xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr300 { // dr300: yes
   template<typename R, typename A> void f(R (&)(A)) {}
@@ -181,9 +182,15 @@
 
 namespace dr311 { // dr311: yes
   namespace X { namespace Y {} }
-  namespace X::Y {} // expected-error {{must define each namespace separately}}
+  namespace X::Y {}
+#if __cplusplus <= 201402L
+  // expected-error@-2 {{define each namespace separately}}
+#endif
   namespace X {
-    namespace X::Y {} // expected-error {{must define each namespace separately}}
+    namespace X::Y {}
+#if __cplusplus <= 201402L
+  // expected-error@-2 {{define each namespace separately}}
+#endif
   }
   // FIXME: The diagnostics here are not very good.
   namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}}
@@ -322,6 +329,7 @@
   int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}}
   int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}}
   int *h = &(void(), s.n); // expected-error {{address of bit-field}}
+  int *i = &++s.n; // expected-error {{address of bit-field}}
 }
 
 namespace dr326 { // dr326: yes
@@ -365,7 +373,7 @@
   } const a, b(a); // expected-error {{no matching constructor}}
 }
 
-namespace dr332 { // dr332: dup 557
+namespace dr332 { // dr332: dup 577
   void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}}
   void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}}
   void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}}
diff --git a/test/CXX/drs/dr412.cpp b/test/CXX/drs/dr412.cpp
index cb33e20..39cdd61 100644
--- a/test/CXX/drs/dr412.cpp
+++ b/test/CXX/drs/dr412.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)"
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
 
 // dr412: yes
 // lwg404: yes
diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp
index 815dbfc..42c6774 100644
--- a/test/CXX/drs/dr4xx.cpp
+++ b/test/CXX/drs/dr4xx.cpp
@@ -1,6 +1,7 @@
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
 __extension__ typedef __SIZE_TYPE__ size_t;
@@ -501,15 +502,15 @@
   void f(); // expected-error {{redefinition}}
 }
 
-namespace dr437 { // dr437: no
+namespace dr437 { // dr437: sup 1308
   // This is superseded by 1308, which is in turn superseded by 1330,
   // which restores this rule.
-  template<typename U> struct T : U {}; // expected-error {{incomplete}}
-  struct S { // expected-note {{not complete}}
+  template<typename U> struct T : U {};
+  struct S {
     void f() throw(S);
-    void g() throw(T<S>); // expected-note {{in instantiation of}}
-    struct U; // expected-note {{forward}}
-    void h() throw(U); // expected-error {{incomplete}}
+    void g() throw(T<S>);
+    struct U;
+    void h() throw(U);
     struct U {};
   };
 }
@@ -755,7 +756,7 @@
     return k;
   }
   int g() {
-    goto later; // expected-error {{protected scope}}
+    goto later; // expected-error {{cannot jump}}
     int k = stuff(); // expected-note {{bypasses variable initialization}}
   later:
     return k;
@@ -1201,7 +1202,7 @@
     struct S {
       mutable int i;
     };
-    const S cs; // expected-error {{default initialization}}
+    const S cs; // expected-error {{default initialization}} expected-note {{add an explicit initializer}}
     int S::*pm = &S::i;
     cs.*pm = 88;
   }
diff --git a/test/CXX/drs/dr5xx.cpp b/test/CXX/drs/dr5xx.cpp
index 0c0d451..b0254f2 100644
--- a/test/CXX/drs/dr5xx.cpp
+++ b/test/CXX/drs/dr5xx.cpp
@@ -1,6 +1,13 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+// FIXME: This is included to avoid a diagnostic with no source location
+// pointing at the implicit operator new. We can't match such a diagnostic
+// with -verify.
+__extension__ typedef __SIZE_TYPE__ size_t;
+void *operator new(size_t); // expected-warning 0-1{{missing exception spec}} expected-note{{candidate}}
 
 namespace dr500 { // dr500: dup 372
   class D;
@@ -195,6 +202,153 @@
   }
 }
 
+namespace dr526 { // dr526: yes
+  template<int> struct S {};
+  template<int N> void f1(S<N> s);
+  template<int N> void f2(S<(N)> s); // expected-note {{couldn't infer}}
+  template<int N> void f3(S<+N> s); // expected-note {{couldn't infer}}
+  template<int N> void g1(int (&)[N]);
+  template<int N> void g2(int (&)[(N)]); // expected-note {{couldn't infer}}
+  template<int N> void g3(int (&)[+N]); // expected-note {{couldn't infer}}
+
+  void test(int (&a)[3], S<3> s) {
+    f1(s);
+    f2(s); // expected-error {{no matching}}
+    f3(s); // expected-error {{no matching}}
+    g1(a);
+    g2(a); // expected-error {{no matching}}
+    g3(a); // expected-error {{no matching}}
+  }
+
+  template<int N> struct X {
+    typedef int type;
+    X<N>::type v1;
+    X<(N)>::type v2; // expected-error {{missing 'typename'}}
+    X<+N>::type v3; // expected-error {{missing 'typename'}}
+  };
+}
+
+namespace dr527 { // dr527: na
+  // This DR is meaningless. It removes a required diagnostic from the case
+  // where a not-externally-visible object is odr-used but not defined, which
+  // requires a diagnostic for a different reason.
+  extern struct { int x; } a; // FIXME: We should reject this, per dr389.
+  static struct { int x; } b;
+  extern "C" struct { int x; } c;
+  namespace { extern struct { int x; } d; }
+  typedef struct { int x; } *P;
+  struct E { static P e; }; // FIXME: We should reject this, per dr389.
+  namespace { struct F { static P f; }; }
+
+  int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
+}
+
+namespace dr530 { // dr530: yes
+  template<int*> struct S { enum { N = 1 }; };
+  template<void(*)()> struct T { enum { N = 1 }; };
+  int n;
+  void f();
+  int a[S<&n>::N];
+  int b[T<&f>::N];
+}
+
+namespace dr531 { // dr531: partial
+  namespace good {
+    template<typename T> struct A {
+      void f(T) { T::error; }
+      template<typename U> void g(T, U) { T::error; }
+      struct B { typename T::error error; };
+      template<typename U> struct C { typename T::error error; };
+      static T n;
+    };
+    template<typename T> T A<T>::n = T::error;
+
+    template<> void A<int>::f(int) {}
+    template<> template<typename U> void A<int>::g(int, U) {}
+    template<> struct A<int>::B {};
+    template<> template<typename U> struct A<int>::C {};
+    template<> int A<int>::n = 0;
+
+    void use(A<int> a) {
+      a.f(a.n);
+      a.g(0, 0);
+      A<int>::B b;
+      A<int>::C<int> c;
+    }
+
+    template<> struct A<char> {
+      void f(char);
+      template<typename U> void g(char, U);
+      struct B;
+      template<typename U> struct C;
+      static char n;
+    };
+
+    void A<char>::f(char) {}
+    template<typename U> void A<char>::g(char, U) {}
+    struct A<char>::B {};
+    template<typename U> struct A<char>::C {};
+    char A<char>::n = 0;
+  }
+
+  namespace bad {
+    template<typename T> struct A {
+      void f(T) { T::error; }
+      template<typename U> void g(T, U) { T::error; }
+      struct B { typename T::error error; };
+      template<typename U> struct C { typename T::error error; }; // expected-note {{here}}
+      static T n;
+    };
+    template<typename T> T A<T>::n = T::error;
+
+    void A<int>::f(int) {} // expected-error {{requires 'template<>'}}
+    template<typename U> void A<int>::g(int, U) {} // expected-error {{should be empty}}
+    struct A<int>::B {}; // expected-error {{requires 'template<>'}}
+    template<typename U> struct A<int>::C {}; // expected-error {{should be empty}} expected-error {{different kind of symbol}}
+    int A<int>::n = 0; // expected-error {{requires 'template<>'}}
+
+    template<> struct A<char> { // expected-note 2{{here}}
+      void f(char);
+      template<typename U> void g(char, U);
+      struct B; // expected-note {{here}}
+      template<typename U> struct C;
+      static char n;
+    };
+
+    template<> void A<char>::f(char) {} // expected-error {{no function template matches}}
+    // FIXME: This is ill-formed; -pedantic-errors should reject.
+    template<> template<typename U> void A<char>::g(char, U) {} // expected-warning {{extraneous template parameter list}}
+    template<> struct A<char>::B {}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}}
+    // FIXME: This is ill-formed; -pedantic-errors should reject.
+    template<> template<typename U> struct A<char>::C {}; // expected-warning {{extraneous template parameter list}}
+    template<> char A<char>::n = 0; // expected-error {{extraneous 'template<>'}}
+  }
+
+  namespace nested {
+    template<typename T> struct A {
+      template<typename U> struct B;
+    };
+    template<> template<typename U> struct A<int>::B {
+      void f();
+      void g();
+      template<typename V> void h();
+      template<typename V> void i();
+    };
+    template<> template<typename U> void A<int>::B<U>::f() {}
+    template<typename U> void A<int>::B<U>::g() {} // expected-error {{should be empty}}
+
+    template<> template<typename U> template<typename V> void A<int>::B<U>::h() {}
+    template<typename U> template<typename V> void A<int>::B<U>::i() {} // expected-error {{should be empty}}
+
+    template<> template<> void A<int>::B<int>::f() {}
+    template<> template<> template<typename V> void A<int>::B<int>::h() {}
+    template<> template<> template<> void A<int>::B<int>::h<int>() {}
+
+    template<> void A<int>::B<char>::f() {} // expected-error {{requires 'template<>'}}
+    template<> template<typename V> void A<int>::B<char>::h() {} // expected-error {{should be empty}}
+  }
+}
+
 // PR8130
 namespace dr532 { // dr532: 3.5
   struct A { };
@@ -210,3 +364,632 @@
     int &ir = b * a;
   }
 }
+
+// dr533: na
+
+namespace dr534 { // dr534: yes
+  struct S {};
+  template<typename T> void operator+(S, T);
+  template<typename T> void operator+<T*>(S, T*) {} // expected-error {{function template partial spec}}
+}
+
+namespace dr535 { // dr535: yes
+  class X { private: X(const X&); };
+  struct A {
+    X x;
+    template<typename T> A(T&);
+  };
+  struct B : A {
+    X y;
+    B(volatile A&);
+  };
+
+  extern A a1;
+  A a2(a1); // ok, uses constructor template
+
+  extern volatile B b1;
+  B b2(b1); // ok, uses converting constructor
+
+  void f() { throw a1; }
+
+#if __cplusplus >= 201103L
+  struct C {
+    constexpr C() : n(0) {}
+    template<typename T> constexpr C(T&t) : n(t.n == 0 ? throw 0 : 0) {}
+    int n;
+  };
+  constexpr C c() { return C(); }
+  // ok, copy is elided
+  constexpr C x = c();
+#endif
+}
+
+// dr537: na
+// dr538: na
+
+// dr539: yes
+const dr539( // expected-error {{requires a type specifier}}
+    const a) { // expected-error {{unknown type name 'a'}}
+  const b; // expected-error {{requires a type specifier}}
+  new const; // expected-error {{expected a type}}
+  try {} catch (const n) {} // expected-error {{unknown type name 'n'}}
+  try {} catch (const) {} // expected-error {{expected a type}}
+  if (const n = 0) {} // expected-error {{requires a type specifier}}
+  switch (const n = 0) {} // expected-error {{requires a type specifier}}
+  while (const n = 0) {} // expected-error {{requires a type specifier}}
+  for (const n = 0; // expected-error {{requires a type specifier}}
+       const m = 0; ) {} // expected-error {{requires a type specifier}}
+  sizeof(const); // expected-error {{requires a type specifier}}
+  struct S {
+    const n; // expected-error {{requires a type specifier}}
+    operator const(); // expected-error {{expected a type}}
+  };
+#if __cplusplus >= 201103L
+  int arr[3];
+  // FIXME: The extra braces here are to avoid the parser getting too
+  // badly confused when recovering here. We should fix this recovery.
+  { for (const n // expected-error {{unknown type name 'n'}} expected-note {{}}
+         : arr) ; {} } // expected-error +{{}}
+  (void) [](const) {}; // expected-error {{requires a type specifier}}
+  (void) [](const n) {}; // expected-error {{unknown type name 'n'}}
+  enum E : const {}; // expected-error {{expected a type}}
+  using T = const; // expected-error {{expected a type}}
+  auto f() -> const; // expected-error {{expected a type}}
+#endif
+}
+
+namespace dr540 { // dr540: yes
+  typedef int &a;
+  typedef const a &a; // expected-warning {{has no effect}}
+  typedef const int &b;
+  typedef b &b;
+  typedef const a &c; // expected-note {{previous}} expected-warning {{has no effect}}
+  typedef const b &c; // expected-error {{different}} expected-warning {{has no effect}}
+}
+
+namespace dr541 { // dr541: yes
+  template<int> struct X { typedef int type; };
+  template<typename T> struct S {
+    int f(T);
+
+    int g(int);
+    T g(bool);
+
+    int h();
+    int h(T);
+
+    void x() {
+      // These are type-dependent expressions, even though we could
+      // determine that all calls have type 'int'.
+      X<sizeof(f(0))>::type a; // expected-error +{{}}
+      X<sizeof(g(0))>::type b; // expected-error +{{}}
+      X<sizeof(h(0))>::type b; // expected-error +{{}}
+
+      typename X<sizeof(f(0))>::type a;
+      typename X<sizeof(h(0))>::type b;
+    }
+  };
+}
+
+namespace dr542 { // dr542: yes
+#if __cplusplus >= 201103L
+  struct A { A() = delete; int n; };
+  A a[32] = {}; // ok, constructor not called
+
+  struct B {
+    int n;
+  private:
+    B() = default;
+  };
+  B b[32] = {}; // ok, constructor not called
+#endif
+}
+
+namespace dr543 { // dr543: yes
+  // In C++98+DR543, this is valid because value-initialization doesn't call a
+  // trivial default constructor, so we never notice that defining the
+  // constructor would be ill-formed.
+  //
+  // In C++11+DR543, this is ill-formed, because the default constructor is
+  // deleted, and value-initialization *does* call a deleted default
+  // constructor, even if it is trivial.
+  struct A {
+    const int n;
+  };
+  A a = A();
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{deleted}}
+  // expected-note@-5 {{would not be initialized}}
+#endif
+}
+
+namespace dr544 { // dr544: yes
+  int *n;
+
+  template<class T> struct A { int n; };
+  template<class T> struct B : A<T> { int get(); };
+  template<> int B<int>::get() { return n; }
+  int k = B<int>().get();
+}
+
+namespace dr546 { // dr546: yes
+  template<typename T> struct A { void f(); };
+  template struct A<int>;
+  template<typename T> void A<T>::f() { T::error; }
+}
+
+namespace dr547 { // dr547: yes
+  // When targeting the MS x86 ABI, the type of a member function includes a
+  // __thiscall qualifier. This is non-conforming, but we still implement
+  // the intent of dr547
+#if defined(_M_IX86) || (defined(__MINGW32__) && !defined(__MINGW64__))
+#define THISCALL __thiscall
+#else
+#define THISCALL
+#endif
+
+  template<typename T> struct X;
+  template<typename T> struct X<THISCALL T() const> {};
+  template<typename T, typename C> X<T> f(T C::*) { return X<T>(); }
+
+  struct S { void f() const; };
+  X<THISCALL void() const> x = f(&S::f);
+
+#undef THISCALL
+}
+
+namespace dr548 { // dr548: dup 482
+  template<typename T> struct S {};
+  template<typename T> void f() {}
+  template struct dr548::S<int>;
+  template void dr548::f<int>();
+}
+
+namespace dr551 { // dr551: yes c++11
+  // FIXME: This obviously should apply in C++98 mode too.
+  template<typename T> void f() {}
+  template inline void f<int>();
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{cannot be 'inline'}}
+#endif
+
+  template<typename T> inline void g() {}
+  template inline void g<int>();
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{cannot be 'inline'}}
+#endif
+
+  template<typename T> struct X {
+    void f() {}
+  };
+  template inline void X<int>::f();
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{cannot be 'inline'}}
+#endif
+}
+
+namespace dr552 { // dr552: yes
+  template<typename T, typename T::U> struct X {};
+  struct Y { typedef int U; };
+  X<Y, 0> x;
+}
+
+struct dr553_class {
+  friend void *operator new(size_t, dr553_class);
+};
+namespace dr553 {
+  dr553_class c;
+  // Contrary to the apparent intention of the DR, operator new is not actually
+  // looked up with a lookup mechanism that performs ADL; the standard says it
+  // "is looked up in global scope", where it is not visible.
+  void *p = new (c) int; // expected-error {{no matching function}}
+
+  struct namespace_scope {
+    friend void *operator new(size_t, namespace_scope); // expected-error {{cannot be declared inside a namespace}}
+  };
+}
+
+// dr556: na
+
+namespace dr557 { // dr557: yes
+  template<typename T> struct S {
+    friend void f(S<T> *);
+    friend void g(S<S<T> > *);
+  };
+  void x(S<int> *p, S<S<int> > *q) {
+    f(p);
+    g(q);
+  }
+}
+
+namespace dr558 { // dr558: yes
+  wchar_t a = L'\uD7FF';
+  wchar_t b = L'\xD7FF';
+  wchar_t c = L'\uD800'; // expected-error {{invalid universal character}}
+  wchar_t d = L'\xD800';
+  wchar_t e = L'\uDFFF'; // expected-error {{invalid universal character}}
+  wchar_t f = L'\xDFFF';
+  wchar_t g = L'\uE000';
+  wchar_t h = L'\xE000';
+}
+
+template<typename> struct dr559 { typedef int T; dr559::T u; }; // dr559: yes
+
+namespace dr561 { // dr561: yes
+  template<typename T> void f(int);
+  template<typename T> void g(T t) {
+    f<T>(t);
+  }
+  namespace {
+    struct S {};
+    template<typename T> static void f(S);
+  }
+  void h(S s) {
+    g(s);
+  }
+}
+
+namespace dr564 { // dr564: yes
+  extern "C++" void f(int);
+  void f(int); // ok
+  extern "C++" { extern int n; }
+  int n; // ok
+}
+
+namespace dr565 { // dr565: yes
+  namespace N {
+    template<typename T> int f(T); // expected-note {{target}}
+  }
+  using N::f; // expected-note {{using}}
+  template<typename T> int f(T*);
+  template<typename T> void f(T);
+  template<typename T, int = 0> int f(T); // expected-error 0-1{{extension}}
+  template<typename T> int f(T, int = 0);
+  template<typename T> int f(T); // expected-error {{conflicts with}}
+}
+
+namespace dr566 { // dr566: yes
+#if __cplusplus >= 201103L
+  int check[int(-3.99) == -3 ? 1 : -1];
+#endif
+}
+
+// dr567: na
+
+namespace dr568 { // dr568: yes c++11
+  // FIXME: This is a DR issue against C++98, so should probably apply there
+  // too.
+  struct x { int y; };
+  class trivial : x {
+    x y;
+  public:
+    int n;
+  };
+  int check_trivial[__is_trivial(trivial) ? 1 : -1];
+
+  struct std_layout {
+    std_layout();
+    std_layout(const std_layout &);
+    ~std_layout();
+  private:
+    int n;
+  };
+  int check_std_layout[__is_standard_layout(std_layout) ? 1 : -1];
+
+  struct aggregate {
+    int x;
+    int y;
+    trivial t;
+    std_layout sl;
+  };
+  aggregate aggr = {};
+
+  void f(...);
+  void g(trivial t) { f(t); }
+#if __cplusplus < 201103L
+  // expected-error@-2 {{non-POD}}
+#endif
+
+  void jump() {
+    goto x;
+#if __cplusplus < 201103L
+    // expected-error@-2 {{cannot jump}}
+    // expected-note@+2 {{non-POD}}
+#endif
+    trivial t;
+  x: ;
+  }
+}
+
+namespace dr569 { // dr569: yes c++11
+  // FIXME: This is a DR issue against C++98, so should probably apply there
+  // too.
+  ;;;;;
+#if __cplusplus < 201103L
+  // expected-error@-2 {{C++11 extension}}
+#endif
+}
+
+namespace dr570 { // dr570: dup 633
+  int n;
+  int &r = n; // expected-note {{previous}}
+  int &r = n; // expected-error {{redefinition}}
+}
+
+namespace dr571 { // dr571 unknown
+  // FIXME: Add a codegen test.
+  typedef int &ir;
+  int n;
+  const ir r = n; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage.
+}
+
+namespace dr572 { // dr572: yes
+  enum E { a = 1, b = 2 };
+  int check[a + b == 3 ? 1 : -1];
+}
+
+namespace dr573 { // dr573: no
+  void *a;
+  int *b = reinterpret_cast<int*>(a);
+  void (*c)() = reinterpret_cast<void(*)()>(a);
+  void *d = reinterpret_cast<void*>(c);
+#if __cplusplus < 201103L
+  // expected-error@-3 {{extension}}
+  // expected-error@-3 {{extension}}
+#endif
+  void f() { delete a; } // expected-error {{cannot delete}}
+  int n = d - a; // expected-error {{arithmetic on pointers to void}}
+  // FIXME: This is ill-formed.
+  template<void*> struct S;
+  template<int*> struct T;
+}
+
+namespace dr574 { // dr574: yes
+  struct A {
+    A &operator=(const A&) const; // expected-note {{does not match because it is const}}
+  };
+  struct B {
+    B &operator=(const B&) volatile; // expected-note {{nearly matches}}
+  };
+#if __cplusplus >= 201103L
+  struct C {
+    C &operator=(const C&) &; // expected-note {{not viable}} expected-note {{nearly matches}} expected-note {{here}}
+  };
+  struct D {
+    D &operator=(const D&) &&; // expected-note {{not viable}} expected-note {{nearly matches}} expected-note {{here}}
+  };
+  void test(C c, D d) {
+    c = c;
+    C() = c; // expected-error {{no viable}}
+    d = d; // expected-error {{no viable}}
+    D() = d;
+  }
+#endif
+  struct Test {
+    friend A &A::operator=(const A&); // expected-error {{does not match}}
+    friend B &B::operator=(const B&); // expected-error {{does not match}}
+#if __cplusplus >= 201103L
+    // FIXME: We shouldn't produce the 'cannot overload' diagnostics here.
+    friend C &C::operator=(const C&); // expected-error {{does not match}} expected-error {{cannot overload}}
+    friend D &D::operator=(const D&); // expected-error {{does not match}} expected-error {{cannot overload}}
+#endif
+  };
+}
+
+namespace dr575 { // dr575: yes
+  template<typename T, typename U = typename T::type> void a(T); void a(...); // expected-error 0-1{{extension}}
+  template<typename T, typename T::type U = 0> void b(T); void b(...); // expected-error 0-1{{extension}}
+  template<typename T, int U = T::value> void c(T); void c(...); // expected-error 0-1{{extension}}
+  template<typename T> void d(T, int = T::value); void d(...); // expected-error {{cannot be used prior to '::'}}
+  void x() {
+    a(0);
+    b(0);
+    c(0);
+    d(0); // expected-note {{in instantiation of default function argument}}
+  }
+
+  template<typename T = int&> void f(T* = 0); // expected-error 0-1{{extension}}
+  template<typename T = int> void f(T = 0); // expected-error 0-1{{extension}}
+  void g() { f<>(); }
+
+  template<typename T> T &h(T *);
+  template<typename T> T *h(T *);
+  void *p = h((void*)0);
+}
+
+namespace dr576 { // dr576: yes
+  typedef void f() {} // expected-error {{function definition is not allowed}}
+  void f(typedef int n); // expected-error {{invalid storage class}}
+  void f(char c) { typedef int n; }
+}
+
+namespace dr577 { // dr577: yes
+  typedef void V;
+  typedef const void CV;
+  void a(void);
+  void b(const void); // expected-error {{qualifiers}}
+  void c(V);
+  void d(CV); // expected-error {{qualifiers}}
+  void (*e)(void) = c;
+  void (*f)(const void); // expected-error {{qualifiers}}
+  void (*g)(V) = a;
+  void (*h)(CV); // expected-error {{qualifiers}}
+  template<typename T> void i(T); // expected-note 2{{requires 1 arg}}
+  template<typename T> void j(void (*)(T)); // expected-note 2{{argument may not have 'void' type}}
+  void k() {
+    a();
+    c();
+    i<void>(); // expected-error {{no match}}
+    i<const void>(); // expected-error {{no match}}
+    j<void>(0); // expected-error {{no match}}
+    j<const void>(0); // expected-error {{no match}}
+  }
+}
+
+namespace dr580 { // dr580: no
+  class C;
+  struct A { static C c; };
+  struct B { static C c; };
+  class C {
+    C(); // expected-note {{here}}
+    ~C(); // expected-note {{here}}
+
+    typedef int I; // expected-note {{here}}
+    template<int> struct X;
+    template<int> friend struct Y;
+    template<int> void f();
+    template<int> friend void g();
+    friend struct A;
+  };
+
+  template<C::I> struct C::X {};
+  template<C::I> struct Y {};
+  template<C::I> struct Z {}; // FIXME: should reject, accepted because C befriends A!
+
+  template<C::I> void C::f() {}
+  template<C::I> void g() {}
+  template<C::I> void h() {} // expected-error {{private}}
+
+  C A::c;
+  C B::c; // expected-error 2{{private}}
+}
+
+// dr582: na
+
+namespace dr583 { // dr583: no
+  // see n3624
+  int *p;
+  // FIXME: These are all ill-formed.
+  bool b1 = p < 0;
+  bool b2 = p > 0;
+  bool b3 = p <= 0;
+  bool b4 = p >= 0;
+}
+
+// dr584: na
+
+namespace dr585 { // dr585: yes
+  template<typename> struct T;
+  struct A {
+    friend T; // expected-error {{requires a type specifier}} expected-error {{can only be classes or functions}}
+    // FIXME: It's not clear whether the standard allows this or what it means,
+    // but the DR585 writeup suggests it as an alternative.
+    template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}
+  };
+  template<template<typename> class T> struct B {
+    friend T; // expected-error {{requires a type specifier}} expected-error {{can only be classes or functions}}
+    template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}
+  };
+}
+
+// dr586: na
+
+namespace dr587 { // dr587: yes
+  template<typename T> void f(bool b, const T x, T y) {
+    const T *p = &(b ? x : y);
+  }
+  struct S {};
+  template void f(bool, const int, int);
+  template void f(bool, const S, S);
+}
+
+namespace dr588 { // dr588: yes
+  struct A { int n; }; // expected-note {{ambiguous}}
+  template<typename T> int f() {
+    struct S : A, T { int f() { return n; } } s;
+    int a = s.f();
+    int b = s.n; // expected-error {{found in multiple}}
+  }
+  struct B { int n; }; // expected-note {{ambiguous}}
+  int k = f<B>(); // expected-note {{here}}
+}
+
+namespace dr589 { // dr589: yes
+  struct B { };
+  struct D : B { };
+  D f();
+  extern const B &b;
+  bool a;
+  const B *p = &(a ? f() : b); // expected-error {{temporary}}
+  const B *q = &(a ? D() : b); // expected-error {{temporary}}
+}
+
+namespace dr590 { // dr590: yes
+  template<typename T> struct A {
+    struct B {
+      struct C {
+        A<T>::B::C f(A<T>::B::C); // ok, no 'typename' required.
+      };
+    };
+  };
+  template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {}
+}
+
+namespace dr591 { // dr591: no
+  template<typename T> struct A {
+    typedef int M;
+    struct B {
+      typedef void M;
+      struct C;
+    };
+  };
+
+  template<typename T> struct A<T>::B::C : A<T> {
+    // FIXME: Should find member of non-dependent base class A<T>.
+    M m; // expected-error {{incomplete type 'M' (aka 'void'}}
+  };
+}
+
+// dr592: na
+// dr593 needs an IRGen test.
+// dr594: na
+
+namespace dr595 { // dr595: dup 1330
+  template<class T> struct X {
+    void f() throw(T) {}
+  };
+  struct S {
+    X<S> xs;
+  };
+}
+
+// dr597: na
+
+namespace dr598 { // dr598: yes
+  namespace N {
+    void f(int);
+    void f(char);
+    // Not found by ADL.
+    void g(void (*)(int));
+    void h(void (*)(int));
+
+    namespace M {
+      struct S {};
+      int &h(void (*)(S));
+    }
+    void i(M::S);
+    void i();
+  }
+  int &g(void(*)(char));
+  int &r = g(N::f);
+  int &s = h(N::f); // expected-error {{undeclared}}
+  int &t = h(N::i);
+}
+
+namespace dr599 { // dr599: partial
+  typedef int Fn();
+  struct S { operator void*(); };
+  struct T { operator Fn*(); };
+  struct U { operator int*(); operator void*(); }; // expected-note 2{{conversion}}
+  struct V { operator int*(); operator Fn*(); };
+  void f(void *p, void (*q)(), S s, T t, U u, V v) {
+    delete p; // expected-error {{cannot delete}}
+    delete q; // expected-error {{cannot delete}}
+    delete s; // expected-error {{cannot delete}}
+    delete t; // expected-error {{cannot delete}}
+    // FIXME: This is valid, but is rejected due to a non-conforming GNU
+    // extension allowing deletion of pointers to void.
+    delete u; // expected-error {{ambiguous}}
+    delete v;
+  }
+}
diff --git a/test/CXX/drs/dr6xx.cpp b/test/CXX/drs/dr6xx.cpp
new file mode 100644
index 0000000..594eac8
--- /dev/null
+++ b/test/CXX/drs/dr6xx.cpp
@@ -0,0 +1,347 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+namespace std { struct type_info {}; }
+
+namespace dr601 { // dr601: yes
+#if __cplusplus >= 201103L
+#define MAX __LLONG_MAX__
+#else
+#define MAX __LONG_MAX__
+#endif
+
+#if 0x8000 < -1
+#error 0x8000 should be signed
+#endif
+
+#if MAX > 0xFFFFFFFF && 0x80000000 < -1
+#error 0x80000000 should be signed
+#endif
+
+#if __INT_MAX__ == 0x7FFFFFFF
+_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-error {{C11}}
+#endif
+
+#if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1
+#error 0x8000000000000000 should be signed
+#endif
+
+#if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFFFFFFFFFFFFFF
+static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); // expected-error {{C11}}
+#endif
+
+#undef MAX
+}
+
+namespace dr602 { // dr602: yes
+  template<class T> struct A {
+    template<class U> friend struct A;
+  };
+
+  template<class T> struct B {
+    class C {
+      template<class U> friend struct B;
+      typedef int type;
+    };
+    typename C::type ct; // ok, befriended
+  };
+  B<int> b;
+}
+
+namespace dr603 { // dr603: yes
+  template<unsigned char> struct S {};
+  typedef S<'\001'> S1;
+  typedef S<(1ul << __CHAR_BIT__) + 1> S1;
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{cannot be narrowed}}
+#endif
+}
+
+// dr604: na
+// dr605 needs IRGen test
+
+namespace dr606 { // dr606: yes
+#if __cplusplus >= 201103L
+  template<typename T> struct S {};
+  template<typename T> void f(S<T> &&); // expected-note {{no known conversion from 'S<int>' to 'S<int> &&'}}
+  template<typename T> void g(T &&);
+  template<typename T> void h(const T &&); // expected-note {{no known conversion from 'S<int>' to 'const dr606::S<int> &&'}}
+
+  void test(S<int> s) {
+    f(s); // expected-error {{no match}}
+    g(s);
+    h(s); // expected-error {{no match}}
+
+    g(test);
+    h(test); // ok, an rvalue reference can bind to a function lvalue
+  }
+#endif
+}
+
+namespace dr608 { // dr608: yes
+  struct A { virtual void f(); };
+  struct B : A {};
+  struct C : A { void f(); };
+  struct D : B, C {};
+}
+
+int dr610[-0u == 0u ? 1 : -1]; // dr610: yes
+
+namespace dr611 { // dr611: yes
+  int k;
+  struct S { int &r; } s = { k ? k : k };
+}
+
+// dr612: na
+
+namespace dr613 { // dr613: yes c++11
+  // see also n2253
+  struct A { int n; static void f(); };
+  int f(int);
+  struct B { virtual void f(); };
+  B &g(int);
+
+  int an1 = sizeof(A::n);
+  int an2 = sizeof(A::n + 1); // valid per dr850
+  int an3 = sizeof A::n;
+  int an4 = sizeof(f(A::n));
+  int an5 = sizeof(g(A::n));
+  const std::type_info &an6 = typeid(A::n);
+  const std::type_info &an7 = typeid(A::n + 1);
+  const std::type_info &an8 = typeid(f(A::n));
+  const std::type_info &an9 = typeid(g(A::n)); // expected-error {{non-static}}
+#if __cplusplus < 201103L
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+  // expected-error@-10 {{non-static}}
+#endif
+
+  void A::f() {
+    int an1 = sizeof n;
+    const std::type_info &an2 = typeid(n + 1);
+#if __cplusplus < 201103L
+  // expected-error@-3 {{static}}
+  // expected-error@-3 {{static}}
+#endif
+    const std::type_info &an3 = typeid(g(n)); // expected-error {{static}}
+  }
+}
+
+int dr614_a[(-1) / 2 == 0 ? 1 : -1]; // dr614: yes
+int dr614_b[(-1) % 2 == -1 ? 1 : -1];
+
+namespace dr615 { // dr615: yes
+  int f();
+  static int n = f();
+}
+
+namespace dr616 { // dr616: no
+#if __cplusplus >= 201103L
+  struct S { int n; } s;
+  // FIXME: These should all be 'int &&'
+  using T = decltype(S().n); // expected-note 2{{previous}}
+  using T = decltype(static_cast<S&&>(s).n);
+  using T = decltype(S().*&S::n);
+  using T = decltype(static_cast<S&&>(s).*&S::n); // expected-error {{different type}}
+  using T = int&&; // expected-error {{different type}}
+#endif
+}
+
+namespace dr618 { // dr618: yes
+#if (unsigned)-1 > 0
+#error wrong
+#endif
+}
+
+namespace dr619 { // dr619: yes
+  extern int x[10];
+  struct S { static int x[10]; };
+
+  int x[];
+  _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}}
+  extern int x[];
+  _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}}
+
+  int S::x[];
+  _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); // expected-error {{C11}}
+
+  void f() {
+    extern int x[];
+    sizeof(x); // expected-error {{incomplete}}
+  }
+}
+
+// dr620: dup 568
+
+namespace dr621 {
+  template<typename T> T f();
+  template<> int f() {} // expected-note {{previous}}
+  template<> int f<int>() {} // expected-error {{redefinition}}
+}
+
+// dr623: na
+// FIXME: Add documentation saying we allow invalid pointer values.
+
+// dr624 needs an IRGen check.
+
+namespace dr625 { // dr625: yes
+  template<typename T> struct A {};
+  A<auto> x = A<int>(); // expected-error {{'auto' not allowed in template argument}} expected-error 0-1{{extension}}
+  void f(int);
+  void (*p)(auto) = f; // expected-error {{'auto' not allowed in function prototype}} expected-error 0-1{{extension}}
+}
+
+namespace dr626 { // dr626: yes
+#define STR(x) #x
+  char c[2] = STR(c); // ok, type matches
+  wchar_t w[2] = STR(w); // expected-error {{initializing wide char array with non-wide string literal}}
+}
+
+namespace dr627 { // dr627: yes
+  void f() {
+    true a = 0; // expected-error +{{}} expected-warning {{unused}}
+  }
+}
+
+// dr628: na
+
+namespace dr629 { // dr629: yes
+  typedef int T;
+  int n = 1;
+  void f() {
+    auto T = 2;
+#if __cplusplus < 201103L
+    // expected-error@-2 {{expected unqualified-id}}
+#else
+    // expected-note@-4 {{previous}}
+#endif
+
+    auto T(n);
+#if __cplusplus >= 201103L
+    // expected-error@-2 {{redefinition of 'T'}}
+#endif
+  }
+}
+
+namespace dr630 { // dr630: yes
+const bool MB_EQ_WC =
+    ' ' == L' ' && '\t' == L'\t' && '\v' == L'\v' && '\r' == L'\r' &&
+    '\n' == L'\n' && //
+    'a' == L'a' && 'b' == L'b' && 'c' == L'c' && 'd' == L'd' && 'e' == L'e' &&
+    'f' == L'f' && 'g' == L'g' && 'h' == L'h' && 'i' == L'i' && 'j' == L'j' &&
+    'k' == L'k' && 'l' == L'l' && 'm' == L'm' && 'n' == L'n' && 'o' == L'o' &&
+    'p' == L'p' && 'q' == L'q' && 'r' == L'r' && 's' == L's' && 't' == L't' &&
+    'u' == L'u' && 'v' == L'v' && 'w' == L'w' && 'x' == L'x' && 'y' == L'y' &&
+    'z' == L'z' && //
+    'A' == L'A' && 'B' == L'B' && 'C' == L'C' && 'D' == L'D' && 'E' == L'E' &&
+    'F' == L'F' && 'G' == L'G' && 'H' == L'H' && 'I' == L'I' && 'J' == L'J' &&
+    'K' == L'K' && 'L' == L'L' && 'M' == L'M' && 'N' == L'N' && 'O' == L'O' &&
+    'P' == L'P' && 'Q' == L'Q' && 'R' == L'R' && 'S' == L'S' && 'T' == L'T' &&
+    'U' == L'U' && 'V' == L'V' && 'W' == L'W' && 'X' == L'X' && 'Y' == L'Y' &&
+    'Z' == L'Z' && //
+    '0' == L'0' && '1' == L'1' && '2' == L'2' && '3' == L'3' && '4' == L'4' &&
+    '5' == L'5' && '6' == L'6' && '7' == L'7' && '8' == L'8' &&
+    '9' == L'9' && //
+    '_' == L'_' && '{' == L'{' && '}' == L'}' && '[' == L'[' && ']' == L']' &&
+    '#' == L'#' && '(' == L'(' && ')' == L')' && '<' == L'<' && '>' == L'>' &&
+    '%' == L'%' && ':' == L':' && ';' == L';' && '.' == L'.' && '?' == L'?' &&
+    '*' == L'*' && '+' == L'+' && '-' == L'-' && '/' == L'/' && '^' == L'^' &&
+    '&' == L'&' && '|' == L'|' && '~' == L'~' && '!' == L'!' && '=' == L'=' &&
+    ',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\'';
+#if __STDC_MB_MIGHT_NEQ_WC__
+_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); // expected-error {{C11}}
+#else
+_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); // expected-error {{C11}}
+#endif
+}
+
+// dr631: na
+
+namespace dr632 { // dr632: yes
+  struct S { int n; } s = {{5}}; // expected-warning {{braces}}
+}
+
+// dr633: na
+// see also n2993
+
+namespace dr634 { // dr634: yes
+  struct S { S(); S(const S&); virtual void f(); ~S(); };
+  int f(...);
+  char f(int);
+  template<typename T> int (&g(T))[sizeof f(T())];
+  int (&a)[sizeof(int)] = g(S());
+  int (&b)[1] = g(0);
+  int k = f(S()); // expected-error {{cannot pass}}
+}
+
+namespace dr635 { // dr635: yes
+  template<typename T> struct A { A(); ~A(); };
+  template<typename T> A<T>::A<T>() {} // expected-error {{cannot have template arguments}}
+  template<typename T> A<T>::~A<T>() {}
+
+  template<typename T> struct B { B(); ~B(); };
+  template<typename T> B<T>::B() {}
+  template<typename T> B<T>::~B() {}
+
+  struct C { template<typename T> C(); C(); };
+  template<typename T> C::C() {}
+  C::C() {}
+  template<> C::C<int>() {} // expected-error {{constructor name}} expected-error {{unqualified-id}}
+  /*FIXME: needed for error recovery:*/;
+
+  template<typename T> struct D { template<typename U> D(); D(); };
+  template<typename T> D<T>::D() {} // expected-note {{previous}}
+  template<typename T> template<typename U> D<T>::D() {}
+  template<typename T> D<T>::D<T>() {} // expected-error {{redefinition}} expected-error {{cannot have template arg}}
+}
+
+namespace dr637 { // dr637: yes
+  void f(int i) {
+    i = ++i + 1;
+    i = i++ + 1; // expected-warning {{unsequenced}}
+  }
+}
+
+namespace dr638 { // dr638: no
+  template<typename T> struct A {
+    struct B;
+    void f();
+    void g();
+    struct C {
+      void h();
+    };
+  };
+
+  class X {
+    typedef int type;
+    template<class T> friend struct A<T>::B; // expected-warning {{not supported}}
+    template<class T> friend void A<T>::f(); // expected-warning {{not supported}}
+    template<class T> friend void A<T>::g(); // expected-warning {{not supported}}
+    template<class T> friend void A<T>::C::h(); // expected-warning {{not supported}}
+  };
+
+  template<> struct A<int> {
+    X::type a; // FIXME: private
+    struct B {
+      X::type b; // ok
+    };
+    int f() { X::type c; } // FIXME: private
+    void g() { X::type d; } // ok
+    struct D {
+      void h() { X::type e; } // FIXME: private
+    };
+  };
+}
+
+namespace dr639 { // dr639: yes
+  void f(int i) {
+    void((i = 0) + (i = 0)); // expected-warning {{unsequenced}}
+  }
+}
diff --git a/test/CXX/drs/dr9xx.cpp b/test/CXX/drs/dr9xx.cpp
index 40dc282..4bcd656 100644
--- a/test/CXX/drs/dr9xx.cpp
+++ b/test/CXX/drs/dr9xx.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 #if __cplusplus < 201103L
 // expected-no-diagnostics
diff --git a/test/CXX/except/except.spec/p1.cpp b/test/CXX/except/except.spec/p1.cpp
index a32f37d..fa53c9f 100644
--- a/test/CXX/except/except.spec/p1.cpp
+++ b/test/CXX/except/except.spec/p1.cpp
@@ -77,5 +77,12 @@
     static int f() noexcept(1/X) { return 10; }  // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}}
   };
 
-  void g() { A<0>::f(); } // expected-note{{in instantiation of exception specification for 'f' requested here}}
+  template<int X> void f() {
+    int (*p)() noexcept(1/X); // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}}
+  };
+
+  void g() {
+    A<0>::f(); // expected-note{{in instantiation of exception specification for 'f'}}
+    f<0>(); // expected-note{{in instantiation of function template specialization}}
+  }
 }
diff --git a/test/CXX/except/except.spec/p14-ir.cpp b/test/CXX/except/except.spec/p14-ir.cpp
index 68c44b5..e3b15e5 100644
--- a/test/CXX/except/except.spec/p14-ir.cpp
+++ b/test/CXX/except/except.spec/p14-ir.cpp
@@ -26,12 +26,12 @@
 struct X5 : X0, X4 { };
 
 void test(X2 x2, X3 x3, X5 x5) {
-  // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* %this, %struct.X2* nonnull) unnamed_addr
+  // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* %this, %struct.X2* dereferenceable({{[0-9]+}})) unnamed_addr
   // CHECK:      call void @_ZN2X2C2ERKS_({{.*}}) [[NUW:#[0-9]+]]
   // CHECK-NEXT: ret void
   // CHECK-NEXT: }
   X2 x2a(x2);
-  // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* %this, %struct.X3* nonnull) unnamed_addr
+  // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* %this, %struct.X3* dereferenceable({{[0-9]+}})) unnamed_addr
   // CHECK:      call void @_ZN2X3C2ERKS_({{.*}}) [[NUW]]
   // CHECK-NEXT: ret void
   // CHECK-NEXT: }
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
index bcf45a0..249e552 100644
--- a/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -277,7 +277,7 @@
 
 // - a lambda-expression (5.1.2);
 struct Lambda {
-  int n : []{ return 1; }(); // expected-error {{constant expression}} expected-error {{integral constant expression}}
+  int n : []{ return 1; }(); // expected-error {{constant expression}} expected-error {{integral constant expression}} expected-note {{non-literal type}}
 };
 
 // - an lvalue-to-rvalue conversion (4.1) unless it is applied to
diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
index fd90482..0e948ce 100644
--- a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
@@ -136,12 +136,11 @@
 
 namespace PR12564 {
   struct Base {
-    void bar(Base&) {} // FIXME: expected-note {{here}}
+    void bar(Base&) {}
   };
 
   struct Derived : Base {
-    // FIXME: This should be accepted.
-    void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} // expected-error {{cannot bind to a value of unrelated type}}
+    void foo(Derived& d) noexcept(noexcept(d.bar(d))) {}
   };
 }
 
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
index 562f92a..c0fa72b 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
@@ -3,4 +3,9 @@
 void test_nonaggregate(int i) {
   auto lambda = [i]() -> void {}; // expected-note 3{{candidate constructor}}
   decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}}
+  static_assert(!__is_literal(decltype(lambda)), "");
+
+  auto lambda2 = []{}; // expected-note {{lambda}}
+  decltype(lambda2) bar = {}; // expected-error{{call to implicitly-deleted default constructor}}
+  static_assert(!__is_literal(decltype(lambda2)), "");
 }
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
index 407b083..90cbf02 100644
--- a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
@@ -140,11 +140,11 @@
   }
 
   template<typename T>
-  struct X2 {
+  struct X2 { // expected-note{{in instantiation of default member initializer 'NonLocalLambdaInstantation::X2<int *>::x' requested here}}
     int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}}
   };
 
   X2<int> x2i;
   X2<float> x2f;
-  X2<int*> x2ip; // expected-note{{in instantiation of template class 'NonLocalLambdaInstantation::X2<int *>' requested here}}
+  X2<int*> x2ip; // expected-note{{implicit default constructor for 'NonLocalLambdaInstantation::X2<int *>' first required here}}
 }
diff --git a/test/CXX/lex/lex.literal/lex.ext/p3.cpp b/test/CXX/lex/lex.literal/lex.ext/p3.cpp
index e812ddd..d764989 100644
--- a/test/CXX/lex/lex.literal/lex.ext/p3.cpp
+++ b/test/CXX/lex/lex.literal/lex.ext/p3.cpp
@@ -9,7 +9,7 @@
 template<char...> char &operator "" _x1 ();
 int &i3 = 0377_x1;
 
-int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-error {{integer constant is larger than the largest unsigned integer type}}
+int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-error {{integer literal is too large to be represented in any integer type}}
 
 double &operator "" _x2 (const char *);
 double &i5 = 123123123123123123123123123123123123123123123_x2;
diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
index 574cb40..d7726c9 100644
--- a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
+++ b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
@@ -30,11 +30,11 @@
 
 void f();
 void test_Y() {
-  goto end; // expected-error{{goto into protected scope}}
+  goto end; // expected-error{{cannot jump from this goto statement to its label}}
   Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
  end:
   f();
-  goto inner; // expected-error{{goto into protected scope}}
+  goto inner; // expected-error{{cannot jump from this goto statement to its label}}
   {
     Y y2; // expected-note{{jump bypasses variable with a non-trivial destructor}}
   inner:
diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
index f52e3b6..4bcc648 100644
--- a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
+++ b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
@@ -29,7 +29,7 @@
 };
 
 void test_Y() {
-  goto end; // expected-error{{goto into protected scope}}
+  goto end; // expected-error{{cannot jump from this goto statement to its label}}
   Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
  end:
   return;
@@ -40,7 +40,7 @@
 };
 
 void test_Z() {
-  goto end; // expected-error{{goto into protected scope}}
+  goto end; // expected-error{{cannot jump from this goto statement to its label}}
   Z z; // expected-note{{jump bypasses initialization of non-POD variable}}
  end:
   return;
diff --git a/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp b/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
index 8a3168e..b0305dd 100644
--- a/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
+++ b/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
@@ -8,7 +8,7 @@
 template<typename T>
 T X0<T>::value = 0; // expected-error{{no viable conversion}}
 
-struct X1 { 
+struct X1 {
   X1(int);
 };
 
@@ -19,8 +19,8 @@
 
 double*& get_double_ptr() { return X0<int*>::value; } // expected-error{{non-const lvalue reference to type 'double *' cannot bind to a value of unrelated type 'int *'}}
 
-X2& get_X2() { 
+X2& get_X2() {
   return X0<X2>::value; // expected-note{{instantiation}}
 }
-  
-template<typename T> T x; // expected-warning{{variable templates are a C++1y extension}}
+
+template<typename T> T x; // expected-warning{{variable templates are a C++14 extension}}
diff --git a/test/CXX/temp/temp.decls/temp.friend/p5.cpp b/test/CXX/temp/temp.decls/temp.friend/p5.cpp
index b26abb6..c4f9d63 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p5.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p5.cpp
@@ -20,7 +20,7 @@
 
   class C {
     static void foo();
-    template <class T> friend void A<T>::f();
+    template <class T> friend void A<T>::f(); // expected-warning {{not supported}}
   };
 
   template <class T> struct A {
@@ -42,7 +42,7 @@
 
   class C {
     static void foo();
-    template <class T> friend void A<T>::g();
+    template <class T> friend void A<T>::g(); // expected-warning {{not supported}}
   };
 
   template <class T> struct A {
@@ -86,7 +86,7 @@
     
     template <class V>
     template <class U>
-    friend void X<V>::operator+=(U);
+    friend void X<V>::operator+=(U); // expected-warning {{not supported}}
   };
 
   void test() {   
@@ -96,7 +96,7 @@
 
 namespace test5 {
   template<template <class> class T> struct A {
-    template<template <class> class U> friend void A<U>::foo();
+    template<template <class> class U> friend void A<U>::foo(); // expected-warning {{not supported}}
   };
 
   template <class> struct B {};
diff --git a/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp b/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
index 73cbd07..f1231f6 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
@@ -243,7 +243,7 @@
   };
 
   template<typename R, typename ...Types>
-  struct Arity<R(Types......)> {
+  struct Arity<R(Types......)> { // expected-warning {{varargs}} expected-note {{pack}} expected-note {{insert ','}}
     static const unsigned value = sizeof...(Types);
   };
 
diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
index dae6865..4f9368f 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -354,6 +354,7 @@
   for (auto t : values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}}
 
   switch (values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}}
+  switch (0) { case 0: case values: ; } // expected-error{{expression contains unexpanded parameter pack 'values'}}
 
   do { } while (values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
 
@@ -422,3 +423,17 @@
   B<1,2>::C<4,5,6> c1; // expected-note{{in instantiation of}}
   B<1,2,3,4>::C<4,5,6> c2; // expected-note{{in instantiation of}}
 }
+
+namespace PR21289 {
+  template<int> using T = int;
+  template<typename> struct S { static const int value = 0; };
+  template<typename> const int vt = 0; // expected-warning {{extension}}
+  int f(...);
+  template<int ...Ns> void g() {
+    f(T<Ns>()...);
+    f(S<T<Ns>>::value...);
+    f(vt<T<Ns>>...);
+  }
+  template void g<>();
+  template void g<1, 2, 3>();
+}
diff --git a/test/CXX/temp/temp.param/p5.cpp b/test/CXX/temp/temp.param/p5.cpp
index c258682..ab430fb 100644
--- a/test/CXX/temp/temp.param/p5.cpp
+++ b/test/CXX/temp/temp.param/p5.cpp
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -verify %s -std=c++11
 
-template<const int I> struct S {
+template<const int I> struct S { // expected-note {{instantiation}}
   decltype(I) n;
   int &&r = I; // expected-warning 2{{binding reference member 'r' to a temporary value}} expected-note 2{{declared here}}
 };
-S<5> s; // expected-note {{instantiation}}
+S<5> s;
 
-template<typename T, T v> struct U {
+template<typename T, T v> struct U { // expected-note {{instantiation}}
   decltype(v) n;
   int &&r = v; // expected-warning {{binding reference member 'r' to a temporary value}} expected-note {{declared here}}
 };
-U<const int, 6> u; // expected-note {{instantiation}}
+U<const int, 6> u;
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
index f804d4d..580ef31 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
@@ -9,7 +9,7 @@
 
 template<typename T>
 struct Y {
-  constexpr int f() { return 0; } // expected-warning{{C++1y}}
+  constexpr int f() { return 0; } // expected-warning{{C++14}}
 };
 
 template constexpr int Y<int>::f() const; // expected-error{{explicit instantiation cannot be 'constexpr'}}
diff --git a/test/CodeGen/2003-08-21-WideString.c b/test/CodeGen/2003-08-21-WideString.c
index 4071d17..1a6e5b7 100644
--- a/test/CodeGen/2003-08-21-WideString.c
+++ b/test/CodeGen/2003-08-21-WideString.c
@@ -5,9 +5,9 @@
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
   || defined(_M_X64) || defined(SHORT_WCHAR)
   #define WCHAR_T_TYPE unsigned short
-#elif defined(__sun) || defined(__AuroraUX__)
+#elif defined(__sun)
   #define WCHAR_T_TYPE long
-#else /* Solaris or AuroraUX. */
+#else /* Solaris. */
   #define WCHAR_T_TYPE int
 #endif
 
diff --git a/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c b/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c
index dd1acc5..0698601 100644
--- a/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c
+++ b/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | \
-// RUN:    opt -std-compile-opts -disable-output
+// RUN:    opt -O3 -disable-output
 // PR580
 
 int X, Y;
diff --git a/test/CodeGen/2005-09-24-AsmUserPrefix.c b/test/CodeGen/2005-09-24-AsmUserPrefix.c
index 1628313..d0e5bd1 100644
--- a/test/CodeGen/2005-09-24-AsmUserPrefix.c
+++ b/test/CodeGen/2005-09-24-AsmUserPrefix.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | opt -std-compile-opts | llc | \
+// RUN: %clang_cc1 %s -emit-llvm -o - | opt -O3 | llc | \
 // RUN:    not grep _foo2
 
 void foo() __asm__("foo2");
diff --git a/test/CodeGen/2007-06-18-SextAttrAggregate.c b/test/CodeGen/2007-06-18-SextAttrAggregate.c
index 92171e2..23c211d 100644
--- a/test/CodeGen/2007-06-18-SextAttrAggregate.c
+++ b/test/CodeGen/2007-06-18-SextAttrAggregate.c
@@ -1,11 +1,13 @@
 // RUN: %clang_cc1 %s -o - -emit-llvm | FileCheck %s
-// XFAIL: aarch64, arm64
+// XFAIL: aarch64, arm64, x86_64-pc-win32, x86_64-w64-mingw32
 
 // PR1513
 
 // AArch64 ABI actually requires the reverse of what this is testing: the callee
 // does any extensions and remaining bits are unspecified.
 
+// Win64 ABI does expect extensions for type smaller than 64bits.
+
 // Technically this test wasn't written to test that feature, but it's a
 // valuable check nevertheless.
 
diff --git a/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c b/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
index 33bd800..7401e11 100644
--- a/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
+++ b/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
@@ -8,5 +8,4 @@
   52, 
 };
 
-// CHECK: @yv7 = global 
-// CHECK: i8 52,
+// CHECK: @yv7 = global %struct.et7 { [0 x float] zeroinitializer, i8 52 }
diff --git a/test/CodeGen/2009-07-15-pad-wchar_t-array.c b/test/CodeGen/2009-07-15-pad-wchar_t-array.c
index df12cae..4ae3515 100644
--- a/test/CodeGen/2009-07-15-pad-wchar_t-array.c
+++ b/test/CodeGen/2009-07-15-pad-wchar_t-array.c
@@ -5,9 +5,9 @@
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
   || defined(_M_X64) || defined(SHORT_WCHAR)
   #define WCHAR_T_TYPE unsigned short
-#elif defined(__sun) || defined(__AuroraUX__)
+#elif defined(__sun)
   #define WCHAR_T_TYPE long
-#else /* Solaris or AuroraUX. */
+#else /* Solaris. */
   #define WCHAR_T_TYPE int
 #endif
 
diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c
index c48ad28..1b80b3e 100644
--- a/test/CodeGen/2009-10-20-GlobalDebug.c
+++ b/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -6,5 +6,5 @@
   return 0;
 }
 
-// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !{{.*}}, i32 5, metadata !{{.*}}, i32 1, i32 1, i32* @main.localstatic, null} ; [ DW_TAG_variable ]
-// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !{{.*}}, i32 3, metadata !{{.*}}, i32 0, i32 1, i32* @global, null} ; [ DW_TAG_variable ]
+// CHECK: metadata !{metadata !"0x34\00localstatic\00localstatic\00\005\001\001", metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}, i32* @main.localstatic, null} ; [ DW_TAG_variable ]
+// CHECK: metadata !{metadata !"0x34\00global\00global\00\003\000\001", null, metadata !{{.*}}, metadata !{{.*}}, i32* @global, null} ; [ DW_TAG_variable ]
diff --git a/test/CodeGen/2010-02-15-DbgStaticVar.c b/test/CodeGen/2010-02-15-DbgStaticVar.c
index facd14e..a75ffbb 100644
--- a/test/CodeGen/2010-02-15-DbgStaticVar.c
+++ b/test/CodeGen/2010-02-15-DbgStaticVar.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -g -emit-llvm %s -o - | grep "metadata ..b., metadata ..b., metadata ...,"
+// RUN: %clang_cc1 -g -emit-llvm %s -o - | FileCheck %s
 // Test to check intentionally empty linkage name for a static variable.
 // Radar 7651244.
 static int foo(int a)
@@ -11,3 +11,4 @@
 	int j = foo(1);
 	return 0;
 }
+// CHECK: metadata !"0x34\00b\00b\00\00{{.*}}",
diff --git a/test/CodeGen/24-bit.c b/test/CodeGen/24-bit.c
new file mode 100644
index 0000000..9dd0157
--- /dev/null
+++ b/test/CodeGen/24-bit.c
@@ -0,0 +1,14 @@
+// RUN:  %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -O0 -o - %s | FileCheck %s
+
+static union ibtt2
+{
+  struct ibtt0 { signed ibt0:10; unsigned short ibt1; } ibt5;
+  struct ibtt1 { signed ibt2:3; signed ibt3:9; signed ibt4:9; } ibt6;
+} ibt15 = {{267, 15266}};
+
+void callee_ibt0f(union ibtt2 ibtp5);
+
+void test(void) {
+// CHECK: = load i32*
+  callee_ibt0f(ibt15);
+}
diff --git a/test/CodeGen/Atomics.c b/test/CodeGen/Atomics.c
index 684f36d..f957883 100644
--- a/test/CodeGen/Atomics.c
+++ b/test/CodeGen/Atomics.c
@@ -49,6 +49,15 @@
   (void) __sync_fetch_and_xor (&sll, 1); // CHECK: atomicrmw xor i64
   (void) __sync_fetch_and_xor (&ull, 1); // CHECK: atomicrmw xor i64
 
+  (void) __sync_fetch_and_nand (&sc, 1); // CHECK: atomicrmw nand i8
+  (void) __sync_fetch_and_nand (&uc, 1); // CHECK: atomicrmw nand i8
+  (void) __sync_fetch_and_nand (&ss, 1); // CHECK: atomicrmw nand i16
+  (void) __sync_fetch_and_nand (&us, 1); // CHECK: atomicrmw nand i16
+  (void) __sync_fetch_and_nand (&si, 1); // CHECK: atomicrmw nand i32
+  (void) __sync_fetch_and_nand (&ui, 1); // CHECK: atomicrmw nand i32
+  (void) __sync_fetch_and_nand (&sll, 1); // CHECK: atomicrmw nand i64
+  (void) __sync_fetch_and_nand (&ull, 1); // CHECK: atomicrmw nand i64
+
   (void) __sync_fetch_and_and (&sc, 1); // CHECK: atomicrmw and i8
   (void) __sync_fetch_and_and (&uc, 1); // CHECK: atomicrmw and i8
   (void) __sync_fetch_and_and (&ss, 1); // CHECK: atomicrmw and i16
@@ -98,6 +107,15 @@
   sll = __sync_fetch_and_xor (&sll, 11); // CHECK: atomicrmw xor
   ull = __sync_fetch_and_xor (&ull, 11); // CHECK: atomicrmw xor
 
+  sc = __sync_fetch_and_nand (&sc, 11); // CHECK: atomicrmw nand
+  uc = __sync_fetch_and_nand (&uc, 11); // CHECK: atomicrmw nand
+  ss = __sync_fetch_and_nand (&ss, 11); // CHECK: atomicrmw nand
+  us = __sync_fetch_and_nand (&us, 11); // CHECK: atomicrmw nand
+  si = __sync_fetch_and_nand (&si, 11); // CHECK: atomicrmw nand
+  ui = __sync_fetch_and_nand (&ui, 11); // CHECK: atomicrmw nand
+  sll = __sync_fetch_and_nand (&sll, 11); // CHECK: atomicrmw nand
+  ull = __sync_fetch_and_nand (&ull, 11); // CHECK: atomicrmw nand
+
   sc = __sync_fetch_and_and (&sc, 11); // CHECK: atomicrmw and
   uc = __sync_fetch_and_and (&uc, 11); // CHECK: atomicrmw and
   ss = __sync_fetch_and_and (&ss, 11); // CHECK: atomicrmw and
@@ -147,6 +165,31 @@
   sll = __sync_xor_and_fetch (&sll, uc); // CHECK: atomicrmw xor
   ull = __sync_xor_and_fetch (&ull, uc); // CHECK: atomicrmw xor
 
+  sc = __sync_nand_and_fetch (&sc, uc); // CHECK: atomicrmw nand
+                                        // CHECK: and
+                                        // CHECK: xor
+  uc = __sync_nand_and_fetch (&uc, uc); // CHECK: atomicrmw nand
+                                        // CHECK: and
+                                        // CHECK: xor
+  ss = __sync_nand_and_fetch (&ss, uc); // CHECK: atomicrmw nand
+                                        // CHECK: and
+                                        // CHECK: xor
+  us = __sync_nand_and_fetch (&us, uc); // CHECK: atomicrmw nand
+                                        // CHECK: and
+                                        // CHECK: xor
+  si = __sync_nand_and_fetch (&si, uc); // CHECK: atomicrmw nand
+                                        // CHECK: and
+                                        // CHECK: xor
+  ui = __sync_nand_and_fetch (&ui, uc); // CHECK: atomicrmw nand
+                                        // CHECK: and
+                                        // CHECK: xor
+  sll = __sync_nand_and_fetch (&sll, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+  ull = __sync_nand_and_fetch (&ull, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+
   sc = __sync_and_and_fetch (&sc, uc); // CHECK: atomicrmw and
   uc = __sync_and_and_fetch (&uc, uc); // CHECK: atomicrmw and
   ss = __sync_and_and_fetch (&ss, uc); // CHECK: atomicrmw and
diff --git a/test/CodeGen/aarch64-poly64.c b/test/CodeGen/aarch64-poly64.c
index 290cc69..a14162c 100644
--- a/test/CodeGen/aarch64-poly64.c
+++ b/test/CodeGen/aarch64-poly64.c
@@ -102,6 +102,18 @@
   // CHECK: dup {{v[0-9]+}}.2d, {{x[0-9]+}}
 }
 
+poly64x1_t test_vmov_n_p64(poly64_t a) {
+  // CHECK-LABEL: test_vmov_n_p64
+  return vmov_n_p64(a);
+  // CHECK: fmov {{d[0-9]+}}, {{x[0-9]+}}
+}
+
+poly64x2_t test_vmovq_n_p64(poly64_t a) {
+  // CHECK-LABEL: test_vmovq_n_p64
+  return vmovq_n_p64(a);
+  // CHECK: dup {{v[0-9]+}}.2d, {{x[0-9]+}}
+}
+
 poly64x1_t test_vdup_lane_p64(poly64x1_t vec) {
   // CHECK-LABEL: test_vdup_lane_p64
   return vdup_lane_p64(vec, 0);
diff --git a/test/CodeGen/aarch64-type-sizes.c b/test/CodeGen/aarch64-type-sizes.c
index b331b6c..3ff8c4f 100644
--- a/test/CodeGen/aarch64-type-sizes.c
+++ b/test/CodeGen/aarch64-type-sizes.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64_be-none-linux-gnu -emit-llvm -w -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
 // char by definition has size 1
 
 // CHECK-LE: target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
diff --git a/test/CodeGen/aarch64-varargs.c b/test/CodeGen/aarch64-varargs.c
index f787afe..248f1c1 100644
--- a/test/CodeGen/aarch64-varargs.c
+++ b/test/CodeGen/aarch64-varargs.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-linux-gnu -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-LE %s
-// RUN: %clang_cc1 -triple arm64_be-linux-gnu -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
+// RUN: %clang_cc1 -triple aarch64_be-linux-gnu -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
 
 #include <stdarg.h>
 
diff --git a/test/CodeGen/adc-builtins.c b/test/CodeGen/adc-builtins.c
new file mode 100644
index 0000000..5577d22
--- /dev/null
+++ b/test/CodeGen/adc-builtins.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffreestanding -emit-llvm -o - %s | FileCheck %s
+
+#include <x86intrin.h>
+
+unsigned char test_addcarry_u32(unsigned char __cf, unsigned int __x,
+                                unsigned int __y, unsigned int *__p) {
+// CHECK-LABEL: test_addcarry_u32
+// CHECK: call i8 @llvm.x86.addcarry.u32
+  return _addcarry_u32(__cf, __x, __y, __p);
+}
+
+unsigned char test_addcarry_u64(unsigned char __cf, unsigned long long __x,
+                                unsigned long long __y,
+                                unsigned long long *__p) {
+// CHECK-LABEL: test_addcarry_u64
+// CHECK: call i8 @llvm.x86.addcarry.u64
+  return _addcarry_u64(__cf, __x, __y, __p);
+}
+
+unsigned char test_subborrow_u32(unsigned char __cf, unsigned int __x,
+                                 unsigned int __y, unsigned int *__p) {
+// CHECK-LABEL: test_subborrow_u32
+// CHECK: call i8 @llvm.x86.subborrow.u32
+  return _subborrow_u32(__cf, __x, __y, __p);
+}
+
+unsigned char test_subborrow_u64(unsigned char __cf, unsigned long long __x,
+                                 unsigned long long __y,
+                                 unsigned long long *__p) {
+// CHECK-LABEL: test_subborrow_u64
+// CHECK: call i8 @llvm.x86.subborrow.u64
+  return _subborrow_u64(__cf, __x, __y, __p);
+}
diff --git a/test/CodeGen/address-safety-attr.cpp b/test/CodeGen/address-safety-attr.cpp
index f94efd6..031d013 100644
--- a/test/CodeGen/address-safety-attr.cpp
+++ b/test/CodeGen/address-safety-attr.cpp
@@ -1,9 +1,16 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=address | FileCheck -check-prefix=ASAN %s
-// RUN: echo "src:%s" > %t.file.blacklist
+int DefinedInDifferentFile(int *a);
+// RUN: echo "int DefinedInDifferentFile(int *a) { return *a; }" > %t.extra-source.cpp
+// RUN: echo "struct S { S(){} ~S(){} };" >> %t.extra-source.cpp
+// RUN: echo "S glob_array[5];" >> %t.extra-source.cpp
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -include %t.extra-source.cpp | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -include %t.extra-source.cpp -fsanitize=address | FileCheck -check-prefix=ASAN %s
+
 // RUN: echo "fun:*BlacklistedFunction*" > %t.func.blacklist
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=address -fsanitize-blacklist=%t.file.blacklist | FileCheck -check-prefix=BLFILE %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=address -fsanitize-blacklist=%t.func.blacklist | FileCheck -check-prefix=BLFUNC %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -include %t.extra-source.cpp -fsanitize=address -fsanitize-blacklist=%t.func.blacklist | FileCheck -check-prefix=BLFUNC %s
+
+// RUN: echo "src:%s" > %t.file.blacklist
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -include %t.extra-source.cpp -fsanitize=address -fsanitize-blacklist=%t.file.blacklist | FileCheck -check-prefix=BLFILE %s
 
 // FIXME: %t.file.blacklist is like "src:x:\path\to\clang\test\CodeGen\address-safety-attr.cpp"
 // REQUIRES: shell
@@ -12,7 +19,25 @@
 // when AddressSanitizer is enabled, unless no_sanitize_address attribute
 // is present.
 
-// WITHOUT:  NoAddressSafety1{{.*}}) [[NOATTR:#[0-9]+]]
+// Attributes for function defined in different source file:
+// WITHOUT: DefinedInDifferentFile{{.*}} [[NOATTR:#[0-9]+]]
+// BLFILE:  DefinedInDifferentFile{{.*}} [[WITH:#[0-9]+]]
+// BLFUNC:  DefinedInDifferentFile{{.*}} [[WITH:#[0-9]+]]
+// ASAN:    DefinedInDifferentFile{{.*}} [[WITH:#[0-9]+]]
+
+// Check that functions generated for global in different source file are
+// not blacklisted.
+// WITHOUT: @__cxx_global_var_init{{.*}}[[NOATTR_NO_TF:#[0-9]+]]
+// WITHOUT: @__cxx_global_array_dtor{{.*}}[[NOATTR_NO_TF]]
+// BLFILE: @__cxx_global_var_init{{.*}}[[WITH_NO_TF:#[0-9]+]]
+// BLFILE: @__cxx_global_array_dtor{{.*}}[[WITH_NO_TF]]
+// BLFUNC: @__cxx_global_var_init{{.*}}[[WITH_NO_TF:#[0-9]+]]
+// BLFUNC: @__cxx_global_array_dtor{{.*}}[[WITH_NO_TF]]
+// ASAN: @__cxx_global_var_init{{.*}}[[WITH_NO_TF:#[0-9]+]]
+// ASAN: @__cxx_global_array_dtor{{.*}}[[WITH_NO_TF]]
+
+
+// WITHOUT:  NoAddressSafety1{{.*}}) [[NOATTR]]
 // BLFILE:  NoAddressSafety1{{.*}}) [[NOATTR:#[0-9]+]]
 // BLFUNC:  NoAddressSafety1{{.*}}) [[NOATTR:#[0-9]+]]
 // ASAN:  NoAddressSafety1{{.*}}) [[NOATTR:#[0-9]+]]
@@ -29,8 +54,8 @@
 
 // WITHOUT:  AddressSafetyOk{{.*}}) [[NOATTR]]
 // BLFILE:  AddressSafetyOk{{.*}}) [[NOATTR]]
-// BLFUNC: AddressSafetyOk{{.*}}) [[WITH:#[0-9]+]]
-// ASAN: AddressSafetyOk{{.*}}) [[WITH:#[0-9]+]]
+// BLFUNC: AddressSafetyOk{{.*}}) [[WITH]]
+// ASAN: AddressSafetyOk{{.*}}) [[WITH]]
 int AddressSafetyOk(int *a) { return *a; }
 
 // WITHOUT:  BlacklistedFunction{{.*}}) [[NOATTR]]
@@ -39,6 +64,21 @@
 // ASAN:  BlacklistedFunction{{.*}}) [[WITH]]
 int BlacklistedFunction(int *a) { return *a; }
 
+#define GENERATE_FUNC(name) \
+    int name(int *a) { return *a; }
+// WITHOUT: GeneratedFunction{{.*}}) [[NOATTR]]
+// BLFILE:  GeneratedFunction{{.*}}) [[NOATTR]]
+// BLFUNC:  GeneratedFunction{{.*}}) [[WITH]]
+// ASAN:    GeneratedFunction{{.*}}) [[WITH]]
+GENERATE_FUNC(GeneratedFunction)
+
+#define GENERATE_NAME(name) name##_generated
+// WITHOUT: Function_generated{{.*}}) [[NOATTR]]
+// BLFILE:  Function_generated{{.*}}) [[NOATTR]]
+// BLFUNC:  Function_generated{{.*}}) [[WITH]]
+// ASAN:    Function_generated{{.*}}) [[WITH]]
+int GENERATE_NAME(Function)(int *a) { return *a; }
+
 // WITHOUT:  TemplateAddressSafetyOk{{.*}}) [[NOATTR]]
 // BLFILE:  TemplateAddressSafetyOk{{.*}}) [[NOATTR]]
 // BLFUNC:  TemplateAddressSafetyOk{{.*}}) [[WITH]]
@@ -60,21 +100,23 @@
 // Check that __cxx_global_var_init* get the sanitize_address attribute.
 int global1 = 0;
 int global2 = *(int*)((char*)&global1+1);
-// WITHOUT: @__cxx_global_var_init{{.*}}[[NOATTR_NO_TF:#[0-9]+]]
+// WITHOUT: @__cxx_global_var_init{{.*}}[[NOATTR_NO_TF]]
 // BLFILE: @__cxx_global_var_init{{.*}}[[NOATTR_NO_TF:#[0-9]+]]
-// BLFUNC: @__cxx_global_var_init{{.*}}[[WITH_NO_TF:#[0-9]+]]
-// ASAN: @__cxx_global_var_init{{.*}}[[WITH_NO_TF:#[0-9]+]]
+// BLFUNC: @__cxx_global_var_init{{.*}}[[WITH_NO_TF]]
+// ASAN: @__cxx_global_var_init{{.*}}[[WITH_NO_TF]]
 
 // WITHOUT: attributes [[NOATTR]] = { nounwind{{.*}} }
 // WITHOUT: attributes [[NOATTR_NO_TF]] = { nounwind }
 
-// BLFILE: attributes [[NOATTR]] = { nounwind{{.*}} }
+// BLFILE: attributes [[WITH]] = { nounwind sanitize_address{{.*}} }
+// BLFILE: attributes [[WITH_NO_TF]] = { nounwind sanitize_address }
 // BLFILE: attributes [[NOATTR_NO_TF]] = { nounwind }
+// BLFILE: attributes [[NOATTR]] = { nounwind{{.*}} }
 
-// BLFUNC: attributes [[NOATTR]] = { nounwind{{.*}} }
 // BLFUNC: attributes [[WITH]] = { nounwind sanitize_address{{.*}} }
 // BLFUNC: attributes [[WITH_NO_TF]] = { nounwind sanitize_address }
+// BLFUNC: attributes [[NOATTR]] = { nounwind{{.*}} }
 
-// ASAN: attributes [[NOATTR]] = { nounwind{{.*}} }
 // ASAN: attributes [[WITH]] = { nounwind sanitize_address{{.*}} }
 // ASAN: attributes [[WITH_NO_TF]] = { nounwind sanitize_address }
+// ASAN: attributes [[NOATTR]] = { nounwind{{.*}} }
diff --git a/test/CodeGen/address-sanitizer-and-array-cookie.cpp b/test/CodeGen/address-sanitizer-and-array-cookie.cpp
new file mode 100644
index 0000000..ea89537
--- /dev/null
+++ b/test/CodeGen/address-sanitizer-and-array-cookie.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address %s | FileCheck %s -check-prefix=ASAN
+
+typedef __typeof__(sizeof(0)) size_t;
+namespace std {
+  struct nothrow_t {};
+  std::nothrow_t nothrow;
+}
+void *operator new[](size_t, const std::nothrow_t &) throw();
+void *operator new[](size_t, char *);
+
+struct C {
+  int x;
+  ~C();
+};
+
+C *CallNew() {
+  return new C[10];
+}
+// PLAIN-LABEL: CallNew
+// PLAIN-NOT: nosanitize
+// PLAIN-NOT: __asan_poison_cxx_array_cookie
+// ASAN-LABEL: CallNew
+// ASAN: store{{.*}}nosanitize
+// ASAN-NOT: nosanitize
+// ASAN: call void @__asan_poison_cxx_array_cookie
+
+C *CallNewNoThrow() {
+  return new (std::nothrow) C[10];
+}
+// PLAIN-LABEL: CallNewNoThrow
+// PLAIN-NOT: nosanitize
+// PLAIN-NOT: __asan_poison_cxx_array_cookie
+// ASAN-LABEL: CallNewNoThrow
+// ASAN: store{{.*}}nosanitize
+// ASAN-NOT: nosanitize
+// ASAN: call void @__asan_poison_cxx_array_cookie
+
+void CallDelete(C *c) {
+  delete [] c;
+}
+
+// PLAIN-LABEL: CallDelete
+// PLAIN-NOT: nosanitize
+// ASAN-LABEL: CallDelete
+// ASAN-NOT: nosanitize
+// ASAN: call i64 @__asan_load_cxx_array_cookie
+// ASAN-NOT: nosanitize
+
+char Buffer[20];
+C *CallPlacementNew() {
+  return new (Buffer) C[20];
+}
+// ASAN-LABEL: CallPlacementNew
+// ASAN-NOT: __asan_poison_cxx_array_cookie
diff --git a/test/CodeGen/adx-builtins.c b/test/CodeGen/adx-builtins.c
new file mode 100644
index 0000000..8738c5d
--- /dev/null
+++ b/test/CodeGen/adx-builtins.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffreestanding -target-feature +adx -emit-llvm -o - %s | FileCheck %s
+
+#include <x86intrin.h>
+
+unsigned char test_addcarryx_u32(unsigned char __cf, unsigned int __x,
+                                 unsigned int __y, unsigned int *__p) {
+// CHECK-LABEL: test_addcarryx_u32
+// CHECK: call i8 @llvm.x86.addcarryx.u32
+  return _addcarryx_u32(__cf, __x, __y, __p);
+}
+
+unsigned char test_addcarryx_u64(unsigned char __cf, unsigned long long __x,
+                                 unsigned long long __y,
+                                 unsigned long long *__p) {
+// CHECK-LABEL: test_addcarryx_u64
+// CHECK: call i8 @llvm.x86.addcarryx.u64
+  return _addcarryx_u64(__cf, __x, __y, __p);
+}
diff --git a/test/CodeGen/alias.c b/test/CodeGen/alias.c
index 98449d3..b773cc8 100644
--- a/test/CodeGen/alias.c
+++ b/test/CodeGen/alias.c
@@ -3,6 +3,8 @@
 
 int g0;
 // CHECKBASIC: @g0 = common global i32 0
+__thread int TL_WITH_ALIAS;
+// CHECKBASIC-DAG: @TL_WITH_ALIAS = thread_local global i32 0, align 4
 static int bar1 = 42;
 // CHECKBASIC: @bar1 = internal global i32 42
 
@@ -10,11 +12,14 @@
 extern int g1 __attribute((alias("g0")));
 // CHECKBASIC-DAG: @g1 = alias i32* @g0
 
+extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
+// CHECKBASIC-DAG: @__libc_errno = thread_local alias i32* @TL_WITH_ALIAS
+
 void f0(void) { }
 extern void f1(void);
 extern void f1(void) __attribute((alias("f0")));
 // CHECKBASIC-DAG: @f1 = alias void ()* @f0
-// CHECKBASIC-DAG: @test8_foo = alias weak bitcast (void ()* @test8_bar to void (...)*)
+// CHECKBASIC-DAG: @test8_foo = weak alias bitcast (void ()* @test8_bar to void (...)*)
 // CHECKBASIC-DAG: @test8_zed = alias bitcast (void ()* @test8_bar to void (...)*)
 // CHECKBASIC-DAG: @test9_zed = alias void ()* @test9_bar
 // CHECKBASIC: define void @f0() [[NUW:#[0-9]+]] {
diff --git a/test/CodeGen/align_value.cpp b/test/CodeGen/align_value.cpp
new file mode 100644
index 0000000..6d0e481
--- /dev/null
+++ b/test/CodeGen/align_value.cpp
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+typedef double * __attribute__((align_value(64))) aligned_double;
+
+void foo(aligned_double x, double * y __attribute__((align_value(32))),
+         double & z __attribute__((align_value(128)))) { };
+// CHECK: define void @_Z3fooPdS_Rd(double* align 64 %x, double* align 32 %y, double* dereferenceable(8) align 128 %z)
+
+struct ad_struct {
+  aligned_double a;
+};
+
+double *foo(ad_struct& x) {
+// CHECK-LABEL: @_Z3fooR9ad_struct
+
+// CHECK: [[PTRINT1:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63
+// CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND1]])
+  return x.a;
+}
+
+double *goo(ad_struct *x) {
+// CHECK-LABEL: @_Z3gooP9ad_struct
+
+// CHECK: [[PTRINT2:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], 63
+// CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND2]])
+  return x->a;
+}
+
+double *bar(aligned_double *x) {
+// CHECK-LABEL: @_Z3barPPd
+
+// CHECK: [[PTRINT3:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR3:%.+]] = and i64 [[PTRINT3]], 63
+// CHECK: [[MASKCOND3:%.+]] = icmp eq i64 [[MASKEDPTR3]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND3]])
+  return *x;
+}
+
+double *car(aligned_double &x) {
+// CHECK-LABEL: @_Z3carRPd
+
+// CHECK: [[PTRINT4:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR4:%.+]] = and i64 [[PTRINT4]], 63
+// CHECK: [[MASKCOND4:%.+]] = icmp eq i64 [[MASKEDPTR4]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND4]])
+  return x;
+}
+
+double *dar(aligned_double *x) {
+// CHECK-LABEL: @_Z3darPPd
+
+// CHECK: [[PTRINT5:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR5:%.+]] = and i64 [[PTRINT5]], 63
+// CHECK: [[MASKCOND5:%.+]] = icmp eq i64 [[MASKEDPTR5]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND5]])
+  return x[5];
+}
+
+aligned_double eep();
+double *ret() {
+// CHECK-LABEL: @_Z3retv
+
+// CHECK: [[PTRINT6:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR6:%.+]] = and i64 [[PTRINT6]], 63
+// CHECK: [[MASKCOND6:%.+]] = icmp eq i64 [[MASKEDPTR6]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND6]])
+  return eep();
+}
+
+double **no1(aligned_double *x) {
+// CHECK-LABEL: @_Z3no1PPd
+  return x;
+// CHECK-NOT: call void @llvm.assume
+}
+
+double *&no2(aligned_double &x) {
+// CHECK-LABEL: @_Z3no2RPd
+  return x;
+// CHECK-NOT: call void @llvm.assume
+}
+
+double **no3(aligned_double &x) {
+// CHECK-LABEL: @_Z3no3RPd
+  return &x;
+// CHECK-NOT: call void @llvm.assume
+}
+
+double no3(aligned_double x) {
+// CHECK-LABEL: @_Z3no3Pd
+  return *x;
+// CHECK-NOT: call void @llvm.assume
+}
+
+double *no4(aligned_double x) {
+// CHECK-LABEL: @_Z3no4Pd
+  return x;
+// CHECK-NOT: call void @llvm.assume
+}
+
diff --git a/test/CodeGen/arm-aapcs-vfp.c b/test/CodeGen/arm-aapcs-vfp.c
index 7bc1b1e..da1e675 100644
--- a/test/CodeGen/arm-aapcs-vfp.c
+++ b/test/CodeGen/arm-aapcs-vfp.c
@@ -1,4 +1,5 @@
 // REQUIRES: arm-registered-target
+// REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \
 // RUN:   -target-abi aapcs \
 // RUN:   -target-cpu cortex-a8 \
@@ -72,7 +73,7 @@
   float f3;
   float f4;
 };
-// CHECK: define arm_aapcs_vfpcc void @test_big({ [5 x i32] } %{{.*}})
+// CHECK: define arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
 // CHECK64: define void @test_big(%struct.big_struct* %{{.*}})
 // CHECK64: call void @llvm.memcpy
 // CHECK64: call void @big_callee(%struct.big_struct*
@@ -88,7 +89,7 @@
   float f1;
   int i2;
 };
-// CHECK: define arm_aapcs_vfpcc void @test_hetero({ [2 x i32] } %{{.*}})
+// CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
 // CHECK64: define void @test_hetero(i64 %{{.*}})
 extern void hetero_callee(struct heterogeneous_struct);
 void test_hetero(struct heterogeneous_struct arg) {
@@ -125,23 +126,28 @@
 // CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_1(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, i64 %k, i32 %l)
 void test_vfp_stack_gpr_split_1(double a, double b, double c, double d, double e, double f, double g, double h, double i, int j, long long k, int l) {}
 
-// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_2(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, [3 x i32], { [2 x i64] } %k.coerce)
+// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_2(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, [3 x i32], [2 x i64] %k.coerce)
 void test_vfp_stack_gpr_split_2(double a, double b, double c, double d, double e, double f, double g, double h, double i, int j, struct_long_long_int k) {}
 
-// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_3(%struct.struct_long_long_int* noalias sret %agg.result, double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, [3 x i32], { [2 x i64] } %k.coerce)
+// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_3(%struct.struct_long_long_int* noalias sret %agg.result, double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, [3 x i32], [2 x i64] %k.coerce)
 struct_long_long_int test_vfp_stack_gpr_split_3(double a, double b, double c, double d, double e, double f, double g, double h, double i, struct_long_long_int k) {}
 
 typedef struct { int a; int b:4; int c; } struct_int_bitfield_int;
-// CHECK: define arm_aapcs_vfpcc void @test_test_vfp_stack_gpr_split_bitfield(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, i32 %k, [2 x i32], { [3 x i32] } %l.coerce)
+// CHECK: define arm_aapcs_vfpcc void @test_test_vfp_stack_gpr_split_bitfield(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, i32 %k, [2 x i32], [3 x i32] %l.coerce)
 void test_test_vfp_stack_gpr_split_bitfield(double a, double b, double c, double d, double e, double f, double g, double h, double i, int j, int k, struct_int_bitfield_int l) {}
 
 // Note: this struct requires internal padding
 typedef struct { int x; long long y; } struct_int_long_long;
-// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_4(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, [3 x i32], { [2 x i64] } %k.coerce)
+// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_4(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, [3 x i32], [2 x i64] %k.coerce)
 void test_vfp_stack_gpr_split_4(double a, double b, double c, double d, double e, double f, double g, double h, double i, int j, struct_int_long_long k) {}
 
 // This very large struct (passed byval) uses up the GPRs, so no padding is needed
 typedef struct { int x[17]; } struct_seventeen_ints;
 typedef struct { int x[4]; } struct_four_ints;
-// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_5(%struct.struct_seventeen_ints* byval align 4 %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, double %j, { [4 x i32] } %k.coerce)
+// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_5(%struct.struct_seventeen_ints* byval align 4 %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, double %j, [4 x i32] %k.coerce)
 void test_vfp_stack_gpr_split_5(struct_seventeen_ints a, double b, double c, double d, double e, double f, double g, double h, double i, double j, struct_four_ints k) {}
+
+// Here, parameter k would need padding to prevent it from being split, but it
+// is passed ByVal (due to being > 64 bytes), so the backend handles this instead.
+void test_vfp_stack_gpr_split_6(double a, double b, double c, double d, double e, double f, double g, double h, double i, int j, struct_seventeen_ints k) {}
+// CHECK: define arm_aapcs_vfpcc void @test_vfp_stack_gpr_split_6(double %a, double %b, double %c, double %d, double %e, double %f, double %g, double %h, double %i, i32 %j, %struct.struct_seventeen_ints* byval align 4 %k)
diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c
index 2c5df91..e4a10fd 100644
--- a/test/CodeGen/arm-arguments.c
+++ b/test/CodeGen/arm-arguments.c
@@ -183,14 +183,9 @@
 struct s34 { char c; };
 void f34(struct s34 s);
 void g34(struct s34 *s) { f34(*s); }
-// APCS-GNU: @g34(%struct.s34* %s)
-// APCS-GNU: %[[a:.*]] = alloca { [1 x i32] }
-// APCS-GNU: %[[gep:.*]] = getelementptr { [1 x i32] }* %[[a]], i32 0, i32 0
-// APCS-GNU: load [1 x i32]* %[[gep]]
 // AAPCS: @g34(%struct.s34* %s)
-// AAPCS: %[[a:.*]] = alloca { [1 x i32] }
-// AAPCS: %[[gep:.*]] = getelementptr { [1 x i32] }* %[[a]], i32 0, i32 0
-// AAPCS: load [1 x i32]* %[[gep]]
+// AAPCS: %[[a:.*]] = alloca [1 x i32]
+// AAPCS: load [1 x i32]* %[[a]]
 
 // rdar://12596507
 struct s35
diff --git a/test/CodeGen/arm-homogenous.c b/test/CodeGen/arm-homogenous.c
index d1b4897..2ab6c10 100644
--- a/test/CodeGen/arm-homogenous.c
+++ b/test/CodeGen/arm-homogenous.c
@@ -22,7 +22,7 @@
 void test_union_with_first_floats(void) {
   takes_union_with_first_floats(g_u_f);
 }
-// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats({ [4 x i32] })
+// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats([4 x i32])
 
 void test_return_union_with_first_floats(void) {
   g_u_f = returns_union_with_first_floats();
@@ -42,7 +42,7 @@
 void test_union_with_non_first_floats(void) {
   takes_union_with_non_first_floats(g_u_nf_f);
 }
-// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats({ [4 x i32] })
+// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats([4 x i32])
 
 void test_return_union_with_non_first_floats(void) {
   g_u_nf_f = returns_union_with_non_first_floats();
@@ -62,7 +62,7 @@
 void test_struct_with_union_with_first_floats(void) {
   takes_struct_with_union_with_first_floats(g_s_f);
 }
-// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats({ [5 x i32] })
+// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats([5 x i32])
 
 void test_return_struct_with_union_with_first_floats(void) {
   g_s_f = returns_struct_with_union_with_first_floats();
@@ -82,7 +82,7 @@
 void test_struct_with_union_with_non_first_floats(void) {
   takes_struct_with_union_with_non_first_floats(g_s_nf_f);
 }
-// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats({ [5 x i32] })
+// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats([5 x i32])
 
 void test_return_struct_with_union_with_non_first_floats(void) {
   g_s_nf_f = returns_struct_with_union_with_non_first_floats();
@@ -186,7 +186,7 @@
 
 void test_struct_of_four_doubles_variadic(void) {
 // CHECK: test_struct_of_four_doubles_variadic
-// CHECK: call arm_aapcs_vfpcc void (double, { [4 x i64] }, { [4 x i64] }, double, ...)* @takes_struct_of_four_doubles_variadic(double {{.*}}, { [4 x i64] } {{.*}}, { [4 x i64] } {{.*}}, double {{.*}})
+// CHECK: call arm_aapcs_vfpcc void (double, [4 x i64], [4 x i64], double, ...)* @takes_struct_of_four_doubles_variadic(double {{.*}}, [4 x i64] {{.*}}, [4 x i64] {{.*}}, double {{.*}})
   takes_struct_of_four_doubles_variadic(3.0, g_s4d, g_s4d, 4.0);
 }
 
diff --git a/test/CodeGen/arm-neon-directed-rounding.c b/test/CodeGen/arm-neon-directed-rounding.c
new file mode 100644
index 0000000..8402931
--- /dev/null
+++ b/test/CodeGen/arm-neon-directed-rounding.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -O1 -emit-llvm %s -o - | FileCheck %s
+
+#include <arm_neon.h>
+
+float32x2_t test_vrnda_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrnda_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vrinta.v2f32(<2 x float> %a)
+  return vrnda_f32(a);
+}
+
+float32x4_t test_vrndaq_f32(float32x4_t a) {
+  // CHECK-LABEL: test_vrndaq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vrinta.v4f32(<4 x float> %a)
+  return vrndaq_f32(a);
+}
+
+float32x2_t test_vrndm_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndm_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vrintm.v2f32(<2 x float> %a)
+  return vrndm_f32(a);
+}
+
+float32x4_t test_vrndmq_f32(float32x4_t a) {
+  // CHECK-LABEL: test_vrndmq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vrintm.v4f32(<4 x float> %a)
+  return vrndmq_f32(a);
+}
+
+float32x2_t test_vrndn_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndn_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vrintn.v2f32(<2 x float> %a)
+  return vrndn_f32(a);
+}
+
+float32x4_t test_vrndnq_f32(float32x4_t a) {
+  // CHECK-LABEL: test_vrndnq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vrintn.v4f32(<4 x float> %a)
+  return vrndnq_f32(a);
+}
+
+float32x2_t test_vrndp_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndp_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vrintp.v2f32(<2 x float> %a)
+  return vrndp_f32(a);
+}
+
+float32x4_t test_vrndpq_f32(float32x4_t a) {
+  // CHECK-LABEL: test_vrndpq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vrintp.v4f32(<4 x float> %a)
+  return vrndpq_f32(a);
+}
+
+float32x2_t test_vrndx_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrndx_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vrintx.v2f32(<2 x float> %a)
+  return vrndx_f32(a);
+}
+
+float32x4_t test_vrndxq_f32(float32x4_t a) {
+  // CHECK-LABEL: test_vrndxq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vrintx.v4f32(<4 x float> %a)
+  return vrndxq_f32(a);
+}
+
+float32x2_t test_vrnd_f32(float32x2_t a) {
+  // CHECK-LABEL: test_vrnd_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vrintz.v2f32(<2 x float> %a)
+  return vrnd_f32(a);
+}
+
+float32x4_t test_vrndq_f32(float32x4_t a) {
+  // CHECK-LABEL: test_vrndq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vrintz.v4f32(<4 x float> %a)
+  return vrndq_f32(a);
+}
diff --git a/test/CodeGen/arm-neon-numeric-maxmin.c b/test/CodeGen/arm-neon-numeric-maxmin.c
new file mode 100644
index 0000000..615a854
--- /dev/null
+++ b/test/CodeGen/arm-neon-numeric-maxmin.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -O1 -emit-llvm %s -o - | FileCheck %s
+
+#include <arm_neon.h>
+
+float32x2_t test_vmaxnm_f32(float32x2_t a, float32x2_t b) {
+  // CHECK-LABEL: test_vmaxnm_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vmaxnm.v2f32(<2 x float> %a, <2 x float> %b)
+  return vmaxnm_f32(a, b);
+}
+
+float32x4_t test_vmaxnmq_f32(float32x4_t a, float32x4_t b) {
+  // CHECK-LABEL: test_vmaxnmq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vmaxnm.v4f32(<4 x float> %a, <4 x float> %b)
+  return vmaxnmq_f32(a, b);
+}
+
+float32x2_t test_vminnm_f32(float32x2_t a, float32x2_t b) {
+  // CHECK-LABEL: test_vminnm_f32
+  // CHECK: call <2 x float> @llvm.arm.neon.vminnm.v2f32(<2 x float> %a, <2 x float> %b)
+  return vminnm_f32(a, b);
+}
+
+float32x4_t test_vminnmq_f32(float32x4_t a, float32x4_t b) {
+  // CHECK-LABEL: test_vminnmq_f32
+  // CHECK: call <4 x float> @llvm.arm.neon.vminnm.v4f32(<4 x float> %a, <4 x float> %b)
+  return vminnmq_f32(a, b);
+}
diff --git a/test/CodeGen/arm64-aapcs-arguments.c b/test/CodeGen/arm64-aapcs-arguments.c
index b430630..38ac522 100644
--- a/test/CodeGen/arm64-aapcs-arguments.c
+++ b/test/CodeGen/arm64-aapcs-arguments.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -target-abi aapcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -target-abi aapcs -ffreestanding -fallow-half-arguments-and-returns -emit-llvm -w -o - %s | FileCheck %s
 
 // AAPCS clause C.8 says: If the argument has an alignment of 16 then the NGRN
 // is rounded up to the next even number.
@@ -40,3 +40,12 @@
 // CHECK: define i8 @test5(i8 %a, i16 %b)
 unsigned char test5(unsigned char a, signed short b) {
 }
+
+// __fp16 can be used as a function argument or return type (ACLE 2.0)
+// CHECK: define half @test_half(half %{{.*}})
+__fp16 test_half(__fp16 A) { }
+
+// __fp16 is a base type for homogeneous floating-point aggregates for AArch64 (but not 32-bit ARM).
+// CHECK: define %struct.HFA_half @test_half_hfa(half %{{.*}}, half %{{.*}}, half %{{.*}}, half %{{.*}})
+struct HFA_half { __fp16 a[4]; };
+struct HFA_half test_half_hfa(struct HFA_half A) { }
diff --git a/test/CodeGen/arm64-be-bitfield.c b/test/CodeGen/arm64-be-bitfield.c
index f563596..b8d497c 100644
--- a/test/CodeGen/arm64-be-bitfield.c
+++ b/test/CodeGen/arm64-be-bitfield.c
@@ -1,9 +1,15 @@
-// RUN:  %clang_cc1 -triple arm64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o - %s | FileCheck %s
+// REQUIRES: aarch64-registered-target
+// RUN:  %clang_cc1 -triple aarch64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o - %s | FileCheck --check-prefix IR %s
+// RUN:  %clang_cc1 -triple aarch64_be-linux-gnu -ffreestanding -S -O1 -o - %s | FileCheck --check-prefix ARM %s
 
 struct bt3 { signed b2:10; signed b3:10; } b16;
 
-// The correct right-shift amount is 40 bits for big endian.
+// Get the high 32-bits and then shift appropriately for big-endian.
 signed callee_b0f(struct bt3 bp11) {
-// CHECK: = lshr i64 %{{.*}}, 40
+// IR: callee_b0f(i64 [[ARG:%.*]])
+// IR: store i64 [[ARG]], i64* [[PTR:%.*]]
+// IR: [[BITCAST:%.*]] = bitcast i64* [[PTR]] to i8*
+// IR: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* [[BITCAST]], i64 4
+// ARM: asr x0, x0, #54
   return bp11.b2;
 }
diff --git a/test/CodeGen/arm64-be-hfa-vararg.c b/test/CodeGen/arm64-be-hfa-vararg.c
index c9d6507..537aab5 100644
--- a/test/CodeGen/arm64-be-hfa-vararg.c
+++ b/test/CodeGen/arm64-be-hfa-vararg.c
@@ -1,4 +1,4 @@
-// RUN:  %clang_cc1 -triple arm64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o - %s | FileCheck %s
+// RUN:  %clang_cc1 -triple aarch64_be-linux-gnu -ffreestanding -emit-llvm -O0 -o - %s | FileCheck %s
 
 #include <stdarg.h>
 
diff --git a/test/CodeGen/arm64-lanes.c b/test/CodeGen/arm64-lanes.c
index 8ab2bd4..4e80df9 100644
--- a/test/CodeGen/arm64-lanes.c
+++ b/test/CodeGen/arm64-lanes.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -O3 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -O3 -triple arm64_be-linux-gnu -target-feature +neon -ffreestanding -emit-llvm -o - %s | FileCheck %s --check-prefix CHECK-BE
+// RUN: %clang_cc1 -O3 -triple aarch64_be-linux-gnu -target-feature +neon -ffreestanding -emit-llvm -o - %s | FileCheck %s --check-prefix CHECK-BE
 
 #include <arm_neon.h>
 
diff --git a/test/CodeGen/arm_acle.c b/test/CodeGen/arm_acle.c
index 88d58a4..5b02450 100644
--- a/test/CodeGen/arm_acle.c
+++ b/test/CodeGen/arm_acle.c
@@ -1,26 +1,149 @@
-// RUN: %clang_cc1 -ffreestanding -triple armv8 -target-cpu cortex-a57 -O -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32
-// RUN: %clang_cc1 -ffreestanding -triple aarch64 -target-cpu cortex-a57 -O -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64
+// RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64
 
 #include <arm_acle.h>
 
-/* Miscellaneous data-processing intrinsics */
-// ARM-LABEL: test_rev
-// ARM: call i32 @llvm.bswap.i32(i32 %t)
-uint32_t test_rev(uint32_t t) {
-  return __rev(t);
+/* 8 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
+/* 8.3 Memory Barriers */
+// ARM-LABEL: test_dmb
+// AArch32: call void @llvm.arm.dmb(i32 1)
+// AArch64: call void @llvm.aarch64.dmb(i32 1)
+void test_dmb(void) {
+  __dmb(1);
 }
 
-// ARM-LABEL: test_revl
-// AArch32: call i32 @llvm.bswap.i32(i32 %t)
-// AArch64: call i64 @llvm.bswap.i64(i64 %t)
-long test_revl(long t) {
-  return __revl(t);
+// ARM-LABEL: test_dsb
+// AArch32: call void @llvm.arm.dsb(i32 2)
+// AArch64: call void @llvm.aarch64.dsb(i32 2)
+void test_dsb(void) {
+  __dsb(2);
 }
 
-// ARM-LABEL: test_revll
-// ARM: call i64 @llvm.bswap.i64(i64 %t)
-uint64_t test_revll(uint64_t t) {
-  return __revll(t);
+// ARM-LABEL: test_isb
+// AArch32: call void @llvm.arm.isb(i32 3)
+// AArch64: call void @llvm.aarch64.isb(i32 3)
+void test_isb(void) {
+  __isb(3);
+}
+
+/* 8.4 Hints */
+// ARM-LABEL: test_yield
+// AArch32: call void @llvm.arm.hint(i32 1)
+// AArch64: call void @llvm.aarch64.hint(i32 1)
+void test_yield(void) {
+  __yield();
+}
+
+// ARM-LABEL: test_wfe
+// AArch32: call void @llvm.arm.hint(i32 2)
+// AArch64: call void @llvm.aarch64.hint(i32 2)
+void test_wfe(void) {
+  __wfe();
+}
+
+// ARM-LABEL: test_wfi
+// AArch32: call void @llvm.arm.hint(i32 3)
+// AArch64: call void @llvm.aarch64.hint(i32 3)
+void test_wfi(void) {
+  __wfi();
+}
+
+// ARM-LABEL: test_sev
+// AArch32: call void @llvm.arm.hint(i32 4)
+// AArch64: call void @llvm.aarch64.hint(i32 4)
+void test_sev(void) {
+  __sev();
+}
+
+// ARM-LABEL: test_sevl
+// AArch32: call void @llvm.arm.hint(i32 5)
+// AArch64: call void @llvm.aarch64.hint(i32 5)
+void test_sevl(void) {
+  __sevl();
+}
+
+#if __ARM_32BIT_STATE
+// AArch32-LABEL: test_dbg
+// AArch32: call void @llvm.arm.dbg(i32 0)
+void test_dbg(void) {
+  __dbg(0);
+}
+#endif
+
+/* 8.5 Swap */
+// ARM-LABEL: test_swp
+// AArch32: call i32 @llvm.arm.ldrex
+// AArch32: call i32 @llvm.arm.strex
+// AArch64: call i64 @llvm.aarch64.ldxr
+// AArch64: call i32 @llvm.aarch64.stxr
+uint32_t test_swp(uint32_t x, volatile void *p) {
+  __swp(x, p);
+}
+
+/* 8.6 Memory prefetch intrinsics */
+/* 8.6.1 Data prefetch */
+// ARM-LABEL: test_pld
+// ARM: call void @llvm.prefetch(i8* null, i32 0, i32 3, i32 1)
+void test_pld() {
+  __pld(0);
+}
+
+// ARM-LABEL: test_pldx
+// AArch32: call void @llvm.prefetch(i8* null, i32 1, i32 3, i32 1)
+// AArch64: call void @llvm.prefetch(i8* null, i32 1, i32 1, i32 1)
+void test_pldx() {
+  __pldx(1, 2, 0, 0);
+}
+
+/* 8.6.2 Instruction prefetch */
+// ARM-LABEL: test_pli
+// ARM: call void @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
+void test_pli() {
+  __pli(0);
+}
+
+// ARM-LABEL: test_plix
+// AArch32: call void @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
+// AArch64: call void @llvm.prefetch(i8* null, i32 0, i32 1, i32 0)
+void test_plix() {
+  __plix(2, 0, 0);
+}
+
+/* 8.7 NOP */
+// ARM-LABEL: test_nop
+// AArch32: call void @llvm.arm.hint(i32 0)
+// AArch64: call void @llvm.aarch64.hint(i32 0)
+void test_nop(void) {
+  __nop();
+}
+
+/* 9 DATA-PROCESSING INTRINSICS */
+/* 9.2 Miscellaneous data-processing intrinsics */
+// ARM-LABEL: test_ror
+// ARM: lshr
+// ARM: sub
+// ARM: shl
+// ARM: or
+uint32_t test_ror(uint32_t x, uint32_t y) {
+  return __ror(x, y);
+}
+
+// ARM-LABEL: test_rorl
+// ARM: lshr
+// ARM: sub
+// ARM: shl
+// ARM: or
+unsigned long test_rorl(unsigned long x, uint32_t y) {
+  return __rorl(x, y);
+}
+
+// ARM-LABEL: test_rorll
+// ARM: lshr
+// ARM: sub
+// ARM: shl
+// ARM: or
+uint64_t test_rorll(uint64_t x, uint32_t y) {
+  return __rorll(x, y);
 }
 
 // ARM-LABEL: test_clz
@@ -42,8 +165,84 @@
   return __clzll(t);
 }
 
-/* Saturating intrinsics */
+// ARM-LABEL: test_rev
+// ARM: call i32 @llvm.bswap.i32(i32 %t)
+uint32_t test_rev(uint32_t t) {
+  return __rev(t);
+}
+
+// ARM-LABEL: test_revl
+// AArch32: call i32 @llvm.bswap.i32(i32 %t)
+// AArch64: call i64 @llvm.bswap.i64(i64 %t)
+long test_revl(long t) {
+  return __revl(t);
+}
+
+// ARM-LABEL: test_revll
+// ARM: call i64 @llvm.bswap.i64(i64 %t)
+uint64_t test_revll(uint64_t t) {
+  return __revll(t);
+}
+
+// ARM-LABEL: test_rev16
+// ARM: llvm.bswap
+// ARM: lshr
+// ARM: shl
+// ARM: or
+uint32_t test_rev16(uint32_t t) {
+  return __rev16(t);
+}
+
+// ARM-LABEL: test_rev16l
+// ARM: llvm.bswap
+// ARM: lshr
+// ARM: shl
+// ARM: or
+long test_rev16l(long t) {
+  return __rev16l(t);
+}
+
+// ARM-LABEL: test_rev16ll
+// ARM: llvm.bswap
+// ARM: lshr
+// ARM: shl
+// ARM: or
+uint64_t test_rev16ll(uint64_t t) {
+  return __rev16ll(t);
+}
+
+// ARM-LABEL: test_revsh
+// ARM: call i16 @llvm.bswap.i16(i16 %t)
+int16_t test_revsh(int16_t t) {
+  return __revsh(t);
+}
+
+// ARM-LABEL: test_rbit
+// AArch32: call i32 @llvm.arm.rbit
+// AArch64: call i32 @llvm.aarch64.rbit.i32
+uint32_t test_rbit(uint32_t t) {
+  return __rbit(t);
+}
+
+// ARM-LABEL: test_rbitl
+// AArch32: call i32 @llvm.arm.rbit
+// AArch64: call i64 @llvm.aarch64.rbit.i64
+long test_rbitl(long t) {
+  return __rbitl(t);
+}
+
+// ARM-LABEL: test_rbitll
+// AArch32: call i32 @llvm.arm.rbit
+// AArch32: call i32 @llvm.arm.rbit
+// AArch64: call i64 @llvm.aarch64.rbit.i64
+uint64_t test_rbitll(uint64_t t) {
+  return __rbitll(t);
+}
+
+/* 9.4 Saturating intrinsics */
 #ifdef __ARM_32BIT_STATE
+
+/* 9.4.1 Width-specified saturation intrinsics */
 // AArch32-LABEL: test_ssat
 // AArch32: call i32 @llvm.arm.ssat(i32 %t, i32 1)
 int32_t test_ssat(int32_t t) {
@@ -55,6 +254,8 @@
 int32_t test_usat(int32_t t) {
   return __usat(t, 2);
 }
+
+/* 9.4.2 Saturating addition and subtraction intrinsics */
 // AArch32-LABEL: test_qadd
 // AArch32: call i32 @llvm.arm.qadd(i32 %a, i32 %b)
 int32_t test_qadd(int32_t a, int32_t b) {
@@ -77,7 +278,7 @@
 }
 #endif
 
-/* CRC32 intrinsics */
+/* 9.7 CRC32 intrinsics */
 // ARM-LABEL: test_crc32b
 // AArch32: call i32 @llvm.arm.crc32b
 // AArch64: call i32 @llvm.aarch64.crc32b
diff --git a/test/CodeGen/arm_neon_intrinsics.c b/test/CodeGen/arm_neon_intrinsics.c
index a084d8b..756e3b4 100644
--- a/test/CodeGen/arm_neon_intrinsics.c
+++ b/test/CodeGen/arm_neon_intrinsics.c
@@ -1474,79 +1474,109 @@
 
 
 // CHECK-LABEL: test_vcombine_s8
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 int8x16_t test_vcombine_s8(int8x8_t a, int8x8_t b) {
   return vcombine_s8(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_s16
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 int16x8_t test_vcombine_s16(int16x4_t a, int16x4_t b) {
   return vcombine_s16(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_s32
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 int32x4_t test_vcombine_s32(int32x2_t a, int32x2_t b) {
   return vcombine_s32(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_s64
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 int64x2_t test_vcombine_s64(int64x1_t a, int64x1_t b) {
   return vcombine_s64(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_f16
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 float16x8_t test_vcombine_f16(float16x4_t a, float16x4_t b) {
   return vcombine_f16(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_f32
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 float32x4_t test_vcombine_f32(float32x2_t a, float32x2_t b) {
   return vcombine_f32(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_u8
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 uint8x16_t test_vcombine_u8(uint8x8_t a, uint8x8_t b) {
   return vcombine_u8(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_u16
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 uint16x8_t test_vcombine_u16(uint16x4_t a, uint16x4_t b) {
   return vcombine_u16(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_u32
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 uint32x4_t test_vcombine_u32(uint32x2_t a, uint32x2_t b) {
   return vcombine_u32(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_u64
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 uint64x2_t test_vcombine_u64(uint64x1_t a, uint64x1_t b) {
   return vcombine_u64(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_p8
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 poly8x16_t test_vcombine_p8(poly8x8_t a, poly8x8_t b) {
   return vcombine_p8(a, b);
 }
 
 // CHECK-LABEL: test_vcombine_p16
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
+// CHECK: vmov d{{[0-9]+}}, r{{[0-9]+}}, r{{[0-9]+}}
 poly16x8_t test_vcombine_p16(poly16x4_t a, poly16x4_t b) {
   return vcombine_p16(a, b);
 }
 
 
 // CHECK-LABEL: test_vcreate_s8
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vclz.i8 d{{[0-9]+}}, [[REG]]
 int8x8_t test_vcreate_s8(uint64_t a) {
-  return vcreate_s8(a);
+  return vclz_s8(vcreate_s8(a));
 }
 
 // CHECK-LABEL: test_vcreate_s16
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vclz.i16 d{{[0-9]+}}, [[REG]]
 int16x4_t test_vcreate_s16(uint64_t a) {
-  return vcreate_s16(a);
+  return vclz_s16(vcreate_s16(a));
 }
 
 // CHECK-LABEL: test_vcreate_s32
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vclz.i32 d{{[0-9]+}}, [[REG]]
 int32x2_t test_vcreate_s32(uint64_t a) {
-  return vcreate_s32(a);
+  return vclz_s32(vcreate_s32(a));
 }
 
 // CHECK-LABEL: test_vcreate_f16
@@ -1560,38 +1590,59 @@
 }
 
 // CHECK-LABEL: test_vcreate_u8
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vclz.i8 d{{[0-9]+}}, [[REG]]
 uint8x8_t test_vcreate_u8(uint64_t a) {
-  return vcreate_u8(a);
+  return vclz_s8(vcreate_u8(a));
 }
 
 // CHECK-LABEL: test_vcreate_u16
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vclz.i16 d{{[0-9]+}}, [[REG]]
 uint16x4_t test_vcreate_u16(uint64_t a) {
-  return vcreate_u16(a);
+  return vclz_s16(vcreate_u16(a));
 }
 
 // CHECK-LABEL: test_vcreate_u32
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vclz.i32 d{{[0-9]+}}, [[REG]]
 uint32x2_t test_vcreate_u32(uint64_t a) {
-  return vcreate_u32(a);
+  return vclz_s32(vcreate_u32(a));
 }
 
+
+// We have two ways of lowering that.  Either with one 'vmov d, r, r' or
+// with two 'vmov d[],r'.  LLVM does the latter. We may want to be less
+// strict about the matching pattern if it starts causing problem.
 // CHECK-LABEL: test_vcreate_u64
+// CHECK: vmov.32 [[REG:d[0-9]+]][0], r0
+// CHECK: vmov.32 [[REG]][1], r1
 uint64x1_t test_vcreate_u64(uint64_t a) {
-  return vcreate_u64(a);
+  uint64x1_t tmp = vcreate_u64(a);
+  return vadd_u64(tmp, tmp);
+
 }
 
 // CHECK-LABEL: test_vcreate_p8
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
+// CHECK: vcnt.8 d{{[0-9]+}}, [[REG]]
 poly8x8_t test_vcreate_p8(uint64_t a) {
-  return vcreate_p8(a);
+  return vcnt_p8(vcreate_p8(a));
 }
 
 // CHECK-LABEL: test_vcreate_p16
+// CHECK: vmov [[REG:d[0-9]+]], r0, r1
 poly16x4_t test_vcreate_p16(uint64_t a) {
-  return vcreate_p16(a);
+  poly16x4_t tmp = vcreate_p16(a);
+  return vbsl_p16(tmp, tmp, tmp);
 }
 
 // CHECK-LABEL: test_vcreate_s64
+// CHECK: vmov.32 [[REG:d[0-9]+]][0], r0
+// CHECK: vmov.32 [[REG]][1], r1
 int64x1_t test_vcreate_s64(uint64_t a) {
-  return vcreate_s64(a);
+  int64x1_t tmp = vcreate_s64(a);
+  return vadd_s64(tmp, tmp);
 }
 
 
@@ -1855,7 +1906,7 @@
 }
 
 // CHECK-LABEL: test_vdup_n_u32
-// CHECK: vmov 
+// CHECK: mov 
 uint32x2_t test_vdup_n_u32(uint32_t a) {
   return vdup_n_u32(a);
 }
@@ -1873,7 +1924,7 @@
 }
 
 // CHECK-LABEL: test_vdup_n_s32
-// CHECK: vmov 
+// CHECK: mov 
 int32x2_t test_vdup_n_s32(int32_t a) {
   return vdup_n_s32(a);
 }
@@ -1897,7 +1948,7 @@
 }
 
 // CHECK-LABEL: test_vdup_n_f32
-// CHECK: vmov 
+// CHECK: mov 
 float32x2_t test_vdup_n_f32(float32_t a) {
   return vdup_n_f32(a);
 }
@@ -1963,27 +2014,32 @@
 }
 
 // CHECK-LABEL: test_vdup_n_s64
-// CHECK: vmov 
+// CHECK: vmov
 int64x1_t test_vdup_n_s64(int64_t a) {
-  return vdup_n_s64(a);
+  int64x1_t tmp = vdup_n_s64(a);
+  return vadd_s64(tmp, tmp);
 }
 
 // CHECK-LABEL: test_vdup_n_u64
-// CHECK: vmov 
+// CHECK: vmov
 uint64x1_t test_vdup_n_u64(uint64_t a) {
-  return vdup_n_u64(a);
+  int64x1_t tmp = vdup_n_u64(a);
+  return vadd_s64(tmp, tmp);
+
 }
 
 // CHECK-LABEL: test_vdupq_n_s64
-// CHECK: vmov 
+// CHECK: vmov
 int64x2_t test_vdupq_n_s64(int64_t a) {
-  return vdupq_n_s64(a);
+  int64x2_t tmp = vdupq_n_s64(a);
+  return vaddq_s64(tmp, tmp);
 }
 
 // CHECK-LABEL: test_vdupq_n_u64
-// CHECK: vmov 
+// CHECK: vmov
 uint64x2_t test_vdupq_n_u64(uint64_t a) {
-  return vdupq_n_u64(a);
+  int64x2_t tmp = vdupq_n_u64(a);
+  return vaddq_u64(tmp, tmp);
 }
 
 
@@ -2302,7 +2358,7 @@
 }
 
 // CHECK-LABEL: test_vget_lane_u32
-// CHECK: vmov 
+// CHECK: mov 
 uint32_t test_vget_lane_u32(uint32x2_t a) {
   return vget_lane_u32(a, 1);
 }
@@ -2320,7 +2376,7 @@
 }
 
 // CHECK-LABEL: test_vget_lane_s32
-// CHECK: vmov 
+// CHECK: mov 
 int32_t test_vget_lane_s32(int32x2_t a) {
   return vget_lane_s32(a, 1);
 }
@@ -2398,13 +2454,13 @@
 }
 
 // CHECK-LABEL: test_vget_lane_s64
-// CHECK: vmov 
+// The optimizer is able to remove all moves now.
 int64_t test_vget_lane_s64(int64x1_t a) {
   return vget_lane_s64(a, 0);
 }
 
 // CHECK-LABEL: test_vget_lane_u64
-// CHECK: vmov 
+// The optimizer is able to remove all moves now.
 uint64_t test_vget_lane_u64(uint64x1_t a) {
   return vget_lane_u64(a, 0);
 }
@@ -4849,49 +4905,49 @@
 
 
 // CHECK-LABEL: test_vmov_n_u8
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 uint8x8_t test_vmov_n_u8(uint8_t a) {
   return vmov_n_u8(a);
 }
 
 // CHECK-LABEL: test_vmov_n_u16
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 uint16x4_t test_vmov_n_u16(uint16_t a) {
   return vmov_n_u16(a);
 }
 
 // CHECK-LABEL: test_vmov_n_u32
-// CHECK: vmov 
+// CHECK: mov {{r[0-9]+}}
 uint32x2_t test_vmov_n_u32(uint32_t a) {
   return vmov_n_u32(a);
 }
 
 // CHECK-LABEL: test_vmov_n_s8
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 int8x8_t test_vmov_n_s8(int8_t a) {
   return vmov_n_s8(a);
 }
 
 // CHECK-LABEL: test_vmov_n_s16
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 int16x4_t test_vmov_n_s16(int16_t a) {
   return vmov_n_s16(a);
 }
 
 // CHECK-LABEL: test_vmov_n_s32
-// CHECK: vmov 
+// CHECK: mov {{r[0-9]+}}
 int32x2_t test_vmov_n_s32(int32_t a) {
   return vmov_n_s32(a);
 }
 
 // CHECK-LABEL: test_vmov_n_p8
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 poly8x8_t test_vmov_n_p8(poly8_t a) {
   return vmov_n_p8(a);
 }
 
 // CHECK-LABEL: test_vmov_n_p16
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 poly16x4_t test_vmov_n_p16(poly16_t a) {
   return vmov_n_p16(a);
 }
@@ -4903,55 +4959,55 @@
 }
 
 // CHECK-LABEL: test_vmov_n_f32
-// CHECK: vmov 
+// CHECK: mov {{r[0-9]+}}
 float32x2_t test_vmov_n_f32(float32_t a) {
   return vmov_n_f32(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_u8
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 uint8x16_t test_vmovq_n_u8(uint8_t a) {
   return vmovq_n_u8(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_u16
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 uint16x8_t test_vmovq_n_u16(uint16_t a) {
   return vmovq_n_u16(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_u32
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 uint32x4_t test_vmovq_n_u32(uint32_t a) {
   return vmovq_n_u32(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_s8
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 int8x16_t test_vmovq_n_s8(int8_t a) {
   return vmovq_n_s8(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_s16
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 int16x8_t test_vmovq_n_s16(int16_t a) {
   return vmovq_n_s16(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_s32
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 int32x4_t test_vmovq_n_s32(int32_t a) {
   return vmovq_n_s32(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_p8
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 poly8x16_t test_vmovq_n_p8(poly8_t a) {
   return vmovq_n_p8(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_p16
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 poly16x8_t test_vmovq_n_p16(poly16_t a) {
   return vmovq_n_p16(a);
 }
@@ -4963,31 +5019,35 @@
 }
 
 // CHECK-LABEL: test_vmovq_n_f32
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 float32x4_t test_vmovq_n_f32(float32_t a) {
   return vmovq_n_f32(a);
 }
 
 // CHECK-LABEL: test_vmov_n_s64
-// CHECK: vmov 
+// CHECK: vmov.32 [[REG:d[0-9]+]][0], r0
+// CHECK: vmov.32 [[REG]][1], r1
 int64x1_t test_vmov_n_s64(int64_t a) {
-  return vmov_n_s64(a);
+  int64x1_t tmp = vmov_n_s64(a);
+  return vadd_s64(tmp, tmp);
 }
 
 // CHECK-LABEL: test_vmov_n_u64
-// CHECK: vmov 
+// CHECK: vmov.32 [[REG:d[0-9]+]][0], r0
+// CHECK: vmov.32 [[REG]][1], r1
 uint64x1_t test_vmov_n_u64(uint64_t a) {
-  return vmov_n_u64(a);
+  uint64x1_t tmp = vmov_n_u64(a);
+  return vadd_u64(tmp, tmp);
 }
 
 // CHECK-LABEL: test_vmovq_n_s64
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 int64x2_t test_vmovq_n_s64(int64_t a) {
   return vmovq_n_s64(a);
 }
 
 // CHECK-LABEL: test_vmovq_n_u64
-// CHECK: vmov 
+// CHECK: vmov {{r[0-9]+}}
 uint64x2_t test_vmovq_n_u64(uint64_t a) {
   return vmovq_n_u64(a);
 }
@@ -9056,7 +9116,7 @@
 }
 
 // CHECK-LABEL: test_vset_lane_u32
-// CHECK: vmov 
+// CHECK: mov 
 uint32x2_t test_vset_lane_u32(uint32_t a, uint32x2_t b) {
   return vset_lane_u32(a, b, 1);
 }
@@ -9074,7 +9134,7 @@
 }
 
 // CHECK-LABEL: test_vset_lane_s32
-// CHECK: vmov 
+// CHECK: mov 
 int32x2_t test_vset_lane_s32(int32_t a, int32x2_t b) {
   return vset_lane_s32(a, b, 1);
 }
@@ -9092,7 +9152,7 @@
 }
 
 // CHECK-LABEL: test_vset_lane_f32
-// CHECK: vmov 
+// CHECK: mov 
 float32x2_t test_vset_lane_f32(float32_t a, float32x2_t b) {
   return vset_lane_f32(a, b, 1);
 }
@@ -9152,13 +9212,13 @@
 }
 
 // CHECK-LABEL: test_vset_lane_s64
-// CHECK: vmov 
+// The optimizer is able to get rid of all moves now.
 int64x1_t test_vset_lane_s64(int64_t a, int64x1_t b) {
   return vset_lane_s64(a, b, 0);
 }
 
 // CHECK-LABEL: test_vset_lane_u64
-// CHECK: vmov 
+// The optimizer is able to get rid of all moves now.
 uint64x1_t test_vset_lane_u64(uint64_t a, uint64x1_t b) {
   return vset_lane_u64(a, b, 0);
 }
diff --git a/test/CodeGen/asan-globals.cpp b/test/CodeGen/asan-globals.cpp
index 2702f1d..4fae9a4 100644
--- a/test/CodeGen/asan-globals.cpp
+++ b/test/CodeGen/asan-globals.cpp
@@ -1,32 +1,37 @@
+// RUN: echo "int extra_global;" > %t.extra-source.cpp
 // RUN: echo "global:*blacklisted_global*" > %t.blacklist
-// RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t.blacklist -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address -fsanitize-blacklist=%t.blacklist -emit-llvm -o - %s | FileCheck %s
 // RUN: echo "src:%s" > %t.blacklist-src
-// RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t.blacklist-src -emit-llvm -o - %s | FileCheck %s --check-prefix=BLACKLIST-SRC
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=address -fsanitize-blacklist=%t.blacklist-src -emit-llvm -o - %s | FileCheck %s --check-prefix=BLACKLIST-SRC
 // REQUIRES: shell
 
 int global;
-// CHECK: [[GLOBAL_LOC:@.asan_loc_descr[0-9]*]] = private unnamed_addr constant {{.*}} i32 [[@LINE-1]], i32 5
 int dyn_init_global = global;
-// CHECK: [[DYN_INIT_LOC:@.asan_loc_descr[0-9]*]] = {{.*}} i32 [[@LINE-1]], i32 5
 int blacklisted_global;
 
 void func() {
   static int static_var = 0;
-  // CHECK: [[STATIC_LOC:@.asan_loc_descr[0-9]*]] = {{.*}} i32 [[@LINE-1]], i32 14
   const char *literal = "Hello, world!";
-  // CHECK: [[LITERAL_LOC:@.asan_loc_descr[0-9]*]] = {{.*}} i32 [[@LINE-1]], i32 25
 }
 
-// CHECK: !llvm.asan.globals = !{![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
-// CHECK: ![[GLOBAL]] = metadata !{{{.*}} [[GLOBAL_LOC]], i1 false, i1 false}
-// CHECK: ![[DYN_INIT_GLOBAL]] = metadata !{{{.*}} [[DYN_INIT_LOC]], i1 true, i1 false}
-// CHECK: ![[BLACKLISTED_GLOBAL]] = metadata !{{{.*}}, null, i1 false, i1 true}
-// CHECK: ![[STATIC_VAR]] = metadata !{{{.*}} [[STATIC_LOC]], i1 false, i1 false}
-// CHECK: ![[LITERAL]] = metadata !{{{.*}} [[LITERAL_LOC]], i1 false, i1 false}
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK: ![[EXTRA_GLOBAL]] = metadata !{{{.*}} metadata ![[EXTRA_GLOBAL_LOC:[0-9]+]], metadata !"extra_global", i1 false, i1 false}
+// CHECK: ![[EXTRA_GLOBAL_LOC]] = metadata !{metadata !"{{.*}}extra-source.cpp", i32 1, i32 5}
+// CHECK: ![[GLOBAL]] = metadata !{{{.*}} metadata ![[GLOBAL_LOC:[0-9]+]], metadata !"global", i1 false, i1 false}
+// CHECK: ![[GLOBAL_LOC]] = metadata !{metadata !"{{.*}}asan-globals.cpp", i32 8, i32 5}
+// CHECK: ![[DYN_INIT_GLOBAL]] = metadata !{{{.*}} metadata ![[DYN_INIT_LOC:[0-9]+]], metadata !"dyn_init_global", i1 true, i1 false}
+// CHECK: ![[DYN_INIT_LOC]] = metadata !{metadata !"{{.*}}asan-globals.cpp", i32 9, i32 5}
+// CHECK: ![[BLACKLISTED_GLOBAL]] = metadata !{{{.*}}, null, null, i1 false, i1 true}
+// CHECK: ![[STATIC_VAR]] = metadata !{{{.*}} metadata ![[STATIC_LOC:[0-9]+]], metadata !"static_var", i1 false, i1 false}
+// CHECK: ![[STATIC_LOC]] = metadata !{metadata !"{{.*}}asan-globals.cpp", i32 13, i32 14}
+// CHECK: ![[LITERAL]] = metadata !{{{.*}} metadata ![[LITERAL_LOC:[0-9]+]], metadata !"<string literal>", i1 false, i1 false}
+// CHECK: ![[LITERAL_LOC]] = metadata !{metadata !"{{.*}}asan-globals.cpp", i32 14, i32 25}
 
-// BLACKLIST-SRC: !llvm.asan.globals = !{![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
-// BLACKLIST-SRC: ![[GLOBAL]] = metadata !{{{.*}} null, i1 false, i1 true}
-// BLACKLIST-SRC: ![[DYN_INIT_GLOBAL]] = metadata !{{{.*}} null, i1 true, i1 true}
-// BLACKLIST-SRC: ![[BLACKLISTED_GLOBAL]] = metadata !{{{.*}}, null, i1 false, i1 true}
-// BLACKLIST-SRC: ![[STATIC_VAR]] = metadata !{{{.*}} null, i1 false, i1 true}
-// BLACKLIST-SRC: ![[LITERAL]] = metadata !{{{.*}} null, i1 false, i1 true}
+// BLACKLIST-SRC: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], ![[DYN_INIT_GLOBAL:[0-9]+]], ![[BLACKLISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// BLACKLIST-SRC: ![[EXTRA_GLOBAL]] = metadata !{{{.*}} metadata ![[EXTRA_GLOBAL_LOC:[0-9]+]], metadata !"extra_global", i1 false, i1 false}
+// BLACKLIST-SRC: ![[EXTRA_GLOBAL_LOC]] = metadata !{metadata !"{{.*}}extra-source.cpp", i32 1, i32 5}
+// BLACKLIST-SRC: ![[GLOBAL]] = metadata !{{{.*}} null, null, i1 false, i1 true}
+// BLACKLIST-SRC: ![[DYN_INIT_GLOBAL]] = metadata !{{{.*}} null, null, i1 true, i1 true}
+// BLACKLIST-SRC: ![[BLACKLISTED_GLOBAL]] = metadata !{{{.*}}, null, null, i1 false, i1 true}
+// BLACKLIST-SRC: ![[STATIC_VAR]] = metadata !{{{.*}} null, null, i1 false, i1 true}
+// BLACKLIST-SRC: ![[LITERAL]] = metadata !{{{.*}} null, null, i1 false, i1 true}
diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c
index 670c244..5dbc01b 100644
--- a/test/CodeGen/asm.c
+++ b/test/CodeGen/asm.c
@@ -239,3 +239,12 @@
 // CHECK: call void asm sideeffect "/* $0 */", "i|r,~{dirflag},~{fpsr},~{flags}"(i32 1)
 }
 
+static unsigned t29_var[1];
+
+void t29(void) {
+  asm volatile("movl %%eax, %0"
+               :
+               : "m"(t29_var));
+  // CHECK: @t29
+  // CHECK: call void asm sideeffect "movl %eax, $0", "*m,~{dirflag},~{fpsr},~{flags}"([1 x i32]* @t29_var)
+}
diff --git a/test/CodeGen/atomic-ops-libcall.c b/test/CodeGen/atomic-ops-libcall.c
index 2a2ff5e..e55a1bd 100644
--- a/test/CodeGen/atomic-ops-libcall.c
+++ b/test/CodeGen/atomic-ops-libcall.c
@@ -7,31 +7,31 @@
 
 int *test_c11_atomic_fetch_add_int_ptr(_Atomic(int *) *p) {
   // CHECK: test_c11_atomic_fetch_add_int_ptr
-  // CHECK: {{%[^ ]*}} = tail call i32* @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 12, i32 5)
+  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 12, i32 5)
   return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
 }
 
 int *test_c11_atomic_fetch_sub_int_ptr(_Atomic(int *) *p) {
   // CHECK: test_c11_atomic_fetch_sub_int_ptr
-  // CHECK: {{%[^ ]*}} = tail call i32* @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 20, i32 5)
+  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 20, i32 5)
   return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
 }
 
 int test_c11_atomic_fetch_add_int(_Atomic(int) *p) {
   // CHECK: test_c11_atomic_fetch_add_int
-  // CHECK: {{%[^ ]*}} = tail call i32 bitcast (i32* (i8*, i32, i32)* @__atomic_fetch_add_4 to i32 (i8*, i32, i32)*)(i8* {{%[0-9]+}}, i32 3, i32 5)
+  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_add_4(i8* {{%[0-9]+}}, i32 3, i32 5)
   return __c11_atomic_fetch_add(p, 3, memory_order_seq_cst);
 }
 
 int test_c11_atomic_fetch_sub_int(_Atomic(int) *p) {
   // CHECK: test_c11_atomic_fetch_sub_int
-  // CHECK: {{%[^ ]*}} = tail call i32 bitcast (i32* (i8*, i32, i32)* @__atomic_fetch_sub_4 to i32 (i8*, i32, i32)*)(i8* {{%[0-9]+}}, i32 5, i32 5)
+  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 5, i32 5)
   return __c11_atomic_fetch_sub(p, 5, memory_order_seq_cst);
 }
 
 int *fp2a(int **p) {
   // CHECK: @fp2a
-  // CHECK: {{%[^ ]*}} = tail call i32* @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 4, i32 0)
+  // CHECK: {{%[^ ]*}} = tail call i32 @__atomic_fetch_sub_4(i8* {{%[0-9]+}}, i32 4, i32 0)
   // Note, the GNU builtins do not multiply by sizeof(T)!
   return __atomic_fetch_sub(p, 4, memory_order_relaxed);
 }
diff --git a/test/CodeGen/atomic-ops.c b/test/CodeGen/atomic-ops.c
index 9e6b480..7bc45b6 100644
--- a/test/CodeGen/atomic-ops.c
+++ b/test/CodeGen/atomic-ops.c
@@ -1,18 +1,15 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -ffreestanding -triple=i686-apple-darwin9 | FileCheck %s
 
 // Also test serialization of atomic operations here, to avoid duplicating the
 // test.
-// RUN: %clang_cc1 %s -emit-pch -o %t -triple=i686-apple-darwin9
-// RUN: %clang_cc1 %s -include-pch %t -triple=i686-apple-darwin9 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-pch -o %t -ffreestanding -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -include-pch %t -ffreestanding -triple=i686-apple-darwin9 -emit-llvm -o - | FileCheck %s
 #ifndef ALREADY_INCLUDED
 #define ALREADY_INCLUDED
 
-// Basic IRGen tests for __c11_atomic_* and GNU __atomic_*
+#include <stdatomic.h>
 
-typedef enum memory_order {
-  memory_order_relaxed, memory_order_consume, memory_order_acquire,
-  memory_order_release, memory_order_acq_rel, memory_order_seq_cst
-} memory_order;
+// Basic IRGen tests for __c11_atomic_* and GNU __atomic_*
 
 int fi1(_Atomic(int) *i) {
   // CHECK-LABEL: @fi1
@@ -34,6 +31,12 @@
   return __atomic_load_n(i, memory_order_seq_cst);
 }
 
+int fi1c(atomic_int *i) {
+  // CHECK-LABEL: @fi1c
+  // CHECK: load atomic i32* {{.*}} seq_cst
+  return atomic_load(i);
+}
+
 void fi2(_Atomic(int) *i) {
   // CHECK-LABEL: @fi2
   // CHECK: store atomic i32 {{.*}} seq_cst
@@ -53,6 +56,12 @@
   __atomic_store_n(i, 1, memory_order_seq_cst);
 }
 
+void fi2c(atomic_int *i) {
+  // CHECK-LABEL: @fi2c
+  // CHECK: store atomic i32 {{.*}} seq_cst
+  atomic_store(i, 1);
+}
+
 int fi3(_Atomic(int) *i) {
   // CHECK-LABEL: @fi3
   // CHECK: atomicrmw and
@@ -89,8 +98,15 @@
   return __atomic_nand_fetch(i, 1, memory_order_seq_cst);
 }
 
+int fi3e(atomic_int *i) {
+  // CHECK-LABEL: @fi3e
+  // CHECK: atomicrmw or
+  // CHECK-NOT: {{ or }}
+  return atomic_fetch_or(i, 1);
+}
+
 _Bool fi4(_Atomic(int) *i) {
-  // CHECK-LABEL: @fi4
+  // CHECK-LABEL: @fi4(
   // CHECK: [[PAIR:%[.0-9A-Z_a-z]+]] = cmpxchg i32* [[PTR:%[.0-9A-Z_a-z]+]], i32 [[EXPECTED:%[.0-9A-Z_a-z]+]], i32 [[DESIRED:%[.0-9A-Z_a-z]+]]
   // CHECK: [[OLD:%[.0-9A-Z_a-z]+]] = extractvalue { i32, i1 } [[PAIR]], 0
   // CHECK: [[CMP:%[.0-9A-Z_a-z]+]] = extractvalue { i32, i1 } [[PAIR]], 1
@@ -101,7 +117,7 @@
 }
 
 _Bool fi4a(int *i) {
-  // CHECK-LABEL: @fi4
+  // CHECK-LABEL: @fi4a
   // CHECK: [[PAIR:%[.0-9A-Z_a-z]+]] = cmpxchg i32* [[PTR:%[.0-9A-Z_a-z]+]], i32 [[EXPECTED:%[.0-9A-Z_a-z]+]], i32 [[DESIRED:%[.0-9A-Z_a-z]+]]
   // CHECK: [[OLD:%[.0-9A-Z_a-z]+]] = extractvalue { i32, i1 } [[PAIR]], 0
   // CHECK: [[CMP:%[.0-9A-Z_a-z]+]] = extractvalue { i32, i1 } [[PAIR]], 1
@@ -113,7 +129,7 @@
 }
 
 _Bool fi4b(int *i) {
-  // CHECK-LABEL: @fi4
+  // CHECK-LABEL: @fi4b(
   // CHECK: [[PAIR:%[.0-9A-Z_a-z]+]] = cmpxchg weak i32* [[PTR:%[.0-9A-Z_a-z]+]], i32 [[EXPECTED:%[.0-9A-Z_a-z]+]], i32 [[DESIRED:%[.0-9A-Z_a-z]+]]
   // CHECK: [[OLD:%[.0-9A-Z_a-z]+]] = extractvalue { i32, i1 } [[PAIR]], 0
   // CHECK: [[CMP:%[.0-9A-Z_a-z]+]] = extractvalue { i32, i1 } [[PAIR]], 1
@@ -123,6 +139,13 @@
   return __atomic_compare_exchange_n(i, &cmp, 1, 1, memory_order_acquire, memory_order_acquire);
 }
 
+_Bool fi4c(atomic_int *i) {
+  // CHECK-LABEL: @fi4c
+  // CHECK: cmpxchg i32*
+  int cmp = 0;
+  return atomic_compare_exchange_strong(i, &cmp, 1);
+}
+
 float ff1(_Atomic(float) *d) {
   // CHECK-LABEL: @ff1
   // CHECK: load atomic i32* {{.*}} monotonic
@@ -139,6 +162,79 @@
   return __c11_atomic_exchange(d, 2, memory_order_seq_cst);
 }
 
+struct S {
+  double x;
+};
+
+struct S fd1(struct S *a) {
+  // CHECK-LABEL: @fd1
+  // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4
+  // CHECK: [[RET:%.*]]    = alloca %struct.S, align 4
+  // CHECK: [[CALL:%.*]]   = call i64 @__atomic_load_8(
+  // CHECK: [[CAST:%.*]]   = bitcast %struct.S* [[RET]] to i64*
+  // CHECK: store i64 [[CALL]], i64* [[CAST]], align 4
+  struct S ret;
+  __atomic_load(a, &ret, memory_order_seq_cst);
+  return ret;
+}
+
+void fd2(struct S *a, struct S *b) {
+  // CHECK-LABEL: @fd2
+  // CHECK:      [[A_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: [[B_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: store %struct.S* %a, %struct.S** [[A_ADDR]], align 4
+  // CHECK-NEXT: store %struct.S* %b, %struct.S** [[B_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_A_PTR:%.*]] = load %struct.S** [[A_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_B_PTR:%.*]] = load %struct.S** [[B_ADDR]], align 4
+  // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i8*
+  // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64*
+  // CHECK-NEXT: [[LOAD_B:%.*]] = load i64* [[COERCED_B]], align 4
+  // CHECK-NEXT: call void @__atomic_store_8(i8* [[COERCED_A]], i64 [[LOAD_B]],
+  // CHECK-NEXT: ret void
+  __atomic_store(a, b, memory_order_seq_cst);
+}
+
+void fd3(struct S *a, struct S *b, struct S *c) {
+  // CHECK-LABEL: @fd3
+  // CHECK:      [[A_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: [[B_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: [[C_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: store %struct.S* %a, %struct.S** [[A_ADDR]], align 4
+  // CHECK-NEXT: store %struct.S* %b, %struct.S** [[B_ADDR]], align 4
+  // CHECK-NEXT: store %struct.S* %c, %struct.S** [[C_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_A_PTR:%.*]] = load %struct.S** [[A_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_B_PTR:%.*]] = load %struct.S** [[B_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_C_PTR:%.*]] = load %struct.S** [[C_ADDR]], align 4
+  // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i8*
+  // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64*
+  // CHECK-NEXT: [[LOAD_B:%.*]] = load i64* [[COERCED_B]], align 4
+  // CHECK-NEXT: [[CALL:%.*]] = call i64 @__atomic_exchange_8(i8* [[COERCED_A]], i64 [[LOAD_B]],
+  // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64*
+  // CHECK-NEXT: store i64 [[CALL]], i64* [[COERCED_C]], align 4
+
+  __atomic_exchange(a, b, c, memory_order_seq_cst);
+}
+
+_Bool fd4(struct S *a, struct S *b, struct S *c) {
+  // CHECK-LABEL: @fd4
+  // CHECK:      [[A_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: [[B_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK-NEXT: [[C_ADDR:%.*]] = alloca %struct.S*, align 4
+  // CHECK:      store %struct.S* %a, %struct.S** [[A_ADDR]], align 4
+  // CHECK-NEXT: store %struct.S* %b, %struct.S** [[B_ADDR]], align 4
+  // CHECK-NEXT: store %struct.S* %c, %struct.S** [[C_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_A_PTR:%.*]] = load %struct.S** [[A_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_B_PTR:%.*]] = load %struct.S** [[B_ADDR]], align 4
+  // CHECK-NEXT: [[LOAD_C_PTR:%.*]] = load %struct.S** [[C_ADDR]], align 4
+  // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i8*
+  // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i8*
+  // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64*
+  // CHECK-NEXT: [[LOAD_C:%.*]] = load i64* [[COERCED_C]], align 4
+  // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange_8(i8* [[COERCED_A]], i8* [[COERCED_B]], i64 [[LOAD_C]]
+  // CHECK-NEXT: ret i1 [[CALL]]
+  return __atomic_compare_exchange(a, b, c, 1, 5, 5);
+}
+
 int* fp1(_Atomic(int*) *p) {
   // CHECK-LABEL: @fp1
   // CHECK: load atomic i32* {{.*}} seq_cst
diff --git a/test/CodeGen/atomic.c b/test/CodeGen/atomic.c
index 43f5bc8..4db3c8e 100644
--- a/test/CodeGen/atomic.c
+++ b/test/CodeGen/atomic.c
@@ -50,7 +50,10 @@
 
   old = __sync_fetch_and_xor(&val, 0xb);
   // CHECK: atomicrmw xor i32* %val, i32 11 seq_cst
-  
+ 
+  old = __sync_fetch_and_nand(&val, 0xc);
+  // CHECK: atomicrmw nand i32* %val, i32 12 seq_cst
+ 
   old = __sync_add_and_fetch(&val, 1);
   // CHECK: atomicrmw add i32* %val, i32 1 seq_cst
 
@@ -65,7 +68,10 @@
 
   old = __sync_xor_and_fetch(&valc, 5);
   // CHECK: atomicrmw xor i8* %valc, i8 5 seq_cst  
-  
+ 
+  old = __sync_nand_and_fetch(&valc, 6);
+  // CHECK: atomicrmw nand i8* %valc, i8 6 seq_cst  
+ 
   __sync_val_compare_and_swap((void **)0, (void *)0, (void *)0);
   // CHECK: [[PAIR:%[a-z0-9_.]+]] = cmpxchg i32* null, i32 0, i32 0 seq_cst
   // CHECK: extractvalue { i32, i1 } [[PAIR]], 0
diff --git a/test/CodeGen/atomics-inlining.c b/test/CodeGen/atomics-inlining.c
index 6456e74..ec916e1 100644
--- a/test/CodeGen/atomics-inlining.c
+++ b/test/CodeGen/atomics-inlining.c
@@ -76,8 +76,8 @@
 // MIPS32: store atomic i32 {{.*}}, i32* @i1 seq_cst
 // MIPS32: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
 // MIPS32: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
-// MIPS32: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8]* @a2, i32 0, i32 0)
-// MIPS32: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8]* @a2, i32 0, i32 0)
+// MIPS32: call void @__atomic_load(i32 zeroext 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8]* @a2, i32 0, i32 0)
+// MIPS32: call void @__atomic_store(i32 zeroext 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8]* @a2, i32 0, i32 0)
 
 // MIPS64-LABEL: define void @test1
 // MIPS64: = load atomic i8* @c1 seq_cst
@@ -88,6 +88,6 @@
 // MIPS64: store atomic i32 {{.*}}, i32* @i1 seq_cst
 // MIPS64: = load atomic i64* @ll1 seq_cst
 // MIPS64: store atomic i64 {{.*}}, i64* @ll1 seq_cst
-// MIPS64: call void @__atomic_load(i64 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0)
-// MIPS64: call void @__atomic_store(i64 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8]* @a2, i32 0, i32 0)
+// MIPS64: call void @__atomic_load(i64 zeroext 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0)
+// MIPS64: call void @__atomic_store(i64 zeroext 100, i8* getelementptr inbounds ([100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8]* @a2, i32 0, i32 0)
 }
diff --git a/test/CodeGen/attr-naked.c b/test/CodeGen/attr-naked.c
index c07dd8d..270fc79 100644
--- a/test/CodeGen/attr-naked.c
+++ b/test/CodeGen/attr-naked.c
@@ -12,7 +12,15 @@
 // Make sure this doesn't explode in the verifier.
 // (It doesn't really make sense, but it isn't invalid.)
 // CHECK: define void @t2() [[NAKED]] {
-__attribute((naked, always_inline)) void t2()  {
+__attribute((naked, always_inline)) void t2() {
+}
+
+// Make sure not to generate prolog or epilog for naked functions.
+__attribute((naked)) void t3(int x) {
+// CHECK: define void @t3(i32)
+// CHECK-NOT: alloca
+// CHECK-NOT: store
+// CHECK: unreachable
 }
 
 // CHECK: attributes [[NAKED]] = { naked noinline nounwind{{.*}} }
diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c
index 356a179..5c9c90d 100644
--- a/test/CodeGen/attributes.c
+++ b/test/CodeGen/attributes.c
@@ -26,7 +26,7 @@
 // CHECK: @t12 = global i32 0, section "SECT"
 int t12 __attribute__((section("SECT")));
 
-// CHECK: @t9 = alias weak bitcast (void ()* @__t8 to void (...)*)
+// CHECK: @t9 = weak alias bitcast (void ()* @__t8 to void (...)*)
 void __t8() {}
 void t9() __attribute__((weak, alias("__t8")));
 
diff --git a/test/CodeGen/avx2-builtins.c b/test/CodeGen/avx2-builtins.c
index 10c3a1b..04825ff 100644
--- a/test/CodeGen/avx2-builtins.c
+++ b/test/CodeGen/avx2-builtins.c
@@ -6,7 +6,7 @@
 #include <immintrin.h>
 
 __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
-  // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i32 3)
+  // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i8 3)
   return _mm256_mpsadbw_epu8(x, y, 3);
 }
 
diff --git a/test/CodeGen/avx512bw-builtins.c b/test/CodeGen/avx512bw-builtins.c
new file mode 100644
index 0000000..ada8465
--- /dev/null
+++ b/test/CodeGen/avx512bw-builtins.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -ffreestanding -target-feature +avx512bw -emit-llvm -o - -Werror | FileCheck %s
+
+#include <immintrin.h>
+
+__mmask64 test_mm512_cmpeq_epi8_mask(__m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_cmpeq_epi8_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.b.512
+  return (__mmask64)_mm512_cmpeq_epi8_mask(__a, __b);
+}
+
+__mmask64 test_mm512_mask_cmpeq_epi8_mask(__mmask64 __u, __m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_mask_cmpeq_epi8_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.b.512
+  return (__mmask64)_mm512_mask_cmpeq_epi8_mask(__u, __a, __b);
+}
+
+__mmask32 test_mm512_cmpeq_epi16_mask(__m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_cmpeq_epi16_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.w.512
+  return (__mmask32)_mm512_cmpeq_epi16_mask(__a, __b);
+}
+
+__mmask32 test_mm512_mask_cmpeq_epi16_mask(__mmask32 __u, __m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_mask_cmpeq_epi16_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.w.512
+  return (__mmask32)_mm512_mask_cmpeq_epi16_mask(__u, __a, __b);
+}
diff --git a/test/CodeGen/avx512f-builtins.c b/test/CodeGen/avx512f-builtins.c
new file mode 100644
index 0000000..ba05f4a
--- /dev/null
+++ b/test/CodeGen/avx512f-builtins.c
@@ -0,0 +1,184 @@
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -target-feature +avx512f -emit-llvm -o - -Werror | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+__m512d test_mm512_sqrt_pd(__m512d a)
+{
+  // CHECK-LABEL: @test_mm512_sqrt_pd
+  // CHECK: @llvm.x86.avx512.sqrt.pd.512
+  return _mm512_sqrt_pd(a);
+}
+
+__m512 test_mm512_sqrt_ps(__m512 a)
+{
+  // CHECK-LABEL: @test_mm512_sqrt_ps
+  // CHECK: @llvm.x86.avx512.sqrt.ps.512
+  return _mm512_sqrt_ps(a);
+}
+
+__m512d test_mm512_rsqrt14_pd(__m512d a)
+{
+  // CHECK-LABEL: @test_mm512_rsqrt14_pd
+  // CHECK: @llvm.x86.avx512.rsqrt14.pd.512
+  return _mm512_rsqrt14_pd(a);
+}
+
+__m512 test_mm512_rsqrt14_ps(__m512 a)
+{
+  // CHECK-LABEL: @test_mm512_rsqrt14_ps
+  // CHECK: @llvm.x86.avx512.rsqrt14.ps.512
+  return _mm512_rsqrt14_ps(a);
+}
+
+__m512 test_mm512_add_ps(__m512 a, __m512 b)
+{
+  // CHECK-LABEL: @test_mm512_add_ps
+  // CHECK: fadd <16 x float>
+  return _mm512_add_ps(a, b);
+}
+
+__m512d test_mm512_add_pd(__m512d a, __m512d b)
+{
+  // CHECK-LABEL: @test_mm512_add_pd
+  // CHECK: fadd <8 x double>
+  return _mm512_add_pd(a, b);
+}
+
+__m512 test_mm512_mul_ps(__m512 a, __m512 b)
+{
+  // CHECK-LABEL: @test_mm512_mul_ps
+  // CHECK: fmul <16 x float>
+  return _mm512_mul_ps(a, b);
+}
+
+__m512d test_mm512_mul_pd(__m512d a, __m512d b)
+{
+  // CHECK-LABEL: @test_mm512_mul_pd
+  // CHECK: fmul <8 x double>
+  return _mm512_mul_pd(a, b);
+}
+
+void test_mm512_storeu_ps(void *p, __m512 a)
+{
+  // CHECK-LABEL: @test_mm512_storeu_ps
+  // CHECK: @llvm.x86.avx512.mask.storeu.ps.512
+  _mm512_storeu_ps(p, a);
+}
+
+void test_mm512_storeu_pd(void *p, __m512d a)
+{
+  // CHECK-LABEL: @test_mm512_storeu_pd
+  // CHECK: @llvm.x86.avx512.mask.storeu.pd.512
+  _mm512_storeu_pd(p, a);
+}
+
+void test_mm512_store_ps(void *p, __m512 a)
+{
+  // CHECK-LABEL: @test_mm512_store_ps
+  // CHECK: store <16 x float>
+  _mm512_store_ps(p, a);
+}
+
+void test_mm512_store_pd(void *p, __m512d a)
+{
+  // CHECK-LABEL: @test_mm512_store_pd
+  // CHECK: store <8 x double>
+  _mm512_store_pd(p, a);
+}
+
+__m512 test_mm512_loadu_ps(void *p)
+{
+  // CHECK-LABEL: @test_mm512_loadu_ps
+  // CHECK: load <16 x float>* {{.*}}, align 1{{$}}
+  return _mm512_loadu_ps(p);
+}
+
+__m512d test_mm512_loadu_pd(void *p)
+{
+  // CHECK-LABEL: @test_mm512_loadu_pd
+  // CHECK: load <8 x double>* {{.*}}, align 1{{$}}
+  return _mm512_loadu_pd(p);
+}
+
+__m512d test_mm512_set1_pd(double d)
+{
+  // CHECK-LABEL: @test_mm512_set1_pd
+  // CHECK: insertelement <8 x double> {{.*}}, i32 0
+  // CHECK: insertelement <8 x double> {{.*}}, i32 1
+  // CHECK: insertelement <8 x double> {{.*}}, i32 2
+  // CHECK: insertelement <8 x double> {{.*}}, i32 3
+  // CHECK: insertelement <8 x double> {{.*}}, i32 4
+  // CHECK: insertelement <8 x double> {{.*}}, i32 5
+  // CHECK: insertelement <8 x double> {{.*}}, i32 6
+  // CHECK: insertelement <8 x double> {{.*}}, i32 7
+  return _mm512_set1_pd(d);
+}
+
+__m512d test_mm512_castpd256_pd512(__m256d a)
+{
+  // CHECK-LABEL: @test_mm512_castpd256_pd512
+  // CHECK: shufflevector <4 x double> {{.*}} <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
+  return _mm512_castpd256_pd512(a);
+}
+
+__mmask16 test_mm512_knot(__mmask16 a)
+{
+  // CHECK-LABEL: @test_mm512_knot
+  // CHECK: @llvm.x86.avx512.knot.w
+  return _mm512_knot(a);
+}
+
+__m512i test_mm512_valign_epi64(__m512i a, __m512i b)
+{
+  // CHECK-LABEL: @test_mm512_valign_epi64
+  // CHECK: @llvm.x86.avx512.mask.valign.q.512
+  return _mm512_valign_epi64(a, b, 2);
+}
+
+__m512d test_mm512_broadcastsd_pd(__m128d a)
+{
+  // CHECK-LABEL: @test_mm512_broadcastsd_pd
+  // CHECK: insertelement <8 x double> {{.*}}, i32 0
+  // CHECK: insertelement <8 x double> {{.*}}, i32 1
+  // CHECK: insertelement <8 x double> {{.*}}, i32 2
+  // CHECK: insertelement <8 x double> {{.*}}, i32 3
+  // CHECK: insertelement <8 x double> {{.*}}, i32 4
+  // CHECK: insertelement <8 x double> {{.*}}, i32 5
+  // CHECK: insertelement <8 x double> {{.*}}, i32 6
+  // CHECK: insertelement <8 x double> {{.*}}, i32 7
+  return _mm512_broadcastsd_pd(a);
+}
+
+__m512i test_mm512_fmadd_pd(__m512d a, __m512d b, __m512d c)
+{
+  // CHECK-LABEL: @test_mm512_fmadd_pd
+  // CHECK: @llvm.x86.fma.mask.vfmadd.pd.512
+  return _mm512_fmadd_pd(a, b, c);
+}
+
+__mmask16 test_mm512_cmpeq_epi32_mask(__m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_cmpeq_epi32_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.512
+  return (__mmask16)_mm512_cmpeq_epi32_mask(__a, __b);
+}
+
+__mmask16 test_mm512_mask_cmpeq_epi32_mask(__mmask16 __u, __m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_mask_cmpeq_epi32_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.512
+  return (__mmask16)_mm512_mask_cmpeq_epi32_mask(__u, __a, __b);
+}
+
+__mmask8 test_mm512_mask_cmpeq_epi64_mask(__mmask8 __u, __m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_mask_cmpeq_epi64_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.512
+  return (__mmask8)_mm512_mask_cmpeq_epi64_mask(__u, __a, __b);
+}
+
+__mmask8 test_mm512_cmpeq_epi64_mask(__m512i __a, __m512i __b) {
+  // CHECK-LABEL: @test_mm512_cmpeq_epi64_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.512
+  return (__mmask8)_mm512_cmpeq_epi64_mask(__a, __b);
+}
diff --git a/test/CodeGen/avx512vl-builtins.c b/test/CodeGen/avx512vl-builtins.c
new file mode 100644
index 0000000..e4b4517
--- /dev/null
+++ b/test/CodeGen/avx512vl-builtins.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -ffreestanding -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o - -Werror | FileCheck %s
+
+#include <immintrin.h>
+
+__mmask8 test_mm256_cmpeq_epi32_mask(__m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_cmpeq_epi32_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.256
+  return (__mmask8)_mm256_cmpeq_epi32_mask(__a, __b);
+}
+
+__mmask8 test_mm256_mask_cmpeq_epi32_mask(__mmask8 __u, __m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_mask_cmpeq_epi32_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.256
+  return (__mmask8)_mm256_mask_cmpeq_epi32_mask(__u, __a, __b);
+}
+
+__mmask8 test_mm_cmpeq_epi32_mask(__m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_cmpeq_epi32_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.128
+  return (__mmask8)_mm_cmpeq_epi32_mask(__a, __b);
+}
+
+__mmask8 test_mm_mask_cmpeq_epi32_mask(__mmask8 __u, __m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_mask_cmpeq_epi32_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.d.128
+  return (__mmask8)_mm_mask_cmpeq_epi32_mask(__u, __a, __b);
+}
+
+__mmask8 test_mm256_cmpeq_epi64_mask(__m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_cmpeq_epi64_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.256
+  return (__mmask8)_mm256_cmpeq_epi64_mask(__a, __b);
+}
+
+__mmask8 test_mm256_mask_cmpeq_epi64_mask(__mmask8 __u, __m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_mask_cmpeq_epi64_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.256
+  return (__mmask8)_mm256_mask_cmpeq_epi64_mask(__u, __a, __b);
+}
+
+__mmask8 test_mm_cmpeq_epi64_mask(__m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_cmpeq_epi64_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.128
+  return (__mmask8)_mm_cmpeq_epi64_mask(__a, __b);
+}
+
+__mmask8 test_mm_mask_cmpeq_epi64_mask(__mmask8 __u, __m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_mask_cmpeq_epi64_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.q.128
+  return (__mmask8)_mm_mask_cmpeq_epi64_mask(__u, __a, __b);
+}
diff --git a/test/CodeGen/avx512vlbw-builtins.c b/test/CodeGen/avx512vlbw-builtins.c
new file mode 100644
index 0000000..a304f7b
--- /dev/null
+++ b/test/CodeGen/avx512vlbw-builtins.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -O0 -triple=x86_64-apple-darwin -ffreestanding -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Werror | FileCheck %s
+
+#include <immintrin.h>
+
+__mmask32 test_mm256_cmpeq_epi8_mask(__m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_cmpeq_epi8_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.b.256
+  return (__mmask32)_mm256_cmpeq_epi8_mask(__a, __b);
+}
+
+__mmask32 test_mm256_mask_cmpeq_epi8_mask(__mmask32 __u, __m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_mask_cmpeq_epi8_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.b.256
+  return (__mmask32)_mm256_mask_cmpeq_epi8_mask(__u, __a, __b);
+}
+
+__mmask16 test_mm_cmpeq_epi8_mask(__m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_cmpeq_epi8_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.b.128
+  return (__mmask16)_mm_cmpeq_epi8_mask(__a, __b);
+}
+
+__mmask16 test_mm_mask_cmpeq_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_mask_cmpeq_epi8_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.b.128
+  return (__mmask16)_mm_mask_cmpeq_epi8_mask(__u, __a, __b);
+}
+
+__mmask16 test_mm256_cmpeq_epi16_mask(__m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_cmpeq_epi16_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.w.256
+  return (__mmask16)_mm256_cmpeq_epi16_mask(__a, __b);
+}
+
+__mmask16 test_mm256_mask_cmpeq_epi16_mask(__mmask16 __u, __m256i __a, __m256i __b) {
+  // CHECK-LABEL: @test_mm256_mask_cmpeq_epi16_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.w.256
+  return (__mmask16)_mm256_mask_cmpeq_epi16_mask(__u, __a, __b);
+}
+
+__mmask8 test_mm_cmpeq_epi16_mask(__m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_cmpeq_epi16_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.w.128
+  return (__mmask8)_mm_cmpeq_epi16_mask(__a, __b);
+}
+
+__mmask8 test_mm_mask_cmpeq_epi16_mask(__mmask8 __u, __m128i __a, __m128i __b) {
+  // CHECK-LABEL: @test_mm_mask_cmpeq_epi16_mask
+  // CHECK: @llvm.x86.avx512.mask.pcmpeq.w.128
+  return (__mmask8)_mm_mask_cmpeq_epi16_mask(__u, __a, __b);
+}
diff --git a/test/CodeGen/block-with-perdefinedexpr.c b/test/CodeGen/block-with-perdefinedexpr.c
new file mode 100644
index 0000000..68fdea6
--- /dev/null
+++ b/test/CodeGen/block-with-perdefinedexpr.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s
+// rdar://18961148
+
+void syslog(const char *, ...);
+
+void handler( );
+
+static void (^spd)() = ^()
+{
+ handler( ^(){ syslog("%s", __FUNCTION__); } );
+};
+// CHECK: @__FUNCTION__.spd_block_invoke_2 = private unnamed_addr constant [19 x i8] c"spd_block_invoke_2\00"
+// CHECK: define internal void @spd_block_invoke_2
+// CHECK: @__FUNCTION__.spd_block_invoke_2
diff --git a/test/CodeGen/blocks-opencl.cl b/test/CodeGen/blocks-opencl.cl
new file mode 100644
index 0000000..ab80f5e
--- /dev/null
+++ b/test/CodeGen/blocks-opencl.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 %s -ffake-address-space-map -emit-llvm -o - -fblocks -triple x86_64-unknown-unknown | FileCheck %s
+// This used to crash due to trying to generate a bitcase from a cstring
+// in the constant address space to i8* in AS0.
+
+void dummy(float (^op)(float))
+{
+}
+
+// CHECK: i8 addrspace(3)* getelementptr inbounds ([9 x i8] addrspace(3)* @.str, i32 0, i32 0)
+
+kernel void test_block()
+{
+  float (^X)(float) = ^(float x) { return x + 42.0f; };
+  dummy(X);
+}
+
diff --git a/test/CodeGen/builtin-assume-aligned.c b/test/CodeGen/builtin-assume-aligned.c
new file mode 100644
index 0000000..1d807a4
--- /dev/null
+++ b/test/CodeGen/builtin-assume-aligned.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @test1
+int test1(int *a) {
+// CHECK: [[PTRINT1:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 31
+// CHECK: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND1]])
+  a = __builtin_assume_aligned(a, 32, 0ull);
+  return a[0];
+}
+
+// CHECK-LABEL: @test2
+int test2(int *a) {
+// CHECK: [[PTRINT2:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR2:%.+]] = and i64 [[PTRINT2]], 31
+// CHECK: [[MASKCOND2:%.+]] = icmp eq i64 [[MASKEDPTR2]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND2]])
+  a = __builtin_assume_aligned(a, 32, 0);
+  return a[0];
+}
+
+// CHECK-LABEL: @test3
+int test3(int *a) {
+// CHECK: [[PTRINT3:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR3:%.+]] = and i64 [[PTRINT3]], 31
+// CHECK: [[MASKCOND3:%.+]] = icmp eq i64 [[MASKEDPTR3]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND3]])
+  a = __builtin_assume_aligned(a, 32);
+  return a[0];
+}
+
+// CHECK-LABEL: @test4
+int test4(int *a, int b) {
+// CHECK-DAG: [[PTRINT4:%.+]] = ptrtoint
+// CHECK-DAG: [[CONV4:%.+]] = sext i32
+// CHECK: [[OFFSETPTR4:%.+]] = sub i64 [[PTRINT4]], [[CONV4]]
+// CHECK: [[MASKEDPTR4:%.+]] = and i64 [[OFFSETPTR4]], 31
+// CHECK: [[MASKCOND4:%.+]] = icmp eq i64 [[MASKEDPTR4]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND4]])
+  a = __builtin_assume_aligned(a, 32, b);
+  return a[0];
+}
+
+int *m1() __attribute__((assume_aligned(64)));
+
+// CHECK-LABEL: @test5
+int test5() {
+  return *m1();
+// CHECK: [[PTRINT5:%.+]] = ptrtoint
+// CHECK: [[MASKEDPTR5:%.+]] = and i64 [[PTRINT5]], 63
+// CHECK: [[MASKCOND5:%.+]] = icmp eq i64 [[MASKEDPTR5]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND5]])
+}
+
+int *m2() __attribute__((assume_aligned(64, 12)));
+
+// CHECK-LABEL: @test6
+int test6() {
+  return *m2();
+// CHECK: [[PTRINT6:%.+]] = ptrtoint
+// CHECK: [[OFFSETPTR6:%.+]] = sub i64 [[PTRINT6]], 12
+// CHECK: [[MASKEDPTR6:%.+]] = and i64 [[OFFSETPTR6]], 63
+// CHECK: [[MASKCOND6:%.+]] = icmp eq i64 [[MASKEDPTR6]], 0
+// CHECK: call void @llvm.assume(i1 [[MASKCOND6]])
+}
+
diff --git a/test/CodeGen/builtin-assume.c b/test/CodeGen/builtin-assume.c
new file mode 100644
index 0000000..8411b72
--- /dev/null
+++ b/test/CodeGen/builtin-assume.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @test1
+int test1(int *a, int i) {
+// CHECK: store i32* %a, i32** [[A_ADDR:%.+]], align
+// CHECK: [[A:%.+]] = load i32** [[A_ADDR]]
+// CHECK: [[CMP:%.+]] = icmp ne i32* [[A]], null
+// CHECK: call void @llvm.assume(i1 [[CMP]])
+#ifdef _MSC_VER
+  __assume(a != 0)
+#else
+  __builtin_assume(a != 0);
+#endif
+
+// Nothing is generated for an assume with side effects...
+// CHECK-NOT: load i32** %i.addr
+// CHECK-NOT: call void @llvm.assume
+#ifdef _MSC_VER
+  __assume(++i != 0)
+#else
+  __builtin_assume(++i != 0);
+#endif
+
+  return a[0];
+}
+
diff --git a/test/CodeGen/builtin-ms-noop.cpp b/test/CodeGen/builtin-ms-noop.cpp
index b579e2d..76c6c13 100644
--- a/test/CodeGen/builtin-ms-noop.cpp
+++ b/test/CodeGen/builtin-ms-noop.cpp
@@ -1,13 +1,30 @@
-// RUN: %clang_cc1 -fms-extensions -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 
-class A {
- public:
+struct A {
   ~A() {}
 };
 
-void f() {
-// CHECK: @_Z1fv
+extern "C" int f() {
+// CHECK: define i32 @f()
 // CHECK-NOT: call void @_ZN1AD1Ev
-// CHECK: ret void
-  __noop(A());
+// CHECK: ret i32 0
+  return __noop(A());
 };
+
+extern "C" int g() {
+  return __noop;
+// CHECK: define i32 @g()
+// CHECK: ret i32 0
+}
+
+extern "C" int h() {
+  return (__noop);
+// CHECK: define i32 @h()
+// CHECK: ret i32 0
+}
+
+extern "C" int i() {
+  return __noop + 1;
+// CHECK: define i32 @i()
+// CHECK: ret i32 1
+}
diff --git a/test/CodeGen/builtins-arm.c b/test/CodeGen/builtins-arm.c
index e55183c..9f3ed9a 100644
--- a/test/CodeGen/builtins-arm.c
+++ b/test/CodeGen/builtins-arm.c
@@ -19,6 +19,12 @@
   res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 1
 }
 
+void nop() {
+  __builtin_arm_nop();
+}
+
+// CHECK: call {{.*}} @llvm.arm.hint(i32 0)
+
 void yield() {
   __builtin_arm_yield();
 }
@@ -49,6 +55,12 @@
 
 // CHECK: call {{.*}} @llvm.arm.hint(i32 5)
 
+void dbg() {
+  __builtin_arm_dbg(0);
+}
+
+// CHECK: call {{.*}} @llvm.arm.dbg(i32 0)
+
 void test_barrier() {
   __builtin_arm_dmb(1); //CHECK: call {{.*}} @llvm.arm.dmb(i32 1)
   __builtin_arm_dsb(2); //CHECK: call {{.*}} @llvm.arm.dsb(i32 2)
@@ -60,3 +72,15 @@
 unsigned rbit(unsigned a) {
   return __builtin_arm_rbit(a);
 }
+
+void prefetch(int i) {
+  __builtin_arm_prefetch(&i, 0, 1);
+// CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 0, i32 3, i32 1)
+
+  __builtin_arm_prefetch(&i, 1, 1);
+// CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 1)
+
+
+  __builtin_arm_prefetch(&i, 1, 0);
+// CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
+}
diff --git a/test/CodeGen/builtins-arm64.c b/test/CodeGen/builtins-arm64.c
index 9e3460c..cc1f547 100644
--- a/test/CodeGen/builtins-arm64.c
+++ b/test/CodeGen/builtins-arm64.c
@@ -14,3 +14,32 @@
 unsigned long long rbit64(unsigned long long a) {
   return __builtin_arm_rbit64(a);
 }
+
+void hints() {
+  __builtin_arm_nop();    //CHECK: call {{.*}} @llvm.aarch64.hint(i32 0)
+  __builtin_arm_yield();  //CHECK: call {{.*}} @llvm.aarch64.hint(i32 1)
+  __builtin_arm_wfe();    //CHECK: call {{.*}} @llvm.aarch64.hint(i32 2)
+  __builtin_arm_wfi();    //CHECK: call {{.*}} @llvm.aarch64.hint(i32 3)
+  __builtin_arm_sev();    //CHECK: call {{.*}} @llvm.aarch64.hint(i32 4)
+  __builtin_arm_sevl();   //CHECK: call {{.*}} @llvm.aarch64.hint(i32 5)
+}
+
+void barriers() {
+  __builtin_arm_dmb(1);  //CHECK: call {{.*}} @llvm.aarch64.dmb(i32 1)
+  __builtin_arm_dsb(2);  //CHECK: call {{.*}} @llvm.aarch64.dsb(i32 2)
+  __builtin_arm_isb(3);  //CHECK: call {{.*}} @llvm.aarch64.isb(i32 3)
+}
+
+void prefetch() {
+  __builtin_arm_prefetch(0, 1, 2, 0, 1); // pstl3keep
+// CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 1, i32 1, i32 1)
+
+  __builtin_arm_prefetch(0, 0, 0, 1, 1); // pldl1keep
+// CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 0, i32 1)
+
+  __builtin_arm_prefetch(0, 0, 0, 1, 1); // pldl1strm
+// CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 0, i32 1)
+
+  __builtin_arm_prefetch(0, 0, 0, 0, 0); // plil1keep
+// CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
+}
diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c
index b161426..c6aa3c2 100644
--- a/test/CodeGen/builtins-ppc-altivec.c
+++ b/test/CodeGen/builtins-ppc-altivec.c
@@ -1047,7 +1047,7 @@
 // CHECK-LE: @llvm.ppc.altivec.vcmpgtfp
 
   /* vec_ctf */
-  res_vf  = vec_ctf(vi, param_i);
+  res_vf  = vec_ctf(vi, 0);
 // CHECK: @llvm.ppc.altivec.vcfsx
 // CHECK-LE: @llvm.ppc.altivec.vcfsx
 
@@ -1082,7 +1082,7 @@
 // CHECK-LE: @llvm.ppc.altivec.vctuxs
 
   /* vec_dss */
-  vec_dss(param_i);
+  vec_dss(0);
 // CHECK: @llvm.ppc.altivec.dss
 // CHECK-LE: @llvm.ppc.altivec.dss
 
@@ -3258,98 +3258,66 @@
   /* vec_sld */
   res_vsc = vec_sld(vsc, vsc, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vuc = vec_sld(vuc, vuc, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vs  = vec_sld(vs, vs, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vus = vec_sld(vus, vus, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vp  = vec_sld(vp, vp, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vi  = vec_sld(vi, vi, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vui = vec_sld(vui, vui, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vf  = vec_sld(vf, vf, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vsc = vec_vsldoi(vsc, vsc, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vuc = vec_vsldoi(vuc, vuc, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vs  = vec_vsldoi(vs, vs, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vus = vec_vsldoi(vus, vus, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vp  = vec_vsldoi(vp, vp, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vi  = vec_vsldoi(vi, vi, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vui = vec_vsldoi(vui, vui, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vf  = vec_vsldoi(vf, vf, 0);
 // CHECK: @llvm.ppc.altivec.vperm
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 1
-// CHECK-LE: sub nsw i32 {{[%_.a-z0-9]+}}, 15
 // CHECK-LE: @llvm.ppc.altivec.vperm
 
   /* vec_sll */
@@ -5189,13 +5157,11 @@
 // CHECK: @llvm.ppc.altivec.vsumsws
 // CHECK-LE: @llvm.ppc.altivec.vperm
 // CHECK-LE: @llvm.ppc.altivec.vsumsws
-// CHECK-LE: @llvm.ppc.altivec.vperm
 
   res_vi = vec_vsumsws(vi, vi);
 // CHECK: @llvm.ppc.altivec.vsumsws
 // CHECK-LE: @llvm.ppc.altivec.vperm
 // CHECK-LE: @llvm.ppc.altivec.vsumsws
-// CHECK-LE: @llvm.ppc.altivec.vperm
 
   /* vec_trunc */
   res_vf = vec_trunc(vf);
diff --git a/test/CodeGen/builtins-ppc-vsx.c b/test/CodeGen/builtins-ppc-vsx.c
new file mode 100644
index 0000000..58a8cc3
--- /dev/null
+++ b/test/CodeGen/builtins-ppc-vsx.c
@@ -0,0 +1,116 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -faltivec -target-feature +vsx -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+vector unsigned char vuc = { 8,  9, 10, 11, 12, 13, 14, 15,
+                             0,  1,  2,  3,  4,  5,  6,  7};
+vector float vf = { -1.5, 2.5, -3.5, 4.5 };
+vector double vd = { 3.5, -7.5 };
+vector signed int vsi = { -1, 2, -3, 4 };
+vector unsigned int vui = { 0, 1, 2, 3 };
+vector signed long long vsll = { 255LL, -937LL };
+vector unsigned long long vull = { 1447LL, 2894LL };
+double d = 23.4;
+
+vector float res_vf;
+vector double res_vd;
+vector signed int res_vsi;
+vector unsigned int res_vui;
+vector signed long long res_vsll;
+vector unsigned long long res_vull;
+double res_d;
+
+void test1() {
+// CHECK-LABEL: define void @test1
+
+  /* vec_div */
+  res_vf = vec_div(vf, vf);
+// CHECK: @llvm.ppc.vsx.xvdivsp
+
+  res_vd = vec_div(vd, vd);
+// CHECK: @llvm.ppc.vsx.xvdivdp
+
+  /* vec_max */
+  res_vf = vec_max(vf, vf);
+// CHECK: @llvm.ppc.vsx.xvmaxsp
+
+  res_vd = vec_max(vd, vd);
+// CHECK: @llvm.ppc.vsx.xvmaxdp
+
+  res_vf = vec_vmaxfp(vf, vf);
+// CHECK: @llvm.ppc.vsx.xvmaxsp
+
+  /* vec_min */
+  res_vf = vec_min(vf, vf);
+// CHECK: @llvm.ppc.vsx.xvminsp
+
+  res_vd = vec_min(vd, vd);
+// CHECK: @llvm.ppc.vsx.xvmindp
+
+  res_vf = vec_vminfp(vf, vf);
+// CHECK: @llvm.ppc.vsx.xvminsp
+
+  res_d = __builtin_vsx_xsmaxdp(d, d);
+// CHECK: @llvm.ppc.vsx.xsmaxdp
+
+  res_d = __builtin_vsx_xsmindp(d, d);
+// CHECK: @llvm.ppc.vsx.xsmindp
+
+  /* vec_perm */
+  res_vsll = vec_perm(vsll, vsll, vuc);
+// CHECK: @llvm.ppc.altivec.vperm
+
+  res_vull = vec_perm(vull, vull, vuc);
+// CHECK: @llvm.ppc.altivec.vperm
+
+  res_vd = vec_perm(vd, vd, vuc);
+// CHECK: @llvm.ppc.altivec.vperm
+
+  res_vsll = vec_vperm(vsll, vsll, vuc);
+// CHECK: @llvm.ppc.altivec.vperm
+
+  res_vull = vec_vperm(vull, vull, vuc);
+// CHECK: @llvm.ppc.altivec.vperm
+
+  res_vd = vec_vperm(vd, vd, vuc);
+// CHECK: @llvm.ppc.altivec.vperm
+
+  /* vec_vsx_ld */
+
+  res_vsi = vec_vsx_ld(0, &vsi);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+
+  res_vui = vec_vsx_ld(0, &vui);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+
+  res_vf = vec_vsx_ld (0, &vf);
+// CHECK: @llvm.ppc.vsx.lxvw4x
+
+  res_vsll = vec_vsx_ld(0, &vsll);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+
+  res_vull = vec_vsx_ld(0, &vull);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+
+  res_vd = vec_vsx_ld(0, &vd);
+// CHECK: @llvm.ppc.vsx.lxvd2x
+
+  /* vec_vsx_st */
+
+  vec_vsx_st(vsi, 0, &res_vsi);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vui, 0, &res_vui);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vf, 0, &res_vf);
+// CHECK: @llvm.ppc.vsx.stxvw4x
+
+  vec_vsx_st(vsll, 0, &res_vsll);
+// CHECK: @llvm.ppc.vsx.stxvd2x
+
+  vec_vsx_st(vull, 0, &res_vull);
+// CHECK: @llvm.ppc.vsx.stxvd2x
+
+  vec_vsx_st(vd, 0, &res_vd);
+// CHECK: @llvm.ppc.vsx.stxvd2x
+}
diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c
index 0f038b8..e9ae834 100644
--- a/test/CodeGen/builtins-x86.c
+++ b/test/CodeGen/builtins-x86.c
@@ -386,7 +386,7 @@
   tmp_V4f = __builtin_ia32_roundss(tmp_V4f, tmp_V4f, imm_i_0_16);
   tmp_V2d = __builtin_ia32_roundsd(tmp_V2d, tmp_V2d, imm_i_0_16);
   tmp_V2d = __builtin_ia32_roundpd(tmp_V2d, imm_i_0_16);
-  tmp_V4f = __builtin_ia32_insertps128(tmp_V4f, tmp_V4f, tmp_i);
+  tmp_V4f = __builtin_ia32_insertps128(tmp_V4f, tmp_V4f, imm_i_0_256);
 #endif
 
   tmp_V4d = __builtin_ia32_addsubpd256(tmp_V4d, tmp_V4d);
diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c
index 39bd84c..1ab29a6 100644
--- a/test/CodeGen/builtins.c
+++ b/test/CodeGen/builtins.c
@@ -171,32 +171,55 @@
 void test_float_builtins(float F, double D, long double LD) {
   volatile int res;
   res = __builtin_isinf(F);
-  // CHECK:  call float @fabsf(float
+  // CHECK:  call float @llvm.fabs.f32(float
   // CHECK:  fcmp oeq float {{.*}}, 0x7FF0000000000000
 
   res = __builtin_isinf(D);
-  // CHECK:  call double @fabs(double
+  // CHECK:  call double @llvm.fabs.f64(double
   // CHECK:  fcmp oeq double {{.*}}, 0x7FF0000000000000
   
   res = __builtin_isinf(LD);
-  // CHECK:  call x86_fp80 @fabsl(x86_fp80
+  // CHECK:  call x86_fp80 @llvm.fabs.f80(x86_fp80
   // CHECK:  fcmp oeq x86_fp80 {{.*}}, 0xK7FFF8000000000000000
   
   res = __builtin_isfinite(F);
   // CHECK: fcmp oeq float 
-  // CHECK: call float @fabsf
+  // CHECK: call float @llvm.fabs.f32(float
   // CHECK: fcmp une float {{.*}}, 0x7FF0000000000000
   // CHECK: and i1 
 
   res = __builtin_isnormal(F);
   // CHECK: fcmp oeq float
-  // CHECK: call float @fabsf
+  // CHECK: call float @llvm.fabs.f32(float
   // CHECK: fcmp ult float {{.*}}, 0x7FF0000000000000
   // CHECK: fcmp uge float {{.*}}, 0x3810000000000000
   // CHECK: and i1
   // CHECK: and i1
 }
 
+// CHECK-LABEL: define void @test_float_builtin_ops
+void test_float_builtin_ops(float F, double D, long double LD) {
+  volatile float resf;
+  volatile double resd;
+  volatile long double resld;
+
+  resf = __builtin_fmodf(F,F);
+  // CHECK: frem float
+
+  resd = __builtin_fmod(D,D);
+  // CHECK: frem double
+
+  resld = __builtin_fmodl(LD,LD);
+  // CHECK: frem x86_fp80
+
+  resf = __builtin_fabsf(F);
+  resd = __builtin_fabs(D);
+  resld = __builtin_fabsl(LD);
+  // CHECK: call float @llvm.fabs.f32(float
+  // CHECK: call double @llvm.fabs.f64(double
+  // CHECK: call x86_fp80 @llvm.fabs.f80(x86_fp80
+}
+
 // CHECK-LABEL: define void @test_builtin_longjmp
 void test_builtin_longjmp(void **buffer) {
   // CHECK: [[BITCAST:%.*]] = bitcast
diff --git a/test/CodeGen/c11atomics.c b/test/CodeGen/c11atomics.c
index 5c761b1..f4c9522 100644
--- a/test/CodeGen/c11atomics.c
+++ b/test/CodeGen/c11atomics.c
@@ -12,6 +12,9 @@
 // they're sufficiently rare that it's not worth making sure that the semantics
 // are correct.
 
+// CHECK: @testStructGlobal = global {{.*}} { i16 1, i16 2, i16 3, i16 4 }
+// CHECK: @testPromotedStructGlobal = global {{.*}} { %{{.*}} { i16 1, i16 2, i16 3 }, [2 x i8] zeroinitializer }
+
 typedef int __attribute__((vector_size(16))) vector;
 
 _Atomic(_Bool) b;
@@ -224,6 +227,7 @@
 }
 
 typedef struct { short x, y, z, w; } S;
+_Atomic S testStructGlobal = (S){1, 2, 3, 4};
 // CHECK: define arm_aapcscc void @testStruct([[S:.*]]*
 void testStruct(_Atomic(S) *fp) {
 // CHECK:      [[FP:%.*]] = alloca [[S]]*, align 4
@@ -272,6 +276,7 @@
 }
 
 typedef struct { short x, y, z; } PS;
+_Atomic PS testPromotedStructGlobal = (PS){1, 2, 3};
 // CHECK: define arm_aapcscc void @testPromotedStruct([[APS:.*]]*
 void testPromotedStruct(_Atomic(PS) *fp) {
 // CHECK:      [[FP:%.*]] = alloca [[APS]]*, align 4
diff --git a/test/CodeGen/captured-statements-nested.c b/test/CodeGen/captured-statements-nested.c
index 2ff9ee9..cd20b5a 100644
--- a/test/CodeGen/captured-statements-nested.c
+++ b/test/CodeGen/captured-statements-nested.c
@@ -11,9 +11,9 @@
 void test_nest_captured_stmt(int param, int size, int param_arr[size]) {
   int w;
   int arr[param][size];
-  // CHECK1: %struct.anon{{.*}} = type { i32*, i32*, i{{.+}}*, i32**, i32* }
-  // CHECK1: %struct.anon{{.*}} = type { i32*, i32*, i32**, i32*, i{{.+}}*, i32**, i32* }
-  // CHECK1: [[T:%struct.anon.*]] = type { i32*, i32*, %struct.A*, i32**, i32*, i{{.+}}*, i32**, i32* }
+  // CHECK1: %struct.anon{{.*}} = type { [[INT:i.+]]*, [[INT]]*, [[SIZE_TYPE:i.+]], [[INT]]**, [[INT]]*, [[SIZE_TYPE]], [[SIZE_TYPE]], [[INT]]* }
+  // CHECK1: %struct.anon{{.*}} = type { [[INT]]*, [[INT]]*, [[INT]]**, [[INT]]*, [[SIZE_TYPE]], [[INT]]**, [[INT]]*, [[SIZE_TYPE]], [[SIZE_TYPE]], [[INT]]* }
+  // CHECK1: [[T:%struct.anon.*]] = type { [[INT]]*, [[INT]]*, %struct.A*, [[INT]]**, [[INT]]*, [[SIZE_TYPE]], [[INT]]**, [[INT]]*, [[SIZE_TYPE]], [[SIZE_TYPE]], [[INT]]* }
   #pragma clang __debug captured
   {
     int x;
@@ -31,39 +31,45 @@
         arr[10][z.a] = 12;
 
         // CHECK1: define internal void @__captured_stmt{{.*}}([[T]]
+        // CHECK1: [[PARAM_ARR_SIZE_REF:%.+]] = getelementptr inbounds [[T]]* {{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 5
+        // CHECK1: [[PARAM_ARR_SIZE:%.+]] = load [[SIZE_TYPE]]* [[PARAM_ARR_SIZE_REF]]
+        // CHECK1: [[ARR_SIZE1_REF:%.+]] = getelementptr inbounds [[T]]* {{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 8
+        // CHECK1: [[ARR_SIZE1:%.+]] = load [[SIZE_TYPE]]* [[ARR_SIZE1_REF]]
+        // CHECK1: [[ARR_SIZE2_REF:%.+]] = getelementptr inbounds [[T]]* {{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 9
+        // CHECK1: [[ARR_SIZE2:%.+]] = load [[SIZE_TYPE]]* [[ARR_SIZE2_REF]]
         //
-        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 2
+        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 2
         // CHECK1-NEXT: load %struct.A**
         // CHECK1-NEXT: getelementptr inbounds %struct.A*
         // CHECK1-NEXT: store i{{.+}} 1
         //
-        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 1
-        // CHECK1-NEXT: load i32**
-        // CHECK1-NEXT: store i32 1
+        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 1
+        // CHECK1-NEXT: load i{{[0-9]+}}**
+        // CHECK1-NEXT: store i{{[0-9]+}} 1
         //
-        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 0
-        // CHECK1-NEXT: load i32**
-        // CHECK1-NEXT: store i32 1
+        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
+        // CHECK1-NEXT: load i{{[0-9]+}}**
+        // CHECK1-NEXT: store i{{[0-9]+}} 1
         //
-        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 4
-        // CHECK1-NEXT: load i32**
-        // CHECK1-NEXT: load i32*
-        // CHECK1-NEXT: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 3
-        // CHECK1-NEXT: load i32***
-        // CHECK1-NEXT: load i32**
-        // CHECK1-NEXT: store i32
+        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 4
+        // CHECK1-NEXT: load i{{[0-9]+}}**
+        // CHECK1-NEXT: load i{{[0-9]+}}*
+        // CHECK1-NEXT: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 3
+        // CHECK1-NEXT: load i{{[0-9]+}}***
+        // CHECK1-NEXT: load i{{[0-9]+}}**
+        // CHECK1-NEXT: store i{{[0-9]+}}
         //
-        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 2
+        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 2
         // CHECK1-NEXT: load %struct.A**
         // CHECK1-NEXT: getelementptr inbounds %struct.A*
         // CHECK1-NEXT: store float
         //
-        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i32 0, i32 2
+        // CHECK1: getelementptr inbounds [[T]]* {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 2
         // CHECK1-NEXT: load %struct.A**
         // CHECK1-NEXT: getelementptr inbounds %struct.A*
         // CHECK1-NEXT: store i8 99
         //
-        // CHECK1: [[SIZE_ADDR_REF:%.*]] = getelementptr inbounds [[T]]* {{.*}}, i{{.+}} 0, i{{.+}} 5
+        // CHECK1: [[SIZE_ADDR_REF:%.*]] = getelementptr inbounds [[T]]* {{.*}}, i{{.+}} 0, i{{.+}} 7
         // CHECK1-DAG: [[SIZE_ADDR:%.*]] = load i{{.+}}** [[SIZE_ADDR_REF]]
         // CHECK1-DAG: [[SIZE:%.*]] = load i{{.+}}* [[SIZE_ADDR]]
         // CHECK1-DAG: [[PARAM_ARR_IDX:%.*]] = sub nsw i{{.+}} [[SIZE]], 1
@@ -77,7 +83,7 @@
         // CHECK1-DAG: [[Z_ADDR:%.*]] = load %struct.A** [[Z_ADDR_REF]]
         // CHECK1-DAG: [[Z_A_ADDR:%.*]] = getelementptr inbounds %struct.A* [[Z_ADDR]], i{{.+}} 0, i{{.+}} 0
         // CHECK1-DAG: [[ARR_IDX_2:%.*]] = load i{{.+}}* [[Z_A_ADDR]]
-        // CHECK1-DAG: [[ARR_ADDR_REF:%.*]] = getelementptr inbounds [[T]]* {{.*}}, i{{.+}} 0, i{{.+}} 7
+        // CHECK1-DAG: [[ARR_ADDR_REF:%.*]] = getelementptr inbounds [[T]]* {{.*}}, i{{.+}} 0, i{{.+}} 10
         // CHECK1-DAG: [[ARR_ADDR:%.*]] = load i{{.+}}** [[ARR_ADDR_REF]]
         // CHECK1-DAG: [[ARR_IDX_1:%.*]] = mul {{.*}} 10
         // CHECK1-DAG: [[ARR_10_ADDR:%.*]] = getelementptr inbounds i{{.+}}* [[ARR_ADDR]], i{{.*}} [[ARR_IDX_1]]
@@ -102,15 +108,15 @@
 
   // CHECK2: define internal void @{{.*}}test_nest_block_block_invoke
   //
-  // CHECK2: [[Z:%[0-9a-z_]*]] = alloca i32
+  // CHECK2: [[Z:%[0-9a-z_]*]] = alloca i{{[0-9]+}},
   // CHECK2: alloca %struct.anon{{.*}}
   //
-  // CHECK2: store i32
-  // CHECK2: store i32* [[Z]]
+  // CHECK2: store i{{[0-9]+}}
+  // CHECK2: store i{{[0-9]+}}* [[Z]]
   //
   // CHECK2: getelementptr inbounds %struct.anon
   // CHECK2-NEXT: getelementptr inbounds
-  // CHECK2-NEXT: store i32*
+  // CHECK2-NEXT: store i{{[0-9]+}}*
   //
   // CHECK2: call void @__captured_stmt
 
@@ -128,22 +134,22 @@
   }
 
   // CHECK2: alloca %struct.__block_byref_b
-  // CHECK2-NEXT: [[C:%[0-9a-z_]*]] = alloca i32
+  // CHECK2-NEXT: [[C:%[0-9a-z_]*]] = alloca i{{[0-9]+}}
   // CHECK2-NEXT: alloca %struct.__block_byref_d
   //
   // CHECK2: bitcast %struct.__block_byref_b*
   // CHECK2-NEXT: store i8*
   //
-  // CHECK2: [[CapA:%[0-9a-z_.]*]] = getelementptr inbounds {{.*}}, i32 0, i32 7
+  // CHECK2: [[CapA:%[0-9a-z_.]*]] = getelementptr inbounds {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 7
   //
-  // CHECK2: getelementptr inbounds %struct.anon{{.*}}, i32 0, i32 0
-  // CHECK2: load i32**
-  // CHECK2: load i32*
-  // CHECK2: store i32 {{.*}}, i32* [[CapA]]
+  // CHECK2: getelementptr inbounds %struct.anon{{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
+  // CHECK2: load i{{[0-9]+}}**
+  // CHECK2: load i{{[0-9]+}}*
+  // CHECK2: store i{{[0-9]+}} {{.*}}, i{{[0-9]+}}* [[CapA]]
   //
-  // CHECK2: [[CapC:%[0-9a-z_.]*]] = getelementptr inbounds {{.*}}, i32 0, i32 8
-  // CHECK2-NEXT: [[Val:%[0-9a-z_]*]] = load i32* [[C]]
-  // CHECK2-NEXT: store i32 [[Val]], i32* [[CapC]]
+  // CHECK2: [[CapC:%[0-9a-z_.]*]] = getelementptr inbounds {{.*}}, i{{[0-9]+}} 0, i{{[0-9]+}} 8
+  // CHECK2-NEXT: [[Val:%[0-9a-z_]*]] = load i{{[0-9]+}}* [[C]]
+  // CHECK2-NEXT: store i{{[0-9]+}} [[Val]], i{{[0-9]+}}* [[CapC]]
   //
   // CHECK2: bitcast %struct.__block_byref_d*
   // CHECK2-NEXT: store i8*
diff --git a/test/CodeGen/captured-statements.c b/test/CodeGen/captured-statements.c
index 85d597a..52747fb 100644
--- a/test/CodeGen/captured-statements.c
+++ b/test/CodeGen/captured-statements.c
@@ -4,6 +4,8 @@
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
 
+typedef __INTPTR_TYPE__ intptr_t;
+
 int foo();
 int global;
 
@@ -61,15 +63,16 @@
 }
 
 // Capture VLA array
-void test4(int size, int vla_arr[size]) {
+void test4(intptr_t size, intptr_t vla_arr[size]) {
   #pragma clang __debug captured
   {
     vla_arr[0] = 1;
   }
-  // CHECK-3: test4([[INT:i.+]] {{.*}}[[SIZE:%.+]], [[INT]]*
-  // CHECK-3: store [[INT]] {{.*}}[[SIZE]], [[INT]]* [[SIZE_ADDR:%.+]],
+  // CHECK-3: test4([[INTPTR_T:i.+]] {{.*}}[[SIZE_ARG:%.+]], [[INTPTR_T]]*
+  // CHECK-3: store [[INTPTR_T]] {{.*}}[[SIZE_ARG]], [[INTPTR_T]]* [[SIZE_ADDR:%.+]],
+  // CHECK-3: [[SIZE:%.+]] = load [[INTPTR_T]]* [[SIZE_ADDR]],
   // CHECK-3: [[REF:%.+]] = getelementptr inbounds
-  // CHECK-3: store [[INT]]* [[SIZE_ADDR]], [[INT]]** [[REF]]
+  // CHECK-3: store [[INTPTR_T]] [[SIZE]], [[INTPTR_T]]* [[REF]]
   // CHECK-3: call void @__captured_stmt
 }
 
diff --git a/test/CodeGen/catch-undef-behavior.c b/test/CodeGen/catch-undef-behavior.c
index 9be2614..3d2697d 100644
--- a/test/CodeGen/catch-undef-behavior.c
+++ b/test/CodeGen/catch-undef-behavior.c
@@ -1,61 +1,49 @@
-// RUN: %clang_cc1 -fsanitize=alignment,null,object-size,shift,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 -fsanitize-undefined-trap-on-error -fsanitize=alignment,null,object-size,shift,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-TRAP
+// RUN: %clang_cc1 -fsanitize=alignment,null,object-size,shift,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-COMMON --check-prefix=CHECK-UBSAN
+// RUN: %clang_cc1 -fsanitize-undefined-trap-on-error -fsanitize=alignment,null,object-size,shift,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-COMMON --check-prefix=CHECK-TRAP
 // RUN: %clang_cc1 -fsanitize=null -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-NULL
 // RUN: %clang_cc1 -fsanitize=signed-integer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-OVERFLOW
 
-// CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
+// CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 
 // FIXME: When we only emit each type once, use [[INT]] more below.
-// CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
-// CHECK: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
-// CHECK: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
-// CHECK: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
-// CHECK: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 4, i8 0 }
-// CHECK: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 4, i8 1 }
+// CHECK-UBSAN: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]], i64 4, i8 1
+// CHECK-UBSAN: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 10 {{.*}}, i64 4, i8 0
+// CHECK-UBSAN: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
+// CHECK-UBSAN: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 12 {{.*}} @{{.*}}, {{.*}} @{{.*}}
+// CHECK-UBSAN: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 10 {{.*}} @{{.*}}, i64 4, i8 0 }
+// CHECK-UBSAN: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 3 {{.*}} @{{.*}}, i64 4, i8 1 }
 
-// CHECK: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, [11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
+// CHECK-UBSAN: @[[STRUCT_S:.*]] = private unnamed_addr constant { i16, i16, [11 x i8] } { i16 -1, i16 0, [11 x i8] c"'struct S'\00" }
 
-// CHECK: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
-// CHECK: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
-// CHECK: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 14 {{.*}} @[[STRUCT_S]], i64 4, i8 3 }
+// CHECK-UBSAN: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 12 {{.*}} @{{.*}} }
+// CHECK-UBSAN: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 11 {{.*}} @{{.*}} }
 
 // CHECK-NULL: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}}
 
 // PR6805
-// CHECK: @foo
-// CHECK-NULL: @foo
-// CHECK-TRAP: @foo
+// CHECK-COMMON-LABEL: @foo
+// CHECK-NULL-LABEL: @foo
 void foo() {
   union { int i; } u;
-  // CHECK:      %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
-  // CHECK-TRAP: %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
+  // CHECK-COMMON:      %[[CHECK0:.*]] = icmp ne {{.*}}* %[[PTR:.*]], null
 
-  // CHECK:      %[[I8PTR:.*]] = bitcast i32* %[[PTR]] to i8*
-  // CHECK-NEXT: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* %[[I8PTR]], i1 false)
-  // CHECK-NEXT: %[[CHECK1:.*]] = icmp uge i64 %[[SIZE]], 4
-  // CHECK-NEXT: %[[CHECK01:.*]] = and i1 %[[CHECK0]], %[[CHECK1]]
+  // CHECK-COMMON:      %[[I8PTR:.*]] = bitcast i32* %[[PTR]] to i8*
+  // CHECK-COMMON-NEXT: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* %[[I8PTR]], i1 false)
+  // CHECK-COMMON-NEXT: %[[CHECK1:.*]] = icmp uge i64 %[[SIZE]], 4
 
-  // CHECK-TRAP:      %[[I8PTR:.*]] = bitcast i32* %[[PTR]] to i8*
-  // CHECK-TRAP-NEXT: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* %[[I8PTR]], i1 false)
-  // CHECK-TRAP-NEXT: %[[CHECK1:.*]] = icmp uge i64 %[[SIZE]], 4
-  // CHECK-TRAP-NEXT: %[[CHECK01:.*]] = and i1 %[[CHECK0]], %[[CHECK1]]
+  // CHECK-COMMON:      %[[PTRTOINT:.*]] = ptrtoint {{.*}}* %[[PTR]] to i64
+  // CHECK-COMMON-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRTOINT]], 3
+  // CHECK-COMMON-NEXT: %[[CHECK2:.*]] = icmp eq i64 %[[MISALIGN]], 0
 
-  // CHECK:      %[[PTRTOINT:.*]] = ptrtoint {{.*}}* %[[PTR]] to i64
-  // CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRTOINT]], 3
-  // CHECK-NEXT: %[[CHECK2:.*]] = icmp eq i64 %[[MISALIGN]], 0
+  // CHECK-COMMON:       %[[CHECK01:.*]] = and i1 %[[CHECK0]], %[[CHECK1]]
+  // CHECK-COMMON-NEXT:  %[[OK:.*]] = and i1 %[[CHECK01]], %[[CHECK2]]
 
-  // CHECK-TRAP:      %[[PTRTOINT:.*]] = ptrtoint {{.*}}* %[[PTR]] to i64
-  // CHECK-TRAP-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRTOINT]], 3
-  // CHECK-TRAP-NEXT: %[[CHECK2:.*]] = icmp eq i64 %[[MISALIGN]], 0
+  // CHECK-UBSAN: br i1 %[[OK]], {{.*}} !prof ![[WEIGHT_MD:.*]], !nosanitize
+  // CHECK-TRAP:  br i1 %[[OK]], {{.*}}
 
-  // CHECK:      %[[OK:.*]] = and i1 %[[CHECK01]], %[[CHECK2]]
-  // CHECK-NEXT: br i1 %[[OK]], {{.*}} !prof ![[WEIGHT_MD:.*]]
-
-  // CHECK-TRAP:      %[[OK:.*]] = and i1 %[[CHECK01]], %[[CHECK2]]
-  // CHECK-TRAP-NEXT: br i1 %[[OK]], {{.*}}
-
-  // CHECK:      %[[ARG:.*]] = ptrtoint {{.*}} %[[PTR]] to i64
-  // CHECK-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), i64 %[[ARG]])
+  // CHECK-UBSAN:      %[[ARG:.*]] = ptrtoint {{.*}} %[[PTR]] to i64
+  // CHECK-UBSAN-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), i64 %[[ARG]])
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW:#[0-9]+]]
   // CHECK-TRAP-NEXT: unreachable
@@ -68,25 +56,17 @@
   u.i=1;
 }
 
-// CHECK: @bar
-// CHECK-TRAP: @bar
+// CHECK-COMMON-LABEL: @bar
 int bar(int *a) {
-  // CHECK:      %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
-  // CHECK-NEXT: icmp uge i64 %[[SIZE]], 4
+  // CHECK-COMMON:      %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
+  // CHECK-COMMON-NEXT: icmp uge i64 %[[SIZE]], 4
 
-  // CHECK-TRAP:      %[[SIZE:.*]] = call i64 @llvm.objectsize.i64
-  // CHECK-TRAP-NEXT: icmp uge i64 %[[SIZE]], 4
+  // CHECK-COMMON:      %[[PTRINT:.*]] = ptrtoint
+  // CHECK-COMMON-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3
+  // CHECK-COMMON-NEXT: icmp eq i64 %[[MISALIGN]], 0
 
-  // CHECK:      %[[PTRINT:.*]] = ptrtoint
-  // CHECK-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3
-  // CHECK-NEXT: icmp eq i64 %[[MISALIGN]], 0
-
-  // CHECK-TRAP:      %[[PTRINT:.*]] = ptrtoint
-  // CHECK-TRAP-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3
-  // CHECK-TRAP-NEXT: icmp eq i64 %[[MISALIGN]], 0
-
-  // CHECK:      %[[ARG:.*]] = ptrtoint
-  // CHECK-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), i64 %[[ARG]])
+  // CHECK-UBSAN:      %[[ARG:.*]] = ptrtoint
+  // CHECK-UBSAN-NEXT: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), i64 %[[ARG]])
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
@@ -95,85 +75,62 @@
   return *a;
 }
 
-// CHECK: @addr_space
+// CHECK-UBSAN-LABEL: @addr_space
 int addr_space(int __attribute__((address_space(256))) *a) {
-  // CHECK-NOT: __ubsan
+  // CHECK-UBSAN-NOT: __ubsan
   return *a;
 }
 
-// CHECK: @lsh_overflow
-// CHECK-TRAP: @lsh_overflow
+// CHECK-COMMON-LABEL: @lsh_overflow
 int lsh_overflow(int a, int b) {
-  // CHECK:      %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
-  // CHECK-NEXT: br i1 %[[INBOUNDS]], label %[[CHECKBB:.*]], label %[[CONTBB:.*]]
+  // CHECK-COMMON:      %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]], label %[[CHECKBB:.*]], label %[[CONTBB:.*]]
 
-  // CHECK-TRAP:      %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]], label %[[CHECKBB:.*]], label %[[CONTBB:.*]]
+  // CHECK-COMMON:      %[[SHIFTED_OUT_WIDTH:.*]] = sub nuw nsw i32 31, %[[RHS]]
+  // CHECK-COMMON-NEXT: %[[SHIFTED_OUT:.*]] = lshr i32 %[[LHS:.*]], %[[SHIFTED_OUT_WIDTH]]
+  // CHECK-COMMON-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT]], 0
+  // CHECK-COMMON-NEXT: br label %[[CONTBB]]
 
-  // CHECK:      %[[SHIFTED_OUT_WIDTH:.*]] = sub nuw nsw i32 31, %[[RHS]]
-  // CHECK-NEXT: %[[SHIFTED_OUT:.*]] = lshr i32 %[[LHS:.*]], %[[SHIFTED_OUT_WIDTH]]
-  // CHECK-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT]], 0
-  // CHECK-NEXT: br label %[[CONTBB]]
+  // CHECK-COMMON:      %[[VALID:.*]] = phi i1 [ %[[INBOUNDS]], {{.*}} ], [ %[[NO_OVERFLOW]], %[[CHECKBB]] ]
+  // CHECK-UBSAN: br i1 %[[VALID]], {{.*}} !prof ![[WEIGHT_MD]]
+  // CHECK-TRAP:  br i1 %[[VALID]]
 
-  // CHECK-TRAP:      %[[SHIFTED_OUT_WIDTH:.*]] = sub nuw nsw i32 31, %[[RHS]]
-  // CHECK-TRAP-NEXT: %[[SHIFTED_OUT:.*]] = lshr i32 %[[LHS:.*]], %[[SHIFTED_OUT_WIDTH]]
-  // CHECK-TRAP-NEXT: %[[NO_OVERFLOW:.*]] = icmp eq i32 %[[SHIFTED_OUT]], 0
-  // CHECK-TRAP-NEXT: br label %[[CONTBB]]
-
-  // CHECK:      %[[VALID:.*]] = phi i1 [ %[[INBOUNDS]], {{.*}} ], [ %[[NO_OVERFLOW]], %[[CHECKBB]] ]
-  // CHECK-NEXT: br i1 %[[VALID]], {{.*}} !prof ![[WEIGHT_MD]]
-
-  // CHECK-TRAP:      %[[VALID:.*]] = phi i1 [ %[[INBOUNDS]], {{.*}} ], [ %[[NO_OVERFLOW]], %[[CHECKBB]] ]
-  // CHECK-TRAP-NEXT: br i1 %[[VALID]]
-
-
-  // CHECK:      %[[ARG1:.*]] = zext
-  // CHECK-NEXT: %[[ARG2:.*]] = zext
-  // CHECK-NEXT: call void @__ubsan_handle_shift_out_of_bounds(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), i64 %[[ARG1]], i64 %[[ARG2]])
-  // CHECK-NOT:  call void @__ubsan_handle_shift_out_of_bounds
+  // CHECK-UBSAN:      %[[ARG1:.*]] = zext
+  // CHECK-UBSAN-NEXT: %[[ARG2:.*]] = zext
+  // CHECK-UBSAN-NEXT: call void @__ubsan_handle_shift_out_of_bounds(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), i64 %[[ARG1]], i64 %[[ARG2]])
+  // CHECK-UBSAN-NOT:  call void @__ubsan_handle_shift_out_of_bounds
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP:      unreachable
   // CHECK-TRAP-NOT:  call void @llvm.trap()
 
-  // CHECK:      %[[RET:.*]] = shl i32 %[[LHS]], %[[RHS]]
-  // CHECK-NEXT: ret i32 %[[RET]]
-
-  // CHECK-TRAP:      %[[RET:.*]] = shl i32 %[[LHS]], %[[RHS]]
-  // CHECK-TRAP-NEXT: ret i32 %[[RET]]
+  // CHECK-COMMON:      %[[RET:.*]] = shl i32 %[[LHS]], %[[RHS]]
+  // CHECK-COMMON-NEXT: ret i32 %[[RET]]
 #line 300
   return a << b;
 }
 
-// CHECK: @rsh_inbounds
-// CHECK-TRAP: @rsh_inbounds
+// CHECK-COMMON-LABEL: @rsh_inbounds
 int rsh_inbounds(int a, int b) {
-  // CHECK:      %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
-  // CHECK:      br i1 %[[INBOUNDS]]
+  // CHECK-COMMON:      %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
+  // CHECK-COMMON:      br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
-  // CHECK-TRAP: br i1 %[[INBOUNDS]]
-
-  // CHECK:      %[[ARG1:.*]] = zext
-  // CHECK-NEXT: %[[ARG2:.*]] = zext
-  // CHECK-NEXT: call void @__ubsan_handle_shift_out_of_bounds(i8* bitcast ({{.*}} @[[LINE_400]] to i8*), i64 %[[ARG1]], i64 %[[ARG2]])
+  // CHECK-UBSAN:      %[[ARG1:.*]] = zext
+  // CHECK-UBSAN-NEXT: %[[ARG2:.*]] = zext
+  // CHECK-UBSAN-NEXT: call void @__ubsan_handle_shift_out_of_bounds(i8* bitcast ({{.*}} @[[LINE_400]] to i8*), i64 %[[ARG1]], i64 %[[ARG2]])
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
 
-  // CHECK:      %[[RET:.*]] = ashr i32 %[[LHS]], %[[RHS]]
-  // CHECK-NEXT: ret i32 %[[RET]]
-
-  // CHECK-TRAP:      %[[RET:.*]] = ashr i32 %[[LHS]], %[[RHS]]
-  // CHECK-TRAP-NEXT: ret i32 %[[RET]]
+  // CHECK-COMMON:      %[[RET:.*]] = ashr i32 %[[LHS]], %[[RHS]]
+  // CHECK-COMMON-NEXT: ret i32 %[[RET]]
 #line 400
   return a >> b;
 }
 
-// CHECK: @load
-// CHECK-TRAP: @load
+// CHECK-COMMON-LABEL: @load
 int load(int *p) {
-  // CHECK: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_500]] to i8*), i64 %{{.*}})
+  // CHECK-UBSAN: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_500]] to i8*), i64 %{{.*}})
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
@@ -181,10 +138,9 @@
   return *p;
 }
 
-// CHECK: @store
-// CHECK-TRAP: @store
+// CHECK-COMMON-LABEL: @store
 void store(int *p, int q) {
-  // CHECK: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_600]] to i8*), i64 %{{.*}})
+  // CHECK-UBSAN: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_600]] to i8*), i64 %{{.*}})
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
@@ -194,10 +150,9 @@
 
 struct S { int k; };
 
-// CHECK: @member_access
-// CHECK-TRAP: @member_access
+// CHECK-COMMON-LABEL: @member_access
 int *member_access(struct S *p) {
-  // CHECK: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_700]] to i8*), i64 %{{.*}})
+  // CHECK-UBSAN: call void @__ubsan_handle_type_mismatch(i8* bitcast ({{.*}} @[[LINE_700]] to i8*), i64 %{{.*}})
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
@@ -205,12 +160,11 @@
   return &p->k;
 }
 
-// CHECK: @signed_overflow
-// CHECK-TRAP: @signed_overflow
+// CHECK-COMMON-LABEL: @signed_overflow
 int signed_overflow(int a, int b) {
-  // CHECK:      %[[ARG1:.*]] = zext
-  // CHECK-NEXT: %[[ARG2:.*]] = zext
-  // CHECK-NEXT: call void @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_800]] to i8*), i64 %[[ARG1]], i64 %[[ARG2]])
+  // CHECK-UBSAN:      %[[ARG1:.*]] = zext
+  // CHECK-UBSAN-NEXT: %[[ARG2:.*]] = zext
+  // CHECK-UBSAN-NEXT: call void @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_800]] to i8*), i64 %[[ARG1]], i64 %[[ARG2]])
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
@@ -218,220 +172,213 @@
   return a + b;
 }
 
-// CHECK: @no_return
-// CHECK-TRAP: @no_return
+// CHECK-COMMON-LABEL: @no_return
 int no_return() {
   // Reaching the end of a noreturn function is fine in C.
   // FIXME: If the user explicitly requests -fsanitize=return, we should catch
   //        that here even though it's not undefined behavior.
-  // CHECK-NOT: call
-  // CHECK-NOT: unreachable
-  // CHECK: ret i32
-
-  // CHECK-TRAP-NOT: call
-  // CHECK-TRAP-NOT: unreachable
-  // CHECK-TRAP: ret i32
+  // CHECK-COMMON-NOT: call
+  // CHECK-COMMON-NOT: unreachable
+  // CHECK-COMMON: ret i32
 }
 
-// CHECK: @vla_bound
+// CHECK-UBSAN-LABEL: @vla_bound
 void vla_bound(int n) {
-  // CHECK:      icmp sgt i32 %[[PARAM:.*]], 0
+  // CHECK-UBSAN:      icmp sgt i32 %[[PARAM:.*]], 0
   //
-  // CHECK:      %[[ARG:.*]] = zext i32 %[[PARAM]] to i64
-  // CHECK-NEXT: call void @__ubsan_handle_vla_bound_not_positive(i8* bitcast ({{.*}} @[[LINE_900]] to i8*), i64 %[[ARG]])
+  // CHECK-UBSAN:      %[[ARG:.*]] = zext i32 %[[PARAM]] to i64
+  // CHECK-UBSAN-NEXT: call void @__ubsan_handle_vla_bound_not_positive(i8* bitcast ({{.*}} @[[LINE_900]] to i8*), i64 %[[ARG]])
 #line 900
   int arr[n * 3];
 }
 
-// CHECK: @int_float_no_overflow
+// CHECK-UBSAN-LABEL: @int_float_no_overflow
 float int_float_no_overflow(__int128 n) {
-  // CHECK-NOT: call void @__ubsan_handle
+  // CHECK-UBSAN-NOT: call void @__ubsan_handle
   return n;
 }
 
-// CHECK: @int_float_overflow
-// CHECK-TRAP: @int_float_overflow
+// CHECK-COMMON-LABEL: @int_float_overflow
 float int_float_overflow(unsigned __int128 n) {
   // This is 2**104. FLT_MAX is 2**128 - 2**104.
-  // CHECK: icmp ule i128 %{{.*}}, -20282409603651670423947251286016
-  // CHECK: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = icmp ule i128 %{{.*}}, -20282409603651670423947251286016
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = icmp ule i128 %{{.*}}, -20282409603651670423947251286016
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   return n;
 }
 
-// CHECK: @int_fp16_overflow
-// CHECK-TRAP: @int_fp16_overflow
+// CHECK-COMMON-LABEL: @int_fp16_overflow
 void int_fp16_overflow(int n, __fp16 *p) {
-  // CHECK: %[[GE:.*]] = icmp sge i32 %{{.*}}, -65504
-  // CHECK: %[[LE:.*]] = icmp sle i32 %{{.*}}, 65504
-  // CHECK: and i1 %[[GE]], %[[LE]]
-  // CHECK: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-COMMON: %[[GE:.*]] = icmp sge i32 %{{.*}}, -65504
+  // CHECK-COMMON: %[[LE:.*]] = icmp sle i32 %{{.*}}, 65504
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[GE:.*]] = icmp sge i32 %{{.*}}, -65504
-  // CHECK-TRAP: %[[LE:.*]] = icmp sle i32 %{{.*}}, 65504
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   *p = n;
 }
 
-// CHECK: @float_int_overflow
-// CHECK-TRAP: @float_int_overflow
+// CHECK-COMMON-LABEL: @float_int_overflow
 int float_int_overflow(float f) {
-  // CHECK: %[[GE:.*]] = fcmp ogt float %[[F:.*]], 0xC1E0000020000000
-  // CHECK: %[[LE:.*]] = fcmp olt float %[[F]], 0x41E0000000000000
-  // CHECK: and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON: %[[GE:.*]] = fcmp ogt float %[[F:.*]], 0xC1E0000020000000
+  // CHECK-COMMON: %[[LE:.*]] = fcmp olt float %[[F]], 0x41E0000000000000
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK: %[[CAST:.*]] = bitcast float %[[F]] to i32
-  // CHECK: %[[ARG:.*]] = zext i32 %[[CAST]] to i64
-  // CHECK: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
-
-  // CHECK-TRAP: %[[GE:.*]] = fcmp ogt float %[[F:.*]], 0xC1E0000020000000
-  // CHECK-TRAP: %[[LE:.*]] = fcmp olt float %[[F]], 0x41E0000000000000
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: %[[CAST:.*]] = bitcast float %[[F]] to i32
+  // CHECK-UBSAN: %[[ARG:.*]] = zext i32 %[[CAST]] to i64
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   return f;
 }
 
-// CHECK: @long_double_int_overflow
-// CHECK-TRAP: @long_double_int_overflow
+// CHECK-COMMON-LABEL: @long_double_int_overflow
 int long_double_int_overflow(long double ld) {
-  // CHECK: alloca x86_fp80
-  // CHECK: %[[GE:.*]] = fcmp ogt x86_fp80 %[[F:.*]], 0xKC01E8000000100000000
-  // CHECK: %[[LE:.*]] = fcmp olt x86_fp80 %[[F]], 0xK401E8000000000000000
-  // CHECK: and i1 %[[GE]], %[[LE]]
+  // CHECK-UBSAN: alloca x86_fp80
 
-  // CHECK: store x86_fp80 %[[F]], x86_fp80* %[[ALLOCA:.*]]
-  // CHECK: %[[ARG:.*]] = ptrtoint x86_fp80* %[[ALLOCA]] to i64
-  // CHECK: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
+  // CHECK-COMMON: %[[GE:.*]] = fcmp ogt x86_fp80 %[[F:.*]], 0xKC01E800000010000000
+  // CHECK-COMMON: %[[LE:.*]] = fcmp olt x86_fp80 %[[F]], 0xK401E800000000000000
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[GE:.*]] = fcmp ogt x86_fp80 %[[F:.*]], 0xKC01E800000010000000
-  // CHECK-TRAP: %[[LE:.*]] = fcmp olt x86_fp80 %[[F]], 0xK401E800000000000000
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: store x86_fp80 %[[F]], x86_fp80* %[[ALLOCA:.*]], !nosanitize
+  // CHECK-UBSAN: %[[ARG:.*]] = ptrtoint x86_fp80* %[[ALLOCA]] to i64
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow({{.*}}, i64 %[[ARG]]
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   return ld;
 }
 
-// CHECK: @float_uint_overflow
-// CHECK-TRAP: @float_uint_overflow
+// CHECK-COMMON-LABEL: @float_uint_overflow
 unsigned float_uint_overflow(float f) {
-  // CHECK: %[[GE:.*]] = fcmp ogt float %[[F:.*]], -1.{{0*}}e+00
-  // CHECK: %[[LE:.*]] = fcmp olt float %[[F]], 0x41F0000000000000
-  // CHECK: and i1 %[[GE]], %[[LE]]
-  // CHECK: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-COMMON: %[[GE:.*]] = fcmp ogt float %[[F:.*]], -1.{{0*}}e+00
+  // CHECK-COMMON: %[[LE:.*]] = fcmp olt float %[[F]], 0x41F0000000000000
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[GE:.*]] = fcmp ogt float %[[F:.*]], -1.{{0*}}e+00
-  // CHECK-TRAP: %[[LE:.*]] = fcmp olt float %[[F]], 0x41F0000000000000
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   return f;
 }
 
-// CHECK: @fp16_char_overflow
-// CHECK-TRAP: @fp16_char_overflow
+// CHECK-COMMON-LABEL: @fp16_char_overflow
 signed char fp16_char_overflow(__fp16 *p) {
-  // CHECK: %[[GE:.*]] = fcmp ogt float %[[F:.*]], -1.29{{0*}}e+02
-  // CHECK: %[[LE:.*]] = fcmp olt float %[[F]], 1.28{{0*}}e+02
-  // CHECK: and i1 %[[GE]], %[[LE]]
-  // CHECK: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-COMMON: %[[GE:.*]] = fcmp ogt float %[[F:.*]], -1.29{{0*}}e+02
+  // CHECK-COMMON: %[[LE:.*]] = fcmp olt float %[[F]], 1.28{{0*}}e+02
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[GE:.*]] = fcmp ogt float %[[F:.*]], -1.29{{0*}}e+02
-  // CHECK-TRAP: %[[LE:.*]] = fcmp olt float %[[F]], 1.28{{0*}}e+02
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   return *p;
 }
 
-// CHECK: @float_float_overflow
-// CHECK-TRAP: @float_float_overflow
+// CHECK-COMMON-LABEL: @float_float_overflow
 float float_float_overflow(double f) {
-  // CHECK: %[[F:.*]] = call double @llvm.fabs.f64(
-  // CHECK: %[[GE:.*]] = fcmp ogt double %[[F]], 0x47EFFFFFE0000000
-  // CHECK: %[[LE:.*]] = fcmp olt double %[[F]], 0x7FF0000000000000
-  // CHECK: and i1 %[[GE]], %[[LE]]
-  // CHECK: call void @__ubsan_handle_float_cast_overflow(
+  // CHECK-COMMON: %[[F:.*]] = call double @llvm.fabs.f64(
+  // CHECK-COMMON: %[[GE:.*]] = fcmp ogt double %[[F]], 0x47EFFFFFE0000000
+  // CHECK-COMMON: %[[LE:.*]] = fcmp olt double %[[F]], 0x7FF0000000000000
+  // CHECK-COMMON: %[[OUTOFBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
+  // CHECK-COMMON: %[[INBOUNDS:.*]] = xor i1 %[[OUTOFBOUNDS]], true
+  // CHECK-COMMON-NEXT: br i1 %[[INBOUNDS]]
 
-  // CHECK-TRAP: %[[F:.*]] = call double @llvm.fabs.f64(
-  // CHECK-TRAP: %[[GE:.*]] = fcmp ogt double %[[F]], 0x47EFFFFFE0000000
-  // CHECK-TRAP: %[[LE:.*]] = fcmp olt double %[[F]], 0x7FF0000000000000
-  // CHECK-TRAP: %[[OUTOFBOUNDS:.*]] = and i1 %[[GE]], %[[LE]]
-  // CHECK-TRAP: %[[INBOUNDS:.*]] = xor i1 %[[OUTOFBOUNDS]], true
-  // CHECK-TRAP-NEXT: br i1 %[[INBOUNDS]]
+  // CHECK-UBSAN: call void @__ubsan_handle_float_cast_overflow(
 
   // CHECK-TRAP:      call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP-NEXT: unreachable
   return f;
 }
 
-// CHECK:          @int_divide_overflow
-// CHECK-OVERFLOW: @int_divide_overflow
+// CHECK-COMMON-LABEL:   @int_divide_overflow
+// CHECK-OVERFLOW-LABEL: @int_divide_overflow
 int int_divide_overflow(int a, int b) {
-  // CHECK:               %[[ZERO:.*]] = icmp ne i32 %[[B:.*]], 0
+  // CHECK-COMMON:         %[[ZERO:.*]] = icmp ne i32 %[[B:.*]], 0
   // CHECK-OVERFLOW-NOT:  icmp ne i32 %{{.*}}, 0
-  // CHECK-TRAP:          %[[ZERO:.*]] = icmp ne i32 %[[B:.*]], 0
 
-  // CHECK:               %[[AOK:.*]] = icmp ne i32 %[[A:.*]], -2147483648
-  // CHECK-NEXT:          %[[BOK:.*]] = icmp ne i32 %[[B]], -1
-  // CHECK-NEXT:          %[[OVER:.*]] = or i1 %[[AOK]], %[[BOK]]
+  // CHECK-COMMON:               %[[AOK:.*]] = icmp ne i32 %[[A:.*]], -2147483648
+  // CHECK-COMMON-NEXT:          %[[BOK:.*]] = icmp ne i32 %[[B]], -1
+  // CHECK-COMMON-NEXT:          %[[OVER:.*]] = or i1 %[[AOK]], %[[BOK]]
+  // CHECK-COMMON:         %[[OK:.*]] = and i1 %[[ZERO]], %[[OVER]]
+  // CHECK-COMMON:         br i1 %[[OK]]
 
   // CHECK-OVERFLOW:      %[[AOK:.*]] = icmp ne i32 %[[A:.*]], -2147483648
   // CHECK-OVERFLOW-NEXT: %[[BOK:.*]] = icmp ne i32 %[[B:.*]], -1
   // CHECK-OVERFLOW-NEXT: %[[OK:.*]] = or i1 %[[AOK]], %[[BOK]]
-
-  // CHECK-TRAP:          %[[AOK:.*]] = icmp ne i32 %[[A:.*]], -2147483648
-  // CHECK-TRAP-NEXT:     %[[BOK:.*]] = icmp ne i32 %[[B]], -1
-  // CHECK-TRAP-NEXT:     %[[OVER:.*]] = or i1 %[[AOK]], %[[BOK]]
-
-  // CHECK:               %[[OK:.*]] = and i1 %[[ZERO]], %[[OVER]]
-
-  // CHECK:               br i1 %[[OK]]
   // CHECK-OVERFLOW:      br i1 %[[OK]]
 
-  // CHECK-TRAP:          %[[OK:.*]] = and i1 %[[ZERO]], %[[OVER]]
-  // CHECK-TRAP:          br i1 %[[OK]]
-
   // CHECK-TRAP: call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP: unreachable
   return a / b;
 
-  // CHECK:          }
+  // CHECK-COMMON:          }
   // CHECK-OVERFLOW: }
-  // CHECK-TRAP:     }
 }
 
-// CHECK: @sour_bool
+// CHECK-COMMON-LABEL: @sour_bool
 _Bool sour_bool(_Bool *p) {
-  // CHECK: %[[OK:.*]] = icmp ule i8 {{.*}}, 1
-  // CHECK: br i1 %[[OK]]
-  // CHECK: call void @__ubsan_handle_load_invalid_value(i8* bitcast ({{.*}}), i64 {{.*}})
+  // CHECK-COMMON: %[[OK:.*]] = icmp ule i8 {{.*}}, 1
+  // CHECK-COMMON: br i1 %[[OK]]
 
-  // CHECK-TRAP: %[[OK:.*]] = icmp ule i8 {{.*}}, 1
-  // CHECK-TRAP: br i1 %[[OK]]
+  // CHECK-UBSAN: call void @__ubsan_handle_load_invalid_value(i8* bitcast ({{.*}}), i64 {{.*}})
 
   // CHECK-TRAP: call void @llvm.trap() [[NR_NUW]]
   // CHECK-TRAP: unreachable
   return *p;
 }
 
-// CHECK: ![[WEIGHT_MD]] = metadata !{metadata !"branch_weights", i32 1048575, i32 1}
+// CHECK-COMMON-LABEL: @ret_nonnull
+__attribute__((returns_nonnull))
+int *ret_nonnull(int *a) {
+  // CHECK-COMMON: [[OK:%.*]] = icmp ne i32* {{.*}}, null
+  // CHECK-COMMON: br i1 [[OK]]
+
+  // CHECK-UBSAN: call void @__ubsan_handle_nonnull_return
+
+  // CHECK-TRAP: call void @llvm.trap() [[NR_NUW]]
+  // CHECK-TRAP: unreachable
+  return a;
+}
+
+// CHECK-COMMON-LABEL: @call_decl_nonnull
+__attribute__((nonnull)) void decl_nonnull(int *a);
+void call_decl_nonnull(int *a) {
+  // CHECK-COMMON: [[OK:%.*]] = icmp ne i32* {{.*}}, null
+  // CHECK-COMMON: br i1 [[OK]]
+
+  // CHECK-UBSAN: call void @__ubsan_handle_nonnull_arg
+
+  // CHECK-TRAP: call void @llvm.trap() [[NR_NUW]]
+  // CHECK-TRAP: unreachable
+  decl_nonnull(a);
+}
+
+// CHECK-COMMON-LABEL: @call_nonnull_variadic
+__attribute__((nonnull)) void nonnull_variadic(int a, ...);
+void call_nonnull_variadic(int a, int *b) {
+  // CHECK-COMMON: [[OK:%.*]] = icmp ne i32* {{.*}}, null
+  // CHECK-COMMON: br i1 [[OK]]
+
+  // CHECK-UBSAN: call void @__ubsan_handle_nonnull_arg
+  // CHECK-UBSAN-NOT: __ubsan_handle_nonnull_arg
+
+  // CHECK-COMMON: call void (i32, ...)* @nonnull_variadic
+  nonnull_variadic(a, b);
+}
+
+// CHECK-UBSAN: ![[WEIGHT_MD]] = metadata !{metadata !"branch_weights", i32 1048575, i32 1}
 
 // CHECK-TRAP: attributes [[NR_NUW]] = { noreturn nounwind }
diff --git a/test/CodeGen/complex-math.c b/test/CodeGen/complex-math.c
new file mode 100644
index 0000000..29172fa
--- /dev/null
+++ b/test/CodeGen/complex-math.c
@@ -0,0 +1,473 @@
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
+
+float _Complex add_float_rr(float a, float b) {
+  // X86-LABEL: @add_float_rr(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+float _Complex add_float_cr(float _Complex a, float b) {
+  // X86-LABEL: @add_float_cr(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+float _Complex add_float_rc(float a, float _Complex b) {
+  // X86-LABEL: @add_float_rc(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+float _Complex add_float_cc(float _Complex a, float _Complex b) {
+  // X86-LABEL: @add_float_cc(
+  // X86: fadd
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+
+float _Complex sub_float_rr(float a, float b) {
+  // X86-LABEL: @sub_float_rr(
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+float _Complex sub_float_cr(float _Complex a, float b) {
+  // X86-LABEL: @sub_float_cr(
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+float _Complex sub_float_rc(float a, float _Complex b) {
+  // X86-LABEL: @sub_float_rc(
+  // X86: fsub
+  // X86: fsub float -0.{{0+}}e+00,
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+float _Complex sub_float_cc(float _Complex a, float _Complex b) {
+  // X86-LABEL: @sub_float_cc(
+  // X86: fsub
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+
+float _Complex mul_float_rr(float a, float b) {
+  // X86-LABEL: @mul_float_rr(
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+float _Complex mul_float_cr(float _Complex a, float b) {
+  // X86-LABEL: @mul_float_cr(
+  // X86: fmul
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+float _Complex mul_float_rc(float a, float _Complex b) {
+  // X86-LABEL: @mul_float_rc(
+  // X86: fmul
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+float _Complex mul_float_cc(float _Complex a, float _Complex b) {
+  // X86-LABEL: @mul_float_cc(
+  // X86: %[[AC:[^ ]+]] = fmul
+  // X86: %[[BD:[^ ]+]] = fmul
+  // X86: %[[AD:[^ ]+]] = fmul
+  // X86: %[[BC:[^ ]+]] = fmul
+  // X86: %[[RR:[^ ]+]] = fsub float %[[AC]], %[[BD]]
+  // X86: %[[RI:[^ ]+]] = fadd float
+  // X86-DAG: %[[AD]]
+  // X86-DAG: ,
+  // X86-DAG: %[[BC]]
+  // X86: fcmp uno float %[[RR]]
+  // X86: fcmp uno float %[[RI]]
+  // X86: call {{.*}} @__mulsc3(
+  // X86: ret
+  return a * b;
+}
+
+float _Complex div_float_rr(float a, float b) {
+  // X86-LABEL: @div_float_rr(
+  // X86: fdiv
+  // X86-NOT: fdiv
+  // X86: ret
+  return a / b;
+}
+float _Complex div_float_cr(float _Complex a, float b) {
+  // X86-LABEL: @div_float_cr(
+  // X86: fdiv
+  // X86: fdiv
+  // X86-NOT: fdiv
+  // X86: ret
+  return a / b;
+}
+float _Complex div_float_rc(float a, float _Complex b) {
+  // X86-LABEL: @div_float_rc(
+  // X86-NOT: fdiv
+  // X86: call {{.*}} @__divsc3(
+  // X86: ret
+  return a / b;
+}
+float _Complex div_float_cc(float _Complex a, float _Complex b) {
+  // X86-LABEL: @div_float_cc(
+  // X86-NOT: fdiv
+  // X86: call {{.*}} @__divsc3(
+  // X86: ret
+  return a / b;
+}
+
+double _Complex add_double_rr(double a, double b) {
+  // X86-LABEL: @add_double_rr(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+double _Complex add_double_cr(double _Complex a, double b) {
+  // X86-LABEL: @add_double_cr(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+double _Complex add_double_rc(double a, double _Complex b) {
+  // X86-LABEL: @add_double_rc(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+double _Complex add_double_cc(double _Complex a, double _Complex b) {
+  // X86-LABEL: @add_double_cc(
+  // X86: fadd
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+
+double _Complex sub_double_rr(double a, double b) {
+  // X86-LABEL: @sub_double_rr(
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+double _Complex sub_double_cr(double _Complex a, double b) {
+  // X86-LABEL: @sub_double_cr(
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+double _Complex sub_double_rc(double a, double _Complex b) {
+  // X86-LABEL: @sub_double_rc(
+  // X86: fsub
+  // X86: fsub double -0.{{0+}}e+00,
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+double _Complex sub_double_cc(double _Complex a, double _Complex b) {
+  // X86-LABEL: @sub_double_cc(
+  // X86: fsub
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+
+double _Complex mul_double_rr(double a, double b) {
+  // X86-LABEL: @mul_double_rr(
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+double _Complex mul_double_cr(double _Complex a, double b) {
+  // X86-LABEL: @mul_double_cr(
+  // X86: fmul
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+double _Complex mul_double_rc(double a, double _Complex b) {
+  // X86-LABEL: @mul_double_rc(
+  // X86: fmul
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+double _Complex mul_double_cc(double _Complex a, double _Complex b) {
+  // X86-LABEL: @mul_double_cc(
+  // X86: %[[AC:[^ ]+]] = fmul
+  // X86: %[[BD:[^ ]+]] = fmul
+  // X86: %[[AD:[^ ]+]] = fmul
+  // X86: %[[BC:[^ ]+]] = fmul
+  // X86: %[[RR:[^ ]+]] = fsub double %[[AC]], %[[BD]]
+  // X86: %[[RI:[^ ]+]] = fadd double
+  // X86-DAG: %[[AD]]
+  // X86-DAG: ,
+  // X86-DAG: %[[BC]]
+  // X86: fcmp uno double %[[RR]]
+  // X86: fcmp uno double %[[RI]]
+  // X86: call {{.*}} @__muldc3(
+  // X86: ret
+  return a * b;
+}
+
+double _Complex div_double_rr(double a, double b) {
+  // X86-LABEL: @div_double_rr(
+  // X86: fdiv
+  // X86-NOT: fdiv
+  // X86: ret
+  return a / b;
+}
+double _Complex div_double_cr(double _Complex a, double b) {
+  // X86-LABEL: @div_double_cr(
+  // X86: fdiv
+  // X86: fdiv
+  // X86-NOT: fdiv
+  // X86: ret
+  return a / b;
+}
+double _Complex div_double_rc(double a, double _Complex b) {
+  // X86-LABEL: @div_double_rc(
+  // X86-NOT: fdiv
+  // X86: call {{.*}} @__divdc3(
+  // X86: ret
+  return a / b;
+}
+double _Complex div_double_cc(double _Complex a, double _Complex b) {
+  // X86-LABEL: @div_double_cc(
+  // X86-NOT: fdiv
+  // X86: call {{.*}} @__divdc3(
+  // X86: ret
+  return a / b;
+}
+
+long double _Complex add_long_double_rr(long double a, long double b) {
+  // X86-LABEL: @add_long_double_rr(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+long double _Complex add_long_double_cr(long double _Complex a, long double b) {
+  // X86-LABEL: @add_long_double_cr(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+long double _Complex add_long_double_rc(long double a, long double _Complex b) {
+  // X86-LABEL: @add_long_double_rc(
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+long double _Complex add_long_double_cc(long double _Complex a, long double _Complex b) {
+  // X86-LABEL: @add_long_double_cc(
+  // X86: fadd
+  // X86: fadd
+  // X86-NOT: fadd
+  // X86: ret
+  return a + b;
+}
+
+long double _Complex sub_long_double_rr(long double a, long double b) {
+  // X86-LABEL: @sub_long_double_rr(
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+long double _Complex sub_long_double_cr(long double _Complex a, long double b) {
+  // X86-LABEL: @sub_long_double_cr(
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+long double _Complex sub_long_double_rc(long double a, long double _Complex b) {
+  // X86-LABEL: @sub_long_double_rc(
+  // X86: fsub
+  // X86: fsub x86_fp80 0xK8{{0+}},
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+long double _Complex sub_long_double_cc(long double _Complex a, long double _Complex b) {
+  // X86-LABEL: @sub_long_double_cc(
+  // X86: fsub
+  // X86: fsub
+  // X86-NOT: fsub
+  // X86: ret
+  return a - b;
+}
+
+long double _Complex mul_long_double_rr(long double a, long double b) {
+  // X86-LABEL: @mul_long_double_rr(
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+long double _Complex mul_long_double_cr(long double _Complex a, long double b) {
+  // X86-LABEL: @mul_long_double_cr(
+  // X86: fmul
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+long double _Complex mul_long_double_rc(long double a, long double _Complex b) {
+  // X86-LABEL: @mul_long_double_rc(
+  // X86: fmul
+  // X86: fmul
+  // X86-NOT: fmul
+  // X86: ret
+  return a * b;
+}
+long double _Complex mul_long_double_cc(long double _Complex a, long double _Complex b) {
+  // X86-LABEL: @mul_long_double_cc(
+  // X86: %[[AC:[^ ]+]] = fmul
+  // X86: %[[BD:[^ ]+]] = fmul
+  // X86: %[[AD:[^ ]+]] = fmul
+  // X86: %[[BC:[^ ]+]] = fmul
+  // X86: %[[RR:[^ ]+]] = fsub x86_fp80 %[[AC]], %[[BD]]
+  // X86: %[[RI:[^ ]+]] = fadd x86_fp80
+  // X86-DAG: %[[AD]]
+  // X86-DAG: ,
+  // X86-DAG: %[[BC]]
+  // X86: fcmp uno x86_fp80 %[[RR]]
+  // X86: fcmp uno x86_fp80 %[[RI]]
+  // X86: call {{.*}} @__mulxc3(
+  // X86: ret
+  // PPC-LABEL: @mul_long_double_cc(
+  // PPC: %[[AC:[^ ]+]] = fmul
+  // PPC: %[[BD:[^ ]+]] = fmul
+  // PPC: %[[AD:[^ ]+]] = fmul
+  // PPC: %[[BC:[^ ]+]] = fmul
+  // PPC: %[[RR:[^ ]+]] = fsub ppc_fp128 %[[AC]], %[[BD]]
+  // PPC: %[[RI:[^ ]+]] = fadd ppc_fp128
+  // PPC-DAG: %[[AD]]
+  // PPC-DAG: ,
+  // PPC-DAG: %[[BC]]
+  // PPC: fcmp uno ppc_fp128 %[[RR]]
+  // PPC: fcmp uno ppc_fp128 %[[RI]]
+  // PPC: call {{.*}} @__multc3(
+  // PPC: ret
+  return a * b;
+}
+
+long double _Complex div_long_double_rr(long double a, long double b) {
+  // X86-LABEL: @div_long_double_rr(
+  // X86: fdiv
+  // X86-NOT: fdiv
+  // X86: ret
+  return a / b;
+}
+long double _Complex div_long_double_cr(long double _Complex a, long double b) {
+  // X86-LABEL: @div_long_double_cr(
+  // X86: fdiv
+  // X86: fdiv
+  // X86-NOT: fdiv
+  // X86: ret
+  return a / b;
+}
+long double _Complex div_long_double_rc(long double a, long double _Complex b) {
+  // X86-LABEL: @div_long_double_rc(
+  // X86-NOT: fdiv
+  // X86: call {{.*}} @__divxc3(
+  // X86: ret
+  // PPC-LABEL: @div_long_double_rc(
+  // PPC-NOT: fdiv
+  // PPC: call {{.*}} @__divtc3(
+  // PPC: ret
+  return a / b;
+}
+long double _Complex div_long_double_cc(long double _Complex a, long double _Complex b) {
+  // X86-LABEL: @div_long_double_cc(
+  // X86-NOT: fdiv
+  // X86: call {{.*}} @__divxc3(
+  // X86: ret
+  // PPC-LABEL: @div_long_double_cc(
+  // PPC-NOT: fdiv
+  // PPC: call {{.*}} @__divtc3(
+  // PPC: ret
+  return a / b;
+}
+
+// Comparison operators don't rely on library calls or have interseting math
+// properties, but test that mixed types work correctly here.
+_Bool eq_float_cr(float _Complex a, float b) {
+  // X86-LABEL: @eq_float_cr(
+  // X86: fcmp oeq
+  // X86: fcmp oeq
+  // X86: and i1
+  // X86: ret
+  return a == b;
+}
+_Bool eq_float_rc(float a, float _Complex b) {
+  // X86-LABEL: @eq_float_rc(
+  // X86: fcmp oeq
+  // X86: fcmp oeq
+  // X86: and i1
+  // X86: ret
+  return a == b;
+}
+_Bool eq_float_cc(float _Complex a, float _Complex b) {
+  // X86-LABEL: @eq_float_cc(
+  // X86: fcmp oeq
+  // X86: fcmp oeq
+  // X86: and i1
+  // X86: ret
+  return a == b;
+}
+_Bool ne_float_cr(float _Complex a, float b) {
+  // X86-LABEL: @ne_float_cr(
+  // X86: fcmp une
+  // X86: fcmp une
+  // X86: or i1
+  // X86: ret
+  return a != b;
+}
+_Bool ne_float_rc(float a, float _Complex b) {
+  // X86-LABEL: @ne_float_rc(
+  // X86: fcmp une
+  // X86: fcmp une
+  // X86: or i1
+  // X86: ret
+  return a != b;
+}
+_Bool ne_float_cc(float _Complex a, float _Complex b) {
+  // X86-LABEL: @ne_float_cc(
+  // X86: fcmp une
+  // X86: fcmp une
+  // X86: or i1
+  // X86: ret
+  return a != b;
+}
diff --git a/test/CodeGen/complex.c b/test/CodeGen/complex.c
index 206db25..1c0e7cb 100644
--- a/test/CodeGen/complex.c
+++ b/test/CodeGen/complex.c
@@ -98,3 +98,19 @@
 
 const _Complex double test9const = 0;
 _Complex double test9func() { return test9const; }
+
+// D6217
+void t91() {
+  // Check for proper type promotion of conditional expression
+  char c[(int)(sizeof(typeof((0 ? 2.0f : (_Complex double) 2.0f))) - sizeof(_Complex double))];
+  // Check for proper codegen
+  (0 ? 2.0f : (_Complex double) 2.0f);
+}
+
+void t92() {
+  // Check for proper type promotion of conditional expression
+  char c[(int)(sizeof(typeof((0 ? (_Complex double) 2.0f : 2.0f))) - sizeof(_Complex double))];
+  // Check for proper codegen
+  (0 ? (_Complex double) 2.0f : 2.0f);
+}
+
diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c
index 7d7ccae..b86274f 100644
--- a/test/CodeGen/const-init.c
+++ b/test/CodeGen/const-init.c
@@ -159,3 +159,25 @@
   static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [5]'}}
   static int c[1] = { L"a" };
 }
+
+// PR21300
+void g30() {
+#pragma pack(1)
+  static struct {
+    int : 1;
+    int x;
+  } a = {};
+  // CHECK: @g30.a = internal global %struct.anon.1 <{ i8 undef, i32 0 }>, align 1
+#pragma pack()
+}
+
+void g31() {
+#pragma pack(4)
+  static struct {
+    short a;
+    long x;
+    short z;
+  } a = {23122, -12312731, -312};
+#pragma pack()
+  // CHECK: @g31.a = internal global %struct.anon.2 { i16 23122, i32 -12312731, i16 -312 }, align 4
+}
diff --git a/test/CodeGen/debug-info-args.c b/test/CodeGen/debug-info-args.c
index 50b8541..d1fa917 100644
--- a/test/CodeGen/debug-info-args.c
+++ b/test/CodeGen/debug-info-args.c
@@ -2,7 +2,7 @@
 
 int somefunc(char *x, int y, double z) {
   
-  // CHECK: metadata ![[NUM:[^,]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type
+  // CHECK: metadata ![[NUM:[^,]*]], null, null, null} ; [ DW_TAG_subroutine_type
   // CHECK: ![[NUM]] = {{metadata !{metadata ![^,]*, metadata ![^,]*, metadata ![^,]*, metadata ![^,]*}}}
   
   return y;
diff --git a/test/CodeGen/debug-info-block-out-return.c b/test/CodeGen/debug-info-block-out-return.c
new file mode 100644
index 0000000..d8f9238
--- /dev/null
+++ b/test/CodeGen/debug-info-block-out-return.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -fblocks -emit-llvm -o - %s | FileCheck %s
+
+// Check that arg numbering is not affected by LLVM IR argument numbering -
+// since the latter is affected by return-by-out-parameter ABI requirements
+
+// 1 for the argument number (1 indexed), 2 for the line number
+// 16777218 == 1 << 24 | 2
+// 33554434 == 2 << 24 | 2
+// This explains the two magic numbers below, testing that these two arguments
+// are numbered correctly. If they are not numbered correctly they may appear
+// out of order or not at all (the latter would occur if they were both assigned
+// the same argument number by mistake).
+
+// CHECK: metadata !"0x101\00.block_descriptor\0016777218\00{{[0-9]+}}", {{.*}} ; [ DW_TAG_arg_variable ] [.block_descriptor]
+// CHECK: metadata !"0x101\00param\0033554434\00{{[0-9]+}}", {{.*}} ; [ DW_TAG_arg_variable ] [param]
+
+// Line directive so we don't have to worry about how many lines preceed the
+// test code (as the line number is mangled in with the argument number as shown
+// above)
+#line 1
+typedef struct { int array[12]; } BigStruct_t;
+BigStruct_t (^a)() = ^(int param) {
+    BigStruct_t b;
+    return b;
+};
diff --git a/test/CodeGen/debug-info-enum.c b/test/CodeGen/debug-info-enum.c
index acf3f52..d4349ea 100644
--- a/test/CodeGen/debug-info-enum.c
+++ b/test/CodeGen/debug-info-enum.c
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
 
-// CHECK: metadata [[TEST3_ENUMS:![0-9]*]], {{[^,]*}}, null, null, null} ; [ DW_TAG_enumeration_type ] [e]
+// CHECK: metadata [[TEST3_ENUMS:![0-9]*]], null, null, null} ; [ DW_TAG_enumeration_type ] [e]
 // CHECK: [[TEST3_ENUMS]] = metadata !{metadata [[TEST3_E:![0-9]*]]}
-// CHECK: [[TEST3_E]] = {{.*}}, metadata !"E", i64 -1} ; [ DW_TAG_enumerator ] [E :: -1]
+// CHECK: [[TEST3_E]] = metadata !{metadata !"0x28\00E\00-1"} ; [ DW_TAG_enumerator ] [E :: -1]
 
 enum e;
 void func(enum e *p) {
diff --git a/test/CodeGen/debug-info-scope.c b/test/CodeGen/debug-info-scope.c
index 9decaea..d84fafd 100644
--- a/test/CodeGen/debug-info-scope.c
+++ b/test/CodeGen/debug-info-scope.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -g -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -gline-tables-only -emit-llvm < %s | FileCheck --check-prefix=GMLT %s
 // Two variables with same name in separate scope.
 // Radar 8330217.
 int main() {
@@ -6,10 +7,21 @@
 	int k = 0;
 // CHECK: DW_TAG_auto_variable ] [i]
 // CHECK-NEXT: DW_TAG_lexical_block
+
+// FIXME: Looks like we don't actually need both these lexical blocks (disc 2
+// just refers to disc 1, nothing actually uses disc 2).
+// GMLT-NOT: DW_TAG_lexical_block
+// GMLT: "0xb\002", {{.*}}} ; [ DW_TAG_lexical_block ]
+// GMLT-NOT: DW_TAG_lexical_block
+// GMLT: "0xb\001", {{.*}}} ; [ DW_TAG_lexical_block ]
+// Make sure we don't have any more lexical blocks because we don't need them in
+// -gmlt.
+// GMLT-NOT: DW_TAG_lexical_block
 	for (int i = 0; i < 10; i++)
 		j++;
 // CHECK: DW_TAG_auto_variable ] [i]
 // CHECK-NEXT: DW_TAG_lexical_block
+// GMLT-NOT: DW_TAG_lexical_block
 	for (int i = 0; i < 10; i++)
 		k++;
 	return 0;
diff --git a/test/CodeGen/debug-info-typedef.c b/test/CodeGen/debug-info-typedef.c
index 51ebcc4..73c7bcd 100644
--- a/test/CodeGen/debug-info-typedef.c
+++ b/test/CodeGen/debug-info-typedef.c
@@ -7,5 +7,5 @@
 
 MyType a;
 
-// CHECK: metadata ![[HEADER:[0-9]+]], null, metadata !"MyType"{{.*}} ; [ DW_TAG_typedef ] [MyType] [line 2, size 0, align 0, offset 0] [from int]
+// CHECK: metadata !{metadata !"0x16\00MyType\002\00{{.*}}", metadata ![[HEADER:[0-9]+]], null{{.*}}} ; [ DW_TAG_typedef ] [MyType] [line 2, size 0, align 0, offset 0] [from int]
 // CHECK: ![[HEADER]] = metadata !{metadata !"b.h",
diff --git a/test/CodeGen/debug-info-version.c b/test/CodeGen/debug-info-version.c
index 325345f..dd303c1 100644
--- a/test/CodeGen/debug-info-version.c
+++ b/test/CodeGen/debug-info-version.c
@@ -4,5 +4,5 @@
   return 0;
 }
 
-// CHECK: metadata !{i32 2, metadata !"Debug Info Version", i32 1}
+// CHECK: metadata !{i32 2, metadata !"Debug Info Version", i32 2}
 // NO_DEBUG-NOT: metadata !"Debug Info Version"
diff --git a/test/CodeGen/debug-info-vla.c b/test/CodeGen/debug-info-vla.c
index 7a8da96..104c251 100644
--- a/test/CodeGen/debug-info-vla.c
+++ b/test/CodeGen/debug-info-vla.c
@@ -2,7 +2,7 @@
 
 void testVLAwithSize(int s)
 {
-// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"vla", metadata {{.*}}, i32 [[@LINE+1]], metadata {{.*}}, i32 8192, i32 0} ; [ DW_TAG_auto_variable ] [vla] [line [[@LINE+1]]]
+// CHECK: metadata !{metadata !"0x100\00vla\00[[@LINE+1]]\008192", metadata {{.*}}, metadata {{.*}}, metadata {{.*}}} ; [ DW_TAG_auto_variable ] [vla] [line [[@LINE+1]]]
   int vla[s];
   int i;
   for (i = 0; i < s; i++) {
diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c
index 12ba605..bf08c58 100644
--- a/test/CodeGen/debug-info.c
+++ b/test/CodeGen/debug-info.c
@@ -42,7 +42,7 @@
 
 
 // Radar 7325611
-// CHECK: "barfoo"
+// CHECK: !"0x16\00barfoo\00{{.*}}"
 typedef int barfoo;
 barfoo foo() {
 }
diff --git a/test/CodeGen/designated-initializers.c b/test/CodeGen/designated-initializers.c
index b11c67a..74532c8 100644
--- a/test/CodeGen/designated-initializers.c
+++ b/test/CodeGen/designated-initializers.c
@@ -139,6 +139,9 @@
   [1].b[1] = 4
 };
 
+// CHECK: @lab = global { [4 x i8], i32 } { [4 x i8] undef, i32 123 }
+struct leading_anon_bitfield { int : 32; int n; } lab = { .n = 123 };
+
 void test1(int argc, char **argv)
 {
   // CHECK: internal global %struct.foo { i8* null, i32 1024 }
diff --git a/test/CodeGen/dllimport.c b/test/CodeGen/dllimport.c
index 32ee81f..89dbb9f 100644
--- a/test/CodeGen/dllimport.c
+++ b/test/CodeGen/dllimport.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c11 -O0 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 %s
-// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=MS %s
+// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c11 -O0 -o - %s | FileCheck --check-prefix=CHECK --check-prefix=GNU %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 --check-prefix=MO1 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c11 -O1 -o - %s | FileCheck --check-prefix=O1 --check-prefix=GO1 %s
 
 #define JOIN2(x, y) x##y
 #define JOIN(x, y) JOIN2(x, y)
@@ -44,6 +44,26 @@
                       extern int GlobalRedecl3; // dllimport ignored
 USEVAR(GlobalRedecl3)
 
+// Make sure this works even if the decl has been used before it's defined (PR20792).
+// CHECK: @GlobalRedecl4 = common global i32
+__declspec(dllimport) extern int GlobalRedecl4;
+USEVAR(GlobalRedecl4)
+                      int GlobalRedecl4; // dllimport ignored
+
+// FIXME: dllimport is dropped in the AST; this should be reflected in codegen (PR02803).
+// CHECK: @GlobalRedecl5 = external dllimport global i32
+__declspec(dllimport) extern int GlobalRedecl5;
+USEVAR(GlobalRedecl5)
+                      extern int GlobalRedecl5; // dllimport ignored
+
+// Redeclaration in local context.
+// CHECK: @GlobalRedecl6 = external dllimport global i32
+__declspec(dllimport) int GlobalRedecl6;
+int functionScope() {
+  extern int GlobalRedecl6; // still dllimport
+  return GlobalRedecl6;
+}
+
 
 
 //===----------------------------------------------------------------------===//
@@ -59,14 +79,18 @@
 void (*use_decl)(void) = &decl;
 
 // Import inline function.
-// CHECK-DAG: declare dllimport void @inlineFunc()
-// O1-DAG: define available_externally dllimport void @inlineFunc()
+// MS-DAG: declare dllimport void @inlineFunc()
+// MO1-DAG: define available_externally dllimport void @inlineFunc()
+// GNU-DAG: declare void @inlineFunc()
+// GO1-DAG: define available_externally void @inlineFunc()
 __declspec(dllimport) inline void inlineFunc(void) {}
 USE(inlineFunc)
 
 // inline attributes
-// CHECK-DAG: declare dllimport void @noinline()
-// O1-DAG: define available_externally dllimport void @noinline()
+// MS-DAG: declare dllimport void @noinline()
+// MO1-DAG: define available_externally dllimport void @noinline()
+// GNU-DAG: declare void @noinline()
+// GO1-DAG: define available_externally void @noinline()
 // CHECK-NOT: @alwaysInline()
 // O1-NOT: @alwaysInline()
 __declspec(dllimport) __attribute__((noinline)) inline void noinline(void) {}
@@ -91,3 +115,15 @@
 __declspec(dllimport) void redecl3(void);
                       void redecl3(void) {} // dllimport ignored
 USE(redecl3)
+
+// Make sure this works even if the decl is used before it's defined (PR20792).
+// CHECK-DAG: define void @redecl4()
+__declspec(dllimport) void redecl4(void);
+USE(redecl4)
+                      void redecl4(void) {} // dllimport ignored
+
+// FIXME: dllimport is dropped in the AST; this should be reflected in codegen (PR20803).
+// CHECK-DAG: declare dllimport
+__declspec(dllimport) void redecl5(void);
+USE(redecl5)
+                      void redecl5(void); // dllimport ignored
diff --git a/test/CodeGen/dwarf-version.c b/test/CodeGen/dwarf-version.c
index 0c67b4f..26dfbcb 100644
--- a/test/CodeGen/dwarf-version.c
+++ b/test/CodeGen/dwarf-version.c
@@ -5,6 +5,7 @@
 // RUN: %clang -target x86_64-apple-darwin -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
+// RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
 int main (void) {
   return 0;
 }
diff --git a/test/CodeGen/ext-vector-indexing.c b/test/CodeGen/ext-vector-indexing.c
new file mode 100644
index 0000000..28c0e1e
--- /dev/null
+++ b/test/CodeGen/ext-vector-indexing.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+// CHECK: @test
+void test()
+{
+  float4 va;
+  va.hi[0] = 3.0;
+// CHECK:  [[VA:%.*]] = alloca <4 x float>
+// CHECK:  [[CONV:%.*]] = bitcast <4 x float>* [[VA]] to float*
+// CHECK:  [[ADD:%.*]] = getelementptr inbounds float* [[CONV]], i64 2
+// CHECK:  [[ARRIDX:%.*]] = getelementptr inbounds float* [[ADD]], i64 0
+// CHECK:   store float 3.000000e+00, float* [[ARRIDX]]
+}
diff --git a/test/CodeGen/fp128_complex.c b/test/CodeGen/fp128_complex.c
new file mode 100644
index 0000000..8775999
--- /dev/null
+++ b/test/CodeGen/fp128_complex.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target aarch64-linux-gnuabi %s -O3 -S -emit-llvm -o - | FileCheck %s
+
+_Complex long double a, b, c, d;
+void test_fp128_compound_assign(void) {
+  // CHECK: tail call { fp128, fp128 } @__multc3
+  a *= b;
+  // CHECK: tail call { fp128, fp128 } @__divtc3
+  c /= d;
+}
diff --git a/test/CodeGen/fp16-ops.c b/test/CodeGen/fp16-ops.c
index a848ed1..b269cf8 100644
--- a/test/CodeGen/fp16-ops.c
+++ b/test/CodeGen/fp16-ops.c
@@ -11,274 +11,274 @@
 
   // Check unary ops
 
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK fptoi float
   test = (h0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp une float
   test = (!h1);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = -h1;
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = +h1;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1++;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   ++h1;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   --h1;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1--;
 
   // Check binary ops with various operands
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = h0 * h2;
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call i16 @llvm.convert.to.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = h0 * (__fp16) -2.0;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = h0 * f2;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = f0 * h2;
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h0 / h2);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h0 / (__fp16) -2.0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h0 / f2);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (f0 / h2);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h2 + h0);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = ((__fp16)-2.0 + h0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h2 + f0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (f2 + h0);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h2 - h0);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = ((__fp16)-2.0 - h0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h2 - f0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (f2 - h0);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp olt
   test = (h2 < h0);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp olt
   test = (h2 < (__fp16)42.0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp olt
   test = (h2 < f0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp olt
   test = (f2 < h0);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ogt
   test = (h0 > h2);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ogt
   test = ((__fp16)42.0 > h2);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ogt
   test = (h0 > f2);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ogt
   test = (f0 > h2);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ole
   test = (h2 <= h0);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ole
   test = (h2 <= (__fp16)42.0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ole
   test = (h2 <= f0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp ole
   test = (f2 <= h0);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oge
   test = (h0 >= h2);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oge
   test = (h0 >= (__fp16)-2.0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oge
   test = (h0 >= f2);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oge
   test = (f0 >= h2);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oeq
   test = (h1 == h2);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oeq
   test = (h1 == (__fp16)1.0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oeq
   test = (h1 == f1);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp oeq
   test = (f1 == h1);
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp une
   test = (h1 != h2);
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp une
   test = (h1 != (__fp16)1.0);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp une
   test = (h1 != f1);
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp une
   test = (f1 != h1);
 
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fcmp une
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h1 = (h1 ? h2 : h0);
   // Check assignments (inc. compound)
   h0 = h1;
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 = (__fp16)-2.0;
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 = f0;
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd float
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 += h1;
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 += (__fp16)1.0;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fadd
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 += f2;
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 -= h1;
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 -= (__fp16)1.0;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fsub
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 -= f2;
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 *= h1;
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 *= (__fp16)1.0;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fmul
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 *= f2;
 
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 /= h1;
-  // CHECK: call float @llvm.convert.from.fp16
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 /= (__fp16)1.0;
-  // CHECK: call float @llvm.convert.from.fp16
+  // CHECK: call float @llvm.convert.from.fp16.f32(
   // CHECK: fdiv
-  // CHECK: call i16 @llvm.convert.to.fp16
+  // CHECK: call i16 @llvm.convert.to.fp16.f32(
   h0 /= f2;
 }
diff --git a/test/CodeGen/fsgsbase-builtins.c b/test/CodeGen/fsgsbase-builtins.c
new file mode 100644
index 0000000..14c51a9
--- /dev/null
+++ b/test/CodeGen/fsgsbase-builtins.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fsgsbase -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned int test_readfsbase_u32()
+{
+  // CHECK: @llvm.x86.rdfsbase.32
+  return _readfsbase_u32();
+}
+
+unsigned long long test_readfsbase_u64()
+{
+  // CHECK: @llvm.x86.rdfsbase.64
+  return _readfsbase_u64();
+}
+
+unsigned int test_readgsbase_u32()
+{
+  // CHECK: @llvm.x86.rdgsbase.32
+  return _readgsbase_u32();
+}
+
+unsigned long long test_readgsbase_u64()
+{
+  // CHECK: @llvm.x86.rdgsbase.64
+  return _readgsbase_u64();
+}
+
+void test_writefsbase_u32(unsigned int __X)
+{
+  // CHECK: @llvm.x86.wrfsbase.32
+  _writefsbase_u32(__X);
+}
+
+void test_writefsbase_u64(unsigned long long __X)
+{
+  // CHECK: @llvm.x86.wrfsbase.64
+  _writefsbase_u64(__X);
+}
+
+void test_writegsbase_u32(unsigned int __X)
+{
+  // CHECK: @llvm.x86.wrgsbase.32
+  _writegsbase_u32(__X);
+}
+
+void test_writegsbase_u64(unsigned long long __X)
+{
+  // CHECK: @llvm.x86.wrgsbase.64
+  _writegsbase_u64(__X);
+}
diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c
index 1b0beae..b396c3b 100644
--- a/test/CodeGen/init.c
+++ b/test/CodeGen/init.c
@@ -132,3 +132,11 @@
   // CHECK: @test13
   // CHECK: and i16 {{.*}}, -1024
 }
+
+// CHECK-LABEL: @PR20473
+void PR20473() {
+  // CHECK: memcpy{{.*}}([2 x i8]* @
+  bar((char[2]) {""});
+  // CHECK: memcpy{{.*}}([3 x i8]* @
+  bar((char[3]) {""});
+}
diff --git a/test/CodeGen/lineno-dbginfo.c b/test/CodeGen/lineno-dbginfo.c
index 1f9b7a5..20f1949 100644
--- a/test/CodeGen/lineno-dbginfo.c
+++ b/test/CodeGen/lineno-dbginfo.c
@@ -1,5 +1,6 @@
 // RUN: echo "#include <stddef.h>" > %t.h
-// RUN: %clang_cc1 -S -g -include %t.h %s -emit-llvm -o %t.ll
-// RUN: grep "i32 5" %t.ll
-// outer is at line number 5.
+// RUN: %clang_cc1 -S -g -include %t.h %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: metadata !"0x34\00outer\00outer\00\00[[@LINE+1]]\000\001"
 int outer = 42;
+
diff --git a/test/CodeGen/link-bitcode-file.c b/test/CodeGen/link-bitcode-file.c
index cf9493f..fb97b4d 100644
--- a/test/CodeGen/link-bitcode-file.c
+++ b/test/CodeGen/link-bitcode-file.c
@@ -6,7 +6,7 @@
 
 #ifdef BITCODE
 
-// CHECK-BC: 'f': symbol multiply defined
+// CHECK-BC: fatal error: cannot link module {{.*}}'f': symbol multiply defined
 int f(void) {
   return 42;
 }
diff --git a/test/CodeGen/lzcnt-builtins.c b/test/CodeGen/lzcnt-builtins.c
index a43c4ee..a083de9 100644
--- a/test/CodeGen/lzcnt-builtins.c
+++ b/test/CodeGen/lzcnt-builtins.c
@@ -22,3 +22,15 @@
   // CHECK: @llvm.ctlz.i64
   return __lzcnt64(__X);
 }
+
+unsigned int test_lzcnt_u32(unsigned int __X)
+{
+  // CHECK: @llvm.ctlz.i32
+  return _lzcnt_u32(__X);
+}
+
+unsigned long long test__lzcnt_u64(unsigned long long __X)
+{
+  // CHECK: @llvm.ctlz.i64
+  return _lzcnt_u64(__X);
+}
diff --git a/test/CodeGen/mangle-blocks.c b/test/CodeGen/mangle-blocks.c
new file mode 100644
index 0000000..c5e08e9
--- /dev/null
+++ b/test/CodeGen/mangle-blocks.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-apple-ios -fblocks -emit-llvm -o - %s | FileCheck %s
+
+void __assert_rtn(const char *, const char *, int, const char *)
+    __attribute__ (( noreturn ));
+
+void (^mangle(void))(void) {
+  return ^{
+    void (^block)(void) = ^{
+      __assert_rtn(__func__, __FILE__, __LINE__, "mangle");
+    };
+  };
+}
+
+// CHECK: @__func__.__mangle_block_invoke_2 = private unnamed_addr constant [24 x i8] c"__mangle_block_invoke_2\00", align 1
+// CHECK: @.str = private unnamed_addr constant {{.*}}, align 1
+// CHECK: @.str1 = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
+
+// CHECK: define internal void @__mangle_block_invoke(i8* %.block_descriptor)
+
+// CHECK: define internal void @__mangle_block_invoke_2(i8* %.block_descriptor){{.*}}{
+// CHECK:   call void @__assert_rtn(i8* getelementptr inbounds ([24 x i8]* @__func__.__mangle_block_invoke_2, i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 9, i8* getelementptr inbounds ([7 x i8]* @.str1, i32 0, i32 0))
+// CHECK: }
+
diff --git a/test/CodeGen/mangle-windows.c b/test/CodeGen/mangle-windows.c
index 37d1018..4a10875 100644
--- a/test/CodeGen/mangle-windows.c
+++ b/test/CodeGen/mangle-windows.c
@@ -1,33 +1,68 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-mingw32 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-mingw32 | FileCheck %s --check-prefix=X64
 
 void __stdcall f1(void) {}
 // CHECK: define x86_stdcallcc void @"\01_f1@0"
+// X64: define void @f1(
 
 void __fastcall f2(void) {}
 // CHECK: define x86_fastcallcc void @"\01@f2@0"
+// X64: define void @f2(
 
 void __stdcall f3() {}
 // CHECK: define x86_stdcallcc void @"\01_f3@0"
+// X64: define void @f3(
 
 void __fastcall f4(char a) {}
 // CHECK: define x86_fastcallcc void @"\01@f4@4"
+// X64: define void @f4(
 
 void __fastcall f5(short a) {}
 // CHECK: define x86_fastcallcc void @"\01@f5@4"
+// X64: define void @f5(
 
 void __fastcall f6(int a) {}
 // CHECK: define x86_fastcallcc void @"\01@f6@4"
+// X64: define void @f6(
 
 void __fastcall f7(long a) {}
 // CHECK: define x86_fastcallcc void @"\01@f7@4"
+// X64: define void @f7(
 
 void __fastcall f8(long long a) {}
 // CHECK: define x86_fastcallcc void @"\01@f8@8"
+// X64: define void @f8(
 
 void __fastcall f9(long long a, char b, char c, short d) {}
-// CHECK: define x86_fastcallcc void @"\01@f9@20"(i64 %a, i8 signext %b, i8
-// signext %c, i16 signext %d)
+// CHECK: define x86_fastcallcc void @"\01@f9@20"(i64 %a, i8 signext %b, i8 signext %c, i16 signext %d)
+// X64: define void @f9(
 
 void f12(void) {}
 // CHECK: define void @f12(
+// X64: define void @f12(
+
+void __vectorcall v1(void) {}
+// CHECK: define x86_vectorcallcc void @"\01v1@@0"(
+// X64: define x86_vectorcallcc void @"\01v1@@0"(
+
+void __vectorcall v2(char a) {}
+// CHECK: define x86_vectorcallcc void @"\01v2@@4"(
+// X64: define x86_vectorcallcc void @"\01v2@@8"(
+
+void __vectorcall v3(short a) {}
+// CHECK: define x86_vectorcallcc void @"\01v3@@4"(
+// X64: define x86_vectorcallcc void @"\01v3@@8"(
+
+void __vectorcall v4(int a) {}
+// CHECK: define x86_vectorcallcc void @"\01v4@@4"(
+// X64: define x86_vectorcallcc void @"\01v4@@8"(
+
+void __vectorcall v5(long long a) {}
+// CHECK: define x86_vectorcallcc void @"\01v5@@8"(
+// X64: define x86_vectorcallcc void @"\01v5@@8"(
+
+void __vectorcall v6(char a, char b) {}
+// CHECK: define x86_vectorcallcc void @"\01v6@@8"(
+// X64: define x86_vectorcallcc void @"\01v6@@16"(
diff --git a/test/CodeGen/microsoft-call-conv.c b/test/CodeGen/microsoft-call-conv.c
index b80c58d..c24db12 100644
--- a/test/CodeGen/microsoft-call-conv.c
+++ b/test/CodeGen/microsoft-call-conv.c
@@ -20,6 +20,11 @@
   f3();
 // CHECK: call x86_thiscallcc void @f3()
 }
+void __vectorcall f61(void) {
+// CHECK-LABEL: define x86_vectorcallcc void @f61()
+  f3();
+// CHECK: call x86_thiscallcc void @f3()
+}
 
 // PR5280
 void (__fastcall *pf1)(void) = f1;
@@ -28,19 +33,22 @@
 void (__fastcall *pf4)(void) = f4;
 void (__stdcall *pf5)(void) = f5;
 void (__thiscall *pf6)(void) = f6;
+void (__vectorcall *pf7)(void) = f61;
 
 int main(void) {
-    f4(); f5(); f6();
+    f4(); f5(); f6(); f61();
     // CHECK: call x86_fastcallcc void @f4()
     // CHECK: call x86_stdcallcc void @f5()
     // CHECK: call x86_thiscallcc void @f6()
-    pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
+    // CHECK: call x86_vectorcallcc void @f61()
+    pf1(); pf2(); pf3(); pf4(); pf5(); pf6(); pf7();
     // CHECK: call x86_fastcallcc void %{{.*}}()
     // CHECK: call x86_stdcallcc void %{{.*}}()
     // CHECK: call x86_thiscallcc void %{{.*}}()
     // CHECK: call x86_fastcallcc void %{{.*}}()
     // CHECK: call x86_stdcallcc void %{{.*}}()
     // CHECK: call x86_thiscallcc void %{{.*}}()
+    // CHECK: call x86_vectorcallcc void %{{.*}}()
     return 0;
 }
 
diff --git a/test/CodeGen/mips-byval-arg.c b/test/CodeGen/mips-byval-arg.c
index 589e85e..0e3d334 100644
--- a/test/CodeGen/mips-byval-arg.c
+++ b/test/CodeGen/mips-byval-arg.c
@@ -7,8 +7,8 @@
 
 extern void foo2(S0);
 
-// O32-LABEL: define void @foo1(i32 %a0.coerce0, i32 %a0.coerce1, i32 %a0.coerce2)
-// N64-LABEL: define void @foo1(i64 %a0.coerce0, i32 %a0.coerce1)
+// O32-LABEL: define void @foo1(i32 inreg %a0.coerce0, i32 inreg %a0.coerce1, i32 inreg %a0.coerce2)
+// N64-LABEL: define void @foo1(i64 inreg %a0.coerce0, i32 inreg %a0.coerce1)
 
 void foo1(S0 a0) {
   foo2(a0);
diff --git a/test/CodeGen/mips-varargs.c b/test/CodeGen/mips-varargs.c
new file mode 100644
index 0000000..e8b6e29
--- /dev/null
+++ b/test/CodeGen/mips-varargs.c
@@ -0,0 +1,184 @@
+// RUN: %clang_cc1 -triple mips-unknown-linux -o - -O1 -emit-llvm %s | FileCheck %s -check-prefix=ALL -check-prefix=O32
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -o - -O1 -emit-llvm %s | FileCheck %s -check-prefix=ALL -check-prefix=O32
+// RUN: %clang_cc1 -triple mips64-unknown-linux -o - -O1 -emit-llvm  -target-abi n32 %s | FileCheck %s -check-prefix=ALL -check-prefix=N32 -check-prefix=NEW
+// RUN: %clang_cc1 -triple mips64-unknown-linux -o - -O1 -emit-llvm  -target-abi n32 %s | FileCheck %s -check-prefix=ALL -check-prefix=N32 -check-prefix=NEW
+// RUN: %clang_cc1 -triple mips64-unknown-linux -o - -O1 -emit-llvm %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NEW
+// RUN: %clang_cc1 -triple mips64el-unknown-linux -o - -O1 -emit-llvm %s | FileCheck %s -check-prefix=ALL -check-prefix=N64 -check-prefix=NEW
+
+#include <stdarg.h>
+
+typedef int v4i32 __attribute__ ((__vector_size__ (16)));
+
+int test_i32(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  int v = va_arg(va, int);
+  va_end(va);
+
+  return v;
+}
+
+// ALL-LABEL: define i32 @test_i32(i8*{{.*}} %fmt, ...)
+//
+// O32:   %va = alloca i8*, align [[PTRALIGN:4]]
+// N32:   %va = alloca i8*, align [[PTRALIGN:4]]
+// N64:   %va = alloca i8*, align [[PTRALIGN:8]]
+//
+// ALL:   [[VA1:%.+]] = bitcast i8** %va to i8*
+// ALL:   call void @llvm.va_start(i8* [[VA1]])
+//
+// O32:   [[TMP0:%.+]] = bitcast i8** %va to i32**
+// O32:   [[AP_CUR:%.+]] = load i32** [[TMP0]], align [[PTRALIGN]]
+// NEW:   [[TMP0:%.+]] = bitcast i8** %va to i64**
+// NEW:   [[AP_CUR:%.+]] = load i64** [[TMP0]], align [[PTRALIGN]]
+//
+// O32:   [[TMP1:%.+]] = getelementptr i32* [[AP_CUR]], i32 1
+// O32:   [[AP_NEXT:%.+]] = bitcast i32* [[TMP1]] to i8*
+// N32:   [[TMP1:%.+]] = getelementptr i64* [[AP_CUR]], {{i32|i64}} 1
+// N64:   [[TMP1:%.+]] = getelementptr i64* [[AP_CUR]], {{i32|i64}} 1
+// NEW:   [[AP_NEXT:%.+]] = bitcast i64* [[TMP1]] to i8*
+//
+// ALL:   store i8* [[AP_NEXT]], i8** %va, align [[PTRALIGN]]
+//
+// O32:   [[ARG1:%.+]] = load i32* [[AP_CUR]], align 4
+// NEW:   [[TMP2:%.+]] = load i64* [[AP_CUR]], align 8
+// NEW:   [[ARG1:%.+]] = trunc i64 [[TMP2]] to i32
+//
+// ALL:   call void @llvm.va_end(i8* [[VA1]])
+// ALL:   ret i32 [[ARG1]]
+// ALL: }
+
+int test_i32_2args(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  int v1 = va_arg(va, int);
+  int v2 = va_arg(va, int);
+  va_end(va);
+
+  return v1 + v2;
+}
+
+// ALL-LABEL: define i32 @test_i32_2args(i8*{{.*}} %fmt, ...)
+//
+// ALL:   %va = alloca i8*, align [[PTRALIGN]]
+// ALL:   [[VA1:%.+]] = bitcast i8** %va to i8*
+// ALL:   call void @llvm.va_start(i8* [[VA1]])
+//
+// O32:   [[TMP0:%.+]] = bitcast i8** %va to i32**
+// O32:   [[AP_CUR:%.+]] = load i32** [[TMP0]], align [[PTRALIGN]]
+// NEW:   [[TMP0:%.+]] = bitcast i8** %va to i64**
+// NEW:   [[AP_CUR:%.+]] = load i64** [[TMP0]], align [[PTRALIGN]]
+//
+// O32:   [[TMP1:%.+]] = getelementptr i32* [[AP_CUR]], i32 1
+// O32:   [[AP_NEXT:%.+]] = bitcast i32* [[TMP1]] to i8*
+// N32:   [[TMP1:%.+]] = getelementptr i64* [[AP_CUR]], [[INTPTR_T:i32]] 1
+// FIXME: N32 optimised this bitcast out. Why only for this ABI?
+// N64:   [[TMP1:%.+]] = getelementptr i64* [[AP_CUR]], [[INTPTR_T:i64]] 1
+// N64:   [[AP_NEXT:%.+]] = bitcast i64* [[TMP1]] to i8*
+//
+// O32:   store i8* [[AP_NEXT]], i8** %va, align [[PTRALIGN]]
+// FIXME: N32 optimised this store out. Why only for this ABI?
+// N64:   store i8* [[AP_NEXT]], i8** %va, align [[PTRALIGN]]
+//
+// O32:   [[ARG1:%.+]] = load i32* [[AP_CUR]], align 4
+// NEW:   [[TMP3:%.+]] = load i64* [[AP_CUR]], align 8
+// NEW:   [[ARG1:%.+]] = trunc i64 [[TMP3]] to i32
+//
+// O32:   [[TMP2:%.+]] = getelementptr i32* [[AP_CUR]], i32 2
+// O32:   [[AP_NEXT:%.+]] = bitcast i32* [[TMP2]] to i8*
+// NEW:   [[TMP2:%.+]] = getelementptr i64* [[AP_CUR]], [[INTPTR_T]] 2
+// NEW:   [[AP_NEXT:%.+]] = bitcast i64* [[TMP2]] to i8*
+//
+// ALL:   store i8* [[AP_NEXT]], i8** %va, align [[PTRALIGN]]
+//
+// O32:   [[ARG2:%.+]] = load i32* [[TMP1]], align 4
+// NEW:   [[TMP4:%.+]] = load i64* [[TMP1]], align 8
+// NEW:   [[ARG2:%.+]] = trunc i64 [[TMP4]] to i32
+//
+// ALL:   call void @llvm.va_end(i8* [[VA1]])
+// ALL:   [[ADD:%.+]] = add nsw i32 [[ARG2]], [[ARG1]]
+// ALL:   ret i32 [[ADD]]
+// ALL: }
+
+long long test_i64(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  long long v = va_arg(va, long long);
+  va_end(va);
+
+  return v;
+}
+
+// ALL-LABEL: define i64 @test_i64(i8*{{.*}} %fmt, ...)
+//
+// ALL:   %va = alloca i8*, align [[PTRALIGN]]
+// ALL:   [[VA1:%.+]] = bitcast i8** %va to i8*
+// ALL:   call void @llvm.va_start(i8* [[VA1]])
+//
+// O32:   [[AP_CUR:%.+]] = load i8** %va, align [[PTRALIGN]]
+// NEW:   [[TMP0:%.+]] = bitcast i8** %va to i64**
+// NEW:   [[AP_CUR:%.+]] = load i64** [[TMP0]], align [[PTRALIGN]]
+//
+// i64 is 8-byte aligned, while this is within O32's stack alignment there's no
+// guarantee that the offset is still 8-byte aligned after earlier reads.
+// O32:   [[PTR0:%.+]] = ptrtoint i8* [[AP_CUR]] to [[INTPTR_T:i32]]
+// O32:   [[PTR1:%.+]] = add i32 [[PTR0]], 7
+// O32:   [[PTR2:%.+]] = and i32 [[PTR1]], -8
+// O32:   [[PTR3:%.+]] = inttoptr [[INTPTR_T]] [[PTR2]] to i64*
+// O32:   [[PTR4:%.+]] = inttoptr [[INTPTR_T]] [[PTR2]] to i8*
+//
+// O32:   [[AP_NEXT:%.+]] = getelementptr i8* [[PTR4]], [[INTPTR_T]] 8
+// N32:   [[TMP1:%.+]] = getelementptr i64* [[AP_CUR]], i32 1
+// N64:   [[TMP1:%.+]] = getelementptr i64* [[AP_CUR]], i64 1
+// NEW:   [[AP_NEXT:%.+]] = bitcast i64* [[TMP1]] to i8*
+//
+// ALL:   store i8* [[AP_NEXT]], i8** %va, align [[PTRALIGN]]
+//
+// O32:   [[ARG1:%.+]] = load i64* [[PTR3]], align 8
+// NEW:   [[ARG1:%.+]] = load i64* [[AP_CUR]], align 8
+//
+// ALL:   call void @llvm.va_end(i8* [[VA1]])
+// ALL:   ret i64 [[ARG1]]
+// ALL: }
+
+int test_v4i32(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  v4i32 v = va_arg(va, v4i32);
+  va_end(va);
+
+  return v[0];
+}
+
+// ALL-LABEL: define i32 @test_v4i32(i8*{{.*}} %fmt, ...)
+//
+// ALL:   %va = alloca i8*, align [[PTRALIGN]]
+// ALL:   [[VA1:%.+]] = bitcast i8** %va to i8*
+// ALL:   call void @llvm.va_start(i8* [[VA1]])
+// ALL:   [[AP_CUR:%.+]] = load i8** %va, align [[PTRALIGN]]
+//
+// O32:   [[PTR0:%.+]] = ptrtoint i8* [[AP_CUR]] to [[INTPTR_T:i32]]
+// N32:   [[PTR0:%.+]] = ptrtoint i8* [[AP_CUR]] to [[INTPTR_T:i32]]
+// N64:   [[PTR0:%.+]] = ptrtoint i8* [[AP_CUR]] to [[INTPTR_T:i64]]
+//
+// Vectors are 16-byte aligned, however the O32 ABI has a maximum alignment of
+// 8-bytes since the base of the stack is 8-byte aligned.
+// O32:   [[PTR1:%.+]] = add i32 [[PTR0]], 7
+// O32:   [[PTR2:%.+]] = and i32 [[PTR1]], -8
+//
+// NEW:   [[PTR1:%.+]] = add [[INTPTR_T]] [[PTR0]], 15
+// NEW:   [[PTR2:%.+]] = and [[INTPTR_T]] [[PTR1]], -16
+//
+// ALL:   [[PTR3:%.+]] = inttoptr [[INTPTR_T]] [[PTR2]] to <4 x i32>*
+// ALL:   [[PTR4:%.+]] = inttoptr [[INTPTR_T]] [[PTR2]] to i8*
+// ALL:   [[AP_NEXT:%.+]] = getelementptr i8* [[PTR4]], [[INTPTR_T]] 16
+// ALL:   store i8* [[AP_NEXT]], i8** %va, align [[PTRALIGN]]
+// ALL:   [[PTR5:%.+]] = load <4 x i32>* [[PTR3]], align 16
+// ALL:   call void @llvm.va_end(i8* [[VA1]])
+// ALL:   [[VECEXT:%.+]] = extractelement <4 x i32> [[PTR5]], i32 0
+// ALL:   ret i32 [[VECEXT]]
+// ALL: }
diff --git a/test/CodeGen/mips-vector-arg.c b/test/CodeGen/mips-vector-arg.c
index 6ffb043..f8c89df 100644
--- a/test/CodeGen/mips-vector-arg.c
+++ b/test/CodeGen/mips-vector-arg.c
@@ -8,19 +8,19 @@
 typedef float  v4sf __attribute__ ((__vector_size__ (16)));
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
-// O32: define void @test_v4sf(i32 %a1.coerce0, i32 %a1.coerce1, i32 %a1.coerce2, i32 %a1.coerce3, i32 %a2, i32, i32 %a3.coerce0, i32 %a3.coerce1, i32 %a3.coerce2, i32 %a3.coerce3) [[NUW:#[0-9]+]]
-// O32: declare i32 @test_v4sf_2(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32)
-// N64: define void @test_v4sf(i64 %a1.coerce0, i64 %a1.coerce1, i32 %a2, i64, i64 %a3.coerce0, i64 %a3.coerce1) [[NUW:#[0-9]+]]
-// N64: declare i32 @test_v4sf_2(i64, i64, i32, i64, i64, i64)
+// O32: define void @test_v4sf(i32 inreg %a1.coerce0, i32 inreg %a1.coerce1, i32 inreg %a1.coerce2, i32 inreg %a1.coerce3, i32 signext %a2, i32, i32 inreg %a3.coerce0, i32 inreg %a3.coerce1, i32 inreg %a3.coerce2, i32 inreg %a3.coerce3) [[NUW:#[0-9]+]]
+// O32: declare i32 @test_v4sf_2(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32 signext, i32, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
+// N64: define void @test_v4sf(i64 inreg %a1.coerce0, i64 inreg %a1.coerce1, i32 signext %a2, i64, i64 inreg %a3.coerce0, i64 inreg %a3.coerce1) [[NUW:#[0-9]+]]
+// N64: declare i32 @test_v4sf_2(i64 inreg, i64 inreg, i32 signext, i64, i64 inreg, i64 inreg)
 extern test_v4sf_2(v4sf, int, v4sf);
 void test_v4sf(v4sf a1, int a2, v4sf a3) {
   test_v4sf_2(a3, a2, a1);
 }
 
-// O32: define void @test_v4i32(i32 %a1.coerce0, i32 %a1.coerce1, i32 %a1.coerce2, i32 %a1.coerce3, i32 %a2, i32, i32 %a3.coerce0, i32 %a3.coerce1, i32 %a3.coerce2, i32 %a3.coerce3) [[NUW]]
-// O32: declare i32 @test_v4i32_2(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32)
-// N64: define void @test_v4i32(i64 %a1.coerce0, i64 %a1.coerce1, i32 %a2, i64, i64 %a3.coerce0, i64 %a3.coerce1) [[NUW]]
-// N64: declare i32 @test_v4i32_2(i64, i64, i32, i64, i64, i64)
+// O32: define void @test_v4i32(i32 inreg %a1.coerce0, i32 inreg %a1.coerce1, i32 inreg %a1.coerce2, i32 inreg %a1.coerce3, i32 signext %a2, i32, i32 inreg %a3.coerce0, i32 inreg %a3.coerce1, i32 inreg %a3.coerce2, i32 inreg %a3.coerce3) [[NUW]]
+// O32: declare i32 @test_v4i32_2(i32 inreg, i32 inreg, i32 inreg, i32 inreg, i32 signext, i32, i32 inreg, i32 inreg, i32 inreg, i32 inreg)
+// N64: define void @test_v4i32(i64 inreg %a1.coerce0, i64 inreg %a1.coerce1, i32 signext %a2, i64, i64 inreg %a3.coerce0, i64 inreg %a3.coerce1) [[NUW]]
+// N64: declare i32 @test_v4i32_2(i64 inreg, i64 inreg, i32 signext, i64, i64 inreg, i64 inreg)
 extern test_v4i32_2(v4i32, int, v4i32);
 void test_v4i32(v4i32 a1, int a2, v4i32 a3) {
   test_v4i32_2(a3, a2, a1);
diff --git a/test/CodeGen/mips-vector-return.c b/test/CodeGen/mips-vector-return.c
index a7c8ce1..8af4998 100644
--- a/test/CodeGen/mips-vector-return.c
+++ b/test/CodeGen/mips-vector-return.c
@@ -9,7 +9,7 @@
 typedef int v4i32 __attribute__ ((__vector_size__ (16)));
 
 // O32-LABEL: define void @test_v4sf(<4 x float>* noalias nocapture sret
-// N64: define { i64, i64 } @test_v4sf
+// N64: define inreg { i64, i64 } @test_v4sf
 v4sf test_v4sf(float a) {
   return (v4sf){0.0f, a, 0.0f, 0.0f};
 }
@@ -23,8 +23,8 @@
 // O32 returns integer vectors whose size is equal to or smaller than 16-bytes
 // in integer registers.
 //
-// O32: define { i32, i32, i32, i32 } @test_v4i32
-// N64: define { i64, i64 } @test_v4i32
+// O32: define inreg { i32, i32, i32, i32 } @test_v4i32
+// N64: define inreg { i64, i64 } @test_v4i32
 v4i32 test_v4i32(int a) {
   return (v4i32){0, a, 0, 0};
 }
diff --git a/test/CodeGen/mips-zero-sized-struct.c b/test/CodeGen/mips-zero-sized-struct.c
new file mode 100644
index 0000000..afff3b4
--- /dev/null
+++ b/test/CodeGen/mips-zero-sized-struct.c
@@ -0,0 +1,16 @@
+// RUN: %clang -target mips-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang -target mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang -target mips64-unknown-linux-gnu -S -emit-llvm -o - %s -mabi=n32 | FileCheck -check-prefix=N32 %s
+// RUN: %clang -target mips64el-unknown-linux-gnu -S -emit-llvm -o - %s -mabi=n32 | FileCheck -check-prefix=N32 %s
+// RUN: %clang -target mips64-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
+// RUN: %clang -target mips64el-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=N64 %s
+
+// O32: define void @fn28(%struct.T2* noalias sret %agg.result, i8 signext %arg0)
+// N32: define void @fn28(i8 signext %arg0)
+// N64: define void @fn28(i8 signext %arg0)
+
+typedef struct T2 {  } T2;
+T2 T2_retval;
+T2 fn28(char arg0) {
+  return T2_retval;
+}
diff --git a/test/CodeGen/mips64-class-return.cpp b/test/CodeGen/mips64-class-return.cpp
index a473c13..57fa8ef 100644
--- a/test/CodeGen/mips64-class-return.cpp
+++ b/test/CodeGen/mips64-class-return.cpp
@@ -24,22 +24,22 @@
 extern D1 gd1;
 extern D2 gd2;
 
-// CHECK: define { i64, i64 } @_Z4foo1v() 
+// CHECK: define inreg { i64, i64 } @_Z4foo1v()
 D0 foo1(void) {
   return gd0;
 }
 
-// CHECK: define { double, float } @_Z4foo2v() 
+// CHECK: define inreg { double, float } @_Z4foo2v()
 D1 foo2(void) {
   return gd1;
 }
 
-// CHECK-LABEL: define void @_Z4foo32D2(i64 %a0.coerce0, double %a0.coerce1) 
+// CHECK-LABEL: define void @_Z4foo32D2(i64 inreg %a0.coerce0, double inreg %a0.coerce1)
 void foo3(D2 a0) {
   gd2 = a0;
 }
 
-// CHECK-LABEL: define void @_Z4foo42D0(i64 %a0.coerce0, i64 %a0.coerce1)
+// CHECK-LABEL: define void @_Z4foo42D0(i64 inreg %a0.coerce0, i64 inreg %a0.coerce1)
 void foo4(D0 a0) {
   gd0 = a0;
 }
diff --git a/test/CodeGen/mips64-padding-arg.c b/test/CodeGen/mips64-padding-arg.c
index 49a29c1..b92098f 100644
--- a/test/CodeGen/mips64-padding-arg.c
+++ b/test/CodeGen/mips64-padding-arg.c
@@ -9,9 +9,9 @@
 
 // Insert padding to ensure arguments of type S0 are aligned to 16-byte boundaries.
 
-// N64-LABEL: define void @foo1(i32 %a0, i64, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 %b, i64, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
-// N64: tail call void @foo2(i32 1, i32 2, i32 %a0, i64 undef, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 3, i64 undef, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
-// N64: declare void @foo2(i32, i32, i32, i64, double, i64, i64, i64, double, i64, i64, i64, i32, i64, double, i64, i64, i64)
+// N64-LABEL: define void @foo1(i32 signext %a0, i64, double inreg %a1.coerce0, i64 inreg %a1.coerce1, i64 inreg %a1.coerce2, i64 inreg %a1.coerce3, double inreg %a2.coerce0, i64 inreg %a2.coerce1, i64 inreg %a2.coerce2, i64 inreg %a2.coerce3, i32 signext %b, i64, double inreg %a3.coerce0, i64 inreg %a3.coerce1, i64 inreg %a3.coerce2, i64 inreg %a3.coerce3)
+// N64: tail call void @foo2(i32 signext 1, i32 signext 2, i32 signext %a0, i64 undef, double inreg %a1.coerce0, i64 inreg %a1.coerce1, i64 inreg %a1.coerce2, i64 inreg %a1.coerce3, double inreg %a2.coerce0, i64 inreg %a2.coerce1, i64 inreg %a2.coerce2, i64 inreg %a2.coerce3, i32 signext 3, i64 undef, double inreg %a3.coerce0, i64 inreg %a3.coerce1, i64 inreg %a3.coerce2, i64 inreg %a3.coerce3)
+// N64: declare void @foo2(i32 signext, i32 signext, i32 signext, i64, double inreg, i64 inreg, i64 inreg, i64 inreg, double inreg, i64 inreg, i64 inreg, i64 inreg, i32 signext, i64, double inreg, i64 inreg, i64 inreg, i64 inreg)
 
 extern void foo2(int, int, int, S0, S0, int, S0);
 
@@ -21,9 +21,9 @@
 
 // Insert padding before long double argument.
 //
-// N64-LABEL: define void @foo3(i32 %a0, i64, fp128 %a1)
-// N64: tail call void @foo4(i32 1, i32 2, i32 %a0, i64 undef, fp128 %a1)
-// N64: declare void @foo4(i32, i32, i32, i64, fp128)
+// N64-LABEL: define void @foo3(i32 signext %a0, i64, fp128 %a1)
+// N64: tail call void @foo4(i32 signext 1, i32 signext 2, i32 signext %a0, i64 undef, fp128 %a1)
+// N64: declare void @foo4(i32 signext, i32 signext, i32 signext, i64, fp128)
 
 extern void foo4(int, int, int, long double);
 
@@ -34,8 +34,8 @@
 // Insert padding after hidden argument.
 //
 // N64-LABEL: define void @foo5(%struct.S0* noalias sret %agg.result, i64, fp128 %a0)
-// N64: call void @foo6(%struct.S0* sret %agg.result, i32 1, i32 2, i64 undef, fp128 %a0)
-// N64: declare void @foo6(%struct.S0* sret, i32, i32, i64, fp128)
+// N64: call void @foo6(%struct.S0* sret %agg.result, i32 signext 1, i32 signext 2, i64 undef, fp128 %a0)
+// N64: declare void @foo6(%struct.S0* sret, i32 signext, i32 signext, i64, fp128)
 
 extern S0 foo6(int, int, long double);
 
@@ -55,7 +55,7 @@
 }
 
 // O32-LABEL: define void @foo9()
-// O32: declare void @foo10(i32, i32
+// O32: declare void @foo10(i32 signext, i32
 
 typedef struct __attribute__((aligned(16))) {
   int a;
diff --git a/test/CodeGen/mmx-inline-asm-error.c b/test/CodeGen/mmx-inline-asm-error.c
index 876c664..1e22461 100644
--- a/test/CodeGen/mmx-inline-asm-error.c
+++ b/test/CodeGen/mmx-inline-asm-error.c
@@ -4,9 +4,9 @@
 vec256 foo(vec256 in) {
   vec256 out;
 
-  asm("something %0" : : "y"(in)); // expected-error {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
-  asm("something %0" : "=y"(out)); // expected-error {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
-  asm("something %0, %0" : "+y"(out)); // expected-error {{invalid type 'vec256' (vector of 8 'int' values) in asm input for constraint 'y'}}
+  asm("something %0" : : "y"(in)); // expected-error {{invalid input size for constraint 'y'}}
+  asm("something %0" : "=y"(out)); // expected-error {{invalid output size for constraint '=y'}}
+  asm("something %0, %0" : "+y"(out)); // expected-error {{invalid output size for constraint '+y'}}
 
   return out;
 }
diff --git a/test/CodeGen/mozilla-ms-inline-asm.c b/test/CodeGen/mozilla-ms-inline-asm.c
new file mode 100644
index 0000000..b8b7a2d
--- /dev/null
+++ b/test/CodeGen/mozilla-ms-inline-asm.c
@@ -0,0 +1,64 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | opt -strip -S | FileCheck %s
+
+// Some test cases for MS inline asm support from Mozilla code base.
+
+void invoke_copy_to_stack() {}
+
+void invoke(void* that, unsigned methodIndex,
+            unsigned paramCount, void* params)
+{
+// CHECK: @invoke
+// CHECK: %5 = alloca i8*, align 4
+// CHECK: %6 = alloca i32, align 4
+// CHECK: %7 = alloca i32, align 4
+// CHECK: %8 = alloca i8*, align 4
+// CHECK: store i8* %0, i8** %5, align 4
+// CHECK: store i32 %1, i32* %6, align 4
+// CHECK: store i32 %2, i32* %7, align 4
+// CHECK: store i8* %3, i8** %8, align 4
+// CHECK: call void asm sideeffect inteldialect
+// CHECK: mov edx,dword ptr $1
+// CHECK: test edx,edx
+// CHECK: jz {{[^_]*}}__MSASMLABEL_.0__noparams
+//             ^ Can't use {{.*}} here because the matching is greedy.
+// CHECK: mov eax,edx
+// CHECK: shl eax,$$3
+// CHECK: sub esp,eax
+// CHECK: mov ecx,esp
+// CHECK: push dword ptr $0
+// CHECK: call dword ptr $2
+// CHECK: {{.*}}__MSASMLABEL_.0__noparams:
+// CHECK: mov ecx,dword ptr $3
+// CHECK: push ecx
+// CHECK: mov edx,[ecx]
+// CHECK: mov eax,dword ptr $4
+// CHECK: call dword ptr[edx+eax*$$4]
+// CHECK: mov esp,ebp
+// CHECK: pop ebp
+// CHECK: ret
+// CHECK: "=*m,*m,*m,*m,*m,~{eax},~{ebp},~{ecx},~{edx},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}"
+// CHECK: (i8** %8, i32* %7, void (...)* bitcast (void ()* @invoke_copy_to_stack to void (...)*), i8** %5, i32* %6)
+// CHECK: ret void
+    __asm {
+        mov     edx,paramCount
+        test    edx,edx
+        jz      noparams
+        mov     eax,edx
+        shl     eax,3
+        sub     esp,eax
+        mov     ecx,esp
+        push    params
+        call    invoke_copy_to_stack
+noparams:
+        mov     ecx,that
+        push    ecx
+        mov     edx,[ecx]
+        mov     eax,methodIndex
+        call    dword ptr[edx+eax*4]
+        mov     esp,ebp
+        pop     ebp
+        ret
+    }
+}
+
diff --git a/test/CodeGen/mrtd.c b/test/CodeGen/mrtd.c
index 8fa7cf0..f929d4c 100644
--- a/test/CodeGen/mrtd.c
+++ b/test/CodeGen/mrtd.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck %s
+
+// CHECK: mrtd.c:10:3: warning: function with no prototype cannot use the stdcall calling convention
 
 void baz(int arg);
 
diff --git a/test/CodeGen/ms-align-tentative.c b/test/CodeGen/ms-align-tentative.c
new file mode 100644
index 0000000..ccd7616
--- /dev/null
+++ b/test/CodeGen/ms-align-tentative.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s
+
+char __declspec(align(8192)) x;
+// CHECK-DAG: @x = global i8 0, align 8192
+
+typedef char __declspec(align(8192)) T;
+T y;
+// CHECK-DAG: @y = global i8 0, align 8192
+
+T __declspec(align(8192)) z;
+// CHECK-DAG: @z = global i8 0, align 8192
+
+int __declspec(align(16)) redef;
+int __declspec(align(32)) redef = 8;
+// CHECK-DAG: @redef = global i32 8, align 32
diff --git a/test/CodeGen/ms-inline-asm-functions.c b/test/CodeGen/ms-inline-asm-functions.c
new file mode 100644
index 0000000..1a6ead9
--- /dev/null
+++ b/test/CodeGen/ms-inline-asm-functions.c
@@ -0,0 +1,60 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc -fms-extensions -S -o - | FileCheck %s
+
+// Yes, this is an assembly test from Clang, because we need to make it all the
+// way through code generation to know if our call became a direct, pc-relative
+// call or an indirect call through memory.
+
+int k(int);
+__declspec(dllimport) int kimport(int);
+int (*kptr)(int);
+int (*gptr())(int);
+
+int foo() {
+  // CHECK-LABEL: _foo:
+  int (*r)(int) = gptr();
+
+  // Simple case: direct call.
+  __asm call k;
+  // CHECK:     calll   _k
+
+  // Marginally harder: indirect calls, via dllimport or function pointer.
+  __asm call r;
+  // CHECK:     calll   *({{.*}})
+  __asm call kimport;
+  // CHECK:     calll   *({{.*}})
+
+  // Broken case: Call through a global function pointer.
+  __asm call kptr;
+  // CHECK:     calll   _kptr
+  // CHECK-FIXME: calll   *_kptr
+}
+
+int bar() {
+  // CHECK-LABEL: _bar:
+  __asm jmp k;
+  // CHECK:     jmp     _k
+}
+
+int baz() {
+  // CHECK-LABEL: _baz:
+  __asm mov eax, k;
+  // CHECK: movl    _k, %eax
+  __asm mov eax, kptr;
+  // CHECK: movl    _kptr, %eax
+}
+
+// Test that this asm blob doesn't require more registers than available.  This
+// has to be an LLVM code generation test.
+
+void __declspec(naked) naked() {
+  __asm pusha
+  __asm call k
+  __asm popa
+  __asm ret
+  // CHECK-LABEL: _naked:
+  // CHECK: pushal
+  // CHECK-NEXT: calll _k
+  // CHECK-NEXT: popal
+  // CHECK-NEXT: retl
+}
diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c
index 3b55b50..59ff202 100644
--- a/test/CodeGen/ms-inline-asm.c
+++ b/test/CodeGen/ms-inline-asm.c
@@ -10,9 +10,7 @@
 
 void t2() {
 // CHECK: @t2
-// CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "nop\0A\09nop\0A\09nop", "~{dirflag},~{fpsr},~{flags}"()
 // CHECK: ret void
   __asm nop
   __asm nop
@@ -28,8 +26,7 @@
 
 void t4(void) {
 // CHECK: @t4
-// CHECK: call void asm sideeffect inteldialect "mov ebx, eax", "~{ebx},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov ecx, ebx", "~{ecx},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "mov ebx, eax\0A\09mov ecx, ebx", "~{ebx},~{ecx},~{dirflag},~{fpsr},~{flags}"()
 // CHECK: ret void
   __asm mov ebx, eax
   __asm mov ecx, ebx
@@ -69,9 +66,7 @@
   __asm int 4
   return 10;
 // CHECK: t8
-// CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call i32 asm sideeffect inteldialect "int $$4\0A\09int $$4", "={eax},~{dirflag},~{fpsr},~{flags}"()
 // CHECK: ret i32 10
 }
 
@@ -93,10 +88,11 @@
   }
   return j;
 // CHECK: t10
+// CHECK: [[r:%[a-zA-Z0-9]+]] = alloca i32, align 4
 // CHECK: [[I:%[a-zA-Z0-9]+]] = alloca i32, align 4
 // CHECK: [[J:%[a-zA-Z0-9]+]] = alloca i32, align 4
 // CHECK: store i32 1, i32* [[I]], align 4
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $1\0A\09mov dword ptr $0, eax", "=*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
+// CHECK: call i32 asm sideeffect inteldialect "mov eax, dword ptr $2\0A\09mov dword ptr $0, eax", "=*m,={eax},*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}})
 // CHECK: [[RET:%[a-zA-Z0-9]+]] = load i32* [[J]], align 4
 // CHECK: ret i32 [[RET]]
 }
@@ -117,7 +113,7 @@
   }
   return j + m;
 // CHECK: t12
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $2\0A\09mov dword ptr $0, eax\0A\09mov eax, dword ptr $3\0A\09mov dword ptr $1, eax", "=*m,=*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}})
+// CHECK: call i32 asm sideeffect inteldialect "mov eax, dword ptr $3\0A\09mov dword ptr $0, eax\0A\09mov eax, dword ptr $4\0A\09mov dword ptr $1, eax", "=*m,=*m,={eax},*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}})
 }
 
 void t13() {
@@ -126,8 +122,7 @@
   __asm movzx eax, i
   __asm movzx eax, j
 // CHECK: t13
-// CHECK: call void asm sideeffect inteldialect "movzx eax, byte ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i8* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "movzx eax, word ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i16* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect "movzx eax, byte ptr $0\0A\09movzx eax, word ptr $1", "*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i8* %{{.*}}i, i16* %{{.*}}j)
 }
 
 void t14() {
@@ -145,14 +140,15 @@
 
 int gvar = 10;
 void t15() {
+// CHECK: t15
   int lvar = 10;
   __asm mov eax, lvar        ; eax = 10
+// CHECK: mov eax, dword ptr $0
   __asm mov eax, offset lvar ; eax = address of lvar
+// CHECK: mov eax, $1
   __asm mov eax, offset gvar ; eax = address of gvar
-// CHECK: t15
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* @{{.*}})
+// CHECK: mov eax, $2
+// CHECK: "*m,r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* @{{.*}})
 }
 
 void t16() {
@@ -163,50 +159,52 @@
 }
 
 void t17() {
-  __asm _emit 0x4A
-  __asm _emit 0x43
-  __asm _emit 0x4B
-  __asm _EMIT 0x4B
 // CHECK: t17
-// CHECK:  call void asm sideeffect inteldialect ".byte 0x4A", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK:  call void asm sideeffect inteldialect ".byte 0x43", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK:  call void asm sideeffect inteldialect ".byte 0x4B", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK:  call void asm sideeffect inteldialect ".byte 0x4B", "~{dirflag},~{fpsr},~{flags}"()
+  __asm _emit 0x4A
+// CHECK: .byte 0x4A
+  __asm _emit 0x43
+// CHECK: .byte 0x43
+  __asm _emit 0x4B
+// CHECK: .byte 0x4B
+  __asm _EMIT 0x4B
+// CHECK: .byte 0x4B
+// CHECK:  "~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t20() {
+// CHECK: t20
   char bar;
   int foo;
   char _bar[2];
   int _foo[4];
 
   __asm mov eax, LENGTH foo
+// CHECK: mov eax, $$1
   __asm mov eax, LENGTH bar
+// CHECK: mov eax, $$1
   __asm mov eax, LENGTH _foo
+// CHECK: mov eax, $$4
   __asm mov eax, LENGTH _bar
-// CHECK: t20
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: mov eax, $$2
 
   __asm mov eax, TYPE foo
+// CHECK: mov eax, $$4
   __asm mov eax, TYPE bar
+// CHECK: mov eax, $$1
   __asm mov eax, TYPE _foo
+// CHECK: mov eax, $$4
   __asm mov eax, TYPE _bar
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: mov eax, $$1
 
   __asm mov eax, SIZE foo
+// CHECK: mov eax, $$4
   __asm mov eax, SIZE bar
+// CHECK: mov eax, $$1
   __asm mov eax, SIZE _foo
+// CHECK: mov eax, $$16
   __asm mov eax, SIZE _bar
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$16", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: mov eax, $$2
+// CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t21() {
@@ -242,45 +240,46 @@
   the_label:
   }
 // CHECK: t23
-// CHECK: call void asm sideeffect inteldialect "the_label:", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.0__the_label:", "~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t24_helper(void) {}
 void t24() {
   __asm call t24_helper
 // CHECK: t24
-// CHECK: call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void ()* @t24_helper)
+// CHECK: call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(void ()* @t24_helper)
 }
 
 void t25() {
-  __asm mov eax, 0ffffffffh
-  __asm mov eax, 0fh
-  __asm mov eax, 0a2h
-  __asm mov eax, 0xa2h
-  __asm mov eax, 0xa2
 // CHECK: t25
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967295", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$15", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$162", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$0xa2h", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$0xa2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+  __asm mov eax, 0ffffffffh
+// CHECK: mov eax, $$4294967295
+  __asm mov eax, 0fh
+// CHECK: mov eax, $$15
+  __asm mov eax, 0a2h
+// CHECK: mov eax, $$162
+  __asm mov eax, 0xa2h
+// CHECK: mov eax, $$0xa2h
+  __asm mov eax, 0xa2
+// CHECK: mov eax, $$0xa2
+// CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t26() {
-  __asm pushad
-  __asm mov eax, 0
-  __asm __emit 0fh
-  __asm __emit 0a2h
-  __asm __EMIT 0a2h
-  __asm popad
-// FIXME: These all need to be merged into the same asm blob.
 // CHECK: t26
-// CHECK: call void asm sideeffect inteldialect "pushad", "~{esp},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$0", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect ".byte 0fh", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect ".byte 0a2h", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect ".byte 0a2h", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "popad", "~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"()
+  __asm pushad
+// CHECK: pushad
+  __asm mov eax, 0
+// CHECK: mov eax, $$0
+  __asm __emit 0fh
+// CHECK: .byte 0fh
+  __asm __emit 0a2h
+// CHECK: .byte 0a2h
+  __asm __EMIT 0a2h
+// CHECK: .byte 0a2h
+  __asm popad
+// CHECK: popad
+// CHECK: "~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t27() {
@@ -290,160 +289,171 @@
 }
 
 void t28() {
-  __asm align 8
-  __asm align 16;
-  __asm align 128;
-  __asm ALIGN 256;
 // CHECK: t28
-// CHECK: call void asm sideeffect inteldialect ".align 3", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect ".align 4", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect ".align 7", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect ".align 8", "~{dirflag},~{fpsr},~{flags}"()
+  __asm align 8
+// CHECK: .align 3
+  __asm align 16;
+// CHECK: .align 4
+  __asm align 128;
+// CHECK: .align 7
+  __asm ALIGN 256;
+// CHECK: .align 8
+// CHECK: "~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t29() {
+// CHECK: t29
   int arr[2] = {0, 0};
   int olen = 0, osize = 0, otype = 0;
   __asm mov olen, LENGTH arr
+// CHECK: mov dword ptr $0, $$2
   __asm mov osize, SIZE arr
+// CHECK: mov dword ptr $1, $$8
   __asm mov otype, TYPE arr
-// CHECK: t29
-// CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$2", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$8", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$4", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
+// CHECK: mov dword ptr $2, $$4
+// CHECK: "=*m,=*m,=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}})
 }
 
 int results[2] = {13, 37};
 int *t30()
+// CHECK: t30
 {
   int *res;
   __asm lea edi, results
+// CHECK: lea edi, dword ptr $2
   __asm mov res, edi
+// CHECK: mov dword ptr $0, edi
   return res;
-// CHECK: t30
-// CHECK: call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"([2 x i32]* @{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(i32** %{{.*}})
+// CHECK: "=*m,={eax},*m,~{edi},~{dirflag},~{fpsr},~{flags}"(i32** %{{.*}}, [2 x i32]* @{{.*}})
 }
 
 void t31() {
-  __asm pushad
-  __asm popad
 // CHECK: t31
-// CHECK: call void asm sideeffect inteldialect "pushad", "~{esp},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "popad", "~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"()
+  __asm pushad
+// CHECK: pushad
+  __asm popad
+// CHECK: popad
+// CHECK: "~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t32() {
+// CHECK: t32
   int i;
   __asm mov eax, i
+// CHECK: mov eax, dword ptr $0
   __asm mov eax, dword ptr i
+// CHECK: mov eax, dword ptr $1
   __asm mov ax, word ptr i
+// CHECK: mov ax, word ptr $2
   __asm mov al, byte ptr i
-// CHECK: t32
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov ax, word ptr $0", "*m,~{ax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov al, byte ptr $0", "*m,~{al},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
+// CHECK: mov al, byte ptr $3
+// CHECK: "*m,*m,*m,*m,~{al},~{ax},~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}})
 }
 
 void t33() {
+// CHECK: t33
   int i;
   __asm mov eax, [i]
+// CHECK: mov eax, dword ptr $0
   __asm mov eax, dword ptr [i]
+// CHECK: mov eax, dword ptr $1
   __asm mov ax, word ptr [i]
+// CHECK: mov ax, word ptr $2
   __asm mov al, byte ptr [i]
-// CHECK: t33
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov ax, word ptr $0", "*m,~{ax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
-// CHECK: call void asm sideeffect inteldialect "mov al, byte ptr $0", "*m,~{al},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
+// CHECK: mov al, byte ptr $3
+// CHECK: "*m,*m,*m,*m,~{al},~{ax},~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}})
 }
 
 void t34() {
-  __asm prefetchnta 64[eax]
-  __asm mov eax, dword ptr 4[eax]
 // CHECK: t34
-// CHECK: call void asm sideeffect inteldialect "prefetchnta $$64[eax]", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4[eax]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+  __asm prefetchnta 64[eax]
+// CHECK: prefetchnta $$64[eax]
+  __asm mov eax, dword ptr 4[eax]
+// CHECK: mov eax, dword ptr $$4[eax]
+// CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t35() {
-  __asm prefetchnta [eax + (200*64)]
-  __asm mov eax, dword ptr [eax + (200*64)]
 // CHECK: t35
-// CHECK: call void asm sideeffect inteldialect "prefetchnta [eax + ($$200*$$64)]", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr [eax + ($$200*$$64)]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+  __asm prefetchnta [eax + (200*64)]
+// CHECK: prefetchnta [eax + ($$200*$$64)]
+  __asm mov eax, dword ptr [eax + (200*64)]
+// CHECK: mov eax, dword ptr [eax + ($$200*$$64)]
+// CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t36() {
-  int arr[4];
-  __asm mov eax, 4[arr]
-  __asm mov eax, 4[arr + 4]
-  __asm mov eax, 8[arr + 4 + 32*2 - 4]
-  __asm mov eax, 12[4 + arr]
-  __asm mov eax, 4[4 + arr + 4]
-  __asm mov eax, 4[64 + arr + (2*32)]
-  __asm mov eax, 4[64 + arr - 2*32]
-  __asm mov eax, [arr + 4]
-  __asm mov eax, [arr + 4 + 32*2 - 4]
-  __asm mov eax, [4 + arr]
-  __asm mov eax, [4 + arr + 4]
-  __asm mov eax, [64 + arr + (2*32)]
-  __asm mov eax, [64 + arr - 2*32]
 // CHECK: t36
+  int arr[4];
+  // Work around PR20368: These should be single line blocks
+  __asm { mov eax, 4[arr] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4[arr + 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 8[arr + 4 + 32*2 - 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 12[4 + arr] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4[4 + arr + 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4[64 + arr + (2*32)] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4[64 + arr - 2*32] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, [arr + 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, [arr + 4 + 32*2 - 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, [4 + arr] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, [4 + arr + 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, [64 + arr + (2*32)] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$128$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, [64 + arr - 2*32] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
 }
 
 void t37() {
-  __asm mov eax, 4 + 8
-  __asm mov eax, 4 + 8 * 16
-  __asm mov eax, -4 + 8 * 16
-  __asm mov eax, (4 + 4) * 16
-  __asm mov eax, 4 + 8 * -16
-  __asm mov eax, 4 + 16 / -8
-  __asm mov eax, (16 + 16) / -8
-  __asm mov eax, ~15
 // CHECK: t37
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$12", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$132", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$124", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$128", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967172", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967292", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967280", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+  __asm mov eax, 4 + 8
+// CHECK: mov eax, $$12
+  __asm mov eax, 4 + 8 * 16
+// CHECK: mov eax, $$132
+  __asm mov eax, -4 + 8 * 16
+// CHECK: mov eax, $$124
+  __asm mov eax, (4 + 4) * 16
+// CHECK: mov eax, $$128
+  __asm mov eax, 4 + 8 * -16
+// CHECK: mov eax, $$4294967172
+  __asm mov eax, 4 + 16 / -8
+// CHECK: mov eax, $$2
+  __asm mov eax, (16 + 16) / -8
+// CHECK: mov eax, $$4294967292
+  __asm mov eax, ~15
+// CHECK: mov eax, $$4294967280
+// CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t38() {
-  int arr[4];
-  __asm mov eax, 4+4[arr]
-  __asm mov eax, (4+4)[arr + 4]
-  __asm mov eax, 8*2[arr + 4 + 32*2 - 4]
-  __asm mov eax, 12+20[4 + arr]
-  __asm mov eax, 4*16+4[4 + arr + 4]
-  __asm mov eax, 4*4[64 + arr + (2*32)]
-  __asm mov eax, 4*(4-2)[64 + arr - 2*32]
-  __asm mov eax, 32*(4-2)[arr - 2*32]
 // CHECK: t38
+  int arr[4];
+  // Work around PR20368: These should be single line blocks
+  __asm { mov eax, 4+4[arr] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, (4+4)[arr + 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 8*2[arr + 4 + 32*2 - 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$80$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 12+20[4 + arr] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$36$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4*16+4[4 + arr + 4] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$76$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4*4[64 + arr + (2*32)] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$144$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 4*(4-2)[64 + arr - 2*32] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
+  __asm { mov eax, 32*(4-2)[arr - 2*32] }
 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$0$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
 }
 
@@ -459,20 +469,87 @@
 } A;
 
 void t39() {
+// CHECK-LABEL: define void @t39
   __asm mov eax, [eax].A.b
+// CHECK: mov eax, [eax].4
   __asm mov eax, [eax] A.b
+// CHECK: mov eax, [eax] .4
   __asm mov eax, fs:[0] A.b
-  // CHECK-LABEL: define void @t39
-  // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-  // CHECK: call void asm sideeffect inteldialect "mov eax, [eax] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
-  // CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: mov eax, fs:[$$0] .4
+// CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
 
 void t40(float a) {
+// CHECK-LABEL: define void @t40
   int i;
   __asm fld a
+// CHECK: fld dword ptr $1
   __asm fistp i
-  // CHECK-LABEL: define void @t40
-  // CHECK: call void asm sideeffect inteldialect "fld dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(float* {{.*}})
-  // CHECK: call void asm sideeffect inteldialect "fistp dword ptr $0", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* {{.*}})
+// CHECK: fistp dword ptr $0
+// CHECK: "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, float* %{{.*}})
+}
+
+void t41(unsigned short a) {
+// CHECK-LABEL: define void @t41(i16 zeroext %a)
+  __asm mov cs, a;
+// CHECK: mov cs, word ptr $0
+  __asm mov ds, a;
+// CHECK: mov ds, word ptr $1
+  __asm mov es, a;
+// CHECK: mov es, word ptr $2
+  __asm mov fs, a;
+// CHECK: mov fs, word ptr $3
+  __asm mov gs, a;
+// CHECK: mov gs, word ptr $4
+  __asm mov ss, a;
+// CHECK: mov ss, word ptr $5
+// CHECK: "*m,*m,*m,*m,*m,*m,~{dirflag},~{fpsr},~{flags}"(i16* {{.*}}, i16* {{.*}}, i16* {{.*}}, i16* {{.*}}, i16* {{.*}}, i16* {{.*}})
+}
+
+void call_clobber() {
+  __asm call t41
+  // CHECK-LABEL: define void @call_clobber
+  // CHECK: call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(void (i16)* @t41)
+}
+
+void xgetbv() {
+  __asm xgetbv
+}
+// CHECK-LABEL: define void @xgetbv()
+// CHECK: call void asm sideeffect inteldialect "xgetbv", "~{eax},~{edx},~{dirflag},~{fpsr},~{flags}"()
+
+void label1() {
+  __asm {
+    label:
+    jmp label
+  }
+  // CHECK-LABEL: define void @label1
+  // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.1__label:\0A\09jmp {{.*}}__MSASMLABEL_.1__label", "~{dirflag},~{fpsr},~{flags}"()
+}
+
+void label2() {
+  __asm {
+    jmp label
+    label:
+  }
+  // CHECK-LABEL: define void @label2
+  // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.2__label\0A\09{{.*}}__MSASMLABEL_.2__label:", "~{dirflag},~{fpsr},~{flags}"()
+}
+
+void label3() {
+  __asm {
+    label:
+    mov eax, label
+  }
+  // CHECK-LABEL: define void @label3
+  // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.3__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.3__label", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+}
+
+void label4() {
+  __asm {
+    label:
+    mov eax, [label]
+  }
+  // CHECK-LABEL: define void @label4
+  // CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.4__label:\0A\09mov eax, {{.*}}__MSASMLABEL_.4__label", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
diff --git a/test/CodeGen/ms-inline-asm.cpp b/test/CodeGen/ms-inline-asm.cpp
index 83fe107..03d971e 100644
--- a/test/CodeGen/ms-inline-asm.cpp
+++ b/test/CodeGen/ms-inline-asm.cpp
@@ -22,11 +22,7 @@
   __asm mov eax, dword ptr [Foo :: ptr]
   __asm mov eax, dword ptr [Foo :: ptr]
 // CHECK: @_Z2t1v
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE)
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3Bar3ptrE)
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE)
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE)
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE)
+// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0\0A\09mov eax, dword ptr $1\0A\09mov eax, dword ptr $2\0A\09mov eax, dword ptr $3\0A\09mov eax, dword ptr $4", "*m,*m,*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE, i32** @_ZN3Foo3Bar3ptrE, i32** @_ZN3Foo3ptrE, i32** @_ZN3Foo3ptrE, i32** @_ZN3Foo3ptrE)
 }
 
 int gvar = 10;
@@ -35,38 +31,26 @@
   __asm mov eax, offset Foo::ptr
   __asm mov eax, offset Foo::Bar::ptr
 // CHECK: t2
-// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE)
-// CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3Bar3ptrE)
+// CHECK: call void asm sideeffect inteldialect "mov eax, $0\0A\09mov eax, $1", "r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32** @_ZN3Foo3ptrE, i32** @_ZN3Foo3Bar3ptrE)
 }
 
 // CHECK-LABEL: define void @_Z2t3v()
 void t3() {
   __asm mov eax, LENGTH Foo::ptr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, LENGTH Foo::Bar::ptr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, LENGTH Foo::arr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, LENGTH Foo::Bar::arr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 
   __asm mov eax, TYPE Foo::ptr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, TYPE Foo::Bar::ptr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, TYPE Foo::arr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, TYPE Foo::Bar::arr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 
   __asm mov eax, SIZE Foo::ptr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, SIZE Foo::Bar::ptr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, SIZE Foo::arr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$16", "~{eax},~{dirflag},~{fpsr},~{flags}"()
   __asm mov eax, SIZE Foo::Bar::arr
-// CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void asm sideeffect inteldialect "mov eax, $$1\0A\09mov eax, $$1\0A\09mov eax, $$4\0A\09mov eax, $$2\0A\09mov eax, $$4\0A\09mov eax, $$4\0A\09mov eax, $$4\0A\09mov eax, $$1\0A\09mov eax, $$4\0A\09mov eax, $$4\0A\09mov eax, $$16\0A\09mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 
 }
 
@@ -82,9 +66,8 @@
 // CHECK: [[THIS:%.*]] = load [[T4]]** [[T0]]
 // CHECK: [[X:%.*]] = getelementptr inbounds [[T4]]* [[THIS]], i32 0, i32 0
   __asm mov eax, x;
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* [[X]])
   __asm mov y, eax;
-// CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, eax", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* @_ZN2T41yE)
+// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $1\0A\09mov dword ptr $0, eax", "=*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* @_ZN2T41yE, i32* {{.*}})
 }
 
 template <class T> struct T5 {
@@ -97,11 +80,9 @@
   // CHECK: [[Y:%.*]] = alloca i32
   int x, y;
   __asm push y
-  // CHECK: call void asm sideeffect inteldialect "push dword ptr $0", "=*m,~{esp},~{dirflag},~{fpsr},~{flags}"(i32* [[Y]])
   __asm call T5<int>::create<float>
-  // CHECK: call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(i32 (float)* @_ZN2T5IiE6createIfEEiT_)
   __asm mov x, eax
-  // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, eax", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* [[X]])
+  // CHECK: call void asm sideeffect inteldialect "push dword ptr $0\0A\09call dword ptr $2\0A\09mov dword ptr $1, eax", "=*m,=*m,*m,~{esp},~{dirflag},~{fpsr},~{flags}"(i32* %y, i32* %x, i32 (float)* @_ZN2T5IiE6createIfEEiT_)
 }
 
 // Just verify this doesn't emit an error.
@@ -141,3 +122,20 @@
   // CHECK-LABEL: define void @_Z8t7_usingv
   // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
 }
+
+void t8() {
+  __asm some_label:
+  // CHECK-LABEL: define void @_Z2t8v()
+  // CHECK: call void asm sideeffect inteldialect "L__MSASMLABEL_.1__some_label:", "~{dirflag},~{fpsr},~{flags}"()
+  struct A {
+    static void g() {
+      __asm jmp some_label ; This should jump forwards
+      __asm some_label:
+      __asm nop
+      // CHECK-LABEL: define internal void @_ZZ2t8vEN1A1gEv()
+      // CHECK: call void asm sideeffect inteldialect "jmp L__MSASMLABEL_.2__some_label\0A\09L__MSASMLABEL_.2__some_label:\0A\09nop", "~{dirflag},~{fpsr},~{flags}"()
+    }
+  };
+  A::g();
+}
+
diff --git a/test/CodeGen/ms-intrinsics.c b/test/CodeGen/ms-intrinsics.c
index fb0f62c..3974e91 100644
--- a/test/CodeGen/ms-intrinsics.c
+++ b/test/CodeGen/ms-intrinsics.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i686--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK -check-prefix CHECK-I386
 // RUN: %clang_cc1 -triple thumbv7--windows -fms-compatibility -Oz -emit-llvm %s -o - | FileCheck %s
 
 void *test_InterlockedExchangePointer(void * volatile *Target, void *Value) {
@@ -36,3 +36,16 @@
 // CHECK:   %[[EXCHANGE:[0-9]+]] = atomicrmw xchg i32* %Target, i32 %Value seq_cst
 // CHECK:   ret i32 %[[EXCHANGE:[0-9]+]]
 // CHECK: }
+
+#if defined(__i386__)
+long test__readfsdword(unsigned long Offset) {
+  return __readfsdword(Offset);
+}
+
+// CHECK-I386: define i32 @test__readfsdword(i32 %Offset){{.*}}{
+// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i32 addrspace(257)*
+// CHECK-I386:   [[VALUE:%[0-9]+]] = load volatile i32 addrspace(257)* [[PTR]], align 4
+// CHECK-I386:   ret i32 [[VALUE:%[0-9]+]]
+// CHECK-I386: }
+#endif
+
diff --git a/test/CodeGen/nonnull.c b/test/CodeGen/nonnull.c
new file mode 100644
index 0000000..7c33e63
--- /dev/null
+++ b/test/CodeGen/nonnull.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck %s
+
+// CHECK: define void @foo(i32* nonnull %x)
+void foo(int * __attribute__((nonnull)) x) {
+  *x = 0;
+}
+
+// CHECK: define void @bar(i32* nonnull %x)
+void bar(int * x) __attribute__((nonnull(1)))  {
+  *x = 0;
+}
+
+// CHECK: define void @bar2(i32* %x, i32* nonnull %y)
+void bar2(int * x, int * y) __attribute__((nonnull(2)))  {
+  *x = 0;
+}
+
+static int a;
+// CHECK: define nonnull i32* @bar3()
+int * bar3() __attribute__((returns_nonnull))  {
+  return &a;
+}
+
+// CHECK: define i32 @bar4(i32 %n, i32* nonnull %p)
+int bar4(int n, int *p) __attribute__((nonnull)) {
+  return n + *p;
+}
+
+// CHECK: define i32 @bar5(i32 %n, i32* nonnull %p)
+int bar5(int n, int *p) __attribute__((nonnull(1, 2))) {
+  return n + *p;
+}
+
+typedef union {
+  unsigned long long n;
+  int *p;
+  double d;
+} TransparentUnion __attribute__((transparent_union));
+
+// CHECK: define i32 @bar6(i64 %
+int bar6(TransparentUnion tu) __attribute__((nonnull(1))) {
+  return *tu.p;
+}
+
+// CHECK: define void @bar7(i32* nonnull %a, i32* nonnull %b)
+void bar7(int *a, int *b) __attribute__((nonnull(1)))
+__attribute__((nonnull(2))) {}
+
+// CHECK: define void @bar8(i32* nonnull %a, i32* nonnull %b)
+void bar8(int *a, int *b) __attribute__((nonnull))
+__attribute__((nonnull(1))) {}
diff --git a/test/CodeGen/nvptx-abi.c b/test/CodeGen/nvptx-abi.c
index f846def..58ad6a1 100644
--- a/test/CodeGen/nvptx-abi.c
+++ b/test/CodeGen/nvptx-abi.c
@@ -5,13 +5,39 @@
   float x, y, z, w;
 } float4_t;
 
-float4_t my_function(void);
-
-// CHECK-DAG: declare %struct.float4_s @my_function
+float4_t my_function(void) {
+// CHECK-LABEL: define %struct.float4_s @my_function
+  float4_t t;
+  return t;
+};
 
 float bar(void) {
   float4_t ret;
-// CHECK-DAG: call %struct.float4_s @my_function
+// CHECK-LABEL: @bar
+// CHECK: call %struct.float4_s @my_function
   ret = my_function();
   return ret.x;
 }
+
+void foo(float4_t x) {
+// CHECK-LABEL: @foo
+// CHECK: %struct.float4_s* byval %x
+}
+
+void fooN(float4_t x, float4_t y, float4_t z) {
+// CHECK-LABEL: @fooN
+// CHECK: %struct.float4_s* byval %x
+// CHECK: %struct.float4_s* byval %y
+// CHECK: %struct.float4_s* byval %z
+}
+
+typedef struct nested_s {
+  unsigned long long x;
+  float z[64];
+  float4_t t;
+} nested_t;
+
+void baz(nested_t x) {
+// CHECK-LABEL: @baz
+// CHECK: %struct.nested_s* byval %x)
+}
diff --git a/test/CodeGen/piclevels.c b/test/CodeGen/piclevels.c
new file mode 100644
index 0000000..1cd750c
--- /dev/null
+++ b/test/CodeGen/piclevels.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -pic-level 2 %s -o - | FileCheck %s -check-prefix=CHECK-BIGPIC
+// RUN: %clang_cc1 -emit-llvm -pic-level 1 %s -o - | FileCheck %s -check-prefix=CHECK-SMALLPIC
+
+// CHECK-BIGPIC: !llvm.module.flags = !{{{.*}}}
+// CHECK-BIGPIC: !{{[0-9]+}} = metadata !{i32 1, metadata !"PIC Level", i32 2}
+// CHECK-SMALLPIC: !llvm.module.flags = !{{{.*}}}
+// CHECK-SMALLPIC: !{{[0-9]+}} = metadata !{i32 1, metadata !"PIC Level", i32 1}
diff --git a/test/CodeGen/ppc-signbit.c b/test/CodeGen/ppc-signbit.c
new file mode 100644
index 0000000..31b71d8
--- /dev/null
+++ b/test/CodeGen/ppc-signbit.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple powerpc64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple powerpc64le-linux-gnu | FileCheck %s
+
+int test(long double x) { return __builtin_signbitl(x); }
+
+// CHECK-LABEL: define signext i32 @test(ppc_fp128 %x)
+// CHECK: bitcast ppc_fp128 %{{.*}} to i128
+// CHECK: trunc i128 %{{.*}} to i64
+// CHECK: icmp slt i64 %{{.*}}, 0
+// CHECK: zext i1 %{{.*}} to i32
+
diff --git a/test/CodeGen/ppc-varargs-struct.c b/test/CodeGen/ppc-varargs-struct.c
new file mode 100644
index 0000000..f0e075b
--- /dev/null
+++ b/test/CodeGen/ppc-varargs-struct.c
@@ -0,0 +1,112 @@
+// REQUIRES: powerpc-registered-target
+// REQUIRES: asserts
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-PPC
+
+#include <stdarg.h>
+
+struct x {
+  long a;
+  double b;
+};
+
+void testva (int n, ...)
+{
+  va_list ap;
+
+  struct x t = va_arg (ap, struct x);
+// CHECK: bitcast i8* %{{[a-z.0-9]*}} to %struct.x*
+// CHECK: bitcast %struct.x* %t to i8*
+// CHECK: bitcast %struct.x* %{{[0-9]+}} to i8*
+// CHECK: call void @llvm.memcpy
+// CHECK-PPC:  [[ARRAYDECAY:%[a-z0-9]+]] = getelementptr inbounds [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
+// CHECK-PPC-NEXT:  [[GPRPTR:%[a-z0-9]+]] = bitcast %struct.__va_list_tag* [[ARRAYDECAY]] to i8*
+// CHECK-PPC-NEXT:  [[ZERO:%[0-9]+]] = ptrtoint i8* [[GPRPTR]] to i32
+// CHECK-PPC-NEXT:  [[ONE:%[0-9]+]] = add i32 [[ZERO]], 1
+// CHECK-PPC-NEXT:  [[TWO:%[0-9]+]] = inttoptr i32 [[ONE]] to i8*
+// CHECK-PPC-NEXT:  [[THREE:%[0-9]+]] = add i32 [[ONE]], 3
+// CHECK-PPC-NEXT:  [[FOUR:%[0-9]+]] = inttoptr i32 [[THREE]] to i8**
+// CHECK-PPC-NEXT:  [[FIVE:%[0-9]+]] = add i32 [[THREE]], 4
+// CHECK-PPC-NEXT:  [[SIX:%[0-9]+]] = inttoptr i32 [[FIVE]] to i8**
+// CHECK-PPC-NEXT:  [[GPR:%[a-z0-9]+]] = load i8* [[GPRPTR]]
+// CHECK-PPC-NEXT:  [[FPR:%[a-z0-9]+]] = load i8* [[TWO]] 
+// CHECK-PPC-NEXT:  [[OVERFLOW_AREA:%[a-z_0-9]+]] = load i8** [[FOUR]]
+// CHECK-PPC-NEXT:  [[SEVEN:%[0-9]+]] = ptrtoint i8* [[OVERFLOW_AREA]] to i32
+// CHECK-PPC-NEXT:  [[REGSAVE_AREA:%[a-z_0-9]+]] = load i8** [[SIX]]
+// CHECK-PPC-NEXT:  [[EIGHT:%[0-9]+]] = ptrtoint i8* [[REGSAVE_AREA]] to i32
+// CHECK-PPC-NEXT:  [[COND:%[a-z0-9]+]] = icmp ult i8 [[GPR]], 8
+// CHECK-PPC-NEXT:  [[NINE:%[0-9]+]] = mul i8 [[GPR]], 4
+// CHECK-PPC-NEXT:  [[TEN:%[0-9]+]] = sext i8 [[NINE]] to i32
+// CHECK-PPC-NEXT:  [[ELEVEN:%[0-9]+]] = add i32 [[EIGHT]], [[TEN]]
+// CHECK-PPC-NEXT:  br i1 [[COND]], label [[USING_REGS:%[a-z_0-9]+]], label [[USING_OVERFLOW:%[a-z_0-9]+]]
+//
+// CHECK-PPC1:[[USING_REGS]]
+// CHECK-PPC:  [[TWELVE:%[0-9]+]] = inttoptr i32 [[ELEVEN]] to %struct.x*
+// CHECK-PPC-NEXT:  [[THIRTEEN:%[0-9]+]] = add i8 [[GPR]], 1
+// CHECK-PPC-NEXT:  store i8 [[THIRTEEN]], i8* [[GPRPTR]]
+// CHECK-PPC-NEXT:  br label [[CONT:%[a-z0-9]+]]
+//
+// CHECK-PPC1:[[USING_OVERFLOW]]
+// CHECK-PPC:  [[FOURTEEN:%[0-9]+]] = inttoptr i32 [[SEVEN]] to %struct.x*
+// CHECK-PPC-NEXT:  [[FIFTEEN:%[0-9]+]] = add i32 [[SEVEN]], 4
+// CHECK-PPC-NEXT:  [[SIXTEEN:%[0-9]+]] = inttoptr i32 [[FIFTEEN]] to i8*
+// CHECK-PPC-NEXT:  store i8* [[SIXTEEN]], i8** [[FOUR]]
+// CHECK-PPC-NEXT:  br label [[CONT]]
+//
+// CHECK-PPC1:[[CONT]]
+// CHECK-PPC:  [[VAARG_ADDR:%[a-z.0-9]+]] = phi %struct.x* [ [[TWELVE]], [[USING_REGS]] ], [ [[FOURTEEN]], [[USING_OVERFLOW]] ]
+// CHECK-PPC-NEXT:  [[AGGRPTR:%[a-z0-9]+]] = bitcast %struct.x* [[VAARG_ADDR]] to i8**
+// CHECK-PPC-NEXT:  [[AGGR:%[a-z0-9]+]] = load i8** [[AGGRPTR]]
+// CHECK-PPC-NEXT:  [[SEVENTEEN:%[0-9]+]] = bitcast %struct.x* %t to i8*
+// CHECK-PPC-NEXT:  call void @llvm.memcpy.p0i8.p0i8.i32(i8* [[SEVENTEEN]], i8* [[AGGR]], i32 16, i32 8, i1 false)
+
+  int v = va_arg (ap, int);
+// CHECK: ptrtoint i8* %{{[a-z.0-9]*}} to i64
+// CHECK: add i64 %{{[0-9]+}}, 4
+// CHECK: inttoptr i64 %{{[0-9]+}} to i8*
+// CHECK: bitcast i8* %{{[0-9]+}} to i32*
+// CHECK-PPC:  [[ARRAYDECAY1:%[a-z0-9]+]] = getelementptr inbounds [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
+// CHECK-PPC-NEXT:  [[GPRPTR1:%[a-z0-9]+]] = bitcast %struct.__va_list_tag* [[ARRAYDECAY1]] to i8*
+// CHECK-PPC-NEXT:  [[EIGHTEEN:%[0-9]+]] = ptrtoint i8* [[GPRPTR1]] to i32
+// CHECK-PPC-NEXT:  [[NINETEEN:%[0-9]+]] = add i32 [[EIGHTEEN]], 1
+// CHECK-PPC-NEXT:  [[TWENTY:%[0-9]+]] = inttoptr i32 [[NINETEEN]] to i8*
+// CHECK-PPC-NEXT:  [[TWENTYONE:%[0-9]+]] = add i32 [[NINETEEN]], 3
+// CHECK-PPC-NEXT:  [[TWENTYTWO:%[0-9]+]] = inttoptr i32 [[TWENTYONE]] to i8**
+// CHECK-PPC-NEXT:  [[TWENTYTHREE:%[0-9]+]] = add i32 [[TWENTYONE]], 4
+// CHECK-PPC-NEXT:  [[TWENTYFOUR:%[0-9]+]] = inttoptr i32 [[TWENTYTHREE]] to i8**
+// CHECK-PPC-NEXT:  [[GPR1:%[a-z0-9]+]] = load i8* [[GPRPTR1]]
+// CHECK-PPC-NEXT:  [[FPR1:%[a-z0-9]+]] = load i8* [[TWENTY]]
+// CHECK-PPC-NEXT:  [[OVERFLOW_AREA1:%[a-z_0-9]+]] = load i8** [[TWENTYTWO]]
+// CHECK-PPC-NEXT:  [[TWENTYFIVE:%[0-9]+]] = ptrtoint i8* [[OVERFLOW_AREA1]] to i32
+// CHECK-PPC-NEXT:  [[REGSAVE_AREA1:%[a-z_0-9]+]] = load i8** [[TWENTYFOUR]]
+// CHECK-PPC-NEXT:  [[TWENTYSIX:%[0-9]+]] = ptrtoint i8* [[REGSAVE_AREA1]] to i32
+// CHECK-PPC-NEXT:  [[COND1:%[a-z0-9]+]] = icmp ult i8 [[GPR1]], 8
+// CHECK-PPC-NEXT:  [[TWENTYSEVEN:%[0-9]+]] = mul i8 [[GPR1]], 4
+// CHECK-PPC-NEXT:  [[TWENTYEIGHT:%[0-9]+]] = sext i8 [[TWENTYSEVEN]] to i32
+// CHECK-PPC-NEXT:  [[TWENTYNINE:%[0-9]+]] = add i32 [[TWENTYSIX]], [[TWENTYEIGHT]]
+// CHECK-PPC-NEXT:  br i1 [[COND1]], label [[USING_REGS1:%[a-z_0-9]+]], label [[USING_OVERFLOW1:%[a-z_0-9]+]]
+//
+// CHECK-PPC1:[[USING_REGS1]]:
+// CHECK-PPC:  [[THIRTY:%[0-9]+]] = inttoptr i32 [[TWENTYNINE]] to i32*
+// CHECK-PPC-NEXT:  [[THIRTYONE:%[0-9]+]] = add i8 [[GPR1]], 1
+// CHECK-PPC-NEXT:  store i8 [[THIRTYONE]], i8* [[GPRPTR1]]
+// CHECK-PPC-NEXT:  br label [[CONT1:%[a-z0-9]+]]
+//
+// CHECK-PPC1:[[USING_OVERFLOW1]]:
+// CHECK-PPC:  [[THIRTYTWO:%[0-9]+]] = inttoptr i32 [[TWENTYFIVE]] to i32*
+// CHECK-PPC-NEXT:  [[THIRTYTHREE:%[0-9]+]] = add i32 [[TWENTYFIVE]], 4
+// CHECK-PPC-NEXT:  [[THIRTYFOUR:%[0-9]+]] = inttoptr i32 [[THIRTYTHREE]] to i8*
+// CHECK-PPC-NEXT:  store i8* [[THIRTYFOUR]], i8** [[TWENTYTWO]]
+// CHECK-PPC-NEXT:  br label [[CONT1]]
+//
+// CHECK-PPC1:[[CONT1]]:
+// CHECK-PPC:  [[VAARG_ADDR1:%[a-z.0-9]+]] = phi i32* [ [[THIRTY]], [[USING_REGS1]] ], [ [[THIRTYTWO]], [[USING_OVERFLOW1]] ]
+// CHECK-PPC-NEXT:  [[THIRTYFIVE:%[0-9]+]] = load i32* [[VAARG_ADDR1]]
+// CHECK-PPC-NEXT:  store i32 [[THIRTYFIVE]], i32* %v, align 4
+
+#ifdef __powerpc64__
+  __int128_t u = va_arg (ap, __int128_t);
+#endif
+// CHECK: bitcast i8* %{{[a-z.0-9]+}} to i128*
+// CHECK-NEXT: load i128* %{{[0-9]+}}
+}
diff --git a/test/CodeGen/ppc64-align-struct.c b/test/CodeGen/ppc64-align-struct.c
index 272809f..a50c849 100644
--- a/test/CodeGen/ppc64-align-struct.c
+++ b/test/CodeGen/ppc64-align-struct.c
@@ -6,35 +6,53 @@
 struct test2 { int x; int y; } __attribute__((aligned (16)));
 struct test3 { int x; int y; } __attribute__((aligned (32)));
 struct test4 { int x; int y; int z; };
+struct test5 { int x[17]; };
+struct test6 { int x[17]; } __attribute__((aligned (16)));
+struct test7 { int x[17]; } __attribute__((aligned (32)));
 
-// CHECK: define void @test1(i32 signext %x, %struct.test1* byval align 8 %y)
+// CHECK: define void @test1(i32 signext %x, i64 %y.coerce)
 void test1 (int x, struct test1 y)
 {
 }
 
-// CHECK: define void @test2(i32 signext %x, %struct.test2* byval align 16 %y)
+// CHECK: define void @test2(i32 signext %x, [1 x i128] %y.coerce)
 void test2 (int x, struct test2 y)
 {
 }
 
-// This case requires run-time realignment of the incoming struct
-// CHECK: define void @test3(i32 signext %x, %struct.test3* byval align 16)
-// CHECK: %y = alloca %struct.test3, align 32
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+// CHECK: define void @test3(i32 signext %x, [2 x i128] %y.coerce)
 void test3 (int x, struct test3 y)
 {
 }
 
-// CHECK: define void @test4(i32 signext %x, %struct.test4* byval align 8 %y)
+// CHECK: define void @test4(i32 signext %x, [2 x i64] %y.coerce)
 void test4 (int x, struct test4 y)
 {
 }
 
+// CHECK: define void @test5(i32 signext %x, %struct.test5* byval align 8 %y)
+void test5 (int x, struct test5 y)
+{
+}
+
+// CHECK: define void @test6(i32 signext %x, %struct.test6* byval align 16 %y)
+void test6 (int x, struct test6 y)
+{
+}
+
+// This case requires run-time realignment of the incoming struct
+// CHECK: define void @test7(i32 signext %x, %struct.test7* byval align 16)
+// CHECK: %y = alloca %struct.test7, align 32
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+void test7 (int x, struct test7 y)
+{
+}
+
 // CHECK: define void @test1va(%struct.test1* noalias sret %agg.result, i32 signext %x, ...)
-// CHECK: %ap.cur = load i8** %ap
-// CHECK: %ap.next = getelementptr i8* %ap.cur, i64 8
-// CHECK: store i8* %ap.next, i8** %ap
-// CHECK: bitcast i8* %ap.cur to %struct.test1*
+// CHECK: %[[CUR:[^ ]+]] = load i8** %ap
+// CHECK: %[[NEXT:[^ ]+]] = getelementptr i8* %[[CUR]], i64 8
+// CHECK: store i8* %[[NEXT]], i8** %ap
+// CHECK: bitcast i8* %[[CUR]] to %struct.test1*
 struct test1 test1va (int x, ...)
 {
   struct test1 y;
@@ -46,14 +64,14 @@
 }
 
 // CHECK: define void @test2va(%struct.test2* noalias sret %agg.result, i32 signext %x, ...)
-// CHECK: %ap.cur = load i8** %ap
-// CHECK: %[[TMP0:[0-9]+]] = ptrtoint i8* %ap.cur to i64
-// CHECK: %[[TMP1:[0-9]+]] = add i64 %[[TMP0]], 15
-// CHECK: %[[TMP2:[0-9]+]] = and i64 %[[TMP1]], -16
-// CHECK: %ap.align = inttoptr i64 %[[TMP2]] to i8*
-// CHECK: %ap.next = getelementptr i8* %ap.align, i64 16
-// CHECK: store i8* %ap.next, i8** %ap
-// CHECK: bitcast i8* %ap.align to %struct.test2*
+// CHECK: %[[CUR:[^ ]+]] = load i8** %ap
+// CHECK: %[[TMP0:[^ ]+]] = ptrtoint i8* %[[CUR]] to i64
+// CHECK: %[[TMP1:[^ ]+]] = add i64 %[[TMP0]], 15
+// CHECK: %[[TMP2:[^ ]+]] = and i64 %[[TMP1]], -16
+// CHECK: %[[ALIGN:[^ ]+]] = inttoptr i64 %[[TMP2]] to i8*
+// CHECK: %[[NEXT:[^ ]+]] = getelementptr i8* %[[ALIGN]], i64 16
+// CHECK: store i8* %[[NEXT]], i8** %ap
+// CHECK: bitcast i8* %[[ALIGN]] to %struct.test2*
 struct test2 test2va (int x, ...)
 {
   struct test2 y;
@@ -65,14 +83,14 @@
 }
 
 // CHECK: define void @test3va(%struct.test3* noalias sret %agg.result, i32 signext %x, ...)
-// CHECK: %ap.cur = load i8** %ap
-// CHECK: %[[TMP0:[0-9]+]] = ptrtoint i8* %ap.cur to i64
-// CHECK: %[[TMP1:[0-9]+]] = add i64 %[[TMP0]], 15
-// CHECK: %[[TMP2:[0-9]+]] = and i64 %[[TMP1]], -16
-// CHECK: %ap.align = inttoptr i64 %[[TMP2]] to i8*
-// CHECK: %ap.next = getelementptr i8* %ap.align, i64 32
-// CHECK: store i8* %ap.next, i8** %ap
-// CHECK: bitcast i8* %ap.align to %struct.test3*
+// CHECK: %[[CUR:[^ ]+]] = load i8** %ap
+// CHECK: %[[TMP0:[^ ]+]] = ptrtoint i8* %[[CUR]] to i64
+// CHECK: %[[TMP1:[^ ]+]] = add i64 %[[TMP0]], 15
+// CHECK: %[[TMP2:[^ ]+]] = and i64 %[[TMP1]], -16
+// CHECK: %[[ALIGN:[^ ]+]] = inttoptr i64 %[[TMP2]] to i8*
+// CHECK: %[[NEXT:[^ ]+]] = getelementptr i8* %[[ALIGN]], i64 32
+// CHECK: store i8* %[[NEXT]], i8** %ap
+// CHECK: bitcast i8* %[[ALIGN]] to %struct.test3*
 struct test3 test3va (int x, ...)
 {
   struct test3 y;
@@ -84,10 +102,10 @@
 }
 
 // CHECK: define void @test4va(%struct.test4* noalias sret %agg.result, i32 signext %x, ...)
-// CHECK: %ap.cur = load i8** %ap
-// CHECK: %ap.next = getelementptr i8* %ap.cur, i64 16
-// CHECK: store i8* %ap.next, i8** %ap
-// CHECK: bitcast i8* %ap.cur to %struct.test4*
+// CHECK: %[[CUR:[^ ]+]] = load i8** %ap
+// CHECK: %[[NEXT:[^ ]+]] = getelementptr i8* %[[CUR]], i64 16
+// CHECK: store i8* %[[NEXT]], i8** %ap
+// CHECK: bitcast i8* %[[CUR]] to %struct.test4*
 struct test4 test4va (int x, ...)
 {
   struct test4 y;
@@ -99,10 +117,10 @@
 }
 
 // CHECK: define void @testva_longdouble(%struct.test_longdouble* noalias sret %agg.result, i32 signext %x, ...)
-// CHECK: %ap.cur = load i8** %ap
-// CHECK: %ap.next = getelementptr i8* %ap.cur, i64 16
-// CHECK: store i8* %ap.next, i8** %ap
-// CHECK: bitcast i8* %ap.cur to %struct.test_longdouble*
+// CHECK: %[[CUR:[^ ]+]] = load i8** %ap
+// CHECK: %[[NEXT:[^ ]+]] = getelementptr i8* %[[CUR]], i64 16
+// CHECK: store i8* %[[NEXT]], i8** %ap
+// CHECK: bitcast i8* %[[CUR]] to %struct.test_longdouble*
 struct test_longdouble { long double x; };
 struct test_longdouble testva_longdouble (int x, ...)
 {
@@ -115,14 +133,14 @@
 }
 
 // CHECK: define void @testva_vector(%struct.test_vector* noalias sret %agg.result, i32 signext %x, ...)
-// CHECK: %ap.cur = load i8** %ap
-// CHECK: %[[TMP0:[0-9]+]] = ptrtoint i8* %ap.cur to i64
-// CHECK: %[[TMP1:[0-9]+]] = add i64 %[[TMP0]], 15
-// CHECK: %[[TMP2:[0-9]+]] = and i64 %[[TMP1]], -16
-// CHECK: %ap.align = inttoptr i64 %[[TMP2]] to i8*
-// CHECK: %ap.next = getelementptr i8* %ap.align, i64 16
-// CHECK: store i8* %ap.next, i8** %ap
-// CHECK: bitcast i8* %ap.align to %struct.test_vector*
+// CHECK: %[[CUR:[^ ]+]] = load i8** %ap
+// CHECK: %[[TMP0:[^ ]+]] = ptrtoint i8* %[[CUR]] to i64
+// CHECK: %[[TMP1:[^ ]+]] = add i64 %[[TMP0]], 15
+// CHECK: %[[TMP2:[^ ]+]] = and i64 %[[TMP1]], -16
+// CHECK: %[[ALIGN:[^ ]+]] = inttoptr i64 %[[TMP2]] to i8*
+// CHECK: %[[NEXT:[^ ]+]] = getelementptr i8* %[[ALIGN]], i64 16
+// CHECK: store i8* %[[NEXT]], i8** %ap
+// CHECK: bitcast i8* %[[ALIGN]] to %struct.test_vector*
 struct test_vector { vector int x; };
 struct test_vector testva_vector (int x, ...)
 {
diff --git a/test/CodeGen/ppc64-elf-abi.c b/test/CodeGen/ppc64-elf-abi.c
new file mode 100644
index 0000000..0dd183e
--- /dev/null
+++ b/test/CodeGen/ppc64-elf-abi.c
@@ -0,0 +1,40 @@
+// REQUIRES: powerpc-registered-target
+
+// Verify ABI selection by the front end
+
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ELFv1
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   -target-abi elfv1 | FileCheck %s --check-prefix=CHECK-ELFv1
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   -target-abi elfv2 | FileCheck %s --check-prefix=CHECK-ELFv2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ELFv2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   -target-abi elfv1 | FileCheck %s --check-prefix=CHECK-ELFv1
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   -target-abi elfv2 | FileCheck %s --check-prefix=CHECK-ELFv2
+
+// CHECK-ELFv1: define void @func_fab(%struct.fab* noalias sret %agg.result, i64 %x.coerce)
+// CHECK-ELFv2: define [2 x float] @func_fab([2 x float] %x.coerce)
+struct fab { float a; float b; };
+struct fab func_fab(struct fab x) { return x; }
+
+// Verify ABI choice is passed on to the back end
+
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -S -o - %s \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASM-ELFv1
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -S -o - %s \
+// RUN:   -target-abi elfv1 | FileCheck %s --check-prefix=CHECK-ASM-ELFv1
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -S -o - %s \
+// RUN:   -target-abi elfv2 | FileCheck %s --check-prefix=CHECK-ASM-ELFv2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -S -o - %s \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASM-ELFv2
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -S -o - %s \
+// RUN:   -target-abi elfv1 | FileCheck %s --check-prefix=CHECK-ASM-ELFv1
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -S -o - %s \
+// RUN:   -target-abi elfv2 | FileCheck %s --check-prefix=CHECK-ASM-ELFv2
+
+// CHECK-ASM-ELFv2: .abiversion 2
+// CHECK-ASM-ELFv1-NOT: .abiversion 2
+
diff --git a/test/CodeGen/ppc64-varargs-struct.c b/test/CodeGen/ppc64-varargs-struct.c
deleted file mode 100644
index 70b242c..0000000
--- a/test/CodeGen/ppc64-varargs-struct.c
+++ /dev/null
@@ -1,30 +0,0 @@
-// REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
-
-#include <stdarg.h>
-
-struct x {
-  long a;
-  double b;
-};
-
-void testva (int n, ...)
-{
-  va_list ap;
-
-  struct x t = va_arg (ap, struct x);
-// CHECK: bitcast i8* %{{[a-z.0-9]*}} to %struct.x*
-// CHECK: bitcast %struct.x* %t to i8*
-// CHECK: bitcast %struct.x* %{{[0-9]+}} to i8*
-// CHECK: call void @llvm.memcpy
-
-  int v = va_arg (ap, int);
-// CHECK: ptrtoint i8* %{{[a-z.0-9]*}} to i64
-// CHECK: add i64 %{{[0-9]+}}, 4
-// CHECK: inttoptr i64 %{{[0-9]+}} to i8*
-// CHECK: bitcast i8* %{{[0-9]+}} to i32*
-
-  __int128_t u = va_arg (ap, __int128_t);
-// CHECK: bitcast i8* %{{[a-z.0-9]+}} to i128*
-// CHECK-NEXT: load i128* %{{[0-9]+}}
-}
diff --git a/test/CodeGen/ppc64-vector.c b/test/CodeGen/ppc64-vector.c
index 3ff07a4..f0211f0 100644
--- a/test/CodeGen/ppc64-vector.c
+++ b/test/CodeGen/ppc64-vector.c
@@ -45,7 +45,7 @@
   return x;
 }
 
-// CHECK: define void @test_struct_v16i16(%struct.v16i16* noalias sret %agg.result, %struct.v16i16* byval align 16)
+// CHECK: define void @test_struct_v16i16(%struct.v16i16* noalias sret %agg.result, [2 x i128] %x.coerce)
 struct v16i16 test_struct_v16i16(struct v16i16 x)
 {
   return x;
diff --git a/test/CodeGen/ppc64le-aggregates.c b/test/CodeGen/ppc64le-aggregates.c
new file mode 100644
index 0000000..e193dcc
--- /dev/null
+++ b/test/CodeGen/ppc64le-aggregates.c
@@ -0,0 +1,427 @@
+// RUN: %clang_cc1 -faltivec -triple powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+// Test homogeneous float aggregate passing and returning.
+
+struct f1 { float f[1]; };
+struct f2 { float f[2]; };
+struct f3 { float f[3]; };
+struct f4 { float f[4]; };
+struct f5 { float f[5]; };
+struct f6 { float f[6]; };
+struct f7 { float f[7]; };
+struct f8 { float f[8]; };
+struct f9 { float f[9]; };
+
+struct fab { float a; float b; };
+struct fabc { float a; float b; float c; };
+
+struct f2a2b { float a[2]; float b[2]; };
+
+// CHECK: define [1 x float] @func_f1(float inreg %x.coerce)
+struct f1 func_f1(struct f1 x) { return x; }
+
+// CHECK: define [2 x float] @func_f2([2 x float] %x.coerce)
+struct f2 func_f2(struct f2 x) { return x; }
+
+// CHECK: define [3 x float] @func_f3([3 x float] %x.coerce)
+struct f3 func_f3(struct f3 x) { return x; }
+
+// CHECK: define [4 x float] @func_f4([4 x float] %x.coerce)
+struct f4 func_f4(struct f4 x) { return x; }
+
+// CHECK: define [5 x float] @func_f5([5 x float] %x.coerce)
+struct f5 func_f5(struct f5 x) { return x; }
+
+// CHECK: define [6 x float] @func_f6([6 x float] %x.coerce)
+struct f6 func_f6(struct f6 x) { return x; }
+
+// CHECK: define [7 x float] @func_f7([7 x float] %x.coerce)
+struct f7 func_f7(struct f7 x) { return x; }
+
+// CHECK: define [8 x float] @func_f8([8 x float] %x.coerce)
+struct f8 func_f8(struct f8 x) { return x; }
+
+// CHECK: define void @func_f9(%struct.f9* noalias sret %agg.result, [5 x i64] %x.coerce)
+struct f9 func_f9(struct f9 x) { return x; }
+
+// CHECK: define [2 x float] @func_fab([2 x float] %x.coerce)
+struct fab func_fab(struct fab x) { return x; }
+
+// CHECK: define [3 x float] @func_fabc([3 x float] %x.coerce)
+struct fabc func_fabc(struct fabc x) { return x; }
+
+// CHECK: define [4 x float] @func_f2a2b([4 x float] %x.coerce)
+struct f2a2b func_f2a2b(struct f2a2b x) { return x; }
+
+// CHECK-LABEL: @call_f1
+// CHECK: %[[TMP:[^ ]+]] = load float* getelementptr inbounds (%struct.f1* @global_f1, i32 0, i32 0, i32 0), align 1
+// CHECK: call [1 x float] @func_f1(float inreg %[[TMP]])
+struct f1 global_f1;
+void call_f1(void) { global_f1 = func_f1(global_f1); }
+
+// CHECK-LABEL: @call_f2
+// CHECK: %[[TMP:[^ ]+]] = load [2 x float]* getelementptr inbounds (%struct.f2* @global_f2, i32 0, i32 0), align 1
+// CHECK: call [2 x float] @func_f2([2 x float] %[[TMP]])
+struct f2 global_f2;
+void call_f2(void) { global_f2 = func_f2(global_f2); }
+
+// CHECK-LABEL: @call_f3
+// CHECK: %[[TMP:[^ ]+]] = load [3 x float]* getelementptr inbounds (%struct.f3* @global_f3, i32 0, i32 0), align 1
+// CHECK: call [3 x float] @func_f3([3 x float] %[[TMP]])
+struct f3 global_f3;
+void call_f3(void) { global_f3 = func_f3(global_f3); }
+
+// CHECK-LABEL: @call_f4
+// CHECK: %[[TMP:[^ ]+]] = load [4 x float]* getelementptr inbounds (%struct.f4* @global_f4, i32 0, i32 0), align 1
+// CHECK: call [4 x float] @func_f4([4 x float] %[[TMP]])
+struct f4 global_f4;
+void call_f4(void) { global_f4 = func_f4(global_f4); }
+
+// CHECK-LABEL: @call_f5
+// CHECK: %[[TMP:[^ ]+]] = load [5 x float]* getelementptr inbounds (%struct.f5* @global_f5, i32 0, i32 0), align 1
+// CHECK: call [5 x float] @func_f5([5 x float] %[[TMP]])
+struct f5 global_f5;
+void call_f5(void) { global_f5 = func_f5(global_f5); }
+
+// CHECK-LABEL: @call_f6
+// CHECK: %[[TMP:[^ ]+]] = load [6 x float]* getelementptr inbounds (%struct.f6* @global_f6, i32 0, i32 0), align 1
+// CHECK: call [6 x float] @func_f6([6 x float] %[[TMP]])
+struct f6 global_f6;
+void call_f6(void) { global_f6 = func_f6(global_f6); }
+
+// CHECK-LABEL: @call_f7
+// CHECK: %[[TMP:[^ ]+]] = load [7 x float]* getelementptr inbounds (%struct.f7* @global_f7, i32 0, i32 0), align 1
+// CHECK: call [7 x float] @func_f7([7 x float] %[[TMP]])
+struct f7 global_f7;
+void call_f7(void) { global_f7 = func_f7(global_f7); }
+
+// CHECK-LABEL: @call_f8
+// CHECK: %[[TMP:[^ ]+]] = load [8 x float]* getelementptr inbounds (%struct.f8* @global_f8, i32 0, i32 0), align 1
+// CHECK: call [8 x float] @func_f8([8 x float] %[[TMP]])
+struct f8 global_f8;
+void call_f8(void) { global_f8 = func_f8(global_f8); }
+
+// CHECK-LABEL: @call_f9
+// CHECK: %[[TMP1:[^ ]+]] = alloca [5 x i64]
+// CHECK: %[[TMP2:[^ ]+]] = bitcast [5 x i64]* %[[TMP1]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %[[TMP2]], i8* bitcast (%struct.f9* @global_f9 to i8*), i64 36, i32 1, i1 false)
+// CHECK: %[[TMP3:[^ ]+]] = load [5 x i64]* %[[TMP1]]
+// CHECK: call void @func_f9(%struct.f9* sret %{{[^ ]+}}, [5 x i64] %[[TMP3]])
+struct f9 global_f9;
+void call_f9(void) { global_f9 = func_f9(global_f9); }
+
+// CHECK-LABEL: @call_fab
+// CHECK: %[[TMP:[^ ]+]] = load [2 x float]* bitcast (%struct.fab* @global_fab to [2 x float]*)
+// CHECK: call [2 x float] @func_fab([2 x float] %[[TMP]])
+struct fab global_fab;
+void call_fab(void) { global_fab = func_fab(global_fab); }
+
+// CHECK-LABEL: @call_fabc
+// CHECK: %[[TMP:[^ ]+]] = load [3 x float]* bitcast (%struct.fabc* @global_fabc to [3 x float]*)
+// CHECK: call [3 x float] @func_fabc([3 x float] %[[TMP]])
+struct fabc global_fabc;
+void call_fabc(void) { global_fabc = func_fabc(global_fabc); }
+
+
+// Test homogeneous vector aggregate passing and returning.
+
+struct v1 { vector int v[1]; };
+struct v2 { vector int v[2]; };
+struct v3 { vector int v[3]; };
+struct v4 { vector int v[4]; };
+struct v5 { vector int v[5]; };
+struct v6 { vector int v[6]; };
+struct v7 { vector int v[7]; };
+struct v8 { vector int v[8]; };
+struct v9 { vector int v[9]; };
+
+struct vab { vector int a; vector int b; };
+struct vabc { vector int a; vector int b; vector int c; };
+
+// CHECK: define [1 x <4 x i32>] @func_v1(<4 x i32> inreg %x.coerce)
+struct v1 func_v1(struct v1 x) { return x; }
+
+// CHECK: define [2 x <4 x i32>] @func_v2([2 x <4 x i32>] %x.coerce)
+struct v2 func_v2(struct v2 x) { return x; }
+
+// CHECK: define [3 x <4 x i32>] @func_v3([3 x <4 x i32>] %x.coerce)
+struct v3 func_v3(struct v3 x) { return x; }
+
+// CHECK: define [4 x <4 x i32>] @func_v4([4 x <4 x i32>] %x.coerce)
+struct v4 func_v4(struct v4 x) { return x; }
+
+// CHECK: define [5 x <4 x i32>] @func_v5([5 x <4 x i32>] %x.coerce)
+struct v5 func_v5(struct v5 x) { return x; }
+
+// CHECK: define [6 x <4 x i32>] @func_v6([6 x <4 x i32>] %x.coerce)
+struct v6 func_v6(struct v6 x) { return x; }
+
+// CHECK: define [7 x <4 x i32>] @func_v7([7 x <4 x i32>] %x.coerce)
+struct v7 func_v7(struct v7 x) { return x; }
+
+// CHECK: define [8 x <4 x i32>] @func_v8([8 x <4 x i32>] %x.coerce)
+struct v8 func_v8(struct v8 x) { return x; }
+
+// CHECK: define void @func_v9(%struct.v9* noalias sret %agg.result, %struct.v9* byval align 16 %x)
+struct v9 func_v9(struct v9 x) { return x; }
+
+// CHECK: define [2 x <4 x i32>] @func_vab([2 x <4 x i32>] %x.coerce)
+struct vab func_vab(struct vab x) { return x; }
+
+// CHECK: define [3 x <4 x i32>] @func_vabc([3 x <4 x i32>] %x.coerce)
+struct vabc func_vabc(struct vabc x) { return x; }
+
+// CHECK-LABEL: @call_v1
+// CHECK: %[[TMP:[^ ]+]] = load <4 x i32>* getelementptr inbounds (%struct.v1* @global_v1, i32 0, i32 0, i32 0), align 1
+// CHECK: call [1 x <4 x i32>] @func_v1(<4 x i32> inreg %[[TMP]])
+struct v1 global_v1;
+void call_v1(void) { global_v1 = func_v1(global_v1); }
+
+// CHECK-LABEL: @call_v2
+// CHECK: %[[TMP:[^ ]+]] = load [2 x <4 x i32>]* getelementptr inbounds (%struct.v2* @global_v2, i32 0, i32 0), align 1
+// CHECK: call [2 x <4 x i32>] @func_v2([2 x <4 x i32>] %[[TMP]])
+struct v2 global_v2;
+void call_v2(void) { global_v2 = func_v2(global_v2); }
+
+// CHECK-LABEL: @call_v3
+// CHECK: %[[TMP:[^ ]+]] = load [3 x <4 x i32>]* getelementptr inbounds (%struct.v3* @global_v3, i32 0, i32 0), align 1
+// CHECK: call [3 x <4 x i32>] @func_v3([3 x <4 x i32>] %[[TMP]])
+struct v3 global_v3;
+void call_v3(void) { global_v3 = func_v3(global_v3); }
+
+// CHECK-LABEL: @call_v4
+// CHECK: %[[TMP:[^ ]+]] = load [4 x <4 x i32>]* getelementptr inbounds (%struct.v4* @global_v4, i32 0, i32 0), align 1
+// CHECK: call [4 x <4 x i32>] @func_v4([4 x <4 x i32>] %[[TMP]])
+struct v4 global_v4;
+void call_v4(void) { global_v4 = func_v4(global_v4); }
+
+// CHECK-LABEL: @call_v5
+// CHECK: %[[TMP:[^ ]+]] = load [5 x <4 x i32>]* getelementptr inbounds (%struct.v5* @global_v5, i32 0, i32 0), align 1
+// CHECK: call [5 x <4 x i32>] @func_v5([5 x <4 x i32>] %[[TMP]])
+struct v5 global_v5;
+void call_v5(void) { global_v5 = func_v5(global_v5); }
+
+// CHECK-LABEL: @call_v6
+// CHECK: %[[TMP:[^ ]+]] = load [6 x <4 x i32>]* getelementptr inbounds (%struct.v6* @global_v6, i32 0, i32 0), align 1
+// CHECK: call [6 x <4 x i32>] @func_v6([6 x <4 x i32>] %[[TMP]])
+struct v6 global_v6;
+void call_v6(void) { global_v6 = func_v6(global_v6); }
+
+// CHECK-LABEL: @call_v7
+// CHECK: %[[TMP:[^ ]+]] = load [7 x <4 x i32>]* getelementptr inbounds (%struct.v7* @global_v7, i32 0, i32 0), align 1
+// CHECK: call [7 x <4 x i32>] @func_v7([7 x <4 x i32>] %[[TMP]])
+struct v7 global_v7;
+void call_v7(void) { global_v7 = func_v7(global_v7); }
+
+// CHECK-LABEL: @call_v8
+// CHECK: %[[TMP:[^ ]+]] = load [8 x <4 x i32>]* getelementptr inbounds (%struct.v8* @global_v8, i32 0, i32 0), align 1
+// CHECK: call [8 x <4 x i32>] @func_v8([8 x <4 x i32>] %[[TMP]])
+struct v8 global_v8;
+void call_v8(void) { global_v8 = func_v8(global_v8); }
+
+// CHECK-LABEL: @call_v9
+// CHECK: call void @func_v9(%struct.v9* sret %{{[^ ]+}}, %struct.v9* byval align 16 @global_v9)
+struct v9 global_v9;
+void call_v9(void) { global_v9 = func_v9(global_v9); }
+
+// CHECK-LABEL: @call_vab
+// CHECK: %[[TMP:[^ ]+]] = load [2 x <4 x i32>]* bitcast (%struct.vab* @global_vab to [2 x <4 x i32>]*)
+// CHECK: call [2 x <4 x i32>] @func_vab([2 x <4 x i32>] %[[TMP]])
+struct vab global_vab;
+void call_vab(void) { global_vab = func_vab(global_vab); }
+
+// CHECK-LABEL: @call_vabc
+// CHECK: %[[TMP:[^ ]+]] = load [3 x <4 x i32>]* bitcast (%struct.vabc* @global_vabc to [3 x <4 x i32>]*)
+// CHECK: call [3 x <4 x i32>] @func_vabc([3 x <4 x i32>] %[[TMP]])
+struct vabc global_vabc;
+void call_vabc(void) { global_vabc = func_vabc(global_vabc); }
+
+
+// As clang extension, non-power-of-two vectors may also be part of
+// homogeneous aggregates.
+
+typedef float float3 __attribute__((vector_size (12)));
+
+struct v3f1 { float3 v[1]; };
+struct v3f2 { float3 v[2]; };
+struct v3f3 { float3 v[3]; };
+struct v3f4 { float3 v[4]; };
+struct v3f5 { float3 v[5]; };
+struct v3f6 { float3 v[6]; };
+struct v3f7 { float3 v[7]; };
+struct v3f8 { float3 v[8]; };
+struct v3f9 { float3 v[9]; };
+
+struct v3fab { float3 a; float3 b; };
+struct v3fabc { float3 a; float3 b; float3 c; };
+
+// CHECK: define [1 x <3 x float>] @func_v3f1(<3 x float> inreg %x.coerce)
+struct v3f1 func_v3f1(struct v3f1 x) { return x; }
+
+// CHECK: define [2 x <3 x float>] @func_v3f2([2 x <3 x float>] %x.coerce)
+struct v3f2 func_v3f2(struct v3f2 x) { return x; }
+
+// CHECK: define [3 x <3 x float>] @func_v3f3([3 x <3 x float>] %x.coerce)
+struct v3f3 func_v3f3(struct v3f3 x) { return x; }
+
+// CHECK: define [4 x <3 x float>] @func_v3f4([4 x <3 x float>] %x.coerce)
+struct v3f4 func_v3f4(struct v3f4 x) { return x; }
+
+// CHECK: define [5 x <3 x float>] @func_v3f5([5 x <3 x float>] %x.coerce)
+struct v3f5 func_v3f5(struct v3f5 x) { return x; }
+
+// CHECK: define [6 x <3 x float>] @func_v3f6([6 x <3 x float>] %x.coerce)
+struct v3f6 func_v3f6(struct v3f6 x) { return x; }
+
+// CHECK: define [7 x <3 x float>] @func_v3f7([7 x <3 x float>] %x.coerce)
+struct v3f7 func_v3f7(struct v3f7 x) { return x; }
+
+// CHECK: define [8 x <3 x float>] @func_v3f8([8 x <3 x float>] %x.coerce)
+struct v3f8 func_v3f8(struct v3f8 x) { return x; }
+
+// CHECK: define void @func_v3f9(%struct.v3f9* noalias sret %agg.result, %struct.v3f9* byval align 16 %x)
+struct v3f9 func_v3f9(struct v3f9 x) { return x; }
+
+// CHECK: define [2 x <3 x float>] @func_v3fab([2 x <3 x float>] %x.coerce)
+struct v3fab func_v3fab(struct v3fab x) { return x; }
+
+// CHECK: define [3 x <3 x float>] @func_v3fabc([3 x <3 x float>] %x.coerce)
+struct v3fabc func_v3fabc(struct v3fabc x) { return x; }
+
+// CHECK-LABEL: @call_v3f1
+// CHECK: %[[TMP:[^ ]+]] = load <3 x float>* getelementptr inbounds (%struct.v3f1* @global_v3f1, i32 0, i32 0, i32 0), align 1
+// CHECK: call [1 x <3 x float>] @func_v3f1(<3 x float> inreg %[[TMP]])
+struct v3f1 global_v3f1;
+void call_v3f1(void) { global_v3f1 = func_v3f1(global_v3f1); }
+
+// CHECK-LABEL: @call_v3f2
+// CHECK: %[[TMP:[^ ]+]] = load [2 x <3 x float>]* getelementptr inbounds (%struct.v3f2* @global_v3f2, i32 0, i32 0), align 1
+// CHECK: call [2 x <3 x float>] @func_v3f2([2 x <3 x float>] %[[TMP]])
+struct v3f2 global_v3f2;
+void call_v3f2(void) { global_v3f2 = func_v3f2(global_v3f2); }
+
+// CHECK-LABEL: @call_v3f3
+// CHECK: %[[TMP:[^ ]+]] = load [3 x <3 x float>]* getelementptr inbounds (%struct.v3f3* @global_v3f3, i32 0, i32 0), align 1
+// CHECK: call [3 x <3 x float>] @func_v3f3([3 x <3 x float>] %[[TMP]])
+struct v3f3 global_v3f3;
+void call_v3f3(void) { global_v3f3 = func_v3f3(global_v3f3); }
+
+// CHECK-LABEL: @call_v3f4
+// CHECK: %[[TMP:[^ ]+]] = load [4 x <3 x float>]* getelementptr inbounds (%struct.v3f4* @global_v3f4, i32 0, i32 0), align 1
+// CHECK: call [4 x <3 x float>] @func_v3f4([4 x <3 x float>] %[[TMP]])
+struct v3f4 global_v3f4;
+void call_v3f4(void) { global_v3f4 = func_v3f4(global_v3f4); }
+
+// CHECK-LABEL: @call_v3f5
+// CHECK: %[[TMP:[^ ]+]] = load [5 x <3 x float>]* getelementptr inbounds (%struct.v3f5* @global_v3f5, i32 0, i32 0), align 1
+// CHECK: call [5 x <3 x float>] @func_v3f5([5 x <3 x float>] %[[TMP]])
+struct v3f5 global_v3f5;
+void call_v3f5(void) { global_v3f5 = func_v3f5(global_v3f5); }
+
+// CHECK-LABEL: @call_v3f6
+// CHECK: %[[TMP:[^ ]+]] = load [6 x <3 x float>]* getelementptr inbounds (%struct.v3f6* @global_v3f6, i32 0, i32 0), align 1
+// CHECK: call [6 x <3 x float>] @func_v3f6([6 x <3 x float>] %[[TMP]])
+struct v3f6 global_v3f6;
+void call_v3f6(void) { global_v3f6 = func_v3f6(global_v3f6); }
+
+// CHECK-LABEL: @call_v3f7
+// CHECK: %[[TMP:[^ ]+]] = load [7 x <3 x float>]* getelementptr inbounds (%struct.v3f7* @global_v3f7, i32 0, i32 0), align 1
+// CHECK: call [7 x <3 x float>] @func_v3f7([7 x <3 x float>] %[[TMP]])
+struct v3f7 global_v3f7;
+void call_v3f7(void) { global_v3f7 = func_v3f7(global_v3f7); }
+
+// CHECK-LABEL: @call_v3f8
+// CHECK: %[[TMP:[^ ]+]] = load [8 x <3 x float>]* getelementptr inbounds (%struct.v3f8* @global_v3f8, i32 0, i32 0), align 1
+// CHECK: call [8 x <3 x float>] @func_v3f8([8 x <3 x float>] %[[TMP]])
+struct v3f8 global_v3f8;
+void call_v3f8(void) { global_v3f8 = func_v3f8(global_v3f8); }
+
+// CHECK-LABEL: @call_v3f9
+// CHECK: call void @func_v3f9(%struct.v3f9* sret %{{[^ ]+}}, %struct.v3f9* byval align 16 @global_v3f9)
+struct v3f9 global_v3f9;
+void call_v3f9(void) { global_v3f9 = func_v3f9(global_v3f9); }
+
+// CHECK-LABEL: @call_v3fab
+// CHECK: %[[TMP:[^ ]+]] = load [2 x <3 x float>]* bitcast (%struct.v3fab* @global_v3fab to [2 x <3 x float>]*)
+// CHECK: call [2 x <3 x float>] @func_v3fab([2 x <3 x float>] %[[TMP]])
+struct v3fab global_v3fab;
+void call_v3fab(void) { global_v3fab = func_v3fab(global_v3fab); }
+
+// CHECK-LABEL: @call_v3fabc
+// CHECK: %[[TMP:[^ ]+]] = load [3 x <3 x float>]* bitcast (%struct.v3fabc* @global_v3fabc to [3 x <3 x float>]*)
+// CHECK: call [3 x <3 x float>] @func_v3fabc([3 x <3 x float>] %[[TMP]])
+struct v3fabc global_v3fabc;
+void call_v3fabc(void) { global_v3fabc = func_v3fabc(global_v3fabc); }
+
+
+// Test returning small aggregates.
+
+struct s1 { char c[1]; };
+struct s2 { char c[2]; };
+struct s3 { char c[3]; };
+struct s4 { char c[4]; };
+struct s5 { char c[5]; };
+struct s6 { char c[6]; };
+struct s7 { char c[7]; };
+struct s8 { char c[8]; };
+struct s9 { char c[9]; };
+struct s16 { char c[16]; };
+struct s17 { char c[17]; };
+
+// CHECK: define i8 @ret_s1()
+struct s1 ret_s1() {
+  return (struct s1) { 17 };
+}
+
+// CHECK: define i16 @ret_s2()
+struct s2 ret_s2() {
+  return (struct s2) { 17, 18 };
+}
+
+// CHECK: define i24 @ret_s3()
+struct s3 ret_s3() {
+  return (struct s3) { 17, 18, 19 };
+}
+
+// CHECK: define i32 @ret_s4()
+struct s4 ret_s4() {
+  return (struct s4) { 17, 18, 19, 20 };
+}
+
+// CHECK: define i40 @ret_s5()
+struct s5 ret_s5() {
+  return (struct s5) { 17, 18, 19, 20, 21 };
+}
+
+// CHECK: define i48 @ret_s6()
+struct s6 ret_s6() {
+  return (struct s6) { 17, 18, 19, 20, 21, 22 };
+}
+
+// CHECK: define i56 @ret_s7()
+struct s7 ret_s7() {
+  return (struct s7) { 17, 18, 19, 20, 21, 22, 23 };
+}
+
+// CHECK: define i64 @ret_s8()
+struct s8 ret_s8() {
+  return (struct s8) { 17, 18, 19, 20, 21, 22, 23, 24 };
+}
+
+// CHECK: define { i64, i64 } @ret_s9()
+struct s9 ret_s9() {
+  return (struct s9) { 17, 18, 19, 20, 21, 22, 23, 24, 25 };
+}
+
+// CHECK: define { i64, i64 } @ret_s16()
+struct s16 ret_s16() {
+  return (struct s16) { 17, 18, 19, 20, 21, 22, 23, 24,
+                        25, 26, 27, 28, 29, 30, 31, 32 };
+}
+
+// CHECK: define void @ret_s17(%struct.s17*
+struct s17 ret_s17() {
+  return (struct s17) { 17, 18, 19, 20, 21, 22, 23, 24,
+                        25, 26, 27, 28, 29, 30, 31, 32, 33 };
+}
+
diff --git a/test/CodeGen/pragma-detect_mismatch.c b/test/CodeGen/pragma-detect_mismatch.c
index b223a61..f15b75d 100644
--- a/test/CodeGen/pragma-detect_mismatch.c
+++ b/test/CodeGen/pragma-detect_mismatch.c
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s

-

-#pragma detect_mismatch("test", "1")

-

-#define BAR "2"

-#pragma detect_mismatch("test2", BAR)

-

-// CHECK: !llvm.module.flags = !{{{.*}}}

-// CHECK: !{{[0-9]+}} = metadata !{i32 6, metadata !"Linker Options", metadata ![[link_opts:[0-9]+]]}

-// CHECK: ![[link_opts]] = metadata !{metadata ![[test:[0-9]+]], metadata ![[test2:[0-9]+]]}

-// CHECK: ![[test]] = metadata !{metadata !"/FAILIFMISMATCH:\22test=1\22"}

-// CHECK: ![[test2]] = metadata !{metadata !"/FAILIFMISMATCH:\22test2=2\22"}

+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s
+
+#pragma detect_mismatch("test", "1")
+
+#define BAR "2"
+#pragma detect_mismatch("test2", BAR)
+
+// CHECK: !llvm.module.flags = !{{{.*}}}
+// CHECK: !{{[0-9]+}} = metadata !{i32 6, metadata !"Linker Options", metadata ![[link_opts:[0-9]+]]}
+// CHECK: ![[link_opts]] = metadata !{metadata ![[test:[0-9]+]], metadata ![[test2:[0-9]+]]}
+// CHECK: ![[test]] = metadata !{metadata !"/FAILIFMISMATCH:\22test=1\22"}
+// CHECK: ![[test2]] = metadata !{metadata !"/FAILIFMISMATCH:\22test2=2\22"}
diff --git a/test/CodeGen/pragma-loop.cpp b/test/CodeGen/pragma-loop.cpp
index 447a709..9a9665e 100644
--- a/test/CodeGen/pragma-loop.cpp
+++ b/test/CodeGen/pragma-loop.cpp
@@ -8,7 +8,7 @@
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave_count(4)
 #pragma clang loop vectorize_width(4)
-#pragma clang loop unroll(enable)
+#pragma clang loop unroll(full)
   while (i < Length) {
     // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
     List[i] = i * 2;
@@ -28,11 +28,13 @@
   } while (i < Length);
 }
 
+enum struct Tuner : short { Interleave = 4, Unroll = 8 };
+
 // Verify for loop is recognized after sequence of pragma clang loop directives.
 void for_test(int *List, int Length) {
 #pragma clang loop interleave(enable)
-#pragma clang loop interleave_count(4)
-#pragma clang loop unroll_count(8)
+#pragma clang loop interleave_count(static_cast<int>(Tuner::Interleave))
+#pragma clang loop unroll_count(static_cast<int>(Tuner::Unroll))
   for (int i = 0; i < Length; i++) {
     // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
     List[i] = i * 2;
@@ -74,28 +76,74 @@
   }
 }
 
+// Verify constant expressions are handled correctly.
+void for_contant_expression_test(int *List, int Length) {
+#pragma clang loop vectorize_width(1 + 4)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
+    List[i] = i;
+  }
+
+#pragma clang loop vectorize_width(3 + VECWIDTH)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_8:.*]]
+    List[i] += i;
+  }
+}
+
 // Verify metadata is generated when template is used.
 template <typename A>
 void for_template_test(A *List, int Length, A Value) {
-
 #pragma clang loop vectorize_width(8) interleave_count(8) unroll_count(8)
   for (int i = 0; i < Length; i++) {
-    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_9:.*]]
     List[i] = i * Value;
   }
 }
 
 // Verify define is resolved correctly when template is used.
-template <typename A>
+template <typename A, typename T>
 void for_template_define_test(A *List, int Length, A Value) {
-#pragma clang loop vectorize_width(VECWIDTH) interleave_count(INTCOUNT)
-#pragma clang loop unroll_count(UNROLLCOUNT)
+  const T VWidth = VECWIDTH;
+  const T ICount = INTCOUNT;
+  const T UCount = UNROLLCOUNT;
+#pragma clang loop vectorize_width(VWidth) interleave_count(ICount)
+#pragma clang loop unroll_count(UCount)
   for (int i = 0; i < Length; i++) {
-    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_8:.*]]
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_10:.*]]
     List[i] = i * Value;
   }
 }
 
+// Verify templates and constant expressions are handled correctly.
+template <typename A, int V, int I, int U>
+void for_template_constant_expression_test(A *List, int Length) {
+#pragma clang loop vectorize_width(V) interleave_count(I) unroll_count(U)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_11:.*]]
+    List[i] = i;
+  }
+
+#pragma clang loop vectorize_width(V * 2 + VECWIDTH) interleave_count(I * 2 + INTCOUNT) unroll_count(U * 2 + UNROLLCOUNT)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_12:.*]]
+    List[i] += i;
+  }
+
+  const int Scale = 4;
+#pragma clang loop vectorize_width(Scale * V) interleave_count(Scale * I) unroll_count(Scale * U)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_13:.*]]
+    List[i] += i;
+  }
+
+#pragma clang loop vectorize_width((Scale * V) + 2)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_14:.*]]
+    List[i] += i;
+  }
+}
+
 #undef VECWIDTH
 #undef INTCOUNT
 #undef UNROLLCOUNT
@@ -105,25 +153,39 @@
   double Value = 10;
 
   for_template_test<double>(List, Length, Value);
-  for_template_define_test<double>(List, Length, Value);
+  for_template_define_test<double, int>(List, Length, Value);
+  for_template_constant_expression_test<double, 2, 4, 8>(List, Length);
 }
 
-// CHECK: ![[LOOP_1]] = metadata !{metadata ![[LOOP_1]], metadata ![[UNROLLENABLE_1:.*]], metadata ![[WIDTH_4:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[INTENABLE_1:.*]]}
-// CHECK: ![[UNROLLENABLE_1]] = metadata !{metadata !"llvm.loop.unroll.enable", i1 true}
+// CHECK: ![[LOOP_1]] = metadata !{metadata ![[LOOP_1]], metadata ![[UNROLL_FULL:.*]], metadata ![[WIDTH_4:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[INTENABLE_1:.*]]}
+// CHECK: ![[UNROLL_FULL]] = metadata !{metadata !"llvm.loop.unroll.full"}
 // CHECK: ![[WIDTH_4]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 4}
-// CHECK: ![[INTERLEAVE_4]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 4}
+// CHECK: ![[INTERLEAVE_4]] = metadata !{metadata !"llvm.loop.interleave.count", i32 4}
 // CHECK: ![[INTENABLE_1]] = metadata !{metadata !"llvm.loop.vectorize.enable", i1 true}
-// CHECK: ![[LOOP_2]] = metadata !{metadata ![[LOOP_2:.*]], metadata ![[UNROLLENABLE_0:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[WIDTH_8:.*]]}
-// CHECK: ![[UNROLLENABLE_0]] = metadata !{metadata !"llvm.loop.unroll.enable", i1 false}
+// CHECK: ![[LOOP_2]] = metadata !{metadata ![[LOOP_2:.*]], metadata ![[UNROLL_DISABLE:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[WIDTH_8:.*]]}
+// CHECK: ![[UNROLL_DISABLE]] = metadata !{metadata !"llvm.loop.unroll.disable"}
 // CHECK: ![[WIDTH_8]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 8}
 // CHECK: ![[LOOP_3]] = metadata !{metadata ![[LOOP_3]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[ENABLE_1:.*]]}
 // CHECK: ![[UNROLL_8]] = metadata !{metadata !"llvm.loop.unroll.count", i32 8}
 // CHECK: ![[LOOP_4]] = metadata !{metadata ![[LOOP_4]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
-// CHECK: ![[INTERLEAVE_2]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 2}
+// CHECK: ![[INTERLEAVE_2]] = metadata !{metadata !"llvm.loop.interleave.count", i32 2}
 // CHECK: ![[WIDTH_2]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 2}
-// CHECK: ![[LOOP_5]] = metadata !{metadata ![[LOOP_5]], metadata ![[UNROLLENABLE_0:.*]], metadata ![[WIDTH_1:.*]]}
+// CHECK: ![[LOOP_5]] = metadata !{metadata ![[LOOP_5]], metadata ![[UNROLL_DISABLE:.*]], metadata ![[WIDTH_1:.*]]}
 // CHECK: ![[WIDTH_1]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 1}
 // CHECK: ![[LOOP_6]] = metadata !{metadata ![[LOOP_6]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
-// CHECK: ![[LOOP_7]] = metadata !{metadata ![[LOOP_7]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_8:.*]], metadata ![[WIDTH_8:.*]]}
-// CHECK: ![[INTERLEAVE_8]] = metadata !{metadata !"llvm.loop.vectorize.unroll", i32 8}
-// CHECK: ![[LOOP_8]] = metadata !{metadata ![[LOOP_8]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
+// CHECK: ![[LOOP_7]] = metadata !{metadata ![[LOOP_7]], metadata ![[WIDTH_5:.*]]}
+// CHECK: ![[WIDTH_5]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 5}
+// CHECK: ![[LOOP_8]] = metadata !{metadata ![[LOOP_8]], metadata ![[WIDTH_5:.*]]}
+// CHECK: ![[LOOP_9]] = metadata !{metadata ![[LOOP_9]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_8:.*]], metadata ![[WIDTH_8:.*]]}
+// CHECK: ![[INTERLEAVE_8]] = metadata !{metadata !"llvm.loop.interleave.count", i32 8}
+// CHECK: ![[LOOP_10]] = metadata !{metadata ![[LOOP_10]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_2:.*]], metadata ![[WIDTH_2:.*]]}
+// CHECK: ![[LOOP_11]] = metadata !{metadata ![[LOOP_11]], metadata ![[UNROLL_8:.*]], metadata ![[INTERLEAVE_4:.*]], metadata ![[WIDTH_2:.*]]}
+// CHECK: ![[LOOP_12]] = metadata !{metadata ![[LOOP_12]], metadata ![[UNROLL_24:.*]], metadata ![[INTERLEAVE_10:.*]], metadata ![[WIDTH_6:.*]]}
+// CHECK: ![[UNROLL_24]] = metadata !{metadata !"llvm.loop.unroll.count", i32 24}
+// CHECK: ![[INTERLEAVE_10]] = metadata !{metadata !"llvm.loop.interleave.count", i32 10}
+// CHECK: ![[WIDTH_6]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 6}
+// CHECK: ![[LOOP_13]] = metadata !{metadata ![[LOOP_13]], metadata ![[UNROLL_32:.*]], metadata ![[INTERLEAVE_16:.*]], metadata ![[WIDTH_8:.*]]}
+// CHECK: ![[UNROLL_32]] = metadata !{metadata !"llvm.loop.unroll.count", i32 32}
+// CHECK: ![[INTERLEAVE_16]] = metadata !{metadata !"llvm.loop.interleave.count", i32 16}
+// CHECK: ![[LOOP_14]] = metadata !{metadata ![[LOOP_14]], metadata ![[WIDTH_10:.*]]}
+// CHECK: ![[WIDTH_10]] = metadata !{metadata !"llvm.loop.vectorize.width", i32 10}
diff --git a/test/CodeGen/pragma-unroll.cpp b/test/CodeGen/pragma-unroll.cpp
new file mode 100644
index 0000000..05d1733
--- /dev/null
+++ b/test/CodeGen/pragma-unroll.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify while loop is recognized after unroll pragma.
+void while_test(int *List, int Length) {
+  // CHECK: define {{.*}} @_Z10while_test
+  int i = 0;
+
+#pragma unroll
+  while (i < Length) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
+    List[i] = i * 2;
+    i++;
+  }
+}
+
+// Verify do loop is recognized after multi-option pragma clang loop directive.
+void do_test(int *List, int Length) {
+  int i = 0;
+
+#pragma nounroll
+  do {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_2:.*]]
+    List[i] = i * 2;
+    i++;
+  } while (i < Length);
+}
+
+// Verify for loop is recognized after unroll pragma.
+void for_test(int *List, int Length) {
+#pragma unroll 8
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
+    List[i] = i * 2;
+  }
+}
+
+// Verify c++11 for range loop is recognized after unroll pragma.
+void for_range_test() {
+  double List[100];
+
+#pragma unroll(4)
+  for (int i : List) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_4:.*]]
+    List[i] = i;
+  }
+}
+
+#define UNROLLCOUNT 8
+
+// Verify defines are correctly resolved in unroll pragmas.
+void for_define_test(int *List, int Length, int Value) {
+#pragma unroll(UNROLLCOUNT)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_5:.*]]
+    List[i] = i * Value;
+  }
+}
+
+// Verify metadata is generated when template is used.
+template <typename A>
+void for_template_test(A *List, int Length, A Value) {
+#pragma unroll 8
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_6:.*]]
+    List[i] = i * Value;
+  }
+}
+
+// Verify define is resolved correctly when template is used.
+template <typename A>
+void for_template_define_test(A *List, int Length, A Value) {
+#pragma unroll(UNROLLCOUNT)
+  for (int i = 0; i < Length; i++) {
+    // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
+    List[i] = i * Value;
+  }
+}
+
+#undef UNROLLCOUNT
+
+// Use templates defined above. Test verifies metadata is generated correctly.
+void template_test(double *List, int Length) {
+  double Value = 10;
+
+  for_template_test<double>(List, Length, Value);
+  for_template_define_test<double>(List, Length, Value);
+}
+
+// CHECK: ![[LOOP_1]] = metadata !{metadata ![[LOOP_1]], metadata ![[UNROLL_FULL:.*]]}
+// CHECK: ![[UNROLL_FULL]] = metadata !{metadata !"llvm.loop.unroll.full"}
+// CHECK: ![[LOOP_2]] = metadata !{metadata ![[LOOP_2:.*]], metadata ![[UNROLL_DISABLE:.*]]}
+// CHECK: ![[UNROLL_DISABLE]] = metadata !{metadata !"llvm.loop.unroll.disable"}
+// CHECK: ![[LOOP_3]] = metadata !{metadata ![[LOOP_3]], metadata ![[UNROLL_8:.*]]}
+// CHECK: ![[UNROLL_8]] = metadata !{metadata !"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[LOOP_4]] = metadata !{metadata ![[LOOP_4]], metadata ![[UNROLL_4:.*]]}
+// CHECK: ![[UNROLL_4]] = metadata !{metadata !"llvm.loop.unroll.count", i32 4}
+// CHECK: ![[LOOP_5]] = metadata !{metadata ![[LOOP_5]], metadata ![[UNROLL_8:.*]]}
+// CHECK: ![[LOOP_6]] = metadata !{metadata ![[LOOP_6]], metadata ![[UNROLL_8:.*]]}
+// CHECK: ![[LOOP_7]] = metadata !{metadata ![[LOOP_7]], metadata ![[UNROLL_8:.*]]}
diff --git a/test/CodeGen/pragma-weak.c b/test/CodeGen/pragma-weak.c
index b5d1863..aba98e1 100644
--- a/test/CodeGen/pragma-weak.c
+++ b/test/CodeGen/pragma-weak.c
@@ -7,16 +7,16 @@
 
 // CHECK-DAG: @both = alias void ()* @__both
 // CHECK-DAG: @both2 = alias void ()* @__both2
-// CHECK-DAG: @weakvar_alias = alias weak i32* @__weakvar_alias
-// CHECK-DAG: @foo = alias weak void ()* @__foo
-// CHECK-DAG: @foo2 = alias weak void ()* @__foo2
-// CHECK-DAG: @stutter = alias weak void ()* @__stutter
-// CHECK-DAG: @stutter2 = alias weak void ()* @__stutter2
-// CHECK-DAG: @declfirst = alias weak void ()* @__declfirst
-// CHECK-DAG: @declfirstattr = alias weak void ()* @__declfirstattr
-// CHECK-DAG: @mix2 = alias weak void ()* @__mix2
-// CHECK-DAG: @a1 = alias weak void ()* @__a1
-// CHECK-DAG: @xxx = alias weak void ()* @__xxx
+// CHECK-DAG: @weakvar_alias = weak alias i32* @__weakvar_alias
+// CHECK-DAG: @foo = weak alias void ()* @__foo
+// CHECK-DAG: @foo2 = weak alias void ()* @__foo2
+// CHECK-DAG: @stutter = weak alias void ()* @__stutter
+// CHECK-DAG: @stutter2 = weak alias void ()* @__stutter2
+// CHECK-DAG: @declfirst = weak alias void ()* @__declfirst
+// CHECK-DAG: @declfirstattr = weak alias void ()* @__declfirstattr
+// CHECK-DAG: @mix2 = weak alias void ()* @__mix2
+// CHECK-DAG: @a1 = weak alias void ()* @__a1
+// CHECK-DAG: @xxx = weak alias void ()* @__xxx
 
 
 
diff --git a/test/CodeGen/predefined-expr.c b/test/CodeGen/predefined-expr.c
index 6c94152..3ccdeb3 100644
--- a/test/CodeGen/predefined-expr.c
+++ b/test/CodeGen/predefined-expr.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fms-extensions %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
 
 // CHECK: @__func__.plainFunction = private unnamed_addr constant [14 x i8] c"plainFunction\00"
 // CHECK: @__PRETTY_FUNCTION__.plainFunction = private unnamed_addr constant [21 x i8] c"void plainFunction()\00"
diff --git a/test/CodeGen/sanitize-address-field-padding.cpp b/test/CodeGen/sanitize-address-field-padding.cpp
new file mode 100644
index 0000000..0683089
--- /dev/null
+++ b/test/CodeGen/sanitize-address-field-padding.cpp
@@ -0,0 +1,236 @@
+// Test -fsanitize-address-field-padding
+// RUN: echo 'type:SomeNamespace::BlacklistedByName=field-padding' > %t.type.blacklist
+// RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.blacklist
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s -O1 -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.file.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_BLACKLIST
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=NO_PADDING
+//
+
+// The reasons to ignore a particular class are not set in stone and will change.
+//
+// CHECK: -fsanitize-address-field-padding applied to Positive1
+// CHECK: -fsanitize-address-field-padding ignored for Negative1 because it is trivially copyable
+// CHECK: -fsanitize-address-field-padding ignored for Negative2 because it is trivially copyable
+// CHECK: -fsanitize-address-field-padding ignored for Negative3 because it is a union
+// CHECK: -fsanitize-address-field-padding ignored for Negative4 because it is trivially copyable
+// CHECK: -fsanitize-address-field-padding ignored for Negative5 because it is packed
+// CHECK: -fsanitize-address-field-padding ignored for SomeNamespace::BlacklistedByName because it is blacklisted
+// CHECK: -fsanitize-address-field-padding ignored for ExternCStruct because it is not C++
+//
+// FILE_BLACKLIST: -fsanitize-address-field-padding ignored for Positive1 because it is in a blacklisted file
+// FILE_BLACKLIST-NOT: __asan_poison_intra_object_redzone
+// NO_PADDING-NOT: __asan_poison_intra_object_redzone
+
+
+class Positive1 {
+ public:
+  Positive1() {}
+  ~Positive1() {}
+  int make_it_non_standard_layout;
+ private:
+  char private1;
+  int private2;
+  short private_array[6];
+  long long private3;
+};
+
+Positive1 positive1;
+// Positive1 with extra paddings
+// CHECK: type { i32, [12 x i8], i8, [15 x i8], i32, [12 x i8], [6 x i16], [12 x i8], i64, [8 x i8] }
+
+struct VirtualBase {
+  int foo;
+};
+
+class ClassWithVirtualBase : public virtual VirtualBase {
+ public:
+  ClassWithVirtualBase() {}
+  ~ClassWithVirtualBase() {}
+  int make_it_non_standard_layout;
+ private:
+  char x[7];
+  char y[9];
+};
+
+ClassWithVirtualBase class_with_virtual_base;
+
+class WithFlexibleArray1 {
+ public:
+  WithFlexibleArray1() {}
+  ~WithFlexibleArray1() {}
+  int make_it_non_standard_layout;
+ private:
+  char private1[33];
+  int flexible[];  // Don't insert padding after this field.
+};
+
+WithFlexibleArray1 with_flexible_array1;
+// CHECK: %class.WithFlexibleArray1 = type { i32, [12 x i8], [33 x i8], [15 x i8], [0 x i32] }
+
+class WithFlexibleArray2 {
+ public:
+  char x[21];
+  WithFlexibleArray1 flex1;  // Don't insert padding after this field.
+};
+
+WithFlexibleArray2 with_flexible_array2;
+// CHECK: %class.WithFlexibleArray2 = type { [21 x i8], [11 x i8], %class.WithFlexibleArray1 }
+
+class WithFlexibleArray3 {
+ public:
+  char x[13];
+  WithFlexibleArray2 flex2;  // Don't insert padding after this field.
+};
+
+WithFlexibleArray3 with_flexible_array3;
+
+
+class Negative1 {
+ public:
+  Negative1() {}
+  int public1, public2;
+};
+Negative1 negative1;
+// CHECK: type { i32, i32 }
+
+class Negative2 {
+ public:
+  Negative2() {}
+ private:
+  int private1, private2;
+};
+Negative2 negative2;
+// CHECK: type { i32, i32 }
+
+union Negative3 {
+  char m1[8];
+  long long m2;
+};
+
+Negative3 negative3;
+// CHECK: type { i64 }
+
+class Negative4 {
+ public:
+  Negative4() {}
+  // No DTOR
+  int make_it_non_standard_layout;
+ private:
+  char private1;
+  int private2;
+};
+
+Negative4 negative4;
+// CHECK: type { i32, i8, i32 }
+
+class __attribute__((packed)) Negative5 {
+ public:
+  Negative5() {}
+  ~Negative5() {}
+  int make_it_non_standard_layout;
+ private:
+  char private1;
+  int private2;
+};
+
+Negative5 negative5;
+// CHECK: type <{ i32, i8, i32 }>
+
+
+namespace SomeNamespace {
+class BlacklistedByName {
+ public:
+  BlacklistedByName() {}
+  ~BlacklistedByName() {}
+  int make_it_non_standard_layout;
+ private:
+  char private1;
+  int private2;
+};
+}  // SomeNamespace
+
+SomeNamespace::BlacklistedByName blacklisted_by_name;
+
+extern "C" {
+class ExternCStruct {
+ public:
+  ExternCStruct() {}
+  ~ExternCStruct() {}
+  int make_it_non_standard_layout;
+ private:
+  char private1;
+  int private2;
+};
+}  // extern "C"
+
+ExternCStruct extern_C_struct;
+
+// CTOR
+// CHECK-LABEL: define {{.*}}Positive1C1Ev
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}}12)
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}}15)
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}}12)
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}}12)
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}}8)
+// CHECK-NOT: __asan_poison_intra_object_redzone
+// CHECK: ret void
+//
+// DTOR
+// CHECK: call void @__asan_unpoison_intra_object_redzone({{.*}}12)
+// CHECK: call void @__asan_unpoison_intra_object_redzone({{.*}}15)
+// CHECK: call void @__asan_unpoison_intra_object_redzone({{.*}}12)
+// CHECK: call void @__asan_unpoison_intra_object_redzone({{.*}}12)
+// CHECK: call void @__asan_unpoison_intra_object_redzone({{.*}}8)
+// CHECK-NOT: __asan_unpoison_intra_object_redzone
+// CHECK: ret void
+//
+//
+// CHECK-LABEL: define linkonce_odr void @_ZN20ClassWithVirtualBaseC1Ev
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}} 12)
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}} 9)
+// CHECK: call void @__asan_poison_intra_object_redzone({{.*}} 15)
+// CHECK-NOT: __asan_poison_intra_object_redzone
+// CHECK: ret void
+//
+
+struct WithVirtualDtor {
+  virtual ~WithVirtualDtor();
+  int x, y;
+};
+struct InheritsFrom_WithVirtualDtor: WithVirtualDtor {
+  int a, b;
+  InheritsFrom_WithVirtualDtor() {}
+  ~InheritsFrom_WithVirtualDtor() {}
+};
+
+void Create_InheritsFrom_WithVirtualDtor() {
+  InheritsFrom_WithVirtualDtor x;
+}
+
+
+// Make sure the dtor of InheritsFrom_WithVirtualDtor remains in the code,
+// i.e. we ignore -mconstructor-aliases when field paddings are added
+// because the paddings in InheritsFrom_WithVirtualDtor needs to be unpoisoned
+// in the dtor.
+// WITH_CTOR_ALIASES-LABEL: define void @_Z35Create_InheritsFrom_WithVirtualDtor
+// WITH_CTOR_ALIASES-NOT: call void @_ZN15WithVirtualDtorD2Ev
+// WITH_CTOR_ALIASES: call void @_ZN28InheritsFrom_WithVirtualDtorD2Ev
+// WITH_CTOR_ALIASES: ret void
+
+// Make sure we don't emit memcpy for operator= if paddings are inserted.
+struct ClassWithTrivialCopy {
+  ClassWithTrivialCopy();
+  ~ClassWithTrivialCopy();
+  void *a;
+ private:
+  void *c;
+};
+
+void MakeTrivialCopy(ClassWithTrivialCopy *s1, ClassWithTrivialCopy *s2) {
+  *s1 = *s2;
+}
+
+// CHECK-LABEL: define void @_Z15MakeTrivialCopyP20ClassWithTrivialCopyS0_
+// CHECK-NOT: memcpy
+// CHECK: ret void
diff --git a/test/CodeGen/sanitize-init-order.cpp b/test/CodeGen/sanitize-init-order.cpp
index 8c662db..6fd215d 100644
--- a/test/CodeGen/sanitize-init-order.cpp
+++ b/test/CodeGen/sanitize-init-order.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s | FileCheck %s
 
 // Test blacklist functionality.
-// RUN: echo "global-init-src:%s" > %t-file.blacklist
-// RUN: echo "global-init-type:struct.PODWithCtorAndDtor" > %t-type.blacklist
+// RUN: echo "src:%s=init" > %t-file.blacklist
+// RUN: echo "type:PODWithCtorAndDtor=init" > %t-type.blacklist
+// RUN: echo "type:NS::PODWithCtor=init" >> %t-type.blacklist
 // RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t-file.blacklist -emit-llvm -o - %s | FileCheck %s --check-prefix=BLACKLIST
 // RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t-type.blacklist -emit-llvm -o - %s | FileCheck %s --check-prefix=BLACKLIST
 // REQUIRES: shell
@@ -25,14 +26,25 @@
 };
 PODWithCtorAndDtor s3;
 
+namespace NS {
+class PODWithCtor {
+public:
+  PODWithCtor() {}
+};
+
+const volatile PODWithCtor array[5][5];
+}
+
 // Check that ASan init-order checking ignores structs with trivial default
 // constructor.
-// CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]]}
+// CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]}
 // CHECK: ![[GLOB_1]] = metadata !{%struct.PODStruct* {{.*}}, i1 false, i1 false}
 // CHECK: ![[GLOB_2]] = metadata !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false}
 // CHECK: ![[GLOB_3]] = metadata !{%struct.PODWithCtorAndDtor* {{.*}}, i1 true, i1 false}
+// CHECK: ![[GLOB_4]] = metadata !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 true, i1 false}
 
-// BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]]}
+// BLACKLIST: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], ![[GLOB_3:[0-9]]], ![[GLOB_4:[0-9]]]}
 // BLACKLIST: ![[GLOB_1]] = metadata !{%struct.PODStruct* {{.*}}, i1 false, i1 false}
 // BLACKLIST: ![[GLOB_2]] = metadata !{%struct.PODWithDtor* {{.*}}, i1 false, i1 false}
 // BLACKLIST: ![[GLOB_3]] = metadata !{%struct.PODWithCtorAndDtor* {{.*}}, i1 false, i1 false}
+// BLACKLIST: ![[GLOB_4]] = metadata !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 false, i1 false}
diff --git a/test/CodeGen/sections.c b/test/CodeGen/sections.c
deleted file mode 100644
index 8d93fed..0000000
--- a/test/CodeGen/sections.c
+++ /dev/null
@@ -1,51 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm -fms-extensions -xc++ -o - < %s | FileCheck %s
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-#pragma const_seg(".my_const")
-#pragma bss_seg(".my_bss")
-int D = 1;
-#pragma data_seg(".data")
-int a = 1;
-#pragma data_seg(push, label, ".data2")
-extern const int b;
-const int b = 1;
-const char* s = "my string!";
-#pragma data_seg(push, ".my_seg")
-int c = 1;
-#pragma data_seg(pop, label)
-int d = 1;
-int e;
-#pragma bss_seg(".c")
-int f;
-void g(void){}
-#pragma code_seg(".my_code")
-void h(void){}
-#pragma bss_seg()
-int i;
-#pragma bss_seg(".bss1")
-#pragma bss_seg(push, test, ".bss2")
-#pragma bss_seg()
-#pragma bss_seg()
-int TEST1;
-#pragma bss_seg(pop)
-int TEST2;
-#ifdef __cplusplus
-}
-#endif
-
-//CHECK: @D = global i32 1
-//CHECK: @a = global i32 1, section ".data"
-//CHECK: @b = constant i32 1, section ".my_const"
-//CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my string!\00"
-//CHECK: @s = global i8* getelementptr inbounds ([11 x i8]* @[[MYSTR]], i32 0, i32 0), section ".data2"
-//CHECK: @c = global i32 1, section ".my_seg"
-//CHECK: @d = global i32 1, section ".data"
-//CHECK: @e = global i32 0, section ".my_bss"
-//CHECK: @f = global i32 0, section ".c"
-//CHECK: @i = global i32 0
-//CHECK: @TEST1 = global i32 0
-//CHECK: @TEST2 = global i32 0, section ".bss1"
-//CHECK: define void @g()
-//CHECK: define void @h() {{.*}} section ".my_code"
diff --git a/test/CodeGen/target-data.c b/test/CodeGen/target-data.c
index 5153be9..a727a7f 100644
--- a/test/CodeGen/target-data.c
+++ b/test/CodeGen/target-data.c
@@ -68,7 +68,7 @@
 
 // RUN: %clang_cc1 -triple arm-nacl-gnueabi -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=ARM-NACL
-// ARM-NACL: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S128"
+// ARM-NACL: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128"
 
 // RUN: %clang_cc1 -triple mipsel-nacl -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-NACL
@@ -128,15 +128,15 @@
 
 // RUN: %clang_cc1 -triple thumb-unknown-gnueabi -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=THUMB
-// THUMB: target datalayout = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-v128:64:128-a:0:32-n32-S64"
+// THUMB: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
 
 // RUN: %clang_cc1 -triple arm-unknown-gnueabi -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=ARM
-// ARM: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
+// ARM: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
 
 // RUN: %clang_cc1 -triple thumb-unknown -o - -emit-llvm -target-abi apcs-gnu \
 // RUN: %s | FileCheck %s -check-prefix=THUMB-GNU
-// THUMB-GNU: target datalayout = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+// THUMB-GNU: target datalayout = "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
 
 // RUN: %clang_cc1 -triple arm-unknown -o - -emit-llvm -target-abi apcs-gnu \
 // RUN: %s | FileCheck %s -check-prefix=ARM-GNU
@@ -152,7 +152,7 @@
 
 // RUN: %clang_cc1 -triple msp430-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MSP430
-// MSP430: target datalayout = "e-m:e-p:16:16-i32:16:32-n8:16"
+// MSP430: target datalayout = "e-m:e-p:16:16-i32:16:32-a:16-n8:16"
 
 // RUN: %clang_cc1 -triple tce-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=TCE
diff --git a/test/CodeGen/transparent-union.c b/test/CodeGen/transparent-union.c
index 21040e4..2f00c2d 100644
--- a/test/CodeGen/transparent-union.c
+++ b/test/CodeGen/transparent-union.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -o %t %s
-// RUN: FileCheck < %t %s
-//
-// FIXME: Note that we don't currently get the ABI right here. f0() should be
-// f0(i8*).
+// RUN: %clang_cc1 -Werror -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -Werror -triple armv7-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 -Werror -triple powerpc64le-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -Werror -triple aarch64-linux -emit-llvm -o - %s | FileCheck %s
 
 typedef union {
   void *f0;
@@ -10,10 +10,15 @@
 
 void f0(transp_t0 obj);
 
-// CHECK-LABEL: define void @f1_0(i32* %a0) 
-// CHECK:  call void @f0(%union.transp_t0* byval align 4 %{{.*}})
+// CHECK-LABEL: define void @f1_0(i32* %a0)
+// CHECK:  call void @f0(i8* %{{.*}})
 // CHECK:  call void %{{.*}}(i8* %{{[a-z0-9]*}})
 // CHECK: }
+
+// ARM-LABEL: define arm_aapcscc void @f1_0(i32* %a0)
+// ARM:  call arm_aapcscc void @f0(i8* %{{.*}})
+// ARM:  call arm_aapcscc void %{{.*}}(i8* %{{[a-z0-9]*}})
+// ARM: }
 void f1_0(int *a0) {
   void (*f0p)(void *) = f0;
   f0(a0);
diff --git a/test/CodeGen/ubsan-type-blacklist.cpp b/test/CodeGen/ubsan-type-blacklist.cpp
new file mode 100644
index 0000000..e2bbb6a
--- /dev/null
+++ b/test/CodeGen/ubsan-type-blacklist.cpp
@@ -0,0 +1,23 @@
+// Verify ubsan vptr does not check down-casts on blacklisted types.
+// RUN: echo "type:_ZTI3Foo" > %t-type.blacklist
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -fsanitize-blacklist=%t-type.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=TYPE
+
+class Bar {
+public:
+  virtual ~Bar() {}
+};
+class Foo : public Bar {};
+
+Bar bar;
+
+// DEFAULT: @_Z7checkmev
+// TYPE: @_Z7checkmev
+void checkme() {
+// DEFAULT: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}} (%class.Bar* @bar to
+// TYPE-NOT: @__ubsan_handle_dynamic_type_cache_miss
+  Foo* foo = static_cast<Foo*>(&bar); // down-casting
+// DEFAULT: ret void
+// TYPE: ret void
+  return;
+}
diff --git a/test/CodeGen/variadic-null-win64.c b/test/CodeGen/variadic-null-win64.c
new file mode 100644
index 0000000..4f57e7b
--- /dev/null
+++ b/test/CodeGen/variadic-null-win64.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-windows-msvc | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-linux | FileCheck %s --check-prefix=LINUX
+
+// Make it possible to pass NULL through variadic functions on platforms where
+// NULL has an integer type that is more narrow than a pointer. On such
+// platforms we widen null pointer constants to a pointer-sized integer.
+
+#define NULL 0
+
+void v(const char *f, ...);
+void f(const char *f) {
+  v(f, 1, 2, 3, NULL);
+}
+// WINDOWS: define void @f(i8* %f)
+// WINDOWS: call void (i8*, ...)* @v(i8* {{.*}}, i32 1, i32 2, i32 3, i64 0)
+// LINUX: define void @f(i8* %f)
+// LINUX: call void (i8*, ...)* @v(i8* {{.*}}, i32 1, i32 2, i32 3, i32 0)
diff --git a/test/CodeGen/vectorcall.c b/test/CodeGen/vectorcall.c
new file mode 100644
index 0000000..17927c7
--- /dev/null
+++ b/test/CodeGen/vectorcall.c
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s --check-prefix=X64
+
+void __vectorcall v1(int a, int b) {}
+// CHECK: define x86_vectorcallcc void @"\01v1@@8"(i32 inreg %a, i32 inreg %b)
+// X64: define x86_vectorcallcc void @"\01v1@@16"(i32 %a, i32 %b)
+
+void __vectorcall v2(char a, char b) {}
+// CHECK: define x86_vectorcallcc void @"\01v2@@8"(i8 inreg signext %a, i8 inreg signext %b)
+// X64: define x86_vectorcallcc void @"\01v2@@16"(i8 %a, i8 %b)
+
+struct Small { int a; };
+void __vectorcall v3(int a, struct Small b, int c) {}
+// CHECK: define x86_vectorcallcc void @"\01v3@@12"(i32 inreg %a, %struct.Small* byval align 4 %b, i32 inreg %c)
+// X64: define x86_vectorcallcc void @"\01v3@@24"(i32 %a, i32 %b.coerce, i32 %c)
+
+struct Large { int a[5]; };
+void __vectorcall v4(int a, struct Large b, int c) {}
+// CHECK: define x86_vectorcallcc void @"\01v4@@28"(i32 inreg %a, %struct.Large* byval align 4 %b, i32 inreg %c)
+// X64: define x86_vectorcallcc void @"\01v4@@40"(i32 %a, %struct.Large* %b, i32 %c)
+
+struct HFA2 { double x, y; };
+struct HFA4 { double w, x, y, z; };
+struct HFA5 { double v, w, x, y, z; };
+
+void __vectorcall hfa1(int a, struct HFA4 b, int c) {}
+// CHECK: define x86_vectorcallcc void @"\01hfa1@@40"(i32 inreg %a, double %b.0, double %b.1, double %b.2, double %b.3, i32 inreg %c)
+// X64: define x86_vectorcallcc void @"\01hfa1@@48"(i32 %a, double %b.0, double %b.1, double %b.2, double %b.3, i32 %c)
+
+// HFAs that would require more than six total SSE registers are passed
+// indirectly. Additional vector arguments can consume the rest of the SSE
+// registers.
+void __vectorcall hfa2(struct HFA4 a, struct HFA4 b, double c) {}
+// CHECK: define x86_vectorcallcc void @"\01hfa2@@72"(double %a.0, double %a.1, double %a.2, double %a.3, %struct.HFA4* inreg %b, double %c)
+// X64: define x86_vectorcallcc void @"\01hfa2@@72"(double %a.0, double %a.1, double %a.2, double %a.3, %struct.HFA4* align 8 %b, double %c)
+
+// Ensure that we pass builtin types directly while counting them against the
+// SSE register usage.
+void __vectorcall hfa3(double a, double b, double c, double d, double e, struct HFA2 f) {}
+// CHECK: define x86_vectorcallcc void @"\01hfa3@@56"(double %a, double %b, double %c, double %d, double %e, %struct.HFA2* inreg %f)
+// X64: define x86_vectorcallcc void @"\01hfa3@@56"(double %a, double %b, double %c, double %d, double %e, %struct.HFA2* align 8 %f)
+
+// Aggregates with more than four elements are not HFAs and are passed byval.
+// Because they are not classified as homogeneous, they don't get special
+// handling to ensure alignment.
+void __vectorcall hfa4(struct HFA5 a) {}
+// CHECK: define x86_vectorcallcc void @"\01hfa4@@40"(%struct.HFA5* byval align 4)
+// X64: define x86_vectorcallcc void @"\01hfa4@@40"(%struct.HFA5* %a)
+
+// Return HFAs of 4 or fewer elements in registers.
+static struct HFA2 g_hfa2;
+struct HFA2 __vectorcall hfa5(void) { return g_hfa2; }
+// CHECK: define x86_vectorcallcc %struct.HFA2 @"\01hfa5@@0"()
+// X64: define x86_vectorcallcc %struct.HFA2 @"\01hfa5@@0"()
+
+typedef float __attribute__((vector_size(16))) v4f32;
+struct HVA2 { v4f32 x, y; };
+struct HVA4 { v4f32 w, x, y, z; };
+
+void __vectorcall hva1(int a, struct HVA4 b, int c) {}
+// CHECK: define x86_vectorcallcc void @"\01hva1@@72"(i32 inreg %a, <4 x float> %b.0, <4 x float> %b.1, <4 x float> %b.2, <4 x float> %b.3, i32 inreg %c)
+// X64: define x86_vectorcallcc void @"\01hva1@@80"(i32 %a, <4 x float> %b.0, <4 x float> %b.1, <4 x float> %b.2, <4 x float> %b.3, i32 %c)
+
+void __vectorcall hva2(struct HVA4 a, struct HVA4 b, v4f32 c) {}
+// CHECK: define x86_vectorcallcc void @"\01hva2@@144"(<4 x float> %a.0, <4 x float> %a.1, <4 x float> %a.2, <4 x float> %a.3, %struct.HVA4* inreg %b, <4 x float> %c)
+// X64: define x86_vectorcallcc void @"\01hva2@@144"(<4 x float> %a.0, <4 x float> %a.1, <4 x float> %a.2, <4 x float> %a.3, %struct.HVA4* align 16 %b, <4 x float> %c)
+
+void __vectorcall hva3(v4f32 a, v4f32 b, v4f32 c, v4f32 d, v4f32 e, struct HVA2 f) {}
+// CHECK: define x86_vectorcallcc void @"\01hva3@@112"(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d, <4 x float> %e, %struct.HVA2* inreg %f)
+// X64: define x86_vectorcallcc void @"\01hva3@@112"(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d, <4 x float> %e, %struct.HVA2* align 16 %f)
+
+typedef float __attribute__((ext_vector_type(3))) v3f32;
+struct OddSizeHVA { v3f32 x, y; };
+
+void __vectorcall odd_size_hva(struct OddSizeHVA a) {}
+// CHECK: define x86_vectorcallcc void @"\01odd_size_hva@@32"(<3 x float> %a.0, <3 x float> %a.1)
+// X64: define x86_vectorcallcc void @"\01odd_size_hva@@32"(<3 x float> %a.0, <3 x float> %a.1)
diff --git a/test/CodeGen/vla.c b/test/CodeGen/vla.c
index 1757ef7..e6cdd5d 100644
--- a/test/CodeGen/vla.c
+++ b/test/CodeGen/vla.c
@@ -195,3 +195,12 @@
   // CHECK-LABEL: define void @test7(
   // CHECK: call i32 @b(i8* null)
 }
+
+// Make sure we emit dereferenceable or nonnull when the static keyword is
+// provided.
+void test8(int a[static 3]) { }
+// CHECK: define void @test8(i32* dereferenceable(12) %a)
+
+void test9(int n, int a[static n]) { }
+// CHECK: define void @test9(i32 %n, i32* nonnull %a)
+
diff --git a/test/CodeGen/wchar-const.c b/test/CodeGen/wchar-const.c
index 34da249..b461d60 100644
--- a/test/CodeGen/wchar-const.c
+++ b/test/CodeGen/wchar-const.c
@@ -7,9 +7,9 @@
 #if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
   || defined(_M_X64) || defined(SHORT_WCHAR)
   #define WCHAR_T_TYPE unsigned short
-#elif defined(__sun) || defined(__AuroraUX__)
+#elif defined(__sun)
   #define WCHAR_T_TYPE long
-#else /* Solaris or AuroraUX. */
+#else /* Solaris. */
   #define WCHAR_T_TYPE int
 #endif
 
diff --git a/test/CodeGen/x86-64-inline-asm.c b/test/CodeGen/x86-64-inline-asm.c
index fefbf76..bb46eda 100644
--- a/test/CodeGen/x86-64-inline-asm.c
+++ b/test/CodeGen/x86-64-inline-asm.c
@@ -10,3 +10,8 @@
 // expected-error@-5 {{scale factor without index register is ignored}}
 #endif
 }
+
+static unsigned var[1] = {};
+void g(void) { asm volatile("movd %%xmm0, %0"
+                            :
+                            : "m"(var)); }
diff --git a/test/CodeGen/x86_32-inline-asm.c b/test/CodeGen/x86_32-inline-asm.c
index 473f78e..c1fba0e 100644
--- a/test/CodeGen/x86_32-inline-asm.c
+++ b/test/CodeGen/x86_32-inline-asm.c
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -triple i386-apple-darwin9 -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -target-feature +avx -verify %s
+
 // <rdar://problem/12415959>
+// rdar://problem/11846140
+// rdar://problem/17476970
 
 typedef unsigned int u_int32_t;
 typedef u_int32_t uint32_t;
@@ -7,6 +11,14 @@
 typedef unsigned long long u_int64_t;
 typedef u_int64_t uint64_t;
 
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+__m128 val128;
+__m256 val256;
+__m512 val512;
+
 int func1() {
   // Error out if size is > 32-bits.
   uint32_t msr = 0x8b;
@@ -21,4 +33,40 @@
   unsigned char data;
   unsigned int port;
   __asm__ volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); // No error expected.
+
+  __asm__ volatile("outb %0, %w1" : : "R" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'R'}}
+  __asm__ volatile("outb %0, %w1" : : "q" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'q'}}
+  __asm__ volatile("outb %0, %w1" : : "Q" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'Q'}}
+  __asm__ volatile("outb %0, %w1" : : "b" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'b'}}
+  __asm__ volatile("outb %0, %w1" : : "c" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'c'}}
+  __asm__ volatile("outb %0, %w1" : : "d" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'd'}}
+  __asm__ volatile("outb %0, %w1" : : "S" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'S'}}
+  __asm__ volatile("outb %0, %w1" : : "D" (val), "Nd" (port)); // expected-error {{invalid input size for constraint 'D'}}
+  __asm__ volatile("foo1 %0" : : "A" (val128)); // expected-error {{invalid input size for constraint 'A'}}
+  __asm__ volatile("foo1 %0" : : "f" (val256)); // expected-error {{invalid input size for constraint 'f'}}
+  __asm__ volatile("foo1 %0" : : "t" (val256)); // expected-error {{invalid input size for constraint 't'}}
+  __asm__ volatile("foo1 %0" : : "u" (val256)); // expected-error {{invalid input size for constraint 'u'}}
+  __asm__ volatile("foo1 %0" : : "x" (val512)); // expected-error {{invalid input size for constraint 'x'}}
+
+  __asm__ volatile("foo1 %0" : "=R" (val)); // expected-error {{invalid output size for constraint '=R'}}
+  __asm__ volatile("foo1 %0" : "=q" (val)); // expected-error {{invalid output size for constraint '=q'}}
+  __asm__ volatile("foo1 %0" : "=Q" (val)); // expected-error {{invalid output size for constraint '=Q'}}
+  __asm__ volatile("foo1 %0" : "=a" (val)); // expected-error {{invalid output size for constraint '=a'}}
+  __asm__ volatile("foo1 %0" : "=b" (val)); // expected-error {{invalid output size for constraint '=b'}}
+  __asm__ volatile("foo1 %0" : "=c" (val)); // expected-error {{invalid output size for constraint '=c'}}
+  __asm__ volatile("foo1 %0" : "=d" (val)); // expected-error {{invalid output size for constraint '=d'}}
+  __asm__ volatile("foo1 %0" : "=S" (val)); // expected-error {{invalid output size for constraint '=S'}}
+  __asm__ volatile("foo1 %0" : "=D" (val)); // expected-error {{invalid output size for constraint '=D'}}
+  __asm__ volatile("foo1 %0" : "=A" (val128)); // expected-error {{invalid output size for constraint '=A'}}
+  __asm__ volatile("foo1 %0" : "=t" (val256)); // expected-error {{invalid output size for constraint '=t'}}
+  __asm__ volatile("foo1 %0" : "=u" (val256)); // expected-error {{invalid output size for constraint '=u'}}
+  __asm__ volatile("foo1 %0" : "=x" (val512)); // expected-error {{invalid output size for constraint '=x'}}
+
+#ifdef __AVX__
+  __asm__ volatile("foo1 %0" : : "x" (val256)); // No error.
+  __asm__ volatile("foo1 %0" : "=x" (val256));  // No error.
+#else
+  __asm__ volatile("foo1 %0" : : "x" (val256)); // expected-error {{invalid input size for constraint 'x'}}
+  __asm__ volatile("foo1 %0" : "=x" (val256)); // expected-error {{invalid output size for constraint '=x'}}
+#endif
 }
diff --git a/test/CodeGen/x86_64-arguments-win32.c b/test/CodeGen/x86_64-arguments-win32.c
new file mode 100644
index 0000000..5aea7fc
--- /dev/null
+++ b/test/CodeGen/x86_64-arguments-win32.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -w -triple x86_64-pc-win32 -emit-llvm -o - %s | FileCheck %s
+
+// To be ABI compatible with code generated by MSVC, there shouldn't be any
+// sign/zero extensions on types smaller than 64bit.
+
+// CHECK-LABEL: define void @f1(i8 %a)
+void f1(char a) {}
+
+// CHECK-LABEL: define void @f2(i8 %a)
+void f2(unsigned char a) {}
+
+// CHECK-LABEL: define void @f3(i16 %a)
+void f3(short a) {}
+
+// CHECK-LABEL: define void @f4(i16 %a)
+void f4(unsigned short a) {}
diff --git a/test/CodeGen/xcore-stringtype.c b/test/CodeGen/xcore-stringtype.c
index 25589d5..4315bc1 100644
--- a/test/CodeGen/xcore-stringtype.c
+++ b/test/CodeGen/xcore-stringtype.c
@@ -5,17 +5,25 @@
 
 // In the tests below, some types are not supported by the ABI (_Complex,
 // variable length arrays) and will thus emit no meta data.
-// The 33 tests that do emit typestrings are gathered into '!xcore.typestrings'
+// The 38 tests that do emit typestrings are gathered into '!xcore.typestrings'
 // Please see 'Tools Development Guide' section 2.16.2 for format details:
 // <https://www.xmos.com/download/public/Tools-Development-Guide%28X9114A%29.pdf>
 
-// CHECK: !xcore.typestrings = !{!1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11,
-// CHECK: !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25,
-// CHECK: !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38}
+// CHECK: !xcore.typestrings = !{
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}},
+// CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}
+// CHECK-NOT: , !{{[0-9]+}}
+// CHECK: }
 
 
 // test BuiltinType
-// CHECK: !1 = metadata !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
+// CHECK: !{{[0-9]+}} = metadata !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
 // CHECK:      i32, i32, i32, i64, i64, i64, float, double, double)*
 // CHECK:      @builtinType, metadata !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl,
 // CHECK:      ul,sl,sll,ull,sll,ft,d,ld)"}
@@ -28,14 +36,14 @@
 
 
 // test FunctionType & Qualifiers
-// CHECK: !2 = metadata !{void ()* @gI, metadata !"f{0}()"}
-// CHECK: !3 = metadata !{void (...)* @eI, metadata !"f{0}()"}
-// CHECK: !4 = metadata !{void ()* @gV, metadata !"f{0}(0)"}
-// CHECK: !5 = metadata !{void ()* @eV, metadata !"f{0}(0)"}
-// CHECK: !6 = metadata !{void (i32, ...)* @gVA, metadata !"f{0}(si,va)"}
-// CHECK: !7 = metadata !{void (i32, ...)* @eVA, metadata !"f{0}(si,va)"}
-// CHECK: !8 = metadata !{i32* (i32*)* @gQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
-// CHECK: !9 = metadata !{i32* (i32*)* @eQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @gI, metadata !"f{0}()"}
+// CHECK: !{{[0-9]+}} = metadata !{void (...)* @eI, metadata !"f{0}()"}
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @gV, metadata !"f{0}(0)"}
+// CHECK: !{{[0-9]+}} = metadata !{void ()* @eV, metadata !"f{0}(0)"}
+// CHECK: !{{[0-9]+}} = metadata !{void (i32, ...)* @gVA, metadata !"f{0}(si,va)"}
+// CHECK: !{{[0-9]+}} = metadata !{void (i32, ...)* @eVA, metadata !"f{0}(si,va)"}
+// CHECK: !{{[0-9]+}} = metadata !{i32* (i32*)* @gQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !{{[0-9]+}} = metadata !{i32* (i32*)* @eQ, metadata !"f{crv:p(cv:si)}(p(cv:si))"}
 extern void eI();
 void gI() {eI();};
 extern void eV(void);
@@ -49,10 +57,10 @@
 
 
 // test PointerType
-// CHECK: !10 = metadata !{i32* (i32*, i32* (i32*)*)*
+// CHECK: !{{[0-9]+}} = metadata !{i32* (i32*, i32* (i32*)*)*
 // CHECK:       @pointerType, metadata !"f{p(si)}(p(si),p(f{p(si)}(p(si))))"}
-// CHECK: !11 = metadata !{i32** @EP, metadata !"p(si)"}
-// CHECK: !12 = metadata !{i32** @GP, metadata !"p(si)"}
+// CHECK: !{{[0-9]+}} = metadata !{i32** @EP, metadata !"p(si)"}
+// CHECK: !{{[0-9]+}} = metadata !{i32** @GP, metadata !"p(si)"}
 extern int* EP;
 int* GP;
 int* pointerType(int *I, int * (*FP)(int *)) {
@@ -60,19 +68,19 @@
 }
 
 // test ArrayType
-// CHECK: !13 = metadata !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)*
+// CHECK: !{{[0-9]+}} = metadata !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)*
 // CHECK:       @arrayType, metadata !"f{p(a(2:si))}(p(si),p(cv:si),p(a(2:si)),
 // CHECK:       p(a(2:si)),p(si))"}
-// CHECK: !14 = metadata !{[0 x i32]* @EA1, metadata !"a(*:cv:si)"}
-// CHECK: !15 = metadata !{[2 x i32]* @EA2, metadata !"a(2:si)"}
-// CHECK: !16 = metadata !{[0 x [2 x i32]]* @EA3, metadata !"a(*:a(2:si))"}
-// CHECK: !17 = metadata !{[3 x [2 x i32]]* @EA4, metadata !"a(3:a(2:si))"}
-// CHECK: !18 = metadata !{[2 x i32]* @GA1, metadata !"a(2:cv:si)"}
-// CHECK: !19 = metadata !{void ([2 x i32]*)* @arrayTypeVariable1,
+// CHECK: !{{[0-9]+}} = metadata !{[0 x i32]* @EA1, metadata !"a(*:cv:si)"}
+// CHECK: !{{[0-9]+}} = metadata !{[2 x i32]* @EA2, metadata !"a(2:si)"}
+// CHECK: !{{[0-9]+}} = metadata !{[0 x [2 x i32]]* @EA3, metadata !"a(*:a(2:si))"}
+// CHECK: !{{[0-9]+}} = metadata !{[3 x [2 x i32]]* @EA4, metadata !"a(3:a(2:si))"}
+// CHECK: !{{[0-9]+}} = metadata !{[2 x i32]* @GA1, metadata !"a(2:cv:si)"}
+// CHECK: !{{[0-9]+}} = metadata !{void ([2 x i32]*)* @arrayTypeVariable1,
 // CHECK:       metadata !"f{0}(p(a(2:si)))"}
-// CHECK: !20 = metadata !{void (void ([2 x i32]*)*)* @arrayTypeVariable2,
+// CHECK: !{{[0-9]+}} = metadata !{void (void ([2 x i32]*)*)* @arrayTypeVariable2,
 // CHECK:       metadata !"f{0}(p(f{0}(p(a(2:si)))))"}
-// CHECK: !21 = metadata !{[3 x [2 x i32]]* @GA2, metadata !"a(3:a(2:si))"}
+// CHECK: !{{[0-9]+}} = metadata !{[3 x [2 x i32]]* @GA2, metadata !"a(3:a(2:si))"}
 extern int GA2[3][2];
 extern const volatile int EA1[];
 extern int EA2[2];
@@ -100,16 +108,16 @@
 
 
 // test StructureType
-// CHECK: !22 = metadata !{void (%struct.S1*)* @structureType1, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%struct.S1*)* @structureType1, metadata
 // CHECK:       !"f{0}(s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}})"}
-// CHECK: !23 = metadata !{void (%struct.S2*)* @structureType2, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%struct.S2*)* @structureType2, metadata
 // CHECK:       !"f{0}(s(S2){m(ps3){p(s(S3){m(s1){s(S1){m(ps2){p(s(S2){})}}}})}})"}
-// CHECK: !24 = metadata !{void (%struct.S3*)* @structureType3, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%struct.S3*)* @structureType3, metadata
 // CHECK:       !"f{0}(s(S3){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){})}})}}}})"}
-// CHECK: !25 = metadata !{void (%struct.S4*)* @structureType4, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%struct.S4*)* @structureType4, metadata
 // CHECK:       !"f{0}(s(S4){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}}}})"}
-// CHECK: !26 = metadata !{%struct.anon* @StructAnon, metadata !"s(){m(A){si}}"}
-// CHECK: !27 = metadata !{i32 (%struct.SB*)* @structureTypeB, metadata
+// CHECK: !{{[0-9]+}} = metadata !{%struct.anon* @StructAnon, metadata !"s(){m(A){si}}"}
+// CHECK: !{{[0-9]+}} = metadata !{i32 (%struct.SB*)* @structureTypeB, metadata
 // CHECK:       !"f{si}(s(SB){m(){b(4:si)},m(){b(2:si)},m(N4){b(4:si)},
 // CHECK:       m(N2){b(2:si)},m(){b(4:ui)},m(){b(4:si)},m(){b(4:c:si)},
 // CHECK:       m(){b(4:c:si)},m(){b(4:cv:si)}})"}
@@ -130,16 +138,16 @@
 
 
 // test UnionType
-// CHECK: !28 = metadata !{void (%union.U1*)* @unionType1, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%union.U1*)* @unionType1, metadata
 // CHECK:       !"f{0}(u(U1){m(pu2){p(u(U2){m(pu3){p(u(U3){m(u1){u(U1){}}})}})}})"}
-// CHECK: !29 = metadata !{void (%union.U2*)* @unionType2, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%union.U2*)* @unionType2, metadata
 // CHECK:       !"f{0}(u(U2){m(pu3){p(u(U3){m(u1){u(U1){m(pu2){p(u(U2){})}}}})}})"}
-// CHECK: !30 = metadata !{void (%union.U3*)* @unionType3, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%union.U3*)* @unionType3, metadata
 // CHECK:       !"f{0}(u(U3){m(u1){u(U1){m(pu2){p(u(U2){m(pu3){p(u(U3){})}})}}}})"}
-// CHECK: !31 = metadata !{void (%union.U4*)* @unionType4, metadata
+// CHECK: !{{[0-9]+}} = metadata !{void (%union.U4*)* @unionType4, metadata
 // CHECK:       !"f{0}(u(U4){m(u1){u(U1){m(pu2){p(u(U2){m(pu3){p(u(U3){m(u1){u(U1){}}})}})}}}})"}
-// CHECK: !32 = metadata !{%union.anon* @UnionAnon, metadata !"u(){m(A){si}}"}
-// CHECK: !33 = metadata !{i32 (%union.UB*)* @unionTypeB, metadata
+// CHECK: !{{[0-9]+}} = metadata !{%union.anon* @UnionAnon, metadata !"u(){m(A){si}}"}
+// CHECK: !{{[0-9]+}} = metadata !{i32 (%union.UB*)* @unionTypeB, metadata
 // CHECK:       !"f{si}(u(UB){m(N2){b(2:si)},m(N4){b(4:si)},m(){b(2:si)},
 // CHECK:       m(){b(4:c:si)},m(){b(4:c:si)},m(){b(4:cv:si)},m(){b(4:si)},
 // CHECK:       m(){b(4:si)},m(){b(4:ui)}})"}
@@ -160,17 +168,17 @@
 
 
 // test EnumType
-// CHECK: !34 = metadata !{i32* @EnumAnon, metadata !"e(){m(EA){3}}"}
-// CHECK: !35 = metadata !{i32 (i32)* @enumType, metadata
+// CHECK: !{{[0-9]+}} = metadata !{i32* @EnumAnon, metadata !"e(){m(EA){3}}"}
+// CHECK: !{{[0-9]+}} = metadata !{i32 (i32)* @enumType, metadata
 // CHECK:       !"f{si}(e(E){m(A){7},m(B){6},m(C){5},m(D){0}})"}
 enum E {D, C=5, B, A};
 enum {EA=3} EnumAnon = EA;
 int enumType(enum E e) {return EnumAnon;}
 
 
-// CHECK: !36 = metadata !{i32 ()* @testReDecl, metadata !"f{si}()"}
-// CHECK: !37 = metadata !{[10 x i32]* @After, metadata !"a(10:si)"}
-// CHECK: !38 = metadata !{[10 x i32]* @Before, metadata !"a(10:si)"}
+// CHECK: !{{[0-9]+}} = metadata !{i32 ()* @testReDecl, metadata !"f{si}()"}
+// CHECK: !{{[0-9]+}} = metadata !{[10 x i32]* @After, metadata !"a(10:si)"}
+// CHECK: !{{[0-9]+}} = metadata !{[10 x i32]* @Before, metadata !"a(10:si)"}
 extern int After[];
 extern int Before[10];
 int testReDecl() {return After[0] + Before[0];}
diff --git a/test/CodeGenCXX/2010-07-23-DeclLoc.cpp b/test/CodeGenCXX/2010-07-23-DeclLoc.cpp
index 4c68902..b1de8f6 100644
--- a/test/CodeGenCXX/2010-07-23-DeclLoc.cpp
+++ b/test/CodeGenCXX/2010-07-23-DeclLoc.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
 // Require the template function declaration refer to the correct filename.
 // First, locate the function decl in metadata, and pluck out the file handle:
-// CHECK: metadata [[filehandle:![0-9]+]], {{[^,]*}}, {{.*extract_dwarf_data_from_header.*extract_dwarf_data_from_header.*extract_dwarf_data_from_header.*[^ ]+", }}
+// CHECK: metadata !"0x2e\00extract_dwarf_data_from_header{{[^"]+}}", metadata [[filehandle:![0-9]+]]
 // Second: Require that filehandle refer to the correct filename:
 // CHECK: [[filehandle]] = {{.*}}decl_should_be_here.hpp"
 typedef long unsigned int __darwin_size_t;
diff --git a/test/CodeGenCXX/Inputs/debug-info-class-limited.cpp b/test/CodeGenCXX/Inputs/debug-info-class-limited.cpp
new file mode 100644
index 0000000..31a0261
--- /dev/null
+++ b/test/CodeGenCXX/Inputs/debug-info-class-limited.cpp
@@ -0,0 +1,49 @@
+
+// CHECK-DAG: [ DW_TAG_structure_type ] [PR16214] [line [[@LINE+1]], {{.*}} [def]
+struct PR16214 {
+  int i;
+};
+
+typedef PR16214 bar;
+
+bar *a;
+bar b;
+
+namespace PR14467 {
+// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
+struct foo {
+};
+
+foo *bar(foo *a) {
+  foo *b = new foo(*a);
+  return b;
+}
+}
+
+namespace test1 {
+// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
+struct foo {
+};
+
+extern int bar(foo *a);
+int baz(foo *a) {
+  return bar(a);
+}
+}
+
+namespace test2 {
+// FIXME: if we were a bit fancier, we could realize that the 'foo' type is only
+// required because of the 'bar' type which is not required at all (or might
+// only be required to be declared)
+// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
+struct foo {
+};
+
+struct bar {
+  foo f;
+};
+
+void func() {
+  foo *f;
+}
+}
diff --git a/test/CodeGenCXX/PR20038.cpp b/test/CodeGenCXX/PR20038.cpp
index 671b8bc..7275e5a 100644
--- a/test/CodeGenCXX/PR20038.cpp
+++ b/test/CodeGenCXX/PR20038.cpp
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 -g -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -g -emit-llvm  %s -o - | FileCheck %s
 
 struct C {
   ~C();
 };
 extern bool b;
-// CHECK: call {{.*}}, !dbg [[DTOR_CALL_LOC:![0-9]*]]
-// CHECK: [[FUN4:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun4]
-// CHECK: [[DTOR_CALL_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN4_BLOCK:.*]], null}
-// CHECK: [[FUN4_BLOCK]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata [[FUN4]],
-void fun4() { b && (C(), 1); }
+// CHECK: call {{.*}}, !dbg [[DTOR_CALL1_LOC:![0-9]*]]
+// CHECK: call {{.*}}, !dbg [[DTOR_CALL2_LOC:![0-9]*]]
+// CHECK: [[FUN1:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun1]
+// CHECK: [[FUN2:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun2]
+// CHECK: [[DTOR_CALL1_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN1_BLOCK:.*]], null}
+// CHECK: [[FUN1_BLOCK]] = metadata !{metadata !"0xb{{[^,]*}}", {{[^,]*}}, metadata [[FUN1]]}
+void fun1() { b && (C(), 1); }
+// CHECK: [[DTOR_CALL2_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN2_BLOCK1:.*]], null}
+// CHECK: [[FUN2_BLOCK1]] = metadata !{metadata !"0xb{{[^,]*}}", {{[^,]*}}, metadata [[FUN2]]}
+bool fun2() { return (C(), b) && 0; }
diff --git a/test/CodeGenCXX/address-space-ref.cpp b/test/CodeGenCXX/address-space-ref.cpp
new file mode 100644
index 0000000..de6bddc
--- /dev/null
+++ b/test/CodeGenCXX/address-space-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// For a reference to a complete type, output the dereferenceable attribute (in
+// any address space).
+
+typedef int a __attribute__((address_space(1)));
+
+a & foo(a &x, a & y) {
+  return x;
+}
+
+// CHECK: define dereferenceable(4) i32 addrspace(1)* @_Z3fooRU3AS1iS0_(i32 addrspace(1)* dereferenceable(4) %x, i32 addrspace(1)* dereferenceable(4) %y)
+
+// For a reference to an incomplete type in an alternate address space, output
+// neither dereferenceable nor nonnull.
+
+class bc;
+typedef bc b __attribute__((address_space(1)));
+
+b & bar(b &x, b & y) {
+  return x;
+}
+
+// CHECK: define %class.bc addrspace(1)* @_Z3barRU3AS12bcS1_(%class.bc addrspace(1)* %x, %class.bc addrspace(1)* %y)
+
+// For a reference to an incomplete type in addrspace(0), output nonnull.
+
+bc & bar2(bc &x, bc & y) {
+  return x;
+}
+
+// CHECK: define nonnull %class.bc* @_Z4bar2R2bcS0_(%class.bc* nonnull %x, %class.bc* nonnull %y)
+
+
diff --git a/test/CodeGenCXX/align-avx-complete-objects.cpp b/test/CodeGenCXX/align-avx-complete-objects.cpp
new file mode 100644
index 0000000..25f4ef1
--- /dev/null
+++ b/test/CodeGenCXX/align-avx-complete-objects.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -x c++ %s -O0 -triple=x86_64-apple-darwin -target-feature +avx2 -fmax-type-align=16 -emit-llvm -o - -Werror | FileCheck %s
+// rdar://16254558
+
+typedef float AVX2Float __attribute__((__vector_size__(32)));
+
+
+volatile float TestAlign(void)
+{
+       volatile AVX2Float *p = new AVX2Float;
+        *p = *p;
+        AVX2Float r = *p;
+        return r[0];
+}
+
+// CHECK: [[R:%.*]] = alloca <8 x float>, align 32
+// CHECK-NEXT:  [[CALL:%.*]] = call noalias i8* @_Znwm(i64 32)
+// CHECK-NEXT:  [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>*
+// CHECK-NEXT:  store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8
+// CHECK-NEXT:  [[ONE:%.*]] = load <8 x float>** [[P]], align 8
+// CHECK-NEXT:  [[TWO:%.*]] = load volatile <8 x float>* [[ONE]], align 16
+// CHECK-NEXT:  [[THREE:%.*]] = load <8 x float>** [[P]], align 8
+// CHECK-NEXT:  store volatile <8 x float> [[TWO]], <8 x float>* [[THREE]], align 16
+// CHECK-NEXT:  [[FOUR:%.*]] = load <8 x float>** [[P]], align 8
+// CHECK-NEXT:  [[FIVE:%.*]] = load volatile <8 x float>* [[FOUR]], align 16
+// CHECK-NEXT:  store <8 x float> [[FIVE]], <8 x float>* [[R]], align 32
+// CHECK-NEXT:  [[SIX:%.*]] = load <8 x float>* [[R]], align 32
+// CHECK-NEXT:  [[VECEXT:%.*]] = extractelement <8 x float> [[SIX]], i32 0
+// CHECK-NEXT:  ret float [[VECEXT]]
+
+typedef float AVX2Float_Explicitly_aligned __attribute__((__vector_size__(32))) __attribute__((aligned (32)));
+
+typedef AVX2Float_Explicitly_aligned AVX2Float_indirect;
+
+typedef AVX2Float_indirect AVX2Float_use_existing_align;
+
+volatile float TestAlign2(void)
+{
+       volatile AVX2Float_use_existing_align *p = new AVX2Float_use_existing_align;
+        *p = *p;
+        AVX2Float_use_existing_align r = *p;
+        return r[0];
+}
+
+// CHECK: [[R:%.*]] = alloca <8 x float>, align 32
+// CHECK-NEXT:  [[CALL:%.*]] = call noalias i8* @_Znwm(i64 32)
+// CHECK-NEXT:  [[ZERO:%.*]] = bitcast i8* [[CALL]] to <8 x float>*
+// CHECK-NEXT:  store <8 x float>* [[ZERO]], <8 x float>** [[P:%.*]], align 8
+// CHECK-NEXT:  [[ONE:%.*]] = load <8 x float>** [[P]], align 8
+// CHECK-NEXT:  [[TWO:%.*]] = load volatile <8 x float>* [[ONE]], align 32
+// CHECK-NEXT:  [[THREE:%.*]] = load <8 x float>** [[P]], align 8
+// CHECK-NEXT:  store volatile <8 x float> [[TWO]], <8 x float>* [[THREE]], align 32
+// CHECK-NEXT:  [[FOUR:%.*]] = load <8 x float>** [[P]], align 8
+// CHECK-NEXT:  [[FIVE:%.*]] = load volatile <8 x float>* [[FOUR]], align 32
+// CHECK-NEXT:  store <8 x float> [[FIVE]], <8 x float>* [[R]], align 32
+// CHECK-NEXT:  [[SIX:%.*]] = load <8 x float>* [[R]], align 32
+// CHECK-NEXT:  [[VECEXT:%.*]] = extractelement <8 x float> [[SIX]], i32 0
+// CHECK-NEXT:  ret float [[VECEXT]]
diff --git a/test/CodeGenCXX/atomicinit.cpp b/test/CodeGenCXX/atomicinit.cpp
index ee2e9e4..91b990b 100644
--- a/test/CodeGenCXX/atomicinit.cpp
+++ b/test/CodeGenCXX/atomicinit.cpp
@@ -1,4 +1,10 @@
-// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 -std=c++11 | FileCheck %s
+
+// CHECK-DAG: @_ZN7PR180978constant1aE = global { i16, i8 } { i16 1, i8 6 }, align 4
+// CHECK-DAG: @_ZN7PR180978constant1bE = global { i16, i8 } { i16 2, i8 6 }, align 4
+// CHECK-DAG: @_ZN7PR180978constant1cE = global { i16, i8 } { i16 3, i8 6 }, align 4
+// CHECK-DAG: @_ZN7PR180978constant1yE = global { { i16, i8 }, i32 } { { i16, i8 } { i16 4, i8 6 }, i32 5 }, align 4
+
 struct A {
   _Atomic(int) i;
   A(int j);
@@ -46,3 +52,51 @@
 // CHECK-NEXT: ret void
 AtomicBoolMember::AtomicBoolMember(bool b) : ab(b) { }
 
+namespace PR18097 {
+  namespace dynamic {
+    struct X {
+      X(int);
+      short n;
+      char c;
+    };
+
+    // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
+    // CHECK: call void @_ZN7PR180977dynamic1XC1Ei({{.*}}* @_ZN7PR180977dynamic1aE, i32 1)
+    _Atomic(X) a = X(1);
+
+    // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
+    // CHECK: call void @_ZN7PR180977dynamic1XC1Ei({{.*}}* @_ZN7PR180977dynamic1bE, i32 2)
+    _Atomic(X) b(X(2));
+
+    // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
+    // CHECK: call void @_ZN7PR180977dynamic1XC1Ei({{.*}}* @_ZN7PR180977dynamic1cE, i32 3)
+    _Atomic(X) c{X(3)};
+
+    struct Y {
+      _Atomic(X) a;
+      _Atomic(int) b;
+    };
+    // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
+    // CHECK: call void @_ZN7PR180977dynamic1XC1Ei({{.*}}* getelementptr inbounds ({{.*}}* @_ZN7PR180977dynamic1yE, i32 0, i32 0), i32 4)
+    // CHECK: store i32 5, i32* getelementptr inbounds ({{.*}}* @_ZN7PR180977dynamic1yE, i32 0, i32 1)
+    Y y = { X(4), 5 };
+  }
+
+  // CHECKs at top of file.
+  namespace constant {
+    struct X {
+      constexpr X(int n) : n(n) {}
+      short n;
+      char c = 6;
+    };
+    _Atomic(X) a = X(1);
+    _Atomic(X) b(X(2));
+    _Atomic(X) c{X(3)};
+
+    struct Y {
+      _Atomic(X) a;
+      _Atomic(int) b;
+    };
+    Y y = { X(4), 5 };
+  }
+}
diff --git a/test/CodeGenCXX/attr-used.cpp b/test/CodeGenCXX/attr-used.cpp
index 8617346..d2a73f7 100644
--- a/test/CodeGenCXX/attr-used.cpp
+++ b/test/CodeGenCXX/attr-used.cpp
@@ -2,16 +2,16 @@
 
 // <rdar://problem/8684363>: clang++ not respecting __attribute__((used)) on destructors
 struct X0 {
-  // CHECK: define linkonce_odr {{.*}} @_ZN2X0C1Ev
+  // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X0C1Ev
   __attribute__((used)) X0() {}
-  // CHECK: define linkonce_odr {{.*}} @_ZN2X0D1Ev
+  // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X0D1Ev
   __attribute__((used)) ~X0() {}
 };
 
 // PR19743: not emitting __attribute__((used)) inline methods in nested classes.
 struct X1 {
   struct Nested {
-    // CHECK: define linkonce_odr {{.*}} @_ZN2X16Nested1fEv
+    // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X16Nested1fEv
     void __attribute__((used)) f() {}
   };
 };
@@ -22,6 +22,6 @@
   void __attribute__((used)) bar() { foo(); }
   void foo() { }
 
-  // CHECK: define linkonce_odr {{.*}} @_ZN2X23barEv
-  // CHECK: define linkonce_odr {{.*}} @_ZN2X23fooEv
+  // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X23barEv
+  // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X23fooEv
 };
diff --git a/test/CodeGenCXX/blocks-cxx11.cpp b/test/CodeGenCXX/blocks-cxx11.cpp
index 9df67f7..10d1c65 100644
--- a/test/CodeGenCXX/blocks-cxx11.cpp
+++ b/test/CodeGenCXX/blocks-cxx11.cpp
@@ -106,7 +106,7 @@
   // CHECK:      [[TO_DESTROY:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
   // CHECK:      [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
   // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[LAMBDA_T]]* [[THIS]], i32 0, i32 0
-  // CHECK-NEXT: call void @_ZN20test_block_in_lambda1AC1ERKS0_({{.*}}* [[T0]], {{.*}}* nonnull [[T1]])
+  // CHECK-NEXT: call void @_ZN20test_block_in_lambda1AC1ERKS0_({{.*}}* [[T0]], {{.*}}* dereferenceable({{[0-9]+}}) [[T1]])
   // CHECK-NEXT: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
   // CHECK-NEXT: call void @_ZN20test_block_in_lambda9takeBlockEU13block_pointerFvvE(void ()* [[T0]])
   // CHECK-NEXT: call void @_ZN20test_block_in_lambda1AD1Ev({{.*}}* [[TO_DESTROY]])
diff --git a/test/CodeGenCXX/blocks.cpp b/test/CodeGenCXX/blocks.cpp
index f1d829a..6b11083 100644
--- a/test/CodeGenCXX/blocks.cpp
+++ b/test/CodeGenCXX/blocks.cpp
@@ -164,7 +164,7 @@
 
   // CHECK-NOT:  br
   // CHECK:      [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
-  // CHECK-NEXT: call void @_ZN5test51AC1ERKS0_([[A]]* [[CAPTURE]], [[A]]* nonnull [[X]])
+  // CHECK-NEXT: call void @_ZN5test51AC1ERKS0_([[A]]* [[CAPTURE]], [[A]]* dereferenceable({{[0-9]+}}) [[X]])
   // CHECK-NEXT: store i1 true, i1* [[CLEANUP_ACTIVE]]
   // CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
   // CHECK-NEXT: br label
diff --git a/test/CodeGenCXX/catch-undef-behavior.cpp b/test/CodeGenCXX/catch-undef-behavior.cpp
index f318c7c..aa65438 100644
--- a/test/CodeGenCXX/catch-undef-behavior.cpp
+++ b/test/CodeGenCXX/catch-undef-behavior.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,array-bounds,function -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fsanitize=vptr,address -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang_cc1 -std=c++11 -fsanitize=vptr -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=DOWNCAST-NULL
 
 struct S {
   double d;
@@ -6,9 +8,15 @@
   virtual int f();
 };
 
+// Check that type descriptor global is not modified by ASan.
+// CHECK-ASAN: [[TYPE_DESCR:@[0-9]+]] = private unnamed_addr constant { i16, i16, [4 x i8] } { i16 -1, i16 0, [4 x i8] c"'S'\00" }
+
+// Check that type mismatch handler is not modified by ASan.
+// CHECK-ASAN: private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 }, { i16, i16, [4 x i8] }*, i8*, i8 } { {{.*}}, { i16, i16, [4 x i8] }* [[TYPE_DESCR]], {{.*}} }
+
 struct T : S {};
 
-// CHECK: @_Z17reference_binding
+// CHECK-LABEL: @_Z17reference_binding
 void reference_binding(int *p, S *q) {
   // C++ core issue 453: If an lvalue to which a reference is directly bound
   // designates neither an existing object or function of an appropriate type,
@@ -30,7 +38,8 @@
   S &r2 = *q;
 }
 
-// CHECK: @_Z13member_access
+// CHECK-LABEL: @_Z13member_access
+// CHECK-ASAN-LABEL: @_Z13member_access
 void member_access(S *p) {
   // (1a) Check 'p' is appropriately sized and aligned for member access.
 
@@ -117,7 +126,7 @@
   k = p->f();
 }
 
-// CHECK: @_Z12lsh_overflow
+// CHECK-LABEL: @_Z12lsh_overflow
 int lsh_overflow(int a, int b) {
   // CHECK: %[[INBOUNDS:.*]] = icmp ule i32 %[[RHS:.*]], 31
   // CHECK-NEXT: br i1 %[[INBOUNDS]]
@@ -142,13 +151,13 @@
   return a << b;
 }
 
-// CHECK: @_Z9no_return
+// CHECK-LABEL: @_Z9no_return
 int no_return() {
   // CHECK:      call void @__ubsan_handle_missing_return(i8* bitcast ({{.*}}* @{{.*}} to i8*)) [[NR_NUW:#[0-9]+]]
   // CHECK-NEXT: unreachable
 }
 
-// CHECK: @_Z9sour_bool
+// CHECK-LABEL: @_Z9sour_bool
 bool sour_bool(bool *p) {
   // CHECK: %[[OK:.*]] = icmp ule i8 {{.*}}, 1
   // CHECK: br i1 %[[OK]]
@@ -160,7 +169,7 @@
 enum E2 { e2a = -1, e2b = 64 } e2;
 enum E3 { e3a = (1u << 31) - 1 } e3;
 
-// CHECK: @_Z14bad_enum_value
+// CHECK-LABEL: @_Z14bad_enum_value
 int bad_enum_value() {
   // CHECK: %[[E1:.*]] = icmp ule i32 {{.*}}, 127
   // CHECK: br i1 %[[E1]]
@@ -181,11 +190,16 @@
   return a + b + c;
 }
 
-// CHECK: @_Z20bad_downcast_pointer
+// CHECK-LABEL: @_Z20bad_downcast_pointer
+// DOWNCAST-NULL-LABEL: @_Z20bad_downcast_pointer
 void bad_downcast_pointer(S *p) {
   // CHECK: %[[NONNULL:.*]] = icmp ne {{.*}}, null
   // CHECK: br i1 %[[NONNULL]],
 
+  // A null poiner access is guarded without -fsanitize=null.
+  // DOWNCAST-NULL: %[[NONNULL:.*]] = icmp ne {{.*}}, null
+  // DOWNCAST-NULL: br i1 %[[NONNULL]],
+
   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(
   // CHECK: %[[E1:.*]] = icmp uge i64 %[[SIZE]], 24
   // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7
@@ -203,15 +217,18 @@
   (void) static_cast<T*>(p);
 }
 
-// CHECK: @_Z22bad_downcast_reference
+// CHECK-LABEL: @_Z22bad_downcast_reference
 void bad_downcast_reference(S &p) {
   // CHECK: %[[E1:.*]] = icmp ne {{.*}}, null
   // CHECK-NOT: br i1
+
   // CHECK: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(
   // CHECK: %[[E2:.*]] = icmp uge i64 %[[SIZE]], 24
-  // CHECK: %[[E12:.*]] = and i1 %[[E1]], %[[E2]]
+
   // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7
   // CHECK: %[[E3:.*]] = icmp eq i64 %[[MISALIGN]], 0
+
+  // CHECK: %[[E12:.*]] = and i1 %[[E1]], %[[E2]]
   // CHECK: %[[E123:.*]] = and i1 %[[E12]], %[[E3]]
   // CHECK: br i1 %[[E123]],
 
@@ -225,7 +242,7 @@
   (void) static_cast<T&>(p);
 }
 
-// CHECK: @_Z11array_index
+// CHECK-LABEL: @_Z11array_index
 int array_index(const int (&a)[4], int n) {
   // CHECK: %[[K1_OK:.*]] = icmp ult i64 %{{.*}}, 4
   // CHECK: br i1 %[[K1_OK]]
@@ -250,7 +267,7 @@
   return k1 + *r1 + k2;
 }
 
-// CHECK: @_Z17multi_array_index
+// CHECK-LABEL: @_Z17multi_array_index
 int multi_array_index(int n, int m) {
   int arr[4][6];
 
@@ -264,7 +281,7 @@
   return arr[n][m];
 }
 
-// CHECK: @_Z11array_arith
+// CHECK-LABEL: @_Z11array_arith
 int array_arith(const int (&a)[4], int n) {
   // CHECK: %[[K1_OK:.*]] = icmp ule i64 %{{.*}}, 4
   // CHECK: br i1 %[[K1_OK]]
@@ -283,7 +300,7 @@
   int a1[5];
   int a2[1];
 };
-// CHECK: @_Z18struct_array_index
+// CHECK-LABEL: @_Z18struct_array_index
 int struct_array_index(ArrayMembers *p, int n) {
   // CHECK: %[[IDX_OK:.*]] = icmp ult i64 %{{.*}}, 5
   // CHECK: br i1 %[[IDX_OK]]
@@ -291,21 +308,21 @@
   return p->a1[n];
 }
 
-// CHECK: @_Z16flex_array_index
+// CHECK-LABEL: @_Z16flex_array_index
 int flex_array_index(ArrayMembers *p, int n) {
   // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
   return p->a2[n];
 }
 
 extern int incomplete[];
-// CHECK: @_Z22incomplete_array_index
+// CHECK-LABEL: @_Z22incomplete_array_index
 int incomplete_array_index(int n) {
   // CHECK-NOT: call void @__ubsan_handle_out_of_bounds(
   return incomplete[n];
 }
 
 typedef __attribute__((ext_vector_type(4))) int V4I;
-// CHECK: @_Z12vector_index
+// CHECK-LABEL: @_Z12vector_index
 int vector_index(V4I v, int n) {
   // CHECK: %[[IDX_OK:.*]] = icmp ult i64 %{{.*}}, 4
   // CHECK: br i1 %[[IDX_OK]]
@@ -313,7 +330,7 @@
   return v[n];
 }
 
-// CHECK: @_Z12string_index
+// CHECK-LABEL: @_Z12string_index
 char string_index(int n) {
   // CHECK: %[[IDX_OK:.*]] = icmp ult i64 %{{.*}}, 6
   // CHECK: br i1 %[[IDX_OK]]
@@ -357,7 +374,7 @@
   // CHECK-NEXT: br i1 [[AND]]
 }
 
-// CHECK-LABEL: define void @_Z18downcast_referenceR1B(%class.B* nonnull %b)
+// CHECK-LABEL: define void @_Z18downcast_referenceR1B(%class.B* dereferenceable({{[0-9]+}}) %b)
 void downcast_reference(B &b) {
   (void) static_cast<C&>(b);
   // Alignment check from EmitTypeCheck(TCK_DowncastReference, ...)
@@ -368,7 +385,7 @@
   // CHECK-NEXT: [[MASKED:%[0-9]*]] = and i64 [[C_INT]], 15
   // CHECK-NEXT: [[TEST:%[0-9]*]] = icmp eq i64 [[MASKED]], 0
   // AND the alignment test with the objectsize test.
-  // CHECK-NEXT: [[AND:%[0-9]*]] = and i1 {{.*}}, [[TEST]]
+  // CHECK:      [[AND:%[0-9]*]] = and i1 {{.*}}, [[TEST]]
   // CHECK-NEXT: br i1 [[AND]]
 }
 
@@ -390,6 +407,40 @@
   p(42);
 }
 
+namespace UpcastPointerTest {
+struct S {};
+struct T : S { double d; };
+struct V : virtual S {};
+
+// CHECK-LABEL: upcast_pointer
+S* upcast_pointer(T* t) {
+  // Check for null pointer
+  // CHECK: %[[NONNULL:.*]] = icmp ne {{.*}}, null
+  // CHECK: br i1 %[[NONNULL]]
+
+  // Check alignment
+  // CHECK: %[[MISALIGN:.*]] = and i64 %{{.*}}, 7
+  // CHECK: icmp eq i64 %[[MISALIGN]], 0
+
+  // CHECK: call void @__ubsan_handle_type_mismatch
+  return t;
+}
+
+V getV();
+
+// CHECK-LABEL: upcast_to_vbase
+void upcast_to_vbase() {
+  // No need to check for null here, as we have a temporary here.
+
+  // CHECK-NOT: br i1
+
+  // CHECK: call i64 @llvm.objectsize
+  // CHECK: call void @__ubsan_handle_type_mismatch
+  // CHECK: call void @__ubsan_handle_dynamic_type_cache_miss
+  const S& s = getV();
+}
+}
+
 namespace CopyValueRepresentation {
   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S3aSERKS0_
   // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value
diff --git a/test/CodeGenCXX/class-layout.cpp b/test/CodeGenCXX/class-layout.cpp
index d7d84a8..610dbc5 100644
--- a/test/CodeGenCXX/class-layout.cpp
+++ b/test/CodeGenCXX/class-layout.cpp
@@ -14,7 +14,7 @@
 
 namespace Test3 {
   // C should have a vtable pointer.
-  // CHECK: %"struct.Test3::A" = type { i32 (...)**, i32 }
+  // CHECK: %"struct.Test3::A" = type <{ i32 (...)**, i32, [4 x i8] }>
   struct A { virtual void f(); int a; } *a;
 }
 
diff --git a/test/CodeGenCXX/conditional-gnu-ext.cpp b/test/CodeGenCXX/conditional-gnu-ext.cpp
index dd93467..3a61a63 100644
--- a/test/CodeGenCXX/conditional-gnu-ext.cpp
+++ b/test/CodeGenCXX/conditional-gnu-ext.cpp
@@ -83,7 +83,7 @@
     // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]]
     // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[T0]])
     // CHECK-NEXT: br i1 [[BOOL]]
-    // CHECK:      call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* nonnull [[T0]])
+    // CHECK:      call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* dereferenceable({{[0-9]+}}) [[T0]])
     // CHECK-NEXT: br label
     // CHECK:      call void @_ZN5test31BC1Ev([[B]]* [[RESULT]])
     // CHECK-NEXT: br label
@@ -97,7 +97,7 @@
     // CHECK-NEXT: call  void @_ZN5test312test1_helperEv([[B]]* sret [[TEMP]])
     // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]])
     // CHECK-NEXT: br i1 [[BOOL]]
-    // CHECK:      call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* nonnull [[TEMP]])
+    // CHECK:      call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* dereferenceable({{[0-9]+}}) [[TEMP]])
     // CHECK-NEXT: br label
     // CHECK:      call void @_ZN5test31BC1Ev([[B]]* [[RESULT]])
     // CHECK-NEXT: br label
diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp
index d99b184..f671e0a 100644
--- a/test/CodeGenCXX/const-init-cxx11.cpp
+++ b/test/CodeGenCXX/const-init-cxx11.cpp
@@ -532,10 +532,10 @@
     // CHECK: call void @_ZN13InitFromConst7consumeIdEEvT_(double 4.300000e+00)
     consume(d);
 
-    // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* nonnull @_ZN13InitFromConstL1sE)
+    // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* dereferenceable({{[0-9]+}}) @_ZN13InitFromConstL1sE)
     consume<const S&>(s);
 
-    // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* nonnull @_ZN13InitFromConstL1sE)
+    // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* dereferenceable({{[0-9]+}}) @_ZN13InitFromConstL1sE)
     consume<const S&>(r);
 
     // CHECK: call void @_ZN13InitFromConst7consumeIPKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
diff --git a/test/CodeGenCXX/constructor-destructor-return-this.cpp b/test/CodeGenCXX/constructor-destructor-return-this.cpp
index ce6ddd2..dcd20fe 100644
--- a/test/CodeGenCXX/constructor-destructor-return-this.cpp
+++ b/test/CodeGenCXX/constructor-destructor-return-this.cpp
@@ -10,7 +10,7 @@
 class A {
 public:
   A();
-  ~A();
+  virtual ~A();
 
 private:
   int x_;
@@ -19,7 +19,7 @@
 class B : public A {
 public:
   B(int *i);
-  ~B();
+  virtual ~B();
 
 private:
   int *i_;
@@ -44,7 +44,7 @@
 // CHECKIOS5-LABEL: define %class.B* @_ZN1BD1Ev(%class.B* %this)
 
 // CHECKMS-LABEL: define x86_thiscallcc %class.B* @"\01??0B@@QAE@PAH@Z"(%class.B* returned %this, i32* %i)
-// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1B@@QAE@XZ"(%class.B* %this)
+// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1B@@UAE@XZ"(%class.B* %this)
 
 class C : public A, public B {
 public:
@@ -61,19 +61,25 @@
 // CHECKGEN-LABEL: define void @_ZN1CC1EPiPc(%class.C* %this, i32* %i, i8* %c)
 // CHECKGEN-LABEL: define void @_ZN1CD2Ev(%class.C* %this)
 // CHECKGEN-LABEL: define void @_ZN1CD1Ev(%class.C* %this)
+// CHECKGEN-LABEL: define void @_ZThn8_N1CD1Ev(%class.C* %this)
 // CHECKGEN-LABEL: define void @_ZN1CD0Ev(%class.C* %this)
+// CHECKGEN-LABEL: define void @_ZThn8_N1CD0Ev(%class.C* %this)
 
 // CHECKARM-LABEL: define %class.C* @_ZN1CC2EPiPc(%class.C* returned %this, i32* %i, i8* %c)
 // CHECKARM-LABEL: define %class.C* @_ZN1CC1EPiPc(%class.C* returned %this, i32* %i, i8* %c)
 // CHECKARM-LABEL: define %class.C* @_ZN1CD2Ev(%class.C* returned %this)
 // CHECKARM-LABEL: define %class.C* @_ZN1CD1Ev(%class.C* returned %this)
+// CHECKARM-LABEL: define %class.C* @_ZThn8_N1CD1Ev(%class.C* %this)
 // CHECKARM-LABEL: define void @_ZN1CD0Ev(%class.C* %this)
+// CHECKARM-LABEL: define void @_ZThn8_N1CD0Ev(%class.C* %this)
 
 // CHECKIOS5-LABEL: define %class.C* @_ZN1CC2EPiPc(%class.C* %this, i32* %i, i8* %c)
 // CHECKIOS5-LABEL: define %class.C* @_ZN1CC1EPiPc(%class.C* %this, i32* %i, i8* %c)
 // CHECKIOS5-LABEL: define %class.C* @_ZN1CD2Ev(%class.C* %this)
 // CHECKIOS5-LABEL: define %class.C* @_ZN1CD1Ev(%class.C* %this)
+// CHECKIOS5-LABEL: define %class.C* @_ZThn8_N1CD1Ev(%class.C* %this)
 // CHECKIOS5-LABEL: define void @_ZN1CD0Ev(%class.C* %this)
+// CHECKIOS5-LABEL: define void @_ZThn8_N1CD0Ev(%class.C* %this)
 
 // CHECKMS-LABEL: define x86_thiscallcc %class.C* @"\01??0C@@QAE@PAHPAD@Z"(%class.C* returned %this, i32* %i, i8* %c)
 // CHECKMS-LABEL: define x86_thiscallcc void @"\01??1C@@UAE@XZ"(%class.C* %this)
@@ -103,7 +109,7 @@
 // CHECKIOS5-LABEL: define %class.D* @_ZN1DD1Ev(%class.D* %this)
 
 // CHECKMS-LABEL: define x86_thiscallcc %class.D* @"\01??0D@@QAE@XZ"(%class.D* returned %this, i32 %is_most_derived)
-// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1D@@QAE@XZ"(%class.D* %this)
+// CHECKMS-LABEL: define x86_thiscallcc void @"\01??1D@@UAE@XZ"(%class.D*)
 
 class E {
 public:
diff --git a/test/CodeGenCXX/constructor-direct-call.cpp b/test/CodeGenCXX/constructor-direct-call.cpp
index 0cbf0f4..9567d09 100644
--- a/test/CodeGenCXX/constructor-direct-call.cpp
+++ b/test/CodeGenCXX/constructor-direct-call.cpp
@@ -54,6 +54,6 @@
   // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1Ev(%class.Test3* %var)
   var.Test3::Test3();
 
-  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* nonnull %var2)
+  // CHECK-NEXT: call x86_thiscallcc void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* dereferenceable({{[0-9]+}}) %var2)
   var.Test3::Test3(var2);
 }
diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp
index 51d1cbc..a8f483e 100644
--- a/test/CodeGenCXX/constructor-init.cpp
+++ b/test/CodeGenCXX/constructor-init.cpp
@@ -163,7 +163,7 @@
 
 // Make sure that the instantiated constructor initializes start and
 // end properly.
-// CHECK-LABEL: define linkonce_odr void @_ZN1XIiEC2ERKS0_(%struct.X* %this, %struct.X* nonnull %other) unnamed_addr
+// CHECK-LABEL: define linkonce_odr void @_ZN1XIiEC2ERKS0_(%struct.X* %this, %struct.X* dereferenceable({{[0-9]+}}) %other) unnamed_addr
 // CHECK: {{store.*null}}
 // CHECK: {{store.*null}}
 // CHECK: ret
diff --git a/test/CodeGenCXX/convert-to-fptr.cpp b/test/CodeGenCXX/convert-to-fptr.cpp
index 78a76bb..c3be962 100644
--- a/test/CodeGenCXX/convert-to-fptr.cpp
+++ b/test/CodeGenCXX/convert-to-fptr.cpp
@@ -39,4 +39,4 @@
 }
 
 // CHECK: call i32 (i32)* (%struct.A*)* @_ZN1AcvPFiiEEv
-// CHECK: call nonnull i32 (i32)* (%struct.B*)* @_ZN1BcvRFiiEEv
+// CHECK: call i32 (i32)* (%struct.B*)* @_ZN1BcvRFiiEEv
diff --git a/test/CodeGenCXX/copy-assign-synthesis-1.cpp b/test/CodeGenCXX/copy-assign-synthesis-1.cpp
index 3f0833b..5813d9c 100644
--- a/test/CodeGenCXX/copy-assign-synthesis-1.cpp
+++ b/test/CodeGenCXX/copy-assign-synthesis-1.cpp
@@ -92,4 +92,4 @@
   dstY.pr();
 }
 
-// CHECK: define linkonce_odr nonnull %struct.X* @_ZN1XaSERKS_
+// CHECK: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.X* @_ZN1XaSERKS_
diff --git a/test/CodeGenCXX/copy-constructor-elim-2.cpp b/test/CodeGenCXX/copy-constructor-elim-2.cpp
index 0f6ee1e..c263b7e 100644
--- a/test/CodeGenCXX/copy-constructor-elim-2.cpp
+++ b/test/CodeGenCXX/copy-constructor-elim-2.cpp
@@ -21,7 +21,7 @@
     Derived(const Other &O);
   };
 
-  // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* returned %this, %"struct.no_elide_base::Other"* nonnull %O) unnamed_addr
+  // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* returned %this, %"struct.no_elide_base::Other"* dereferenceable({{[0-9]+}}) %O) unnamed_addr
   Derived::Derived(const Other &O) 
     // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv
     // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_
diff --git a/test/CodeGenCXX/copy-constructor-synthesis-2.cpp b/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
index aeb920d..4bb0fee 100644
--- a/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
+++ b/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
@@ -3,5 +3,5 @@
 struct A { virtual void a(); };
 A x(A& y) { return y; }
 
-// CHECK: define linkonce_odr {{.*}} @_ZN1AC1ERKS_(%struct.A* {{.*}}%this, %struct.A* nonnull) unnamed_addr
+// CHECK: define linkonce_odr {{.*}} @_ZN1AC1ERKS_(%struct.A* {{.*}}%this, %struct.A* dereferenceable({{[0-9]+}})) unnamed_addr
 // CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2)
diff --git a/test/CodeGenCXX/copy-constructor-synthesis.cpp b/test/CodeGenCXX/copy-constructor-synthesis.cpp
index bb06bc1..47f8e13 100644
--- a/test/CodeGenCXX/copy-constructor-synthesis.cpp
+++ b/test/CodeGenCXX/copy-constructor-synthesis.cpp
@@ -21,7 +21,7 @@
 };
 
 
-// CHECK-LABEL: define linkonce_odr void @_ZN1XC1ERKS_(%struct.X* %this, %struct.X* nonnull) unnamed_addr
+// CHECK-LABEL: define linkonce_odr void @_ZN1XC1ERKS_(%struct.X* %this, %struct.X* dereferenceable({{[0-9]+}})) unnamed_addr
 struct X  : M, N, P { // ...
   X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
         au_i1(1234), au1_4("MASKED") {}
@@ -136,7 +136,7 @@
   B b2 = b1;
 }
 
-// CHECK:    define linkonce_odr nonnull [[A:%.*]]* @_ZN12rdar138169401AaSERKS0_(
+// CHECK:    define linkonce_odr dereferenceable({{[0-9]+}}) [[A:%.*]]* @_ZN12rdar138169401AaSERKS0_(
 // CHECK:      [[THIS:%.*]] = load [[A]]**
 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A]]* [[THIS]], i32 0, i32 1
 // CHECK-NEXT: [[OTHER:%.*]] = load [[A]]**
@@ -158,7 +158,7 @@
 // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T4]], i8* [[T5]], i64 8, i32 8, i1 false)
 // CHECK-NEXT: ret void
 
-// CHECK-LABEL: define linkonce_odr void @_ZN6PR66281BC2ERKS0_(%"struct.PR6628::B"* %this, %"struct.PR6628::B"* nonnull) unnamed_addr
+// CHECK-LABEL: define linkonce_odr void @_ZN6PR66281BC2ERKS0_(%"struct.PR6628::B"* %this, %"struct.PR6628::B"* dereferenceable({{[0-9]+}})) unnamed_addr
 // CHECK: call void @_ZN6PR66281TC1Ev
 // CHECK: call void @_ZN6PR66281TC1Ev
 // CHECK: call void @_ZN6PR66281AC2ERKS0_RKNS_1TES5_
diff --git a/test/CodeGenCXX/coverage.cpp b/test/CodeGenCXX/coverage.cpp
index 88f7409..16703bd 100644
--- a/test/CodeGenCXX/coverage.cpp
+++ b/test/CodeGenCXX/coverage.cpp
@@ -3,5 +3,5 @@
 extern "C" void test_name1() {}
 void test_name2() {}
 
-// CHECK: metadata !"test_name1", metadata !"test_name1", metadata !"",{{.*}}DW_TAG_subprogram
-// CHECK: metadata !"test_name2", metadata !"test_name2", metadata !"_Z10test_name2v",{{.*}}DW_TAG_subprogram
+// CHECK: metadata !"0x2e\00test_name1\00test_name1\00\00{{[^,]+}}", {{.*}} DW_TAG_subprogram
+// CHECK: metadata !"0x2e\00test_name2\00test_name2\00_Z10test_name2v\00{{[^,]+}}", {{.*}} DW_TAG_subprogram
diff --git a/test/CodeGenCXX/ctor-dtor-alias.cpp b/test/CodeGenCXX/ctor-dtor-alias.cpp
index d869a2b..1ae9ead 100644
--- a/test/CodeGenCXX/ctor-dtor-alias.cpp
+++ b/test/CodeGenCXX/ctor-dtor-alias.cpp
@@ -1,20 +1,33 @@
-// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
 // RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
 
-// RUN: %clang_cc1 -triple x86_64--netbsd -emit-llvm \
-// RUN: -mconstructor-aliases -O2 %s -o - | FileCheck --check-prefix=CHECK-RAUW %s
+// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns > %t
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t %s
+
+// RUN: %clang_cc1 %s -triple i686-pc-windows-gnu -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck --check-prefix=COFF %s
 
 namespace test1 {
-// test that we don't produce an alias when the destructor is weak_odr. The
-// reason to avoid it that another TU might have no explicit template
-// instantiation definition or declaration, causing it to to output only
-// one of the destructors as linkonce_odr, producing a different comdat.
+// Test that we produce the apropriate comdats when creating aliases to
+// weak_odr constructors and destructors.
 
-// CHECK-DAG: define weak_odr void @_ZN5test16foobarIvEC2Ev
-// CHECK-DAG: define weak_odr void @_ZN5test16foobarIvEC1Ev
+// CHECK1: @_ZN5test16foobarIvEC1Ev = weak_odr alias void {{.*}} @_ZN5test16foobarIvEC2Ev
+// CHECK1: @_ZN5test16foobarIvED1Ev = weak_odr alias void (%"struct.test1::foobar"*)* @_ZN5test16foobarIvED2Ev
+// CHECK1: define weak_odr void @_ZN5test16foobarIvEC2Ev({{.*}} comdat $_ZN5test16foobarIvEC5Ev
+// CHECK1: define weak_odr void @_ZN5test16foobarIvED2Ev({{.*}} comdat $_ZN5test16foobarIvED5Ev
+// CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} comdat $_ZN5test16foobarIvED5Ev
+// CHECK1-NOT: comdat
 
-template <typename T> struct foobar {
+// COFF doesn't support comdats with arbitrary names (C5/D5).
+// COFF-NOT: comdat
+
+template <typename T>
+struct foobar {
   foobar() {}
+  virtual ~foobar() {}
 };
 
 template struct foobar<void>;
@@ -24,8 +37,9 @@
 // test that when the destrucor is linkonce_odr we just replace every use of
 // C1 with C2.
 
-// CHECK-DAG: define linkonce_odr void @_ZN5test26foobarIvEC2Ev(
-// CHECK-DAG: call void @_ZN5test26foobarIvEC2Ev
+// CHECK1: define internal void @__cxx_global_var_init()
+// CHECK1: call void @_ZN5test26foobarIvEC2Ev
+// CHECK1: define linkonce_odr void @_ZN5test26foobarIvEC2Ev(
 void g();
 template <typename T> struct foobar {
   foobar() { g(); }
@@ -37,8 +51,9 @@
 // test that instead of an internal alias we just use the other destructor
 // directly.
 
-// CHECK-DAG: define internal void @_ZN5test312_GLOBAL__N_11AD2Ev(
-// CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test312_GLOBAL__N_11AD2Ev
+// CHECK1: define internal void @__cxx_global_var_init1()
+// CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test312_GLOBAL__N_11AD2Ev
+// CHECK1: define internal void @_ZN5test312_GLOBAL__N_11AD2Ev(
 namespace {
 struct A {
   ~A() {}
@@ -55,13 +70,15 @@
   // guarantee that they will be present in every TU. Instead, we just call
   // A's destructor directly.
 
-  // CHECK-DAG: define linkonce_odr void @_ZN5test41AD2Ev(
-  // CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
+  // CHECK1: define internal void @__cxx_global_var_init2()
+  // CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
+  // CHECK1: define linkonce_odr void @_ZN5test41AD2Ev(
 
   // test that we don't do this optimization at -O0 so that the debugger can
   // see both destructors.
-  // NOOPT-DAG: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
-  // NOOPT-DAG: define linkonce_odr void @_ZN5test41BD2Ev
+  // NOOPT: define internal void @__cxx_global_var_init2()
+  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
+  // NOOPT: define linkonce_odr void @_ZN5test41BD2Ev
   struct A {
     virtual ~A() {}
   };
@@ -74,8 +91,9 @@
 namespace test5 {
   // similar to test4, but with an internal B.
 
-  // CHECK-DAG: define linkonce_odr void @_ZN5test51AD2Ev(
-  // CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test51AD2Ev
+  // CHECK2: define internal void @__cxx_global_var_init3()
+  // CHECK2: call i32 @__cxa_atexit{{.*}}_ZN5test51AD2Ev
+  // CHECK2: define linkonce_odr void @_ZN5test51AD2Ev(
   struct A {
     virtual ~A() {}
   };
@@ -99,14 +117,15 @@
   };
   }
   B X;
-  // CHECK-DAG: call i32 @__cxa_atexit({{.*}}@_ZN5test61AD2Ev
+  // CHECK3: define internal void @__cxx_global_var_init4()
+  // CHECK3: call i32 @__cxa_atexit({{.*}}@_ZN5test61AD2Ev
 }
 
 namespace test7 {
   // Test that we don't produce an alias from ~B to ~A<int> (or crash figuring
   // out if we should).
   // pr17875.
-  // CHECK-DAG: define void @_ZN5test71BD2Ev
+  // CHECK3: define void @_ZN5test71BD2Ev
   template <typename> struct A {
     ~A() {}
   };
@@ -119,8 +138,9 @@
 
 namespace test8 {
   // Test that we replace ~zed with ~bar which is an alias to ~foo.
-  // CHECK-DAG: call i32 @__cxa_atexit({{.*}}@_ZN5test83barD2Ev
-  // CHECK-DAG: @_ZN5test83barD2Ev = alias {{.*}} @_ZN5test83fooD2Ev
+  // CHECK4: @_ZN5test83barD2Ev = alias {{.*}} @_ZN5test83fooD2Ev
+  // CHECK4: define internal void @__cxx_global_var_init5()
+  // CHECK4: call i32 @__cxa_atexit({{.*}}@_ZN5test83barD2Ev
   struct foo {
     ~foo();
   };
@@ -144,12 +164,12 @@
 void zed() {
   // Test that we produce a call to bar's destructor. We used to call foo's, but
   // it has a different calling conversion.
-  // CHECK-DAG: call void @_ZN5test93barD2Ev
+  // CHECK4: call void @_ZN5test93barD2Ev
   bar ptr;
 }
 }
 
-// CHECK-RAUW: @_ZTV1C = linkonce_odr unnamed_addr constant [4 x i8*] [{{[^@]*}}@_ZTI1C {{[^@]*}}@_ZN1CD2Ev {{[^@]*}}@_ZN1CD0Ev {{[^@]*}}]
+// CHECK5: @_ZTV1C = linkonce_odr unnamed_addr constant [4 x i8*] [{{[^@]*}}@_ZTI1C {{[^@]*}}@_ZN1CD2Ev {{[^@]*}}@_ZN1CD0Ev {{[^@]*}}]
 // r194296 replaced C::~C with B::~B without emitting the later.
 
 class A {
@@ -177,3 +197,38 @@
 fn1() {
   new C;
 }
+
+namespace test10 {
+// Test that if a destructor is in a comdat, we don't try to emit is as an
+// alias to a base class destructor.
+struct bar {
+  ~bar();
+};
+bar::~bar() {
+}
+} // closing the namespace causes ~bar to be sent to CodeGen
+namespace test10 {
+template <typename T>
+struct foo : public bar {
+  ~foo();
+};
+template <typename T>
+foo<T>::~foo() {}
+template class foo<int>;
+// CHECK5: define weak_odr void @_ZN6test103fooIiED2Ev({{.*}} comdat $_ZN6test103fooIiED5Ev
+}
+
+namespace test11 {
+// Test that when we don't have to worry about COMDATs we produce an alias
+// from complate to base and from base to base class base.
+struct bar {
+  ~bar();
+};
+bar::~bar() {}
+struct foo : public bar {
+  ~foo();
+};
+foo::~foo() {}
+// CHECK6: @_ZN6test113fooD2Ev = alias {{.*}} @_ZN6test113barD2Ev
+// CHECK6: @_ZN6test113fooD1Ev = alias {{.*}} @_ZN6test113fooD2Ev
+}
diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
index 33bd844..4d30344 100644
--- a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -455,3 +455,13 @@
   };
   S x[1] = {};
 }
+
+namespace PR20445 {
+  struct vector { vector(std::initializer_list<int>); };
+  struct MyClass { explicit MyClass(const vector &v); };
+  template<int x> void f() { new MyClass({42, 43}); }
+  template void f<0>();
+  // CHECK-LABEL: define {{.*}} @_ZN7PR204451fILi0EEEvv(
+  // CHECK: call void @_ZN7PR204456vectorC1ESt16initializer_listIiE(
+  // CHECK: call void @_ZN7PR204457MyClassC1ERKNS_6vectorE(
+}
diff --git a/test/CodeGenCXX/cxx11-exception-spec.cpp b/test/CodeGenCXX/cxx11-exception-spec.cpp
index 3b1516b..75f939f 100644
--- a/test/CodeGenCXX/cxx11-exception-spec.cpp
+++ b/test/CodeGenCXX/cxx11-exception-spec.cpp
@@ -122,3 +122,8 @@
 
 // CHECK: attributes [[NONE]] = { {{.*}} }
 // CHECK: attributes [[NUW]] = { nounwind{{.*}} }
+
+namespace PR19190 {
+template <class T> struct DWFIterator { virtual void get() throw(int) = 0; };
+void foo(DWFIterator<int> *foo) { foo->get(); }
+}
diff --git a/test/CodeGenCXX/cxx11-initializer-aggregate.cpp b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
index 94f3058..789970b 100644
--- a/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -20,7 +20,7 @@
   // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8
   // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B* %[[INITLIST2:.*]], i32 0, i32 0
   // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8
-  // CHECK: call nonnull i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]])
+  // CHECK: call dereferenceable({{[0-9]+}}) i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]])
   return B{v}.f();
 }
 
diff --git a/test/CodeGenCXX/cxx11-special-members.cpp b/test/CodeGenCXX/cxx11-special-members.cpp
index 59461f9..037e59a 100644
--- a/test/CodeGenCXX/cxx11-special-members.cpp
+++ b/test/CodeGenCXX/cxx11-special-members.cpp
@@ -28,5 +28,19 @@
 // CHECK: define {{.*}} @_ZN1BaSEOS_(
 // CHECK: call {{.*}} @_ZN1AaSERKS_(
 
+// rdar://18309639 {
+template<int> struct C { C() = default; };
+struct D {
+  C<0> c;
+  D() { }
+};
+template struct C<0>; // was asserting
+void f3() {
+  C<0> a;
+  D b;
+}
+// CHECK: define {{.*}} @_ZN1CILi0EEC1Ev
+// CHECK: define {{.*}} @_ZN1DC1Ev
+
 // CHECK: define {{.*}} @_ZN1BC2EOS_(
 // CHECK: call {{.*}} @_ZN1AC1ERKS_(
diff --git a/test/CodeGenCXX/cxx11-thread-local-reference.cpp b/test/CodeGenCXX/cxx11-thread-local-reference.cpp
index 9718a93..4143164 100644
--- a/test/CodeGenCXX/cxx11-thread-local-reference.cpp
+++ b/test/CodeGenCXX/cxx11-thread-local-reference.cpp
@@ -10,10 +10,10 @@
 int &g() { return r; }
 
 // CHECK: define {{.*}} @[[R_INIT:.*]]()
-// CHECK: call nonnull i32* @_Z1fv()
+// CHECK: call dereferenceable({{[0-9]+}}) i32* @_Z1fv()
 // CHECK: store i32* %{{.*}}, i32** @r, align 8
 
-// CHECK-LABEL: define nonnull i32* @_Z1gv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i32* @_Z1gv()
 // CHECK: call i32* @_ZTW1r()
 // CHECK: ret i32* %{{.*}}
 
diff --git a/test/CodeGenCXX/cxx11-thread-local.cpp b/test/CodeGenCXX/cxx11-thread-local.cpp
index a3690b3..a6f0106 100644
--- a/test/CodeGenCXX/cxx11-thread-local.cpp
+++ b/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -44,9 +44,9 @@
 // CHECK: @llvm.global_ctors = appending global {{.*}} @[[GLOBAL_INIT:[^ ]*]]
 
 // CHECK: @_ZTH1a = alias void ()* @__tls_init
-// CHECK: @_ZTHL1d = alias internal void ()* @__tls_init
+// CHECK: @_ZTHL1d = internal alias void ()* @__tls_init
 // CHECK: @_ZTHN1U1mE = alias void ()* @__tls_init
-// CHECK: @_ZTHN1VIiE1mE = alias linkonce_odr void ()* @__tls_init
+// CHECK: @_ZTHN1VIiE1mE = linkonce_odr alias void ()* @__tls_init
 
 
 // Individual variable initialization functions:
diff --git a/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp b/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp
index 8bdf863..098a4b9 100644
--- a/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp
+++ b/test/CodeGenCXX/cxx1y-initializer-aggregate.cpp
@@ -36,6 +36,17 @@
 B z { 1 };
 // CHECK: @z = global {{.*}} { i32 1 }
 
+// Brace initialization should initialize the first field even though it is
+// unnamed.
+union C {
+  struct {
+    int C::*memptr;
+  };
+};
+
+C n{};
+// CHECK: @n = global %union.C { %struct.anon { i64 -1 } }, align 8
+
 // Initialization of 'a':
 
 // CHECK: store i32 0, i32* getelementptr inbounds ({{.*}} @a, i32 0, i32 0)
diff --git a/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp b/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp
new file mode 100644
index 0000000..8c0b8c2
--- /dev/null
+++ b/test/CodeGenCXX/cxx1y-variable-template-linkage.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-optzns %s -o - | FileCheck %s -check-prefix=CHECKA -check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-optzns -fcxx-exceptions %s -o - | FileCheck %s -check-prefix=CHECKB -check-prefix=CHECK
+// expected-no-diagnostics
+
+// The variable template specialization x<Foo> generated in each file
+// should be 'internal global' and not 'linkonce_odr global'.
+
+template <typename T> int x = 42;
+
+// CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global
+
+// CHECK-DAG: define internal dereferenceable(4) i32* @_ZL3foov(
+static int &foo() {
+   struct Foo { };
+   
+   // CHECK-DAG: ret i32* @_Z1xIZL3foovE3FooE
+   return x<Foo>;
+}
+
+
+#if !__has_feature(cxx_exceptions) // File A
+// CHECKA-DAG: define dereferenceable(4) i32* @_Z3barv(
+int &bar() { 
+	// CHECKA-DAG: call dereferenceable(4) i32* @_ZL3foov()
+	return foo();
+}
+
+#else // File B
+
+// CHECKB-DAG: declare dereferenceable(4) i32* @_Z3barv(
+int &bar();
+
+int main() {
+	// CHECKB-DAG: call dereferenceable(4) i32* @_Z3barv()
+	// CHECKB-DAG: call dereferenceable(4) i32* @_ZL3foov()
+	&bar() == &foo() ? throw 0 : (void)0; // Should not throw exception at runtime.
+}
+
+#endif // end of Files A and B
+
diff --git a/test/CodeGenCXX/cxx1z-fold-expression.cpp b/test/CodeGenCXX/cxx1z-fold-expression.cpp
new file mode 100644
index 0000000..5dac66b
--- /dev/null
+++ b/test/CodeGenCXX/cxx1z-fold-expression.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++1z -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+template<int> struct A {};
+template<int ...N> void foldr(A<(N + ...)>);
+template<int ...N> void foldl(A<(... + N)>);
+template<int ...N> void foldr1(A<(N + ... + 1)>);
+template<int ...N> void foldl1(A<(1 + ... + N)>);
+void use() {
+  foldr<1, 2, 3>({});
+  foldl<1, 2, 3>({});
+  foldr1<1, 2, 3>({});
+  foldl1<1, 2, 3>({});
+  // CHECK-DAG: @_Z5foldrIJLi1ELi2ELi3EEEv1AIXfrplT_EE(
+  // CHECK-DAG: @_Z5foldlIJLi1ELi2ELi3EEEv1AIXflplT_EE(
+  // CHECK-DAG: @_Z6foldr1IJLi1ELi2ELi3EEEv1AIXfRplT_Li1EEE(
+  // CHECK-DAG: @_Z6foldl1IJLi1ELi2ELi3EEEv1AIXfLplLi1ET_EE(
+}
+
+template<int ...N> using Foldr = A<(N + ...)>;
+template<int ...N> using Foldl = A<(... + N)>;
+template<int ...N> using Foldr1 = A<(N + ... + 1)>;
+template<int ...N> using Foldl1 = A<(1 + ... + N)>;
+
+template<int ...A> struct Partial {
+  template<int ...B> void foldr(Foldr<A..., B..., A..., B...>);
+  template<int ...B> void foldl(Foldl<A..., B..., A..., B...>);
+  template<int ...B> void foldr1(Foldr1<A..., B..., A..., B...>);
+  template<int ...B> void foldl1(Foldl1<A..., B..., A..., B...>);
+};
+void use(Partial<1, 2> p) {
+  p.foldr<3, 4>({});
+  p.foldl<3, 4>({});
+  p.foldr1<3, 4>({});
+  p.foldl1<3, 4>({});
+  // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE5foldrIJLi3ELi4EEEEv1AIXplLi1EplLi2EfRplT_plLi1EplLi2EfrplT_EE(
+  // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE5foldlIJLi3ELi4EEEEv1AIXfLplplplfLplplLi1ELi2ET_Li1ELi2ET_EE
+  // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE6foldr1IJLi3ELi4EEEEv1AIXplLi1EplLi2EfRplT_plLi1EplLi2EfRplT_Li1EEE(
+  // CHECK-DAG: @_ZN7PartialIJLi1ELi2EEE6foldl1IJLi3ELi4EEEEv1AIXfLplplplfLplplplLi1ELi1ELi2ET_Li1ELi2ET_EE(
+}
+
+extern int n;
+template<int ...N> void f() {
+  (n = ... = N);
+}
+template void f<>();
diff --git a/test/CodeGenCXX/debug-info-access.cpp b/test/CodeGenCXX/debug-info-access.cpp
new file mode 100644
index 0000000..d6dfd87
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-access.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple %itanium_abi_triple %s -o - | FileCheck %s
+// Test the various accessibility flags in the debug info.
+struct A {
+  // CHECK-DAG: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [pub_default]
+  void pub_default();
+  // CHECK-DAG: [ DW_TAG_member ] [pub_default_static] [line [[@LINE+1]]{{.*}}offset 0] [static]
+  static int pub_default_static;
+};
+
+// CHECK: [ DW_TAG_inheritance ] {{.*}} [public] [from {{.*}}A]
+class B : public A {
+public:
+  // CHECK-DAG: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [public] [pub]
+  void pub();
+  // CHECK-DAG: [ DW_TAG_member ] [public_static] [line [[@LINE+1]]{{.*}} [public] [static]
+  static int public_static;
+protected:
+  // CHECK: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [protected] [prot]
+  void prot();
+private:
+  // CHECK: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [priv_default]
+  void priv_default();
+};
+
+union U {
+  // CHECK-DAG: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [union_pub_default]
+  void union_pub_default();
+private:
+  // CHECK-DAG: [ DW_TAG_member ] [union_priv] [line [[@LINE+1]]{{.*}} [private] 
+  int union_priv;
+};
+
+
+// CHECK: {{.*}}\00256\00{{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [free]
+void free() {}
+
+A a;
+B b;
+U u;
diff --git a/test/CodeGenCXX/debug-info-alias.cpp b/test/CodeGenCXX/debug-info-alias.cpp
index fb18ac5..609b5b7 100644
--- a/test/CodeGenCXX/debug-info-alias.cpp
+++ b/test/CodeGenCXX/debug-info-alias.cpp
@@ -13,15 +13,15 @@
 = foo<T*>;
 }
 
-// CHECK: metadata [[BINT:![0-9]*]], i32 0, i32 1, {{.*}} ; [ DW_TAG_variable ] [bi]
+// CHECK: metadata [[BINT:![0-9]*]], {{[^,]+, [^,]+}}} ; [ DW_TAG_variable ] [bi]
 // CHECK: [[BINT]] = {{.*}} ; [ DW_TAG_typedef ] [bar<int>] [line 42
 x::bar<int> bi;
-// CHECK: metadata [[BFLOAT:![0-9]*]], i32 0, i32 1, {{.*}} ; [ DW_TAG_variable ] [bf]
+// CHECK: metadata [[BFLOAT:![0-9]*]], {{[^,]+, [^,]+}}} ; [ DW_TAG_variable ] [bf]
 // CHECK: [[BFLOAT]] = {{.*}} ; [ DW_TAG_typedef ] [bar<float>] [line 42
 x::bar<float> bf;
 
 using
-// CHECK: metadata [[NARF:![0-9]*]], i32 0, i32 1, {{.*}} ; [ DW_TAG_variable ] [n]
+// CHECK: metadata [[NARF:![0-9]*]], {{[^,]+, [^,]+}}} ; [ DW_TAG_variable ] [n]
 # 142
 narf // CHECK: [[NARF]] = {{.*}} ; [ DW_TAG_typedef ] [narf] [line 142
 = int;
diff --git a/test/CodeGenCXX/debug-info-artificial-arg.cpp b/test/CodeGenCXX/debug-info-artificial-arg.cpp
index 84f496f..a558d20 100644
--- a/test/CodeGenCXX/debug-info-artificial-arg.cpp
+++ b/test/CodeGenCXX/debug-info-artificial-arg.cpp
@@ -24,6 +24,6 @@
 
 // CHECK: ![[CLASSTYPE:.*]] = {{.*}}, metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A]
 // CHECK: ![[ARTARG:.*]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
-// CHECK: metadata !"_ZTS1A", {{.*}} ; [ DW_TAG_subprogram ] [line 12] [A]
-// CHECK: metadata [[FUNCTYPE:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+// CHECK: metadata !"_ZTS1A", {{.*}} ; [ DW_TAG_subprogram ] [line 12] [public] [A]
+// CHECK: metadata [[FUNCTYPE:![0-9]*]], null, null, null} ; [ DW_TAG_subroutine_type ]
 // CHECK: [[FUNCTYPE]] = metadata !{null, metadata ![[ARTARG]], metadata !{{.*}}, metadata !{{.*}}}
diff --git a/test/CodeGenCXX/debug-info-class-limited-plugin.test b/test/CodeGenCXX/debug-info-class-limited-plugin.test
new file mode 100644
index 0000000..61d258d
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-class-limited-plugin.test
@@ -0,0 +1,2 @@
+RUN: %clang_cc1 -emit-llvm -fno-standalone-debug -g -o - -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-function-names %S/Inputs/debug-info-class-limited.cpp 2>&1 | FileCheck %S/Inputs/debug-info-class-limited.cpp
+REQUIRES: plugins, examples
diff --git a/test/CodeGenCXX/debug-info-class-limited.cpp b/test/CodeGenCXX/debug-info-class-limited.cpp
deleted file mode 100644
index 30abd2d..0000000
--- a/test/CodeGenCXX/debug-info-class-limited.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// RUN: %clang -emit-llvm -fno-standalone-debug -g -S %s -o - | FileCheck %s
-
-namespace PR16214_1 {
-// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
-struct foo {
-  int i;
-};
-
-typedef foo bar;
-
-bar *a;
-bar b;
-}
-
-namespace PR14467 {
-// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
-struct foo {
-};
-
-foo *bar(foo *a) {
-  foo *b = new foo(*a);
-  return b;
-}
-}
-
-namespace test1 {
-// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
-struct foo {
-};
-
-extern int bar(foo *a);
-int baz(foo *a) {
-  return bar(a);
-}
-}
-
-namespace test2 {
-// FIXME: if we were a bit fancier, we could realize that the 'foo' type is only
-// required because of the 'bar' type which is not required at all (or might
-// only be required to be declared)
-// CHECK-DAG: [ DW_TAG_structure_type ] [foo] [line [[@LINE+1]], {{.*}} [def]
-struct foo {
-};
-
-struct bar {
-  foo f;
-};
-
-void func() {
-  foo *f;
-}
-}
diff --git a/test/CodeGenCXX/debug-info-class-limited.test b/test/CodeGenCXX/debug-info-class-limited.test
new file mode 100644
index 0000000..0b10728
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-class-limited.test
@@ -0,0 +1 @@
+RUN: %clang_cc1 -emit-llvm -fno-standalone-debug -g %S/Inputs/debug-info-class-limited.cpp -o - | FileCheck %S/Inputs/debug-info-class-limited.cpp
diff --git a/test/CodeGenCXX/debug-info-class.cpp b/test/CodeGenCXX/debug-info-class.cpp
index 34add04..5da5321 100644
--- a/test/CodeGenCXX/debug-info-class.cpp
+++ b/test/CodeGenCXX/debug-info-class.cpp
@@ -94,20 +94,20 @@
 // CHECK: DW_TAG_class_type ] [bar]
 // CHECK: DW_TAG_union_type ] [baz]
 // CHECK: DW_TAG_class_type ] [B] {{.*}} [def]
-// CHECK: metadata !"_vptr$B", {{.*}}, i32 64, metadata !{{.*}}} ; [ DW_TAG_member ]
+// CHECK: metadata !"0xd\00_vptr$B\00{{.*}}\0064", {{.*}} ; [ DW_TAG_member ]
 
-// CHECK: [[C:![0-9]*]] = {{.*}} metadata [[C_MEM:![0-9]*]], i32 0, metadata !"_ZTS1C", null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] {{.*}} [def]
+// CHECK: [[C:![0-9]*]] = {{.*}} metadata [[C_MEM:![0-9]*]], metadata !"_ZTS1C", null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] {{.*}} [def]
 // CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_S:![0-9]*]], metadata [[C_DTOR:![0-9]*]]}
 // CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$C] {{.*}} [artificial]
 // CHECK: [[C_S]] = {{.*}} ; [ DW_TAG_member ] [s] {{.*}} [static] [from int]
 // CHECK: [[C_DTOR]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [~C]
 
-// CHECK: null, i32 0, null, null, metadata !"_ZTS1D"} ; [ DW_TAG_structure_type ] [D] {{.*}} [decl]
-// CHECK: null, i32 0, null, null, metadata !"_ZTS1E"} ; [ DW_TAG_structure_type ] [E] {{.*}} [decl]
-// CHECK: [[F:![0-9]*]] = {{.*}} null, i32 0, null, null, metadata !"_ZTS1F"} ; [ DW_TAG_structure_type ] [F] {{.*}} [decl]
+// CHECK: null, null, null, metadata !"_ZTS1D"} ; [ DW_TAG_structure_type ] [D] {{.*}} [decl]
+// CHECK: null, null, null, metadata !"_ZTS1E"} ; [ DW_TAG_structure_type ] [E] {{.*}} [decl]
+// CHECK: [[F:![0-9]*]] = {{.*}} null, null, null, metadata !"_ZTS1F"} ; [ DW_TAG_structure_type ] [F] {{.*}} [decl]
 
-// CHECK: null, i32 0, null, null, metadata !"_ZTS1G"} ; [ DW_TAG_structure_type ] [G] {{.*}} [decl]
-// CHECK: metadata [[G_INNER_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN1G5innerE"} ; [ DW_TAG_structure_type ] [inner] [line 50, {{.*}} [def]
+// CHECK: null, null, null, metadata !"_ZTS1G"} ; [ DW_TAG_structure_type ] [G] {{.*}} [decl]
+// CHECK: metadata [[G_INNER_MEM:![0-9]*]], null, null, metadata !"_ZTSN1G5innerE"} ; [ DW_TAG_structure_type ] [inner] [line 50, {{.*}} [def]
 // CHECK: [[G_INNER_MEM]] = metadata !{metadata [[G_INNER_I:![0-9]*]]}
 // CHECK: [[G_INNER_I]] = {{.*}} ; [ DW_TAG_member ] [j] {{.*}} [from int]
 
@@ -115,12 +115,8 @@
 // CHECK: HdrSize
 // CHECK: ; [ DW_TAG_structure_type ] [I] {{.*}} [def]
 //
-// CHECK: metadata !"_ZTS1D", {{.*}}, metadata [[D_FUNC_DECL:![0-9]*]], metadata {{![0-9]*}}, i32 {{[0-9]*}}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
-// CHECK: [[D_FUNC_DECL]] = {{.*}}, metadata !"_ZTS1D", {{.*}}, i32 0, null, i32 {{[0-9]*}}} ; [ DW_TAG_subprogram ] {{.*}} [func]
-
-// CHECK: [[F_I_DEF:![0-9]*]] = {{.*}}, metadata [[F_I:![0-9]*]]} ; [ DW_TAG_variable ] [i]
-
-// CHECK: [[F_I]] = {{.*}}, metadata !"_ZTS1F", {{.*}} ; [ DW_TAG_member ] [i]
+// CHECK: metadata !"_ZTS1D", {{.*}}, metadata [[D_FUNC_DECL:![0-9]*]], metadata {{![0-9]*}}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
+// CHECK: [[D_FUNC_DECL]] = metadata !{metadata !"0x2e\00func\00{{.*}}\000\00{{[0-9]+}}"{{.*}}, metadata !"_ZTS1D", {{.*}}, null} ; [ DW_TAG_subprogram ] {{.*}} [func]
 
 // CHECK: ![[EXCEPTLOC]] = metadata !{i32 84,
 // CHECK: ![[RETLOC]] = metadata !{i32 83,
diff --git a/test/CodeGenCXX/debug-info-cxx1y.cpp b/test/CodeGenCXX/debug-info-cxx1y.cpp
index 3cb7e45..5e5741a 100644
--- a/test/CodeGenCXX/debug-info-cxx1y.cpp
+++ b/test/CodeGenCXX/debug-info-cxx1y.cpp
@@ -1,7 +1,20 @@
-// RUN: not %clang_cc1 -emit-llvm-only -std=c++1y -g %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only -std=c++14 -emit-llvm -g %s -o - | FileCheck %s
+
+// CHECK: [[EMPTY:![0-9]*]] = metadata !{}
+// CHECK: \00foo\00{{.*}}, metadata [[EMPTY]], {{.*}}} ; [ DW_TAG_structure_type ]
+// FIXME: The context of this definition should be the CU/file scope, not the class.
+// CHECK: metadata !"_ZTS3foo", metadata [[SUBROUTINE_TYPE:![0-9]*]], {{.*}}, metadata [[FUNC_DECL:![0-9]*]], metadata {{![0-9]*}}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
+// CHECK: [[SUBROUTINE_TYPE]] = {{.*}}, metadata [[TYPE_LIST:![0-9]*]],
+// CHECK: [[TYPE_LIST]] = metadata !{metadata [[INT:![0-9]*]]}
+// CHECK: [[INT]] = {{.*}} ; [ DW_TAG_base_type ] [int]
+// CHECK: [[FUNC_DECL]] = {{.*}}, metadata !"_ZTS3foo", metadata [[SUBROUTINE_TYPE]], {{.*}}} ; [ DW_TAG_subprogram ] {{.*}} [func]
 
 struct foo {
-  auto func(); // CHECK: error: debug information for auto is not yet supported
+  static auto func();
 };
 
 foo f;
+
+auto foo::func() {
+  return 1;
+}
diff --git a/test/CodeGenCXX/debug-info-decl-nested.cpp b/test/CodeGenCXX/debug-info-decl-nested.cpp
index f79a8e9..3b36ce5 100644
--- a/test/CodeGenCXX/debug-info-decl-nested.cpp
+++ b/test/CodeGenCXX/debug-info-decl-nested.cpp
@@ -17,17 +17,18 @@
   public:
     InnerClass(); // Here createContextChain() generates a limited type for OuterClass.
   } theInnerClass;
-// CHECK0: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [private] [OuterClass]
+// CHECK0: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [OuterClass]
   OuterClass(const Foo *); // line 10
 };
 OuterClass::InnerClass OuterClass::theInnerClass; // This toplevel decl causes InnerClass to be generated.
-// CHECK0: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+1]]} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [OuterClass]
+// CHECK0: metadata !"0x2e\00OuterClass\00{{.*}}\00[[@LINE+1]]"{{.*}}, metadata ![[DECL]], metadata {{![0-9]+}}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [OuterClass]
 OuterClass::OuterClass(const Foo *meta) { } // line 13
 
 
 
 
 
+
 class Foo1;
 class OuterClass1
 {
@@ -35,8 +36,8 @@
   public:
     InnerClass1();
   } theInnerClass1;
-// CHECK1: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+2]]] [private] [Bar]
-// CHECK1: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+4]]} ; [ DW_TAG_subprogram ] [line [[@LINE+4]]] [def] [Bar]
+// CHECK1: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+2]]] [Bar]
+// CHECK1: metadata !"0x2e\00Bar\00{{.*}}\00[[@LINE+4]]"{{.*}}, metadata ![[DECL]], metadata {{![0-9]+}}} ; [ DW_TAG_subprogram ] [line [[@LINE+4]]] [def] [Bar]
   void Bar(const Foo1 *);
 };
 OuterClass1::InnerClass1 OuterClass1::theInnerClass1;
@@ -53,9 +54,9 @@
   public:
     InnerClass2();
   } theInnerClass2;
-// CHECK2: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [private] [~OuterClass2]
+// CHECK2: [[DECL:[0-9]+]] = {{.*}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [~OuterClass2]
   ~OuterClass2(); // line 10
 };
 OuterClass2::InnerClass2 OuterClass2::theInnerClass2;
-// CHECK2: metadata {{.*}}, metadata ![[DECL]], metadata {{.*}}, i32 [[@LINE+1]]} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [~OuterClass2]
+// CHECK2: metadata !"0x2e\00~OuterClass2\00{{.*}}\00[[@LINE+1]]"{{.*}}, metadata ![[DECL]], metadata {{.*}}} ; [ DW_TAG_subprogram ] [line [[@LINE+1]]] [def] [~OuterClass2]
 OuterClass2::~OuterClass2() { }
diff --git a/test/CodeGenCXX/debug-info-enum-class.cpp b/test/CodeGenCXX/debug-info-enum-class.cpp
index f0b97cc..cfa9611 100644
--- a/test/CodeGenCXX/debug-info-enum-class.cpp
+++ b/test/CodeGenCXX/debug-info-enum-class.cpp
@@ -29,10 +29,10 @@
 
 namespace test2 {
 // FIXME: this should just be a declaration under -fno-standalone-debug
-// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST2:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS:![0-9]*]], {{[^,]*}}, null, null, metadata !"_ZTSN5test21EE"} ; [ DW_TAG_enumeration_type ] [E]
+// CHECK: metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST2:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS:![0-9]*]], null, null, metadata !"_ZTSN5test21EE"} ; [ DW_TAG_enumeration_type ] [E]
 // CHECK: [[TEST2]] = {{.*}} ; [ DW_TAG_namespace ] [test2]
 // CHECK: [[TEST_ENUMS]] = metadata !{metadata [[TEST_E:![0-9]*]]}
-// CHECK: [[TEST_E]] = {{.*}}, metadata !"e", i64 0} ; [ DW_TAG_enumerator ] [e :: 0]
+// CHECK: [[TEST_E]] = metadata !{metadata !"0x28\00e\000"} ; [ DW_TAG_enumerator ] [e :: 0]
 enum E : int;
 void func(E *) {
 }
@@ -41,7 +41,7 @@
 
 namespace test3 {
 // FIXME: this should just be a declaration under -fno-standalone-debug
-// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS]], {{[^,]*}}, null, null, metadata !"_ZTSN5test31EE"} ; [ DW_TAG_enumeration_type ] [E]
+// CHECK: metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS]], null, null, metadata !"_ZTSN5test31EE"} ; [ DW_TAG_enumeration_type ] [E]
 // CHECK: [[TEST3]] = {{.*}} ; [ DW_TAG_namespace ] [test3]
 enum E : int { e };
 void func(E *) {
@@ -49,7 +49,7 @@
 }
 
 namespace test4 {
-// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST4:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS]], {{[^,]*}}, null, null, metadata !"_ZTSN5test41EE"} ; [ DW_TAG_enumeration_type ] [E]
+// CHECK: metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST4:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS]], null, null, metadata !"_ZTSN5test41EE"} ; [ DW_TAG_enumeration_type ] [E]
 // CHECK: [[TEST4]] = {{.*}} ; [ DW_TAG_namespace ] [test4]
 enum E : int;
 void f1(E *) {
@@ -62,7 +62,7 @@
 // CHECK: ; [ DW_TAG_enumeration_type ] [D] [line 6, size 16, align 16, offset 0] [decl] [from ]
 
 namespace test5 {
-// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST5:![0-9]*]], {{.*}}, null, {{[^,]*}}, null, null, metadata !"_ZTSN5test51EE"} ; [ DW_TAG_enumeration_type ] [E]
+// CHECK: metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST5:![0-9]*]], {{.*}}, null, null, null, metadata !"_ZTSN5test51EE"} ; [ DW_TAG_enumeration_type ] [E]
 // CHECK: [[TEST5]] = {{.*}} ; [ DW_TAG_namespace ] [test5]
 enum E : int;
 void f1(E *) {
diff --git a/test/CodeGenCXX/debug-info-enum.cpp b/test/CodeGenCXX/debug-info-enum.cpp
index 810c3ee..9aa2d1b 100644
--- a/test/CodeGenCXX/debug-info-enum.cpp
+++ b/test/CodeGenCXX/debug-info-enum.cpp
@@ -1,13 +1,13 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -g %s -o - | FileCheck %s
 
-// CHECK: [[ENUMS:![0-9]*]], {{[^,]*}}, {{[^,]*}}, {{[^,]*}}, {{[^,]*}}, {{[^,]*}}} ; [ DW_TAG_compile_unit ]
+// CHECK: metadata !"0x11\00{{.*}}", {{[^,]*}}, metadata [[ENUMS:![0-9]*]], {{.*}}} ; [ DW_TAG_compile_unit ]
 // CHECK: [[ENUMS]] = metadata !{metadata [[E1:![0-9]*]], metadata [[E2:![0-9]*]], metadata [[E3:![0-9]*]]}
 
 namespace test1 {
-// CHECK: [[E1]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST1:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS:![0-9]*]], {{[^,]*}}, null, null, metadata !"_ZTSN5test11eE"} ; [ DW_TAG_enumeration_type ] [e]
+// CHECK: [[E1]] = metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST1:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS:![0-9]*]], null, null, metadata !"_ZTSN5test11eE"} ; [ DW_TAG_enumeration_type ] [e]
 // CHECK: [[TEST1]] = {{.*}} ; [ DW_TAG_namespace ] [test1]
 // CHECK: [[TEST1_ENUMS]] = metadata !{metadata [[TEST1_E:![0-9]*]]}
-// CHECK: [[TEST1_E]] = {{.*}}, metadata !"E", i64 0} ; [ DW_TAG_enumerator ] [E :: 0]
+// CHECK: [[TEST1_E]] = metadata !{metadata !"0x28\00E\000"} ; [ DW_TAG_enumerator ] [E :: 0]
 enum e { E };
 void foo() {
   int v = E;
@@ -16,7 +16,7 @@
 
 namespace test2 {
 // rdar://8195980
-// CHECK: [[E2]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST2:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS]], {{[^,]*}}, null, null, metadata !"_ZTSN5test21eE"} ; [ DW_TAG_enumeration_type ] [e]
+// CHECK: [[E2]] = metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST2:![0-9]*]], {{.*}}, metadata [[TEST1_ENUMS]], null, null, metadata !"_ZTSN5test21eE"} ; [ DW_TAG_enumeration_type ] [e]
 // CHECK: [[TEST2]] = {{.*}} ; [ DW_TAG_namespace ] [test2]
 enum e { E };
 bool func(int i) {
@@ -25,10 +25,10 @@
 }
 
 namespace test3 {
-// CHECK: [[E3]] = metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST3_ENUMS:![0-9]*]], {{[^,]*}}, null, null, metadata !"_ZTSN5test31eE"} ; [ DW_TAG_enumeration_type ] [e]
+// CHECK: [[E3]] = metadata !{metadata !"0x4\00{{.*}}", {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST3_ENUMS:![0-9]*]], null, null, metadata !"_ZTSN5test31eE"} ; [ DW_TAG_enumeration_type ] [e]
 // CHECK: [[TEST3]] = {{.*}} ; [ DW_TAG_namespace ] [test3]
 // CHECK: [[TEST3_ENUMS]] = metadata !{metadata [[TEST3_E:![0-9]*]]}
-// CHECK: [[TEST3_E]] = {{.*}}, metadata !"E", i64 -1} ; [ DW_TAG_enumerator ] [E :: -1]
+// CHECK: [[TEST3_E]] = metadata !{metadata !"0x28\00E\00-1"} ; [ DW_TAG_enumerator ] [E :: -1]
 enum e { E = -1 };
 void func() {
   e x;
diff --git a/test/CodeGenCXX/debug-info-flex-member.cpp b/test/CodeGenCXX/debug-info-flex-member.cpp
index 11329aa..7f54415 100644
--- a/test/CodeGenCXX/debug-info-flex-member.cpp
+++ b/test/CodeGenCXX/debug-info-flex-member.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
 
-// CHECK: metadata !{i32 {{.*}}, i64 0, i64 -1}        ; [ DW_TAG_subrange_type ]
+// CHECK: metadata !{metadata !"0x21\000\00-1"}        ; [ DW_TAG_subrange_type ]
 
 struct StructName {
   int member[];
diff --git a/test/CodeGenCXX/debug-info-function-context.cpp b/test/CodeGenCXX/debug-info-function-context.cpp
index e65d328..d58f7c6 100644
--- a/test/CodeGenCXX/debug-info-function-context.cpp
+++ b/test/CodeGenCXX/debug-info-function-context.cpp
@@ -25,12 +25,12 @@
 // functions that belong to the namespace have it as a context, and the global
 // function has the file as a context.
 
-// CHECK: metadata !"_ZTS1C", metadata !"member_function"{{.*}} [ DW_TAG_subprogram ] [line 11] [def] [member_function]
+// CHECK: metadata !"0x2e\00member_function\00{{.*}}", metadata !{{[0-9]+}}, metadata !"_ZTS1C"{{.*}} [ DW_TAG_subprogram ] [line 11] [def] [member_function]
 
-// CHECK: metadata !"_ZTS1C", metadata !"static_member_function"{{.*}}  [ DW_TAG_subprogram ] [line 13] [def] [static_member_function]
+// CHECK: metadata !"0x2e\00static_member_function\00{{.*}}", metadata !{{[0-9]+}}, metadata !"_ZTS1C"{{.*}}  [ DW_TAG_subprogram ] [line 13] [def] [static_member_function]
 
-// CHECK: metadata [[FILE:![0-9]*]], metadata !"global_function"{{.*}}  [ DW_TAG_subprogram ] [line 17] [def] [global_function]
+// CHECK: metadata !"0x2e\00global_function\00{{[^,]+}}", metadata !{{[0-9]+}}, metadata [[FILE:![0-9]*]]{{.*}}  [ DW_TAG_subprogram ] [line 17] [def] [global_function]
 // CHECK: [[FILE]] = {{.*}} [ DW_TAG_file_type ]
 
-// CHECK: metadata [[NS:![0-9]*]], metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function]
+// CHECK: metadata !"0x2e\00global_namespace_function\00{{[^,]+}}", metadata !{{[0-9]+}}, metadata [[NS:![0-9]*]]{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function]
 // CHECK: [[NS]] = {{.*}} [ DW_TAG_namespace ] [ns] [line 19]
diff --git a/test/CodeGenCXX/debug-info-global.cpp b/test/CodeGenCXX/debug-info-global.cpp
index 8dc30c8..10900f3 100644
--- a/test/CodeGenCXX/debug-info-global.cpp
+++ b/test/CodeGenCXX/debug-info-global.cpp
@@ -10,10 +10,10 @@
   return ns::cnst + ns::cnst;
 }
 
-// CHECK: metadata [[GLOBALS:![0-9]*]], metadata {{![0-9]*}}, metadata !"{{.*}}", i32 {{[0-9]*}}} ; [ DW_TAG_compile_unit ]
+// CHECK: metadata !"0x11\00{{.*}}"{{.*}}, metadata [[GLOBALS:![0-9]*]], metadata {{![0-9]*}}} ; [ DW_TAG_compile_unit ]
 
 // CHECK: [[GLOBALS]] = metadata !{metadata [[CNST:![0-9]*]]}
 
-// CHECK: [[CNST]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"cnst", {{.*}}; [ DW_TAG_variable ] [cnst]
+// CHECK: [[CNST]] = metadata !{metadata !"0x34\00cnst\00{{.*}}", metadata [[NS:![0-9]*]], {{[^,]+, [^,]+, [^,]+, [^,]+}}} ; [ DW_TAG_variable ] [cnst]
 // CHECK: [[NS]] = {{.*}}; [ DW_TAG_namespace ] [ns]
 
diff --git a/test/CodeGenCXX/debug-info-line-if.cpp b/test/CodeGenCXX/debug-info-line-if.cpp
index 0d4d223..bd96377 100644
--- a/test/CodeGenCXX/debug-info-line-if.cpp
+++ b/test/CodeGenCXX/debug-info-line-if.cpp
@@ -1,20 +1,55 @@
-// RUN: %clang -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s
 // PR19864
+extern int v[2];
+int a = 0, b = 0;
 int main() {
-    int v[] = {13, 21, 8, 3, 34, 1, 5, 2};
-    int a = 0, b = 0;
-    for (int x : v)
-      if (x >= 3)
-        ++b;     // CHECK: add nsw{{.*}}, 1
-      else if (x >= 0)
-        ++a;    // CHECK: add nsw{{.*}}, 1
-    // The continuation block if the if statement should not share the
-    // location of the ++a statement. Having it point to the end of
-    // the condition is not ideal either, but it's less missleading.
+#line 100
+  for (int x : v)
+    if (x)
+      ++b; // CHECK: add nsw{{.*}}, 1
+    else
+      ++a; // CHECK: add nsw{{.*}}, 1
+  // The continuation block if the if statement should not share the
+  // location of the ++a statement. The branch back to the start of the loop
+  // should be attributed to the loop header line.
 
-    // CHECK: br label
-    // CHECK: br label
-    // CHECK: br label {{.*}}, !dbg ![[DBG:.*]]
-    // CHECK: ![[DBG]] = metadata !{i32 [[@LINE-11]], i32 0, metadata !{{.*}}, null}
+  // CHECK: br label
+  // CHECK: br label
+  // CHECK: br label {{.*}}, !dbg [[DBG1:!.*]]
 
+#line 200
+  while (a)
+    if (b)
+      ++b; // CHECK: add nsw{{.*}}, 1
+    else
+      ++a; // CHECK: add nsw{{.*}}, 1
+
+  // CHECK: br label
+  // CHECK: br label {{.*}}, !dbg [[DBG2:!.*]]
+
+#line 300
+  for (; a; )
+    if (b)
+      ++b; // CHECK: add nsw{{.*}}, 1
+    else
+      ++a; // CHECK: add nsw{{.*}}, 1
+
+  // CHECK: br label
+  // CHECK: br label {{.*}}, !dbg [[DBG3:!.*]]
+
+#line 400
+  int x[] = {1, 2};
+  for (int y : x)
+    if (b)
+      ++b; // CHECK: add nsw{{.*}}, 1
+    else
+      ++a; // CHECK: add nsw{{.*}}, 1
+
+  // CHECK: br label
+  // CHECK: br label {{.*}}, !dbg [[DBG4:!.*]]
+
+  // CHECK: [[DBG1]] = metadata !{i32 100, i32 0, metadata !{{.*}}, null}
+  // CHECK: [[DBG2]] = metadata !{i32 200, i32 0, metadata !{{.*}}, null}
+  // CHECK: [[DBG3]] = metadata !{i32 300, i32 0, metadata !{{.*}}, null}
+  // CHECK: [[DBG4]] = metadata !{i32 401, i32 0, metadata !{{.*}}, null}
 }
diff --git a/test/CodeGenCXX/debug-info-method.cpp b/test/CodeGenCXX/debug-info-method.cpp
index 49b8dc4..02b7426 100644
--- a/test/CodeGenCXX/debug-info-method.cpp
+++ b/test/CodeGenCXX/debug-info-method.cpp
@@ -1,14 +1,14 @@
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 -g %s -o - | FileCheck %s
 // CHECK: metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A]
-// CHECK: metadata !"_ZN1A3fooEiS_3$_0", {{.*}} [protected]
+// CHECK: metadata !"{{.*}}\00_ZN1A3fooEiS_3$_0\00{{.*}}", {{.*}} [protected]
 // CHECK: ![[THISTYPE:[0-9]+]] = {{.*}} ; [ DW_TAG_pointer_type ] {{.*}} [artificial] [from _ZTS1A]
 // CHECK: DW_TAG_ptr_to_member_type
 // CHECK: {{.*}}metadata ![[MEMFUNTYPE:[0-9]+]], metadata !{{.*}}} ; [ DW_TAG_ptr_to_member_type ] {{.*}} [from ]
-// CHECK: ![[MEMFUNTYPE]] = {{.*}}metadata ![[MEMFUNARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] {{.*}} [from ]
+// CHECK: ![[MEMFUNTYPE]] = {{.*}}metadata ![[MEMFUNARGS:[0-9]+]], null, null, null} ; [ DW_TAG_subroutine_type ] {{.*}} [from ]
 // CHECK: ![[MEMFUNARGS]] = {{.*}}, metadata ![[THISTYPE]],
-// CHECK: ""{{.*}}DW_TAG_arg_variable
-// CHECK: ""{{.*}}DW_TAG_arg_variable
-// CHECK: ""{{.*}}DW_TAG_arg_variable
+// CHECK: metadata !"0x101\00\00{{.*}}"{{.*}} DW_TAG_arg_variable
+// CHECK: metadata !"0x101\00\00{{.*}}"{{.*}} DW_TAG_arg_variable
+// CHECK: metadata !"0x101\00\00{{.*}}"{{.*}} DW_TAG_arg_variable
 union {
   int a;
   float b;
diff --git a/test/CodeGenCXX/debug-info-namespace.cpp b/test/CodeGenCXX/debug-info-namespace.cpp
index 2eb942e..c999ce2 100644
--- a/test/CodeGenCXX/debug-info-namespace.cpp
+++ b/test/CodeGenCXX/debug-info-namespace.cpp
@@ -1,16 +1,20 @@
-// RUN: %clang -g -fno-standalone-debug -S -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang -g -gline-tables-only    -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-GMLT %s
-// RUN: %clang -g -fstandalone-debug    -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-NOLIMIT %s
+// RUN: %clang_cc1 -g -fno-standalone-debug -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -g -gline-tables-only    -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-GMLT %s
+// RUN: %clang_cc1 -g -fstandalone-debug    -S -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-NOLIMIT %s
 
 namespace A {
 #line 1 "foo.cpp"
 namespace B {
-int i;
-void f1() { }
+extern int i;
+int f1() { return 0; }
 void f1(int) { }
 struct foo;
 struct bar { };
 typedef bar baz;
+extern int var_decl;
+void func_decl(void);
+extern int var_fwd;
+void func_fwd(void);
 }
 }
 namespace A {
@@ -19,7 +23,7 @@
 
 using namespace A;
 namespace E = A;
-
+int B::i = f1();
 int func(bool b) {
   if (b) {
     using namespace A::B;
@@ -33,51 +37,65 @@
   using B::baz;
   namespace X = A;
   namespace Y = X;
+  using B::var_decl;
+  using B::func_decl;
+  using B::var_fwd;
+  using B::func_fwd;
   return i + X::B::i + Y::B::i;
 }
 
 namespace A {
 using B::i;
+namespace B {
+int var_fwd = i;
 }
+}
+void B::func_fwd() {}
 
 // This should work even if 'i' and 'func' were declarations & not definitions,
 // but it doesn't yet.
 
-// CHECK: [[CU:![0-9]*]] = {{.*}}[[MODULES:![0-9]*]], metadata !"", i32 1} ; [ DW_TAG_compile_unit ]
-// CHECK: [[FILE:![0-9]*]] {{.*}}debug-info-namespace.cpp"
+// CHECK: [[CU:![0-9]*]] = metadata !{metadata !"0x11\00{{.*}}\001"{{.*}}, metadata [[MODULES:![0-9]*]]} ; [ DW_TAG_compile_unit ]
 // CHECK: [[FOO:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [foo] [line 5, size 0, align 0, offset 0] [decl] [from ]
 // CHECK: [[FOOCPP:![0-9]*]] = metadata !{metadata !"foo.cpp", {{.*}}
-// CHECK: [[NS:![0-9]*]] = {{.*}}, metadata [[FILE2:![0-9]*]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1]
-// CHECK: [[CTXT]] = {{.*}}, metadata [[FILE]], null, {{.*}} ; [ DW_TAG_namespace ] [A] [line 5]
+// CHECK: [[NS:![0-9]*]] = metadata !{metadata !"0x39\00B\001", metadata [[FILE2:![0-9]*]], metadata [[CTXT:![0-9]*]]} ; [ DW_TAG_namespace ] [B] [line 1]
+// CHECK: [[CTXT]] = metadata !{metadata !"0x39\00A\005", metadata [[FILE:![0-9]*]], null} ; [ DW_TAG_namespace ] [A] [line 5]
+// CHECK: [[FILE]] {{.*}}debug-info-namespace.cpp"
 // CHECK: [[BAR:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [decl] [from ]
 // CHECK: [[F1:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 4] [def] [f1]
-// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
 // CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp]
-// CHECK: [[I:![0-9]*]] = {{.*}}, metadata [[NS]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i]
-// CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]], metadata [[M5:![0-9]*]], metadata [[M6:![0-9]*]], metadata [[M7:![0-9]*]], metadata [[M8:![0-9]*]], metadata [[M9:![0-9]*]], metadata [[M10:![0-9]*]], metadata [[M11:![0-9]*]], metadata [[M12:![0-9]*]], metadata [[M13:![0-9]*]]}
-// CHECK: [[M1]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[NS]], i32 11} ; [ DW_TAG_imported_module ]
-// CHECK: [[M2]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_module ]
-// CHECK: [[M3]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 15, metadata !"E"} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M4]] = metadata !{i32 {{[0-9]*}}, metadata [[LEX2:![0-9]*]], metadata [[NS]], i32 19} ; [ DW_TAG_imported_module ]
-// CHECK: [[LEX2]] = metadata !{i32 {{[0-9]*}}, metadata [[FILE2]], metadata [[LEX1:![0-9]+]], i32 {{[0-9]*}}, i32 0, i32 {{.*}}} ; [ DW_TAG_lexical_block ]
-// CHECK: [[LEX1]] = metadata !{i32 {{[0-9]*}}, metadata [[FILE2]], metadata [[FUNC]], i32 {{[0-9]*}}, i32 0, i32 {{.*}}} ; [ DW_TAG_lexical_block ]
-// CHECK: [[M5]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[CTXT]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_module ]
-// CHECK: [[M6]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[FOO:!"_ZTSN1A1B3fooE"]], i32 23} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M7]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[BAR:!"_ZTSN1A1B3barE"]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M8]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[F1]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M9]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[I]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M10]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[BAZ:![0-9]*]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[BAZ]] = metadata !{i32 {{[0-9]*}}, metadata [[FOOCPP]], metadata [[NS]], {{.*}}, metadata !"_ZTSN1A1B3barE"} ; [ DW_TAG_typedef ] [baz] {{.*}} [from _ZTSN1A1B3barE]
-// CHECK: [[M11]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[CTXT]], i32 {{[0-9]*}}, metadata !"X"} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M12]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[M11]], i32 {{[0-9]*}}, metadata !"Y"} ; [ DW_TAG_imported_declaration ]
-// CHECK: [[M13]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[I]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
+// CHECK: [[FUNC_FWD:![0-9]*]] {{.*}} [ DW_TAG_subprogram ] [line 47] [def] [func_fwd]
+// CHECK: [[I:![0-9]*]] = metadata !{metadata !"0x34\00i\00{{.*}}", metadata [[NS]], {{.*}} ; [ DW_TAG_variable ] [i]
+// CHECK: [[VAR_FWD:![0-9]*]] = metadata !{metadata !"0x34\00var_fwd\00{{.*}}", metadata [[NS]], {{.*}}} ; [ DW_TAG_variable ] [var_fwd] [line 44] [def]
 
-// CHECK-GMLT: [[CU:![0-9]*]] = {{.*}}[[MODULES:![0-9]*]], metadata !"", i32 2} ; [ DW_TAG_compile_unit ]
+// CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]], metadata [[M5:![0-9]*]], metadata [[M6:![0-9]*]], metadata [[M7:![0-9]*]], metadata [[M8:![0-9]*]], metadata [[M9:![0-9]*]], metadata [[M10:![0-9]*]], metadata [[M11:![0-9]*]], metadata [[M12:![0-9]*]], metadata [[M13:![0-9]*]], metadata [[M14:![0-9]*]], metadata [[M15:![0-9]*]], metadata [[M16:![0-9]*]], metadata [[M17:![0-9]*]]}
+// CHECK: [[M1]] = metadata !{metadata !"0x3a\0015\00", metadata [[CTXT]], metadata [[NS]]} ; [ DW_TAG_imported_module ]
+// CHECK: [[M2]] = metadata !{metadata !"0x3a\00{{[0-9]+}}\00", metadata [[CU]], metadata [[CTXT]]} ; [ DW_TAG_imported_module ]
+// CHECK: [[M3]] = metadata !{metadata !"0x8\0019\00E", metadata [[CU]], metadata [[CTXT]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M4]] = metadata !{metadata !"0x3a\0023\00", metadata [[LEX2:![0-9]*]], metadata [[NS]]} ; [ DW_TAG_imported_module ]
+// CHECK: [[LEX2]] = metadata !{metadata !"0xb\00{{[0-9]*}}\000\00{{.*}}", metadata [[FILE2]], metadata [[LEX1:![0-9]+]]} ; [ DW_TAG_lexical_block ]
+// CHECK: [[LEX1]] = metadata !{metadata !"0xb\00{{[0-9]*}}\000\00{{.*}}", metadata [[FILE2]], metadata [[FUNC]]} ; [ DW_TAG_lexical_block ]
+// CHECK: [[M5]] = metadata !{metadata !"0x3a\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[CTXT]]} ; [ DW_TAG_imported_module ]
+// CHECK: [[M6]] = metadata !{metadata !"0x8\0027\00", metadata [[FUNC]], metadata [[FOO:!"_ZTSN1A1B3fooE"]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M7]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[BAR:!"_ZTSN1A1B3barE"]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M8]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[F1]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M9]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[I]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M10]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[BAZ:![0-9]*]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[BAZ]] = metadata !{metadata !"0x16\00baz\00{{.*}}", metadata [[FOOCPP]], metadata [[NS]], metadata !"_ZTSN1A1B3barE"} ; [ DW_TAG_typedef ] [baz] {{.*}} [from _ZTSN1A1B3barE]
+// CHECK: [[M11]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00X", metadata [[FUNC]], metadata [[CTXT]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M12]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00Y", metadata [[FUNC]], metadata [[M11]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M13]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[VAR_DECL:![0-9]*]]} ; [ DW_TAG_imported_declaration ]
+// CHECK [[VAR_DECL]] = metadata !{metadata !"0x34\00var_decl\00{{.*}}", metadata [[NS]], {{.*}}} ; [ DW_TAG_variable ] [var_decl] [line 8]
+// CHECK: [[M14]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[FUNC_DECL:![0-9]*]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[FUNC_DECL]] = metadata !{metadata !"0x2e\00func_decl\00{{.*}}", metadata [[FOOCPP]], metadata [[NS]], {{.*}}} ; [ DW_TAG_subprogram ] [line 9] [scope 0] [func_decl]
+// CHECK: [[M15]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[VAR_FWD:![0-9]*]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M16]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[FUNC]], metadata [[FUNC_FWD:![0-9]*]]} ; [ DW_TAG_imported_declaration ]
+// CHECK: [[M17]] = metadata !{metadata !"0x8\00{{[0-9]+}}\00", metadata [[CTXT]], metadata [[I]]} ; [ DW_TAG_imported_declaration ]
+// CHECK-GMLT: [[CU:![0-9]*]] = metadata !{metadata !"0x11\00{{.*}}\002"{{.*}}, metadata [[MODULES:![0-9]*]]} ; [ DW_TAG_compile_unit ]
 // CHECK-GMLT: [[MODULES]] = metadata !{}
 
 // CHECK-NOLIMIT: ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [def] [from ]
 
-// FIXME: It is confused on win32 to generate file entry when dosish filename is given.
-// REQUIRES: shell
 // REQUIRES: shell-preserves-root
 // REQUIRES: dw2
diff --git a/test/CodeGenCXX/debug-info-qualifiers.cpp b/test/CodeGenCXX/debug-info-qualifiers.cpp
index c6b935f..301e315 100644
--- a/test/CodeGenCXX/debug-info-qualifiers.cpp
+++ b/test/CodeGenCXX/debug-info-qualifiers.cpp
@@ -2,25 +2,25 @@
 // Test (r)value and CVR qualifiers on C++11 non-static member functions.
 class A {
 public:
-  // CHECK: i32 [[@LINE+2]], metadata ![[PLSR:[0-9]+]], {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+2]]] [reference] [l]
+  // CHECK: metadata !"0x2e\00l\00{{.*}}\00[[@LINE+2]]"{{, [^,]+, [^,]+}}, metadata ![[PLSR:[0-9]+]], {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+2]]] [public] [reference] [l]
   // CHECK: ![[PLSR]] ={{.*}}[ DW_TAG_subroutine_type ]{{.*}}[reference]
   void l() const &;
   // CHECK: ![[ARGS:[0-9]+]] = metadata !{null, metadata ![[THIS:[0-9]+]]}
   // CHECK: ![[THIS]] = {{.*}} metadata ![[CONST_A:.*]]} ; [ DW_TAG_pointer_type ]
   // CHECK: ![[CONST_A]] = {{.*}} [ DW_TAG_const_type ]
-  // CHECK: i32 [[@LINE+2]], metadata ![[PRSR:[0-9]+]], {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+2]]] [rvalue reference] [r]
-  // CHECK: ![[PRSR]] ={{.*}}metadata ![[ARGS]], i32 0, null, null, null}{{.*}}[ DW_TAG_subroutine_type ]{{.*}}[rvalue reference]
+  // CHECK: metadata !"0x2e\00r\00{{.*}}\00[[@LINE+2]]"{{, [^,]+, [^,]+}}, metadata ![[PRSR:[0-9]+]], {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+2]]] [public] [rvalue reference] [r]
+  // CHECK: ![[PRSR]] ={{.*}}metadata ![[ARGS]], null, null, null}{{.*}}[ DW_TAG_subroutine_type ]{{.*}}[rvalue reference]
   void r() const &&;
 };
 
 void g() {
   A a;
   // The type of pl is "void (A::*)() const &".
-  // CHECK: metadata ![[PL:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [pl] [line [[@LINE+2]]]
+  // CHECK: metadata ![[PL:[0-9]+]]} ; [ DW_TAG_auto_variable ] [pl] [line [[@LINE+2]]]
   // CHECK: metadata ![[PLSR]], metadata !"{{.*}}"} ; [ DW_TAG_ptr_to_member_type ]
   auto pl = &A::l;
 
-  // CHECK: metadata ![[PR:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [pr] [line [[@LINE+2]]]
+  // CHECK: metadata ![[PR:[0-9]+]]} ; [ DW_TAG_auto_variable ] [pr] [line [[@LINE+2]]]
   // CHECK: metadata ![[PRSR]], metadata !"{{.*}}"} ; [ DW_TAG_ptr_to_member_type ]
   auto pr = &A::r;
 }
diff --git a/test/CodeGenCXX/debug-info-rvalue-ref.cpp b/test/CodeGenCXX/debug-info-rvalue-ref.cpp
index 142f587..ce5d3c1 100644
--- a/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ b/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -8,4 +8,4 @@
   printf("%d\n", i);
 }
 
-// CHECK: metadata !{i32 {{.*}}, null, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !{{.*}}} ; [ DW_TAG_rvalue_reference_type ]
+// CHECK: metadata !{metadata !"0x42\00\000\000\000\000\000", null, null, metadata !{{.*}}} ; [ DW_TAG_rvalue_reference_type ]
diff --git a/test/CodeGenCXX/debug-info-scope.cpp b/test/CodeGenCXX/debug-info-scope.cpp
index 0447dc0..8957e60 100644
--- a/test/CodeGenCXX/debug-info-scope.cpp
+++ b/test/CodeGenCXX/debug-info-scope.cpp
@@ -1,32 +1,55 @@
-// RUN: %clang_cc1 -g -emit-llvm %s -o -| FileCheck %s
+// RUN: %clang_cc1 -g -std=c++11 -emit-llvm %s -o -| FileCheck %s
 //
 // Two variables with the same name in subsequent if staments need to be in separate scopes.
 //
 // rdar://problem/14024005
-//
 
-int printf(const char*, ...);
+int src();
 
-char *return_char (int input)
-{
-  if (input%2 == 0)
-    return "I am even.\n";
-  else
-    return "I am odd.\n";
-}
+void f();
 
-int main2() {
-// CHECK: [ DW_TAG_auto_variable ] [ptr] [line [[@LINE+2]]]
-// CHECK: metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
-  if (char *ptr = return_char(1)) {
-    printf ("%s", ptr);
+void func() {
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[IF1:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
+  // CHECK: [[IF1]] = metadata !{metadata !"0xb\00[[@LINE+1]]\00{{.*}}", metadata !{{.*}}} ; [ DW_TAG_lexical_block ]
+  if (int i = src())
+    f();
+
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[IF2:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
+  // CHECK: [[IF2]] = metadata !{metadata !"0xb\00[[@LINE+1]]\00{{.*}}", metadata !{{.*}}} ; [ DW_TAG_lexical_block ]
+  if (int i = src()) {
+    f();
+  } else
+    f();
+
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
+  // CHECK: [[FOR]] = metadata !{metadata !"0xb\00[[@LINE+1]]\00{{.*}}", metadata !{{.*}}} ; [ DW_TAG_lexical_block ]
+  for (int i = 0;
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[FOR_BODY:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+6]]]
+  // The scope could be located at 'bool b', but LLVM drops line information for
+  // scopes anyway, so it's not terribly important.
+  // FIXME: change the debug info schema to not include locations of scopes,
+  // since they're not used.
+  // CHECK: [[FOR_BODY]] = metadata !{metadata !"0xb\00[[@LINE-6]]\00{{.*}}", metadata !{{.*}}} ; [ DW_TAG_lexical_block ]
+       bool b = i != 10; ++i)
+    f();
+
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]
+  // CHECK: [[FOR]] = metadata !{metadata !"0xb\00[[@LINE+1]]\00{{.*}}", metadata !{{.*}}} ; [ DW_TAG_lexical_block ]
+  for (int i = 0; i != 10; ++i) {
+  // FIXME: Do not include scopes that have only other scopes (and no variables
+  // or using declarations) as direct children, they just waste
+  // space/relocations/etc.
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[FOR_COMPOUND:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+3]]]
+  // CHECK: [[FOR_COMPOUND]] = metadata !{metadata !"0xb\00[[@LINE-5]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[FOR_BODY:![0-9]+]]} ; [ DW_TAG_lexical_block ]
+  // CHECK: [[FOR_BODY]] = metadata !{metadata !"0xb\00[[@LINE-6]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[FOR]]} ; [ DW_TAG_lexical_block ]
+    bool b = i % 2;
   }
-// CHECK: [ DW_TAG_auto_variable ] [ptr] [line [[@LINE+2]]]
-// CHECK: metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
-  if (char *ptr = return_char(2)) {
-    printf ("%s", ptr);
-  }
-  else printf ("%s", ptr);
 
-  return 0;
+  int x[] = {1, 2};
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[RANGE_FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [__range] [line 0]
+  // CHECK: [[RANGE_FOR]] = metadata !{metadata !"0xb\00[[@LINE+1]]\00{{.*}}", metadata !{{.*}}} ; [ DW_TAG_lexical_block ]
+  for (int i : x) {
+  // CHECK: = metadata !{metadata !"0x100\00{{.*}}", metadata [[RANGE_FOR_BODY:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE-1]]]
+  // CHECK: [[RANGE_FOR_BODY]] = metadata !{metadata !"0xb\00[[@LINE-2]]\00{{.*}}", metadata !{{[0-9]+}}, metadata [[RANGE_FOR]]} ; [ DW_TAG_lexical_block ]
+  }
 }
diff --git a/test/CodeGenCXX/debug-info-static-fns.cpp b/test/CodeGenCXX/debug-info-static-fns.cpp
index 136261c..eb2a245 100644
--- a/test/CodeGenCXX/debug-info-static-fns.cpp
+++ b/test/CodeGenCXX/debug-info-static-fns.cpp
@@ -7,4 +7,4 @@
 }
 
 // Verify that a is present and mangled.
-// CHECK: metadata !"_ZN1AL1aEi", {{.*}}, i32 (i32)* @_ZN1AL1aEi, {{.*}} ; [ DW_TAG_subprogram ] [line 4] [local] [def] [a]
+// CHECK: metadata !"0x2e\00a\00a\00_ZN1AL1aEi\00{{.*}}", {{.*}}, i32 (i32)* @_ZN1AL1aEi, {{.*}} ; [ DW_TAG_subprogram ] [line 4] [local] [def] [a]
diff --git a/test/CodeGenCXX/debug-info-static-member.cpp b/test/CodeGenCXX/debug-info-static-member.cpp
index 1ac235c..d80f978 100644
--- a/test/CodeGenCXX/debug-info-static-member.cpp
+++ b/test/CodeGenCXX/debug-info-static-member.cpp
@@ -35,13 +35,70 @@
 
 // CHECK: metadata !"_ZTS1X"} ; [ DW_TAG_enumeration_type ] [X]
 // CHECK: metadata !"_ZTS1C"} ; [ DW_TAG_class_type ] [C]
-// CHECK: ![[DECL_A:[0-9]+]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
-// CHECK: metadata !"const_a", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
-// CHECK: ![[DECL_B:[0-9]+]] {{.*}} metadata !"b", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
-// CHECK: metadata !"const_b", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
-// CHECK: ![[DECL_C:[0-9]+]] {{.*}} metadata !"c", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [static]
-// CHECK: metadata !"const_c", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [static]
-// CHECK: metadata !"x_a", {{.*}} [ DW_TAG_member ] [x_a] {{.*}} [static]
-// CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A]]} ; [ DW_TAG_variable ] [a] {{.*}} [def]
-// CHECK: metadata !"b", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def]
-// CHECK: metadata !"c", {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def]
+// CHECK: ![[DECL_A:[0-9]+]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [static]
+// CHECK: metadata !"0xd\00const_a\00{{.*}}", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [static]
+// CHECK: ![[DECL_B:[0-9]+]] = metadata !{metadata !"0xd\00b\00{{.*}}", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
+// CHECK: metadata !"0xd\00const_b\00{{.*}}", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
+// CHECK: ![[DECL_C:[0-9]+]] = metadata !{metadata !"0xd\00c\00{{.*}}", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [public] [static]
+// CHECK: metadata !"0xd\00const_c\00{{.*}}", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [public] [static]
+// CHECK: metadata !"0xd\00x_a\00{{.*}}", {{.*}} [ DW_TAG_member ] [x_a] {{.*}} [public] [static]
+
+// CHECK: ; [ DW_TAG_structure_type ] [static_decl_templ<int>] {{.*}} [def]
+// CHECK: ; [ DW_TAG_member ] [static_decl_templ_var]
+
+// CHECK: [[NS_X:![0-9]+]] = {{.*}} ; [ DW_TAG_namespace ] [x]
+
+// Test this in an anonymous namespace to ensure the type is retained even when
+// it doesn't get automatically retained by the string type reference machinery.
+namespace {
+struct anon_static_decl_struct {
+  static const int anon_static_decl_var = 117;
+};
+}
+
+
+// CHECK: ; [ DW_TAG_structure_type ] [anon_static_decl_struct] {{.*}} [def]
+// CHECK: ; [ DW_TAG_member ] [anon_static_decl_var]
+
+int ref() {
+  return anon_static_decl_struct::anon_static_decl_var;
+}
+
+template<typename T>
+struct static_decl_templ {
+  static const int static_decl_templ_var = 7;
+};
+
+template<typename T>
+const int static_decl_templ<T>::static_decl_templ_var;
+
+int static_decl_templ_ref() {
+  return static_decl_templ<int>::static_decl_templ_var;
+}
+
+// CHECK: metadata !{metadata !"0x34\00a\00{{.*}}", null, {{.*}} @_ZN1C1aE, metadata ![[DECL_A]]} ; [ DW_TAG_variable ] [a] {{.*}} [def]
+// CHECK: metadata !{metadata !"0x34\00b\00{{.*}}", null, {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def]
+// CHECK: metadata !{metadata !"0x34\00c\00{{.*}}", null, {{.*}} @_ZN1C1cE, metadata ![[DECL_C]]} ; [ DW_TAG_variable ] [c] {{.*}} [def]
+
+// CHECK-NOT: ; [ DW_TAG_variable ] [anon_static_decl_var]
+
+// Verify that even when a static member declaration is created lazily when
+// creating the definition, the declaration line is that of the canonical
+// declaration, not the definition. Also, since we look at the canonical
+// definition, we should also correctly emit the constant value (42) into the
+// debug info.
+struct V {
+  virtual ~V(); // cause the definition of 'V' to be omitted by no-standalone-debug optimization
+  static const int const_va = 42;
+};
+// CHECK: i32 42} ; [ DW_TAG_member ] [const_va] [line [[@LINE-2]],
+const int V::const_va;
+
+namespace x {
+struct y {
+  static int z;
+};
+int y::z;
+}
+
+// CHECK: metadata !{metadata !"0x34\00z\00{{.*}}", metadata [[NS_X]], {{.*}} ; [ DW_TAG_variable ] [z] {{.*}} [def]
diff --git a/test/CodeGenCXX/debug-info-template-limit.cpp b/test/CodeGenCXX/debug-info-template-limit.cpp
index e1f23ad..2e80cd8 100644
--- a/test/CodeGenCXX/debug-info-template-limit.cpp
+++ b/test/CodeGenCXX/debug-info-template-limit.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -fno-standalone-debug -triple %itanium_abi_triple -g %s -o - | FileCheck %s
 
 // Check that this pointer type is TC<int>
-// CHECK: ![[LINE:[0-9]+]] = {{.*}}"TC<int>", {{.*}} metadata !"_ZTS2TCIiE"} ; [ DW_TAG_class_type ]
+// CHECK: ![[LINE:[0-9]+]] = metadata !{metadata !"0x2\00TC<int>\00{{.*}}", {{.*}} metadata !"_ZTS2TCIiE"} ; [ DW_TAG_class_type ]
 // CHECK: metadata !"_ZTS2TCIiE"} ; [ DW_TAG_pointer_type ]{{.*}}[from _ZTS2TCIiE]
 
 template<typename T>
diff --git a/test/CodeGenCXX/debug-info-template-member.cpp b/test/CodeGenCXX/debug-info-template-member.cpp
index c9a3d9b..7aa1d3d 100644
--- a/test/CodeGenCXX/debug-info-template-member.cpp
+++ b/test/CodeGenCXX/debug-info-template-member.cpp
@@ -16,29 +16,35 @@
   return MyClass().add<3>(x); // even though add<3> is ODR used, don't emit it since we don't codegen it
 }
 
-// CHECK: [[FOO_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo]
+// CHECK: [[FOO_MEM:![0-9]*]], null, null, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo]
 // CHECK: [[FOO_MEM]] = metadata !{metadata [[FOO_FUNC:![0-9]*]]}
-// CHECK: [[FOO_FUNC]] = {{.*}}, metadata !"_ZN3foo4funcEN5outerIS_E5innerE", i32 {{[0-9]*}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
-// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
-// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata [[OUTER_FOO_INNER:![0-9]*]]}
-// CHECK: [[OUTER_FOO_INNER]] = {{.*}}, null, metadata !"[[OUTER_FOO_INNER_ID:.*]]"} ; [ DW_TAG_structure_type ] [inner]
+// CHECK: [[FOO_FUNC]] = metadata !{metadata !"0x2e\00func\00func\00_ZN3foo4funcEN5outerIS_E5innerE\00{{.*}}"{{, [^,]+, [^,]+}}, metadata [[FOO_FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
+// CHECK: [[FOO_FUNC_TYPE]] = {{.*}}, metadata [[FOO_FUNC_PARAMS:![0-9]*]], null, null, null} ; [ DW_TAG_subroutine_type ]
+// CHECK: [[FOO_FUNC_PARAMS]] = metadata !{null, metadata !{{[0-9]*}}, metadata !"[[OUTER_FOO_INNER_ID:.*]]"}
+// CHECK: !{{[0-9]*}} = {{.*}}, null, metadata !"[[OUTER_FOO_INNER_ID]]"} ; [ DW_TAG_structure_type ] [inner]
 
-// CHECK: metadata [[VIRT_MEM:![0-9]*]], i32 0, metadata !"_ZTS4virtI4elemE", metadata [[VIRT_TEMP_PARAM:![0-9]*]], metadata !"_ZTS4virtI4elemE"} ; [ DW_TAG_structure_type ] [virt<elem>] {{.*}} [def]
+// CHECK: metadata [[VIRT_MEM:![0-9]*]], metadata !"_ZTS4virtI4elemE", metadata [[VIRT_TEMP_PARAM:![0-9]*]], metadata !"_ZTS4virtI4elemE"} ; [ DW_TAG_structure_type ] [virt<elem>] {{.*}} [def]
 // CHECK: [[VIRT_TEMP_PARAM]] = metadata !{metadata [[VIRT_T:![0-9]*]]}
-// CHECK: [[VIRT_T]] = {{.*}}, metadata !"T", metadata !"_ZTS4elem", {{.*}} ; [ DW_TAG_template_type_parameter ]
+// CHECK: [[VIRT_T]] = metadata !{metadata !"0x2f\00T\000\000"{{, [^,]+}}, metadata !"_ZTS4elem", {{.*}} ; [ DW_TAG_template_type_parameter ]
 
-// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], i32 0, metadata !"_ZTS7MyClass", null, metadata !"_ZTS7MyClass"} ; [ DW_TAG_structure_type ] [MyClass]
-// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_ADD:![0-9]*]], metadata [[C_FUNC:![0-9]*]], metadata [[C_CTOR:![0-9]*]]}
+// CHECK: [[C:![0-9]*]] = {{.*}}, metadata [[C_MEM:![0-9]*]], metadata !"_ZTS7MyClass", null, metadata !"_ZTS7MyClass"} ; [ DW_TAG_structure_type ] [MyClass]
+// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_FUNC:![0-9]*]]}
 // CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$MyClass]
 
-// CHECK: [[C_ADD]] = {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
 // CHECK: [[C_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] [line 7] [func]
-// CHECK: [[C_CTOR]] = {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass]
 
-// CHECK: [[ELEM:![0-9]*]] = {{.*}}, metadata [[ELEM_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS4elem"} ; [ DW_TAG_structure_type ] [elem] {{.*}} [def]
+// CHECK: [[ELEM:![0-9]*]] = {{.*}}, metadata [[ELEM_MEM:![0-9]*]], null, null, metadata !"_ZTS4elem"} ; [ DW_TAG_structure_type ] [elem] {{.*}} [def]
 // CHECK: [[ELEM_MEM]] = metadata !{metadata [[ELEM_X:![0-9]*]]}
 // CHECK: [[ELEM_X]] = {{.*}} ; [ DW_TAG_member ] [x] {{.*}} [static] [from _ZTS4virtI4elemE]
 
+// Check that the member function template specialization and implicit special
+// members (the default ctor) refer to their class by scope, even though they
+// didn't appear in the class's member list (C_MEM). This prevents the functions
+// from being added to type units, while still appearing in the type
+// declaration/reference in the compile unit.
+// CHECK: metadata !"_ZTS7MyClass", {{.*}} ; [ DW_TAG_subprogram ] [line 4] [add<2>]
+// CHECK: metadata !"_ZTS7MyClass", {{.*}} ; [ DW_TAG_subprogram ] [line 0] [MyClass]
+
 template<typename T>
 struct outer {
   struct inner {
@@ -59,7 +65,7 @@
 
 outer<foo>::inner x;
 
-// CHECK: metadata !"[[OUTER_FOO_INNER_ID]]", i32 {{[0-9]*}}, i32 {{[0-9]*}}, %"struct.outer<foo>::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x]
+// CHECK: metadata !{metadata !"0x34\00{{.*}}", {{.*}}, metadata !"[[OUTER_FOO_INNER_ID]]", %"struct.outer<foo>::inner"* @x, {{.*}} ; [ DW_TAG_variable ] [x]
 
 template <typename T>
 struct virt {
diff --git a/test/CodeGenCXX/debug-info-template-quals.cpp b/test/CodeGenCXX/debug-info-template-quals.cpp
index 740f7bf..a9cd513 100644
--- a/test/CodeGenCXX/debug-info-template-quals.cpp
+++ b/test/CodeGenCXX/debug-info-template-quals.cpp
@@ -16,7 +16,7 @@
 }
 
 // CHECK: [[BS:.*]] = {{.*}} ; [ DW_TAG_structure_type ] [basic_string<char>] [line 4, size 8, align 8, offset 0] [def] [from ]
-// CHECK: [[TYPE:![0-9]*]] = metadata !{i32 {{.*}}, metadata [[ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+// CHECK: [[TYPE:![0-9]*]] = metadata !{metadata !"0x15\00{{.*}}"{{.*}}, metadata [[ARGS:.*]], null, null, null} ; [ DW_TAG_subroutine_type ]
 // CHECK: [[ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata [[P:![0-9]*]], metadata [[R:.*]]}
 // CHECK: [[P]] = {{.*}}, metadata [[CON:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
 // CHECK: [[CON]] = {{.*}}, metadata [[CH:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char]
@@ -24,4 +24,4 @@
 
 // CHECK: [[R]] = {{.*}}, metadata [[CON2:![0-9]*]]} ; [ DW_TAG_reference_type ] [line 0, size 0, align 0, offset 0] [from ]
 // CHECK: [[CON2]] = {{.*}}, metadata !"_ZTS12basic_stringIcE"} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _ZTS12basic_stringIcE]
-// CHECK: {{.*}} metadata [[TYPE]], {{.*}}, metadata !{{[0-9]*}}, metadata !{{[0-9]*}}, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign]
+// CHECK: metadata !"0x2e\00assign\00{{.*}}\008"{{, [^,]+, [^,]+}}, metadata !8, {{.*}} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign]
diff --git a/test/CodeGenCXX/debug-info-template.cpp b/test/CodeGenCXX/debug-info-template.cpp
index d071830..b7652f7 100644
--- a/test/CodeGenCXX/debug-info-template.cpp
+++ b/test/CodeGenCXX/debug-info-template.cpp
@@ -1,92 +1,106 @@
 // RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++11 | FileCheck %s
 
-// CHECK: {{.*}}, i1 false, metadata !"", i32 0, metadata !{{[0-9]]*}}, metadata [[RETAIN:![0-9]*]], {{.*}} ; [ DW_TAG_compile_unit ]
+// CHECK: metadata !"0x11\00{{.*}}"{{, [^,]+, [^,]+}}, metadata [[RETAIN:![0-9]*]], {{.*}} ; [ DW_TAG_compile_unit ]
 // CHECK: [[EMPTY:![0-9]*]] = metadata !{}
 // CHECK: [[RETAIN]] = metadata !{metadata !{{[0-9]]*}}, metadata [[FOO:![0-9]*]],
 
 
-// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]], metadata !"{{.*}}"} ; [ DW_TAG_structure_type ] [TC<unsigned int, 2, &glb, &foo::e, &foo::f, &func, tmpl_impl, 1, 2, 3>]
-// CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]], metadata [[TCARG3:![0-9]*]], metadata [[TCARG4:![0-9]*]], metadata [[TCARG5:![0-9]*]], metadata [[TCARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCARG8:![0-9]*]]}
+// CHECK: [[TC:![0-9]*]] = {{.*}}, metadata [[TCARGS:![0-9]*]], metadata !"{{.*}}"} ; [ DW_TAG_structure_type ] [TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>]
+// CHECK: [[TCARGS]] = metadata !{metadata [[TCARG1:![0-9]*]], metadata [[TCARG2:![0-9]*]], metadata [[TCARG3:![0-9]*]], metadata [[TCARG4:![0-9]*]], metadata [[TCARG5:![0-9]*]], metadata [[TCARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]]}
 //
 // We seem to be missing file/line/col info on template value parameters -
 // metadata supports it but it's not populated. GCC doesn't emit it either,
 // perhaps we should just drop it from the metadata.
 //
-// CHECK: [[TCARG1]] = {{.*}}metadata !"T", metadata [[UINT:![0-9]*]], {{.*}} ; [ DW_TAG_template_type_parameter ]
+// CHECK: [[TCARG1]] = metadata !{metadata !"0x2f\00T\000\000", null, metadata [[UINT:![0-9]*]], null} ; [ DW_TAG_template_type_parameter ]
 // CHECK: [[UINT:![0-9]*]] = {{.*}} ; [ DW_TAG_base_type ] [unsigned int]
-// CHECK: [[TCARG2]] = {{.*}}metadata !"", metadata [[UINT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[TCARG3]] = {{.*}}metadata !"x", metadata [[INTPTR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[INTPTR]] = {{.*}}, metadata [[INT:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
+// CHECK: [[TCARG2]] = metadata !{metadata !"0x30\00\00{{.*}}", {{[^,]+}}, metadata [[UINT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG3]] = metadata !{metadata !"0x30\00x\00{{.*}}", {{[^,]+}}, metadata [[CINTPTR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[CINTPTR]] = {{.*}}, metadata [[CINT:![0-9]*]]} ; [ DW_TAG_pointer_type ] {{.*}} [from ]
+// CHECK: [[CINT]] = {{.*}}, metadata [[INT:![0-9]*]]} ; [ DW_TAG_const_type ] {{.*}} [from int]
 // CHECK: [[INT]] = {{.*}} ; [ DW_TAG_base_type ] [int]
-// CHECK: [[TCARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR:![0-9]*]], i64 8, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG4]] = metadata !{metadata !"0x30\00a\00{{.*}}", {{[^,]+}}, metadata [[MEMINTPTR:![0-9]*]], i64 8, {{.*}} ; [ DW_TAG_template_value_parameter ]
 // CHECK: [[MEMINTPTR]] = {{.*}}, metadata !"_ZTS3foo"} ; [ DW_TAG_ptr_to_member_type ] {{.*}}[from int]
 //
 // Currently Clang emits the pointer-to-member-function value, but LLVM doesn't
 // use it (GCC doesn't emit a value for pointers to member functions either - so
 // it's not clear what, if any, format would be acceptable to GDB)
 //
-// CHECK: [[TCARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR:![0-9]*]], { i64, i64 } { i64 ptrtoint (void (%struct.foo*)* @_ZN3foo1fEv to i64), i64 0 }, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG5]] = metadata !{metadata !"0x30\00b\00{{.*}}", {{[^,]+}}, metadata [[MEMFUNPTR:![0-9]*]], { i64, i64 } { i64 ptrtoint (void (%struct.foo*)* @_ZN3foo1fEv to i64), i64 0 }, {{.*}} ; [ DW_TAG_template_value_parameter ]
 // CHECK: [[MEMFUNPTR]] = {{.*}}, metadata [[FTYPE:![0-9]*]], metadata !"_ZTS3foo"} ; [ DW_TAG_ptr_to_member_type ]
-// CHECK: [[FTYPE]] = {{.*}}, metadata [[FARGS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+// CHECK: [[FTYPE]] = {{.*}}, metadata [[FARGS:![0-9]*]], null, null, null} ; [ DW_TAG_subroutine_type ]
 // CHECK: [[FARGS]] = metadata !{null, metadata [[FARG1:![0-9]*]]}
 // CHECK: [[FARG1]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS3foo]
 //
-// CHECK: [[TCARG6]] = {{.*}}metadata !"f", metadata [[FUNPTR:![0-9]*]], void ()* @_Z4funcv, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG6]] = metadata !{metadata !"0x30\00f\00{{.*}}", {{[^,]+}}, metadata [[FUNPTR:![0-9]*]], void ()* @_ZN3foo1gEv, {{.*}} ; [ DW_TAG_template_value_parameter ]
 // CHECK: [[FUNPTR]] = {{.*}}, metadata [[FUNTYPE:![0-9]*]]} ; [ DW_TAG_pointer_type ]
-// CHECK: [[FUNTYPE]] = {{.*}}, metadata [[FUNARGS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
+// CHECK: [[FUNTYPE]] = {{.*}}, metadata [[FUNARGS:![0-9]*]], null, null, null} ; [ DW_TAG_subroutine_type ]
 // CHECK: [[FUNARGS]] = metadata !{null}
-// CHECK: [[TCARG7]] = {{.*}}metadata !"tmpl", null, metadata !"tmpl_impl", {{.*}} ; [ DW_TAG_GNU_template_template_param ]
-// CHECK: [[TCARG8]] = {{.*}}metadata !"Is", null, metadata [[TCARG8_VALS:![0-9]*]], {{.*}} ; [ DW_TAG_GNU_template_parameter_pack ]
-// CHECK: [[TCARG8_VALS]] = metadata !{metadata [[TCARG8_1:![0-9]*]], metadata [[TCARG8_2:![0-9]*]], metadata [[TCARG8_3:![0-9]*]]}
-// CHECK: [[TCARG8_1]] = {{.*}}metadata !"", metadata [[INT]], i32 1, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[TCARG8_2]] = {{.*}}metadata !"", metadata [[INT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[TCARG8_3]] = {{.*}}metadata !"", metadata [[INT]], i32 3, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG7]] = metadata !{metadata !"0x4107\00Is\000\000", null, null, metadata [[TCARG7_VALS:![0-9]*]], null} ; [ DW_TAG_GNU_template_parameter_pack ]
+// CHECK: [[TCARG7_VALS]] = metadata !{metadata [[TCARG7_1:![0-9]*]], metadata [[TCARG7_2:![0-9]*]], metadata [[TCARG7_3:![0-9]*]]}
+// CHECK: [[TCARG7_1]] = metadata !{metadata !"0x30\00\00{{.*}}", {{[^,]+}}, metadata [[INT]], i32 1, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG7_2]] = metadata !{metadata !"0x30\00\00{{.*}}", {{[^,]+}}, metadata [[INT]], i32 2, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCARG7_3]] = metadata !{metadata !"0x30\00\00{{.*}}", {{[^,]+}}, metadata [[INT]], i32 3, {{.*}} ; [ DW_TAG_template_value_parameter ]
 //
 // We could just emit a declaration of 'foo' here, rather than the entire
 // definition (same goes for any time we emit a member (function or data)
 // pointer type)
 // CHECK: [[FOO]] = {{.*}}, metadata !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo]
-// CHECK: metadata !"f", metadata !"_ZN3foo1fEv", i32 {{[0-9]*}}, metadata [[FTYPE:![0-9]*]],
+// CHECK: metadata !"0x2e\00f\00f\00_ZN3foo1fEv\00{{.*}}", metadata [[FTYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ]
 //
 
-
-// CHECK: metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata !"_ZTS2TCIjLj2EXadL_Z3glbEEXadL_ZN3foo1eEEEXadL_ZNS0_1fEvEEXadL_Z4funcvEE9tmpl_implJLi1ELi2ELi3EEE", {{.*}}, metadata !"[[TCNESTED:.*]]"} ; [ DW_TAG_structure_type ] [nested]
-// CHECK: metadata [[TCNARGS:![0-9]*]], metadata !"[[TCNT:.*]]"} ; [ DW_TAG_structure_type ] [TC<int, -3, nullptr, nullptr, nullptr, nullptr, tmpl_impl>]
-// CHECK: [[TCNARGS]] = metadata !{metadata [[TCNARG1:![0-9]*]], metadata [[TCNARG2:![0-9]*]], metadata [[TCNARG3:![0-9]*]], metadata [[TCNARG4:![0-9]*]], metadata [[TCNARG5:![0-9]*]], metadata [[TCNARG6:![0-9]*]], metadata [[TCARG7:![0-9]*]], metadata [[TCNARG8:![0-9]*]]}
-// CHECK: [[TCNARG1]] = {{.*}}metadata !"T", metadata [[INT]], {{.*}} ; [ DW_TAG_template_type_parameter ]
-// CHECK: [[TCNARG2]] = {{.*}}metadata !"", metadata [[INT]], i32 -3, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[TCNARG3]] = {{.*}}metadata !"x", metadata [[INTPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: metadata !{metadata !"0x13\00{{.*}}", metadata !{{[0-9]*}}, metadata !"_ZTS2TCIjLj2EXadL_Z3glbEEXadL_ZN3foo1eEEEXadL_ZNS0_1fEvEEXadL_ZNS0_1gEvEEJLi1ELi2ELi3EEE", {{.*}}, metadata !"[[TCNESTED:.*]]"} ; [ DW_TAG_structure_type ] [nested]
+// CHECK: metadata [[TCNARGS:![0-9]*]], metadata !"[[TCNT:.*]]"} ; [ DW_TAG_structure_type ] [TC<int, -3, nullptr, nullptr, nullptr, nullptr>]
+// CHECK: [[TCNARGS]] = metadata !{metadata [[TCNARG1:![0-9]*]], metadata [[TCNARG2:![0-9]*]], metadata [[TCNARG3:![0-9]*]], metadata [[TCNARG4:![0-9]*]], metadata [[TCNARG5:![0-9]*]], metadata [[TCNARG6:![0-9]*]], metadata [[TCNARG7:![0-9]*]]}
+// CHECK: [[TCNARG1]] = metadata !{metadata !"0x2f\00T\000\000", null, metadata [[INT]], null} ; [ DW_TAG_template_type_parameter ]
+// CHECK: [[TCNARG2]] = metadata !{metadata !"0x30\00\000\000", null, metadata [[INT]], i32 -3, null} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCNARG3]] = metadata !{metadata !"0x30\00x\000\000", null, metadata [[CINTPTR]], i8 0, null} ; [ DW_TAG_template_value_parameter ]
 
 // The interesting null pointer: -1 for member data pointers (since they are
 // just an offset in an object, they can be zero and non-null for the first
 // member)
 
-// CHECK: [[TCNARG4]] = {{.*}}metadata !"a", metadata [[MEMINTPTR]], i64 -1, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCNARG4]] = metadata !{metadata !"0x30\00a\000\000", null, metadata [[MEMINTPTR]], i64 -1, null} ; [ DW_TAG_template_value_parameter ]
 //
 // In some future iteration we could possibly emit the value of a null member
 // function pointer as '{ i64, i64 } zeroinitializer' as it may be handled
 // naturally from the LLVM CodeGen side once we decide how to handle non-null
 // member function pointers. For now, it's simpler just to emit the 'i8 0'.
 //
-// CHECK: [[TCNARG5]] = {{.*}}metadata !"b", metadata [[MEMFUNPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[TCNARG6]] = {{.*}}metadata !"f", metadata [[FUNPTR]], i8 0, {{.*}} ; [ DW_TAG_template_value_parameter ]
-// CHECK: [[TCNARG8]] = {{.*}}metadata !"Is", null, metadata [[EMPTY]], {{.*}} ; [ DW_TAG_GNU_template_parameter_pack ]
+// CHECK: [[TCNARG5]] = metadata !{metadata !"0x30\00b\000\000", null, metadata [[MEMFUNPTR]], i8 0, null} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCNARG6]] = metadata !{metadata !"0x30\00f\000\000", null, metadata [[FUNPTR]], i8 0, null} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TCNARG7]] = metadata !{metadata !"0x4107\00Is\000\000", null, null, metadata [[EMPTY]], null} ; [ DW_TAG_GNU_template_parameter_pack ]
+
+// FIXME: these parameters should probably be rendered as 'glb' rather than
+// '&glb', since they're references, not pointers.
+// CHECK: metadata [[NNARGS:![0-9]*]], metadata !"[[NNT:.*]]"} ; [ DW_TAG_structure_type ] [NN<tmpl_impl, &glb, &glb>]
+// CHECK: [[NNARGS]] = metadata !{metadata [[NNARG1:![0-9]*]], metadata [[NNARG2:![0-9]*]], metadata [[NNARG3:![0-9]*]]}
+// CHECK: [[NNARG1]] = metadata !{metadata !"0x4106\00tmpl\000\000", null, null, metadata !"tmpl_impl", null} ; [ DW_TAG_GNU_template_template_param ]
+// CHECK: [[NNARG2]] = metadata !{metadata !"0x30\00lvr\00{{.*}}", {{[^,]+}}, metadata [[INTLVR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[INTLVR]] = {{.*}}, metadata [[INT]]} ; [ DW_TAG_reference_type ] {{.*}} [from int]
+// CHECK: [[NNARG3]] = metadata !{metadata !"0x30\00rvr\00{{.*}}", {{[^,]+}}, metadata [[INTRVR:![0-9]*]], i32* @glb, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[INTRVR]] = {{.*}}, metadata [[INT]]} ; [ DW_TAG_rvalue_reference_type ] {{.*}} [from int]
 
 // CHECK: metadata [[PTOARGS:![0-9]*]], metadata !"{{.*}}"} ; [ DW_TAG_structure_type ] [PaddingAtEndTemplate<&PaddedObj>]
 // CHECK: [[PTOARGS]] = metadata !{metadata [[PTOARG1:![0-9]*]]}
-// CHECK: [[PTOARG1]] = {{.*}}metadata !"", metadata [[CONST_PADDINGATEND_PTR:![0-9]*]], { i32, i8, [3 x i8] }* @PaddedObj, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[PTOARG1]] = metadata !{metadata !"0x30\00\000\000", null, metadata [[CONST_PADDINGATEND_PTR:![0-9]*]], %struct.PaddingAtEnd* @PaddedObj, null} ; [ DW_TAG_template_value_parameter ]
 // CHECK: [[CONST_PADDINGATEND_PTR]] = {{.*}} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS12PaddingAtEnd]
 
-// CHECK: metadata !"[[TCNESTED]]", i32 0, i32 1, %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &func, tmpl_impl, 1, 2, 3>::nested"* @tci, null} ; [ DW_TAG_variable ] [tci]
+// CHECK: metadata !"[[TCNESTED]]", %"struct.TC<unsigned int, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested"* @tci, null} ; [ DW_TAG_variable ] [tci]
 
-// CHECK: metadata !"[[TCNT]]", i32 0, i32 1, %struct.TC* @tcn, null} ; [ DW_TAG_variable ] [tcn]
+// CHECK: metadata !"[[TCNT]]", %struct.TC* @tcn, null} ; [ DW_TAG_variable ] [tcn]
+
+// CHECK: metadata !"[[NNT]]", %struct.NN* @nn, null} ; [ DW_TAG_variable ] [nn]
 struct foo {
   char pad[8]; // make the member pointer to 'e' a bit more interesting (nonzero)
   int e;
   void f();
+  static void g();
 };
 
-template<typename T, T, int *x, int foo::*a, void (foo::*b)(), void (*f)(), template<typename> class tmpl, int ...Is>
+typedef int foo::*foo_mem;
+
+template<typename T, T, const int *x, foo_mem a, void (foo::*b)(), void (*f)(), int ...Is>
 struct TC {
   struct nested {
   };
@@ -95,12 +109,18 @@
 int glb;
 void func();
 
+TC<unsigned, 2, &glb, &foo::e, &foo::f, &foo::g, 1, 2, 3>::nested tci;
+TC<int, -3, nullptr, nullptr, nullptr, nullptr> tcn;
+
 template<typename>
 struct tmpl_impl {
 };
 
-TC<unsigned, 2, &glb, &foo::e, &foo::f, &func, tmpl_impl, 1, 2, 3>::nested tci;
-TC<int, -3, nullptr, nullptr, nullptr, nullptr, tmpl_impl> tcn;
+template <template <typename> class tmpl, int &lvr, int &&rvr>
+struct NN {
+};
+
+NN<tmpl_impl, glb, glb> nn;
 
 struct PaddingAtEnd {
   int i;
@@ -109,7 +129,7 @@
 
 PaddingAtEnd PaddedObj = {};
 
-template <const PaddingAtEnd *>
+template <PaddingAtEnd *>
 struct PaddingAtEndTemplate {
 };
 
diff --git a/test/CodeGenCXX/debug-info-thunk.cpp b/test/CodeGenCXX/debug-info-thunk.cpp
index 1d6f1a7..a2dd43c 100644
--- a/test/CodeGenCXX/debug-info-thunk.cpp
+++ b/test/CodeGenCXX/debug-info-thunk.cpp
@@ -14,4 +14,4 @@
 
 void C::f() { }
 
-// CHECK: metadata !"_ZThn{{4|8}}_N1C1fEv", i32 15, {{.*}} ; [ DW_TAG_subprogram ] [line 15] [def]{{$}}
+// CHECK: metadata !{metadata !"0x2e\00\00\00_ZThn{{[48]}}_N1C1fEv\0015\00{{.*}}", {{.*}} ; [ DW_TAG_subprogram ] [line 15] [def]{{$}}
diff --git a/test/CodeGenCXX/debug-info-union-template.cpp b/test/CodeGenCXX/debug-info-union-template.cpp
index 570520d..6f644a9 100644
--- a/test/CodeGenCXX/debug-info-union-template.cpp
+++ b/test/CodeGenCXX/debug-info-union-template.cpp
@@ -10,6 +10,6 @@
   Value<float> f;
 }
 
-// CHECK: {{.*}}, metadata !"Value<float>", {{.*}}, null, metadata [[TTPARAM:.*]], metadata !"_ZTSN7PR156375ValueIfEE"} ; [ DW_TAG_union_type ] [Value<float>]
+// CHECK: metadata !{metadata !"0x17\00Value<float>\00{{.*}}", {{.*}}, metadata [[TTPARAM:![0-9]+]], metadata !"_ZTSN7PR156375ValueIfEE"} ; [ DW_TAG_union_type ] [Value<float>]
 // CHECK: [[TTPARAM]] = metadata !{metadata [[PARAMS:.*]]}
-// CHECK: [[PARAMS]] = metadata !{{{.*}}metadata !"T",{{.*}}} ; [ DW_TAG_template_type_parameter ]
+// CHECK: [[PARAMS]] = metadata !{metadata !"0x2f\00T\000\000", {{.*}} ; [ DW_TAG_template_type_parameter ]
diff --git a/test/CodeGenCXX/debug-info-uuid.cpp b/test/CodeGenCXX/debug-info-uuid.cpp
index 6137400..5bc0489 100644
--- a/test/CodeGenCXX/debug-info-uuid.cpp
+++ b/test/CodeGenCXX/debug-info-uuid.cpp
@@ -1,14 +1,20 @@
 // RUN: %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-pc-win32 -g %s -o - -std=c++11 | FileCheck %s
-// RUN: not %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-unknown-unknown -g %s -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-ITANIUM
+// RUN: %clang_cc1 -emit-llvm -fms-extensions -triple=x86_64-unknown-unknown -g %s -o - -std=c++11 2>&1 | FileCheck %s --check-prefix=CHECK-ITANIUM
 
 // CHECK: metadata [[TGIARGS:![0-9]*]], null} ; [ DW_TAG_structure_type ] [tmpl_guid<&__uuidof(uuid)>]
 // CHECK: [[TGIARGS]] = metadata !{metadata [[TGIARG1:![0-9]*]]}
-// CHECK: [[TGIARG1]] = {{.*}}metadata !"", metadata [[CONST_GUID_PTR:![0-9]*]], { i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[TGIARG1]] = metadata !{metadata !"0x30\00\00{{.*}}", {{[^,]+}}, metadata [[CONST_GUID_PTR:![0-9]*]], { i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab, {{.*}} ; [ DW_TAG_template_value_parameter ]
 // CHECK: [[CONST_GUID_PTR]] = {{.*}}, metadata [[CONST_GUID:![0-9]*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ]
 // CHECK: [[CONST_GUID]] = {{.*}}, metadata [[GUID:![0-9]*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from _GUID]
 // CHECK: [[GUID]] = {{.*}} ; [ DW_TAG_structure_type ] [_GUID]
 
-// CHECK-ITANIUM: error: cannot yet mangle expression type CXXUuidofExpr
+// CHECK: metadata [[TGI2ARGS:![0-9]*]], null} ; [ DW_TAG_structure_type ] [tmpl_guid2<__uuidof(uuid)>]
+// CHECK: [[TGI2ARGS]] = metadata !{metadata [[TGI2ARG1:![0-9]*]]}
+// CHECK: [[TGI2ARG1]] = metadata !{metadata !"0x30\00\00{{.*}}", {{[^,]+}}, metadata [[CONST_GUID_REF:![0-9]*]], { i32, i16, i16, [8 x i8] }* @_GUID_12345678_1234_1234_1234_1234567890ab, {{.*}} ; [ DW_TAG_template_value_parameter ]
+// CHECK: [[CONST_GUID_REF]] = {{.*}}, metadata [[CONST_GUID:![0-9]*]]} ; [ DW_TAG_reference_type ] [line 0, size 0, align 0, offset 0] [from ]
+
+// CHECK-ITANIUM: metadata !"_ZTS9tmpl_guidIXadu8__uuidoft4uuidEE"} ; [ DW_TAG_structure_type ] [tmpl_guid<&__uuidof(uuid)>]
+// CHECK-ITANIUM: metadata !"_ZTS10tmpl_guid2IXu8__uuidoft4uuidEE"} ; [ DW_TAG_structure_type ] [tmpl_guid2<__uuidof(uuid)>]
 
 struct _GUID;
 template <const _GUID *>
@@ -17,3 +23,7 @@
 
 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890ab}")) uuid;
 tmpl_guid<&__uuidof(uuid)> tgi;
+
+template <const _GUID &>
+struct tmpl_guid2 {};
+tmpl_guid2<__uuidof(uuid)> tgi2;
diff --git a/test/CodeGenCXX/debug-info-varargs.cpp b/test/CodeGenCXX/debug-info-varargs.cpp
index cc92477..6175e65 100644
--- a/test/CodeGenCXX/debug-info-varargs.cpp
+++ b/test/CodeGenCXX/debug-info-varargs.cpp
@@ -2,21 +2,21 @@
 
 struct A
 {
-  // CHECK-DAG: ", i32 [[@LINE+1]], metadata ![[ATY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[a]
+  // CHECK-DAG: metadata !{metadata !"0x2e\00a\00a\00_ZN1A1aEiz\00[[@LINE+1]]\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[ATY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[a]
   void a(int c, ...) {}
-  // CHECK: ![[ATY]] ={{.*}} metadata ![[AARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
-  // CHECK: ![[AARGS]] = {{.*}} metadata ![[UNSPEC:[0-9]+]]}
-  // CHECK: ![[UNSPEC]] = {{.*}} [ DW_TAG_unspecified_parameters ]
+  // CHECK: ![[ATY]] ={{.*}} metadata ![[AARGS:[0-9]+]], null, null, null} ; [ DW_TAG_subroutine_type ]
+  // We no longer use an explicit unspecified parameter. Instead we use a trailing null to mean the function is variadic.
+  // CHECK: ![[AARGS]] = metadata !{null, metadata !{{[0-9]+}}, metadata !{{[0-9]+}}, null}
 };
 
-  // CHECK: ", i32 [[@LINE+1]], metadata ![[BTY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[b]
+  // CHECK: metadata !{metadata !"0x2e\00b\00b\00_Z1biz\00[[@LINE+1]]\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[BTY:[0-9]+]]{{.*}}[ DW_TAG_subprogram ]{{.*}}[b]
 void b(int c, ...) {
-  // CHECK: ![[BTY]] ={{.*}} metadata ![[BARGS:[0-9]+]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ]
-  // CHECK: ![[BARGS]] = {{.*}} metadata ![[UNSPEC:[0-9]+]]}
+  // CHECK: ![[BTY]] ={{.*}} metadata ![[BARGS:[0-9]+]], null, null, null} ; [ DW_TAG_subroutine_type ]
+  // CHECK: ![[BARGS]] = metadata !{null, metadata !{{[0-9]+}}, null}
 
   A a;
 
-  // CHECK: metadata ![[PST:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [fptr] [line [[@LINE+1]]]
+  // CHECK: metadata !{metadata !"0x100\00fptr\00[[@LINE+1]]\000"{{, [^,]+, [^,]+}}, metadata ![[PST:[0-9]+]]} ; [ DW_TAG_auto_variable ] [fptr] [line [[@LINE+1]]]
   void (*fptr)(int, ...) = b;
   // CHECK: ![[PST]] ={{.*}} metadata ![[BTY]]} ; [ DW_TAG_pointer_type ]
 }
diff --git a/test/CodeGenCXX/debug-info-wchar.cpp b/test/CodeGenCXX/debug-info-wchar.cpp
index 6f53849..dff3b3c 100644
--- a/test/CodeGenCXX/debug-info-wchar.cpp
+++ b/test/CodeGenCXX/debug-info-wchar.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm -g %s -o -| FileCheck %s
 void foo() {
-// CHECK: metadata !"wchar_t",
+// CHECK: metadata !{metadata !"0x24\00wchar_t\00{{.*}}", null, null} ; [ DW_TAG_base_type ] [wchar_t]
   const wchar_t w = L'x';
 }
diff --git a/test/CodeGenCXX/debug-info-zero-length-arrays.cpp b/test/CodeGenCXX/debug-info-zero-length-arrays.cpp
index 1017965..144c476 100644
--- a/test/CodeGenCXX/debug-info-zero-length-arrays.cpp
+++ b/test/CodeGenCXX/debug-info-zero-length-arrays.cpp
@@ -7,6 +7,6 @@
 A a;
 
 // CHECK: metadata [[ARRAY_TYPE:![0-9]*]]} ; [ DW_TAG_member ] [x]
-// CHECK: metadata [[ELEM_TYPE:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int]
+// CHECK: metadata !{metadata !"0x1\00\000\000\0032\000\000\000", null, null, metadata {{![0-9]+}}, metadata [[ELEM_TYPE:![0-9]+]], null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int]
 // CHECK: [[ELEM_TYPE]] = metadata !{metadata [[SUBRANGE:.*]]}
-// CHECK: [[SUBRANGE]] = metadata !{i32 786465, i64 0, i64 -1} ; [ DW_TAG_subrange_type ] [unbounded]
+// CHECK: [[SUBRANGE]] = metadata !{metadata !"0x21\000\00-1"} ; [ DW_TAG_subrange_type ] [unbounded]
diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp
index 7c89dfc..95a53fe 100644
--- a/test/CodeGenCXX/debug-info.cpp
+++ b/test/CodeGenCXX/debug-info.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -g %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -g %s -o - | FileCheck %s --check-prefix=MSVC
+
 template<typename T> struct Identity {
   typedef T Type;
 };
@@ -43,14 +45,25 @@
 }
 
 namespace VirtualBase {
-  struct A { };
-  struct B : virtual A { };
+  struct A { int a; };
+  struct B : virtual A { int b; };
 
   void f() {
     B b;
   }
 }
 
+// MSVC: [[VBASE_B:![0-9]+]] = metadata !{metadata !"0x13\00B\00{{[0-9]+}}\0096\0032\000\000\000", {{.*}}, null, metadata [[VBASE_B_DEF:![0-9]+]], {{.*}}} ; [ DW_TAG_structure_type ] [B] [line 49, size 96, align 32, offset 0] [def] [from ]
+// MSVC: [[VBASE_B_DEF]] = metadata !{metadata [[VBASE_A_IN_B:![0-9]+]],
+//
+// Look for the vbtable offset of A, which should be 4.
+// MSVC: [[VBASE_A_IN_B]] = metadata !{metadata !"0x1c\00\000\000\000\004\0032", null, metadata [[VBASE_B]], metadata !{{[0-9]*}}} ; [ DW_TAG_inheritance ] [line 0, size 0, align 0, offset 4] [from A]
+
+// CHECK: metadata !{metadata !"0x13\00B\00{{[0-9]+}}\00128\0064\000\000\000", {{.*}}, null, metadata [[VBASE_B_DEF:![0-9]+]], {{.*}}} ; [ DW_TAG_structure_type ] [B] [line 49, size 128, align 64, offset 0] [def] [from ]
+// CHECK: [[VBASE_B_DEF]] = metadata !{metadata [[VBASE_A_IN_B:![0-9]+]],
+//
+// Look for the vtable offset offset, which should be -24.
+// CHECK: [[VBASE_A_IN_B]] = metadata !{metadata !"0x1c\00\000\000\000\0024\0032", null, metadata !"_ZTSN11VirtualBase1BE", metadata !"_ZTSN11VirtualBase1AE"} ; [ DW_TAG_inheritance ] [line 0, size 0, align 0, offset 24] [from _ZTSN11VirtualBase1AE]
 namespace b5249287 {
 template <typename T> class A {
   struct B;
@@ -72,15 +85,15 @@
   return f; // reference 'f' for now because otherwise we hit another bug
 }
 
-// CHECK: metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata [[PR14763:![0-9]*]], {{.*}}, metadata !"[[FOO:.*]]"} ; [ DW_TAG_structure_type ] [foo]
+// CHECK: metadata !{metadata !"0x13\00{{.*}}", metadata !{{[0-9]*}}, metadata [[PR14763:![0-9]*]], {{.*}}, metadata !"[[FOO:.*]]"} ; [ DW_TAG_structure_type ] [foo]
 // CHECK: [[PR14763]] = {{.*}} ; [ DW_TAG_namespace ] [pr14763]
 // CHECK: [[INCTYPE:![0-9]*]] = {{.*}} ; [ DW_TAG_structure_type ] [incomplete]{{.*}} [decl]
-// CHECK: metadata [[A_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN7pr162141aE"} ; [ DW_TAG_structure_type ] [a]
+// CHECK: metadata [[A_MEM:![0-9]*]], null, null, metadata !"_ZTSN7pr162141aE"} ; [ DW_TAG_structure_type ] [a]
 // CHECK: [[A_MEM]] = metadata !{metadata [[A_I:![0-9]*]]}
 // CHECK: [[A_I]] = {{.*}} ; [ DW_TAG_member ] [i] {{.*}} [from int]
 // CHECK: ; [ DW_TAG_structure_type ] [b] {{.*}}[decl]
 
-// CHECK: [[FUNC:![0-9]*]] = {{.*}} metadata !"_ZN7pr147634funcENS_3fooE", i32 {{[0-9]*}}, metadata [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
+// CHECK: [[FUNC:![0-9]*]] = metadata !{metadata !"0x2e\00func\00func\00_ZN7pr147634funcENS_3fooE\00{{.*}}"{{, [^,]+, [^,]+}}, metadata [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
 }
 
 void foo() {
@@ -93,13 +106,13 @@
 namespace pr9608 { // also pr9600
 struct incomplete;
 incomplete (*x)[3];
-// CHECK: metadata [[INCARRAYPTR:![0-9]*]], i32 0, i32 1, [3 x i8]** @_ZN6pr96081xE, null} ; [ DW_TAG_variable ] [x]
+// CHECK: metadata [[INCARRAYPTR:![0-9]*]], [3 x i8]** @_ZN6pr96081xE, null} ; [ DW_TAG_variable ] [x]
 // CHECK: [[INCARRAYPTR]] = {{.*}}metadata [[INCARRAY:![0-9]*]]} ; [ DW_TAG_pointer_type ]
-// CHECK: [[INCARRAY]] = {{.*}}metadata !"_ZTSN6pr960810incompleteE", metadata {{![0-9]*}}, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 0, offset 0] [from _ZTSN6pr960810incompleteE]
+// CHECK: [[INCARRAY]] = metadata !{metadata !"0x1\00\000\000\000\000\000\000", null, null, metadata !"_ZTSN6pr960810incompleteE", metadata {{![0-9]+}}, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 0, offset 0] [from _ZTSN6pr960810incompleteE]
 }
 
 // For some reason function arguments ended up down here
-// CHECK: = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], {{.*}}, metadata !"[[FOO]]", i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [f]
+// CHECK: = metadata !{metadata !"0x101\00f\00{{.*}}\008192", metadata [[FUNC]], metadata {{![0-9]+}}, metadata !"[[FOO]]"} ; [ DW_TAG_arg_variable ] [f]
 
 // CHECK: ; [ DW_TAG_auto_variable ] [c]
 
diff --git a/test/CodeGenCXX/debug-lambda-expressions.cpp b/test/CodeGenCXX/debug-lambda-expressions.cpp
index 0b08736..f8ccbae 100644
--- a/test/CodeGenCXX/debug-lambda-expressions.cpp
+++ b/test/CodeGenCXX/debug-lambda-expressions.cpp
@@ -30,38 +30,38 @@
 // CHECK: [[D_FUNC:.*]] = {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE:.*]]] [def] [d]
 
 // Back to D. -- 24
-// CHECK: [[LAM_D:.*]] = {{.*}}, metadata [[D_FUNC]], {{.*}}, metadata [[LAM_D_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[D_LINE]],
+// CHECK: [[LAM_D:.*]] = {{.*}}, metadata [[D_FUNC]], {{.*}}, metadata [[LAM_D_ARGS:.*]], null, null, null} ; [ DW_TAG_class_type ] [line [[D_LINE]],
 // CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]]}
 // CHECK: [[CAP_D_X]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_member ] [x] [line [[D_LINE]],
 // CHECK: [[CAP_D_Y]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_member ] [y] [line [[D_LINE]],
-// CHECK: [[CON_LAM_D]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE]]] [operator()]
+// CHECK: [[CON_LAM_D]] = {{.*}}, metadata [[LAM_D]], {{.*}} [ DW_TAG_subprogram ] [line [[D_LINE]]] [public] [operator()]
 
 
 // Back to C. -- 55
-// CHECK: [[LAM_C:.*]] = {{.*}}, metadata [[C_FUNC]], {{.*}}, metadata [[LAM_C_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[C_LINE]],
+// CHECK: [[LAM_C:.*]] = {{.*}}, metadata [[C_FUNC]], {{.*}}, metadata [[LAM_C_ARGS:.*]], null, null, null} ; [ DW_TAG_class_type ] [line [[C_LINE]],
 // CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]]}
 // Ignoring the member type for now.
 // CHECK: [[CAP_C]] = {{.*}}, metadata [[LAM_C]], {{.*}}} ; [ DW_TAG_member ] [x] [line [[C_LINE]],
-// CHECK: [[CON_LAM_C]] = {{.*}}, metadata [[LAM_C]], {{.*}} [ DW_TAG_subprogram ] [line [[C_LINE]]] [operator()]
+// CHECK: [[CON_LAM_C]] = {{.*}}, metadata [[LAM_C]], {{.*}} [ DW_TAG_subprogram ] [line [[C_LINE]]] [public] [operator()]
 
 
 // Back to B. -- 67
-// CHECK: [[LAM_B:.*]] = {{.*}}, metadata [[B_FUNC]], {{.*}}, metadata [[LAM_B_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[B_LINE]],
+// CHECK: [[LAM_B:.*]] = {{.*}}, metadata [[B_FUNC]], {{.*}}, metadata [[LAM_B_ARGS:.*]], null, null, null} ; [ DW_TAG_class_type ] [line [[B_LINE]],
 // CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]]}
 // CHECK: [[CAP_B]] = {{.*}}, metadata [[LAM_B]], {{.*}}} ; [ DW_TAG_member ] [x] [line [[B_LINE]],
-// CHECK: [[CON_LAM_B]] = {{.*}}, metadata [[LAM_B]], {{.*}} [ DW_TAG_subprogram ] [line [[B_LINE]]] [operator()]
+// CHECK: [[CON_LAM_B]] = {{.*}}, metadata [[LAM_B]], {{.*}} [ DW_TAG_subprogram ] [line [[B_LINE]]] [public] [operator()]
 
 // Back to A. -- 78
-// CHECK: [[LAM_A:.*]] = {{.*}}, metadata [[A_FUNC]], {{.*}}, metadata [[LAM_A_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[A_LINE]],
+// CHECK: [[LAM_A:.*]] = {{.*}}, metadata [[A_FUNC]], {{.*}}, metadata [[LAM_A_ARGS:.*]], null, null, null} ; [ DW_TAG_class_type ] [line [[A_LINE]],
 // CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]]}
-// CHECK: [[CON_LAM_A]] = {{.*}}, metadata [[LAM_A]], {{.*}} [ DW_TAG_subprogram ] [line [[A_LINE]]] [operator()]
+// CHECK: [[CON_LAM_A]] = {{.*}}, metadata [[LAM_A]], {{.*}} [ DW_TAG_subprogram ] [line [[A_LINE]]] [public] [operator()]
 
 // CVAR:
 // CHECK: {{.*}} metadata [[CVAR_T:![0-9]*]], {{.*}} ; [ DW_TAG_variable ] [cvar] [line [[CVAR_LINE:[0-9]*]]] 
-// CHECK: [[CVAR_T]] = {{.*}}, metadata ![[CVAR_ARGS:.*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[CVAR_LINE]],
+// CHECK: [[CVAR_T]] = {{.*}}, metadata ![[CVAR_ARGS:.*]], null, null, null} ; [ DW_TAG_class_type ] [line [[CVAR_LINE]],
 // CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}}
 
 // VAR:
 // CHECK: {{.*}} metadata [[VAR_T:![0-9]*]], {{.*}} ; [ DW_TAG_variable ] [var] [line [[VAR_LINE:[0-9]*]]]
-// CHECK: [[VAR_T]] = {{.*}}, metadata [[VAR_ARGS:![0-9]*]], i32 0, null, null, null} ; [ DW_TAG_class_type ] [line [[VAR_LINE]],
+// CHECK: [[VAR_T]] = {{.*}}, metadata [[VAR_ARGS:![0-9]*]], null, null, null} ; [ DW_TAG_class_type ] [line [[VAR_LINE]],
 // CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}}
diff --git a/test/CodeGenCXX/debug-lambda-this.cpp b/test/CodeGenCXX/debug-lambda-this.cpp
index e7155e7..87a317d 100644
--- a/test/CodeGenCXX/debug-lambda-this.cpp
+++ b/test/CodeGenCXX/debug-lambda-this.cpp
@@ -12,4 +12,4 @@
   }();
 }
 
-// CHECK: {{.*}} [ DW_TAG_member ] [this] [line 11, size 64, align 64, offset 0] [private] [from ]
+// CHECK: {{.*}} [ DW_TAG_member ] [this] [line 11, size 64, align 64, offset 0] [from ]
diff --git a/test/CodeGenCXX/decl-ref-init.cpp b/test/CodeGenCXX/decl-ref-init.cpp
index 333e388..117d277 100644
--- a/test/CodeGenCXX/decl-ref-init.cpp
+++ b/test/CodeGenCXX/decl-ref-init.cpp
@@ -23,5 +23,5 @@
 	const A& rca2 = d();
 }
 
-// CHECK: call nonnull %struct.A* @_ZN1BcvR1AEv
-// CHECK: call nonnull %struct.A* @_ZN1BcvR1AEv
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.A* @_ZN1BcvR1AEv
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.A* @_ZN1BcvR1AEv
diff --git a/test/CodeGenCXX/default-arg-temps.cpp b/test/CodeGenCXX/default-arg-temps.cpp
index 7910942..6a7f43a 100644
--- a/test/CodeGenCXX/default-arg-temps.cpp
+++ b/test/CodeGenCXX/default-arg-temps.cpp
@@ -16,12 +16,12 @@
 // CHECK-LABEL: define void @_Z1gv()
 void g() {
   // CHECK:      call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]])
-  // CHECK-NEXT: call void @_Z1fRK1T([[T]]* nonnull [[AGG1]])
+  // CHECK-NEXT: call void @_Z1fRK1T([[T]]* dereferenceable({{[0-9]+}}) [[AGG1]])
   // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG1]])
   f();
 
   // CHECK-NEXT: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG2:%.*]])
-  // CHECK-NEXT: call void @_Z1fRK1T([[T]]* nonnull [[AGG2]])
+  // CHECK-NEXT: call void @_Z1fRK1T([[T]]* dereferenceable({{[0-9]+}}) [[AGG2]])
   // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG2]])
   f();
 
diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp
index 7589cf6..f4ef0e5 100644
--- a/test/CodeGenCXX/derived-to-base-conv.cpp
+++ b/test/CodeGenCXX/derived-to-base-conv.cpp
@@ -33,9 +33,9 @@
   test0_helper(x);
   // CHECK-LABEL:    define void @_Z5test01X(
   // CHECK:      [[TMP:%.*]] = alloca [[A:%.*]], align
-  // CHECK-NEXT: [[T0:%.*]] = call nonnull [[B:%.*]]* @_ZN1XcvR1BEv(
+  // CHECK-NEXT: [[T0:%.*]] = call dereferenceable({{[0-9]+}}) [[B:%.*]]* @_ZN1XcvR1BEv(
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]* [[T0]] to [[A]]*
-  // CHECK-NEXT: call void @_ZN1AC1ERKS_([[A]]* [[TMP]], [[A]]* nonnull [[T1]])
+  // CHECK-NEXT: call void @_ZN1AC1ERKS_([[A]]* [[TMP]], [[A]]* dereferenceable({{[0-9]+}}) [[T1]])
   // CHECK-NEXT: call void @_Z12test0_helper1A([[A]]* [[TMP]])
   // CHECK-NEXT: call void @_ZN1AD1Ev([[A]]* [[TMP]])
   // CHECK-NEXT: ret void
diff --git a/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp b/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp
index cf876b4..d859283 100644
--- a/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp
+++ b/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp
@@ -9,7 +9,7 @@
   virtual void f();
 };
 
-// CHECK-LABEL: define nonnull %struct.B* @_Z1fR1D
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.B* @_Z1fR1D
 B &f(D &d) {
   // CHECK-NOT: load i8**
   return d;
diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp
index 5c43048..bc9a683 100644
--- a/test/CodeGenCXX/destructors.cpp
+++ b/test/CodeGenCXX/destructors.cpp
@@ -1,21 +1,13 @@
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns | FileCheck %s
-
-// CHECK-DAG: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
-// CHECK-DAG: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
-// CHECK-DAG: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev
-// CHECK-DAG: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
-// CHECK-DAG: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
-
-// WIN32-DAG: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
-// WIN32-DAG: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
-// WIN32-DAG: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev
-// WIN32-DAG: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
-// WIN32-DAG: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
-
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns > %t
+// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
 
 struct A {
   int a;
-  
+
   ~A();
 };
 
@@ -29,7 +21,7 @@
 // Field with non-trivial destructor
 struct C {
   A a;
-  
+
   ~C();
 };
 
@@ -43,11 +35,11 @@
 
   struct allocator_derived : allocator { };
 
-  // CHECK-LABEL: define void @_ZN6PR75263fooEv()
-  // CHECK: call void {{.*}} @_ZN6PR75269allocatorD2Ev
+  // CHECK1-LABEL: define void @_ZN6PR75263fooEv()
+  // CHECK1: call void {{.*}} @_ZN6PR75269allocatorD2Ev
 
-  // CHECK-LABEL: define void @_ZN6PR75269allocatorD2Ev(%"struct.PR7526::allocator"* %this) unnamed_addr
-  // CHECK: call void @__cxa_call_unexpected
+  // CHECK1-LABEL: define void @_ZN6PR75269allocatorD2Ev(%"struct.PR7526::allocator"* %this) unnamed_addr
+  // CHECK1: call void @__cxa_call_unexpected
   allocator::~allocator() throw() { foo(); }
 
   void foo() {
@@ -68,12 +60,12 @@
   struct A {
     ~A();
   };
-  
+
   A::~A() { }
   struct B : A {
     virtual ~B();
   };
-  
+
   B::~B()  {}
 }
 
@@ -96,11 +88,12 @@
 
 // complete destructor alias tested above
 
-// CHECK-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr
-// CHECK: invoke void @_ZN5test06MemberD1Ev
-// CHECK:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
-// CHECK: invoke void @_ZN5test04BaseD2Ev
-// CHECK:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2-LABEL: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK2-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr
+// CHECK2: invoke void @_ZN5test06MemberD1Ev
+// CHECK2:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2: invoke void @_ZN5test04BaseD2Ev
+// CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
   struct B : Base, virtual VBase {
     Member M;
@@ -109,19 +102,19 @@
   B::~B() try { } catch (int i) {}
   // It will suppress the delegation optimization here, though.
 
-// CHECK-LABEL: define void @_ZN5test01BD2Ev(%"struct.test0::B"* %this, i8** %vtt) unnamed_addr
-// CHECK: invoke void @_ZN5test06MemberD1Ev
-// CHECK:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
-// CHECK: invoke void @_ZN5test04BaseD2Ev
-// CHECK:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2-LABEL: define void @_ZN5test01BD2Ev(%"struct.test0::B"* %this, i8** %vtt) unnamed_addr
+// CHECK2: invoke void @_ZN5test06MemberD1Ev
+// CHECK2:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2: invoke void @_ZN5test04BaseD2Ev
+// CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
-// CHECK-LABEL: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) unnamed_addr
-// CHECK: invoke void @_ZN5test06MemberD1Ev
-// CHECK:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
-// CHECK: invoke void @_ZN5test04BaseD2Ev
-// CHECK:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
-// CHECK: invoke void @_ZN5test05VBaseD2Ev
-// CHECK:   unwind label [[VBASE_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2-LABEL: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) unnamed_addr
+// CHECK2: invoke void @_ZN5test06MemberD1Ev
+// CHECK2:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2: invoke void @_ZN5test04BaseD2Ev
+// CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK2: invoke void @_ZN5test05VBaseD2Ev
+// CHECK2:   unwind label [[VBASE_UNWIND:%[a-zA-Z0-9.]+]]
 }
 
 // Test base-class aliasing.
@@ -136,33 +129,37 @@
   A::~A() { delete m; }
 
   struct M : A { ~M(); };
-  M::~M() {} // alias tested above
+  M::~M() {}
+  // CHECK3: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
 
   struct N : A, Empty { ~N(); };
-  N::~N() {} // alias tested above
+  N::~N() {}
+  // CHECK3: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev
 
   struct O : Empty, A { ~O(); };
-  O::~O() {} // alias tested above
+  O::~O() {}
+  // CHECK3: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
 
   struct P : NonEmpty, A { ~P(); };
-  P::~P() {} // CHECK-LABEL: define void @_ZN5test11PD2Ev(%"struct.test1::P"* %this) unnamed_addr
+  P::~P() {} // CHECK3-LABEL: define void @_ZN5test11PD2Ev(%"struct.test1::P"* %this) unnamed_addr
 
   struct Q : A, B { ~Q(); };
-  Q::~Q() {} // CHECK-LABEL: define void @_ZN5test11QD2Ev(%"struct.test1::Q"* %this) unnamed_addr
+  Q::~Q() {} // CHECK3-LABEL: define void @_ZN5test11QD2Ev(%"struct.test1::Q"* %this) unnamed_addr
 
   struct R : A { ~R(); };
-  R::~R() { A a; } // CHECK-LABEL: define void @_ZN5test11RD2Ev(%"struct.test1::R"* %this) unnamed_addr
+  R::~R() { A a; } // CHECK3-LABEL: define void @_ZN5test11RD2Ev(%"struct.test1::R"* %this) unnamed_addr
 
   struct S : A { ~S(); int x; };
-  S::~S() {} // alias tested above
+  S::~S() {}
+  // CHECK4: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
 
   struct T : A { ~T(); B x; };
-  T::~T() {} // CHECK-LABEL: define void @_ZN5test11TD2Ev(%"struct.test1::T"* %this) unnamed_addr
+  T::~T() {} // CHECK4-LABEL: define void @_ZN5test11TD2Ev(%"struct.test1::T"* %this) unnamed_addr
 
   // The VTT parameter prevents this.  We could still make this work
   // for calling conventions that are safe against extra parameters.
   struct U : A, virtual B { ~U(); };
-  U::~U() {} // CHECK-LABEL: define void @_ZN5test11UD2Ev(%"struct.test1::U"* %this, i8** %vtt) unnamed_addr
+  U::~U() {} // CHECK4-LABEL: define void @_ZN5test11UD2Ev(%"struct.test1::U"* %this, i8** %vtt) unnamed_addr
 }
 
 // PR6471
@@ -171,8 +168,8 @@
   struct B : A { ~B(); };
 
   B::~B() {}
-  // CHECK-LABEL: define void @_ZN5test21BD2Ev(%"struct.test2::B"* %this) unnamed_addr
-  // CHECK: call void @_ZN5test21AD2Ev
+  // CHECK4-LABEL: define void @_ZN5test21BD2Ev(%"struct.test2::B"* %this) unnamed_addr
+  // CHECK4: call void @_ZN5test21AD2Ev
 }
 
 // PR7142
@@ -187,14 +184,63 @@
   void test() {
     new D; // Force emission of D's vtable
   }
+
+  // CHECK4-LABEL: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::(anonymous namespace)::D"* %this) unnamed_addr
+  // CHECK4: invoke void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+  // CHECK4: call void @_ZdlPv({{.*}}) [[NUW:#[0-9]+]]
+  // CHECK4: ret void
+  // CHECK4: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+  // CHECK4-NEXT: cleanup
+  // CHECK4: call void @_ZdlPv({{.*}}) [[NUW]]
+  // CHECK4: resume { i8*, i32 }
+
+  // CHECK4-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD1Ev(
+  // CHECK4: getelementptr inbounds i8* {{.*}}, i64 -8
+  // CHECK4: call void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+  // CHECK4: ret void
+
+  // CHECK4-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD0Ev(
+  // CHECK4: getelementptr inbounds i8* {{.*}}, i64 -8
+  // CHECK4: call void @_ZN5test312_GLOBAL__N_11DD0Ev(
+  // CHECK4: ret void
+
+  // CHECK4-LABEL: declare void @_ZN5test31BD2Ev(
+  // CHECK4-LABEL: declare void @_ZN5test31AD2Ev(
+
+  // CHECK4-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev(%"struct.test3::(anonymous namespace)::C"* %this) unnamed_addr
+  // CHECK4: invoke void @_ZN5test31BD2Ev(
+  // CHECK4: call void @_ZN5test31AD2Ev(
+  // CHECK4: ret void
+
+
+  // CHECK4-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(%"struct.test3::(anonymous namespace)::C"* %this) unnamed_addr
+  // CHECK4: invoke void @_ZN5test312_GLOBAL__N_11CD2Ev(
+  // CHECK4: call void @_ZdlPv({{.*}}) [[NUW]]
+  // CHECK4: ret void
+  // CHECK4: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+  // CHECK4-NEXT: cleanup
+  // CHECK4: call void @_ZdlPv({{.*}}) [[NUW]]
+  // CHECK4: resume { i8*, i32 }
+
+  // CHECK4-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev(
+  // CHECK4: getelementptr inbounds i8* {{.*}}, i64 -8
+  // CHECK4: call void @_ZN5test312_GLOBAL__N_11CD2Ev(
+  // CHECK4: ret void
+
+  // CHECK4-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD0Ev(
+  // CHECK4: getelementptr inbounds i8* {{.*}}, i64 -8
+  // CHECK4: call void @_ZN5test312_GLOBAL__N_11CD0Ev(
+  // CHECK4: ret void
+
+  // CHECK4: attributes [[NUW]] = {{[{].*}} nounwind {{.*[}]}}
 }
 
 namespace test4 {
   struct A { ~A(); };
 
-  // CHECK-LABEL: define void @_ZN5test43fooEv()
-  // CHECK: call void @_ZN5test41AD1Ev
-  // CHECK: ret void
+  // CHECK5-LABEL: define void @_ZN5test43fooEv()
+  // CHECK5: call void @_ZN5test41AD1Ev
+  // CHECK5: ret void
   void foo() {
     {
       A a;
@@ -205,20 +251,20 @@
     return;
   }
 
-  // CHECK-LABEL: define void @_ZN5test43barEi(
-  // CHECK:      [[X:%.*]] = alloca i32
-  // CHECK-NEXT: [[A:%.*]] = alloca
-  // CHECK:      br label
-  // CHECK:      [[TMP:%.*]] = load i32* [[X]]
-  // CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[TMP]], 0
-  // CHECK-NEXT: br i1
-  // CHECK:      call void @_ZN5test41AD1Ev(
-  // CHECK:      br label
-  // CHECK:      [[TMP:%.*]] = load i32* [[X]]
-  // CHECK:      [[TMP2:%.*]] = add nsw i32 [[TMP]], -1
-  // CHECK:      store i32 [[TMP2]], i32* [[X]]
-  // CHECK:      br label
-  // CHECK:      ret void
+  // CHECK5-LABEL: define void @_ZN5test43barEi(
+  // CHECK5:      [[X:%.*]] = alloca i32
+  // CHECK5-NEXT: [[A:%.*]] = alloca
+  // CHECK5:      br label
+  // CHECK5:      [[TMP:%.*]] = load i32* [[X]]
+  // CHECK5-NEXT: [[CMP:%.*]] = icmp ne i32 [[TMP]], 0
+  // CHECK5-NEXT: br i1
+  // CHECK5:      call void @_ZN5test41AD1Ev(
+  // CHECK5:      br label
+  // CHECK5:      [[TMP:%.*]] = load i32* [[X]]
+  // CHECK5:      [[TMP2:%.*]] = add nsw i32 [[TMP]], -1
+  // CHECK5:      store i32 [[TMP2]], i32* [[X]]
+  // CHECK5:      br label
+  // CHECK5:      ret void
   void bar(int x) {
     for (A a; x; ) {
       x--;
@@ -230,27 +276,27 @@
 namespace test5 {
   struct A { ~A(); };
 
-  // CHECK-LABEL: define void @_ZN5test53fooEv()
-  // CHECK:      [[ELEMS:%.*]] = alloca [5 x [[A:%.*]]], align
-  // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
-  // CHECK-NEXT: [[SEL:%.*]] = alloca i32
-  // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [5 x [[A]]]* [[ELEMS]], i32 0, i32 0
-  // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 5
-  // CHECK-NEXT: br label
-  // CHECK:      [[POST:%.*]] = phi [[A]]* [ [[END]], {{%.*}} ], [ [[ELT:%.*]], {{%.*}} ]
-  // CHECK-NEXT: [[ELT]] = getelementptr inbounds [[A]]* [[POST]], i64 -1
-  // CHECK-NEXT: invoke void @_ZN5test51AD1Ev([[A]]* [[ELT]])
-  // CHECK:      [[T0:%.*]] = icmp eq [[A]]* [[ELT]], [[BEGIN]]
-  // CHECK-NEXT: br i1 [[T0]],
-  // CHECK:      ret void
+  // CHECK5-LABEL: define void @_ZN5test53fooEv()
+  // CHECK5:      [[ELEMS:%.*]] = alloca [5 x [[A:%.*]]], align
+  // CHECK5-NEXT: [[EXN:%.*]] = alloca i8*
+  // CHECK5-NEXT: [[SEL:%.*]] = alloca i32
+  // CHECK5-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [5 x [[A]]]* [[ELEMS]], i32 0, i32 0
+  // CHECK5-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 5
+  // CHECK5-NEXT: br label
+  // CHECK5:      [[POST:%.*]] = phi [[A]]* [ [[END]], {{%.*}} ], [ [[ELT:%.*]], {{%.*}} ]
+  // CHECK5-NEXT: [[ELT]] = getelementptr inbounds [[A]]* [[POST]], i64 -1
+  // CHECK5-NEXT: invoke void @_ZN5test51AD1Ev([[A]]* [[ELT]])
+  // CHECK5:      [[T0:%.*]] = icmp eq [[A]]* [[ELT]], [[BEGIN]]
+  // CHECK5-NEXT: br i1 [[T0]],
+  // CHECK5:      ret void
   // lpad
-  // CHECK:      [[EMPTY:%.*]] = icmp eq [[A]]* [[BEGIN]], [[ELT]]
-  // CHECK-NEXT: br i1 [[EMPTY]]
-  // CHECK:      [[AFTER:%.*]] = phi [[A]]* [ [[ELT]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
-  // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]]* [[AFTER]], i64 -1
-  // CHECK-NEXT: invoke void @_ZN5test51AD1Ev([[A]]* [[CUR]])
-  // CHECK:      [[DONE:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]]
-  // CHECK-NEXT: br i1 [[DONE]],
+  // CHECK5:      [[EMPTY:%.*]] = icmp eq [[A]]* [[BEGIN]], [[ELT]]
+  // CHECK5-NEXT: br i1 [[EMPTY]]
+  // CHECK5:      [[AFTER:%.*]] = phi [[A]]* [ [[ELT]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+  // CHECK5-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]]* [[AFTER]], i64 -1
+  // CHECK5-NEXT: invoke void @_ZN5test51AD1Ev([[A]]* [[CUR]])
+  // CHECK5:      [[DONE:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]]
+  // CHECK5-NEXT: br i1 [[DONE]],
   void foo() {
     A elems[5];
   }
@@ -269,37 +315,37 @@
   };
 
   C::C() { opaque(); }
-  // CHECK-LABEL: define void @_ZN5test61CC1Ev(%"struct.test6::C"* %this) unnamed_addr
-  // CHECK:   call void @_ZN5test61BILj2EEC2Ev
-  // CHECK:   invoke void @_ZN5test61BILj3EEC2Ev
-  // CHECK:   invoke void @_ZN5test61BILj0EEC2Ev
-  // CHECK:   invoke void @_ZN5test61BILj1EEC2Ev
-  // CHECK:   invoke void @_ZN5test66opaqueEv
-  // CHECK:   ret void
+  // CHECK5-LABEL: define void @_ZN5test61CC1Ev(%"struct.test6::C"* %this) unnamed_addr
+  // CHECK5:   call void @_ZN5test61BILj2EEC2Ev
+  // CHECK5:   invoke void @_ZN5test61BILj3EEC2Ev
+  // CHECK5:   invoke void @_ZN5test61BILj0EEC2Ev
+  // CHECK5:   invoke void @_ZN5test61BILj1EEC2Ev
+  // CHECK5:   invoke void @_ZN5test66opaqueEv
+  // CHECK5:   ret void
   // FIXME: way too much EH cleanup code follows
 
   C::~C() { opaque(); }
-  // CHECK-LABEL: define void @_ZN5test61CD2Ev(%"struct.test6::C"* %this, i8** %vtt) unnamed_addr
-  // CHECK:   invoke void @_ZN5test66opaqueEv
-  // CHECK:   invoke void @_ZN5test61AD1Ev
-  // CHECK:   invoke void @_ZN5test61AD1Ev
-  // CHECK:   invoke void @_ZN5test61AD1Ev
-  // CHECK:   invoke void @_ZN5test61BILj1EED2Ev
-  // CHECK:   call void @_ZN5test61BILj0EED2Ev
-  // CHECK:   ret void
-  // CHECK:   invoke void @_ZN5test61AD1Ev
-  // CHECK:   invoke void @_ZN5test61AD1Ev
-  // CHECK:   invoke void @_ZN5test61AD1Ev
-  // CHECK:   invoke void @_ZN5test61BILj1EED2Ev
-  // CHECK:   invoke void @_ZN5test61BILj0EED2Ev
+  // CHECK5-LABEL: define void @_ZN5test61CD2Ev(%"struct.test6::C"* %this, i8** %vtt) unnamed_addr
+  // CHECK5:   invoke void @_ZN5test66opaqueEv
+  // CHECK5:   invoke void @_ZN5test61AD1Ev
+  // CHECK5:   invoke void @_ZN5test61AD1Ev
+  // CHECK5:   invoke void @_ZN5test61AD1Ev
+  // CHECK5:   invoke void @_ZN5test61BILj1EED2Ev
+  // CHECK5:   call void @_ZN5test61BILj0EED2Ev
+  // CHECK5:   ret void
+  // CHECK5:   invoke void @_ZN5test61AD1Ev
+  // CHECK5:   invoke void @_ZN5test61AD1Ev
+  // CHECK5:   invoke void @_ZN5test61AD1Ev
+  // CHECK5:   invoke void @_ZN5test61BILj1EED2Ev
+  // CHECK5:   invoke void @_ZN5test61BILj0EED2Ev
 
-  // CHECK-LABEL: define void @_ZN5test61CD1Ev(%"struct.test6::C"* %this) unnamed_addr
-  // CHECK:   invoke void @_ZN5test61CD2Ev
-  // CHECK:   invoke void @_ZN5test61BILj3EED2Ev
-  // CHECK:   call void @_ZN5test61BILj2EED2Ev
-  // CHECK:   ret void
-  // CHECK:   invoke void @_ZN5test61BILj3EED2Ev
-  // CHECK:   invoke void @_ZN5test61BILj2EED2Ev
+  // CHECK5-LABEL: define void @_ZN5test61CD1Ev(%"struct.test6::C"* %this) unnamed_addr
+  // CHECK5:   invoke void @_ZN5test61CD2Ev
+  // CHECK5:   invoke void @_ZN5test61BILj3EED2Ev
+  // CHECK5:   call void @_ZN5test61BILj2EED2Ev
+  // CHECK5:   ret void
+  // CHECK5:   invoke void @_ZN5test61BILj3EED2Ev
+  // CHECK5:   invoke void @_ZN5test61BILj2EED2Ev
 }
 
 // PR 9197
@@ -315,9 +361,9 @@
   };
 
   // Verify that this doesn't get emitted as an alias
-  // CHECK-LABEL: define void @_ZN5test71BD2Ev(
-  // CHECK:   invoke void @_ZN5test71DD1Ev(
-  // CHECK:   call void @_ZN5test71AD2Ev(
+  // CHECK5-LABEL: define void @_ZN5test71BD2Ev(
+  // CHECK5:   invoke void @_ZN5test71DD1Ev(
+  // CHECK5:   call void @_ZN5test71AD2Ev(
   B::~B() {}
 }
 
@@ -335,16 +381,16 @@
   l: die();
   }
 
-  // CHECK-LABEL:    define void @_ZN5test84testEv()
-  // CHECK:      [[X:%.*]] = alloca [[A:%.*]], align 1
-  // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]], align 1
-  // CHECK:      call void @_ZN5test81AC1Ev([[A]]* [[X]])
-  // CHECK-NEXT: br label
-  // CHECK:      invoke void @_ZN5test81AC1Ev([[A]]* [[Y]])
-  // CHECK:      invoke void @_ZN5test81AD1Ev([[A]]* [[Y]])
-  // CHECK-NOT:  switch
-  // CHECK:      invoke void @_ZN5test83dieEv()
-  // CHECK:      unreachable
+  // CHECK5-LABEL:    define void @_ZN5test84testEv()
+  // CHECK5:      [[X:%.*]] = alloca [[A:%.*]], align 1
+  // CHECK5-NEXT: [[Y:%.*]] = alloca [[A:%.*]], align 1
+  // CHECK5:      call void @_ZN5test81AC1Ev([[A]]* [[X]])
+  // CHECK5-NEXT: br label
+  // CHECK5:      invoke void @_ZN5test81AC1Ev([[A]]* [[Y]])
+  // CHECK5:      invoke void @_ZN5test81AD1Ev([[A]]* [[Y]])
+  // CHECK5-NOT:  switch
+  // CHECK5:      invoke void @_ZN5test83dieEv()
+  // CHECK5:      unreachable
 }
 
 // PR12710
@@ -359,8 +405,8 @@
     f1<int>();
     f2();
   }
-  // CHECK: call void @_ZN5test97ArgTypeD1Ev(%"struct.test9::ArgType"* %
-  // CHECK: call void @_ZN5test92f2Ev()
+  // CHECK5: call void @_ZN5test97ArgTypeD1Ev(%"struct.test9::ArgType"* %
+  // CHECK5: call void @_ZN5test92f2Ev()
 }
 
 namespace test10 {
@@ -371,60 +417,10 @@
   };
   template <class DataType> class opt : public Option {};
   template class opt<int>;
-  // CHECK-LABEL: define zeroext i1 @_ZN6test1016handleOccurrenceEv(
+  // CHECK5-LABEL: define zeroext i1 @_ZN6test1016handleOccurrenceEv(
   bool handleOccurrence() {
-    // CHECK: call void @_ZN6test106OptionD2Ev(
+    // CHECK5: call void @_ZN6test106OptionD2Ev(
     Option x;
     return true;
   }
 }
-
-// Checks from test3:
-
-  // CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::(anonymous namespace)::D"* %this) unnamed_addr
-  // CHECK: invoke void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
-  // CHECK: call void @_ZdlPv({{.*}}) [[NUW:#[0-9]+]]
-  // CHECK: ret void
-  // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
-  // CHECK-NEXT: cleanup
-  // CHECK: call void @_ZdlPv({{.*}}) [[NUW]]
-  // CHECK: resume { i8*, i32 }
-
-  // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD1Ev(
-  // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
-  // CHECK: call void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
-  // CHECK: ret void
-
-  // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD0Ev(
-  // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
-  // CHECK: call void @_ZN5test312_GLOBAL__N_11DD0Ev(
-  // CHECK: ret void
-
-  // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev(
-  // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
-  // CHECK: call void @_ZN5test312_GLOBAL__N_11CD2Ev(
-  // CHECK: ret void
-
-  // CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev(%"struct.test3::(anonymous namespace)::C"* %this) unnamed_addr
-  // CHECK: invoke void @_ZN5test31BD2Ev(
-  // CHECK: call void @_ZN5test31AD2Ev(
-  // CHECK: ret void
-
-  // CHECK: declare void @_ZN5test31BD2Ev(
-  // CHECK: declare void @_ZN5test31AD2Ev(
-
-  // CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(%"struct.test3::(anonymous namespace)::C"* %this) unnamed_addr
-  // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD2Ev(
-  // CHECK: call void @_ZdlPv({{.*}}) [[NUW]]
-  // CHECK: ret void
-  // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
-  // CHECK-NEXT: cleanup
-  // CHECK: call void @_ZdlPv({{.*}}) [[NUW]]
-  // CHECK: resume { i8*, i32 }
-
-  // CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD0Ev(
-  // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
-  // CHECK: call void @_ZN5test312_GLOBAL__N_11CD0Ev(
-  // CHECK: ret void
-
-  // CHECK: attributes [[NUW]] = {{[{].*}} nounwind {{.*[}]}}
diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
index 11026e8..89c9a61 100644
--- a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
+++ b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -178,9 +178,12 @@
   A *f(RC *x) {
     // FIXME: It should be possible to devirtualize this case, but that is
     // not implemented yet.
-    // CHECK: getelementptr
-    // CHECK-NEXT: %[[FUNC:.*]] = load
-    // CHECK-NEXT: bitcast
+    // CHECK: load
+    // CHECK: bitcast
+    // CHECK: [[F_PTR_RA:%.+]] = bitcast
+    // CHECK: [[VTABLE:%.+]] = load {{.+}} [[F_PTR_RA]]
+    // CHECK: [[VFN:%.+]] = getelementptr inbounds {{.+}} [[VTABLE]], i{{[0-9]+}} 0
+    // CHECK-NEXT: %[[FUNC:.*]] = load {{.+}} [[VFN]]
     // CHECK-NEXT: = call {{.*}} %[[FUNC]]
     return static_cast<RA*>(x)->f();
   }
diff --git a/test/CodeGenCXX/dllexport-alias.cpp b/test/CodeGenCXX/dllexport-alias.cpp
new file mode 100644
index 0000000..479595d
--- /dev/null
+++ b/test/CodeGenCXX/dllexport-alias.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -mconstructor-aliases %s -S -emit-llvm -o - | FileCheck %s
+
+// This test assumes that the C1 constructor will be aliased to the C2
+// constructor, and the D1 destructor to the D2. It then checks that the aliases
+// are dllexport'ed.
+
+class __declspec(dllexport) A {
+public:
+    A();
+    ~A();
+};
+
+A::A() {}
+
+A::~A() {}
+
+// CHECK: @_ZN1AC1Ev = dllexport alias void (%class.A*)* @_ZN1AC2Ev
+// CHECK: @_ZN1AD1Ev = dllexport alias void (%class.A*)* @_ZN1AD2Ev
diff --git a/test/CodeGenCXX/dllexport-members.cpp b/test/CodeGenCXX/dllexport-members.cpp
index 353b952..d913c09 100644
--- a/test/CodeGenCXX/dllexport-members.cpp
+++ b/test/CodeGenCXX/dllexport-members.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=MSC --check-prefix=M32 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=MSC --check-prefix=M64 %s
-// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G32 %s
-// RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G64 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-compatibility   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=MSC --check-prefix=M32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu                       -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu                     -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G64 %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Exported {};
@@ -288,32 +288,32 @@
   // G64-DAG: define dllexport                void @_ZN14ExportSpecialsD2Ev(%struct.ExportSpecials* %this)
   __declspec(dllexport) ~ExportSpecials();
 
-  // M32-DAG: define dllexport x86_thiscallcc %struct.ExportSpecials* @"\01??0ExportSpecials@@QAE@ABU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* nonnull)
-  // M64-DAG: define dllexport                %struct.ExportSpecials* @"\01??0ExportSpecials@@QEAA@AEBU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* nonnull)
-  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC1ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC1ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC2ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC2ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
+  // M32-DAG: define dllexport x86_thiscallcc %struct.ExportSpecials* @"\01??0ExportSpecials@@QAE@ABU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: define dllexport                %struct.ExportSpecials* @"\01??0ExportSpecials@@QEAA@AEBU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC1ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC1ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC2ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC2ERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllexport) ExportSpecials(const ExportSpecials&);
 
-  // M32-DAG: define dllexport x86_thiscallcc nonnull %struct.ExportSpecials* @"\01??4ExportSpecials@@QAEAAU0@ABU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // M64-DAG: define dllexport                nonnull %struct.ExportSpecials* @"\01??4ExportSpecials@@QEAAAEAU0@AEBU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G32-DAG: define dllexport x86_thiscallcc nonnull %struct.ExportSpecials* @_ZN14ExportSpecialsaSERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G64-DAG: define dllexport                nonnull %struct.ExportSpecials* @_ZN14ExportSpecialsaSERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
+  // M32-DAG: define dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @"\01??4ExportSpecials@@QAEAAU0@ABU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: define dllexport                dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @"\01??4ExportSpecials@@QEAAAEAU0@AEBU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @_ZN14ExportSpecialsaSERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define dllexport                dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @_ZN14ExportSpecialsaSERKS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllexport) ExportSpecials& operator=(const ExportSpecials&);
 
-  // M32-DAG: define dllexport x86_thiscallcc %struct.ExportSpecials* @"\01??0ExportSpecials@@QAE@$$QAU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* nonnull)
-  // M64-DAG: define dllexport                %struct.ExportSpecials* @"\01??0ExportSpecials@@QEAA@$$QEAU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* nonnull)
-  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC1EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC1EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC2EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC2EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
+  // M32-DAG: define dllexport x86_thiscallcc %struct.ExportSpecials* @"\01??0ExportSpecials@@QAE@$$QAU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: define dllexport                %struct.ExportSpecials* @"\01??0ExportSpecials@@QEAA@$$QEAU0@@Z"(%struct.ExportSpecials* returned %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC1EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC1EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define dllexport x86_thiscallcc void @_ZN14ExportSpecialsC2EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define dllexport                void @_ZN14ExportSpecialsC2EOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllexport) ExportSpecials(ExportSpecials&&);
 
-  // M32-DAG: define dllexport x86_thiscallcc nonnull %struct.ExportSpecials* @"\01??4ExportSpecials@@QAEAAU0@$$QAU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // M64-DAG: define dllexport                nonnull %struct.ExportSpecials* @"\01??4ExportSpecials@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G32-DAG: define dllexport x86_thiscallcc nonnull %struct.ExportSpecials* @_ZN14ExportSpecialsaSEOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
-  // G64-DAG: define dllexport                nonnull %struct.ExportSpecials* @_ZN14ExportSpecialsaSEOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* nonnull)
+  // M32-DAG: define dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @"\01??4ExportSpecials@@QAEAAU0@$$QAU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: define dllexport                dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @"\01??4ExportSpecials@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @_ZN14ExportSpecialsaSEOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define dllexport                dereferenceable({{[0-9]+}}) %struct.ExportSpecials* @_ZN14ExportSpecialsaSEOS_(%struct.ExportSpecials* %this, %struct.ExportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllexport) ExportSpecials& operator=(ExportSpecials&&);
 };
 ExportSpecials::ExportSpecials() {}
@@ -344,10 +344,10 @@
   // G64-DAG: define weak_odr dllexport                void @_ZN20ExportInlineSpecialsC1ERKS_(
   __declspec(dllexport) inline ExportInlineSpecials(const ExportInlineSpecials&);
 
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QAEAAU0@ABU0@@Z"(
-  // M64-DAG: define weak_odr dllexport                nonnull %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QEAAAEAU0@AEBU0@@Z"(
-  // G32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSERKS_(
-  // G64-DAG: define weak_odr dllexport                nonnull %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSERKS_(
+  // M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QAEAAU0@ABU0@@Z"(
+  // M64-DAG: define weak_odr dllexport                dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QEAAAEAU0@AEBU0@@Z"(
+  // G32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSERKS_(
+  // G64-DAG: define weak_odr dllexport                dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSERKS_(
   __declspec(dllexport) ExportInlineSpecials& operator=(const ExportInlineSpecials&);
 
   // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.ExportInlineSpecials* @"\01??0ExportInlineSpecials@@QAE@$$QAU0@@Z"(
@@ -356,10 +356,10 @@
   // G64-DAG: define weak_odr dllexport                void @_ZN20ExportInlineSpecialsC1EOS_(
   __declspec(dllexport) ExportInlineSpecials(ExportInlineSpecials&&) {}
 
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QAEAAU0@$$QAU0@@Z"(
-  // M64-DAG: define weak_odr dllexport                nonnull %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QEAAAEAU0@$$QEAU0@@Z"(
-  // G32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSEOS_(
-  // G64-DAG: define weak_odr dllexport                nonnull %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSEOS_(
+  // M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QAEAAU0@$$QAU0@@Z"(
+  // M64-DAG: define weak_odr dllexport                dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @"\01??4ExportInlineSpecials@@QEAAAEAU0@$$QEAU0@@Z"(
+  // G32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSEOS_(
+  // G64-DAG: define weak_odr dllexport                dereferenceable({{[0-9]+}}) %struct.ExportInlineSpecials* @_ZN20ExportInlineSpecialsaSEOS_(
   __declspec(dllexport) ExportInlineSpecials& operator=(ExportInlineSpecials&&) { return *this; }
 };
 ExportInlineSpecials::ExportInlineSpecials(const ExportInlineSpecials&) {}
@@ -392,32 +392,32 @@
 // G64-DAG: define dllexport                void @_ZN19ExportDefaultedDefsD2Ev(%struct.ExportDefaultedDefs* %this)
 ExportDefaultedDefs::~ExportDefaultedDefs() = default;
 
-// M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QAE@ABU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* nonnull)
-// M64-DAG: define weak_odr dllexport                %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QEAA@AEBU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* nonnull)
-// G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC1ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G64-DAG: define weak_odr dllexport                void @_ZN19ExportDefaultedDefsC1ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC2ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G64-DAG: define weak_odr dllexport                void @_ZN19ExportDefaultedDefsC2ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
+// M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QAE@ABU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: define weak_odr dllexport                %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QEAA@AEBU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC1ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define weak_odr dllexport                void @_ZN19ExportDefaultedDefsC1ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC2ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define weak_odr dllexport                void @_ZN19ExportDefaultedDefsC2ERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
 __declspec(dllexport) ExportDefaultedDefs::ExportDefaultedDefs(const ExportDefaultedDefs&) = default;
 
-// M32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QAEAAU0@ABU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// M64-DAG: define weak_odr dllexport                nonnull %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QEAAAEAU0@AEBU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G64-DAG: define weak_odr dllexport                nonnull %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
+// M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QAEAAU0@ABU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: define weak_odr dllexport                dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QEAAAEAU0@AEBU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define weak_odr dllexport                dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSERKS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
 inline ExportDefaultedDefs& ExportDefaultedDefs::operator=(const ExportDefaultedDefs&) = default;
 
-// M32-DAG: define dllexport x86_thiscallcc %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QAE@$$QAU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* nonnull)
-// M64-DAG: define dllexport                %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QEAA@$$QEAU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* nonnull)
-// G32-DAG: define dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC1EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G64-DAG: define dllexport                void @_ZN19ExportDefaultedDefsC1EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G32-DAG: define dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC2EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G64-DAG: define dllexport                void @_ZN19ExportDefaultedDefsC2EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
+// M32-DAG: define dllexport x86_thiscallcc %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QAE@$$QAU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: define dllexport                %struct.ExportDefaultedDefs* @"\01??0ExportDefaultedDefs@@QEAA@$$QEAU0@@Z"(%struct.ExportDefaultedDefs* returned %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC1EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define dllexport                void @_ZN19ExportDefaultedDefsC1EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define dllexport x86_thiscallcc void @_ZN19ExportDefaultedDefsC2EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define dllexport                void @_ZN19ExportDefaultedDefsC2EOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
 __declspec(dllexport) ExportDefaultedDefs::ExportDefaultedDefs(ExportDefaultedDefs&&) = default;
 
-// M32-DAG: define dllexport x86_thiscallcc nonnull %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QAEAAU0@$$QAU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// M64-DAG: define dllexport                nonnull %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G32-DAG: define dllexport x86_thiscallcc nonnull %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSEOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
-// G64-DAG: define dllexport                nonnull %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSEOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* nonnull)
+// M32-DAG: define dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QAEAAU0@$$QAU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: define dllexport                dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @"\01??4ExportDefaultedDefs@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSEOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define dllexport                dereferenceable({{[0-9]+}}) %struct.ExportDefaultedDefs* @_ZN19ExportDefaultedDefsaSEOS_(%struct.ExportDefaultedDefs* %this, %struct.ExportDefaultedDefs* dereferenceable({{[0-9]+}}))
 ExportDefaultedDefs& ExportDefaultedDefs::operator=(ExportDefaultedDefs&&) = default;
 
 
diff --git a/test/CodeGenCXX/dllexport.cpp b/test/CodeGenCXX/dllexport.cpp
index 197b18e..0878dff 100644
--- a/test/CodeGenCXX/dllexport.cpp
+++ b/test/CodeGenCXX/dllexport.cpp
@@ -1,10 +1,8 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=MSC --check-prefix=M32 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -O1 -mconstructor-aliases -disable-llvm-optzns -o - %s | FileCheck --check-prefix=MSC --check-prefix=M32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=MSC --check-prefix=M64 %s
 // RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU --check-prefix=G64 %s
 
-// RUN: %clang_cc1 -triple i686-pc-win32 -O1 -mconstructor-aliases -std=c++1y -emit-llvm -o - %s | FileCheck %s --check-prefix=MSC --check-prefix=M32
-
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Exported {};
 struct ExplicitDecl_Exported {};
@@ -77,8 +75,8 @@
 __declspec(dllexport) auto ExternalAutoTypeGlobal = External();
 
 int f();
-// MSC-DAG: @"\01?x@?0??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0
-// MSC-DAG: @"\01?$S1@?0??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0
+// MSC-DAG: @"\01?x@?1??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0
+// MSC-DAG: @"\01?$S1@?1??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0
 int __declspec(dllexport) nonInlineStaticLocalsFunc() {
   static int x = f();
   return x++;
@@ -489,7 +487,7 @@
 
 struct __declspec(dllexport) T {
   // Copy assignment operator:
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.T* @"\01??4T@@QAEAAU0@ABU0@@Z"
+  // M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@ABU0@@Z"
 
   // Explicitly defaulted copy constructur:
   T(const T&) = default;
@@ -509,11 +507,9 @@
 int T::c;
 
 template <typename T> struct __declspec(dllexport) U { void foo() {} };
-// The U<int> specialization below must cause the following to be emitted:
-// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?foo@?$U@H@@QAEXXZ"
-// M32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.U* @"\01??4?$U@H@@QAEAAU0@ABU0@@Z"
 struct __declspec(dllexport) V : public U<int> { };
-
+// U<int>'s assignment operator is emitted.
+// M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.U* @"\01??4?$U@H@@QAEAAU0@ABU0@@Z"
 
 struct __declspec(dllexport) W { virtual void foo() {} };
 // Default ctor:
@@ -531,26 +527,27 @@
 
 struct __declspec(dllexport) Y {
   // Move assignment operator:
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc nonnull %struct.Y* @"\01??4Y@@QAEAAU0@$$QAU0@@Z"
+  // M32-DAG: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.Y* @"\01??4Y@@QAEAAU0@$$QAU0@@Z"
 
   int x;
 };
 
 struct __declspec(dllexport) Z { virtual ~Z() {} };
 // The scalar deleting dtor does not get exported:
-// M32-DAG: define linkonce_odr x86_thiscallcc void @"\01??_GZ@@UAEPAXI@Z"
+// M32-DAG: define linkonce_odr x86_thiscallcc i8* @"\01??_GZ@@UAEPAXI@Z"
 
 
 // The user-defined dtor does get exported:
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??1Z@@UAE@XZ"
 
-namespace DontUseDtorAlias {
+namespace UseDtorAlias {
   struct __declspec(dllexport) A { ~A(); };
   struct __declspec(dllexport) B : A { ~B(); };
   A::~A() { }
   B::~B() { }
-  // Emit a real definition of B's constructor; don't alias it to A's.
-  // M32-DAG: define dllexport x86_thiscallcc void @"\01??1B@DontUseDtorAlias@@QAE@XZ"
+  // Emit a alias definition of B's constructor.
+  // M32-DAG: @"\01??1B@UseDtorAlias@@QAE@XZ" = dllexport alias {{.*}} @"\01??1A@UseDtorAlias@@QAE@XZ"
+
 }
 
 struct __declspec(dllexport) DefaultedCtorsDtors {
@@ -581,106 +578,140 @@
 // M32-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$PartiallySpecializedClassTemplate@PAX@@QAEXXZ"
 // G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv
 
+// Attributes on explicit specializations are honored.
 template <typename T> struct ExplicitlySpecializedClassTemplate {};
 template <> struct __declspec(dllexport) ExplicitlySpecializedClassTemplate<void*> { void f() {} };
 USEMEMFUNC(ExplicitlySpecializedClassTemplate<void*>, f);
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$ExplicitlySpecializedClassTemplate@PAX@@QAEXXZ"
 // G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv
 
+// MS inherits DLL attributes to partial specializations.
+template <typename T> struct __declspec(dllexport) PartiallySpecializedExportedClassTemplate {};
+template <typename T> struct PartiallySpecializedExportedClassTemplate<T*> { void f() {} };
+USEMEMFUNC(PartiallySpecializedExportedClassTemplate<void*>, f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$PartiallySpecializedExportedClassTemplate@PAX@@QAEXXZ"
+// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN41PartiallySpecializedExportedClassTemplateIPvE1fEv
+
+// MS ignores DLL attributes on partial specializations; inheritance still works though.
+template <typename T> struct __declspec(dllexport) PartiallySpecializedExportedClassTemplate2 {};
+template <typename T> struct __declspec(dllimport) PartiallySpecializedExportedClassTemplate2<T*> { void f(); };
+template <typename T> void PartiallySpecializedExportedClassTemplate2<T*>::f() {}
+USEMEMFUNC(PartiallySpecializedExportedClassTemplate2<void*>, f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$PartiallySpecializedExportedClassTemplate2@PAX@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN42PartiallySpecializedExportedClassTemplate2IPvE1fEv
+
+// Attributes on the instantiation take precedence over attributes on the template.
+template <typename T> struct __declspec(dllimport) ExplicitlyInstantiatedWithDifferentAttr { void f() {} };
+template struct __declspec(dllexport) ExplicitlyInstantiatedWithDifferentAttr<int>;
+USEMEMFUNC(ExplicitlyInstantiatedWithDifferentAttr<int>, f);
+// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?f@?$ExplicitlyInstantiatedWithDifferentAttr@H@@QAEXXZ"
+
+// Don't create weak dllexport aliases. (PR21373)
+struct NonExportedBaseClass {
+  virtual ~NonExportedBaseClass();
+};
+NonExportedBaseClass::~NonExportedBaseClass() {}
+
+struct __declspec(dllexport) ExportedDerivedClass : NonExportedBaseClass {};
+// M32-DAG: weak_odr dllexport x86_thiscallcc void @"\01??1ExportedDerivedClass@@UAE@XZ"
+
+
 //===----------------------------------------------------------------------===//
 // Classes with template base classes
 //===----------------------------------------------------------------------===//
 
 template <typename T> struct ClassTemplate { void func() {} };
 template <typename T> struct __declspec(dllexport) ExportedClassTemplate { void func() {} };
-template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func() {} };
+template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func(); };
+template <typename T> void ImportedClassTemplate<T>::func() {}
 
 template <typename T> struct ExplicitlySpecializedTemplate { void func() {} };
 template <> struct ExplicitlySpecializedTemplate<int> { void func() {} };
 template <typename T> struct ExplicitlyExportSpecializedTemplate { void func() {} };
 template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate<int> { void func() {} };
-template <typename T> struct ExplicitlyImportSpecializedTemplate { void func() {} };
-template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func() {} };
+template <typename T> struct ExplicitlyImportSpecializedTemplate { void func(); };
+template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func(); };
 
 template <typename T> struct ExplicitlyInstantiatedTemplate { void func() {} };
 template struct ExplicitlyInstantiatedTemplate<int>;
 template <typename T> struct ExplicitlyExportInstantiatedTemplate { void func() {} };
 template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate<int>;
-template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func() {} };
+template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func(); };
 template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate<int>;
 
 
 // MS: ClassTemplate<int> gets exported.
 struct __declspec(dllexport) DerivedFromTemplate : public ClassTemplate<int> {};
-USEMEMFUNC(ClassTemplate<int>, func)
+USEMEMFUNC(DerivedFromTemplate, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ClassTemplate@H@@QAEXXZ"
 // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ClassTemplateIiE4funcEv
 
 // ExportedTemplate is explicitly exported.
 struct __declspec(dllexport) DerivedFromExportedTemplate : public ExportedClassTemplate<int> {};
+USEMEMFUNC(DerivedFromExportedTemplate, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExportedClassTemplate@H@@QAEXXZ"
 // G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN21ExportedClassTemplateIiE4funcEv
 
 // ImportedClassTemplate is explicitly imported.
 struct __declspec(dllexport) DerivedFromImportedTemplate : public ImportedClassTemplate<int> {};
-USEMEMFUNC(ImportedClassTemplate<int>, func)
+USEMEMFUNC(DerivedFromImportedTemplate, func)
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ImportedClassTemplate@H@@QAEXXZ"
 // G32-DAG: declare dllimport x86_thiscallcc void @_ZN21ImportedClassTemplateIiE4funcEv
 
 // Base class already instantiated without dll attribute.
 struct DerivedFromTemplateD : public ClassTemplate<double> {};
 struct __declspec(dllexport) DerivedFromTemplateD2 : public ClassTemplate<double> {};
-USEMEMFUNC(ClassTemplate<double>, func)
+USEMEMFUNC(DerivedFromTemplateD2, func)
 // M32-DAG: define linkonce_odr x86_thiscallcc void @"\01?func@?$ClassTemplate@N@@QAEXXZ"
 // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ClassTemplateIdE4funcEv
 
 // MS: Base class already instantiated with different dll attribute.
 struct __declspec(dllimport) DerivedFromTemplateB : public ClassTemplate<bool> {};
 struct __declspec(dllexport) DerivedFromTemplateB2 : public ClassTemplate<bool> {};
-USEMEMFUNC(ClassTemplate<bool>, func)
+USEMEMFUNC(DerivedFromTemplateB2, func)
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ClassTemplate@_N@@QAEXXZ"
 // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ClassTemplateIbE4funcEv
 
 // Base class already specialized without dll attribute.
 struct __declspec(dllexport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {};
-USEMEMFUNC(ExplicitlySpecializedTemplate<int>, func)
+USEMEMFUNC(DerivedFromExplicitlySpecializedTemplate, func)
 // M32-DAG: define linkonce_odr x86_thiscallcc void @"\01?func@?$ExplicitlySpecializedTemplate@H@@QAEXXZ"
 // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv
 
 // Base class alredy specialized with export attribute.
 struct __declspec(dllexport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate<int> {};
-USEMEMFUNC(ExplicitlyExportSpecializedTemplate<int>, func)
+USEMEMFUNC(DerivedFromExplicitlyExportSpecializedTemplate, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitlyExportSpecializedTemplate@H@@QAEXXZ"
 // G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv
 
 // Base class already specialized with import attribute.
 struct __declspec(dllexport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {};
-USEMEMFUNC(ExplicitlyImportSpecializedTemplate<int>, func)
-// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ"
-// G32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
+USEMEMFUNC(DerivedFromExplicitlyImportSpecializedTemplate, func)
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
 
 // Base class already instantiated without dll attribute.
 struct __declspec(dllexport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {};
-USEMEMFUNC(ExplicitlyInstantiatedTemplate<int>, func)
+USEMEMFUNC(DerivedFromExplicitlyInstantiatedTemplate, func)
 // M32-DAG: define weak_odr x86_thiscallcc void @"\01?func@?$ExplicitlyInstantiatedTemplate@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv
 
 // Base class already instantiated with export attribute.
 struct __declspec(dllexport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate<int> {};
-USEMEMFUNC(ExplicitlyExportInstantiatedTemplate<int>, func)
+USEMEMFUNC(DerivedFromExplicitlyExportInstantiatedTemplate, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$ExplicitlyExportInstantiatedTemplate@H@@QAEXXZ"
 // G32-DAG: define weak_odr dllexport x86_thiscallcc void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv
 
 // Base class already instantiated with import attribute.
 struct __declspec(dllexport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate<int> {};
-USEMEMFUNC(ExplicitlyImportInstantiatedTemplate<int>, func)
-// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ"
-// G32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
+USEMEMFUNC(DerivedFromExplicitlyImportInstantiatedTemplate, func)
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
 
 // MS: A dll attribute propagates through multiple levels of instantiation.
 template <typename T> struct TopClass { void func() {} };
 template <typename T> struct MiddleClass : public TopClass<T> { };
-struct __declspec(dllexport) BottomClas : public MiddleClass<int> { };
-USEMEMFUNC(TopClass<int>, func)
+struct __declspec(dllexport) BottomClass : public MiddleClass<int> { };
+USEMEMFUNC(BottomClass, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01?func@?$TopClass@H@@QAEXXZ"
 // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN8TopClassIiE4funcEv
diff --git a/test/CodeGenCXX/dllimport-members.cpp b/test/CodeGenCXX/dllimport-members.cpp
index 8eab9d4..e88b7e9 100644
--- a/test/CodeGenCXX/dllimport-members.cpp
+++ b/test/CodeGenCXX/dllimport-members.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC --check-prefix=M32 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC --check-prefix=M64 %s
-// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c++1y -O0 -o - %s         | FileCheck --check-prefix=GNU --check-prefix=G32 %s
-// RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y -O0 -o - %s         | FileCheck --check-prefix=GNU --check-prefix=G64 %s
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -O1 -o - %s -DMSABI | FileCheck --check-prefix=MO1 %s
-// RUN: %clang_cc1 -triple i686-windows-gnu    -emit-llvm -std=c++1y -O1 -o - %s         | FileCheck --check-prefix=GO1 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-compatibility   -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC --check-prefix=M32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu                       -emit-llvm -std=c++1y -O0 -o - %s         | FileCheck --check-prefix=GNU --check-prefix=G32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu                     -emit-llvm -std=c++1y -O0 -o - %s         | FileCheck --check-prefix=GNU --check-prefix=G64 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-compatibility   -emit-llvm -std=c++1y -O1 -o - %s -DMSABI | FileCheck --check-prefix=MO1 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu                       -emit-llvm -std=c++1y -O1 -o - %s         | FileCheck --check-prefix=GO1 %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
@@ -63,64 +63,64 @@
 struct ImportMembers {
   struct Nested;
 
-  // M32-DAG: define            x86_thiscallcc void @"\01?normalDef@ImportMembers@@QAEXXZ"(%struct.ImportMembers* %this)
-  // M64-DAG: define                           void @"\01?normalDef@ImportMembers@@QEAAXXZ"(%struct.ImportMembers* %this)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalDecl@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?normalDecl@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalInclass@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?normalInclass@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalInlineDef@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?normalInlineDef@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalInlineDecl@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?normalInlineDecl@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
-  // G32-DAG: define            x86_thiscallcc void @_ZN13ImportMembers9normalDefEv(%struct.ImportMembers* %this)
-  // G64-DAG: define                           void @_ZN13ImportMembers9normalDefEv(%struct.ImportMembers* %this)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers10normalDeclEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers10normalDeclEv(%struct.ImportMembers*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers13normalInclassEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers13normalInclassEv(%struct.ImportMembers*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers15normalInlineDefEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers15normalInlineDefEv(%struct.ImportMembers*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers16normalInlineDeclEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers16normalInlineDeclEv(%struct.ImportMembers*)
+  // M32-DAG: define              x86_thiscallcc void @"\01?normalDef@ImportMembers@@QAEXXZ"(%struct.ImportMembers* %this)
+  // M64-DAG: define                             void @"\01?normalDef@ImportMembers@@QEAAXXZ"(%struct.ImportMembers* %this)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalDecl@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?normalDecl@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalInclass@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?normalInclass@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalInlineDef@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?normalInlineDef@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalInlineDecl@ImportMembers@@QAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?normalInlineDecl@ImportMembers@@QEAAXXZ"(%struct.ImportMembers*)
+  // G32-DAG: define              x86_thiscallcc void @_ZN13ImportMembers9normalDefEv(%struct.ImportMembers* %this)
+  // G64-DAG: define                             void @_ZN13ImportMembers9normalDefEv(%struct.ImportMembers* %this)
+  // G32-DAG: declare dllimport   x86_thiscallcc void @_ZN13ImportMembers10normalDeclEv(%struct.ImportMembers*)
+  // G64-DAG: declare dllimport                  void @_ZN13ImportMembers10normalDeclEv(%struct.ImportMembers*)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers13normalInclassEv(%struct.ImportMembers* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers13normalInclassEv(%struct.ImportMembers* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers15normalInlineDefEv(%struct.ImportMembers* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers15normalInlineDefEv(%struct.ImportMembers* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers16normalInlineDeclEv(%struct.ImportMembers* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers16normalInlineDeclEv(%struct.ImportMembers* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?normalInclass@ImportMembers@@QAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?normalInlineDef@ImportMembers@@QAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?normalInlineDecl@ImportMembers@@QAEXXZ"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers13normalInclassEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers15normalInlineDefEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers16normalInlineDeclEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers13normalInclassEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers15normalInlineDefEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers16normalInlineDeclEv(
   __declspec(dllimport)                void normalDef(); // dllimport ignored
   __declspec(dllimport)                void normalDecl();
   __declspec(dllimport)                void normalInclass() {}
   __declspec(dllimport)                void normalInlineDef();
   __declspec(dllimport)         inline void normalInlineDecl();
 
-  // M32-DAG: define            x86_thiscallcc void @"\01?virtualDef@ImportMembers@@UAEXXZ"(%struct.ImportMembers* %this)
-  // M64-DAG: define                           void @"\01?virtualDef@ImportMembers@@UEAAXXZ"(%struct.ImportMembers* %this)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualDecl@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?virtualDecl@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualInclass@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?virtualInclass@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualInlineDef@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?virtualInlineDef@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualInlineDecl@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
-  // M64-DAG: declare dllimport                void @"\01?virtualInlineDecl@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
-  // G32-DAG: define            x86_thiscallcc void @_ZN13ImportMembers10virtualDefEv(%struct.ImportMembers* %this)
-  // G64-DAG: define                           void @_ZN13ImportMembers10virtualDefEv(%struct.ImportMembers* %this)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers11virtualDeclEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers11virtualDeclEv(%struct.ImportMembers*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers14virtualInclassEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers14virtualInclassEv(%struct.ImportMembers*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers16virtualInlineDefEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers16virtualInlineDefEv(%struct.ImportMembers*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers17virtualInlineDeclEv(%struct.ImportMembers*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers17virtualInlineDeclEv(%struct.ImportMembers*)
+  // M32-DAG: define              x86_thiscallcc void @"\01?virtualDef@ImportMembers@@UAEXXZ"(%struct.ImportMembers* %this)
+  // M64-DAG: define                             void @"\01?virtualDef@ImportMembers@@UEAAXXZ"(%struct.ImportMembers* %this)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualDecl@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualDecl@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualInclass@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualInclass@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualInlineDef@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualInlineDef@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualInlineDecl@ImportMembers@@UAEXXZ"(%struct.ImportMembers*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualInlineDecl@ImportMembers@@UEAAXXZ"(%struct.ImportMembers*)
+  // G32-DAG: define              x86_thiscallcc void @_ZN13ImportMembers10virtualDefEv(%struct.ImportMembers* %this)
+  // G64-DAG: define                             void @_ZN13ImportMembers10virtualDefEv(%struct.ImportMembers* %this)
+  // G32-DAG: declare dllimport   x86_thiscallcc void @_ZN13ImportMembers11virtualDeclEv(%struct.ImportMembers*)
+  // G64-DAG: declare dllimport                  void @_ZN13ImportMembers11virtualDeclEv(%struct.ImportMembers*)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers14virtualInclassEv(%struct.ImportMembers* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers14virtualInclassEv(%struct.ImportMembers* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers16virtualInlineDefEv(%struct.ImportMembers* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers16virtualInlineDefEv(%struct.ImportMembers* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers17virtualInlineDeclEv(%struct.ImportMembers* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers17virtualInlineDeclEv(%struct.ImportMembers* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?virtualInclass@ImportMembers@@UAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?virtualInlineDef@ImportMembers@@UAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?virtualInlineDecl@ImportMembers@@UAEXXZ"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers14virtualInclassEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers16virtualInlineDefEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers17virtualInlineDeclEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers14virtualInclassEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers16virtualInlineDefEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers17virtualInlineDeclEv(
   __declspec(dllimport) virtual        void virtualDef(); // dllimport ignored
   __declspec(dllimport) virtual        void virtualDecl();
   __declspec(dllimport) virtual        void virtualInclass() {}
@@ -134,15 +134,15 @@
   // MSC-DAG: declare dllimport                void @"\01?staticInlineDecl@ImportMembers@@SAXXZ"()
   // GNU-DAG: define                           void @_ZN13ImportMembers9staticDefEv()
   // GNU-DAG: declare dllimport                void @_ZN13ImportMembers10staticDeclEv()
-  // GNU-DAG: declare dllimport                void @_ZN13ImportMembers13staticInclassEv()
-  // GNU-DAG: declare dllimport                void @_ZN13ImportMembers15staticInlineDefEv()
-  // GNU-DAG: declare dllimport                void @_ZN13ImportMembers16staticInlineDeclEv()
+  // GNU-DAG: define linkonce_odr              void @_ZN13ImportMembers13staticInclassEv()
+  // GNU-DAG: define linkonce_odr              void @_ZN13ImportMembers15staticInlineDefEv()
+  // GNU-DAG: define linkonce_odr              void @_ZN13ImportMembers16staticInlineDeclEv()
   // MO1-DAG: define available_externally dllimport void @"\01?staticInclass@ImportMembers@@SAXXZ"()
   // MO1-DAG: define available_externally dllimport void @"\01?staticInlineDef@ImportMembers@@SAXXZ"()
   // MO1-DAG: define available_externally dllimport void @"\01?staticInlineDecl@ImportMembers@@SAXXZ"()
-  // GO1-DAG: define available_externally dllimport void @_ZN13ImportMembers13staticInclassEv()
-  // GO1-DAG: define available_externally dllimport void @_ZN13ImportMembers15staticInlineDefEv()
-  // GO1-DAG: define available_externally dllimport void @_ZN13ImportMembers16staticInlineDeclEv()
+  // GO1-DAG: define linkonce_odr              void @_ZN13ImportMembers13staticInclassEv()
+  // GO1-DAG: define linkonce_odr              void @_ZN13ImportMembers15staticInlineDefEv()
+  // GO1-DAG: define linkonce_odr              void @_ZN13ImportMembers16staticInlineDeclEv()
   __declspec(dllimport) static         void staticDef(); // dllimport ignored
   __declspec(dllimport) static         void staticDecl();
   __declspec(dllimport) static         void staticInclass() {}
@@ -235,65 +235,65 @@
 
 // Import individual members of a nested class.
 struct ImportMembers::Nested {
-  // M32-DAG: define            x86_thiscallcc void @"\01?normalDef@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"* %this)
-  // M64-DAG: define                           void @"\01?normalDef@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"* %this)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalDecl@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?normalDecl@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalInclass@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?normalInclass@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalInlineDef@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?normalInlineDef@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?normalInlineDecl@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?normalInlineDecl@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: define            x86_thiscallcc void @_ZN13ImportMembers6Nested9normalDefEv(%"struct.ImportMembers::Nested"* %this)
-  // G64-DAG: define                           void @_ZN13ImportMembers6Nested9normalDefEv(%"struct.ImportMembers::Nested"* %this)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested10normalDeclEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested10normalDeclEv(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested13normalInclassEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested13normalInclassEv(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested15normalInlineDefEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested15normalInlineDefEv(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested16normalInlineDeclEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested16normalInlineDeclEv(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: define              x86_thiscallcc void @"\01?normalDef@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"* %this)
+  // M64-DAG: define                             void @"\01?normalDef@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"* %this)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalDecl@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?normalDecl@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalInclass@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?normalInclass@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalInlineDef@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?normalInlineDef@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?normalInlineDecl@Nested@ImportMembers@@QAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?normalInlineDecl@Nested@ImportMembers@@QEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // G32-DAG: define              x86_thiscallcc void @_ZN13ImportMembers6Nested9normalDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define                             void @_ZN13ImportMembers6Nested9normalDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G32-DAG: declare dllimport   x86_thiscallcc void @_ZN13ImportMembers6Nested10normalDeclEv(%"struct.ImportMembers::Nested"*)
+  // G64-DAG: declare dllimport                  void @_ZN13ImportMembers6Nested10normalDeclEv(%"struct.ImportMembers::Nested"*)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested13normalInclassEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers6Nested13normalInclassEv(%"struct.ImportMembers::Nested"* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested15normalInlineDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers6Nested15normalInlineDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested16normalInlineDeclEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers6Nested16normalInlineDeclEv(%"struct.ImportMembers::Nested"* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?normalInclass@Nested@ImportMembers@@QAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?normalInlineDef@Nested@ImportMembers@@QAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?normalInlineDecl@Nested@ImportMembers@@QAEXXZ"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested13normalInclassEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested15normalInlineDefEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested16normalInlineDeclEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested13normalInclassEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested15normalInlineDefEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested16normalInlineDeclEv(
   __declspec(dllimport)                void normalDef(); // dllimport ignored
   __declspec(dllimport)                void normalDecl();
   __declspec(dllimport)                void normalInclass() {}
   __declspec(dllimport)                void normalInlineDef();
   __declspec(dllimport)         inline void normalInlineDecl();
 
-  // M32-DAG: define            x86_thiscallcc void @"\01?virtualDef@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"* %this)
-  // M64-DAG: define                           void @"\01?virtualDef@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"* %this)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualDecl@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?virtualDecl@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualInclass@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?virtualInclass@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualInlineDef@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?virtualInlineDef@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01?virtualInlineDecl@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
-  // M64-DAG: declare dllimport                void @"\01?virtualInlineDecl@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: define            x86_thiscallcc void @_ZN13ImportMembers6Nested10virtualDefEv(%"struct.ImportMembers::Nested"* %this)
-  // G64-DAG: define                           void @_ZN13ImportMembers6Nested10virtualDefEv(%"struct.ImportMembers::Nested"* %this)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested11virtualDeclEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested11virtualDeclEv(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested14virtualInclassEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested14virtualInclassEv(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested16virtualInlineDefEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested16virtualInlineDefEv(%"struct.ImportMembers::Nested"*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested17virtualInlineDeclEv(%"struct.ImportMembers::Nested"*)
-  // G64-DAG: declare dllimport                void @_ZN13ImportMembers6Nested17virtualInlineDeclEv(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: define              x86_thiscallcc void @"\01?virtualDef@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"* %this)
+  // M64-DAG: define                             void @"\01?virtualDef@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"* %this)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualDecl@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualDecl@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualInclass@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualInclass@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualInlineDef@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualInlineDef@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01?virtualInlineDecl@Nested@ImportMembers@@UAEXXZ"(%"struct.ImportMembers::Nested"*)
+  // M64-DAG: declare dllimport                  void @"\01?virtualInlineDecl@Nested@ImportMembers@@UEAAXXZ"(%"struct.ImportMembers::Nested"*)
+  // G32-DAG: define              x86_thiscallcc void @_ZN13ImportMembers6Nested10virtualDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define                             void @_ZN13ImportMembers6Nested10virtualDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G32-DAG: declare dllimport   x86_thiscallcc void @_ZN13ImportMembers6Nested11virtualDeclEv(%"struct.ImportMembers::Nested"*)
+  // G64-DAG: declare dllimport                  void @_ZN13ImportMembers6Nested11virtualDeclEv(%"struct.ImportMembers::Nested"*)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested14virtualInclassEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers6Nested14virtualInclassEv(%"struct.ImportMembers::Nested"* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested16virtualInlineDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers6Nested16virtualInlineDefEv(%"struct.ImportMembers::Nested"* %this)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN13ImportMembers6Nested17virtualInlineDeclEv(%"struct.ImportMembers::Nested"* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN13ImportMembers6Nested17virtualInlineDeclEv(%"struct.ImportMembers::Nested"* %this)
 
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?virtualInclass@Nested@ImportMembers@@UAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?virtualInlineDef@Nested@ImportMembers@@UAEXXZ"(
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?virtualInlineDecl@Nested@ImportMembers@@UAEXXZ"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested14virtualInclassEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested16virtualInlineDefEv(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN13ImportMembers6Nested17virtualInlineDeclEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc                   void @_ZN13ImportMembers6Nested14virtualInclassEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc                   void @_ZN13ImportMembers6Nested16virtualInlineDefEv(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc                   void @_ZN13ImportMembers6Nested17virtualInlineDeclEv(
   __declspec(dllimport) virtual        void virtualDef(); // dllimport ignored
   __declspec(dllimport) virtual        void virtualDecl();
   __declspec(dllimport) virtual        void virtualInclass() {}
@@ -307,15 +307,15 @@
   // MSC-DAG: declare dllimport                void @"\01?staticInlineDecl@Nested@ImportMembers@@SAXXZ"()
   // GNU-DAG: define                           void @_ZN13ImportMembers6Nested9staticDefEv()
   // GNU-DAG: declare dllimport                void @_ZN13ImportMembers6Nested10staticDeclEv()
-  // GNU-DAG: declare dllimport                void @_ZN13ImportMembers6Nested13staticInclassEv()
-  // GNU-DAG: declare dllimport                void @_ZN13ImportMembers6Nested15staticInlineDefEv()
-  // GNU-DAG: declare dllimport                void @_ZN13ImportMembers6Nested16staticInlineDeclEv()
+  // GNU-DAG: define linkonce_odr              void @_ZN13ImportMembers6Nested13staticInclassEv()
+  // GNU-DAG: define linkonce_odr              void @_ZN13ImportMembers6Nested15staticInlineDefEv()
+  // GNU-DAG: define linkonce_odr              void @_ZN13ImportMembers6Nested16staticInlineDeclEv()
   // MO1-DAG: define available_externally dllimport void @"\01?staticInclass@Nested@ImportMembers@@SAXXZ"()
   // MO1-DAG: define available_externally dllimport void @"\01?staticInlineDef@Nested@ImportMembers@@SAXXZ"()
   // MO1-DAG: define available_externally dllimport void @"\01?staticInlineDecl@Nested@ImportMembers@@SAXXZ"()
-  // GO1-DAG: define available_externally dllimport void @_ZN13ImportMembers6Nested13staticInclassEv()
-  // GO1-DAG: define available_externally dllimport void @_ZN13ImportMembers6Nested15staticInlineDefEv()
-  // GO1-DAG: define available_externally dllimport void @_ZN13ImportMembers6Nested16staticInlineDeclEv()
+  // GO1-DAG: define linkonce_odr              void @_ZN13ImportMembers6Nested13staticInclassEv()
+  // GO1-DAG: define linkonce_odr              void @_ZN13ImportMembers6Nested15staticInlineDefEv()
+  // GO1-DAG: define linkonce_odr              void @_ZN13ImportMembers6Nested16staticInlineDeclEv()
   __declspec(dllimport) static         void staticDef(); // dllimport ignored
   __declspec(dllimport) static         void staticDecl();
   __declspec(dllimport) static         void staticInclass() {}
@@ -420,28 +420,28 @@
   // G64-DAG: declare dllimport                void                    @_ZN14ImportSpecialsD1Ev(%struct.ImportSpecials*)
   __declspec(dllimport) ~ImportSpecials();
 
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportSpecials* @"\01??0ImportSpecials@@QAE@ABU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* nonnull)
-  // M64-DAG: declare dllimport                %struct.ImportSpecials* @"\01??0ImportSpecials@@QEAA@AEBU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc void                    @_ZN14ImportSpecialsC1ERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // G64-DAG: declare dllimport                void                    @_ZN14ImportSpecialsC1ERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
+  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportSpecials* @"\01??0ImportSpecials@@QAE@ABU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                %struct.ImportSpecials* @"\01??0ImportSpecials@@QEAA@AEBU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: declare dllimport x86_thiscallcc void                    @_ZN14ImportSpecialsC1ERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: declare dllimport                void                    @_ZN14ImportSpecialsC1ERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportSpecials(const ImportSpecials&);
 
-  // M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportSpecials* @"\01??4ImportSpecials@@QAEAAU0@ABU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // M64-DAG: declare dllimport                nonnull %struct.ImportSpecials* @"\01??4ImportSpecials@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportSpecials* @_ZN14ImportSpecialsaSERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // G64-DAG: declare dllimport                nonnull %struct.ImportSpecials* @_ZN14ImportSpecialsaSERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
+  // M32-DAG: declare dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @"\01??4ImportSpecials@@QAEAAU0@ABU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @"\01??4ImportSpecials@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: declare dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @_ZN14ImportSpecialsaSERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: declare dllimport                dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @_ZN14ImportSpecialsaSERKS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportSpecials& operator=(const ImportSpecials&);
 
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportSpecials* @"\01??0ImportSpecials@@QAE@$$QAU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* nonnull)
-  // M64-DAG: declare dllimport                %struct.ImportSpecials* @"\01??0ImportSpecials@@QEAA@$$QEAU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc void                    @_ZN14ImportSpecialsC1EOS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // G64-DAG: declare dllimport                void                    @_ZN14ImportSpecialsC1EOS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
+  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportSpecials* @"\01??0ImportSpecials@@QAE@$$QAU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                %struct.ImportSpecials* @"\01??0ImportSpecials@@QEAA@$$QEAU0@@Z"(%struct.ImportSpecials* returned, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: declare dllimport x86_thiscallcc void                    @_ZN14ImportSpecialsC1EOS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: declare dllimport                void                    @_ZN14ImportSpecialsC1EOS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportSpecials(ImportSpecials&&);
 
-  // M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportSpecials* @"\01??4ImportSpecials@@QAEAAU0@$$QAU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // M64-DAG: declare dllimport                nonnull %struct.ImportSpecials* @"\01??4ImportSpecials@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportSpecials* @_ZN14ImportSpecialsaSEOS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
-  // G64-DAG: declare dllimport                nonnull %struct.ImportSpecials* @_ZN14ImportSpecialsaSEOS_(%struct.ImportSpecials*, %struct.ImportSpecials* nonnull)
+  // M32-DAG: declare dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @"\01??4ImportSpecials@@QAEAAU0@$$QAU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @"\01??4ImportSpecials@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: declare dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @_ZN14ImportSpecialsaSEOS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: declare dllimport                dereferenceable({{[0-9]+}}) %struct.ImportSpecials* @_ZN14ImportSpecialsaSEOS_(%struct.ImportSpecials*, %struct.ImportSpecials* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportSpecials& operator=(ImportSpecials&&);
 };
 USESPECIALS(ImportSpecials)
@@ -449,52 +449,52 @@
 
 // Export inline special member functions.
 struct ImportInlineSpecials {
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@XZ"(%struct.ImportInlineSpecials* returned)
-  // M64-DAG: declare dllimport                %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QEAA@XZ"(%struct.ImportInlineSpecials* returned)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsC1Ev(%struct.ImportInlineSpecials*)
-  // G64-DAG: declare dllimport                void @_ZN20ImportInlineSpecialsC1Ev(%struct.ImportInlineSpecials*)
+  // M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@XZ"(%struct.ImportInlineSpecials* returned)
+  // M64-DAG: declare dllimport                  %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QEAA@XZ"(%struct.ImportInlineSpecials* returned)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1Ev(%struct.ImportInlineSpecials* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN20ImportInlineSpecialsC1Ev(%struct.ImportInlineSpecials* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@XZ"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsC1Ev(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1Ev(
   __declspec(dllimport) ImportInlineSpecials() {}
 
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportInlineSpecials@@QAE@XZ"(%struct.ImportInlineSpecials*)
-  // M64-DAG: declare dllimport                void @"\01??1ImportInlineSpecials@@QEAA@XZ"(%struct.ImportInlineSpecials*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsD1Ev(%struct.ImportInlineSpecials*)
-  // G64-DAG: declare dllimport                void @_ZN20ImportInlineSpecialsD1Ev(%struct.ImportInlineSpecials*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01??1ImportInlineSpecials@@QAE@XZ"(%struct.ImportInlineSpecials*)
+  // M64-DAG: declare dllimport                  void @"\01??1ImportInlineSpecials@@QEAA@XZ"(%struct.ImportInlineSpecials*)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsD1Ev(%struct.ImportInlineSpecials* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN20ImportInlineSpecialsD1Ev(%struct.ImportInlineSpecials* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1ImportInlineSpecials@@QAE@XZ"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsD1Ev(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsD1Ev(
   __declspec(dllimport) ~ImportInlineSpecials() {}
 
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@ABU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* nonnull)
-  // M64-DAG: declare dllimport                %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QEAA@AEBU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsC1ERKS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // G64-DAG: declare dllimport                void @_ZN20ImportInlineSpecialsC1ERKS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
+  // M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@ABU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QEAA@AEBU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1ERKS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                void @_ZN20ImportInlineSpecialsC1ERKS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
   // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@ABU0@@Z"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsC1ERKS_(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1ERKS_(
   __declspec(dllimport) inline ImportInlineSpecials(const ImportInlineSpecials&);
 
-  // M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@ABU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // M64-DAG: declare dllimport                nonnull %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSERKS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // G64-DAG: declare dllimport                nonnull %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSERKS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@ABU0@@Z"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSERKS_(
+  // M32-DAG: declare dllimport   x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@ABU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSERKS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSERKS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@ABU0@@Z"(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSERKS_(
   __declspec(dllimport) ImportInlineSpecials& operator=(const ImportInlineSpecials&);
 
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@$$QAU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* nonnull)
-  // M64-DAG: declare dllimport                %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QEAA@$$QEAU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsC1EOS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // G64-DAG: declare dllimport                void @_ZN20ImportInlineSpecialsC1EOS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
+  // M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@$$QAU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QEAA@$$QEAU0@@Z"(%struct.ImportInlineSpecials* returned, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1EOS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                void @_ZN20ImportInlineSpecialsC1EOS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
   // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportInlineSpecials* @"\01??0ImportInlineSpecials@@QAE@$$QAU0@@Z"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN20ImportInlineSpecialsC1EOS_(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN20ImportInlineSpecialsC1EOS_(
   __declspec(dllimport) ImportInlineSpecials(ImportInlineSpecials&&) {}
 
-  // M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@$$QAU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // M64-DAG: declare dllimport                nonnull %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSEOS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // G64-DAG: declare dllimport                nonnull %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSEOS_(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* nonnull)
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@$$QAU0@@Z"(
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSEOS_(
+  // M32-DAG: declare dllimport   x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@$$QAU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportInlineSpecials*, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSEOS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSEOS_(%struct.ImportInlineSpecials* %this, %struct.ImportInlineSpecials* dereferenceable({{[0-9]+}}))
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @"\01??4ImportInlineSpecials@@QAEAAU0@$$QAU0@@Z"(
+  // GO1-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportInlineSpecials* @_ZN20ImportInlineSpecialsaSEOS_(
   __declspec(dllimport) ImportInlineSpecials& operator=(ImportInlineSpecials&&) { return *this; }
 };
 ImportInlineSpecials::ImportInlineSpecials(const ImportInlineSpecials&) {}
@@ -504,52 +504,52 @@
 
 // Import defaulted member functions.
 struct ImportDefaulted {
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@XZ"(%struct.ImportDefaulted* returned)
-  // M64-DAG: declare dllimport                %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QEAA@XZ"(%struct.ImportDefaulted* returned)
-  // G32-DAG: declare dllimport x86_thiscallcc void                     @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted*)
-  // G64-DAG: declare dllimport                void                     @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted*)
+  // M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@XZ"(%struct.ImportDefaulted* returned)
+  // M64-DAG: declare dllimport                  %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QEAA@XZ"(%struct.ImportDefaulted* returned)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void                     @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted* %this)
+  // G64-DAG: define linkonce_odr                void                     @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@XZ"(%struct.ImportDefaulted* returned %this)
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted* %this)
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedC1Ev(%struct.ImportDefaulted* %this)
   __declspec(dllimport) ImportDefaulted() = default;
 
-  // M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportDefaulted@@QAE@XZ"(%struct.ImportDefaulted*)
-  // M64-DAG: declare dllimport                void @"\01??1ImportDefaulted@@QEAA@XZ"(%struct.ImportDefaulted*)
-  // G32-DAG: declare dllimport x86_thiscallcc void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted*)
-  // G64-DAG: declare dllimport                void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted*)
+  // M32-DAG: declare dllimport   x86_thiscallcc void @"\01??1ImportDefaulted@@QAE@XZ"(%struct.ImportDefaulted*)
+  // M64-DAG: declare dllimport                  void @"\01??1ImportDefaulted@@QEAA@XZ"(%struct.ImportDefaulted*)
+  // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted* %this)
+  // G64-DAG: define linkonce_odr                void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted* %this)
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01??1ImportDefaulted@@QAE@XZ"(%struct.ImportDefaulted* %this)
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted* %this)
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedD1Ev(%struct.ImportDefaulted* %this)
   __declspec(dllimport) ~ImportDefaulted() = default;
 
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@ABU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* nonnull)
-  // M64-DAG: declare dllimport                %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QEAA@AEBU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc void                     @_ZN15ImportDefaultedC1ERKS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // G64-DAG: declare dllimport                void                     @_ZN15ImportDefaultedC1ERKS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@ABU0@@Z"(%struct.ImportDefaulted* returned %this, %struct.ImportDefaulted* nonnull)
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN15ImportDefaultedC1ERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* nonnull)
+  // M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@ABU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QEAA@AEBU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc void                     @_ZN15ImportDefaultedC1ERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                void                     @_ZN15ImportDefaultedC1ERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@ABU0@@Z"(%struct.ImportDefaulted* returned %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedC1ERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportDefaulted(const ImportDefaulted&) = default;
 
-  // M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@ABU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // M64-DAG: declare dllimport                nonnull %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @_ZN15ImportDefaultedaSERKS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // G64-DAG: declare dllimport                nonnull %struct.ImportDefaulted* @_ZN15ImportDefaultedaSERKS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@ABU0@@Z"(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* nonnull)
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @_ZN15ImportDefaultedaSERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* nonnull)
+  // M32-DAG: declare dllimport   x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@ABU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @_ZN15ImportDefaultedaSERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @_ZN15ImportDefaultedaSERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@ABU0@@Z"(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // GO1-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @_ZN15ImportDefaultedaSERKS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportDefaulted& operator=(const ImportDefaulted&) = default;
 
-  // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@$$QAU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* nonnull)
-  // M64-DAG: declare dllimport                %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QEAA@$$QEAU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc void                     @_ZN15ImportDefaultedC1EOS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // G64-DAG: declare dllimport                void                     @_ZN15ImportDefaultedC1EOS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@$$QAU0@@Z"(%struct.ImportDefaulted* returned %this, %struct.ImportDefaulted* nonnull)
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc void @_ZN15ImportDefaultedC1EOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* nonnull)
+  // M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@$$QAU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QEAA@$$QEAU0@@Z"(%struct.ImportDefaulted* returned, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc void                     @_ZN15ImportDefaultedC1EOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                void                     @_ZN15ImportDefaultedC1EOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc %struct.ImportDefaulted* @"\01??0ImportDefaulted@@QAE@$$QAU0@@Z"(%struct.ImportDefaulted* returned %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // GO1-DAG: define linkonce_odr x86_thiscallcc void @_ZN15ImportDefaultedC1EOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportDefaulted(ImportDefaulted&&) = default;
 
-  // M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@$$QAU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // M64-DAG: declare dllimport                nonnull %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @_ZN15ImportDefaultedaSEOS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // G64-DAG: declare dllimport                nonnull %struct.ImportDefaulted* @_ZN15ImportDefaultedaSEOS_(%struct.ImportDefaulted*, %struct.ImportDefaulted* nonnull)
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@$$QAU0@@Z"(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* nonnull)
-  // GO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.ImportDefaulted* @_ZN15ImportDefaultedaSEOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* nonnull)
+  // M32-DAG: declare dllimport   x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@$$QAU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // M64-DAG: declare dllimport                  dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportDefaulted*, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G32-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @_ZN15ImportDefaultedaSEOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // G64-DAG: define linkonce_odr                dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @_ZN15ImportDefaultedaSEOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @"\01??4ImportDefaulted@@QAEAAU0@$$QAU0@@Z"(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
+  // GO1-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaulted* @_ZN15ImportDefaultedaSEOS_(%struct.ImportDefaulted* %this, %struct.ImportDefaulted* dereferenceable({{[0-9]+}}))
   __declspec(dllimport) ImportDefaulted& operator=(ImportDefaulted&&) = default;
 
   ForceNonTrivial v; // ensure special members are non-trivial
@@ -569,42 +569,44 @@
   __declspec(dllimport) ImportDefaultedDefs& operator=(ImportDefaultedDefs&&);
 };
 
+#ifdef MSABI
+// For MinGW, the function will not be dllimport, and we cannot add the attribute now.
 // M32-DAG: declare dllimport x86_thiscallcc %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QAE@XZ"(%struct.ImportDefaultedDefs* returned)
 // M64-DAG: declare dllimport                %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QEAA@XZ"(%struct.ImportDefaultedDefs* returned)
-// G32-DAG: declare dllimport x86_thiscallcc void                         @_ZN19ImportDefaultedDefsC1Ev(%struct.ImportDefaultedDefs*)
-// G64-DAG: declare dllimport                void                         @_ZN19ImportDefaultedDefsC1Ev(%struct.ImportDefaultedDefs*)
 __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs() = default;
+#endif
 
+#ifdef MSABI
+// For MinGW, the function will not be dllimport, and we cannot add the attribute now.
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01??1ImportDefaultedDefs@@QAE@XZ"(%struct.ImportDefaultedDefs*)
 // M64-DAG: declare dllimport                void @"\01??1ImportDefaultedDefs@@QEAA@XZ"(%struct.ImportDefaultedDefs*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN19ImportDefaultedDefsD1Ev(%struct.ImportDefaultedDefs*)
-// G64-DAG: declare dllimport                void @_ZN19ImportDefaultedDefsD1Ev(%struct.ImportDefaultedDefs*)
 __declspec(dllimport) ImportDefaultedDefs::~ImportDefaultedDefs() = default;
+#endif
 
-// M32-DAG: declare dllimport x86_thiscallcc %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QAE@ABU0@@Z"(%struct.ImportDefaultedDefs* returned, %struct.ImportDefaultedDefs* nonnull)
-// M64-DAG: declare dllimport                %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QEAA@AEBU0@@Z"(%struct.ImportDefaultedDefs* returned, %struct.ImportDefaultedDefs* nonnull)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN19ImportDefaultedDefsC1ERKS_(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* nonnull)
-// G64-DAG: declare dllimport                void @_ZN19ImportDefaultedDefsC1ERKS_(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* nonnull)
+// M32-DAG: declare dllimport   x86_thiscallcc %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QAE@ABU0@@Z"(%struct.ImportDefaultedDefs* returned, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: declare dllimport                  %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QEAA@AEBU0@@Z"(%struct.ImportDefaultedDefs* returned, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN19ImportDefaultedDefsC1ERKS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define linkonce_odr                void @_ZN19ImportDefaultedDefsC1ERKS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
 inline ImportDefaultedDefs::ImportDefaultedDefs(const ImportDefaultedDefs&) = default;
 
-// M32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QAEAAU0@ABU0@@Z"(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* nonnull)
-// M64-DAG: declare dllimport                nonnull %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* nonnull)
-// G32-DAG: declare dllimport x86_thiscallcc nonnull %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSERKS_(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* nonnull)
-// G64-DAG: declare dllimport                nonnull %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSERKS_(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* nonnull)
+// M32-DAG: declare dllimport   x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QAEAAU0@ABU0@@Z"(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: declare dllimport                  dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QEAAAEAU0@AEBU0@@Z"(%struct.ImportDefaultedDefs*, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSERKS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define linkonce_odr                dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSERKS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
 inline ImportDefaultedDefs& ImportDefaultedDefs::operator=(const ImportDefaultedDefs&) = default;
 
-// M32-DAG: define x86_thiscallcc %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QAE@$$QAU0@@Z"(%struct.ImportDefaultedDefs* returned %this, %struct.ImportDefaultedDefs* nonnull)
-// M64-DAG: define                %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QEAA@$$QEAU0@@Z"(%struct.ImportDefaultedDefs* returned %this, %struct.ImportDefaultedDefs* nonnull)
-// G32-DAG: define x86_thiscallcc void @_ZN19ImportDefaultedDefsC1EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
-// G64-DAG: define                void @_ZN19ImportDefaultedDefsC1EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
-// G32-DAG: define x86_thiscallcc void @_ZN19ImportDefaultedDefsC2EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
-// G64-DAG: define                void @_ZN19ImportDefaultedDefsC2EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
+// M32-DAG: define x86_thiscallcc %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QAE@$$QAU0@@Z"(%struct.ImportDefaultedDefs* returned %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: define                %struct.ImportDefaultedDefs* @"\01??0ImportDefaultedDefs@@QEAA@$$QEAU0@@Z"(%struct.ImportDefaultedDefs* returned %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define x86_thiscallcc void @_ZN19ImportDefaultedDefsC1EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define                void @_ZN19ImportDefaultedDefsC1EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define x86_thiscallcc void @_ZN19ImportDefaultedDefsC2EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define                void @_ZN19ImportDefaultedDefsC2EOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
 ImportDefaultedDefs::ImportDefaultedDefs(ImportDefaultedDefs&&) = default; // dllimport ignored
 
-// M32-DAG: define x86_thiscallcc nonnull %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QAEAAU0@$$QAU0@@Z"(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
-// M64-DAG: define                nonnull %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
-// G32-DAG: define x86_thiscallcc nonnull %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSEOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
-// G64-DAG: define                nonnull %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSEOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* nonnull)
+// M32-DAG: define x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QAEAAU0@$$QAU0@@Z"(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// M64-DAG: define                dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @"\01??4ImportDefaultedDefs@@QEAAAEAU0@$$QEAU0@@Z"(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G32-DAG: define x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSEOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
+// G64-DAG: define                dereferenceable({{[0-9]+}}) %struct.ImportDefaultedDefs* @_ZN19ImportDefaultedDefsaSEOS_(%struct.ImportDefaultedDefs* %this, %struct.ImportDefaultedDefs* dereferenceable({{[0-9]+}}))
 ImportDefaultedDefs& ImportDefaultedDefs::operator=(ImportDefaultedDefs&&) = default; // dllimport ignored
 
 USESPECIALS(ImportDefaultedDefs)
@@ -655,14 +657,14 @@
 };
 
 // Import implicit instantiation of an imported member function template.
-// M32-DAG: declare dllimport x86_thiscallcc void @"\01??$importedNormal@UImplicitInst_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
-// M64-DAG: declare dllimport                void @"\01??$importedNormal@UImplicitInst_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl14importedNormalI21ImplicitInst_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedNormalI21ImplicitInst_ImportedEEvv(%struct.MemFunTmpl*)
+// M32-DAG: declare dllimport   x86_thiscallcc void @"\01??$importedNormal@UImplicitInst_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
+// M64-DAG: declare dllimport                  void @"\01??$importedNormal@UImplicitInst_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
+// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN10MemFunTmpl14importedNormalI21ImplicitInst_ImportedEEvv(%struct.MemFunTmpl* %this)
+// G64-DAG: define linkonce_odr                void @_ZN10MemFunTmpl14importedNormalI21ImplicitInst_ImportedEEvv(%struct.MemFunTmpl* %this)
 USEMF(MemFunTmpl, importedNormal<ImplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport                void @"\01??$importedStatic@UImplicitInst_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedStaticI21ImplicitInst_ImportedEEvv()
+// GNU-DAG: define linkonce_odr              void @_ZN10MemFunTmpl14importedStaticI21ImplicitInst_ImportedEEvv()
 USE(MemFunTmpl::importedStatic<ImplicitInst_Imported>)
 
 
@@ -670,13 +672,13 @@
 // template.
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01??$importedNormal@UExplicitDecl_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
 // M64-DAG: declare dllimport                void @"\01??$importedNormal@UExplicitDecl_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl14importedNormalI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedNormalI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
+// G32-DAG: declare x86_thiscallcc           void @_ZN10MemFunTmpl14importedNormalI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
+// G64-DAG: declare                          void @_ZN10MemFunTmpl14importedNormalI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
 extern template void MemFunTmpl::importedNormal<ExplicitDecl_Imported>();
 USEMF(MemFunTmpl, importedNormal<ExplicitDecl_Imported>)
 
 // MSC-DAG: declare dllimport                void @"\01??$importedStatic@UExplicitDecl_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedStaticI21ExplicitDecl_ImportedEEvv()
+// GNU-DAG: declare                          void @_ZN10MemFunTmpl14importedStaticI21ExplicitDecl_ImportedEEvv()
 extern template void MemFunTmpl::importedStatic<ExplicitDecl_Imported>();
 USE(MemFunTmpl::importedStatic<ExplicitDecl_Imported>)
 
@@ -685,13 +687,13 @@
 // template.
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01??$importedNormal@UExplicitInst_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
 // M64-DAG: declare dllimport                void @"\01??$importedNormal@UExplicitInst_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl14importedNormalI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedNormalI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl*)
+// G32-DAG: define weak_odr x86_thiscallcc   void @_ZN10MemFunTmpl14importedNormalI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl* %this)
+// G64-DAG: define weak_odr                  void @_ZN10MemFunTmpl14importedNormalI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl* %this)
 template void MemFunTmpl::importedNormal<ExplicitInst_Imported>();
 USEMF(MemFunTmpl, importedNormal<ExplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport                void @"\01??$importedStatic@UExplicitInst_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedStaticI21ExplicitInst_ImportedEEvv()
+// GNU-DAG: define weak_odr                  void @_ZN10MemFunTmpl14importedStaticI21ExplicitInst_ImportedEEvv()
 template void MemFunTmpl::importedStatic<ExplicitInst_Imported>();
 USE(MemFunTmpl::importedStatic<ExplicitInst_Imported>)
 
@@ -711,10 +713,10 @@
 //USEMF(MemFunTmpl, importedNormal<ExplicitSpec_Def_Imported>)
 #endif
 
-// M32-DAG: declare dllimport x86_thiscallcc void @"\01??$importedNormal@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
-// M64-DAG: declare dllimport                void @"\01??$importedNormal@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl14importedNormalI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedNormalI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl*)
+// M32-DAG: declare dllimport   x86_thiscallcc void @"\01??$importedNormal@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
+// M64-DAG: declare dllimport                  void @"\01??$importedNormal@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
+// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN10MemFunTmpl14importedNormalI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl* %this)
+// G64-DAG: define linkonce_odr                void @_ZN10MemFunTmpl14importedNormalI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl* %this)
 template<> __declspec(dllimport) inline void MemFunTmpl::importedNormal<ExplicitSpec_InlineDef_Imported>() {}
 USEMF(MemFunTmpl, importedNormal<ExplicitSpec_InlineDef_Imported>)
 
@@ -731,7 +733,7 @@
 #endif
 
 // MSC-DAG: declare dllimport                void @"\01??$importedStatic@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport                void @_ZN10MemFunTmpl14importedStaticI31ExplicitSpec_InlineDef_ImportedEEvv()
+// GNU-DAG: define linkonce_odr              void @_ZN10MemFunTmpl14importedStaticI31ExplicitSpec_InlineDef_ImportedEEvv()
 template<> __declspec(dllimport) inline void MemFunTmpl::importedStatic<ExplicitSpec_InlineDef_Imported>() {}
 USE(MemFunTmpl::importedStatic<ExplicitSpec_InlineDef_Imported>)
 
@@ -755,13 +757,13 @@
 // template.
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01??$normalDef@UExplicitDecl_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
 // M64-DAG: declare dllimport                void @"\01??$normalDef@UExplicitDecl_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl9normalDefI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl9normalDefI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
+// G32-DAG: declare x86_thiscallcc           void @_ZN10MemFunTmpl9normalDefI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
+// G64-DAG: declare                          void @_ZN10MemFunTmpl9normalDefI21ExplicitDecl_ImportedEEvv(%struct.MemFunTmpl*)
 extern template __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitDecl_Imported>();
 USEMF(MemFunTmpl, normalDef<ExplicitDecl_Imported>)
 
 // MSC-DAG: declare dllimport                void @"\01??$staticDef@UExplicitDecl_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport                void @_ZN10MemFunTmpl9staticDefI21ExplicitDecl_ImportedEEvv()
+// GNU-DAG: declare                          void @_ZN10MemFunTmpl9staticDefI21ExplicitDecl_ImportedEEvv()
 extern template __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitDecl_Imported>();
 USE(MemFunTmpl::staticDef<ExplicitDecl_Imported>)
 
@@ -770,13 +772,13 @@
 // template.
 // M32-DAG: declare dllimport x86_thiscallcc void @"\01??$normalDef@UExplicitInst_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
 // M64-DAG: declare dllimport                void @"\01??$normalDef@UExplicitInst_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl9normalDefI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl9normalDefI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl*)
+// G32-DAG: define weak_odr x86_thiscallcc   void @_ZN10MemFunTmpl9normalDefI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl* %this)
+// G64-DAG: define weak_odr                  void @_ZN10MemFunTmpl9normalDefI21ExplicitInst_ImportedEEvv(%struct.MemFunTmpl* %this)
 template __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitInst_Imported>();
 USEMF(MemFunTmpl, normalDef<ExplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport                void @"\01??$staticDef@UExplicitInst_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport                void @_ZN10MemFunTmpl9staticDefI21ExplicitInst_ImportedEEvv()
+// GNU-DAG: define weak_odr                  void @_ZN10MemFunTmpl9staticDefI21ExplicitInst_ImportedEEvv()
 template __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitInst_Imported>();
 USE(MemFunTmpl::staticDef<ExplicitInst_Imported>)
 
@@ -796,10 +798,10 @@
 //USEMF(MemFunTmpl, normalDef<ExplicitSpec_Def_Imported>)
 #endif
 
-// M32-DAG: declare dllimport x86_thiscallcc void @"\01??$normalDef@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
-// M64-DAG: declare dllimport                void @"\01??$normalDef@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
-// G32-DAG: declare dllimport x86_thiscallcc void @_ZN10MemFunTmpl9normalDefI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl*)
-// G64-DAG: declare dllimport                void @_ZN10MemFunTmpl9normalDefI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl*)
+// M32-DAG: declare dllimport   x86_thiscallcc void @"\01??$normalDef@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QAEXXZ"(%struct.MemFunTmpl*)
+// M64-DAG: declare dllimport                  void @"\01??$normalDef@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@QEAAXXZ"(%struct.MemFunTmpl*)
+// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN10MemFunTmpl9normalDefI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl* %this)
+// G64-DAG: define linkonce_odr                void @_ZN10MemFunTmpl9normalDefI31ExplicitSpec_InlineDef_ImportedEEvv(%struct.MemFunTmpl* %this)
 template<> __declspec(dllimport) inline void MemFunTmpl::normalDef<ExplicitSpec_InlineDef_Imported>() {}
 USEMF(MemFunTmpl, normalDef<ExplicitSpec_InlineDef_Imported>)
 
@@ -816,7 +818,7 @@
 #endif
 
 // MSC-DAG: declare dllimport void @"\01??$staticDef@UExplicitSpec_InlineDef_Imported@@@MemFunTmpl@@SAXXZ"()
-// GNU-DAG: declare dllimport void @_ZN10MemFunTmpl9staticDefI31ExplicitSpec_InlineDef_ImportedEEvv()
+// GNU-DAG: define linkonce_odr void @_ZN10MemFunTmpl9staticDefI31ExplicitSpec_InlineDef_ImportedEEvv()
 template<> __declspec(dllimport) inline void MemFunTmpl::staticDef<ExplicitSpec_InlineDef_Imported>() {}
 USE(MemFunTmpl::staticDef<ExplicitSpec_InlineDef_Imported>)
 
diff --git a/test/CodeGenCXX/dllimport-rtti.cpp b/test/CodeGenCXX/dllimport-rtti.cpp
index 7ed7dad..b5a5d54 100644
--- a/test/CodeGenCXX/dllimport-rtti.cpp
+++ b/test/CodeGenCXX/dllimport-rtti.cpp
@@ -1,13 +1,17 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -O1 -disable-llvm-optzns -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -O1 -disable-llvm-optzns -o - %s | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -triple i686-windows-gnu  -emit-llvm -std=c++1y -O1 -disable-llvm-optzns -o - %s | FileCheck %s --check-prefix=GNU
 
 struct __declspec(dllimport) S {
-  virtual void f();
+  virtual void f() {}
 } s;
-// CHECK-DAG: @"\01??_7S@@6B@" = available_externally dllimport
-// CHECK-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
-// CHECK-DAG: @"\01??_R1A@?0A@EA@S@@8" = linkonce_odr
-// CHECK-DAG: @"\01??_R2S@@8" = linkonce_odr
-// CHECK-DAG: @"\01??_R3S@@8" = linkonce_odr
+// MSVC-DAG: @"\01??_7S@@6B@" = available_externally dllimport
+// MSVC-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
+// MSVC-DAG: @"\01??_R1A@?0A@EA@S@@8" = linkonce_odr
+// MSVC-DAG: @"\01??_R2S@@8" = linkonce_odr
+// MSVC-DAG: @"\01??_R3S@@8" = linkonce_odr
+
+// GNU-DAG: @_ZTV1S = available_externally dllimport
+// GNU-DAG: @_ZTI1S = external dllimport
 
 struct U : S {
 } u;
diff --git a/test/CodeGenCXX/dllimport.cpp b/test/CodeGenCXX/dllimport.cpp
index d15eea2..5ebedd9 100644
--- a/test/CodeGenCXX/dllimport.cpp
+++ b/test/CodeGenCXX/dllimport.cpp
@@ -95,7 +95,7 @@
 USE(inlineStaticLocalsFunc);
 
 // The address of a dllimport global cannot be used in constant initialization.
-// M32-DAG: @"\01?arr@?0??initializationFunc@@YAPAHXZ@4QBQAHB" = internal global [1 x i32*] zeroinitializer
+// M32-DAG: @"\01?arr@?1??initializationFunc@@YAPAHXZ@4QBQAHB" = internal global [1 x i32*] zeroinitializer
 // GNU-DAG: @_ZZ18initializationFuncvE3arr = internal global [1 x i32*] zeroinitializer
 int *initializationFunc() {
   static int *const arr[] = {&ExternGlobalDecl};
@@ -214,31 +214,31 @@
 
 // Import inline function.
 // MSC-DAG: declare dllimport void @"\01?inlineFunc@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z10inlineFuncv()
+// GNU-DAG: define linkonce_odr void @_Z10inlineFuncv()
 // MO1-DAG: define available_externally dllimport void @"\01?inlineFunc@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z10inlineFuncv()
+// GO1-DAG: define linkonce_odr void @_Z10inlineFuncv()
 __declspec(dllimport) inline void inlineFunc() {}
 USE(inlineFunc)
 
 // MSC-DAG: declare dllimport void @"\01?inlineDecl@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z10inlineDeclv()
+// GNU-DAG: define linkonce_odr void @_Z10inlineDeclv()
 // MO1-DAG: define available_externally dllimport void @"\01?inlineDecl@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z10inlineDeclv()
+// GO1-DAG: define linkonce_odr void @_Z10inlineDeclv()
 __declspec(dllimport) inline void inlineDecl();
                              void inlineDecl() {}
 USE(inlineDecl)
 
 // MSC-DAG: declare dllimport void @"\01?inlineDef@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z9inlineDefv()
+// GNU-DAG: define linkonce_odr void @_Z9inlineDefv()
 // MO1-DAG: define available_externally dllimport void @"\01?inlineDef@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z9inlineDefv()
+// GO1-DAG: define linkonce_odr void @_Z9inlineDefv()
 __declspec(dllimport) void inlineDef();
                inline void inlineDef() {}
 USE(inlineDef)
 
 // inline attributes
 // MSC-DAG: declare dllimport void @"\01?noinline@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z8noinlinev()
+// GNU-DAG: define linkonce_odr void @_Z8noinlinev()
 __declspec(dllimport) __attribute__((noinline)) inline void noinline() {}
 USE(noinline)
 
@@ -276,6 +276,11 @@
 // GNU-DAG: declare           void @_Z7friend2v()
 // MSC-DAG: define            void @"\01?friend3@@YAXXZ"()
 // GNU-DAG: define            void @_Z7friend3v()
+// MSC-DAG: declare           void @"\01?friend4@@YAXXZ"()
+// GNU-DAG: declare           void @_Z7friend4v()
+// MSC-DAG: declare dllimport void @"\01?friend5@@YAXXZ"()
+// GNU-DAG: declare dllimport void @_Z7friend5v()
+
 struct FuncFriend {
   friend __declspec(dllimport) void friend1();
   friend __declspec(dllimport) void friend2();
@@ -284,9 +289,18 @@
 __declspec(dllimport) void friend1();
                       void friend2(); // dllimport ignored
                       void friend3() {} // dllimport ignored
+
+__declspec(dllimport) void friend4();
+__declspec(dllimport) void friend5();
+struct FuncFriendRedecl {
+  friend void friend4(); // dllimport ignored
+  friend void ::friend5();
+};
 USE(friend1)
 USE(friend2)
 USE(friend3)
+USE(friend4)
+USE(friend5)
 
 // Implicit declarations can be redeclared with dllimport.
 // MSC-DAG: declare dllimport noalias i8* @"\01??2@{{YAPAXI|YAPEAX_K}}@Z"(
@@ -315,31 +329,31 @@
 
 // Import inline function template.
 // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl1@UImplicitInst_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z15inlineFuncTmpl1I21ImplicitInst_ImportedEvv()
 template<typename T> __declspec(dllimport) inline void inlineFuncTmpl1() {}
 USE(inlineFuncTmpl1<ImplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl2@UImplicitInst_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z15inlineFuncTmpl2I21ImplicitInst_ImportedEvv()
 template<typename T> inline void __attribute__((dllimport)) inlineFuncTmpl2() {}
 USE(inlineFuncTmpl2<ImplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDecl@UImplicitInst_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z18inlineFuncTmplDeclI21ImplicitInst_ImportedEvv()
 template<typename T> __declspec(dllimport) inline void inlineFuncTmplDecl();
 template<typename T>                              void inlineFuncTmplDecl() {}
 USE(inlineFuncTmplDecl<ImplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmplDef@UImplicitInst_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z17inlineFuncTmplDefI21ImplicitInst_ImportedEvv()
 template<typename T> __declspec(dllimport) void inlineFuncTmplDef();
 template<typename T>                inline void inlineFuncTmplDef() {}
 USE(inlineFuncTmplDef<ImplicitInst_Imported>)
@@ -373,7 +387,7 @@
 // MSC-DAG: define linkonce_odr void @"\01??$funcTmplFriend3@UImplicitInst_NotImported@@@@YAXXZ"()
 // GNU-DAG: define linkonce_odr void @_Z15funcTmplFriend3I24ImplicitInst_NotImportedEvv()
 // MSC-DAG: declare dllimport   void @"\01??$funcTmplFriend4@UImplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport   void @_Z15funcTmplFriend4I21ImplicitInst_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z15funcTmplFriend4I21ImplicitInst_ImportedEvv()
 struct FuncTmplFriend {
   template<typename T> friend __declspec(dllimport) void funcTmplFriend1();
   template<typename T> friend __declspec(dllimport) void funcTmplFriend2();
@@ -406,24 +420,24 @@
 USE(importedFuncTmplDecl<ImplicitInst_Imported>)
 
 // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UImplicitInst_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z16importedFuncTmplI21ImplicitInst_ImportedEvv()
 USE(importedFuncTmpl<ImplicitInst_Imported>)
 
 // Import explicit instantiation declaration of an imported function template.
 // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
+// GNU-DAG: declare void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
+// GO1-DAG: define available_externally void @_Z16importedFuncTmplI21ExplicitDecl_ImportedEvv()
 extern template void importedFuncTmpl<ExplicitDecl_Imported>();
 USE(importedFuncTmpl<ExplicitDecl_Imported>)
 
 // Import explicit instantiation definition of an imported function template.
 // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
+// GNU-DAG: define weak_odr void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
+// GO1-DAG: define weak_odr void @_Z16importedFuncTmplI21ExplicitInst_ImportedEvv()
 template void importedFuncTmpl<ExplicitInst_Imported>();
 USE(importedFuncTmpl<ExplicitInst_Imported>)
 
@@ -442,9 +456,9 @@
 #endif
 
 // MSC-DAG: declare dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmplDecl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z20importedFuncTmplDeclI31ExplicitSpec_InlineDef_ImportedEvv()
 template<> __declspec(dllimport) inline void importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>() {}
 USE(importedFuncTmplDecl<ExplicitSpec_InlineDef_Imported>)
 
@@ -462,9 +476,9 @@
 #endif
 
 // MSC-DAG: declare dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$importedFuncTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z16importedFuncTmplI31ExplicitSpec_InlineDef_ImportedEvv()
 template<> __declspec(dllimport) inline void importedFuncTmpl<ExplicitSpec_InlineDef_Imported>() {}
 USE(importedFuncTmpl<ExplicitSpec_InlineDef_Imported>)
 
@@ -481,9 +495,9 @@
 // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
 // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
 // GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitDecl_ImportedEvv()
-// GNU-DAG: declare dllimport void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
+// GNU-DAG: declare void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitDecl_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
+// GO1-DAG: define available_externally void @_Z14inlineFuncTmplI21ExplicitDecl_ImportedEvv()
 extern template __declspec(dllimport) void funcTmpl<ExplicitDecl_Imported>();
 extern template __declspec(dllimport) void inlineFuncTmpl<ExplicitDecl_Imported>();
 USE(funcTmpl<ExplicitDecl_Imported>)
@@ -494,11 +508,11 @@
 // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
 // MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
 // GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
-// GNU-DAG: declare dllimport void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
+// GNU-DAG: define weak_odr void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
 // MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
 // GO1-DAG: define available_externally dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
-// GO1-DAG: define available_externally dllimport void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
+// GO1-DAG: define weak_odr void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
 template __declspec(dllimport) void funcTmpl<ExplicitInst_Imported>();
 template __declspec(dllimport) void inlineFuncTmpl<ExplicitInst_Imported>();
 USE(funcTmpl<ExplicitInst_Imported>)
@@ -519,9 +533,9 @@
 #endif
 
 // MSC-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
-// GNU-DAG: declare dllimport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
+// GNU-DAG: define linkonce_odr void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
 // MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitSpec_InlineDef_Imported@@@@YAXXZ"()
-// GO1-DAG: define available_externally dllimport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
+// GO1-DAG: define linkonce_odr void @_Z8funcTmplI31ExplicitSpec_InlineDef_ImportedEvv()
 template<> __declspec(dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {}
 USE(funcTmpl<ExplicitSpec_InlineDef_Imported>)
 
@@ -539,11 +553,11 @@
   // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32
 
   T& operator=(T&) = default;
-  // MO1-DAG: define available_externally dllimport x86_thiscallcc nonnull %struct.T* @"\01??4T@@QAEAAU0@AAU0@@Z"
+  // MO1-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@AAU0@@Z"
 
   T& operator=(T&&) = default;
   // Note: Don't mark inline move operators dllimport because current MSVC versions don't export them.
-  // MO1-DAG: define linkonce_odr x86_thiscallcc nonnull %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
+  // MO1-DAG: define linkonce_odr x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
 };
 USEMEMFUNC(T, a)
 USEVAR(T::b)
@@ -658,18 +672,56 @@
   // MSC-DAG: @"\01?y@?$D@$0CK@@PR19933@@2HA" = available_externally dllimport global i32 0
 }
 
+namespace PR21355 {
+  struct __declspec(dllimport) S {
+    virtual ~S();
+  };
+  S::~S() {}
+
+  // S::~S is a key function, so we would ordinarily emit a strong definition for
+  // the vtable. However, S is imported, so the vtable should be too.
+
+  // GNU-DAG: @_ZTVN7PR213551SE = available_externally dllimport unnamed_addr constant [4 x i8*]
+}
+
+namespace PR21366 {
+  struct __declspec(dllimport) S {
+    void outOfLineMethod();
+    void inlineMethod() {}
+    inline void anotherInlineMethod();
+    void outOfClassInlineMethod();
+  };
+  void S::anotherInlineMethod() {}
+  inline void S::outOfClassInlineMethod() {}
+}
+
 // MS ignores DLL attributes on partial specializations.
 template <typename T> struct PartiallySpecializedClassTemplate {};
-template <typename T> struct __declspec(dllimport) PartiallySpecializedClassTemplate<T*> { void f() {} };
+template <typename T> struct __declspec(dllimport) PartiallySpecializedClassTemplate<T*> { void f(); };
 USEMEMFUNC(PartiallySpecializedClassTemplate<void*>, f);
-// M32-DAG: define linkonce_odr x86_thiscallcc void @"\01?f@?$PartiallySpecializedClassTemplate@PAX@@QAEXXZ"
-// G32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv
+// M32-DAG: declare x86_thiscallcc void @"\01?f@?$PartiallySpecializedClassTemplate@PAX@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv
 
+// Attributes on explicit specializations are honored.
 template <typename T> struct ExplicitlySpecializedClassTemplate {};
-template <> struct __declspec(dllimport) ExplicitlySpecializedClassTemplate<void*> { void f() {} };
+template <> struct __declspec(dllimport) ExplicitlySpecializedClassTemplate<void*> { void f(); };
 USEMEMFUNC(ExplicitlySpecializedClassTemplate<void*>, f);
-// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$ExplicitlySpecializedClassTemplate@PAX@@QAEXXZ"
-// G32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01?f@?$ExplicitlySpecializedClassTemplate@PAX@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv
+
+// MS inherits DLL attributes to partial specializations.
+template <typename T> struct __declspec(dllimport) PartiallySpecializedImportedClassTemplate {};
+template <typename T> struct PartiallySpecializedImportedClassTemplate<T*> { void f() {} };
+USEMEMFUNC(PartiallySpecializedImportedClassTemplate<void*>, f);
+// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$PartiallySpecializedImportedClassTemplate@PAX@@QAEXXZ"
+// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN41PartiallySpecializedImportedClassTemplateIPvE1fEv
+
+// Attributes on the instantiation take precedence over attributes on the template.
+template <typename T> struct __declspec(dllexport) ExplicitlyInstantiatedWithDifferentAttr { void f() {} };
+template struct __declspec(dllimport) ExplicitlyInstantiatedWithDifferentAttr<int>;
+USEMEMFUNC(ExplicitlyInstantiatedWithDifferentAttr<int>, f);
+// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$ExplicitlyInstantiatedWithDifferentAttr@H@@QAEXXZ"
+
 
 //===----------------------------------------------------------------------===//
 // Classes with template base classes
@@ -677,20 +729,20 @@
 
 template <typename T> struct ClassTemplate { void func() {} };
 template <typename T> struct __declspec(dllexport) ExportedClassTemplate { void func() {} };
-template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func() {} };
+template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func(); };
 
 template <typename T> struct ExplicitlySpecializedTemplate { void func() {} };
 template <> struct ExplicitlySpecializedTemplate<int> { void func() {} };
 template <typename T> struct ExplicitlyExportSpecializedTemplate { void func() {} };
 template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate<int> { void func() {} };
 template <typename T> struct ExplicitlyImportSpecializedTemplate { void func() {} };
-template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func() {} };
+template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func(); };
 
 template <typename T> struct ExplicitlyInstantiatedTemplate { void func() {} };
 template struct ExplicitlyInstantiatedTemplate<int>;
 template <typename T> struct ExplicitlyExportInstantiatedTemplate { void func() {} };
 template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate<int>;
-template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func() {} };
+template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func(); };
 template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate<int>;
 
 
@@ -703,7 +755,7 @@
 // ImportedTemplate is explicitly imported.
 struct __declspec(dllimport) DerivedFromImportedTemplate : public ImportedClassTemplate<int> {};
 USEMEMFUNC(ImportedClassTemplate<int>, func)
-// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ImportedClassTemplate@H@@QAEXXZ"
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ImportedClassTemplate@H@@QAEXXZ"
 // G32-DAG: declare dllimport x86_thiscallcc void @_ZN21ImportedClassTemplateIiE4funcEv
 
 // ExportedTemplate is explicitly exported.
@@ -741,8 +793,8 @@
 // Base class already specialized with import attribute.
 struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {};
 USEMEMFUNC(ExplicitlyImportSpecializedTemplate<int>, func)
-// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ"
-// G32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
 
 // Base class already instantiated without dll attribute.
 struct __declspec(dllimport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {};
@@ -759,13 +811,13 @@
 // Base class already instantiated with import attribute.
 struct __declspec(dllimport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate<int> {};
 USEMEMFUNC(ExplicitlyImportInstantiatedTemplate<int>, func)
-// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ"
-// G32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
+// M32-DAG: declare dllimport x86_thiscallcc void @"\01?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ"
+// G32-DAG: declare dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
 
 // MS: A dll attribute propagates through multiple levels of instantiation.
 template <typename T> struct TopClass { void func() {} };
 template <typename T> struct MiddleClass : public TopClass<T> { };
-struct __declspec(dllimport) BottomClas : public MiddleClass<int> { };
+struct __declspec(dllimport) BottomClass : public MiddleClass<int> { };
 USEMEMFUNC(TopClass<int>, func)
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?func@?$TopClass@H@@QAEXXZ"
 // G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN8TopClassIiE4funcEv
diff --git a/test/CodeGenCXX/duplicate-mangled-name.cpp b/test/CodeGenCXX/duplicate-mangled-name.cpp
index 65bfa22..e57012e 100644
--- a/test/CodeGenCXX/duplicate-mangled-name.cpp
+++ b/test/CodeGenCXX/duplicate-mangled-name.cpp
@@ -4,7 +4,7 @@
 class MyClass {
  static void meth();
 };
-void MyClass::meth() { }
+void MyClass::meth() { } // expected-note {{previous}}
 extern "C" {
   void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}}
 }
diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp
index c11e90b..cb07697 100644
--- a/test/CodeGenCXX/eh.cpp
+++ b/test/CodeGenCXX/eh.cpp
@@ -34,7 +34,7 @@
 // CHECK-NEXT:  [[SELECTORVAR:%.*]] = alloca i32
 // CHECK-NEXT:  [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 16)
 // CHECK-NEXT:  [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
-// CHECK-NEXT:  invoke void @_ZN7test2_DC1ERKS_([[DSTAR]] [[EXN]], [[DSTAR]] nonnull @d2)
+// CHECK-NEXT:  invoke void @_ZN7test2_DC1ERKS_([[DSTAR]] [[EXN]], [[DSTAR]] dereferenceable({{[0-9]+}}) @d2)
 // CHECK-NEXT:     to label %[[CONT:.*]] unwind label %{{.*}}
 //      :     [[CONT]]:   (can't check this in Release-Asserts builds)
 // CHECK:       call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({{.*}}* @_ZTI7test2_D to i8*), i8* null) [[NR]]
@@ -428,7 +428,7 @@
     // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[EXN]] to [[B:%.*]]*
     // CHECK-NEXT: invoke void @_ZN6test161AC1Ev([[A]]* [[TEMP]])
     // CHECK:      store i1 true, i1* [[TEMP_ACTIVE]]
-    // CHECK-NEXT: invoke void @_ZN6test161BC1ERKNS_1AE([[B]]* [[T0]], [[A]]* nonnull [[TEMP]])
+    // CHECK-NEXT: invoke void @_ZN6test161BC1ERKNS_1AE([[B]]* [[T0]], [[A]]* dereferenceable({{[0-9]+}}) [[TEMP]])
     // CHECK:      store i1 false, i1* [[EXN_ACTIVE]]
     // CHECK-NEXT: invoke void @__cxa_throw(i8* [[EXN]],
 
diff --git a/test/CodeGenCXX/empty-nontrivially-copyable.cpp b/test/CodeGenCXX/empty-nontrivially-copyable.cpp
index a1098b0..a0977a7 100644
--- a/test/CodeGenCXX/empty-nontrivially-copyable.cpp
+++ b/test/CodeGenCXX/empty-nontrivially-copyable.cpp
@@ -19,7 +19,7 @@
 }
 
 void caller(Empty &e) {
-// CHECK: @_Z6callerR5Empty(%struct.Empty* nonnull %e)
+// CHECK: @_Z6callerR5Empty(%struct.Empty* dereferenceable({{[0-9]+}}) %e)
 // CHECK: call {{.*}} @_ZN5EmptyC1ERKS_(%struct.Empty* [[NEWTMP:%.*]], %struct.Empty*
 // CHECK: call {{.*}} @_Z3foo5Empty(%struct.Empty* [[NEWTMP]])
   foo(e);
diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp
index ae0c826..5016e9a 100644
--- a/test/CodeGenCXX/exceptions.cpp
+++ b/test/CodeGenCXX/exceptions.cpp
@@ -279,7 +279,7 @@
   // CHECK-NEXT: [[ADJ:%.*]] = call i8* @__cxa_get_exception_ptr(i8* [[EXN]])
   // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[ADJ]] to [[A_T]]*
   // CHECK-NEXT: invoke void @_ZN5test51TC1Ev([[T_T]]* [[T]])
-  // CHECK:      invoke void @_ZN5test51AC1ERKS0_RKNS_1TE([[A_T]]* [[A]], [[A_T]]* nonnull [[SRC]], [[T_T]]* nonnull [[T]])
+  // CHECK:      invoke void @_ZN5test51AC1ERKS0_RKNS_1TE([[A_T]]* [[A]], [[A_T]]* dereferenceable({{[0-9]+}}) [[SRC]], [[T_T]]* dereferenceable({{[0-9]+}}) [[T]])
   // CHECK:      invoke void @_ZN5test51TD1Ev([[T_T]]* [[T]])
   // CHECK:      call i8* @__cxa_begin_catch(i8* [[EXN]]) [[NUW]]
   // CHECK-NEXT: invoke void @_ZN5test51AD1Ev([[A_T]]* [[A]])
diff --git a/test/CodeGenCXX/extern-c.cpp b/test/CodeGenCXX/extern-c.cpp
index fefb216..7852644 100644
--- a/test/CodeGenCXX/extern-c.cpp
+++ b/test/CodeGenCXX/extern-c.cpp
@@ -59,10 +59,10 @@
 
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
-  // CHECK: @internal_var = alias internal i32* @_Z12internal_var
+  // CHECK: @internal_var = internal alias i32* @_Z12internal_var
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
-  // CHECK: @internal_fn = alias internal i32 ()* @_Z11internal_fnv
+  // CHECK: @internal_fn = internal alias i32 ()* @_Z11internal_fnv
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
 }
diff --git a/test/CodeGenCXX/fastcall.cpp b/test/CodeGenCXX/fastcall.cpp
index a48dfe1..0820324 100644
--- a/test/CodeGenCXX/fastcall.cpp
+++ b/test/CodeGenCXX/fastcall.cpp
@@ -3,7 +3,7 @@
 void __attribute__((fastcall)) foo1(int &y);
 void bar1(int &y) {
   // CHECK-LABEL: define void @_Z4bar1Ri
-  // CHECK: call x86_fastcallcc void @_Z4foo1Ri(i32* inreg nonnull %
+  // CHECK: call x86_fastcallcc void @_Z4foo1Ri(i32* inreg dereferenceable({{[0-9]+}}) %
   foo1(y);
 }
 
diff --git a/test/CodeGenCXX/field-access-debug-info.cpp b/test/CodeGenCXX/field-access-debug-info.cpp
index aed4ee5..2b5b53d 100644
--- a/test/CodeGenCXX/field-access-debug-info.cpp
+++ b/test/CodeGenCXX/field-access-debug-info.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang -g -S -emit-llvm %s -o - | FileCheck %s
 
-// CHECK: [ DW_TAG_member ] [p] [{{[^]]*}}] [from int]
-// CHECK: [ DW_TAG_member ] [pr] [{{[^]]*}}] [private] [from int]
+// CHECK: [ DW_TAG_member ] [p] [{{[^]]*}}] [public] [from int]
+// CHECK: [ DW_TAG_member ] [pr] [{{[^]]*}}] [from int]
 
 class A {
 public:
diff --git a/test/CodeGenCXX/funcsig.cpp b/test/CodeGenCXX/funcsig.cpp
index 684a796..2a6e641 100644
--- a/test/CodeGenCXX/funcsig.cpp
+++ b/test/CodeGenCXX/funcsig.cpp
@@ -8,7 +8,7 @@
 void freeFunc(int *, char) {
   printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
 }
-// CHECK: private unnamed_addr constant [{{.*}} x i8] c"void __cdecl freeFunc(int *, char)\00"
+// CHECK: @"\01??_C@_0CD@KLGMNNL@void?5__cdecl?5freeFunc?$CIint?5?$CK?0?5cha@" = linkonce_odr unnamed_addr constant [{{.*}} x i8] c"void __cdecl freeFunc(int *, char)\00"
 
 struct TopLevelClass {
   void topLevelMethod(int *, char);
@@ -16,7 +16,7 @@
 void TopLevelClass::topLevelMethod(int *, char) {
   printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
 }
-// CHECK: private unnamed_addr constant [{{.*}} x i8] c"void __thiscall TopLevelClass::topLevelMethod(int *, char)\00"
+// CHECK: @"\01??_C@_0DL@OBHNMDP@void?5__thiscall?5TopLevelClass?3?3t@" = linkonce_odr unnamed_addr constant [{{.*}} x i8] c"void __thiscall TopLevelClass::topLevelMethod(int *, char)\00"
 
 namespace NS {
 struct NamespacedClass {
@@ -25,5 +25,5 @@
 void NamespacedClass::namespacedMethod(int *, char) {
   printf("__FUNCSIG__ %s\n\n", __FUNCSIG__);
 }
-// CHECK: private unnamed_addr constant [{{.*}} x i8] c"void __thiscall NS::NamespacedClass::namespacedMethod(int *, char)\00"
+// CHECK: @"\01??_C@_0ED@PFDKIEBA@void?5__thiscall?5NS?3?3NamespacedCl@" = linkonce_odr unnamed_addr constant [{{.*}} x i8] c"void __thiscall NS::NamespacedClass::namespacedMethod(int *, char)\00"
 }
diff --git a/test/CodeGenCXX/globalinit-loc.cpp b/test/CodeGenCXX/globalinit-loc.cpp
index eb39aec..113a26c 100644
--- a/test/CodeGenCXX/globalinit-loc.cpp
+++ b/test/CodeGenCXX/globalinit-loc.cpp
@@ -6,7 +6,7 @@
 //
 // CHECK: define internal void @_GLOBAL__sub_I_globalinit_loc.cpp
 // CHECK: !dbg ![[DBG:.*]]
-// CHECK: "_GLOBAL__sub_I_globalinit_loc.cpp", i32 0, {{.*}}, i32 0} ; [ DW_TAG_subprogram ] [line 0] [local] [def]
+// CHECK: metadata !{metadata !"0x2e\00\00\00_GLOBAL__sub_I_globalinit_loc.cpp\000\00{{.*}}\000", {{.*}} ; [ DW_TAG_subprogram ] [line 0] [local] [def]
 // CHECK: ![[DBG]] = metadata !{i32 0, i32 0,
 # 99 "someheader.h"
 class A {
diff --git a/test/CodeGenCXX/goto.cpp b/test/CodeGenCXX/goto.cpp
index 36bb2a5..c1a0eec 100644
--- a/test/CodeGenCXX/goto.cpp
+++ b/test/CodeGenCXX/goto.cpp
@@ -22,7 +22,7 @@
     // CHECK:      store i1 true, i1* [[CLEANUPACTIVE]]
     // CHECK:      [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
     // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
-    // CHECK:      invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* nonnull [[TMP]])
+    // CHECK:      invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* dereferenceable({{[0-9]+}}) [[TMP]])
     // CHECK:      store i1 false, i1* [[CLEANUPACTIVE]]
     // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[TMP]])
     A y;
diff --git a/test/CodeGenCXX/homogeneous-aggregates.cpp b/test/CodeGenCXX/homogeneous-aggregates.cpp
new file mode 100644
index 0000000..4800aac
--- /dev/null
+++ b/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC
+// RUN: %clang_cc1 -mfloat-abi hard -triple armv7-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM32
+// RUN: %clang_cc1 -mfloat-abi hard -triple aarch64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64
+// RUN: %clang_cc1 -mfloat-abi hard -triple x86_64-unknown-windows-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=X64
+
+#if defined(__x86_64__)
+#define CC __attribute__((vectorcall))
+#else
+#define CC
+#endif
+
+// Test that C++ classes are correctly classified as homogeneous aggregates.
+
+struct Base1 {
+  int x;
+};
+struct Base2 {
+  double x;
+};
+struct Base3 {
+  double x;
+};
+struct D1 : Base1 {  // non-homogeneous aggregate
+  double y, z;
+};
+struct D2 : Base2 {  // homogeneous aggregate
+  double y, z;
+};
+struct D3 : Base1, Base2 {  // non-homogeneous aggregate
+  double y, z;
+};
+struct D4 : Base2, Base3 {  // homogeneous aggregate
+  double y, z;
+};
+
+struct I1 : Base2 {};
+struct I2 : Base2 {};
+struct I3 : Base2 {};
+struct D5 : I1, I2, I3 {}; // homogeneous aggregate
+
+// PPC: define void @_Z7func_D12D1(%struct.D1* noalias sret %agg.result, [3 x i64] %x.coerce)
+// ARM32: define arm_aapcs_vfpcc void @_Z7func_D12D1(%struct.D1* noalias sret %agg.result, [3 x i64] %x.coerce)
+// ARM64: define void @_Z7func_D12D1(%struct.D1* noalias sret %agg.result, %struct.D1* %x)
+// X64: define x86_vectorcallcc void @"\01_Z7func_D12D1@@24"(%struct.D1* noalias sret %agg.result, %struct.D1* %x)
+D1 CC func_D1(D1 x) { return x; }
+
+// PPC: define [3 x double] @_Z7func_D22D2([3 x double] %x.coerce)
+// ARM32: define arm_aapcs_vfpcc %struct.D2 @_Z7func_D22D2(%struct.D2 %x.coerce)
+// ARM64: define %struct.D2 @_Z7func_D22D2(double %x.0, double %x.1, double %x.2)
+// X64: define x86_vectorcallcc %struct.D2 @"\01_Z7func_D22D2@@24"(double %x.0, double %x.1, double %x.2)
+D2 CC func_D2(D2 x) { return x; }
+
+// PPC: define void @_Z7func_D32D3(%struct.D3* noalias sret %agg.result, [4 x i64] %x.coerce)
+// ARM32: define arm_aapcs_vfpcc void @_Z7func_D32D3(%struct.D3* noalias sret %agg.result, [4 x i64] %x.coerce)
+// ARM64: define void @_Z7func_D32D3(%struct.D3* noalias sret %agg.result, %struct.D3* %x)
+D3 CC func_D3(D3 x) { return x; }
+
+// PPC: define [4 x double] @_Z7func_D42D4([4 x double] %x.coerce)
+// ARM32: define arm_aapcs_vfpcc %struct.D4 @_Z7func_D42D4(%struct.D4 %x.coerce)
+// ARM64: define %struct.D4 @_Z7func_D42D4(double %x.0, double %x.1, double %x.2, double %x.3)
+D4 CC func_D4(D4 x) { return x; }
+
+D5 CC func_D5(D5 x) { return x; }
+// PPC: define [3 x double] @_Z7func_D52D5([3 x double] %x.coerce)
+// ARM32: define arm_aapcs_vfpcc %struct.D5 @_Z7func_D52D5(%struct.D5 %x.coerce)
+
+// The C++ multiple inheritance expansion case is a little more complicated, so
+// do some extra checking.
+//
+// ARM64-LABEL: define %struct.D5 @_Z7func_D52D5(double %x.0, double %x.1, double %x.2)
+// ARM64: bitcast %struct.D5* %{{.*}} to %struct.I1*
+// ARM64: bitcast %struct.I1* %{{.*}} to %struct.Base2*
+// ARM64: getelementptr inbounds %struct.Base2* %{{.*}}, i32 0, i32 0
+// ARM64: store double %x.0, double*
+// ARM64: getelementptr inbounds i8* %{{.*}}, i64 8
+// ARM64: getelementptr inbounds %struct.Base2* %{{.*}}, i32 0, i32 0
+// ARM64: store double %x.1, double*
+// ARM64: getelementptr inbounds i8* %{{.*}}, i64 16
+// ARM64: getelementptr inbounds %struct.Base2* %{{.*}}, i32 0, i32 0
+// ARM64: store double %x.2, double*
+
+void call_D5(D5 *p) {
+  func_D5(*p);
+}
+
+// Check the call site.
+//
+// ARM64-LABEL: define void @_Z7call_D5P2D5(%struct.D5* %p)
+// ARM64: bitcast %struct.D5* %{{.*}} to %struct.I1*
+// ARM64: bitcast %struct.I1* %{{.*}} to %struct.Base2*
+// ARM64: getelementptr inbounds %struct.Base2* %{{.*}}, i32 0, i32 0
+// ARM64: load double*
+// ARM64: getelementptr inbounds i8* %{{.*}}, i64 8
+// ARM64: bitcast i8* %{{.*}} to %struct.I2*
+// ARM64: bitcast %struct.I2* %{{.*}} to %struct.Base2*
+// ARM64: getelementptr inbounds %struct.Base2* %{{.*}}, i32 0, i32 0
+// ARM64: load double*
+// ARM64: getelementptr inbounds i8* %{{.*}}, i64 16
+// ARM64: bitcast i8* %{{.*}} to %struct.I3*
+// ARM64: bitcast %struct.I3* %{{.*}} to %struct.Base2*
+// ARM64: getelementptr inbounds %struct.Base2* %{{.*}}, i32 0, i32 0
+// ARM64: load double*
+// ARM64: call %struct.D5 @_Z7func_D52D5(double %{{.*}}, double %{{.*}}, double %{{.*}})
+
+struct Empty { };
+struct Float1 { float x; };
+struct Float2 { float y; };
+struct HVAWithEmptyBase : Float1, Empty, Float2 { float z; };
+
+// PPC: define void @_Z15with_empty_base16HVAWithEmptyBase([3 x float] %a.coerce)
+// ARM64: define void @_Z15with_empty_base16HVAWithEmptyBase(float %a.0, float %a.1, float %a.2)
+// ARM32: define arm_aapcs_vfpcc void @_Z15with_empty_base16HVAWithEmptyBase(%struct.HVAWithEmptyBase %a.coerce)
+void CC with_empty_base(HVAWithEmptyBase a) {}
+
+// FIXME: MSVC doesn't consider this an HVA becuase of the empty base.
+// X64: define x86_vectorcallcc void @"\01_Z15with_empty_base16HVAWithEmptyBase@@16"(float %a.0, float %a.1, float %a.2)
+
+struct HVAWithEmptyBitField : Float1, Float2 {
+  int : 0; // Takes no space.
+  float z;
+};
+
+// PPC: define void @_Z19with_empty_bitfield20HVAWithEmptyBitField([3 x float] %a.coerce)
+// ARM64: define void @_Z19with_empty_bitfield20HVAWithEmptyBitField(float %a.0, float %a.1, float %a.2)
+// ARM32: define arm_aapcs_vfpcc void @_Z19with_empty_bitfield20HVAWithEmptyBitField(%struct.HVAWithEmptyBitField %a.coerce)
+// X64: define x86_vectorcallcc void @"\01_Z19with_empty_bitfield20HVAWithEmptyBitField@@16"(float %a.0, float %a.1, float %a.2)
+void CC with_empty_bitfield(HVAWithEmptyBitField a) {}
diff --git a/test/CodeGenCXX/implicit-copy-assign-operator.cpp b/test/CodeGenCXX/implicit-copy-assign-operator.cpp
index f01d362..fded035 100644
--- a/test/CodeGenCXX/implicit-copy-assign-operator.cpp
+++ b/test/CodeGenCXX/implicit-copy-assign-operator.cpp
@@ -40,7 +40,7 @@
   d1 = d2;
 }
 
-// CHECK-LABEL: define linkonce_odr nonnull %struct.D* @_ZN1DaSERS_
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.D* @_ZN1DaSERS_
 // CHECK: {{call.*_ZN1AaSERS_}}
 // CHECK: {{call.*_ZN1BaSERS_}}
 // CHECK: {{call.*_ZN1CaSERKS_}}
diff --git a/test/CodeGenCXX/implicit-copy-constructor.cpp b/test/CodeGenCXX/implicit-copy-constructor.cpp
index fa6be99..d022413 100644
--- a/test/CodeGenCXX/implicit-copy-constructor.cpp
+++ b/test/CodeGenCXX/implicit-copy-constructor.cpp
@@ -40,7 +40,7 @@
   D d2(d);
 }
 
-// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D* nonnull) unnamed_addr
+// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D* dereferenceable({{[0-9]+}})) unnamed_addr
 // CHECK: call void @_ZN1AC1Ev
 // CHECK: call void @_ZN1CC2ERS_1A
 // CHECK: call void @_ZN1AD1Ev
diff --git a/test/CodeGenCXX/linetable-cleanup.cpp b/test/CodeGenCXX/linetable-cleanup.cpp
index ce7f2c6..45c207c 100644
--- a/test/CodeGenCXX/linetable-cleanup.cpp
+++ b/test/CodeGenCXX/linetable-cleanup.cpp
@@ -46,14 +46,14 @@
 void baz()
 {
   if (!foo())
-    // CHECK: ![[SCOPE1:.*]] = metadata !{{{.*}}, i32 [[@LINE-1]], {{.*}}} ; [ DW_TAG_lexical_block ]
+    // CHECK: ![[SCOPE1:.*]] = metadata !{metadata !"0xb\00[[@LINE-1]]\00{{.*}}", {{.*}} ; [ DW_TAG_lexical_block ]
     // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[SCOPE1]], null}
     return;
 
   if (foo()) {
     // no cleanup
     // CHECK: {{.*}} = metadata !{i32 [[@LINE+2]], i32 0, metadata ![[SCOPE2:.*]], null}
-    // CHECK: ![[SCOPE2]] = metadata !{{{.*}}, i32 [[@LINE-3]], {{.*}}} ; [ DW_TAG_lexical_block ]
+    // CHECK: ![[SCOPE2]] = metadata !{metadata !"0xb\00[[@LINE-3]]\00{{.*}}", {{.*}} ; [ DW_TAG_lexical_block ]
     return;
   }
   // CHECK: ![[RETBAZ]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
diff --git a/test/CodeGenCXX/linetable-eh.cpp b/test/CodeGenCXX/linetable-eh.cpp
index 14a5067..4ef037a 100644
--- a/test/CodeGenCXX/linetable-eh.cpp
+++ b/test/CodeGenCXX/linetable-eh.cpp
@@ -4,10 +4,10 @@
 // entries for the code that triggered it.
 
 // CHECK: call void @llvm.dbg.declare
-// CHECK: call void @llvm.dbg.declare(metadata !{{{.*}}}, metadata ![[CURRENT_ADDR:.*]]), !dbg ![[DBG1:.*]]
+// CHECK: call void @llvm.dbg.declare(metadata !{{{.*}}}, metadata ![[CURRENT_ADDR:.*]], metadata !{{.*}}), !dbg ![[DBG1:.*]]
 // CHECK: unwind label %{{.*}}, !dbg ![[DBG1]]
 // CHECK: store i64 %{{.*}}, i64* %current_address, align 8, !dbg ![[DBG4:.*]]
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{{{.*}}}, metadata ![[FOUND_IT:.*]]), !dbg ![[DBG2:.*]]
+// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{{{.*}}}, metadata ![[FOUND_IT:.*]], metadata !{{.*}}), !dbg ![[DBG2:.*]]
 // CHECK: = landingpad
 // CHECK-NEXT: cleanup, !dbg ![[DBG3:.*]]
 // CHECK-DAG: ![[CURRENT_ADDR]] = {{.*}} [current_address]
diff --git a/test/CodeGenCXX/linetable-fnbegin.cpp b/test/CodeGenCXX/linetable-fnbegin.cpp
index ce46306..9ae43d4 100644
--- a/test/CodeGenCXX/linetable-fnbegin.cpp
+++ b/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -5,7 +5,7 @@
 // CHECK-NOT: define
 // CHECK: ret {{.*}}, !dbg [[DBG:.*]]
 // CHECK: [[HPP:.*]] = metadata !{metadata !"./template.hpp",
-// CHECK: [[SP:.*]] = metadata !{i32 786478, metadata [[HPP]],{{.*}}[ DW_TAG_subprogram ] [line 22] [def] [bar]
+// CHECK: [[SP:.*]] = metadata !{metadata !"0x2e\00{{.*}}", metadata [[HPP]],{{.*}}[ DW_TAG_subprogram ] [line 22] [def] [bar]
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = metadata !{i32 23, i32 0, metadata [[SP]], null}
 
diff --git a/test/CodeGenCXX/mangle-exprs.cpp b/test/CodeGenCXX/mangle-exprs.cpp
index e935f51..ee7f244 100644
--- a/test/CodeGenCXX/mangle-exprs.cpp
+++ b/test/CodeGenCXX/mangle-exprs.cpp
@@ -56,6 +56,18 @@
   void static_(typename enable_if< O <= static_cast<unsigned>(4) >::type* = 0) {
   }
 
+  template <unsigned O, typename T>
+  void reinterpret_(typename enable_if<O <= sizeof(reinterpret_cast<T *>(0))>::type * = 0) {
+  }
+
+  template <typename T, T *p>
+  void const_(typename enable_if<0 <= sizeof(const_cast<T *>(p))>::type * = 0) {
+  }
+
+  template <typename T, T *p>
+  void dynamic_(typename enable_if<0 <= sizeof(dynamic_cast<T *>(p))>::type * = 0) {
+  }
+
   template< typename T >
   void auto_(decltype(new auto(T()))) {
   }
@@ -64,11 +76,12 @@
   void scalar_(decltype(T(), int())) {
   }
 
-  // FIXME: Test const_cast, reinterpret_cast, dynamic_cast, which are
-  // a bit harder to use in template arguments.
   template <unsigned N> struct T {};
 
   template <int N> T<N> f() { return T<N>(); }
+
+  extern int i;
+  extern struct S {} s;
   
   // CHECK-LABEL: define weak_odr void @_ZN5Casts8implicitILj4EEEvPN9enable_ifIXleT_Li4EEvE4typeE
   template void implicit<4>(void*);
@@ -76,8 +89,14 @@
   template void cstyle<4>(void*);
   // CHECK-LABEL: define weak_odr void @_ZN5Casts10functionalILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
   template void functional<4>(void*);
-  // CHECK-LABEL: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+  // CHECK-LABEL: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_scjLi4EEvE4typeE
   template void static_<4>(void*);
+  // CHECK-LABEL: define weak_odr void @_ZN5Casts12reinterpret_ILj4EiEEvPN9enable_ifIXleT_szrcPT0_Li0EEvE4typeE
+  template void reinterpret_<4, int>(void*);
+  // CHECK-LABEL: define weak_odr void @_ZN5Casts6const_IiXadL_ZNS_1iEEEEEvPN9enable_ifIXleLi0EszccPT_T0_EvE4typeE
+  template void const_<int, &i>(void*);
+  // CHECK-LABEL: define weak_odr void @_ZN5Casts8dynamic_INS_1SEXadL_ZNS_1sEEEEEvPN9enable_ifIXleLi0EszdcPT_T0_EvE4typeE
+  template void dynamic_<struct S, &s>(void*);
 
   // CHECK-LABEL: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv
   template T<6> f<6>();
@@ -198,3 +217,79 @@
   template void a<int>(decltype(noexcept(int())));
   // CHECK: void @_ZN5test51aIiEEvDTnxcvT__EE(
 }
+
+namespace test6 {
+  struct X {
+    int i;
+  };
+
+  struct Y {
+    union {
+      int i;
+    };
+  };
+
+  struct Z {
+    union {
+      X ua;
+      Y ub;
+    };
+
+    struct {
+      X s;
+    };
+
+    union {
+      union {
+        struct {
+          struct {
+            X uuss;
+          };
+        };
+      };
+    };
+  };
+
+  Z z, *zp;
+
+  template<typename T>
+  void f1(decltype(T(z.ua.i))) {}
+  template void f1<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f1IiEEvDTcvT_dtdtL_ZNS_1zEE2ua1iE
+
+  template<typename T>
+  void f2(decltype(T(z.ub.i))) {}
+  template void f2<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f2IiEEvDTcvT_dtdtL_ZNS_1zEE2ub1iE
+
+  template<typename T>
+  void f3(decltype(T(z.s.i))) {}
+  template void f3<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f3IiEEvDTcvT_dtdtL_ZNS_1zEE1s1iE
+
+  template<typename T>
+  void f4(decltype(T(z.uuss.i))) {}
+  template void f4<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f4IiEEvDTcvT_dtdtL_ZNS_1zEE4uuss1iE
+
+  template<typename T>
+  void f5(decltype(T(zp->ua.i))) {}
+  template void f5<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f5IiEEvDTcvT_dtptL_ZNS_2zpEE2ua1iE
+
+  template<typename T>
+  void f6(decltype(T(zp->ub.i))) {}
+  template void f6<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f6IiEEvDTcvT_dtptL_ZNS_2zpEE2ub1iE
+
+  template<typename T>
+  void f7(decltype(T(zp->s.i))) {}
+  template void f7<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f7IiEEvDTcvT_dtptL_ZNS_2zpEE1s1iE
+
+  template<typename T>
+  void f8(decltype(T(zp->uuss.i))) {}
+  template void f8<int>(int);
+  // CHECK-LABEL: define weak_odr void @_ZN5test62f8IiEEvDTcvT_dtptL_ZNS_2zpEE4uuss1iE
+}
+
diff --git a/test/CodeGenCXX/mangle-lambdas.cpp b/test/CodeGenCXX/mangle-lambdas.cpp
index b926fb2..e8d3f19 100644
--- a/test/CodeGenCXX/mangle-lambdas.cpp
+++ b/test/CodeGenCXX/mangle-lambdas.cpp
@@ -192,7 +192,7 @@
   };
   void B::h() { f(); }
 }
-// CHECK-LABEL: define linkonce_odr nonnull %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv
 
 namespace PR12808 {
   template <typename> struct B {
diff --git a/test/CodeGenCXX/mangle-literal-suffix.cpp b/test/CodeGenCXX/mangle-literal-suffix.cpp
new file mode 100644
index 0000000..ab557d5
--- /dev/null
+++ b/test/CodeGenCXX/mangle-literal-suffix.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mips-none-none -emit-llvm -o - %s | FileCheck %s
+
+template <class T> void g3(char (&buffer)[sizeof(T() + 5.0)]) {}
+template void g3<int>(char (&)[sizeof(double)]);
+// CHECK: _Z2g3IiEvRAszplcvT__ELd4014000000000000E_c
+
+template <class T> void g4(char (&buffer)[sizeof(T() + 5.0L)]) {}
+template void g4<int>(char (&)[sizeof(long double)]);
+// CHECK: _Z2g4IiEvRAszplcvT__ELe4014000000000000E_c
+
+template <class T> void g5(char (&buffer)[sizeof(T() + 5)]) {}
+template void g5<int>(char (&)[sizeof(int)]);
+// CHECK: _Z2g5IiEvRAszplcvT__ELi5E_c
+
+template <class T> void g6(char (&buffer)[sizeof(T() + 5L)]) {}
+template void g6<int>(char (&)[sizeof(long int)]);
+// CHECK: _Z2g6IiEvRAszplcvT__ELl5E_c
diff --git a/test/CodeGenCXX/mangle-ms-cxx11.cpp b/test/CodeGenCXX/mangle-ms-cxx11.cpp
index 373d2b7..ded08b9 100644
--- a/test/CodeGenCXX/mangle-ms-cxx11.cpp
+++ b/test/CodeGenCXX/mangle-ms-cxx11.cpp
@@ -1,5 +1,58 @@
 // RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
 
+namespace FTypeWithQuals {
+template <typename T>
+struct S {};
+
+using A = int () const;
+S<A> a;
+// CHECK-DAG: @"\01?a@FTypeWithQuals@@3U?$S@$$A8@@BAHXZ@1@A"
+
+using B = int () volatile;
+S<B> b;
+// CHECK-DAG: @"\01?b@FTypeWithQuals@@3U?$S@$$A8@@CAHXZ@1@A"
+
+using C = int () __restrict;
+S<C> c;
+// CHECK-DAG: @"\01?c@FTypeWithQuals@@3U?$S@$$A8@@IAAHXZ@1@A"
+
+using D = int () const &;
+S<D> d;
+// CHECK-DAG: @"\01?d@FTypeWithQuals@@3U?$S@$$A8@@GBAHXZ@1@A"
+
+using E = int () volatile &;
+S<E> e;
+// CHECK-DAG: @"\01?e@FTypeWithQuals@@3U?$S@$$A8@@GCAHXZ@1@A"
+
+using F = int () __restrict &;
+S<F> f;
+// CHECK-DAG: @"\01?f@FTypeWithQuals@@3U?$S@$$A8@@IGAAHXZ@1@A"
+
+using G = int () const &&;
+S<G> g;
+// CHECK-DAG: @"\01?g@FTypeWithQuals@@3U?$S@$$A8@@HBAHXZ@1@A"
+
+using H = int () volatile &&;
+S<H> h;
+// CHECK-DAG: @"\01?h@FTypeWithQuals@@3U?$S@$$A8@@HCAHXZ@1@A"
+
+using I = int () __restrict &&;
+S<I> i;
+// CHECK-DAG: @"\01?i@FTypeWithQuals@@3U?$S@$$A8@@IHAAHXZ@1@A"
+
+using J = int ();
+S<J> j;
+// CHECK-DAG: @"\01?j@FTypeWithQuals@@3U?$S@$$A6AHXZ@1@A"
+
+using K = int () &;
+S<K> k;
+// CHECK-DAG: @"\01?k@FTypeWithQuals@@3U?$S@$$A8@@GAAHXZ@1@A"
+
+using L = int () &&;
+S<L> l;
+// CHECK-DAG: @"\01?l@FTypeWithQuals@@3U?$S@$$A8@@HAAHXZ@1@A"
+}
+
 // CHECK: "\01?DeducedType@@3HA"
 auto DeducedType = 30;
 
@@ -98,7 +151,7 @@
 
 struct { } a;
 decltype(a) fun(decltype(a) x, decltype(a)) { return x; }
-// CHECK-DAG: ?fun@PR18022@@YA?AU<unnamed-type-a>@1@U21@0@Z
+// CHECK-DAG: @"\01?fun@PR18022@@YA?AU<unnamed-type-a>@1@U21@0@Z"
 
 }
 
@@ -106,17 +159,32 @@
   static auto lambda = [] { static int local; ++local; return local; };
 // First, we have the static local variable of type "<lambda_1>" inside of
 // "define_lambda".
-// CHECK-DAG: ?lambda@?1??define_lambda@@YAHXZ@4V<lambda_1>@@A
+// CHECK-DAG: @"\01?lambda@?1??define_lambda@@YAHXZ@4V<lambda_1>@?1@YAHXZ@A"
 // Next, we have the "operator()" for "<lambda_1>" which is inside of
 // "define_lambda".
-// CHECK-DAG: ??R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ
+// CHECK-DAG: @"\01??R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ"
 // Finally, we have the local which is inside of "<lambda_1>" which is inside of
 // "define_lambda". Hooray.
-// CHECK-DAG: ?local@?2???R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ@4HA
+// CHECK-DAG: @"\01?local@?2???R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ@4HA"
   return lambda();
 }
 
+template <typename T>
+void use_lambda_arg(T) {}
+
+inline void call_with_lambda_arg1() {
+  use_lambda_arg([]{});
+  // CHECK-DAG: @"\01??$use_lambda_arg@V<lambda_1>@?call_with_lambda_arg1@@YAXXZ@@@YAXV<lambda_1>@?call_with_lambda_arg1@@YAXXZ@@Z"
+}
+
+inline void call_with_lambda_arg2() {
+  use_lambda_arg([]{});
+  // CHECK-DAG: @"\01??$use_lambda_arg@V<lambda_1>@?call_with_lambda_arg2@@YAXXZ@@@YAXV<lambda_1>@?call_with_lambda_arg2@@YAXXZ@@Z"
+}
+
 int call_lambda() {
+  call_with_lambda_arg1();
+  call_with_lambda_arg2();
   return define_lambda();
 }
 
@@ -139,3 +207,29 @@
 
 template void templ_fun_with_pack<>();
 // CHECK-DAG: @"\01??$templ_fun_with_pack@$S@@YAXXZ"
+
+template <typename...>
+void templ_fun_with_ty_pack() {}
+
+template void templ_fun_with_ty_pack<>();
+// CHECK-DAG: @"\01??$templ_fun_with_ty_pack@$$V@@YAXXZ"
+
+template <template <class> class...>
+void templ_fun_with_templ_templ_pack() {}
+
+template void templ_fun_with_templ_templ_pack<>();
+// CHECK-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$V@@YAXXZ"
+
+namespace PR20047 {
+template <typename T>
+struct A {};
+
+template <typename T>
+using AliasA = A<T>;
+
+template <template <typename> class>
+void f() {}
+
+template void f<AliasA>();
+// CHECK-DAG: @"\01??$f@$$YAliasA@PR20047@@@PR20047@@YAXXZ"
+}
diff --git a/test/CodeGenCXX/mangle-ms-cxx14.cpp b/test/CodeGenCXX/mangle-ms-cxx14.cpp
index 0399561..c06efe2 100644
--- a/test/CodeGenCXX/mangle-ms-cxx14.cpp
+++ b/test/CodeGenCXX/mangle-ms-cxx14.cpp
@@ -13,7 +13,7 @@
   return LocalType{};
 }
 
-// CHECK: "\01?ValueFromFunctionWithLocalType@@3ULocalType@?0??FunctionWithLocalType@@YA?A?<auto>@@XZ@A"
+// CHECK: "\01?ValueFromFunctionWithLocalType@@3ULocalType@?1??FunctionWithLocalType@@YA?A?<auto>@@XZ@A"
 auto ValueFromFunctionWithLocalType = FunctionWithLocalType();
 
 // CHECK: "\01??R<lambda_0>@@QBE?A?<auto>@@XZ"
@@ -22,7 +22,7 @@
   return LocalType{};
 };
 
-// CHECK: "\01?ValueFromLambdaWithLocalType@@3ULocalType@?0???R<lambda_0>@@QBE?A?<auto>@@XZ@A"
+// CHECK: "\01?ValueFromLambdaWithLocalType@@3ULocalType@?1???R<lambda_0>@@QBE?A?<auto>@@XZ@A"
 auto ValueFromLambdaWithLocalType = LambdaWithLocalType();
 
 template <typename T>
diff --git a/test/CodeGenCXX/mangle-ms.cpp b/test/CodeGenCXX/mangle-ms.cpp
index 3285c98..662278b 100644
--- a/test/CodeGenCXX/mangle-ms.cpp
+++ b/test/CodeGenCXX/mangle-ms.cpp
@@ -117,6 +117,19 @@
 int (foo2::*l)(int);
 // CHECK-DAG: @"\01?l@@3P8foo@@AEHH@ZQ1@"
 
+// Ensure typedef CV qualifiers are mangled correctly
+typedef const int cInt;
+typedef volatile int vInt;
+typedef const volatile int cvInt;
+
+extern cInt g_cInt = 1;
+vInt g_vInt = 2;
+cvInt g_cvInt = 3;
+
+// CHECK-DAG: @"\01?g_cInt@@3HB"
+// CHECK-DAG: @"\01?g_vInt@@3HC"
+// CHECK-DAG: @"\01?g_cvInt@@3HD"
+
 // Static functions are mangled, too.
 // Also make sure calling conventions, arglists, and throw specs work.
 static void __stdcall alpha(float a, double b) throw() {}
@@ -365,3 +378,5 @@
 // CHECK-DAG: ??3TypedefNewDelete@@SAXPAX@Z
 // CHECK-DAG: ??_VTypedefNewDelete@@SAXPAX@Z
 
+void __vectorcall vector_func() { }
+// CHECK-DAG: @"\01?vector_func@@YQXXZ"
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 66cc026..9af0d9d 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -280,13 +280,13 @@
   void *v;
 };
 
-// CHECK-LABEL: define nonnull %struct.Ops* @_ZN3OpsplERKS_
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsplERKS_
 Ops& Ops::operator+(const Ops&) { return *this; }
-// CHECK-LABEL: define nonnull %struct.Ops* @_ZN3OpsmiERKS_
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsmiERKS_
 Ops& Ops::operator-(const Ops&) { return *this; }
-// CHECK-LABEL: define nonnull %struct.Ops* @_ZN3OpsanERKS_
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsanERKS_
 Ops& Ops::operator&(const Ops&) { return *this; }
-// CHECK-LABEL: define nonnull %struct.Ops* @_ZN3OpsmlERKS_
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.Ops* @_ZN3OpsmlERKS_
 Ops& Ops::operator*(const Ops&) { return *this; }
 
 // PR5861
@@ -991,3 +991,25 @@
   template void f<S>(S::u *);
   // CHECK-LABEL: define weak_odr void @_ZN6test481fINS_1SEEEvPTuNT_1uE(%"union.test48::S::u"*)
 }
+
+namespace test49 {
+  template <int>
+  struct S {};
+
+  template <template <int> class T>
+  T<3> fin(T<3>);
+
+  auto v = fin<S>;
+  // CHECK-LABEL: declare void @_ZN6test493finINS_1SEEET_ILi3EES3_()
+}
+
+namespace test50 {
+  template <int>
+  struct S {};
+
+  template <template <int> class T>
+  T<3> fin(T<4>);
+
+  auto v = fin<S>;
+  // CHECK-LABEL: declare void @_ZN6test503finINS_1SEEET_ILi3EES2_ILi4EE()
+}
diff --git a/test/CodeGenCXX/merge-functions.cpp b/test/CodeGenCXX/merge-functions.cpp
new file mode 100644
index 0000000..2137f19
--- /dev/null
+++ b/test/CodeGenCXX/merge-functions.cpp
@@ -0,0 +1,14 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O1 -fmerge-functions -emit-llvm -o - -x c++ < %s | FileCheck %s
+
+// Basic functionality test. Function merging doesn't kick in on functions that
+// are too simple.
+
+struct A {
+  virtual int f(int x, int *p) { return x ? *p : 1; }
+  virtual int g(int x, int *p) { return x ? *p : 1; }
+} a;
+
+// CHECK: define {{.*}} @_ZN1A1gEiPi
+// CHECK-NEXT: tail call i32 @_ZN1A1fEiPi
+// CHECK-NEXT: ret
diff --git a/test/CodeGenCXX/microsoft-abi-byval-sret.cpp b/test/CodeGenCXX/microsoft-abi-byval-sret.cpp
index 985b1ce..a34a245 100644
--- a/test/CodeGenCXX/microsoft-abi-byval-sret.cpp
+++ b/test/CodeGenCXX/microsoft-abi-byval-sret.cpp
@@ -5,25 +5,66 @@
   A(const A &o) : a(o.a) {}
   ~A() {}
   int a;
-  A foo(A o);
 };
 
-A A::foo(A x) {
-  A y(*this);
-  y.a += x.a;
-  return y;
+struct B {
+  A foo(A o);
+  A __cdecl bar(A o);
+  A __stdcall baz(A o);
+  A __fastcall qux(A o);
+};
+
+A B::foo(A x) {
+  return x;
 }
 
-// CHECK-LABEL: define x86_thiscallcc %struct.A* @"\01?foo@A@@QAE?AU1@U1@@Z"
-// CHECK:       (%struct.A* %this, <{ %struct.A*, %struct.A }>* inalloca)
+// CHECK-LABEL: define x86_thiscallcc %struct.A* @"\01?foo@B@@QAE?AUA@@U2@@Z"
+// CHECK:       (%struct.B* %this, <{ %struct.A*, %struct.A }>* inalloca)
 // CHECK:   getelementptr inbounds <{ %struct.A*, %struct.A }>* %{{.*}}, i32 0, i32 0
 // CHECK:   load %struct.A**
 // CHECK:   ret %struct.A*
 
-int main() {
-  A x;
-  A y = x.foo(x);
+A B::bar(A x) {
+  return x;
 }
 
-// CHECK: call x86_thiscallcc %struct.A* @"\01?foo@A@@QAE?AU1@U1@@Z"
-// CHECK:       (%struct.A* %{{[^,]*}}, <{ %struct.A*, %struct.A }>* inalloca %{{[^,]*}})
+// CHECK-LABEL: define %struct.A* @"\01?bar@B@@QAA?AUA@@U2@@Z"
+// CHECK:       (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca)
+// CHECK:   getelementptr inbounds <{ %struct.B*, %struct.A*, %struct.A }>* %{{.*}}, i32 0, i32 1
+// CHECK:   load %struct.A**
+// CHECK:   ret %struct.A*
+
+A B::baz(A x) {
+  return x;
+}
+
+// CHECK-LABEL: define x86_stdcallcc %struct.A* @"\01?baz@B@@QAG?AUA@@U2@@Z"
+// CHECK:       (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca)
+// CHECK:   getelementptr inbounds <{ %struct.B*, %struct.A*, %struct.A }>* %{{.*}}, i32 0, i32 1
+// CHECK:   load %struct.A**
+// CHECK:   ret %struct.A*
+
+A B::qux(A x) {
+  return x;
+}
+
+// CHECK-LABEL: define x86_fastcallcc void @"\01?qux@B@@QAI?AUA@@U2@@Z"
+// CHECK:       (%struct.B* inreg %this, %struct.A* inreg noalias sret %agg.result, <{ %struct.A }>* inalloca)
+// CHECK:   ret void
+
+int main() {
+  B b;
+  A a = b.foo(A());
+  a = b.bar(a);
+  a = b.baz(a);
+  a = b.qux(a);
+}
+
+// CHECK: call x86_thiscallcc %struct.A* @"\01?foo@B@@QAE?AUA@@U2@@Z"
+// CHECK:       (%struct.B* %{{[^,]*}}, <{ %struct.A*, %struct.A }>* inalloca %{{[^,]*}})
+// CHECK: call %struct.A* @"\01?bar@B@@QAA?AUA@@U2@@Z"
+// CHECK:       (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca %{{[^,]*}})
+// CHECK: call x86_stdcallcc %struct.A* @"\01?baz@B@@QAG?AUA@@U2@@Z"
+// CHECK:       (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca %{{[^,]*}})
+// CHECK: call x86_fastcallcc void @"\01?qux@B@@QAI?AUA@@U2@@Z"
+// CHECK:       (%struct.B* inreg %{{[^,]*}}, %struct.A* inreg sret %{{.*}}, <{ %struct.A }>* inalloca %{{[^,]*}})
diff --git a/test/CodeGenCXX/microsoft-abi-byval-thunks.cpp b/test/CodeGenCXX/microsoft-abi-byval-thunks.cpp
new file mode 100644
index 0000000..9bcfb9c
--- /dev/null
+++ b/test/CodeGenCXX/microsoft-abi-byval-thunks.cpp
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 %s -fno-rtti -triple=i686-pc-win32 -emit-llvm -o - | FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang_cc1 %s -fno-rtti -triple=x86_64-pc-win32 -emit-llvm -o - | FileCheck --check-prefix=CHECK64 %s
+
+namespace byval_thunk {
+struct Agg {
+  Agg();
+  Agg(const Agg &);
+  ~Agg();
+  int x;
+};
+
+struct A { virtual void foo(Agg x); };
+struct B { virtual void foo(Agg x); };
+struct C : A, B { C(); virtual void foo(Agg x); };
+C::C() {} // force emission
+
+// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01?foo@C@byval_thunk@@W3AEXUAgg@2@@Z"
+// CHECK32:             (%"struct.byval_thunk::C"* %this, <{ %"struct.byval_thunk::Agg" }>* inalloca)
+// CHECK32:   getelementptr i8* %{{.*}}, i32 -4
+// CHECK32:   musttail call x86_thiscallcc void @"\01?foo@C@byval_thunk@@UAEXUAgg@2@@Z"
+// CHECK32:       (%"struct.byval_thunk::C"* %{{.*}}, <{ %"struct.byval_thunk::Agg" }>* inalloca %0)
+// CHECK32-NEXT: ret void
+
+// CHECK64-LABEL: define linkonce_odr void @"\01?foo@C@byval_thunk@@W7EAAXUAgg@2@@Z"
+// CHECK64:             (%"struct.byval_thunk::C"* %this, %"struct.byval_thunk::Agg"* %x)
+// CHECK64:   getelementptr i8* %{{.*}}, i32 -8
+// CHECK64:   call void @"\01?foo@C@byval_thunk@@UEAAXUAgg@2@@Z"
+// CHECK64:       (%"struct.byval_thunk::C"* %{{.*}}, %"struct.byval_thunk::Agg"* %x)
+// CHECK64-NOT: call
+// CHECK64:   ret void
+}
+
+namespace stdcall_thunk {
+struct Agg {
+  Agg();
+  Agg(const Agg &);
+  ~Agg();
+  int x;
+};
+
+struct A { virtual void __stdcall foo(Agg x); };
+struct B { virtual void __stdcall foo(Agg x); };
+struct C : A, B { C(); virtual void __stdcall foo(Agg x); };
+C::C() {} // force emission
+
+// CHECK32-LABEL: define linkonce_odr x86_stdcallcc void @"\01?foo@C@stdcall_thunk@@W3AGXUAgg@2@@Z"
+// CHECK32:             (<{ %"struct.stdcall_thunk::C"*, %"struct.stdcall_thunk::Agg" }>* inalloca)
+// CHECK32:   %[[this_slot:[^ ]*]] = getelementptr inbounds <{ %"struct.stdcall_thunk::C"*, %"struct.stdcall_thunk::Agg" }>* %0, i32 0, i32 0
+// CHECK32:   load %"struct.stdcall_thunk::C"** %[[this_slot]]
+// CHECK32:   getelementptr i8* %{{.*}}, i32 -4
+// CHECK32:   store %"struct.stdcall_thunk::C"* %{{.*}}, %"struct.stdcall_thunk::C"** %[[this_slot]]
+// CHECK32:   musttail call x86_stdcallcc void @"\01?foo@C@stdcall_thunk@@UAGXUAgg@2@@Z"
+// CHECK32:       (<{ %"struct.stdcall_thunk::C"*, %"struct.stdcall_thunk::Agg" }>*  inalloca %0)
+// CHECK32-NEXT: ret void
+
+// CHECK64-LABEL: define linkonce_odr void @"\01?foo@C@stdcall_thunk@@W7EAAXUAgg@2@@Z"
+// CHECK64:             (%"struct.stdcall_thunk::C"* %this, %"struct.stdcall_thunk::Agg"* %x)
+// CHECK64:   getelementptr i8* %{{.*}}, i32 -8
+// CHECK64:   call void @"\01?foo@C@stdcall_thunk@@UEAAXUAgg@2@@Z"
+// CHECK64:       (%"struct.stdcall_thunk::C"* %{{.*}}, %"struct.stdcall_thunk::Agg"* %x)
+// CHECK64-NOT: call
+// CHECK64:   ret void
+}
+
+namespace sret_thunk {
+struct Agg {
+  Agg();
+  Agg(const Agg &);
+  ~Agg();
+  int x;
+};
+
+struct A { virtual Agg __cdecl foo(Agg x); };
+struct B { virtual Agg __cdecl foo(Agg x); };
+struct C : A, B { C(); virtual Agg __cdecl foo(Agg x); };
+C::C() {} // force emission
+
+// CHECK32-LABEL: define linkonce_odr %"struct.sret_thunk::Agg"* @"\01?foo@C@sret_thunk@@W3AA?AUAgg@2@U32@@Z"
+// CHECK32:             (<{ %"struct.sret_thunk::C"*, %"struct.sret_thunk::Agg"*, %"struct.sret_thunk::Agg" }>* inalloca)
+// CHECK32:   %[[this_slot:[^ ]*]] = getelementptr inbounds <{ %"struct.sret_thunk::C"*, %"struct.sret_thunk::Agg"*, %"struct.sret_thunk::Agg" }>* %0, i32 0, i32 0
+// CHECK32:   load %"struct.sret_thunk::C"** %[[this_slot]]
+// CHECK32:   getelementptr i8* %{{.*}}, i32 -4
+// CHECK32:   store %"struct.sret_thunk::C"* %{{.*}}, %"struct.sret_thunk::C"** %[[this_slot]]
+// CHECK32:   %[[rv:[^ ]*]] = musttail call %"struct.sret_thunk::Agg"* @"\01?foo@C@sret_thunk@@UAA?AUAgg@2@U32@@Z"
+// CHECK32:       (<{ %"struct.sret_thunk::C"*, %"struct.sret_thunk::Agg"*, %"struct.sret_thunk::Agg" }>*  inalloca %0)
+// CHECK32-NEXT: ret %"struct.sret_thunk::Agg"* %[[rv]]
+
+// CHECK64-LABEL: define linkonce_odr void @"\01?foo@C@sret_thunk@@W7EAA?AUAgg@2@U32@@Z"
+// CHECK64:             (%"struct.sret_thunk::C"* %this, %"struct.sret_thunk::Agg"* noalias sret %agg.result, %"struct.sret_thunk::Agg"* %x)
+// CHECK64:   getelementptr i8* %{{.*}}, i32 -8
+// CHECK64:   call void @"\01?foo@C@sret_thunk@@UEAA?AUAgg@2@U32@@Z"
+// CHECK64:       (%"struct.sret_thunk::C"* %{{.*}}, %"struct.sret_thunk::Agg"* sret %agg.result, %"struct.sret_thunk::Agg"* %x)
+// CHECK64-NOT: call
+// CHECK64:   ret void
+}
+
+#if 0
+// FIXME: When we extend LLVM IR to allow forwarding of varargs through musttail
+// calls, use this test.
+namespace variadic_thunk {
+struct Agg {
+  Agg();
+  Agg(const Agg &);
+  ~Agg();
+  int x;
+};
+
+struct A { virtual void foo(Agg x, ...); };
+struct B { virtual void foo(Agg x, ...); };
+struct C : A, B { C(); virtual void foo(Agg x, ...); };
+C::C() {} // force emission
+}
+#endif
diff --git a/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp b/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
index 225407b..f2e9da7 100644
--- a/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
+++ b/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
@@ -20,11 +20,10 @@
 T* test2(A* x) { return &dynamic_cast<T&>(*x); }
 // CHECK-LABEL: define %struct.T* @"\01?test2@@YAPAUT@@PAUA@@@Z"(%struct.A* %x)
 // CHECK:        [[CAST:%.*]] = bitcast %struct.A* %x to i8*
-// CHECK-NEXT:   [[BITCAST:%.*]] = bitcast %struct.A* %x to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4
-// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32*
-// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST]], align 4
+// CHECK-NEXT:   [[VBPTRPTR:%.*]] = getelementptr inbounds %struct.A* %x, i32 0, i32 0
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBPTRPTR]], align 4
+// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[CAST]], i32 [[VBOFFS]]
 // CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[VBOFFS]], i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUA@@@8" to i8*), i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 1)
 // CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[CALL]] to %struct.T*
@@ -34,11 +33,10 @@
 // CHECK-LABEL: define %struct.T* @"\01?test3@@YAPAUT@@PAUB@@@Z"(%struct.B* %x)
 // CHECK:        [[VOIDP:%.*]] = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0
 // CHECK-NEXT:   [[VBPTR:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 4
-// CHECK-NEXT:   [[BITCAST:%.*]] = bitcast i8* [[VBPTR:%.*]] to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4
-// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32*
-// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST]], align 4
+// CHECK-NEXT:   [[VBPTRPTR:%.*]] = bitcast i8* [[VBPTR:%.*]] to i32**
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBPTRPTR]], align 4
+// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 [[DELTA]]
 // CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[DELTA]], i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUB@@@8" to i8*), i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 1)
@@ -57,11 +55,10 @@
 // CHECK:        [[CHECK:%.*]] = icmp eq %struct.A* %x, null
 // CHECK-NEXT:   br i1 [[CHECK]]
 // CHECK:        [[VOIDP:%.*]] = bitcast %struct.A* %x to i8*
-// CHECK-NEXT:   [[BITCAST:%.*]] = bitcast %struct.A* %x to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4
-// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32*
-// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4
+// CHECK-NEXT:   [[VBPTRPTR:%.*]] = getelementptr inbounds %struct.A* %x, i32 0, i32 0
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBPTRPTR]], align 4
+// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 [[VBOFFS]]
 // CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[VBOFFS]], i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUA@@@8" to i8*), i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 0)
 // CHECK-NEXT:   [[RES:%.*]] = bitcast i8* [[CALL]] to %struct.T*
@@ -75,11 +72,10 @@
 // CHECK-NEXT:   br i1 [[CHECK]]
 // CHECK:        [[CAST:%.*]] = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0
 // CHECK-NEXT:   [[VBPTR:%.*]] = getelementptr inbounds i8* [[CAST]], i32 4
-// CHECK-NEXT:   [[BITCAST:%.*]] = bitcast i8* [[VBPTR]] to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4
-// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32*
-// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4
+// CHECK-NEXT:   [[VBPTRPTR:%.*]] = bitcast i8* [[VBPTR]] to i32**
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBPTRPTR]], align 4
+// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[CAST]], i32 [[DELTA]]
 // CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[DELTA]], i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUB@@@8" to i8*), i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 0)
@@ -99,11 +95,10 @@
 // CHECK:        [[CHECK:%.*]] = icmp eq %struct.A* %x, null
 // CHECK-NEXT:   br i1 [[CHECK]]
 // CHECK:        [[VOIDP:%.*]] = bitcast %struct.A* %x to i8*
-// CHECK-NEXT:   [[BITCAST:%.*]] = bitcast %struct.A* %x to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4
-// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32*
-// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4
+// CHECK-NEXT:   [[VBPTRPTR:%.*]] = getelementptr inbounds %struct.A* %x, i32 0, i32 0
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBPTRPTR]], align 4
+// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 [[VBOFFS]]
 // CHECK-NEXT:   [[RES:%.*]] = tail call i8* @__RTCastToVoid(i8* [[ADJ]])
 // CHECK-NEXT:   br label
@@ -116,11 +111,10 @@
 // CHECK-NEXT:   br i1 [[CHECK]]
 // CHECK:        [[CAST:%.*]] = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0
 // CHECK-NEXT:   [[VBPTR:%.*]] = getelementptr inbounds i8* [[CAST]], i32 4
-// CHECK-NEXT:   [[BITCAST:%.*]] = bitcast i8* [[VBPTR]] to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4
-// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32*
-// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4
+// CHECK-NEXT:   [[VBPTRPTR:%.*]] = bitcast i8* [[VBPTR]] to i32**
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBPTRPTR]], align 4
+// CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBOFFS:%.*]] = load i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[CAST]], i32 [[DELTA]]
 // CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTCastToVoid(i8* [[ADJ]])
diff --git a/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
index 18e8c82..f403aff 100644
--- a/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
+++ b/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
@@ -1,9 +1,19 @@
-// RUN: %clang_cc1 -std=c++11 -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s
-// RUN: %clang_cc1 -std=c++11 -fno-rtti -emit-llvm %s -o - -triple=x86_64-pc-win32 -fms-extensions | FileCheck %s -check-prefix=X64
-// RUN: %clang_cc1 -std=c++11 -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -DINCOMPLETE_VIRTUAL -fms-extensions -verify
-// RUN: %clang_cc1 -std=c++11 -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -DINCOMPLETE_VIRTUAL -DMEMFUN -fms-extensions -verify
-// FIXME: Test x86_64 member pointers when codegen no longer asserts on records
-// with virtual bases.
+// RUN: %clang_cc1 -std=c++11 -Wno-uninitialized -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -Wno-uninitialized -fno-rtti -emit-llvm %s -o - -triple=x86_64-pc-win32 -fms-extensions | FileCheck %s -check-prefix=X64
+// RUN: %clang_cc1 -std=c++11 -Wno-uninitialized -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -DINCOMPLETE_VIRTUAL -fms-extensions -verify
+// RUN: %clang_cc1 -std=c++11 -Wno-uninitialized -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 -DINCOMPLETE_VIRTUAL -DMEMFUN -fms-extensions -verify
+
+namespace PR20947 {
+struct A;
+int A::**a = nullptr;
+// CHECK: %[[opaque0:.*]] = type opaque
+// CHECK: %[[opaque1:.*]] = type opaque
+// CHECK: @"\01?a@PR20947@@3PAPQA@1@HA" = global %[[opaque0]]* null, align 4
+
+struct B;
+int B::*&b = b;
+// CHECK: @"\01?b@PR20947@@3AAPQB@1@HA" = global %[[opaque1]]* null, align 4
+}
 
 #ifndef INCOMPLETE_VIRTUAL
 struct B1 {
@@ -265,11 +275,11 @@
 // CHECK:   %[[memptr1:.*]] = extractvalue { i32, i32 } %[[memptr:.*]], 1
 // CHECK:   %[[v6:.*]] = bitcast %{{.*}}* %[[o]] to i8*
 // CHECK:   %[[vbptr:.*]] = getelementptr inbounds i8* %[[v6]], i32 0
-// CHECK:   %[[vbptr_a:.*]] = bitcast i8* %[[vbptr]] to i8**
-// CHECK:   %[[vbtable:.*]] = load i8** %[[vbptr_a:.*]]
-// CHECK:   %[[v7:.*]] = getelementptr inbounds i8* %[[vbtable]], i32 %[[memptr1]]
-// CHECK:   %[[v8:.*]] = bitcast i8* %[[v7]] to i32*
-// CHECK:   %[[vbase_offs:.*]] = load i32* %[[v8]]
+// CHECK:   %[[vbptr_a:.*]] = bitcast i8* %[[vbptr]] to i32**
+// CHECK:   %[[vbtable:.*]] = load i32** %[[vbptr_a:.*]]
+// CHECK:   %[[memptr1_shr:.*]] = ashr exact i32 %[[memptr1]], 2
+// CHECK:   %[[v7:.*]] = getelementptr inbounds i32* %[[vbtable]], i32 %[[memptr1_shr]]
+// CHECK:   %[[vbase_offs:.*]] = load i32* %[[v7]]
 // CHECK:   %[[v10:.*]] = getelementptr inbounds i8* %[[vbptr]], i32 %[[vbase_offs]]
 // CHECK:   %[[offset:.*]] = getelementptr inbounds i8* %[[v10]], i32 %[[memptr0]]
 // CHECK:   %[[v11:.*]] = bitcast i8* %[[offset]] to i32*
@@ -299,11 +309,11 @@
 //
 // CHECK: [[vadjust]]
 // CHECK:   %[[vbptr:.*]] = getelementptr inbounds i8* %[[base]], i32 %[[memptr1]]
-// CHECK:   %[[vbptr_a:.*]] = bitcast i8* %[[vbptr]] to i8**
-// CHECK:   %[[vbtable:.*]] = load i8** %[[vbptr_a:.*]]
-// CHECK:   %[[v7:.*]] = getelementptr inbounds i8* %[[vbtable]], i32 %[[memptr2]]
-// CHECK:   %[[v8:.*]] = bitcast i8* %[[v7]] to i32*
-// CHECK:   %[[vbase_offs:.*]] = load i32* %[[v8]]
+// CHECK:   %[[vbptr_a:.*]] = bitcast i8* %[[vbptr]] to i32**
+// CHECK:   %[[vbtable:.*]] = load i32** %[[vbptr_a:.*]]
+// CHECK:   %[[memptr2_shr:.*]] = ashr exact i32 %[[memptr2]], 2
+// CHECK:   %[[v7:.*]] = getelementptr inbounds i32* %[[vbtable]], i32 %[[memptr2_shr]]
+// CHECK:   %[[vbase_offs:.*]] = load i32* %[[v7]]
 // CHECK:   %[[base_adj:.*]] = getelementptr inbounds i8* %[[vbptr]], i32 %[[vbase_offs]]
 //
 // CHECK: [[skip]]
@@ -350,11 +360,11 @@
 // CHECK:   %[[memptr1:.*]] = extractvalue { i8*, i32, i32 } %{{.*}}, 1
 // CHECK:   %[[memptr2:.*]] = extractvalue { i8*, i32, i32 } %{{.*}}, 2
 // CHECK:   %[[vbptr:.*]] = getelementptr inbounds i8* %{{.*}}, i32 0
-// CHECK:   %[[vbptr_a:.*]] = bitcast i8* %[[vbptr]] to i8**
-// CHECK:   %[[vbtable:.*]] = load i8** %[[vbptr_a:.*]]
-// CHECK:   %[[v7:.*]] = getelementptr inbounds i8* %[[vbtable]], i32 %[[memptr2]]
-// CHECK:   %[[v8:.*]] = bitcast i8* %[[v7]] to i32*
-// CHECK:   %[[vbase_offs:.*]] = load i32* %[[v8]]
+// CHECK:   %[[vbptr_a:.*]] = bitcast i8* %[[vbptr]] to i32**
+// CHECK:   %[[vbtable:.*]] = load i32** %[[vbptr_a:.*]]
+// CHECK:   %[[memptr2_shr:.*]] = ashr exact i32 %[[memptr2]], 2
+// CHECK:   %[[v7:.*]] = getelementptr inbounds i32* %[[vbtable]], i32 %[[memptr2_shr]]
+// CHECK:   %[[vbase_offs:.*]] = load i32* %[[v7]]
 // CHECK:   %[[v10:.*]] = getelementptr inbounds i8* %[[vbptr]], i32 %[[vbase_offs]]
 // CHECK:   %[[this_adjusted:.*]] = getelementptr inbounds i8* %[[v10]], i32 %[[memptr1]]
 // CHECK:   %[[fptr:.*]] = bitcast i8* %[[memptr0]] to void ({{.*}})
@@ -595,15 +605,15 @@
   return &C::g;
 }
 // CHECK-LABEL: define i64 @"\01?getmp@Test4@@YAP8C@1@AEXXZXZ"()
-// CHECK: store { i8*, i32 } { i8* bitcast (void (i8*)* @"\01??_9C@Test4@@$BA@AE" to i8*), i32 4 }, { i8*, i32 }* %{{.*}}
+// CHECK: store { i8*, i32 } { i8* bitcast (void (%"struct.Test4::C"*, ...)* @"\01??_9C@Test4@@$BA@AE" to i8*), i32 4 }, { i8*, i32 }* %{{.*}}
 //
 
-// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@Test4@@$BA@AE"(i8*)
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@Test4@@$BA@AE"(%"struct.Test4::C"* %this, ...)
 // CHECK-NOT:  getelementptr
-// CHECK:  load void (i8*)*** %{{.*}}
-// CHECK:  getelementptr inbounds void (i8*)** %{{.*}}, i64 0
+// CHECK:  load void (%"struct.Test4::C"*, ...)*** %{{.*}}
+// CHECK:  getelementptr inbounds void (%"struct.Test4::C"*, ...)** %{{.*}}, i64 0
 // CHECK-NOT:  getelementptr
-// CHECK:  call x86_thiscallcc void %
+// CHECK:  musttail call x86_thiscallcc void (%"struct.Test4::C"*, ...)* %
 
 }
 
@@ -630,6 +640,34 @@
 // CHECK: store i8* bitcast (void (%"struct.pr20007_kw::A"*)* @"\01?f@A@pr20007_kw@@QAEXXZ" to i8*)
 }
 
+namespace pr20007_pragma {
+struct A {
+  void f();
+  void f(int);
+};
+struct B : public A {};
+void test() { (void)(void (B::*)()) &B::f; }
+#pragma pointers_to_members(full_generality, virtual_inheritance)
+static_assert(sizeof(int B::*) == 4, "");
+static_assert(sizeof(int A::*) == 4, "");
+#pragma pointers_to_members(best_case)
+// CHECK-LABEL: define void @"\01?test@pr20007_pragma@@YAXXZ"
+}
+
+namespace pr20007_pragma2 {
+struct A {
+};
+struct B : public A {
+  void f();
+};
+void test() { (void)&B::f; }
+#pragma pointers_to_members(full_generality, virtual_inheritance)
+static_assert(sizeof(int B::*) == 4, "");
+static_assert(sizeof(int A::*) == 12, "");
+#pragma pointers_to_members(best_case)
+// CHECK-LABEL: define void @"\01?test@pr20007_pragma2@@YAXXZ"
+}
+
 namespace pr19987 {
 template <typename T>
 struct S {
diff --git a/test/CodeGenCXX/microsoft-abi-nontrivial-covariant-thunk.cpp b/test/CodeGenCXX/microsoft-abi-nontrivial-covariant-thunk.cpp
index d305dd8..cb8b522 100644
--- a/test/CodeGenCXX/microsoft-abi-nontrivial-covariant-thunk.cpp
+++ b/test/CodeGenCXX/microsoft-abi-nontrivial-covariant-thunk.cpp
@@ -18,7 +18,7 @@
 struct C : A, B {
   C();
   int c;
-  virtual C *clone(A); // expected-error {{cannot compile this non-trivial argument copy for thunk yet}}
+  virtual C *clone(A); // expected-error {{cannot compile this non-trivial argument copy for return-adjusting thunk yet}}
 };
 B::B() {}  // force emission
 C::C() {}  // force emission
diff --git a/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp b/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
index de1b7aa..96c23c6 100644
--- a/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ b/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -137,10 +137,10 @@
 
 // Test that references aren't destroyed in the callee.
 void ref_small_arg_with_dtor(const SmallWithDtor &s) { }
-// WIN32: define void @"\01?ref_small_arg_with_dtor@@YAXABUSmallWithDtor@@@Z"(%struct.SmallWithDtor* nonnull %s) {{.*}} {
+// WIN32: define void @"\01?ref_small_arg_with_dtor@@YAXABUSmallWithDtor@@@Z"(%struct.SmallWithDtor* dereferenceable({{[0-9]+}}) %s) {{.*}} {
 // WIN32-NOT:   call x86_thiscallcc void @"\01??1SmallWithDtor@@QAE@XZ"
 // WIN32: }
-// WIN64-LABEL: define void @"\01?ref_small_arg_with_dtor@@YAXAEBUSmallWithDtor@@@Z"(%struct.SmallWithDtor* nonnull %s)
+// WIN64-LABEL: define void @"\01?ref_small_arg_with_dtor@@YAXAEBUSmallWithDtor@@@Z"(%struct.SmallWithDtor* dereferenceable({{[0-9]+}}) %s)
 
 void big_arg_with_dtor(BigWithDtor s) {}
 // WIN64-LABEL: define void @"\01?big_arg_with_dtor@@YAXUBigWithDtor@@@Z"(%struct.BigWithDtor* %s)
diff --git a/test/CodeGenCXX/microsoft-abi-static-initializers.cpp b/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
index a3127c7..76d7e9e 100644
--- a/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
+++ b/test/CodeGenCXX/microsoft-abi-static-initializers.cpp
@@ -1,9 +1,12 @@
 // RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -mconstructor-aliases -triple=i386-pc-win32 | FileCheck %s
 
-// CHECK: @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }]
-// CHECK: [{ i32, void ()*, i8* } { i32 65535, void ()* @"\01??__Efoo@?$B@H@@2VA@@A@YAXXZ",
-// CHECK:       i8* bitcast (%class.A* @"\01?foo@?$B@H@@2VA@@A" to i8*) },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_microsoft_abi_static_initializers.cpp, i8* null }]
+// CHECK: @llvm.global_ctors = appending global [5 x { i32, void ()*, i8* }] [
+// CHECK: { i32, void ()*, i8* } { i32 65535, void ()* @"\01??__Eselectany1@@YAXXZ", i8* getelementptr inbounds (%struct.S* @"\01?selectany1@@3US@@A", i32 0, i32 0) },
+// CHECK: { i32, void ()*, i8* } { i32 65535, void ()* @"\01??__Eselectany2@@YAXXZ", i8* getelementptr inbounds (%struct.S* @"\01?selectany2@@3US@@A", i32 0, i32 0) },
+// CHECK: { i32, void ()*, i8* } { i32 65535, void ()* @"\01??__Es@?$ExportedTemplate@H@@2US@@A@YAXXZ", i8* getelementptr inbounds (%struct.S* @"\01?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0) },
+// CHECK: { i32, void ()*, i8* } { i32 65535, void ()* @"\01??__Efoo@?$B@H@@2VA@@A@YAXXZ", i8* bitcast (%class.A* @"\01?foo@?$B@H@@2VA@@A" to i8*) },
+// CHECK: { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_microsoft_abi_static_initializers.cpp, i8* null }
+// CHECK: ]
 
 struct S {
   S();
@@ -21,8 +24,8 @@
 // CHECK: call x86_thiscallcc void @"\01??1S@@QAE@XZ"
 // CHECK: ret void
 
-// These globals should use distinct guard variables, and not different bits of
-// the same global.
+// These globals should have initializers comdat associative with the global.
+// See @llvm.global_ctors above.
 __declspec(selectany) S selectany1;
 __declspec(selectany) S selectany2;
 // CHECK: define linkonce_odr void @"\01??__Eselectany1@@YAXXZ"()
@@ -34,12 +37,23 @@
 // CHECK: call x86_thiscallcc %struct.S* @"\01??0S@@QAE@XZ"
 // CHECK: ret void
 
+// The implicitly instantiated static data member should have initializer
+// comdat associative with the global.
+template <typename T> struct __declspec(dllexport) ExportedTemplate {
+  static S s;
+};
+template <typename T> S ExportedTemplate<T>::s;
+void useExportedTemplate(ExportedTemplate<int> x) {
+  (void)x.s;
+}
+
 void StaticLocal() {
   static S TheS;
 }
+
 // CHECK-LABEL: define void @"\01?StaticLocal@@YAXXZ"()
-// CHECK: load i32* @"\01?$S1@?0??StaticLocal@@YAXXZ@4IA"
-// CHECK: store i32 {{.*}}, i32* @"\01?$S1@?0??StaticLocal@@YAXXZ@4IA"
+// CHECK: load i32* @"\01?$S1@?1??StaticLocal@@YAXXZ@4IA"
+// CHECK: store i32 {{.*}}, i32* @"\01?$S1@?1??StaticLocal@@YAXXZ@4IA"
 // CHECK: ret
 
 void MultipleStatics() {
@@ -80,7 +94,7 @@
   static S S35;
 }
 // CHECK-LABEL: define void @"\01?MultipleStatics@@YAXXZ"()
-// CHECK: load i32* @"\01?$S1@?0??MultipleStatics@@YAXXZ@4IA"
+// CHECK: load i32* @"\01?$S1@?1??MultipleStatics@@YAXXZ@4IA"
 // CHECK: and i32 {{.*}}, 1
 // CHECK: and i32 {{.*}}, 2
 // CHECK: and i32 {{.*}}, 4
@@ -88,7 +102,7 @@
 // CHECK: and i32 {{.*}}, 16
 //   ...
 // CHECK: and i32 {{.*}}, -2147483648
-// CHECK: load i32* @"\01?$S1@?0??MultipleStatics@@YAXXZ@4IA1"
+// CHECK: load i32* @"\01?$S1@?1??MultipleStatics@@YAXXZ@4IA1"
 // CHECK: and i32 {{.*}}, 1
 // CHECK: and i32 {{.*}}, 2
 // CHECK: and i32 {{.*}}, 4
@@ -119,7 +133,7 @@
   return s;
 }
 
-// CHECK-LABEL: define linkonce_odr nonnull %struct.S* @"\01?UnreachableStatic@@YAAAUS@@XZ"()
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.S* @"\01?UnreachableStatic@@YAAAUS@@XZ"()
 // CHECK: and i32 {{.*}}, 2
 // CHECK: or i32 {{.*}}, 2
 // CHECK: ret
@@ -129,7 +143,7 @@
   return TheS;
 }
 
-// CHECK-LABEL: define linkonce_odr nonnull %struct.S* @"\01?getS@@YAAAUS@@XZ"
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.S* @"\01?getS@@YAAAUS@@XZ"
 // CHECK: load i32* @"\01??_B?1??getS@@YAAAUS@@XZ@51"
 // CHECK: and i32 {{.*}}, 1
 // CHECK: icmp ne i32 {{.*}}, 0
diff --git a/test/CodeGenCXX/microsoft-abi-structors-delayed-template.cpp b/test/CodeGenCXX/microsoft-abi-structors-delayed-template.cpp
new file mode 100644
index 0000000..f9e1880
--- /dev/null
+++ b/test/CodeGenCXX/microsoft-abi-structors-delayed-template.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -fdelayed-template-parsing -std=c++11 -o - -triple=i386-pc-win32 %s > %t
+// RUN: FileCheck %s < %t
+
+// PR20671
+namespace vtable_referenced_from_template {
+struct ImplicitCtor {
+  virtual ~ImplicitCtor();
+};
+template <class T> void foo(T t) { new ImplicitCtor; }
+void bar() { foo(0); }
+// CHECK: store {{.*}} @"\01??_7ImplicitCtor@vtable_referenced_from_template@@6B@"
+}
diff --git a/test/CodeGenCXX/microsoft-abi-structors.cpp b/test/CodeGenCXX/microsoft-abi-structors.cpp
index 04227e3..0bc4c42 100644
--- a/test/CodeGenCXX/microsoft-abi-structors.cpp
+++ b/test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -mconstructor-aliases -triple=i386-pc-win32 -fno-rtti > %t
+// RUN: %clang_cc1 -emit-llvm -fno-rtti %s -std=c++11 -o - -mconstructor-aliases -triple=i386-pc-win32 -fno-rtti > %t
 // RUN: FileCheck %s < %t
 // vftables are emitted very late, so do another pass to try to keep the checks
 // in source order.
@@ -46,8 +46,9 @@
 
 struct C {
   virtual ~C() {
-// DTORS:      define linkonce_odr x86_thiscallcc void @"\01??_GC@basic@@UAEPAXI@Z"(%"struct.basic::C"* %this, i32 %should_call_delete)
+// DTORS:      define linkonce_odr x86_thiscallcc i8* @"\01??_GC@basic@@UAEPAXI@Z"(%"struct.basic::C"* %this, i32 %should_call_delete)
 // DTORS:        store i32 %should_call_delete, i32* %[[SHOULD_DELETE_VAR:[0-9a-z._]+]], align 4
+// DTORS:        store i8* %{{.*}}, i8** %[[RETVAL:[0-9a-z._]+]]
 // DTORS:        %[[SHOULD_DELETE_VALUE:[0-9a-z._]+]] = load i32* %[[SHOULD_DELETE_VAR]]
 // DTORS:        call x86_thiscallcc void @"\01??1C@basic@@UAE@XZ"(%"struct.basic::C"* %[[THIS:[0-9a-z]+]])
 // DTORS-NEXT:   %[[CONDITION:[0-9]+]] = icmp eq i32 %[[SHOULD_DELETE_VALUE]], 0
@@ -59,7 +60,8 @@
 // DTORS-NEXT:   br label %[[CONTINUE_LABEL]]
 //
 // DTORS:      [[CONTINUE_LABEL]]
-// DTORS-NEXT:   ret void
+// DTORS-NEXT:   %[[RET:.*]] = load i8** %[[RETVAL]]
+// DTORS-NEXT:   ret i8* %[[RET]]
 
 // Check that we do the mangling correctly on x64.
 // DTORS-X64:  @"\01??_GC@basic@@UEAAPEAXI@Z"
@@ -81,11 +83,11 @@
 // CHECK: define void @"\01?call_complete_dtor@basic@@YAXPAUC@1@@Z"(%"struct.basic::C"* %obj_ptr)
   obj_ptr->~C();
 // CHECK: %[[OBJ_PTR_VALUE:.*]] = load %"struct.basic::C"** %{{.*}}, align 4
-// CHECK-NEXT: %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to void (%"struct.basic::C"*, i32)***
-// CHECK-NEXT: %[[VTABLE:.*]] = load void (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
-// CHECK-NEXT: %[[PVDTOR:.*]] = getelementptr inbounds void (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
-// CHECK-NEXT: %[[VDTOR:.*]] = load void (%"struct.basic::C"*, i32)** %[[PVDTOR]]
-// CHECK-NEXT: call x86_thiscallcc void %[[VDTOR]](%"struct.basic::C"* %[[OBJ_PTR_VALUE]], i32 0)
+// CHECK-NEXT: %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to i8* (%"struct.basic::C"*, i32)***
+// CHECK-NEXT: %[[VTABLE:.*]] = load i8* (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
+// CHECK-NEXT: %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
+// CHECK-NEXT: %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
+// CHECK-NEXT: call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* %[[OBJ_PTR_VALUE]], i32 0)
 // CHECK-NEXT: ret void
 }
 
@@ -96,11 +98,27 @@
 // CHECK:      br i1 {{.*}}, label %[[DELETE_NULL:.*]], label %[[DELETE_NOTNULL:.*]]
 
 // CHECK:      [[DELETE_NOTNULL]]
-// CHECK-NEXT:   %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to void (%"struct.basic::C"*, i32)***
-// CHECK-NEXT:   %[[VTABLE:.*]] = load void (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
-// CHECK-NEXT:   %[[PVDTOR:.*]] = getelementptr inbounds void (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
-// CHECK-NEXT:   %[[VDTOR:.*]] = load void (%"struct.basic::C"*, i32)** %[[PVDTOR]]
-// CHECK-NEXT:   call x86_thiscallcc void %[[VDTOR]](%"struct.basic::C"* %[[OBJ_PTR_VALUE]], i32 1)
+// CHECK-NEXT:   %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to i8* (%"struct.basic::C"*, i32)***
+// CHECK-NEXT:   %[[VTABLE:.*]] = load i8* (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
+// CHECK-NEXT:   %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
+// CHECK-NEXT:   %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
+// CHECK-NEXT:   call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* %[[OBJ_PTR_VALUE]], i32 1)
+// CHECK:      ret void
+}
+
+void call_deleting_dtor_and_global_delete(C *obj_ptr) {
+// CHECK: define void @"\01?call_deleting_dtor_and_global_delete@basic@@YAXPAUC@1@@Z"(%"struct.basic::C"* %obj_ptr)
+  ::delete obj_ptr;
+// CHECK:      %[[OBJ_PTR_VALUE:.*]] = load %"struct.basic::C"** %{{.*}}, align 4
+// CHECK:      br i1 {{.*}}, label %[[DELETE_NULL:.*]], label %[[DELETE_NOTNULL:.*]]
+
+// CHECK:      [[DELETE_NOTNULL]]
+// CHECK-NEXT:   %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to i8* (%"struct.basic::C"*, i32)***
+// CHECK-NEXT:   %[[VTABLE:.*]] = load i8* (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
+// CHECK-NEXT:   %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
+// CHECK-NEXT:   %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
+// CHECK-NEXT:   %[[CALL:.*]] = call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* %[[OBJ_PTR_VALUE]], i32 0)
+// CHECK-NEXT:   call void @"\01??3@YAXPAX@Z"(i8* %[[CALL]])
 // CHECK:      ret void
 }
 
@@ -153,13 +171,13 @@
 void foo() {
   C c;
 }
-// DTORS2-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_EC@dtor_in_second_nvbase@@W3AEPAXI@Z"
+// DTORS2-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_EC@dtor_in_second_nvbase@@W3AEPAXI@Z"
 // DTORS2:       (%"struct.dtor_in_second_nvbase::C"* %this, i32 %should_call_delete)
 //      Do an adjustment from B* to C*.
 // DTORS2:   getelementptr i8* %{{.*}}, i32 -4
 // DTORS2:   bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::C"*
-// DTORS2:   call x86_thiscallcc void @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
-// DTORS2:   ret void
+// DTORS2:   %[[CALL:.*]] = call x86_thiscallcc i8* @"\01??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
+// DTORS2:   ret i8* %[[CALL]]
 
 }
 
@@ -229,8 +247,8 @@
   // CHECK: [[INIT_VBASES]]
   // CHECK-NEXT: %[[this_i8:.*]] = bitcast %"struct.constructors::C"* %{{.*}} to i8*
   // CHECK-NEXT: %[[vbptr_off:.*]] = getelementptr inbounds i8* %[[this_i8]], i64 0
-  // CHECK-NEXT: %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to [2 x i32]**
-  // CHECK-NEXT: store [2 x i32]* @"\01??_8C@constructors@@7B@", [2 x i32]** %[[vbptr]]
+  // CHECK-NEXT: %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
+  // CHECK-NEXT: store i32* getelementptr inbounds ([2 x i32]* @"\01??_8C@constructors@@7B@", i32 0, i32 0), i32** %[[vbptr]]
   // CHECK-NEXT: bitcast %"struct.constructors::C"* %{{.*}} to i8*
   // CHECK-NEXT: getelementptr inbounds i8* %{{.*}}, i64 4
   // CHECK-NEXT: bitcast i8* %{{.*}} to %"struct.constructors::A"*
@@ -264,8 +282,8 @@
   // CHECK: [[INIT_VBASES]]
   // CHECK-NEXT: %[[this_i8:.*]] = bitcast %"struct.constructors::D"* %{{.*}} to i8*
   // CHECK-NEXT: %[[vbptr_off:.*]] = getelementptr inbounds i8* %[[this_i8]], i64 0
-  // CHECK-NEXT: %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to [2 x i32]**
-  // CHECK-NEXT: store [2 x i32]* @"\01??_8D@constructors@@7B@", [2 x i32]** %[[vbptr]]
+  // CHECK-NEXT: %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
+  // CHECK-NEXT: store i32* getelementptr inbounds ([2 x i32]* @"\01??_8D@constructors@@7B@", i32 0, i32 0), i32** %[[vbptr]]
   // CHECK-NEXT: bitcast %"struct.constructors::D"* %{{.*}} to i8*
   // CHECK-NEXT: getelementptr inbounds i8* %{{.*}}, i64 4
   // CHECK-NEXT: bitcast i8* %{{.*}} to %"struct.constructors::A"*
@@ -291,11 +309,11 @@
   // CHECK: [[INIT_VBASES]]
   // CHECK-NEXT: %[[this_i8:.*]] = bitcast %"struct.constructors::E"* %{{.*}} to i8*
   // CHECK-NEXT: %[[offs:.*]] = getelementptr inbounds i8* %[[this_i8]], i64 0
-  // CHECK-NEXT: %[[vbptr_E:.*]] = bitcast i8* %[[offs]] to [3 x i32]**
-  // CHECK-NEXT: store [3 x i32]* @"\01??_8E@constructors@@7B01@@", [3 x i32]** %[[vbptr_E]]
+  // CHECK-NEXT: %[[vbptr_E:.*]] = bitcast i8* %[[offs]] to i32**
+  // CHECK-NEXT: store i32* getelementptr inbounds ([3 x i32]* @"\01??_8E@constructors@@7B01@@", i32 0, i32 0), i32** %[[vbptr_E]]
   // CHECK-NEXT: %[[offs:.*]] = getelementptr inbounds i8* %[[this_i8]], i64 4
-  // CHECK-NEXT: %[[vbptr_C:.*]] = bitcast i8* %[[offs]] to [2 x i32]**
-  // CHECK-NEXT: store [2 x i32]* @"\01??_8E@constructors@@7BC@1@@", [2 x i32]** %[[vbptr_C]]
+  // CHECK-NEXT: %[[vbptr_C:.*]] = bitcast i8* %[[offs]] to i32**
+  // CHECK-NEXT: store i32* getelementptr inbounds ([2 x i32]* @"\01??_8E@constructors@@7BC@1@@", i32 0, i32 0), i32** %[[vbptr_C]]
   // CHECK-NEXT: bitcast %"struct.constructors::E"* %{{.*}} to i8*
   // CHECK-NEXT: getelementptr inbounds i8* %{{.*}}, i64 4
   // CHECK-NEXT: bitcast i8* %{{.*}} to %"struct.constructors::A"*
@@ -406,6 +424,26 @@
 // CHECK:               (%"struct.test1::B"* {{.*}}, i32 1, i8* {{.*}}, i32 1, i32 2)
 }
 
+namespace implicit_copy_vtable {
+// This was a crash that only reproduced in ABIs without key functions.
+struct ImplicitCopy {
+  // implicit copy ctor
+  virtual ~ImplicitCopy();
+};
+void CreateCopy(ImplicitCopy *a) {
+  new ImplicitCopy(*a);
+}
+// CHECK: store {{.*}} @"\01??_7ImplicitCopy@implicit_copy_vtable@@6B@"
+
+struct MoveOnly {
+  MoveOnly(MoveOnly &&o) = default;
+  virtual ~MoveOnly();
+};
+MoveOnly &&f();
+void g() { new MoveOnly(f()); }
+// CHECK: store {{.*}} @"\01??_7MoveOnly@implicit_copy_vtable@@6B@"
+}
+
 // Dtor thunks for classes in anonymous namespaces should be internal, not
 // linkonce_odr.
 namespace {
@@ -416,7 +454,7 @@
 void *getA() {
   return (void*)new A();
 }
-// CHECK: define internal x86_thiscallcc void @"\01??_GA@?A@@UAEPAXI@Z"
+// CHECK: define internal x86_thiscallcc i8* @"\01??_GA@?A@@UAEPAXI@Z"
 // CHECK:               (%"struct.(anonymous namespace)::A"* %this, i32 %should_call_delete)
 // CHECK: define internal x86_thiscallcc void @"\01??1A@?A@@UAE@XZ"
 // CHECK:               (%"struct.(anonymous namespace)::A"* %this)
diff --git a/test/CodeGenCXX/microsoft-abi-thunks.cpp b/test/CodeGenCXX/microsoft-abi-thunks.cpp
index c755b30..843bc89 100644
--- a/test/CodeGenCXX/microsoft-abi-thunks.cpp
+++ b/test/CodeGenCXX/microsoft-abi-thunks.cpp
@@ -61,10 +61,10 @@
 
 C::C() {}  // Emits vftable and forces thunk generation.
 
-// CODEGEN-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_EC@@W3AEPAXI@Z"(%struct.C* %this, i32 %should_call_delete)
+// CODEGEN-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_EC@@W3AEPAXI@Z"(%struct.C* %this, i32 %should_call_delete)
 // CODEGEN:   getelementptr i8* {{.*}}, i32 -4
 // FIXME: should actually call _EC, not _GC.
-// CODEGEN:   call x86_thiscallcc void @"\01??_GC@@UAEPAXI@Z"
+// CODEGEN:   call x86_thiscallcc i8* @"\01??_GC@@UAEPAXI@Z"
 // CODEGEN: ret
 
 // CODEGEN-LABEL: define linkonce_odr x86_thiscallcc void @"\01?public_f@C@@W3AEXXZ"(%struct.C*
@@ -128,10 +128,9 @@
 // CODEGEN: %[[ORIG_RET:.*]] = call x86_thiscallcc %struct.F* @"\01?goo@I@@UAEPAUF@@XZ"
 // CODEGEN: %[[ORIG_RET_i8:.*]] = bitcast %struct.F* %[[ORIG_RET]] to i8*
 // CODEGEN: %[[VBPTR_i8:.*]] = getelementptr inbounds i8* %[[ORIG_RET_i8]], i32 4
-// CODEGEN: %[[VBPTR:.*]] = bitcast i8* %[[VBPTR_i8]] to i8**
-// CODEGEN: %[[VBTABLE:.*]] = load i8** %[[VBPTR]]
-// CODEGEN: %[[VBASE_OFFSET_PTR_i8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 8
-// CODEGEN: %[[VBASE_OFFSET_PTR:.*]] = bitcast i8* %[[VBASE_OFFSET_PTR_i8]] to i32*
+// CODEGEN: %[[VBPTR:.*]] = bitcast i8* %[[VBPTR_i8]] to i32**
+// CODEGEN: %[[VBTABLE:.*]] = load i32** %[[VBPTR]]
+// CODEGEN: %[[VBASE_OFFSET_PTR:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 2
 // CODEGEN: %[[VBASE_OFFSET:.*]] = load i32* %[[VBASE_OFFSET_PTR]]
 // CODEGEN: %[[RES_i8:.*]] = getelementptr inbounds i8* %[[VBPTR_i8]], i32 %[[VBASE_OFFSET]]
 // CODEGEN: %[[RES:.*]] = bitcast i8* %[[RES_i8]] to %struct.F*
diff --git a/test/CodeGenCXX/microsoft-abi-typeid.cpp b/test/CodeGenCXX/microsoft-abi-typeid.cpp
index 4ee004d..1beb211 100644
--- a/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ b/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -31,11 +31,10 @@
 // CHECK:        tail call i8* @__RTtypeid(i8* null)
 // CHECK-NEXT:   unreachable
 // CHECK:        [[THIS:%.*]] = bitcast %struct.A* [[CALL]] to i8*
-// CHECK-NEXT:   [[VBTBLP:%.*]] = bitcast %struct.A* [[CALL]] to i8**
-// CHECK-NEXT:   [[VBTBL:%.*]] = load i8** [[VBTBLP]], align 4
-// CHECK-NEXT:   [[VBSLOT:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4
-// CHECK-NEXT:   [[VBITCST:%.*]] = bitcast i8* [[VBSLOT]] to i32*
-// CHECK-NEXT:   [[VBASE_OFFS:%.*]] = load i32* [[VBITCST]], align 4
+// CHECK-NEXT:   [[VBTBLP:%.*]] = getelementptr inbounds %struct.A* [[CALL]], i32 0, i32 0
+// CHECK-NEXT:   [[VBTBL:%.*]] = load i32** [[VBTBLP]], align 4
+// CHECK-NEXT:   [[VBSLOT:%.*]] = getelementptr inbounds i32* [[VBTBL]], i32 1
+// CHECK-NEXT:   [[VBASE_OFFS:%.*]] = load i32* [[VBSLOT]], align 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8* [[THIS]], i32 [[VBASE_OFFS]]
 // CHECK-NEXT:   [[RT:%.*]] = tail call i8* @__RTtypeid(i8* [[ADJ]])
 // CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
diff --git a/test/CodeGenCXX/microsoft-abi-vftables.cpp b/test/CodeGenCXX/microsoft-abi-vftables.cpp
index 4368cc7..ce2ed2d 100644
--- a/test/CodeGenCXX/microsoft-abi-vftables.cpp
+++ b/test/CodeGenCXX/microsoft-abi-vftables.cpp
@@ -3,6 +3,7 @@
 
 // RTTI-DAG: $"\01??_7S@@6B@" = comdat largest
 // RTTI-DAG: $"\01??_7V@@6B@" = comdat largest
+// RTTI-DAG: $"\01??_7W@?A@@6B@" = comdat largest
 
 struct S {
   virtual ~S();
@@ -35,7 +36,7 @@
   virtual ~W();
 } w;
 }
-// RTTI-DAG: [[VTABLE_W:@.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast ({{.*}} @"\01??_R4W@?A@@6B@" to i8*), i8* bitcast ({{.*}} @"\01??_GW@?A@@UAEPAXI@Z" to i8*)]
-// RTTI-DAG: @"\01??_7W@?A@@6B@" = unnamed_addr alias internal getelementptr inbounds ([2 x i8*]* @1, i32 0, i32 1)
+// RTTI-DAG: [[VTABLE_W:@.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast ({{.*}} @"\01??_R4W@?A@@6B@" to i8*), i8* bitcast ({{.*}} @"\01??_GW@?A@@UAEPAXI@Z" to i8*)], comdat $"\01??_7W@?A@@6B@"
+// RTTI-DAG: @"\01??_7W@?A@@6B@" = internal unnamed_addr alias getelementptr inbounds ([2 x i8*]* @1, i32 0, i32 1)
 
 // NO-RTTI-DAG: @"\01??_7W@?A@@6B@" = internal unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GW@?A@@UAEPAXI@Z" to i8*)]
diff --git a/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp b/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
index a6fcdea..26eb012 100644
--- a/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
+++ b/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
@@ -72,10 +72,9 @@
 // CHECK: %[[VTORDISP_NEG:.*]] = sub i32 0, %[[VTORDISP]]
 // CHECK: %[[VTORDISP_ADJUSTED_i8:.*]] = getelementptr i8* %[[ECX_i8]], i32 %[[VTORDISP_NEG]]
 // CHECK: %[[VBPTR_i8:.*]] = getelementptr inbounds i8* %[[VTORDISP_ADJUSTED_i8]], i32 -16
-// CHECK: %[[VBPTR:.*]] = bitcast i8* %[[VBPTR_i8]] to i8**
-// CHECK: %[[VBTABLE:.*]] = load i8** %[[VBPTR]]
-// CHECK: %[[VBOFFSET_PTR_i8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 12
-// CHECK: %[[VBOFFSET_PTR:.*]] = bitcast i8* %[[VBOFFSET_PTR_i8]] to i32*
+// CHECK: %[[VBPTR:.*]] = bitcast i8* %[[VBPTR_i8]] to i32**
+// CHECK: %[[VBTABLE:.*]] = load i32** %[[VBPTR]]
+// CHECK: %[[VBOFFSET_PTR:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 3
 // CHECK: %[[VBASE_OFFSET:.*]] = load i32* %[[VBOFFSET_PTR]]
 // CHECK: %[[VBASE:.*]] = getelementptr inbounds i8* %[[VBPTR_i8]], i32 %[[VBASE_OFFSET]]
 // CHECK: %[[ARG_i8:.*]] = getelementptr i8* %[[VBASE]], i32 8
diff --git a/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
index 2f0fffee..c851f55 100644
--- a/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ b/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -96,7 +96,7 @@
   // CHECK2: call x86_thiscallcc void @"\01??1VBase@@UAE@XZ"(%struct.VBase* %[[VBASE]])
   // CHECK2: ret
 
-  // CHECK2-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_GB@@UAEPAXI@Z"
+  // CHECK2-LABEL: define linkonce_odr x86_thiscallcc i8* @"\01??_GB@@UAEPAXI@Z"
   // CHECK2:   %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* {{.*}} to i8*
   // CHECK2:   %[[THIS_i8:.*]] = getelementptr inbounds i8* %[[THIS_PARAM_i8:.*]], i32 -8
   // CHECK2:   %[[THIS:.*]] = bitcast i8* %[[THIS_i8]] to %struct.B*
@@ -122,10 +122,9 @@
 // CHECK: %[[THIS:.*]] = load %struct.B** %[[THIS_ADDR]]
 // CHECK: %[[THIS8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8* %[[THIS8]], i32 0
-// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i8**
-// CHECK: %[[VBTABLE:.*]] = load i8** %[[VBPTR8]]
-// CHECK: %[[VBENTRY8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 4
-// CHECK: %[[VBENTRY:.*]] = bitcast i8* %[[VBENTRY8]] to i32*
+// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i32**
+// CHECK: %[[VBTABLE:.*]] = load i32** %[[VBPTR8]]
+// CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[THIS8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
@@ -147,10 +146,9 @@
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 0
-// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i8**
-// CHECK: %[[VBTABLE:.*]] = load i8** %[[VBPTR8]]
-// CHECK: %[[VBENTRY8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 4
-// CHECK: %[[VBENTRY:.*]] = bitcast i8* %[[VBENTRY8]] to i32*
+// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i32**
+// CHECK: %[[VBTABLE:.*]] = load i32** %[[VBPTR8]]
+// CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
@@ -161,10 +159,9 @@
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 0
-// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i8**
-// CHECK: %[[VBTABLE:.*]] = load i8** %[[VBPTR8]]
-// CHECK: %[[VBENTRY8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 4
-// CHECK: %[[VBENTRY:.*]] = bitcast i8* %[[VBENTRY8]] to i32*
+// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i32**
+// CHECK: %[[VBTABLE:.*]] = load i32** %[[VBPTR8]]
+// CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
@@ -181,30 +178,28 @@
   delete obj;
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 0
-// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i8**
-// CHECK: %[[VBTABLE:.*]] = load i8** %[[VBPTR8]]
-// CHECK: %[[VBENTRY8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 4
-// CHECK: %[[VBENTRY:.*]] = bitcast i8* %[[VBENTRY8]] to i32*
+// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i32**
+// CHECK: %[[VBTABLE:.*]] = load i32** %[[VBPTR8]]
+// CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to void (%struct.B*, i32)***
-// CHECK: %[[VFTABLE:.*]] = load void (%struct.B*, i32)*** %[[VFPTR]]
-// CHECK: %[[VFUN:.*]] = getelementptr inbounds void (%struct.B*, i32)** %[[VFTABLE]], i64 0
-// CHECK: %[[VFUN_VALUE:.*]] = load void (%struct.B*, i32)** %[[VFUN]]
+// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (%struct.B*, i32)***
+// CHECK: %[[VFTABLE:.*]] = load i8* (%struct.B*, i32)*** %[[VFPTR]]
+// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (%struct.B*, i32)** %[[VFTABLE]], i64 0
+// CHECK: %[[VFUN_VALUE:.*]] = load i8* (%struct.B*, i32)** %[[VFUN]]
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 0
-// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i8**
-// CHECK: %[[VBTABLE:.*]] = load i8** %[[VBPTR8]]
-// CHECK: %[[VBENTRY8:.*]] = getelementptr inbounds i8* %[[VBTABLE]], i32 4
-// CHECK: %[[VBENTRY:.*]] = bitcast i8* %[[VBENTRY8]] to i32*
+// CHECK: %[[VBPTR8:.*]] = bitcast i8* %[[VBPTR]] to i32**
+// CHECK: %[[VBTABLE:.*]] = load i32** %[[VBPTR8]]
+// CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
 // CHECK: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.B*
 //
-// CHECK: call x86_thiscallcc void %[[VFUN_VALUE]](%struct.B* %[[VBASE]], i32 1)
+// CHECK: call x86_thiscallcc i8* %[[VFUN_VALUE]](%struct.B* %[[VBASE]], i32 1)
 // CHECK: ret void
 }
 
@@ -412,11 +407,11 @@
   // CHECK-LABEL: define void @"\01?destroy@test4@@YAXPAUC@1@@Z"(%"struct.test4::C"* %obj)
 
   delete obj;
-  // CHECK: %[[VPTR:.*]] = bitcast %"struct.test4::C"* %[[OBJ:.*]] to void (%"struct.test4::C"*, i32)***
-  // CHECK: %[[VFTABLE:.*]] = load void (%"struct.test4::C"*, i32)*** %[[VPTR]]
-  // CHECK: %[[VFTENTRY:.*]] = getelementptr inbounds void (%"struct.test4::C"*, i32)** %[[VFTABLE]], i64 0
-  // CHECK: %[[VFUN:.*]] = load void (%"struct.test4::C"*, i32)** %[[VFTENTRY]]
-  // CHECK: call x86_thiscallcc void %[[VFUN]](%"struct.test4::C"* %[[OBJ]], i32 1)
+  // CHECK: %[[VPTR:.*]] = bitcast %"struct.test4::C"* %[[OBJ:.*]] to i8* (%"struct.test4::C"*, i32)***
+  // CHECK: %[[VFTABLE:.*]] = load i8* (%"struct.test4::C"*, i32)*** %[[VPTR]]
+  // CHECK: %[[VFTENTRY:.*]] = getelementptr inbounds i8* (%"struct.test4::C"*, i32)** %[[VFTABLE]], i64 0
+  // CHECK: %[[VFUN:.*]] = load i8* (%"struct.test4::C"*, i32)** %[[VFTENTRY]]
+  // CHECK: call x86_thiscallcc i8* %[[VFUN]](%"struct.test4::C"* %[[OBJ]], i32 1)
   // CHECK: ret
 }
 
@@ -447,15 +442,15 @@
   // CHECK-NOT: getelementptr
   // CHECK: %[[OBJ_i8:.*]] = bitcast %"struct.test4::E"* %[[OBJ:.*]] to i8*
   // CHECK: %[[B_i8:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 4
-  // CHECK: %[[VPTR:.*]] = bitcast i8* %[[B_i8]] to void (%"struct.test4::E"*, i32)***
-  // CHECK: %[[VFTABLE:.*]] = load void (%"struct.test4::E"*, i32)*** %[[VPTR]]
-  // CHECK: %[[VFTENTRY:.*]] = getelementptr inbounds void (%"struct.test4::E"*, i32)** %[[VFTABLE]], i64 0
-  // CHECK: %[[VFUN:.*]] = load void (%"struct.test4::E"*, i32)** %[[VFTENTRY]]
+  // CHECK: %[[VPTR:.*]] = bitcast i8* %[[B_i8]] to i8* (%"struct.test4::E"*, i32)***
+  // CHECK: %[[VFTABLE:.*]] = load i8* (%"struct.test4::E"*, i32)*** %[[VPTR]]
+  // CHECK: %[[VFTENTRY:.*]] = getelementptr inbounds i8* (%"struct.test4::E"*, i32)** %[[VFTABLE]], i64 0
+  // CHECK: %[[VFUN:.*]] = load i8* (%"struct.test4::E"*, i32)** %[[VFTENTRY]]
   // CHECK: %[[OBJ_i8:.*]] = bitcast %"struct.test4::E"* %[[OBJ]] to i8*
   // CHECK: %[[B_i8:.*]] = getelementptr inbounds i8* %[[OBJ_i8]], i32 4
   // FIXME: in fact, the call should take i8* and the bitcast is redundant.
   // CHECK: %[[B_as_E:.*]] = bitcast i8* %[[B_i8]] to %"struct.test4::E"*
-  // CHECK: call x86_thiscallcc void %[[VFUN]](%"struct.test4::E"* %[[B_as_E]], i32 1)
+  // CHECK: call x86_thiscallcc i8* %[[VFUN]](%"struct.test4::E"* %[[B_as_E]], i32 1)
   delete obj;
 }
 
diff --git a/test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp b/test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp
index 974953c..b5db7c7 100644
--- a/test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp
+++ b/test/CodeGenCXX/microsoft-abi-virtual-member-pointers.cpp
@@ -45,92 +45,95 @@
 
 
 // CHECK32-LABEL: define void @"\01?f@@YAXXZ"()
-// CHECK32: store i8* bitcast (void (%struct.C*)* @"\01??_9C@@$BA@AE" to i8*), i8** %ptr
-// CHECK32: store i8* bitcast (i32 (%struct.C*, i32, double)* @"\01??_9C@@$B3AE" to i8*), i8** %ptr2
-// CHECK32: store i8* bitcast (void (%struct.C*, %struct.S*, i32)* @"\01??_9C@@$B7AE" to i8*), i8** %ptr3
-// CHECK32: store i8* bitcast (void (%"struct.(anonymous namespace)::D"*)* @"\01??_9D@?A@@$BA@AE" to i8*), i8** %ptr4
+// CHECK32: store i8* bitcast (void (%struct.C*, ...)* @"\01??_9C@@$BA@AE" to i8*), i8** %ptr
+// CHECK32: store i8* bitcast (void (%struct.C*, ...)* @"\01??_9C@@$B3AE" to i8*), i8** %ptr2
+// CHECK32: store i8* bitcast (void (%struct.C*, ...)* @"\01??_9C@@$B7AE" to i8*), i8** %ptr3
+// CHECK32: store i8* bitcast (void (%"struct.(anonymous namespace)::D"*, ...)* @"\01??_9D@?A@@$BA@AE" to i8*), i8** %ptr4
 // CHECK32: }
 //
 // CHECK64-LABEL: define void @"\01?f@@YAXXZ"()
-// CHECK64: store i8* bitcast (void (%struct.C*)* @"\01??_9C@@$BA@AA" to i8*), i8** %ptr
-// CHECK64: store i8* bitcast (i32 (%struct.C*, i32, double)* @"\01??_9C@@$B7AA" to i8*), i8** %ptr2
-// CHECK64: store i8* bitcast (void (%struct.C*, %struct.S*, i32)* @"\01??_9C@@$BBA@AA" to i8*), i8** %ptr3
-// CHECK64: store i8* bitcast (void (%"struct.(anonymous namespace)::D"*)* @"\01??_9D@?A@@$BA@AA" to i8*), i8** %ptr
+// CHECK64: store i8* bitcast (void (%struct.C*, ...)* @"\01??_9C@@$BA@AA" to i8*), i8** %ptr
+// CHECK64: store i8* bitcast (void (%struct.C*, ...)* @"\01??_9C@@$B7AA" to i8*), i8** %ptr2
+// CHECK64: store i8* bitcast (void (%struct.C*, ...)* @"\01??_9C@@$BBA@AA" to i8*), i8** %ptr3
+// CHECK64: store i8* bitcast (void (%"struct.(anonymous namespace)::D"*, ...)* @"\01??_9D@?A@@$BA@AA" to i8*), i8** %ptr
 // CHECK64: }
 }
 
 
 // Thunk for calling the 1st virtual function in C with no parameters.
-// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@@$BA@AE"(%struct.C* %this) unnamed_addr
-// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*)** %{{.*}}, i64 0
-// CHECK32: [[CALLEE:%.*]] = load void (%struct.C*)** [[VPTR]]
-// CHECK32: musttail call x86_thiscallcc void [[CALLEE]](%struct.C* %{{.*}})
-// CHECK32: ret void
+// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@@$BA@AE"(%struct.C* %this, ...)
+// CHECK32-NOT:             unnamed_addr
+// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 0
+// CHECK32: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK32: musttail call x86_thiscallcc void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK32-NEXT: ret void
 // CHECK32: }
 //
-// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$BA@AA"(%struct.C* %this) unnamed_addr
-// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*)** %{{.*}}, i64 0
-// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*)** [[VPTR]]
-// CHECK64: musttail call void [[CALLEE]](%struct.C* %{{.*}})
-// CHECK64: ret void
+// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$BA@AA"(%struct.C* %this, ...)
+// CHECK64-NOT:             unnamed_addr
+// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 0
+// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK64: musttail call void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK64-NEXT: ret void
 // CHECK64: }
 
 // Thunk for calling the 2nd virtual function in C, taking int and double as parameters, returning int.
-// CHECK32-LABEL: define linkonce_odr x86_thiscallcc i32 @"\01??_9C@@$B3AE"(%struct.C* %this, i32, double) unnamed_addr
-// CHECK32: [[VPTR:%.*]] = getelementptr inbounds i32 (%struct.C*, i32, double)** %{{.*}}, i64 1
-// CHECK32: [[CALLEE:%.*]] = load i32 (%struct.C*, i32, double)** [[VPTR]]
-// CHECK32: [[CALL:%.*]] = musttail call x86_thiscallcc i32 [[CALLEE]](%struct.C* %{{.*}}, i32 %{{.*}}, double %{{.*}})
-// CHECK32: ret i32 [[CALL]]
+// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@@$B3AE"(%struct.C* %this, ...)
+// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 1
+// CHECK32: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK32: musttail call x86_thiscallcc void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK32-NEXT: ret void
 // CHECK32: }
 //
-// CHECK64-LABEL: define linkonce_odr i32 @"\01??_9C@@$B7AA"(%struct.C* %this, i32, double) unnamed_addr
-// CHECK64: [[VPTR:%.*]] = getelementptr inbounds i32 (%struct.C*, i32, double)** %{{.*}}, i64 1
-// CHECK64: [[CALLEE:%.*]] = load i32 (%struct.C*, i32, double)** [[VPTR]]
-// CHECK64: [[CALL:%.*]] = musttail call i32 [[CALLEE]](%struct.C* %{{.*}}, i32 %{{.*}}, double %{{.*}})
-// CHECK64: ret i32 [[CALL]]
+// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$B7AA"(%struct.C* %this, ...)
+// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 1
+// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK64: musttail call void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK64-NEXT: ret void
 // CHECK64: }
 
 // Thunk for calling the 3rd virtual function in C, taking an int parameter, returning a struct.
-// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@@$B7AE"(%struct.C* %this, %struct.S* noalias sret %agg.result, i32) unnamed_addr
-// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, %struct.S*, i32)** %{{.*}}, i64 2
-// CHECK32: [[CALLEE:%.*]] = load void (%struct.C*, %struct.S*, i32)** [[VPTR]]
-// CHECK32: musttail call x86_thiscallcc void [[CALLEE]](%struct.C* %{{.*}}, %struct.S* sret %agg.result, i32 %{{.*}})
-// CHECK32: ret void
+// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@@$B7AE"(%struct.C* %this, ...)
+// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 2
+// CHECK32: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK32: musttail call x86_thiscallcc void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK32-NEXT: ret void
 // CHECK32: }
 //
-// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$BBA@AA"(%struct.C* %this, %struct.S* noalias sret %agg.result, i32) unnamed_addr
-// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, %struct.S*, i32)** %{{.*}}, i64 2
-// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*, %struct.S*, i32)** [[VPTR]]
-// CHECK64: musttail call void [[CALLEE]](%struct.C* %{{.*}}, %struct.S* sret %agg.result, i32 %{{.*}})
-// CHECK64: ret void
+// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$BBA@AA"(%struct.C* %this, ...)
+// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 2
+// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK64: musttail call void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK64-NEXT: ret void
 // CHECK64: }
 
 // Thunk for calling the virtual function in internal class D.
-// CHECK32-LABEL: define internal x86_thiscallcc void @"\01??_9D@?A@@$BA@AE"(%"struct.(anonymous namespace)::D"* %this) unnamed_addr
-// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%"struct.(anonymous namespace)::D"*)** %{{.*}}, i64 0
-// CHECK32: [[CALLEE:%.*]] = load void (%"struct.(anonymous namespace)::D"*)** [[VPTR]]
-// CHECK32: musttail call x86_thiscallcc void [[CALLEE]](%"struct.(anonymous namespace)::D"* %{{.*}})
-// CHECK32: ret void
+// CHECK32-LABEL: define internal x86_thiscallcc void @"\01??_9D@?A@@$BA@AE"(%"struct.(anonymous namespace)::D"* %this, ...)
+// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%"struct.(anonymous namespace)::D"*, ...)** %{{.*}}, i64 0
+// CHECK32: [[CALLEE:%.*]] = load void (%"struct.(anonymous namespace)::D"*, ...)** [[VPTR]]
+// CHECK32: musttail call x86_thiscallcc void (%"struct.(anonymous namespace)::D"*, ...)* [[CALLEE]](%"struct.(anonymous namespace)::D"* %{{.*}}, ...)
+// CHECK32-NEXT: ret void
 // CHECK32: }
 //
-// CHECK64-LABEL: define internal void @"\01??_9D@?A@@$BA@AA"(%"struct.(anonymous namespace)::D"* %this) unnamed_addr
-// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%"struct.(anonymous namespace)::D"*)** %{{.*}}, i64 0
-// CHECK64: [[CALLEE:%.*]] = load void (%"struct.(anonymous namespace)::D"*)** [[VPTR]]
-// CHECK64: musttail call void [[CALLEE]](%"struct.(anonymous namespace)::D"* %{{.*}})
-// CHECK64: ret void
+// CHECK64-LABEL: define internal void @"\01??_9D@?A@@$BA@AA"(%"struct.(anonymous namespace)::D"* %this, ...)
+// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%"struct.(anonymous namespace)::D"*, ...)** %{{.*}}, i64 0
+// CHECK64: [[CALLEE:%.*]] = load void (%"struct.(anonymous namespace)::D"*, ...)** [[VPTR]]
+// CHECK64: musttail call void (%"struct.(anonymous namespace)::D"*, ...)* [[CALLEE]](%"struct.(anonymous namespace)::D"* %{{.*}}, ...)
+// CHECK64-NEXT: ret void
 // CHECK64: }
 
-// Thunk for calling the fourth virtual function in C, taking a struct parameter and returning a struct.
-// CHECK32-LABEL: define linkonce_odr x86_thiscallcc %struct.S* @"\01??_9C@@$BM@AE"(%struct.C* %this, <{ %struct.S*, %struct.U }>* inalloca) unnamed_addr
-// CHECK32: [[VPTR:%.*]] = getelementptr inbounds %struct.S* (%struct.C*, <{ %struct.S*, %struct.U }>*)** %{{.*}}, i64 3
-// CHECK32: [[CALLEE:%.*]] = load %struct.S* (%struct.C*, <{ %struct.S*, %struct.U }>*)** [[VPTR]]
-// CHECK32: [[CALL:%.*]] = musttail call x86_thiscallcc %struct.S* [[CALLEE]](%struct.C* %this, <{ %struct.S*, %struct.U }>* inalloca %{{.*}})
-// CHECK32: ret %struct.S* [[CALL]]
+// Thunk for calling the fourth virtual function in C, taking a struct parameter
+// and returning a struct.
+// CHECK32-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@@$BM@AE"(%struct.C* %this, ...)
+// CHECK32: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 3
+// CHECK32: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK32: musttail call x86_thiscallcc void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
+// CHECK32-NEXT: ret void
 // CHECK32: }
 //
-// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$BBI@AA"(%struct.C* %this, %struct.S* noalias sret %agg.result, %struct.U*) unnamed_addr
-// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, %struct.S*, %struct.U*)** %{{.*}}, i64 3
-// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*, %struct.S*, %struct.U*)** [[VPTR]]
-// CHECK64: musttail call void [[CALLEE]](%struct.C* %this, %struct.S* sret %agg.result, %struct.U* %{{.*}})
+// CHECK64-LABEL: define linkonce_odr void @"\01??_9C@@$BBI@AA"(%struct.C* %this, ...)
+// CHECK64: [[VPTR:%.*]] = getelementptr inbounds void (%struct.C*, ...)** %{{.*}}, i64 3
+// CHECK64: [[CALLEE:%.*]] = load void (%struct.C*, ...)** [[VPTR]]
+// CHECK64: musttail call void (%struct.C*, ...)* [[CALLEE]](%struct.C* %{{.*}}, ...)
 // CHECK64: ret void
 // CHECK64: }
diff --git a/test/CodeGenCXX/microsoft-abi-vmemptr-conflicts.cpp b/test/CodeGenCXX/microsoft-abi-vmemptr-conflicts.cpp
new file mode 100644
index 0000000..35ff4f3
--- /dev/null
+++ b/test/CodeGenCXX/microsoft-abi-vmemptr-conflicts.cpp
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fno-rtti -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s
+
+// In each test case, we have two member pointers whose thunks have the same
+// vtable offset and same mangling, but their prototypes conflict.  The
+// arguments and return type may differ.  Therefore, we have to bitcast the
+// function prototype.  Unfortunately, if the return types differ, LLVM's
+// optimizers can get upset.
+
+namespace num_params {
+struct A { virtual void a(int); };
+struct B { virtual void b(int, int); };
+struct C : A, B {
+  virtual void a(int);
+  virtual void b(int, int);
+};
+void f(C *c) {
+  (c->*(&C::a))(0);
+  (c->*(&C::b))(0, 0);
+}
+}
+
+// CHECK-LABEL: define void @"\01?f@num_params@@YAXPAUC@1@@Z"(%"struct.num_params::C"* %c)
+// CHECK: call x86_thiscallcc void bitcast (void (%"struct.num_params::C"*, ...)* @"\01??_9C@num_params@@$BA@AE" to void (%"struct.num_params::C"*, i32)*)(%"struct.num_params::C"* %{{.*}}, i32 0)
+// CHECK: call x86_thiscallcc void bitcast (void (%"struct.num_params::C"*, ...)* @"\01??_9C@num_params@@$BA@AE" to void (%"struct.num_params::C"*, i32, i32)*)(%"struct.num_params::C"* %{{.*}}, i32 0, i32 0)
+
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@num_params@@$BA@AE"(%"struct.num_params::C"* %this, ...)
+// CHECK: musttail call x86_thiscallcc void (%"struct.num_params::C"*, ...)* %{{.*}}(%"struct.num_params::C"* %{{.*}}, ...)
+// CHECK-NEXT: ret void
+
+namespace i64_return {
+struct A { virtual int a(); };
+struct B { virtual long long b(); };
+struct C : A, B {
+  virtual int a();
+  virtual long long b();
+};
+long long f(C *c) {
+  int x = (c->*(&C::a))();
+  long long y = (c->*(&C::b))();
+  return x + y;
+}
+}
+
+// CHECK-LABEL: define i64 @"\01?f@i64_return@@YA_JPAUC@1@@Z"(%"struct.i64_return::C"* %c)
+// CHECK: call x86_thiscallcc i32 bitcast (void (%"struct.i64_return::C"*, ...)* @"\01??_9C@i64_return@@$BA@AE" to i32 (%"struct.i64_return::C"*)*)(%"struct.i64_return::C"* %{{.*}})
+// CHECK: call x86_thiscallcc i64 bitcast (void (%"struct.i64_return::C"*, ...)* @"\01??_9C@i64_return@@$BA@AE" to i64 (%"struct.i64_return::C"*)*)(%"struct.i64_return::C"* %{{.*}})
+
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@i64_return@@$BA@AE"(%"struct.i64_return::C"* %this, ...)
+// CHECK: musttail call x86_thiscallcc void (%"struct.i64_return::C"*, ...)* %{{.*}}(%"struct.i64_return::C"* %{{.*}}, ...)
+// CHECK-NEXT: ret void
+
+namespace sret {
+struct Big { int big[32]; };
+struct A { virtual int a(); };
+struct B { virtual Big b(); };
+struct C : A, B {
+  virtual int a();
+  virtual Big b();
+};
+void f(C *c) {
+  (c->*(&C::a))();
+  Big b((c->*(&C::b))());
+}
+}
+
+// CHECK-LABEL: define void @"\01?f@sret@@YAXPAUC@1@@Z"(%"struct.sret::C"* %c)
+// CHECK: call x86_thiscallcc i32 bitcast (void (%"struct.sret::C"*, ...)* @"\01??_9C@sret@@$BA@AE" to i32 (%"struct.sret::C"*)*)(%"struct.sret::C"* %{{.*}})
+// CHECK: call x86_thiscallcc void bitcast (void (%"struct.sret::C"*, ...)* @"\01??_9C@sret@@$BA@AE" to void (%"struct.sret::C"*, %"struct.sret::Big"*)*)(%"struct.sret::C"* %{{.*}}, %"struct.sret::Big"* sret %{{.*}})
+
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_9C@sret@@$BA@AE"(%"struct.sret::C"* %this, ...)
+// CHECK: musttail call x86_thiscallcc void (%"struct.sret::C"*, ...)* %{{.*}}(%"struct.sret::C"* %{{.*}}, ...)
+// CHECK-NEXT: ret void
+
+namespace cdecl_inalloca {
+// Fairly evil, since now we end up doing an inalloca-style call through a
+// thunk that doesn't use inalloca.  Hopefully the stacks line up?
+struct Big {
+  Big();
+  ~Big();
+  int big[32];
+};
+struct A { virtual void __cdecl a(); };
+struct B { virtual void __cdecl b(Big); };
+struct C : A, B {
+  virtual void __cdecl a();
+  virtual void __cdecl b(Big);
+};
+void f(C *c) {
+  Big b;
+  (c->*(&C::a))();
+  ((c->*(&C::b))(b));
+}
+}
+
+// CHECK-LABEL: define void @"\01?f@cdecl_inalloca@@YAXPAUC@1@@Z"(%"struct.cdecl_inalloca::C"* %c)
+// CHECK: call void bitcast (void (%"struct.cdecl_inalloca::C"*, ...)* @"\01??_9C@cdecl_inalloca@@$BA@AE" to void (%"struct.cdecl_inalloca::C"*)*)(%"struct.cdecl_inalloca::C"* %{{.*}})
+// CHECK: call void bitcast (void (%"struct.cdecl_inalloca::C"*, ...)* @"\01??_9C@cdecl_inalloca@@$BA@AE" to void (<{ %"struct.cdecl_inalloca::C"*, %"struct.cdecl_inalloca::Big" }>*)*)(<{ %"struct.cdecl_inalloca::C"*, %"struct.cdecl_inalloca::Big" }>* inalloca %{{.*}})
+
+// CHECK-LABEL: define linkonce_odr void @"\01??_9C@cdecl_inalloca@@$BA@AE"(%"struct.cdecl_inalloca::C"* %this, ...)
+// CHECK: musttail call void (%"struct.cdecl_inalloca::C"*, ...)* %{{.*}}(%"struct.cdecl_inalloca::C"* %{{.*}}, ...)
+// CHECK-NEXT: ret void
diff --git a/test/CodeGenCXX/microsoft-abi-vmemptr-fastcall.cpp b/test/CodeGenCXX/microsoft-abi-vmemptr-fastcall.cpp
new file mode 100644
index 0000000..6d42b85
--- /dev/null
+++ b/test/CodeGenCXX/microsoft-abi-vmemptr-fastcall.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fms-extensions -triple i686-pc-windows-msvc %s -emit-llvm-only -verify
+
+// We reject this because LLVM doesn't forward the second regparm through the
+// thunk.
+
+struct A {
+  virtual void __fastcall f(int a, int b); // expected-error {{cannot compile this pointer to fastcall virtual member function yet}}
+};
+void (__fastcall A::*doit())(int, int) {
+  return &A::f;
+}
diff --git a/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-return-adjustment.cpp b/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-return-adjustment.cpp
index 2d0bf63..232c0d9 100644
--- a/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-return-adjustment.cpp
+++ b/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-return-adjustment.cpp
@@ -295,3 +295,70 @@
 
 void build_vftable(X *obj) { obj->foo(); }
 }
+
+namespace test7 {
+struct A {
+  virtual A *f() = 0;
+};
+struct B {
+  virtual void g();
+};
+struct C : B, A {
+  virtual void g();
+  virtual C *f() = 0;
+  // CHECK-LABEL: VFTable for 'test7::B' in 'test7::C' (1 entry).
+  // CHECK-NEXT:   0 | void test7::C::g()
+
+  // CHECK-LABEL: VFTable for 'test7::A' in 'test7::C' (2 entries).
+  // CHECK-NEXT:   0 | test7::C *test7::C::f() [pure]
+  // CHECK-NEXT:   1 | test7::C *test7::C::f() [pure]
+
+  // No return adjusting thunks needed for pure virtual methods.
+  // CHECK-NOT: Thunks for 'test7::C *test7::C::f()'
+};
+
+void build_vftable(C *obj) { obj->g(); }
+}
+
+namespace pr20444 {
+struct A {
+  virtual A* f();
+};
+struct B {
+  virtual B* f();
+};
+struct C : A, B {
+  virtual C* f();
+  // CHECK-LABEL: VFTable for 'pr20444::A' in 'pr20444::C' (1 entry).
+  // CHECK-NEXT:   0 | pr20444::C *pr20444::C::f()
+
+  // CHECK-LABEL: VFTable for 'pr20444::B' in 'pr20444::C' (2 entries).
+  // CHECK-NEXT:   0 | pr20444::C *pr20444::C::f()
+  // CHECK-NEXT:       [return adjustment (to type 'struct pr20444::B *'): 4 non-virtual]
+  // CHECK-NEXT:       [this adjustment: -4 non-virtual]
+  // CHECK-NEXT:   1 | pr20444::C *pr20444::C::f()
+  // CHECK-NEXT:       [return adjustment (to type 'struct pr20444::C *'): 0 non-virtual]
+  // CHECK-NEXT:       [this adjustment: -4 non-virtual]
+};
+
+void build_vftable(C *obj) { obj->f(); }
+
+struct D : C {
+  virtual D* f();
+  // CHECK-LABEL: VFTable for 'pr20444::A' in 'pr20444::C' in 'pr20444::D' (1 entry).
+  // CHECK-NEXT:   0 | pr20444::D *pr20444::D::f()
+
+  // CHECK-LABEL: VFTable for 'pr20444::B' in 'pr20444::C' in 'pr20444::D' (3 entries).
+  // CHECK-NEXT:   0 | pr20444::D *pr20444::D::f()
+  // CHECK-NEXT:       [return adjustment (to type 'struct pr20444::B *'): 4 non-virtual]
+  // CHECK-NEXT:       [this adjustment: -4 non-virtual]
+  // CHECK-NEXT:   1 | pr20444::D *pr20444::D::f()
+  // CHECK-NEXT:       [return adjustment (to type 'struct pr20444::C *'): 0 non-virtual]
+  // CHECK-NEXT:       [this adjustment: -4 non-virtual]
+  // CHECK-NEXT:   2 | pr20444::D *pr20444::D::f()
+  // CHECK-NEXT:       [return adjustment (to type 'struct pr20444::D *'): 0 non-virtual]
+  // CHECK-NEXT:       [this adjustment: -4 non-virtual]
+};
+
+void build_vftable(D *obj) { obj->f(); }
+}
diff --git a/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp b/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp
index a4a2110..072cb95 100644
--- a/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp
+++ b/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp
@@ -104,3 +104,27 @@
 // GLOBALS-LABEL: @"\01??_7K@test2@@6B@" = linkonce_odr unnamed_addr constant [3 x i8*]
 
 }
+
+namespace pr20479 {
+struct A {
+  virtual A *f();
+};
+
+struct B : virtual A {
+  virtual B *f();
+};
+
+struct C : virtual A, B {
+// VFTABLES-LABEL: VFTable for 'pr20479::A' in 'pr20479::B' in 'pr20479::C' (2 entries).
+// VFTABLES-NEXT:   0 | pr20479::B *pr20479::B::f()
+// VFTABLES-NEXT:       [return adjustment (to type 'struct pr20479::A *'): vbase #1, 0 non-virtual]
+// VFTABLES-NEXT:   1 | pr20479::B *pr20479::B::f()
+  C();
+};
+
+C::C() {}
+
+// GLOBALS-LABEL: @"\01??_7C@pr20479@@6B@" = linkonce_odr unnamed_addr constant [2 x i8*]
+// GLOBALS: @"\01?f@B@pr20479@@QAEPAUA@2@XZ"
+// GLOBALS: @"\01?f@B@pr20479@@UAEPAU12@XZ"
+}
diff --git a/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp
index d453f5c..baed351 100644
--- a/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp
+++ b/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp
@@ -289,3 +289,13 @@
 
 R r;
 void use(R *obj) { obj->foo(42l); }
+
+struct S {
+  // CHECK-LABEL: VFTable for 'S' (1 entry).
+  // CHECK-NEXT:   0 | void S::f() [deleted]
+  virtual void f() = delete;
+  S();
+  // EMITS-VFTABLE-DAG: @"\01??_7S@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast (void ()* @_purecall to i8*)]
+};
+
+S::S() {}
diff --git a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
index f63808a..1f6d420 100644
--- a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
+++ b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
@@ -32,8 +32,8 @@
 void use_somewhere_else(void*);
 
 namespace simple {
-// In case of a single-layer virtual inheritance, the "this" adjustment is done
-// staically:
+// In case of a single-layer virtual inheritance, the "this" adjustment for a
+// virtual method is done staically:
 //   struct A {
 //     virtual void f();  // Expects "(A*)this" in ECX
 //   };
@@ -48,9 +48,9 @@
 // current class layout and the most derived class layout are different.
 // This is done using vtordisp thunks.
 //
-// A simple vtordisp{A,B} thunk for Method@Class is something like:
-//   sub  ecx, [ecx+A]  // apply the vtordisp adjustment
-//   sub  ecx, B        // apply the subobject adjustment, if needed.
+// A simple vtordisp{x,y} thunk for Method@Class is something like:
+//   sub  ecx, [ecx+x]  // apply the vtordisp adjustment
+//   sub  ecx, y        // apply the subobject adjustment, if needed.
 //   jmp Method@Class
 
 struct A : virtual V1 {
@@ -227,12 +227,12 @@
 // In this case, we should use the extended form of vtordisp thunks, called
 // vtordispex thunks.
 //
-// vtordispex{A,B,C,D} thunk for Method@Class is something like:
-//   sub  ecx, [ecx+C]  // apply the vtordisp adjustment
-//   sub  ecx, A        // jump to the vbtable of the most derived class
+// vtordispex{x,y,z,w} thunk for Method@Class is something like:
+//   sub  ecx, [ecx+z]  // apply the vtordisp adjustment
+//   sub  ecx, x        // jump to the vbptr of the most derived class
 //   mov  eax, [ecx]    // load the vbtable address
-//   add  ecx, [eax+B]  // lookup the final overrider's vbase offset
-//   add  ecx, D        // apphy the subobject offset if needed
+//   add  ecx, [eax+y]  // lookup the final overrider's vbase offset
+//   add  ecx, w        // apphy the subobject offset if needed
 //   jmp Method@Class
 
 struct A : virtual simple::A {
diff --git a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
index 4ce4e9c..65d6a9d 100644
--- a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
+++ b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fno-rtti -emit-llvm -o %t.ll -fdump-vtable-layouts %s -triple=i386-pc-win32 >%t
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -fno-rtti -emit-llvm -o %t.ll -fdump-vtable-layouts %s -triple=i386-pc-win32 >%t
 // RUN: FileCheck %s < %t
 // RUN: FileCheck --check-prefix=MANGLING %s < %t.ll
 
@@ -764,3 +764,46 @@
 
 W::W() {}
 }
+
+namespace Test13 {
+struct A {
+  virtual void f();
+};
+struct __declspec(dllexport) B : virtual A {
+  virtual void f() = 0;
+  // MANGLING-DAG: @"\01??_7B@Test13@@6B@" = weak_odr dllexport unnamed_addr constant [1 x i8*] [i8* bitcast (void ()* @_purecall to i8*)]
+};
+}
+
+namespace pr21031_1 {
+// This ordering of base specifiers regressed in r202425.
+struct A { virtual void f(void); };
+struct B : virtual A { virtual void g(void); };
+struct C : virtual A, B { C(); };
+C::C() {}
+
+// CHECK-LABEL: VFTable for 'pr21031_1::A' in 'pr21031_1::B' in 'pr21031_1::C' (1 entry)
+// CHECK-NEXT:   0 | void pr21031_1::A::f()
+
+// CHECK-LABEL: VFTable for 'pr21031_1::B' in 'pr21031_1::C' (1 entry)
+// CHECK-NEXT:   0 | void pr21031_1::B::g()
+
+// MANGLING-DAG: @"\01??_7C@pr21031_1@@6BB@1@@" = {{.*}} constant [1 x i8*]
+// MANGLING-DAG: @"\01??_7C@pr21031_1@@6B@" = {{.*}} constant [1 x i8*]
+}
+
+namespace pr21031_2 {
+struct A { virtual void f(void); };
+struct B : virtual A { virtual void g(void); };
+struct C : B, virtual A { C(); };
+C::C() {}
+
+// CHECK-LABEL: VFTable for 'pr21031_2::B' in 'pr21031_2::C' (1 entry)
+// CHECK-NEXT:   0 | void pr21031_2::B::g()
+
+// CHECK-LABEL: VFTable for 'pr21031_2::A' in 'pr21031_2::B' in 'pr21031_2::C' (1 entry)
+// CHECK-NEXT:   0 | void pr21031_2::A::f()
+
+// MANGLING-DAG: @"\01??_7C@pr21031_2@@6BA@1@@" = {{.*}} constant [1 x i8*]
+// MANGLING-DAG: @"\01??_7C@pr21031_2@@6BB@1@@" = {{.*}} constant [1 x i8*]
+}
diff --git a/test/CodeGenCXX/microsoft-no-rtti-data.cpp b/test/CodeGenCXX/microsoft-no-rtti-data.cpp
index d4002c2..fded4c9 100644
--- a/test/CodeGenCXX/microsoft-no-rtti-data.cpp
+++ b/test/CodeGenCXX/microsoft-no-rtti-data.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -fno-rtti-data -triple=i386-pc-win32 -o - -emit-llvm | FileCheck %s
 
 // vftable shouldn't have RTTI data in it.
+// CHECK-NOT: @"\01??_R4S@@6B@"
 // CHECK: @"\01??_7S@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GS@@UAEPAXI@Z" to i8*)]
 
 struct type_info;
diff --git a/test/CodeGenCXX/microsoft-templ-uuidof.cpp b/test/CodeGenCXX/microsoft-templ-uuidof.cpp
new file mode 100644
index 0000000..0ee3908
--- /dev/null
+++ b/test/CodeGenCXX/microsoft-templ-uuidof.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -DDEFINE_GUID -triple=i386-pc-win32 -fms-extensions | FileCheck %s --check-prefix=CHECK
+
+struct _GUID;
+
+template <typename>
+struct X {
+};
+
+struct __declspec(uuid("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}")) A {};
+
+struct B {};
+
+template <>
+struct __declspec(uuid("{BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB}")) X<B> {};
+
+struct __declspec(uuid("{CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC}")) C {};
+
+const _GUID &xa = __uuidof(X<A>);
+// CHECK-DAG:  @"\01?xa@@3ABU_GUID@@B" = {{.*}} @_GUID_aaaaaaaa_aaaa_aaaa_aaaa_aaaaaaaaaaaa
+
+const _GUID &xb = __uuidof(X<B>);
+// CHECK-DAG:  @"\01?xb@@3ABU_GUID@@B" = {{.*}} @_GUID_bbbbbbbb_bbbb_bbbb_bbbb_bbbbbbbbbbbb
+const _GUID &xc = __uuidof(X<C>);
+// CHECK-DAG:  @"\01?xc@@3ABU_GUID@@B" = {{.*}} @_GUID_cccccccc_cccc_cccc_cccc_cccccccccccc
+
+template <>
+struct __declspec(uuid("{DDDDDDDD-DDDD-DDDD-DDDD-DDDDDDDDDDDD}")) X<C> {};
+
+template <typename>
+struct __declspec(uuid("{EEEEEEEE-EEEE-EEEE-EEEE-EEEEEEEEEEEE}")) Y {
+};
+
+const _GUID &xd = __uuidof(X<C>);
+// CHECK-DAG:  @"\01?xd@@3ABU_GUID@@B" = {{.*}} @_GUID_dddddddd_dddd_dddd_dddd_dddddddddddd
+
+const _GUID &yd = __uuidof(Y<X<C> >);
+// CHECK-DAG:  @"\01?yd@@3ABU_GUID@@B" = {{.*}} @_GUID_dddddddd_dddd_dddd_dddd_dddddddddddd
diff --git a/test/CodeGenCXX/microsoft-uuidof-mangling.cpp b/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
new file mode 100644
index 0000000..9019aa8
--- /dev/null
+++ b/test/CodeGenCXX/microsoft-uuidof-mangling.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-unknown-unknown -fms-extensions | FileCheck %s
+// rdar://17784718
+
+typedef struct _GUID
+{
+    unsigned int  Data1;
+    unsigned short Data2;
+    unsigned short Data3;
+    unsigned char  Data4[ 8 ];
+} GUID;
+
+
+template < typename T, const GUID & T_iid = __uuidof(T)>
+class UUIDTest
+{
+public:
+	UUIDTest() { }
+};
+
+struct __declspec(uuid("EAFA1952-66F8-438B-8FBA-AF1BBAE42191")) TestStruct
+{
+	int foo;
+};
+
+template <class T> void test_uuidofType(void *arg[sizeof(__uuidof(T))] = 0) {}
+
+template <class T> void test_uuidofExpr(void *arg[sizeof(__uuidof(T::member))] = 0) {}
+
+struct HasMember { typedef TestStruct member; };
+
+int main(int argc, const char * argv[])
+{
+
+    UUIDTest<TestStruct> uuidof_test;
+    test_uuidofType<TestStruct>();
+    test_uuidofExpr<HasMember>();
+    return 0;
+}
+
+// CHECK: define i32 @main
+// CHECK: call void @_ZN8UUIDTestI10TestStructXu8__uuidoftS0_EEC1Ev
+// CHECK: call void @_Z15test_uuidofTypeI10TestStructEvPPv(i8** null)
+// CHECK: call void @_Z15test_uuidofExprI9HasMemberEvPPv(i8** null)
+
+// CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructXu8__uuidoftS0_EEC1Ev
+// CHECK: define linkonce_odr void @_Z15test_uuidofTypeI10TestStructEvPPv
+// CHECK: define linkonce_odr void @_Z15test_uuidofExprI9HasMemberEvPPv
+// CHECK: define linkonce_odr void @_ZN8UUIDTestI10TestStructXu8__uuidoftS0_EEC2Ev
diff --git a/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp b/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
new file mode 100644
index 0000000..bacddb2
--- /dev/null
+++ b/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
+
+extern "C" void foo();
+extern "C" void bar();
+
+struct Cleanup {
+  ~Cleanup() {
+    bar();
+  }
+};
+
+extern "C" void test() {
+  Cleanup x;
+  foo();
+}
+
+// X64: define void @test()
+// X64: invoke void @foo()
+// X64: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_seh0 to i8*)
+
+// X86: define void @test()
+// X86: invoke void @foo()
+// X86: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
diff --git a/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp b/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
index 92e704a..869fded 100644
--- a/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
+++ b/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
@@ -10,13 +10,13 @@
   return rv;
 }
 // O32-LABEL: define i32* @_Z10alloc_longv()
-// O32: call noalias i8* @_Znwj(i32 4)
+// O32: call noalias i8* @_Znwj(i32 zeroext 4)
 
 // N32-LABEL: define i32* @_Z10alloc_longv()
-// N32: call noalias i8* @_Znwj(i32 4)
+// N32: call noalias i8* @_Znwj(i32 zeroext 4)
 
 // N64-LABEL: define i64* @_Z10alloc_longv()
-// N64: call noalias i8* @_Znwm(i64 8)
+// N64: call noalias i8* @_Znwm(i64 zeroext 8)
 
 long *alloc_long_array() {
   long *rv = new long[2];
@@ -24,13 +24,13 @@
 }
 
 // O32-LABEL: define i32* @_Z16alloc_long_arrayv()
-// O32: call noalias i8* @_Znaj(i32 8)
+// O32: call noalias i8* @_Znaj(i32 zeroext 8)
 
 // N32-LABEL: define i32* @_Z16alloc_long_arrayv()
-// N32: call noalias i8* @_Znaj(i32 8)
+// N32: call noalias i8* @_Znaj(i32 zeroext 8)
 
 // N64-LABEL: define i64* @_Z16alloc_long_arrayv()
-// N64: call noalias i8* @_Znam(i64 16)
+// N64: call noalias i8* @_Znam(i64 zeroext 16)
 
 #include <stddef.h>
 
diff --git a/test/CodeGenCXX/ms-inline-asm-return.cpp b/test/CodeGenCXX/ms-inline-asm-return.cpp
new file mode 100644
index 0000000..26fc426
--- /dev/null
+++ b/test/CodeGenCXX/ms-inline-asm-return.cpp
@@ -0,0 +1,100 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks | FileCheck %s
+
+// Check that we take EAX or EAX:EDX and return it from these functions for MSVC
+// compatibility.
+
+extern "C" {
+
+long long f_i64() {
+  __asm {
+    mov eax, 1
+    mov edx, 1
+  }
+}
+// CHECK-LABEL: define i64 @f_i64()
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}"
+// CHECK: ret i64 %[[r]]
+
+int f_i32() {
+  __asm {
+    mov eax, 1
+    mov edx, 1
+  }
+}
+// CHECK-LABEL: define i32 @f_i32()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: ret i32 %[[r]]
+
+short f_i16() {
+  __asm {
+    mov eax, 1
+    mov edx, 1
+  }
+}
+// CHECK-LABEL: define signext i16 @f_i16()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16
+// CHECK: ret i16 %[[r_i16]]
+
+char f_i8() {
+  __asm {
+    mov eax, 1
+    mov edx, 1
+  }
+}
+// CHECK-LABEL: define signext i8 @f_i8()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
+// CHECK: ret i8 %[[r_i8]]
+
+bool f_i1() {
+  __asm {
+    mov eax, 1
+    mov edx, 1
+  }
+}
+// CHECK-LABEL: define zeroext i1 @f_i1()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}"
+// CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8
+// CHECK: store i8 %[[r_i8]], i8* %{{.*}}
+// CHECK: %[[r_i1:[^ ]*]] = load i1* %{{.*}}
+// CHECK: ret i1 %[[r_i1]]
+
+struct FourChars {
+  char a, b, c, d;
+};
+FourChars f_s4() {
+  __asm {
+    mov eax, 0x01010101
+  }
+}
+// CHECK-LABEL: define i32 @f_s4()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$0x01010101", "={eax},~{eax},{{.*}}"
+// CHECK: store i32 %[[r]], i32* %{{.*}}
+// CHECK: %[[r_i32:[^ ]*]] = load i32* %{{.*}}
+// CHECK: ret i32 %[[r_i32]]
+
+struct EightChars {
+  char a, b, c, d, e, f, g, h;
+};
+EightChars f_s8() {
+  __asm {
+    mov eax, 0x01010101
+    mov edx, 0x01010101
+  }
+}
+// CHECK-LABEL: define i64 @f_s8()
+// CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$0x01010101\0A\09mov edx, $$0x01010101", "=A,~{eax},{{.*}}"
+// CHECK: store i64 %[[r]], i64* %{{.*}}
+// CHECK: %[[r_i64:[^ ]*]] = load i64* %{{.*}}
+// CHECK: ret i64 %[[r_i64]]
+
+} // extern "C"
+
+int main() {
+  __asm xor eax, eax
+}
+// CHECK-LABEL: define i32 @main()
+// CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}"
+// CHECK: ret i32 %[[r]]
diff --git a/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp b/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
new file mode 100644
index 0000000..3f868f3
--- /dev/null
+++ b/test/CodeGenCXX/ms-integer-static-data-members-exported.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
+
+enum Enum { zero, one, two };
+
+struct __declspec(dllexport) S {
+  // In MS compatibility mode, this counts as a definition.
+  // Since it is exported, it must be emitted even if it's unreferenced.
+  static const short x = 42;
+
+  // This works for enums too.
+  static const Enum y = two;
+
+  struct NonExported {
+    // dllexport is not inherited by this nested class.
+    // Since z is not referenced, it should not be emitted.
+    static const int z = 42;
+  };
+};
+
+// CHECK: @"\01?x@S@@2FB" = weak_odr dllexport constant i16 42, align 2
+// CHECK: @"\01?y@S@@2W4Enum@@B" = weak_odr dllexport constant i32 2, align 4
+// CHECK-NOT: NonExported
diff --git a/test/CodeGenCXX/ms-integer-static-data-members.cpp b/test/CodeGenCXX/ms-integer-static-data-members.cpp
index 5505db1..b02b679 100644
--- a/test/CodeGenCXX/ms-integer-static-data-members.cpp
+++ b/test/CodeGenCXX/ms-integer-static-data-members.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s
-// RUN: %clang_cc1 -DINLINE_INIT -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s --check-prefix=CHECK-INLINE
-// RUN: %clang_cc1 -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s --check-prefix=CHECK-OUTOFLINE
-// RUN: %clang_cc1 -DINLINE_INIT -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s --check-prefix=CHECK-INLINE
+// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DINLINE_INIT -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s --check-prefix=CHECK-INLINE
+// RUN: %clang_cc1 -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s --check-prefix=CHECK-OUTOFLINE
+// RUN: %clang_cc1 -DINLINE_INIT -DREAL_DEFINITION -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s --check-prefix=CHECK-INLINE
 
 struct S {
   // For MS ABI, we emit a linkonce_odr definition here, even though it's really just a declaration.
diff --git a/test/CodeGenCXX/ms-thread_local.cpp b/test/CodeGenCXX/ms-thread_local.cpp
new file mode 100644
index 0000000..de72ea9
--- /dev/null
+++ b/test/CodeGenCXX/ms-thread_local.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -emit-llvm -o - | FileCheck %s
+
+struct A {
+  A();
+  ~A();
+};
+
+// CHECK-DAG: $"\01??$a@X@@3UA@@A" = comdat any
+// CHECK-DAG: @"\01??$a@X@@3UA@@A" = linkonce_odr thread_local global %struct.A zeroinitializer, comdat $"\01??$a@X@@3UA@@A"
+// CHECK-DAG: @"\01??__E?$a@X@@YAXXZ$initializer$" = internal constant void ()* @"\01??__E?$a@X@@YAXXZ", section ".CRT$XDU", comdat $"\01??$a@X@@3UA@@A"
+template <typename T>
+thread_local A a = A();
+
+// CHECK-DAG: @"\01?b@@3UA@@A" = thread_local global %struct.A zeroinitializer, align 1
+// CHECK-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+thread_local A b;
+
+// CHECK-LABEL: define internal void @__tls_init()
+// CHECK: call void @"\01??__Eb@@YAXXZ"
+
+thread_local A &c = b;
+thread_local A &d = c;
+
+A f() {
+  (void)a<void>;
+  (void)b;
+  return c;
+}
diff --git a/test/CodeGenCXX/nrvo.cpp b/test/CodeGenCXX/nrvo.cpp
index 2bbf277..aad287d 100644
--- a/test/CodeGenCXX/nrvo.cpp
+++ b/test/CodeGenCXX/nrvo.cpp
@@ -169,7 +169,7 @@
   return a;
   // CHECK:      [[A:%.*]] = alloca [[X:%.*]], align 8
   // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev([[X]]* [[A]])
-  // CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_([[X]]* {{%.*}}, [[X]]* nonnull [[A]])
+  // CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_([[X]]* {{%.*}}, [[X]]* dereferenceable({{[0-9]+}}) [[A]])
   // CHECK-NEXT: call {{.*}} @_ZN1XD1Ev([[X]]* [[A]])
   // CHECK-NEXT: ret void
 }
diff --git a/test/CodeGenCXX/pod-member-memcpys.cpp b/test/CodeGenCXX/pod-member-memcpys.cpp
index 396129e..a3ee990 100644
--- a/test/CodeGenCXX/pod-member-memcpys.cpp
+++ b/test/CodeGenCXX/pod-member-memcpys.cpp
@@ -67,6 +67,13 @@
   NonPOD np;
 };
 
+struct BitfieldMember3 {
+  virtual void f();
+  int   : 8;
+  int x : 1;
+  int y;
+};
+
 struct InnerClassMember {
   struct {
     int a, b, c, d;
@@ -108,59 +115,59 @@
 CALL_AO(PackedMembers)
 
 // Basic copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.Basic* @_ZN5BasicaSERKS_(%struct.Basic* %this, %struct.Basic* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.Basic* @_ZN5BasicaSERKS_(%struct.Basic* %this, %struct.Basic* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret %struct.Basic*
 
 // PODMember copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.PODMember* @_ZN9PODMemberaSERKS_(%struct.PODMember* %this, %struct.PODMember* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.PODMember* @_ZN9PODMemberaSERKS_(%struct.PODMember* %this, %struct.PODMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 32, i32 4{{.*}})
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret %struct.PODMember*
 
 // PODLikeMember copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.PODLikeMember* @_ZN13PODLikeMemberaSERKS_(%struct.PODLikeMember* %this, %struct.PODLikeMember* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.PODLikeMember* @_ZN13PODLikeMemberaSERKS_(%struct.PODLikeMember* %this, %struct.PODLikeMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 32, i32 4{{.*}})
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret %struct.PODLikeMember*
 
 // ArrayMember copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.ArrayMember* @_ZN11ArrayMemberaSERKS_(%struct.ArrayMember* %this, %struct.ArrayMember* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.ArrayMember* @_ZN11ArrayMemberaSERKS_(%struct.ArrayMember* %this, %struct.ArrayMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 64, i32 4{{.*}})
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 64, i32 4{{.*}})
 // CHECK: ret %struct.ArrayMember*
 
 // VolatileMember copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.VolatileMember* @_ZN14VolatileMemberaSERKS_(%struct.VolatileMember* %this, %struct.VolatileMember* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.VolatileMember* @_ZN14VolatileMemberaSERKS_(%struct.VolatileMember* %this, %struct.VolatileMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: load volatile i32* {{.*}}, align 4
 // CHECK: store volatile i32 {{.*}}, align 4
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret %struct.VolatileMember*
 
 // BitfieldMember copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.BitfieldMember* @_ZN14BitfieldMemberaSERKS_(%struct.BitfieldMember* %this, %struct.BitfieldMember* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.BitfieldMember* @_ZN14BitfieldMemberaSERKS_(%struct.BitfieldMember* %this, %struct.BitfieldMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 3, i32 1{{.*}})
 // CHECK: ret %struct.BitfieldMember*
 
 // InnerClass copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.InnerClassMember* @_ZN16InnerClassMemberaSERKS_(%struct.InnerClassMember* %this, %struct.InnerClassMember* nonnull)
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.InnerClassMember* @_ZN16InnerClassMemberaSERKS_(%struct.InnerClassMember* %this, %struct.InnerClassMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 32, i32 4{{.*}})
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret %struct.InnerClassMember*
 
 // PackedMembers copy-assignment:
-// CHECK-LABEL: define linkonce_odr nonnull %struct.PackedMembers* @_ZN13PackedMembersaSERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* nonnull)
-// CHECK: call nonnull %struct.NonPOD* @_ZN6NonPODaSERKS_
+// CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.PackedMembers* @_ZN13PackedMembersaSERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* dereferenceable({{[0-9]+}}))
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 1{{.*}})
 // CHECK: ret %struct.PackedMembers*
 
@@ -174,6 +181,7 @@
 
 CALL_CC(PackedMembers)
 CALL_CC(BitfieldMember2)
+CALL_CC(BitfieldMember3)
 CALL_CC(ReferenceMember)
 CALL_CC(InnerClassMember)
 CALL_CC(BitfieldMember)
@@ -184,21 +192,21 @@
 CALL_CC(Basic)
 
 // Basic copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN5BasicC2ERKS_(%struct.Basic* %this, %struct.Basic* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN5BasicC2ERKS_(%struct.Basic* %this, %struct.Basic* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret void
 
 // PODMember copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN9PODMemberC2ERKS_(%struct.PODMember* %this, %struct.PODMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN9PODMemberC2ERKS_(%struct.PODMember* %this, %struct.PODMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 32, i32 4{{.*}})
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret void
 
 // PODLikeMember copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN13PODLikeMemberC2ERKS_(%struct.PODLikeMember* %this, %struct.PODLikeMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN13PODLikeMemberC2ERKS_(%struct.PODLikeMember* %this, %struct.PODLikeMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 32, i32 4{{.*}})
 // CHECK: invoke void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
@@ -207,14 +215,14 @@
 // CHECK: invoke void @_ZN7PODLikeD1Ev
 
 // ArrayMember copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN11ArrayMemberC2ERKS_(%struct.ArrayMember* %this, %struct.ArrayMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN11ArrayMemberC2ERKS_(%struct.ArrayMember* %this, %struct.ArrayMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 64, i32 4{{.*}})
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 64, i32 4{{.*}})
 // CHECK: ret void
 
 // VolatileMember copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN14VolatileMemberC2ERKS_(%struct.VolatileMember* %this, %struct.VolatileMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN14VolatileMemberC2ERKS_(%struct.VolatileMember* %this, %struct.VolatileMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: load volatile i32* {{.*}}, align 4
 // CHECK: store volatile i32 {{.*}}, align 4
@@ -223,34 +231,39 @@
 // CHECK: ret void
 
 // BitfieldMember copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN14BitfieldMemberC2ERKS_(%struct.BitfieldMember* %this, %struct.BitfieldMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN14BitfieldMemberC2ERKS_(%struct.BitfieldMember* %this, %struct.BitfieldMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 3, i32 1{{.*}})
 // CHECK: ret void
 
 // InnerClass copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN16InnerClassMemberC2ERKS_(%struct.InnerClassMember* %this, %struct.InnerClassMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN16InnerClassMemberC2ERKS_(%struct.InnerClassMember* %this, %struct.InnerClassMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 32, i32 4{{.*}})
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret void
 
 // ReferenceMember copy-constructor:
-// CHECK-LABEL: define linkonce_odr void @_ZN15ReferenceMemberC2ERKS_(%struct.ReferenceMember* %this, %struct.ReferenceMember* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN15ReferenceMemberC2ERKS_(%struct.ReferenceMember* %this, %struct.ReferenceMember* dereferenceable({{[0-9]+}}))
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 8{{.*}})
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 8{{.*}})
 // CHECK: ret void
 
+// BitfieldMember3 copy-constructor:
+// CHECK-LABEL: define linkonce_odr void @_ZN15BitfieldMember3C2ERKS_(%struct.BitfieldMember3* %this, %struct.BitfieldMember3* dereferenceable({{[0-9]+}}))
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 8, i32 8, i1 false)
+// CHECK: ret void
+
 // BitfieldMember2 copy-constructor:
-// CHECK-2-LABEL: define linkonce_odr void @_ZN15BitfieldMember2C2ERKS_(%struct.BitfieldMember2* %this, %struct.BitfieldMember2* nonnull)
+// CHECK-2-LABEL: define linkonce_odr void @_ZN15BitfieldMember2C2ERKS_(%struct.BitfieldMember2* %this, %struct.BitfieldMember2* dereferenceable({{[0-9]+}}))
 // CHECK-2: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4, i1 false)
 // CHECK-2: call void @_ZN6NonPODC1ERKS_
 // CHECK-2: ret void
 
 // PackedMembers copy-assignment:
-// CHECK-LABEL: define linkonce_odr void @_ZN13PackedMembersC2ERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* nonnull)
+// CHECK-LABEL: define linkonce_odr void @_ZN13PackedMembersC2ERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* dereferenceable({{[0-9]+}}))
 // CHECK: call void @_ZN6NonPODC1ERKS_
 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 1{{.*}})
 // CHECK: ret void
diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp
index 866fba2..0b99fea 100644
--- a/test/CodeGenCXX/pointers-to-data-members.cpp
+++ b/test/CodeGenCXX/pointers-to-data-members.cpp
@@ -55,7 +55,7 @@
   };
 
   struct C : A, B { int j; };
-  // CHECK-GLOBAL: @_ZN8ZeroInit1cE = global {{%.*}} { %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::B" { [10 x %"struct.ZeroInit::A"] [%"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }], i8 0, i64 -1 }, i32 0 }, align 8
+  // CHECK-GLOBAL: @_ZN8ZeroInit1cE = global {{%.*}} <{ %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::B" { [10 x %"struct.ZeroInit::A"] [%"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }], i8 0, i64 -1 }, i32 0, [4 x i8] zeroinitializer }>, align 8
   C c;
 }
 
@@ -202,7 +202,7 @@
     bool member;
   };
 
-  // CHECK-LABEL: define nonnull i8* @_ZN15BoolPtrToMember1fERNS_1XEMS0_b
+  // CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_ZN15BoolPtrToMember1fERNS_1XEMS0_b
   bool &f(X &x, bool X::*member) {
     // CHECK: {{bitcast.* to i8\*}}
     // CHECK-NEXT: getelementptr inbounds i8*
@@ -255,4 +255,26 @@
   // CHECK: call void @_ZN7PR130971XC1ERKS0_
 }
 
+namespace PR21089 {
+struct A {
+  bool : 1;
+  int A::*x;
+  bool y;
+  A();
+};
+struct B : A {
+};
+B b;
+// CHECK-GLOBAL: @_ZN7PR210891bE = global %"struct.PR21089::B" { %"struct.PR21089::A.base" <{ i8 0, [7 x i8] zeroinitializer, i64 -1, i8 0 }>, [7 x i8] zeroinitializer }, align 8
+}
+
+namespace PR21282 {
+union U {
+  int U::*x;
+  long y[2];
+};
+U u;
+// CHECK-GLOBAL: @_ZN7PR212821uE = global %"union.PR21282::U" { i64 -1, [8 x i8] zeroinitializer }, align 8
+}
+
 // CHECK-O3: attributes [[NUW]] = { nounwind readnone{{.*}} }
diff --git a/test/CodeGenCXX/pr12251.cpp b/test/CodeGenCXX/pr12251.cpp
index bb1c82d..21dadf5 100644
--- a/test/CodeGenCXX/pr12251.cpp
+++ b/test/CodeGenCXX/pr12251.cpp
@@ -18,14 +18,14 @@
   return *x;
 }
 // CHECK-LABEL: define i32 @_Z2g1P2e1
-// CHECK: load i32* %x, align 4, !range [[RANGE_i32_0_1:![^ ]*]]
+// CHECK: ret i32 0
 
 enum e2 { e2_a = 0 };
 e2 g2(e2 *x) {
   return *x;
 }
 // CHECK-LABEL: define i32 @_Z2g2P2e2
-// CHECK: load i32* %x, align 4, !range [[RANGE_i32_0_1]]
+// CHECK: ret i32 0
 
 enum e3 { e3_a = 16 };
 e3 g3(e3 *x) {
@@ -137,7 +137,6 @@
 
 
 // CHECK: [[RANGE_i8_0_2]] = metadata !{i8 0, i8 2}
-// CHECK: [[RANGE_i32_0_1]] = metadata !{i32 0, i32 1}
 // CHECK: [[RANGE_i32_0_32]] = metadata !{i32 0, i32 32}
 // CHECK: [[RANGE_i32_m16_16]] = metadata !{i32 -16, i32 16}
 // CHECK: [[RANGE_i32_m32_32]] = metadata !{i32 -32, i32 32}
diff --git a/test/CodeGenCXX/pr18635.cpp b/test/CodeGenCXX/pr18635.cpp
new file mode 100644
index 0000000..94b5e45
--- /dev/null
+++ b/test/CodeGenCXX/pr18635.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -triple x86_64-pc-linux-gnu -o- %s | FileCheck %s
+
+// Global @x:
+// CHECK: [[X_GLOBAL:@[^ ]+]]{{.*}}thread_local global
+
+// returned somewhere in TLS wrapper:
+// CHECK: ret{{.*}}[[X_GLOBAL]]
+
+template <typename T> class unique_ptr {
+  template <typename F, typename S> struct pair {
+    F first;
+    S second;
+  };
+  pair<T *, int> data;
+public:
+  constexpr unique_ptr() noexcept : data() {}
+  explicit unique_ptr(T *p) noexcept : data() {}
+};
+
+thread_local unique_ptr<int> x;
+int main() { x = unique_ptr<int>(new int(5)); }
+
diff --git a/test/CodeGenCXX/pr18962.cpp b/test/CodeGenCXX/pr18962.cpp
index ab537b4..9e6ef16 100644
--- a/test/CodeGenCXX/pr18962.cpp
+++ b/test/CodeGenCXX/pr18962.cpp
@@ -26,7 +26,7 @@
 
 // We end up using an opaque type for 'append' to avoid circular references.
 // CHECK: %class.A = type { {}* }
-// CHECK: %class.C = type { %class.D*, %class.B }
+// CHECK: %class.C = type <{ %class.D*, %class.B, [3 x i8] }>
 // CHECK: %class.D = type { %class.C.base, [3 x i8] }
 // CHECK: %class.C.base = type <{ %class.D*, %class.B }>
 // CHECK: %class.B = type { i8 }
diff --git a/test/CodeGenCXX/pr20719.cpp b/test/CodeGenCXX/pr20719.cpp
new file mode 100644
index 0000000..208d111
--- /dev/null
+++ b/test/CodeGenCXX/pr20719.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++11 -o - %s | FileCheck %s
+
+// Make sure that we emit H's constructor twice: once with the first lambda
+// inside of 'lep' and again with the second lambda inside of 'lep'.
+// CHECK-DAG: @"\01??0?$H@V<lambda_1>@??$lep@X@@YAXXZ@@@QAE@XZ"
+// CHECK-DAG: @"\01??0?$H@V<lambda_2>@??$lep@X@@YAXXZ@@@QAE@XZ"
+
+template <typename>
+struct H {
+  H() {}
+};
+
+template <typename Fx>
+int K_void(const Fx &) {
+  H<Fx> callee;
+  return 0;
+}
+template <typename Fx>
+int K_int(const Fx &) {
+  H<Fx> callee;
+  return 0;
+}
+
+struct pair {
+  pair(int, int);
+};
+
+struct E1;
+
+template <typename>
+void lep() {
+  pair x(K_void([] {}), K_int([] {}));
+}
+
+auto z = lep<void>;
diff --git a/test/CodeGenCXX/pr20897.cpp b/test/CodeGenCXX/pr20897.cpp
new file mode 100644
index 0000000..49d669b
--- /dev/null
+++ b/test/CodeGenCXX/pr20897.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y -O0 -o - %s | FileCheck %s
+struct Base {};
+
+// __declspec(dllexport) causes us to export the implicit constructor.
+struct __declspec(dllexport) Derived : virtual Base {
+// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc %struct.Derived* @"\01??0Derived@@QAE@ABU0@@Z"
+// CHECK:      %[[this:.*]] = load %struct.Derived** {{.*}}
+// CHECK-NEXT: store %struct.Derived* %[[this]], %struct.Derived** %[[retval:.*]]
+// CHECK:      %[[dest_a_gep:.*]] = getelementptr inbounds %struct.Derived* %[[this]], i32 0, i32 1
+// CHECK-NEXT: %[[src_load:.*]]   = load %struct.Derived** {{.*}}
+// CHECK-NEXT: %[[src_a_gep:.*]]  = getelementptr inbounds %struct.Derived* %[[src_load:.*]], i32 0, i32 1
+// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %[[dest_a_gep]], i8* %[[src_a_gep]], i64 1, i32 4, i1 false)
+// CHECK-NEXT: %[[dest_this:.*]] = load %struct.Derived** %[[retval]]
+// CHECK-NEXT: ret %struct.Derived* %[[dest_this]]
+  bool a : 1;
+  bool b : 1;
+};
+
+// __declspec(dllexport) causes us to export the implicit copy constructor.
+struct __declspec(dllexport) Derived2 : virtual Base {
+// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc %struct.Derived2* @"\01??0Derived2@@QAE@ABU0@@Z"
+// CHECK:      %[[this:.*]] = load %struct.Derived2** {{.*}}
+// CHECK-NEXT: store %struct.Derived2* %[[this]], %struct.Derived2** %[[retval:.*]]
+// CHECK:      %[[dest_a_gep:.*]] = getelementptr inbounds %struct.Derived2* %[[this]], i32 0, i32 1
+// CHECK-NEXT: %[[src_load:.*]]   = load %struct.Derived2** {{.*}}
+// CHECK-NEXT: %[[src_a_gep:.*]]  = getelementptr inbounds %struct.Derived2* %[[src_load:.*]], i32 0, i32 1
+// CHECK-NEXT: %[[dest_a_bitcast:.*]]  = bitcast [1 x i32]* %[[dest_a_gep]] to i8*
+// CHECK-NEXT: %[[src_a_bitcast:.*]] = bitcast [1 x i32]* %[[src_a_gep]] to i8*
+// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[dest_a_bitcast]], i8* %[[src_a_bitcast]], i32 4, i32 4, i1 false)
+// CHECK-NEXT: %[[dest_this:.*]] = load %struct.Derived2** %[[retval]]
+// CHECK-NEXT: ret %struct.Derived2* %[[dest_this]]
+  int Array[1];
+};
diff --git a/test/CodeGenCXX/pragma-init_seg.cpp b/test/CodeGenCXX/pragma-init_seg.cpp
index 7356c52..3f9ff21 100644
--- a/test/CodeGenCXX/pragma-init_seg.cpp
+++ b/test/CodeGenCXX/pragma-init_seg.cpp
@@ -1,16 +1,72 @@
-// RUN: not %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm-only 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s
 
-// Reduced from WebKit.
+int f();
 
-// FIXME: Implement this pragma and test the codegen.  We probably want to
-// completely skip @llvm.global_ctors and just create global function pointers
-// to the initializer with the right section.
+// CHECK: $"\01?x@selectany_init@@3HA" = comdat any
+// CHECK: $"\01?x@?$A@H@explicit_template_instantiation@@2HB" = comdat any
+// CHECK: $"\01?x@?$A@H@implicit_template_instantiation@@2HB" = comdat any
 
-// CHECK: '#pragma init_seg' not implemented
-#pragma init_seg(".unwantedstaticinits")
-struct A {
-  A();
-  ~A();
-  int a;
-};
-A a;
+namespace simple_init {
+#pragma init_seg(compiler)
+int x = f();
+// CHECK: @"\01?x@simple_init@@3HA" = global i32 0, align 4
+// CHECK: @__cxx_init_fn_ptr = private constant void ()* @"\01??__Ex@simple_init@@YAXXZ", section ".CRT$XCC"
+
+#pragma init_seg(lib)
+int y = f();
+// CHECK: @"\01?y@simple_init@@3HA" = global i32 0, align 4
+// CHECK: @__cxx_init_fn_ptr1 = private constant void ()* @"\01??__Ey@simple_init@@YAXXZ", section ".CRT$XCL"
+
+#pragma init_seg(user)
+int z = f();
+// CHECK: @"\01?z@simple_init@@3HA" = global i32 0, align 4
+// No function pointer!  This one goes on @llvm.global_ctors.
+}
+
+#pragma init_seg(".asdf")
+
+namespace internal_init {
+namespace {
+int x = f();
+// CHECK: @"\01?x@?A@internal_init@@3HA" = internal global i32 0, align 4
+// CHECK: @__cxx_init_fn_ptr2 = private constant void ()* @"\01??__Ex@?A@internal_init@@YAXXZ", section ".asdf"
+}
+}
+
+namespace selectany_init {
+int __declspec(selectany) x = f();
+// CHECK: @"\01?x@selectany_init@@3HA" = weak_odr global i32 0, comdat $"\01?x@selectany_init@@3HA", align 4
+// CHECK: @__cxx_init_fn_ptr3 = private constant void ()* @"\01??__Ex@selectany_init@@YAXXZ", section ".asdf", comdat $"\01?x@selectany_init@@3HA"
+}
+
+namespace explicit_template_instantiation {
+template <typename T> struct A { static const int x; };
+template <typename T> const int A<T>::x = f();
+template struct A<int>;
+// CHECK: @"\01?x@?$A@H@explicit_template_instantiation@@2HB" = weak_odr global i32 0, comdat $"\01?x@?$A@H@explicit_template_instantiation@@2HB", align 4
+// CHECK: @__cxx_init_fn_ptr4 = private constant void ()* @"\01??__Ex@?$A@H@explicit_template_instantiation@@2HB@YAXXZ", section ".asdf", comdat $"\01?x@?$A@H@explicit_template_instantiation@@2HB"
+}
+
+namespace implicit_template_instantiation {
+template <typename T> struct A { static const int x; };
+template <typename T> const int A<T>::x = f();
+int g() { return A<int>::x; }
+// CHECK: @"\01?x@?$A@H@implicit_template_instantiation@@2HB" = linkonce_odr global i32 0, comdat $"\01?x@?$A@H@implicit_template_instantiation@@2HB", align 4
+// CHECK: @__cxx_init_fn_ptr5 = private constant void ()* @"\01??__Ex@?$A@H@implicit_template_instantiation@@2HB@YAXXZ", section ".asdf", comdat $"\01?x@?$A@H@implicit_template_instantiation@@2HB"
+}
+
+// ... and here's where we emitted user level ctors.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }]
+// CHECK: [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_pragma_init_seg.cpp, i8* null }]
+
+// We have to mark everything used so we can survive globalopt, even through
+// LTO.  There's no way LLVM could really understand if data in the .asdf
+// section is really used or dead.
+//
+// CHECK: @llvm.used = appending global [6 x i8*]
+// CHECK: [i8* bitcast (void ()** @__cxx_init_fn_ptr to i8*),
+// CHECK: i8* bitcast (void ()** @__cxx_init_fn_ptr1 to i8*),
+// CHECK: i8* bitcast (void ()** @__cxx_init_fn_ptr2 to i8*),
+// CHECK: i8* bitcast (void ()** @__cxx_init_fn_ptr3 to i8*),
+// CHECK: i8* bitcast (void ()** @__cxx_init_fn_ptr4 to i8*),
+// CHECK: i8* bitcast (void ()** @__cxx_init_fn_ptr5 to i8*)], section "llvm.metadata"
diff --git a/test/CodeGenCXX/predefined-expr-cxx14.cpp b/test/CodeGenCXX/predefined-expr-cxx14.cpp
new file mode 100644
index 0000000..1f03575
--- /dev/null
+++ b/test/CodeGenCXX/predefined-expr-cxx14.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple %itanium_abi_triple -fblocks -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++14 -triple %itanium_abi_triple -fblocks -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -std=c++14 -fblocks -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: @__func__._ZN13ClassTemplateIiE21classTemplateFunctionERi = private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
+// CHECK-DAG: @__PRETTY_FUNCTION__._ZN13ClassTemplateIiE21classTemplateFunctionERi = private unnamed_addr constant [69 x i8] c"const auto &ClassTemplate<int>::classTemplateFunction(T &) [T = int]\00"
+
+// CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace16functionTemplateIiEERDaRT_ = private unnamed_addr constant [17 x i8] c"functionTemplate\00"
+// CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace16functionTemplateIiEERDaRT_ = private unnamed_addr constant [64 x i8] c"auto &ClassInTopLevelNamespace::functionTemplate(T &) [T = int]\00"
+
+// CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace16variadicFunctionEPiz = private unnamed_addr constant [17 x i8] c"variadicFunction\00"
+// CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace16variadicFunctionEPiz = private unnamed_addr constant [70 x i8] c"decltype(auto) ClassInTopLevelNamespace::variadicFunction(int *, ...)\00"
+
+// CHECK-DAG: @__func__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
+// CHECK-DAG: @__PRETTY_FUNCTION__._ZN24ClassInTopLevelNamespace25topLevelNamespaceFunctionEv = private unnamed_addr constant [60 x i8] c"auto *ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
+
+// CHECK-DAG: @__func__.___ZN16ClassBlockConstrD2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrD2Ev_block_invoke\00"
+// CHECK-DAG: @__func__.___ZN16ClassBlockConstrC2Ev_block_invoke = private unnamed_addr constant [41 x i8] c"___ZN16ClassBlockConstrC2Ev_block_invoke\00"
+
+int printf(const char * _Format, ...);
+
+class ClassInTopLevelNamespace {
+public:
+  auto *topLevelNamespaceFunction() {
+    printf("__func__ %s\n", __func__);
+    printf("__FUNCTION__ %s\n", __FUNCTION__);
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+    return static_cast<int *>(nullptr);
+  }
+
+  decltype(auto) variadicFunction(int *a, ...) {
+    printf("__func__ %s\n", __func__);
+    printf("__FUNCTION__ %s\n", __FUNCTION__);
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+    return a;
+  }
+
+  template<typename T>
+  auto &functionTemplate(T &t) {
+    printf("__func__ %s\n", __func__);
+    printf("__FUNCTION__ %s\n", __FUNCTION__);
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+    return t;
+  }
+};
+
+template<typename T>
+class ClassTemplate {
+public:
+  const auto &classTemplateFunction(T &t) {
+    printf("__func__ %s\n", __func__);
+    printf("__FUNCTION__ %s\n", __FUNCTION__);
+    printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+    return t;
+  }
+};
+
+struct ClassBlockConstr {
+  const char *s;
+  ClassBlockConstr() {
+    const char * (^b)() = ^() {
+    return __func__;
+    };
+    s = b();
+  }
+  ~ClassBlockConstr() {
+    const char * (^b)() = ^() {
+    return __func__;
+    };
+    s = b();
+  }
+};
+
+template <class T>
+class FuncTemplate {
+  const char *Func;
+
+public:
+  FuncTemplate() : Func(__func__) {}
+  const char *getFunc() const { return Func; }
+};
+
+int
+main() {
+  int a;
+  ClassInTopLevelNamespace topLevelNamespace;
+  ClassBlockConstr classBlockConstr;
+  topLevelNamespace.topLevelNamespaceFunction();
+  topLevelNamespace.variadicFunction(&a);
+  topLevelNamespace.functionTemplate(a);
+
+  ClassTemplate<int> t;
+  t.classTemplateFunction(a);
+  return 0;
+}
+#else
+void Foo() {
+  FuncTemplate<int> FTi;
+  (void)FTi.getFunc();
+}
+#endif
+
diff --git a/test/CodeGenCXX/reference-cast.cpp b/test/CodeGenCXX/reference-cast.cpp
index 0596ceb..c4be5b7 100644
--- a/test/CodeGenCXX/reference-cast.cpp
+++ b/test/CodeGenCXX/reference-cast.cpp
@@ -3,7 +3,7 @@
 // PR6024
 extern int i;
 
-// CHECK: define nonnull i32* @_Z16lvalue_noop_castv() [[NUW:#[0-9]+]]
+// CHECK: define dereferenceable({{[0-9]+}}) i32* @_Z16lvalue_noop_castv() [[NUW:#[0-9]+]]
 const int &lvalue_noop_cast() {
   if (i == 0)
     // CHECK: store i32 17, i32*
@@ -15,7 +15,7 @@
   return 17;
 }
 
-// CHECK-LABEL: define nonnull i16* @_Z20lvalue_integral_castv() 
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i16* @_Z20lvalue_integral_castv() 
 const short &lvalue_integral_cast() {
   if (i == 0)
     // CHECK: store i16 17, i16*
@@ -27,7 +27,7 @@
   return 17;
 }
 
-// CHECK-LABEL: define nonnull i16* @_Z29lvalue_floating_integral_castv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i16* @_Z29lvalue_floating_integral_castv()
 const short &lvalue_floating_integral_cast() {
   if (i == 0)
     // CHECK: store i16 17, i16*
@@ -39,7 +39,7 @@
   return 17.5;
 }
 
-// CHECK-LABEL: define nonnull float* @_Z29lvalue_integral_floating_castv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) float* @_Z29lvalue_integral_floating_castv()
 const float &lvalue_integral_floating_cast() {
   if (i == 0)
     // CHECK: store float 1.700000e+{{0*}}1, float*
@@ -51,7 +51,7 @@
   return 17;
 }
 
-// CHECK-LABEL: define nonnull float* @_Z20lvalue_floating_castv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) float* @_Z20lvalue_floating_castv()
 const float &lvalue_floating_cast() {
   if (i == 0)
     // CHECK: store float 1.700000e+{{0*}}1, float*
@@ -65,7 +65,7 @@
 
 int get_int();
 
-// CHECK-LABEL: define nonnull i8* @_Z24lvalue_integer_bool_castv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z24lvalue_integer_bool_castv()
 const bool &lvalue_integer_bool_cast() {
   if (i == 0)
     // CHECK: call i32 @_Z7get_intv()
@@ -82,7 +82,7 @@
 
 float get_float();
 
-// CHECK-LABEL: define nonnull i8* @_Z25lvalue_floating_bool_castv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z25lvalue_floating_bool_castv()
 const bool &lvalue_floating_bool_cast() {
   if (i == 0)
     // CHECK: call float @_Z9get_floatv()
@@ -107,7 +107,7 @@
 pm get_pointer_to_member_data();
 pmf get_pointer_to_member_function();
 
-// CHECK-LABEL: define nonnull i8* @_Z26lvalue_ptrmem_to_bool_castv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z26lvalue_ptrmem_to_bool_castv()
 const bool &lvalue_ptrmem_to_bool_cast() {
   if (i == 0)
     // CHECK: call i64 @_Z26get_pointer_to_member_datav()
@@ -125,7 +125,7 @@
   return get_pointer_to_member_data();
 }
 
-// CHECK-LABEL: define nonnull i8* @_Z27lvalue_ptrmem_to_bool_cast2v
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i8* @_Z27lvalue_ptrmem_to_bool_cast2v
 const bool &lvalue_ptrmem_to_bool_cast2() {
   if (i == 0)
     // CHECK: {{call.*_Z30get_pointer_to_member_functionv}}
diff --git a/test/CodeGenCXX/rvalue-references.cpp b/test/CodeGenCXX/rvalue-references.cpp
index 6c723b8..66705bf 100644
--- a/test/CodeGenCXX/rvalue-references.cpp
+++ b/test/CodeGenCXX/rvalue-references.cpp
@@ -7,8 +7,8 @@
 
 B &getB();
 
-// CHECK-LABEL: define nonnull %struct.A* @_Z4getAv()
-// CHECK: call nonnull %struct.B* @_Z4getBv()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) %struct.A* @_Z4getAv()
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.B* @_Z4getBv()
 // CHECK-NEXT: bitcast %struct.B*
 // CHECK-NEXT: getelementptr inbounds i8*
 // CHECK-NEXT: bitcast i8* {{.*}} to %struct.A*
@@ -19,17 +19,17 @@
 int &&getIntXValue();
 int getIntPRValue();
 
-// CHECK-LABEL: define nonnull i32* @_Z2f0v()
-// CHECK: call nonnull i32* @_Z12getIntLValuev()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i32* @_Z2f0v()
+// CHECK: call dereferenceable({{[0-9]+}}) i32* @_Z12getIntLValuev()
 // CHECK-NEXT: ret i32*
 int &&f0() { return static_cast<int&&>(getIntLValue()); }
 
-// CHECK-LABEL: define nonnull i32* @_Z2f1v()
-// CHECK: call nonnull i32* @_Z12getIntXValuev()
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i32* @_Z2f1v()
+// CHECK: call dereferenceable({{[0-9]+}}) i32* @_Z12getIntXValuev()
 // CHECK-NEXT: ret i32*
 int &&f1() { return static_cast<int&&>(getIntXValue()); }
 
-// CHECK-LABEL: define nonnull i32* @_Z2f2v
+// CHECK-LABEL: define dereferenceable({{[0-9]+}}) i32* @_Z2f2v
 // CHECK: call i32 @_Z13getIntPRValuev()
 // CHECK-NEXT: store i32 {{.*}}, i32*
 // CHECK-NEXT: ret i32*
@@ -95,7 +95,7 @@
   };
 
   // CHECK-LABEL:    define void @_ZN5test11BC2Ei(
-  // CHECK:      [[T0:%.*]] = call nonnull i32* @_ZN5test14moveERi(
+  // CHECK:      [[T0:%.*]] = call dereferenceable({{[0-9]+}}) i32* @_ZN5test14moveERi(
   // CHECK-NEXT: [[T1:%.*]] = load i32* [[T0]]
   // CHECK-NEXT: call void @_ZN5test11AC1Ei({{.*}}, i32 [[T1]])
   // CHECK-NEXT: ret void
diff --git a/test/CodeGenCXX/sections.cpp b/test/CodeGenCXX/sections.cpp
new file mode 100644
index 0000000..f84f9d9
--- /dev/null
+++ b/test/CodeGenCXX/sections.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s
+
+extern "C" {
+
+#pragma const_seg(".my_const")
+#pragma bss_seg(".my_bss")
+int D = 1;
+#pragma data_seg(".data")
+int a = 1;
+#pragma data_seg(push, label, ".data2")
+extern const int b;
+const int b = 1;
+const char* s = "my string!";
+#pragma data_seg(push, ".my_seg")
+int c = 1;
+#pragma data_seg(pop, label)
+int d = 1;
+int e;
+#pragma bss_seg(".c")
+int f;
+void g(void){}
+#pragma code_seg(".my_code")
+void h(void){}
+#pragma bss_seg()
+int i;
+#pragma bss_seg(".bss1")
+#pragma bss_seg(push, test, ".bss2")
+#pragma bss_seg()
+#pragma bss_seg()
+int TEST1;
+#pragma bss_seg(pop)
+int TEST2;
+
+#pragma section("read_flag_section", read)
+// Even though they are not declared const, these become constant since they are
+// in a read-only section.
+__declspec(allocate("read_flag_section")) int unreferenced = 0;
+extern __declspec(allocate("read_flag_section")) int referenced = 42;
+int *user() { return &referenced; }
+
+#pragma section("no_section_attributes")
+// A pragma section with no section attributes is read/write.
+__declspec(allocate("no_section_attributes")) int implicitly_read_write = 42;
+
+#pragma section("long_section", long)
+// Pragma section ignores "long".
+__declspec(allocate("long_section")) long long_var = 42;
+
+#pragma section("short_section", short)
+// Pragma section ignores "short".
+__declspec(allocate("short_section")) short short_var = 42;
+}
+
+//CHECK: @D = global i32 1
+//CHECK: @a = global i32 1, section ".data"
+//CHECK: @b = constant i32 1, section ".my_const"
+//CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my string!\00"
+//CHECK: @s = global i8* getelementptr inbounds ([11 x i8]* @[[MYSTR]], i32 0, i32 0), section ".data2"
+//CHECK: @c = global i32 1, section ".my_seg"
+//CHECK: @d = global i32 1, section ".data"
+//CHECK: @e = global i32 0, section ".my_bss"
+//CHECK: @f = global i32 0, section ".c"
+//CHECK: @i = global i32 0
+//CHECK: @TEST1 = global i32 0
+//CHECK: @TEST2 = global i32 0, section ".bss1"
+//CHECK: @unreferenced = constant i32 0, section "read_flag_section"
+//CHECK: @referenced = constant i32 42, section "read_flag_section"
+//CHECK: @implicitly_read_write = global i32 42, section "no_section_attributes"
+//CHECK: @long_var = global i32 42, section "long_section"
+//CHECK: @short_var = global i16 42, section "short_section"
+//CHECK: define void @g()
+//CHECK: define void @h() {{.*}} section ".my_code"
diff --git a/test/CodeGenCXX/static-data-member.cpp b/test/CodeGenCXX/static-data-member.cpp
index eea9794..5ec3755 100644
--- a/test/CodeGenCXX/static-data-member.cpp
+++ b/test/CodeGenCXX/static-data-member.cpp
@@ -1,9 +1,13 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=MACHO %s
 
 // CHECK: @_ZN5test11A1aE = constant i32 10, align 4
 // CHECK: @_ZN5test212_GLOBAL__N_11AIiE1xE = internal global i32 0, align 4
-// CHECK: @_ZN5test31AIiE1xE = weak_odr global i32 0, align 4
-// CHECK: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
+// CHECK: @_ZN5test31AIiE1xE = weak_odr global i32 0, comdat $_ZN5test31AIiE1xE, align 4
+// CHECK: @_ZGVN5test31AIiE1xE = weak_odr global i64 0, comdat $_ZN5test31AIiE1xE
+// MACHO: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
+// MACHO-NOT: comdat
 
 // CHECK: _ZN5test51U2k0E = global i32 0
 // CHECK: _ZN5test51U2k1E = global i32 0
@@ -60,7 +64,9 @@
   template <class T> int A<T>::x = foo();
   template struct A<int>;
 
-  // CHECK-LABEL: define internal void @__cxx_global_var_init1()
+  // CHECK-LABEL: define internal void @__cxx_global_var_init1() {{.*}} comdat $_ZN5test31AIiE1xE
+  // MACHO-LABEL: define internal void @__cxx_global_var_init1()
+  // MACHO-NOT: comdat
   // CHECK:      [[GUARDBYTE:%.*]] = load i8* bitcast (i64* @_ZGVN5test31AIiE1xE to i8*)
   // CHECK-NEXT: [[UNINITIALIZED:%.*]] = icmp eq i8 [[GUARDBYTE]], 0
   // CHECK-NEXT: br i1 [[UNINITIALIZED]]
diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp
index d23ead4..a9debe3 100644
--- a/test/CodeGenCXX/static-init.cpp
+++ b/test/CodeGenCXX/static-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -o - | FileCheck %s
 
 // CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
 // CHECK: @base_req = global [4 x i8] c"foo\00", align 1
@@ -6,8 +6,11 @@
 
 // CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
 // CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
+
 // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
+// CHECK-NOT: comdat
 // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0
+// CHECK-NOT: comdat
 
 struct A {
   A();
@@ -34,6 +37,8 @@
   static const int i = a();
 }
 
+// CHECK: define linkonce_odr void @_Z2h2v()
+// CHECK-NOT: comdat
 inline void h2() {
   static int i = a();
 }
diff --git a/test/CodeGenCXX/static-local-in-local-class.cpp b/test/CodeGenCXX/static-local-in-local-class.cpp
index ebf560a..729b937 100644
--- a/test/CodeGenCXX/static-local-in-local-class.cpp
+++ b/test/CodeGenCXX/static-local-in-local-class.cpp
@@ -1,6 +1,13 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
-// PR6769
+// RUN: %clang_cc1 -triple x86_64-linux -fblocks -emit-llvm -o - %s -std=c++1y | FileCheck %s
 
+// CHECK: @"_ZZNK3$_2clEvE1x" = internal global i32 42
+// CHECK: @_ZZ18static_local_labelPvE1q = linkonce_odr global i8* blockaddress(@_Z18static_local_labelPv, %{{.*}})
+// CHECK: @_ZZZL20block_deduced_returnvEUb_E1n = internal global i32 42
+// CHECK: @_ZZL14deduced_returnvE1n = internal global i32 42
+// CHECK: @"_ZZZNK17pr18020_constexpr3$_1clEvENKUlvE_clEvE2l2" =
+// CHECK: internal global i32* @"_ZZNK17pr18020_constexpr3$_1clEvE2l1"
+
+namespace pr6769 {
 struct X {
   static void f();
 };
@@ -19,8 +26,9 @@
   }
   (void)i;
 }
+}
 
-// pr7101
+namespace pr7101 {
 void foo() {
     static int n = 0;
     struct Helper {
@@ -30,4 +38,123 @@
     };
     Helper::Execute();
 }
+}
 
+// These tests all break the assumption that the static var decl has to be
+// emitted before use of the var decl.  This happens because we defer emission
+// of variables with internal linkage and no initialization side effects, such
+// as 'x'.  Then we hit operator()() in 'f', and emit the callee before we emit
+// the arguments, so we emit the innermost function first.
+
+namespace pr18020_lambda {
+// Referring to l1 before emitting it used to crash.
+auto x = []() {
+  static int l1 = 0;
+  return [] { return l1; };
+};
+int f() { return x()(); }
+}
+
+// CHECK-LABEL: define internal i32 @"_ZZNK14pr18020_lambda3$_0clEvENKUlvE_clEv"
+// CHECK: load i32* @"_ZZNK14pr18020_lambda3$_0clEvE2l1"
+
+namespace pr18020_constexpr {
+// Taking the address of l1 in a constant expression used to crash.
+auto x = []() {
+  static int l1 = 0;
+  return [] {
+    static int *l2 = &l1;
+    return *l2;
+  };
+};
+int f() { return x()(); }
+}
+
+// CHECK-LABEL: define internal i32 @"_ZZNK17pr18020_constexpr3$_1clEvENKUlvE_clEv"
+// CHECK: load i32** @"_ZZZNK17pr18020_constexpr3$_1clEvENKUlvE_clEvE2l2"
+
+// Lambda-less reduction that references l1 before emitting it.  This didn't
+// crash if you put it in a namespace.
+struct pr18020_class {
+  auto operator()() {
+    static int l1 = 0;
+    struct U {
+      int operator()() { return l1; }
+    };
+    return U();
+  }
+};
+static pr18020_class x;
+int pr18020_f() { return x()(); }
+
+// CHECK-LABEL: define linkonce_odr i32 @_ZZN13pr18020_classclEvEN1UclEv
+// CHECK: load i32* @_ZZN13pr18020_classclEvE2l1
+
+// In this test case, the function containing the static local will not be
+// emitted because it is unneeded. However, the operator call of the inner class
+// is called, and the static local is referenced and must be emitted.
+static auto deduced_return() {
+  static int n = 42;
+  struct S { int *operator()() { return &n; } };
+  return S();
+}
+extern "C" int call_deduced_return_operator() {
+  return *decltype(deduced_return())()();
+}
+
+// CHECK-LABEL: define i32 @call_deduced_return_operator()
+// CHECK: call i32* @_ZZL14deduced_returnvEN1SclEv(
+// CHECK: load i32* %
+// CHECK: ret i32 %
+
+// CHECK-LABEL: define internal i32* @_ZZL14deduced_returnvEN1SclEv(%struct.S* %this)
+// CHECK: ret i32* @_ZZL14deduced_returnvE1n
+
+static auto block_deduced_return() {
+  auto (^b)() = ^() {
+    static int n = 42;
+    struct S { int *operator()() { return &n; } };
+    return S();
+  };
+  return b();
+}
+extern "C" int call_block_deduced_return() {
+  return *decltype(block_deduced_return())()();
+}
+
+// CHECK-LABEL: define i32 @call_block_deduced_return()
+// CHECK: call i32* @_ZZZL20block_deduced_returnvEUb_EN1SclEv(
+// CHECK: load i32* %
+// CHECK: ret i32 %
+
+// CHECK-LABEL: define internal i32* @_ZZZL20block_deduced_returnvEUb_EN1SclEv(%struct.S.6* %this) #0 align 2 {
+// CHECK: ret i32* @_ZZZL20block_deduced_returnvEUb_E1n
+
+inline auto static_local_label(void *p) {
+  if (p)
+    goto *p;
+  static void *q = &&label;
+  struct S { static void *get() { return q; } };
+  return S();
+label:
+  __builtin_abort();
+}
+void *global_label = decltype(static_local_label(0))::get();
+
+// CHECK-LABEL: define linkonce_odr i8* @_ZZ18static_local_labelPvEN1S3getEv()
+// CHECK: %[[lbl:[^ ]*]] = load i8** @_ZZ18static_local_labelPvE1q
+// CHECK: ret i8* %[[lbl]]
+
+auto global_lambda = []() {
+  static int x = 42;
+  struct S { static int *get() { return &x; } };
+  return S();
+};
+extern "C" int use_global_lambda() {
+  return *decltype(global_lambda())::get();
+}
+// CHECK-LABEL: define i32 @use_global_lambda()
+// CHECK: call i32* @"_ZZNK3$_2clEvEN1S3getEv"()
+
+// CHECK-LABEL: define internal i32* @"_ZZNK3$_2clEvEN1S3getEv"()
+// CHECK: ret i32* @"_ZZNK3$_2clEvE1x"
diff --git a/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp b/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
index 98c09b8..430fa2b 100644
--- a/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
+++ b/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
@@ -1,25 +1,42 @@
-// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
-// CHECK: ; ModuleID
+// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=ELF --check-prefix=ALL %s
+// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck --check-prefix=MACHO --check-prefix=ALL %s
+
+// ALL: ; ModuleID
 
 extern "C" int foo();
 
 template<typename T> struct A { static int a; };
 template<typename T> int A<T>::a = foo();
 
-// CHECK-NOT: @_ZN1AIcE1aE
+// ALLK-NOT: @_ZN1AIcE1aE
 template<> int A<char>::a;
 
-// CHECK: @_ZN1AIbE1aE = global i32 10
+// ALL: @_ZN1AIbE1aE = global i32 10
 template<> int A<bool>::a = 10;
 
-// CHECK: @llvm.global_ctors = appending global [7 x { i32, void ()*, i8* }]
-// CHECK: [{ i32, void ()*, i8* } { i32 65535, void ()* @[[unordered1:[^,]*]], i8* bitcast (i32* @_ZN1AIsE1aE to i8*) },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered2:[^,]*]], i8* bitcast (i16* @_Z1xIsE to i8*) },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered3:[^,]*]], i8* bitcast (i32* @_ZN2ns1aIiE1iE to i8*) },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered4:[^,]*]], i8* bitcast (i32* @_ZN2ns1b1iIiEE to i8*) },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered5:[^,]*]], i8* bitcast (i32* @_ZN1AIvE1aE to i8*) },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered6:[^,]*]], i8* @_Z1xIcE },
-// CHECK:  { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp, i8* null }]
+// ALL: @llvm.global_ctors = appending global [8 x { i32, void ()*, i8* }]
+
+// ELF: [{ i32, void ()*, i8* } { i32 65535, void ()* @[[unordered1:[^,]*]], i8* bitcast (i32* @_ZN1AIsE1aE to i8*) },
+// MACHO: [{ i32, void ()*, i8* } { i32 65535, void ()* @[[unordered1:[^,]*]], i8* null },
+
+// ELF:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered2:[^,]*]], i8* bitcast (i16* @_Z1xIsE to i8*) },
+// MACHO:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered2:[^,]*]], i8* null },
+
+// ELF:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered3:[^,]*]], i8* bitcast (i32* @_ZN2ns1aIiE1iE to i8*) },
+// MACHO:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered3:[^,]*]], i8* null },
+
+// ELF:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered4:[^,]*]], i8* bitcast (i32* @_ZN2ns1b1iIiEE to i8*) },
+// MACHO:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered4:[^,]*]], i8* null },
+
+// ELF:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered5:[^,]*]], i8* bitcast (i32* @_ZN1AIvE1aE to i8*) },
+// MACHO:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered5:[^,]*]], i8* null },
+
+// ELF:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered6:[^,]*]], i8* @_Z1xIcE },
+// MACHO:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered6:[^,]*]], i8* null },
+
+// ALL:  { i32, void ()*, i8* } { i32 65535, void ()* @[[unordered7:[^,]*]], i8* null },
+
+// ALL:  { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp, i8* null }]
 
 template int A<short>::a;  // Unordered
 int b = foo();
@@ -52,45 +69,57 @@
 template<typename T> T b::i = foo();
 template int b::i<int>;
 }
-// CHECK: define internal void @[[unordered1]]
-// CHECK: call i32 @foo()
-// CHECK: store {{.*}} @_ZN1AIsE1aE
-// CHECK: ret
 
-// CHECK: define internal void @[[unordered2]]
-// CHECK: call i32 @foo()
-// CHECK: store {{.*}} @_Z1xIsE
-// CHECK: ret
+namespace {
+template<typename T> struct Internal { static int a; };
+template<typename T> int Internal<T>::a = foo();
+}
+int *use_internal_a = &Internal<int>::a;
 
-// CHECK: define internal void @[[unordered3]]
-// CHECK: call i32 @foo()
-// CHECK: store {{.*}} @_ZN2ns1aIiE1iE
-// CHECK: ret
+// ALL: define internal void @[[unordered1]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_ZN1AIsE1aE
+// ALL: ret
 
-// CHECK: define internal void @[[unordered4]]
-// CHECK: call i32 @foo()
-// CHECK: store {{.*}} @_ZN2ns1b1iIiEE
-// CHECK: ret
+// ALL: define internal void @[[unordered2]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_Z1xIsE
+// ALL: ret
 
-// CHECK: define internal void @[[unordered5]]
-// CHECK: call i32 @foo()
-// CHECK: store {{.*}} @_ZN1AIvE1aE
-// CHECK: ret
+// ALL: define internal void @[[unordered3]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_ZN2ns1aIiE1iE
+// ALL: ret
 
-// CHECK: define internal void @[[unordered6]]
-// CHECK: call i32 @foo()
-// CHECK: store {{.*}} @_Z1xIcE
-// CHECK: ret
+// ALL: define internal void @[[unordered4]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_ZN2ns1b1iIiEE
+// ALL: ret
 
-// CHECK: define internal void @_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp()
+// ALL: define internal void @[[unordered5]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_ZN1AIvE1aE
+// ALL: ret
+
+// ALL: define internal void @[[unordered6]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_Z1xIcE
+// ALL: ret
+
+// ALL: define internal void @[[unordered7]]
+// ALL: call i32 @foo()
+// ALL: store {{.*}} @_ZN12_GLOBAL__N_18InternalIiE1aE
+// ALL: ret
+
+// ALL: define internal void @_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp()
 //   We call unique stubs for every ordered dynamic initializer in the TU.
-// CHECK: call
-// CHECK: call
-// CHECK: call
-// CHECK: call
-// CHECK: call
-// CHECK: call
-// CHECK: call
-// CHECK: call
-// CHECK-NOT: call
-// CHECK: ret
+// ALL: call
+// ALL: call
+// ALL: call
+// ALL: call
+// ALL: call
+// ALL: call
+// ALL: call
+// ALL: call
+// ALL-NOT: call
+// ALL: ret
diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp
index 37286c2..7f5c7af 100644
--- a/test/CodeGenCXX/temporaries.cpp
+++ b/test/CodeGenCXX/temporaries.cpp
@@ -325,7 +325,7 @@
 void g() {
   // CHECK: call void @_ZN3T121AC1Ev
   // CHECK-NEXT: call i32 @_ZN3T121A1fEv(
-  // CHECK-NEXT: call nonnull i32* @_ZN3T121fEi(
+  // CHECK-NEXT: call dereferenceable({{[0-9]+}}) i32* @_ZN3T121fEi(
   // CHECK-NEXT: call void @_ZN3T121AD1Ev(
   int& i = f(A().f());
 }
@@ -427,10 +427,10 @@
     // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8
 
     // CHECK:      call void @_ZN7Elision1AC1Ev([[A]]* [[I]])
-    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[I]], [[A]]* nonnull [[X:%.*]])
+    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[I]], [[A]]* dereferenceable({{[0-9]+}}) [[X:%.*]])
     A i = (c ? A() : x);
 
-    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[J]], [[A]]* nonnull [[X]])
+    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[J]], [[A]]* dereferenceable({{[0-9]+}}) [[X]])
     // CHECK:      call void @_ZN7Elision1AC1Ev([[A]]* [[J]])
     A j = (c ? x : A());
 
@@ -450,10 +450,10 @@
   A test3(int v, A x) {
     if (v < 5)
     // CHECK:      call void @_ZN7Elision1AC1Ev([[A]]* [[RET:%.*]])
-    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* nonnull [[X:%.*]])
+    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* dereferenceable({{[0-9]+}}) [[X:%.*]])
       return (v < 0 ? A() : x);
     else
-    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* nonnull [[X]])
+    // CHECK:      call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* dereferenceable({{[0-9]+}}) [[X]])
     // CHECK:      call void @_ZN7Elision1AC1Ev([[A]]* [[RET]])
       return (v > 10 ? x : A());
 
@@ -471,7 +471,7 @@
     // CHECK-NEXT: [[XS0:%.*]] = getelementptr inbounds [2 x [[A]]]* [[XS]], i64 0, i64 0
     // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[XS0]])
     // CHECK-NEXT: [[XS1:%.*]] = getelementptr inbounds [[A]]* [[XS0]], i64 1
-    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[XS1]], [[A]]* nonnull [[X]])
+    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[XS1]], [[A]]* dereferenceable({{[0-9]+}}) [[X]])
     A xs[] = { A(), x };
 
     // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [2 x [[A]]]* [[XS]], i32 0, i32 0
@@ -498,7 +498,7 @@
 
     // CHECK:      call void @_ZN7Elision1BC1Ev([[B]]* [[BT0]])
     // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT0]], i32 0, i32 0
-    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[AT0]], [[A]]* nonnull [[AM]])
+    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[AT0]], [[A]]* dereferenceable({{[0-9]+}}) [[AM]])
     // CHECK-NEXT: call void @_ZN7Elision5takeAENS_1AE([[A]]* [[AT0]])
     // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[AT0]])
     // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT0]])
@@ -506,13 +506,13 @@
 
     // CHECK-NEXT: call void @_ZN7Elision1BC1Ev([[B]]* [[BT1]])
     // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT1]], i32 0, i32 0
-    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[X]], [[A]]* nonnull [[AM]])
+    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[X]], [[A]]* dereferenceable({{[0-9]+}}) [[AM]])
     // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT1]])
     A x = B().a;
 
     // CHECK-NEXT: call void @_ZN7Elision1BC1Ev([[B]]* [[BT2]])
     // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT2]], i32 0, i32 0
-    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET:%.*]], [[A]]* nonnull [[AM]])
+    // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET:%.*]], [[A]]* dereferenceable({{[0-9]+}}) [[AM]])
     // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT2]])
     return B().a;
 
diff --git a/test/CodeGenCXX/throw-expressions.cpp b/test/CodeGenCXX/throw-expressions.cpp
index 549aef0..4dd5322 100644
--- a/test/CodeGenCXX/throw-expressions.cpp
+++ b/test/CodeGenCXX/throw-expressions.cpp
@@ -97,7 +97,7 @@
   cond ? throw test7 : val;
 }
 
-// CHECK-LABEL: define nonnull i32* @_Z5test8b(
+// CHECK-LABEL: define dereferenceable(4) i32* @_Z5test8b(
 int &test8(bool cond) {
   // CHECK: br i1
   //
diff --git a/test/CodeGenCXX/tls-init-funcs.cpp b/test/CodeGenCXX/tls-init-funcs.cpp
index 99fe75f..d47329c 100644
--- a/test/CodeGenCXX/tls-init-funcs.cpp
+++ b/test/CodeGenCXX/tls-init-funcs.cpp
@@ -1,11 +1,34 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++11 -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++1y -S -emit-llvm %s -o - | FileCheck %s
 
 // CHECK: @a = internal thread_local global
+// CHECK: @_Z2vtIiE = internal thread_local global i32 5
+// CHECK: @_ZZ3inlvE3loc = linkonce_odr thread_local global i32 0
 // CHECK: @_tlv_atexit({{.*}}@_ZN1AD1Ev
-// CHECK: define weak hidden {{.*}} @_ZTW1a
+// CHECK: call i32* @_ZTW3ext()
+// CHECK: declare i32* @_ZTW3ext()
+// CHECK: define weak i32* @_ZTW2vtIiE()
+// CHECK: define weak i32* @_ZTW2vtIvE()
+// CHECK: define {{.*}} @_ZTW1a
 
 struct A {
   ~A();
 };
 
 thread_local A a;
+
+extern thread_local int ext;
+int &get_ext() { return ext; }
+
+template <typename T>
+thread_local int vt = 5;
+
+int get_vt() { return vt<int>; }
+
+inline int &inl() {
+  thread_local int loc;
+  return loc;
+}
+int &use_inl() { return inl(); }
+
+template int vt<void>;
+int &get_vt_void() { return vt<void>; }
diff --git a/test/CodeGenCXX/try-catch.cpp b/test/CodeGenCXX/try-catch.cpp
index 89f229f..b50214e 100644
--- a/test/CodeGenCXX/try-catch.cpp
+++ b/test/CodeGenCXX/try-catch.cpp
@@ -11,3 +11,11 @@
   } catch (const X x) {
   }
 }
+
+void h() {
+  try {
+    throw "ABC";
+    // CHECK: @_ZTIPKc to i8
+  } catch (char const(&)[4]) {
+  }
+}
diff --git a/test/CodeGenCXX/typeid-should-throw.cpp b/test/CodeGenCXX/typeid-should-throw.cpp
new file mode 100644
index 0000000..1d8fc85
--- /dev/null
+++ b/test/CodeGenCXX/typeid-should-throw.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -Wno-unused-value -emit-llvm -o - -std=c++11 | FileCheck %s
+namespace std {
+struct type_info;
+}
+
+struct A {
+  virtual ~A();
+  operator bool();
+};
+struct B : A {};
+
+void f1(A *x) { typeid(false, *x); }
+// CHECK-LABEL: define void @_Z2f1P1A
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f2(bool b, A *x, A *y) { typeid(b ? *x : *y); }
+// CHECK-LABEL: define void @_Z2f2bP1AS0_
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f3(bool b, A *x, A &y) { typeid(b ? *x : y); }
+// CHECK-LABEL: define void @_Z2f3bP1ARS_
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f4(bool b, A &x, A *y) { typeid(b ? x : *y); }
+// CHECK-LABEL: define void @_Z2f4bR1APS_
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f5(volatile A *x) { typeid(*x); }
+// CHECK-LABEL: define void @_Z2f5PV1A
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f6(A *x) { typeid((B &)*(B *)x); }
+// CHECK-LABEL: define void @_Z2f6P1A
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f7(A *x) { typeid((*x)); }
+// CHECK-LABEL: define void @_Z2f7P1A
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f8(A *x) { typeid(x[0]); }
+// CHECK-LABEL: define void @_Z2f8P1A
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f9(A *x) { typeid(0[x]); }
+// CHECK-LABEL: define void @_Z2f9P1A
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f10(A *x, A *y) { typeid(*y ?: *x); }
+// CHECK-LABEL: define void @_Z3f10P1AS0_
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f11(A *x, A &y) { typeid(*x ?: y); }
+// CHECK-LABEL: define void @_Z3f11P1ARS_
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f12(A &x, A *y) { typeid(x ?: *y); }
+// CHECK-LABEL: define void @_Z3f12R1APS_
+// CHECK:       icmp eq {{.*}}, null
+// CHECK-NEXT:  br i1
+
+void f13(A &x, A &y) { typeid(x ?: y); }
+// CHECK-LABEL: define void @_Z3f13R1AS0_
+// CHECK-NOT:   icmp eq {{.*}}, null
+
+void f14(A *x) { typeid((const A &)(A)*x); }
+// CHECK-LABEL: define void @_Z3f14P1A
+// CHECK-NOT:   icmp eq {{.*}}, null
+
+void f15(A *x) { typeid((A &&)*(A *)nullptr); }
+// CHECK-LABEL: define void @_Z3f15P1A
+// CHECK-NOT:   icmp eq {{.*}}, null
diff --git a/test/CodeGenCXX/unknown-anytype.cpp b/test/CodeGenCXX/unknown-anytype.cpp
index aacb849..e6f887b 100644
--- a/test/CodeGenCXX/unknown-anytype.cpp
+++ b/test/CodeGenCXX/unknown-anytype.cpp
@@ -115,3 +115,11 @@
 void test10() {
   (void) test10_any(), (void) test10_any();
 }
+
+extern "C" __unknown_anytype malloc(...);
+void test11() {
+  void *s = (void*)malloc(12);
+  // COMMON: call i8* (i32, ...)* @malloc(i32 12)
+  void *d = (void*)malloc(435);
+  // COMMON: call i8* (i32, ...)* @malloc(i32 435)
+}
diff --git a/test/CodeGenCXX/value-init.cpp b/test/CodeGenCXX/value-init.cpp
index fad459b..423d973 100644
--- a/test/CodeGenCXX/value-init.cpp
+++ b/test/CodeGenCXX/value-init.cpp
@@ -262,6 +262,59 @@
 void r170806_a(bool b = bool());
 void r170806_b() { r170806_a(); }
 
+namespace PR20256 {
+  struct data { int i; };
+
+  template<typename T = int>
+  data g() {
+    data d; // not value-init
+    return d;
+  }
+  template data g();
+  // CHECK-LABEL: define {{.*}} @_ZN7PR202561gIiEENS_4dataEv(
+  // CHECK-NOT: store
+  // CHECK-NOT: memset
+  // CHECK: }
+
+  template<typename ...T>
+  data h(T ...t) {
+    data d(t...); // value-init
+    return d;
+  }
+  template data h();
+  // CHECK-LABEL: define {{.*}} @_ZN7PR202561hIJEEENS_4dataEDpT_(
+  // CHECK: call void @llvm.memset
+  // CHECK: }
+
+
+  template<typename T = int>
+  data j() {
+    data d = {}; // value-init
+    return d;
+  }
+  template data j();
+  // CHECK-LABEL: define {{.*}} @_ZN7PR202561jIiEENS_4dataEv(
+  // CHECK: call void @llvm.memset
+  // CHECK: }
+
+  data f() {
+    data d; // not value-init
+    return d;
+  }
+  // CHECK-LABEL: define {{.*}} @_ZN7PR202561fEv(
+  // CHECK-NOT: store
+  // CHECK-NOT: memset
+  // CHECK: }
+
+  data i() {
+    data d = {}; // value-init
+    return d;
+  }
+  // CHECK-LABEL: define {{.*}} @_ZN7PR202561iEv(
+  // CHECK: call void @llvm.memset
+  // CHECK: }
+}
+
 // CHECK-LABEL: define linkonce_odr void @_ZN8zeroinit2X3IiEC2Ev(%"struct.zeroinit::X3"* %this) unnamed_addr
 // CHECK: call void @llvm.memset.p0i8.i64
 // CHECK-NEXT: call void @_ZN8zeroinit2X2IiEC2Ev
diff --git a/test/CodeGenCXX/vararg-non-pod-ms-compat.cpp b/test/CodeGenCXX/vararg-non-pod-ms-compat.cpp
new file mode 100644
index 0000000..668fadf
--- /dev/null
+++ b/test/CodeGenCXX/vararg-non-pod-ms-compat.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -Wno-error=non-pod-varargs -triple i686-pc-win32 -fms-compatibility -emit-llvm -o - %s | FileCheck %s -check-prefix=X86 -check-prefix=CHECK
+// RUN: %clang_cc1 -Wno-error=non-pod-varargs -triple x86_64-pc-win32 -fms-compatibility -emit-llvm -o - %s | FileCheck %s -check-prefix=X64 -check-prefix=CHECK
+
+struct X {
+  X();
+  ~X();
+  int data;
+};
+
+void vararg(...);
+
+void test(X x) {
+  // CHECK-LABEL: define void @"\01?test@@YAXUX@@@Z"
+
+  // X86: %[[argmem:[^ ]*]] = alloca inalloca <{ %struct.X }>
+  // X86: call void (<{ %struct.X }>*, ...)* bitcast (void (...)* @"\01?vararg@@YAXZZ" to void (<{ %struct.X }>*, ...)*)(<{ %struct.X }>* inalloca %[[argmem]])
+
+  // X64: alloca %struct.X
+
+  // X64: %[[agg:[^ ]*]] = alloca %struct.X
+  // X64: %[[valptr:[^ ]*]] = getelementptr %struct.X* %[[agg]], i32 0, i32 0
+  // X64: %[[val:[^ ]*]] = load i32* %[[valptr]]
+  // X64: call void (...)* @"\01?vararg@@YAXZZ"(i32 %[[val]])
+
+  // CHECK-NOT: llvm.trap
+  vararg(x);
+  // CHECK: ret void
+}
diff --git a/test/CodeGenCXX/virtual-base-cast.cpp b/test/CodeGenCXX/virtual-base-cast.cpp
index 6a4894b..0dcf319 100644
--- a/test/CodeGenCXX/virtual-base-cast.cpp
+++ b/test/CodeGenCXX/virtual-base-cast.cpp
@@ -20,11 +20,10 @@
 
 // MSVC: @"\01?a@@YAPAUA@@XZ"() [[NUW:#[0-9]+]] {
 // MSVC:   %[[vbptr_off:.*]] = getelementptr inbounds i8* {{.*}}, i32 0
-// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i8**
-// MSVC:   %[[vbtable:.*]] = load i8** %[[vbptr]]
-// MSVC:   %[[entry:.*]] = getelementptr inbounds i8* {{.*}}, i32 4
-// MSVC:   %[[entry_i32:.*]] = bitcast i8* %[[entry]] to i32*
-// MSVC:   %[[offset:.*]] = load i32* %[[entry_i32]]
+// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
+// MSVC:   %[[vbtable:.*]] = load i32** %[[vbptr]]
+// MSVC:   %[[entry:.*]] = getelementptr inbounds i32* {{.*}}, i32 1
+// MSVC:   %[[offset:.*]] = load i32* %[[entry]]
 // MSVC:   add nsw i32 0, %[[offset]]
 // MSVC: }
 
@@ -38,11 +37,10 @@
 // Same as 'a' except we use a different vbtable offset.
 // MSVC: @"\01?b@@YAPAUB@@XZ"() [[NUW:#[0-9]+]] {
 // MSVC:   %[[vbptr_off:.*]] = getelementptr inbounds i8* {{.*}}, i32 0
-// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i8**
-// MSVC:   %[[vbtable:.*]] = load i8** %[[vbptr]]
-// MSVC:   %[[entry:.*]] = getelementptr inbounds i8* {{.*}}, i32 8
-// MSVC:   %[[entry_i32:.*]] = bitcast i8* %[[entry]] to i32*
-// MSVC:   %[[offset:.*]] = load i32* %[[entry_i32]]
+// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
+// MSVC:   %[[vbtable:.*]] = load i32** %[[vbptr]]
+// MSVC:   %[[entry:.*]] = getelementptr inbounds i32* {{.*}}, i32 2
+// MSVC:   %[[offset:.*]] = load i32* %[[entry]]
 // MSVC:   add nsw i32 0, %[[offset]]
 // MSVC: }
 
@@ -58,11 +56,10 @@
 // Same as 'a' except we use a different vbtable offset.
 // MSVC: @"\01?c@@YAPAUBB@@XZ"() [[NUW:#[0-9]+]] {
 // MSVC:   %[[vbptr_off:.*]] = getelementptr inbounds i8* {{.*}}, i32 0
-// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i8**
-// MSVC:   %[[vbtable:.*]] = load i8** %[[vbptr]]
-// MSVC:   %[[entry:.*]] = getelementptr inbounds i8* {{.*}}, i32 16
-// MSVC:   %[[entry_i32:.*]] = bitcast i8* %[[entry]] to i32*
-// MSVC:   %[[offset:.*]] = load i32* %[[entry_i32]]
+// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
+// MSVC:   %[[vbtable:.*]] = load i32** %[[vbptr]]
+// MSVC:   %[[entry:.*]] = getelementptr inbounds i32* {{.*}}, i32 4
+// MSVC:   %[[offset:.*]] = load i32* %[[entry]]
 // MSVC:   add nsw i32 0, %[[offset]]
 // MSVC: }
 
@@ -78,11 +75,10 @@
 // final add.
 // MSVC: @"\01?d@@YAPAUBB@@XZ"() [[NUW:#[0-9]+]] {
 // MSVC:   %[[vbptr_off:.*]] = getelementptr inbounds i8* {{.*}}, i32 4
-// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i8**
-// MSVC:   %[[vbtable:.*]] = load i8** %[[vbptr]]
-// MSVC:   %[[entry:.*]] = getelementptr inbounds i8* {{.*}}, i32 16
-// MSVC:   %[[entry_i32:.*]] = bitcast i8* %[[entry]] to i32*
-// MSVC:   %[[offset:.*]] = load i32* %[[entry_i32]]
+// MSVC:   %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
+// MSVC:   %[[vbtable:.*]] = load i32** %[[vbptr]]
+// MSVC:   %[[entry:.*]] = getelementptr inbounds i32* {{.*}}, i32 4
+// MSVC:   %[[offset:.*]] = load i32* %[[entry]]
 // MSVC:   add nsw i32 4, %[[offset]]
 // MSVC: }
 
diff --git a/test/CodeGenCXX/virtual-destructor-calls.cpp b/test/CodeGenCXX/virtual-destructor-calls.cpp
index 3e7fa82..f0e3dc5 100644
--- a/test/CodeGenCXX/virtual-destructor-calls.cpp
+++ b/test/CodeGenCXX/virtual-destructor-calls.cpp
@@ -17,8 +17,8 @@
 // CHECK: @_ZN1BD1Ev = alias {{.*}} @_ZN1BD2Ev
 
 // (aliases from C)
-// CHECK: @_ZN1CD1Ev = alias {{.*}} @_ZN1CD2Ev
 // CHECK: @_ZN1CD2Ev = alias bitcast {{.*}} @_ZN1BD2Ev
+// CHECK: @_ZN1CD1Ev = alias {{.*}} @_ZN1CD2Ev
 
 // Base dtor: actually calls A's base dtor.
 // CHECK-LABEL: define void @_ZN1BD2Ev(%struct.B* %this) unnamed_addr
diff --git a/test/CodeGenCXX/vla-lambda-capturing.cpp b/test/CodeGenCXX/vla-lambda-capturing.cpp
new file mode 100644
index 0000000..4ad183d
--- /dev/null
+++ b/test/CodeGenCXX/vla-lambda-capturing.cpp
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -emit-pch -o %t
+// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+// CHECK-DAG:   [[CAP_TYPE1:%.+]] = type { [[INTPTR_T:i.+]], [[INTPTR_T]]*, [[INTPTR_T]]* }
+// CHECK-DAG:   [[CAP_TYPE2:%.+]] = type { [[INTPTR_T]], [[INTPTR_T]]* }
+// CHECK-DAG:   [[CAP_TYPE3:%.+]] = type { [[INTPTR_T]]*, [[INTPTR_T]], [[INTPTR_T]], [[INTPTR_T]]*, [[INTPTR_T]]* }
+// CHECK-DAG:   [[CAP_TYPE4:%.+]] = type { [[INTPTR_T]]*, [[INTPTR_T]], [[INTPTR_T]]*, [[INTPTR_T]], [[INTPTR_T]]* }
+
+// CHECK:       define void [[G:@.+]](
+// CHECK:       [[N_ADDR:%.+]] = alloca [[INTPTR_T]]
+// CHECK:       store [[INTPTR_T]] %{{.+}}, [[INTPTR_T]]* [[N_ADDR]]
+// CHECK:       [[N_VAL:%.+]] = load [[INTPTR_T]]* [[N_ADDR]]
+// CHECK:       [[CAP_EXPR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE1]]* [[CAP_ARG:%.+]], i{{.+}} 0, i{{.+}} 0
+// CHECK:       store [[INTPTR_T]] [[N_VAL]], [[INTPTR_T]]* [[CAP_EXPR_REF]]
+// CHECK:       [[CAP_BUFFER_ADDR:%.+]] = getelementptr inbounds [[CAP_TYPE1]]* [[CAP_ARG]], i{{.+}} 0, i{{.+}} 1
+// CHECK:       store [[INTPTR_T]]* %{{.+}}, [[INTPTR_T]]** [[CAP_BUFFER_ADDR]]
+// CHECK:       [[CAP_N_REF:%.+]] = getelementptr inbounds [[CAP_TYPE1]]* [[CAP_ARG:%.+]], i{{.+}} 0, i{{.+}} 2
+// CHECK:       store [[INTPTR_T]]* [[N_ADDR]], [[INTPTR_T]]** [[CAP_N_REF]]
+// CHECK:       call void [[G_LAMBDA:@.+]]([[CAP_TYPE1]]* [[CAP_ARG]])
+// CHECK:       ret void
+void g(intptr_t n) {
+  intptr_t buffer[n];
+  [&buffer, &n]() {
+    __typeof(buffer) x;
+  }();
+}
+
+// CHECK: void [[G_LAMBDA]]([[CAP_TYPE1]]*
+// CHECK: [[THIS:%.+]] = load [[CAP_TYPE1]]**
+// CHECK: [[N_ADDR:%.+]] = getelementptr inbounds [[CAP_TYPE1]]* [[THIS]], i{{.+}} 0, i{{.+}} 0
+// CHECK: [[N:%.+]] = load [[INTPTR_T]]* [[N_ADDR]]
+// CHECK: [[BUFFER_ADDR:%.+]] = getelementptr inbounds [[CAP_TYPE1]]* [[THIS]], i{{.+}} 0, i{{.+}} 1
+// CHECK: [[BUFFER:%.+]] = load [[INTPTR_T]]** [[BUFFER_ADDR]]
+// CHECK: call i{{.+}}* @llvm.stacksave()
+// CHECK: alloca [[INTPTR_T]], [[INTPTR_T]] [[N]]
+// CHECK: call void @llvm.stackrestore(
+// CHECK: ret void
+
+template <typename T>
+void f(T n, T m) {
+  intptr_t buffer[n + m];
+  [&buffer]() {
+    __typeof(buffer) x;
+  }();
+}
+
+template <typename T>
+intptr_t getSize(T);
+
+template <typename T>
+void b(intptr_t n, T arg) {
+  typedef intptr_t ArrTy[getSize(arg)];
+  ArrTy buffer2;
+  ArrTy buffer1[n + arg];
+  intptr_t a;
+  [&]() {
+    n = sizeof(buffer1[n]);
+    [&](){
+      n = sizeof(buffer2);
+      n = sizeof(buffer1);
+    }();
+  }();
+}
+
+// CHECK-LABEL: @main
+int main() {
+  // CHECK:       call void [[G]]([[INTPTR_T]] 1)
+  g((intptr_t)1);
+  // CHECK:       call void [[F_INT:@.+]]([[INTPTR_T]] 1, [[INTPTR_T]] 2)
+  f((intptr_t)1, (intptr_t)2);
+  // CHECK:       call void [[B_INT:@.+]]([[INTPTR_T]] 12, [[INTPTR_T]] 13)
+  b((intptr_t)12, (intptr_t)13);
+  // CHECK:       ret i32 0
+  return 0;
+}
+
+// CHECK: void [[F_INT]]([[INTPTR_T]]
+// CHECK: [[SIZE:%.+]] = add
+// CHECK: call i{{.+}}* @llvm.stacksave()
+// CHECK: [[BUFFER_ADDR:%.+]] = alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]]
+// CHECK: [[CAP_SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]]* [[CAP_ARG:%.+]], i{{.+}} 0, i{{.+}} 0
+// CHECK: store [[INTPTR_T]] [[SIZE]], [[INTPTR_T]]* [[CAP_SIZE_REF]]
+// CHECK: [[CAP_BUFFER_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]]* [[CAP_ARG]], i{{.+}} 0, i{{.+}} 1
+// CHECK: store [[INTPTR_T]]* [[BUFFER_ADDR]], [[INTPTR_T]]** [[CAP_BUFFER_ADDR_REF]]
+// CHECK: call void [[F_INT_LAMBDA:@.+]]([[CAP_TYPE2]]* [[CAP_ARG]])
+// CHECK: call void @llvm.stackrestore(
+// CHECK: ret void
+// CHECK: void [[B_INT]]([[INTPTR_T]]
+// CHECK: [[SIZE1:%.+]] = call [[INTPTR_T]]
+// CHECK: call i{{.+}}* @llvm.stacksave()
+// CHECK: [[BUFFER2_ADDR:%.+]] = alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE1]]
+// CHECK: [[SIZE2:%.+]] = add
+// CHECK: [[BUFFER1_ADDR:%.+]] = alloca [[INTPTR_T]], [[INTPTR_T]]
+// CHECK: [[CAP_N_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[CAP_ARG:%.+]], i{{.+}} 0, i{{.+}} 0
+// CHECK: store [[INTPTR_T]]* {{%.+}}, [[INTPTR_T]]** [[CAP_N_ADDR_REF]]
+// CHECK: [[CAP_SIZE2_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[CAP_ARG]], i{{.+}} 0, i{{.+}} 1
+// CHECK: store i{{[0-9]+}} [[SIZE2]], i{{[0-9]+}}* [[CAP_SIZE2_REF]]
+// CHECK: [[CAP_SIZE1_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[CAP_ARG]], i{{.+}} 0, i{{.+}} 2
+// CHECK: store i{{[0-9]+}} [[SIZE1]], i{{[0-9]+}}* [[CAP_SIZE1_REF]]
+// CHECK: [[CAP_BUFFER1_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[CAP_ARG]], i{{.+}} 0, i{{.+}} 3
+// CHECK: store [[INTPTR_T]]* [[BUFFER1_ADDR]], [[INTPTR_T]]** [[CAP_BUFFER1_ADDR_REF]]
+// CHECK: [[CAP_BUFFER2_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[CAP_ARG]], i{{.+}} 0, i{{.+}} 4
+// CHECK: store [[INTPTR_T]]* [[BUFFER2_ADDR]], [[INTPTR_T]]** [[CAP_BUFFER2_ADDR_REF]]
+// CHECK: call void [[B_INT_LAMBDA:@.+]]([[CAP_TYPE3]]* [[CAP_ARG]])
+// CHECK: call void @llvm.stackrestore(
+// CHECK: ret void
+
+// CHECK: define {{.*}} void [[B_INT_LAMBDA]]([[CAP_TYPE3]]*
+// CHECK: [[SIZE2_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+// CHECK: [[SIZE2:%.+]] = load i{{[0-9]+}}* [[SIZE2_REF]]
+// CHECK: [[SIZE1_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
+// CHECK: [[SIZE1:%.+]] = load i{{[0-9]+}}* [[SIZE1_REF]]
+// CHECK: [[N_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[N_ADDR:%.+]] = load [[INTPTR_T]]** [[N_ADDR_REF]]
+// CHECK: [[N:%.+]] = load [[INTPTR_T]]* [[N_ADDR]]
+// CHECK: [[BUFFER1_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 3
+// CHECK: [[BUFFER1_ADDR:%.+]] = load [[INTPTR_T]]** [[BUFFER1_ADDR_REF]]
+// CHECK: [[ELEM_OFFSET:%.+]] = mul {{.*}} i{{[0-9]+}} [[N]], [[SIZE1]]
+// CHECK: [[ELEM_ADDR:%.+]] = getelementptr inbounds [[INTPTR_T]]* [[BUFFER1_ADDR]], i{{[0-9]+}} [[ELEM_OFFSET]]
+// CHECK: [[SIZEOF:%.+]] = mul {{.*}} i{{[0-9]+}} {{[0-9]+}}, [[SIZE1]]
+// CHECK: [[N_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[N_ADDR:%.+]] = load [[INTPTR_T]]** [[N_ADDR_REF]]
+// CHECK: store [[INTPTR_T]] {{%.+}}, [[INTPTR_T]]* [[N_ADDR]]
+// CHECK: [[N_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[CAP:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[N_ADDR_REF_ORIG:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[N_ADDR_ORIG:%.+]] = load [[INTPTR_T]]** [[N_ADDR_REF_ORIG]]
+// CHECK: store [[INTPTR_T]]* [[N_ADDR_ORIG]], [[INTPTR_T]]** [[N_ADDR_REF]]
+// CHECK: [[SIZE1_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[CAP]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+// CHECK: store i{{[0-9]+}} [[SIZE1]], i{{[0-9]+}}* [[SIZE1_REF]]
+// CHECK: [[BUFFER2_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[CAP]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
+// CHECK: [[BUFFER2_ADDR_REF_ORIG:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 4
+// CHECK: [[BUFFER2_ADDR_ORIG:%.+]] = load [[INTPTR_T]]** [[BUFFER2_ADDR_REF_ORIG]]
+// CHECK: store [[INTPTR_T]]* [[BUFFER2_ADDR_ORIG]], [[INTPTR_T]]** [[BUFFER2_ADDR_REF]]
+// CHECK: [[SIZE2_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[CAP]], i{{[0-9]+}} 0, i{{[0-9]+}} 3
+// CHECK: store i{{[0-9]+}} [[SIZE2]], i{{[0-9]+}}* [[SIZE2_REF]]
+// CHECK: [[BUFFER1_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[CAP]], i{{[0-9]+}} 0, i{{[0-9]+}} 4
+// CHECK: [[BUFFER1_ADDR_REF_ORIG:%.+]] = getelementptr inbounds [[CAP_TYPE3]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 3
+// CHECK: [[BUFFER1_ADDR_ORIG:%.+]] = load [[INTPTR_T]]** [[BUFFER1_ADDR_REF_ORIG]]
+// CHECK: store [[INTPTR_T]]* [[BUFFER1_ADDR_ORIG]], [[INTPTR_T]]** [[BUFFER1_ADDR_REF]]
+// CHECK: call void [[B_INT_LAMBDA_LAMBDA:@.+]]([[CAP_TYPE4]]* [[CAP]])
+// CHECK: ret void
+
+// CHECK: define {{.*}} void [[B_INT_LAMBDA_LAMBDA]]([[CAP_TYPE4]]*
+// CHECK: [[SIZE1_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[THIS:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
+// CHECK: [[SIZE1:%.+]] = load i{{[0-9]+}}* [[SIZE1_REF]]
+// CHECK: [[SIZE2_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 3
+// CHECK: [[SIZE2:%.+]] = load i{{[0-9]+}}* [[SIZE2_REF]]
+// CHECK: [[BUFFER2_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 2
+// CHECK: [[BUFFER2_ADDR:%.+]] = load [[INTPTR_T]]** [[BUFFER2_ADDR_REF]]
+// CHECK: [[SIZEOF_BUFFER2:%.+]] = mul {{.*}} i{{[0-9]+}} {{[0-9]+}}, [[SIZE1]]
+// CHECK: [[BUFFER1_ADDR_REF:%.+]] = getelementptr inbounds [[CAP_TYPE4]]* [[THIS]], i{{[0-9]+}} 0, i{{[0-9]+}} 4
+// CHECK: [[BUFFER1_ADDR:%.+]] = load [[INTPTR_T]]** [[BUFFER1_ADDR_REF]]
+// CHECK: [[MUL:%.+]] = mul {{.*}} i{{[0-9]+}} [[SIZE2]], [[SIZE1]]
+// CHECK: mul {{.*}} i{{[0-9]+}} {{[0-9]+}}, [[MUL]]
+// CHECK: ret void
+
+// CHECK: void [[F_INT_LAMBDA]]([[CAP_TYPE2]]*
+// CHECK: [[THIS:%.+]] = load [[CAP_TYPE2]]**
+// CHECK: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0
+// CHECK: [[SIZE:%.+]] = load [[INTPTR_T]]* [[SIZE_REF]]
+// CHECK: call i{{.+}}* @llvm.stacksave()
+// CHECK: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]]
+// CHECK: call void @llvm.stackrestore(
+// CHECK: ret void
+#endif
diff --git a/test/CodeGenCXX/volatile.cpp b/test/CodeGenCXX/volatile.cpp
index b2dd36e..f6ae0c5 100644
--- a/test/CodeGenCXX/volatile.cpp
+++ b/test/CodeGenCXX/volatile.cpp
@@ -15,7 +15,7 @@
   void test(A t) {
     // CHECK:      [[ARR:%.*]] = load [[A:%.*]]** @_ZN5test05arrayE, align 8
     // CHECK-NEXT: [[IDX:%.*]] = getelementptr inbounds [[A]]* [[ARR]], i64 0
-    // CHECK-NEXT: [[TMP:%.*]] = call nonnull [[A]]* @_ZNV5test01AaSERVKS0_([[A]]* [[IDX]], [[A]]* nonnull [[T:%.*]])
+    // CHECK-NEXT: [[TMP:%.*]] = call dereferenceable({{[0-9]+}}) [[A]]* @_ZNV5test01AaSERVKS0_([[A]]* [[IDX]], [[A]]* dereferenceable({{[0-9]+}}) [[T:%.*]])
     // CHECK-NEXT: ret void
     array[0] = t;
   }
diff --git a/test/CodeGenCXX/vtable-align.cpp b/test/CodeGenCXX/vtable-align.cpp
new file mode 100644
index 0000000..f1f10c0
--- /dev/null
+++ b/test/CodeGenCXX/vtable-align.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-32
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-64
+
+struct A {
+  virtual void f();
+  virtual void g();
+  virtual void h();
+};
+
+void A::f() {}
+
+// CHECK-32: @_ZTV1A = unnamed_addr constant [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1fEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1gEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1hEv to i8*)], align 4
+
+// CHECK-64: @_ZTV1A = unnamed_addr constant [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1fEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1gEv to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A1hEv to i8*)], align 8
diff --git a/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp b/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
new file mode 100644
index 0000000..bb9bd88
--- /dev/null
+++ b/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-nacl -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnux32 -emit-llvm -o - %s | FileCheck %s
+
+struct test_struct {};
+typedef int test_struct::* test_struct_mdp;
+typedef int (test_struct::*test_struct_mfp)();
+
+// CHECK-LABEL: define i32 @{{.*}}f_mdp{{.*}}(i32 %a)
+test_struct_mdp f_mdp(test_struct_mdp a) { return a; }
+
+// CHECK-LABEL: define {{.*}} @{{.*}}f_mfp{{.*}}(i64 %a.coerce)
+test_struct_mfp f_mfp(test_struct_mfp a) { return a; }
+
+// A struct with <= 12 bytes before a member data pointer should still
+// be allowed in registers, since the member data pointer is only 4 bytes.
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mdp{{.*}}(i64 %a.coerce0, i64 %a.coerce1)
+struct struct_with_mdp { char *a; char *b; char *c; test_struct_mdp d; };
+void f_struct_with_mdp(struct_with_mdp a) { (void)a; }
+
+struct struct_with_mdp_too_much {
+  char *a; char *b; char *c; char *d; test_struct_mdp e;
+};
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mdp_too_much{{.*}}({{.*}} byval {{.*}} %a)
+void f_struct_with_mdp_too_much(struct_with_mdp_too_much a) {
+  (void)a;
+}
+
+// A struct with <= 8 bytes before a member function pointer should still
+// be allowed in registers, since the member function pointer is only 8 bytes.
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_0{{.*}}(i64 %a.coerce0, i32 %a.coerce1)
+struct struct_with_mfp_0 { char *a; test_struct_mfp b; };
+void f_struct_with_mfp_0(struct_with_mfp_0 a) { (void)a; }
+
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_1{{.*}}(i64 %a.coerce0, i64 %a.coerce1)
+struct struct_with_mfp_1 { char *a; char *b; test_struct_mfp c; };
+void f_struct_with_mfp_1(struct_with_mfp_1 a) { (void)a; }
+
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_too_much{{.*}}({{.*}} byval {{.*}} %a, i32 %x)
+struct struct_with_mfp_too_much {
+  char *a; char *b; char *c; test_struct_mfp d;
+};
+void f_struct_with_mfp_too_much(struct_with_mfp_too_much a, int x) {
+  (void)a;
+}
diff --git a/test/CodeGenCXX/x86_64-arguments.cpp b/test/CodeGenCXX/x86_64-arguments.cpp
index 2172e08..815ef61 100644
--- a/test/CodeGenCXX/x86_64-arguments.cpp
+++ b/test/CodeGenCXX/x86_64-arguments.cpp
@@ -32,6 +32,21 @@
 s4_mdp f4_0(s4_mdp a) { return a; }
 s4_mfp f4_1(s4_mfp a) { return a; }
 
+// A struct with <= one eightbyte before a member data pointer should still
+// be allowed in registers.
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mdp{{.*}}(i8* %a.coerce0, i64 %a.coerce1)
+struct struct_with_mdp { char *a; s4_mdp b; };
+void f_struct_with_mdp(struct_with_mdp a) { (void)a; }
+
+// A struct with anything before a member function will be too big and
+// goes in memory.
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_0{{.*}}(%struct{{.*}} byval align 8 %a)
+struct struct_with_mfp_0 { char a; s4_mfp b; };
+void f_struct_with_mfp_0(struct_with_mfp_0 a) { (void)a; }
+
+// CHECK-LABEL: define void @{{.*}}f_struct_with_mfp_1{{.*}}(%struct{{.*}} byval align 8 %a)
+struct struct_with_mfp_1 { void *a; s4_mfp b; };
+void f_struct_with_mfp_1(struct_with_mfp_1 a) { (void)a; }
 
 namespace PR7523 {
 struct StringRef {
diff --git a/test/CodeGenObjC/2010-02-09-DbgSelf.m b/test/CodeGenObjC/2010-02-09-DbgSelf.m
index 9aebe3d..e939ede 100644
--- a/test/CodeGenObjC/2010-02-09-DbgSelf.m
+++ b/test/CodeGenObjC/2010-02-09-DbgSelf.m
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | FileCheck %s
 // Test to check that "self" argument is assigned a location.
-// CHECK: call void @llvm.dbg.declare(metadata !{%0** %{{[^}]+}}}, metadata [[SELF:![0-9]*]])
+// CHECK: call void @llvm.dbg.declare(metadata !{%0** %{{[^}]+}}}, metadata [[SELF:![0-9]*]], metadata !{{.*}})
 // CHECK: [[SELF]] = {{.*}} ; [ DW_TAG_arg_variable ] [self]
 
 @interface Foo 
diff --git a/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m b/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m
index 5186b20..3fb98c5 100644
--- a/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m
+++ b/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | grep  subprogram | grep "i32 9"
+// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | FileCheck "%s"
 // Test to check that subprogram start location.
 
 @interface Foo
@@ -7,6 +7,7 @@
 
 @implementation Foo
 -(int) barMethod {
+// CHECK: [ DW_TAG_subprogram ] [line [[@LINE-1]]]
   int i = 0;
   int j = 1;
   int k = 1;
diff --git a/test/CodeGenObjC/arc-foreach.m b/test/CodeGenObjC/arc-foreach.m
index ec767d3..46c5da0 100644
--- a/test/CodeGenObjC/arc-foreach.m
+++ b/test/CodeGenObjC/arc-foreach.m
@@ -46,7 +46,7 @@
 // CHECK-LP64-NEXT: [[SAVED_ARRAY:%.*]] = bitcast i8* [[T2]] to [[ARRAY_T]]*
 
 // Call the enumeration method.
-// CHECK-LP64-NEXT: [[T0:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-LP64-NEXT: [[T0:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
 // CHECK-LP64-NEXT: [[SIZE:%.*]] = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, [[STATE_T]]*, [16 x i8*]*, i64)*)(i8* [[T1]], i8* [[T0]], [[STATE_T]]* [[STATE]], [16 x i8*]* [[BUFFER]], i64 16)
 
@@ -69,7 +69,7 @@
 // CHECK-LP64: call void @use_block(
 // CHECK-LP64-NEXT: call void @objc_storeStrong(i8** [[D0]], i8* null)
 
-// CHECK-LP64:      [[T0:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-LP64:      [[T0:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
 // CHECK-LP64-NEXT: [[SIZE:%.*]] = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, [[STATE_T]]*, [16 x i8*]*, i64)*)(i8* [[T1]], i8* [[T0]], [[STATE_T]]* [[STATE]], [16 x i8*]* [[BUFFER]], i64 16)
 
@@ -135,7 +135,7 @@
 // CHECK-LP64-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[ARRAY_T]]*
 
 // Make sure it's not immediately released before starting the iteration.
-// CHECK-LP64-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-LP64-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-LP64-NEXT: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[COLL]] to i8*
 // CHECK-LP64-NEXT: @objc_msgSend
 
diff --git a/test/CodeGenObjC/arc-literals.m b/test/CodeGenObjC/arc-literals.m
index 19a5516..abeb49f 100644
--- a/test/CodeGenObjC/arc-literals.m
+++ b/test/CodeGenObjC/arc-literals.m
@@ -50,8 +50,8 @@
   // CHECK-NEXT: [[V1:%.*]] = load i8** [[B]],
   // CHECK-NEXT: store i8* [[V1]], i8** [[T0]]
 
-  // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]** @"\01L_OBJC_CLASSLIST
-  // CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+  // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]** @"OBJC_CLASSLIST
+  // CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8*
   // CHECK-NEXT: [[T2:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8**
   // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast ({{.*@objc_msgSend.*}})(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i64 2)
@@ -93,8 +93,8 @@
   // CHECK-NEXT: store i8* [[V3]], i8** [[T0]]
 
   // Constructing the dictionary
-  // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]** @"\01L_OBJC_CLASSLIST
-  // CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+  // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T:%.*]]** @"OBJC_CLASSLIST
+  // CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8*
   // CHECK-NEXT: [[T2:%.*]] = bitcast [2 x i8*]* [[OBJECTS]] to i8**
   // CHECK-NEXT: [[T3:%.*]] = bitcast [2 x i8*]* [[KEYS]] to i8**
@@ -127,7 +127,7 @@
   // CHECK:      [[T0:%.*]] = getelementptr inbounds [1 x i8*]* [[OBJECTS:%.*]], i32 0, i32 0
 
   // Invoke 'prop'
-  // CHECK:      [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+  // CHECK:      [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
   // CHECK-NEXT: [[T1:%.*]] = bitcast
   // CHECK-NEXT: [[T2:%.*]] = call [[B:%.*]]* bitcast ({{.*}} @objc_msgSend to {{.*}})(i8* [[T1]], i8* [[SEL]])
   // CHECK-NEXT: [[T3:%.*]] = bitcast [[B]]* [[T2]] to i8*
@@ -139,8 +139,8 @@
   // CHECK-NEXT: store i8* [[V1]], i8** [[T0]]
 
   // Invoke arrayWithObjects:count:
-  // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T]]** @"\01L_OBJC_CLASSLIST
-  // CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+  // CHECK-NEXT: [[T0:%.*]] = load [[CLASS_T]]** @"OBJC_CLASSLIST
+  // CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[CLASS_T]]* [[T0]] to i8*
   // CHECK-NEXT: [[T2:%.*]] = bitcast [1 x i8*]* [[OBJECTS]] to i8**
   // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast ({{.*}} @objc_msgSend to {{.*}}(i8* [[T1]], i8* [[SEL]], i8** [[T2]], i64 1)
diff --git a/test/CodeGenObjC/arc-loadweakretained-release.m b/test/CodeGenObjC/arc-loadweakretained-release.m
index a84719d..4db67a9 100644
--- a/test/CodeGenObjC/arc-loadweakretained-release.m
+++ b/test/CodeGenObjC/arc-loadweakretained-release.m
@@ -30,7 +30,7 @@
 
 // CHECK: [[SIXTEEN:%.*]]  = call i8* @objc_loadWeakRetained(i8** {{%.*}})
 // CHECK-NEXT:  [[SEVENTEEN:%.*]] = bitcast i8* [[SIXTEEN]] to {{%.*}}
-// CHECK-NEXT:  [[EIGHTEEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_6"
+// CHECK-NEXT:  [[EIGHTEEN:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_6
 // CHECK-NEXT:  [[NINETEEN:%.*]] = bitcast %0* [[SEVENTEEN]] to i8*
 // CHECK-NEXT:  call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
 // CHECK-NEXT:  [[TWENTY:%.*]] = bitcast %0* [[SEVENTEEN]] to i8*
diff --git a/test/CodeGenObjC/arc-precise-lifetime.m b/test/CodeGenObjC/arc-precise-lifetime.m
index e15d5d4..ddbd704 100644
--- a/test/CodeGenObjC/arc-precise-lifetime.m
+++ b/test/CodeGenObjC/arc-precise-lifetime.m
@@ -41,7 +41,7 @@
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
   // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutorelease(i8* [[T1]])
   // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
-  // CHECK-NEXT: [[T4:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T4:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8*
   // CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
   // CHECK-NEXT: store i8* [[T6]], i8**
@@ -61,7 +61,7 @@
   // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
   // CHECK-NEXT: store [[TEST1]]* [[T3]]
   // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]**
-  // CHECK-NEXT: [[T1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T1:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
   // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast
   // CHECK-NEXT: store i8* [[T3]], i8**
@@ -84,7 +84,7 @@
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
   // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutorelease(i8* [[T1]])
   // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
-  // CHECK-NEXT: [[T4:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T4:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8*
   // CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
   // CHECK-NEXT: store i8* [[T6]], i8**
@@ -106,7 +106,7 @@
   // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
   // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retainAutorelease
   // CHECK-NEXT: [[SIX:%.*]] = bitcast i8* [[T3]] to [[TEST1]]*
-  // CHECK-NEXT: [[SEVEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[SEVEN:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[EIGHT:%.*]] = bitcast [[TEST1]]* [[SIX]] to i8*
   // CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[EIGHT]], i8* [[SEVEN]])
   // CHECK-NEXT: store i8* [[CALL1]], i8**
diff --git a/test/CodeGenObjC/arc-property.m b/test/CodeGenObjC/arc-property.m
index 8398a1b..02cd50d 100644
--- a/test/CodeGenObjC/arc-property.m
+++ b/test/CodeGenObjC/arc-property.m
@@ -101,13 +101,13 @@
 // CHECK-NEXT: [[X:%.*]] = alloca i8*,
 //   Property access.
 // CHECK:      [[T0:%.*]] = load [[TEST3]]** [[T]],
-// CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
 // CHECK-NEXT: [[T2:%.*]] = call i8* bitcast ({{.*}} @objc_msgSend to {{.*}})(i8* [[T1]], i8* [[SEL]])
 // CHECK-NEXT: store i8* [[T2]], i8** [[X]],
 //   Message send.
 // CHECK-NEXT: [[T0:%.*]] = load [[TEST3]]** [[T]],
-// CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
 // CHECK-NEXT: [[T2:%.*]] = call i8* bitcast ({{.*}} @objc_msgSend to {{.*}})(i8* [[T1]], i8* [[SEL]])
 // CHECK-NEXT: [[T3:%.*]] = load i8** [[X]],
diff --git a/test/CodeGenObjC/arc.m b/test/CodeGenObjC/arc.m
index 8fc68ca..a83fe0f 100644
--- a/test/CodeGenObjC/arc.m
+++ b/test/CodeGenObjC/arc.m
@@ -103,8 +103,8 @@
   Test3 *x;
 
   // Call to +alloc.
-  // CHECK-NEXT: load {{.*}}* @"\01L_OBJC_CLASSLIST_REFERENCES_
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load {{.*}}* @"OBJC_CLASSLIST_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
   // CHECK-NEXT: bitcast
@@ -113,7 +113,7 @@
   [Test3 alloc];
 
   // CHECK-NEXT: [[T0:%.*]] = load [[TEST3]]** [[X]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
   // CHECK-NEXT: [[COPY:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend {{.*}})(i8* [[T1]],
   // CHECK-NEXT: call void @objc_release(i8* [[COPY]]) [[NUW:#[0-9]+]]
@@ -132,14 +132,14 @@
   id x = [[Test3 alloc] initWith: 5];
 
   // Call to +alloc.
-  // CHECK-NEXT: load {{.*}}* @"\01L_OBJC_CLASSLIST_REFERENCES_
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load {{.*}}* @"OBJC_CLASSLIST_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
   // CHECK-NEXT: bitcast
 
   // Call to -initWith: with elided retain of consumed argument.
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* 
   // CHECK-NEXT: bitcast
@@ -149,7 +149,7 @@
 
   // Call to -copy.
   // CHECK-NEXT: [[V:%.*]] = load i8** [[X]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[COPY:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend {{.*}})(i8* [[V]],
 
   // Assignment to x.
@@ -169,14 +169,14 @@
 // CHECK-LABEL: define i8* @test4()
 id test4() {
   // Call to +alloc.
-  // CHECK:      load {{.*}}* @"\01L_OBJC_CLASSLIST_REFERENCES_
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK:      load {{.*}}* @"OBJC_CLASSLIST_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
   // CHECK-NEXT: [[ALLOC:%.*]] = bitcast
 
   // Call to -initWith: with elided retain of consumed argument.
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[ALLOC:%.*]] = bitcast
   // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* [[ALLOC]],
 
@@ -289,13 +289,13 @@
   // CHECK-NEXT: [[Y:%.*]] = alloca i8*, align
   // CHECK-NEXT: store [[TEST10]]* null, [[TEST10]]** [[X]]
   // CHECK-NEXT: load [[TEST10]]** [[X]], align
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_{{[0-9]*}}"
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_{{[0-9]*}}
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: [[T0:%.*]] = call [[TEST10]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST10]]* [[T0]] to i8*
   // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
   // CHECK-NEXT: [[V:%.*]] = bitcast i8* [[T2]] to [[TEST10]]*
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_{{[0-9]*}}"
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_{{[0-9]*}}
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: [[T0:%.*]] = call [[TEST10]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
   // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST10]]* [[T0]] to i8*
@@ -412,11 +412,11 @@
   // CHECK-NEXT: [[BASE2:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
   // CHECK-NEXT: [[T0:%.*]] = getelementptr
   // CHECK-NEXT: store i8* [[BASE2]], i8** [[T0]]
-  // CHECK-NEXT: load {{%.*}}** @"\01L_OBJC_CLASSLIST_SUP_REFS_$_
+  // CHECK-NEXT: load {{%.*}}** @"OBJC_CLASSLIST_SUP_REFS_$_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: getelementptr
   // CHECK-NEXT: store
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: call void bitcast (i8* ({{.*}})* @objc_msgSendSuper2 to void (
   // CHECK-NEXT: ret void
 }
@@ -675,7 +675,7 @@
 // CHECK-NEXT: store [[TEST29]]* null, [[TEST29]]** [[SELF]]
 
 // Actual message send.
-// CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: [[T2:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-NEXT: [[T3:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
 // CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T3]], i8* [[T2]], i8* [[T1]])
 
@@ -782,7 +782,7 @@
 
 // Call.
 // CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]** [[SELF]]
-// CHECK-NEXT: [[T1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: [[T1:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
 // CHECK-NEXT: [[CALL:%.*]] = call [[TEST30_HELPER:%.*]]* bitcast {{.*}} @objc_msgSend {{.*}}(i8* [[T2]], i8* [[T1]])
 
@@ -868,7 +868,7 @@
   // CHECK-NEXT: load [[TEST33]]** [[PTR]]
   // CHECK-NEXT: [[W0:%.*]] = load [[A_T]]** [[A]]
   // CHECK-NEXT: store [[A_T]]* [[W0]], [[A_T]]** [[TEMP0]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[TEMP0]])
   // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[TEMP0]]
@@ -884,7 +884,7 @@
   // CHECK-NEXT: load [[TEST33]]** [[PTR]]
   // CHECK-NEXT: [[W0:%.*]] = load [[A_T]]** [[A]]
   // CHECK-NEXT: store [[A_T]]* [[W0]], [[A_T]]** [[TEMP1]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[TEMP1]])
   // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[TEMP1]]
@@ -898,19 +898,19 @@
   // CHECK-NEXT: call void @objc_release(i8* [[T5]])
 
   // CHECK-NEXT: load [[TEST33]]** [[PTR]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[A]])
 
   // CHECK-NEXT: load [[TEST33]]** [[PTR]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[A]])
 
   // 'out'
   // CHECK-NEXT: load [[TEST33]]** [[PTR]]
   // CHECK-NEXT: store [[A_T]]* null, [[A_T]]** [[TEMP2]]
-  // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: bitcast
   // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[TEMP2]])
   // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[TEMP2]]
@@ -1270,16 +1270,16 @@
 
   // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make()
   // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
-  // CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
-  // CHECK-NEXT: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T2:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T3:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T1]], i8* [[T3]], i8* [[T2]])
   // CHECK-NEXT: call void @objc_release(i8* [[T1]])
   [test61_make() performSelector: @selector(test61_void)];
 
   // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make()
   // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
-  // CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
-  // CHECK-NEXT: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T2:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
+  // CHECK-NEXT: [[T3:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T1]], i8* [[T3]], i8* [[T2]])
   // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]])
   // CHECK-NEXT: store i8* [[T5]], i8** [[Y]]
@@ -1372,7 +1372,7 @@
 // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST66]]*
 // CHECK-NEXT: [[T4:%.*]] = call i8* @test66_arg()
 // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]])
-// CHECK-NEXT: [[T6:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T7:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
 // CHECK-NEXT: [[SIX:%.*]] = icmp eq i8* [[T7]], null
 // CHECK-NEXT: br i1 [[SIX]], label [[NULINIT:%.*]], label [[CALL:%.*]]
diff --git a/test/CodeGenObjC/block-byref-debuginfo.m b/test/CodeGenObjC/block-byref-debuginfo.m
index 88a8d8d..231767e 100644
--- a/test/CodeGenObjC/block-byref-debuginfo.m
+++ b/test/CodeGenObjC/block-byref-debuginfo.m
@@ -3,7 +3,7 @@
 // rdar://problem/14386148
 // Test that the foo is aligned at an 8 byte boundary in the DWARF
 // expression (256) that locates it inside of the byref descriptor:
-// CHECK: metadata !"foo", i32 0, i64 {{[0-9]+}}, i64 64, i64 256, i32 0, metadata
+// CHECK: [ DW_TAG_member ] [foo] [line 0, size {{[0-9]+}}, align 64, offset 256] [from Foo]
 
 struct Foo {
   unsigned char *data;
diff --git a/test/CodeGenObjC/block-over-align.m b/test/CodeGenObjC/block-over-align.m
new file mode 100644
index 0000000..2747040
--- /dev/null
+++ b/test/CodeGenObjC/block-over-align.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s
+// rdar://17878679
+
+typedef struct
+{
+  int i;
+} GAXBackboardState  __attribute__ ((aligned(32))); // minimum alignment is 32-byte boundary
+
+@interface GAXSpringboard @end
+
+@implementation GAXSpringboard
+{
+ GAXBackboardState _reflectedBackboardState;
+}
+
+- (void) MyMethod
+{
+ GAXBackboardState newBackboardState;
+ ^{
+    _reflectedBackboardState = newBackboardState;
+    return newBackboardState.i;
+  }();
+}
+@end
+
diff --git a/test/CodeGenObjC/boxing.m b/test/CodeGenObjC/boxing.m
index efd2b16..33dc4e6 100644
--- a/test/CodeGenObjC/boxing.m
+++ b/test/CodeGenObjC/boxing.m
@@ -53,18 +53,18 @@
 + (id)stringWithUTF8String:(const char *)nullTerminatedCString;
 @end
 
-// CHECK: [[WithIntMeth:@".*"]] = private global [15 x i8] c"numberWithInt:\00"
-// CHECK: [[WithIntSEL:@".*"]] = private externally_initialized global i8* getelementptr inbounds ([15 x i8]* [[WithIntMeth]]
-// CHECK: [[WithCharMeth:@".*"]] = private global [16 x i8] c"numberWithChar:\00"
-// CHECK: [[WithCharSEL:@".*"]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8]* [[WithCharMeth]]
-// CHECK: [[WithBoolMeth:@".*"]] = private global [16 x i8] c"numberWithBool:\00"
-// CHECK: [[WithBoolSEL:@".*"]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8]* [[WithBoolMeth]]
-// CHECK: [[WithIntegerMeth:@".*"]] = private global [19 x i8] c"numberWithInteger:\00"
-// CHECK: [[WithIntegerSEL:@".*"]] = private externally_initialized global i8* getelementptr inbounds ([19 x i8]* [[WithIntegerMeth]]
-// CHECK: [[WithUnsignedIntegerMeth:@".*"]] = private global [27 x i8] c"numberWithUnsignedInteger:\00"
-// CHECK: [[WithUnsignedIntegerSEL:@".*"]] = private externally_initialized global i8* getelementptr inbounds ([27 x i8]* [[WithUnsignedIntegerMeth]]
-// CHECK: [[stringWithUTF8StringMeth:@".*"]] = private global [22 x i8] c"stringWithUTF8String:\00"
-// CHECK: [[stringWithUTF8StringSEL:@".*"]] = private externally_initialized global i8* getelementptr inbounds ([22 x i8]* [[stringWithUTF8StringMeth]]
+// CHECK: [[WithIntMeth:@.*]] = private global [15 x i8] c"numberWithInt:\00"
+// CHECK: [[WithIntSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([15 x i8]* [[WithIntMeth]]
+// CHECK: [[WithCharMeth:@.*]] = private global [16 x i8] c"numberWithChar:\00"
+// CHECK: [[WithCharSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8]* [[WithCharMeth]]
+// CHECK: [[WithBoolMeth:@.*]] = private global [16 x i8] c"numberWithBool:\00"
+// CHECK: [[WithBoolSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8]* [[WithBoolMeth]]
+// CHECK: [[WithIntegerMeth:@.*]] = private global [19 x i8] c"numberWithInteger:\00"
+// CHECK: [[WithIntegerSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([19 x i8]* [[WithIntegerMeth]]
+// CHECK: [[WithUnsignedIntegerMeth:@.*]] = private global [27 x i8] c"numberWithUnsignedInteger:\00"
+// CHECK: [[WithUnsignedIntegerSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([27 x i8]* [[WithUnsignedIntegerMeth]]
+// CHECK: [[stringWithUTF8StringMeth:@.*]] = private global [22 x i8] c"stringWithUTF8String:\00"
+// CHECK: [[stringWithUTF8StringSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([22 x i8]* [[stringWithUTF8StringMeth]]
 
 int main() {
   // CHECK: load i8** [[WithIntSEL]]
diff --git a/test/CodeGenObjC/catch-lexical-block.m b/test/CodeGenObjC/catch-lexical-block.m
index 618d3a2..d5aeee1 100644
--- a/test/CodeGenObjC/catch-lexical-block.m
+++ b/test/CodeGenObjC/catch-lexical-block.m
@@ -10,6 +10,6 @@
 // We should have 3 lexical blocks here at the moment, including one
 // for the catch block.
 // CHECK: lexical_block
-// CHECK: lexical_block
 // CHECK: auto_variable
 // CHECK: lexical_block
+// CHECK: lexical_block
diff --git a/test/CodeGenObjC/category-super-class-meth.m b/test/CodeGenObjC/category-super-class-meth.m
index 5ba7adf..268f0b5 100644
--- a/test/CodeGenObjC/category-super-class-meth.m
+++ b/test/CodeGenObjC/category-super-class-meth.m
@@ -22,8 +22,8 @@
 @end
 
 // CHECK: define internal i8* @"\01+[Sub2(Category) copy]
-// CHECK: [[ONE:%.*]] = load %struct._class_t** @"\01L_OBJC_CLASSLIST_SUP_REFS_$_3"
+// CHECK: [[ONE:%.*]] = load %struct._class_t** @"OBJC_CLASSLIST_SUP_REFS_$_3"
 // CHECK: [[TWO:%.*]] = bitcast %struct._class_t* [[ONE]] to i8*
 // CHECK: [[THREE:%.*]] = getelementptr inbounds %struct._objc_super* [[OBJC_SUPER:%.*]], i32 0, i32 1
 // CHECK: store i8* [[TWO]], i8** [[THREE]]
-// CHECK: [[FOUR:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK: [[FOUR:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
diff --git a/test/CodeGenObjC/debug-info-block-captured-self.m b/test/CodeGenObjC/debug-info-block-captured-self.m
index 183e91b..87ef9a3 100644
--- a/test/CodeGenObjC/debug-info-block-captured-self.m
+++ b/test/CodeGenObjC/debug-info-block-captured-self.m
@@ -55,15 +55,15 @@
 // CHECK-NEXT:   %[[MEM2:.*]] = alloca i8*, align 8
 // CHECK:        store i8* [[BLOCK_DESC:%.*]], i8** %[[MEM1]], align 8
 // CHECK:        %[[TMP0:.*]] = load i8** %[[MEM1]]
-// CHECK:        call void @llvm.dbg.value(metadata !{i8* %[[TMP0]]}, i64 0, metadata ![[BDMD:[0-9]+]])
-// CHECK:        call void @llvm.dbg.declare(metadata !{i8* [[BLOCK_DESC]]}, metadata ![[BDMD:[0-9]+]])
+// CHECK:        call void @llvm.dbg.value(metadata !{i8* %[[TMP0]]}, i64 0, metadata ![[BDMD:[0-9]+]], metadata !{{.*}})
+// CHECK:        call void @llvm.dbg.declare(metadata !{i8* [[BLOCK_DESC]]}, metadata ![[BDMD:[0-9]+]], metadata !{{.*}})
 // CHECK:        %[[TMP1:.*]] = bitcast
 // CHECK-NEXT:   store
-// CHECK:        call void @llvm.dbg.declare(metadata !{<{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** {{.*}}}, metadata ![[SELF:.*]])
+// CHECK:        call void @llvm.dbg.declare(metadata !{<{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** {{.*}}}, metadata ![[SELF:.*]], metadata !{{.*}})
 // make sure we are still in the same function
 // CHECK: define {{.*}}__copy_helper_block_
 // Metadata
-// CHECK:        ![[MAIN:.*]] = {{.*}}!"Main"{{.*}}DW_TAG_structure_type{{.*}}line 23
+// CHECK:        ![[MAIN:.*]] = metadata !{metadata !"0x13\00Main\0023\00{{.*}}", {{.*}} ; [ DW_TAG_structure_type ] [Main] [line 23,
 // CHECK:        ![[PMAIN:.*]] = {{.*}}![[MAIN]]} ; [ DW_TAG_pointer_type ]{{.*}}from Main
 // CHECK:        ![[BDMD]] = metadata {{.*}}.block_descriptor
 // CHECK:        ![[SELF]] = {{.*}}![[PMAIN]]{{.*}}[ DW_TAG_auto_variable ] [self] [line 40]
diff --git a/test/CodeGenObjC/debug-info-block-type.m b/test/CodeGenObjC/debug-info-block-type.m
new file mode 100644
index 0000000..e50163e
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-block-type.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -fblocks -g  -triple x86_64-apple-darwin14 -x objective-c < %s -o - | FileCheck %s
+#define nil ((void*) 0)
+typedef signed char BOOL;
+// CHECK: ![[BOOL:[0-9]+]] = {{.*}} [ DW_TAG_typedef ] [BOOL] [line [[@LINE-1]]
+// CHECK: ![[ID:[0-9]+]] = {{.*}} [ DW_TAG_typedef ] [id]
+
+typedef BOOL (^SomeKindOfPredicate)(id obj);
+// CHECK: metadata ![[PTR:[0-9]+]]} ; [ DW_TAG_member ] [__FuncPtr]
+// CHECK: ![[PTR]] = {{.*}}, metadata ![[FNTYPE:[0-9]+]]} ; [ DW_TAG_pointer_type ]
+// CHECK: ![[FNTYPE]] = {{.*}} metadata ![[ARGS:[0-9]+]]{{.*}} ; [ DW_TAG_subroutine_type ]
+// CHECK: ![[ARGS]] = metadata !{metadata ![[BOOL]], metadata ![[ID]]}
+
+int main()
+{
+  SomeKindOfPredicate p = ^BOOL(id obj) { return obj != nil; };
+  // CHECK: metadata ![[PTR]]} ; [ DW_TAG_member ] [__FuncPtr] [line [[@LINE-1]], size 64, align 64, offset 128]
+  return p(nil);
+}
diff --git a/test/CodeGenObjC/debug-info-blocks.m b/test/CodeGenObjC/debug-info-blocks.m
index d025ca8..aaa28d2 100644
--- a/test/CodeGenObjC/debug-info-blocks.m
+++ b/test/CodeGenObjC/debug-info-blocks.m
@@ -7,8 +7,8 @@
 // CHECK: define {{.*}}_block_invoke
 // CHECK: %[[BLOCK:.*]] = bitcast i8* %.block_descriptor to <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>*, !dbg
 // CHECK-NEXT: store <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>* %[[BLOCK]], <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA:.*]], align
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{<{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]]}, metadata ![[SELF:[0-9]+]])
-// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{%1** %d}, metadata ![[D:[0-9]+]])
+// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{<{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** %[[ALLOCA]]}, metadata ![[SELF:[0-9]+]], metadata !{{.*}})
+// CHECK-NEXT: call void @llvm.dbg.declare(metadata !{%1** %d}, metadata ![[D:[0-9]+]], metadata !{{.*}})
 
 // rdar://problem/14386148
 // Test that we don't emit bogus line numbers for the helper functions.
diff --git a/test/CodeGenObjC/debug-info-getter-name.m b/test/CodeGenObjC/debug-info-getter-name.m
index 70d9936..cf38116 100644
--- a/test/CodeGenObjC/debug-info-getter-name.m
+++ b/test/CodeGenObjC/debug-info-getter-name.m
@@ -1,7 +1,7 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -fexceptions -fobjc-exceptions -g %s -o - | FileCheck %s
 
-// CHECK: {{.*}}, metadata !"-[InstanceVariablesEverywhereButTheInterface someString]", {{.*}}} ; [ DW_TAG_subprogram ]
+// CHECK: metadata !{metadata !"0x2e\00-[InstanceVariablesEverywhereButTheInterface someString]\00{{.*}}", {{.*}} ; [ DW_TAG_subprogram ]
 
 //rdar: //8498026
 
diff --git a/test/CodeGenObjC/debug-info-id-with-protocol.m b/test/CodeGenObjC/debug-info-id-with-protocol.m
index 7e96baf..b14c30a 100644
--- a/test/CodeGenObjC/debug-info-id-with-protocol.m
+++ b/test/CodeGenObjC/debug-info-id-with-protocol.m
@@ -36,6 +36,7 @@
     }
 }
 // Verify that the debug type for both variables is 'id'.
-// CHECK: metadata !{i32 {{[0-9]+}}, metadata !{{[0-9]+}}, metadata !"bad_carrier", null, i32 {{[0-9]+}}, metadata ![[IDTYPE:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_arg_variable ] [bad_carrier] [line 0]
-// CHECK: metadata !{i32 {{[0-9]+}}, metadata !{{[0-9]+}}, metadata !"good_carrier", null, i32 {{[0-9]+}}, metadata !{{.*}}[[IDTYPE]], i32 0, i32 0} ; [ DW_TAG_arg_variable ] [good_carrier] [line 0]
-// CHECK !{{.*}}[[IDTYPE]] = metadata !{i32 {{[0-9]+}}, null, metadata !"id", metadata !{{[0-9]+}}, i32 !{{[0-9]+}}, i64 0, i64 0, i64 0, i32 0, metadata !{{[0-9]+}}} ; [ DW_TAG_typedef ] [id]
+// CHECK: metadata !{metadata !"0x101\00bad_carrier\00{{[0-9]+}}\000", metadata !{{[0-9]+}}, null, metadata ![[IDTYPE:[0-9]+]]} ; [ DW_TAG_arg_variable ] [bad_carrier] [line 0]
+//
+// CHECK: metadata !{metadata !"0x101\00good_carrier\00{{[0-9]+}}\000", metadata !{{[0-9]+}}, null, metadata ![[IDTYPE]]} ; [ DW_TAG_arg_variable ] [good_carrier] [line 0]
+// CHECK !{{.*}}[[IDTYPE]] = metadata !{metadata !"0x16\00id\00{{[0-9]+}}\000\000\000\000", null, metadata !{{[0-9]+}}, metadata !{{[0-9]+}}} ; [ DW_TAG_typedef ] [id]
diff --git a/test/CodeGenObjC/debug-info-instancetype.m b/test/CodeGenObjC/debug-info-instancetype.m
index 1c15517..4a7c581 100644
--- a/test/CodeGenObjC/debug-info-instancetype.m
+++ b/test/CodeGenObjC/debug-info-instancetype.m
@@ -14,8 +14,8 @@
 @implementation Foo
 +(instancetype)defaultFoo {return 0;}
 // CHECK: ![[FOO:[0-9]+]] = metadata {{.*}}; [ DW_TAG_structure_type ] [Foo]
-// CHECK: metadata !"+[Foo defaultFoo]", metadata !"", i32 [[@LINE-2]], metadata ![[TYPE:[0-9]+]]
-// CHECK: ![[TYPE]] = {{.*}} metadata ![[RESULT:[0-9]+]], i32 {{.*}}, null, null, null} ; [ DW_TAG_subroutine_type ]
+// CHECK: metadata !{metadata !"0x2e\00+[Foo defaultFoo]\00+[Foo defaultFoo]\00\00[[@LINE-2]]\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[TYPE:[0-9]+]]
+// CHECK: ![[TYPE]] = {{.*}} metadata ![[RESULT:[0-9]+]], null, null, null} ; [ DW_TAG_subroutine_type ]
 // CHECK: ![[RESULT]] = metadata {{.*}}{metadata ![[FOOPTR:[0-9]+]],
 // CHECK: ![[FOOPTR]] = {{.*}}, metadata ![[FOO]]}{{.*}}[ DW_TAG_pointer_type ] {{.*}} [from Foo]
 @end
diff --git a/test/CodeGenObjC/debug-info-ivars-extension.m b/test/CodeGenObjC/debug-info-ivars-extension.m
index e43b598..9dd7152 100644
--- a/test/CodeGenObjC/debug-info-ivars-extension.m
+++ b/test/CodeGenObjC/debug-info-ivars-extension.m
@@ -26,8 +26,8 @@
 
 // CHECK: {{.*}} [ DW_TAG_structure_type ] [I]
 // Check for "a".
-// CHECK: {{.*}} [ DW_TAG_member ] [a] [line 7, size 32, align 32, offset 0] [from int]
+// CHECK: {{.*}} [ DW_TAG_member ] [a] [line 7, size 32, align 32, offset 0] [public] [from int]
 // Make sure we don't output the same type twice.
 // CHECK-NOT: {{.*}} [ DW_TAG_structure_type ] [I]
 // Check for "b".
-// CHECK: {{.*}} [ DW_TAG_member ] [b] [line 18, size 32, align 32, offset 0] [from int]
+// CHECK: {{.*}} [ DW_TAG_member ] [b] [line 18, size 32, align 32, offset 0] [public] [from int]
diff --git a/test/CodeGenObjC/debug-info-lifetime-crash.m b/test/CodeGenObjC/debug-info-lifetime-crash.m
index 81c7fbc..43e196e 100644
--- a/test/CodeGenObjC/debug-info-lifetime-crash.m
+++ b/test/CodeGenObjC/debug-info-lifetime-crash.m
@@ -13,10 +13,10 @@
 {
   // The debug type for these two will be identical, because we do not
   // actually emit the ownership qualifier.
-  // CHECK-DAG: metadata !"weakSelf", metadata !{{[0-9]+}}, i32 [[@LINE+1]], metadata ![[SELFTY:[0-9]+]], i32 0, i32 0, {{.*}}} ; [ DW_TAG_auto_variable ] [weakSelf]
+  // CHECK-DAG: metadata !{metadata !"0x100\00weakSelf\00[[@LINE+1]]\000"{{, [^,]+, [^,]+}}, metadata ![[SELFTY:[0-9]+]]} ; [ DW_TAG_auto_variable ] [weakSelf]
   __attribute__((objc_ownership(weak))) __typeof(self) weakSelf = self;
   Block = [^{
-  // CHECK-DAG: metadata !"strongSelf", metadata !{{[0-9]+}}, i32 [[@LINE+1]], metadata ![[SELFTY]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [strongSelf]
+  // CHECK-DAG: metadata !{metadata !"0x100\00strongSelf\00[[@LINE+1]]\000"{{, [^,]+, [^,]+}}, metadata ![[SELFTY]]} ; [ DW_TAG_auto_variable ] [strongSelf]
       __attribute__((objc_ownership(strong))) __typeof(self) strongSelf = weakSelf;
     } copy];
 }
diff --git a/test/CodeGenObjC/debug-info-nested-blocks.m b/test/CodeGenObjC/debug-info-nested-blocks.m
new file mode 100644
index 0000000..029348c
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-nested-blocks.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm -gdwarf-2 -fblocks -o - -x objective-c %s| FileCheck %s
+// This code triggered a bug where a dbg.declare intrinsic ended up with the
+// wrong parent and subsequently failed the Verifier.
+void baz(id b);
+void fub(id block);
+int foo(void);
+void bar(void) {
+  fub(^() {
+      id a;
+      id b = [a bar:^(int e){}];
+      if (b) {
+        ^() {
+            if ((0 && foo()) ? 1 : 0) {
+              baz([a aMessage]);
+            }
+        };
+      }
+  });
+}
+
+// Verify that debug info for BlockPointerDbgLoc is emitted for the
+// innermost block.
+//
+// CHECK: define {{.*}}void @__bar_block_invoke_3(i8* %.block_descriptor)
+// CHECK: %[[BLOCKADDR:.*]] = alloca <{{.*}}>*, align
+// CHECK: call void @llvm.dbg.declare(metadata !{{.*}}%[[BLOCKADDR]]
diff --git a/test/CodeGenObjC/debug-info-property-accessors.m b/test/CodeGenObjC/debug-info-property-accessors.m
index 4c7b984..4510dcf 100644
--- a/test/CodeGenObjC/debug-info-property-accessors.m
+++ b/test/CodeGenObjC/debug-info-property-accessors.m
@@ -5,7 +5,7 @@
 // Ensure we emit the names of explicit/renamed accessors even if they
 // are defined later in the implementation section.
 //
-// CHECK: metadata !{i32 {{.*}}, metadata !"blah", {{.*}} metadata !"isBlah", metadata !"", {{.*}}} ; [ DW_TAG_APPLE_property ] [blah]
+// CHECK: metadata !{metadata !"0x4200\00blah\00{{[0-9]+}}\00isBlah\00{{.*}}", {{.*}}} ; [ DW_TAG_APPLE_property ] [blah]
 
 @class NSString;
 extern void NSLog(NSString *format, ...);
diff --git a/test/CodeGenObjC/debug-info-property3.m b/test/CodeGenObjC/debug-info-property3.m
index f63e744..f09f821 100644
--- a/test/CodeGenObjC/debug-info-property3.m
+++ b/test/CodeGenObjC/debug-info-property3.m
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -S -emit-llvm -g %s -o - | FileCheck %s
 
-// CHECK: metadata !"p1", metadata !{{.*}}, i32 5, metadata !"", metadata !"", i32 2316, metadata !{{.*}}} ; [ DW_TAG_APPLE_property ]
+// CHECK: metadata !{metadata !"0x4200\00p1\005\00\00\002316", {{.*}}} ; [ DW_TAG_APPLE_property ]
 @interface I1
 @property int p1;
 @end
diff --git a/test/CodeGenObjC/debug-info-self.m b/test/CodeGenObjC/debug-info-self.m
index 7a484d8..c02ca57 100644
--- a/test/CodeGenObjC/debug-info-self.m
+++ b/test/CodeGenObjC/debug-info-self.m
@@ -14,6 +14,6 @@
 }
 @end
 
-// CHECK: metadata !{i32 {{.*}}, metadata ![[CTOR:.*]], metadata !"self", null, i32 16777216, metadata !{{.*}}, i32 1088, i32 0} ; [ DW_TAG_arg_variable ] [self] [line 0]
-// CHECK: metadata !{i32 {{.*}}, metadata ![[CTOR]], metadata !"_cmd", null, i32 33554432, metadata !{{.*}}, i32 64, i32 0} ; [ DW_TAG_arg_variable ] [_cmd] [line 0]
-// CHECK: metadata !{i32 {{.*}}, metadata ![[CTOR]], metadata !"myarg", metadata !{{.*}}, i32 50331659, metadata !{{.*}}, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [myarg] [line 11]
+// CHECK: metadata !{metadata !"0x101\00self\0016777216\001088", metadata ![[CTOR:.*]], null, metadata !{{.*}}} ; [ DW_TAG_arg_variable ] [self] [line 0]
+// CHECK: metadata !{metadata !"0x101\00_cmd\0033554432\0064", metadata ![[CTOR]], null, metadata !{{.*}}} ; [ DW_TAG_arg_variable ] [_cmd] [line 0]
+// CHECK: metadata !{metadata !"0x101\00myarg\0050331659\000", metadata ![[CTOR]], metadata !{{.*}}, metadata !{{.*}}} ; [ DW_TAG_arg_variable ] [myarg] [line 11]
diff --git a/test/CodeGenObjC/debug-info-static-var.m b/test/CodeGenObjC/debug-info-static-var.m
index 2c10d59..45f9d82 100644
--- a/test/CodeGenObjC/debug-info-static-var.m
+++ b/test/CodeGenObjC/debug-info-static-var.m
@@ -2,7 +2,7 @@
 // Radar 8801045
 // Do not emit AT_MIPS_linkage_name for static variable i
 
-// CHECK: metadata !"i", metadata !"i", metadata !""
+// CHECK: metadata !{metadata !"0x34\00i\00i\00\00{{.*}}"
 
 @interface A {
 }
diff --git a/test/CodeGenObjC/debug-info-variadic-method.m b/test/CodeGenObjC/debug-info-variadic-method.m
new file mode 100644
index 0000000..a4e759d
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-variadic-method.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -o - -emit-llvm -g %s | FileCheck %s
+
+// This test verifies that variadic ObjC methods get the
+// DW_TAG_unspecified_parameter marker.
+
+@interface Foo
+- (void) Bar: (int) n, ...;
+@end
+
+@implementation Foo
+- (void) Bar: (int) n, ...
+{
+  // CHECK: metadata ![[NUM:[^,]*]], null, null, null} ; [ DW_TAG_subroutine_type ]
+  // CHECK: ![[NUM]] = {{metadata !{null, metadata ![^,]*, metadata ![^,]*, metadata ![^,]*, null}}}    
+}
+@end
diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m
index 6f2423b..b61fbb3 100644
--- a/test/CodeGenObjC/encode-test.m
+++ b/test/CodeGenObjC/encode-test.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s
 // RUN: FileCheck < %t %s
 //
-// CHECK: @"\01L_OBJC_METH_VAR_TYPE_34" = private global [16 x i8] c"v12@0:4[3[4@]]8\00"
+// CHECK: @OBJC_METH_VAR_TYPE_34 = private global [16 x i8] c"v12@0:4[3[4@]]8\00"
 
 @class Int1;
 
diff --git a/test/CodeGenObjC/exceptions-asm-attribute.m b/test/CodeGenObjC/exceptions-asm-attribute.m
new file mode 100644
index 0000000..c5ef467
--- /dev/null
+++ b/test/CodeGenObjC/exceptions-asm-attribute.m
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -fobjc-exceptions -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s
+// RUN: FileCheck -check-prefix=CHECK-EHTYPE < %t %s
+// rdar://16462586
+
+// We need exactly 3 of these.
+// CHECK-EHTYPE: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
+// CHECK-EHTYPE: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
+// CHECK-EHTYPE: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
+// CHECK-EHTYPE-NOT: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
+
+// CHECK-X86_64: @"OBJC_CLASS_$_MySecretNamespace.A" = global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64: @"OBJC_METACLASS_$_MySecretNamespace.A" = global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64: @OBJC_CLASS_NAME_ = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 8
+// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
+// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = global {{.*}}, section "__DATA,__objc_const", align 8
+// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8
+// CHECK-X86_64: define internal void @"\01-[A im0]"
+// CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s
+
+// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64-HIDDEN: @"OBJC_METACLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak hidden global {{.*}}, section "__DATA,__datacoal_nt,coalesced"
+// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
+// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = hidden global {{.*}}, section "__DATA,__objc_const", align 8
+// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
+// CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
+
+// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-exceptions -emit-llvm -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
+
+// CHECK-ARMV6: @"OBJC_CLASS_$_MySecretNamespace.A" = global {{.*}}, section "__DATA, __objc_data", align 4
+// CHECK-ARMV6: @"OBJC_METACLASS_$_MySecretNamespace.A" = global {{.*}}, section "__DATA, __objc_data", align 4
+// CHECK-ARMV6: @OBJC_CLASS_NAME_ = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 4
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = global {{.*}}, section "__DATA,__objc_const", align 4
+// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4
+// CHECK-ARMV6: define internal void @"\01-[A im0]"
+// CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]"
+
+__attribute__((objc_runtime_name("MySecretNamespace.A")))
+@interface A
+@end
+
+@implementation A
+-(void) im0 {
+}
+@end
+
+@implementation A (Cat)
+-(void) im1 {
+}
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.EH1")))
+@interface EH1
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.EH2")))
+__attribute__((__objc_exception__))
+@interface EH2
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.EH3")))
+__attribute__((__objc_exception__))
+@interface EH3
+@end
+
+void f1();
+
+void f0(id x) {
+  @try {
+    f1();
+  } @catch (EH1 *x) {
+  } @catch (EH2 *x) {
+  } @catch (EH3 *x) {
+  }
+}
+
+@implementation EH3
+@end
diff --git a/test/CodeGenObjC/externally-initialized-selectors.m b/test/CodeGenObjC/externally-initialized-selectors.m
index 0b7c24e..7dcd727 100644
--- a/test/CodeGenObjC/externally-initialized-selectors.m
+++ b/test/CodeGenObjC/externally-initialized-selectors.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | FileCheck %s
 // RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck %s
 
-// CHECK: @"\01L_OBJC_SELECTOR_REFERENCES_" = private externally_initialized global
+// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global
 
 void test(id x) {
   [x doSomething];
diff --git a/test/CodeGenObjC/forward-protocol-metadata-symbols.m b/test/CodeGenObjC/forward-protocol-metadata-symbols.m
index 2b687d1..2e7ee63 100644
--- a/test/CodeGenObjC/forward-protocol-metadata-symbols.m
+++ b/test/CodeGenObjC/forward-protocol-metadata-symbols.m
@@ -23,4 +23,4 @@
 // CHECK: @"\01l_OBJC_LABEL_PROTOCOL_$_P0" = weak hidden global
 // CHECK: @"\01l_OBJC_PROTOCOL_REFERENCE_$_P0" = weak hidden global
 
-// CHECK: llvm.compiler.used = appending global [10 x i8*] {{[^"]*}}"\01L_OBJC_CLASS_NAME_"{{[^"]*}}"\01L_OBJC_METH_VAR_NAME_"{{[^"]*}}"\01L_OBJC_METH_VAR_TYPE_"{{[^"]*}}"\01l_OBJC_$_CLASS_METHODS_A"{{[^"]*}}"\01l_OBJC_CLASS_PROTOCOLS_$_A"{{[^"]*}}"\01L_OBJC_CLASS_NAME_1"{{[^"]*}}"\01l_OBJC_PROTOCOL_$_P0"{{[^"]*}}"\01l_OBJC_LABEL_PROTOCOL_$_P0"{{[^"]*}}"\01l_OBJC_PROTOCOL_REFERENCE_$_P0"{{[^"]*}}"\01L_OBJC_LABEL_CLASS_$"{{[^"]*}} section "llvm.metadata"
+// CHECK: llvm.compiler.used = appending global [10 x i8*] {{[^"]*}}OBJC_CLASS_NAME_{{[^"]*}}OBJC_METH_VAR_NAME_{{[^"]*}}OBJC_METH_VAR_TYPE_{{[^"]*}}"\01l_OBJC_$_CLASS_METHODS_A"{{[^"]*}}"\01l_OBJC_CLASS_PROTOCOLS_$_A"{{[^"]*}}OBJC_CLASS_NAME_1{{[^"]*}}"\01l_OBJC_PROTOCOL_$_P0"{{[^"]*}}"\01l_OBJC_LABEL_PROTOCOL_$_P0"{{[^"]*}}"\01l_OBJC_PROTOCOL_REFERENCE_$_P0"{{[^"]*}}"OBJC_LABEL_CLASS_$"{{[^"]*}} section "llvm.metadata"
diff --git a/test/CodeGenObjC/ivar-layout-64.m b/test/CodeGenObjC/ivar-layout-64.m
index 068d109..0dfdbb9 100644
--- a/test/CodeGenObjC/ivar-layout-64.m
+++ b/test/CodeGenObjC/ivar-layout-64.m
@@ -33,9 +33,9 @@
 @property int p3;
 @end
 
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"C\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"\11p\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"!`\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"C\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\11p\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"!`\00"
 
 
 @implementation C
@@ -48,9 +48,9 @@
 @property (assign) __weak id p2;
 @end
 
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"A\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"\11q\10\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"!q\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"A\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\11q\10\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"!q\00"
 
 @implementation A
 @synthesize p0 = _p0;
@@ -62,9 +62,9 @@
 @property int p3;
 @end
 
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"D\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"\11p\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"!`\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"D\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\11p\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"!`\00"
 
 @implementation D
 @synthesize p3 = _p3;
@@ -89,8 +89,8 @@
 }
 @end
 
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"NSFileLocationComponent\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"\01\14\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"NSFileLocationComponent\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\01\14\00"
 
 @implementation NSFileLocationComponent @end
 
@@ -108,7 +108,7 @@
 }
 @end
 
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"Foo\00"
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{.*}}" = private global {{.*}} c"\02\10\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"Foo\00"
+// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\02\10\00"
 
 @implementation Foo @end
diff --git a/test/CodeGenObjC/mangle-blocks.m b/test/CodeGenObjC/mangle-blocks.m
new file mode 100644
index 0000000..f0339c1
--- /dev/null
+++ b/test/CodeGenObjC/mangle-blocks.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i386-apple-ios -fblocks -emit-llvm -o - %s -Wno-objc-root-class \
+// RUN:   | FileCheck %s
+
+void __assert_rtn(const char *, const char *, int, const char *);
+
+@interface Test
+- (void (^)(void)) mangle;
+@end
+
+@implementation Test
+- (void (^)(void)) mangle {
+  return ^() {
+    void (^b)(void) = ^() {
+      __assert_rtn(__func__, __FILE__, __LINE__, "mangle");
+    };
+  };
+}
+@end
+
+// CHECK: @"__func__.__14-[Test mangle]_block_invoke_2" = private unnamed_addr constant [34 x i8] c"__14-[Test mangle]_block_invoke_2\00", align 1
+// CHECK: @.str = private unnamed_addr constant {{.*}}, align 1
+// CHECK: @.str1 = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
+
+// CHECK: define internal void @"__14-[Test mangle]_block_invoke"(i8* %.block_descriptor)
+
+// CHECK: define internal void @"__14-[Test mangle]_block_invoke_2"(i8* %.block_descriptor){{.*}}{
+// CHECK: call void @__assert_rtn(i8* getelementptr inbounds ([34 x i8]* @"__func__.__14-[Test mangle]_block_invoke_2", i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 14, i8* getelementptr inbounds ([7 x i8]* @.str1, i32 0, i32 0))
+// CHECK: }
+
diff --git a/test/CodeGenObjC/metadata-symbols-32.m b/test/CodeGenObjC/metadata-symbols-32.m
index 61279e1..c75f641 100644
--- a/test/CodeGenObjC/metadata-symbols-32.m
+++ b/test/CodeGenObjC/metadata-symbols-32.m
@@ -2,30 +2,30 @@
 
 // CHECK: .lazy_reference .objc_class_name_J0
 
-// CHECK: @"\01L_OBJC_METH_VAR_NAME_{{[0-9]*}}" = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
-// CHECK: @"\01L_OBJC_METH_VAR_TYPE_{{[0-9]*}}" = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK: @OBJC_METH_VAR_NAME_{{[0-9]*}} = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK: @OBJC_METH_VAR_TYPE_{{[0-9]*}} = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
 // CHECK: @"\01l_OBJC_PROTOCOLEXT_P" = private global
 // CHECK-NOT: section
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{[0-9]*}}" = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
-// CHECK: @"\01L_OBJC_PROTOCOL_INSTANCE_METHODS_P" = private global {{.*}}section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_PROTOCOL_CLASS_METHODS_P" = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_PROTOCOL_P" = private global {{.*}}section "__OBJC,__protocol,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_PROTOCOLS_A" = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_METHODS_A" = private global {{.*}}section "__OBJC,__cls_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_METACLASS_A" = private global {{.*}}section "__OBJC,__meta_class,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_INSTANCE_VARIABLES_A" = private global {{.*}}section "__OBJC,__instance_vars,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_INSTANCE_METHODS_A" = private global {{.*}}section "__OBJC,__inst_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_PROP_NAME_ATTR_{{[0-9]*}}" = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK: @OBJC_CLASS_NAME_{{[0-9]*}} = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK: @OBJC_PROTOCOL_INSTANCE_METHODS_P = private global {{.*}}section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_PROTOCOL_CLASS_METHODS_P = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_PROTOCOL_P = private global {{.*}}section "__OBJC,__protocol,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_PROTOCOLS_A = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_METHODS_A = private global {{.*}}section "__OBJC,__cls_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_METACLASS_A = private global {{.*}}section "__OBJC,__meta_class,regular,no_dead_strip", align 4
+// CHECK: @OBJC_INSTANCE_VARIABLES_A = private global {{.*}}section "__OBJC,__instance_vars,regular,no_dead_strip", align 4
+// CHECK: @OBJC_INSTANCE_METHODS_A = private global {{.*}}section "__OBJC,__inst_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_PROP_NAME_ATTR_{{[0-9]*}} = private global {{.*}}section "__TEXT,__cstring,cstring_literals", align 1
 // CHECK: @"\01l_OBJC_$_PROP_LIST_A" = private global {{.*}}section "__OBJC,__property,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASSEXT_A" = private global {{.*}}section "__OBJC,__class_ext,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_A" = private global {{.*}}section "__OBJC,__class,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CATEGORY_INSTANCE_METHODS_A_Cat" = private global {{.*}}section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CATEGORY_CLASS_METHODS_A_Cat" = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CATEGORY_A_Cat" = private global {{.*}}section "__OBJC,__category,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_REFERENCES_{{[0-9]*}}" = private global {{.*}}section "__OBJC,__cls_refs,literal_pointers,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_SELECTOR_REFERENCES_{{[0-9]*}}" = private externally_initialized global {{.*}}section "__OBJC,__message_refs,literal_pointers,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_SYMBOLS" = private global {{.*}}section "__OBJC,__symbols,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_MODULES" = private global {{.*}}section "__OBJC,__module_info,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASSEXT_A = private global {{.*}}section "__OBJC,__class_ext,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_A = private global {{.*}}section "__OBJC,__class,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CATEGORY_INSTANCE_METHODS_A_Cat = private global {{.*}}section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CATEGORY_CLASS_METHODS_A_Cat = private global {{.*}}section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CATEGORY_A_Cat = private global {{.*}}section "__OBJC,__category,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_REFERENCES_{{[0-9]*}} = private global {{.*}}section "__OBJC,__cls_refs,literal_pointers,no_dead_strip", align 4
+// CHECK: @OBJC_SELECTOR_REFERENCES_{{[0-9]*}} = private externally_initialized global {{.*}}section "__OBJC,__message_refs,literal_pointers,no_dead_strip", align 4
+// CHECK: @OBJC_SYMBOLS = private global {{.*}}section "__OBJC,__symbols,regular,no_dead_strip", align 4
+// CHECK: @OBJC_MODULES = private global {{.*}}section "__OBJC,__module_info,regular,no_dead_strip", align 4
 
 // Clang's Obj-C 32-bit doesn't emit ivars for the root class.
 // CHECKX: @"\01L_OBJC_CLASS_VARIABLES_A" = private global {{.*}}section "__OBJC,__class_vars,regular,no_dead_strip", align 4
diff --git a/test/CodeGenObjC/metadata-symbols-64.m b/test/CodeGenObjC/metadata-symbols-64.m
index 7b96093..8f598f4 100644
--- a/test/CodeGenObjC/metadata-symbols-64.m
+++ b/test/CodeGenObjC/metadata-symbols-64.m
@@ -5,9 +5,9 @@
 // CHECK: @_objc_empty_vtable = external global
 // CHECK: @"OBJC_CLASS_$_A" = global
 // CHECK: @"OBJC_METACLASS_$_A" = global {{.*}} section "__DATA, __objc_data", align 8
-// CHECK: @"\01L_OBJC_CLASS_NAME_{{[0-9]*}}" = private global {{.*}} section "__TEXT,__objc_classname,cstring_literals", align 1
-// CHECK: @"\01L_OBJC_METH_VAR_NAME_{{[0-9]*}}" = private global {{.*}} section "__TEXT,__objc_methname,cstring_literals", align 1
-// CHECK: @"\01L_OBJC_METH_VAR_TYPE_{{[0-9]*}}" = private global {{.*}} section "__TEXT,__objc_methtype,cstring_literals", align 1
+// CHECK: @OBJC_CLASS_NAME_{{[0-9]*}} = private global {{.*}} section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK: @OBJC_METH_VAR_NAME_{{[0-9]*}} = private global {{.*}} section "__TEXT,__objc_methname,cstring_literals", align 1
+// CHECK: @OBJC_METH_VAR_TYPE_{{[0-9]*}} = private global {{.*}} section "__TEXT,__objc_methtype,cstring_literals", align 1
 // CHECK: @"\01l_OBJC_$_CLASS_METHODS_A" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_PROTOCOL_INSTANCE_METHODS_P" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_PROTOCOL_CLASS_METHODS_P" = private global {{.*}} section "__DATA, __objc_const", align 8
@@ -17,20 +17,20 @@
 // CHECK: @"\01l_OBJC_METACLASS_RO_$_A" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_INSTANCE_METHODS_A" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_INSTANCE_VARIABLES_A" = private global {{.*}} section "__DATA, __objc_const", align 8
-// CHECK: @"\01L_OBJC_PROP_NAME_ATTR_{{[0-9]*}}" = private global {{.*}} section "__TEXT,__cstring,cstring_literals", align 1
+// CHECK: @OBJC_PROP_NAME_ATTR_{{[0-9]*}} = private global {{.*}} section "__TEXT,__cstring,cstring_literals", align 1
 // CHECK: @"\01l_OBJC_$_PROP_LIST_A" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_CLASS_RO_$_A" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_CATEGORY_INSTANCE_METHODS_A_$_Cat" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_CATEGORY_CLASS_METHODS_A_$_Cat" = private global {{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_CATEGORY_A_$_Cat" = private global {{.*}} section "__DATA, __objc_const", align 8
-// CHECK: @"\01L_OBJC_CLASSLIST_SUP_REFS_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8
-// CHECK: @"\01L_OBJC_SELECTOR_REFERENCES_" = private externally_initialized global {{.*}} section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
-// CHECK: @"\01L_OBJC_CLASSLIST_SUP_REFS_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8
+// CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8
+// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global {{.*}} section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
+// CHECK: @"OBJC_CLASSLIST_SUP_REFS_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8
 // CHECK: @"OBJC_CLASS_$_B" = external global
-// CHECK: @"\01L_OBJC_CLASSLIST_REFERENCES_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
+// CHECK: @"OBJC_CLASSLIST_REFERENCES_$_{{[0-9]*}}" = private global {{.*}} section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8
 // CHECK: @"\01l_objc_msgSend_fixup_alloc" = weak hidden global {{.*}} section "__DATA, __objc_msgrefs, coalesced", align 16
-// CHECK: @"\01L_OBJC_LABEL_CLASS_$" = private global {{.*}} section "__DATA, __objc_classlist, regular, no_dead_strip", align 8
-// CHECK: @"\01L_OBJC_LABEL_CATEGORY_$" = private global {{.*}} section "__DATA, __objc_catlist, regular, no_dead_strip", align 8
+// CHECK: @"OBJC_LABEL_CLASS_$" = private global {{.*}} section "__DATA, __objc_classlist, regular, no_dead_strip", align 8
+// CHECK: @"OBJC_LABEL_CATEGORY_$" = private global {{.*}} section "__DATA, __objc_catlist, regular, no_dead_strip", align 8
 // CHECK: @objc_msgSend_fpret(
 // CHECK: @objc_msgSend_fixup(
 
diff --git a/test/CodeGenObjC/metadata_symbols.m b/test/CodeGenObjC/metadata_symbols.m
index 2b61c5d..2c44fb5 100644
--- a/test/CodeGenObjC/metadata_symbols.m
+++ b/test/CodeGenObjC/metadata_symbols.m
@@ -10,11 +10,11 @@
 
 // CHECK-X86_64: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 8
 // CHECK-X86_64: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 8
-// CHECK-X86_64: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK-X86_64: @OBJC_CLASS_NAME_ = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 8
 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH2" = external global
 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 8
-// CHECK-X86_64: @"\01L_OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8
+// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8
 // CHECK-X86_64: define internal void @"\01-[A im0]"
 // CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
 
@@ -34,11 +34,11 @@
 
 // CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4
 // CHECK-ARMV6: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4
-// CHECK-ARMV6: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK-ARMV6: @OBJC_CLASS_NAME_ = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
 // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 4
 // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH2" = external global
 // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 4
-// CHECK-ARMV6: @"\01L_OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4
+// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4
 // CHECK-ARMV6: define internal void @"\01-[A im0]"
 // CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]"
 
diff --git a/test/CodeGenObjC/non-lazy-classes.m b/test/CodeGenObjC/non-lazy-classes.m
index 760ddad..400d3e9 100644
--- a/test/CodeGenObjC/non-lazy-classes.m
+++ b/test/CodeGenObjC/non-lazy-classes.m
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
-// RUN: grep '@".01L_OBJC_LABEL_NONLAZY_CLASS_$" = private global \[1 x .*\] .*@"OBJC_CLASS_$_A".*, section "__DATA, __objc_nlclslist, regular, no_dead_strip", align 8' %t
-// RUN: grep '@".01L_OBJC_LABEL_NONLAZY_CATEGORY_$" = private global \[1 x .*\] .*@".01l_OBJC_$_CATEGORY_A_$_Cat".*, section "__DATA, __objc_nlcatlist, regular, no_dead_strip", align 8' %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | \
+// RUN: FileCheck %s
+// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [1 x {{.*}}] {{.*}}@"OBJC_CLASS_$_A"{{.*}}, section "__DATA, __objc_nlclslist, regular, no_dead_strip", align 8
+// CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private global [1 x {{.*}}] {{.*}}@"\01l_OBJC_$_CATEGORY_A_$_Cat"{{.*}}, section "__DATA, __objc_nlcatlist, regular, no_dead_strip", align 8
 
 @interface A @end
 @implementation A
diff --git a/test/CodeGenObjC/objc-align.m b/test/CodeGenObjC/objc-align.m
index 2b2133e..4276335 100644
--- a/test/CodeGenObjC/objc-align.m
+++ b/test/CodeGenObjC/objc-align.m
@@ -1,33 +1,14 @@
 // 32-bit
 
 // RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s
-// CHECK: @"\01L_OBJC_METACLASS_A" = private global {{.*}}, section "__OBJC,__meta_class,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_A" = private global {{.*}}, section "__OBJC,__class,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CATEGORY_A_Cat" = private global {{.*}}, section "__OBJC,__category,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_PROTOCOL_P" = private global {{.*}}, section "__OBJC,__protocol,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_PROTOCOLS_C" = private global {{.*}}, section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_METACLASS_C" = private global {{.*}}, section "__OBJC,__meta_class,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_CLASS_C" = private global {{.*}}, section "__OBJC,__class,regular,no_dead_strip", align 4
-// CHECK: @"\01L_OBJC_MODULES" = private global {{.*}}, section "__OBJC,__module_info,regular,no_dead_strip", align 4
-
-// 64-bit
-
-// RUNX: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
-// RUNX: grep '@"OBJC_CLASS_$_A" = global' %t &&
-// RUNX: grep '@"OBJC_CLASS_$_C" = global' %t &&
-// RUNX: grep '@"OBJC_METACLASS_$_A" = global' %t &&
-// RUNX: grep '@"OBJC_METACLASS_$_C" = global' %t &&
-// RUNX: grep '@"\\01L_OBJC_CLASSLIST_REFERENCES_$_0" = private global .*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8' %t &&
-// RUNX: grep '@"\\01L_OBJC_LABEL_CATEGORY_$" = private global .*, section "__DATA, __objc_catlist, regular, no_dead_strip", align 8' %t &&
-// RUNX: grep '@"\\01L_OBJC_LABEL_CLASS_$" = private global .*, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_$_CATEGORY_A_$_Cat" = private global .*, section "__DATA, __objc_const", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_CLASS_PROTOCOLS_$_C" = private global .*, section "__DATA, __objc_const", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_CLASS_RO_$_A" = private global .*, section "__DATA, __objc_const", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_CLASS_RO_$_C" = private global .*, section "__DATA, __objc_const", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_LABEL_PROTOCOL_$_P" = weak hidden global .*, section "__DATA, __objc_protolist, coalesced, no_dead_strip", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_METACLASS_RO_$_A" = private global .*, section "__DATA, __objc_const", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_METACLASS_RO_$_C" = private global .*, section "__DATA, __objc_const", align 8' %t &&
-// RUNX: grep '@"\\01l_OBJC_PROTOCOL_$_P" = weak hidden global .*, section "__DATA,__datacoal_nt,coalesced", align 8' %t &&
+// CHECK: @OBJC_METACLASS_A = private global {{.*}}, section "__OBJC,__meta_class,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_A = private global {{.*}}, section "__OBJC,__class,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CATEGORY_A_Cat = private global {{.*}}, section "__OBJC,__category,regular,no_dead_strip", align 4
+// CHECK: @OBJC_PROTOCOL_P = private global {{.*}}, section "__OBJC,__protocol,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_PROTOCOLS_C = private global {{.*}}, section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4
+// CHECK: @OBJC_METACLASS_C = private global {{.*}}, section "__OBJC,__meta_class,regular,no_dead_strip", align 4
+// CHECK: @OBJC_CLASS_C = private global {{.*}}, section "__OBJC,__class,regular,no_dead_strip", align 4
+// CHECK: @OBJC_MODULES = private global {{.*}}, section "__OBJC,__module_info,regular,no_dead_strip", align 4
 
 
 @interface A @end
diff --git a/test/CodeGenObjC/objc-asm-attribute-neg-test.m b/test/CodeGenObjC/objc-asm-attribute-neg-test.m
new file mode 100644
index 0000000..e9bef4c
--- /dev/null
+++ b/test/CodeGenObjC/objc-asm-attribute-neg-test.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://16462586
+
+__attribute__((objc_runtime_name("MySecretNamespace.Protocol")))
+@protocol Protocol
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@interface Message <Protocol> { 
+__attribute__((objc_runtime_name("MySecretNamespace.Message"))) // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
+  id MyIVAR;
+}
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@property int MyProperty; // expected-error {{prefix attribute must be followed by an interface or protocol}}}}
+
+- (int) getMyProperty __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
+
+- (void) setMyProperty : (int) arg __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
+
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.ForwardClass")))
+@class ForwardClass; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+__attribute__((objc_runtime_name("MySecretNamespace.ForwardProtocol")))
+@protocol ForwardProtocol;
+
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@implementation Message // expected-error {{prefix attribute must be followed by an interface or protocol}}
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+- (id) MyMethod {
+  return MyIVAR;
+}
+@end
diff --git a/test/CodeGenObjC/objc-asm-attribute-test.m b/test/CodeGenObjC/objc-asm-attribute-test.m
new file mode 100644
index 0000000..12903b52
--- /dev/null
+++ b/test/CodeGenObjC/objc-asm-attribute-test.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// rdar://16462586
+
+__attribute__((objc_runtime_name("MySecretNamespace.Protocol")))
+@protocol Protocol
+- (void) MethodP;
++ (void) ClsMethodP;
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.Protocol2")))
+@protocol Protocol2
+- (void) MethodP2;
++ (void) ClsMethodP2;
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@interface Message <Protocol, Protocol2> {
+  id MyIVAR;
+}
+@end
+
+@implementation Message
+- (id) MyMethod {
+  return MyIVAR;
+}
+
++ (id) MyClsMethod {
+  return 0;
+}
+
+- (void) MethodP{}
+- (void) MethodP2{}
+
++ (void) ClsMethodP {}
++ (void) ClsMethodP2 {}
+@end
+
+// rdar://16877359
+__attribute__((objc_runtime_name("foo")))
+@interface SLREarth
+- (instancetype)init;
++ (instancetype)alloc;
+@end
+
+id Test16877359() {
+    return [SLREarth alloc];
+}
+
+// CHECK: @"OBJC_IVAR_$_MySecretNamespace.Message.MyIVAR" = global i64
+// CHECK: @"OBJC_CLASS_$_MySecretNamespace.Message" = global %struct._class_t
+// CHECK: @"OBJC_METACLASS_$_MySecretNamespace.Message" = global %struct._class_t
+// CHECK: @"OBJC_CLASS_$_foo" = external global %struct._class_t
+// CHECK: define internal i8* @"\01-[Message MyMethod]"
+// CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_MySecretNamespace.Message.MyIVAR"
diff --git a/test/CodeGenObjC/objc-container-subscripting-1.m b/test/CodeGenObjC/objc-container-subscripting-1.m
index 91b7f46..9ddfd39 100644
--- a/test/CodeGenObjC/objc-container-subscripting-1.m
+++ b/test/CodeGenObjC/objc-container-subscripting-1.m
@@ -19,7 +19,7 @@
 
   id oldObject = array[10];
 // CHECK: [[ARR:%.*]] = load {{%.*}} [[array:%.*]], align 8
-// CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-NEXT: [[ARRC:%.*]] = bitcast {{%.*}} [[ARR]] to i8*
 // CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* [[ARRC]], i8* [[SEL]], i32 10)
 // CHECK-NEXT: store i8* [[CALL]], i8** [[OLDOBJ:%.*]], align 8
@@ -27,7 +27,7 @@
   val = (array[10] = oldObject);
 // CHECK: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
 // CHECK-NEXT: [[FOUR:%.*]] = load i8** [[oldObject:%.*]], align 8
-// CHECK-NEXT: [[FIVE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2"
+// CHECK-NEXT: [[FIVE:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_2
 // CHECK-NEXT: [[SIX:%.*]] = bitcast {{%.*}} [[THREE]] to i8*
 // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i32)*)(i8* [[SIX]], i8* [[FIVE]], i8* [[FOUR]], i32 10)
 // CHECK-NEXT: store i8* [[FOUR]], i8** [[val:%.*]]
@@ -38,7 +38,7 @@
   oldObject = dictionary[key];
 // CHECK:  [[SEVEN:%.*]] = load {{%.*}} [[DICTIONARY:%.*]], align 8
 // CHECK-NEXT:  [[EIGHT:%.*]] = load i8** [[KEY:%.*]], align 8
-// CHECK-NEXT:  [[TEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_4"
+// CHECK-NEXT:  [[TEN:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_4
 // CHECK-NEXT:  [[ELEVEN:%.*]] = bitcast {{%.*}} [[SEVEN]] to i8*
 // CHECK-NEXT:  [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[ELEVEN]], i8* [[TEN]], i8* [[EIGHT]])
 // CHECK-NEXT:  store i8* [[CALL1]], i8** [[oldObject:%.*]], align 8
@@ -48,7 +48,7 @@
 // CHECK: [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8
 // CHECK-NEXT:  [[THIRTEEN:%.*]] = load i8** [[KEY]], align 8
 // CHECK-NEXT:  [[FOURTEEN:%.*]] = load i8** [[NEWOBJECT:%.*]], align 8
-// CHECK-NEXT:  [[SIXTEEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_6"
+// CHECK-NEXT:  [[SIXTEEN:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_6
 // CHECK-NEXT:  [[SEVENTEEN:%.*]] = bitcast {{%.*}} [[TWELVE]] to i8*
 // CHECK-NEXT:  call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i8*)*)(i8* [[SEVENTEEN]], i8* [[SIXTEEN]], i8* [[FOURTEEN]], i8* [[THIRTEEN]])
 // CHECK-NEXT: store i8* [[FOURTEEN]], i8** [[val:%.*]]
diff --git a/test/CodeGenObjC/objc-fixed-enum.m b/test/CodeGenObjC/objc-fixed-enum.m
index 55c2a7c..9a028ea 100644
--- a/test/CodeGenObjC/objc-fixed-enum.m
+++ b/test/CodeGenObjC/objc-fixed-enum.m
@@ -34,13 +34,13 @@
 
 int main() {
   Enum0 e0 = Enum0One;
-  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM0:[0-9]+]])
+  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM0:[0-9]+]], metadata !{{.*}})
   Enum1 e1 = Enum1One;
-  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM1:[0-9]+]])
+  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM1:[0-9]+]], metadata !{{.*}})
   Enum2 e2 = Enum2One;
-  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM2:[0-9]+]])
+  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM2:[0-9]+]], metadata !{{.*}})
   Enum3 e3 = Enum3One;
-  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM3:[0-9]+]])
+  // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM3:[0-9]+]], metadata !{{.*}})
 
   // -Werror and the following line ensures that these enums are not
   // -treated as C++11 strongly typed enums.
@@ -51,14 +51,14 @@
 // CHECK: ![[ENUMERATOR3:[0-9]+]] = {{.*}}; [ DW_TAG_typedef ] [NSInteger] [line 6{{.*}}] [from long int]
 // CHECK: ![[ENUMERATOR2:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 22{{.*}}] [from NSInteger]
 
-// CHECK: ![[ENUM0]] = metadata !{{{.*}}!"e0", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE0:[0-9]+]]
-// CHECK: ![[TYPE0]] = metadata !{{{.*}}!"Enum0", {{.*}} metadata ![[ENUMERATOR0]]} ; [ DW_TAG_typedef ] [Enum0]
+// CHECK: ![[ENUM0]] = metadata !{metadata !"0x100\00e0\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[TYPE0:[0-9]+]]} ; [ DW_TAG_auto_variable ]
+// CHECK: ![[TYPE0]] = metadata !{metadata !"0x16\00Enum0\00{{.*}}", {{.*}}, metadata ![[ENUMERATOR0]]} ; [ DW_TAG_typedef ] [Enum0]
 
-// CHECK: ![[ENUM1]] = metadata !{{{.*}}!"e1", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE1:[0-9]+]]
-// CHECK: ![[TYPE1]] = metadata !{{{.*}}!"Enum1", {{.*}} metadata ![[ENUMERATOR1]]} ; [ DW_TAG_typedef ] [Enum1]
+// CHECK: ![[ENUM1]] = metadata !{metadata !"0x100\00e1\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[TYPE1:[0-9]+]]} ; [ DW_TAG_auto_variable ]
+// CHECK: ![[TYPE1]] = metadata !{metadata !"0x16\00Enum1\00{{.*}}", {{.*}}, metadata ![[ENUMERATOR1]]} ; [ DW_TAG_typedef ] [Enum1]
 
-// CHECK: ![[ENUM2]] = metadata !{{{.*}}!"e2", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE2:[0-9]+]]
-// CHECK: ![[TYPE2]] = metadata !{{{.*}}!"Enum2", {{.*}} metadata ![[ENUMERATOR2]]} ; [ DW_TAG_typedef ] [Enum2]
+// CHECK: ![[ENUM2]] = metadata !{metadata !"0x100\00e2\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[TYPE2:[0-9]+]]} ; [ DW_TAG_auto_variable ]
+// CHECK: ![[TYPE2]] = metadata !{metadata !"0x16\00Enum2\00{{.*}}", {{.*}}, metadata ![[ENUMERATOR2]]} ; [ DW_TAG_typedef ] [Enum2]
 
-// CHECK: ![[ENUM3]] = metadata !{{{.*}}!"e3", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE3:[0-9]+]]
-// CHECK: ![[TYPE3]] = metadata !{{{.*}}!"Enum3", {{.*}} metadata ![[ENUMERATOR3]]} ; [ DW_TAG_typedef ] [Enum3]
+// CHECK: ![[ENUM3]] = metadata !{metadata !"0x100\00e3\00{{[^,]*}}"{{, [^,]+, [^,]+}}, metadata ![[TYPE3:[0-9]+]]} ; [ DW_TAG_auto_variable ]
+// CHECK: ![[TYPE3]] = metadata !{metadata !"0x16\00Enum3\00{{.*}}", {{.*}}, metadata ![[ENUMERATOR3]]} ; [ DW_TAG_typedef ] [Enum3]
diff --git a/test/CodeGenObjC/optimize-ivar-offset-load.m b/test/CodeGenObjC/optimize-ivar-offset-load.m
index d34ac13..29f70be 100644
--- a/test/CodeGenObjC/optimize-ivar-offset-load.m
+++ b/test/CodeGenObjC/optimize-ivar-offset-load.m
@@ -44,7 +44,7 @@
     }
 }
 @end
-// CHECK: [[ZERO:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !invariant.load
+// CHECK: [[ZERO:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load
 // CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load
 
 @interface Sample : SampleClass @end
@@ -59,6 +59,6 @@
     }
 }
 @end
-// CHECK: [[ZERO:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !invariant.load 
+// CHECK: [[ZERO:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load 
 // CHECK: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_SampleClass._value", align 8, !invariant.load
 
diff --git a/test/CodeGenObjC/private-extern-selector-reference.m b/test/CodeGenObjC/private-extern-selector-reference.m
new file mode 100644
index 0000000..c954d77
--- /dev/null
+++ b/test/CodeGenObjC/private-extern-selector-reference.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-ios6.0.0 -emit-llvm -o - %s | FileCheck %s
+// rdar://18150301
+
+@interface Query
++ (void)_configureCI;
+@end
+
+__attribute__((visibility("default"))) __attribute__((availability(ios,introduced=7.0)))
+@interface ObserverQuery : Query @end
+
+@implementation ObserverQuery
++ (void)_configureCI {
+    [super _configureCI];
+}
+@end
+
+// CHECK: @"OBJC_METACLASS_$_ObserverQuery" = global %struct._class_t
+// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global
diff --git a/test/CodeGenObjC/property-array-type.m b/test/CodeGenObjC/property-array-type.m
index 6600fd0..84191ef 100644
--- a/test/CodeGenObjC/property-array-type.m
+++ b/test/CodeGenObjC/property-array-type.m
@@ -26,5 +26,5 @@
 
 // CHECK: [[M:%.*]] = getelementptr inbounds %struct._GLKMatrix4* [[TMP:%.*]], i32 0, i32 0
 // CHECK: [[ARRAYDECAY:%.*]] = getelementptr inbounds [16 x float]* [[M]], i32 0, i32 0
-// CHECK: [[SIX:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK: [[SIX:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK:  call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, float*)*)(i8* [[SEVEN:%.*]], i8* [[SIX]], float* [[ARRAYDECAY]])
diff --git a/test/CodeGenObjC/property-type-mismatch.m b/test/CodeGenObjC/property-type-mismatch.m
index b920b45..b5618cb 100644
--- a/test/CodeGenObjC/property-type-mismatch.m
+++ b/test/CodeGenObjC/property-type-mismatch.m
@@ -13,5 +13,5 @@
 // CHECK: [[C1:%.*]] = call float bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
 // CHECK: [[I:%.*]] = fadd float [[C1]], 1.000000e+00
 // CHECK: [[CONV:%.*]] = fptosi float [[I]] to i32
-// CHECK: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2"
+// CHECK: [[T3:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_2
 // CHECK:  call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
diff --git a/test/CodeGenObjC/property.m b/test/CodeGenObjC/property.m
index e156270..0f63a0f 100644
--- a/test/CodeGenObjC/property.m
+++ b/test/CodeGenObjC/property.m
@@ -136,33 +136,33 @@
 // CHECK:      [[T:%.*]] = alloca [[TEST7]]*,
 // CHECK-NEXT: store
 // CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
 // CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
 // CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
 // CHECK-NEXT: [[T4:%.*]] = and i32 [[T3]], 2
 // CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
 // CHECK-NEXT: call void bitcast
 // CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
 // CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
 // CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
 // CHECK-NEXT: [[T4:%.*]] = or i32 [[T3]], 5
 // CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
 // CHECK-NEXT: call void bitcast
 // CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
 // CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
 // CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
 // CHECK-NEXT: [[T4:%.*]] = xor i32 [[T3]], 8
 // CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES
 // CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
 // CHECK-NEXT: call void bitcast
 // CHECK-NEXT: ret void
diff --git a/test/CodeGenObjC/reorder-synthesized-ivars.m b/test/CodeGenObjC/reorder-synthesized-ivars.m
index 8faafff..958d447 100644
--- a/test/CodeGenObjC/reorder-synthesized-ivars.m
+++ b/test/CodeGenObjC/reorder-synthesized-ivars.m
@@ -38,21 +38,21 @@
 }
 @end
 
-// CHECK: @"{{.*}}" = private global [10 x i8] c"_boolean1
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean2
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean3
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean4
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean5
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean6
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean7
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean8
-// CHECK-NEXT: @"{{.*}}" = private global [10 x i8] c"_boolean9
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object1
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object2
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object3
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object4
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object5
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object6
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object7
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object8
-// CHECK-NEXT: @"{{.*}}" = private global [9 x i8] c"_object9
+// CHECK: @{{.*}} = private global [10 x i8] c"_boolean1
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean2
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean3
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean4
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean5
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean6
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean7
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean8
+// CHECK-NEXT: @{{.*}} = private global [10 x i8] c"_boolean9
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object1
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object2
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object3
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object4
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object5
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object6
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object7
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object8
+// CHECK-NEXT: @{{.*}} = private global [9 x i8] c"_object9
diff --git a/test/CodeGenObjC/return-objc-object.mm b/test/CodeGenObjC/return-objc-object.mm
index 25ed202..d756c4b 100644
--- a/test/CodeGenObjC/return-objc-object.mm
+++ b/test/CodeGenObjC/return-objc-object.mm
@@ -15,5 +15,5 @@
   f();
   f1();
 }
-// CHECK: call nonnull %0* @_Z1fv()
-// CHECK: call nonnull %0* @_Z2f1v()  
+// CHECK: call dereferenceable({{[0-9]+}}) %0* @_Z1fv()
+// CHECK: call dereferenceable({{[0-9]+}}) %0* @_Z2f1v()  
diff --git a/test/CodeGenObjC/selector-ref-invariance.m b/test/CodeGenObjC/selector-ref-invariance.m
index e356419..599bc3a 100644
--- a/test/CodeGenObjC/selector-ref-invariance.m
+++ b/test/CodeGenObjC/selector-ref-invariance.m
@@ -3,7 +3,7 @@
 // rdar://6027699
 
 void test(id x) {
-// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load
+// CHECK: load i8** @OBJC_SELECTOR_REFERENCES_, !invariant.load
 // CHECK: @objc_msgSend
   [x foo];
 }
diff --git a/test/CodeGenObjC/super-message-fragileabi.m b/test/CodeGenObjC/super-message-fragileabi.m
index b6c9086..2c917d7 100644
--- a/test/CodeGenObjC/super-message-fragileabi.m
+++ b/test/CodeGenObjC/super-message-fragileabi.m
@@ -24,7 +24,7 @@
  {
 	;
  }
-// CHECK: load %struct._objc_class** getelementptr inbounds (%struct._objc_class* @"\01L_OBJC_CLASS_BetterTable", i32 0, i32 1)
+// CHECK: load %struct._objc_class** getelementptr inbounds (%struct._objc_class* @OBJC_CLASS_BetterTable, i32 0, i32 1)
 
  return self;
 }
diff --git a/test/CodeGenObjC/tentative-cfconstantstring.m b/test/CodeGenObjC/tentative-cfconstantstring.m
index 714c1a4..2b2601a 100644
--- a/test/CodeGenObjC/tentative-cfconstantstring.m
+++ b/test/CodeGenObjC/tentative-cfconstantstring.m
@@ -35,8 +35,8 @@
 // CHECK: @_unnamed_cfstring_{{.*}} = private constant %struct.NSConstantString { i32* getelementptr inbounds ([24 x i32]* @__CFConstantStringClassReference, i32 0, i32 0)
 
 // CHECK-LABEL: define internal void @_inlineFunction()
-// CHECK:  [[ZERO:%.*]] = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_
-// CHECK-NEXT:   [[ONE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK:  [[ZERO:%.*]] = load %struct._class_t** @"OBJC_CLASSLIST_REFERENCES_
+// CHECK-NEXT:   [[ONE:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-NEXT:   [[TWO:%.*]] = bitcast %struct._class_t* [[ZERO]] to i8*
 // CHECK-NEXT:   call void (i8*, i8*, [[T:%.*]]*, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, [[T:%.*]]*, ...)*)(i8* [[TWO]], i8* [[ONE]], [[T:%.*]]* bitcast (%struct.NSConstantString* @_unnamed_cfstring_{{.*}} to [[T:%.*]]*))
 // CHECK-NEXT:   ret void
diff --git a/test/CodeGenObjC/undefined-protocol2.m b/test/CodeGenObjC/undefined-protocol2.m
new file mode 100644
index 0000000..f171523
--- /dev/null
+++ b/test/CodeGenObjC/undefined-protocol2.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm %s -o - | FileCheck %s
+
+// Test that we produce a declaration for the protocol. It must be matched
+// by a definition in another TU, so external is the correct linkage
+// (not extern_weak).
+// CHECK: @"\01l_OBJC_PROTOCOL_$_p1" = external global
+
+@interface NSObject
+@end
+
+@protocol p1;
+
+@interface I1 : NSObject <p1>
+@end
+
+@implementation I1
+@end
diff --git a/test/CodeGenObjC/weak-metaclass-visibility.m b/test/CodeGenObjC/weak-metaclass-visibility.m
index 128f881..d174bdb 100644
--- a/test/CodeGenObjC/weak-metaclass-visibility.m
+++ b/test/CodeGenObjC/weak-metaclass-visibility.m
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -emit-llvm  -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios -emit-llvm -o - %s | FileCheck %s
 // rdar://16206443
 
 @interface NSObject 
@@ -43,3 +45,16 @@
 
 // CHECK: @"OBJC_METACLASS_$_NSURLQueryItem" = extern_weak global
 // CHECK: @"OBJC_CLASS_$_NSURLQueryItem" = extern_weak global
+
+// rdar://17633301
+__attribute__((visibility("default"))) __attribute__((availability(ios,introduced=9876.5)))
+@interface AVScheduledAudioParameters @end
+
+@interface XXXX : AVScheduledAudioParameters
+@end
+
+@implementation AVScheduledAudioParameters @end
+@implementation XXXX @end
+
+// CHECK: @"OBJC_CLASS_$_AVScheduledAudioParameters" = global %struct._class_t
+// CHECK: @"OBJC_METACLASS_$_AVScheduledAudioParameters" = global %struct._class_t 
diff --git a/test/CodeGenObjCXX/arc-blocks.mm b/test/CodeGenObjCXX/arc-blocks.mm
index 4fc3885..2695b4d 100644
--- a/test/CodeGenObjCXX/arc-blocks.mm
+++ b/test/CodeGenObjCXX/arc-blocks.mm
@@ -38,7 +38,7 @@
   // CHECK-NEXT: load
   // CHECK-NEXT: [[T2:%.*]] = bitcast i8* {{.*}} to [[BYREF_A]]*
   // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_A]]* [[T2]], i32 0, i32 7
-  // CHECK-NEXT: call void @_ZN5test01AC1ERKS0_([[A]]* [[T1]], [[A]]* nonnull [[T3]])
+  // CHECK-NEXT: call void @_ZN5test01AC1ERKS0_([[A]]* [[T1]], [[A]]* dereferenceable({{[0-9]+}}) [[T3]])
   // CHECK-NEXT: ret void
 
   // CHECK:    define internal void [[DISPOSE_HELPER]](
diff --git a/test/CodeGenObjCXX/arc-cxx11-init-list.mm b/test/CodeGenObjCXX/arc-cxx11-init-list.mm
new file mode 100644
index 0000000..7356b6e
--- /dev/null
+++ b/test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm -o - %s \
+// RUN:     | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+template <typename _Ep>
+class initializer_list {
+  const _Ep* __begin_;
+  size_t __size_;
+
+  initializer_list(const _Ep* __b, size_t __s);
+};
+}
+
+@interface I
++ (instancetype) new;
+@end
+
+void function(std::initializer_list<I *>);
+
+extern "C" void single() { function({ [I new] }); }
+
+// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
+// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE]] to %0*
+// CHECK-NEXT: store %0* [[CAST]], %0** [[ARRAY:%.*]],
+// CHECK: call {{.*}} void @objc_release(i8* {{.*}})
+
+extern "C" void multiple() { function({ [I new], [I new] }); }
+
+// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
+// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE]] to %0*
+// CHECK-NEXT: store %0* [[CAST]], %0** [[ARRAY:%.*]],
+// CHECK: call {{.*}} void @objc_release(i8* {{.*}})
+// CHECK-NEXT: icmp eq
+
+void external();
+
+extern "C" void extended() {
+  const auto && temporary = { [I new] };
+  external();
+}
+
+// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
+// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE:%.*]] to {{.*}}*
+// CHECK-NEXT: store {{.*}}* [[CAST]], {{.*}}** {{.*}}
+// CHECK: {{.*}} call {{.*}} void @_Z8externalv()
+// CHECK: {{.*}} call {{.*}} void @objc_release(i8* {{.*}})
+
+std::initializer_list<I *> il = { [I new] };
+
+// CHECK: [[POOL:%.*]] = {{.*}} call {{.*}} i8* @objc_autoreleasePoolPush()
+// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
+// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE]] to %0*
+// CHECK-NEXT: store %0* [[CAST]], %0** getelementptr inbounds ([1 x %0*]* @_ZGR2il_, i32 0, i32 0)
+// CHECK: {{.*}} call {{.*}} void @objc_autoreleasePoolPop(i8* [[POOL]])
+
diff --git a/test/CodeGenObjCXX/arc-cxx11-member-init.mm b/test/CodeGenObjCXX/arc-cxx11-member-init.mm
index 213e7a1..5129f9f 100644
--- a/test/CodeGenObjCXX/arc-cxx11-member-init.mm
+++ b/test/CodeGenObjCXX/arc-cxx11-member-init.mm
@@ -23,10 +23,23 @@
 @end
 
 // CHECK: [[mClipData:%.*]] = getelementptr inbounds %class.XClipboardDataSet* 
-// CHECK: [[ZERO:%.*]] = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_"
-// CHECK: [[ONE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK: [[ZERO:%.*]] = load %struct._class_t** @"OBJC_CLASSLIST_REFERENCES_$_"
+// CHECK: [[ONE:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK: [[TWO:%.*]] = bitcast %struct._class_t* [[ZERO]] to i8*
 // CHECK: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[TWO]], i8* [[ONE]])
 // CHECK: [[THREE:%.*]] = bitcast i8* [[CALL]] to [[T:%.*]]*
 // CHECK: store [[T]]* [[THREE]], [[T]]** [[mClipData]], align 8
 
+// rdar://18950072
+struct Butt { };
+
+__attribute__((objc_root_class))
+@interface Foo {
+  Butt x;
+  Butt y;
+  Butt z;
+}
+@end
+@implementation Foo
+@end
+// CHECK-NOT: define internal i8* @"\01-[Foo .cxx_construct
diff --git a/test/CodeGenObjCXX/arc-move.mm b/test/CodeGenObjCXX/arc-move.mm
index 7e90388..d7b9f55 100644
--- a/test/CodeGenObjCXX/arc-move.mm
+++ b/test/CodeGenObjCXX/arc-move.mm
@@ -33,7 +33,7 @@
 
 // CHECK-LABEL: define void @_Z12library_moveRU8__strongP11objc_objectS2_
 void library_move(__strong id &x, __strong id &y) {
-  // CHECK: call nonnull i8** @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
+  // CHECK: call dereferenceable({{[0-9]+}}) i8** @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
   // CHECK: load i8**
   // CHECK: store i8* null, i8**
   // CHECK: load i8***
@@ -46,7 +46,7 @@
 
 // CHECK-LABEL: define void @_Z12library_moveRU8__strongP11objc_object
 void library_move(__strong id &y) {
-  // CHECK: [[Y:%[a-zA-Z0-9]+]] = call nonnull i8** @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
+  // CHECK: [[Y:%[a-zA-Z0-9]+]] = call dereferenceable({{[0-9]+}}) i8** @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
   // Load the object
   // CHECK-NEXT: [[OBJ:%[a-zA-Z0-9]+]] = load i8** [[Y]]
   // Null out y
@@ -65,7 +65,7 @@
 // CHECK-LABEL: define void @_Z10const_moveRKU8__strongP11objc_object(
 void const_move(const __strong id &x) {
   // CHECK:      [[Y:%.*]] = alloca i8*,
-  // CHECK:      [[X:%.*]] = call nonnull i8** @_Z4moveIRKU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_(
+  // CHECK:      [[X:%.*]] = call dereferenceable({{[0-9]+}}) i8** @_Z4moveIRKU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_(
   // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
   // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
   // CHECK-NEXT: store i8* [[T1]], i8** [[Y]]
diff --git a/test/CodeGenObjCXX/arc-references.mm b/test/CodeGenObjCXX/arc-references.mm
index 10e7f64..0acb6d5 100644
--- a/test/CodeGenObjCXX/arc-references.mm
+++ b/test/CodeGenObjCXX/arc-references.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
 
 @interface A
 @end
diff --git a/test/CodeGenObjCXX/arc-special-member-functions.mm b/test/CodeGenObjCXX/arc-special-member-functions.mm
index c8c6dd7..8b002d5 100644
--- a/test/CodeGenObjCXX/arc-special-member-functions.mm
+++ b/test/CodeGenObjCXX/arc-special-member-functions.mm
@@ -91,7 +91,7 @@
 }
 
 // Implicitly-generated copy assignment operator for ObjCBlockMember
-// CHECK:    define linkonce_odr nonnull {{%.*}}* @_ZN15ObjCBlockMemberaSERKS_(
+// CHECK:    define linkonce_odr dereferenceable({{[0-9]+}}) {{%.*}}* @_ZN15ObjCBlockMemberaSERKS_(
 // CHECK:      [[T0:%.*]] = getelementptr inbounds [[T:%.*]]* {{%.*}}, i32 0, i32 0
 // CHECK-NEXT: [[T1:%.*]] = load i32 (i32)** [[T0]], align 8
 // CHECK-NEXT: [[T2:%.*]] = bitcast i32 (i32)* [[T1]] to i8*
diff --git a/test/CodeGenObjCXX/arc.mm b/test/CodeGenObjCXX/arc.mm
index e31b094..6b42a4c 100644
--- a/test/CodeGenObjCXX/arc.mm
+++ b/test/CodeGenObjCXX/arc.mm
@@ -203,7 +203,7 @@
 // CHECK-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[NSARRAY]]*
 
 // Make sure it's not immediately released before starting the iteration.
-// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK-NEXT: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
 // CHECK-NEXT: @objc_msgSend
 
diff --git a/test/CodeGenObjCXX/block-id.mm b/test/CodeGenObjCXX/block-id.mm
new file mode 100644
index 0000000..e324841
--- /dev/null
+++ b/test/CodeGenObjCXX/block-id.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
+
+// N.B.  This test verifies that two blocks which are otherwise
+//       indistinguishable receive distinct manglings.
+//       We had a bug where the first two blocks in the global block map could
+//       get the same unqualified-block mangling because the logic to handle
+//       block-ids believed it was handling Itanium-style discriminators.
+
+template<typename T>
+int tf() {
+    return T::value;
+}
+int i1 = ^int {
+    struct S { enum { value = 1 };};
+    // CHECK-DAG: @_Z2tfIZUb_E1SEiv
+    return tf<S>();
+}();
+int i2 = ^int(int p1) {
+    struct S { enum { value = 2 };};
+    // CHECK-DAG: @_Z2tfIZUb0_E1SEiv
+    return tf<S>() + p1;
+}(1);
diff --git a/test/CodeGenObjCXX/destroy.mm b/test/CodeGenObjCXX/destroy.mm
new file mode 100644
index 0000000..c53ac39
--- /dev/null
+++ b/test/CodeGenObjCXX/destroy.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -disable-llvm-optzns -o - %s | FileCheck %s
+// rdar://18249673
+
+@class MyObject;
+struct base {
+  ~base() = default;
+};
+struct derived : public base {
+  MyObject *myobject;
+};
+
+void test1() {
+  derived d1;
+}
+// CHECK-LABEL: define void @_Z5test1v()
+// CHECK: call void @_ZN7derivedC1Ev
+// CHECK: call void @_ZN7derivedD1Ev
+
+void test2() {
+  derived *d2 = new derived;
+  delete d2;
+}
+// CHECK-LABEL: define void @_Z5test2v()
+// CHECK:   call void @_ZN7derivedC1Ev
+// CHECK:   call void @_ZN7derivedD1Ev
+
+template <typename T>
+struct tderived : public base {
+  MyObject *myobject;
+};
+void test3() {
+  tderived<int> d1;
+}
+// CHECK-LABEL: define void @_Z5test3v()
+// CHECK: call void @_ZN8tderivedIiEC1Ev
+// CHECK: call void @_ZN8tderivedIiED1Ev
+
+void test4() {
+  tderived<int> *d2 = new tderived<int>;
+  delete d2;
+}
+// CHECK-LABEL: define void @_Z5test4v()
+// CHECK: call void @_ZN8tderivedIiEC1Ev
+// CHECK: call void @_ZN8tderivedIiED1Ev
+
+// CHECK-LABEL: define linkonce_odr void @_ZN8tderivedIiED2Ev
+// CHECK: call void @objc_storeStrong(i8** {{.*}}, i8* null)
+
+// CHECK-LABEL: define linkonce_odr void @_ZN7derivedD2Ev
+// CHECK: call void @objc_storeStrong(i8** {{.*}}, i8* null)
diff --git a/test/CodeGenObjCXX/externally-initialized-selectors.mm b/test/CodeGenObjCXX/externally-initialized-selectors.mm
index 0b7c24e..7dcd727 100644
--- a/test/CodeGenObjCXX/externally-initialized-selectors.mm
+++ b/test/CodeGenObjCXX/externally-initialized-selectors.mm
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | FileCheck %s
 // RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck %s
 
-// CHECK: @"\01L_OBJC_SELECTOR_REFERENCES_" = private externally_initialized global
+// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global
 
 void test(id x) {
   [x doSomething];
diff --git a/test/CodeGenObjCXX/implicit-copy-assign-operator.mm b/test/CodeGenObjCXX/implicit-copy-assign-operator.mm
index f9cdcb4..01d8112 100644
--- a/test/CodeGenObjCXX/implicit-copy-assign-operator.mm
+++ b/test/CodeGenObjCXX/implicit-copy-assign-operator.mm
@@ -43,7 +43,7 @@
   d1 = d2;
 }
 
-// CHECK-OBJ-LABEL: define linkonce_odr nonnull %struct.D* @_ZN1DaSERS_
+// CHECK-OBJ-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.D* @_ZN1DaSERS_
 // CHECK-OBJ: {{call.*_ZN1AaSERS_}}
 // CHECK-OBJ: {{call.*_ZN1BaSERS_}}
 // CHECK-OBJ: {{call.*_ZN1CaSERKS_}}
diff --git a/test/CodeGenObjCXX/implicit-copy-constructor.mm b/test/CodeGenObjCXX/implicit-copy-constructor.mm
index d279a6b..6c56616 100644
--- a/test/CodeGenObjCXX/implicit-copy-constructor.mm
+++ b/test/CodeGenObjCXX/implicit-copy-constructor.mm
@@ -41,7 +41,7 @@
   D d2(d);
 }
 
-// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D* nonnull) unnamed_addr
+// CHECK-LABEL: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D* dereferenceable({{[0-9]+}})) unnamed_addr
 // CHECK: call void @_ZN1AC1Ev
 // CHECK: call void @_ZN1CC2ERS_1A
 // CHECK: call void @_ZN1AD1Ev
diff --git a/test/CodeGenObjCXX/lambda-expressions.mm b/test/CodeGenObjCXX/lambda-expressions.mm
index 435f805..9129ff0 100644
--- a/test/CodeGenObjCXX/lambda-expressions.mm
+++ b/test/CodeGenObjCXX/lambda-expressions.mm
@@ -4,8 +4,8 @@
 typedef int (^fp)();
 fp f() { auto x = []{ return 3; }; return x; }
 
-// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = private global [5 x i8] c"copy\00"
-// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = private global [12 x i8] c"autorelease\00"
+// MRC: @OBJC_METH_VAR_NAME{{.*}} = private global [5 x i8] c"copy\00"
+// MRC: @OBJC_METH_VAR_NAME{{.*}} = private global [12 x i8] c"autorelease\00"
 // MRC-LABEL: define i32 ()* @_Z1fv(
 // MRC-LABEL: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
 // MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
diff --git a/test/CodeGenObjCXX/lvalue-reference-getter.mm b/test/CodeGenObjCXX/lvalue-reference-getter.mm
index fcf9b29..87c1320 100644
--- a/test/CodeGenObjCXX/lvalue-reference-getter.mm
+++ b/test/CodeGenObjCXX/lvalue-reference-getter.mm
@@ -23,6 +23,6 @@
 
 // CHECK: [[SELF:%.*]] = alloca [[T6:%.*]]*, align
 // CHECK: [[T0:%.*]] = load {{.*}}* [[SELF]], align
-// CHECK: [[T1:%.*]] = load {{.*}}* @"\01L_OBJC_SELECTOR_REFERENCES_"
-// CHECK: [[C:%.*]] = call nonnull %struct.SetSection* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
-// CHECK: call nonnull i32* @_ZN10SetSection2atEi(%struct.SetSection* [[C]]
+// CHECK: [[T1:%.*]] = load {{.*}}* @OBJC_SELECTOR_REFERENCES_
+// CHECK: [[C:%.*]] = call dereferenceable({{[0-9]+}}) %struct.SetSection* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call dereferenceable({{[0-9]+}}) i32* @_ZN10SetSection2atEi(%struct.SetSection* [[C]]
diff --git a/test/CodeGenObjCXX/mangle-blocks.mm b/test/CodeGenObjCXX/mangle-blocks.mm
index 405e528..1f3f163 100644
--- a/test/CodeGenObjCXX/mangle-blocks.mm
+++ b/test/CodeGenObjCXX/mangle-blocks.mm
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
 
-// CHECK: @_ZGVZZ3foovEUb_E5value = internal global i64 0
-// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub_E1k = linkonce_odr global i32 0
-// CHECK: @_ZZ26externally_visible_statics1S1xMUb_E1j = linkonce_odr global i32 0
-// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb_E1i = linkonce_odr global i32 0
+// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub0_E1k = linkonce_odr global i32 0
+// CHECK: @_ZZ26externally_visible_statics1S1xMUb0_E1j = linkonce_odr global i32 0
+// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb0_E1i = linkonce_odr global i32 0
 
 int f();
 
@@ -27,7 +26,7 @@
 - (void)method { 
   // CHECK: define internal signext i8 @"__11-[A method]_block_invoke"
   (void)^(int x) {
-    // CHECK: @"_ZZZ11-[A method]EUb0_E4name"
+    // CHECK: @"_ZZZ11-[A method]EUb1_E4name"
     static const char *name = "hello";
     return name[x];
   };
@@ -45,7 +44,7 @@
   // CHECK-LABEL: define internal signext i8 @___Z3fooi_block_invoke
   void bar() {
     (void)^(int x) { 
-      // CHECK: @_ZZZN1N3barEvEUb2_E4name
+      // CHECK: @_ZZZN1N3barEvEUb3_E4name
       static const char *name = "hello";
       return name[x];
     };
@@ -57,7 +56,7 @@
 };
 C::C() {
   (void)^(int x) { 
-    // CHECK: @_ZZZN1CC1EvEUb3_E5nameb
+    // CHECK: @_ZZZN1CC1EvEUb4_E5nameb
     static const char *nameb = "hello";
     return nameb[x];
   };
diff --git a/test/CodeGenObjCXX/message-reference.mm b/test/CodeGenObjCXX/message-reference.mm
index 37230d1..6b341f8 100644
--- a/test/CodeGenObjCXX/message-reference.mm
+++ b/test/CodeGenObjCXX/message-reference.mm
@@ -15,6 +15,6 @@
 }
 @end
 
-// CHECK: [[T:%.*]] = call nonnull i32* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[T:%.*]] = call dereferenceable({{[0-9]+}}) i32* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
 // CHECK: [[U:%.*]] = load i32* [[T]]
 // CHECK  [[V:%.*]] = icmp eq i32 [[U]], 0
diff --git a/test/CodeGenObjCXX/property-dot-reference.mm b/test/CodeGenObjCXX/property-dot-reference.mm
index 01b41a5..8f3b29d 100644
--- a/test/CodeGenObjCXX/property-dot-reference.mm
+++ b/test/CodeGenObjCXX/property-dot-reference.mm
@@ -11,7 +11,7 @@
 
 @implementation TNodeIconAndNameCell     
 - (const TFENode&) node {
-// CHECK: call nonnull %struct.TFENode* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call dereferenceable({{[0-9]+}}) %struct.TFENode* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
 // CHECK-NEXT: call void @_ZNK7TFENode6GetURLEv(%struct.TFENode* %{{.*}})
 	self.node.GetURL();
 }	// expected-warning {{control reaches end of non-void function}}
@@ -27,12 +27,12 @@
 - (const X&) target;
 @end
 void f1(A *a) {
-// CHECK: [[PRP:%.*]] = call nonnull %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
-// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* nonnull [[PRP]])
+// CHECK: [[PRP:%.*]] = call dereferenceable({{[0-9]+}}) %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* dereferenceable({{[0-9]+}}) [[PRP]])
   f0(a.target);
 
-// CHECK: [[MSG:%.*]] = call nonnull %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
-// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* nonnull [[MSG]])
+// CHECK: [[MSG:%.*]] = call dereferenceable({{[0-9]+}}) %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* dereferenceable({{[0-9]+}}) [[MSG]])
   f0([a target]);
 }
 
diff --git a/test/CodeGenObjCXX/property-lvalue-capture.mm b/test/CodeGenObjCXX/property-lvalue-capture.mm
index 911bdbe..1242246 100644
--- a/test/CodeGenObjCXX/property-lvalue-capture.mm
+++ b/test/CodeGenObjCXX/property-lvalue-capture.mm
@@ -24,10 +24,10 @@
 }
 @end
 
-// CHECK:   [[TWO:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load ![[MD_NUM:[0-9]+]]
+// CHECK:   [[TWO:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_, !invariant.load ![[MD_NUM:[0-9]+]]
 // CHECK:   [[THREE:%.*]] = bitcast [[ONET:%.*]]* [[ONE:%.*]] to i8*
 // CHECK:   [[CALL:%.*]] = call nonnull %struct.Quad2* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %struct.Quad2* (i8*, i8*)*)(i8* [[THREE]], i8* [[TWO]])
-// CHECK:   [[FOUR:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2", !invariant.load ![[MD_NUM]]
+// CHECK:   [[FOUR:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_2, !invariant.load ![[MD_NUM]]
 // CHECK:   [[FIVE:%.*]] = bitcast [[ONET]]* [[ZERO:%.*]] to i8*
 // CHECK:   call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.Quad2*)*)(i8* [[FIVE]], i8* [[FOUR]], %struct.Quad2* nonnull [[CALL]])
 
@@ -47,7 +47,7 @@
 }
 
 // CHECK:   [[ONE1:%.*]] = load %struct.A** [[AADDR:%.*]], align 8
-// CHECK:   [[TWO1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_5", !invariant.load ![[MD_NUM]]
+// CHECK:   [[TWO1:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_5, !invariant.load ![[MD_NUM]]
 // CHECK:   [[THREE1:%.*]] = bitcast [[TWOT:%.*]]* [[ZERO1:%.*]] to i8*
-// CHECK:   call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.A*)*)(i8* [[THREE1]], i8* [[TWO1]], %struct.A* nonnull [[ONE1]])
+// CHECK:   call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.A*)*)(i8* [[THREE1]], i8* [[TWO1]], %struct.A* dereferenceable({{[0-9]+}}) [[ONE1]])
 // CHECK:   store %struct.A* [[ONE1]], %struct.A** [[RESULT:%.*]], align 8
diff --git a/test/CodeGenObjCXX/property-object-reference-2.mm b/test/CodeGenObjCXX/property-object-reference-2.mm
index 4142967..20949f7 100644
--- a/test/CodeGenObjCXX/property-object-reference-2.mm
+++ b/test/CodeGenObjCXX/property-object-reference-2.mm
@@ -33,7 +33,7 @@
 // CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
 // CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
 // CHECK: [[CALL:%.*]] = call i32 @_Z7DEFAULTv()
-// CHECK:  call void @_ZN10TCPPObjectC1ERKS_i(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* nonnull [[THREE]], i32 [[CALL]])
+// CHECK:  call void @_ZN10TCPPObjectC1ERKS_i(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* dereferenceable({{[0-9]+}}) [[THREE]], i32 [[CALL]])
 // CHECK:  ret void
 
 // CHECK: define internal void @"\01-[MyDocument MyProperty]"(
@@ -46,7 +46,7 @@
 // CHECK-LABEL: define internal void @__assign_helper_atomic_property_(
 // CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
 // CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
-// CHECK: [[CALL:%.*]] = call nonnull %struct.TCPPObject* @_ZN10TCPPObjectaSERKS_(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* nonnull [[THREE]])
+// CHECK: [[CALL:%.*]] = call dereferenceable({{[0-9]+}}) %struct.TCPPObject* @_ZN10TCPPObjectaSERKS_(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* dereferenceable({{[0-9]+}}) [[THREE]])
 // CHECK:  ret void
 
 // CHECK: define internal void @"\01-[MyDocument setMyProperty:]"(
diff --git a/test/CodeGenObjCXX/property-object-reference.mm b/test/CodeGenObjCXX/property-object-reference.mm
index ec311f1..691e6ff 100644
--- a/test/CodeGenObjCXX/property-object-reference.mm
+++ b/test/CodeGenObjCXX/property-object-reference.mm
@@ -25,11 +25,11 @@
 @end
 
 // CHECK: [[T0:%.*]] = load {{%.*}} [[S0:%.*]]
-// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK: load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK:  [[T2:%.*]]  = bitcast {{%.*}} [[T0]] to i8*
 // CHECK:  @objc_msgSend
 // CHECK: [[R0:%.*]] = load {{%.*}} [[U0:%.*]]
-// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK: load i8** @OBJC_SELECTOR_REFERENCES_
 // CHECK:  [[R2:%.*]]  = bitcast {{%.*}} [[R0]] to i8*
 // CHECK:  @objc_msgSend
 
diff --git a/test/CodeGenObjCXX/property-objects.mm b/test/CodeGenObjCXX/property-objects.mm
index 732d10f..73ed21d 100644
--- a/test/CodeGenObjCXX/property-objects.mm
+++ b/test/CodeGenObjCXX/property-objects.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -g -o - | FileCheck %s
 
 class S {
 public:
@@ -32,9 +32,14 @@
 @synthesize frame;
 
 // CHECK: define internal void @"\01-[I setPosition:]"
-// CHECK: call nonnull %class.S* @_ZN1SaSERKS_
+// CHECK: call dereferenceable({{[0-9]+}}) %class.S* @_ZN1SaSERKS_
 // CHECK-NEXT: ret void
 
+// Don't attach debug locations to the prologue instructions. These were
+// leaking over from the previous function emission by accident.
+// CHECK: define internal void @"\01-[I setBounds:]"
+// CHECK-NOT: !dbg
+// CHECK: call void @llvm.dbg.declare
 - (void)setFrame:(CGRect)frameRect {}
 - (CGRect)frame {return bounds;}
 
@@ -55,7 +60,7 @@
 @end
 
 // CHECK-LABEL: define i32 @main
-// CHECK: call void @_ZN1SC1ERKS_(%class.S* [[AGGTMP:%[a-zA-Z0-9\.]+]], %class.S* nonnull {{%[a-zA-Z0-9\.]+}})
+// CHECK: call void @_ZN1SC1ERKS_(%class.S* [[AGGTMP:%[a-zA-Z0-9\.]+]], %class.S* dereferenceable({{[0-9]+}}) {{%[a-zA-Z0-9\.]+}})
 // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %class.S*)*)(i8* {{%[a-zA-Z0-9\.]+}}, i8* {{%[a-zA-Z0-9\.]+}}, %class.S* [[AGGTMP]])
 // CHECK-NEXT: ret i32 0
 int main() {
@@ -68,7 +73,7 @@
 // rdar://8379892
 // CHECK-LABEL: define void @_Z1fP1A
 // CHECK: call void @_ZN1XC1Ev(%struct.X* [[LVTEMP:%[a-zA-Z0-9\.]+]])
-// CHECK: call void @_ZN1XC1ERKS_(%struct.X* [[AGGTMP:%[a-zA-Z0-9\.]+]], %struct.X* nonnull [[LVTEMP]])
+// CHECK: call void @_ZN1XC1ERKS_(%struct.X* [[AGGTMP:%[a-zA-Z0-9\.]+]], %struct.X* dereferenceable({{[0-9]+}}) [[LVTEMP]])
 // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.X*)*)({{.*}} %struct.X* [[AGGTMP]])
 struct X {
   X();
diff --git a/test/CodeGenObjCXX/property-reference.mm b/test/CodeGenObjCXX/property-reference.mm
index 8ac59ac..e426900 100644
--- a/test/CodeGenObjCXX/property-reference.mm
+++ b/test/CodeGenObjCXX/property-reference.mm
@@ -26,7 +26,7 @@
   const MyStruct& currentMyStruct = myClass.foo;   
 }
 
-// CHECK: [[C:%.*]] = call nonnull %struct.MyStruct* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[C:%.*]] = call dereferenceable({{[0-9]+}}) %struct.MyStruct* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
 // CHECK:   store %struct.MyStruct* [[C]], %struct.MyStruct** [[D:%.*]]
 
 namespace test1 {
@@ -40,7 +40,7 @@
 @implementation Test1
 @synthesize prop1 = ivar;
 @end
-// CHECK:    define internal nonnull [[A:%.*]]* @"\01-[Test1 prop1]"(
+// CHECK:    define internal dereferenceable({{[0-9]+}}) [[A:%.*]]* @"\01-[Test1 prop1]"(
 // CHECK:      [[SELF:%.*]] = alloca [[TEST1:%.*]]*, align 8
 // CHECK:      [[T0:%.*]] = load [[TEST1]]** [[SELF]]
 // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
@@ -49,7 +49,7 @@
 // CHECK-NEXT: ret [[A]]* [[T3]]
 
 // CHECK:    define internal void @"\01-[Test1 setProp1:]"(
-// CHECK:      call nonnull [[A]]* @_ZN5test11AaSERKS0_(
+// CHECK:      call dereferenceable({{[0-9]+}}) [[A]]* @_ZN5test11AaSERKS0_(
 // CHECK-NEXT: ret void
 
 // rdar://problem/10497174
diff --git a/test/CodeGenOpenCL/addr-space-struct-arg.cl b/test/CodeGenOpenCL/addr-space-struct-arg.cl
index f04923d..d711f78 100644
--- a/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,23 +1,23 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple i686-pc-darwin | FileCheck %s

-

-typedef struct {

-  int cells[9];

-} Mat3X3;

-

-typedef struct {

-  int cells[16];

-} Mat4X4;

-

-Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {

-  Mat4X4 out;

-  return out;

-}

-

-kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {

-  out[0] = foo(in[1]);

-}

-

-// Expect two mem copies: one for the argument "in", and one for

-// the return value.

-// CHECK: call void @llvm.memcpy.p0i8.p1i8.i32(i8*

-// CHECK: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*

+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple i686-pc-darwin | FileCheck %s
+
+typedef struct {
+  int cells[9];
+} Mat3X3;
+
+typedef struct {
+  int cells[16];
+} Mat4X4;
+
+Mat4X4 __attribute__((noinline)) foo(Mat3X3 in) {
+  Mat4X4 out;
+  return out;
+}
+
+kernel void ker(global Mat3X3 *in, global Mat4X4 *out) {
+  out[0] = foo(in[1]);
+}
+
+// Expect two mem copies: one for the argument "in", and one for
+// the return value.
+// CHECK: call void @llvm.memcpy.p0i8.p1i8.i32(i8*
+// CHECK: call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)*
diff --git a/test/CodeGenOpenCL/address-space-constant-initializers.cl b/test/CodeGenOpenCL/address-space-constant-initializers.cl
index ae8cedc..079b070 100644
--- a/test/CodeGenOpenCL/address-space-constant-initializers.cl
+++ b/test/CodeGenOpenCL/address-space-constant-initializers.cl
@@ -12,7 +12,7 @@
 } ConstantArrayPointerStruct;
 
 // CHECK: %struct.ConstantArrayPointerStruct = type { float addrspace(3)* }
-// CHECK: addrspace(3) global %struct.ConstantArrayPointerStruct { float addrspace(3)* bitcast (i8 addrspace(3)* getelementptr (i8 addrspace(3)* bitcast (%struct.ArrayStruct addrspace(3)* @constant_array_struct to i8 addrspace(3)*), i64 4) to float addrspace(3)*) }
+// CHECK: addrspace(3) constant %struct.ConstantArrayPointerStruct { float addrspace(3)* bitcast (i8 addrspace(3)* getelementptr (i8 addrspace(3)* bitcast (%struct.ArrayStruct addrspace(3)* @constant_array_struct to i8 addrspace(3)*), i64 4) to float addrspace(3)*) }
 // Bug  18567
 __constant ConstantArrayPointerStruct constant_array_pointer_struct = {
     &constant_array_struct.f
diff --git a/test/CodeGenOpenCL/builtins-r600.cl b/test/CodeGenOpenCL/builtins-r600.cl
index 0531038..129531f 100644
--- a/test/CodeGenOpenCL/builtins-r600.cl
+++ b/test/CodeGenOpenCL/builtins-r600.cl
@@ -28,3 +28,101 @@
   *out = __builtin_amdgpu_div_scalef(a, b, true, &flag);
   *flagout = flag;
 }
+
+// CHECK-LABEL: @test_div_fmas_f32
+// CHECK: call float @llvm.AMDGPU.div.fmas.f32
+void test_div_fmas_f32(global float* out, float a, float b, float c, int d)
+{
+  *out = __builtin_amdgpu_div_fmasf(a, b, c, d);
+}
+
+// CHECK-LABEL: @test_div_fmas_f64
+// CHECK: call double @llvm.AMDGPU.div.fmas.f64
+void test_div_fmas_f64(global double* out, double a, double b, double c, int d)
+{
+  *out = __builtin_amdgpu_div_fmas(a, b, c, d);
+}
+
+// CHECK-LABEL: @test_div_fixup_f32
+// CHECK: call float @llvm.AMDGPU.div.fixup.f32
+void test_div_fixup_f32(global float* out, float a, float b, float c)
+{
+  *out = __builtin_amdgpu_div_fixupf(a, b, c);
+}
+
+// CHECK-LABEL: @test_div_fixup_f64
+// CHECK: call double @llvm.AMDGPU.div.fixup.f64
+void test_div_fixup_f64(global double* out, double a, double b, double c)
+{
+  *out = __builtin_amdgpu_div_fixup(a, b, c);
+}
+
+// CHECK-LABEL: @test_trig_preop_f32
+// CHECK: call float @llvm.AMDGPU.trig.preop.f32
+void test_trig_preop_f32(global float* out, float a, int b)
+{
+  *out = __builtin_amdgpu_trig_preopf(a, b);
+}
+
+// CHECK-LABEL: @test_trig_preop_f64
+// CHECK: call double @llvm.AMDGPU.trig.preop.f64
+void test_trig_preop_f64(global double* out, double a, int b)
+{
+  *out = __builtin_amdgpu_trig_preop(a, b);
+}
+
+// CHECK-LABEL: @test_rcp_f32
+// CHECK: call float @llvm.AMDGPU.rcp.f32
+void test_rcp_f32(global float* out, float a)
+{
+  *out = __builtin_amdgpu_rcpf(a);
+}
+
+// CHECK-LABEL: @test_rcp_f64
+// CHECK: call double @llvm.AMDGPU.rcp.f64
+void test_rcp_f64(global double* out, double a)
+{
+  *out = __builtin_amdgpu_rcp(a);
+}
+
+// CHECK-LABEL: @test_rsq_f32
+// CHECK: call float @llvm.AMDGPU.rsq.f32
+void test_rsq_f32(global float* out, float a)
+{
+  *out = __builtin_amdgpu_rsqf(a);
+}
+
+// CHECK-LABEL: @test_rsq_f64
+// CHECK: call double @llvm.AMDGPU.rsq.f64
+void test_rsq_f64(global double* out, double a)
+{
+  *out = __builtin_amdgpu_rsq(a);
+}
+
+// CHECK-LABEL: @test_rsq_clamped_f32
+// CHECK: call float @llvm.AMDGPU.rsq.clamped.f32
+void test_rsq_clamped_f32(global float* out, float a)
+{
+  *out = __builtin_amdgpu_rsq_clampedf(a);
+}
+
+// CHECK-LABEL: @test_rsq_clamped_f64
+// CHECK: call double @llvm.AMDGPU.rsq.clamped.f64
+void test_rsq_clamped_f64(global double* out, double a)
+{
+  *out = __builtin_amdgpu_rsq_clamped(a);
+}
+
+// CHECK-LABEL: @test_ldexp_f32
+// CHECK: call float @llvm.AMDGPU.ldexp.f32
+void test_ldexp_f32(global float* out, float a, int b)
+{
+  *out = __builtin_amdgpu_ldexpf(a, b);
+}
+
+// CHECK-LABEL: @test_ldexp_f64
+// CHECK: call double @llvm.AMDGPU.ldexp.f64
+void test_ldexp_f64(global double* out, double a, int b)
+{
+  *out = __builtin_amdgpu_ldexp(a, b);
+}
diff --git a/test/CodeGenOpenCL/constant-addr-space-globals.cl b/test/CodeGenOpenCL/constant-addr-space-globals.cl
new file mode 100644
index 0000000..92fb979
--- /dev/null
+++ b/test/CodeGenOpenCL/constant-addr-space-globals.cl
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+
+// CHECK: @array = addrspace({{[0-9]+}}) constant
+__constant float array[2] = {0.0f, 1.0f};
+
+kernel void test(global float *out) {
+  *out = array[0];
+}
diff --git a/test/CodeGenOpenCL/denorms-are-zero.cl b/test/CodeGenOpenCL/denorms-are-zero.cl
new file mode 100644
index 0000000..488004f
--- /dev/null
+++ b/test/CodeGenOpenCL/denorms-are-zero.cl
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -S -cl-denorms-are-zero -o - %s 2>&1
+
+// This test just checks that the -cl-denorms-are-zero argument is accepted
+// by clang.  This option is currently a no-op, which is allowed by the
+// OpenCL specification.
diff --git a/test/CodeGenOpenCL/kernel-arg-info.cl b/test/CodeGenOpenCL/kernel-arg-info.cl
index 9832604..89da3fd 100644
--- a/test/CodeGenOpenCL/kernel-arg-info.cl
+++ b/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -8,6 +8,7 @@
 // CHECK: metadata !{metadata !"kernel_arg_addr_space", i32 1, i32 0, i32 0, i32 2}
 // CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"none", metadata !"none", metadata !"none", metadata !"none"}
 // CHECK: metadata !{metadata !"kernel_arg_type", metadata !"int*", metadata !"int", metadata !"int", metadata !"float*"}
+// CHECK: metadata !{metadata !"kernel_arg_base_type", metadata !"int*", metadata !"int", metadata !"int", metadata !"float*"}
 // CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !"restrict", metadata !"const", metadata !"volatile", metadata !"restrict const"}
 // CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X", metadata !"Y", metadata !"anotherArg", metadata !"Z"}
 
@@ -16,6 +17,7 @@
 // CHECK: metadata !{metadata !"kernel_arg_addr_space", i32 1, i32 1, i32 1}
 // CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"read_only", metadata !"read_only", metadata !"write_only"}
 // CHECK: metadata !{metadata !"kernel_arg_type", metadata !"image1d_t", metadata !"image2d_t", metadata !"image2d_array_t"}
+// CHECK: metadata !{metadata !"kernel_arg_base_type", metadata !"image1d_t", metadata !"image2d_t", metadata !"image2d_array_t"}
 // CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !"", metadata !"", metadata !""}
 // CHECK: metadata !{metadata !"kernel_arg_name", metadata !"img1", metadata !"img2", metadata !"img3"}
 
@@ -24,5 +26,24 @@
 // CHECK: metadata !{metadata !"kernel_arg_addr_space", i32 1}
 // CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"none"}
 // CHECK: metadata !{metadata !"kernel_arg_type", metadata !"half*"}
+// CHECK: metadata !{metadata !"kernel_arg_base_type", metadata !"half*"}
 // CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !""}
 // CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X"}
+
+typedef unsigned int myunsignedint;
+kernel void foo4(__global unsigned int * X, __global myunsignedint * Y) {
+}
+// CHECK: metadata !{metadata !"kernel_arg_addr_space", i32 1, i32 1}
+// CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"none", metadata !"none"}
+// CHECK: metadata !{metadata !"kernel_arg_type", metadata !"uint*", metadata !"myunsignedint*"}
+// CHECK: metadata !{metadata !"kernel_arg_base_type", metadata !"uint*", metadata !"uint*"}
+// CHECK: metadata !{metadata !"kernel_arg_type_qual", metadata !"", metadata !""}
+// CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X", metadata !"Y"}
+
+typedef image1d_t myImage;
+kernel void foo5(read_only myImage img1, write_only image1d_t img2) {
+}
+// CHECK: metadata !{metadata !"kernel_arg_access_qual", metadata !"read_only", metadata !"write_only"}
+// CHECK: metadata !{metadata !"kernel_arg_type", metadata !"myImage", metadata !"image1d_t"}
+// CHECK: metadata !{metadata !"kernel_arg_base_type", metadata !"image1d_t", metadata !"image1d_t"}
+// CHECK: metadata !{metadata !"kernel_arg_name", metadata !"img1", metadata !"img2"}
diff --git a/test/CodeGenOpenCL/local-initializer-undef.cl b/test/CodeGenOpenCL/local-initializer-undef.cl
new file mode 100644
index 0000000..5d34f56
--- /dev/null
+++ b/test/CodeGenOpenCL/local-initializer-undef.cl
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -O0 -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+
+typedef struct Foo {
+    int x;
+    float y;
+    float z;
+} Foo;
+
+// CHECK-DAG: @test.lds_int = internal addrspace(2) global i32 undef
+// CHECK-DAG: @test.lds_int_arr = internal addrspace(2) global [128 x i32] undef
+// CHECK-DAG: @test.lds_struct = internal addrspace(2) global %struct.Foo undef
+// CHECK-DAG: @test.lds_struct_arr = internal addrspace(2) global [64 x %struct.Foo] undef
+__kernel void test()
+{
+    __local int lds_int;
+    __local int lds_int_arr[128];
+    __local Foo lds_struct;
+    __local Foo lds_struct_arr[64];
+
+    lds_int = 1;
+    lds_int_arr[0] = 1;
+    lds_struct.x = 1;
+    lds_struct_arr[0].x = 1;
+}
diff --git a/test/CodeGenOpenCL/local.cl b/test/CodeGenOpenCL/local.cl
index 895c8fa..f1031cd 100644
--- a/test/CodeGenOpenCL/local.cl
+++ b/test/CodeGenOpenCL/local.cl
@@ -1,9 +1,11 @@
 // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=no -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
 
+void func(local int*);
+
 __kernel void foo(void) {
-  // CHECK: @foo.i = internal unnamed_addr addrspace(2)
+  // CHECK: @foo.i = internal addrspace(2) global i32 undef
   __local int i;
-  ++i;
+  func(&i);
 }
 
 // CHECK-LABEL: define void @_Z3barPU7CLlocali
diff --git a/test/CodeGenOpenCL/opencl_types.cl b/test/CodeGenOpenCL/opencl_types.cl
index 7e99fc5..ed2bf6d 100644
--- a/test/CodeGenOpenCL/opencl_types.cl
+++ b/test/CodeGenOpenCL/opencl_types.cl
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
 
 constant sampler_t glb_smp = 7;
-// CHECK: global i32 7
+// CHECK: constant i32 7
 
 void fnc1(image1d_t img) {}
 // CHECK: @fnc1(%opencl.image1d_t*
diff --git a/test/CodeGenOpenCL/str_literals.cl b/test/CodeGenOpenCL/str_literals.cl
index 43c90f8..092b637 100644
--- a/test/CodeGenOpenCL/str_literals.cl
+++ b/test/CodeGenOpenCL/str_literals.cl
@@ -5,5 +5,5 @@
 
 // CHECK: unnamed_addr addrspace(3) constant
 // CHECK-NOT: addrspace(3) unnamed_addr constant
-// CHECK: @x = addrspace(3) global i8 addrspace(3)*
-// CHECK: @y = addrspace(3) global i8 addrspace(3)*
+// CHECK: @x = addrspace(3) constant i8 addrspace(3)*
+// CHECK: @y = addrspace(3) constant i8 addrspace(3)*
diff --git a/test/Coverage/html-diagnostics.c b/test/Coverage/html-diagnostics.c
index 410ee2a..045943a 100644
--- a/test/Coverage/html-diagnostics.c
+++ b/test/Coverage/html-diagnostics.c
@@ -1,9 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
-// RUN: cat %t/*.html | FileCheck %s
+// RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
 
-// Because of the glob (*.html)
-// REQUIRES: shell
+// REQUIRES: staticanalyzer
 
 // CHECK: <h3>Annotated Source Code</h3>
 
diff --git a/test/CoverageMapping/Inputs/code.h b/test/CoverageMapping/Inputs/code.h
new file mode 100644
index 0000000..cd3cfb5
--- /dev/null
+++ b/test/CoverageMapping/Inputs/code.h
@@ -0,0 +1,11 @@
+x = x;
+if (x == 0) {
+  x = 1;
+} else {
+  x = 2;
+}
+if (true) {
+  x = x;
+} else {
+  x = x;
+}
diff --git a/test/CoverageMapping/Inputs/header1.h b/test/CoverageMapping/Inputs/header1.h
new file mode 100644
index 0000000..d01e813
--- /dev/null
+++ b/test/CoverageMapping/Inputs/header1.h
@@ -0,0 +1,31 @@
+#ifndef HEADER1_H
+#define HEADER1_H
+
+inline void func(int i) {
+  int x = 0;
+  if (i == 0) {
+    x = 1;
+  } else {
+    x = 2;
+  }
+}
+static void static_func(int j) {
+  int x = 0;
+  if (j == x) {
+    x = !j;
+  } else {
+    x = 42;
+  }
+  j = x * j;
+}
+static void static_func2(int j) {
+  int x = 0;
+  if (j == x) {
+    x = !j;
+  } else {
+    x = 42;
+  }
+  j = x * j;
+}
+
+#endif // HEADER1_H
diff --git a/test/CoverageMapping/break.c b/test/CoverageMapping/break.c
new file mode 100644
index 0000000..f5a0af5
--- /dev/null
+++ b/test/CoverageMapping/break.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %s | FileCheck %s
+
+int main() {         // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+28]]:2 = #0 (HasCodeBefore = 0)
+  int cnt = 0;       // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = #0 (HasCodeBefore = 0)
+  while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+3]]:4 = #1 (HasCodeBefore = 0)
+    break;
+    ++cnt;           // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = 0 (HasCodeBefore = 0)
+  }                  // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = #0 (HasCodeBefore = 0)
+  while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+6]]:4 = #2 (HasCodeBefore = 0)
+    {
+      break;
+      ++cnt;         // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE+2]]:10 = 0 (HasCodeBefore = 0)
+    }
+    ++cnt;
+  }                  // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = ((#0 + #3) - #4) (HasCodeBefore = 0)
+  while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+6]]:4 = #3 (HasCodeBefore = 0)
+    if(cnt == 0) {   // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+3]]:6 = #4 (HasCodeBefore = 0)
+      break;
+      ++cnt;         // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = 0 (HasCodeBefore = 0)
+    }
+    ++cnt;           // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = (#3 - #4) (HasCodeBefore = 0)
+  }                  // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = (#0 + #6) (HasCodeBefore = 0)
+  while(cnt < 100) { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+7]]:4 = #5 (HasCodeBefore = 0)
+    if(cnt == 0) {   // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+5]]:10 = #6 (HasCodeBefore = 0)
+      ++cnt;
+    } else {         // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = (#5 - #6) (HasCodeBefore = 0)
+      break;
+    }
+    ++cnt;
+  }
+}
diff --git a/test/CoverageMapping/builtinmacro.c b/test/CoverageMapping/builtinmacro.c
new file mode 100644
index 0000000..a023abc
--- /dev/null
+++ b/test/CoverageMapping/builtinmacro.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %s | FileCheck %s
+
+// Test the coverage mapping generation for built-in macroes.
+
+// CHECK: filename
+const char *filename (const char *name) { // CHECK-NEXT: File 0, [[@LINE]]:41 -> [[@LINE+3]]:2 = #0 (HasCodeBefore = 0)
+  static const char this_file[] = __FILE__;
+  return this_file;
+}
+
+int main() { // CHECK-NEXT: main
+  filename(__FILE__ "test.c");
+  return 0;
+}
diff --git a/test/CoverageMapping/casts.c b/test/CoverageMapping/casts.c
new file mode 100644
index 0000000..94c13dc
--- /dev/null
+++ b/test/CoverageMapping/casts.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name casts.c %s | FileCheck %s
+
+int main() {                                                   // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+                                                               // CHECK-NEXT: File 0, [[@LINE+1]]:41 -> [[@LINE+1]]:54 = #1 (HasCodeBefore = 0)
+  int window_size = (sizeof(int) <= 2 ? (unsigned)512 : 1024); // CHECK-NEXT: File 0, [[@LINE]]:57 -> [[@LINE]]:61 = (#0 - #1) (HasCodeBefore = 0)
+  return 0;
+}
+
+
+
+
diff --git a/test/CoverageMapping/classtemplate.cpp b/test/CoverageMapping/classtemplate.cpp
new file mode 100644
index 0000000..6062266
--- /dev/null
+++ b/test/CoverageMapping/classtemplate.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CONSTRUCTOR
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-GETTER
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-SETTER
+
+template<class TT>
+class Test {
+public:
+  enum BaseType {
+    A, C, G, T, Invalid
+  };
+  const static int BaseCount = 4;
+  double bases[BaseCount];
+
+                                        // CHECK-CONSTRUCTOR: _ZN4TestIjEC
+  Test() { }                            // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:10 -> [[@LINE]]:13 = #0 (HasCodeBefore = 0)
+
+  // FIXME: It would be nice to emit no-coverage for get, but trying to do this
+  // runs afoul of cases like Test3::unmangleable below.
+                                        // FIXME-GETTER: _ZNK4TestIjE3get
+  double get(TT position) const {       // FIXME-GETTER: File 0, [[@LINE]]:33 -> [[@LINE+2]]:4 = 0 (HasCodeBefore = 0)
+    return bases[position];
+  }
+                                        // CHECK-SETTER: _ZN4TestIjE3set
+  void set(TT position, double value) { // CHECK-SETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = #0 (HasCodeBefore = 0)
+    bases[position] = value;
+  }
+};
+
+class Test2 {
+                                        // CHECK-CONSTRUCTOR: _ZN5Test2C
+  Test2() { }                           // CHECK-CONSTRUCTOR: File 0, [[@LINE]]:11 -> [[@LINE]]:14 = 0 (HasCodeBefore = 0)
+                                        // CHECK-GETTER: _ZNK5Test23get
+  double get(unsigned position) const { // CHECK-GETTER: File 0, [[@LINE]]:39 -> [[@LINE+2]]:4 = 0 (HasCodeBefore = 0)
+    return 0.0;
+  }
+};
+
+// Test3::unmangleable can't be mangled, since there isn't a complete type for
+// the __is_final type trait expression. This would cause errors if we try to
+// emit a no-coverage mapping for the method.
+template <class T, bool = __is_final(T)> class UninstantiatedClassWithTraits {};
+template <class T> class Test3 {
+  void unmangleable(UninstantiatedClassWithTraits<T> x) {}
+};
+
+int main() {
+  Test<unsigned> t;
+  t.set(Test<unsigned>::A, 5.5);
+  t.set(Test<unsigned>::T, 5.6);
+  t.set(Test<unsigned>::G, 5.7);
+  t.set(Test<unsigned>::C, 5.8);
+  return 0;
+}
diff --git a/test/CoverageMapping/continue.c b/test/CoverageMapping/continue.c
new file mode 100644
index 0000000..b56b164
--- /dev/null
+++ b/test/CoverageMapping/continue.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %s | FileCheck %s
+
+int main() {                    // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 = #0 (HasCodeBefore = 0)
+  int j = 0;                    // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = (#0 + #1) (HasCodeBefore = 0)
+                                // CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:29 = #1 (HasCodeBefore = 0)
+  for(int i = 0; i < 20; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:31 -> [[@LINE+17]]:4 = #1 (HasCodeBefore = 0)
+    if(i < 10) {                // CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE+13]]:6 = #2 (HasCodeBefore = 0)
+      if(i < 5) {               // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:8 = #3 (HasCodeBefore = 0)
+        continue;
+        j = 1;                   // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:14 = 0 (HasCodeBefore = 0)
+      } else {                   // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+7]]:13 = (#2 - #3) (HasCodeBefore = 0)
+        j = 2;
+      }
+      j = 3;
+      if(i < 7) {                // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:8 = #4 (HasCodeBefore = 0)
+        continue;
+        j = 4;                   // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:14 = 0 (HasCodeBefore = 0)
+      } else j = 5;              // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+1]]:12 = ((#2 - #3) - #4) (HasCodeBefore = 0)
+      j = 6;
+    } else                       // CHECK-NEXT: File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:12 = (#1 - #2) (HasCodeBefore = 0)
+      j = 7;
+    j = 8;                       // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = ((#1 - #3) - #4) (HasCodeBefore = 0)
+  }
+}
diff --git a/test/CoverageMapping/header.cpp b/test/CoverageMapping/header.cpp
new file mode 100644
index 0000000..c268191
--- /dev/null
+++ b/test/CoverageMapping/header.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name tu1.cpp %s > %tmapping
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-FUNC
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC2
+
+#include "Inputs/header1.h"
+
+int main() {
+  func(1);
+  static_func(2);
+}
+
+// CHECK-FUNC: func
+// CHECK-FUNC: File 0, 4:25 -> 11:2 = #0 (HasCodeBefore = 0)
+// CHECK-FUNC: File 0, 6:15 -> 8:4 = #1 (HasCodeBefore = 0)
+// CHECK-FUNC: File 0, 8:10 -> 10:4 = (#0 - #1) (HasCodeBefore = 0)
+// CHECK-FUNC: Expansion,File 1, 6:10 -> 6:28 = #0 (HasCodeBefore = 0, Expanded file = 0)
+
+// CHECK-STATIC-FUNC: static_func
+// CHECK-STATIC-FUNC: File 0, 12:32 -> 20:2 = #0 (HasCodeBefore = 0)
+// CHECK-STATIC-FUNC: File 0, 14:15 -> 16:4 = #1 (HasCodeBefore = 0)
+// CHECK-STATIC-FUNC: File 0, 16:10 -> 18:4 = (#0 - #1) (HasCodeBefore = 0)
+// CHECK-STATIC-FUNC: Expansion,File 1, 6:10 -> 6:28 = #0 (HasCodeBefore = 0, Expanded file = 0)
+
+// CHECK-STATIC-FUNC2: static_func2
+// CHECK-STATIC-FUNC2: File 0, 21:33 -> 29:2 = 0 (HasCodeBefore = 0)
+// CHECK-STATIC-FUNC2: Expansion,File 1, 6:10 -> 6:28 = 0 (HasCodeBefore = 0, Expanded file = 0)
diff --git a/test/CoverageMapping/if.c b/test/CoverageMapping/if.c
new file mode 100644
index 0000000..4767b40
--- /dev/null
+++ b/test/CoverageMapping/if.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name if.c %s | FileCheck %s
+
+int main() {                    // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+  if(i == 0) i = 1;             // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE]]:19 = #1 (HasCodeBefore = 0)
+  if(i == 1)
+    i = 2;                      // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = #2 (HasCodeBefore = 0)
+  if(i == 0) { i = 1;           // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #3 (HasCodeBefore = 0)
+    i = 2;
+  }
+  if(i != 0) {                  // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #4 (HasCodeBefore = 0)
+    i = 1;
+  } else {                      // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE+2]]:4 = (#0 - #4) (HasCodeBefore = 0)
+    i = 3;
+  }
+
+  i = i == 0?
+        i + 1 :                 // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:14 = #5 (HasCodeBefore = 0)
+        i + 2;                  // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:14 = (#0 - #5) (HasCodeBefore = 0)
+                                // CHECK-NEXT: File 0, [[@LINE+1]]:14 -> [[@LINE+1]]:20 = #6 (HasCodeBefore = 0)
+  i = i == 0?i + 12:i + 10;     // CHECK-NEXT: File 0, [[@LINE]]:21 -> [[@LINE]]:27 = (#0 - #6) (HasCodeBefore = 0)
+
+  return 0;
+}
diff --git a/test/CoverageMapping/includehell.cpp b/test/CoverageMapping/includehell.cpp
new file mode 100644
index 0000000..653f414
--- /dev/null
+++ b/test/CoverageMapping/includehell.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s | FileCheck %s
+
+int main() {               // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+  int x = 0;
+  #include "Inputs/code.h" // CHECK-NEXT: Expansion,File 0, [[@LINE]]:12 -> [[@LINE]]:27 = #0 (HasCodeBefore = 0, Expanded file = 1)
+  return 0;
+}
+// CHECK-NEXT: File 1, 1:1 -> 9:7 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 2:13 -> 4:2 = #1 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 4:8 -> 6:2 = (#0 - #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 7:11 -> 9:2 = #2 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 9:8 -> 11:2 = (#0 - #2) (HasCodeBefore = 0)
diff --git a/test/CoverageMapping/ir.c b/test/CoverageMapping/ir.c
new file mode 100644
index 0000000..a1cb570
--- /dev/null
+++ b/test/CoverageMapping/ir.c
@@ -0,0 +1,12 @@
+// Check the data structures emitted by coverage mapping
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm -fprofile-instr-generate -fcoverage-mapping | FileCheck %s
+
+
+void foo(void) { }
+
+int main(void) {
+  foo();
+  return 0;
+}
+
+// CHECK: @__llvm_coverage_mapping = internal constant { i32, i32, i32, i32, [2 x { i8*, i32, i32, i64 }], [{{[0-9]+}} x i8] } { i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 0, [2 x { i8*, i32, i32, i64 }] [{ i8*, i32, i32, i64 } { i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i32 3, i32 9, i64 {{[0-9]+}} }, { i8*, i32, i32, i64 } { i8* getelementptr inbounds ([4 x i8]* @__llvm_profile_name_main, i32 0, i32 0), i32 4, i32 9, i64 {{[0-9]+}} }]
diff --git a/test/CoverageMapping/label.cpp b/test/CoverageMapping/label.cpp
new file mode 100644
index 0000000..d936260
--- /dev/null
+++ b/test/CoverageMapping/label.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s
+
+                             // CHECK: func
+void func() {                // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+18]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;                 // CHECK-NEXT: File 0, [[@LINE+2]]:14 -> [[@LINE+2]]:20 = (#0 + #3) (HasCodeBefore = 0)
+                             // CHECK-NEXT: File 0, [[@LINE+1]]:22 -> [[@LINE+1]]:25 = #3 (HasCodeBefore = 0)
+  for(i = 0; i < 10; ++i) {  // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+10]]:4 = #1 (HasCodeBefore = 0)
+    if(i < 5) {              // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+6]]:6 = #2 (HasCodeBefore = 0)
+      {
+        x:                   // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+6]]:14 = #3 (HasCodeBefore = 0)
+          int j = 1;
+      }
+      int m = 2;
+    } else
+      goto x;                // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = (#1 - #2) (HasCodeBefore = 0)
+    int k = 3;
+  }
+  static int j = 0;          // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:12 = ((#0 + #3) - #1) (HasCodeBefore = 0)
+  ++j;
+  if(j == 1)
+    goto x;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #4 (HasCodeBefore = 0)
+}
+
+                             // CHECK-NEXT: test1
+void test1(int x) {          // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+7]]:2 = #0 (HasCodeBefore = 0)
+  if(x == 0)
+    goto a;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 (HasCodeBefore = 0)
+  goto b;                    // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:9 = (#0 - #1) (HasCodeBefore = 0)
+a:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE]]:2 = #2 (HasCodeBefore = 0)
+b:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+1]]:12 = #3 (HasCodeBefore = 0)
+  x = x + 1;
+}
+
+                             // CHECK-NEXT: test2
+void test2(int x) {          // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+8]]:2 = #0 (HasCodeBefore = 0)
+  if(x == 0)
+    goto a;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = #1 (HasCodeBefore = 0)
+                             // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+1]]:17 = (#0 - #1) (HasCodeBefore = 0)
+  else if(x == 1) goto b;    // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE]]:25 = #2 (HasCodeBefore = 0)
+a:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE]]:2 = #3 (HasCodeBefore = 0)
+b:                           // CHECK-NEXT: File 0, [[@LINE]]:1 -> [[@LINE+1]]:12 = #4 (HasCodeBefore = 0)
+  x = x + 1;
+}
+
+                             // CHECK-NEXT: main
+int main() {                 // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+17]]:2 = #0 (HasCodeBefore = 0)
+  int j = 0;
+  for(int i = 0; i < 10; ++i) { // CHECK: File 0, [[@LINE]]:31 -> [[@LINE+11]]:4 = #1 (HasCodeBefore = 0)
+  a:                         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:13 = #2 (HasCodeBefore = 0)
+    if(i < 3)
+      goto e;                // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = #3 (HasCodeBefore = 0)
+    goto c;                  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:11 = (#2 - #3) (HasCodeBefore = 0)
+  b:                         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4 (HasCodeBefore = 0)
+    j = 2;
+  c:                         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #5 (HasCodeBefore = 0)
+    j = 1;
+                             // CHECK-NEXT: File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:4 = #6 (HasCodeBefore = 0)
+  e: f: ;                    // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:10 = #7 (HasCodeBefore = 0)
+  }
+  func();                    // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:11 = ((#0 + #7) - #1) (HasCodeBefore = 0)
+  test1(0);
+  test2(2);
+}
diff --git a/test/CoverageMapping/logical.cpp b/test/CoverageMapping/logical.cpp
new file mode 100644
index 0000000..0971c75
--- /dev/null
+++ b/test/CoverageMapping/logical.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %s | FileCheck %s
+
+int main() {                        // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+10]]:2 = #0 (HasCodeBefore = 0)
+  bool bt = true;
+  bool bf = false;
+  bool a = bt && bf;                // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE]]:20 = #1 (HasCodeBefore = 0)
+  a = bt &&
+      bf;                           // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:9 = #2 (HasCodeBefore = 0)
+  a = bf || bt;                     // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:15 = #3 (HasCodeBefore = 0)
+  a = bf ||
+      bt;                           // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:9 = #4 (HasCodeBefore = 0)
+  return 0;
+}
diff --git a/test/CoverageMapping/loopmacro.c b/test/CoverageMapping/loopmacro.c
new file mode 100644
index 0000000..8480dbd
--- /dev/null
+++ b/test/CoverageMapping/loopmacro.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loopmacro.c %s | FileCheck %s
+
+#   define HASH_BITS  15
+#define MIN_MATCH  3
+#define H_SHIFT  ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
+#define WMASK 0xFFFF
+#define HASH_MASK 0xFFFF
+#define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
+#define INSERT_STRING(s, match_head) \
+   (UPDATE_HASH(ins_h, window[(s) + MIN_MATCH-1]), \
+    prev[(s) & WMASK] = match_head = head[ins_h], \
+    head[ins_h] = (s))
+
+int main() {                                // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+12]]:2 = #0 (HasCodeBefore = 0)
+  int strstart = 0;
+  int hash_head = 2;
+  int prev_length = 5;
+  int ins_h = 1;
+  int prev[32] = { 0 };
+  int head[32] = { 0 };
+  int window[1024] = { 0 };
+  do {                                     // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE+3]]:30 = (#0 + #1) (HasCodeBefore = 0)
+      strstart++;
+      INSERT_STRING(strstart, hash_head);  // CHECK-NEXT: Expansion,File 0, [[@LINE]]:7 -> [[@LINE]]:20 = (#0 + #1) (HasCodeBefore = 0, Expanded file = 1)
+  } while (--prev_length != 0);
+}
+// CHECK-NEXT: File 0, 24:21 -> 24:29 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 24:21 -> 24:29 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 24:21 -> 24:29 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 0, 24:31 -> 24:40 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 10:4 -> 12:23 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 1, 10:5 -> 10:16 = (#0 + #1) (HasCodeBefore = 0, Expanded file = 2)
+// CHECK-NEXT: File 1, 10:17 -> 10:22 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 10:17 -> 10:22 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 10:24 -> 10:32 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 10:33 -> 10:36 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 10:46 -> 10:49 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: File 2, 8:26 -> 8:66 = (#0 + #1) (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 2, 8:38 -> 8:45 = (#0 + #1) (HasCodeBefore = 0, Expanded file = 3)
+// CHECK-NEXT: File 3, 5:18 -> 5:53 = (#0 + #1) (HasCodeBefore = 0)
diff --git a/test/CoverageMapping/loops.cpp b/test/CoverageMapping/loops.cpp
new file mode 100644
index 0000000..81fad91
--- /dev/null
+++ b/test/CoverageMapping/loops.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
+
+                                    // CHECK: rangedFor
+void rangedFor() {                  // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+6]]:2 = #0 (HasCodeBefore = 0)
+  int arr[] = { 1, 2, 3, 4, 5 };
+  int sum = 0;
+  for(auto i : arr) {               // CHECK-NEXT: File 0, [[@LINE]]:21 -> [[@LINE+2]]:4 = #1 (HasCodeBefore = 0)
+    sum += i;
+  }
+}
+
+                                    // CHECK-NEXT: main
+int main() {                        // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+24]]:2 = #0 (HasCodeBefore = 0)
+                                    // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:24 = (#0 + #1) (HasCodeBefore = 0)
+  for(int i = 0; i < 10; ++i)       // CHECK-NEXT: File 0, [[@LINE]]:26 -> [[@LINE]]:29 = #1 (HasCodeBefore = 0)
+     ;                              // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:7 = #1 (HasCodeBefore = 0)
+  for(int i = 0;
+      i < 10;                       // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:13 = (#0 + #2) (HasCodeBefore = 0)
+      ++i)                          // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:10 = #2 (HasCodeBefore = 0)
+  {                                 // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:4 = #2 (HasCodeBefore = 0)
+    int x = 0;
+  }
+  int j = 0;                        // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:14 = (#0 + #3) (HasCodeBefore = 0)
+  while(j < 5) ++j;                 // CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE]]:19 = #3 (HasCodeBefore = 0)
+  do {                              // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE+2]]:17 = (#0 + #4) (HasCodeBefore = 0)
+    ++j;
+  } while(j < 10);
+  j = 0;
+  while
+   (j < 5)                          // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:10 = (#0 + #5) (HasCodeBefore = 0)
+     ++j;                           // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE]]:9 = #5 (HasCodeBefore = 0)
+  do
+    ++j;                            // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+1]]:15 = (#0 + #6) (HasCodeBefore = 0)
+  while(j < 10);
+  rangedFor();
+  return 0;
+}
diff --git a/test/CoverageMapping/macroception.c b/test/CoverageMapping/macroception.c
new file mode 100644
index 0000000..edbd84a
--- /dev/null
+++ b/test/CoverageMapping/macroception.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroception.c %s | FileCheck %s
+
+#define M2 {
+#define M1 M2
+#define M22 }
+#define M11 M22
+
+// CHECK-LABEL: main:
+int main() M1       // CHECK-NEXT: Expansion,File 0, [[@LINE]]:12 -> [[@LINE]]:14 = #0 (HasCodeBefore = 0, Expanded file = 2)
+  return 0;         // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:2 = #0 (HasCodeBefore = 0)
+}
+// CHECK-NEXT: File 1, 3:12 -> 3:13 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 2, 4:12 -> 4:14 = #0 (HasCodeBefore = 0, Expanded file = 1)
+
+
+// CHECK-LABEL: func2:
+void func2() {      // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+1]]:12 = #0 (HasCodeBefore = 0)
+  int x = 0;
+M11                 // CHECK-NEXT: Expansion,File 0, [[@LINE]]:1 -> [[@LINE]]:4 = #0 (HasCodeBefore = 0, Expanded file = 2)
+// CHECK-NEXT: File 1, 5:13 -> 5:14 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 2, 6:13 -> 6:16 = #0 (HasCodeBefore = 0, Expanded file = 1)
+
+// CHECK-LABEL: func3:
+void func3() M1     // CHECK-NEXT: Expansion,File 0, [[@LINE]]:14 -> [[@LINE]]:16 = #0 (HasCodeBefore = 0, Expanded file = 2)
+  int x = 0;        // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:12 = #0 (HasCodeBefore = 0)
+M11                 // CHECK-NEXT: Expansion,File 0, [[@LINE]]:1 -> [[@LINE]]:4 = #0 (HasCodeBefore = 0, Expanded file = 4)
+
+// CHECK-NEXT: File 1, 3:12 -> 3:13 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 2, 4:12 -> 4:14 = #0 (HasCodeBefore = 0, Expanded file = 1)
+// CHECK-NEXT: File 3, 5:13 -> 5:14 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 4, 6:13 -> 6:16 = #0 (HasCodeBefore = 0, Expanded file = 3)
+
+// CHECK-LABEL: func4:
+// CHECK-NEXT: File 0, 3:12 -> 3:13 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 1, 4:12 -> 4:14 = #0 (HasCodeBefore = 0, Expanded file = 0)
+void func4() M1 M11
+// CHECK-NEXT: Expansion,File 2, [[@LINE-1]]:14 -> [[@LINE-1]]:16 = #0 (HasCodeBefore = 0, Expanded file = 1)
+// CHECK-NEXT: Expansion,File 2, [[@LINE-2]]:17 -> [[@LINE-2]]:20 = #0 (HasCodeBefore = 0, Expanded file = 4)
+// CHECK-NEXT: File 3, 5:13 -> 5:14 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 4, 6:13 -> 6:16 = #0 (HasCodeBefore = 0, Expanded file = 3)
diff --git a/test/CoverageMapping/macroparams.c b/test/CoverageMapping/macroparams.c
new file mode 100644
index 0000000..adf01ec
--- /dev/null
+++ b/test/CoverageMapping/macroparams.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams.c %s | FileCheck %s
+
+#define MACRO2(X2) (X2 + 2) // CHECK-DAG: File 2, [[@LINE]]:20 -> [[@LINE]]:28 = #0 (HasCodeBefore = 0)
+#define MACRO(X) MACRO2(x)  // CHECK-DAG: File 1, [[@LINE]]:25 -> [[@LINE]]:26 = #0 (HasCodeBefore = 0)
+                            // CHECK-DAG: Expansion,File 1, [[@LINE-1]]:18 -> [[@LINE-1]]:24 = #0 (HasCodeBefore = 0, Expanded file = 2)
+
+
+int main() {                // CHECK-DAG: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+  int x = 0;
+  MACRO(x);                 // CHECK-DAG: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:8 = #0 (HasCodeBefore = 0, Expanded file = 1)
+  return 0;
+}
diff --git a/test/CoverageMapping/macroparams2.c b/test/CoverageMapping/macroparams2.c
new file mode 100644
index 0000000..0445370
--- /dev/null
+++ b/test/CoverageMapping/macroparams2.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %s | FileCheck %s
+
+// A test case for when the first macro parameter is used after the second
+// macro parameter.
+
+struct S {
+  int i, j;
+};
+
+#define MACRO(REFS, CALLS)  (4 * (CALLS) < (REFS))
+
+int main() {                       // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+7]]:2 = #0 (HasCodeBefore = 0)
+  struct S arr[32] = { 0 };        // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:7 -> [[@LINE+2]]:12 = #0 (HasCodeBefore = 0, Expanded file = 1)
+  int n = 0;                       // CHECK-NEXT: File 0, [[@LINE+1]]:13 -> [[@LINE+1]]:21 = #0 (HasCodeBefore = 0)
+  if (MACRO(arr[n].j, arr[n].i)) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE]]:31 = #0 (HasCodeBefore = 0)
+    n = 1;                         // CHECK-NEXT: File 0, [[@LINE-1]]:34 -> [[@LINE+1]]:4 = #1 (HasCodeBefore = 0)
+  }
+  return n;
+}                                  // CHECK-NEXT: File 1, [[@LINE-9]]:29 -> [[@LINE-9]]:51 = #0 (HasCodeBefore = 0
+
diff --git a/test/CoverageMapping/macros.c b/test/CoverageMapping/macros.c
new file mode 100644
index 0000000..d3a0e6a
--- /dev/null
+++ b/test/CoverageMapping/macros.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
+
+void bar();
+#define MACRO return; bar()
+#define MACRO_2 bar()
+#define MACRO_1 return; MACRO_2
+
+               // CHECK: func
+void func() {  // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+  MACRO;       // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:8 = #0 (HasCodeBefore = 0, Expanded file = 1)
+  i = 2;       // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:8 = 0 (HasCodeBefore = 0)
+}
+// CHECK-NEXT: File 1, 4:15 -> 4:21 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: File 1, 4:23 -> 4:28 = 0 (HasCodeBefore = 0)
+
+               // CHECK-NEXT: func2
+void func2() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+  MACRO_1;     // CHECK-NEXT: Expansion,File 0, [[@LINE]]:3 -> [[@LINE]]:10 = #0 (HasCodeBefore = 0, Expanded file = 1)
+  i = 2;       // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:8 = 0 (HasCodeBefore = 0)
+}
+// CHECK-NEXT: File 1, 6:17 -> 6:23 = #0 (HasCodeBefore = 0)
+// CHECK-NEXT: Expansion,File 1, 6:25 -> 6:32 = 0 (HasCodeBefore = 0, Expanded file = 2)
+// CHECK-NEXT: File 2, 5:17 -> 5:22 = 0 (HasCodeBefore = 0)
+
diff --git a/test/CoverageMapping/nestedclass.cpp b/test/CoverageMapping/nestedclass.cpp
new file mode 100644
index 0000000..aca4abf
--- /dev/null
+++ b/test/CoverageMapping/nestedclass.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name nestedclass.cpp %s > %tmapping
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-OUTER
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INNER
+// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INNERMOST
+
+struct Test {                   // CHECK-OUTER: emitTest
+  void emitTest() {             // CHECK-OUTER: File 0, [[@LINE]]:19 -> [[@LINE+2]]:4 = #0 (HasCodeBefore = 0)
+    int i = 0;
+  }
+  struct Test2 {                // CHECK-INNER: emitTest2
+    void emitTest2() {          // CHECK-INNER: File 0, [[@LINE]]:22 -> [[@LINE+2]]:6 = #0 (HasCodeBefore = 0)
+      int i = 0;
+    }
+    struct Test3 {              // CHECK-INNERMOST: emitTest3
+      static void emitTest3() { // CHECK-INNERMOST: File 0, [[@LINE]]:31 -> [[@LINE+2]]:8 = 0 (HasCodeBefore = 0)
+        int i = 0;
+      }
+    };
+  };
+};
+
+int main() {
+  Test t;
+  Test::Test2 t2;
+  t.emitTest();
+  t2.emitTest2();
+  return 0;
+}
diff --git a/test/CoverageMapping/objc.m b/test/CoverageMapping/objc.m
new file mode 100644
index 0000000..b41ab94
--- /dev/null
+++ b/test/CoverageMapping/objc.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
+
+@interface A
+- (void)bork:(int)msg;
+@end
+
+                      // CHECK: func
+void func(A *a) {     // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+3]]:2 = #0 (HasCodeBefore = 0)
+  if (a)
+    [a bork:  20  ];  // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:20 = #1 (HasCodeBefore = 0)
+}
+
+@interface NSArray
++ (NSArray*) arrayWithObjects: (id) first, ...;
+- (unsigned) count;
+@end
+
+                               // CHECK: func2
+void func2(NSArray *array) {   // CHECK-NEXT: File 0, [[@LINE]]:28 -> [[@LINE+10]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+  for (NSArray *x in array) {  // CHECK-NEXT: File 0, [[@LINE]]:29 -> [[@LINE+6]]:4 = #1 (HasCodeBefore = 0)
+    if (x) {                   // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = #2 (HasCodeBefore = 0)
+      i = 1;
+    } else {                   // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = (#1 - #2) (HasCodeBefore = 0)
+      i = -1;
+    }
+  }
+  i = 0;
+}
diff --git a/test/CoverageMapping/preprocessor.c b/test/CoverageMapping/preprocessor.c
new file mode 100644
index 0000000..a6edeb7
--- /dev/null
+++ b/test/CoverageMapping/preprocessor.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name preprocessor.c %s | FileCheck %s
+
+                 // CHECK: func
+void func() {    // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+#ifdef MACRO     // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+2]]:2 = 0 (HasCodeBefore = 0)
+  int x = i;
+#endif
+}
+
+#if 0
+  int g = 0;
+
+  void bar() { }
+#endif
+
+                 // CHECK: main
+int main() {     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+19]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+#if 0            // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4]]:2 = 0 (HasCodeBefore = 0)
+  if(i == 0) {
+    i = 1;
+  }
+#endif
+
+#if 1
+  if(i == 0) {   // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1 (HasCodeBefore = 0)
+    i = 1;
+  }
+#else            // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+5]]:2 = 0 (HasCodeBefore = 0)
+  if(i == 1) {
+    i = 0;
+  }
+}
+#endif
+  return 0;
+}
diff --git a/test/CoverageMapping/return.c b/test/CoverageMapping/return.c
new file mode 100644
index 0000000..9c68759
--- /dev/null
+++ b/test/CoverageMapping/return.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name return.c %s | FileCheck %s
+
+                                // CHECK: func
+void func() {                   // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+3]]:2 = #0 (HasCodeBefore = 0)
+  return;
+  int i = 0;                    // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:12 = 0 (HasCodeBefore = 0)
+}
+
+                                // CHECK-NEXT: func2
+void func2() {                  // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+13]]:2 = #0 (HasCodeBefore = 0)
+                                // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = ((#0 + #1) - #2) (HasCodeBefore = 0)
+                                // CHECK-NEXT: File 0, [[@LINE+1]]:26 -> [[@LINE+1]]:29 = (#1 - #2) (HasCodeBefore = 0)
+  for(int i = 0; i < 10; ++i) { // CHECK-NEXT: File 0, [[@LINE]]:31 -> [[@LINE+9]]:4 = #1 (HasCodeBefore = 0)
+    if(i > 2) {                 // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+2]]:6 = #2 (HasCodeBefore = 0)
+      return;
+    }                           // CHECK-NEXT: File 0, [[@LINE+1]]:5 -> [[@LINE+3]]:11 = (#1 - #2) (HasCodeBefore = 0)
+    if(i == 3) {                // CHECK-NEXT: File 0, [[@LINE]]:16 -> [[@LINE+2]]:6 = #3 (HasCodeBefore = 0)
+      int j = 1;
+    } else {                    // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+2]]:6 = ((#1 - #2) - #3) (HasCodeBefore = 0)
+      int j = 2;
+    }
+  }
+}
+
+                               // CHECK-NEXT: func3
+void func3(int x) {            // CHECK-NEXT: File 0, [[@LINE]]:19 -> [[@LINE+9]]:2 = #0 (HasCodeBefore = 0)
+  if(x > 5) {                  // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE+6]]:4 = #1 (HasCodeBefore = 0)
+    while(x >= 9) {            // CHECK-NEXT: File 0, [[@LINE]]:11 -> [[@LINE]]:17 = #1 (HasCodeBefore = 0)
+      return;                  // CHECK-NEXT: File 0, [[@LINE-1]]:19 -> [[@LINE+2]]:6 = #2 (HasCodeBefore = 0)
+      --x;                     // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:10 = 0 (HasCodeBefore = 0)
+    }
+    int i = 0;                 // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:14 = (#1 - #2) (HasCodeBefore = 0)
+  }
+  int j = 0;                   // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:12 = (#0 - #2) (HasCodeBefore = 0)
+}
diff --git a/test/CoverageMapping/switch.c b/test/CoverageMapping/switch.c
new file mode 100644
index 0000000..b667225
--- /dev/null
+++ b/test/CoverageMapping/switch.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
+                    // CHECK: foo
+void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0 (HasCodeBefore = 0)
+  switch(i) {
+  case 1:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = #2 (HasCodeBefore = 0)
+    return;
+  case 2:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #3 (HasCodeBefore = 0)
+    break;
+  }                 // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:12 = #1 (HasCodeBefore = 0)
+  int x = 0;
+}
+
+                    // CHECK-NEXT: main
+int main() {        // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+34]]:2 = #0 (HasCodeBefore = 0)
+  int i = 0;
+  switch(i) {
+  case 0:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #2 (HasCodeBefore = 0)
+    i = 1;
+    break;
+  case 1:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #3 (HasCodeBefore = 0)
+    i = 2;
+    break;
+  default:          // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #4 (HasCodeBefore = 0)
+    break;
+  }                 // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:14 = #1 (HasCodeBefore = 0)
+  switch(i) {
+  case 0:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+2]]:10 = #6 (HasCodeBefore = 0)
+    i = 1;
+    break;
+  case 1:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = #7 (HasCodeBefore = 0)
+    i = 2;
+  default:          // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:10 = (#7 + #8) (HasCodeBefore = 0)
+    break;
+  }                 // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:14 = #5 (HasCodeBefore = 0)
+
+
+  switch(i) {
+  case 1:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:10 = #10 (HasCodeBefore = 0)
+  case 2:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = (#10 + #11) (HasCodeBefore = 0)
+    i = 11;
+  case 3:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:10 = ((#10 + #11) + #12) (HasCodeBefore = 0)
+  case 4:           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+1]]:11 = (((#10 + #11) + #12) + #13) (HasCodeBefore = 0)
+    i = 99;
+  }                 // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE+3]]:11 = #9 (HasCodeBefore = 0)
+
+  foo(1);
+  return 0;
+}
diff --git a/test/CoverageMapping/templates.cpp b/test/CoverageMapping/templates.cpp
new file mode 100644
index 0000000..fcb92e1
--- /dev/null
+++ b/test/CoverageMapping/templates.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
+
+template<typename T>
+void unused(T x) {
+  return;
+}
+
+template<typename T>
+int func(T x) {  // CHECK: func
+  if(x)          // CHECK: func
+    return 0;
+  else
+    return 1;
+  int j = 1;
+}
+
+int main() {
+  func<int>(0);
+  func<bool>(true);
+  return 0;
+}
diff --git a/test/CoverageMapping/test.c b/test/CoverageMapping/test.c
new file mode 100644
index 0000000..594bcf6
--- /dev/null
+++ b/test/CoverageMapping/test.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name test.c %s | FileCheck %s
+
+void bar();
+static void static_func();
+
+                                 // CHECK: main
+int main() {                     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+7]]:2 = #0 (HasCodeBefore = 0)
+                                 // CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:24 = (#0 + #1) (HasCodeBefore = 0)
+  for(int i = 0; i < 10; ++i) {  // CHECK-NEXT: File 0, [[@LINE]]:26 -> [[@LINE]]:29 = #1 (HasCodeBefore = 0)
+    bar();                       // CHECK-NEXT: File 0, [[@LINE-1]]:31 -> [[@LINE+1]]:4 = #1 (HasCodeBefore = 0)
+  }
+  static_func();
+  return 0;
+}
+
+                                 // CHECK-NEXT: foo
+void foo() {                     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0 (HasCodeBefore = 0)
+  if(1) {                        // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE+2]]:4 = #1 (HasCodeBefore = 0)
+    int i = 0;
+  }
+}
+
+                                 // CHECK-NEXT: bar
+void bar() {                     // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+1]]:2 = #0 (HasCodeBefore = 0)
+}
+
+                                 // CHECK-NEXT: static_func
+void static_func() { }           // CHECK: File 0, [[@LINE]]:20 -> [[@LINE]]:23 = #0 (HasCodeBefore = 0)
+
+                                 // CHECK-NEXT: func
+static void func() { }           // CHECK: File 0, [[@LINE]]:20 -> [[@LINE]]:23 = 0 (HasCodeBefore = 0)
diff --git a/test/CoverageMapping/trycatch.cpp b/test/CoverageMapping/trycatch.cpp
new file mode 100644
index 0000000..a513845
--- /dev/null
+++ b/test/CoverageMapping/trycatch.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trycatch.cpp %s | FileCheck %s
+
+class Error {
+};
+
+class ImportantError {
+};
+
+class Warning {
+};
+
+                                      // CHECK: func
+void func(int i) {                    // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+5]]:2 = #0 (HasCodeBefore = 0)
+  if(i % 2)
+    throw Error();                    // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:16 = #1 (HasCodeBefore = 0)
+  else if(i == 8)                     // CHECK-NEXT: File 0, [[@LINE]]:8 -> [[@LINE]]:17 = (#0 - #1) (HasCodeBefore = 0)
+    throw ImportantError();           // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE]]:25 = #2 (HasCodeBefore = 0)
+}
+
+                                      // CHECK-NEXT: main
+int main() {                          // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+13]]:2 = #0 (HasCodeBefore = 0)
+  int j = 0;
+  try {
+    func(j);
+  } catch(const Error &e) {           // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:10 = #2 (HasCodeBefore = 0)
+    j = 1;
+  } catch(const ImportantError &e) {  // CHECK-NEXT: File 0, [[@LINE]]:36 -> [[@LINE+3]]:8 = #3 (HasCodeBefore = 0)
+    j = 11;
+  }
+  catch(const Warning &w) {           // CHECK-NEXT: File 0, [[@LINE]]:27 -> [[@LINE+2]]:4 = #4 (HasCodeBefore = 0)
+    j = 0;
+  }
+  return 0;                           // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:11 = #1 (HasCodeBefore = 0)
+}
diff --git a/test/Driver/B-opt.c b/test/Driver/B-opt.c
index 6759353..3180094 100644
--- a/test/Driver/B-opt.c
+++ b/test/Driver/B-opt.c
@@ -3,20 +3,20 @@
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN:     -B %S/Inputs/B_opt_tree/dir1 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-TRIPLE %s
-// CHECK-B-OPT-TRIPLE: "{{.*}}/Inputs/B_opt_tree/dir1{{/|\\}}i386-unknown-linux-ld"
+// CHECK-B-OPT-TRIPLE: "{{.*}}/Inputs/B_opt_tree/dir1{{/|\\\\}}i386-unknown-linux-ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN:     -B %S/Inputs/B_opt_tree/dir2 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-DIR %s
-// CHECK-B-OPT-DIR: "{{.*}}/Inputs/B_opt_tree/dir2{{/|\\}}ld"
+// CHECK-B-OPT-DIR: "{{.*}}/Inputs/B_opt_tree/dir2{{/|\\\\}}ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN:     -B %S/Inputs/B_opt_tree/dir3/prefix- 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-PREFIX %s
-// CHECK-B-OPT-PREFIX: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\}}prefix-ld"
+// CHECK-B-OPT-PREFIX: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\\\}}prefix-ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN:     -B %S/Inputs/B_opt_tree/dir3/prefix- \
 // RUN:     -B %S/Inputs/B_opt_tree/dir2 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-MULT %s
-// CHECK-B-OPT-MULT: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\}}prefix-ld"
+// CHECK-B-OPT-MULT: "{{.*}}/Inputs/B_opt_tree/dir3{{/|\\\\}}prefix-ld"
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o b/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/armv7-windows-itanium-ld
old mode 100644
new mode 100755
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o
copy to test/Driver/Inputs/Windows/ARM/8.1/usr/bin/armv7-windows-itanium-ld
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crti.o b/test/Driver/Inputs/basic_netbsd_tree/usr/lib/eabihf/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crti.o
copy to test/Driver/Inputs/basic_netbsd_tree/usr/lib/eabihf/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crti.o b/test/Driver/Inputs/basic_netbsd_tree/usr/lib/powerpc/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crti.o
copy to test/Driver/Inputs/basic_netbsd_tree/usr/lib/powerpc/crti.o
diff --git a/test/Driver/Inputs/cc1-response.txt b/test/Driver/Inputs/cc1-response.txt
new file mode 100644
index 0000000..0236fdc
--- /dev/null
+++ b/test/Driver/Inputs/cc1-response.txt
@@ -0,0 +1,4 @@
+
+
+-cc1
+-triple i686-pc-windows-msvc
diff --git a/test/Driver/Inputs/gen-response.c b/test/Driver/Inputs/gen-response.c
new file mode 100644
index 0000000..84ffb40
--- /dev/null
+++ b/test/Driver/Inputs/gen-response.c
@@ -0,0 +1,8 @@
+#define M -DTEST
+#define M1 M M M M M M M M M M
+#define M2 M1 M1 M1 M1 M1 M1 M1 M1 M1 M1
+#define M3 M2 M2 M2 M2 M2 M2 M2 M2 M2 M2
+#define M4 M3 M3 M3 M3 M3 M3 M3 M3 M3 M3
+#define M5 M4 M4 M4 M4 M4 M4 M4 M4 M4 M4
+#define TEXT M5 M5 M5
+TEXT
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/gentoo_linux_gcc_4.6.2_tree/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/gentoo_linux_gcc_4.6.2_tree/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/gentoo_linux_gcc_4.6.4_tree/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/gentoo_linux_gcc_4.6.4_tree/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/include-fixed/uclibc/el/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/include-fixed/uclibc/el/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/bits/.keep b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/include-fixed/uclibc/nan2008/el/.keep
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/bits/.keep
rename to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/include-fixed/uclibc/nan2008/el/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/bits/.keep b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/include-fixed/uclibc/soft-float/el/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/bits/.keep
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/include-fixed/uclibc/soft-float/el/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/el/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/el/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/el/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/el/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtbegin.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtend.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/el/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/el/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/el/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/nan2008/el/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/el/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/el/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/el/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/el/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/lib/uclibc/el/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/lib/uclibc/el/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/lib/uclibc/nan2008/el/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/lib/uclibc/nan2008/el/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/lib/uclibc/soft-float/el/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/lib/uclibc/soft-float/el/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/lib/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/lib/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/el/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/lib/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/lib/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/lib/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/lib/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/lib/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/lib/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/nan2008/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/lib/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/lib/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/lib/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/lib/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/soft-float/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/include/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/include/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_cs_tree/mips-linux-gnu/libc/uclibc/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/micromips/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips16/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips32/mips16/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/64/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/64/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/el/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/nan2008/crtbegin.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/nan2008/crtbegin.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/nan2008/crtend.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/mips64r2/fp64/nan2008/crtend.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/crtbegin.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
rename to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/crtend.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
rename to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/nan2008/crtbegin.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/nan2008/crtbegin.o
rename to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/nan2008/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/nan2008/crtend.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/nan2008/crtend.o
rename to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/nan2008/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/sof/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/sof/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/sof/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/el/sof/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/nan2008/crtbegin.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtbegin.o
rename to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/nan2008/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/nan2008/crtend.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/nan2008/crtend.o
rename to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/nan2008/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/sof/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/sof/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o b/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/sof/crtend.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtend.o
copy to test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/uclibc/sof/crtend.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/fp64/bits/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/fp64/bits/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el/nan2008/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep
copy to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el/nan2008/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el/sof/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep
copy to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el/sof/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/nan2008/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep
copy to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/nan2008/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/sof/bits/.keep
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/bits/.keep
rename to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/sof/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/micromips/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/micromips/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/micromips/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/micromips/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/micromips/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/micromips/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips16/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips16/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips16/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips16/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips16/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips16/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/mips16/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/mips16/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/mips16/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/mips16/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/mips16/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips32/mips16/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/64/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/64/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/64/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/64/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/64/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/64/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/64/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/64/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/64/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/64/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/64/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/64/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/el/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/el/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/fp64/nan2008/.keep
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/mips64r2/fp64/nan2008/.keep
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/el/nan2008/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/el/nan2008/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/el/sof/.keep
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
rename to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/el/sof/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/nan2008/.keep
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
rename to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/nan2008/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/sof/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/uclibc/sof/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/micromips/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips16/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips32/mips16/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/64/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/64/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/el/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/nan2008/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crt1.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crt1.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crti.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crti.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crtn.o
deleted file mode 100644
index e69de29..0000000
--- a/test/Driver/Inputs/mips_fsf_tree/sysroot/mips64r2/fp64/usr/lib/crtn.o
+++ /dev/null
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/include/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/include/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/nan2008/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/include/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/include/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/sof/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/include/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/include/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/lib/crt1.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crt1.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/lib/crti.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crti.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/lib/crtn.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crtn.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/el/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/include/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/include/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/lib/crt1.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crt1.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/lib/crti.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crti.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/lib/crtn.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/nan2008/usr/lib/crtn.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/nan2008/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/include/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/include/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/lib/crt1.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crt1.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/lib/crti.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crti.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/lib/crtn.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/el/fp64/usr/lib/crtn.o
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/sof/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/include/bits/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/include/bits/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/lib/crt1.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crti.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/lib/crti.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crti.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/lib/crti.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crtn.o b/test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/lib/crtn.o
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crtn.o
rename to test/Driver/Inputs/mips_fsf_tree/sysroot/uclibc/usr/lib/crtn.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/lib/i386-linux-gnu/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/lib/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/lib/x86_64-linux-gnu/.keep
old mode 100644
new mode 100755
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/fp64/nan2008/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/lib/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/include/c++/4.8/backward/.keep
old mode 100644
new mode 100755
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/include/c++/4.8/backward/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/include/i386-linux-gnu/c++/4.8/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/include/i386-linux-gnu/c++/4.8/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/bits/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/include/x86_64-linux-gnu/c++/4.8/32/.keep
old mode 100644
new mode 100755
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/bits/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/include/x86_64-linux-gnu/c++/4.8/32/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/gcc/i686-linux-gnu/4.8/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/gcc/x86_64-linux-gnu/4.8/32/crtbegin.o
old mode 100644
new mode 100755
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/gcc/x86_64-linux-gnu/4.8/32/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o
old mode 100644
new mode 100755
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/el/fp64/crtbegin.o
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/i386-linux-gnu/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep b/test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/x86_64-linux-gnu/.keep
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/mips-mti-linux-gnu/lib/el/fp64/nan2008/.keep
copy to test/Driver/Inputs/ubuntu_14.04_multiarch_tree2/usr/lib/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o b/test/Driver/Inputs/wildcard1.c
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o
copy to test/Driver/Inputs/wildcard1.c
diff --git a/test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o b/test/Driver/Inputs/wildcard2.c
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/sysroot/fp64/usr/lib/crt1.o
copy to test/Driver/Inputs/wildcard2.c
diff --git a/test/Driver/Xlinker-args.c b/test/Driver/Xlinker-args.c
index 4285af7..87b238b 100644
--- a/test/Driver/Xlinker-args.c
+++ b/test/Driver/Xlinker-args.c
@@ -3,17 +3,17 @@
 
 // RUN: %clang -target i386-apple-darwin9 -### \
 // RUN:   -Xlinker one -Xlinker --no-demangle \
-// RUN:   -Wl,two,--no-demangle,three -Xlinker four %s 2> %t
+// RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five %s 2> %t
 // RUN: FileCheck -check-prefix=DARWIN < %t %s
 //
 // RUN: %clang -target x86_64-pc-linux-gnu -### \
 // RUN:   -Xlinker one -Xlinker --no-demangle \
-// RUN:   -Wl,two,--no-demangle,three -Xlinker four %s 2> %t
+// RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
 //
 // DARWIN-NOT: --no-demangle
-// DARWIN: "one" "two" "three" "four"
-// LINUX: "--no-demangle" "one" "two" "three" "four"
+// DARWIN: "one" "two" "three" "four" "-z" "five"
+// LINUX: "--no-demangle" "one" "two" "three" "four" "-z" "five"
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -### \
diff --git a/test/Driver/aarch64-cpus.c b/test/Driver/aarch64-cpus.c
index 886bb00..1627660 100644
--- a/test/Driver/aarch64-cpus.c
+++ b/test/Driver/aarch64-cpus.c
@@ -7,7 +7,7 @@
 
 // RUN: %clang -target arm64 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s
 // RUN: %clang -target arm64 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s
-// RUN: %clang -target arm64_be -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s
+
 // ARM64-GENERIC: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-DARWIN %s
@@ -16,21 +16,28 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
 // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
+// RUN: %clang -target aarch64 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
 // CA53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53"
 
 // RUN: %clang -target arm64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
-// RUN: %clang -target arm64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
+// RUN: %clang -target arm64 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
 // ARM64-CA53: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a53"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s
 // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s
+// RUN: %clang -target aarch64 -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57 %s
 // CA57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a57"
 
 // RUN: %clang -target arm64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s
-// RUN: %clang -target arm64_be -mlittle-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s
+// RUN: %clang -target arm64 -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57 %s
 // ARM64-CA57: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cortex-a57"
 
 // RUN: %clang -target aarch64_be -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC-BE %s
@@ -38,27 +45,22 @@
 // RUN: %clang -target aarch64_be -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC-BE %s
 // GENERIC-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic"
 
-// RUN: %clang -target arm64_be -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC-BE %s
-// RUN: %clang -target arm64 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC-BE %s
-// RUN: %clang -target arm64_be -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC-BE %s
-// ARM64-GENERIC-BE: "-cc1"{{.*}} "-triple" "arm64_be{{.*}}" "-target-cpu" "generic"
-
 // RUN: %clang -target aarch64_be -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-BE %s
+// RUN: %clang -target aarch64_be -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-BE %s
+// RUN: %clang -target aarch64 -mbig-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-BE %s
+// RUN: %clang -target aarch64_be -mbig-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-BE %s
 // CA53-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "cortex-a53"
 
-// RUN: %clang -target arm64_be -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53-BE %s
-// RUN: %clang -target arm64 -mbig-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53-BE %s
-// RUN: %clang -target arm64_be -mbig-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53-BE %s
-// ARM64-CA53-BE: "-cc1"{{.*}} "-triple" "arm64_be{{.*}}" "-target-cpu" "cortex-a53"
-
 // RUN: %clang -target aarch64_be -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-BE %s
+// RUN: %clang -target aarch64_be -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-BE %s
+// RUN: %clang -target aarch64 -mbig-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-BE %s
+// RUN: %clang -target aarch64_be -mbig-endian -mtune=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CA57-BE %s
 // CA57-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "cortex-a57"
 
-// RUN: %clang -target arm64_be -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57-BE %s
-// RUN: %clang -target arm64 -mbig-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57-BE %s
-// RUN: %clang -target arm64_be -mbig-endian -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA57-BE %s
-// ARM64-CA57-BE: "-cc1"{{.*}} "-triple" "arm64_be{{.*}}" "-target-cpu" "cortex-a57"
+// RUN: %clang -target aarch64 -mcpu=cortex-a57 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=MCPU-MTUNE %s
+// RUN: %clang -target aarch64 -mtune=cortex-a53 -mcpu=cortex-a57  -### -c %s 2>&1 | FileCheck -check-prefix=MCPU-MTUNE %s
+// MCPU-MTUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53"
diff --git a/test/Driver/aarch64-mfpu.c b/test/Driver/aarch64-mfpu.c
deleted file mode 100644
index ba00bfb..0000000
--- a/test/Driver/aarch64-mfpu.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// Test that different values of -mfpu pick correct AArch64 FPU target-feature(s).
-
-// RUN: %clang -target aarch64-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NEON %s
-// RUN: %clang -target aarch64-linux-eabi %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NEON %s
-// RUN: %clang -target arm64-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NEON %s
-// RUN: %clang -target arm64-linux-eabi %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NEON %s
-// CHECK-NEON: "-target-feature" "+neon"
-
-// RUN: %clang -target aarch64-linux-eabi -mfpu=fp-armv8 %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-ARMV8 %s
-// RUN: %clang -target arm64-linux-eabi -mfpu=fp-armv8 %s -### -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-ARMV8 %s
-// CHECK-FP-ARMV8: "-target-feature" "+fp-armv8"
-
-// RUN: %clang -target aarch64-linux-eabi -mfpu=neon-fp-armv8 %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NEON-FP-ARMV8 %s
-// RUN: %clang -target arm64-linux-eabi -mfpu=neon-fp-armv8 %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-NEON-FP-ARMV8 %s
-// CHECK-NEON-FP-ARMV8: "-target-feature" "+fp-armv8"
-// CHECK-NEON-FP-ARMV8: "-target-feature" "+neon"
-
-// RUN: %clang -target aarch64-linux-eabi -mfpu=crypto-neon-fp-armv8 %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-CRYPTO-NEON-FP-ARMV8 %s
-// RUN: %clang -target arm64-linux-eabi -mfpu=crypto-neon-fp-armv8 %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-CRYPTO-NEON-FP-ARMV8 %s
-// CHECK-CRYPTO-NEON-FP-ARMV8: "-target-feature" "+fp-armv8"
-// CHECK-CRYPTO-NEON-FP-ARMV8: "-target-feature" "+neon"
-// CHECK-CRYPTO-NEON-FP-ARMV8: "-target-feature" "+crypto"
diff --git a/test/Driver/arm-abi.c b/test/Driver/arm-abi.c
new file mode 100644
index 0000000..812a849
--- /dev/null
+++ b/test/Driver/arm-abi.c
@@ -0,0 +1,53 @@
+// The default ABI is aapcs
+// RUN: %clang -target arm--- %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+// RUN: %clang -target armeb--- %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+// RUN: %clang -target thumb--- %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+// RUN: %clang -target thumbeb--- %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+
+// MachO targets default to apcs-gnu, except for m-class processors
+// RUN: %clang -target arm--darwin- -arch armv7s %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-APCS-GNU %s
+// RUN: %clang -target thumb--darwin- -arch armv7s %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-APCS-GNU %s
+// RUN: %clang -target thumb--darwin- -arch armv7m %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+
+// Windows targets default to AAPCS, regardless of environment
+// RUN: %clang -target arm--windows-gnueabi %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+
+// NetBSD defaults to apcs-gnu, but can also use aapcs
+// RUN: %clang -target arm--netbsd- %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-APCS-GNU %s
+// RUN: %clang -target arm--netbsd-eabi %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+// RUN: %clang -target arm--netbsd-eabihf %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+
+// Otherwise, ABI is celected based on environment
+// RUN: %clang -target arm---android %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
+// RUN: %clang -target arm---gnueabi %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
+// RUN: %clang -target arm---gnueabihf %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
+// RUN: %clang -target arm---eabi %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+// RUN: %clang -target arm---eabihf %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+
+// ABI can be overridden by the -mabi= option
+// RUN: %clang -target arm---eabi -mabi=apcs-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-APCS-GNU %s
+// RUN: %clang -target arm---gnueabi -mabi=aapcs %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
+// RUN: %clang -target arm---eabi -mabi=aapcs-linux %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
+
+// CHECK-APCS-GNU: "-target-abi" "apcs-gnu"
+// CHECK-AAPCS: "-target-abi" "aapcs"
+// CHECK-AAPCS-LINUX: "-target-abi" "aapcs-linux"
diff --git a/test/Driver/arm-alignment.c b/test/Driver/arm-alignment.c
index 98046d7..3fe5951 100644
--- a/test/Driver/arm-alignment.c
+++ b/test/Driver/arm-alignment.c
@@ -44,5 +44,17 @@
 // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -mstrict-align -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
+// RUN: %clang -target aarch64-none-gnueabi -mkernel -mno-unaligned-access -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
+
 // CHECK-ALIGNED-ARM: "-backend-option" "-arm-strict-align"
 // CHECK-ALIGNED-AARCH64: "-backend-option" "-aarch64-strict-align"
+
+// Make sure that v6M cores always trigger the unsupported aligned accesses error
+// for all supported architecture triples.
+// RUN: not %clang -c -target thumbv6m-none-gnueabi -mcpu=cortex-m0 -munaligned-access %s 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-UNALIGN-NOT-SUPPORTED %s
+// RUN: not %clang -c -target thumb-none-gnueabi -mcpu=cortex-m0 -munaligned-access %s 2>&1 | \
+// RUN:   FileCheck --check-prefix CHECK-UNALIGN-NOT-SUPPORTED %s
+
+// CHECK-UNALIGN-NOT-SUPPORTED: error: the v6m sub-architecture does not support unaligned accesses
diff --git a/test/Driver/arm-cortex-cpus.c b/test/Driver/arm-cortex-cpus.c
index 224ba57..b1f2533 100644
--- a/test/Driver/arm-cortex-cpus.c
+++ b/test/Driver/arm-cortex-cpus.c
@@ -14,7 +14,7 @@
 // CHECK-V5: "-cc1"{{.*}} "-triple" "armv5-{{.*}} "-target-cpu" "arm10tdmi"
 
 // RUN: %clang -target armv5 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V5-THUMB %s
-// RUN: %clang -target armv -march=armv5 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V5-THUMB %s
+// RUN: %clang -target arm -march=armv5 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V5-THUMB %s
 // RUN: %clang -target armv5t -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V5-THUMB %s
 // RUN: %clang -target arm -march=armv5 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V5-THUMB %s
 // CHECK-V5-THUMB: "-cc1"{{.*}} "-triple" "thumbv5-{{.*}} "-target-cpu" "arm10tdmi"
@@ -169,12 +169,14 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a9 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a12 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a15 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a17 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a5 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a7 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a8 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a9 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a12 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a15 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a17 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A %s
 // CHECK-CPUV7A: "-cc1"{{.*}} "-triple" "armv7-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a5 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
@@ -183,12 +185,14 @@
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a9 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a12 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a15 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
+// RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a17 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a5 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a7 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a8 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a9 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a12 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a15 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a17 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A %s
 // CHECK-BE-CPUV7A: "-cc1"{{.*}} "-triple" "armebv7-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a5 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
@@ -197,12 +201,14 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a9 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a12 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a15 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a17 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a5 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a7 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a8 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a9 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a12 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a15 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a17 -mlittle-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7A-THUMB %s
 // CHECK-CPUV7A-THUMB: "-cc1"{{.*}} "-triple" "thumbv7-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a5 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
@@ -211,12 +217,14 @@
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a9 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a12 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a15 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
+// RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-a17 -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a5 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a7 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a8 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a9 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a12 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a15 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-a17 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7A-THUMB %s
 // CHECK-BE-CPUV7A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m0 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV6M %s
@@ -231,11 +239,15 @@
 // CHECK-BE-CPUV7M: "-cc1"{{.*}} "-triple" "thumbebv7m-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m7 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m4 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m7 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7EM %s
 // CHECK-CPUV7EM: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}}
 
 // RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-m4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s
+// RUN: %clang -target armeb-linux-gnueabi -mcpu=cortex-m7 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m4 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-m7 -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7EM %s
 // CHECK-BE-CPUV7EM: "-cc1"{{.*}} "-triple" "thumbebv7em-{{.*}}
 
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV7R %s
diff --git a/test/Driver/arm-fixed-r9.c b/test/Driver/arm-fixed-r9.c
index 0a95d87..2cec8b4 100644
--- a/test/Driver/arm-fixed-r9.c
+++ b/test/Driver/arm-fixed-r9.c
@@ -1,4 +1,4 @@
-// RUN: %clang -target arm-none-gnueeabi -ffixed-r9 -### %s 2> %t
+// RUN: %clang -target arm-none-gnueabi -ffixed-r9 -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-FIXED-R9 < %t %s
 
 // CHECK-FIXED-R9: "-backend-option" "-arm-reserve-r9"
diff --git a/test/Driver/arm-mfpu.c b/test/Driver/arm-mfpu.c
index 89c2035..e762478 100644
--- a/test/Driver/arm-mfpu.c
+++ b/test/Driver/arm-mfpu.c
@@ -63,6 +63,25 @@
 // CHECK-FP4-SP-D16: "-target-feature" "+fp-only-sp"
 // CHECK-FP4-SP-D16: "-target-feature" "-neon"
 
+// RUN: %clang -target arm-linux-eabi -mfpu=fp5-sp-d16 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FP5-SP-D16 %s
+// RUN: %clang -target arm-linux-eabi -mfpu=fpv5-sp-d16 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FP5-SP-D16 %s
+// CHECK-FP5-SP-D16: "-target-feature" "+fp-armv8"
+// CHECK-FP5-SP-D16: "-target-feature" "+fp-only-sp"
+// CHECK-FP5-SP-D16: "-target-feature" "+d16"
+// CHECK-FP5-SP-D16: "-target-feature" "-neon"
+// CHECK-FP5-SP-D16: "-target-feature" "-crypto"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=fp5-dp-d16 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FP5-DP-D16 %s
+// RUN: %clang -target arm-linux-eabi -mfpu=fpv5-dp-d16 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FP5-DP-D16 %s
+// CHECK-FP5-DP-D16: "-target-feature" "+fp-armv8"
+// CHECK-FP5-DP-D16: "-target-feature" "+d16"
+// CHECK-FP5-DP-D16: "-target-feature" "-neon"
+// CHECK-FP5-DP-D16: "-target-feature" "-crypto"
+
 // RUN: %clang -target arm-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NEON %s
 // CHECK-NEON: "-target-feature" "+neon"
diff --git a/test/Driver/biarch.c b/test/Driver/biarch.c
new file mode 100644
index 0000000..1f0982e
--- /dev/null
+++ b/test/Driver/biarch.c
@@ -0,0 +1,41 @@
+// RUN: %clang -target i386--netbsd -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
+
+// RUN: %clang -target i386--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
+
+// RUN: %clang -target x86_64--netbsd -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
+
+// RUN: %clang -target x86_64--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
+
+// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "armv6--netbsd-eabihf"' %t
+
+// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
+
+// RUN: %clang -target sparcv9--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t
+
+// RUN: %clang -target sparc64--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "sparc64--netbsd"' %t
+
+// RUN: %clang -target sparc--netbsd -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
+
+// RUN: %clang -target sparc--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t
+
+// RUN: %clang -target mips64--netbsd -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t
+
+// RUN: %clang -target mips64--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t
+
+// RUN: %clang -target mips--netbsd -m32 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t
+
+// RUN: %clang -target mips--netbsd -m64 %s -### 2> %t
+// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t
diff --git a/test/Driver/cc1-response-files.c b/test/Driver/cc1-response-files.c
new file mode 100644
index 0000000..f47e644
--- /dev/null
+++ b/test/Driver/cc1-response-files.c
@@ -0,0 +1,2 @@
+// RUN: %clang @%S/Inputs/cc1-response.txt -fsyntax-only -disable-llvm-optzns
+int main() {}
diff --git a/test/Driver/cl-inputs.c b/test/Driver/cl-inputs.c
index 029aead..b0265df 100644
--- a/test/Driver/cl-inputs.c
+++ b/test/Driver/cl-inputs.c
@@ -34,6 +34,16 @@
 // WARN: note: The last /TC or /TP option takes precedence over earlier instances
 // WARN-NOT: note
 
+// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s
+// TPlib: warning: cl-test.lib: 'linker' input unused
+// TPlib: warning: argument unused during compilation: '/TP'
+// TPlib-NOT: cl-test.lib
+
+// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TC cl-test.lib -### 2>&1 | FileCheck -check-prefix=TClib %s
+// TClib: warning: cl-test.lib: 'linker' input unused
+// TClib: warning: argument unused during compilation: '/TC'
+// TClib-NOT: cl-test.lib
+
 // RUN: not %clang_cl - 2>&1 | FileCheck -check-prefix=STDIN %s
 // STDIN: error: use /Tc or /Tp
 
diff --git a/test/Driver/cl-link-at-file.c b/test/Driver/cl-link-at-file.c
new file mode 100644
index 0000000..f817ce5
--- /dev/null
+++ b/test/Driver/cl-link-at-file.c
@@ -0,0 +1,22 @@
+// PR17239 - The /link option, when inside a response file, should only extend
+// until the end of the response file (and not the entire command line)
+
+// Don't attempt slash switches on msys bash.
+// REQUIRES: shell-preserves-root
+
+// Note: %s must be preceded by -- or bound to another option, otherwise it may
+// be interpreted as a command-line option, e.g. on Mac where %s is commonly
+// under /Users.
+
+// RUN: echo /link bar.lib baz.lib > %t.args
+// RUN: touch %t.obj
+// RUN: %clang_cl -### @%t.args -- %t.obj 2>&1 | FileCheck %s -check-prefix=ARGS
+// If the "/link" option captures all remaining args beyond its response file,
+// it will also capture "--" and our input argument. In this case, Clang will
+// be clueless and will emit "argument unused" warnings. If PR17239 is properly
+// fixed, this should not happen because the "/link" option is restricted to
+// consume only remaining args in its response file.
+// ARGS-NOT: warning
+// ARGS-NOT: argument unused during compilation
+// Identify the linker command
+// ARGS: link.exe
diff --git a/test/Driver/cl-link.c b/test/Driver/cl-link.c
index f471746..5bd2001 100644
--- a/test/Driver/cl-link.c
+++ b/test/Driver/cl-link.c
@@ -19,6 +19,15 @@
 // ASAN: "{{.*}}clang_rt.asan_cxx-i386.lib"
 // ASAN: "{{.*}}cl-link{{.*}}.obj"
 
+// RUN: %clang_cl /MD /Tc%s -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s
+// ASAN-MD: link.exe
+// ASAN-MD: "-debug"
+// ASAN-MD: "-incremental:no"
+// ASAN-MD: "{{.*}}clang_rt.asan_dynamic-i386.lib"
+// ASAN-MD: "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
+// ASAN-MD: "-include:___asan_seh_interceptor"
+// ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
+
 // RUN: %clang_cl /LD -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
 // RUN: %clang_cl /LDd -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s
 // DLL: link.exe
diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c
index 90b6325..44242c8 100644
--- a/test/Driver/cl-options.c
+++ b/test/Driver/cl-options.c
@@ -87,6 +87,10 @@
 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
 // showIncludes: --show-includes
 
+// RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
+// RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
+// showIncludes_E: warning: argument unused during compilation: '--show-includes'
+
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
@@ -131,6 +135,12 @@
 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
 // w: -w
 
+// RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
+// ZP: -fpack-struct=1
+
+// RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
+// ZP2: -fpack-struct=2
+
 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
 // Zs: -fsyntax-only
 
@@ -162,6 +172,7 @@
 // (/Zs is for syntax-only)
 // RUN: %clang_cl /Zs \
 // RUN:    /analyze- \
+// RUN:    /d2Zi+ \
 // RUN:    /errorReport:foo \
 // RUN:    /FS \
 // RUN:    /GF \
@@ -180,8 +191,11 @@
 // RUN:    /Zc:wchar_t \
 // RUN:    /Zc:inline \
 // RUN:    /Zc:rvalueCast \
+// RUN:    /Zo \
+// RUN:    /Zo- \
 // RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
 // IGNORED-NOT: argument unused during compilation
+// IGNORED-NOT: no such file or directory
 
 // Ignored options and compile-only options are ignored for link jobs.
 // RUN: touch %t.obj
@@ -198,10 +212,8 @@
 // (/Zs is for syntax-only)
 // RUN: %clang_cl /Zs \
 // RUN:     /AIfoo \
-// RUN:     /arch:sse2 \
 // RUN:     /clr:pure \
 // RUN:     /docname \
-// RUN:     /d2Zi+ \
 // RUN:     /EHsc \
 // RUN:     /F \
 // RUN:     /FA \
@@ -275,8 +287,6 @@
 // RUN:     /Zi \
 // RUN:     /ZI \
 // RUN:     /Zl \
-// RUN:     /Zp \
-// RUN:     /Zp1 \
 // RUN:     /ZW:nostdlib \
 // RUN:     -- %s 2>&1
 
@@ -285,10 +295,6 @@
 // Xclang: "-cc1"
 // Xclang: "hellocc1"
 
-// We support -m32 and -m64.
-// RUN: %clang_cl /Zs /WX -m32 -m64 -### -- 2>&1 %s | FileCheck -check-prefix=MFLAGS %s
-// MFLAGS-NOT: argument unused during compilation
-
 // RTTI is on by default. /GR- controls -fno-rtti-data.
 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
 // NoRTTI: "-fno-rtti-data"
@@ -297,5 +303,17 @@
 // RTTI-NOT: "-fno-rtti-data"
 // RTTI-NOT: "-fno-rtti"
 
+// Accept "core" clang options.
+// (/Zs is for syntax-only)
+// RUN: %clang_cl \
+// RUN:     --driver-mode=cl \
+// RUN:     -ferror-limit=10 \
+// RUN:     -fmsc-version=1800 \
+// RUN:     -fno-strict-aliasing \
+// RUN:     -fstrict-aliasing \
+// RUN:     -mllvm -disable-llvm-optzns \
+// RUN:     -Wunused-variables \
+// RUN:     /Zs -- %s 2>&1
+
 
 void f() { }
diff --git a/test/Driver/cl-outputs.c b/test/Driver/cl-outputs.c
index 46502f6..be1172f 100644
--- a/test/Driver/cl-outputs.c
+++ b/test/Driver/cl-outputs.c
@@ -7,6 +7,9 @@
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
 // DEFAULT: "-o" "cl-outputs.obj"
 
+// RUN: %clang_cl /Fo -### -- %s 2>&1 | FileCheck -check-prefix=FoEMPTY %s
+// FoEMPTY:  "-o" "cl-outputs.obj"
+
 // RUN: %clang_cl /Foa -### -- %s 2>&1 | FileCheck -check-prefix=FoNAME %s
 // FoNAME:  "-o" "a.obj"
 
@@ -25,15 +28,68 @@
 // RUN: %clang_cl /Fo.. -### -- %s 2>&1 | FileCheck -check-prefix=FoCRAZY %s
 // FoCRAZY:  "-o" "..obj"
 
-// RUN: %clang_cl /Fo -### 2>&1 | FileCheck -check-prefix=FoMISSINGARG %s
-// FoMISSINGARG: error: argument to '/Fo' is missing (expected 1 value)
-
 // RUN: %clang_cl /Foa.obj -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEERROR %s
 // CHECK-MULTIPLESOURCEERROR: error: cannot specify '/Foa.obj' when compiling multiple source files
 
 // RUN: %clang_cl /Fomydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK %s
 // CHECK-MULTIPLESOURCEOK: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
 
+// RUN: %clang_cl /Fo -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK2 %s
+// CHECK-MULTIPLESOURCEOK2: "-o" "cl-outputs.obj"
+// CHECK-MULTIPLESOURCEOK2: "-o" "cl-outputs.obj"
+
+// RUN: %clang_cl /c /oa -### -- %s 2>&1 | FileCheck -check-prefix=oNAME1 %s
+// oNAME1:  "-o" "a.obj"
+
+// RUN: %clang_cl /c /o a -### -- %s 2>&1 | FileCheck -check-prefix=oNAME2 %s
+// oNAME2:  "-o" "a.obj"
+
+// RUN: %clang_cl /c /oa.ext /ob.ext -### -- %s 2>&1 | FileCheck -check-prefix=oNAMEEXT1 %s
+// oNAMEEXT1:  "-o" "b.ext"
+
+// RUN: %clang_cl /c /o a.ext /ob.ext -### -- %s 2>&1 | FileCheck -check-prefix=oNAMEEXT2 %s
+// oNAMEEXT2:  "-o" "b.ext"
+
+// RUN: %clang_cl /c /ofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=oDIR1 %s
+// oDIR1:  "-o" "foo.dir{{[/\\]+}}cl-outputs.obj"
+
+// RUN: %clang_cl /c /o foo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=oDIR2 %s
+// oDIR2:  "-o" "foo.dir{{[/\\]+}}cl-outputs.obj"
+
+// RUN: %clang_cl /c /ofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAME1 %s
+// oDIRNAME1:  "-o" "foo.dir{{[/\\]+}}a.obj"
+
+// RUN: %clang_cl /c /o foo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAME2 %s
+// oDIRNAME2:  "-o" "foo.dir{{[/\\]+}}a.obj"
+
+// RUN: %clang_cl /c /ofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAMEEXT1 %s
+// oDIRNAMEEXT1:  "-o" "foo.dir{{[/\\]+}}a.ext"
+
+// RUN: %clang_cl /c /o foo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=oDIRNAMEEXT2 %s
+// oDIRNAMEEXT2:  "-o" "foo.dir{{[/\\]+}}a.ext"
+
+// RUN: %clang_cl /c /o.. -### -- %s 2>&1 | FileCheck -check-prefix=oCRAZY1 %s
+// oCRAZY1:  "-o" "..obj"
+
+// RUN: %clang_cl /c /o .. -### -- %s 2>&1 | FileCheck -check-prefix=oCRAZY2 %s
+// oCRAZY2:  "-o" "..obj"
+
+// RUN: %clang_cl /c %s -### /o 2>&1 | FileCheck -check-prefix=oMISSINGARG %s
+// oMISSINGARG: error: argument to '/o' is missing (expected 1 value)
+
+// RUN: %clang_cl /c /omydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-oMULTIPLESOURCEOK1 %s
+// CHECK-oMULTIPLESOURCEOK1: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
+
+// RUN: %clang_cl /c /o mydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-oMULTIPLESOURCEOK2 %s
+// CHECK-oMULTIPLESOURCEOK2: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
+
+
+// RUN: %clang_cl /c /obar /Fofoo -### -- %s 2>&1 | FileCheck -check-prefix=FooRACE1 %s
+// FooRACE1: "-o" "foo.obj"
+
+// RUN: %clang_cl /c /Fofoo /obar -### -- %s 2>&1 | FileCheck -check-prefix=FooRACE2 %s
+// FooRACE2: "-o" "bar.obj"
+
 
 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTEXE %s
 // DEFAULTEXE: cl-outputs.exe
@@ -46,6 +102,10 @@
 // RUN: %clang_cl /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXT %s
 // FeNOEXT: "-out:foo.exe"
 
+// RUN: %clang_cl /Fe -### -- %s 2>&1 | FileCheck -check-prefix=FeEMPTY %s
+// FeEMPTY-NOT: argument to '/Fe' is missing
+// FeEMPTY: "-out:cl-outputs.exe"
+
 // RUN: %clang_cl /Fefoo /LD -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
 // RUN: %clang_cl /Fefoo /LDd -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
 // FeNOEXTDLL: "-out:foo.dll"
@@ -83,15 +143,83 @@
 // FeDIRNAMEEXTDLL: "-out:foo.dir{{[/\\]+}}a.ext"
 // FeDIRNAMEEXTDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
 
-// RUN: %clang_cl /Fe -### 2>&1 | FileCheck -check-prefix=FeMISSINGARG %s
-// FeMISSINGARG: error: argument to '/Fe' is missing (expected 1 value)
-
 // RUN: %clang_cl /Fefoo /Febar -### -- %s 2>&1 | FileCheck -check-prefix=FeOVERRIDE %s
 // FeOVERRIDE: "-out:bar.exe"
 
 
+// RUN: %clang_cl /obar /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeoRACE1 %s
+// FeoRACE1: "-out:foo.exe"
+
+// RUN: %clang_cl /Fefoo /obar -### -- %s 2>&1 | FileCheck -check-prefix=FeoRACE2 %s
+// FeoRACE2: "-out:bar.exe"
+
+
+// RUN: %clang_cl /ofoo -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXT1 %s
+// FeoNOEXT1: "-out:foo.exe"
+
+// RUN: %clang_cl /o foo -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXT2 %s
+// FeoNOEXT2: "-out:foo.exe"
+
+// RUN: %clang_cl /o foo /LD -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXTDLL %s
+// RUN: %clang_cl /ofoo /LDd -### -- %s 2>&1 | FileCheck -check-prefix=FeoNOEXTDLL %s
+// FeoNOEXTDLL: "-out:foo.dll"
+// FeoNOEXTDLL: "-implib:foo.lib"
+
+// RUN: %clang_cl /ofoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXT1 %s
+// FeoEXT1: "-out:foo.ext"
+
+// RUN: %clang_cl /o foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXT2 %s
+// FeoEXT2: "-out:foo.ext"
+
+// RUN: %clang_cl /LD /o foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXTDLL %s
+// RUN: %clang_cl /LDd /ofoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoEXTDLL %s
+// FeoEXTDLL: "-out:foo.ext"
+// FeoEXTDLL: "-implib:foo.lib"
+
+// RUN: %clang_cl /ofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIR1 %s
+// FeoDIR1: "-out:foo.dir{{[/\\]+}}cl-outputs.exe"
+
+// RUN: %clang_cl /o foo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIR2 %s
+// FeoDIR2: "-out:foo.dir{{[/\\]+}}cl-outputs.exe"
+
+// RUN: %clang_cl /LD /o foo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRDLL %s
+// RUN: %clang_cl /LDd /ofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRDLL %s
+// FeoDIRDLL: "-out:foo.dir{{[/\\]+}}cl-outputs.dll"
+// FeoDIRDLL: "-implib:foo.dir{{[/\\]+}}cl-outputs.lib"
+
+// RUN: %clang_cl /ofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAME1 %s
+// FeoDIRNAME1: "-out:foo.dir{{[/\\]+}}a.exe"
+
+// RUN: %clang_cl /o foo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAME2 %s
+// FeoDIRNAME2: "-out:foo.dir{{[/\\]+}}a.exe"
+
+// RUN: %clang_cl /LD /o foo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEDLL %s
+// RUN: %clang_cl /LDd /ofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEDLL %s
+// FeoDIRNAMEDLL: "-out:foo.dir{{[/\\]+}}a.dll"
+// FeoDIRNAMEDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
+
+// RUN: %clang_cl /ofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXT1 %s
+// FeoDIRNAMEEXT1: "-out:foo.dir{{[/\\]+}}a.ext"
+
+// RUN: %clang_cl /o foo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXT2 %s
+// FeoDIRNAMEEXT2: "-out:foo.dir{{[/\\]+}}a.ext"
+
+// RUN: %clang_cl /LD /o foo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXTDLL %s
+// RUN: %clang_cl /LDd /ofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeoDIRNAMEEXTDLL %s
+// FeoDIRNAMEEXTDLL: "-out:foo.dir{{[/\\]+}}a.ext"
+// FeoDIRNAMEEXTDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
+
+// RUN: %clang_cl -### /o 2>&1 | FileCheck -check-prefix=FeoMISSINGARG %s
+// FeoMISSINGARG: error: argument to '/o' is missing (expected 1 value)
+
+// RUN: %clang_cl /ofoo /o bar -### -- %s 2>&1 | FileCheck -check-prefix=FeoOVERRIDE %s
+// FeoOVERRIDE: "-out:bar.exe"
+
+
 // RUN: %clang_cl /FA -### -- %s 2>&1 | FileCheck -check-prefix=FA %s
 // FA: "-o" "cl-outputs.asm"
+// RUN: %clang_cl /FA /Fa -### -- %s 2>&1 | FileCheck -check-prefix=FaEMPTY %s
+// FaEMPTY: "-o" "cl-outputs.asm"
 // RUN: %clang_cl /FA /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
 // RUN: %clang_cl /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
 // FaNAME:  "-o" "foo.asm"
@@ -105,6 +233,9 @@
 // FaDIRNAMEEXT:  "-o" "foo.dir{{[/\\]+}}a.ext"
 // RUN: %clang_cl /Faa.asm -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCE %s
 // FaMULTIPLESOURCE: error: cannot specify '/Faa.asm' when compiling multiple source files
+// RUN: %clang_cl /Fa -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCEOK %s
+// FaMULTIPLESOURCEOK: "-o" "cl-outputs.asm"
+// FaMULTIPLESOURCEOK: "-o" "cl-outputs.asm"
 
 // RUN: %clang_cl /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
 // P: "-E"
@@ -117,3 +248,28 @@
 // RUN: %clang_cl /P /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fi2 %s
 // Fi2: "-E"
 // Fi2: "-o" "foo.x"
+
+// RUN: %clang_cl /P /ofoo -### -- %s 2>&1 | FileCheck -check-prefix=Fio1 %s
+// Fio1: "-E"
+// Fio1: "-o" "foo.i"
+
+// RUN: %clang_cl /P /o foo -### -- %s 2>&1 | FileCheck -check-prefix=Fio2 %s
+// Fio2: "-E"
+// Fio2: "-o" "foo.i"
+
+// RUN: %clang_cl /P /ofoo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio3 %s
+// Fio3: "-E"
+// Fio3: "-o" "foo.x"
+
+// RUN: %clang_cl /P /o foo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio4 %s
+// Fio4: "-E"
+// Fio4: "-o" "foo.x"
+
+
+// RUN: %clang_cl /P /obar.x /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE1 %s
+// FioRACE1: "-E"
+// FioRACE1: "-o" "foo.x"
+
+// RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE2 %s
+// FioRACE2: "-E"
+// FioRACE2: "-o" "bar.x"
diff --git a/test/Driver/cl-x86-flags.c b/test/Driver/cl-x86-flags.c
new file mode 100644
index 0000000..5aae4c4
--- /dev/null
+++ b/test/Driver/cl-x86-flags.c
@@ -0,0 +1,83 @@
+// Don't attempt slash switches on msys bash.
+// REQUIRES: shell-preserves-root
+// REQUIRES: x86-registered-target
+
+// We support -m32 and -m64.  We support all x86 CPU feature flags in gcc's -m
+// flag space.
+// RUN: %clang_cl /Zs /WX -m32 -m64 -msse3 -msse4.1 -mavx -mno-avx \
+// RUN:     --target=i386-pc-win32 -### -- 2>&1 %s | FileCheck -check-prefix=MFLAGS %s
+// MFLAGS-NOT: argument unused during compilation
+
+// -arch:IA32 is no-op.
+// RUN: %clang_cl -m32 -arch:IA32 --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=IA32 %s
+// IA32-NOT: argument unused during compilation
+// IA32-NOT: -target-feature
+
+// RUN: %clang_cl -m32 -arch:ia32 --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=ia32 %s
+// ia32: argument unused during compilation
+// ia32-NOT: -target-feature
+
+// RUN: %clang_cl -m64 -arch:IA32 --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=IA3264 %s
+// IA3264: argument unused during compilation
+// IA3264-NOT: -target-feature
+
+// RUN: %clang_cl -m32 -arch:SSE --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=SSE %s
+// SSE: -target-feature
+// SSE: +sse
+// SSE-NOT: argument unused during compilation
+
+// RUN: %clang_cl -m32 -arch:sse --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=sse %s
+// sse: argument unused during compilation
+// sse-NOT: -target-feature
+
+// RUN: %clang_cl -m32 -arch:SSE2 --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=SSE2 %s
+// SSE2: -target-feature
+// SSE2: +sse2
+// SSE2-NOT: argument unused during compilation
+
+// RUN: %clang_cl -m32 -arch:sse2 --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=sse %s
+// sse2: argument unused during compilation
+// sse2-NOT: -target-feature
+
+// RUN: %clang_cl -m64 -arch:SSE --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=SSE64 %s
+// SSE64: argument unused during compilation
+// SSE64-NOT: -target-feature
+
+// RUN: %clang_cl -m64 -arch:SSE2 --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=SSE264 %s
+// SSE264: argument unused during compilation
+// SSE264-NOT: -target-feature
+
+// RUN: %clang_cl -m32 -arch:AVX --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=AVX %s
+// AVX: -target-feature
+// AVX: +avx
+
+// RUN: %clang_cl -m32 -arch:avx --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=avx %s
+// avx: argument unused during compilation
+// avx-NOT: -target-feature
+
+// RUN: %clang_cl -m32 -arch:AVX2 --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=AVX2 %s
+// AVX2: -target-feature
+// AVX2: +avx2
+
+// RUN: %clang_cl -m32 -arch:avx2 --target=i386 -### -- 2>&1 %s | FileCheck -check-prefix=avx2 %s
+// avx2: argument unused during compilation
+// avx2-NOT: -target-feature
+
+// RUN: %clang_cl -m64 -arch:AVX --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=AVX64 %s
+// AVX64: -target-feature
+// AVX64: +avx
+
+// RUN: %clang_cl -m64 -arch:avx --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=avx64 %s
+// avx64: argument unused during compilation
+// avx64-NOT: -target-feature
+
+// RUN: %clang_cl -m64 -arch:AVX2 --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=AVX264 %s
+// AVX264: -target-feature
+// AVX264: +avx2
+
+// RUN: %clang_cl -m64 -arch:avx2 --target=x86_64 -### -- 2>&1 %s | FileCheck -check-prefix=avx264 %s
+// avx264: argument unused during compilation
+// avx264-NOT: -target-feature
+
+void f() {
+}
diff --git a/test/Driver/clang-g-opts.c b/test/Driver/clang-g-opts.c
index a9566b7..4a1e719 100644
--- a/test/Driver/clang-g-opts.c
+++ b/test/Driver/clang-g-opts.c
@@ -17,6 +17,8 @@
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g0 -g -target x86_64-pc-freebsd10.0 2>&1 \
 // RUN:             | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
+// RUN: %clang -### -S %s -g0 -g -target i386-pc-solaris 2>&1 \
+// RUN:             | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 
 // CHECK-WITHOUT-G-NOT: "-g"
 // CHECK-WITH-G: "-g"
diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c
index c5ebe6c..3ca9f28 100644
--- a/test/Driver/clang_f_opts.c
+++ b/test/Driver/clang_f_opts.c
@@ -59,6 +59,13 @@
 // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
 // CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
+// RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s
+// RUN: %clang -### -S -fno-profile-arcs -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s
+// RUN: %clang -### -S -fno-profile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-ARCS %s
+// RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-ARCS %s
+// CHECK-PROFILE-ARCS: "-femit-coverage-data"
+// CHECK-NO-PROFILE-ARCS-NOT: "-femit-coverage-data"
+
 // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
@@ -127,11 +134,14 @@
 // CHECK-MAX-O: -O3
 
 // RUN: %clang -S -O20 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-O %s
-// CHECK-INVALID-O: warning: optimization level '-O20' is unsupported; using '-O3' instead
+// CHECK-INVALID-O: warning: optimization level '-O20' is not supported; using '-O3' instead
 
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
+// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror                                                \
 // RUN:     -falign-functions -falign-functions=2 -fno-align-functions        \
@@ -144,6 +154,7 @@
 // RUN:     -fident -fno-ident                                                \
 // RUN:     -fimplicit-templates -fno-implicit-templates                      \
 // RUN:     -finput-charset=UTF-8                                             \
+// RUN:     -fexec-charset=UTF-8                                             \
 // RUN:     -fivopts -fno-ivopts                                              \
 // RUN:     -fnon-call-exceptions -fno-non-call-exceptions                    \
 // RUN:     -fpermissive -fno-permissive                                      \
@@ -164,9 +175,215 @@
 // RUN:     -fno-unsigned-char                                                \
 // RUN:     -fno-signed-char                                                  \
 // RUN:     -fstrength-reduce -fno-strength-reduce                            \
+// RUN:     -finline-limit=1000                                               \
+// RUN:     -finline-limit                                                    \
+// RUN:     -flto=1                                                           \
+// RUN:     -falign-labels                                                    \
+// RUN:     -falign-labels=100                                                \
+// RUN:     -falign-loops                                                     \
+// RUN:     -falign-loops=100                                                 \
+// RUN:     -falign-jumps                                                     \
+// RUN:     -falign-jumps=100                                                 \
+// RUN:     -fexcess-precision=100                                            \
+// RUN:     -fbranch-count-reg                                                \
+// RUN:     -fcaller-saves                                                    \
+// RUN:     -fno-default-inline -fdefault-inline                              \
+// RUN:     -fgcse-after-reload                                               \
+// RUN:     -fgcse-las                                                        \
+// RUN:     -fgcse-sm                                                         \
+// RUN:     -fipa-cp                                                          \
+// RUN:     -finline-functions-called-once                                    \
+// RUN:     -fmodulo-sched                                                    \
+// RUN:     -fmodulo-sched-allow-regmoves                                     \
+// RUN:     -fpeel-loops                                                      \
+// RUN:     -frename-registers                                                \
+// RUN:     -fschedule-insns2                                                 \
+// RUN:     -fsingle-precision-constant                                       \
+// RUN:     -ftree_loop_im                                                    \
+// RUN:     -ftree_loop_ivcanon                                               \
+// RUN:     -ftree_loop_linear                                                \
+// RUN:     -funsafe-loop-optimizations                                       \
+// RUN:     -fuse-linker-plugin                                               \
+// RUN:     -fvect-cost-model                                                 \
+// RUN:     -fvariable-expansion-in-unroller                                  \
+// RUN:     -fweb                                                             \
+// RUN:     -fwhole-program                                                   \
+// RUN:     -fno-tree-dce -ftree-dce                                          \
+// RUN:     -fno-tree-ter -ftree-ter                                          \
+// RUN:     -fno-tree-vrp -ftree-vrp                                          \
+// RUN:     -fno-delete-null-pointer-checks -fdelete-null-pointer-checks      \
+// RUN:     -fno-inline-small-functions -finline-small-functions              \
+// RUN:     -fno-fat-lto-objects -ffat-lto-objects                            \
+// RUN:     -fno-merge-constants -fmerge-constants                            \
+// RUN:     -fno-caller-saves -fcaller-saves                                  \
+// RUN:     -fno-reorder-blocks -freorder-blocks                              \
+// RUN:     -fno-schedule-insns2 -fschedule-insns2                            \
+// RUN:     -fno-stack-check                                                  \
+// RUN:     -fno-check-new -fcheck-new                                        \
+// RUN:     -ffriend-injection                                                \
+// RUN:     -fno-implement-inlines -fimplement-inlines                        \
+// RUN:     -fstack-check                                                     \
+// RUN:     -fforce-addr                                                      \
+// RUN:     -malign-functions=100                                             \
+// RUN:     -malign-loops=100                                                 \
+// RUN:     -malign-jumps=100                                                 \
 // RUN:     %s 2>&1 | FileCheck --check-prefix=IGNORE %s
 // IGNORE-NOT: error: unknown argument
 
+// Test that the warning is displayed on these.
+// RUN: %clang -###                                                           \
+// RUN: -finline-limit=1000                                                   \
+// RUN: -finline-limit                                                        \
+// RUN: -fexpensive-optimizations                                             \
+// RUN: -fno-expensive-optimizations                                          \
+// RUN: -fno-defer-pop                                                        \
+// RUN: -finline-functions                                                    \
+// RUN: -fkeep-inline-functions                                               \
+// RUN: -fno-keep-inline-functions                                            \
+// RUN: -freorder-blocks                                                      \
+// RUN: -fprofile-dir=/rand/dir                                               \
+// RUN: -fprofile-use                                                         \
+// RUN: -fprofile-use=/rand/dir                                               \
+// RUN: -falign-functions                                                     \
+// RUN: -falign-functions=1                                                   \
+// RUN: -ffloat-store                                                         \
+// RUN: -fgcse                                                                \
+// RUN: -fivopts                                                              \
+// RUN: -fprefetch-loop-arrays                                                \
+// RUN: -fprofile-correction                                                  \
+// RUN: -fprofile-values                                                      \
+// RUN: -frounding-math                                                       \
+// RUN: -fschedule-insns                                                      \
+// RUN: -fsignaling-nans                                                      \
+// RUN: -fstrength-reduce                                                     \
+// RUN: -ftracer                                                              \
+// RUN: -funroll-all-loops                                                    \
+// RUN: -funswitch-loops                                                      \
+// RUN: -flto=1                                                               \
+// RUN: -falign-labels                                                        \
+// RUN: -falign-labels=100                                                    \
+// RUN: -falign-loops                                                         \
+// RUN: -falign-loops=100                                                     \
+// RUN: -falign-jumps                                                         \
+// RUN: -falign-jumps=100                                                     \
+// RUN: -fexcess-precision=100                                                \
+// RUN: -fbranch-count-reg                                                    \
+// RUN: -fcaller-saves                                                        \
+// RUN: -fno-default-inline                                                   \
+// RUN: -fgcse-after-reload                                                   \
+// RUN: -fgcse-las                                                            \
+// RUN: -fgcse-sm                                                             \
+// RUN: -fipa-cp                                                              \
+// RUN: -finline-functions-called-once                                        \
+// RUN: -fmodulo-sched                                                        \
+// RUN: -fmodulo-sched-allow-regmoves                                         \
+// RUN: -fpeel-loops                                                          \
+// RUN: -frename-registers                                                    \
+// RUN: -fschedule-insns2                                                     \
+// RUN: -fsingle-precision-constant                                           \
+// RUN: -ftree_loop_im                                                        \
+// RUN: -ftree_loop_ivcanon                                                   \
+// RUN: -ftree_loop_linear                                                    \
+// RUN: -funsafe-loop-optimizations                                           \
+// RUN: -fuse-linker-plugin                                                   \
+// RUN: -fvect-cost-model                                                     \
+// RUN: -fvariable-expansion-in-unroller                                      \
+// RUN: -fweb                                                                 \
+// RUN: -fwhole-program                                                       \
+// RUN: -fcaller-saves                                                        \
+// RUN: -freorder-blocks                                                      \
+// RUN: -fdelete-null-pointer-checks                                          \
+// RUN: -ffat-lto-objects                                                     \
+// RUN: -fmerge-constants                                                     \
+// RUN: -finline-small-functions                                              \
+// RUN: -ftree-dce                                                            \
+// RUN: -ftree-ter                                                            \
+// RUN: -ftree-vrp                                                            \
+// RUN: -fno-devirtualize                                                     \
+// RUN: -fno-devirtualize-speculatively                                       \
+// RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING %s
+// CHECK-WARNING-DAG: optimization flag '-finline-limit=1000' is not supported
+// CHECK-WARNING-DAG: optimization flag '-finline-limit' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
+// CHECK-WARNING-DAG: optimization flag '-finline-functions' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
+// CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fprofile-dir=/rand/dir' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fprofile-use' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fprofile-use=/rand/dir' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-functions' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-functions=1' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ffloat-store' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fgcse' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fivopts' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fprefetch-loop-arrays' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fprofile-correction' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fprofile-values' is not supported
+// CHECK-WARNING-DAG: optimization flag '-frounding-math' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fschedule-insns' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fsignaling-nans' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fstrength-reduce' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftracer' is not supported
+// CHECK-WARNING-DAG: optimization flag '-funroll-all-loops' is not supported
+// CHECK-WARNING-DAG: optimization flag '-funswitch-loops' is not supported
+// CHECK-WARNING-DAG: optimization flag '-flto=1' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-labels' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-labels=100' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-loops=100' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-jumps' is not supported
+// CHECK-WARNING-DAG: optimization flag '-falign-jumps=100' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fexcess-precision=100' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fbranch-count-reg' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fno-default-inline' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fgcse-after-reload' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fgcse-las' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fgcse-sm' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fipa-cp' is not supported
+// CHECK-WARNING-DAG: optimization flag '-finline-functions-called-once' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fmodulo-sched' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fmodulo-sched-allow-regmoves' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fpeel-loops' is not supported
+// CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
+// CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fvariable-expansion-in-unroller' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fweb' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
+// CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fdelete-null-pointer-checks' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported
+// CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree-dce' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree-ter' is not supported
+// CHECK-WARNING-DAG: optimization flag '-ftree-vrp' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fno-devirtualize' is not supported
+// CHECK-WARNING-DAG: optimization flag '-fno-devirtualize-speculatively' is not supported
+
+// Test that we mute the warning on these
+// RUN: %clang -### -finline-limit=1000 -Wno-invalid-command-line-argument              \
+// RUN:     %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING1 %s
+// RUN: %clang -### -finline-limit -Wno-invalid-command-line-argument                   \
+// RUN:     %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING2 %s
+// RUN: %clang -### -finline-limit \
+// RUN:     -Winvalid-command-line-argument -Wno-ignored-optimization-argument          \
+// RUN:     %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING2 %s
+// CHECK-NO-WARNING1-NOT: optimization flag '-finline-limit=1000' is not supported
+// CHECK-NO-WARNING2-NOT: optimization flag '-finline-limit' is not supported
+
+
 // RUN: %clang -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 %s
 // RUN: %clang -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 %s
 // CHECK-WCHAR1: -fno-short-wchar
diff --git a/test/Driver/coverage_no_integrated_as.c b/test/Driver/coverage_no_integrated_as.c
new file mode 100644
index 0000000..6f85b42
--- /dev/null
+++ b/test/Driver/coverage_no_integrated_as.c
@@ -0,0 +1,23 @@
+// REQUIRES: clang-driver
+// XFAIL: win32,win64
+
+// RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
+// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
+// RUN: %clang -### -c -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
+// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-DEFAULT-LOCATION %s
+
+// RUN: %clang -### -S -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
+// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
+// RUN: %clang -### -c -fprofile-arcs %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
+// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s -o /foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s
+
+// RUN: %clang -### -S -fprofile-arcs %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
+// RUN: %clang -### -S -fprofile-arcs -no-integrated-as %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
+// RUN: %clang -### -c -fprofile-arcs %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
+// RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
+
+
+// CHECK-GCNO-DEFAULT-LOCATION: "-coverage-file" "{{.*}}/coverage_no_integrated_as.c"
+// CHECK-GCNO-DEFAULT-LOCATION-NOT: "-coverage-file" "/tmp/{{.*}}/coverage_no_integrated_as.c"
+// CHECK-GCNO-LOCATION: "-coverage-file" "/foo/bar.o"
+// CHECK-GCNO-LOCATION-REL-PATH: "-coverage-file" "{{.*}}/foo/bar.o"
diff --git a/test/Driver/crash report spaces.c b/test/Driver/crash report spaces.c
new file mode 100644
index 0000000..9bc4626
--- /dev/null
+++ b/test/Driver/crash report spaces.c
@@ -0,0 +1,18 @@
+// RUN: rm -rf "%t"
+// RUN: mkdir "%t"
+// RUN: not env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 %clang -fsyntax-only "%s" 2>&1 | FileCheck "%s"
+// RUN: cat "%t/crash report spaces"-*.c | FileCheck --check-prefix=CHECKSRC "%s"
+// RUN: cat "%t/crash report spaces"-*.sh | FileCheck --check-prefix=CHECKSH "%s"
+// REQUIRES: crash-recovery
+
+// because of the glob (*.c, *.sh)
+// REQUIRES: shell
+
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.c
+FOO
+// CHECKSRC: FOO
+// CHECKSH: "-cc1"
+// CHECKSH: "-main-file-name" "crash report spaces.c"
+// CHECKSH: "crash report spaces-{{[^ ]*}}.c"
diff --git a/test/Driver/crash-report-modules.m b/test/Driver/crash-report-modules.m
index d1c7832..84b1604 100644
--- a/test/Driver/crash-report-modules.m
+++ b/test/Driver/crash-report-modules.m
@@ -25,8 +25,8 @@
 // CHECKSRC: @import simple;
 // CHECKSRC: const int x = 10;
 
-// CHECKSH: -cc1
-// CHECKSH: -D "FOO=BAR"
-// CHECKSH-NOT: -fmodules-cache-path=/tmp/
-// CHECKSH: crash-report-modules-{{[^ ]*}}.m
-// CHECKSH: -ivfsoverlay crash-report-modules-{{[^ ]*}}.cache/vfs/vfs.yaml
+// CHECKSH: "-cc1"
+// CHECKSH: "-D" "FOO=BAR"
+// CHECKSH-NOT: "-fmodules-cache-path=/tmp/"
+// CHECKSH: "crash-report-modules-{{[^ ]*}}.m"
+// CHECKSH: "-ivfsoverlay" "crash-report-modules-{{[^ ]*}}.cache/vfs/vfs.yaml"
diff --git a/test/Driver/crash-report-null.test b/test/Driver/crash-report-null.test
new file mode 100644
index 0000000..477dd28
--- /dev/null
+++ b/test/Driver/crash-report-null.test
@@ -0,0 +1,7 @@
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH=1 %clang -fsyntax-only -x c /dev/null -lstdc++ 2>&1 | FileCheck %s
+
+// FIXME: Investigating. "fatal error: file 'nul' modified since it was first processed"
+// XFAIL: mingw32
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c
diff --git a/test/Driver/crash-report.c b/test/Driver/crash-report.c
index da1ff95..3370da8 100644
--- a/test/Driver/crash-report.c
+++ b/test/Driver/crash-report.c
@@ -13,27 +13,23 @@
 // because of the glob (*.c, *.sh)
 // REQUIRES: shell
 
-// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH=1 %clang -fsyntax-only -x c /dev/null -lstdc++ 2>&1 | FileCheck %s
-
-// FIXME: Investigating. "fatal error: file 'nul' modified since it was first processed"
-// XFAIL: mingw32
-
 #pragma clang __debug parser_crash
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.c
 FOO
 // CHECKSRC: FOO
-// CHECKSH: -cc1
-// CHECKSH: -D "FOO=BAR"
-// CHECKSH-NOT: -F/tmp/
-// CHECKSH-NOT: -I /tmp/
-// CHECKSH-NOT: -idirafter /tmp/
-// CHECKSH-NOT: -iquote /tmp/
-// CHECKSH-NOT: -isystem /tmp/
-// CHECKSH-NOT: -iprefix /the/prefix
-// CHECKSH-NOT: -iwithprefix /tmp/
-// CHECKSH-NOT: -iwithprefixbefore /tmp/
-// CHECKSH-NOT: -internal-isystem /tmp/
-// CHECKSH-NOT: -internal-externc-isystem /tmp/
-// CHECKSH-NOT: -dwarf-debug-flags
-// CHECKSH: crash-report-{{[^ ]*}}.c
+// CHECKSH: "-cc1"
+// CHECKSH: "-main-file-name" "crash-report.c"
+// CHECKSH: "-D" "FOO=BAR"
+// CHECKSH-NOT: "-F/tmp/"
+// CHECKSH-NOT: "-I" "/tmp/"
+// CHECKSH-NOT: "-idirafter" "/tmp/"
+// CHECKSH-NOT: "-iquote" "/tmp/"
+// CHECKSH-NOT: "-isystem" "/tmp/"
+// CHECKSH-NOT: "-iprefix" "/the/prefix"
+// CHECKSH-NOT: "-iwithprefix" "/tmp/"
+// CHECKSH-NOT: "-iwithprefixbefore" "/tmp/"
+// CHECKSH-NOT: "-internal-isystem" "/tmp/"
+// CHECKSH-NOT: "-internal-externc-isystem" "/tmp/"
+// CHECKSH-NOT: "-dwarf-debug-flags"
+// CHECKSH: "crash-report-{{[^ ]*}}.c"
diff --git a/test/Driver/cross-linux.c b/test/Driver/cross-linux.c
index ade8d8f..3b13504 100644
--- a/test/Driver/cross-linux.c
+++ b/test/Driver/cross-linux.c
@@ -3,24 +3,24 @@
 // RUN:   --target=i386-unknown-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-I386 %s
 // CHECK-I386: "-cc1" "-triple" "i386-unknown-linux-gnu"
-// CHECK-I386: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/4.6.0/../../../../i386-unknown-linux-gnu/bin{{/|\\}}as" "--32"
-// CHECK-I386: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/4.6.0/../../../../i386-unknown-linux-gnu/bin{{/|\\}}ld" {{.*}} "-m" "elf_i386"
+// CHECK-I386: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/4.6.0/../../../../i386-unknown-linux-gnu/bin{{/|\\\\}}as" "--32"
+// CHECK-I386: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/4.6.0/../../../../i386-unknown-linux-gnu/bin{{/|\\\\}}ld" {{.*}} "-m" "elf_i386"
 //
 // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
 // RUN:   --target=x86_64-unknown-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-X86-64 %s
 // CHECK-X86-64: "-cc1" "-triple" "x86_64-unknown-linux-gnu"
-// CHECK-X86-64: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\}}as" "--64"
-// CHECK-X86-64: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\}}ld" {{.*}} "-m" "elf_x86_64"
+// CHECK-X86-64: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\\\}}as" "--64"
+// CHECK-X86-64: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\\\}}ld" {{.*}} "-m" "elf_x86_64"
 //
 // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
 // RUN:   --target=x86_64-unknown-linux-gnux32 \
 // RUN:   | FileCheck --check-prefix=CHECK-X32 %s
 // CHECK-X32: "-cc1" "-triple" "x86_64-unknown-linux-gnux32"
-// CHECK-X32: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\}}as" "--x32"
-// CHECK-X32: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\}}ld" {{.*}} "-m" "elf32_x86_64"
+// CHECK-X32: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\\\}}as" "--x32"
+// CHECK-X32: "{{.*}}/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\\\}}ld" {{.*}} "-m" "elf32_x86_64"
 //
 // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
@@ -38,8 +38,8 @@
 // RUN:   --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-MULTI32-I386 %s
 // CHECK-MULTI32-I386: "-cc1" "-triple" "i386-unknown-linux"
-// CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\}}as" "--32"
-// CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\}}ld"
+// CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}as" "--32"
+// CHECK-MULTI32-I386: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
 // CHECK-MULTI32-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
 // CHECK-MULTI32-I386: "-m" "elf_i386"
 // CHECK-MULTI32-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]{{/|\\\\}}crtbegin.o"
@@ -55,8 +55,8 @@
 // RUN:   --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-MULTI32-X86-64 %s
 // CHECK-MULTI32-X86-64: "-cc1" "-triple" "x86_64-unknown-linux"
-// CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\}}as" "--64"
-// CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\}}ld"
+// CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}as" "--64"
+// CHECK-MULTI32-X86-64: "{{.*}}/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/bin{{/|\\\\}}ld"
 // CHECK-MULTI32-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
 // CHECK-MULTI32-X86-64: "-m" "elf_x86_64"
 // CHECK-MULTI32-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0]]/64{{/|\\\\}}crtbegin.o"
@@ -73,8 +73,8 @@
 // RUN:   --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-MULTI64-I386 %s
 // CHECK-MULTI64-I386: "-cc1" "-triple" "i386-unknown-linux"
-// CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\}}as" "--32"
-// CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\}}ld"
+// CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}as" "--32"
+// CHECK-MULTI64-I386: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
 // CHECK-MULTI64-I386: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
 // CHECK-MULTI64-I386: "-m" "elf_i386"
 // CHECK-MULTI64-I386: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]/32{{/|\\\\}}crtbegin.o"
@@ -91,8 +91,8 @@
 // RUN:   --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-MULTI64-X86-64 %s
 // CHECK-MULTI64-X86-64: "-cc1" "-triple" "x86_64-unknown-linux"
-// CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\}}as" "--64"
-// CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\}}ld"
+// CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}as" "--64"
+// CHECK-MULTI64-X86-64: "{{.*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/bin{{/|\\\\}}ld"
 // CHECK-MULTI64-X86-64: "--sysroot=[[sysroot:.*/Inputs/basic_linux_tree]]"
 // CHECK-MULTI64-X86-64: "-m" "elf_x86_64"
 // CHECK-MULTI64-X86-64: "crti.o" "[[gcc_install:.*/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0]]{{/|\\\\}}crtbegin.o"
diff --git a/test/Driver/darwin-arch-default.c b/test/Driver/darwin-arch-default.c
index 60bf61d..e7e5e89 100644
--- a/test/Driver/darwin-arch-default.c
+++ b/test/Driver/darwin-arch-default.c
@@ -2,6 +2,42 @@
 //
 // RUN: %clang -target powerpc-apple-darwin8 -### \
 // RUN:   -ccc-print-phases %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-POWERPC < %t %s
+// RUN: FileCheck --check-prefix=CHECK-BIND-PPC < %t %s
 //
-// CHECK-POWERPC: bind-arch, "ppc"
+// CHECK-BIND-PPC: bind-arch, "ppc"
+//
+// RUN: %clang -target powerpc64-apple-darwin8 -### \
+// RUN:   -ccc-print-phases %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-BIND-PPC64 < %t %s
+//
+// CHECK-BIND-PPC64: bind-arch, "ppc64"
+
+// Check that the correct arch name is passed to the external assembler
+//
+// RUN: %clang -target powerpc-apple-darwin8 -### \
+// RUN:   -no-integrated-as -c %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-AS-PPC < %t %s
+//
+// CHECK-AS-PPC: {{as(.exe)?"}}
+// CHECK-AS-PPC: "-arch" "ppc"
+//
+// RUN: %clang -target powerpc64-apple-darwin8 -### \
+// RUN:   -no-integrated-as -c %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-AS-PPC64 < %t %s
+//
+// CHECK-AS-PPC64: {{as(.exe)?"}}
+// CHECK-AS-PPC64: "-arch" "ppc64"
+
+// Check that the correct arch name is passed to the external linker
+//
+// RUN: %clang -target powerpc-apple-darwin8 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-LD-PPC < %t %s
+//
+// CHECK-LD-PPC: {{ld(.exe)?"}}
+// CHECK-LD-PPC: "-arch" "ppc"
+//
+// RUN: %clang -target powerpc64-apple-darwin8 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-LD-PPC64 < %t %s
+//
+// CHECK-LD-PPC64: {{ld(.exe)?"}}
+// CHECK-LD-PPC64: "-arch" "ppc64"
diff --git a/test/Driver/darwin-debug-flags.c b/test/Driver/darwin-debug-flags.c
index f98e9ce..1b12ad5 100644
--- a/test/Driver/darwin-debug-flags.c
+++ b/test/Driver/darwin-debug-flags.c
@@ -1,4 +1,4 @@
-// RUN: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin9 -g -Os %s  -emit-llvm -S -o - | FileCheck %s
+// RUN: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin9 -I "path with \spaces" -g -Os %s  -emit-llvm -S -o - | FileCheck %s
 // <rdar://problem/7256886>
 // RUN: touch %t.s
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
@@ -6,6 +6,7 @@
 // RUN: %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=P %s
 
 // CHECK: !0 = metadata !{
+// CHECK: -I path\5C with\5C \5C\5Cspaces
 // CHECK: -g -Os
 // CHECK: -mmacosx-version-min=10.5.0
 // CHECK: [ DW_TAG_compile_unit ]
@@ -15,3 +16,6 @@
 // S: "-dwarf-debug-flags"
 
 // P: "-dwarf-debug-producer"
+
+// This depends on shell quoting.
+// REQUIRES: shell
diff --git a/test/Driver/darwin-ld-demangle.c b/test/Driver/darwin-ld-demangle.c
new file mode 100644
index 0000000..1eef3c7
--- /dev/null
+++ b/test/Driver/darwin-ld-demangle.c
@@ -0,0 +1,8 @@
+// REQUIRES: system-darwin
+
+// On Darwin, -demangle is passed to the linker of HOST_LINK_VERSION
+// is high enough. It is assumed to be high enough on systems where
+// this test gets run.
+
+// RUN: %clang -### %s 2>&1 | FileCheck %s
+// CHECK: -demangle
diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c
index 2da0d30..d3d0f1d 100644
--- a/test/Driver/darwin-ld.c
+++ b/test/Driver/darwin-ld.c
@@ -17,6 +17,8 @@
 // RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
 
 // LINK_IPHONE_3_0: {{ld(.exe)?"}}
+// LINK_IPHONE_3_0: -iphoneos_version_min
+// LINK_IPHONE_3_0: 3.0.0
 // LINK_IPHONE_3_0-NOT: -lcrt1.3.1.o
 // LINK_IPHONE_3_0: -lcrt1.o
 // LINK_IPHONE_3_0: -lSystem
@@ -34,6 +36,8 @@
 // RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
 
 // LINK_IPHONE_3_1: {{ld(.exe)?"}}
+// LINK_IPHONE_3_1: -iphoneos_version_min
+// LINK_IPHONE_3_1: 3.1.0
 // LINK_IPHONE_3_1-NOT: -lcrt1.o
 // LINK_IPHONE_3_1: -lcrt1.3.1.o
 // LINK_IPHONE_3_1: -lSystem
@@ -51,6 +55,8 @@
 // RUN: FileCheck -check-prefix=LINK_IOSSIM_3_0 %s < %t.log
 
 // LINK_IOSSIM_3_0: {{ld(.exe)?"}}
+// LINK_IOSSIM_3_0: -ios_simulator_version_min
+// LINK_IOSSIM_3_0: 3.0.0
 // LINK_IOSSIM_3_0-NOT: -lcrt1.o
 // LINK_IOSSIM_3_0: -lSystem
 // LINK_IOSSIM_3_0: {{ld(.exe)?"}}
@@ -187,10 +193,14 @@
 // LINK_X86_64H_MULTIARCH: {{ld(.exe)?"}}
 // LINK_X86_64H_MULTIARCH: "x86_64h"
 
-// Check that clang passes -iphoneos_version_min to the linker when building
-// for the iOS simulator but when -mios-simulator-version-min is not
-// explicitly specified (<rdar://problem/15959009>).
+// Check for the linker options to specify the iOS version when the
+// IPHONEOS_DEPLOYMENT_TARGET variable is used instead of the command-line
+// deployment target options.
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target arm64-apple-darwin -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_IPHONEOS_VERSION_MIN %s < %t.log
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
 // RUN:   %clang -target i386-apple-darwin -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=LINK_IPHONEOS_VERSION_MIN %s < %t.log
+// RUN: FileCheck -check-prefix=LINK_IOS_SIMULATOR_VERSION_MIN %s < %t.log
 // LINK_IPHONEOS_VERSION_MIN: -iphoneos_version_min
+// LINK_IOS_SIMULATOR_VERSION_MIN: -ios_simulator_version_min
diff --git a/test/Driver/darwin-max-type-align.c b/test/Driver/darwin-max-type-align.c
new file mode 100644
index 0000000..6532f4a
--- /dev/null
+++ b/test/Driver/darwin-max-type-align.c
@@ -0,0 +1,15 @@
+// Check the -fmax-type-align=N flag
+// rdar://16254558
+//
+// RUN: %clang -no-canonical-prefixes -target x86_64-apple-macosx10.7.0 %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST0 %s
+// TEST0: -fmax-type-align=16
+// RUN: %clang -no-canonical-prefixes -fmax-type-align=32 -target x86_64-apple-macosx10.7.0 %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST1 %s
+// TEST1: -fmax-type-align=32
+// RUN: %clang -no-canonical-prefixes -fmax-type-align=32 -fno-max-type-align -target x86_64-apple-macosx10.7.0 %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST2 %s
+// TEST2-NOT: -fmax-type-align
+// RUN: %clang -no-canonical-prefixes -fno-max-type-align -target x86_64-apple-macosx10.7.0 %s -o - -### 2>&1 | \
+// RUN:   FileCheck -check-prefix=TEST3 %s
+// TEST3-NOT: -fmax-type-align
diff --git a/test/Driver/darwin-sanitizer-ld.c b/test/Driver/darwin-sanitizer-ld.c
index 85cfb73..500fec4 100644
--- a/test/Driver/darwin-sanitizer-ld.c
+++ b/test/Driver/darwin-sanitizer-ld.c
@@ -7,6 +7,8 @@
 // CHECK-ASAN: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ASAN: stdc++
 // CHECK-ASAN: libclang_rt.asan_osx_dynamic.dylib"
+// CHECK-ASAN: "-rpath" "@executable_path"
+// CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
@@ -15,6 +17,8 @@
 // CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ASAN-IOSSIM: lc++
 // CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
+// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
@@ -22,7 +26,9 @@
 
 // CHECK-DYN-ASAN: "{{.*}}ld{{(.exe)?}}"
 // CHECK-DYN-ASAN: "-dylib"
-// CHECK-DYN-ASAN: libclang_rt.asan_osx_dynamic.dylib
+// CHECK-DYN-ASAN: libclang_rt.asan_osx_dynamic.dylib"
+// CHECK-DYN-ASAN: "-rpath" "@executable_path"
+// CHECK-DYN-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fsanitize=undefined %s -o %t.o 2>&1 \
diff --git a/test/Driver/darwin-sdkroot.c b/test/Driver/darwin-sdkroot.c
index b727fa6..58bc683 100644
--- a/test/Driver/darwin-sdkroot.c
+++ b/test/Driver/darwin-sdkroot.c
@@ -33,3 +33,10 @@
 //
 // It doesn't make sense on msys bash.
 // REQUIRES: shell-preserves-root
+//
+// This test will fail with MSYS env.exe, since it does not preserve root,
+// expanding / into C:/MINGW/MSYS/1.0. To see the problem, from cmd.exe run:
+//
+//   env SDKROOT=/ cmd //c echo %SDKROOT%
+//
+// This test passes using env.exe from GnuWin32.
diff --git a/test/Driver/darwin-verify-debug.c b/test/Driver/darwin-verify-debug.c
index 4878c74..50a6cf3 100644
--- a/test/Driver/darwin-verify-debug.c
+++ b/test/Driver/darwin-verify-debug.c
@@ -1,6 +1,5 @@
 // Check that we verify debug output properly with multiple -arch options.
 //
-// REQUIRES: asserts
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-phases \
 // RUN:   --verify-debug-info -arch i386 -arch x86_64 %s -g 2> %t
 // RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s
diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c
index e179ef0..5046179 100644
--- a/test/Driver/debug-options.c
+++ b/test/Driver/debug-options.c
@@ -33,6 +33,8 @@
 // RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
 // RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
 //
+// RUN: %clang -### -c -g1 %s 2>&1 \
+// RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
 // RUN: %clang -### -c -gmlt %s 2>&1 \
 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
 // RUN: %clang -### -c -gline-tables-only %s 2>&1 \
@@ -51,6 +53,8 @@
 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \
 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
+// RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
 // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
 // RUN:             | FileCheck -check-prefix=GLTO_NO %s
 //
@@ -68,6 +72,10 @@
 // RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=NOFDTS %s
 //
+// RUN: %clang -### -g -gno-column-info %s 2>&1 \
+// RUN:        | FileCheck -check-prefix=NOCI %s
+//
+// RUN: %clang -### -g %s 2>&1 | FileCheck -check-prefix=CI %s
 //
 // G: "-cc1"
 // G: "-g"
@@ -114,3 +122,7 @@
 // FDTS: "-backend-option" "-generate-type-units"
 //
 // NOFDTS-NOT: "-backend-option" "-generate-type-units"
+//
+// CI: "-dwarf-column-info"
+//
+// NOCI-NOT: "-dwarf-column-info"
diff --git a/test/Driver/fatal-warnings.c b/test/Driver/fatal-warnings.c
new file mode 100644
index 0000000..6239b25
--- /dev/null
+++ b/test/Driver/fatal-warnings.c
@@ -0,0 +1,8 @@
+// RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -Wa,--fatal-warnings 2>&1 | FileCheck %s
+// RUN: not %clang %s -c -o %t.o -target i686-pc-linux-gnu -integrated-as -Wa,--fatal-warnings 2>&1 %t.log
+// FileCheck --check-prefix=CHECK-AS %s -input-file %t.log
+
+// CHECK: "-cc1" {{.*}} "-massembler-fatal-warnings"
+// CHECK-AS: error: .warning argument must be a string
+
+__asm(".warning 1");
diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c
index f0275d0..0c04fd2 100644
--- a/test/Driver/freebsd.c
+++ b/test/Driver/freebsd.c
@@ -1,4 +1,12 @@
 // RUN: %clang -no-canonical-prefixes \
+// RUN:   -target aarch64-pc-freebsd11 %s                              \
+// RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM64 %s
+// CHECK-ARM64: "-cc1" "-triple" "aarch64-pc-freebsd11"
+// CHECK-ARM64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ARM64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+//
+// RUN: %clang -no-canonical-prefixes \
 // RUN:   -target powerpc-pc-freebsd8 %s    \
 // RUN:   --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC %s
diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c
index 57ea5a2..c78dfc6 100644
--- a/test/Driver/fsanitize.c
+++ b/test/Driver/fsanitize.c
@@ -1,13 +1,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-undefined-trap-on-error -fsanitize=undefined-trap %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
-// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool),?){14}"}}
+// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){16}"}}
 // CHECK-UNDEFINED-TRAP: "-fsanitize-undefined-trap-on-error"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
-// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool),?){16}"}}
+// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN
-// CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool),?){15}"}}
+// CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER
 // CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift),?){4}"}}
@@ -16,7 +16,7 @@
 // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}}
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=thread,undefined -fno-sanitize=thread -fno-sanitize=float-cast-overflow,vptr,bool,enum %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PARTIAL-UNDEFINED
-// CHECK-PARTIAL-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift|unreachable|return|vla-bound|alignment|null|object-size|array-bounds),?){12}"}}
+// CHECK-PARTIAL-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift|unreachable|return|vla-bound|alignment|null|object-size|array-bounds|returns-nonnull-attribute|nonnull-attribute),?){14}"}}
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP-ON-ERROR-UNDEF
 // CHECK-UNDEFINED-TRAP-ON-ERROR-UNDEF: '-fsanitize=undefined' not allowed with '-fsanitize-undefined-trap-on-error'
@@ -80,6 +80,27 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=3 -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-3
 // CHECK-TRACK-ORIGINS-3: error: invalid value '3' in '-fsanitize-memory-track-origins=3'
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address                       %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
+// CHECK-SANITIZE-COVERAGE-0-NOT: fsanitize-coverage
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-1
+// CHECK-SANITIZE-COVERAGE-1: fsanitize-coverage=1
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=4 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-4
+// CHECK-SANITIZE-COVERAGE-4: fsanitize-coverage=4
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=5 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-5
+// CHECK-SANITIZE-COVERAGE-5: error: invalid value '5' in '-fsanitize-coverage=5'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-field-padding=0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FIELD-PADDING-0
+// CHECK-ASAN-FIELD-PADDING-0-NOT: -fsanitize-address-field-padding
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-field-padding=1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FIELD-PADDING-1
+// CHECK-ASAN-FIELD-PADDING-1: -fsanitize-address-field-padding=1
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-field-padding=2 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FIELD-PADDING-2
+// CHECK-ASAN-FIELD-PADDING-2: -fsanitize-address-field-padding=2
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-field-padding=3 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FIELD-PADDING-3
+// CHECK-ASAN-FIELD-PADDING-3: error: invalid value '3' in '-fsanitize-address-field-padding=3'
+// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-field-padding=2 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FIELD-PADDING-NO-ASAN
+// CHECK-ASAN-FIELD-PADDING-NO-ASAN: warning: argument unused during compilation: '-fsanitize-address-field-padding=2'
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
 // OK
 
@@ -98,11 +119,11 @@
 // RUN: %clang -target arm-linux-androideabi %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-NO-ASAN
 // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic"
 
-// RUN: %clang -target x86_64-linux-gnu %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
-// RUN: %clang -target x86_64-linux-gnu %s -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
-// RUN: %clang -target x86_64-linux-gnu %s -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
-// RUN: %clang -target x86_64-linux-gnu %s -fno-sanitize-recover -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
-// RUN: %clang -target x86_64-linux-gnu %s -fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fno-sanitize-recover -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
+// RUZ: %clang -target x86_64-linux-gnu %s -fsanitize=undefined -fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
 // CHECK-RECOVER-NOT: sanitize-recover
 // CHECK-NO-RECOVER: "-fno-sanitize-recover"
 
@@ -142,3 +163,21 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=function -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FSAN-UBSAN-DARWIN
 // CHECK-FSAN-UBSAN-DARWIN: unsupported option '-fsanitize=function' for target 'x86_64-apple-darwin10'
+
+// RUN: %clang_cl -fsanitize=address -c -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
+// RUN: %clang_cl -fsanitize=address -c -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
+// RUN: %clang_cl -fsanitize=address -c -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
+// RUN: %clang_cl -fsanitize=address -c -MD -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
+// RUN: %clang_cl -fsanitize=address -c -MT -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
+// RUN: %clang_cl -fsanitize=address -c -LD -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
+// CHECK-ASAN-DEBUGRTL: error: invalid argument
+// CHECK-ASAN-DEBUGRTL: not allowed with '-fsanitize=address'
+// CHECK-ASAN-DEBUGRTL: note: AddressSanitizer doesn't support linking with debug runtime libraries yet
+
+// RUN: %clang_cl -fsanitize=address -c -MT -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-RELEASERTL
+// RUN: %clang_cl -fsanitize=address -c -MD -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-RELEASERTL
+// RUN: %clang_cl -fsanitize=address -c -LD -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-RELEASERTL
+// RUN: %clang_cl -fsanitize=address -c -MTd -MT -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-RELEASERTL
+// RUN: %clang_cl -fsanitize=address -c -MDd -MD -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-RELEASERTL
+// RUN: %clang_cl -fsanitize=address -c -LDd -LD -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-RELEASERTL
+// CHECK-ASAN-RELEASERTL-NOT: error: invalid argument
diff --git a/test/Driver/hexagon-toolchain-elf.c b/test/Driver/hexagon-toolchain-elf.c
index 87c33c7..984dc04 100644
--- a/test/Driver/hexagon-toolchain-elf.c
+++ b/test/Driver/hexagon-toolchain-elf.c
@@ -4,22 +4,24 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK001 %s
 // CHECK001: "-cc1" {{.*}} "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK001:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK001:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK001-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK001-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK002 %s
 // CHECK002: "-cc1" {{.*}} "-internal-isystem" "[[INSTALL_DIR:.*]]/Inputs/hexagon_tree/qc/bin/../../gnu{{/|\\\\}}hexagon/include/c++/4.4.0"
 // CHECK002:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK002:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK002:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK002-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK002-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // -----------------------------------------------------------------------------
 // Test -nostdinc, -nostdlibinc, -nostdinc++
@@ -27,6 +29,7 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdinc \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK003 %s
@@ -34,10 +37,11 @@
 // CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK003-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK003-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdlibinc \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK004 %s
@@ -45,10 +49,11 @@
 // CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK004-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK004-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdlibinc \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK005 %s
@@ -57,54 +62,59 @@
 // CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK005-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK005-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdinc++ \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK006 %s
 // CHECK006: "-cc1"
 // CHECK006-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
-// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // -----------------------------------------------------------------------------
 // Test -march=<archname> -mcpu=<archname> -mv<number>
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -march=hexagonv3 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK007 %s
 // CHECK007: "-cc1" {{.*}} "-target-cpu" "hexagonv3"
-// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v3"
-// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv3"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -mcpu=hexagonv5 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK008 %s
 // CHECK008: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
-// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v5"
-// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv5"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -mv2 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK009 %s
 // CHECK009: "-cc1" {{.*}} "-target-cpu" "hexagonv2"
-// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v2"
-// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv2"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK010 %s
 // CHECK010: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
-// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v4"
-// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv4"
 
 // RUN: not %clang -march=hexagonv2 -target hexagon-unknown-elf \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
@@ -131,11 +141,12 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK011 %s
 // CHECK011: "-cc1"
-// CHECK011-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK011-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK011-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK011-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK011-NOT: "-static"
 // CHECK011-NOT: "-shared"
 // CHECK011: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
@@ -155,11 +166,12 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK012 %s
 // CHECK012: "-cc1"
-// CHECK012-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK012-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK012-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK012-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK012-NOT: "-static"
 // CHECK012-NOT: "-shared"
 // CHECK012: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
@@ -180,12 +192,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -Lone -L two -L three \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK013 %s
 // CHECK013: "-cc1"
-// CHECK013-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK013-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK013-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK013-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK013: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK013: "{{.*}}/hexagon/lib/v4/crt0.o"
 // CHECK013: "{{.*}}/hexagon/lib/v4/init.o"
@@ -204,12 +217,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -static \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK014 %s
 // CHECK014: "-cc1"
-// CHECK014-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK014-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK014-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK014-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK014: "-static"
 // CHECK014: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK014: "{{.*}}/hexagon/lib/v4/crt0.o"
@@ -225,12 +239,13 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -shared \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK015 %s
 // CHECK015: "-cc1"
-// CHECK015-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK015-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK015-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK015-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK015: "-shared" "-call_shared"
 // CHECK015-NOT: crt0_standalone.o
 // CHECK015-NOT: crt0.o
@@ -254,13 +269,14 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -shared \
 // RUN:   -static \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK016 %s
 // CHECK016: "-cc1"
-// CHECK016-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK016-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK016-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK016-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK016: "-shared" "-call_shared" "-static"
 // CHECK016-NOT: crt0_standalone.o
 // CHECK016-NOT: crt0.o
@@ -287,12 +303,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdlib \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK017 %s
 // CHECK017: "-cc1"
-// CHECK017-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK017-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK017-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK017-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK017-NOT: crt0_standalone.o
 // CHECK017-NOT: crt0.o
 // CHECK017-NOT: init.o
@@ -313,12 +330,13 @@
 
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostartfiles \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK018 %s
 // CHECK018: "-cc1"
-// CHECK018-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK018-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK018-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK018-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK018-NOT: crt0_standalone.o
 // CHECK018-NOT: crt0.o
 // CHECK018-NOT: init.o
@@ -339,12 +357,13 @@
 
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nodefaultlibs \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK019 %s
 // CHECK019: "-cc1"
-// CHECK019-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK019-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK019-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK019-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK019: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK019: "{{.*}}/hexagon/lib/v4/crt0.o"
 // CHECK019: "{{.*}}/hexagon/lib/v4/init.o"
@@ -368,12 +387,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -moslib=first -moslib=second \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK020 %s
 // CHECK020: "-cc1"
-// CHECK020-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK020-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK020-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK020-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK020-NOT: "-static"
 // CHECK020-NOT: "-shared"
 // CHECK020-NOT: crt0_standalone.o
@@ -393,12 +413,13 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -moslib=first -moslib=second -moslib=standalone\
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK021 %s
 // CHECK021: "-cc1"
-// CHECK021-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK021-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK021-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK021-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK021-NOT: "-static"
 // CHECK021-NOT: "-shared"
 // CHECK021: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
@@ -421,6 +442,7 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clangxx -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -s \
 // RUN:   -Tbss 0xdead -Tdata 0xbeef -Ttext 0xcafe \
 // RUN:   -t \
@@ -429,8 +451,8 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK022 %s
 // CHECK022: "-cc1"
-// CHECK022-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK022-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK022-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK022-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK022: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK022: "{{.*}}/hexagon/lib/v4/crt0.o"
 // CHECK022: "{{.*}}/hexagon/lib/v4/init.o"
@@ -453,27 +475,31 @@
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK023 %s
 // CHECK023:      "-cc1"
 // CHECK023:        "-mrelocation-model" "static"
-// CHECK023-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK023-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK023-NOT:    "-G{{[0-9]+}}"
-// CHECK023-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK023-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK023-NOT:    "-G{{[0-9]+}}"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -fpic \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK024 %s
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -fPIC \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK024 %s
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -fPIC \
 // RUN:   -msmall-data-threshold=8 \
 // RUN:   %s 2>&1 \
@@ -482,32 +508,35 @@
 // CHECK024-NOT:    "-mrelocation-model" "static"
 // CHECK024:        "-pic-level" "{{[12]}}"
 // CHECK024:        "-mllvm" "-hexagon-small-data-threshold=0"
-// CHECK024-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK024-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK024:        "-G0"
-// CHECK024-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK024-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK024:        "-G0"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -G=8 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -G 8 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -msmall-data-threshold=8 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // CHECK025:      "-cc1"
 // CHECK025:        "-mrelocation-model" "static"
 // CHECK025:        "-mllvm" "-hexagon-small-data-threshold=8"
-// CHECK025-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK025-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK025:        "-G8"
-// CHECK025-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK025-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK025:        "-G8"
 
 // -----------------------------------------------------------------------------
@@ -515,22 +544,24 @@
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -pie \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK026 %s
 // CHECK026:      "-cc1"
-// CHECK026-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
-// CHECK026-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK026-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
+// CHECK026-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK026:        "-pie"
 
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -pie -shared \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK027 %s
 // CHECK027:      "-cc1"
-// CHECK027-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
-// CHECK027-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK027-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
+// CHECK027-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK027-NOT:    "-pie"
 
 // -----------------------------------------------------------------------------
@@ -538,25 +569,27 @@
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK028 %s
 // CHECK028:      "-cc1"
 // CHECK028:        "-mqdsp6-compat"
 // CHECK028:        "-Wreturn-type"
-// CHECK028-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
-// CHECK028-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK028-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
+// CHECK028-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 
 // -----------------------------------------------------------------------------
 // Test Assembler related args
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-elf     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -gdwarf-2 \
 // RUN:   -Wa,--noexecstack,--trap \
 // RUN:   -Xassembler --keep-locals \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK029 %s
 // CHECK029:      "-cc1"
-// CHECK029-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK029-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK029:      "--noexecstack" "--trap" "--keep-locals"
-// CHECK029-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK029-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
diff --git a/test/Driver/hexagon-toolchain.c b/test/Driver/hexagon-toolchain.c
index 88440f8..391b78a 100644
--- a/test/Driver/hexagon-toolchain.c
+++ b/test/Driver/hexagon-toolchain.c
@@ -4,22 +4,24 @@
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK001 %s
 // CHECK001: "-cc1" {{.*}} "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK001:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK001:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK001-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK001-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK002 %s
 // CHECK002: "-cc1" {{.*}} "-internal-isystem" "[[INSTALL_DIR:.*]]/Inputs/hexagon_tree/qc/bin/../../gnu{{/|\\\\}}hexagon/include/c++/4.4.0"
 // CHECK002:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK002:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK002:   "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK002-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK002-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // -----------------------------------------------------------------------------
 // Test -nostdinc, -nostdlibinc, -nostdinc++
@@ -27,6 +29,7 @@
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdinc \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK003 %s
@@ -34,10 +37,11 @@
 // CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK003-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK003-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdlibinc \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK004 %s
@@ -45,10 +49,11 @@
 // CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK004-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK004-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdlibinc \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK005 %s
@@ -57,54 +62,59 @@
 // CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
 // CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
 // CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
-// CHECK005-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK005-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdinc++ \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK006 %s
 // CHECK006: "-cc1"
 // CHECK006-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
-// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"
+// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"
 
 // -----------------------------------------------------------------------------
 // Test -march=<archname> -mcpu=<archname> -mv<number>
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -march=hexagonv3 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK007 %s
 // CHECK007: "-cc1" {{.*}} "-target-cpu" "hexagonv3"
-// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v3"
-// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv3"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -mcpu=hexagonv5 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK008 %s
 // CHECK008: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
-// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v5"
-// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv5"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -mv2 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK009 %s
 // CHECK009: "-cc1" {{.*}} "-target-cpu" "hexagonv2"
-// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v2"
-// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv2"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK010 %s
 // CHECK010: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
-// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-as"{{.*}} "-march=v4"
-// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\}}hexagon-ld"{{.*}} "-mv4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-as"{{.*}} "-march=v4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin{{/|\\\\}}hexagon-ld"{{.*}} "-mv4"
 
 // RUN: not %clang -march=hexagonv2 -target hexagon-unknown-linux \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
@@ -131,11 +141,12 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK011 %s
 // CHECK011: "-cc1"
-// CHECK011-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK011-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK011-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK011-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK011-NOT: "-static"
 // CHECK011-NOT: "-shared"
 // CHECK011: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
@@ -155,11 +166,12 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK012 %s
 // CHECK012: "-cc1"
-// CHECK012-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK012-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK012-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK012-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK012-NOT: "-static"
 // CHECK012-NOT: "-shared"
 // CHECK012: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
@@ -180,12 +192,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -Lone -L two -L three \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK013 %s
 // CHECK013: "-cc1"
-// CHECK013-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK013-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK013-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK013-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK013: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK013: "{{.*}}/hexagon/lib/v4/crt0.o"
 // CHECK013: "{{.*}}/hexagon/lib/v4/init.o"
@@ -204,12 +217,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -static \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK014 %s
 // CHECK014: "-cc1"
-// CHECK014-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK014-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK014-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK014-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK014: "-static"
 // CHECK014: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK014: "{{.*}}/hexagon/lib/v4/crt0.o"
@@ -225,12 +239,13 @@
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -shared \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK015 %s
 // CHECK015: "-cc1"
-// CHECK015-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK015-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK015-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK015-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK015: "-shared" "-call_shared"
 // CHECK015-NOT: crt0_standalone.o
 // CHECK015-NOT: crt0.o
@@ -254,13 +269,14 @@
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -shared \
 // RUN:   -static \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK016 %s
 // CHECK016: "-cc1"
-// CHECK016-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK016-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK016-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK016-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK016: "-shared" "-call_shared" "-static"
 // CHECK016-NOT: crt0_standalone.o
 // CHECK016-NOT: crt0.o
@@ -287,12 +303,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostdlib \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK017 %s
 // CHECK017: "-cc1"
-// CHECK017-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK017-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK017-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK017-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK017-NOT: crt0_standalone.o
 // CHECK017-NOT: crt0.o
 // CHECK017-NOT: init.o
@@ -313,12 +330,13 @@
 
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nostartfiles \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK018 %s
 // CHECK018: "-cc1"
-// CHECK018-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK018-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK018-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK018-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK018-NOT: crt0_standalone.o
 // CHECK018-NOT: crt0.o
 // CHECK018-NOT: init.o
@@ -339,12 +357,13 @@
 
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -nodefaultlibs \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK019 %s
 // CHECK019: "-cc1"
-// CHECK019-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK019-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK019-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK019-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK019: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK019: "{{.*}}/hexagon/lib/v4/crt0.o"
 // CHECK019: "{{.*}}/hexagon/lib/v4/init.o"
@@ -368,12 +387,13 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -moslib=first -moslib=second \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK020 %s
 // CHECK020: "-cc1"
-// CHECK020-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK020-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK020-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK020-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK020-NOT: "-static"
 // CHECK020-NOT: "-shared"
 // CHECK020-NOT: crt0_standalone.o
@@ -393,12 +413,13 @@
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -moslib=first -moslib=second -moslib=standalone\
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK021 %s
 // CHECK021: "-cc1"
-// CHECK021-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK021-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK021-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK021-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK021-NOT: "-static"
 // CHECK021-NOT: "-shared"
 // CHECK021: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
@@ -421,6 +442,7 @@
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 // RUN: %clangxx -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -s \
 // RUN:   -Tbss 0xdead -Tdata 0xbeef -Ttext 0xcafe \
 // RUN:   -t \
@@ -429,8 +451,8 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK022 %s
 // CHECK022: "-cc1"
-// CHECK022-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"{{.*}}
-// CHECK022-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK022-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"{{.*}}
+// CHECK022-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK022: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
 // CHECK022: "{{.*}}/hexagon/lib/v4/crt0.o"
 // CHECK022: "{{.*}}/hexagon/lib/v4/init.o"
@@ -453,27 +475,31 @@
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK023 %s
 // CHECK023:      "-cc1"
 // CHECK023:        "-mrelocation-model" "static"
-// CHECK023-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK023-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK023-NOT:    "-G{{[0-9]+}}"
-// CHECK023-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK023-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK023-NOT:    "-G{{[0-9]+}}"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -fpic \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK024 %s
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -fPIC \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK024 %s
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -fPIC \
 // RUN:   -msmall-data-threshold=8 \
 // RUN:   %s 2>&1 \
@@ -482,32 +508,35 @@
 // CHECK024-NOT:    "-mrelocation-model" "static"
 // CHECK024:        "-pic-level" "{{[12]}}"
 // CHECK024:        "-mllvm" "-hexagon-small-data-threshold=0"
-// CHECK024-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK024-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK024:        "-G0"
-// CHECK024-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK024-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK024:        "-G0"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -G=8 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -G 8 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -msmall-data-threshold=8 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK025 %s
 // CHECK025:      "-cc1"
 // CHECK025:        "-mrelocation-model" "static"
 // CHECK025:        "-mllvm" "-hexagon-small-data-threshold=8"
-// CHECK025-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK025-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK025:        "-G8"
-// CHECK025-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK025-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK025:        "-G8"
 
 // -----------------------------------------------------------------------------
@@ -515,22 +544,24 @@
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -pie \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK026 %s
 // CHECK026:      "-cc1"
-// CHECK026-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
-// CHECK026-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK026-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
+// CHECK026-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK026:        "-pie"
 
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -pie -shared \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK027 %s
 // CHECK027:      "-cc1"
-// CHECK027-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
-// CHECK027-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK027-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
+// CHECK027-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 // CHECK027-NOT:    "-pie"
 
 // -----------------------------------------------------------------------------
@@ -538,25 +569,27 @@
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK028 %s
 // CHECK028:      "-cc1"
 // CHECK028:        "-mqdsp6-compat"
 // CHECK028:        "-Wreturn-type"
-// CHECK028-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
-// CHECK028-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK028-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
+// CHECK028-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
 
 // -----------------------------------------------------------------------------
 // Test Assembler related args
 // -----------------------------------------------------------------------------
 // RUN: %clang -### -target hexagon-unknown-linux     \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN:   --gcc-toolchain="" \
 // RUN:   -gdwarf-2 \
 // RUN:   -Wa,--noexecstack,--trap \
 // RUN:   -Xassembler --keep-locals \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK029 %s
 // CHECK029:      "-cc1"
-// CHECK029-NEXT: "{{.*}}/bin{{/|\\}}hexagon-as"
+// CHECK029-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-as"
 // CHECK029:      "--noexecstack" "--trap" "--keep-locals"
-// CHECK029-NEXT: "{{.*}}/bin{{/|\\}}hexagon-ld"
+// CHECK029-NEXT: "{{.*}}/bin{{/|\\\\}}hexagon-ld"
diff --git a/test/Driver/instrprof-ld.c b/test/Driver/instrprof-ld.c
index f70ae47..f16fa8f 100644
--- a/test/Driver/instrprof-ld.c
+++ b/test/Driver/instrprof-ld.c
@@ -35,7 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-I386-SHARED %s
 //
 // CHECK-LINUX-I386-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-LINUX-I386-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-pic-i386.a" {{.*}} "-lc"
+// CHECK-LINUX-I386-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-i386.a" {{.*}} "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -shared \
@@ -45,7 +45,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64-SHARED %s
 //
 // CHECK-LINUX-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-LINUX-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-pic-x86_64.a" {{.*}} "-lc"
+// CHECK-LINUX-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -shared \
@@ -55,4 +55,4 @@
 // RUN:   | FileCheck --check-prefix=CHECK-FREEBSD-X86-64-SHARED %s
 //
 // CHECK-FREEBSD-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
-// CHECK-FREEBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}freebsd{{/|\\\\}}libclang_rt.profile-pic-x86_64.a"
+// CHECK-FREEBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}freebsd{{/|\\\\}}libclang_rt.profile-x86_64.a"
diff --git a/test/Driver/le32-unknown-nacl.cpp b/test/Driver/le32-unknown-nacl.cpp
index e029f66..379ddb6 100644
--- a/test/Driver/le32-unknown-nacl.cpp
+++ b/test/Driver/le32-unknown-nacl.cpp
@@ -4,9 +4,9 @@
 
 // ECHO: {{.*}} "-cc1" {{.*}}le32-unknown-nacl.c
 
-// Check platform defines
-#include <stdarg.h>
-#include <stddef.h>
+typedef __builtin_va_list va_list;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
 
 extern "C" {
 
diff --git a/test/Driver/le64-unknown-unknown.cpp b/test/Driver/le64-unknown-unknown.cpp
new file mode 100644
index 0000000..d0a5859
--- /dev/null
+++ b/test/Driver/le64-unknown-unknown.cpp
@@ -0,0 +1,137 @@
+// RUN: %clang -target le64-unknown-unknown -### %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
+// RUN: %clang -target le64-unknown-unknown %s -emit-llvm -S -c -o - | FileCheck %s
+
+// ECHO: {{.*}} "-cc1" {{.*}}le64-unknown-unknown.c
+
+typedef __builtin_va_list va_list;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+extern "C" {
+
+// CHECK: @align_c = global i32 1
+int align_c = __alignof(char);
+
+// CHECK: @align_s = global i32 2
+int align_s = __alignof(short);
+
+// CHECK: @align_i = global i32 4
+int align_i = __alignof(int);
+
+// CHECK: @align_l = global i32 8
+int align_l = __alignof(long);
+
+// CHECK: @align_ll = global i32 8
+int align_ll = __alignof(long long);
+
+// CHECK: @align_p = global i32 8
+int align_p = __alignof(void*);
+
+// CHECK: @align_f = global i32 4
+int align_f = __alignof(float);
+
+// CHECK: @align_d = global i32 8
+int align_d = __alignof(double);
+
+// CHECK: @align_ld = global i32 8
+int align_ld = __alignof(long double);
+
+// CHECK: @align_vl = global i32 4
+int align_vl = __alignof(va_list);
+
+// CHECK: __LITTLE_ENDIAN__defined
+#ifdef __LITTLE_ENDIAN__
+void __LITTLE_ENDIAN__defined() {}
+#endif
+
+// CHECK: __le64defined
+#ifdef __le64
+void __le64defined() {}
+#endif
+
+// CHECK: __le64__defined
+#ifdef __le64__
+void __le64__defined() {}
+#endif
+
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
+#endif
+
+// CHECK: __unixdefined
+#ifdef __unix
+void __unixdefined() {}
+#endif
+
+// CHECK: __unix__defined
+#ifdef __unix__
+void __unix__defined() {}
+#endif
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// Check types
+
+// CHECK: signext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: i64 @check_long()
+long check_long() { return 0; }
+
+// CHECK: i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: i64 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: i64 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: i64 @check_ptrdiff_t()
+ptrdiff_t check_ptrdiff_t() { return 0; }
+
+// CHECK: float @check_float()
+float check_float() { return 0; }
+
+// CHECK: double @check_double()
+double check_double() { return 0; }
+
+// CHECK: double @check_longdouble()
+long double check_longdouble() { return 0; }
+
+}
+
+template<int> void Switch();
+template<> void Switch<4>();
+template<> void Switch<8>();
+template<> void Switch<16>();
+
+void check_pointer_size() {
+  // CHECK: SwitchILi8
+  Switch<sizeof(void*)>();
+
+  // CHECK: SwitchILi16
+  Switch<sizeof(va_list)>();
+}
diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c
index 3fc95ec..24866a6 100644
--- a/test/Driver/linker-opts.c
+++ b/test/Driver/linker-opts.c
@@ -5,3 +5,7 @@
 // XFAIL: win32
 // REQUIRES: clang-driver
 // REQUIRES: native
+
+// Make sure that LIBRARY_PATH works for both i386 and x86_64 on Darwin.
+// RUN: env LIBRARY_PATH=%T/test1 %clang -target x86_64-apple-darwin %s -### 2>&1 | FileCheck %s
+// RUN: env LIBRARY_PATH=%T/test1 %clang -target i386-apple-darwin  %s -### 2>&1 | FileCheck %s
diff --git a/test/Driver/linux-header-search.cpp b/test/Driver/linux-header-search.cpp
index 9635519..309ece2 100644
--- a/test/Driver/linux-header-search.cpp
+++ b/test/Driver/linux-header-search.cpp
@@ -46,8 +46,8 @@
 // CHECK-UBUNTU-13-04: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-UBUNTU-13-04: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7"
-// CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward"
 // CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7"
+// CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward"
 // CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-UBUNTU-13-04: "-internal-isystem" "{{.*}}{{/|\\\\}}lib{{(64|32)?}}{{/|\\\\}}clang{{/|\\\\}}{{[0-9]\.[0-9]\.[0-9]}}{{/|\\\\}}include"
 // CHECK-UBUNTU-13-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/x86_64-linux-gnu"
@@ -61,9 +61,8 @@
 // CHECK-UBUNTU-14-04: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-UBUNTU-14-04: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-14-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"
-// CHECK-UBUNTU-14-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu/x32"
-// CHECK-UBUNTU-14-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
 // CHECK-UBUNTU-14-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8/x32"
+// CHECK-UBUNTU-14-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
 // CHECK-UBUNTU-14-04: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-UBUNTU-14-04: "-internal-isystem" "{{.*}}{{/|\\\\}}lib{{(64|x32)?}}{{/|\\\\}}clang{{/|\\\\}}{{[0-9]\.[0-9]\.[0-9]}}{{/|\\\\}}include"
 // CHECK-UBUNTU-14-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/x86_64-linux-gnu"
@@ -77,8 +76,8 @@
 // CHECK-UBUNTU-13-04-CROSS: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-UBUNTU-13-04-CROSS: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-13-04-CROSS: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/../../../../include/c++/4.7"
-// CHECK-UBUNTU-13-04-CROSS: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/../../../../include/c++/4.7/backward"
 // CHECK-UBUNTU-13-04-CROSS: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/../../../../include/arm-linux-gnueabihf/c++/4.7"
+// CHECK-UBUNTU-13-04-CROSS: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc-cross/arm-linux-gnueabihf/4.7/../../../../include/c++/4.7/backward"
 // CHECK-UBUNTU-13-04-CROSS: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-UBUNTU-13-04-CROSS: "-internal-isystem" "{{.*}}{{/|\\\\}}lib{{(64|32)?}}{{/|\\\\}}clang{{/|\\\\}}{{[0-9]\.[0-9]\.[0-9]}}{{/|\\\\}}include"
 // CHECK-UBUNTU-13-04-CROSS: "-internal-externc-isystem" "[[SYSROOT]]/include"
@@ -93,9 +92,8 @@
 // CHECK-UBUNTU-13-04-M32: "-triple" "i386-unknown-linux-gnu"
 // CHECK-UBUNTU-13-04-M32: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7"
-// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/x86_64-linux-gnu/32"
-// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward"
 // CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/32"
+// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward"
 //
 // Test Ubuntu/Debian's Ubuntu 14.04 config variant, with -m32
 // and an empty 4.9 directory.
@@ -107,9 +105,22 @@
 // CHECK-UBUNTU-14-04-M32: "-triple" "i386-unknown-linux-gnu"
 // CHECK-UBUNTU-14-04-M32: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-14-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"
-// CHECK-UBUNTU-14-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu/32"
-// CHECK-UBUNTU-14-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
 // CHECK-UBUNTU-14-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8/32"
+// CHECK-UBUNTU-14-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
+//
+// Test Ubuntu/Debian's Ubuntu 14.04 with -m32 and an i686 cross compiler
+// installed rather than relying on multilib. Also happens to look like an
+// actual i686 Ubuntu system.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target x86_64-unknown-linux-gnu -m32 \
+// RUN:     --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 \
+// RUN:   | FileCheck --check-prefix=CHECK-UBUNTU-14-04-I686 %s
+// CHECK-UBUNTU-14-04-I686: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-UBUNTU-14-04-I686: "-triple" "i386-unknown-linux-gnu"
+// CHECK-UBUNTU-14-04-I686: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-14-04-I686: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/c++/4.8"
+// CHECK-UBUNTU-14-04-I686: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/i386-linux-gnu/c++/4.8"
+// CHECK-UBUNTU-14-04-I686: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/c++/4.8/backward"
 //
 // Test Ubuntu/Debian's Ubuntu 14.04 for powerpc64le
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
@@ -120,9 +131,8 @@
 // CHECK-UBUNTU-14-04-PPC64LE: "-triple" "powerpc64le-unknown-linux-gnu"
 // CHECK-UBUNTU-14-04-PPC64LE: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-UBUNTU-14-04-PPC64LE: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8"
-// CHECK-UBUNTU-14-04-PPC64LE: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8/powerpc64le-linux-gnu"
-// CHECK-UBUNTU-14-04-PPC64LE: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8/backward"
 // CHECK-UBUNTU-14-04-PPC64LE: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8"
+// CHECK-UBUNTU-14-04-PPC64LE: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8/backward"
 // CHECK-UBUNTU-14-04-PPC64LE: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc64le-linux-gnu"
 // CHECK-UBUNTU-14-04-PPC64LE: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-UBUNTU-14-04-PPC64LE: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
index cbb4a71..b3c1aeb 100644
--- a/test/Driver/linux-ld.c
+++ b/test/Driver/linux-ld.c
@@ -216,6 +216,73 @@
 // CHECK-X32: "-L[[SYSROOT]]/usr/lib"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=x86_64-unknown-linux -mx32 \
+// RUN:     --sysroot=%S/Inputs/multilib_64bit_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-64-TO-X32 %s
+// CHECK-64-TO-X32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-TO-X32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/x32{{/|\\\\}}crtbegin.o"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/x32"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../libx32"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../libx32"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/lib/../libx32"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/../libx32"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/lib"
+// CHECK-64-TO-X32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=i386-unknown-linux -mx32 \
+// RUN:     --sysroot=%S/Inputs/multilib_64bit_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-32-TO-X32 %s
+// CHECK-32-TO-X32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-32-TO-X32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/x32{{/|\\\\}}crtbegin.o"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/x32"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../libx32"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../libx32"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/lib/../libx32"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/../libx32"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/lib"
+// CHECK-32-TO-X32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=x86_64-unknown-linux-gnux32 -m64 \
+// RUN:     --sysroot=%S/Inputs/multilib_64bit_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-X32-TO-64 %s
+// CHECK-X32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-X32-TO-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0{{/|\\\\}}crtbegin.o"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib64"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib64"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/lib"
+// CHECK-X32-TO-64: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=x86_64-unknown-linux-gnux32 -m32 \
+// RUN:     --sysroot=%S/Inputs/multilib_64bit_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-X32-TO-32 %s
+// CHECK-X32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-X32-TO-32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32{{/|\\\\}}crtbegin.o"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib32"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib32"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/lib"
+// CHECK-X32-TO-32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=x86_64-unknown-linux -m32 \
 // RUN:     --gcc-toolchain=%S/Inputs/multilib_64bit_linux_tree/usr \
 // RUN:     --sysroot=%S/Inputs/multilib_32bit_linux_tree \
@@ -490,12 +557,47 @@
 // CHECK-ARM-HF: "-dynamic-linker" "{{.*}}/lib/ld-linux-armhf.so.3"
 //
 // RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=powerpc64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC64 %s
+// CHECK-PPC64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-PPC64: "-m" "elf64ppc"
+// CHECK-PPC64: "-dynamic-linker" "{{.*}}/lib64/ld64.so.1"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=powerpc64-linux-gnu -mabi=elfv1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC64-ELFv1 %s
+// CHECK-PPC64-ELFv1: "{{.*}}ld{{(.exe)?}}"
+// CHECK-PPC64-ELFv1: "-m" "elf64ppc"
+// CHECK-PPC64-ELFv1: "-dynamic-linker" "{{.*}}/lib64/ld64.so.1"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=powerpc64-linux-gnu -mabi=elfv2 \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC64-ELFv2 %s
+// CHECK-PPC64-ELFv2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-PPC64-ELFv2: "-m" "elf64ppc"
+// CHECK-PPC64-ELFv2: "-dynamic-linker" "{{.*}}/lib64/ld64.so.2"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN:     --target=powerpc64le-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-PPC64LE %s
 // CHECK-PPC64LE: "{{.*}}ld{{(.exe)?}}"
 // CHECK-PPC64LE: "-m" "elf64lppc"
 // CHECK-PPC64LE: "-dynamic-linker" "{{.*}}/lib64/ld64.so.2"
 //
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=powerpc64le-linux-gnu -mabi=elfv1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC64LE-ELFv1 %s
+// CHECK-PPC64LE-ELFv1: "{{.*}}ld{{(.exe)?}}"
+// CHECK-PPC64LE-ELFv1: "-m" "elf64lppc"
+// CHECK-PPC64LE-ELFv1: "-dynamic-linker" "{{.*}}/lib64/ld64.so.1"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:     --target=powerpc64le-linux-gnu -mabi=elfv2 \
+// RUN:   | FileCheck --check-prefix=CHECK-PPC64LE-ELFv2 %s
+// CHECK-PPC64LE-ELFv2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-PPC64LE-ELFv2: "-m" "elf64lppc"
+// CHECK-PPC64LE-ELFv2: "-dynamic-linker" "{{.*}}/lib64/ld64.so.2"
+//
 // Check that we do not pass --hash-style=gnu and --hash-style=both to linker
 // and provide correct path to the dynamic linker and emulation mode when build
 // for MIPS platforms.
@@ -840,7 +942,7 @@
 // RUN:     -static \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN:     --target=x86-linux-android \
+// RUN:     --target=x86_64-linux-android \
 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:     -static \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s
diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c
index 99e350e..12f1844 100644
--- a/test/Driver/mips-as.c
+++ b/test/Driver/mips-as.c
@@ -3,130 +3,136 @@
 // RUN: %clang -target mips-linux-gnu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32R2-EB-AS %s
-// MIPS32R2-EB-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// RUN: %clang -target mipsel-linux-gnu -### \
+// RUN:   -no-integrated-as -c -EB %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS32R2-EB-AS %s
+// MIPS32R2-EB-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 // MIPS32R2-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
 //
 // RUN: %clang -target mips-linux-gnu -### \
 // RUN:   -no-integrated-as -fPIC -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32R2-EB-PIC %s
-// MIPS32R2-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32R2-EB-PIC: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-call_nonpic" "-EB"
 // MIPS32R2-EB-PIC: "-KPIC"
 //
 // RUN: %clang -target mipsel-linux-gnu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32R2-DEF-EL-AS %s
-// MIPS32R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL"
+// MIPS32R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EL"
 //
 // RUN: %clang -target mips64-linux-gnu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EB-AS %s
-// MIPS64R2-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+// MIPS64R2-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips64el-linux-gnu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-DEF-EL-AS %s
-// MIPS64R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL"
+// MIPS64R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"  "-mno-shared" "-KPIC" "-EL"
 //
 // RUN: %clang -target mips-linux-gnu -mabi=eabi -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-EABI %s
-// MIPS-EABI: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "eabi" "-EB"
+// MIPS-EABI: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "eabi" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-N32 %s
-// MIPS-N32: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-EB"
+// MIPS-N32: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mipsel-linux-gnu -mabi=32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32R2-EL-AS %s
-// MIPS32R2-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL"
+// RUN: %clang -target mips-linux-gnu -mabi=32 -### \
+// RUN:   -no-integrated-as -c %s -EL 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS32R2-EL-AS %s
+// MIPS32R2-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EL"
 //
 // RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EL-AS %s
-// MIPS64R2-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL"
+// MIPS64R2-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EL"
 //
 // RUN: %clang -target mips-linux-gnu -march=mips32r2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-32R2 %s
-// MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s
-// MIPS-OCTEON: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-EB"
+// MIPS-OCTEON: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips1 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-1 %s
-// MIPS-ALIAS-1: as{{(.exe)?}}" "-march" "mips1" "-mabi" "32" "-EB"
+// MIPS-ALIAS-1: as{{(.exe)?}}" "-march" "mips1" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-2 %s
-// MIPS-ALIAS-2: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
+// MIPS-ALIAS-2: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips3 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-3 %s
-// MIPS-ALIAS-3: as{{(.exe)?}}" "-march" "mips3" "-mabi" "32" "-EB"
+// MIPS-ALIAS-3: as{{(.exe)?}}" "-march" "mips3" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips4 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-4 %s
-// MIPS-ALIAS-4: as{{(.exe)?}}" "-march" "mips4" "-mabi" "32" "-EB"
+// MIPS-ALIAS-4: as{{(.exe)?}}" "-march" "mips4" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips5 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-5 %s
-// MIPS-ALIAS-5: as{{(.exe)?}}" "-march" "mips5" "-mabi" "32" "-EB"
+// MIPS-ALIAS-5: as{{(.exe)?}}" "-march" "mips5" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32 %s
-// MIPS-ALIAS-32: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+// MIPS-ALIAS-32: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips32r2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32R2 %s
-// MIPS-ALIAS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS-ALIAS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips32r6 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-32R6 %s
-// MIPS-ALIAS-32R6: as{{(.exe)?}}" "-march" "mips32r6" "-mabi" "32" "-EB"
+// MIPS-ALIAS-32R6: as{{(.exe)?}}" "-march" "mips32r6" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64 %s
-// MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+// MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
-// MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+// MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r6 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R6 %s
-// MIPS-ALIAS-64R6: as{{(.exe)?}}" "-march" "mips64r6" "-mabi" "64" "-EB"
+// MIPS-ALIAS-64R6: as{{(.exe)?}}" "-march" "mips64r6" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-N16 %s
 // MIPS-N16: as{{(.exe)?}}"
-// MIPS-N16-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-mips16"
+// MIPS-N16: -no-mips16
 //
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -137,7 +143,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -148,7 +154,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2"
 //
 // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -159,7 +165,7 @@
 // RUN: %clang -target mips-linux-gnu -mnan=legacy -mnan=2008 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-NAN2008 %s
-// MIPS-NAN2008: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mnan=2008"
+// MIPS-NAN2008: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mnan=2008"
 //
 // RUN: %clang -target mips-linux-gnu -mnan=2008 -mnan=legacy -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -167,20 +173,25 @@
 // MIPS-NAN-LEGACY: as{{(.exe)?}}"
 // MIPS-NAN-LEGACY-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-mnan={{.*}}"
 //
-// RUN: %clang -target mips-linux-gnu -mfp64 -mfp32 -### \
+// RUN: %clang -target mips-linux-gnu -mfp64 -mfpxx -mfp32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MFP32 %s
-// MIPS-MFP32: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mfp32"
+// MIPS-MFP32: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfp32"
 //
-// RUN: %clang -target mips-linux-gnu -mfp32 -mfp64 -### \
+// RUN: %clang -target mips-linux-gnu -mfp32 -mfp64 -mfpxx -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-MFPXX %s
+// MIPS-MFPXX: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx"
+//
+// RUN: %clang -target mips-linux-gnu -mfpxx -mfp32 -mfp64 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MFP64 %s
-// MIPS-MFP64: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mfp64"
+// MIPS-MFP64: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfp64"
 //
 // RUN: %clang -target mips-linux-gnu -mno-msa -mmsa -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MSA %s
-// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB" "-mmsa"
+// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmsa"
 //
 // RUN: %clang -target mips-linux-gnu -mmsa -mno-msa -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -193,45 +204,60 @@
 // when the CPU name is absent from a StringSwitch in getMipsCPUAndABI()
 // RUN: %clang -target mips-linux-gnu -### -no-integrated-as -c %s -mcpu=mips1 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS1-EB-AS %s
-// MIPS1-EB-AS: as{{(.exe)?}}" "-march" "mips1" "-mabi" "32" "-EB"
+// MIPS1-EB-AS: as{{(.exe)?}}" "-march" "mips1" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 // MIPS1-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
 //
 // RUN: %clang -target mips-linux-gnu -### -no-integrated-as -c %s -mcpu=mips2 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS2-EB-AS %s
-// MIPS2-EB-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-EB"
+// MIPS2-EB-AS: as{{(.exe)?}}" "-march" "mips2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 // MIPS2-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -### -no-integrated-as -c %s -mcpu=mips3 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS3-EB-AS %s
-// MIPS3-EB-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-EB"
-// MIPS3-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
+// MIPS3-EB-AS: as{{(.exe)?}}" "-march" "mips3" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -### -no-integrated-as -c %s -mcpu=mips4 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS4-EB-AS %s
-// MIPS4-EB-AS: as{{(.exe)?}}" "-march" "mips4" "-mabi" "64" "-EB"
-// MIPS4-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
+// MIPS4-EB-AS: as{{(.exe)?}}" "-march" "mips4" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -### -no-integrated-as -c %s -mcpu=mips5 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS5-EB-AS %s
-// MIPS5-EB-AS: as{{(.exe)?}}" "-march" "mips5" "-mabi" "64" "-EB"
-// MIPS5-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
+// MIPS5-EB-AS: as{{(.exe)?}}" "-march" "mips5" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -### -no-integrated-as -c %s -mcpu=mips32 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS32-EB-AS %s
-// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 // MIPS32-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
 //
 // RUN: %clang -target mips-linux-gnu -### -no-integrated-as -c %s -mcpu=mips32r6 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS32R6-EB-AS %s
-// MIPS32R6-EB-AS: as{{(.exe)?}}" "-march" "mips32r6" "-mabi" "32" "-EB"
+// MIPS32R6-EB-AS: as{{(.exe)?}}" "-march" "mips32r6" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB"
 // MIPS32R6-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -### -no-integrated-as -c %s -mcpu=mips64 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS64-EB-AS %s
-// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
-// MIPS64-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
+// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -### -no-integrated-as -c %s -mcpu=mips64r6 \
 // RUN:   2>&1 | FileCheck -check-prefix=MIPS64R6-EB-AS %s
-// MIPS64R6-EB-AS: as{{(.exe)?}}" "-march" "mips64r6" "-mabi" "64" "-EB"
-// MIPS64R6-EB-AS-NOT: "{{[ A-Za-z\\\/]*}}as{{(.exe)?}}{{.*}}"-KPIC"
+// MIPS64R6-EB-AS: as{{(.exe)?}}" "-march" "mips64r6" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
+//
+// RUN: %clang -target mips-linux-gnu -### -no-integrated-as -msoft-float -mhard-float -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=HARDFLOAT --implicit-check-not=-msoft-float %s
+// HARDFLOAT: as{{(.exe)?}}"
+// HARDFLOAT: -mhard-float
+//
+// RUN: %clang -target mips-linux-gnu -### -no-integrated-as -mhard-float -msoft-float -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=SOFTFLOAT --implicit-check-not=-mhard-float %s
+// SOFTFLOAT: as{{(.exe)?}}"
+// SOFTFLOAT: -msoft-float
+//
+// RUN: %clang -target mips-linux-gnu -### -no-integrated-as -mno-odd-spreg -modd-spreg -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=ODDSPREG --implicit-check-not=-mno-odd-spreg %s
+// ODDSPREG: as{{(.exe)?}}"
+// ODDSPREG: -modd-spreg
+//
+// RUN: %clang -target mips-linux-gnu -### -no-integrated-as -modd-spreg -mno-odd-spreg -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=NOODDSPREG --implicit-check-not=-modd-spreg %s
+// NOODDSPREG: as{{(.exe)?}}"
+// NOODDSPREG: -mno-odd-spreg
diff --git a/test/Driver/mips-cs.cpp b/test/Driver/mips-cs.cpp
index 275d615..62a90f0 100644
--- a/test/Driver/mips-cs.cpp
+++ b/test/Driver/mips-cs.cpp
@@ -17,6 +17,7 @@
 // CHECK-BE-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-HF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc"
+// CHECK-BE-HF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-32: "[[TC]]{{/|\\\\}}crtbegin.o"
@@ -27,6 +28,35 @@
 // CHECK-BE-HF-32: "[[TC]]{{/|\\\\}}crtend.o"
 // CHECK-BE-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Big-endian, hard float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_cs_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-UC-HF-32 %s
+// CHECK-BE-UC-HF-32: "-internal-isystem"
+// CHECK-BE-UC-HF-32: "[[TC:[^"]+/lib/gcc/mips-linux-gnu/4.6.3]]/../../../../mips-linux-gnu/include/c++/4.6.3"
+// CHECK-BE-UC-HF-32: "-internal-isystem"
+// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc"
+// CHECK-BE-UC-HF-32: "-internal-isystem"
+// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/backward"
+// CHECK-BE-UC-HF-32: "-internal-externc-isystem"
+// CHECK-BE-UC-HF-32: "[[TC]]/include"
+// CHECK-BE-UC-HF-32: "-internal-externc-isystem"
+// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/include"
+// CHECK-BE-UC-HF-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-UC-HF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/uclibc"
+// CHECK-BE-UC-HF-32: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-UC-HF-32: "[[TC]]/uclibc{{/|\\\\}}crtbegin.o"
+// CHECK-BE-UC-HF-32: "-L[[TC]]/uclibc"
+// CHECK-BE-UC-HF-32: "-L[[TC]]/../../../../mips-linux-gnu/lib/../lib/uclibc"
+// CHECK-BE-UC-HF-32-NOT: "-L[[TC]]"
+// CHECK-BE-UC-HF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/lib/../lib"
+// CHECK-BE-UC-HF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/lib/../lib"
+// CHECK-BE-UC-HF-32: "[[TC]]/uclibc{{/|\\\\}}crtend.o"
+// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Big-endian, hard float, mips16
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mips-linux-gnu -mips16 \
@@ -44,6 +74,7 @@
 // CHECK-BE-HF-16: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-HF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-16: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/mips16"
+// CHECK-BE-HF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-16: "[[TC]]/mips16{{/|\\\\}}crtbegin.o"
@@ -72,6 +103,7 @@
 // CHECK-BE-HF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-HF-MICRO: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-MICRO: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/micromips"
+// CHECK-BE-HF-MICRO: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-MICRO: "[[TC]]/micromips{{/|\\\\}}crtbegin.o"
@@ -100,6 +132,7 @@
 // CHECK-BE-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-HF-NAN: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-NAN: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/nan2008"
+// CHECK-BE-HF-NAN: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-BE-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-NAN: "[[TC]]/nan2008{{/|\\\\}}crtbegin.o"
@@ -111,6 +144,35 @@
 // CHECK-BE-HF-NAN: "[[TC]]/nan2008{{/|\\\\}}crtend.o"
 // CHECK-BE-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Big-endian, hard float, uclibc, nan2008
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -muclibc -mnan=2008 \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_cs_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-UC-HF-NAN %s
+// CHECK-BE-UC-HF-NAN: "-internal-isystem"
+// CHECK-BE-UC-HF-NAN: "[[TC:[^"]+/lib/gcc/mips-linux-gnu/4.6.3]]/../../../../mips-linux-gnu/include/c++/4.6.3"
+// CHECK-BE-UC-HF-NAN: "-internal-isystem"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc/nan2008"
+// CHECK-BE-UC-HF-NAN: "-internal-isystem"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/backward"
+// CHECK-BE-UC-HF-NAN: "-internal-externc-isystem"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/include"
+// CHECK-BE-UC-HF-NAN: "-internal-externc-isystem"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/include"
+// CHECK-BE-UC-HF-NAN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-UC-HF-NAN: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008"
+// CHECK-BE-UC-HF-NAN: "-dynamic-linker" "/lib/ld-uClibc-mipsn8.so.0"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/uclibc/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-UC-HF-NAN: "-L[[TC]]/uclibc/nan2008"
+// CHECK-BE-UC-HF-NAN: "-L[[TC]]/../../../../mips-linux-gnu/lib/../lib/uclibc/nan2008"
+// CHECK-BE-UC-HF-NAN-NOT: "-L[[TC]]"
+// CHECK-BE-UC-HF-NAN: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/lib/../lib"
+// CHECK-BE-UC-HF-NAN: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/usr/lib/../lib"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/uclibc/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Big-endian, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mips-linux-gnu -msoft-float \
@@ -128,6 +190,7 @@
 // CHECK-BE-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-SF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/soft-float"
+// CHECK-BE-SF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-32: "[[TC]]/soft-float{{/|\\\\}}crtbegin.o"
@@ -139,6 +202,35 @@
 // CHECK-BE-SF-32: "[[TC]]/soft-float{{/|\\\\}}crtend.o"
 // CHECK-BE-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Big-endian, soft float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -muclibc -msoft-float \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_cs_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-UC-SF-32 %s
+// CHECK-BE-UC-SF-32: "-internal-isystem"
+// CHECK-BE-UC-SF-32: "[[TC:[^"]+/lib/gcc/mips-linux-gnu/4.6.3]]/../../../../mips-linux-gnu/include/c++/4.6.3"
+// CHECK-BE-UC-SF-32: "-internal-isystem"
+// CHECK-BE-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc/soft-float"
+// CHECK-BE-UC-SF-32: "-internal-isystem"
+// CHECK-BE-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/backward"
+// CHECK-BE-UC-SF-32: "-internal-externc-isystem"
+// CHECK-BE-UC-SF-32: "[[TC]]/include"
+// CHECK-BE-UC-SF-32: "-internal-externc-isystem"
+// CHECK-BE-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/include"
+// CHECK-BE-UC-SF-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-UC-SF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float"
+// CHECK-BE-UC-SF-32: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-BE-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-UC-SF-32: "[[TC]]/uclibc/soft-float{{/|\\\\}}crtbegin.o"
+// CHECK-BE-UC-SF-32: "-L[[TC]]/uclibc/soft-float"
+// CHECK-BE-UC-SF-32: "-L[[TC]]/../../../../mips-linux-gnu/lib/../lib/uclibc/soft-float"
+// CHECK-BE-UC-SF-32-NOT: "-L[[TC]]"
+// CHECK-BE-UC-SF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/lib/../lib"
+// CHECK-BE-UC-SF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/usr/lib/../lib"
+// CHECK-BE-UC-SF-32: "[[TC]]/uclibc/soft-float{{/|\\\\}}crtend.o"
+// CHECK-BE-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Big-endian, soft float, mips16
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mips-linux-gnu -msoft-float -mips16 \
@@ -156,6 +248,7 @@
 // CHECK-BE-SF-16: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-SF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-16: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/mips16/soft-float"
+// CHECK-BE-SF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/soft-float/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/soft-float/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-16: "[[TC]]/mips16/soft-float{{/|\\\\}}crtbegin.o"
@@ -184,6 +277,7 @@
 // CHECK-BE-SF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-SF-MICRO: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-MICRO: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/micromips/soft-float"
+// CHECK-BE-SF-MICRO: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/soft-float/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/soft-float/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-MICRO: "[[TC]]/micromips/soft-float{{/|\\\\}}crtbegin.o"
@@ -212,6 +306,7 @@
 // CHECK-BE-HF-64: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-HF-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-64: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc"
+// CHECK-BE-HF-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-BE-HF-64: "[[TC]]/../../../../mips-linux-gnu/libc/usr/lib/../lib64{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-64: "[[TC]]/../../../../mips-linux-gnu/libc/usr/lib/../lib64{{/|\\\\}}crti.o"
 // CHECK-BE-HF-64: "[[TC]]/64{{/|\\\\}}crtbegin.o"
@@ -240,6 +335,7 @@
 // CHECK-BE-SF-64: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-BE-SF-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-64: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/soft-float"
+// CHECK-BE-SF-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-BE-SF-64: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/usr/lib/../lib64{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-64: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/usr/lib/../lib64{{/|\\\\}}crti.o"
 // CHECK-BE-SF-64: "[[TC]]/soft-float/64{{/|\\\\}}crtbegin.o"
@@ -268,6 +364,7 @@
 // CHECK-EL-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-HF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/el"
+// CHECK-EL-HF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-32: "[[TC]]/el{{/|\\\\}}crtbegin.o"
@@ -279,6 +376,35 @@
 // CHECK-EL-HF-32: "[[TC]]/el{{/|\\\\}}crtend.o"
 // CHECK-EL-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Little-endian, hard float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -mhard-float -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_cs_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-UC-HF-32 %s
+// CHECK-EL-UC-HF-32: "-internal-isystem"
+// CHECK-EL-UC-HF-32: "[[TC:[^"]+/lib/gcc/mips-linux-gnu/4.6.3]]/../../../../mips-linux-gnu/include/c++/4.6.3"
+// CHECK-EL-UC-HF-32: "-internal-isystem"
+// CHECK-EL-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc/el"
+// CHECK-EL-UC-HF-32: "-internal-isystem"
+// CHECK-EL-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/backward"
+// CHECK-EL-UC-HF-32: "-internal-externc-isystem"
+// CHECK-EL-UC-HF-32: "[[TC]]/include"
+// CHECK-EL-UC-HF-32: "-internal-externc-isystem"
+// CHECK-EL-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/include"
+// CHECK-EL-UC-HF-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-UC-HF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/uclibc/el"
+// CHECK-EL-UC-HF-32: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-EL-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-UC-HF-32: "[[TC]]/uclibc/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-UC-HF-32: "-L[[TC]]/uclibc/el"
+// CHECK-EL-UC-HF-32: "-L[[TC]]/../../../../mips-linux-gnu/lib/../lib/uclibc/el"
+// CHECK-EL-UC-HF-32-NOT: "-L[[TC]]"
+// CHECK-EL-UC-HF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/el/lib/../lib"
+// CHECK-EL-UC-HF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/el/usr/lib/../lib"
+// CHECK-EL-UC-HF-32: "[[TC]]/uclibc/el{{/|\\\\}}crtend.o"
+// CHECK-EL-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/el/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Little-endian, hard float, mips16
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mipsel-linux-gnu -mips16 \
@@ -296,6 +422,7 @@
 // CHECK-EL-HF-16: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-HF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-16: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/mips16/el"
+// CHECK-EL-HF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-16: "[[TC]]/mips16/el{{/|\\\\}}crtbegin.o"
@@ -324,6 +451,7 @@
 // CHECK-EL-HF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-HF-MICRO: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-MICRO: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/micromips/el"
+// CHECK-EL-HF-MICRO: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-MICRO: "[[TC]]/micromips/el{{/|\\\\}}crtbegin.o"
@@ -352,6 +480,7 @@
 // CHECK-EL-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-HF-NAN: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-NAN: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/nan2008/el"
+// CHECK-EL-HF-NAN: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-EL-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/nan2008/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/nan2008/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-NAN: "[[TC]]/nan2008/el{{/|\\\\}}crtbegin.o"
@@ -363,6 +492,35 @@
 // CHECK-EL-HF-NAN: "[[TC]]/nan2008/el{{/|\\\\}}crtend.o"
 // CHECK-EL-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/nan2008/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Little-endian, hard float, uclibc, nan2008
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -muclibc -mnan=2008 \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_cs_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-UC-HF-NAN %s
+// CHECK-EL-UC-HF-NAN: "-internal-isystem"
+// CHECK-EL-UC-HF-NAN: "[[TC:[^"]+/lib/gcc/mips-linux-gnu/4.6.3]]/../../../../mips-linux-gnu/include/c++/4.6.3"
+// CHECK-EL-UC-HF-NAN: "-internal-isystem"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc/nan2008/el"
+// CHECK-EL-UC-HF-NAN: "-internal-isystem"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/backward"
+// CHECK-EL-UC-HF-NAN: "-internal-externc-isystem"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/include"
+// CHECK-EL-UC-HF-NAN: "-internal-externc-isystem"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/include"
+// CHECK-EL-UC-HF-NAN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-UC-HF-NAN: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/el"
+// CHECK-EL-UC-HF-NAN: "-dynamic-linker" "/lib/ld-uClibc-mipsn8.so.0"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/uclibc/nan2008/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-UC-HF-NAN: "-L[[TC]]/uclibc/nan2008/el"
+// CHECK-EL-UC-HF-NAN: "-L[[TC]]/../../../../mips-linux-gnu/lib/../lib/uclibc/nan2008/el"
+// CHECK-EL-UC-HF-NAN-NOT: "-L[[TC]]"
+// CHECK-EL-UC-HF-NAN: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/el/lib/../lib"
+// CHECK-EL-UC-HF-NAN: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/../lib"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/uclibc/nan2008/el{{/|\\\\}}crtend.o"
+// CHECK-EL-UC-HF-NAN: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/nan2008/el/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Little-endian, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mipsel-linux-gnu -mfloat-abi=soft \
@@ -380,6 +538,7 @@
 // CHECK-EL-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-SF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el"
+// CHECK-EL-SF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-32: "[[TC]]/soft-float/el{{/|\\\\}}crtbegin.o"
@@ -391,6 +550,35 @@
 // CHECK-EL-SF-32: "[[TC]]/soft-float/el{{/|\\\\}}crtend.o"
 // CHECK-EL-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Little-endian, soft float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -mfloat-abi=soft -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_cs_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-UC-SF-32 %s
+// CHECK-EL-UC-SF-32: "-internal-isystem"
+// CHECK-EL-UC-SF-32: "[[TC:[^"]+/lib/gcc/mips-linux-gnu/4.6.3]]/../../../../mips-linux-gnu/include/c++/4.6.3"
+// CHECK-EL-UC-SF-32: "-internal-isystem"
+// CHECK-EL-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc/soft-float/el"
+// CHECK-EL-UC-SF-32: "-internal-isystem"
+// CHECK-EL-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/backward"
+// CHECK-EL-UC-SF-32: "-internal-externc-isystem"
+// CHECK-EL-UC-SF-32: "[[TC]]/include"
+// CHECK-EL-UC-SF-32: "-internal-externc-isystem"
+// CHECK-EL-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/usr/include"
+// CHECK-EL-UC-SF-32: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-UC-SF-32: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/el"
+// CHECK-EL-UC-SF-32: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-EL-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-UC-SF-32: "[[TC]]/uclibc/soft-float/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-UC-SF-32: "-L[[TC]]/uclibc/soft-float/el"
+// CHECK-EL-UC-SF-32: "-L[[TC]]/../../../../mips-linux-gnu/lib/../lib/uclibc/soft-float/el"
+// CHECK-EL-UC-SF-32-NOT: "-L[[TC]]"
+// CHECK-EL-UC-SF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/el/lib/../lib"
+// CHECK-EL-UC-SF-32: "-L[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/../lib"
+// CHECK-EL-UC-SF-32: "[[TC]]/uclibc/soft-float/el{{/|\\\\}}crtend.o"
+// CHECK-EL-UC-SF-32: "[[TC]]/../../../../mips-linux-gnu/libc/uclibc/soft-float/el/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Little-endian, soft float, mips16
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mipsel-linux-gnu -mips16 -msoft-float \
@@ -408,6 +596,7 @@
 // CHECK-EL-SF-16: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-SF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-16: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/mips16/soft-float/el"
+// CHECK-EL-SF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-16: "[[TC]]/../../../../mips-linux-gnu/libc/mips16/soft-float/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-16: "[[TC]]/mips16/soft-float/el{{/|\\\\}}crtbegin.o"
@@ -436,6 +625,7 @@
 // CHECK-EL-SF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-SF-MICRO: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-MICRO: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/micromips/soft-float/el"
+// CHECK-EL-SF-MICRO: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/soft-float/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-MICRO: "[[TC]]/../../../../mips-linux-gnu/libc/micromips/soft-float/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-MICRO: "[[TC]]/micromips/soft-float/el{{/|\\\\}}crtbegin.o"
@@ -464,6 +654,7 @@
 // CHECK-EL-HF-64: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-HF-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-64: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/el"
+// CHECK-EL-HF-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-EL-HF-64: "[[TC]]/../../../../mips-linux-gnu/libc/el/usr/lib/../lib64{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-64: "[[TC]]/../../../../mips-linux-gnu/libc/el/usr/lib/../lib64{{/|\\\\}}crti.o"
 // CHECK-EL-HF-64: "[[TC]]/el/64{{/|\\\\}}crtbegin.o"
@@ -492,6 +683,7 @@
 // CHECK-EL-SF-64: "[[TC]]/../../../../mips-linux-gnu/libc/usr/include"
 // CHECK-EL-SF-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-64: "--sysroot=[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el"
+// CHECK-EL-SF-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-EL-SF-64: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el/usr/lib/../lib64{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-64: "[[TC]]/../../../../mips-linux-gnu/libc/soft-float/el/usr/lib/../lib64{{/|\\\\}}crti.o"
 // CHECK-EL-SF-64: "[[TC]]/soft-float/el/64{{/|\\\\}}crtbegin.o"
diff --git a/test/Driver/mips-eleb.c b/test/Driver/mips-eleb.c
index 0cc696d..aaa80e0 100644
--- a/test/Driver/mips-eleb.c
+++ b/test/Driver/mips-eleb.c
@@ -4,26 +4,30 @@
 // RUN:        -EL -no-integrated-as %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=MIPS32-EL %s
 // MIPS32-EL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mipsel-unknown-linux-gnu"
-// MIPS32-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EL"
+// MIPS32-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32"
+// MIPS32-EL: "-EL"
 // MIPS32-EL: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf32ltsmip"
 //
 // RUN: %clang -no-canonical-prefixes -target mips64-unknown-linux-gnu -### \
 // RUN:        -EL -no-integrated-as %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=MIPS64-EL %s
 // MIPS64-EL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips64el-unknown-linux-gnu"
-// MIPS64-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL"
+// MIPS64-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"
+// MIPS64-EL: "-EL"
 // MIPS64-EL: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf64ltsmip"
 //
 // RUN: %clang -no-canonical-prefixes -target mipsel-unknown-linux-gnu -### \
 // RUN:        -EB -no-integrated-as %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=MIPS32-EB %s
 // MIPS32-EB: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips-unknown-linux-gnu"
-// MIPS32-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-EB"
+// MIPS32-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32"
+// MIPS32-EB: "-EB"
 // MIPS32-EB: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf32btsmip"
 //
 // RUN: %clang -no-canonical-prefixes -target mips64el-unknown-linux-gnu -### \
 // RUN:        -EB -no-integrated-as %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=MIPS64-EB %s
 // MIPS64-EB: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips64-unknown-linux-gnu"
-// MIPS64-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB"
+// MIPS64-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"
+// MIPS64-EB: "-EB"
 // MIPS64-EB: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf64btsmip"
diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c
index 2abb632..f702230 100644
--- a/test/Driver/mips-features.c
+++ b/test/Driver/mips-features.c
@@ -1,5 +1,15 @@
 // Check handling MIPS specific features options.
 //
+// -mabicalls
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mabicalls 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MABICALLS %s
+// CHECK-MABICALLS: "-target-feature" "-noabicalls"
+//
+// -mno-abicalls
+// RUN: %clang -target mips-linux-gnu -### -c %s -mabicalls -mno-abicalls 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
+// CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:     -mno-mips16 -mips16 2>&1 \
@@ -70,6 +80,18 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NOMODDSPREG %s
 // CHECK-NOMODDSPREG: "-target-feature" "+nooddspreg"
 //
+// -mfpxx
+// RUN: %clang -target mips-linux-gnu -### -c %s -mfpxx 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MFPXX %s
+// CHECK-MFPXX: "-target-feature" "+fpxx"
+// CHECK-MFPXX: "-target-feature" "+nooddspreg"
+//
+// -mfpxx -modd-spreg
+// RUN: %clang -target mips-linux-gnu -### -c %s -mfpxx -modd-spreg 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MFPXX-ODDSPREG %s
+// CHECK-MFPXX-ODDSPREG: "-target-feature" "+fpxx"
+// CHECK-MFPXX-ODDSPREG: "-target-feature" "-nooddspreg"
+//
 // -mfp64
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:     -mfp32 -mfp64 2>&1 \
diff --git a/test/Driver/mips-fsf.cpp b/test/Driver/mips-fsf.cpp
index c557b20..07b95c8 100644
--- a/test/Driver/mips-fsf.cpp
+++ b/test/Driver/mips-fsf.cpp
@@ -17,6 +17,7 @@
 // CHECK-BE-HF-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-32: "--sysroot=[[TC]]/../../../../sysroot/mips32"
+// CHECK-BE-HF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-32: "[[TC]]/../../../../sysroot/mips32/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-32: "[[TC]]/../../../../sysroot/mips32/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-32: "[[TC]]/mips32{{/|\\\\}}crtbegin.o"
@@ -34,7 +35,7 @@
 // CHECK-BE-HF64-32: "-internal-isystem"
 // CHECK-BE-HF64-32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-32: "-internal-isystem"
-// CHECK-BE-HF64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/fp64"
+// CHECK-BE-HF64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32"
 // CHECK-BE-HF64-32: "-internal-isystem"
 // CHECK-BE-HF64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-32: "-internal-externc-isystem"
@@ -42,15 +43,16 @@
 // CHECK-BE-HF64-32: "-internal-externc-isystem"
 // CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/fp64"
-// CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/mips32/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/mips32/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-32: "[[TC]]/mips32/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-32: "-L[[TC]]/mips32/fp64"
-// CHECK-BE-HF64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/fp64"
-// CHECK-BE-HF64-32: "-L[[TC]]/../../../../sysroot/mips32/fp64/usr/lib/../lib"
-// CHECK-BE-HF64-32: "[[TC]]/mips32/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/mips32/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32"
+// CHECK-BE-HF64-32: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/mips32/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/mips32/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-32: "[[TC]]/mips32{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-32: "-L[[TC]]/mips32"
+// CHECK-BE-HF64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32"
+// CHECK-BE-HF64-32: "-L[[TC]]/../../../../sysroot/mips32/usr/lib/../lib"
+// CHECK-BE-HF64-32: "[[TC]]/mips32{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-32: "[[TC]]/../../../../sysroot/mips32/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -69,6 +71,7 @@
 // CHECK-BE-SF-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/sof"
+// CHECK-BE-SF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-32: "[[TC]]/../../../../sysroot/mips32/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-32: "[[TC]]/../../../../sysroot/mips32/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-32: "[[TC]]/mips32/sof{{/|\\\\}}crtbegin.o"
@@ -95,6 +98,7 @@
 // CHECK-BE-HF-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16"
+// CHECK-BE-HF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-16: "[[TC]]/../../../../sysroot/mips32/mips16/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-16: "[[TC]]/../../../../sysroot/mips32/mips16/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-16: "[[TC]]/mips32/mips16{{/|\\\\}}crtbegin.o"
@@ -112,7 +116,7 @@
 // CHECK-BE-HF64-16: "-internal-isystem"
 // CHECK-BE-HF64-16: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-16: "-internal-isystem"
-// CHECK-BE-HF64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/fp64"
+// CHECK-BE-HF64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16"
 // CHECK-BE-HF64-16: "-internal-isystem"
 // CHECK-BE-HF64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-16: "-internal-externc-isystem"
@@ -120,15 +124,16 @@
 // CHECK-BE-HF64-16: "-internal-externc-isystem"
 // CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-16: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/fp64"
-// CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-16: "[[TC]]/mips32/mips16/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-16: "-L[[TC]]/mips32/mips16/fp64"
-// CHECK-BE-HF64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/fp64"
-// CHECK-BE-HF64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/fp64/usr/lib/../lib"
-// CHECK-BE-HF64-16: "[[TC]]/mips32/mips16/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16"
+// CHECK-BE-HF64-16: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-16: "[[TC]]/mips32/mips16{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-16: "-L[[TC]]/mips32/mips16"
+// CHECK-BE-HF64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16"
+// CHECK-BE-HF64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/usr/lib/../lib"
+// CHECK-BE-HF64-16: "[[TC]]/mips32/mips16{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips16 / mips32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -147,6 +152,7 @@
 // CHECK-BE-SF-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/sof"
+// CHECK-BE-SF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-16: "[[TC]]/../../../../sysroot/mips32/mips16/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-16: "[[TC]]/../../../../sysroot/mips32/mips16/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-16: "[[TC]]/mips32/mips16/sof{{/|\\\\}}crtbegin.o"
@@ -173,6 +179,7 @@
 // CHECK-BE-NAN-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/nan2008"
+// CHECK-BE-NAN-16: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-16: "[[TC]]/../../../../sysroot/mips32/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-16: "[[TC]]/../../../../sysroot/mips32/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-16: "[[TC]]/mips32/mips16/nan2008{{/|\\\\}}crtbegin.o"
@@ -190,7 +197,7 @@
 // CHECK-BE-NAN64-16: "-internal-isystem"
 // CHECK-BE-NAN64-16: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-16: "-internal-isystem"
-// CHECK-BE-NAN64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/fp64/nan2008"
+// CHECK-BE-NAN64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/nan2008"
 // CHECK-BE-NAN64-16: "-internal-isystem"
 // CHECK-BE-NAN64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-16: "-internal-externc-isystem"
@@ -198,15 +205,16 @@
 // CHECK-BE-NAN64-16: "-internal-externc-isystem"
 // CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-16: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/fp64/nan2008"
-// CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-16: "[[TC]]/mips32/mips16/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-16: "-L[[TC]]/mips32/mips16/fp64/nan2008"
-// CHECK-BE-NAN64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/fp64/nan2008"
-// CHECK-BE-NAN64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/fp64/nan2008/usr/lib/../lib"
-// CHECK-BE-NAN64-16: "[[TC]]/mips32/mips16/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/nan2008"
+// CHECK-BE-NAN64-16: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-16: "[[TC]]/mips32/mips16/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-16: "-L[[TC]]/mips32/mips16/nan2008"
+// CHECK-BE-NAN64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/nan2008"
+// CHECK-BE-NAN64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/nan2008/usr/lib/../lib"
+// CHECK-BE-NAN64-16: "[[TC]]/mips32/mips16/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips32, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -225,6 +233,7 @@
 // CHECK-BE-NAN-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/nan2008"
+// CHECK-BE-NAN-32: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-32: "[[TC]]/../../../../sysroot/mips32/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-32: "[[TC]]/../../../../sysroot/mips32/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-32: "[[TC]]/mips32/nan2008{{/|\\\\}}crtbegin.o"
@@ -242,7 +251,7 @@
 // CHECK-BE-NAN64-32: "-internal-isystem"
 // CHECK-BE-NAN64-32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-32: "-internal-isystem"
-// CHECK-BE-NAN64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/fp64/nan2008"
+// CHECK-BE-NAN64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/nan2008"
 // CHECK-BE-NAN64-32: "-internal-isystem"
 // CHECK-BE-NAN64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-32: "-internal-externc-isystem"
@@ -250,15 +259,16 @@
 // CHECK-BE-NAN64-32: "-internal-externc-isystem"
 // CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/fp64/nan2008"
-// CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/mips32/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/mips32/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-32: "[[TC]]/mips32/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-32: "-L[[TC]]/mips32/fp64/nan2008"
-// CHECK-BE-NAN64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/fp64/nan2008"
-// CHECK-BE-NAN64-32: "-L[[TC]]/../../../../sysroot/mips32/fp64/nan2008/usr/lib/../lib"
-// CHECK-BE-NAN64-32: "[[TC]]/mips32/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/mips32/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/nan2008"
+// CHECK-BE-NAN64-32: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/mips32/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/mips32/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-32: "[[TC]]/mips32/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-32: "-L[[TC]]/mips32/nan2008"
+// CHECK-BE-NAN64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/nan2008"
+// CHECK-BE-NAN64-32: "-L[[TC]]/../../../../sysroot/mips32/nan2008/usr/lib/../lib"
+// CHECK-BE-NAN64-32: "[[TC]]/mips32/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-32: "[[TC]]/../../../../sysroot/mips32/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips32r2, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -277,6 +287,7 @@
 // CHECK-BE-HF-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-32R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-32R2: "--sysroot=[[TC]]/../../../../sysroot"
+// CHECK-BE-HF-32R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-32R2: "[[TC]]/../../../../sysroot/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-32R2: "[[TC]]/../../../../sysroot/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-32R2: "[[TC]]{{/|\\\\}}crtbegin.o"
@@ -286,6 +297,33 @@
 // CHECK-BE-HF-32R2: "[[TC]]{{/|\\\\}}crtend.o"
 // CHECK-BE-HF-32R2: "[[TC]]/../../../../sysroot/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Big-endian, mips32r2, hard float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -mips32r2 -mhard-float -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-UC-HF-32R2 %s
+// CHECK-BE-UC-HF-32R2: "-internal-isystem"
+// CHECK-BE-UC-HF-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-BE-UC-HF-32R2: "-internal-isystem"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc"
+// CHECK-BE-UC-HF-32R2: "-internal-isystem"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-BE-UC-HF-32R2: "-internal-externc-isystem"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/include"
+// CHECK-BE-UC-HF-32R2: "-internal-externc-isystem"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/include"
+// CHECK-BE-UC-HF-32R2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-UC-HF-32R2: "--sysroot=[[TC]]/../../../../sysroot/uclibc"
+// CHECK-BE-UC-HF-32R2: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/uclibc{{/|\\\\}}crtbegin.o"
+// CHECK-BE-UC-HF-32R2: "-L[[TC]]/uclibc"
+// CHECK-BE-UC-HF-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/uclibc"
+// CHECK-BE-UC-HF-32R2: "-L[[TC]]/../../../../sysroot/uclibc/usr/lib/../lib"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/uclibc{{/|\\\\}}crtend.o"
+// CHECK-BE-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Big-endian, mips32r2, fp64, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mips-linux-gnu -mips32r2 -mfp64 -mhard-float \
@@ -294,7 +332,7 @@
 // CHECK-BE-HF64-32R2: "-internal-isystem"
 // CHECK-BE-HF64-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-32R2: "-internal-isystem"
-// CHECK-BE-HF64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64"
+// CHECK-BE-HF64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu"
 // CHECK-BE-HF64-32R2: "-internal-isystem"
 // CHECK-BE-HF64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-32R2: "-internal-externc-isystem"
@@ -302,15 +340,16 @@
 // CHECK-BE-HF64-32R2: "-internal-externc-isystem"
 // CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-32R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-32R2: "--sysroot=[[TC]]/../../../../sysroot/fp64"
-// CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-32R2: "[[TC]]/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-32R2: "-L[[TC]]/fp64"
-// CHECK-BE-HF64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/fp64"
-// CHECK-BE-HF64-32R2: "-L[[TC]]/../../../../sysroot/fp64/usr/lib/../lib"
-// CHECK-BE-HF64-32R2: "[[TC]]/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-32R2: "--sysroot=[[TC]]/../../../../sysroot"
+// CHECK-BE-HF64-32R2: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-32R2: "[[TC]]{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-32R2: "-L[[TC]]"
+// CHECK-BE-HF64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib"
+// CHECK-BE-HF64-32R2: "-L[[TC]]/../../../../sysroot/usr/lib/../lib"
+// CHECK-BE-HF64-32R2: "[[TC]]{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-32R2: "[[TC]]/../../../../sysroot/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips32r2, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -329,6 +368,7 @@
 // CHECK-BE-SF-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-32R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-32R2: "--sysroot=[[TC]]/../../../../sysroot/sof"
+// CHECK-BE-SF-32R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-32R2: "[[TC]]/../../../../sysroot/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-32R2: "[[TC]]/../../../../sysroot/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-32R2: "[[TC]]/sof{{/|\\\\}}crtbegin.o"
@@ -338,6 +378,33 @@
 // CHECK-BE-SF-32R2: "[[TC]]/sof{{/|\\\\}}crtend.o"
 // CHECK-BE-SF-32R2: "[[TC]]/../../../../sysroot/sof/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Big-endian, mips32r2, soft float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -mips32r2 -msoft-float -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-UC-SF-32R2 %s
+// CHECK-BE-UC-SF-32R2: "-internal-isystem"
+// CHECK-BE-UC-SF-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-BE-UC-SF-32R2: "-internal-isystem"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/sof"
+// CHECK-BE-UC-SF-32R2: "-internal-isystem"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-BE-UC-SF-32R2: "-internal-externc-isystem"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/include"
+// CHECK-BE-UC-SF-32R2: "-internal-externc-isystem"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/include"
+// CHECK-BE-UC-SF-32R2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-UC-SF-32R2: "--sysroot=[[TC]]/../../../../sysroot/uclibc/sof"
+// CHECK-BE-UC-SF-32R2: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/sof/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/uclibc/sof{{/|\\\\}}crtbegin.o"
+// CHECK-BE-UC-SF-32R2: "-L[[TC]]/uclibc/sof"
+// CHECK-BE-UC-SF-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/uclibc/sof"
+// CHECK-BE-UC-SF-32R2: "-L[[TC]]/../../../../sysroot/uclibc/sof/usr/lib/../lib"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/uclibc/sof{{/|\\\\}}crtend.o"
+// CHECK-BE-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/sof/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Big-endian, mips32r2 / mips16, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mips-linux-gnu -mips32r2 -mips16 -mhard-float \
@@ -355,6 +422,7 @@
 // CHECK-BE-HF-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-16R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16"
+// CHECK-BE-HF-16R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-16R2: "[[TC]]/../../../../sysroot/mips16/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-16R2: "[[TC]]/../../../../sysroot/mips16/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-16R2: "[[TC]]/mips16{{/|\\\\}}crtbegin.o"
@@ -372,7 +440,7 @@
 // CHECK-BE-HF64-16R2: "-internal-isystem"
 // CHECK-BE-HF64-16R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-16R2: "-internal-isystem"
-// CHECK-BE-HF64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/fp64"
+// CHECK-BE-HF64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16"
 // CHECK-BE-HF64-16R2: "-internal-isystem"
 // CHECK-BE-HF64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-16R2: "-internal-externc-isystem"
@@ -380,15 +448,16 @@
 // CHECK-BE-HF64-16R2: "-internal-externc-isystem"
 // CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-16R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/fp64"
-// CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-16R2: "[[TC]]/mips16/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-16R2: "-L[[TC]]/mips16/fp64"
-// CHECK-BE-HF64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/fp64"
-// CHECK-BE-HF64-16R2: "-L[[TC]]/../../../../sysroot/mips16/fp64/usr/lib/../lib"
-// CHECK-BE-HF64-16R2: "[[TC]]/mips16/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16"
+// CHECK-BE-HF64-16R2: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-16R2: "[[TC]]/mips16{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-16R2: "-L[[TC]]/mips16"
+// CHECK-BE-HF64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16"
+// CHECK-BE-HF64-16R2: "-L[[TC]]/../../../../sysroot/mips16/usr/lib/../lib"
+// CHECK-BE-HF64-16R2: "[[TC]]/mips16{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips32r2 / mips16, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -407,6 +476,7 @@
 // CHECK-BE-SF-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-16R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/sof"
+// CHECK-BE-SF-16R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-16R2: "[[TC]]/../../../../sysroot/mips16/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-16R2: "[[TC]]/../../../../sysroot/mips16/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-16R2: "[[TC]]/mips16/sof{{/|\\\\}}crtbegin.o"
@@ -433,6 +503,7 @@
 // CHECK-BE-NAN-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-16R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/nan2008"
+// CHECK-BE-NAN-16R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-16R2: "[[TC]]/../../../../sysroot/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-16R2: "[[TC]]/../../../../sysroot/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-16R2: "[[TC]]/mips16/nan2008{{/|\\\\}}crtbegin.o"
@@ -450,7 +521,7 @@
 // CHECK-BE-NAN64-16R2: "-internal-isystem"
 // CHECK-BE-NAN64-16R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-16R2: "-internal-isystem"
-// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/fp64/nan2008"
+// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/nan2008"
 // CHECK-BE-NAN64-16R2: "-internal-isystem"
 // CHECK-BE-NAN64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-16R2: "-internal-externc-isystem"
@@ -458,15 +529,16 @@
 // CHECK-BE-NAN64-16R2: "-internal-externc-isystem"
 // CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-16R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/fp64/nan2008"
-// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-16R2: "[[TC]]/mips16/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-16R2: "-L[[TC]]/mips16/fp64/nan2008"
-// CHECK-BE-NAN64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/fp64/nan2008"
-// CHECK-BE-NAN64-16R2: "-L[[TC]]/../../../../sysroot/mips16/fp64/nan2008/usr/lib/../lib"
-// CHECK-BE-NAN64-16R2: "[[TC]]/mips16/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/nan2008"
+// CHECK-BE-NAN64-16R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-16R2: "[[TC]]/mips16/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-16R2: "-L[[TC]]/mips16/nan2008"
+// CHECK-BE-NAN64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/nan2008"
+// CHECK-BE-NAN64-16R2: "-L[[TC]]/../../../../sysroot/mips16/nan2008/usr/lib/../lib"
+// CHECK-BE-NAN64-16R2: "[[TC]]/mips16/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips32r2, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -485,6 +557,7 @@
 // CHECK-BE-NAN-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-32R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-32R2: "--sysroot=[[TC]]/../../../../sysroot/nan2008"
+// CHECK-BE-NAN-32R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-32R2: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-32R2: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-32R2: "[[TC]]/nan2008{{/|\\\\}}crtbegin.o"
@@ -494,6 +567,33 @@
 // CHECK-BE-NAN-32R2: "[[TC]]/nan2008{{/|\\\\}}crtend.o"
 // CHECK-BE-NAN-32R2: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Big-endian, mips32r2, nan2008, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -mips32r2 -mnan=2008 -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-UC-NAN-32R2 %s
+// CHECK-BE-UC-NAN-32R2: "-internal-isystem"
+// CHECK-BE-UC-NAN-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-BE-UC-NAN-32R2: "-internal-isystem"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/nan2008"
+// CHECK-BE-UC-NAN-32R2: "-internal-isystem"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-BE-UC-NAN-32R2: "-internal-externc-isystem"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/include"
+// CHECK-BE-UC-NAN-32R2: "-internal-externc-isystem"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/include"
+// CHECK-BE-UC-NAN-32R2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-UC-NAN-32R2: "--sysroot=[[TC]]/../../../../sysroot/uclibc/nan2008"
+// CHECK-BE-UC-NAN-32R2: "-dynamic-linker" "/lib/ld-uClibc-mipsn8.so.0"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/uclibc/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-UC-NAN-32R2: "-L[[TC]]/uclibc/nan2008"
+// CHECK-BE-UC-NAN-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/uclibc/nan2008"
+// CHECK-BE-UC-NAN-32R2: "-L[[TC]]/../../../../sysroot/uclibc/nan2008/usr/lib/../lib"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/uclibc/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Big-endian, mips32r2, fp64, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mips-linux-gnu -mips32r2 -mfp64 -mnan=2008 \
@@ -502,7 +602,7 @@
 // CHECK-BE-NAN64-32R2: "-internal-isystem"
 // CHECK-BE-NAN64-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-32R2: "-internal-isystem"
-// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/fp64/nan2008"
+// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/nan2008"
 // CHECK-BE-NAN64-32R2: "-internal-isystem"
 // CHECK-BE-NAN64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-32R2: "-internal-externc-isystem"
@@ -510,15 +610,43 @@
 // CHECK-BE-NAN64-32R2: "-internal-externc-isystem"
 // CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-32R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-32R2: "--sysroot=[[TC]]/../../../../sysroot/fp64/nan2008"
-// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-32R2: "[[TC]]/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-32R2: "-L[[TC]]/fp64/nan2008"
-// CHECK-BE-NAN64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/fp64/nan2008"
-// CHECK-BE-NAN64-32R2: "-L[[TC]]/../../../../sysroot/fp64/nan2008/usr/lib/../lib"
-// CHECK-BE-NAN64-32R2: "[[TC]]/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-32R2: "--sysroot=[[TC]]/../../../../sysroot/nan2008"
+// CHECK-BE-NAN64-32R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-32R2: "[[TC]]/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-32R2: "-L[[TC]]/nan2008"
+// CHECK-BE-NAN64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/nan2008"
+// CHECK-BE-NAN64-32R2: "-L[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib"
+// CHECK-BE-NAN64-32R2: "[[TC]]/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-32R2: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
+// = Big-endian, default (mips32r2), fp64, nan2008
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips-linux-gnu -mfp64 -mnan=2008 \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-NAN64-32R2-DEF %s
+// CHECK-BE-NAN64-32R2-DEF: "-internal-isystem"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-BE-NAN64-32R2-DEF: "-internal-isystem"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/nan2008"
+// CHECK-BE-NAN64-32R2-DEF: "-internal-isystem"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-BE-NAN64-32R2-DEF: "-internal-externc-isystem"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/include"
+// CHECK-BE-NAN64-32R2-DEF: "-internal-externc-isystem"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/usr/include"
+// CHECK-BE-NAN64-32R2-DEF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-NAN64-32R2-DEF: "--sysroot=[[TC]]/../../../../sysroot/nan2008"
+// CHECK-BE-NAN64-32R2-DEF: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-32R2-DEF: "-L[[TC]]/nan2008"
+// CHECK-BE-NAN64-32R2-DEF: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/nan2008"
+// CHECK-BE-NAN64-32R2-DEF: "-L[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, micromips, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -537,6 +665,7 @@
 // CHECK-BE-HF-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-MM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips"
+// CHECK-BE-HF-MM: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-HF-MM: "[[TC]]/../../../../sysroot/micromips/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-MM: "[[TC]]/../../../../sysroot/micromips/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-MM: "[[TC]]/micromips{{/|\\\\}}crtbegin.o"
@@ -554,7 +683,7 @@
 // CHECK-BE-HF64-MM: "-internal-isystem"
 // CHECK-BE-HF64-MM: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-MM: "-internal-isystem"
-// CHECK-BE-HF64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/fp64"
+// CHECK-BE-HF64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips"
 // CHECK-BE-HF64-MM: "-internal-isystem"
 // CHECK-BE-HF64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-MM: "-internal-externc-isystem"
@@ -562,15 +691,16 @@
 // CHECK-BE-HF64-MM: "-internal-externc-isystem"
 // CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-MM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/fp64"
-// CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/micromips/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/micromips/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-MM: "[[TC]]/micromips/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-MM: "-L[[TC]]/micromips/fp64"
-// CHECK-BE-HF64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/fp64"
-// CHECK-BE-HF64-MM: "-L[[TC]]/../../../../sysroot/micromips/fp64/usr/lib/../lib"
-// CHECK-BE-HF64-MM: "[[TC]]/micromips/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/micromips/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips"
+// CHECK-BE-HF64-MM: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/micromips/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/micromips/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-MM: "[[TC]]/micromips{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-MM: "-L[[TC]]/micromips"
+// CHECK-BE-HF64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips"
+// CHECK-BE-HF64-MM: "-L[[TC]]/../../../../sysroot/micromips/usr/lib/../lib"
+// CHECK-BE-HF64-MM: "[[TC]]/micromips{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-MM: "[[TC]]/../../../../sysroot/micromips/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, micromips, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -589,6 +719,7 @@
 // CHECK-BE-SF-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-MM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/sof"
+// CHECK-BE-SF-MM: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-BE-SF-MM: "[[TC]]/../../../../sysroot/micromips/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-MM: "[[TC]]/../../../../sysroot/micromips/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-MM: "[[TC]]/micromips/sof{{/|\\\\}}crtbegin.o"
@@ -615,6 +746,7 @@
 // CHECK-BE-NAN-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-MM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/nan2008"
+// CHECK-BE-NAN-MM: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-MM: "[[TC]]/../../../../sysroot/micromips/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-MM: "[[TC]]/../../../../sysroot/micromips/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-MM: "[[TC]]/micromips/nan2008{{/|\\\\}}crtbegin.o"
@@ -632,7 +764,7 @@
 // CHECK-BE-NAN64-MM: "-internal-isystem"
 // CHECK-BE-NAN64-MM: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-MM: "-internal-isystem"
-// CHECK-BE-NAN64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/fp64/nan2008"
+// CHECK-BE-NAN64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/nan2008"
 // CHECK-BE-NAN64-MM: "-internal-isystem"
 // CHECK-BE-NAN64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-MM: "-internal-externc-isystem"
@@ -640,15 +772,16 @@
 // CHECK-BE-NAN64-MM: "-internal-externc-isystem"
 // CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-MM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/fp64/nan2008"
-// CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-MM: "[[TC]]/micromips/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-MM: "-L[[TC]]/micromips/fp64/nan2008"
-// CHECK-BE-NAN64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/fp64/nan2008"
-// CHECK-BE-NAN64-MM: "-L[[TC]]/../../../../sysroot/micromips/fp64/nan2008/usr/lib/../lib"
-// CHECK-BE-NAN64-MM: "[[TC]]/micromips/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/nan2008"
+// CHECK-BE-NAN64-MM: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-MM: "[[TC]]/micromips/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-MM: "-L[[TC]]/micromips/nan2008"
+// CHECK-BE-NAN64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/nan2008"
+// CHECK-BE-NAN64-MM: "-L[[TC]]/../../../../sysroot/micromips/nan2008/usr/lib/../lib"
+// CHECK-BE-NAN64-MM: "[[TC]]/micromips/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64, ABI n32, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -667,6 +800,7 @@
 // CHECK-BE-HF-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-64-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64"
+// CHECK-BE-HF-64-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-BE-HF-64-N32: "[[TC]]/../../../../sysroot/mips64/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-64-N32: "[[TC]]/../../../../sysroot/mips64/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-64-N32: "[[TC]]/mips64{{/|\\\\}}crtbegin.o"
@@ -684,7 +818,7 @@
 // CHECK-BE-HF64-64-N32: "-internal-isystem"
 // CHECK-BE-HF64-64-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-64-N32: "-internal-isystem"
-// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/fp64"
+// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64"
 // CHECK-BE-HF64-64-N32: "-internal-isystem"
 // CHECK-BE-HF64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-64-N32: "-internal-externc-isystem"
@@ -692,15 +826,16 @@
 // CHECK-BE-HF64-64-N32: "-internal-externc-isystem"
 // CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-64-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/fp64"
-// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-64-N32: "[[TC]]/mips64/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-64-N32: "-L[[TC]]/mips64/fp64"
-// CHECK-BE-HF64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/fp64"
-// CHECK-BE-HF64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/fp64/usr/lib"
-// CHECK-BE-HF64-64-N32: "[[TC]]/mips64/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64"
+// CHECK-BE-HF64-64-N32: "-dynamic-linker" "/lib32/ld.so.1"
+// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-64-N32: "[[TC]]/mips64{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-64-N32: "-L[[TC]]/mips64"
+// CHECK-BE-HF64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64"
+// CHECK-BE-HF64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/usr/lib"
+// CHECK-BE-HF64-64-N32: "[[TC]]/mips64{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64, ABI n32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -719,6 +854,7 @@
 // CHECK-BE-SF-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-64-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/sof"
+// CHECK-BE-SF-64-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-BE-SF-64-N32: "[[TC]]/../../../../sysroot/mips64/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-64-N32: "[[TC]]/../../../../sysroot/mips64/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-64-N32: "[[TC]]/mips64/sof{{/|\\\\}}crtbegin.o"
@@ -745,6 +881,7 @@
 // CHECK-BE-NAN-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-64-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/nan2008"
+// CHECK-BE-NAN-64-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-64-N32: "[[TC]]/../../../../sysroot/mips64/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-64-N32: "[[TC]]/../../../../sysroot/mips64/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-64-N32: "[[TC]]/mips64/nan2008{{/|\\\\}}crtbegin.o"
@@ -762,7 +899,7 @@
 // CHECK-BE-NAN64-64-N32: "-internal-isystem"
 // CHECK-BE-NAN64-64-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-64-N32: "-internal-isystem"
-// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/fp64/nan2008"
+// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/nan2008"
 // CHECK-BE-NAN64-64-N32: "-internal-isystem"
 // CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-64-N32: "-internal-externc-isystem"
@@ -770,15 +907,16 @@
 // CHECK-BE-NAN64-64-N32: "-internal-externc-isystem"
 // CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-64-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/fp64/nan2008"
-// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-64-N32: "[[TC]]/mips64/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-64-N32: "-L[[TC]]/mips64/fp64/nan2008"
-// CHECK-BE-NAN64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/fp64/nan2008"
-// CHECK-BE-NAN64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/fp64/nan2008/usr/lib"
-// CHECK-BE-NAN64-64-N32: "[[TC]]/mips64/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/nan2008"
+// CHECK-BE-NAN64-64-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-64-N32: "[[TC]]/mips64/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-64-N32: "-L[[TC]]/mips64/nan2008"
+// CHECK-BE-NAN64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/nan2008"
+// CHECK-BE-NAN64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/nan2008/usr/lib"
+// CHECK-BE-NAN64-64-N32: "[[TC]]/mips64/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64, ABI 64, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -797,6 +935,7 @@
 // CHECK-BE-HF-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-64-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64"
+// CHECK-BE-HF-64-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-BE-HF-64-64: "[[TC]]/../../../../sysroot/mips64/64/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-64-64: "[[TC]]/../../../../sysroot/mips64/64/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-64-64: "[[TC]]/mips64/64{{/|\\\\}}crtbegin.o"
@@ -814,7 +953,7 @@
 // CHECK-BE-HF64-64-64: "-internal-isystem"
 // CHECK-BE-HF64-64-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-64-64: "-internal-isystem"
-// CHECK-BE-HF64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/fp64"
+// CHECK-BE-HF64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64"
 // CHECK-BE-HF64-64-64: "-internal-isystem"
 // CHECK-BE-HF64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-64-64: "-internal-externc-isystem"
@@ -822,15 +961,16 @@
 // CHECK-BE-HF64-64-64: "-internal-externc-isystem"
 // CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-64-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/fp64"
-// CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-64-64: "[[TC]]/mips64/64/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-64-64: "-L[[TC]]/mips64/64/fp64"
-// CHECK-BE-HF64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/fp64"
-// CHECK-BE-HF64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/fp64/usr/lib"
-// CHECK-BE-HF64-64-64: "[[TC]]/mips64/64/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64"
+// CHECK-BE-HF64-64-64: "-dynamic-linker" "/lib64/ld.so.1"
+// CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-64-64: "[[TC]]/mips64/64{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-64-64: "-L[[TC]]/mips64/64"
+// CHECK-BE-HF64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64"
+// CHECK-BE-HF64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/usr/lib"
+// CHECK-BE-HF64-64-64: "[[TC]]/mips64/64{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64, ABI 64, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -849,6 +989,7 @@
 // CHECK-BE-SF-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-64-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/sof"
+// CHECK-BE-SF-64-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-BE-SF-64-64: "[[TC]]/../../../../sysroot/mips64/64/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-64-64: "[[TC]]/../../../../sysroot/mips64/64/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-64-64: "[[TC]]/mips64/64/sof{{/|\\\\}}crtbegin.o"
@@ -875,6 +1016,7 @@
 // CHECK-BE-NAN-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-64-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/nan2008"
+// CHECK-BE-NAN-64-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-64-64: "[[TC]]/../../../../sysroot/mips64/64/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-64-64: "[[TC]]/../../../../sysroot/mips64/64/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-64-64: "[[TC]]/mips64/64/nan2008{{/|\\\\}}crtbegin.o"
@@ -892,7 +1034,7 @@
 // CHECK-BE-NAN64-64-64: "-internal-isystem"
 // CHECK-BE-NAN64-64-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-64-64: "-internal-isystem"
-// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/fp64/nan2008"
+// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/nan2008"
 // CHECK-BE-NAN64-64-64: "-internal-isystem"
 // CHECK-BE-NAN64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-64-64: "-internal-externc-isystem"
@@ -900,15 +1042,16 @@
 // CHECK-BE-NAN64-64-64: "-internal-externc-isystem"
 // CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-64-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/fp64/nan2008"
-// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-64-64: "[[TC]]/mips64/64/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-64-64: "-L[[TC]]/mips64/64/fp64/nan2008"
-// CHECK-BE-NAN64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/fp64/nan2008"
-// CHECK-BE-NAN64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/fp64/nan2008/usr/lib"
-// CHECK-BE-NAN64-64-64: "[[TC]]/mips64/64/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/nan2008"
+// CHECK-BE-NAN64-64-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-64-64: "[[TC]]/mips64/64/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-64-64: "-L[[TC]]/mips64/64/nan2008"
+// CHECK-BE-NAN64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/nan2008"
+// CHECK-BE-NAN64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/nan2008/usr/lib"
+// CHECK-BE-NAN64-64-64: "[[TC]]/mips64/64/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64r2, ABI n32, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -927,6 +1070,7 @@
 // CHECK-BE-HF-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-64R2-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2"
+// CHECK-BE-HF-64R2-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-BE-HF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-64R2-N32: "[[TC]]/mips64r2{{/|\\\\}}crtbegin.o"
@@ -944,7 +1088,7 @@
 // CHECK-BE-HF64-64R2-N32: "-internal-isystem"
 // CHECK-BE-HF64-64R2-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-64R2-N32: "-internal-isystem"
-// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/fp64"
+// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2"
 // CHECK-BE-HF64-64R2-N32: "-internal-isystem"
 // CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-64R2-N32: "-internal-externc-isystem"
@@ -952,15 +1096,16 @@
 // CHECK-BE-HF64-64R2-N32: "-internal-externc-isystem"
 // CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-64R2-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/fp64"
-// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-64R2-N32: "[[TC]]/mips64r2/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-64R2-N32: "-L[[TC]]/mips64r2/fp64"
-// CHECK-BE-HF64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/fp64"
-// CHECK-BE-HF64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/fp64/usr/lib"
-// CHECK-BE-HF64-64R2-N32: "[[TC]]/mips64r2/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2"
+// CHECK-BE-HF64-64R2-N32: "-dynamic-linker" "/lib32/ld.so.1"
+// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-64R2-N32: "[[TC]]/mips64r2{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-64R2-N32: "-L[[TC]]/mips64r2"
+// CHECK-BE-HF64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2"
+// CHECK-BE-HF64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/usr/lib"
+// CHECK-BE-HF64-64R2-N32: "[[TC]]/mips64r2{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64r2, ABI n32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -979,6 +1124,7 @@
 // CHECK-BE-SF-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-64R2-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/sof"
+// CHECK-BE-SF-64R2-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-BE-SF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-64R2-N32: "[[TC]]/mips64r2/sof{{/|\\\\}}crtbegin.o"
@@ -1005,6 +1151,7 @@
 // CHECK-BE-NAN-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-64R2-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/nan2008"
+// CHECK-BE-NAN-64R2-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-64R2-N32: "[[TC]]/mips64r2/nan2008{{/|\\\\}}crtbegin.o"
@@ -1022,7 +1169,7 @@
 // CHECK-BE-NAN64-64R2-N32: "-internal-isystem"
 // CHECK-BE-NAN64-64R2-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-64R2-N32: "-internal-isystem"
-// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/fp64/nan2008"
+// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/nan2008"
 // CHECK-BE-NAN64-64R2-N32: "-internal-isystem"
 // CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-64R2-N32: "-internal-externc-isystem"
@@ -1030,15 +1177,16 @@
 // CHECK-BE-NAN64-64R2-N32: "-internal-externc-isystem"
 // CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-64R2-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/fp64/nan2008"
-// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-64R2-N32: "[[TC]]/mips64r2/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-64R2-N32: "-L[[TC]]/mips64r2/fp64/nan2008"
-// CHECK-BE-NAN64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/fp64/nan2008"
-// CHECK-BE-NAN64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/fp64/nan2008/usr/lib"
-// CHECK-BE-NAN64-64R2-N32: "[[TC]]/mips64r2/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/nan2008"
+// CHECK-BE-NAN64-64R2-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-64R2-N32: "[[TC]]/mips64r2/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-64R2-N32: "-L[[TC]]/mips64r2/nan2008"
+// CHECK-BE-NAN64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/nan2008"
+// CHECK-BE-NAN64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/nan2008/usr/lib"
+// CHECK-BE-NAN64-64R2-N32: "[[TC]]/mips64r2/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64r2, ABI 64, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1057,6 +1205,7 @@
 // CHECK-BE-HF-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF-64R2-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-HF-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64"
+// CHECK-BE-HF-64R2-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-BE-HF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-HF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-HF-64R2-64: "[[TC]]/mips64r2/64{{/|\\\\}}crtbegin.o"
@@ -1074,7 +1223,7 @@
 // CHECK-BE-HF64-64R2-64: "-internal-isystem"
 // CHECK-BE-HF64-64R2-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-HF64-64R2-64: "-internal-isystem"
-// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/fp64"
+// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64"
 // CHECK-BE-HF64-64R2-64: "-internal-isystem"
 // CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-HF64-64R2-64: "-internal-externc-isystem"
@@ -1082,15 +1231,16 @@
 // CHECK-BE-HF64-64R2-64: "-internal-externc-isystem"
 // CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-HF64-64R2-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-HF64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/fp64"
-// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-HF64-64R2-64: "[[TC]]/mips64r2/64/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-BE-HF64-64R2-64: "-L[[TC]]/mips64r2/64/fp64"
-// CHECK-BE-HF64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/fp64"
-// CHECK-BE-HF64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/fp64/usr/lib"
-// CHECK-BE-HF64-64R2-64: "[[TC]]/mips64r2/64/fp64{{/|\\\\}}crtend.o"
-// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-HF64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64"
+// CHECK-BE-HF64-64R2-64: "-dynamic-linker" "/lib64/ld.so.1"
+// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-HF64-64R2-64: "[[TC]]/mips64r2/64{{/|\\\\}}crtbegin.o"
+// CHECK-BE-HF64-64R2-64: "-L[[TC]]/mips64r2/64"
+// CHECK-BE-HF64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64"
+// CHECK-BE-HF64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/usr/lib"
+// CHECK-BE-HF64-64R2-64: "[[TC]]/mips64r2/64{{/|\\\\}}crtend.o"
+// CHECK-BE-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Big-endian, mips64r2, ABI 64, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1109,6 +1259,7 @@
 // CHECK-BE-SF-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-SF-64R2-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-SF-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/sof"
+// CHECK-BE-SF-64R2-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-BE-SF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-SF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-SF-64R2-64: "[[TC]]/mips64r2/64/sof{{/|\\\\}}crtbegin.o"
@@ -1135,6 +1286,7 @@
 // CHECK-BE-NAN-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN-64R2-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-BE-NAN-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/nan2008"
+// CHECK-BE-NAN-64R2-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
 // CHECK-BE-NAN-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-BE-NAN-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-BE-NAN-64R2-64: "[[TC]]/mips64r2/64/nan2008{{/|\\\\}}crtbegin.o"
@@ -1152,7 +1304,7 @@
 // CHECK-BE-NAN64-64R2-64: "-internal-isystem"
 // CHECK-BE-NAN64-64R2-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-BE-NAN64-64R2-64: "-internal-isystem"
-// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/fp64/nan2008"
+// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/nan2008"
 // CHECK-BE-NAN64-64R2-64: "-internal-isystem"
 // CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-BE-NAN64-64R2-64: "-internal-externc-isystem"
@@ -1160,15 +1312,43 @@
 // CHECK-BE-NAN64-64R2-64: "-internal-externc-isystem"
 // CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-BE-NAN64-64R2-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-BE-NAN64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/fp64/nan2008"
-// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-BE-NAN64-64R2-64: "[[TC]]/mips64r2/64/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-BE-NAN64-64R2-64: "-L[[TC]]/mips64r2/64/fp64/nan2008"
-// CHECK-BE-NAN64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/fp64/nan2008"
-// CHECK-BE-NAN64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/fp64/nan2008/usr/lib"
-// CHECK-BE-NAN64-64R2-64: "[[TC]]/mips64r2/64/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-BE-NAN64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-64R2-64: "[[TC]]/mips64r2/64/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-64R2-64: "-L[[TC]]/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib"
+// CHECK-BE-NAN64-64R2-64: "[[TC]]/mips64r2/64/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+//
+// = Big-endian, default (mips64r2), ABI 64, fp64, nan2008
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips64-linux-gnu -mabi=64 -mfp64 -mnan=2008 \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BE-NAN64-64R2-64-DEF %s
+// CHECK-BE-NAN64-64R2-64-DEF: "-internal-isystem"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-BE-NAN64-64R2-64-DEF: "-internal-isystem"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64-DEF: "-internal-isystem"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-BE-NAN64-64R2-64-DEF: "-internal-externc-isystem"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/include"
+// CHECK-BE-NAN64-64R2-64-DEF: "-internal-externc-isystem"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/usr/include"
+// CHECK-BE-NAN64-64R2-64-DEF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BE-NAN64-64R2-64-DEF: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64-DEF: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/mips64r2/64/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-BE-NAN64-64R2-64-DEF: "-L[[TC]]/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64-DEF: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/nan2008"
+// CHECK-BE-NAN64-64R2-64-DEF: "-L[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/mips64r2/64/nan2008{{/|\\\\}}crtend.o"
+// CHECK-BE-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/mips64r2/64/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1187,6 +1367,7 @@
 // CHECK-EL-HF-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el"
+// CHECK-EL-HF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-32: "[[TC]]/../../../../sysroot/mips32/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-32: "[[TC]]/../../../../sysroot/mips32/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-32: "[[TC]]/mips32/el{{/|\\\\}}crtbegin.o"
@@ -1204,7 +1385,7 @@
 // CHECK-EL-HF64-32: "-internal-isystem"
 // CHECK-EL-HF64-32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-32: "-internal-isystem"
-// CHECK-EL-HF64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el/fp64"
+// CHECK-EL-HF64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el"
 // CHECK-EL-HF64-32: "-internal-isystem"
 // CHECK-EL-HF64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-32: "-internal-externc-isystem"
@@ -1212,15 +1393,16 @@
 // CHECK-EL-HF64-32: "-internal-externc-isystem"
 // CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el/fp64"
-// CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/mips32/el/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/mips32/el/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-32: "[[TC]]/mips32/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-32: "-L[[TC]]/mips32/el/fp64"
-// CHECK-EL-HF64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/el/fp64"
-// CHECK-EL-HF64-32: "-L[[TC]]/../../../../sysroot/mips32/el/fp64/usr/lib/../lib"
-// CHECK-EL-HF64-32: "[[TC]]/mips32/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/mips32/el/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el"
+// CHECK-EL-HF64-32: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/mips32/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/mips32/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-32: "[[TC]]/mips32/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-32: "-L[[TC]]/mips32/el"
+// CHECK-EL-HF64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/el"
+// CHECK-EL-HF64-32: "-L[[TC]]/../../../../sysroot/mips32/el/usr/lib/../lib"
+// CHECK-EL-HF64-32: "[[TC]]/mips32/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-32: "[[TC]]/../../../../sysroot/mips32/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1239,6 +1421,7 @@
 // CHECK-EL-SF-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el/sof"
+// CHECK-EL-SF-32: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-32: "[[TC]]/../../../../sysroot/mips32/el/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-32: "[[TC]]/../../../../sysroot/mips32/el/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-32: "[[TC]]/mips32/el/sof{{/|\\\\}}crtbegin.o"
@@ -1265,6 +1448,7 @@
 // CHECK-EL-HF-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el"
+// CHECK-EL-HF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-16: "[[TC]]/mips32/mips16/el{{/|\\\\}}crtbegin.o"
@@ -1282,7 +1466,7 @@
 // CHECK-EL-HF64-16: "-internal-isystem"
 // CHECK-EL-HF64-16: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-16: "-internal-isystem"
-// CHECK-EL-HF64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/el/fp64"
+// CHECK-EL-HF64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/el"
 // CHECK-EL-HF64-16: "-internal-isystem"
 // CHECK-EL-HF64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-16: "-internal-externc-isystem"
@@ -1290,15 +1474,16 @@
 // CHECK-EL-HF64-16: "-internal-externc-isystem"
 // CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-16: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el/fp64"
-// CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-16: "[[TC]]/mips32/mips16/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-16: "-L[[TC]]/mips32/mips16/el/fp64"
-// CHECK-EL-HF64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/el/fp64"
-// CHECK-EL-HF64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/usr/lib/../lib"
-// CHECK-EL-HF64-16: "[[TC]]/mips32/mips16/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el"
+// CHECK-EL-HF64-16: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-16: "[[TC]]/mips32/mips16/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-16: "-L[[TC]]/mips32/mips16/el"
+// CHECK-EL-HF64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/el"
+// CHECK-EL-HF64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/el/usr/lib/../lib"
+// CHECK-EL-HF64-16: "[[TC]]/mips32/mips16/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32 / mips16, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1317,6 +1502,7 @@
 // CHECK-EL-SF-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el/sof"
+// CHECK-EL-SF-16: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-16: "[[TC]]/mips32/mips16/el/sof{{/|\\\\}}crtbegin.o"
@@ -1343,6 +1529,7 @@
 // CHECK-EL-NAN-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-16: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008"
+// CHECK-EL-NAN-16: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-16: "[[TC]]/mips32/mips16/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -1360,7 +1547,7 @@
 // CHECK-EL-NAN64-16: "-internal-isystem"
 // CHECK-EL-NAN64-16: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-16: "-internal-isystem"
-// CHECK-EL-NAN64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/el/fp64/nan2008"
+// CHECK-EL-NAN64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/mips16/el/nan2008"
 // CHECK-EL-NAN64-16: "-internal-isystem"
 // CHECK-EL-NAN64-16: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-16: "-internal-externc-isystem"
@@ -1368,15 +1555,16 @@
 // CHECK-EL-NAN64-16: "-internal-externc-isystem"
 // CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-16: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/nan2008"
-// CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-16: "[[TC]]/mips32/mips16/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-16: "-L[[TC]]/mips32/mips16/el/fp64/nan2008"
-// CHECK-EL-NAN64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/el/fp64/nan2008"
-// CHECK-EL-NAN64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/../lib"
-// CHECK-EL-NAN64-16: "[[TC]]/mips32/mips16/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-16: "--sysroot=[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008"
+// CHECK-EL-NAN64-16: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-16: "[[TC]]/mips32/mips16/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-16: "-L[[TC]]/mips32/mips16/el/nan2008"
+// CHECK-EL-NAN64-16: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/mips16/el/nan2008"
+// CHECK-EL-NAN64-16: "-L[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008/usr/lib/../lib"
+// CHECK-EL-NAN64-16: "[[TC]]/mips32/mips16/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-16: "[[TC]]/../../../../sysroot/mips32/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1395,6 +1583,7 @@
 // CHECK-EL-NAN-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el/nan2008"
+// CHECK-EL-NAN-32: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-32: "[[TC]]/../../../../sysroot/mips32/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-32: "[[TC]]/../../../../sysroot/mips32/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-32: "[[TC]]/mips32/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -1412,7 +1601,7 @@
 // CHECK-EL-NAN64-32: "-internal-isystem"
 // CHECK-EL-NAN64-32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-32: "-internal-isystem"
-// CHECK-EL-NAN64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el/fp64/nan2008"
+// CHECK-EL-NAN64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips32/el/nan2008"
 // CHECK-EL-NAN64-32: "-internal-isystem"
 // CHECK-EL-NAN64-32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-32: "-internal-externc-isystem"
@@ -1420,15 +1609,16 @@
 // CHECK-EL-NAN64-32: "-internal-externc-isystem"
 // CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el/fp64/nan2008"
-// CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/mips32/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/mips32/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-32: "[[TC]]/mips32/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-32: "-L[[TC]]/mips32/el/fp64/nan2008"
-// CHECK-EL-NAN64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/el/fp64/nan2008"
-// CHECK-EL-NAN64-32: "-L[[TC]]/../../../../sysroot/mips32/el/fp64/nan2008/usr/lib/../lib"
-// CHECK-EL-NAN64-32: "[[TC]]/mips32/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/mips32/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-32: "--sysroot=[[TC]]/../../../../sysroot/mips32/el/nan2008"
+// CHECK-EL-NAN64-32: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/mips32/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/mips32/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-32: "[[TC]]/mips32/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-32: "-L[[TC]]/mips32/el/nan2008"
+// CHECK-EL-NAN64-32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips32/el/nan2008"
+// CHECK-EL-NAN64-32: "-L[[TC]]/../../../../sysroot/mips32/el/nan2008/usr/lib/../lib"
+// CHECK-EL-NAN64-32: "[[TC]]/mips32/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-32: "[[TC]]/../../../../sysroot/mips32/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32r2, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1447,6 +1637,7 @@
 // CHECK-EL-HF-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-32R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-32R2: "--sysroot=[[TC]]/../../../../sysroot/el"
+// CHECK-EL-HF-32R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-32R2: "[[TC]]/../../../../sysroot/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-32R2: "[[TC]]/../../../../sysroot/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-32R2: "[[TC]]/el{{/|\\\\}}crtbegin.o"
@@ -1456,6 +1647,33 @@
 // CHECK-EL-HF-32R2: "[[TC]]/el{{/|\\\\}}crtend.o"
 // CHECK-EL-HF-32R2: "[[TC]]/../../../../sysroot/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Little-endian, mips32r2, hard float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -mips32r2 -mhard-float -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-UC-HF-32R2 %s
+// CHECK-EL-UC-HF-32R2: "-internal-isystem"
+// CHECK-EL-UC-HF-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-EL-UC-HF-32R2: "-internal-isystem"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el"
+// CHECK-EL-UC-HF-32R2: "-internal-isystem"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-EL-UC-HF-32R2: "-internal-externc-isystem"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/include"
+// CHECK-EL-UC-HF-32R2: "-internal-externc-isystem"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/include"
+// CHECK-EL-UC-HF-32R2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-UC-HF-32R2: "--sysroot=[[TC]]/../../../../sysroot/uclibc/el"
+// CHECK-EL-UC-HF-32R2: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/uclibc/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-UC-HF-32R2: "-L[[TC]]/uclibc/el"
+// CHECK-EL-UC-HF-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/uclibc/el"
+// CHECK-EL-UC-HF-32R2: "-L[[TC]]/../../../../sysroot/uclibc/el/usr/lib/../lib"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/uclibc/el{{/|\\\\}}crtend.o"
+// CHECK-EL-UC-HF-32R2: "[[TC]]/../../../../sysroot/uclibc/el/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Little-endian, mips32r2, fp64, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mipsel-linux-gnu -mips32r2 -mfp64 -mhard-float \
@@ -1464,7 +1682,7 @@
 // CHECK-EL-HF64-32R2: "-internal-isystem"
 // CHECK-EL-HF64-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-32R2: "-internal-isystem"
-// CHECK-EL-HF64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64"
+// CHECK-EL-HF64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el"
 // CHECK-EL-HF64-32R2: "-internal-isystem"
 // CHECK-EL-HF64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-32R2: "-internal-externc-isystem"
@@ -1472,15 +1690,16 @@
 // CHECK-EL-HF64-32R2: "-internal-externc-isystem"
 // CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-32R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-32R2: "--sysroot=[[TC]]/../../../../sysroot/el/fp64"
-// CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/el/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/el/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-32R2: "[[TC]]/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-32R2: "-L[[TC]]/el/fp64"
-// CHECK-EL-HF64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/el/fp64"
-// CHECK-EL-HF64-32R2: "-L[[TC]]/../../../../sysroot/el/fp64/usr/lib/../lib"
-// CHECK-EL-HF64-32R2: "[[TC]]/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/el/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-32R2: "--sysroot=[[TC]]/../../../../sysroot/el"
+// CHECK-EL-HF64-32R2: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-32R2: "[[TC]]/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-32R2: "-L[[TC]]/el"
+// CHECK-EL-HF64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/el"
+// CHECK-EL-HF64-32R2: "-L[[TC]]/../../../../sysroot/el/usr/lib/../lib"
+// CHECK-EL-HF64-32R2: "[[TC]]/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-32R2: "[[TC]]/../../../../sysroot/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32r2, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1499,6 +1718,7 @@
 // CHECK-EL-SF-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-32R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-32R2: "--sysroot=[[TC]]/../../../../sysroot/el/sof"
+// CHECK-EL-SF-32R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-32R2: "[[TC]]/../../../../sysroot/el/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-32R2: "[[TC]]/../../../../sysroot/el/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-32R2: "[[TC]]/el/sof{{/|\\\\}}crtbegin.o"
@@ -1508,6 +1728,33 @@
 // CHECK-EL-SF-32R2: "[[TC]]/el/sof{{/|\\\\}}crtend.o"
 // CHECK-EL-SF-32R2: "[[TC]]/../../../../sysroot/el/sof/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Little-endian, mips32r2, soft float, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -mips32r2 -msoft-float -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-UC-SF-32R2 %s
+// CHECK-EL-UC-SF-32R2: "-internal-isystem"
+// CHECK-EL-UC-SF-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-EL-UC-SF-32R2: "-internal-isystem"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el/sof"
+// CHECK-EL-UC-SF-32R2: "-internal-isystem"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-EL-UC-SF-32R2: "-internal-externc-isystem"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/include"
+// CHECK-EL-UC-SF-32R2: "-internal-externc-isystem"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/include"
+// CHECK-EL-UC-SF-32R2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-UC-SF-32R2: "--sysroot=[[TC]]/../../../../sysroot/uclibc/el/sof"
+// CHECK-EL-UC-SF-32R2: "-dynamic-linker" "/lib/ld-uClibc.so.0"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/el/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/el/sof/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/uclibc/el/sof{{/|\\\\}}crtbegin.o"
+// CHECK-EL-UC-SF-32R2: "-L[[TC]]/uclibc/el/sof"
+// CHECK-EL-UC-SF-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/uclibc/el/sof"
+// CHECK-EL-UC-SF-32R2: "-L[[TC]]/../../../../sysroot/uclibc/el/sof/usr/lib/../lib"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/uclibc/el/sof{{/|\\\\}}crtend.o"
+// CHECK-EL-UC-SF-32R2: "[[TC]]/../../../../sysroot/uclibc/el/sof/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Little-endian, mips32r2 / mips16, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mipsel-linux-gnu -mips32r2 -mips16 -mhard-float \
@@ -1525,6 +1772,7 @@
 // CHECK-EL-HF-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-16R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el"
+// CHECK-EL-HF-16R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-16R2: "[[TC]]/../../../../sysroot/mips16/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-16R2: "[[TC]]/../../../../sysroot/mips16/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-16R2: "[[TC]]/mips16/el{{/|\\\\}}crtbegin.o"
@@ -1542,7 +1790,7 @@
 // CHECK-EL-HF64-16R2: "-internal-isystem"
 // CHECK-EL-HF64-16R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-16R2: "-internal-isystem"
-// CHECK-EL-HF64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el/fp64"
+// CHECK-EL-HF64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el"
 // CHECK-EL-HF64-16R2: "-internal-isystem"
 // CHECK-EL-HF64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-16R2: "-internal-externc-isystem"
@@ -1550,15 +1798,16 @@
 // CHECK-EL-HF64-16R2: "-internal-externc-isystem"
 // CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-16R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el/fp64"
-// CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/el/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/el/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-16R2: "[[TC]]/mips16/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-16R2: "-L[[TC]]/mips16/el/fp64"
-// CHECK-EL-HF64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/el/fp64"
-// CHECK-EL-HF64-16R2: "-L[[TC]]/../../../../sysroot/mips16/el/fp64/usr/lib/../lib"
-// CHECK-EL-HF64-16R2: "[[TC]]/mips16/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/el/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el"
+// CHECK-EL-HF64-16R2: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-16R2: "[[TC]]/mips16/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-16R2: "-L[[TC]]/mips16/el"
+// CHECK-EL-HF64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/el"
+// CHECK-EL-HF64-16R2: "-L[[TC]]/../../../../sysroot/mips16/el/usr/lib/../lib"
+// CHECK-EL-HF64-16R2: "[[TC]]/mips16/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-16R2: "[[TC]]/../../../../sysroot/mips16/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32r2 / mips16, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1577,6 +1826,7 @@
 // CHECK-EL-SF-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-16R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el/sof"
+// CHECK-EL-SF-16R2: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-16R2: "[[TC]]/../../../../sysroot/mips16/el/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-16R2: "[[TC]]/../../../../sysroot/mips16/el/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-16R2: "[[TC]]/mips16/el/sof{{/|\\\\}}crtbegin.o"
@@ -1603,6 +1853,7 @@
 // CHECK-EL-NAN-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-16R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el/nan2008"
+// CHECK-EL-NAN-16R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-16R2: "[[TC]]/../../../../sysroot/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-16R2: "[[TC]]/../../../../sysroot/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-16R2: "[[TC]]/mips16/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -1620,7 +1871,7 @@
 // CHECK-EL-NAN64-16R2: "-internal-isystem"
 // CHECK-EL-NAN64-16R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-16R2: "-internal-isystem"
-// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el/fp64/nan2008"
+// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips16/el/nan2008"
 // CHECK-EL-NAN64-16R2: "-internal-isystem"
 // CHECK-EL-NAN64-16R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-16R2: "-internal-externc-isystem"
@@ -1628,15 +1879,16 @@
 // CHECK-EL-NAN64-16R2: "-internal-externc-isystem"
 // CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-16R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el/fp64/nan2008"
-// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-16R2: "[[TC]]/mips16/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-16R2: "-L[[TC]]/mips16/el/fp64/nan2008"
-// CHECK-EL-NAN64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/el/fp64/nan2008"
-// CHECK-EL-NAN64-16R2: "-L[[TC]]/../../../../sysroot/mips16/el/fp64/nan2008/usr/lib/../lib"
-// CHECK-EL-NAN64-16R2: "[[TC]]/mips16/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-16R2: "--sysroot=[[TC]]/../../../../sysroot/mips16/el/nan2008"
+// CHECK-EL-NAN64-16R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-16R2: "[[TC]]/mips16/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-16R2: "-L[[TC]]/mips16/el/nan2008"
+// CHECK-EL-NAN64-16R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/mips16/el/nan2008"
+// CHECK-EL-NAN64-16R2: "-L[[TC]]/../../../../sysroot/mips16/el/nan2008/usr/lib/../lib"
+// CHECK-EL-NAN64-16R2: "[[TC]]/mips16/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-16R2: "[[TC]]/../../../../sysroot/mips16/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips32r2, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1655,6 +1907,7 @@
 // CHECK-EL-NAN-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-32R2: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-32R2: "--sysroot=[[TC]]/../../../../sysroot/el/nan2008"
+// CHECK-EL-NAN-32R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-32R2: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-32R2: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-32R2: "[[TC]]/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -1664,6 +1917,33 @@
 // CHECK-EL-NAN-32R2: "[[TC]]/el/nan2008{{/|\\\\}}crtend.o"
 // CHECK-EL-NAN-32R2: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
+// = Little-endian, mips32r2, nan2008, uclibc
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -mips32r2 -mnan=2008 -muclibc \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-UC-NAN-32R2 %s
+// CHECK-EL-UC-NAN-32R2: "-internal-isystem"
+// CHECK-EL-UC-NAN-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-EL-UC-NAN-32R2: "-internal-isystem"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/uclibc/el/nan2008"
+// CHECK-EL-UC-NAN-32R2: "-internal-isystem"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-EL-UC-NAN-32R2: "-internal-externc-isystem"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/include"
+// CHECK-EL-UC-NAN-32R2: "-internal-externc-isystem"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/usr/include"
+// CHECK-EL-UC-NAN-32R2: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-UC-NAN-32R2: "--sysroot=[[TC]]/../../../../sysroot/uclibc/el/nan2008"
+// CHECK-EL-UC-NAN-32R2: "-dynamic-linker" "/lib/ld-uClibc-mipsn8.so.0"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/uclibc/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-UC-NAN-32R2: "-L[[TC]]/uclibc/el/nan2008"
+// CHECK-EL-UC-NAN-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/uclibc/el/nan2008"
+// CHECK-EL-UC-NAN-32R2: "-L[[TC]]/../../../../sysroot/uclibc/el/nan2008/usr/lib/../lib"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/uclibc/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-UC-NAN-32R2: "[[TC]]/../../../../sysroot/uclibc/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
 // = Little-endian, mips32r2, fp64, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     --target=mipsel-linux-gnu -mips32r2 -mfp64 -mnan=2008 \
@@ -1672,7 +1952,7 @@
 // CHECK-EL-NAN64-32R2: "-internal-isystem"
 // CHECK-EL-NAN64-32R2: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-32R2: "-internal-isystem"
-// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/fp64/nan2008"
+// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/nan2008"
 // CHECK-EL-NAN64-32R2: "-internal-isystem"
 // CHECK-EL-NAN64-32R2: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-32R2: "-internal-externc-isystem"
@@ -1680,15 +1960,43 @@
 // CHECK-EL-NAN64-32R2: "-internal-externc-isystem"
 // CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-32R2: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-32R2: "--sysroot=[[TC]]/../../../../sysroot/el/fp64/nan2008"
-// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-32R2: "[[TC]]/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-32R2: "-L[[TC]]/el/fp64/nan2008"
-// CHECK-EL-NAN64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/el/fp64/nan2008"
-// CHECK-EL-NAN64-32R2: "-L[[TC]]/../../../../sysroot/el/fp64/nan2008/usr/lib/../lib"
-// CHECK-EL-NAN64-32R2: "[[TC]]/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-32R2: "--sysroot=[[TC]]/../../../../sysroot/el/nan2008"
+// CHECK-EL-NAN64-32R2: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-32R2: "[[TC]]/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-32R2: "-L[[TC]]/el/nan2008"
+// CHECK-EL-NAN64-32R2: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/el/nan2008"
+// CHECK-EL-NAN64-32R2: "-L[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib"
+// CHECK-EL-NAN64-32R2: "[[TC]]/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-32R2: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+//
+// = Little-endian, default (mips32r2), fp64, nan2008
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mipsel-linux-gnu -mfp64 -mnan=2008 \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-NAN64-32R2-DEF %s
+// CHECK-EL-NAN64-32R2-DEF: "-internal-isystem"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-EL-NAN64-32R2-DEF: "-internal-isystem"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/el/nan2008"
+// CHECK-EL-NAN64-32R2-DEF: "-internal-isystem"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-EL-NAN64-32R2-DEF: "-internal-externc-isystem"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/include"
+// CHECK-EL-NAN64-32R2-DEF: "-internal-externc-isystem"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/usr/include"
+// CHECK-EL-NAN64-32R2-DEF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-NAN64-32R2-DEF: "--sysroot=[[TC]]/../../../../sysroot/el/nan2008"
+// CHECK-EL-NAN64-32R2-DEF: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-32R2-DEF: "-L[[TC]]/el/nan2008"
+// CHECK-EL-NAN64-32R2-DEF: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/el/nan2008"
+// CHECK-EL-NAN64-32R2-DEF: "-L[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-32R2-DEF: "[[TC]]/../../../../sysroot/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, micromips, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1707,6 +2015,7 @@
 // CHECK-EL-HF-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-MM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el"
+// CHECK-EL-HF-MM: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-HF-MM: "[[TC]]/../../../../sysroot/micromips/el/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-MM: "[[TC]]/../../../../sysroot/micromips/el/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-MM: "[[TC]]/micromips/el{{/|\\\\}}crtbegin.o"
@@ -1724,7 +2033,7 @@
 // CHECK-EL-HF64-MM: "-internal-isystem"
 // CHECK-EL-HF64-MM: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-MM: "-internal-isystem"
-// CHECK-EL-HF64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el/fp64"
+// CHECK-EL-HF64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el"
 // CHECK-EL-HF64-MM: "-internal-isystem"
 // CHECK-EL-HF64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-MM: "-internal-externc-isystem"
@@ -1732,15 +2041,16 @@
 // CHECK-EL-HF64-MM: "-internal-externc-isystem"
 // CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-MM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el/fp64"
-// CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/micromips/el/fp64/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/micromips/el/fp64/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-MM: "[[TC]]/micromips/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-MM: "-L[[TC]]/micromips/el/fp64"
-// CHECK-EL-HF64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/el/fp64"
-// CHECK-EL-HF64-MM: "-L[[TC]]/../../../../sysroot/micromips/el/fp64/usr/lib/../lib"
-// CHECK-EL-HF64-MM: "[[TC]]/micromips/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/micromips/el/fp64/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el"
+// CHECK-EL-HF64-MM: "-dynamic-linker" "/lib/ld.so.1"
+// CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/micromips/el/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/micromips/el/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-MM: "[[TC]]/micromips/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-MM: "-L[[TC]]/micromips/el"
+// CHECK-EL-HF64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/el"
+// CHECK-EL-HF64-MM: "-L[[TC]]/../../../../sysroot/micromips/el/usr/lib/../lib"
+// CHECK-EL-HF64-MM: "[[TC]]/micromips/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-MM: "[[TC]]/../../../../sysroot/micromips/el/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, micromips, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1759,6 +2069,7 @@
 // CHECK-EL-SF-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-MM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el/sof"
+// CHECK-EL-SF-MM: "-dynamic-linker" "/lib/ld.so.1"
 // CHECK-EL-SF-MM: "[[TC]]/../../../../sysroot/micromips/el/sof/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-MM: "[[TC]]/../../../../sysroot/micromips/el/sof/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-MM: "[[TC]]/micromips/el/sof{{/|\\\\}}crtbegin.o"
@@ -1785,6 +2096,7 @@
 // CHECK-EL-NAN-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-MM: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el/nan2008"
+// CHECK-EL-NAN-MM: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-MM: "[[TC]]/../../../../sysroot/micromips/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-MM: "[[TC]]/../../../../sysroot/micromips/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-MM: "[[TC]]/micromips/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -1802,7 +2114,7 @@
 // CHECK-EL-NAN64-MM: "-internal-isystem"
 // CHECK-EL-NAN64-MM: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-MM: "-internal-isystem"
-// CHECK-EL-NAN64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el/fp64/nan2008"
+// CHECK-EL-NAN64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/micromips/el/nan2008"
 // CHECK-EL-NAN64-MM: "-internal-isystem"
 // CHECK-EL-NAN64-MM: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-MM: "-internal-externc-isystem"
@@ -1810,15 +2122,16 @@
 // CHECK-EL-NAN64-MM: "-internal-externc-isystem"
 // CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-MM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el/fp64/nan2008"
-// CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-MM: "[[TC]]/micromips/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-MM: "-L[[TC]]/micromips/el/fp64/nan2008"
-// CHECK-EL-NAN64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/el/fp64/nan2008"
-// CHECK-EL-NAN64-MM: "-L[[TC]]/../../../../sysroot/micromips/el/fp64/nan2008/usr/lib/../lib"
-// CHECK-EL-NAN64-MM: "[[TC]]/micromips/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/el/fp64/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-MM: "--sysroot=[[TC]]/../../../../sysroot/micromips/el/nan2008"
+// CHECK-EL-NAN64-MM: "-dynamic-linker" "/lib/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/el/nan2008/usr/lib/../lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/el/nan2008/usr/lib/../lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-MM: "[[TC]]/micromips/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-MM: "-L[[TC]]/micromips/el/nan2008"
+// CHECK-EL-NAN64-MM: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/../lib/micromips/el/nan2008"
+// CHECK-EL-NAN64-MM: "-L[[TC]]/../../../../sysroot/micromips/el/nan2008/usr/lib/../lib"
+// CHECK-EL-NAN64-MM: "[[TC]]/micromips/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-MM: "[[TC]]/../../../../sysroot/micromips/el/nan2008/usr/lib/../lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64, ABI n32, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1837,6 +2150,7 @@
 // CHECK-EL-HF-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-64-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el"
+// CHECK-EL-HF-64-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-EL-HF-64-N32: "[[TC]]/../../../../sysroot/mips64/el/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-64-N32: "[[TC]]/../../../../sysroot/mips64/el/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-64-N32: "[[TC]]/mips64/el{{/|\\\\}}crtbegin.o"
@@ -1854,7 +2168,7 @@
 // CHECK-EL-HF64-64-N32: "-internal-isystem"
 // CHECK-EL-HF64-64-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-64-N32: "-internal-isystem"
-// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el/fp64"
+// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el"
 // CHECK-EL-HF64-64-N32: "-internal-isystem"
 // CHECK-EL-HF64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-64-N32: "-internal-externc-isystem"
@@ -1862,15 +2176,16 @@
 // CHECK-EL-HF64-64-N32: "-internal-externc-isystem"
 // CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-64-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el/fp64"
-// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-64-N32: "[[TC]]/mips64/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-64-N32: "-L[[TC]]/mips64/el/fp64"
-// CHECK-EL-HF64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/el/fp64"
-// CHECK-EL-HF64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/el/fp64/usr/lib"
-// CHECK-EL-HF64-64-N32: "[[TC]]/mips64/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el"
+// CHECK-EL-HF64-64-N32: "-dynamic-linker" "/lib32/ld.so.1"
+// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-64-N32: "[[TC]]/mips64/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-64-N32: "-L[[TC]]/mips64/el"
+// CHECK-EL-HF64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/el"
+// CHECK-EL-HF64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/el/usr/lib"
+// CHECK-EL-HF64-64-N32: "[[TC]]/mips64/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64, ABI n32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1889,6 +2204,7 @@
 // CHECK-EL-SF-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-64-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el/sof"
+// CHECK-EL-SF-64-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-EL-SF-64-N32: "[[TC]]/../../../../sysroot/mips64/el/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-64-N32: "[[TC]]/../../../../sysroot/mips64/el/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-64-N32: "[[TC]]/mips64/el/sof{{/|\\\\}}crtbegin.o"
@@ -1915,6 +2231,7 @@
 // CHECK-EL-NAN-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-64-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el/nan2008"
+// CHECK-EL-NAN-64-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-64-N32: "[[TC]]/../../../../sysroot/mips64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-64-N32: "[[TC]]/../../../../sysroot/mips64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-64-N32: "[[TC]]/mips64/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -1932,7 +2249,7 @@
 // CHECK-EL-NAN64-64-N32: "-internal-isystem"
 // CHECK-EL-NAN64-64-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-64-N32: "-internal-isystem"
-// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el/fp64/nan2008"
+// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/el/nan2008"
 // CHECK-EL-NAN64-64-N32: "-internal-isystem"
 // CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-64-N32: "-internal-externc-isystem"
@@ -1940,15 +2257,16 @@
 // CHECK-EL-NAN64-64-N32: "-internal-externc-isystem"
 // CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-64-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-64-N32: "[[TC]]/mips64/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-64-N32: "-L[[TC]]/mips64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/el/fp64/nan2008/usr/lib"
-// CHECK-EL-NAN64-64-N32: "[[TC]]/mips64/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-64-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64/el/nan2008"
+// CHECK-EL-NAN64-64-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-64-N32: "[[TC]]/mips64/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-64-N32: "-L[[TC]]/mips64/el/nan2008"
+// CHECK-EL-NAN64-64-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/el/nan2008"
+// CHECK-EL-NAN64-64-N32: "-L[[TC]]/../../../../sysroot/mips64/el/nan2008/usr/lib"
+// CHECK-EL-NAN64-64-N32: "[[TC]]/mips64/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-64-N32: "[[TC]]/../../../../sysroot/mips64/el/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64, ABI 64, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -1967,6 +2285,7 @@
 // CHECK-EL-HF-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-64-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el"
+// CHECK-EL-HF-64-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-EL-HF-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-64-64: "[[TC]]/mips64/64/el{{/|\\\\}}crtbegin.o"
@@ -1984,7 +2303,7 @@
 // CHECK-EL-HF64-64-64: "-internal-isystem"
 // CHECK-EL-HF64-64-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-64-64: "-internal-isystem"
-// CHECK-EL-HF64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el/fp64"
+// CHECK-EL-HF64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el"
 // CHECK-EL-HF64-64-64: "-internal-isystem"
 // CHECK-EL-HF64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-64-64: "-internal-externc-isystem"
@@ -1992,15 +2311,16 @@
 // CHECK-EL-HF64-64-64: "-internal-externc-isystem"
 // CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-64-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el/fp64"
-// CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-64-64: "[[TC]]/mips64/64/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-64-64: "-L[[TC]]/mips64/64/el/fp64"
-// CHECK-EL-HF64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/el/fp64"
-// CHECK-EL-HF64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/el/fp64/usr/lib"
-// CHECK-EL-HF64-64-64: "[[TC]]/mips64/64/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el"
+// CHECK-EL-HF64-64-64: "-dynamic-linker" "/lib64/ld.so.1"
+// CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-64-64: "[[TC]]/mips64/64/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-64-64: "-L[[TC]]/mips64/64/el"
+// CHECK-EL-HF64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/el"
+// CHECK-EL-HF64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/el/usr/lib"
+// CHECK-EL-HF64-64-64: "[[TC]]/mips64/64/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64, ABI 64, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -2019,6 +2339,7 @@
 // CHECK-EL-SF-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-64-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el/sof"
+// CHECK-EL-SF-64-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-EL-SF-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-64-64: "[[TC]]/mips64/64/el/sof{{/|\\\\}}crtbegin.o"
@@ -2045,6 +2366,7 @@
 // CHECK-EL-NAN-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-64-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el/nan2008"
+// CHECK-EL-NAN-64-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-64-64: "[[TC]]/mips64/64/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -2062,7 +2384,7 @@
 // CHECK-EL-NAN64-64-64: "-internal-isystem"
 // CHECK-EL-NAN64-64-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-64-64: "-internal-isystem"
-// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el/fp64/nan2008"
+// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64/64/el/nan2008"
 // CHECK-EL-NAN64-64-64: "-internal-isystem"
 // CHECK-EL-NAN64-64-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-64-64: "-internal-externc-isystem"
@@ -2070,15 +2392,16 @@
 // CHECK-EL-NAN64-64-64: "-internal-externc-isystem"
 // CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-64-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-64-64: "[[TC]]/mips64/64/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-64-64: "-L[[TC]]/mips64/64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/el/fp64/nan2008/usr/lib"
-// CHECK-EL-NAN64-64-64: "[[TC]]/mips64/64/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-64-64: "--sysroot=[[TC]]/../../../../sysroot/mips64/64/el/nan2008"
+// CHECK-EL-NAN64-64-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-64-64: "[[TC]]/mips64/64/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-64-64: "-L[[TC]]/mips64/64/el/nan2008"
+// CHECK-EL-NAN64-64-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64/64/el/nan2008"
+// CHECK-EL-NAN64-64-64: "-L[[TC]]/../../../../sysroot/mips64/64/el/nan2008/usr/lib"
+// CHECK-EL-NAN64-64-64: "[[TC]]/mips64/64/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-64-64: "[[TC]]/../../../../sysroot/mips64/64/el/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64r2, ABI n32, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -2097,6 +2420,7 @@
 // CHECK-EL-HF-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-64R2-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el"
+// CHECK-EL-HF-64R2-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-EL-HF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-64R2-N32: "[[TC]]/mips64r2/el{{/|\\\\}}crtbegin.o"
@@ -2114,7 +2438,7 @@
 // CHECK-EL-HF64-64R2-N32: "-internal-isystem"
 // CHECK-EL-HF64-64R2-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-64R2-N32: "-internal-isystem"
-// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el/fp64"
+// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el"
 // CHECK-EL-HF64-64R2-N32: "-internal-isystem"
 // CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-64R2-N32: "-internal-externc-isystem"
@@ -2122,15 +2446,16 @@
 // CHECK-EL-HF64-64R2-N32: "-internal-externc-isystem"
 // CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-64R2-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el/fp64"
-// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-64R2-N32: "[[TC]]/mips64r2/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-64R2-N32: "-L[[TC]]/mips64r2/el/fp64"
-// CHECK-EL-HF64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/el/fp64"
-// CHECK-EL-HF64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/el/fp64/usr/lib"
-// CHECK-EL-HF64-64R2-N32: "[[TC]]/mips64r2/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el"
+// CHECK-EL-HF64-64R2-N32: "-dynamic-linker" "/lib32/ld.so.1"
+// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-64R2-N32: "[[TC]]/mips64r2/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-64R2-N32: "-L[[TC]]/mips64r2/el"
+// CHECK-EL-HF64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/el"
+// CHECK-EL-HF64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/el/usr/lib"
+// CHECK-EL-HF64-64R2-N32: "[[TC]]/mips64r2/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64r2, ABI n32, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -2149,6 +2474,7 @@
 // CHECK-EL-SF-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-64R2-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el/sof"
+// CHECK-EL-SF-64R2-N32: "-dynamic-linker" "/lib32/ld.so.1"
 // CHECK-EL-SF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-64R2-N32: "[[TC]]/mips64r2/el/sof{{/|\\\\}}crtbegin.o"
@@ -2175,6 +2501,7 @@
 // CHECK-EL-NAN-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-64R2-N32: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el/nan2008"
+// CHECK-EL-NAN-64R2-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-64R2-N32: "[[TC]]/mips64r2/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -2192,7 +2519,7 @@
 // CHECK-EL-NAN64-64R2-N32: "-internal-isystem"
 // CHECK-EL-NAN64-64R2-N32: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-64R2-N32: "-internal-isystem"
-// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el/fp64/nan2008"
+// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/el/nan2008"
 // CHECK-EL-NAN64-64R2-N32: "-internal-isystem"
 // CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-64R2-N32: "-internal-externc-isystem"
@@ -2200,15 +2527,16 @@
 // CHECK-EL-NAN64-64R2-N32: "-internal-externc-isystem"
 // CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-64R2-N32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el/fp64/nan2008"
-// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-64R2-N32: "[[TC]]/mips64r2/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-64R2-N32: "-L[[TC]]/mips64r2/el/fp64/nan2008"
-// CHECK-EL-NAN64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/el/fp64/nan2008"
-// CHECK-EL-NAN64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/el/fp64/nan2008/usr/lib"
-// CHECK-EL-NAN64-64R2-N32: "[[TC]]/mips64r2/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-64R2-N32: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/el/nan2008"
+// CHECK-EL-NAN64-64R2-N32: "-dynamic-linker" "/lib32/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-64R2-N32: "[[TC]]/mips64r2/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-64R2-N32: "-L[[TC]]/mips64r2/el/nan2008"
+// CHECK-EL-NAN64-64R2-N32: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/el/nan2008"
+// CHECK-EL-NAN64-64R2-N32: "-L[[TC]]/../../../../sysroot/mips64r2/el/nan2008/usr/lib"
+// CHECK-EL-NAN64-64R2-N32: "[[TC]]/mips64r2/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-64R2-N32: "[[TC]]/../../../../sysroot/mips64r2/el/nan2008/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64r2, ABI 64, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -2227,6 +2555,7 @@
 // CHECK-EL-HF-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF-64R2-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-HF-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el"
+// CHECK-EL-HF-64R2-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-EL-HF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-HF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-HF-64R2-64: "[[TC]]/mips64r2/64/el{{/|\\\\}}crtbegin.o"
@@ -2244,7 +2573,7 @@
 // CHECK-EL-HF64-64R2-64: "-internal-isystem"
 // CHECK-EL-HF64-64R2-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-HF64-64R2-64: "-internal-isystem"
-// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/fp64"
+// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el"
 // CHECK-EL-HF64-64R2-64: "-internal-isystem"
 // CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-HF64-64R2-64: "-internal-externc-isystem"
@@ -2252,15 +2581,16 @@
 // CHECK-EL-HF64-64R2-64: "-internal-externc-isystem"
 // CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-HF64-64R2-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-HF64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el/fp64"
-// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-HF64-64R2-64: "[[TC]]/mips64r2/64/el/fp64{{/|\\\\}}crtbegin.o"
-// CHECK-EL-HF64-64R2-64: "-L[[TC]]/mips64r2/64/el/fp64"
-// CHECK-EL-HF64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/el/fp64"
-// CHECK-EL-HF64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/usr/lib"
-// CHECK-EL-HF64-64R2-64: "[[TC]]/mips64r2/64/el/fp64{{/|\\\\}}crtend.o"
-// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-HF64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el"
+// CHECK-EL-HF64-64R2-64: "-dynamic-linker" "/lib64/ld.so.1"
+// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-HF64-64R2-64: "[[TC]]/mips64r2/64/el{{/|\\\\}}crtbegin.o"
+// CHECK-EL-HF64-64R2-64: "-L[[TC]]/mips64r2/64/el"
+// CHECK-EL-HF64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/el"
+// CHECK-EL-HF64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/el/usr/lib"
+// CHECK-EL-HF64-64R2-64: "[[TC]]/mips64r2/64/el{{/|\\\\}}crtend.o"
+// CHECK-EL-HF64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/usr/lib{{/|\\\\}}crtn.o"
 //
 // = Little-endian, mips64r2, ABI 64, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -2279,6 +2609,7 @@
 // CHECK-EL-SF-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-SF-64R2-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-SF-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el/sof"
+// CHECK-EL-SF-64R2-64: "-dynamic-linker" "/lib64/ld.so.1"
 // CHECK-EL-SF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/sof/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-SF-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/sof/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-SF-64R2-64: "[[TC]]/mips64r2/64/el/sof{{/|\\\\}}crtbegin.o"
@@ -2305,6 +2636,7 @@
 // CHECK-EL-NAN-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN-64R2-64: "{{.*}}ld{{(.exe)?}}"
 // CHECK-EL-NAN-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN-64R2-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
 // CHECK-EL-NAN-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
 // CHECK-EL-NAN-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
 // CHECK-EL-NAN-64R2-64: "[[TC]]/mips64r2/64/el/nan2008{{/|\\\\}}crtbegin.o"
@@ -2322,7 +2654,7 @@
 // CHECK-EL-NAN64-64R2-64: "-internal-isystem"
 // CHECK-EL-NAN64-64R2-64: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
 // CHECK-EL-NAN64-64R2-64: "-internal-isystem"
-// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/fp64/nan2008"
+// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/nan2008"
 // CHECK-EL-NAN64-64R2-64: "-internal-isystem"
 // CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
 // CHECK-EL-NAN64-64R2-64: "-internal-externc-isystem"
@@ -2330,12 +2662,40 @@
 // CHECK-EL-NAN64-64R2-64: "-internal-externc-isystem"
 // CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/usr/include"
 // CHECK-EL-NAN64-64R2-64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-EL-NAN64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/nan2008/usr/lib{{/|\\\\}}crt1.o"
-// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/nan2008/usr/lib{{/|\\\\}}crti.o"
-// CHECK-EL-NAN64-64R2-64: "[[TC]]/mips64r2/64/el/fp64/nan2008{{/|\\\\}}crtbegin.o"
-// CHECK-EL-NAN64-64R2-64: "-L[[TC]]/mips64r2/64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/el/fp64/nan2008"
-// CHECK-EL-NAN64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/nan2008/usr/lib"
-// CHECK-EL-NAN64-64R2-64: "[[TC]]/mips64r2/64/el/fp64/nan2008{{/|\\\\}}crtend.o"
-// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/fp64/nan2008/usr/lib{{/|\\\\}}crtn.o"
+// CHECK-EL-NAN64-64R2-64: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-64R2-64: "[[TC]]/mips64r2/64/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-64R2-64: "-L[[TC]]/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64: "-L[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib"
+// CHECK-EL-NAN64-64R2-64: "[[TC]]/mips64r2/64/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-64R2-64: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crtn.o"
+//
+// = Little-endian, default (mips64r2), ABI 64, fp64, nan2008
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     --target=mips64el-linux-gnu -mabi=64 -mfp64 -mnan=2008 \
+// RUN:     --gcc-toolchain=%S/Inputs/mips_fsf_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-EL-NAN64-64R2-64-DEF %s
+// CHECK-EL-NAN64-64R2-64-DEF: "-internal-isystem"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC:[^"]+/lib/gcc/mips-mti-linux-gnu/4.9.0]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0"
+// CHECK-EL-NAN64-64R2-64-DEF: "-internal-isystem"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/mips-mti-linux-gnu/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64-DEF: "-internal-isystem"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/../../../../mips-mti-linux-gnu/include/c++/4.9.0/backward"
+// CHECK-EL-NAN64-64R2-64-DEF: "-internal-externc-isystem"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/include"
+// CHECK-EL-NAN64-64R2-64-DEF: "-internal-externc-isystem"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/usr/include"
+// CHECK-EL-NAN64-64R2-64-DEF: "{{.*}}ld{{(.exe)?}}"
+// CHECK-EL-NAN64-64R2-64-DEF: "--sysroot=[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64-DEF: "-dynamic-linker" "/lib64/ld-linux-mipsn8.so.1"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crt1.o"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crti.o"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/mips64r2/64/el/nan2008{{/|\\\\}}crtbegin.o"
+// CHECK-EL-NAN64-64R2-64-DEF: "-L[[TC]]/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64-DEF: "-L[[TC]]/../../../../mips-mti-linux-gnu/lib/mips64r2/64/el/nan2008"
+// CHECK-EL-NAN64-64R2-64-DEF: "-L[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/mips64r2/64/el/nan2008{{/|\\\\}}crtend.o"
+// CHECK-EL-NAN64-64R2-64-DEF: "[[TC]]/../../../../sysroot/mips64r2/64/el/nan2008/usr/lib{{/|\\\\}}crtn.o"
diff --git a/test/Driver/mips-integrated-as.s b/test/Driver/mips-integrated-as.s
new file mode 100644
index 0000000..b648650
--- /dev/null
+++ b/test/Driver/mips-integrated-as.s
@@ -0,0 +1,217 @@
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-O32 %s
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=32 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-O32 %s
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=o32 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-O32 %s
+// ABI-O32: -cc1as
+// ABI-O32: "-target-feature" "-n64"
+// ABI-O32: "-target-feature" "+o32"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=eabi 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-EABI32 %s
+// ABI-EABI32: -cc1as
+// ABI-EABI32: "-target-feature" "-o32"
+// ABI-EABI32: "-target-feature" "-n64"
+// ABI-EABI32: "-target-feature" "+eabi"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n32 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N32 %s
+// RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mabi=n32 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N32 %s
+// ABI-N32: -cc1as
+// ABI-N32: "-target-feature" "-o32"
+// ABI-N32: "-target-feature" "-n64"
+// ABI-N32: "-target-feature" "+n32"
+
+// FIXME: We should also test '-target mips-linux-gnu -mips64' defaults to the
+//        default 64-bit ABI (N64 but GCC uses N32). It currently selects O32
+//        because of the triple.
+// RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mips64 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N64 %s
+//
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=64 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N64 %s
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n64 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N64 %s
+// RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=64 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N64 %s
+// RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n64 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-N64 %s
+// ABI-N64: -cc1as
+// ABI-N64: "-target-feature" "-o32"
+// ABI-N64: "-target-feature" "+n64"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -msoft-float 2>&1 | \
+// RUN:   FileCheck -check-prefix=SOFTFLOAT %s
+// SOFTFLOAT: -cc1as
+// SOFTFLOAT: "-target-feature" "+soft-float"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=HARDFLOAT %s
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mhard-float 2>&1 | \
+// RUN:   FileCheck -check-prefix=HARDFLOAT %s
+// HARDFLOAT: -cc1as
+// HARDFLOAT-NOT: "-target-feature" "+soft-float"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=NAN-DEFAULT %s
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips32r6 2>&1 | \
+// RUN:   FileCheck -check-prefix=NAN-DEFAULT %s
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips64r6 2>&1 | \
+// RUN:   FileCheck -check-prefix=NAN-DEFAULT %s
+// NAN-DEFAULT: -cc1as
+// NAN-DEFAULT-NOT: "-target-feature" "{{[-+]}}nan2008"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mnan=legacy 2>&1 | \
+// RUN:   FileCheck -check-prefix=NAN-LEGACY %s
+// NAN-LEGACY: -cc1as
+// NAN-LEGACY: "-target-feature" "-nan2008"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mnan=2008 2>&1 | \
+// RUN:   FileCheck -check-prefix=NAN-2008 %s
+// NAN-2008: -cc1as
+// NAN-2008: "-target-feature" "+nan2008"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=DEFAULT-FLOAT %s
+// DEFAULT-FLOAT: -cc1as
+// DEFAULT-FLOAT-NOT: "-target-feature" "{{[+-]}}single-float"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -msingle-float 2>&1 | \
+// RUN:   FileCheck -check-prefix=SINGLE-FLOAT %s
+// SINGLE-FLOAT: -cc1as
+// SINGLE-FLOAT: "-target-feature" "+single-float"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mdouble-float 2>&1 | \
+// RUN:   FileCheck -check-prefix=DOUBLE-FLOAT %s
+// DOUBLE-FLOAT: -cc1as
+// DOUBLE-FLOAT: "-target-feature" "-single-float"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS16-DEFAULT %s
+// MIPS16-DEFAULT: -cc1as
+// MIPS16-DEFAULT-NOT: "-target-feature" "{{[+-]}}mips16"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips16 2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS16-ON %s
+// MIPS16-ON: -cc1as
+// MIPS16-ON: "-target-feature" "+mips16"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-mips16 2>&1 | \
+// RUN:   FileCheck -check-prefix=MIPS16-OFF %s
+// MIPS16-OFF: -cc1as
+// MIPS16-OFF: "-target-feature" "-mips16"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=MICROMIPS-DEFAULT %s
+// MICROMIPS-DEFAULT: -cc1as
+// MICROMIPS-DEFAULT-NOT: "-target-feature" "{{[+-]}}micromips"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mmicromips 2>&1 | \
+// RUN:   FileCheck -check-prefix=MICROMIPS-ON %s
+// MICROMIPS-ON: -cc1as
+// MICROMIPS-ON: "-target-feature" "+micromips"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-micromips 2>&1 | \
+// RUN:   FileCheck -check-prefix=MICROMIPS-OFF %s
+// MICROMIPS-OFF: -cc1as
+// MICROMIPS-OFF: "-target-feature" "-micromips"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=DSP-DEFAULT %s
+// DSP-DEFAULT: -cc1as
+// DSP-DEFAULT-NOT: "-target-feature" "{{[+-]}}dsp"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mdsp 2>&1 | \
+// RUN:   FileCheck -check-prefix=DSP-ON %s
+// DSP-ON: -cc1as
+// DSP-ON: "-target-feature" "+dsp"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-dsp 2>&1 | \
+// RUN:   FileCheck -check-prefix=DSP-OFF %s
+// DSP-OFF: -cc1as
+// DSP-OFF: "-target-feature" "-dsp"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=DSPR2-DEFAULT %s
+// DSPR2-DEFAULT: -cc1as
+// DSPR2-DEFAULT-NOT: "-target-feature" "{{[+-]}}dspr2"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mdspr2 2>&1 | \
+// RUN:   FileCheck -check-prefix=DSPR2-ON %s
+// DSPR2-ON: -cc1as
+// DSPR2-ON: "-target-feature" "+dspr2"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-dspr2 2>&1 | \
+// RUN:   FileCheck -check-prefix=DSPR2-OFF %s
+// DSPR2-OFF: -cc1as
+// DSPR2-OFF: "-target-feature" "-dspr2"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=MSA-DEFAULT %s
+// MSA-DEFAULT: -cc1as
+// MSA-DEFAULT-NOT: "-target-feature" "{{[+-]}}msa"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mmsa 2>&1 | \
+// RUN:   FileCheck -check-prefix=MSA-ON %s
+// MSA-ON: -cc1as
+// MSA-ON: "-target-feature" "+msa"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-msa 2>&1 | \
+// RUN:   FileCheck -check-prefix=MSA-OFF %s
+// MSA-OFF: -cc1as
+// MSA-OFF: "-target-feature" "-msa"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
+// FPXX-DEFAULT: -cc1as
+// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
+// RUN:   FileCheck -check-prefix=FP32 %s
+// FP32: -cc1as
+// FP32: "-target-feature" "-fp64"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfpxx 2>&1 | \
+// RUN:   FileCheck -check-prefix=FPXX %s
+// FPXX: -cc1as
+// FPXX: "-target-feature" "+fpxx"
+// FPXX: "-target-feature" "+nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp64 2>&1 | \
+// RUN:   FileCheck -check-prefix=FP64 %s
+// FP64: -cc1as
+// FP64: "-target-feature" "+fp64"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
+// ODDSPREG-DEFAULT: -cc1as
+// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
+// RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
+// ODDSPREG-ON: -cc1as
+// ODDSPREG-ON: "-target-feature" "-nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-odd-spreg 2>&1 | \
+// RUN:   FileCheck -check-prefix=ODDSPREG-OFF %s
+// ODDSPREG-OFF: -cc1as
+// ODDSPREG-OFF: "-target-feature" "+nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfpxx -modd-spreg 2>&1 | \
+// RUN:   FileCheck -check-prefix=FPXX-ODDSPREG %s
+// FPXX-ODDSPREG: -cc1as
+// FPXX-ODDSPREG: "-target-feature" "+fpxx"
+// FPXX-ODDSPREG: "-target-feature" "-nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabicalls 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABICALLS-ON %s
+// ABICALLS-ON: -cc1as
+// ABICALLS-ON: "-target-feature" "-noabicalls"
+
+// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mno-abicalls 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABICALLS-OFF %s
+// ABICALLS-OFF: -cc1as
+// ABICALLS-OFF: "-target-feature" "+noabicalls"
diff --git a/test/Driver/modules.m b/test/Driver/modules.m
index d8e20e4..8a0c8ba 100644
--- a/test/Driver/modules.m
+++ b/test/Driver/modules.m
@@ -4,18 +4,36 @@
 // RUN: %clang -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
 // CHECK-HAS-MODULES: -fmodules
 
-// RUN: %clang -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
-// TIMESTAMP_ONLY: -fbuild-session-timestamp=123
+// RUN: %clang -fbuild-session-file=doesntexist -### %s 2>&1 | FileCheck -check-prefix=NOFILE %s
+// NOFILE: no such file or directory: 'doesntexist'
+
+// RUN: touch -m -a -t 201008011501 %t.build-session-file
+// RUN: %clang -fbuild-session-file=%t.build-session-file -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
+
+// RUN: %clang -fbuild-session-timestamp=1280703457 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
+// TIMESTAMP_ONLY: -fbuild-session-timestamp=128
+
+// RUN: %clang -fbuild-session-file=%t.build-session-file -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=CONFLICT %s
+// CONFLICT: error: invalid argument '-fbuild-session-file={{.*}}.build-session-file' not allowed with '-fbuild-session-timestamp'
 
 // RUN: %clang -fbuild-session-timestamp=123 -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE %s
 // MODULES_VALIDATE_ONCE: -fbuild-session-timestamp=123
 // MODULES_VALIDATE_ONCE: -fmodules-validate-once-per-build-session
 
+// RUN: %clang -fbuild-session-file=%t.build-session-file -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_FILE %s
+// MODULES_VALIDATE_ONCE_FILE: -fbuild-session-timestamp=128
+// MODULES_VALIDATE_ONCE_FILE: -fmodules-validate-once-per-build-session
+
 // RUN: %clang -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s
-// MODULES_VALIDATE_ONCE_ERR: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>'
+// MODULES_VALIDATE_ONCE_ERR: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=<seconds since Epoch>' or '-fbuild-session-file=<file>'
 
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT-NOT: -fmodules-validate-system-headers
 
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
+
+// RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
+// CHECK-MODULE-MAP-FILES: "-fmodules"
+// CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
+// CHECK-MODULE-MAP-FILES: "-fmodule-map-file=bar.map"
diff --git a/test/Driver/modules.mm b/test/Driver/modules.mm
index b2948c4..63db699 100644
--- a/test/Driver/modules.mm
+++ b/test/Driver/modules.mm
@@ -1,6 +1,8 @@
-// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
 // RUN: %clang -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang -fmodules -fno-cxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
 // CHECK-NO-MODULES-NOT: -fmodules
 
-// RUN: %clang -fcxx-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
+// RUN: %clang -fmodules -fno-cxx-modules -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
 // CHECK-HAS-MODULES: -fmodules
diff --git a/test/Driver/msc-version.c b/test/Driver/msc-version.c
index 027072f..1a88419 100644
--- a/test/Driver/msc-version.c
+++ b/test/Driver/msc-version.c
@@ -1,42 +1,68 @@
+//
+// Verify defaults
+//
+
 // RUN: %clang -target i686-windows -fms-compatibility -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-NO-MSC-VERSION
 
 // CHECK-NO-MSC-VERSION: _MSC_BUILD 1
 // CHECK-NO-MSC-VERSION: _MSC_FULL_VER 170000000
 // CHECK-NO-MSC-VERSION: _MSC_VER 1700
 
-// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=1600 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION
 
-// CHECK-MSC-VERSION: _MSC_BUILD 1
-// CHECK-MSC-VERSION: _MSC_FULL_VER 160000000
-// CHECK-MSC-VERSION: _MSC_VER 1600
+//
+// Verify -fms-compatibility-version parsing
+//
 
-// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=160030319 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-EXT
-
-// CHECK-MSC-VERSION-EXT: _MSC_BUILD 1
-// CHECK-MSC-VERSION-EXT: _MSC_FULL_VER 160030319
-// CHECK-MSC-VERSION-EXT: _MSC_VER 1600
-
-// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=14 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR
+// RUN: %clang -target i686-windows -fms-compatibility -fms-compatibility-version=14 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR
 
 // CHECK-MSC-VERSION-MAJOR: _MSC_BUILD 1
 // CHECK-MSC-VERSION-MAJOR: _MSC_FULL_VER 140000000
 // CHECK-MSC-VERSION-MAJOR: _MSC_VER 1400
 
-// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=17.00 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR
+// RUN: %clang -target i686-windows -fms-compatibility -fms-compatibility-version=15.00 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR
 
 // CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_BUILD 1
-// CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_FULL_VER 170000000
-// CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_VER 1700
+// CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_FULL_VER 150000000
+// CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_VER 1500
 
-// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=15.00.20706 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR-BUILD
+// RUN: %clang -target i686-windows -fms-compatibility -fms-compatibility-version=15.00.20706 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR-BUILD
 
 // CHECK-MSC-VERSION-MAJOR-MINOR-BUILD: _MSC_BUILD 1
 // CHECK-MSC-VERSION-MAJOR-MINOR-BUILD: _MSC_FULL_VER 150020706
 // CHECK-MSC-VERSION-MAJOR-MINOR-BUILD: _MSC_VER 1500
 
-// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=15.00.20706.01 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR-BUILD-PATCH
+// RUN: %clang -target i686-windows -fms-compatibility -fms-compatibility-version=15.00.20706.01 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR-BUILD-PATCH
 
 // CHECK-MSC-VERSION-MAJOR-MINOR-BUILD-PATCH: _MSC_BUILD 1
 // CHECK-MSC-VERSION-MAJOR-MINOR-BUILD-PATCH: _MSC_FULL_VER 150020706
 // CHECK-MSC-VERSION-MAJOR-MINOR-BUILD-PATCH: _MSC_VER 1500
 
+
+//
+// Verify -fmsc-version and -fms-compatibility-version diagnostic
+//
+
+// RUN: not %clang -target i686-windows -fms-compatibility -fmsc-version=1700 -fms-compatibility-version=17.00.50727.1 -E - </dev/null 2>&1 | FileCheck %s -check-prefix CHECK-BASIC-EXTENDED-DIAGNOSTIC
+
+// CHECK-BASIC-EXTENDED-DIAGNOSTIC: invalid argument '-fmsc-version={{.*}}' not allowed with '-fms-compatibility-version={{.*}}'
+
+
+//
+// Verify -fmsc-version to -fms-compatibility-version conversion
+//
+
+// RUN: %clang -### -target i686-windows -fms-compatibility -fmsc-version=17 -E - </dev/null -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-MSC-17
+
+// CHECK-MSC-17-NOT: "-fmsc-version=1700"
+// CHECK-MSC-17: "-fms-compatibility-version=17.0"
+
+// RUN: %clang -### -target i686-windows -fms-compatibility -fmsc-version=1600 -E - </dev/null -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-MSC-16
+
+// CHECK-MSC-16-NOT: "-fmsc-version=1600"
+// CHECK-MSC-16: "-fms-compatibility-version=16.0"
+
+// RUN: %clang -### -target i686-windows -fms-compatibility -fmsc-version=150020706 -E - </dev/null -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-MSC-15
+
+// CHECK-MSC-15-NOT: "-fmsc-version=150020706"
+// CHECK-MSC-15: "-fms-compatibility-version=15.0.20706"
+
diff --git a/test/Driver/msvc_forward.c b/test/Driver/msvc_forward.c
index fe0ae84..15f941e 100644
--- a/test/Driver/msvc_forward.c
+++ b/test/Driver/msvc_forward.c
@@ -1,5 +1,7 @@
-// RUN: %clang -target i686-pc-win32 -lkernel32.lib -luser32.lib -### %s 2>&1 | FileCheck %s
+// RUN: %clang -target i686-pc-win32 -loldnames -lkernel32.lib -luser32.lib -### %s 2>&1 | FileCheck %s
+// CHECK-NOT: "-loldnames.lib"
 // CHECK-NOT: "-lkernel32.lib"
 // CHECK-NOT: "-luser32.lib"
+// CHECK: "oldnames.lib"
 // CHECK: "kernel32.lib"
 // CHECK: "user32.lib"
diff --git a/test/Driver/netbsd.c b/test/Driver/netbsd.c
index 0e3ebf3..eded7f5 100644
--- a/test/Driver/netbsd.c
+++ b/test/Driver/netbsd.c
@@ -13,36 +13,42 @@
 // RUN: %clang -no-canonical-prefixes -target aarch64--netbsd7.0.0 \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=AARCH64-7 %s
-// RUN: %clang -no-canonical-prefixes -target arm64--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=ARM64 %s
-// RUN: %clang -no-canonical-prefixes -target arm64--netbsd7.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=ARM64-7 %s
 // RUN: %clang -no-canonical-prefixes -target arm--netbsd-eabi \
 // RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=ARM %s
+// RUN: %clang -no-canonical-prefixes -target armeb--netbsd-eabi \
+// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=ARMEB %s
 // RUN: %clang -no-canonical-prefixes -target arm--netbsd \
 // RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=ARM-APCS %s
+// RUN: %clang -no-canonical-prefixes -target arm--netbsd-eabihf \
+// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-HF %s
 // RUN: %clang -no-canonical-prefixes -target thumb--netbsd-eabi \
 // RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=THUMB %s
+// RUN: %clang -no-canonical-prefixes -target thumbeb--netbsd-eabi \
+// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=THUMBEB %s
 // RUN: %clang -no-canonical-prefixes -target arm--netbsd7.0.0-eabi \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=ARM-7 %s
 // RUN: %clang -no-canonical-prefixes -target arm--netbsd6.0.0-eabi \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=ARM-6 %s
-// RUN: %clang -no-canonical-prefixes -target arm--netbsd-eabihf \
-// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=ARM-HF %s
 // RUN: %clang -no-canonical-prefixes -target sparc--netbsd \
 // RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC %s
 // RUN: %clang -no-canonical-prefixes -target sparc64--netbsd \
 // RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC64 %s
+// RUN: %clang -no-canonical-prefixes -target powerpc--netbsd \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=POWERPC %s
+// RUN: %clang -no-canonical-prefixes -target powerpc64--netbsd \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=POWERPC64 %s
 
 // RUN: %clang -no-canonical-prefixes -target x86_64--netbsd -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
@@ -59,15 +65,12 @@
 // RUN: %clang -no-canonical-prefixes -target aarch64--netbsd7.0.0 -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-AARCH64-7 %s
-// RUN: %clang -no-canonical-prefixes -target arm64--netbsd -static \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=S-ARM64 %s
-// RUN: %clang -no-canonical-prefixes -target arm64--netbsd7.0.0 -static \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=S-ARM64-7 %s
 // RUN: %clang -no-canonical-prefixes -target arm--netbsd-eabi -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-ARM %s
+// RUN: %clang -no-canonical-prefixes -target armeb--netbsd-eabi -static \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=S-ARMEB %s
 // RUN: %clang -no-canonical-prefixes -target arm--netbsd7.0.0-eabi -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-ARM-7 %s
@@ -80,6 +83,12 @@
 // RUN: %clang -no-canonical-prefixes -target sparc64--netbsd -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-SPARC64 %s
+// RUN: %clang -no-canonical-prefixes -target powerpc--netbsd -static \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=S-POWERPC %s
+// RUN: %clang -no-canonical-prefixes -target powerpc64--netbsd -static \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=S-POWERPC64 %s
 
 // X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
 // X86_64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
@@ -103,30 +112,14 @@
 // AARCH64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // AARCH64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
 // AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
 // AARCH64-7: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd7.0.0"
 // AARCH64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // AARCH64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
 // AARCH64-7:  "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// AARCH64-7: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
-// ARM64: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd"
-// ARM64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
-// ARM64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// ARM64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
-// ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
-// ARM64-7: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd7.0.0"
-// ARM64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
-// ARM64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// ARM64-7:  "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// ARM64-7: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
-// ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
 // ARM: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd-eabi"
 // ARM: as{{.*}}" "-mcpu=arm926ej-s" "-o"
 // ARM: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
@@ -136,6 +129,15 @@
 // ARM: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // ARM: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
+// ARMEB: clang{{.*}}" "-cc1" "-triple" "armebv5e--netbsd-eabi"
+// ARMEB: as{{.*}}" "-mcpu=arm926ej-s" "-o"
+// ARMEB: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// ARMEB: "-m" "armelfb_nbsd_eabi"
+// ARMEB: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// ARMEB: "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o"
+// ARMEB: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// ARMEB: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
 // ARM-APCS: clang{{.*}}" "-cc1" "-triple" "armv4--netbsd"
 // ARM-APCS: as{{.*}}" "-mcpu=strongarm" "-o"
 // ARM-APCS: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
@@ -145,6 +147,15 @@
 // ARM-APCS: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // ARM-APCS: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
+// ARM-HF: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd-eabihf"
+// ARM-HF: as{{.*}}" "-mcpu=arm926ej-s" "-o"
+// ARM-HF: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// ARM-HF: "-m" "armelf_nbsd_eabihf"
+// ARM-HF: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// ARM-HF: "{{.*}}/usr/lib{{/|\\\\}}eabihf{{/|\\\\}}crti.o"
+// ARM-HF: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// ARM-HF: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
 // THUMB: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd-eabi"
 // THUMB: as{{.*}}" "-mcpu=arm926ej-s" "-o"
 // THUMB: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
@@ -154,6 +165,15 @@
 // THUMB: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // THUMB: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
+// THUMBEB: clang{{.*}}" "-cc1" "-triple" "armebv5e--netbsd-eabi"
+// THUMBEB: as{{.*}}" "-mcpu=arm926ej-s" "-o"
+// THUMBEB: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// THUMBEB: "-m" "armelfb_nbsd_eabi"
+// THUMBEB: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// THUMBEB: "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o"
+// THUMBEB: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// THUMBEB: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
 // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd7.0.0-eabi"
 // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // ARM-7: "-m" "armelf_nbsd_eabi"
@@ -170,9 +190,6 @@
 // ARM-6: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // ARM-6: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
-// ARM-HF: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd-eabihf"
-// ARM-HF: ld{{.*}}" "-m" "armelf_nbsd_eabihf"
-
 // SPARC: clang{{.*}}" "-cc1" "-triple" "sparc--netbsd"
 // SPARC: as{{.*}}" "-32" "-o"
 // SPARC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
@@ -190,6 +207,22 @@
 // SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
+// POWERPC: clang{{.*}}" "-cc1" "-triple" "powerpc--netbsd"
+// POWERPC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// POWERPC: "-m" "elf32ppc_nbsd"
+// POWERPC: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// POWERPC: "{{.*}}/usr/lib{{/|\\\\}}powerpc{{/|\\\\}}crti.o"
+// POWERPC: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// POWERPC: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
+// POWERPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64--netbsd"
+// POWERPC64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// POWERPC64: "-m" "elf64ppc"
+// POWERPC64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crti.o"
+// POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
 // S-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
 // S-X86_64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-X86_64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
@@ -213,30 +246,14 @@
 // S-AARCH64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-AARCH64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
 // S-AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// S-AARCH64: "-lgcc_eh" "-lc" "-lgcc"
 // S-AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
 // S-AARCH64-7: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd7.0.0"
 // S-AARCH64-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-AARCH64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
 // S-AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// S-AARCH64-7: "-lgcc_eh" "-lc" "-lgcc"
 // S-AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
-// S-ARM64: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd"
-// S-ARM64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
-// S-ARM64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// S-ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// S-ARM64: "-lgcc_eh" "-lc" "-lgcc"
-// S-ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
-// S-ARM64-7: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd7.0.0"
-// S-ARM64-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
-// S-ARM64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// S-ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
-// S-ARM64-7: "-lgcc_eh" "-lc" "-lgcc"
-// S-ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
 // S-ARM: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd-eabi"
 // S-ARM: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-ARM: "-m" "armelf_nbsd_eabi"
@@ -245,6 +262,14 @@
 // S-ARM: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // S-ARM: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
+// S-ARMEB: clang{{.*}}" "-cc1" "-triple" "armebv5e--netbsd-eabi"
+// S-ARMEB: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
+// S-ARMEB: "-m" "armelfb_nbsd_eabi"
+// S-ARMEB: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// S-ARMEB: "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o"
+// S-ARMEB: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// S-ARMEB: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
 // S-ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd7.0.0-eabi"
 // S-ARM-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-ARM-7: "-m" "armelf_nbsd_eabi"
@@ -278,3 +303,19 @@
 // S-SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
 // S-SPARC64: "-lgcc_eh" "-lc" "-lgcc"
 // S-SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
+// S-POWERPC: clang{{.*}}" "-cc1" "-triple" "powerpc--netbsd"
+// S-POWERPC: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
+// S-POWERPC: "-m" "elf32ppc_nbsd"
+// S-POWERPC: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// S-POWERPC: "{{.*}}/usr/lib{{/|\\\\}}powerpc{{/|\\\\}}crti.o"
+// S-POWERPC: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// S-POWERPC: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
+// S-POWERPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64--netbsd"
+// S-POWERPC64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
+// S-POWERPC64: "-m" "elf64ppc"
+// S-POWERPC64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// S-POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crti.o"
+// S-POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc"
+// S-POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
diff --git a/test/Driver/netbsd.cpp b/test/Driver/netbsd.cpp
index 43b9fde..e386a21 100644
--- a/test/Driver/netbsd.cpp
+++ b/test/Driver/netbsd.cpp
@@ -19,18 +19,18 @@
 // RUN: %clangxx -no-canonical-prefixes -target aarch64--netbsd7.0.0 \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=AARCH64-7 %s
-// RUN: %clangxx -no-canonical-prefixes -target arm64--netbsd \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=ARM64 %s
-// RUN: %clangxx -no-canonical-prefixes -target arm64--netbsd7.0.0 \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=ARM64-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc--netbsd \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc64--netbsd \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=SPARC64 %s
+// RUN: %clangxx -no-canonical-prefixes -target powerpc--netbsd \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=POWERPC %s
+// RUN: %clangxx -no-canonical-prefixes -target powerpc64--netbsd \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=POWERPC64 %s
 
 // RUN: %clangxx -no-canonical-prefixes -target x86_64--netbsd -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
@@ -53,18 +53,18 @@
 // RUN: %clangxx -no-canonical-prefixes -target aarch64--netbsd7.0.0 -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-AARCH64-7 %s
-// RUN: %clangxx -no-canonical-prefixes -target arm64--netbsd -static \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=S-ARM64 %s
-// RUN: %clangxx -no-canonical-prefixes -target arm64--netbsd7.0.0 -static \
-// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
-// RUN: | FileCheck -check-prefix=S-ARM64-7 %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc--netbsd -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-SPARC %s
 // RUN: %clangxx -no-canonical-prefixes -target sparc64--netbsd -static \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
 // RUN: | FileCheck -check-prefix=S-SPARC64 %s
+// RUN: %clangxx -no-canonical-prefixes -target powerpc--netbsd -static \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=S-POWERPC %s
+// RUN: %clangxx -no-canonical-prefixes -target powerpc64--netbsd -static \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=S-POWERPC64 %s
 
 // X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
 // X86_64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
@@ -101,31 +101,17 @@
 // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd"
 // AARCH64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // AARCH64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// AARCH64: "-lm" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// AARCH64: "-lm" "-lc"
 // AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
 // AARCH64-7: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd7.0.0"
 // AARCH64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // AARCH64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// AARCH64-7: "-lm" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// AARCH64-7: "-lm" "-lc"
 // AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
-// ARM64: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd"
-// ARM64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
-// ARM64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// ARM64: "-lm" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
-// ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
-// ARM64-7: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd7.0.0"
-// ARM64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
-// ARM64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// ARM64-7: "-lm" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
-// ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
 // SPARC: clang{{.*}}" "-cc1" "-triple" "sparc--netbsd"
 // SPARC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // SPARC: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
@@ -141,6 +127,20 @@
 // SPARC64: "-lm" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 // SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
+// POWERPC: clang{{.*}}" "-cc1" "-triple" "powerpc--netbsd"
+// POWERPC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// POWERPC: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// POWERPC: "{{.*}}/usr/lib{{/|\\\\}}powerpc{{/|\\\\}}crti.o"
+// POWERPC: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// POWERPC: "-lm" "-lc" "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
+// POWERPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64--netbsd"
+// POWERPC64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
+// POWERPC64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crti.o"
+// POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// POWERPC64: "-lm" "-lc" "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
 // S-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
 // S-X86_64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-X86_64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
@@ -176,31 +176,17 @@
 // S-AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd"
 // S-AARCH64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-AARCH64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// S-AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// S-AARCH64: "-lm" "-lc" "-lgcc_eh" "-lc" "-lgcc"
+// S-AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// S-AARCH64: "-lm" "-lc"
 // S-AARCH64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
 // S-AARCH64-7: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd7.0.0"
 // S-AARCH64-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-AARCH64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// S-AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// S-AARCH64-7: "-lm" "-lc" "-lgcc_eh" "-lc" "-lgcc"
+// S-AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// S-AARCH64-7: "-lm" "-lc"
 // S-AARCH64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
-// S-ARM64: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd"
-// S-ARM64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
-// S-ARM64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// S-ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// S-ARM64: "-lm" "-lc" "-lgcc_eh" "-lc" "-lgcc"
-// S-ARM64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
-// S-ARM64-7: clang{{.*}}" "-cc1" "-triple" "arm64--netbsd7.0.0"
-// S-ARM64-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
-// S-ARM64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}crti.o"
-// S-ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
-// S-ARM64-7: "-lm" "-lc" "-lgcc_eh" "-lc" "-lgcc"
-// S-ARM64-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
-
 // S-SPARC: clang{{.*}}" "-cc1" "-triple" "sparc--netbsd"
 // S-SPARC: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-SPARC: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
@@ -215,3 +201,17 @@
 // S-SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lstdc++"
 // S-SPARC64: "-lm" "-lc" "-lgcc_eh" "-lc" "-lgcc"
 // S-SPARC64: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
+// S-POWERPC: clang{{.*}}" "-cc1" "-triple" "powerpc--netbsd"
+// S-POWERPC: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
+// S-POWERPC: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// S-POWERPC: "{{.*}}/usr/lib{{/|\\\\}}powerpc{{/|\\\\}}crti.o"
+// S-POWERPC: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// S-POWERPC: "-lm" "-lc" "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
+
+// S-POWERPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64--netbsd"
+// S-POWERPC64: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
+// S-POWERPC64: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o"
+// S-POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crti.o"
+// S-POWERPC64: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++"
+// S-POWERPC64: "-lm" "-lc" "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
diff --git a/test/Driver/no-canonical-prefixes.c b/test/Driver/no-canonical-prefixes.c
new file mode 100644
index 0000000..1aef9f4
--- /dev/null
+++ b/test/Driver/no-canonical-prefixes.c
@@ -0,0 +1,10 @@
+// REQUIRES: shell
+// RUN: mkdir -p %t
+// RUN: cd %t
+// RUN: ln -sf %clang test-clang
+// RUN: ./test-clang -v -S %s 2>&1 | FileCheck %s
+// RUN: ./test-clang -v -S %s -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=NCP %s
+
+
+// CHECK: /clang{{.*}}" -cc1
+// NCP: test-clang" -cc1
diff --git a/test/Driver/openbsd.c b/test/Driver/openbsd.c
index 6507838..d263f48 100644
--- a/test/Driver/openbsd.c
+++ b/test/Driver/openbsd.c
@@ -60,7 +60,11 @@
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
 
-// Check that the integrated assembler is enabled for PowerPC
+// Check that the integrated assembler is enabled for PowerPC and SPARC
 // RUN: %clang -target powerpc-unknown-openbsd -### -c %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-POWERPC-AS %s
-// CHECK-POWERPC-AS-NOT: "-no-integrated-as"
+// RUN:   | FileCheck -check-prefix=CHECK-IAS %s
+// RUN: %clang -target sparc-unknown-openbsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-IAS %s
+// RUN: %clang -target sparc64-unknown-openbsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-IAS %s
+// CHECK-IAS-NOT: "-no-integrated-as"
diff --git a/test/Driver/parse-progname.c b/test/Driver/parse-progname.c
new file mode 100644
index 0000000..33c6378
--- /dev/null
+++ b/test/Driver/parse-progname.c
@@ -0,0 +1,58 @@
+// REQUIRES: shell, arm-registered-target
+
+
+
+// RUN: ln -fs %clang %T/clang++
+// RUN: ln -fs %clang %T/clang++3.5.0
+// RUN: ln -fs %clang %T/clang++-3.5
+// RUN: ln -fs %clang %T/clang++-tot
+// RUN: ln -fs %clang %T/clang-c++
+// RUN: ln -fs %clang %T/clang-g++
+// RUN: ln -fs %clang %T/c++
+// RUN: ln -fs %clang %T/foo-clang++
+// RUN: ln -fs %clang %T/foo-clang++-3.5
+// RUN: ln -fs %clang %T/foo-clang++3.5
+// RUN: %T/clang++          -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/clang++3.5.0     -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/clang++-3.5      -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/clang++-tot      -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/clang-c++        -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/clang-g++        -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/c++              -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/foo-clang++      -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/foo-clang++-3.5  -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// RUN: %T/foo-clang++3.5   -### %s 2>&1 | FileCheck -check-prefix=CXXMODE %s
+// CXXMODE: "-x" "c++"
+
+
+// RUN: ln -fs %clang %T/clang-cl
+// RUN: ln -fs %clang %T/cl
+// RUN: ln -fs %clang %T/cl.exe
+// RUN: ln -fs %clang %T/clang-cl3.5
+// RUN: ln -fs %clang %T/clang-cl-3.5
+// Note: use -- in front of the filename so it's not mistaken for an option on
+// filesystems that use slashes for dir separators.
+// RUN: %T/clang-cl         -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// RUN: %T/cl               -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// RUN: %T/cl.exe           -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// RUN: %T/clang-cl3.5      -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// RUN: %T/clang-cl-3.5     -### -- %s 2>&1 | FileCheck -check-prefix=CLMODE %s
+// CLMODE: "-fdiagnostics-format" "msvc"
+
+
+// RUN: ln -fs %clang %T/clang-cpp
+// RUN: ln -fs %clang %T/cpp
+// RUN: %T/clang-cpp        -### %s 2>&1 | FileCheck -check-prefix=CPPMODE %s
+// RUN: %T/cpp              -### %s 2>&1 | FileCheck -check-prefix=CPPMODE %s
+// CPPMODE: "-E"
+
+
+// RUN: ln -fs %clang %T/cl-clang
+// RUN: %T/cl-clang        -### %s 2>&1 | FileCheck -check-prefix=CMODE %s
+// CMODE: "-x" "c"
+// CMODE-NOT: "-fdiagnostics-format" "msvc"
+
+
+// RUN: ln -fs %clang %T/arm-linux-gnueabi-clang
+// RUN: %T/arm-linux-gnueabi-clang -### %s 2>&1 | FileCheck -check-prefix=TARGET %s
+// TARGET: Target: arm--linux-gnueabi
diff --git a/test/Driver/ppc-abi.c b/test/Driver/ppc-abi.c
new file mode 100644
index 0000000..6fee63a
--- /dev/null
+++ b/test/Driver/ppc-abi.c
@@ -0,0 +1,19 @@
+// Check passing PowerPC ABI options to the backend.
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ELFv1 %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1 %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
+
+// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ELFv2 %s
+// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv1 | FileCheck -check-prefix=CHECK-ELFv1 %s
+// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   -mabi=elfv2 | FileCheck -check-prefix=CHECK-ELFv2 %s
+
+// CHECK-ELFv1: "-target-abi" "elfv1"
+// CHECK-ELFv2: "-target-abi" "elfv2"
+
diff --git a/test/Driver/ppc-features.cpp b/test/Driver/ppc-features.cpp
index fa9a7ec..c62f5b9 100644
--- a/test/Driver/ppc-features.cpp
+++ b/test/Driver/ppc-features.cpp
@@ -95,6 +95,12 @@
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-vsx -mvsx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-VSX %s
 // CHECK-VSX: "-target-feature" "+vsx"
 
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOP8VECTOR %s
+// CHECK-NOP8VECTOR: "-target-feature" "-power8-vector"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-power8-vector -mpower8-vector -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-P8VECTOR %s
+// CHECK-P8VECTOR: "-target-feature" "+power8-vector"
+
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-crbits -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOCRBITS %s
 // CHECK-NOCRBITS: "-target-feature" "-crbits"
 
@@ -102,11 +108,11 @@
 // CHECK-CRBITS: "-target-feature" "+crbits"
 
 // Assembler features
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK_BE_AS_ARGS %s
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o -no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_BE_AS_ARGS %s
 // CHECK_BE_AS_ARGS: "-mppc64"
 // CHECK_BE_AS_ARGS: "-many"
 
-// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK_LE_AS_ARGS %s
+// RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o -no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_LE_AS_ARGS %s
 // CHECK_LE_AS_ARGS: "-mppc64"
 // CHECK_LE_AS_ARGS: "-many"
 // CHECK_LE_AS_ARGS: "-mlittle-endian"
diff --git a/test/Driver/prefixed-tools.c b/test/Driver/prefixed-tools.c
index d7c342a..cdd59da 100644
--- a/test/Driver/prefixed-tools.c
+++ b/test/Driver/prefixed-tools.c
@@ -6,7 +6,7 @@
 // RUN:        -m32 -target x86_64--linux %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-M32 %s
 
-// CHECK-M64: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-as"
-// CHECK-M64: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-ld"
-// CHECK-M32: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-as"
-// CHECK-M32: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-ld"
+// CHECK-M64: "{{.*}}{{/|\\\\}}prefixed_tools_tree{{/|\\\\}}x86_64--linux-as"
+// CHECK-M64: "{{.*}}{{/|\\\\}}prefixed_tools_tree{{/|\\\\}}x86_64--linux-ld"
+// CHECK-M32: "{{.*}}{{/|\\\\}}prefixed_tools_tree{{/|\\\\}}x86_64--linux-as"
+// CHECK-M32: "{{.*}}{{/|\\\\}}prefixed_tools_tree{{/|\\\\}}x86_64--linux-ld"
diff --git a/test/Driver/r600-mcpu.cl b/test/Driver/r600-mcpu.cl
index 7238ff4..47c0185 100644
--- a/test/Driver/r600-mcpu.cl
+++ b/test/Driver/r600-mcpu.cl
@@ -34,6 +34,7 @@
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=kabini %s -o - 2>&1 | FileCheck --check-prefix=KABINI-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=kaveri %s -o - 2>&1 | FileCheck --check-prefix=KAVERI-CHECK %s
 // RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=hawaii %s -o - 2>&1 | FileCheck --check-prefix=HAWAII-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=mullins %s -o - 2>&1 | FileCheck --check-prefix=MULLINS-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -58,3 +59,4 @@
 // KABINI-CHECK: "-target-cpu" "kabini"
 // KAVERI-CHECK: "-target-cpu" "kaveri"
 // HAWAII-CHECK: "-target-cpu" "hawaii"
+// MULLINS-CHECK: "-target-cpu" "mullins"
diff --git a/test/Driver/response-file.c b/test/Driver/response-file.c
new file mode 100644
index 0000000..208a941
--- /dev/null
+++ b/test/Driver/response-file.c
@@ -0,0 +1,23 @@
+// REQUIRES: long_tests
+
+// Check that clang is able to process short response files
+// Since this is a short response file, clang must not use a response file
+// to pass its parameters to other tools. This is only necessary for a large
+// number of parameters.
+// RUN: echo "-DTEST" >> %t.0.txt
+// RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT
+// SHORT-NOT: Arguments passed via response file
+// SHORT: extern int it_works;
+
+// Check that clang is able to process long response files, routing a long
+// sequence of arguments to other tools by using response files as well.
+// We generate a 2MB response file to be big enough to surpass any system
+// limit.
+// RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt
+// RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG
+// LONG: Arguments passed via response file
+// LONG: extern int it_works;
+
+#ifdef TEST
+extern int it_works;
+#endif
diff --git a/test/Driver/rewrite-legacy-objc.m b/test/Driver/rewrite-legacy-objc.m
index 0c6404e..b0b78d0 100644
--- a/test/Driver/rewrite-legacy-objc.m
+++ b/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
-// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fdiagnostics-show-option"
-// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fdiagnostics-show-option"
+// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m
index 95db582..ba5f835 100644
--- a/test/Driver/rewrite-objc.m
+++ b/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
diff --git a/test/Driver/sanitizer-ld.c b/test/Driver/sanitizer-ld.c
index 786262c..dc8e93e 100644
--- a/test/Driver/sanitizer-ld.c
+++ b/test/Driver/sanitizer-ld.c
@@ -9,11 +9,12 @@
 // CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-LINUX-NOT: "-lc"
 // CHECK-ASAN-LINUX: libclang_rt.asan-i386.a"
+// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
+// CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
+// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
 // CHECK-ASAN-LINUX: "-lpthread"
 // CHECK-ASAN-LINUX: "-lrt"
 // CHECK-ASAN-LINUX: "-ldl"
-// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
-// CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux -fsanitize=address -shared-libasan \
@@ -24,8 +25,8 @@
 // CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-lc"
 // CHECK-SHARED-ASAN-LINUX-NOT: libclang_rt.asan-i386.a"
-// CHECK-SHARED-ASAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-preinit-i386.a" "-no-whole-archive"
 // CHECK-SHARED-ASAN-LINUX: libclang_rt.asan-i386.so"
+// CHECK-SHARED-ASAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-preinit-i386.a" "-no-whole-archive"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-lpthread"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-lrt"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-ldl"
@@ -60,10 +61,10 @@
 // CHECK-ASAN-FREEBSD-NOT: libclang_rt.asan_cxx
 // CHECK-ASAN-FREEBSD: freebsd{{/|\\+}}libclang_rt.asan-i386.a"
 // CHECK-ASAN-FREEBSD-NOT: libclang_rt.asan_cxx
+// CHECK-ASAN-FREEBSD-NOT: "--dynamic-list"
+// CHECK-ASAN-FREEBSD: "-export-dynamic"
 // CHECK-ASAN-FREEBSD: "-lpthread"
 // CHECK-ASAN-FREEBSD: "-lrt"
-// CHECK-ASAN-FREEBSD: "-export-dynamic"
-// CHECK-ASAN-FREEBSD-NOT: "--dynamic-list"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-freebsd -fsanitize=address \
@@ -82,14 +83,14 @@
 //
 // CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-LINUX-CXX-NOT: "-lc"
-// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"
 // CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"
+// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
+// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
+// CHECK-ASAN-LINUX-CXX: stdc++
 // CHECK-ASAN-LINUX-CXX: "-lpthread"
 // CHECK-ASAN-LINUX-CXX: "-lrt"
 // CHECK-ASAN-LINUX-CXX: "-ldl"
-// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
-// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
-// CHECK-ASAN-LINUX-CXX: stdc++
 
 // RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
 // RUN:     -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \
@@ -126,10 +127,10 @@
 //
 // CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-ASAN-ANDROID-NOT: "-lc"
-// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
-// CHECK-ASAN-ANDROID-NOT: "-lpthread"
 // CHECK-ASAN-ANDROID: "-pie"
 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
+// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
+// CHECK-ASAN-ANDROID-NOT: "-lpthread"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target arm-linux-androideabi -fsanitize=address \
@@ -159,12 +160,13 @@
 // CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-TSAN-LINUX-CXX-NOT: stdc++
 // CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
+// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
+// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
+// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
+// CHECK-TSAN-LINUX-CXX: stdc++
 // CHECK-TSAN-LINUX-CXX: "-lpthread"
 // CHECK-TSAN-LINUX-CXX: "-lrt"
 // CHECK-TSAN-LINUX-CXX: "-ldl"
-// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
-// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
-// CHECK-TSAN-LINUX-CXX: stdc++
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target x86_64-unknown-linux -lstdc++ -fsanitize=memory \
@@ -175,12 +177,13 @@
 // CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-MSAN-LINUX-CXX-NOT: stdc++
 // CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
+// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
+// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
+// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
+// CHECK-MSAN-LINUX-CXX: stdc++
 // CHECK-MSAN-LINUX-CXX: "-lpthread"
 // CHECK-MSAN-LINUX-CXX: "-lrt"
 // CHECK-MSAN-LINUX-CXX: "-ldl"
-// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
-// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
-// CHECK-MSAN-LINUX-CXX: stdc++
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux \
@@ -188,12 +191,23 @@
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
 // CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
 // CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
 // CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
-// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
 // CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
-// CHECK-UBSAN-LINUX: "-lpthread"
+// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
 // CHECK-UBSAN-LINUX-NOT: "-lstdc++"
+// CHECK-UBSAN-LINUX: "-lpthread"
+
+// RUN: %clang -fsanitize=undefined -fsanitize-link-c++-runtime %s -### -o %t.o 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-LINK-CXX %s
+// CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
+// CHECK-UBSAN-LINUX-LINK-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
 
 // RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux \
@@ -205,11 +219,16 @@
 // CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
 // CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
 // CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
 // CHECK-UBSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.ubsan-i386.a.syms"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
 // CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
-// CHECK-UBSAN-LINUX-CXX: "-lpthread"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
 // CHECK-UBSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.ubsan_cxx-i386.a.syms"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
 // CHECK-UBSAN-LINUX-CXX: "-lstdc++"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX-CXX: "-lpthread"
 
 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux \
@@ -221,8 +240,8 @@
 // CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
 // CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
 // CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
-// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
 // CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
+// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
 
 // RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux \
@@ -234,8 +253,8 @@
 // CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
-// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux \
@@ -271,8 +290,8 @@
 // CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.san
 // CHECK-LSAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-x86_64.a" "-no-whole-archive"
 // CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
-// CHECK-LSAN-UBSAN-LINUX: "-lpthread"
 // CHECK-LSAN-UBSAN-LINUX-NOT: "-lstdc++"
+// CHECK-LSAN-UBSAN-LINUX: "-lpthread"
 
 // RUN: %clang -fsanitize=leak,address %s -### -o %t.o 2>&1 \
 // RUN:     -target x86_64-unknown-linux \
diff --git a/test/Driver/sparc-float.c b/test/Driver/sparc-float.c
new file mode 100644
index 0000000..e84c487
--- /dev/null
+++ b/test/Driver/sparc-float.c
@@ -0,0 +1,42 @@
+// Check handling -mhard-float / -msoft-float options
+// when build for SPARC platforms.
+//
+// Default sparc
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN:     -target sparc-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-DEF %s
+// CHECK-DEF: "-target-feature" "+soft-float"
+// CHECK-DEF: "-msoft-float"
+//
+// -mhard-float
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN:     -target sparc-linux-gnu -mhard-float \
+// RUN:   | FileCheck --check-prefix=CHECK-HARD %s
+// CHECK-HARD: "-mhard-float"
+//
+// -msoft-float
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN:     -target sparc-linux-gnu -msoft-float \
+// RUN:   | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: "-target-feature" "+soft-float"
+// CHECK-SOFT: "-msoft-float"
+//
+// Default sparc64
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN:     -target sparc64-linux-gnu \
+// RUN:   | FileCheck --check-prefix=CHECK-DEF-SPARC64 %s
+// CHECK-DEF-SPARC64: "-target-feature" "+soft-float"
+// CHECK-DEF-SPARC64: "-msoft-float"
+//
+// -mhard-float
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN:     -target sparc64-linux-gnu -mhard-float \
+// RUN:   | FileCheck --check-prefix=CHECK-HARD-SPARC64 %s
+// CHECK-HARD-SPARC64: "-mhard-float"
+//
+// -msoft-float
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN:     -target sparc64-linux-gnu -msoft-float \
+// RUN:   | FileCheck --check-prefix=CHECK-SOFT-SPARC64 %s
+// CHECK-SOFT-SPARC64: "-target-feature" "+soft-float"
+// CHECK-SOFT-SPARC64: "-msoft-float"
diff --git a/test/Driver/split-debug.c b/test/Driver/split-debug.c
index 792abbd..6296c46 100644
--- a/test/Driver/split-debug.c
+++ b/test/Driver/split-debug.c
@@ -1,6 +1,5 @@
 // Check that we split debug output properly
 //
-// REQUIRES: asserts
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
diff --git a/test/Driver/split-debug.s b/test/Driver/split-debug.s
index d5f077a..64e8f2f 100644
--- a/test/Driver/split-debug.s
+++ b/test/Driver/split-debug.s
@@ -1,6 +1,5 @@
 // Check that we split debug output properly
 //
-// REQUIRES: asserts
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
diff --git a/test/Driver/systemz-as.s b/test/Driver/systemz-as.s
new file mode 100644
index 0000000..34ad9c4
--- /dev/null
+++ b/test/Driver/systemz-as.s
@@ -0,0 +1,14 @@
+// Make sure SystemZ defaults to using the integrated assembler
+
+// RUN: %clang -target s390x-ibm-linux -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=IAS %s
+
+// RUN: %clang -target s390x-ibm-linux -integrated-as -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=IAS %s
+// IAS: "-cc1as"{{.*}} "-target-cpu" "z10"
+
+// RUN: %clang -target s390x-ibm-linux -no-integrated-as -### -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=NO-IAS %s
+// NO-IAS-NOT: -cc1as
+// NO-IAS: "-march=z10"
+
diff --git a/test/Driver/thread-model.c b/test/Driver/thread-model.c
new file mode 100644
index 0000000..9702c22
--- /dev/null
+++ b/test/Driver/thread-model.c
@@ -0,0 +1,15 @@
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -mthread-model posix -v 2>&1 | FileCheck -check-prefix=CHECK-POSIX %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -mthread-model single -v 2>&1 | FileCheck -check-prefix=CHECK-SINGLE %s
+// RUN: not %clang -target arm-unknown-linux-gnu -c %s -mthread-model silly -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+// CHECK-POSIX: "-mthread-model" "posix"
+// CHECK-SINGLE: "-mthread-model" "single"
+// CHECK-INVALID: error: invalid thread model 'silly' in '-mthread-model silly' for this target
+
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-LINUX-POSIX %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v -mthread-model single 2>&1 | FileCheck -check-prefix=CHECK-LINUX-SINGLE %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v -mthread-model silly 2>&1 | FileCheck -check-prefix=CHECK-LINUX-INVALID %s
+// CHECK-LINUX-POSIX: Thread model: posix
+// CHECK-LINUX-POSIX: "-mthread-model" "posix"
+// CHECK-LINUX-SINGLE: Thread model: single
+// CHECK-LINUX-SINGLE: "-mthread-model" "single"
+// CHECK-LINUX-INVALID-NOT: Thread model:
diff --git a/test/Driver/unknown-gcc-arch.c b/test/Driver/unknown-gcc-arch.c
index 6317e13..9e687b7 100644
--- a/test/Driver/unknown-gcc-arch.c
+++ b/test/Driver/unknown-gcc-arch.c
@@ -14,23 +14,23 @@
 // RUN: -no-integrated-as 2>&1 | FileCheck -check-prefix=I386-M64 %s
 // I386-M64: {{.*as.*--64}}
 
-
-// RUN: %clang -target powerpc64-unknown-unknown -c -x assembler %s -### 2>&1 \
-// RUN:   | FileCheck -check-prefix=PPC64 %s
+// RUN: %clang -target powerpc64-unknown-unknown -c -x assembler %s -### \
+// RUN: -no-integrated-as 2>&1 | FileCheck -check-prefix=PPC64 %s
 // PPC64: {{.*as.*-a64}}
 
-// RUN: %clang -target powerpc64-unknown-unknown -c -x assembler %s -### -m32 2>&1 \
-// RUN:   | FileCheck -check-prefix=PPC64-M32 %s
+// RUN: %clang -target powerpc-unknown-unknown -c -x assembler %s -### -m64 \
+// RUN: -no-integrated-as 2>&1  | FileCheck -check-prefix=PPC-M64 %s
+// PPC-M64: {{.*as.*-a64}}
+
+
+// RUN: %clang -target powerpc64-unknown-unknown -c -x assembler %s -### -m32 \
+// RUN: 2>&1 | FileCheck -check-prefix=PPC64-M32 %s
 // PPC64-M32: {{.*as.*-a32}}
 
 // RUN: %clang -target powerpc-unknown-unknown -c -x assembler %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=PPC %s
 // PPC: {{.*as.*-a32}}
 
-// RUN: %clang -target powerpc-unknown-unknown -c -x assembler %s -### -m64 2>&1 \
-// RUN:   | FileCheck -check-prefix=PPC-M64 %s
-// PPC-M64: {{.*as.*-a64}}
-
 // RUN: %clang -target sparc64-unknown-unknown -no-integrated-as -c -x assembler %s -### -m32 2>&1 \
 // RUN:   | FileCheck -check-prefix=SPARCV8 %s
 // SPARCV8: {{.*as.*-32}}
diff --git a/test/Driver/windows-cross.c b/test/Driver/windows-cross.c
new file mode 100644
index 0000000..c8dbfdb
--- /dev/null
+++ b/test/Driver/windows-cross.c
@@ -0,0 +1,40 @@
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-BASIC
+
+// CHECK-BASIC: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-RTLIB
+
+// CHECK-RTLIB: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}libclang_rt.builtins-arm.lib"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-C-LIBCXX
+
+// CHECK-C-LIBCXX: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}libclang_rt.builtins-arm.lib"
+
+// RUN: %clangxx -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-LIBCXX
+
+// CHECK-LIBCXX: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "{{.*}}.o" "-lc++" "-lmsvcrt" "{{.*[\\/]}}libclang_rt.builtins-arm.lib"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -shared -rtlib=compiler-rt -stdlib=libc++ -o shared.dll %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-SHARED
+
+// CHECK-SHARED: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-shared" "-Bdynamic" "--enable-auto-image-base" "--entry" "_DllMainCRTStartup" "--allow-multiple-definition" "-o" "shared.dll" "--out-implib" "shared.lib" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbeginS.obj" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}libclang_rt.builtins-arm.lib"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -shared -rtlib=compiler-rt -stdlib=libc++ -nostartfiles -o shared.dll %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-NOSTARTFILES
+
+// CHECK-NOSTARTFILES: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-shared" "-Bdynamic" "--enable-auto-image-base" "--entry" "_DllMainCRTStartup" "--allow-multiple-definition" "-o" "shared.dll" "--out-implib" "shared.lib" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}libclang_rt.builtins-arm.lib"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -shared -rtlib=compiler-rt -stdlib=libc++ -nostartfiles -nodefaultlibs -o shared.dll %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-STANDALONE
+
+// CHECK-STANDALONE: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-shared" "-Bdynamic" "--enable-auto-image-base" "--entry" "_DllMainCRTStartup" "--allow-multiple-definition" "-o" "shared.dll" "--out-implib" "shared.lib" "{{.*}}.o"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %/Inputs/Windows/ARM/8.1/usr/bin -shared -o shared.dll -x c++ %s 2>&1 \
+// RUN:    | FileCheck %s --check-prefix CHECK-LIBSTDCXX
+
+// CHECK-LIBSTDCXX:  "-internal-isystem" "{{.*}}/usr/include/c++" "-internal-isystem" "{{.*}}/usr/include/c++/armv7--windows-itanium" "-internal-isystem" "{{.*}}/usr/include/c++/backwards"
+
diff --git a/test/Driver/windows-wildcard-expansion.c b/test/Driver/windows-wildcard-expansion.c
new file mode 100644
index 0000000..3977dc3
--- /dev/null
+++ b/test/Driver/windows-wildcard-expansion.c
@@ -0,0 +1,7 @@
+// Clang does wildcard expansion on Windows. On other OSs, it's done by the shell.
+// REQUIRES: system-windows
+
+// RUN: %clang -c -### %S/Inputs/wildcard*.c 2>&1 | FileCheck %s
+// RUN: %clang -c -### %S/Inputs/wildcard?.c 2>&1 | FileCheck %s
+// CHECK: wildcard1.c
+// CHECK: wildcard2.c
diff --git a/test/FixIt/fixit-class-method-messaging.m b/test/FixIt/fixit-class-method-messaging.m
new file mode 100644
index 0000000..e2592d0
--- /dev/null
+++ b/test/FixIt/fixit-class-method-messaging.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// rdar://16263395
+
+@interface NSObject @end
+
+@interface I : NSObject // expected-note 3 {{receiver is instance of class declared here}}
++ (id) ClassMeth;
+- (I*) MethInstPI;
+@end
+
+I* pi;
+
+I* foobar();
+
+@implementation I
+- (id) PrivInstMeth {
+  [ foobar() ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \
+			 // expected-note {{receiver expression is here}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:5-[[@LINE-2]]:13}:"I
+  [[self MethInstPI] ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \
+				 // expected-note {{receiver expression is here}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:4-[[@LINE-2]]:21}:"I
+  return [pi ClassMeth]; // expected-warning {{instance method '-ClassMeth' not found (return type defaults to 'id')}} \
+                         // expected-note {{receiver expression is here}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:11-[[@LINE-2]]:13}:"I
+}
++ (id) ClassMeth { return 0; }
+- (I*) MethInstPI { return 0; }
+@end
diff --git a/test/FixIt/fixit-cxx1y-compat.cpp b/test/FixIt/fixit-cxx1y-compat.cpp
index 9fd5ff2..819e398 100644
--- a/test/FixIt/fixit-cxx1y-compat.cpp
+++ b/test/FixIt/fixit-cxx1y-compat.cpp
@@ -7,6 +7,6 @@
 // This is a test of the code modification hints for C++1y-compatibility problems.
 
 struct S {
-  constexpr int &f(); // expected-warning {{'constexpr' non-static member function will not be implicitly 'const' in C++1y; add 'const' to avoid a change in behavior}}
+  constexpr int &f(); // expected-warning {{'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior}}
   int &f();
 };
diff --git a/test/FixIt/fixit-errors.c b/test/FixIt/fixit-errors.c
index c425fc8..d727adb 100644
--- a/test/FixIt/fixit-errors.c
+++ b/test/FixIt/fixit-errors.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -fixit -x c %t
-// RUN: %clang_cc1 -pedantic -Werror -x c %t
+// RUN: %clang_cc1 -pedantic -Werror -Wno-invalid-noreturn -x c %t
 
 /* This is a test of the various code modification hints that are
    provided as part of warning or extension diagnostics. All of the
@@ -21,3 +21,11 @@
 void test_point() {
   (void)get_origin->x; // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments?}}
 }
+
+void noreturn_1() _Noreturn; // expected-error {{must precede function declarator}}
+void noreturn_1() {
+  return; // expected-warning {{should not return}}
+}
+void noreturn_2() _Noreturn { // expected-error {{must precede function declarator}}
+  return; // expected-warning {{should not return}}
+}
diff --git a/test/FixIt/fixit-unrecoverable.cpp b/test/FixIt/fixit-unrecoverable.cpp
index 1e1f1b8..f555792 100644
--- a/test/FixIt/fixit-unrecoverable.cpp
+++ b/test/FixIt/fixit-unrecoverable.cpp
@@ -6,7 +6,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 float f(int y) {
-  return static_cst<float>(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}} \
-  // expected-error{{for function-style cast or type construction}}
+  return static_cst<float>(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}}
 }
-
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index f264938..20b5b52 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s
-// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t
 // RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t
@@ -308,6 +308,13 @@
     ~bar() { }  // expected-error {{expected the class name after '~' to name a destructor}}
     // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:6-[[@LINE-1]]:9}:"foo"
   };
+
+  class bar {
+    ~bar();
+  };
+  ~bar::bar() {} // expected-error {{'~' in destructor name should be after nested name specifier}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:4}:""
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:9-[[@LINE-2]]:9}:"~"
 }
 
 namespace PR5066 {
@@ -340,3 +347,37 @@
     return c->a;  // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; maybe you meant to use '.'?}}
   }
 }
+
+namespace curly_after_base_clause {
+struct A { void f(); };
+struct B : A // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+  int i;
+};
+struct C : A // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+  using A::f;
+};
+struct D : A // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+    protected:
+};
+struct E : A  // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+  template<typename T> struct inner { };
+};
+struct F : A  // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+  F() { }
+};
+#if __cplusplus >= 201103L
+struct G : A  // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+  constexpr G(int) { }
+};
+struct H : A  // expected-error{{expected '{' after base class list}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
+  static_assert(true, "");
+};
+#endif
+}
diff --git a/test/FixIt/lit.local.cfg b/test/FixIt/lit.local.cfg
deleted file mode 100644
index 5bbc711..0000000
--- a/test/FixIt/lit.local.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-if config.root.clang_rewriter == 0:
-    config.unsupported = True
diff --git a/test/FixIt/multiarg-selector-fixit.m b/test/FixIt/multiarg-selector-fixit.m
new file mode 100644
index 0000000..d60d312
--- /dev/null
+++ b/test/FixIt/multiarg-selector-fixit.m
@@ -0,0 +1,15 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x objective-c -fixit %t
+// RUN: diff %t %s
+// rdar://15756038
+
+#define nil (void *)0
+
+@interface NSObject
+- (void)testDataSource:(id)object withMultipleArguments:(id)arguments;
+@end
+
+int main() {
+  id obj;
+  [obj TestDataSource:nil withMultipleArguments:nil];
+}
diff --git a/test/FixIt/property-access-fixit.m b/test/FixIt/property-access-fixit.m
new file mode 100644
index 0000000..8623d29
--- /dev/null
+++ b/test/FixIt/property-access-fixit.m
@@ -0,0 +1,31 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x objective-c -fixit %t
+// RUN: %clang_cc1 -x objective-c -Werror %t
+//rdar://17911746
+
+@class BridgeFormatter;
+
+@interface NSObject 
++ (id)new;
+@end
+
+@interface X : NSObject
+@property int x;
+@property int Y;
+@property(assign, readwrite, getter=formatter, setter=setFormatter:) BridgeFormatter* cppFormatter;
+@end
+
+@implementation X
+- (void) endit
+{
+ self.formatter = 0;
+}
+@end
+ 
+int main()
+{
+    X *obj = [X new];
+    obj.X = 3;
+    obj.y = 4;
+    return obj.x + obj.Y;
+}
diff --git a/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof b/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof
new file mode 100644
index 0000000..ba9a678
--- /dev/null
+++ b/test/Frontend/Inputs/profile-sample-use-loc-tracking.prof
@@ -0,0 +1,2 @@
+bar:100:100
+1: 2000
diff --git a/test/Frontend/darwin-version.c b/test/Frontend/darwin-version.c
index 7234ab4..2e0804b 100644
--- a/test/Frontend/darwin-version.c
+++ b/test/Frontend/darwin-version.c
@@ -23,3 +23,5 @@
 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1
+// RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min=10.10 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '101000' | count 1
diff --git a/test/Frontend/exceptions.c b/test/Frontend/exceptions.c
index 4bbaaa3..981b5b9 100644
--- a/test/Frontend/exceptions.c
+++ b/test/Frontend/exceptions.c
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -fms-compatibility -fexceptions -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -fms-compatibility -fexceptions -fcxx-exceptions -DMS_MODE -verify %s
 // expected-no-diagnostics
 
-#if defined(__EXCEPTIONS)
+// RUN: %clang_cc1 -fms-compatibility -fexceptions -verify %s
+// expected-no-diagnostics
+
+#if defined(MS_MODE) && defined(__EXCEPTIONS)
 #error __EXCEPTIONS should not be defined.
 #endif
diff --git a/test/Frontend/invalid-o-level.c b/test/Frontend/invalid-o-level.c
index b9e01fc..73be9b1 100644
--- a/test/Frontend/invalid-o-level.c
+++ b/test/Frontend/invalid-o-level.c
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 %s -O900 -o /dev/null 2> %t.log
 // RUN: FileCheck %s -input-file=%t.log
 
-// CHECK: warning: optimization level '-O900' is unsupported; using '-O3' instead
+// CHECK: warning: optimization level '-O900' is not supported; using '-O3' instead
diff --git a/test/Frontend/optimization-remark.c b/test/Frontend/optimization-remark.c
index e512253..6ada003 100644
--- a/test/Frontend/optimization-remark.c
+++ b/test/Frontend/optimization-remark.c
@@ -6,6 +6,21 @@
 // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -verify
 // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -gline-tables-only -verify
 // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s
+//
+// Check that we can override -Rpass= with -Rno-pass.
+// RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+//
+// FIXME: -Reverything should imply -Rpass=.*.
+// RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+//
+// FIXME: -Rpass should either imply -Rpass=.* or should be rejected.
+// RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+
+// CHECK-REMARKS: remark:
+// CHECK-NO-REMARKS-NOT: remark:
 
 // -Rpass should produce source location annotations, exclusively (just
 // like -gmlt).
diff --git a/test/Frontend/output-failures.c b/test/Frontend/output-failures.c
index e2af7c7..362deb5 100644
--- a/test/Frontend/output-failures.c
+++ b/test/Frontend/output-failures.c
@@ -1,4 +1,4 @@
 // RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
-// OUTPUTFAIL: Error opening output file '{{.*}}doesnotexist{{.*}}'
+// OUTPUTFAIL: error: unable to open output file '{{.*}}{{[/\\]}}test{{[/\\]}}Frontend{{[/\\]}}doesnotexist{{[/\\]}}somename': '{{[nN]}}o such file or directory'
diff --git a/test/Frontend/print-header-includes.c b/test/Frontend/print-header-includes.c
index e248c76..6fde00c 100644
--- a/test/Frontend/print-header-includes.c
+++ b/test/Frontend/print-header-includes.c
@@ -1,3 +1,6 @@
+// REQUIRES: shell
+
+// RUN: cd %S
 // RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.stderr
 // RUN: FileCheck < %t.stderr %s
 
diff --git a/test/Frontend/profile-sample-use-loc-tracking.c b/test/Frontend/profile-sample-use-loc-tracking.c
new file mode 100644
index 0000000..31faad6
--- /dev/null
+++ b/test/Frontend/profile-sample-use-loc-tracking.c
@@ -0,0 +1,19 @@
+// This file tests that -fprofile-sample-use enables location tracking
+// generation in the same way that -Rpass does. The sample profiler needs
+// to associate line locations in the profile to the code, so it needs the
+// frontend to emit source location annotations.
+
+// RUN: %clang_cc1 %s -fprofile-sample-use=%S/Inputs/profile-sample-use-loc-tracking.prof -emit-llvm -o - 2>/dev/null | FileCheck %s
+
+// -fprofile-sample-use should produce source location annotations, exclusively
+// (just like -gmlt).
+// CHECK: , !dbg !
+// CHECK-NOT: DW_TAG_base_type
+
+// But llvm.dbg.cu should be missing (to prevent writing debug info to
+// the final output).
+// CHECK-NOT: !llvm.dbg.cu = !{
+
+int bar(int j) {
+  return (j + j - 2) * (j - 2) * j;
+}
diff --git a/test/Frontend/rewrite-macros.c b/test/Frontend/rewrite-macros.c
index eab6657..759afb0 100644
--- a/test/Frontend/rewrite-macros.c
+++ b/test/Frontend/rewrite-macros.c
@@ -17,5 +17,3 @@
 
 // CHECK: {{^}}//#pragma mark mark{{$}}
 #pragma mark mark
-
-
diff --git a/test/Frontend/std.cl b/test/Frontend/std.cl
new file mode 100644
index 0000000..b811b64
--- /dev/null
+++ b/test/Frontend/std.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.1
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0
+// RUN: not %clang_cc1 %s -fsyntax-only -cl-std=invalid -DINVALID 2>&1 | FileCheck %s
+
+#ifdef INVALID 
+// CHECK: invalid value 'invalid' in '-cl-std=invalid'
+#endif
diff --git a/test/Frontend/warning-options.cpp b/test/Frontend/warning-options.cpp
index 85bea62..3c3396b 100644
--- a/test/Frontend/warning-options.cpp
+++ b/test/Frontend/warning-options.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
-// RUN:        -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
+// RUN:        -Wno-unused-command-line-argument -Wmodule-build -Rmodule-built %s 2>&1 | FileCheck %s
 // CHECK: unknown warning option '-Wmonkey'
 // CHECK: unknown warning option '-Wno-monkey'
 // CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?
+// CHECK: unknown warning option '-Wmodule-build'; did you mean '-Wmodule-conflict'?
+// CHECK: unknown remark option '-Rmodule-built'; did you mean '-Rmodule-build'?
diff --git a/test/Headers/altivec-header.c b/test/Headers/altivec-header.c
index 3d85957..7b6c516 100644
--- a/test/Headers/altivec-header.c
+++ b/test/Headers/altivec-header.c
@@ -12,4 +12,5 @@
 // CHECK-NEXT: .file
 // CHECK-NEXT: {{^$}}
 // CHECK-NEXT: .ident{{.*$}}
+// CHECK-NEXT: .section ".note.GNU-stack","",@progbits
 // CHECK-NOT: .
diff --git a/test/Headers/altivec-intrin.c b/test/Headers/altivec-intrin.c
new file mode 100644
index 0000000..a4de7e7
--- /dev/null
+++ b/test/Headers/altivec-intrin.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -target-cpu power8 \
+// RUN:     -faltivec -verify %s
+
+// Test special behavior of Altivec intrinsics in this file.
+
+#include <altivec.h>
+
+__attribute__((__aligned__(16))) float x[20];
+
+int main()
+{
+  vector unsigned char l = vec_lvsl (0, &x[1]); // expected-warning {{is deprecated: use assignment for unaligned little endian loads/stores}}
+  vector unsigned char r = vec_lvsr (0, &x[1]); // expected-warning {{is deprecated: use assignment for unaligned little endian loads/stores}}
+}
+// FIXME: As noted in ms-intrin.cpp, it would be nice if we didn't have to
+// hard-code the line number from altivec.h here.
+// expected-note@altivec.h:2389 {{deprecated here}}
+// expected-note@altivec.h:2524 {{deprecated here}}
diff --git a/test/Headers/arm-acle-header.c b/test/Headers/arm-acle-header.c
index 523e77e..d9d2e04 100644
--- a/test/Headers/arm-acle-header.c
+++ b/test/Headers/arm-acle-header.c
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -triple armv7 -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s
-// RUN: %clang_cc1 -triple aarch64 -target-cpu cortex-a53 -fsyntax-only -ffreestanding %s
-// RUN: %clang_cc1 -x c++ -triple armv7 -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s
-// RUN: %clang_cc1 -x c++ -triple aarch64 -target-cpu cortex-a57 -fsyntax-only -ffreestanding %s
+// RUN: %clang_cc1 -triple armv7-eabi -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s
+// RUN: %clang_cc1 -triple aarch64-eabi -target-cpu cortex-a53 -fsyntax-only -ffreestanding %s
+// RUN: %clang_cc1 -triple thumbv7-windows -target-cpu cortex-a53 -fsyntax-only -ffreestanding %s
+// RUN: %clang_cc1 -x c++ -triple armv7-eabi -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s
+// RUN: %clang_cc1 -x c++ -triple aarch64-eabi -target-cpu cortex-a57 -fsyntax-only -ffreestanding %s
+// RUN: %clang_cc1 -x c++ -triple thumbv7-windows -target-cpu cortex-a15 -fsyntax-only -ffreestanding %s
 // expected-no-diagnostics
 
 #include <arm_acle.h>
diff --git a/test/Headers/c11.c b/test/Headers/c11.c
index c1454c8..6594823 100644
--- a/test/Headers/c11.c
+++ b/test/Headers/c11.c
@@ -1,8 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules -fmodules-cache-path=%t %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules -fmodules-cache-path=%t %s -D__STDC_WANT_LIB_EXT1__=1
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 -fmsc-version=1700 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 -fms-compatibility-version=17.00 %s
 
 noreturn int f(); // expected-error 1+{{}}
 
diff --git a/test/Headers/cpuid.c b/test/Headers/cpuid.c
new file mode 100644
index 0000000..b0ba07a
--- /dev/null
+++ b/test/Headers/cpuid.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-64
+// RUN: %clang_cc1 %s -ffreestanding -triple i386 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-32
+
+#include <cpuid.h>
+
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A cpuid\0A xchgq %rbx,${1:q}", "={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  cpuid\0A  xchgq  %rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}})
+
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}})
+
+unsigned eax0, ebx0, ecx0, edx0;
+unsigned eax1, ebx1, ecx1, edx1;
+
+void test_cpuid(unsigned level, unsigned count) {
+  __cpuid(level, eax1, ebx1, ecx1, edx1);
+  __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
+}
diff --git a/test/Headers/cxx11.cpp b/test/Headers/cxx11.cpp
index 5b0ec0b..0b35a7c 100644
--- a/test/Headers/cxx11.cpp
+++ b/test/Headers/cxx11.cpp
@@ -1,5 +1,6 @@
+// RUN: rm -rf %t
 // RUN: %clang_cc1 -ffreestanding -fsyntax-only -std=c++11 %s
-// RUN: %clang_cc1 -ffreestanding -fsyntax-only -std=c++11 -fmodules %s
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -std=c++11 -fmodules -fmodules-cache-path=%t %s
 
 // This test fails on systems with older OS X 10.9 SDK headers, see PR18322.
 
diff --git a/test/Headers/ms-intrin.cpp b/test/Headers/ms-intrin.cpp
index d2cc627..a83225e 100644
--- a/test/Headers/ms-intrin.cpp
+++ b/test/Headers/ms-intrin.cpp
@@ -1,16 +1,21 @@
 // RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu pentium4 \
-// RUN:     -fms-extensions -fms-compatibility -fmsc-version=1700 \
+// RUN:     -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN:     -ffreestanding -fsyntax-only -Werror \
+// RUN:     -isystem %S/Inputs/include %s
+
+// RUN: %clang_cc1 -triple i386-pc-win32 -target-cpu broadwell \
+// RUN:     -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN:     -ffreestanding -fsyntax-only -Werror \
 // RUN:     -isystem %S/Inputs/include %s
 
 // RUN: %clang_cc1 -triple x86_64-pc-win32  \
-// RUN:     -fms-extensions -fms-compatibility -fmsc-version=1700 \
+// RUN:     -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN:     -ffreestanding -fsyntax-only -Werror \
 // RUN:     -isystem %S/Inputs/include %s
 
 // RUN: %clang_cc1 -triple thumbv7--windows \
-// RUN:     -ffreestanding -fsyntax-only -fms-compatibility -fmsc-version=1700 \
-// RUN:     -Werror \
+// RUN:     -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN:     -ffreestanding -fsyntax-only -Werror \
 // RUN:     -isystem %S/Inputs/include %s
 
 // Intrin.h needs size_t, but -ffreestanding prevents us from getting it from
diff --git a/test/Headers/ms-null-ms-header-vs-stddef.cpp b/test/Headers/ms-null-ms-header-vs-stddef.cpp
index 237ed51..e391089 100644
--- a/test/Headers/ms-null-ms-header-vs-stddef.cpp
+++ b/test/Headers/ms-null-ms-header-vs-stddef.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -fms-compatibility -fmsc-version=1700 %s
+// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -fms-compatibility -fms-compatibility-version=17.00 %s
 // RUN: %clang_cc1 -fsyntax-only -triple i386-mingw32 %s
 
 // Something in MSVC's headers (pulled in e.g. by <crtdefs.h>) defines __null
diff --git a/test/Headers/x86intrin.c b/test/Headers/x86intrin.c
index d095c00..4c9665b 100644
--- a/test/Headers/x86intrin.c
+++ b/test/Headers/x86intrin.c
@@ -84,6 +84,18 @@
 #ifndef __RDRND__
 #define __RDRND__
 #endif
+#ifndef __AVX512F__
+#define __AVX512F__
+#endif
+#ifndef __AVX512VL__
+#define __AVX512VL__
+#endif
+#ifndef __AVX512BW__
+#define __AVX512BW__
+#endif
+#ifndef __AVX512ER__
+#define __AVX512ER__
+#endif
 
 // Now include the metaheader that includes all x86 intrinsic headers.
 #include <x86intrin.h>
diff --git a/test/Index/Inputs/complete-at-EOF.c b/test/Index/Inputs/complete-at-EOF.c
new file mode 100644
index 0000000..8207f72
--- /dev/null
+++ b/test/Index/Inputs/complete-at-EOF.c
@@ -0,0 +1,3 @@
+#define CAKE 1
+
+typedef int foo;
diff --git a/test/Index/Inputs/declare-objc-predef.h b/test/Index/Inputs/declare-objc-predef.h
new file mode 100644
index 0000000..6a03c4f
--- /dev/null
+++ b/test/Index/Inputs/declare-objc-predef.h
@@ -0,0 +1,3 @@
+@class Protocol;
+typedef struct objc_class *Class
+@class id;
diff --git a/test/Index/Inputs/module-undef.h b/test/Index/Inputs/module-undef.h
new file mode 100644
index 0000000..8212d75
--- /dev/null
+++ b/test/Index/Inputs/module-undef.h
@@ -0,0 +1,2 @@
+#define MY_MACRO 1
+#undef MY_MACRO
diff --git a/test/Index/Inputs/module.map b/test/Index/Inputs/module.map
index 8f24840..4bfc109 100644
--- a/test/Index/Inputs/module.map
+++ b/test/Index/Inputs/module.map
@@ -4,3 +4,5 @@
   export *
 }
 framework module * { }
+
+module ModuleUndef { header "module-undef.h" }
diff --git a/test/Index/annotate-deep-statements.cpp b/test/Index/annotate-deep-statements.cpp
index c0a55f2..1803c2b 100644
--- a/test/Index/annotate-deep-statements.cpp
+++ b/test/Index/annotate-deep-statements.cpp
@@ -3,8 +3,8 @@
 // rdar://11979525
 // Check that we don't get stack overflow trying to annotate an extremely deep AST.
 
-// AddressSanitizer increases stack usage.
-// REQUIRES: not_asan
+// AddressSanitizer and UndefinedBehaviorSanitizer increases stack usage.
+// REQUIRES: not_asan, not_ubsan
 
 struct S {
   S &operator()();
diff --git a/test/Index/attributes-cuda.cu b/test/Index/attributes-cuda.cu
index 953ef3d..824bdb4 100644
--- a/test/Index/attributes-cuda.cu
+++ b/test/Index/attributes-cuda.cu
@@ -3,6 +3,7 @@
 __attribute__((device)) void f_device();
 __attribute__((global)) void f_global();
 __attribute__((constant)) int* g_constant;
+__attribute__((shared)) float *g_shared;
 __attribute__((host)) void f_host();
 
 // CHECK:       attributes-cuda.cu:3:30: FunctionDecl=f_device:3:30
@@ -11,5 +12,7 @@
 // CHECK-NEXT:  attributes-cuda.cu:4:16: attribute(global)
 // CHECK:       attributes-cuda.cu:5:32: VarDecl=g_constant:5:32 (Definition)
 // CHECK-NEXT:  attributes-cuda.cu:5:16: attribute(constant)
-// CHECK:       attributes-cuda.cu:6:28: FunctionDecl=f_host:6:28
-// CHECK-NEXT:  attributes-cuda.cu:6:16: attribute(host)
+// CHECK:       attributes-cuda.cu:6:32: VarDecl=g_shared:6:32 (Definition)
+// CHECK-NEXT:  attributes-cuda.cu:6:16: attribute(shared)
+// CHECK:       attributes-cuda.cu:7:28: FunctionDecl=f_host:7:28
+// CHECK-NEXT:  attributes-cuda.cu:7:16: attribute(host)
diff --git a/test/Index/comment-c-decls.c b/test/Index/comment-c-decls.c
index 371e453..2a99b36 100644
--- a/test/Index/comment-c-decls.c
+++ b/test/Index/comment-c-decls.c
@@ -101,4 +101,4 @@
  *\brief block declaration
 */
 int (^Block1) (int i, int j) = ^(int i, int j) { return i + j; };
-// CHECK: <Declaration>int (^Block1)(int, int) = ^(int i, int j) {}</Declaration>
+// CHECK: <Declaration>int (^Block1)(int, int) = ^(int i, int j) {\n}</Declaration>
diff --git a/test/Index/comment-lots-of-unknown-commands.c b/test/Index/comment-lots-of-unknown-commands.c
new file mode 100644
index 0000000..f0640ef
--- /dev/null
+++ b/test/Index/comment-lots-of-unknown-commands.c
@@ -0,0 +1,295 @@
+// RUN: c-index-test -test-load-source-reparse 1 local %s | FileCheck %s
+
+// See PR 21254. We had too few bits to encode command IDs so if you created
+// enough of them the ID codes would wrap around. This test creates commands up
+// to an ID of 258. Ideally we should check for large numbers, but that would
+// require a test source file which is megabytes in size. This is the test case
+// from the PR.
+
+/**
+@s
+@tr
+@y
+@tt
+@tg
+@alu
+@U
+@I
+@r
+@t0
+@t1
+@ur
+@S
+@E
+@pb
+@f
+@pe
+@lue
+@re
+@oa
+@l
+@x
+@R
+@ute
+@am
+@ei
+@oun
+@ou
+@nl
+@ien
+@fr
+@en
+@tet
+@le
+@L
+@os
+@A
+@ro
+@o
+@ho
+@ca
+@Tie
+@tl
+@g
+@hr
+@et
+@fro
+@ast
+@ae
+@nN
+@pc
+@tae
+@ws
+@ia
+@N
+@lc
+@psg
+@ta
+@t2
+@D
+@str
+@ra
+@t3
+@t
+@xt
+@eN
+@fe
+@rU
+@ar
+@eD
+@iE
+@se
+@st1
+@rr
+@ime
+@ft
+@lm
+@wD
+@wne
+@h
+@otn
+@use
+@roi
+@ldc
+@ln
+@d
+@ee
+@ep
+@us
+@ut
+@u
+@n
+@Nme
+@min
+@ma
+@pct
+@hd
+@be
+@It
+@id
+@cm
+@ua
+@fs
+@Al
+@axn
+@rt
+@to
+@is
+@fo
+@i
+@an
+@de
+@tel
+@nd
+@dic
+@Lo
+@il
+@tle
+@axt
+@ba
+@ust
+@ac
+@tpe
+@tpl
+@ctG
+@ru
+@m
+@tG
+@it
+@rh
+@G
+@rpc
+@el
+@er
+@w
+@eo
+@tx
+@oo
+@dD
+@dD
+*/
+void f();
+
+// CHECK:  CommentAST=[
+// CHECK:    (CXComment_FullComment
+// CHECK:       (CXComment_Paragraph
+// CHECK:         (CXComment_InlineCommand CommandName=[s] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tr] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[y] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tt] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tg] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[alu] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[U] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[I] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[r] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[t0] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[t1] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ur] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[S] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[E] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[pb] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[f] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[pe] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[lue] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[re] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[oa] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[l] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[x] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[R] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ute] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[am] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ei] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[oun] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ou] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[nl] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ien] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[fr] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[en] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tet] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[le] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[L] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[os] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[A] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ro] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[o] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ho] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ca] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[Tie] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tl] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[g] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[hr] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[et] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[fro] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ast] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ae] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[nN] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[pc] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tae] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ws] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ia] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[N] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[lc] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[psg] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ta] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[t2] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[D] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[str] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ra] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[t3] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[t] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[xt] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[eN] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[fe] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[rU] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ar] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[eD] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[iE] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[se] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[st1] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[rr] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ime] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ft] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[lm] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[wD] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[wne] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[h] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[otn] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[use] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[roi] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ldc] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ln] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[d] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ee] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ep] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[us] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ut] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[u] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[n] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[Nme] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[min] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ma] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[pct] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[hd] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[be] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[It] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[id] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[cm] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ua] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[fs] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[Al] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[axn] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[rt] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[to] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[is] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[fo] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[i] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[an] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[de] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tel] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[nd] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[dic] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[Lo] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[il] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tle] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[axt] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ba] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ust] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ac] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tpe] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tpl] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ctG] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[ru] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[m] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tG] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[it] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[rh] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[G] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[rpc] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[el] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[er] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[w] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[eo] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[tx] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[oo] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[dD] RenderNormal HasTrailingNewline)
+// CHECK:         (CXComment_InlineCommand CommandName=[dD] RenderNormal)))]
diff --git a/test/Index/complete-at-EOF.c b/test/Index/complete-at-EOF.c
new file mode 100644
index 0000000..d039aaa
--- /dev/null
+++ b/test/Index/complete-at-EOF.c
@@ -0,0 +1,9 @@
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test \
+// RUN:	    -code-completion-at=%S/Inputs/complete-at-EOF.c:4:1 %S/Inputs/complete-at-EOF.c | FileCheck -check-prefix=CHECK-EOF %s
+// CHECK-EOF: macro definition:{TypedText CAKE}
+// CHECK-EOF: TypedefDecl:{TypedText foo}
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test \
+// RUN:     -code-completion-at=%S/Inputs/complete-at-EOF.c:2:1 %S/Inputs/complete-at-EOF.c | FileCheck -check-prefix=CHECK-AFTER-PREAMBLE %s
+// CHECK-AFTER-PREAMBLE: macro definition:{TypedText CAKE}
diff --git a/test/Index/complete-module-undef.m b/test/Index/complete-module-undef.m
new file mode 100644
index 0000000..a9dd000
--- /dev/null
+++ b/test/Index/complete-module-undef.m
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: env CINDEXTEST_COMPLETION_CACHING=1 \
+// RUN:     c-index-test -test-load-source-reparse 2 local %s -fmodules -fmodules-cache-path=%t -I %S/Inputs \
+// RUN:   | FileCheck %s
+
+// rdar://18416901 (used to crash)
+// CHECK: complete-module-undef.m:8:1: ModuleImport=ModuleUndef:8:1 (Definition) Extent=[8:1 - 8:20]
+@import ModuleUndef;
diff --git a/test/Index/cursor-dynamic-call.mm b/test/Index/cursor-dynamic-call.mm
index ac9e6d3..a926c3d 100644
--- a/test/Index/cursor-dynamic-call.mm
+++ b/test/Index/cursor-dynamic-call.mm
@@ -37,6 +37,18 @@
   [cls ClsMeth];
 }
 
+@interface NSObject
++(id)alloc;
+-(id)init;
+@end
+
+@interface Test : NSObject
+@end
+
+void test2() {
+  id o = [[Test alloc] init];
+}
+
 // RUN: c-index-test -cursor-at=%s:8:11 \
 // RUN:              -cursor-at=%s:9:11 \
 // RUN:              -cursor-at=%s:25:11 \
@@ -46,6 +58,7 @@
 // RUN:              -cursor-at=%s:35:9 \
 // RUN:              -cursor-at=%s:36:9 \
 // RUN:              -cursor-at=%s:37:9 \
+// RUN:              -cursor-at=%s:49:26 \
 // RUN:       %s | FileCheck %s
 
 // CHECK:     8:11 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call
@@ -59,3 +72,4 @@
 // CHECK-NOT: 36:3 {{.*}} Dynamic-call
 // CHECK:     36:3 {{.*}} Receiver-type=ObjCInterface
 // CHECK:     37:3 ObjCMessageExpr=ClsMeth:15:8 {{.*}} Dynamic-call Receiver-type=ObjCClass
+// CHECK-NOT: 49:10 {{.*}} Dynamic-call
diff --git a/test/Index/format-comment-cdecls.c b/test/Index/format-comment-cdecls.c
index 471be2b..34cedfd 100644
--- a/test/Index/format-comment-cdecls.c
+++ b/test/Index/format-comment-cdecls.c
@@ -96,4 +96,4 @@
  *\brief block declaration
 */
 int (^Block1) (int i, int j) = ^(int i, int j) { return i + j; };
-// CHECK: <Declaration>int (^Block1)(int, int) = ^(int i, int j) {}</Declaration>
+// CHECK: <Declaration>int (^Block1)(int, int) = ^(int i, int j) {\n}</Declaration>
diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp
index 996ecc2..60aab5f 100644
--- a/test/Index/get-cursor.cpp
+++ b/test/Index/get-cursor.cpp
@@ -65,6 +65,84 @@
 #define EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 EXTERN_TEMPLATE(class TC<char>)
 
+class A {
+  A();
+  virtual ~A();
+
+  // Assignment operators
+  A& operator=(const A&);
+  A& operator=(A&&) noexcept;
+
+  // Unary operators
+  A    operator+() const;
+  A    operator-() const;
+  A    operator~() const;
+  A    operator*() const;
+  A    operator&() const;
+  bool operator!() const;
+
+  // (pre-|post-) increment and decrement
+  A& operator++();
+  A& operator--();
+  A  operator++(int);
+  A  operator--(int);
+
+  // Arithmetic operators
+  A operator+(const A&) const;
+  A operator-(const A&) const;
+  A operator*(const A&) const;
+  A operator/(const A&) const;
+  A operator%(const A&) const;
+  A operator&(const A&) const;
+  A operator|(const A&) const;
+  A operator^(const A&) const;
+
+  A operator<<(const A&) const;
+  A operator>>(const A&) const;
+
+  // Arithmetic-assignment operators
+  A& operator+=(const A&);
+  A& operator-=(const A&);
+  A& operator*=(const A&);
+  A& operator/=(const A&);
+  A& operator%=(const A&);
+  A& operator&=(const A&);
+  A& operator|=(const A&);
+  A& operator^=(const A&);
+
+  A& operator<<=(const A&);
+  A& operator>>=(const A&);
+
+  // Logical operators
+  bool operator<(const A&) const;
+  bool operator>(const A&) const;
+
+  bool operator&&(const A&) const;
+  bool operator||(const A&) const;
+  bool operator<=(const A&) const;
+  bool operator>=(const A&) const;
+  bool operator!=(const A&) const;
+  bool operator==(const A&) const;
+
+  // Special operators
+  A& operator[](unsigned long long);
+  A* operator->();
+  A  operator()(unsigned, int) const;
+
+  explicit operator bool() const;
+};
+
+struct TestColl {
+  int* begin();
+  int* end();
+};
+
+void test(TestColl coll) {
+  for (auto lv : coll) {
+    (void)lv;
+  }
+}
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -128,3 +206,56 @@
 
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
+
+// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 -cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 -std=c++11 %s | FileCheck -check-prefix=CHECK-SPELLING %s
+// CHECK-SPELLING: 69:3 CXXConstructor=A:69:3 Extent=[69:3 - 69:6] Spelling=A ([69:3 - 69:4])
+// CHECK-SPELLING: 70:11 CXXDestructor=~A:70:11 (virtual) Extent=[70:3 - 70:15] Spelling=~A ([70:11 - 70:13])
+// CHECK-SPELLING: 73:6 CXXMethod=operator=:73:6 Extent=[73:3 - 73:25] Spelling=operator= ([73:6 - 73:15])
+// CHECK-SPELLING: 74:6 CXXMethod=operator=:74:6 Extent=[74:3 - 74:29] Spelling=operator= ([74:6 - 74:15])
+// CHECK-SPELLING: 77:8 CXXMethod=operator+:77:8 (const) Extent=[77:3 - 77:25] Spelling=operator+ ([77:8 - 77:17])
+// CHECK-SPELLING: 78:8 CXXMethod=operator-:78:8 (const) Extent=[78:3 - 78:25] Spelling=operator- ([78:8 - 78:17])
+// CHECK-SPELLING: 79:8 CXXMethod=operator~:79:8 (const) Extent=[79:3 - 79:25] Spelling=operator~ ([79:8 - 79:17])
+// CHECK-SPELLING: 80:8 CXXMethod=operator*:80:8 (const) Extent=[80:3 - 80:25] Spelling=operator* ([80:8 - 80:17])
+// CHECK-SPELLING: 81:8 CXXMethod=operator&:81:8 (const) Extent=[81:3 - 81:25] Spelling=operator& ([81:8 - 81:17])
+// CHECK-SPELLING: 82:8 CXXMethod=operator!:82:8 (const) Extent=[82:3 - 82:25] Spelling=operator! ([82:8 - 82:17])
+// CHECK-SPELLING: 85:6 CXXMethod=operator++:85:6 Extent=[85:3 - 85:18] Spelling=operator++ ([85:6 - 85:16])
+// CHECK-SPELLING: 86:6 CXXMethod=operator--:86:6 Extent=[86:3 - 86:18] Spelling=operator-- ([86:6 - 86:16])
+// CHECK-SPELLING: 87:6 CXXMethod=operator++:87:6 Extent=[87:3 - 87:21] Spelling=operator++ ([87:6 - 87:16])
+// CHECK-SPELLING: 88:6 CXXMethod=operator--:88:6 Extent=[88:3 - 88:21] Spelling=operator-- ([88:6 - 88:16])
+// CHECK-SPELLING: 91:5 CXXMethod=operator+:91:5 (const) Extent=[91:3 - 91:30] Spelling=operator+ ([91:5 - 91:14])
+// CHECK-SPELLING: 92:5 CXXMethod=operator-:92:5 (const) Extent=[92:3 - 92:30] Spelling=operator- ([92:5 - 92:14])
+// CHECK-SPELLING: 93:5 CXXMethod=operator*:93:5 (const) Extent=[93:3 - 93:30] Spelling=operator* ([93:5 - 93:14])
+// CHECK-SPELLING: 94:5 CXXMethod=operator/:94:5 (const) Extent=[94:3 - 94:30] Spelling=operator/ ([94:5 - 94:14])
+// CHECK-SPELLING: 95:5 CXXMethod=operator%:95:5 (const) Extent=[95:3 - 95:30] Spelling=operator% ([95:5 - 95:14])
+// CHECK-SPELLING: 96:5 CXXMethod=operator&:96:5 (const) Extent=[96:3 - 96:30] Spelling=operator& ([96:5 - 96:14])
+// CHECK-SPELLING: 97:5 CXXMethod=operator|:97:5 (const) Extent=[97:3 - 97:30] Spelling=operator| ([97:5 - 97:14])
+// CHECK-SPELLING: 98:5 CXXMethod=operator^:98:5 (const) Extent=[98:3 - 98:30] Spelling=operator^ ([98:5 - 98:14])
+// CHECK-SPELLING: 100:5 CXXMethod=operator<<:100:5 (const) Extent=[100:3 - 100:31] Spelling=operator<< ([100:5 - 100:15])
+// CHECK-SPELLING: 101:5 CXXMethod=operator>>:101:5 (const) Extent=[101:3 - 101:31] Spelling=operator>> ([101:5 - 101:15])
+// CHECK-SPELLING: 104:6 CXXMethod=operator+=:104:6 Extent=[104:3 - 104:26] Spelling=operator+= ([104:6 - 104:16])
+// CHECK-SPELLING: 105:6 CXXMethod=operator-=:105:6 Extent=[105:3 - 105:26] Spelling=operator-= ([105:6 - 105:16])
+// CHECK-SPELLING: 106:6 CXXMethod=operator*=:106:6 Extent=[106:3 - 106:26] Spelling=operator*= ([106:6 - 106:16])
+// CHECK-SPELLING: 107:6 CXXMethod=operator/=:107:6 Extent=[107:3 - 107:26] Spelling=operator/= ([107:6 - 107:16])
+// CHECK-SPELLING: 108:6 CXXMethod=operator%=:108:6 Extent=[108:3 - 108:26] Spelling=operator%= ([108:6 - 108:16])
+// CHECK-SPELLING: 109:6 CXXMethod=operator&=:109:6 Extent=[109:3 - 109:26] Spelling=operator&= ([109:6 - 109:16])
+// CHECK-SPELLING: 110:6 CXXMethod=operator|=:110:6 Extent=[110:3 - 110:26] Spelling=operator|= ([110:6 - 110:16])
+// CHECK-SPELLING: 111:6 CXXMethod=operator^=:111:6 Extent=[111:3 - 111:26] Spelling=operator^= ([111:6 - 111:16])
+// CHECK-SPELLING: 113:6 CXXMethod=operator<<=:113:6 Extent=[113:3 - 113:27] Spelling=operator<<= ([113:6 - 113:17])
+// CHECK-SPELLING: 114:6 CXXMethod=operator>>=:114:6 Extent=[114:3 - 114:27] Spelling=operator>>= ([114:6 - 114:17])
+// CHECK-SPELLING: 117:8 CXXMethod=operator<:117:8 (const) Extent=[117:3 - 117:33] Spelling=operator< ([117:8 - 117:17])
+// CHECK-SPELLING: 118:8 CXXMethod=operator>:118:8 (const) Extent=[118:3 - 118:33] Spelling=operator> ([118:8 - 118:17])
+// CHECK-SPELLING: 120:8 CXXMethod=operator&&:120:8 (const) Extent=[120:3 - 120:34] Spelling=operator&& ([120:8 - 120:18])
+// CHECK-SPELLING: 121:8 CXXMethod=operator||:121:8 (const) Extent=[121:3 - 121:34] Spelling=operator|| ([121:8 - 121:18])
+// CHECK-SPELLING: 122:8 CXXMethod=operator<=:122:8 (const) Extent=[122:3 - 122:34] Spelling=operator<= ([122:8 - 122:18])
+// CHECK-SPELLING: 123:8 CXXMethod=operator>=:123:8 (const) Extent=[123:3 - 123:34] Spelling=operator>= ([123:8 - 123:18])
+// CHECK-SPELLING: 124:8 CXXMethod=operator!=:124:8 (const) Extent=[124:3 - 124:34] Spelling=operator!= ([124:8 - 124:18])
+// CHECK-SPELLING: 125:8 CXXMethod=operator==:125:8 (const) Extent=[125:3 - 125:34] Spelling=operator== ([125:8 - 125:18])
+// CHECK-SPELLING: 128:6 CXXMethod=operator[]:128:6 Extent=[128:3 - 128:36] Spelling=operator[] ([128:6 - 128:16])
+// CHECK-SPELLING: 129:6 CXXMethod=operator->:129:6 Extent=[129:3 - 129:18] Spelling=operator-> ([129:6 - 129:16])
+// CHECK-SPELLING: 130:6 CXXMethod=operator():130:6 (const) Extent=[130:3 - 130:37] Spelling=operator() ([130:6 - 130:16])
+// CHECK-SPELLING: 132:12 CXXConversion=operator bool:132:12 (const) Extent=[132:3 - 132:33] Spelling=operator bool ([132:12 - 132:25])
+
+// RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 -cursor-at=%s:142:11 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s
+// CHECK-FORRANGE: 141:13 VarDecl=lv:141:13 (Definition) Extent=[141:8 - 141:17] Spelling=lv ([141:13 - 141:15])
+// CHECK-FORRANGE: 141:18 DeclRefExpr=coll:140:20 Extent=[141:18 - 141:22] Spelling=coll ([141:18 - 141:22])
+// CHECK-FORRANGE: 142:11 DeclRefExpr=lv:141:13 Extent=[142:11 - 142:13] Spelling=lv ([142:11 - 142:13])
diff --git a/test/Index/index-many-call-ops.cpp b/test/Index/index-many-call-ops.cpp
index e732b5f..7644697 100644
--- a/test/Index/index-many-call-ops.cpp
+++ b/test/Index/index-many-call-ops.cpp
@@ -4,6 +4,9 @@
 // Check that we don't get stack overflow trying to index a huge number of
 // call operators.
 
+// UBSan increses stack usage.
+// REQUIRES: not_ubsan
+
 struct S {
   S &operator()();
 };
diff --git a/test/Index/index-many-logical-ops.c b/test/Index/index-many-logical-ops.c
index 67017de..0fd4e75 100644
--- a/test/Index/index-many-logical-ops.c
+++ b/test/Index/index-many-logical-ops.c
@@ -4,6 +4,9 @@
 // Check that we don't get stack overflow trying to index a huge number of
 // logical operators.
 
+// UBSan increses stack usage.
+// REQUIRES: not_ubsan
+
 // CHECK: [indexDeclaration]: kind: function | name: foo
 int foo(int x) {
   return
diff --git a/test/Index/index-module.m b/test/Index/index-module.m
index 8e01556..8ed7a84 100644
--- a/test/Index/index-module.m
+++ b/test/Index/index-module.m
@@ -40,7 +40,7 @@
 // CHECK-TMOD-NEXT: [ppIncludedFile]: [[TMOD_MODULE_H:.*/Modules/Inputs/Module\.framework[/\\]Headers[/\\]Module\.h]] | {{.*}} | hash loc: <invalid>
 // CHECK-TMOD-NEXT: [ppIncludedFile]: [[TMODHDR:.*/Modules/Inputs/Module.framework[/\\]Headers.]]Sub.h | name: "Module/Sub.h" | hash loc: [[TMOD_MODULE_H]]:23:1 | isImport: 0 | isAngled: 1
 // CHECK-TMOD-NEXT: [ppIncludedFile]: [[TMODHDR]]Sub2.h | name: "Module/Sub2.h" | hash loc: [[TMODHDR]]Sub.h:1:1 | isImport: 0 | isAngled: 1
-// CHECK-TMOD-NEXT: [ppIncludedFile]: [[TMODHDR]]Buried/Treasure.h | name: "Module/Buried/Treasure.h" | hash loc: [[TMOD_MODULE_H]]:24:1 | isImport: 0 | isAngled: 1
+// CHECK-TMOD-NEXT: [ppIncludedFile]: [[TMODHDR]]Buried{{[/\\]}}Treasure.h | name: "Module/Buried/Treasure.h" | hash loc: [[TMOD_MODULE_H]]:24:1 | isImport: 0 | isAngled: 1
 // CHECK-TMOD-NEXT: [ppIncludedFile]: [[TMOD_SUB_H:.*[/\\]Modules[/\\]Inputs[/\\]Module\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] | {{.*}} | hash loc: <invalid>
 // CHECK-TMOD-NEXT: [indexDeclaration]: kind: function | name: getModuleVersion | {{.*}} | loc: [[TMOD_MODULE_H]]:9:13
 // CHECK-TMOD-NEXT: [indexDeclaration]: kind: objc-class | name: Module | {{.*}} | loc: [[TMOD_MODULE_H]]:15:12
@@ -52,6 +52,6 @@
 // CHECK-TMOD-NEXT: [importedASTFile]: [[PCM]] | loc: [[TMODHDR]]Sub.h:1:2 | name: "Module.Sub2" | isImplicit: 1
 // CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Module_Sub | {{.*}} | loc: [[TMODHDR]]Sub.h:2:6
 // CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Module_Sub2 | USR: c:@Module_Sub2 | {{.*}} | loc: [[TMODHDR]]Sub2.h:1:6
-// CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Buried_Treasure | {{.*}} | loc: [[TMODHDR]]Buried/Treasure.h:1:11
+// CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: Buried_Treasure | {{.*}} | loc: [[TMODHDR]]Buried{{[/\\]}}Treasure.h:1:11
 // CHECK-TMOD-NEXT: [indexDeclaration]: kind: variable | name: module_subframework | {{.*}} | loc: [[TMOD_SUB_H]]:4:7
 // CHECK-TMOD-NOT: [indexDeclaration]
diff --git a/test/Index/index-templates.cpp b/test/Index/index-templates.cpp
index 5fcb652..1552235 100644
--- a/test/Index/index-templates.cpp
+++ b/test/Index/index-templates.cpp
@@ -100,6 +100,16 @@
 template<typename T, typename U>
 struct SuperPair : Pair<int, int>, Pair<T, U> { };
 
+enum FxnTmplEnum {
+  FxnTmplEnum_A, FxnTmplEnum_B, FxnTmplEnum_C,
+};
+template <typename T, int I, FxnTmplEnum, int E>
+void foo(T Value) {}
+
+static const int FxnTmpl_Var = 7;
+template <>
+void foo<float, 9, FxnTmplEnum_B, FxnTmpl_Var + 7>(float Value);
+
 // RUN: c-index-test -test-load-source all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-LOAD %s
 // CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22]
 // CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:10 - 3:20]
@@ -178,7 +188,7 @@
 // CHECK-LOAD: index-templates.cpp:100:31: TemplateTypeParameter=U:100:31 (Definition) Extent=[100:22 - 100:32]
 // CHECK-LOAD: index-templates.cpp:101:20: C++ base class specifier=Pair<int, int>:98:16 [access=public isVirtual=false] Extent=[101:20 - 101:34]
 // CHECK-LOAD: index-templates.cpp:101:36: C++ base class specifier=Pair<T, U>:76:8 [access=public isVirtual=false] Extent=[101:36 - 101:46]
-
+// CHECK-LOAD: index-templates.cpp:111:6: FunctionDecl=foo:111:6 [Specialization of foo:107:6] [Template arg 0: kind: 1, type: float] [Template arg 1: kind: 4, intval: 9] [Template arg 2: kind: 4, intval: 1] [Template arg 3: kind: 4, intval: 14] Extent=[110:1 - 111:64]
 
 // RUN: c-index-test -test-load-source-usrs all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-USRS %s
 // CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22S0_# Extent=[3:1 - 4:22]
diff --git a/test/Index/preamble_macro_template.cpp b/test/Index/preamble_macro_template.cpp
index 20f16b5..0771cab 100644
--- a/test/Index/preamble_macro_template.cpp
+++ b/test/Index/preamble_macro_template.cpp
@@ -4,7 +4,7 @@
 
 // RUN: c-index-test -write-pch %t.pch -fno-delayed-template-parsing -x c++-header %S/Inputs/preamble_macro_template.h
 // RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -fno-delayed-template-parsing -I %S/Inputs -include %t %s 2>&1 | tee %t.check.txt | FileCheck %s
-// CHECK: preamble_macro_template.h:4:6: FunctionDecl=foo:4:6 (Definition) [Specialization of foo:4:6] Extent=[4:1 - 6:2]
+// CHECK: preamble_macro_template.h:4:6: FunctionDecl=foo:4:6 (Definition) [Specialization of foo:4:6] [Template arg 0: kind: 1, type: int] Extent=[4:1 - 6:2]
 // CHECK: preamble_macro_template.h:4:13: ParmDecl=p:4:13 (Definition) Extent=[4:10 - 4:14]
 // CHECK: preamble_macro_template.h:4:16: CompoundStmt= Extent=[4:16 - 6:2]
 // CHECK: preamble_macro_template.h:5:3: CStyleCastExpr= Extent=[5:3 - 5:27]
diff --git a/test/Index/print-mangled-name.cpp b/test/Index/print-mangled-name.cpp
new file mode 100644
index 0000000..b7e79c3
--- /dev/null
+++ b/test/Index/print-mangled-name.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-pch %s -o %t_linux.ast
+// RUN: c-index-test -test-print-mangle %t_linux.ast | FileCheck %s --check-prefix=ITANIUM
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-pch %s -o %t_macho.ast
+// RUN: c-index-test -test-print-mangle %t_macho.ast | FileCheck %s --check-prefix=MACHO
+
+// RUN: %clang_cc1 -triple i686-pc-win32 -emit-pch %s -o %t_msft.ast
+// RUN: c-index-test -test-print-mangle %t_msft.ast | FileCheck %s --check-prefix=MICROSOFT
+
+int foo(int, int);
+// ITANIUM: mangled=_Z3fooii
+// MACHO: mangled=__Z3fooii
+// MICROSOFT: mangled=?foo@@YAHHH
+
+int foo(float, int);
+// ITANIUM: mangled=_Z3foofi
+// MACHO: mangled=__Z3foofi
+// MICROSOFT: mangled=?foo@@YAHMH
+
+struct S {
+  int x, y;
+};
+// ITANIUM: StructDecl{{.*}}mangled=]
+// MACHO: StructDecl{{.*}}mangled=]
+// MICROSOFT: StructDecl{{.*}}mangled=]
+
+int foo(S, S&);
+// ITANIUM: mangled=_Z3foo1SRS_
+// MACHO: mangled=__Z3foo1SRS_
+// MICROSOFT: mangled=?foo@@YAHUS
diff --git a/test/Index/reparse-predef-objc-protocol.m b/test/Index/reparse-predef-objc-protocol.m
new file mode 100644
index 0000000..fc9d857
--- /dev/null
+++ b/test/Index/reparse-predef-objc-protocol.m
@@ -0,0 +1,9 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 3 local %s -I %S/Inputs
+#import "declare-objc-predef.h"
+// PR20633
+
+// CHECK: declare-objc-predef.h:1:8: ObjCInterfaceDecl=Protocol:1:8 Extent=[1:1 - 1:16]
+// CHECK: declare-objc-predef.h:1:8: ObjCClassRef=Protocol:1:8 Extent=[1:8 - 1:16]
+// CHECK: declare-objc-predef.h:2:16: StructDecl=objc_class:2:16 Extent=[2:9 - 2:26]
+// CHECK: declare-objc-predef.h:2:28: TypedefDecl=Class:2:28 (Definition) Extent=[2:1 - 2:33]
+// CHECK: declare-objc-predef.h:2:16: TypeRef=struct objc_class:2:16 Extent=[2:16 - 2:26]
diff --git a/test/Layout/itanium-union-bitfield.cpp b/test/Layout/itanium-union-bitfield.cpp
new file mode 100644
index 0000000..b06fd36
--- /dev/null
+++ b/test/Layout/itanium-union-bitfield.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple %itanium_abi_triple -fdump-record-layouts %s 2>/dev/null \
+// RUN:            | FileCheck %s
+
+union A {
+  int f1: 3;
+  A();
+};
+
+A::A() {}
+
+union B {
+  char f1: 35;
+  B();
+};
+
+B::B() {}
+
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT:   0 | union A
+// CHECK-NEXT:   0 |   int f1
+// CHECK-NEXT:     | [sizeof=4, dsize=1, align=4
+// CHECK-NEXT:     |  nvsize=1, nvalign=4]
+
+// CHECK:*** Dumping AST Record Layout
+// CHECK-NEXT:   0 | union B
+// CHECK-NEXT:   0 |   char f1
+// CHECK-NEXT:     | [sizeof=8, dsize=5, align=4
+// CHECK-NEXT:     |  nvsize=5, nvalign=4]
+
diff --git a/test/Layout/ms-x86-basic-layout.cpp b/test/Layout/ms-x86-basic-layout.cpp
index b6ffeee..aac7aed 100644
--- a/test/Layout/ms-x86-basic-layout.cpp
+++ b/test/Layout/ms-x86-basic-layout.cpp
@@ -816,6 +816,36 @@
 // CHECK-X64-NEXT:      | [sizeof=16, align=4
 // CHECK-X64-NEXT:      |  nvsize=16, nvalign=4]
 
+struct EmptyIntMemb {
+  int FlexArrayMemb[0];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct EmptyIntMemb
+// CHECK-NEXT:    0 |   int [0] FlexArrayMemb
+// CHECK-NEXT:      | [sizeof=1, align=4
+// CHECK-NEXT:      |  nvsize=0, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct EmptyIntMemb
+// CHECK-X64-NEXT:    0 |   int [0] FlexArrayMemb
+// CHECK-X64-NEXT:      | [sizeof=4, align=4
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=4]
+
+struct EmptyLongLongMemb {
+  long long FlexArrayMemb[0];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct EmptyLongLongMemb
+// CHECK-NEXT:    0 |   long long [0] FlexArrayMemb
+// CHECK-NEXT:      | [sizeof=1, align=8
+// CHECK-NEXT:      |  nvsize=0, nvalign=8]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct EmptyLongLongMemb
+// CHECK-X64-NEXT:    0 |   long long [0] FlexArrayMemb
+// CHECK-X64-NEXT:      | [sizeof=8, align=8
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=8]
+
 int a[
 sizeof(TestF0)+
 sizeof(TestF1)+
@@ -840,4 +870,6 @@
 sizeof(ArrayFieldOfRecords)+
 sizeof(ArrayOfArrayFieldOfRecords)+
 sizeof(RecordArrayTypedef)+
+sizeof(EmptyIntMemb)+
+sizeof(EmptyLongLongMemb)+
 0];
diff --git a/test/Layout/ms-x86-empty-layout.c b/test/Layout/ms-x86-empty-layout.c
new file mode 100644
index 0000000..faca0be
--- /dev/null
+++ b/test/Layout/ms-x86-empty-layout.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
+// RUN:            | FileCheck %s
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
+// RUN:            | FileCheck %s
+
+struct EmptyIntMemb {
+  int FlexArrayMemb[0];
+};
+// CHECK: *** Dumping AST Record Layout
+// CHECK: Type: struct EmptyIntMemb
+// CHECK: Record: 
+// CHECK: Layout: <ASTRecordLayout
+// CHECK:     Size:32
+// CHECK:     Alignment:32
+// CHECK:     FieldOffsets: [0]>
+
+struct EmptyLongLongMemb {
+  long long FlexArrayMemb[0];
+};
+// CHECK: *** Dumping AST Record Layout
+// CHECK: Type: struct EmptyLongLongMemb
+// CHECK: Record: 
+// CHECK: Layout: <ASTRecordLayout
+// CHECK:     Size:32
+// CHECK:     Alignment:64
+// CHECK:     FieldOffsets: [0]>
+
+struct EmptyAligned2LongLongMemb {
+  long long __declspec(align(2)) FlexArrayMemb[0];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: Type: struct EmptyAligned2LongLongMemb
+// CHECK: Record: 
+// CHECK: Layout: <ASTRecordLayout
+// CHECK:     Size:32
+// CHECK:     Alignment:64
+// CHECK:     FieldOffsets: [0]>
+
+struct EmptyAligned8LongLongMemb {
+  long long __declspec(align(8)) FlexArrayMemb[0];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: Type: struct EmptyAligned8LongLongMemb
+// CHECK: Record: 
+// CHECK: Layout: <ASTRecordLayout
+// CHECK:     Size:64
+// CHECK:     Alignment:64
+// CHECK:     FieldOffsets: [0]>
+
+#pragma pack(1)
+struct __declspec(align(4)) EmptyPackedAligned4LongLongMemb {
+  long long FlexArrayMemb[0];
+};
+#pragma pack()
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: Type: struct EmptyPackedAligned4LongLongMemb
+// CHECK: Record: 
+// CHECK: Layout: <ASTRecordLayout
+// CHECK:     Size:32
+// CHECK:     Alignment:32
+// CHECK:     FieldOffsets: [0]>
+
+#pragma pack(1)
+struct EmptyPackedAligned8LongLongMemb {
+  long long __declspec(align(8)) FlexArrayMemb[0];
+};
+#pragma pack()
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: Type: struct EmptyPackedAligned8LongLongMemb
+// CHECK: Record: 
+// CHECK: Layout: <ASTRecordLayout
+// CHECK:     Size:64
+// CHECK:     Alignment:64
+// CHECK:     FieldOffsets: [0]>
+
+
+int a[
+sizeof(struct EmptyIntMemb)+
+sizeof(struct EmptyLongLongMemb)+
+sizeof(struct EmptyAligned2LongLongMemb)+
+sizeof(struct EmptyAligned8LongLongMemb)+
+sizeof(struct EmptyPackedAligned4LongLongMemb)+
+sizeof(struct EmptyPackedAligned8LongLongMemb)+
+0];
diff --git a/test/Layout/ms-x86-pack-and-align.cpp b/test/Layout/ms-x86-pack-and-align.cpp
index be0499c..9783233 100644
--- a/test/Layout/ms-x86-pack-and-align.cpp
+++ b/test/Layout/ms-x86-pack-and-align.cpp
@@ -544,6 +544,263 @@
 // CHECK-X64-NEXT:      | [sizeof=1029, align=1
 // CHECK-X64-NEXT:      |  nvsize=1029, nvalign=1]
 
+struct NA {};
+struct NB {};
+#pragma pack(push, 1)
+struct NC : virtual NA, virtual NB {};
+#pragma pack(pop)
+struct ND : NC {};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct NA (empty)
+// CHECK-NEXT:      | [sizeof=1, align=1
+// CHECK-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct NB (empty)
+// CHECK-NEXT:      | [sizeof=1, align=1
+// CHECK-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct NC
+// CHECK-NEXT:    0 |   (NC vbtable pointer)
+// CHECK-NEXT:    4 |   struct NA (virtual base) (empty)
+// CHECK-NEXT:    8 |   struct NB (virtual base) (empty)
+// CHECK-NEXT:      | [sizeof=8, align=1
+// CHECK-NEXT:      |  nvsize=4, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct ND
+// CHECK-NEXT:    0 |   struct NC (base)
+// CHECK-NEXT:    0 |     (NC vbtable pointer)
+// CHECK-NEXT:    4 |   struct NA (virtual base) (empty)
+// CHECK-NEXT:    8 |   struct NB (virtual base) (empty)
+// CHECK-NEXT:      | [sizeof=8, align=4
+// CHECK-NEXT:      |  nvsize=4, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct NA (empty)
+// CHECK-X64-NEXT:      | [sizeof=1, align=1
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct NB (empty)
+// CHECK-X64-NEXT:      | [sizeof=1, align=1
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct NC
+// CHECK-X64-NEXT:    0 |   (NC vbtable pointer)
+// CHECK-X64-NEXT:    8 |   struct NA (virtual base) (empty)
+// CHECK-X64-NEXT:   12 |   struct NB (virtual base) (empty)
+// CHECK-X64-NEXT:      | [sizeof=12, align=1
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct ND
+// CHECK-X64-NEXT:    0 |   struct NC (base)
+// CHECK-X64-NEXT:    0 |     (NC vbtable pointer)
+// CHECK-X64-NEXT:    8 |   struct NA (virtual base) (empty)
+// CHECK-X64-NEXT:   12 |   struct NB (virtual base) (empty)
+// CHECK-X64-NEXT:      | [sizeof=12, align=4
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=4]
+
+struct OA {};
+struct OB {};
+struct OC : virtual OA, virtual OB {};
+#pragma pack(push, 1)
+struct OD : OC {};
+#pragma pack(pop)
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct OA (empty)
+// CHECK-NEXT:      | [sizeof=1, align=1
+// CHECK-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct OB (empty)
+// CHECK-NEXT:      | [sizeof=1, align=1
+// CHECK-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct OC
+// CHECK-NEXT:    0 |   (OC vbtable pointer)
+// CHECK-NEXT:    4 |   struct OA (virtual base) (empty)
+// CHECK-NEXT:    8 |   struct OB (virtual base) (empty)
+// CHECK-NEXT:      | [sizeof=8, align=4
+// CHECK-NEXT:      |  nvsize=4, nvalign=4]
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct OD
+// CHECK-NEXT:    0 |   struct OC (base)
+// CHECK-NEXT:    0 |     (OC vbtable pointer)
+// CHECK-NEXT:    4 |   struct OA (virtual base) (empty)
+// CHECK-NEXT:    8 |   struct OB (virtual base) (empty)
+// CHECK-NEXT:      | [sizeof=8, align=1
+// CHECK-NEXT:      |  nvsize=4, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct OA (empty)
+// CHECK-X64-NEXT:      | [sizeof=1, align=1
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct OB (empty)
+// CHECK-X64-NEXT:      | [sizeof=1, align=1
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=1]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct OC
+// CHECK-X64-NEXT:    0 |   (OC vbtable pointer)
+// CHECK-X64-NEXT:    8 |   struct OA (virtual base) (empty)
+// CHECK-X64-NEXT:   12 |   struct OB (virtual base) (empty)
+// CHECK-X64-NEXT:      | [sizeof=16, align=8
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=8]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct OD
+// CHECK-X64-NEXT:    0 |   struct OC (base)
+// CHECK-X64-NEXT:    0 |     (OC vbtable pointer)
+// CHECK-X64-NEXT:    8 |   struct OA (virtual base) (empty)
+// CHECK-X64-NEXT:   12 |   struct OB (virtual base) (empty)
+// CHECK-X64-NEXT:      | [sizeof=12, align=1
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=1]
+
+struct __declspec(align(4)) PA {
+  int c;
+};
+
+typedef __declspec(align(8)) PA PB;
+
+#pragma pack(push, 1)
+struct PC {
+  char a;
+  PB x;
+};
+#pragma pack(pop)
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK:         0 | struct PC
+// CHECK-NEXT:    0 |   char a
+// CHECK-NEXT:    8 |   struct PA x
+// CHECK-NEXT:    8 |     int c
+// CHECK-NEXT:      |   [sizeof=4, align=4
+// CHECK-NEXT:      |    nvsize=4, nvalign=4]
+// CHECK-NEXT:      | [sizeof=16, align=8
+// CHECK-NEXT:      |  nvsize=12, nvalign=8]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64:         0 | struct PC
+// CHECK-X64-NEXT:    0 |   char a
+// CHECK-X64-NEXT:    8 |   struct PA x
+// CHECK-X64-NEXT:    8 |     int c
+// CHECK-X64-NEXT:      |   [sizeof=4, align=4
+// CHECK-X64-NEXT:      |    nvsize=4, nvalign=4]
+// CHECK-X64-NEXT:      | [sizeof=16, align=8
+// CHECK-X64-NEXT:      |  nvsize=12, nvalign=8]
+
+typedef PB PD;
+
+#pragma pack(push, 1)
+struct PE {
+  char a;
+  PD x;
+};
+#pragma pack(pop)
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK:         0 | struct PE
+// CHECK-NEXT:    0 |   char a
+// CHECK-NEXT:    8 |   struct PA x
+// CHECK-NEXT:    8 |     int c
+// CHECK-NEXT:      |   [sizeof=4, align=4
+// CHECK-NEXT:      |    nvsize=4, nvalign=4]
+// CHECK-NEXT:      | [sizeof=16, align=8
+// CHECK-NEXT:      |  nvsize=12, nvalign=8]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64:         0 | struct PE
+// CHECK-X64-NEXT:    0 |   char a
+// CHECK-X64-NEXT:    8 |   struct PA x
+// CHECK-X64-NEXT:    8 |     int c
+// CHECK-X64-NEXT:      |   [sizeof=4, align=4
+// CHECK-X64-NEXT:      |    nvsize=4, nvalign=4]
+// CHECK-X64-NEXT:      | [sizeof=16, align=8
+// CHECK-X64-NEXT:      |  nvsize=12, nvalign=8]
+
+typedef int __declspec(align(2)) QA;
+#pragma pack(push, 1)
+struct QB {
+  char a;
+  QA b;
+};
+#pragma pack(pop)
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct QB
+// CHECK-NEXT:    0 |   char a
+// CHECK-NEXT:    2 |   QA b
+// CHECK-NEXT:      | [sizeof=6, align=2
+// CHECK-NEXT:      |  nvsize=6, nvalign=2]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct QB
+// CHECK-X64-NEXT:    0 |   char a
+// CHECK-X64-NEXT:    2 |   QA b
+// CHECK-X64-NEXT:      | [sizeof=6, align=2
+// CHECK-X64-NEXT:      |  nvsize=6, nvalign=2]
+
+struct QC {
+  char a;
+  QA b;
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct QC
+// CHECK-NEXT:    0 |   char a
+// CHECK-NEXT:    4 |   QA b
+// CHECK-NEXT:      | [sizeof=8, align=4
+// CHECK-NEXT:      |  nvsize=8, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct QC
+// CHECK-X64-NEXT:    0 |   char a
+// CHECK-X64-NEXT:    4 |   QA b
+// CHECK-X64-NEXT:      | [sizeof=8, align=4
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=4]
+
+struct QD {
+  char a;
+  QA b : 3;
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct QD
+// CHECK-NEXT:    0 |   char a
+// CHECK-NEXT:    4 |   QA b
+// CHECK-NEXT:      | [sizeof=8, align=4
+// CHECK-NEXT:      |  nvsize=8, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct QD
+// CHECK-X64-NEXT:    0 |   char a
+// CHECK-X64-NEXT:    4 |   QA b
+// CHECK-X64-NEXT:      | [sizeof=8, align=4
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=4]
+
+struct __declspec(align(4)) EmptyAlignedLongLongMemb {
+  long long FlexArrayMemb[0];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct EmptyAlignedLongLongMemb
+// CHECK-NEXT:    0 |   long long [0] FlexArrayMemb
+// CHECK-NEXT:      | [sizeof=8, align=8
+// CHECK-NEXT:      |  nvsize=0, nvalign=8]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct EmptyAlignedLongLongMemb
+// CHECK-X64-NEXT:    0 |   long long [0] FlexArrayMemb
+// CHECK-X64-NEXT:      | [sizeof=8, align=8
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=8]
+
+#pragma pack(1)
+struct __declspec(align(4)) EmptyPackedAlignedLongLongMemb {
+  long long FlexArrayMemb[0];
+};
+#pragma pack()
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct EmptyPackedAlignedLongLongMemb
+// CHECK-NEXT:    0 |   long long [0] FlexArrayMemb
+// CHECK-NEXT:      | [sizeof=4, align=4
+// CHECK-NEXT:      |  nvsize=0, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct EmptyPackedAlignedLongLongMemb
+// CHECK-X64-NEXT:    0 |   long long [0] FlexArrayMemb
+// CHECK-X64-NEXT:      | [sizeof=4, align=4
+// CHECK-X64-NEXT:      |  nvsize=0, nvalign=4]
+
 int a[
 sizeof(X)+
 sizeof(Y)+
@@ -568,4 +825,13 @@
 sizeof(RB3)+
 sizeof(RC)+
 sizeof(RE)+
+sizeof(ND)+
+sizeof(OD)+
+sizeof(PC)+
+sizeof(PE)+
+sizeof(QB)+
+sizeof(QC)+
+sizeof(QD)+
+sizeof(EmptyAlignedLongLongMemb)+
+sizeof(EmptyPackedAlignedLongLongMemb)+
 0];
diff --git a/test/Layout/ms-x86-vtordisp.cpp b/test/Layout/ms-x86-vtordisp.cpp
index 60779fb..1b78d9f 100644
--- a/test/Layout/ms-x86-vtordisp.cpp
+++ b/test/Layout/ms-x86-vtordisp.cpp
@@ -416,6 +416,31 @@
 // CHECK-X64-NEXT:      | [sizeof=32, align=8
 // CHECK-X64-NEXT:      |  nvsize=8, nvalign=8]
 
+struct IA {
+  virtual void f();
+};
+struct __declspec(dllexport) IB : virtual IA {
+  virtual void f() = 0;
+  IB() {}
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct IB
+// CHECK-NEXT:    0 |   (IB vbtable pointer)
+// CHECK-NEXT:    4 |   struct IA (virtual base)
+// CHECK-NEXT:    4 |     (IA vftable pointer)
+// CHECK-NEXT:      | [sizeof=8, align=4
+// CHECK-NEXT:      |  nvsize=4, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct IB
+// CHECK-X64-NEXT:    0 |   (IB vbtable pointer)
+// CHECK-X64-NEXT:    8 |   struct IA (virtual base)
+// CHECK-X64-NEXT:    8 |     (IA vftable pointer)
+// CHECK-X64-NEXT:      | [sizeof=16, align=8
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=8]
+
 int a[
 sizeof(A)+
 sizeof(C)+
@@ -428,4 +453,5 @@
 sizeof(pragma_test4::C)+
 sizeof(GD)+
 sizeof(HC)+
+sizeof(IB)+
 0];
diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c
index f0cd4d7..267e75e 100644
--- a/test/Lexer/constants.c
+++ b/test/Lexer/constants.c
@@ -15,9 +15,9 @@
 #endif
 #if -01000000000000000000000  // should not warn.
 #endif
-#if 9223372036854775808 // expected-warning {{integer constant is larger than the largest signed integer type}}
+#if 9223372036854775808 // expected-warning {{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
 #endif
-#if 0x10000000000000000 // expected-error {{integer constant is larger than the largest unsigned integer type}}
+#if 0x10000000000000000 // expected-error {{integer literal is too large to be represented in any integer type}}
 #endif
 
 int c[] = {
diff --git a/test/Lexer/cxx-features.cpp b/test/Lexer/cxx-features.cpp
index 1202ecb..670a105 100644
--- a/test/Lexer/cxx-features.cpp
+++ b/test/Lexer/cxx-features.cpp
@@ -16,6 +16,10 @@
 #error "wrong value for __cpp_binary_literals"
 #endif
 
+#if check(digit_separators, 0, 0, 201309)
+#error "wrong value for __cpp_digit_separators"
+#endif
+
 #if check(init_captures, 0, 0, 201304)
 #error "wrong value for __cpp_init_captures"
 #endif
@@ -24,6 +28,10 @@
 #error "wrong value for __cpp_generic_lambdas"
 #endif
 
+#if check(sized_deallocation, 0, 0, 201309)
+#error "wrong value for __cpp_sized_deallocation"
+#endif
+
 #if check(constexpr, 0, 200704, 201304)
 #error "wrong value for __cpp_constexpr"
 #endif
@@ -68,6 +76,10 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
+#if check(range_based_for, 0, 200907, 200907)
+#error "wrong value for __cpp_range_based_for"
+#endif
+
 #if check(static_assert, 0, 200410, 200410)
 #error "wrong value for __cpp_static_assert"
 #endif
@@ -87,3 +99,27 @@
 #if check(variadic_templates, 0, 200704, 200704)
 #error "wrong value for __cpp_variadic_templates"
 #endif
+
+#if check(initializer_lists, 0, 200806, 200806)
+#error "wrong value for __cpp_initializer_lists"
+#endif
+
+#if check(delegating_constructors, 0, 200604, 200604)
+#error "wrong value for __cpp_delegating_constructors"
+#endif
+
+#if check(nsdmi, 0, 200809, 200809)
+#error "wrong value for __cpp_nsdmi"
+#endif
+
+#if check(inheriting_constructors, 0, 200802, 200802)
+#error "wrong value for __cpp_inheriting_constructors"
+#endif
+
+#if check(ref_qualifiers, 0, 200710, 200710)
+#error "wrong value for __cpp_ref_qualifiers"
+#endif
+
+#if check(alias_templates, 0, 200704, 200704)
+#error "wrong value for __cpp_alias_templates"
+#endif
diff --git a/test/Lexer/has_extension.c b/test/Lexer/has_extension.c
index 3b08510..2ab3d1d 100644
--- a/test/Lexer/has_extension.c
+++ b/test/Lexer/has_extension.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-PED-NONE %s
-// RUN: %clang_cc1 -pedantic-errors -E %s -o - | FileCheck --check-prefix=CHECK-PED-ERR %s
+// RUN: %clang_cc1 -std=c99 -E %s -o - | FileCheck --check-prefix=CHECK-PED-NONE %s
+// RUN: %clang_cc1 -std=c99 -pedantic-errors -E %s -o - | FileCheck --check-prefix=CHECK-PED-ERR %s
 
 // CHECK-PED-NONE: no_dummy_extension
 #if !__has_extension(dummy_extension)
diff --git a/test/Lexer/has_feature_c1x.c b/test/Lexer/has_feature_c1x.c
index e26e309..cba329c 100644
--- a/test/Lexer/has_feature_c1x.c
+++ b/test/Lexer/has_feature_c1x.c
@@ -1,5 +1,11 @@
-// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c1x %s -o - | FileCheck --check-prefix=CHECK-1X %s
-// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c89 %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=iso9899:199409 %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c99 %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=c11 %s -o - | FileCheck --check-prefix=CHECK-1X %s
+//
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=gnu89 %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=gnu99 %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+// RUN: %clang_cc1 -E -triple x86_64-linux-gnu -std=gnu11 %s -o - | FileCheck --check-prefix=CHECK-1X %s
 
 #if __has_feature(c_atomic)
 int has_atomic();
diff --git a/test/Lexer/string-literal-errors.cpp b/test/Lexer/string-literal-errors.cpp
index d8e2993..223dca4 100644
--- a/test/Lexer/string-literal-errors.cpp
+++ b/test/Lexer/string-literal-errors.cpp
@@ -23,3 +23,5 @@
   // CHECK: {{^       \^~$}}
   // CHECK: {{^          \^~$}}
 }
+
+#define foo() lots and lots of tokens, need at least 8 to fill up the smallvector buffer #BadThingsHappenNow
diff --git a/test/Lexer/utf8-char-literal.cpp b/test/Lexer/utf8-char-literal.cpp
index 7a4d126..0ddaabc 100644
--- a/test/Lexer/utf8-char-literal.cpp
+++ b/test/Lexer/utf8-char-literal.cpp
@@ -1,6 +1,15 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c11 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++1z -fsyntax-only -verify %s
 
 int array0[u'ñ' == u'\xf1'? 1 : -1];
 int array1['\xF1' !=  u'\xf1'? 1 : -1];
 int array1['ñ' !=  u'\xf1'? 1 : -1]; // expected-error {{character too large for enclosing character literal type}}
+#if __cplusplus > 201402L
+char a = u8'ñ'; // expected-error {{character too large for enclosing character literal type}}
+char b = u8'\x80'; // ok
+char c = u8'\u0080'; // expected-error {{character too large for enclosing character literal type}}
+char d = u8'\u1234'; // expected-error {{character too large for enclosing character literal type}}
+char e = u8'ሴ'; // expected-error {{character too large for enclosing character literal type}}
+char f = u8'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+#endif
diff --git a/test/Lexer/wchar-signedness.c b/test/Lexer/wchar-signedness.c
index b5d4ac8..1d8bc4d 100644
--- a/test/Lexer/wchar-signedness.c
+++ b/test/Lexer/wchar-signedness.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-X86
 // RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
+// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM
 
 // CHECK-X86-NOT: #define __WCHAR_UNSIGNED__
 // CHECK-X86: #define __WINT_UNSIGNED__ 1
diff --git a/test/Makefile b/test/Makefile
index da7b965..5cb8a8b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -46,8 +46,8 @@
 	@$(ECHOPATH) s=@CLANG_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp
 	@$(ECHOPATH) s=@CLANG_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
 	@$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp
+	@$(ECHOPATH) s=@LLVM_HOST_TRIPLE@=$(HOST_TRIPLE)=g >> lit.tmp
 	@$(ECHOPATH) s=@ENABLE_CLANG_ARCMT@=$(ENABLE_CLANG_ARCMT)=g >> lit.tmp
-	@$(ECHOPATH) s=@ENABLE_CLANG_REWRITER@=$(ENABLE_CLANG_REWRITER)=g >> lit.tmp
 	@$(ECHOPATH) s=@ENABLE_CLANG_STATIC_ANALYZER@=$(ENABLE_CLANG_STATIC_ANALYZER)=g >> lit.tmp
 	@$(ECHOPATH) s=@ENABLE_CLANG_EXAMPLES@=$(ENABLE_CLANG_EXAMPLES)=g >> lit.tmp
 	@$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> lit.tmp
diff --git a/test/Misc/ast-dump-arm-attr.c b/test/Misc/ast-dump-arm-attr.c
index bec3531..4132816 100644
--- a/test/Misc/ast-dump-arm-attr.c
+++ b/test/Misc/ast-dump-arm-attr.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple arm-apple-darwin -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s

-

-__attribute__((interrupt)) void Test(void);

-// CHECK: FunctionDecl{{.*}}Test

-// CHECK-NEXT: ARMInterruptAttr

+// RUN: %clang_cc1 -triple arm-apple-darwin -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
+
+__attribute__((interrupt)) void Test(void);
+// CHECK: FunctionDecl{{.*}}Test
+// CHECK-NEXT: ARMInterruptAttr
diff --git a/test/Misc/ast-dump-attr.cpp b/test/Misc/ast-dump-attr.cpp
index 1aa6adf..446f0fa 100644
--- a/test/Misc/ast-dump-attr.cpp
+++ b/test/Misc/ast-dump-attr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
 
 int TestLocation
 __attribute__((unused));
@@ -135,3 +135,18 @@
   // CHECK-NOT: NoReturnAttr
   // CHECK: CXXConversionDecl{{.*}}operator void (*)() __attribute__((noreturn))
 }
+
+namespace PR20930 {
+struct S {
+  struct { int Test __attribute__((deprecated)); };
+  // CHECK: FieldDecl{{.*}}Test 'int'
+  // CHECK-NEXT: DeprecatedAttr
+};
+
+void f() {
+  S s;
+  s.Test = 1;
+  // CHECK: IndirectFieldDecl{{.*}}Test 'int'
+  // CHECK: DeprecatedAttr
+}
+}
diff --git a/test/Misc/ast-dump-color.cpp b/test/Misc/ast-dump-color.cpp
index 0bb6dd0..db4dc2b 100644
--- a/test/Misc/ast-dump-color.cpp
+++ b/test/Misc/ast-dump-color.cpp
@@ -29,11 +29,11 @@
   __attribute__((noinline)) Invalid(error);
 } Invalid;
 
-//CHECK: {{^}}[[Blue:.\[0;34m]][[RESET:.\[0m]][[GREEN:.\[0;1;32m]]TranslationUnitDecl[[RESET]][[Yellow:.\[0;33m]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]<invalid sloc>[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]<invalid sloc>[[RESET]] implicit[[CYAN:.\[0;1;36m]] __int128_t[[RESET]] [[Green:.\[0;32m]]'__int128'[[RESET]]{{$}}
+//CHECK: {{^}}[[GREEN:.\[0;1;32m]]TranslationUnitDecl[[RESET:.\[0m]][[Yellow:.\[0;33m]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]<invalid sloc>[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue:.\[0;34m]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]<invalid sloc>[[RESET]] implicit[[CYAN:.\[0;1;36m]] __int128_t[[RESET]] [[Green:.\[0;32m]]'__int128'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]<invalid sloc>[[RESET]] implicit[[CYAN]] __uint128_t[[RESET]] [[Green]]'unsigned __int128'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]TypedefDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]<invalid sloc>[[RESET]] implicit[[CYAN]] __builtin_va_list[[RESET]] [[Green]]'__va_list_tag [1]'[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]{{.*}}ast-dump-color.cpp:6:1[[RESET]], [[Yellow]]col:5[[RESET]]> [[Yellow]]col:5[[RESET]][[CYAN]] Test[[RESET]] [[Green]]'int'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]{{.*}}ast-dump-color.cpp:6:1[[RESET]], [[Yellow]]col:5[[RESET]]> [[Yellow]]col:5[[RESET]][[CYAN]] Test[[RESET]] [[Green]]'int'[[RESET]]
 //CHECK: {{^}}[[Blue]]| |-[[RESET]][[BLUE:.\[0;1;34m]]UnusedAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:25[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:4:4[[RESET]], [[Yellow]]line:5:8[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[Blue]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:4:4[[RESET]], [[Yellow]]line:5:8[[RESET]]>{{$}}
@@ -75,29 +75,29 @@
 //CHECK: {{^}}[[Blue]]| |   | `-[[RESET]][[Blue]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:6[[RESET]], [[Yellow]]col:22[[RESET]]> Text=" Another variable"{{$}}
 //CHECK: {{^}}[[Blue]]| |   `-[[RESET]][[Blue]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:23:6[[RESET]], [[Yellow]]col:44[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| |     `-[[RESET]][[Blue]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:6[[RESET]], [[Yellow]]col:44[[RESET]]> Text=" Like the other variable, but different"{{$}}
-//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:33[[RESET]]> [[Yellow]]col:33[[RESET]] implicit used[[CYAN]] Mutex[[RESET]] [[Green]]'void (void)'[[RESET]] inline{{.*$}}
+//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:33[[RESET]]> [[Yellow]]col:33[[RESET]] implicit used[[CYAN]] Mutex[[RESET]] [[Green]]'void (void) noexcept'[[RESET]] inline{{.*$}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> [[Yellow]]col:33[[RESET]] implicit[[CYAN]] Mutex[[RESET]] [[Green]]'void (const class Mutex &)'[[RESET]] inline{{ .*$}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> [[Yellow]]col:33[[RESET]] [[Green]]'const class Mutex &'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| `-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> [[Yellow]]col:33[[RESET]] implicit[[CYAN]] Mutex[[RESET]] [[Green]]'void (class Mutex &&)'[[RESET]] inline{{ .*$}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:33[[RESET]]> [[Yellow]]col:33[[RESET]] [[Green]]'class Mutex &&'[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]line:25:3[[RESET]]> [[Yellow]]col:3[[RESET]] referenced[[CYAN]] mu1[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void)'[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], [[Yellow]]line:25:8[[RESET]]> [[Yellow]]col:8[[RESET]][[CYAN]] mu2[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void)'[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:26:1[[RESET]], [[Yellow]]col:5[[RESET]]> [[Yellow]]col:5[[RESET]][[CYAN]] TestExpr[[RESET]] [[Green]]'int'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]line:25:3[[RESET]]> [[Yellow]]col:3[[RESET]] referenced[[CYAN]] mu1[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]
+//CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void) noexcept'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], [[Yellow]]line:25:8[[RESET]]> [[Yellow]]col:8[[RESET]][[CYAN]] mu2[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]
+//CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void) noexcept'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:26:1[[RESET]], [[Yellow]]col:5[[RESET]]> [[Yellow]]col:5[[RESET]][[CYAN]] TestExpr[[RESET]] [[Green]]'int'[[RESET]]
 //CHECK: {{^}}[[Blue]]| `-[[RESET]][[BLUE]]GuardedByAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:29[[RESET]], [[Yellow]]col:43[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[MAGENTA]]DeclRefExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:40[[RESET]]> [[Green]]'class Mutex':'class Mutex'[[RESET]][[Cyan]] lvalue[[RESET]][[Cyan]][[RESET]] [[GREEN]]Var[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]][[CYAN]] 'mu1'[[RESET]] [[Green]]'class Mutex':'class Mutex'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:1[[RESET]], [[Yellow]]line:30:1[[RESET]]> [[Yellow]]line:28:8[[RESET]] struct[[CYAN]] Invalid[[RESET]] definition
-//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit struct[[CYAN]] Invalid[[RESET]]
+//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit referenced struct[[CYAN]] Invalid[[RESET]]
 //CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:29:3[[RESET]], [[Yellow]]col:42[[RESET]]> [[Yellow]]col:29[[RESET]] invalid[[CYAN]] Invalid[[RESET]] [[Green]]'void (int)'[[RESET]]
 //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:37[[RESET]], [[Yellow]]<invalid sloc>[[RESET]]> [[Yellow]]col:42[[RESET]] invalid [[Green]]'int'[[RESET]]
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[BLUE]]NoInlineAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:18[[RESET]]>
-//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit used[[CYAN]] Invalid[[RESET]] [[Green]]'void (void)'[[RESET]] inline noexcept-unevaluated 0x{{[0-9a-fA-F]*}}
+//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit used[[CYAN]] Invalid[[RESET]] [[Green]]'void (void) noexcept'[[RESET]] inline
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]>
 //CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit[[CYAN]] Invalid[[RESET]] [[Green]]'void (const struct Invalid &)'[[RESET]] inline noexcept-unevaluated 0x{{[0-9a-fA-F]*}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] [[Green]]'const struct Invalid &'[[RESET]]
 //CHECK: {{^}}[[Blue]]| `-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit[[CYAN]] Invalid[[RESET]] [[Green]]'void (struct Invalid &&)'[[RESET]] inline noexcept-unevaluated 0x{{[0-9a-fA-F]*}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] [[Green]]'struct Invalid &&'[[RESET]]
 //CHECK: {{^}}[[Blue]]`-[[RESET]][[GREEN]]VarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]line:30:3[[RESET]]> [[Yellow]]col:3[[RESET]][[CYAN]] Invalid[[RESET]] [[Green]]'struct Invalid':'struct Invalid'[[RESET]]
-//CHECK: {{^}}[[Blue]]  `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'struct Invalid':'struct Invalid'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void)'[[RESET]]
+//CHECK: {{^}}[[Blue]]  `-[[RESET]][[MAGENTA]]CXXConstructExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:3[[RESET]]> [[Green]]'struct Invalid':'struct Invalid'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]] [[Green]]'void (void) noexcept'[[RESET]]
diff --git a/test/Misc/ast-dump-decl.cpp b/test/Misc/ast-dump-decl.cpp
index b41e4ee..fe7ea75 100644
--- a/test/Misc/ast-dump-decl.cpp
+++ b/test/Misc/ast-dump-decl.cpp
@@ -116,6 +116,7 @@
   class TestCXXConstructorDecl : public A {
     int I;
     TestCXXConstructorDecl(A &a, int i) : A(a), I(i) { }
+    TestCXXConstructorDecl(A &a) : TestCXXConstructorDecl(a, 0) { }
   };
 }
 // CHECK:      CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
@@ -126,6 +127,10 @@
 // CHECK:        CXXCtorInitializer{{.*}}I
 // CHECK-NEXT:     Expr
 // CHECK:        CompoundStmt
+// CHECK:      CXXConstructorDecl{{.*}} TestCXXConstructorDecl 'void {{.*}}'
+// CHECK-NEXT:   ParmVarDecl{{.*}} a
+// CHECK-NEXT:   CXXCtorInitializer{{.*}}TestCXXConstructorDecl
+// CHECK-NEXT:     CXXConstructExpr{{.*}}TestCXXConstructorDecl
 
 class TestCXXDestructorDecl {
   ~TestCXXDestructorDecl() { }
diff --git a/test/Misc/ast-dump-lookups.cpp b/test/Misc/ast-dump-lookups.cpp
new file mode 100644
index 0000000..5c6da48
--- /dev/null
+++ b/test/Misc/ast-dump-lookups.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix DECLS %s
+// RUN: %clang_cc1 -std=c++11 -ast-dump-lookups -ast-dump-filter Test %s | FileCheck -check-prefix LOOKUPS %s
+// RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter Test %s | FileCheck -check-prefix DECLS-LOOKUPS %s
+
+namespace Test {
+  extern int a;
+  int a = 0;
+}
+
+namespace Test { }
+
+// DECLS: Dumping Test:
+// DECLS-NEXT: NamespaceDecl {{.*}} Test
+// DECLS-NEXT: |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern
+// DECLS-NEXT: `-VarDecl {{.*}} prev [[EXTERN_A]] {{.*}} a 'int' cinit
+// DECLS-NEXT:   `-IntegerLiteral {{.*}} 'int' 0
+//
+// DECLS: Dumping Test:
+// DECLS-NEXT: NamespaceDecl {{.*}} Test
+
+// LOOKUPS: Dumping Test:
+// LOOKUPS-NEXT: StoredDeclsMap Namespace {{.*}} 'Test'
+// LOOKUPS-NEXT: `-DeclarationName 'a'
+// LOOKUPS-NEXT:   `-Var {{.*}} 'a' 'int'
+//
+// LOOKUPS: Dumping Test:
+// LOOKUPS-NEXT: Lookup map is in primary DeclContext
+
+// DECLS-LOOKUPS: Dumping Test:
+// DECLS-LOOKUPS-NEXT: StoredDeclsMap Namespace {{.*}} 'Test'
+// DECLS-LOOKUPS-NEXT: `-DeclarationName 'a'
+// DECLS-LOOKUPS-NEXT:   `-Var [[A:[^ ]*]] 'a' 'int'
+// DECLS-LOOKUPS-NEXT:     |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern
+// DECLS-LOOKUPS-NEXT:     `-VarDecl [[A]] prev [[EXTERN_A]] {{.*}} a 'int' cinit
+// DECLS-LOOKUPS-NEXT:       `-IntegerLiteral {{.*}} 'int' 0
+//
+// DECLS-LOOKUPS: Dumping Test:
+// DECLS-LOOKUPS-NEXT: Lookup map is in primary DeclContext
diff --git a/test/Misc/ast-dump-msp430-attr.c b/test/Misc/ast-dump-msp430-attr.c
index 170e0be..3ccb3bd 100644
--- a/test/Misc/ast-dump-msp430-attr.c
+++ b/test/Misc/ast-dump-msp430-attr.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple msp430-unknown-unknown -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s

-

-__attribute__((interrupt(12))) void Test(void);

-// CHECK: FunctionDecl{{.*}}Test

-// CHECK-NEXT: MSP430InterruptAttr

+// RUN: %clang_cc1 -triple msp430-unknown-unknown -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
+
+__attribute__((interrupt(12))) void Test(void);
+// CHECK: FunctionDecl{{.*}}Test
+// CHECK-NEXT: MSP430InterruptAttr
diff --git a/test/Misc/ast-dump-templates.cpp b/test/Misc/ast-dump-templates.cpp
index b7aeca8..022d5c4 100644
--- a/test/Misc/ast-dump-templates.cpp
+++ b/test/Misc/ast-dump-templates.cpp
@@ -39,6 +39,18 @@
 // CHECK1: template <int A, typename B> B bar()
 // CHECK2: template <int A, typename B> B bar()
 
+// CHECK1-LABEL: template <typename ...T> struct A {
+// CHECK1-NEXT:    template <T ...x[3]> struct B {
+template <typename ...T> struct A {
+  template <T ...x[3]> struct B {};
+};
+
+// CHECK1-LABEL: template <typename ...T> void f(T ...[3]) {
+// CHECK1-NEXT:    A<T [3]...> a;
+template <typename ...T> void f(T ...[3]) {
+  A<T [3]...> a;
+}
+
 namespace test2 {
 void func(int);
 void func(float);
diff --git a/test/Misc/ast-print-objectivec.m b/test/Misc/ast-print-objectivec.m
new file mode 100644
index 0000000..ef0fcaa
--- /dev/null
+++ b/test/Misc/ast-print-objectivec.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+
+@interface NSObject @end
+
+@protocol P
+- (void)MethP __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2)));
+@end
+
+@interface I : NSObject <P>
+- (void)MethI __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2)));
+@end
+
+@interface I(CAT)
+- (void)MethCAT __attribute__((availability(macosx,introduced=10_1_0,deprecated=10_2)));
+@end
+
+@implementation I
+- (void)MethP __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
+- (void)MethI __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
+@end
+
+// CHECK: @protocol P
+// CHECK: - (void) MethP __attribute__((availability(macosx, introduced=10.1.0, deprecated=10.2)));
+// CHECK: @end
+
+// CHECK: @interface I : NSObject<P> 
+// CHECK: - (void) MethI __attribute__((availability(macosx, introduced=10.1.0, deprecated=10.2)));
+// CHECK: @end
+
+// CHECK: @interface I(CAT)
+// CHECK: - (void) MethCAT __attribute__((availability(macosx, introduced=10_1_0, deprecated=10_2)));
+// CHECK: @end
+
+// CHECK: @implementation I
+// CHECK: - (void) MethP __attribute__((availability(macosx, introduced=10.1.0, deprecated=10.2))) {
+// CHECK: }
+
+// CHECK: - (void) MethI __attribute__((availability(macosx, introduced=10.1.0, deprecated=10.2))) {
+// CHECK: }
+
+// CHECK: @end
diff --git a/test/Misc/ast-print-pragmas.cpp b/test/Misc/ast-print-pragmas.cpp
index 25421fc..23f533f 100644
--- a/test/Misc/ast-print-pragmas.cpp
+++ b/test/Misc/ast-print-pragmas.cpp
@@ -38,3 +38,18 @@
     i++;
   }
 }
+
+template <int V, int I>
+void test_nontype_template_param(int *List, int Length) {
+#pragma clang loop vectorize_width(V) interleave_count(I)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
+// CHECK: #pragma clang loop interleave_count(I)
+// CHECK: #pragma clang loop vectorize_width(V)
+
+void test_templates(int *List, int Length) {
+  test_nontype_template_param<2, 4>(List, Length);
+}
diff --git a/test/Misc/attr-source-range.cpp b/test/Misc/attr-source-range.cpp
new file mode 100644
index 0000000..d5540ad
--- /dev/null
+++ b/test/Misc/attr-source-range.cpp
@@ -0,0 +1,16 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s
+
+void f(int i) __attribute__((format_arg(1)));
+// CHECK: attr-source-range.cpp:3:30:{3:41-3:42}{3:8-3:13}
+
+void g(int i, ...) __attribute__((format(printf, 1, 1)));
+// CHECK: attr-source-range.cpp:6:35:{6:50-6:51}{6:8-6:13}
+
+int h(void) __attribute__((returns_nonnull));
+// CHECK: attr-source-range.cpp:9:28:{9:1-9:4}
+
+void i(int j) __attribute__((nonnull(1)));
+// CHECK: attr-source-range.cpp:12:30:{12:38-12:39}{12:8-12:13}
+
+void j(__attribute__((nonnull)) int i);
+// CHECK: attr-source-range.cpp:15:23:{15:8-15:38}
diff --git a/test/Misc/backend-optimization-failure.cpp b/test/Misc/backend-optimization-failure.cpp
new file mode 100644
index 0000000..2ee42b8
--- /dev/null
+++ b/test/Misc/backend-optimization-failure.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -O3 -emit-llvm -gline-tables-only -S -verify -o /dev/null
+// REQUIRES: x86-registered-target
+
+// Test verifies optimization failures generated by the backend are handled
+// correctly by clang. LLVM tests verify all of the failure conditions.
+
+void test_switch(int *A, int *B, int Length) {
+#pragma clang loop vectorize(enable) unroll(disable)
+  /* expected-warning {{loop not vectorized: failed explicitly specified loop vectorization}} */ for (int i = 0; i < Length; i++) {
+    switch (A[i]) {
+    case 0:
+      B[i] = 1;
+      break;
+    case 1:
+      B[i] = 2;
+      break;
+    default:
+      B[i] = 3;
+    }
+  }
+}
diff --git a/test/Misc/diag-format.c b/test/Misc/diag-format.c
index eca5cab..8e30cf7 100644
--- a/test/Misc/diag-format.c
+++ b/test/Misc/diag-format.c
@@ -3,10 +3,13 @@
 // RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300  %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fms-compatibility-version=13.00  %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc  %s 2>&1 | FileCheck %s -check-prefix=MSVC
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fms-compatibility-version=13.00 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=vi    %s 2>&1 | FileCheck %s -check-prefix=VI
@@ -16,6 +19,7 @@
 // RUN: %clang -fsyntax-only -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=NO_COLUMN
 //
 // RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback -fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK
+// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback -fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK
 // RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback %s 2>&1 | FileCheck %s -check-prefix=MSVC-FALLBACK
 
 
@@ -30,12 +34,12 @@
 
 #ifdef foo
 #endif bad // extension!
-// DEFAULT: {{.*}}:32:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// MSVC2010: {{.*}}(32,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// MSVC: {{.*}}(32,8) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// VI: {{.*}} +32:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// MSVC_ORIG: {{.*}}(32) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// NO_COLUMN: {{.*}}:32: warning: extra tokens at end of #endif directive [-Wextra-tokens]
-// MSVC2010-FALLBACK: {{.*}}(32,7) : error(clang): extra tokens at end of #endif directive
-// MSVC-FALLBACK: {{.*}}(32,8) : error(clang): extra tokens at end of #endif directive
+// DEFAULT: {{.*}}:36:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC2010: {{.*}}(36,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC: {{.*}}(36,8) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// VI: {{.*}} +36:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC_ORIG: {{.*}}(36) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// NO_COLUMN: {{.*}}:36: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC2010-FALLBACK: {{.*}}(36,7) : error(clang): extra tokens at end of #endif directive
+// MSVC-FALLBACK: {{.*}}(36,8) : error(clang): extra tokens at end of #endif directive
 int x;
diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp
index c43ed26..bdd6d62 100644
--- a/test/Misc/diag-template-diffing.cpp
+++ b/test/Misc/diag-template-diffing.cpp
@@ -24,17 +24,17 @@
   }
 } // end namespace std
 // CHECK-ELIDE-NOTREE: no matching function for call to 'f'
-// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<class std::basic_string>' to 'vector<class versa_string>' for 1st argument 
+// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<std::basic_string>' to 'vector<versa_string>' for 1st argument
 // CHECK-NOELIDE-NOTREE: no matching function for call to 'f'
-// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<class std::basic_string>' to 'vector<class versa_string>' for 1st argument
+// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<std::basic_string>' to 'vector<versa_string>' for 1st argument
 // CHECK-ELIDE-TREE: no matching function for call to 'f'
 // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-ELIDE-TREE:   vector<
-// CHECK-ELIDE-TREE:     [class std::basic_string != class versa_string]>
+// CHECK-ELIDE-TREE:     [std::basic_string != versa_string]>
 // CHECK-NOELIDE-TREE: no matching function for call to 'f'
 // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
 // CHECK-NOELIDE-TREE:   vector<
-// CHECK-NOELIDE-TREE:     [class std::basic_string != class versa_string]>
+// CHECK-NOELIDE-TREE:     [std::basic_string != versa_string]>
 
 template <int... A>
 class I1{};
@@ -1047,7 +1047,7 @@
     using T2 = M<C<N>>;
     T2 p;
     T1 x = p;
-    // CHECK-ELIDE-NOTREE: no viable conversion from 'M<C<struct DependentInt::N, INT<1>>>' to 'M<C<int, INT<0>>>'
+    // CHECK-ELIDE-NOTREE: no viable conversion from 'M<C<DependentInt::N, INT<1>>>' to 'M<C<int, INT<0>>>'
   }
 }
 
@@ -1064,7 +1064,7 @@
 void foo() {
   vector<Atom *> v;
   AtomVector v2(v);
-  // CHECK-ELIDE-NOTREE: no known conversion from 'vector<class PR17510::Atom *, [...]>' to 'const vector<const class PR17510::Atom *, [...]>'
+  // CHECK-ELIDE-NOTREE: no known conversion from 'vector<PR17510::Atom *, [...]>' to 'const vector<const PR17510::Atom *, [...]>'
 }
 }
 
@@ -1105,6 +1105,148 @@
 }
 }
 
+namespace AddressOf {
+template <int*>
+struct S {};
+
+template <class T>
+struct Wrapper {};
+
+template <class T>
+Wrapper<T> MakeWrapper();
+int global, global2;
+constexpr int * ptr = nullptr;
+Wrapper<S<ptr>> W = MakeWrapper<S<&global>>();
+// Don't print an extra '&' for 'ptr'
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr>>'
+
+// Handle parens correctly
+Wrapper<S<(&global2)>> W2 = MakeWrapper<S<&global>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
+Wrapper<S<&global2>> W3 = MakeWrapper<S<(&global)>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
+Wrapper<S<(&global2)>> W4 = MakeWrapper<S<(&global)>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
+}
+
+namespace NullPtr {
+template <int*, int*>
+struct S {};
+
+template <class T>
+struct Wrapper {};
+
+template <class T>
+Wrapper<T> MakeWrapper();
+int global, global2;
+constexpr int * ptr = nullptr;
+constexpr int * ptr2 = static_cast<int*>(0);
+
+S<&global> s1 = S<&global, ptr>();
+S<&global, nullptr> s2 = S<&global, ptr>();
+
+S<&global, nullptr> s3 = S<&global, &global>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'S<[...], &global>' to 'S<[...], nullptr>'
+S<&global, ptr> s4 = S<&global, &global>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'S<[...], &global>' to 'S<[...], ptr>
+
+Wrapper<S<&global, nullptr>> W1 = MakeWrapper<S<&global, ptr>>();
+Wrapper<S<&global, static_cast<int*>(0)>> W2 = MakeWrapper<S<&global, ptr>>();
+
+Wrapper<S<&global, nullptr>> W3 = MakeWrapper<S<&global, &global>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], nullptr>>'
+Wrapper<S<&global, ptr>> W4 = MakeWrapper<S<&global, &global>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], ptr>>'
+
+Wrapper<S<&global2, ptr>> W5 = MakeWrapper<S<&global, nullptr>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, nullptr>> W6 = MakeWrapper<S<&global, nullptr>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, ptr2>> W7 = MakeWrapper<S<&global, nullptr>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, nullptr>> W8 = MakeWrapper<S<&global, ptr2>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, ptr>> W9 = MakeWrapper<S<&global, ptr2>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, ptr2>> W10 = MakeWrapper<S<&global, ptr>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, static_cast<int *>(0)>> W11 =
+    MakeWrapper<S<&global, nullptr>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+Wrapper<S<&global2, nullptr>> W12 =
+    MakeWrapper<S<&global, static_cast<int *>(0)>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
+
+Wrapper<S<&global, &global>> W13 = MakeWrapper<S<&global, ptr>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], nullptr>>' to 'Wrapper<S<[...], &global>>'
+Wrapper<S<&global, ptr>> W14 = MakeWrapper<S<&global, &global>>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], ptr>>'
+}
+
+namespace TemplateTemplateDefault {
+template <class> class A{};
+template <class> class B{};
+template <class> class C{};
+template <template <class> class, template <class> class = A>
+        class T {};
+
+T<A> t1 = T<A, C>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'T<[...], template C>' to 'T<[...], (default) template A>'
+T<A, C> t2 = T<A>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'T<[...], (default) template A>' to 'T<[...], template C>'
+T<A> t3 = T<B>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template B>' to 'T<template A>'
+T<B, C> t4 = T<C, B>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template C, template B>' to 'T<template B, template C>'
+T<A, A> t5 = T<B>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template B, [...]>' to 'T<template A, [...]>'
+T<B> t6 = T<A, A>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template A, [...]>' to 'T<template B, [...]>'
+}
+
+namespace Bool {
+template <class> class A{};
+A<bool> a1 = A<int>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'A<int>' to 'A<bool>'
+A<int> a2 = A<bool>();
+// CHECK-ELIDE-NOTREE: no viable conversion from 'A<bool>' to 'A<int>'
+}
+
+namespace TypeAlias {
+template <int, int = 0> class A {};
+
+template <class T> using a = A<T::num, 0>;
+template <class T> using a = A<T::num>;
+
+template <class T> using A1 = A<T::num>;
+template <class T> using A1 = A<T::num + 0>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 0>' vs 'A<T::num>')
+
+template <class T> using A2 = A<1 + T::num>;
+template <class T> using A2 = A<T::num + 1>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 1>' vs 'A<1 + T::num>')
+
+template <class T> using A3 = A<(T::num)>;
+template <class T> using A3 = A<T::num>;
+// CHECK-ELIDE-NOTREE: error: type alias template redefinition with different types ('A<T::num>' vs 'A<(T::num)>')
+
+          template <class T> using A4 = A<(T::num)>;
+template <class T> using A4 = A<((T::num))>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<((T::num))>' vs 'A<(T::num)>')
+
+template <class T> using A5 = A<T::num, 1>;
+template <class T> using A5 = A<T::num>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
+
+template <class T> using A6 = A<T::num + 5, 1>;
+template <class T> using A6 = A<T::num + 5>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
+
+template <class T> using A7 = A<T::num, 1>;
+template <class T> using A7 = A<(T::num)>;
+// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<(T::num), (default) 0>' vs 'A<T::num, 1>')
+}
+
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
diff --git a/test/Misc/serialized-diags-driver.c b/test/Misc/serialized-diags-driver.c
new file mode 100644
index 0000000..ad07d66
--- /dev/null
+++ b/test/Misc/serialized-diags-driver.c
@@ -0,0 +1,20 @@
+// Test that the driver correctly combines its own diagnostics with CC1's in the
+// serialized diagnostics. To test this, we need to trigger diagnostics from
+// both processes, so we compile code that has a warning (with an associated
+// note) and then force the driver to crash. We compile stdin so that the crash
+// doesn't litter the user's system with preprocessed output.
+
+// RUN: rm -f %t
+// RUN: %clang -Wx-unknown-warning -Wall -fsyntax-only --serialize-diagnostics %t.diag %s
+// RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
+
+// CHECK: warning: unknown warning option '-Wx-unknown-warning' [-Wunknown-warning-option] []
+
+// CHECK: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: Number of diagnostics: 2
+
+void foo() {
+  int voodoo;
+  voodoo = voodoo + 1;
+}
diff --git a/test/Misc/serialized-diags.m b/test/Misc/serialized-diags.m
index aac791e..71c983b 100644
--- a/test/Misc/serialized-diags.m
+++ b/test/Misc/serialized-diags.m
@@ -21,7 +21,7 @@
 // CHECK: Range: {{.*[/\\]}}serialized-diags.m:8:4 {{.*[/\\]}}serialized-diags.m:8:9
 // CHECK: Number FIXITs = 1
 // CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.m:8:4 - {{.*[/\\]}}serialized-diags.m:8:9): "self"
-// CHECK: +-(null):0:0: note: 'self' is an implicit parameter [] []
+// CHECK: +-(null):0:0: note: 'self' is an implicit parameter [] [Semantic Issue]
 // CHECK: Number FIXITs = 0
 // CHECK: {{.*[/\\]}}serialized-diags.m:1:12: warning: class 'Foo' defined without specifying a base class [-Wobjc-root-class] [Semantic Issue]
 // CHECK: Number FIXITs = 0
diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c
index b46e4fe..2afa88f 100644
--- a/test/Misc/warning-flags.c
+++ b/test/Misc/warning-flags.c
@@ -18,11 +18,13 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (105):
-CHECK-NEXT:   ext_delete_void_ptr_operand
+CHECK: Warnings without flags (98):
+CHECK-NEXT:   ext_excess_initializers
+CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
 CHECK-NEXT:   ext_implicit_lib_function_decl
+CHECK-NEXT:   ext_initializer_string_for_char_array_too_long
 CHECK-NEXT:   ext_many_braces_around_scalar_init
 CHECK-NEXT:   ext_missing_declspec
 CHECK-NEXT:   ext_missing_whitespace_after_macro_name
@@ -69,8 +71,6 @@
 CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_exception_caught_by_earlier_handler
-CHECK-NEXT:   warn_excess_initializers
-CHECK-NEXT:   warn_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
 CHECK-NEXT:   warn_fe_cc_log_diagnostics_failure
@@ -80,12 +80,10 @@
 CHECK-NEXT:   warn_ignoring_ftabstop_value
 CHECK-NEXT:   warn_implements_nscopying
 CHECK-NEXT:   warn_incompatible_qualified_id
-CHECK-NEXT:   warn_initializer_string_for_char_array_too_long
 CHECK-NEXT:   warn_inline_namespace_reopened_noninline
 CHECK-NEXT:   warn_invalid_asm_cast_lvalue
 CHECK-NEXT:   warn_maynot_respond
 CHECK-NEXT:   warn_method_param_redefinition
-CHECK-NEXT:   warn_mismatched_exception_spec
 CHECK-NEXT:   warn_missing_case_for_condition
 CHECK-NEXT:   warn_missing_dependent_template_keyword
 CHECK-NEXT:   warn_missing_exception_specification
@@ -97,7 +95,6 @@
 CHECK-NEXT:   warn_objc_property_copy_missing_on_block
 CHECK-NEXT:   warn_objc_protocol_qualifier_missing_id
 CHECK-NEXT:   warn_on_superclass_use
-CHECK-NEXT:   warn_param_default_argument_redefinition
 CHECK-NEXT:   warn_partial_specs_not_deducible
 CHECK-NEXT:   warn_pp_convert_lhs_to_positive
 CHECK-NEXT:   warn_pp_convert_rhs_to_positive
@@ -105,12 +102,8 @@
 CHECK-NEXT:   warn_pp_line_decimal
 CHECK-NEXT:   warn_pragma_pack_pop_identifer_and_alignment
 CHECK-NEXT:   warn_pragma_pack_show
-CHECK-NEXT:   warn_property_attr_mismatch
-CHECK-NEXT:   warn_property_attribute
 CHECK-NEXT:   warn_property_getter_owning_mismatch
-CHECK-NEXT:   warn_property_types_are_incompatible
 CHECK-NEXT:   warn_readonly_property
-CHECK-NEXT:   warn_redeclaration_without_attribute_prev_attribute_ignored
 CHECK-NEXT:   warn_register_objc_catch_parm
 CHECK-NEXT:   warn_related_result_type_compatibility_class
 CHECK-NEXT:   warn_related_result_type_compatibility_protocol
diff --git a/test/Modules/Inputs/AddRemovePrivate.framework/Headers/AddRemovePrivate.h b/test/Modules/Inputs/AddRemovePrivate.framework/Headers/AddRemovePrivate.h
new file mode 100644
index 0000000..3ab7743
--- /dev/null
+++ b/test/Modules/Inputs/AddRemovePrivate.framework/Headers/AddRemovePrivate.h
@@ -0,0 +1 @@
+// AddRemovePrivate.h
diff --git a/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.modulemap b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.modulemap
new file mode 100644
index 0000000..7d84297
--- /dev/null
+++ b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.modulemap
@@ -0,0 +1 @@
+framework module AddRemovePrivate { umbrella header "AddRemovePrivate.h" }
diff --git a/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap
new file mode 100644
index 0000000..69b67c2
--- /dev/null
+++ b/test/Modules/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap
@@ -0,0 +1 @@
+explicit module AddRemovePrivate.Private { }
diff --git a/test/Modules/Inputs/PR20399/FirstHeader.h b/test/Modules/Inputs/PR20399/FirstHeader.h
new file mode 100644
index 0000000..43adf3d
--- /dev/null
+++ b/test/Modules/Inputs/PR20399/FirstHeader.h
@@ -0,0 +1,14 @@
+#ifndef FIRSTHEADER
+#define FIRSTHEADER
+
+#include "SecondHeader.h" // Just a class which gets in the lazy deserialization chain
+
+#include "stl_map.h"
+#include "vector"
+typedef std::map<int>::iterator el;
+
+inline void func() {
+  std::vector<int>::func();
+}
+
+#endif
diff --git a/test/Modules/Inputs/PR20399/SecondHeader.h b/test/Modules/Inputs/PR20399/SecondHeader.h
new file mode 100644
index 0000000..92815e9
--- /dev/null
+++ b/test/Modules/Inputs/PR20399/SecondHeader.h
@@ -0,0 +1,13 @@
+#ifndef SECONDHEADER
+#define SECONDHEADER
+
+#include "vector"
+
+template <class T>
+struct Address {};
+
+template <>
+struct Address<std::vector<bool>>
+    : Address<std::vector<bool>::iterator> {};
+
+#endif
diff --git a/test/Modules/Inputs/PR20399/module.modulemap b/test/Modules/Inputs/PR20399/module.modulemap
new file mode 100644
index 0000000..223434a
--- /dev/null
+++ b/test/Modules/Inputs/PR20399/module.modulemap
@@ -0,0 +1,18 @@
+module stdlib [system] {
+    header "stl_map.h"
+    header "vector"
+ }
+
+module libCore {
+  header "SecondHeader.h"
+    use stdlib
+  export *
+}
+
+module libGdml {
+  header "FirstHeader.h"
+  use libCore
+    use stdlib
+  export *
+}
+
diff --git a/test/Modules/Inputs/PR20399/stl_map.h b/test/Modules/Inputs/PR20399/stl_map.h
new file mode 100644
index 0000000..334f8b3
--- /dev/null
+++ b/test/Modules/Inputs/PR20399/stl_map.h
@@ -0,0 +1,13 @@
+namespace std {
+struct reverse_iterator {};
+
+inline void
+operator-(int __x, reverse_iterator __y) {}
+
+template <typename _Key>
+struct map {
+  typedef int iterator;
+
+  friend bool operator<(const map &, const map &);
+};
+} // namespace std
diff --git a/test/Modules/Inputs/PR20399/vector b/test/Modules/Inputs/PR20399/vector
new file mode 100644
index 0000000..1e1b670
--- /dev/null
+++ b/test/Modules/Inputs/PR20399/vector
@@ -0,0 +1,17 @@
+namespace std {
+template <typename _Tp, typename _Alloc = int>
+struct vector {
+  static void func() { vector *i, *j; i - j; }
+};
+
+struct bit_iterator { ~bit_iterator() {} };
+
+inline void operator-(int __x, const bit_iterator &__y) {
+}
+
+template <typename _Alloc>
+struct vector<bool, _Alloc> : bit_iterator {
+  typedef bit_iterator iterator;
+};
+
+} // namespace std
diff --git a/test/Modules/Inputs/PR20786/TBranchProxy.h b/test/Modules/Inputs/PR20786/TBranchProxy.h
new file mode 100644
index 0000000..91f3730
--- /dev/null
+++ b/test/Modules/Inputs/PR20786/TBranchProxy.h
@@ -0,0 +1,2 @@
+#include "random.h"
+#include "TFormula.h"
diff --git a/test/Modules/Inputs/PR20786/TFormula.h b/test/Modules/Inputs/PR20786/TFormula.h
new file mode 100644
index 0000000..316e3ad
--- /dev/null
+++ b/test/Modules/Inputs/PR20786/TFormula.h
@@ -0,0 +1 @@
+#include "TMath.h"
diff --git a/test/Modules/Inputs/PR20786/TMath.h b/test/Modules/Inputs/PR20786/TMath.h
new file mode 100644
index 0000000..b7dba62
--- /dev/null
+++ b/test/Modules/Inputs/PR20786/TMath.h
@@ -0,0 +1 @@
+#include "random.h"
diff --git a/test/Modules/Inputs/PR20786/module.modulemap b/test/Modules/Inputs/PR20786/module.modulemap
new file mode 100644
index 0000000..daf78cd
--- /dev/null
+++ b/test/Modules/Inputs/PR20786/module.modulemap
@@ -0,0 +1,3 @@
+module TMath { header "TMath.h" }
+module TFormula { header "TFormula.h" }
+module TBranchProxy { header "TBranchProxy.h" }
diff --git a/test/Modules/Inputs/PR20786/random.h b/test/Modules/Inputs/PR20786/random.h
new file mode 100644
index 0000000..86a7d83
--- /dev/null
+++ b/test/Modules/Inputs/PR20786/random.h
@@ -0,0 +1,12 @@
+namespace std {
+  template<typename> struct mersenne_twister_engine {
+    friend bool operator==(const mersenne_twister_engine &,
+                           const mersenne_twister_engine &) {
+      return false;
+    }
+  };
+  struct random_device {
+    mersenne_twister_engine<int> mt; // require complete type
+  };
+}
+
diff --git a/test/Modules/Inputs/StdDef/include_again.h b/test/Modules/Inputs/StdDef/include_again.h
new file mode 100644
index 0000000..f29f636
--- /dev/null
+++ b/test/Modules/Inputs/StdDef/include_again.h
@@ -0,0 +1,2 @@
+#include <stddef.h>
+
diff --git a/test/Modules/Inputs/StdDef/module.map b/test/Modules/Inputs/StdDef/module.map
index 69c69ea..5c4e0da 100644
--- a/test/Modules/Inputs/StdDef/module.map
+++ b/test/Modules/Inputs/StdDef/module.map
@@ -8,4 +8,14 @@
     header "other.h"
     export *
   }
+
+  module PtrDiffT {
+    header "ptrdiff_t.h"
+    export *
+  }
+
+  module IncludeAgain {
+    header "include_again.h"
+    export *
+  }
 }
diff --git a/test/Modules/Inputs/StdDef/ptrdiff_t.h b/test/Modules/Inputs/StdDef/ptrdiff_t.h
new file mode 100644
index 0000000..acb0ab8
--- /dev/null
+++ b/test/Modules/Inputs/StdDef/ptrdiff_t.h
@@ -0,0 +1,2 @@
+#define __need_ptrdiff_t
+#include <stddef.h>
diff --git a/test/Modules/Inputs/cxx-decls-imported.h b/test/Modules/Inputs/cxx-decls-imported.h
index 38cc00d..8c1e74f 100644
--- a/test/Modules/Inputs/cxx-decls-imported.h
+++ b/test/Modules/Inputs/cxx-decls-imported.h
@@ -23,3 +23,27 @@
 
 extern int mergeUsedFlag;
 inline int getMergeUsedFlag() { return mergeUsedFlag; }
+
+typedef struct {
+  int n;
+  int m;
+} NameForLinkage;
+
+struct HasVirtualFunctions {
+  virtual void f();
+};
+struct OverridesVirtualFunctions : HasVirtualFunctions {
+  void f();
+};
+extern "C" void ExternCFunction();
+
+typedef struct {
+  struct Inner {
+    int n;
+  };
+} NameForLinkage2;
+auto name_for_linkage2_inner_a = NameForLinkage2::Inner();
+typedef decltype(name_for_linkage2_inner_a) NameForLinkage2Inner;
+
+namespace Aliased { extern int a; }
+namespace Alias = Aliased;
diff --git a/test/Modules/Inputs/cxx-decls-merged.h b/test/Modules/Inputs/cxx-decls-merged.h
index ccc3b01..86e81a9 100644
--- a/test/Modules/Inputs/cxx-decls-merged.h
+++ b/test/Modules/Inputs/cxx-decls-merged.h
@@ -1 +1,27 @@
 extern int mergeUsedFlag;
+
+typedef struct {
+  int n;
+  int m;
+} NameForLinkage;
+extern NameForLinkage name_for_linkage;
+
+struct HasVirtualFunctions {
+  virtual void f();
+};
+struct OverridesVirtualFunctions : HasVirtualFunctions {
+  void f();
+};
+extern OverridesVirtualFunctions overrides_virtual_functions;
+extern "C" void ExternCFunction();
+
+typedef struct {
+  struct Inner {
+    int n;
+  };
+} NameForLinkage2;
+auto name_for_linkage2_inner_b = NameForLinkage2::Inner();
+typedef decltype(name_for_linkage2_inner_b) NameForLinkage2Inner;
+
+namespace Aliased { extern int b; }
+namespace Alias = Aliased;
diff --git a/test/Modules/Inputs/cxx-decls-premerged.h b/test/Modules/Inputs/cxx-decls-premerged.h
new file mode 100644
index 0000000..064fb9e
--- /dev/null
+++ b/test/Modules/Inputs/cxx-decls-premerged.h
@@ -0,0 +1,3 @@
+extern "C" void ExternCFunction();
+
+#include "cxx-decls-imported.h"
diff --git a/test/Modules/Inputs/cxx-irgen-left.h b/test/Modules/Inputs/cxx-irgen-left.h
index ceb5084..31ae805 100644
--- a/test/Modules/Inputs/cxx-irgen-left.h
+++ b/test/Modules/Inputs/cxx-irgen-left.h
@@ -9,3 +9,18 @@
 inline int instantiate_CtorInit(CtorInit<int> i = CtorInit<int>()) {
   return i.a;
 }
+
+namespace ImplicitSpecialMembers {
+  inline void create_left() {
+    // Trigger declaration, but not definition, of special members.
+    B b(0); C c(0); D d(0);
+    // Trigger definition of copy constructor.
+    C c2(c); D d2(d);
+  }
+}
+
+namespace OperatorDeleteLookup {
+  // Trigger definition of A::~A() and lookup of operator delete.
+  // Likewise for B<int>::~B().
+  inline void f() { A a; B<int> b; }
+}
diff --git a/test/Modules/Inputs/cxx-irgen-right.h b/test/Modules/Inputs/cxx-irgen-right.h
index 4400c76..30686a1 100644
--- a/test/Modules/Inputs/cxx-irgen-right.h
+++ b/test/Modules/Inputs/cxx-irgen-right.h
@@ -1,3 +1,13 @@
 #include "cxx-irgen-top.h"
 
 inline int h() { return S<int>::f(); }
+
+namespace ImplicitSpecialMembers {
+  inline void create_right() {
+    // Trigger declaration, but not definition, of special members.
+    B b(0); C c(0); D d(0);
+    // Trigger definition of move constructor.
+    B b2(static_cast<B&&>(b));
+    D d2(static_cast<D&&>(d));
+  }
+}
diff --git a/test/Modules/Inputs/cxx-irgen-top.h b/test/Modules/Inputs/cxx-irgen-top.h
index 8753d8d..f1a0bee 100644
--- a/test/Modules/Inputs/cxx-irgen-top.h
+++ b/test/Modules/Inputs/cxx-irgen-top.h
@@ -14,3 +14,38 @@
   int a;
   CtorInit() : a(f()) {}
 };
+
+namespace ImplicitSpecialMembers {
+  struct A {
+    A(const A&);
+  };
+  struct B {
+    A a;
+    B(int);
+  };
+  struct C {
+    A a;
+    C(int);
+  };
+  struct D {
+    A a;
+    D(int);
+  };
+}
+
+namespace OperatorDeleteLookup {
+  struct A { void operator delete(void*); virtual ~A() = default; };
+  template<typename T> struct B { void operator delete(void*); virtual ~B() {} typedef int t; };
+  typedef B<int>::t b_int_instantated;
+}
+
+namespace EmitInlineMethods {
+  struct A {
+    void f() {}
+    void g();
+  };
+  struct B {
+    void f();
+    void g() {}
+  };
+}
diff --git a/test/Modules/Inputs/cxx-lookup/a.h b/test/Modules/Inputs/cxx-lookup/a.h
new file mode 100644
index 0000000..25f614f
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/a.h
@@ -0,0 +1,2 @@
+// a
+namespace llvm { class GlobalValue; }
diff --git a/test/Modules/Inputs/cxx-lookup/b.h b/test/Modules/Inputs/cxx-lookup/b.h
new file mode 100644
index 0000000..c2ede9f
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/b.h
@@ -0,0 +1,3 @@
+// b
+namespace llvm { class GlobalValue; }
+#include "y.h"
diff --git a/test/Modules/Inputs/cxx-lookup/c1.h b/test/Modules/Inputs/cxx-lookup/c1.h
new file mode 100644
index 0000000..dba4a4c
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/c1.h
@@ -0,0 +1,3 @@
+// c1
+#include "a.h"
+#include "b.h"
diff --git a/test/Modules/Inputs/cxx-lookup/c2.h b/test/Modules/Inputs/cxx-lookup/c2.h
new file mode 100644
index 0000000..463e270
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/c2.h
@@ -0,0 +1,2 @@
+// c2
+namespace llvm { class GlobalValue; }
diff --git a/test/Modules/Inputs/cxx-lookup/module.modulemap b/test/Modules/Inputs/cxx-lookup/module.modulemap
new file mode 100644
index 0000000..6d397af
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/module.modulemap
@@ -0,0 +1,8 @@
+module A { header "a.h" export * }
+module B { header "b.h" export * }
+module C {
+  module C2 { header "c2.h" export * }
+  module C1 { header "c1.h" export * }
+}
+module X { header "x.h" export * }
+module Y { header "y.h" export * }
diff --git a/test/Modules/Inputs/cxx-lookup/x.h b/test/Modules/Inputs/cxx-lookup/x.h
new file mode 100644
index 0000000..a8826e0
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/x.h
@@ -0,0 +1,2 @@
+template <class T> class allocator;
+struct X { virtual allocator<char> f(); };
diff --git a/test/Modules/Inputs/cxx-lookup/y.h b/test/Modules/Inputs/cxx-lookup/y.h
new file mode 100644
index 0000000..8867e8a
--- /dev/null
+++ b/test/Modules/Inputs/cxx-lookup/y.h
@@ -0,0 +1,5 @@
+#include "x.h"
+namespace llvm {
+  struct ulittle32_t;
+  extern allocator<ulittle32_t> *x;
+}
diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h
index 12b647b..4340910 100644
--- a/test/Modules/Inputs/cxx-templates-a.h
+++ b/test/Modules/Inputs/cxx-templates-a.h
@@ -29,6 +29,8 @@
   SomeTemplate<char[2]> a;
   SomeTemplate<char[1]> b, c;
   b = c;
+
+  (void)&WithImplicitSpecialMembers<int>::n;
 }
 
 template<int> struct MergeTemplates;
@@ -56,6 +58,7 @@
   T &f() { static T t; return t; }
 };
 typedef WithPartialSpecializationUse::type WithPartialSpecializationInstantiate;
+typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate2;
 
 template<> struct WithExplicitSpecialization<int> {
   int n;
@@ -63,3 +66,41 @@
     return n;
   }
 };
+
+template<typename T> template<typename U>
+constexpr int Outer<T>::Inner<U>::f() { return 1; }
+static_assert(Outer<int>::Inner<int>::f() == 1, "");
+
+template<typename T> struct MergeTemplateDefinitions {
+  static constexpr int f();
+  static constexpr int g();
+};
+template<typename T> constexpr int MergeTemplateDefinitions<T>::f() { return 1; }
+
+template<typename T> using AliasTemplate = T;
+
+template<typename T> struct PartiallyInstantiatePartialSpec {};
+template<typename T> struct PartiallyInstantiatePartialSpec<T*> {
+  static T *foo() { return reinterpret_cast<T*>(0); }
+  static T *bar() { return reinterpret_cast<T*>(0); }
+};
+typedef PartiallyInstantiatePartialSpec<int*> PartiallyInstantiatePartialSpecHelper;
+
+void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>);
+inline int InstantiateWithAnonymousDeclsA(WithAnonymousDecls<int> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; }
+inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x);
+
+
+template<typename T1 = int>
+struct MergeAnonUnionMember {
+  MergeAnonUnionMember() { (void)values.t1; }
+  union { int t1; } values;
+};
+inline MergeAnonUnionMember<> maum_a() { return {}; }
+
+template<typename T> struct DontWalkPreviousDeclAfterMerging { struct Inner { typedef T type; }; };
+
+namespace TestInjectedClassName {
+  template<typename T> struct X { X(); };
+  typedef X<char[1]> A;
+}
diff --git a/test/Modules/Inputs/cxx-templates-b.h b/test/Modules/Inputs/cxx-templates-b.h
index a682855..d763c80 100644
--- a/test/Modules/Inputs/cxx-templates-b.h
+++ b/test/Modules/Inputs/cxx-templates-b.h
@@ -20,6 +20,15 @@
 template<int> struct MergeTemplates;
 MergeTemplates<0> *merge_templates_b;
 
+template<typename T> template<typename U>
+constexpr int Outer<T>::Inner<U>::g() { return 2; }
+static_assert(Outer<int>::Inner<int>::g() == 2, "");
+
+namespace TestInjectedClassName {
+  template<typename T> struct X { X(); };
+  typedef X<char[2]> B;
+}
+
 @import cxx_templates_b_impl;
 
 template<typename T, typename> struct Identity { typedef T type; };
@@ -42,6 +51,8 @@
   SomeTemplate<char[1]> a;
   SomeTemplate<char[2]> b, c;
   b = c;
+
+  WithImplicitSpecialMembers<int> wism1, wism2(wism1);
 }
 
 auto enum_b_from_b = CommonTemplate<int>::b;
@@ -51,6 +62,8 @@
 template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
 constexpr void (*UseRedeclaredEnumB)(UseInt<1>) = UseRedeclaredEnum<int>;
 
+typedef WithPartialSpecialization<void(int)>::type WithPartialSpecializationInstantiate3;
+
 template<typename> struct MergeSpecializations;
 template<typename T> struct MergeSpecializations<T&> {
   typedef int partially_specialized_in_b;
@@ -59,6 +72,16 @@
   typedef int explicitly_specialized_in_b;
 };
 
+template<typename U> using AliasTemplate = U;
+
+void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>);
+inline int InstantiateWithAnonymousDeclsB(WithAnonymousDecls<int> x) {
+  return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e;
+}
+inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x) {
+  return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e;
+}
+
 @import cxx_templates_a;
 template<typename T> void UseDefinedInBImplIndirectly(T &v) {
   PerformDelayedLookup(v);
@@ -67,4 +90,6 @@
 void TriggerInstantiation() {
   UseDefinedInBImpl<void>();
   Std::f<int>();
+  PartiallyInstantiatePartialSpec<int*>::foo();
+  WithPartialSpecialization<void(int)>::type x;
 }
diff --git a/test/Modules/Inputs/cxx-templates-c.h b/test/Modules/Inputs/cxx-templates-c.h
index 4c0fc8a..e5395b6 100644
--- a/test/Modules/Inputs/cxx-templates-c.h
+++ b/test/Modules/Inputs/cxx-templates-c.h
@@ -5,3 +5,24 @@
 template<> struct MergeSpecializations<bool> {
   typedef int explicitly_specialized_in_c;
 };
+
+template<typename T> struct MergeTemplateDefinitions {
+  static constexpr int f();
+  static constexpr int g();
+};
+template<typename T> constexpr int MergeTemplateDefinitions<T>::g() { return 2; }
+
+template<typename T1 = int>
+struct MergeAnonUnionMember {
+  MergeAnonUnionMember() { (void)values.t1; }
+  union { int t1; } values;
+};
+inline MergeAnonUnionMember<> maum_c() { return {}; }
+
+template<typename T> struct DontWalkPreviousDeclAfterMerging { struct Inner { typedef T type; }; };
+typedef DontWalkPreviousDeclAfterMerging<char>::Inner dwpdam_typedef;
+
+namespace TestInjectedClassName {
+  template<typename T> struct X { X(); };
+  typedef X<char[3]> C;
+}
diff --git a/test/Modules/Inputs/cxx-templates-common.h b/test/Modules/Inputs/cxx-templates-common.h
index 986c52b..a9ca624 100644
--- a/test/Modules/Inputs/cxx-templates-common.h
+++ b/test/Modules/Inputs/cxx-templates-common.h
@@ -26,13 +26,31 @@
 
 template<typename T> struct Outer {
   template<typename U> struct Inner {
-    void f();
-    void g();
+    static constexpr int f();
+    static constexpr int g();
   };
 };
 
 template<typename T> struct WithPartialSpecialization {};
+template<typename T> struct WithPartialSpecialization<void(T)> { typedef int type; };
 typedef WithPartialSpecialization<int*> WithPartialSpecializationUse;
+typedef WithPartialSpecialization<void(int)> WithPartialSpecializationUse2;
 
 template<typename T> struct WithExplicitSpecialization;
 typedef WithExplicitSpecialization<int> WithExplicitSpecializationUse;
+
+template<typename T> struct WithImplicitSpecialMembers { int n; };
+
+template<typename T> struct WithAliasTemplate {
+  template<typename> using X = T;
+};
+
+template<typename T> struct WithAnonymousDecls {
+  struct { bool k; };
+  union { int a, b; };
+  struct { int c, d; } s;
+  enum { e = 123 };
+  typedef int X;
+};
+
+#include "cxx-templates-textual.h"
diff --git a/test/Modules/Inputs/cxx-templates-d.h b/test/Modules/Inputs/cxx-templates-d.h
new file mode 100644
index 0000000..1fb1a22
--- /dev/null
+++ b/test/Modules/Inputs/cxx-templates-d.h
@@ -0,0 +1,9 @@
+@import cxx_templates_common;
+
+inline int InstantiateWithAnonymousDeclsD(WithAnonymousDecls<char> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; }
+
+namespace TestInjectedClassName {
+  template<typename T> struct X { X(); };
+  typedef X<int> D;
+  inline D UseD() { return D(); }
+}
diff --git a/test/Modules/Inputs/cxx-templates-textual.h b/test/Modules/Inputs/cxx-templates-textual.h
new file mode 100644
index 0000000..8bffb8e
--- /dev/null
+++ b/test/Modules/Inputs/cxx-templates-textual.h
@@ -0,0 +1,2 @@
+template<typename T> struct MergeClassTemplateSpecializations_basic_string {};
+typedef MergeClassTemplateSpecializations_basic_string<char> MergeClassTemplateSpecializations_string;
diff --git a/test/Modules/Inputs/declare-use/k.h b/test/Modules/Inputs/declare-use/k.h
new file mode 100644
index 0000000..338178e
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/k.h
@@ -0,0 +1,8 @@
+#ifdef GIMME_A_K
+
+#ifndef K_H
+#define K_H
+const int k = 42;
+#endif
+
+#endif
diff --git a/test/Modules/Inputs/declare-use/l.h b/test/Modules/Inputs/declare-use/l.h
new file mode 100644
index 0000000..a43fd1a
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/l.h
@@ -0,0 +1,8 @@
+#ifdef GIMME_AN_L
+
+#ifndef L_H
+#define L_H
+const int l = 42;
+#endif
+
+#endif
diff --git a/test/Modules/Inputs/declare-use/m.h b/test/Modules/Inputs/declare-use/m.h
new file mode 100644
index 0000000..e9089ab
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/m.h
@@ -0,0 +1,8 @@
+#ifdef GIMME_AN_M
+
+#ifndef M_H
+#define M_H
+const int m = 42;
+#endif
+
+#endif
diff --git a/test/Modules/Inputs/declare-use/m2.h b/test/Modules/Inputs/declare-use/m2.h
new file mode 100644
index 0000000..9e72835
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/m2.h
@@ -0,0 +1 @@
+#include "m.h"
diff --git a/test/Modules/Inputs/declare-use/module.map b/test/Modules/Inputs/declare-use/module.map
index a176fb3..ae86152 100644
--- a/test/Modules/Inputs/declare-use/module.map
+++ b/test/Modules/Inputs/declare-use/module.map
@@ -38,6 +38,7 @@
   use XC
   use XE
   use XJ
+  use XK
 }
 
 module XH {
@@ -52,5 +53,18 @@
   header "j.h"
 }
 
+module XK {
+  textual header "k.h"
+}
+
+module XL {
+  textual header "l.h"
+}
+
+module XM {
+  private textual header "m.h"
+  textual header "m2.h"
+}
+
 module XS {
 }
diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h
index fce2e48..6494551 100644
--- a/test/Modules/Inputs/diamond_left.h
+++ b/test/Modules/Inputs/diamond_left.h
@@ -1,3 +1,5 @@
+int top_left_before(void *);
+
 @import diamond_top;
 
 float left(float *);
diff --git a/test/Modules/Inputs/diamond_top.h b/test/Modules/Inputs/diamond_top.h
index 34998cd..30da14f 100644
--- a/test/Modules/Inputs/diamond_top.h
+++ b/test/Modules/Inputs/diamond_top.h
@@ -2,3 +2,4 @@
 
 int top_left(char *c);
 
+int top_left_before(void *);
diff --git a/test/Modules/Inputs/explicit-build/a.h b/test/Modules/Inputs/explicit-build/a.h
new file mode 100644
index 0000000..5e3602f
--- /dev/null
+++ b/test/Modules/Inputs/explicit-build/a.h
@@ -0,0 +1,5 @@
+#if !__building_module(a)
+#error "should only get here when building module a"
+#endif
+
+const int a = 1;
diff --git a/test/Modules/Inputs/explicit-build/b.h b/test/Modules/Inputs/explicit-build/b.h
new file mode 100644
index 0000000..449b385
--- /dev/null
+++ b/test/Modules/Inputs/explicit-build/b.h
@@ -0,0 +1,7 @@
+#include "a.h"
+
+#if !__building_module(b)
+#error "should only get here when building module b"
+#endif
+
+const int b = 2;
diff --git a/test/Modules/Inputs/explicit-build/c.h b/test/Modules/Inputs/explicit-build/c.h
new file mode 100644
index 0000000..2c66a23
--- /dev/null
+++ b/test/Modules/Inputs/explicit-build/c.h
@@ -0,0 +1,7 @@
+#include "b.h"
+
+#if !__building_module(c)
+#error "should only get here when building module c"
+#endif
+
+const int c = 3;
diff --git a/test/Modules/Inputs/explicit-build/module.modulemap b/test/Modules/Inputs/explicit-build/module.modulemap
new file mode 100644
index 0000000..bd6ea83
--- /dev/null
+++ b/test/Modules/Inputs/explicit-build/module.modulemap
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" export * }
+module c { header "c.h" export * }
diff --git a/test/Modules/Inputs/filename/a.h b/test/Modules/Inputs/filename/a.h
new file mode 100644
index 0000000..8f896a9
--- /dev/null
+++ b/test/Modules/Inputs/filename/a.h
@@ -0,0 +1 @@
+const char *p = __FILE__;
diff --git a/test/Modules/Inputs/filename/module.map b/test/Modules/Inputs/filename/module.map
new file mode 100644
index 0000000..ff164ad
--- /dev/null
+++ b/test/Modules/Inputs/filename/module.map
@@ -0,0 +1,3 @@
+module "A" {
+  header "a.h"
+}
diff --git a/test/Modules/Inputs/include_next/x/a.h b/test/Modules/Inputs/include_next/x/a.h
new file mode 100644
index 0000000..7182287
--- /dev/null
+++ b/test/Modules/Inputs/include_next/x/a.h
@@ -0,0 +1,2 @@
+#include_next "a.h"
+enum { ax = 1 };
diff --git a/test/Modules/Inputs/include_next/x/module.modulemap b/test/Modules/Inputs/include_next/x/module.modulemap
new file mode 100644
index 0000000..d0956d9
--- /dev/null
+++ b/test/Modules/Inputs/include_next/x/module.modulemap
@@ -0,0 +1,2 @@
+module xa { header "a.h" export * }
+module xb { header "subdir/b.h" export * }
diff --git a/test/Modules/Inputs/include_next/x/subdir/b.h b/test/Modules/Inputs/include_next/x/subdir/b.h
new file mode 100644
index 0000000..d9449e1
--- /dev/null
+++ b/test/Modules/Inputs/include_next/x/subdir/b.h
@@ -0,0 +1,2 @@
+#include_next <b.h>
+enum { bx = 3 };
diff --git a/test/Modules/Inputs/include_next/y/a.h b/test/Modules/Inputs/include_next/y/a.h
new file mode 100644
index 0000000..703ec95
--- /dev/null
+++ b/test/Modules/Inputs/include_next/y/a.h
@@ -0,0 +1 @@
+enum { ay = 2 };
diff --git a/test/Modules/Inputs/include_next/y/b.h b/test/Modules/Inputs/include_next/y/b.h
new file mode 100644
index 0000000..629e7fd
--- /dev/null
+++ b/test/Modules/Inputs/include_next/y/b.h
@@ -0,0 +1 @@
+enum { by = 4 };
diff --git a/test/Modules/Inputs/include_next/y/module.modulemap b/test/Modules/Inputs/include_next/y/module.modulemap
new file mode 100644
index 0000000..5dc3c53
--- /dev/null
+++ b/test/Modules/Inputs/include_next/y/module.modulemap
@@ -0,0 +1,2 @@
+module ya { header "a.h" export * }
+module yb { header "b.h" export * }
diff --git a/test/Modules/Inputs/macro-hiding/a1.h b/test/Modules/Inputs/macro-hiding/a1.h
new file mode 100644
index 0000000..b17c8ee
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/a1.h
@@ -0,0 +1 @@
+#define assert(x)
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o b/test/Modules/Inputs/macro-hiding/a2.h
similarity index 100%
rename from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o
rename to test/Modules/Inputs/macro-hiding/a2.h
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o b/test/Modules/Inputs/macro-hiding/b1.h
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o
copy to test/Modules/Inputs/macro-hiding/b1.h
diff --git a/test/Modules/Inputs/macro-hiding/b2.h b/test/Modules/Inputs/macro-hiding/b2.h
new file mode 100644
index 0000000..8391848
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/b2.h
@@ -0,0 +1,2 @@
+#include "a2.h"
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/c1.h b/test/Modules/Inputs/macro-hiding/c1.h
new file mode 100644
index 0000000..4b78b3c
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/c1.h
@@ -0,0 +1,2 @@
+#include "b1.h"
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/d1.h b/test/Modules/Inputs/macro-hiding/d1.h
new file mode 100644
index 0000000..8391848
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/d1.h
@@ -0,0 +1,2 @@
+#include "a2.h"
+#define assert(x)
diff --git a/test/Modules/Inputs/macro-hiding/e1.h b/test/Modules/Inputs/macro-hiding/e1.h
new file mode 100644
index 0000000..bd01708
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/e1.h
@@ -0,0 +1 @@
+#include "a1.h"
diff --git a/test/Modules/Inputs/macro-hiding/e2.h b/test/Modules/Inputs/macro-hiding/e2.h
new file mode 100644
index 0000000..f3a49c7
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/e2.h
@@ -0,0 +1,2 @@
+#include "a1.h"
+inline void e1() { assert(true); }
diff --git a/test/Modules/Inputs/macro-hiding/module.modulemap b/test/Modules/Inputs/macro-hiding/module.modulemap
new file mode 100644
index 0000000..20632d3
--- /dev/null
+++ b/test/Modules/Inputs/macro-hiding/module.modulemap
@@ -0,0 +1,18 @@
+module a {
+  module a1 { header "a1.h" export * }
+  module a2 { header "a2.h" export * }
+}
+module b {
+  module b1 { header "b1.h" export * }
+  module b2 { header "b2.h" export * }
+}
+module c {
+  module c1 { header "c1.h" export * }
+}
+module d {
+  module d1 { header "d1.h" export * }
+}
+module e {
+  module e1 { header "e1.h" export * }
+  module e2 { header "e2.h" export * }
+}
diff --git a/test/Modules/Inputs/macros_bottom.h b/test/Modules/Inputs/macros_bottom.h
new file mode 100644
index 0000000..fc0a78e
--- /dev/null
+++ b/test/Modules/Inputs/macros_bottom.h
@@ -0,0 +1,3 @@
+@import macros_right;
+
+extern TOP_DEF_RIGHT_UNDEF *TDRUp;
diff --git a/test/Modules/Inputs/macros_right_undef.h b/test/Modules/Inputs/macros_right_undef.h
index 15a8366..5084561 100644
--- a/test/Modules/Inputs/macros_right_undef.h
+++ b/test/Modules/Inputs/macros_right_undef.h
@@ -2,3 +2,4 @@
 
 @import macros_top;
 #undef TOP_OTHER_DEF_RIGHT_UNDEF
+#undef TOP_DEF_RIGHT_UNDEF
diff --git a/test/Modules/Inputs/macros_top.h b/test/Modules/Inputs/macros_top.h
index 1093504..e063133 100644
--- a/test/Modules/Inputs/macros_top.h
+++ b/test/Modules/Inputs/macros_top.h
@@ -22,3 +22,4 @@
 #define TOP_OTHER_DEF_RIGHT_UNDEF void
 
 #define TOP_REDEF_IN_SUBMODULES 0
+#define TOP_DEF_RIGHT_UNDEF void
diff --git a/test/Modules/Inputs/merge-typedefs/a1.h b/test/Modules/Inputs/merge-typedefs/a1.h
new file mode 100644
index 0000000..cacc530
--- /dev/null
+++ b/test/Modules/Inputs/merge-typedefs/a1.h
@@ -0,0 +1,11 @@
+#ifndef A1_H
+#define A1_H
+namespace llvm {
+class MachineBasicBlock;
+template <class NodeT> class DomTreeNodeBase;
+typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode;
+}
+
+typedef struct {} foo_t;
+typedef foo_t foo2_t;
+#endif
diff --git a/test/Modules/Inputs/merge-typedefs/a2.h b/test/Modules/Inputs/merge-typedefs/a2.h
new file mode 100644
index 0000000..ba30666
--- /dev/null
+++ b/test/Modules/Inputs/merge-typedefs/a2.h
@@ -0,0 +1,3 @@
+#ifndef A2_H
+#define A2_H
+#endif
diff --git a/test/Modules/Inputs/merge-typedefs/b1.h b/test/Modules/Inputs/merge-typedefs/b1.h
new file mode 100644
index 0000000..8dde5f6
--- /dev/null
+++ b/test/Modules/Inputs/merge-typedefs/b1.h
@@ -0,0 +1,11 @@
+#ifndef B1_H
+#define B1_H
+typedef struct {} foo_t;
+typedef foo_t foo2_t;
+#include "a2.h"
+namespace llvm {
+class MachineBasicBlock;
+template <class NodeT> class DomTreeNodeBase;
+typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode;
+}
+#endif
diff --git a/test/Modules/Inputs/merge-typedefs/b2.h b/test/Modules/Inputs/merge-typedefs/b2.h
new file mode 100644
index 0000000..75bd63a
--- /dev/null
+++ b/test/Modules/Inputs/merge-typedefs/b2.h
@@ -0,0 +1,3 @@
+#ifndef B2_H
+#define B2_H
+#endif
diff --git a/test/Modules/Inputs/merge-typedefs/module.modulemap b/test/Modules/Inputs/merge-typedefs/module.modulemap
new file mode 100644
index 0000000..4858f1b
--- /dev/null
+++ b/test/Modules/Inputs/merge-typedefs/module.modulemap
@@ -0,0 +1,9 @@
+module A {
+  module A1 { header "a1.h" export * }
+  module A2 { header "a2.h" export * }
+}
+
+module B {
+  module B1 { header "b1.h" export * }
+  module B2 { header "b2.h" export * }
+}
diff --git a/test/Modules/Inputs/merge-using-decls/a.h b/test/Modules/Inputs/merge-using-decls/a.h
new file mode 100644
index 0000000..0fe0067
--- /dev/null
+++ b/test/Modules/Inputs/merge-using-decls/a.h
@@ -0,0 +1,43 @@
+struct X {
+  int v;
+  typedef int t;
+};
+
+struct YA {
+  int value;
+  typedef int type;
+};
+
+template<typename T> struct C : X, T {
+  using T::value;
+  using typename T::type;
+  using X::v;
+  using typename X::t;
+};
+
+template<typename T> struct D : X, T {
+  using T::value;
+  using typename T::type;
+  using X::v;
+  using typename X::t;
+};
+
+template<typename T> struct E : X, T {
+  using T::value;
+  using typename T::type;
+  using X::v;
+  using typename X::t;
+};
+
+template<typename T> struct F : X, T {
+  using T::value;
+  using typename T::type;
+  using X::v;
+  using typename X::t;
+};
+
+// Force instantiation.
+typedef C<YA>::type I;
+typedef D<YA>::type I;
+typedef E<YA>::type I;
+typedef F<YA>::type I;
diff --git a/test/Modules/Inputs/merge-using-decls/b.h b/test/Modules/Inputs/merge-using-decls/b.h
new file mode 100644
index 0000000..3595555
--- /dev/null
+++ b/test/Modules/Inputs/merge-using-decls/b.h
@@ -0,0 +1,50 @@
+struct X {
+  int v;
+  typedef int t;
+};
+
+struct YB {
+  typedef YB Y;
+  int value;
+  typedef int type;
+};
+
+struct YBRev {
+  typedef int value;
+  int type;
+};
+
+template<typename T> struct C : X, T {
+  using T::value;
+  using typename T::type;
+  using X::v;
+  using typename X::t;
+};
+
+template<typename T> struct D : X, T {
+  // Mismatch in type/non-type-ness.
+  using typename T::value;
+  using T::type;
+  using X::v;
+  using typename X::t;
+};
+
+template<typename T> struct E : X, T {
+  // Mismatch in using/access-declaration-ness.
+  T::value;
+  X::v;
+};
+
+template<typename T> struct F : X, T {
+  // Mismatch in nested-name-specifier.
+  using T::Y::value;
+  using typename T::Y::type;
+  using ::X::v;
+  using typename ::X::t;
+};
+
+// Force instantiation.
+typedef C<YB>::type I;
+typedef D<YBRev>::t I;
+typedef E<YB>::type I;
+typedef F<YB>::type I;
diff --git a/test/Modules/Inputs/merge-using-decls/module.modulemap b/test/Modules/Inputs/merge-using-decls/module.modulemap
new file mode 100644
index 0000000..a415527
--- /dev/null
+++ b/test/Modules/Inputs/merge-using-decls/module.modulemap
@@ -0,0 +1,2 @@
+module A { header "a.h" }
+module B { header "b.h" }
diff --git a/test/Modules/Inputs/modular_maps/c.h b/test/Modules/Inputs/modular_maps/c.h
new file mode 100644
index 0000000..6e3468e
--- /dev/null
+++ b/test/Modules/Inputs/modular_maps/c.h
@@ -0,0 +1,4 @@
+#ifndef C_H
+#define C_H
+const int c = 5;
+#endif
diff --git a/test/Modules/Inputs/modular_maps/common.h b/test/Modules/Inputs/modular_maps/common.h
index f690bcb..349bf5f 100644
--- a/test/Modules/Inputs/modular_maps/common.h
+++ b/test/Modules/Inputs/modular_maps/common.h
@@ -1,4 +1,4 @@
 #ifndef COMMON_H
 #define COMMON_H
-const int c = 2;
+const int x = 2;
 #endif
diff --git a/test/Modules/Inputs/modular_maps/modulec.map b/test/Modules/Inputs/modular_maps/modulec.map
new file mode 100644
index 0000000..c5a1ffe
--- /dev/null
+++ b/test/Modules/Inputs/modular_maps/modulec.map
@@ -0,0 +1,3 @@
+module C {
+  header "c.h"
+}
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
index fea1201..7040ee7 100644
--- a/test/Modules/Inputs/module.map
+++ b/test/Modules/Inputs/module.map
@@ -40,6 +40,10 @@
     header "macros_right_undef.h"
   }
 }
+module macros_bottom { 
+  header "macros_bottom.h" 
+  export *
+}
 module macros { header "macros.h" }
 module macros_other { header "macros_other.h" }
 module category_top { header "category_top.h" }
@@ -229,6 +233,10 @@
   header "cxx-templates-c.h"
 }
 
+module cxx_templates_d {
+  header "cxx-templates-d.h"
+}
+
 module cxx_decls {
   module unimported {
     header "cxx-decls-unimported.h"
@@ -238,6 +246,10 @@
   }
 }
 
+module cxx_decls_premerged {
+  header "cxx-decls-premerged.h"
+}
+
 module cxx_decls_merged {
   header "cxx-decls-merged.h"
 }
@@ -280,6 +292,10 @@
   header "warning.h"
 }
 
+module warn_unused_local_typedef {
+  header "warn-unused-local-typedef.h"
+}
+
 module initializer_list {
   header "initializer_list"
 }
diff --git a/test/Modules/Inputs/odr/a.h b/test/Modules/Inputs/odr/a.h
index 26144b8..5a3f524 100644
--- a/test/Modules/Inputs/odr/a.h
+++ b/test/Modules/Inputs/odr/a.h
@@ -8,6 +8,12 @@
   int n;
 } x1;
 
+template<typename T>
+struct F {
+  int n;
+  friend bool operator==(const F &a, const F &b) { return a.n == b.n; }
+};
+
 int f() {
   return y1.n + e1 + y1.f + x1.n;
 }
diff --git a/test/Modules/Inputs/odr/b.h b/test/Modules/Inputs/odr/b.h
index b406397..a4a693d 100644
--- a/test/Modules/Inputs/odr/b.h
+++ b/test/Modules/Inputs/odr/b.h
@@ -4,6 +4,12 @@
 } y2;
 enum E { e2 };
 
+template<typename T>
+struct F {
+  int n;
+  friend bool operator==(const F &a, const F &b) { return a.n == b.n; }
+};
+
 int g() {
-  return y2.m + e2 + y2.f;
+  return y2.m + e2 + y2.f + (F<int>{0} == F<int>{1});
 }
diff --git a/test/Modules/Inputs/pch-used.h b/test/Modules/Inputs/pch-used.h
index 60e0097..bc53bb3 100644
--- a/test/Modules/Inputs/pch-used.h
+++ b/test/Modules/Inputs/pch-used.h
@@ -1,2 +1,3 @@
 @import cstd.stdio;
+@import other_constants.dbl_max;
 static inline void SPXTrace() { fprintf(__stderrp, ""); }
diff --git a/test/Modules/Inputs/pr19692/AIX.h b/test/Modules/Inputs/pr19692/AIX.h
new file mode 100644
index 0000000..710871e
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/AIX.h
@@ -0,0 +1,2 @@
+  #undef INT64_MAX
+
diff --git a/test/Modules/Inputs/pr19692/Blah.h b/test/Modules/Inputs/pr19692/Blah.h
new file mode 100644
index 0000000..bdaa83a
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/Blah.h
@@ -0,0 +1,2 @@
+  #include "stdint.h"
+
diff --git a/test/Modules/Inputs/pr19692/TBlah.h b/test/Modules/Inputs/pr19692/TBlah.h
new file mode 100644
index 0000000..a045a8b
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/TBlah.h
@@ -0,0 +1,3 @@
+#include "Blah.h"
+  int use = INT64_MAX;
+
diff --git a/test/Modules/Inputs/pr19692/TFoo.h b/test/Modules/Inputs/pr19692/TFoo.h
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/TFoo.h
@@ -0,0 +1 @@
+
diff --git a/test/Modules/Inputs/pr19692/module.map b/test/Modules/Inputs/pr19692/module.map
new file mode 100644
index 0000000..f4120dc
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/module.map
@@ -0,0 +1,3 @@
+module cstd { module stdint { header "stdint.h" } }
+module LLVMSupport { module Blah { header "Blah.h" export * } module AIX { header "AIX.h" } }
+module LLVMTarget { module Blah { header "TBlah.h" export * } module Foo { header "TFoo.h" } }
diff --git a/test/Modules/Inputs/pr19692/my.cc b/test/Modules/Inputs/pr19692/my.cc
new file mode 100644
index 0000000..bb0b7c5
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/my.cc
@@ -0,0 +1,5 @@
+#include "TFoo.h"
+#include "stdint.h"
+
+  int k = INT64_MAX; // error!
+
diff --git a/test/Modules/Inputs/pr19692/stdint.h b/test/Modules/Inputs/pr19692/stdint.h
new file mode 100644
index 0000000..7615e83
--- /dev/null
+++ b/test/Modules/Inputs/pr19692/stdint.h
@@ -0,0 +1,2 @@
+  #define INT64_MAX 42
+
diff --git a/test/Modules/Inputs/preprocess-prefix.h b/test/Modules/Inputs/preprocess-prefix.h
new file mode 100644
index 0000000..04d0175
--- /dev/null
+++ b/test/Modules/Inputs/preprocess-prefix.h
@@ -0,0 +1,2 @@
+int left_and_right(int *);
+#import "diamond_left.h"
diff --git a/test/Modules/Inputs/templates-left.h b/test/Modules/Inputs/templates-left.h
index 2bd79be..cbe8943 100644
--- a/test/Modules/Inputs/templates-left.h
+++ b/test/Modules/Inputs/templates-left.h
@@ -60,3 +60,13 @@
 void outOfLineInlineUseLeftF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f);
 void outOfLineInlineUseLeftG(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::g);
 void outOfLineInlineUseLeftH(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::h);
+
+namespace EmitDefaultedSpecialMembers {
+  inline void f() {
+    SmallString<256> SS;
+  };
+}
+
+inline int *getStaticDataMemberLeft() {
+  return WithUndefinedStaticDataMember<int[]>::undefined;
+}
diff --git a/test/Modules/Inputs/templates-right.h b/test/Modules/Inputs/templates-right.h
index 5907cbc..daea97b 100644
--- a/test/Modules/Inputs/templates-right.h
+++ b/test/Modules/Inputs/templates-right.h
@@ -43,3 +43,7 @@
 void outOfLineInlineUseRightF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f);
 void outOfLineInlineUseRightG(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::g);
 void outOfLineInlineUseRightH(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::h);
+
+inline int *getStaticDataMemberRight() {
+  return WithUndefinedStaticDataMember<int[]>::undefined;
+}
diff --git a/test/Modules/Inputs/templates-top.h b/test/Modules/Inputs/templates-top.h
index 1216266..31f5e41 100644
--- a/test/Modules/Inputs/templates-top.h
+++ b/test/Modules/Inputs/templates-top.h
@@ -40,3 +40,20 @@
 template<typename T> inline void OutOfLineInline<T>::f() {}
 template<typename T> inline void OutOfLineInline<T>::g() {}
 template<typename T> inline void OutOfLineInline<T>::h() {}
+
+namespace EmitDefaultedSpecialMembers {
+  template<typename T> struct SmallVectorImpl {
+    SmallVectorImpl() {}
+    ~SmallVectorImpl() {} // non-trivial dtor
+  };
+  template<typename T, unsigned N> struct SmallVector : SmallVectorImpl<T> {
+    // trivial dtor
+  };
+  template<unsigned N> struct SmallString : SmallVector<char, N> {
+    // trivial dtor
+  };
+}
+
+template<typename T> struct WithUndefinedStaticDataMember {
+  static T undefined;
+};
diff --git a/test/Modules/Inputs/va_list/module.modulemap b/test/Modules/Inputs/va_list/module.modulemap
new file mode 100644
index 0000000..870f38b
--- /dev/null
+++ b/test/Modules/Inputs/va_list/module.modulemap
@@ -0,0 +1,2 @@
+module va_list_a { header "va_list_a.h" }
+module va_list_b { header "va_list_b.h" }
diff --git a/test/Modules/Inputs/va_list/va_list_a.h b/test/Modules/Inputs/va_list/va_list_a.h
new file mode 100644
index 0000000..7193ca2
--- /dev/null
+++ b/test/Modules/Inputs/va_list/va_list_a.h
@@ -0,0 +1 @@
+int  vprintf(const char * __restrict, va_list);
diff --git a/test/Modules/Inputs/va_list/va_list_b.h b/test/Modules/Inputs/va_list/va_list_b.h
new file mode 100644
index 0000000..b7f9b3d
--- /dev/null
+++ b/test/Modules/Inputs/va_list/va_list_b.h
@@ -0,0 +1,2 @@
+@import va_list_a;
+void NSLogv(id, va_list);
diff --git a/test/Modules/Inputs/warn-unused-local-typedef.h b/test/Modules/Inputs/warn-unused-local-typedef.h
new file mode 100644
index 0000000..6006de0
--- /dev/null
+++ b/test/Modules/Inputs/warn-unused-local-typedef.h
@@ -0,0 +1 @@
+inline void myfun() { typedef int a; }
diff --git a/test/Modules/Rmodule-build.m b/test/Modules/Rmodule-build.m
index 4ac36ef..e8f2935 100644
--- a/test/Modules/Rmodule-build.m
+++ b/test/Modules/Rmodule-build.m
@@ -1,22 +1,41 @@
-// REQUIRES: shell
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: echo '// A' > %t/A.h
-// RUN: echo '// B' > %t/B.h
+// RUN: echo '#include "C.h"' > %t/B.h
+// RUN: echo '// C' > %t/C.h
 // RUN: echo 'module A { header "A.h" }' > %t/module.modulemap
 // RUN: echo 'module B { header "B.h" }' >> %t/module.modulemap
+// RUN: echo 'module C { header "C.h" }' >> %t/module.modulemap
 
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -verify \
-// RUN:            -I %t -Wmodule-build
+// RUN:            -I %t -Rmodule-build
 
-@import A; // expected-remark{{building module 'A' as}}
-@import B; // expected-remark{{building module 'B' as}}
+@import A; // expected-remark{{building module 'A' as}} expected-remark {{finished building module 'A'}}
+@import B; // expected-remark{{building module 'B' as}} expected-remark {{finished building module 'B'}}
 @import A; // no diagnostic
 @import B; // no diagnostic
 
+// RUN: echo ' ' >> %t/C.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN:            -Rmodule-build 2>&1 | FileCheck %s
+
+// RUN: echo ' ' >> %t/C.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN:            -Reverything 2>&1 | FileCheck %s
+
 // RUN: echo ' ' >> %t/B.h
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
-// RUN:            -Wmodule-build 2>&1 | FileCheck %s
+// RUN:            2>&1 | FileCheck -allow-empty -check-prefix=NO-REMARKS %s
+
+// RUN: echo ' ' >> %t/B.h
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fsyntax-only %s -I %t \
+// RUN:            -Rmodule-build -Rno-everything 2>&1 | \
+// RUN:    FileCheck -allow-empty -check-prefix=NO-REMARKS %s
 
 // CHECK-NOT: building module 'A'
 // CHECK: building module 'B'
+// CHECK: building module 'C'
+// CHECK: finished building module 'C'
+// CHECK: finished building module 'B'
+// NO-REMARKS-NOT: building module 'A'
+// NO-REMARKS-NOT: building module 'B'
diff --git a/test/Modules/Werror-Wsystem-headers.m b/test/Modules/Werror-Wsystem-headers.m
index c4cd1a6..4391aa0 100644
--- a/test/Modules/Werror-Wsystem-headers.m
+++ b/test/Modules/Werror-Wsystem-headers.m
@@ -1,21 +1,20 @@
-// REQUIRES: shell
 // RUN: rm -rf %t
 // RUN: rm -rf %t-saved
 // RUN: mkdir %t-saved
 
 // Initial module build
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify
+// RUN:     -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify
 // RUN: cp %t/cstd.pcm %t-saved/cstd.pcm
 
 // Even with -Werror don't rebuild a system module
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -Werror
+// RUN:     -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify -Werror
 // RUN: diff %t/cstd.pcm %t-saved/cstd.pcm
 
 // Unless -Wsystem-headers is on
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify \
+// RUN:     -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify \
 // RUN:     -Werror=unused -Wsystem-headers
 // RUN: not diff %t/cstd.pcm %t-saved/cstd.pcm
 
diff --git a/test/Modules/Werror.m b/test/Modules/Werror.m
index 94a98a5..6444ea5 100644
--- a/test/Modules/Werror.m
+++ b/test/Modules/Werror.m
@@ -1,4 +1,3 @@
-// REQUIRES: shell
 // RUN: rm -rf %t
 // RUN: rm -rf %t-saved
 // RUN: mkdir -p %t-saved
diff --git a/test/Modules/add-remove-private.m b/test/Modules/add-remove-private.m
new file mode 100644
index 0000000..49e81e1
--- /dev/null
+++ b/test/Modules/add-remove-private.m
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: rm -rf %t.mcp
+// RUN: mkdir -p %t
+// RUN: cp -r %S/Inputs/AddRemovePrivate.framework %t/AddRemovePrivate.framework
+
+// Build with module.private.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -verify -DP
+// RUN: cp %t.mcp/AddRemovePrivate.pcm %t/with.pcm
+
+// Build without module.private.modulemap
+// RUN: rm %t/AddRemovePrivate.framework/Modules/module.private.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -verify
+// RUN: not diff %t.mcp/AddRemovePrivate.pcm %t/with.pcm
+// RUN: cp %t.mcp/AddRemovePrivate.pcm %t/without.pcm
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -DP 2>&1 | FileCheck %s
+// CHECK: no submodule named 'Private'
+
+// Build with module.private.modulemap (again)
+// RUN: cp %S/Inputs/AddRemovePrivate.framework/Modules/module.private.modulemap %t/AddRemovePrivate.framework/Modules/module.private.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fdisable-module-hash -F %t %s -verify -DP
+// RUN: not diff %t.mcp/AddRemovePrivate.pcm %t/without.pcm
+
+// expected-no-diagnostics
+
+@import AddRemovePrivate;
+#ifdef P
+@import AddRemovePrivate.Private;
+#endif
diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m
index 3d1dcf3..24bca19 100644
--- a/test/Modules/cstd.m
+++ b/test/Modules/cstd.m
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -fmodules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
+// RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -ffreestanding -fmodules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
 
 @import uses_other_constants;
 const double other_value = DBL_MAX;
diff --git a/test/Modules/cxx-decls.cpp b/test/Modules/cxx-decls.cpp
index 5498b47..109306e 100644
--- a/test/Modules/cxx-decls.cpp
+++ b/test/Modules/cxx-decls.cpp
@@ -30,7 +30,27 @@
 
 int importMergeUsedFlag = getMergeUsedFlag();
 
+int use_name_for_linkage(NameForLinkage &nfl) {
+  return nfl.n + nfl.m;
+}
+int use_overrides_virtual_functions(OverridesVirtualFunctions ovf) { return 0; }
+
 @import cxx_decls_merged;
 
+NameForLinkage2Inner use_name_for_linkage2_inner;
+NameForLinkage2 use_name_for_linkage2;
+
+int name_for_linkage_test = use_name_for_linkage(name_for_linkage);
+int overrides_virtual_functions_test =
+    use_overrides_virtual_functions(overrides_virtual_functions);
+
+void use_extern_c_function() { ExternCFunction(); }
+
+int use_namespace_alias() { return Alias::a + Alias::b; }
+
+@import cxx_decls_premerged;
+
+void use_extern_c_function_2() { ExternCFunction(); }
+
 // CHECK: VarDecl [[mergeUsedFlag:0x[0-9a-f]*]] {{.*}} in cxx_decls.imported used mergeUsedFlag
 // CHECK: VarDecl {{0x[0-9a-f]*}} prev [[mergeUsedFlag]] {{.*}} in cxx_decls_merged used mergeUsedFlag
diff --git a/test/Modules/cxx-irgen.cpp b/test/Modules/cxx-irgen.cpp
index 4c61a3a..ecaf704 100644
--- a/test/Modules/cxx-irgen.cpp
+++ b/test/Modules/cxx-irgen.cpp
@@ -1,5 +1,6 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-optzns -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fmodules -x objective-c++ -std=c++11 -fmodules-cache-path=%t -I %S/Inputs -triple %itanium_abi_triple -disable-llvm-optzns -emit-llvm -g -o - %s | FileCheck %s
 // FIXME: When we have a syntax for modules in C++, use that.
 
 @import cxx_irgen_top;
@@ -10,13 +11,66 @@
 @import cxx_irgen_left;
 @import cxx_irgen_right;
 
+// Keep these two namespace definitions separate; merging them hides the bug.
+namespace EmitInlineMethods {
+  // CHECK-DAG: define linkonce_odr [[CC:(x86_thiscallcc[ ]+)?]]void @_ZN17EmitInlineMethods1C1fEPNS_1AE(
+  // CHECK-DAG: declare [[CC]]void @_ZN17EmitInlineMethods1A1gEv(
+  struct C {
+    __attribute__((used)) void f(A *p) { p->g(); }
+  };
+}
+namespace EmitInlineMethods {
+  // CHECK-DAG: define linkonce_odr [[CC]]void @_ZN17EmitInlineMethods1D1fEPNS_1BE(
+  // CHECK-DAG: define linkonce_odr [[CC]]void @_ZN17EmitInlineMethods1B1gEv(
+  struct D {
+    __attribute__((used)) void f(B *p) { p->g(); }
+  };
+}
+
 // CHECK-DAG: define available_externally hidden {{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
 int a = S<int>::g();
 
-// CHECK-DAG: define available_externally {{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
 int b = h();
 
 // CHECK-DAG: define linkonce_odr {{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
 int c = min(1, 2);
 
+// CHECK-LABEL: define {{.*}} @_ZN20OperatorDeleteLookup1AD0Ev(
+// CHECK: call void @_ZN20OperatorDeleteLookup1AdlEPv(
+
+namespace ImplicitSpecialMembers {
+  // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2EOS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+  // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1DC2ERKS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+  // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2EOS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+  // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1CC2ERKS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+  // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2EOS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+  // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+
+  extern B b1;
+  B b2(b1);
+  B b3(static_cast<B&&>(b1));
+
+  extern C c1;
+  C c2(c1);
+  C c3(static_cast<C&&>(c1));
+
+  extern D d1;
+  D d2(d1);
+  D d3(static_cast<D&&>(d1));
+}
+
+namespace OperatorDeleteLookup {
+  // Trigger emission of B's vtable and deleting dtor.
+  // This requires us to know what operator delete was selected.
+  void g() { f(); }
+}
+
+// CHECK: define available_externally {{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+
 // CHECK: attributes #[[ALWAYS_INLINE]] = {{.*}} alwaysinline
diff --git a/test/Modules/cxx-lookup.cpp b/test/Modules/cxx-lookup.cpp
new file mode 100644
index 0000000..47c879d
--- /dev/null
+++ b/test/Modules/cxx-lookup.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t %s -I%S/Inputs/cxx-lookup -verify
+// expected-no-diagnostics
+namespace llvm {}
+#include "c2.h"
+llvm::GlobalValue *p;
diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp
index f68bc72..d9c8a8c 100644
--- a/test/Modules/cxx-templates.cpp
+++ b/test/Modules/cxx-templates.cpp
@@ -1,12 +1,18 @@
 // RUN: rm -rf %t
-// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL
-// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N
+// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL
+// RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N
 // RUN: not %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump | FileCheck %s --check-prefix=CHECK-DUMP
 // RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fno-modules-error-recovery -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 -DEARLY_IMPORT
+
+#ifdef EARLY_IMPORT
+#include "cxx-templates-textual.h"
+#endif
 
 @import cxx_templates_a;
 @import cxx_templates_b;
 @import cxx_templates_c;
+@import cxx_templates_d;
 @import cxx_templates_common;
 
 template<typename, char> struct Tmpl_T_C {};
@@ -22,15 +28,21 @@
   f<double>(1.0);
   f<int>();
   f(); // expected-error {{no matching function}}
+#ifdef EARLY_IMPORT
+  // FIXME: The textual inclusion above shouldn't affect this!
+  // expected-note@Inputs/cxx-templates-a.h:3 {{couldn't infer template argument}}
+  // expected-note@Inputs/cxx-templates-a.h:4 {{requires 1 argument}}
+#else
   // expected-note@Inputs/cxx-templates-b.h:3 {{couldn't infer template argument}}
   // expected-note@Inputs/cxx-templates-b.h:4 {{requires single argument}}
+#endif
 
   N::f(0);
   N::f<double>(1.0);
   N::f<int>();
   N::f(); // expected-error {{no matching function}}
-  // expected-note@Inputs/cxx-templates-a.h:6 {{couldn't infer template argument}}
-  // expected-note@Inputs/cxx-templates-a.h:7 {{requires 1 argument}}
+  // expected-note@Inputs/cxx-templates-b.h:6 {{couldn't infer template argument}}
+  // expected-note@Inputs/cxx-templates-b.h:7 {{requires single argument}}
 
   template_param_kinds_1<0>(); // ok, from cxx-templates-a.h
   template_param_kinds_1<int>(); // ok, from cxx-templates-b.h
@@ -105,8 +117,25 @@
 
   int &p = WithPartialSpecializationUse().f();
   int &q = WithExplicitSpecializationUse().inner_template<int>();
+  int *r = PartiallyInstantiatePartialSpec<int*>::bar();
+
+  (void)&WithImplicitSpecialMembers<int>::n;
+
+  MergeClassTemplateSpecializations_string s;
+
+  extern TestInjectedClassName::A *use_a;
+  extern TestInjectedClassName::C *use_c;
+  TestInjectedClassName::UseD();
 }
 
+static_assert(Outer<int>::Inner<int>::f() == 1, "");
+static_assert(Outer<int>::Inner<int>::g() == 2, "");
+
+#ifndef EARLY_IMPORT
+// FIXME: The textual inclusion above shouldn't cause this to fail!
+static_assert(MergeTemplateDefinitions<int>::f() == 1, "");
+static_assert(MergeTemplateDefinitions<int>::g() == 2, "");
+
 RedeclaredAsFriend<int> raf1;
 RedeclareTemplateAsFriend<double> rtaf;
 RedeclaredAsFriend<double> raf2;
@@ -117,6 +146,21 @@
 MergeSpecializations<char>::explicitly_specialized_in_a spec_in_a_2;
 MergeSpecializations<double>::explicitly_specialized_in_b spec_in_b_2;
 MergeSpecializations<bool>::explicitly_specialized_in_c spec_in_c_2;
+#endif
+
+MergeAnonUnionMember<> maum_main;
+typedef DontWalkPreviousDeclAfterMerging<int> dwpdam_typedef_2;
+dwpdam_typedef::type dwpdam_typedef_use;
+DontWalkPreviousDeclAfterMerging<int>::Inner::type dwpdam;
+
+using AliasTemplateMergingTest = WithAliasTemplate<int>::X<char>;
+
+int AnonymousDeclsMergingTest(WithAnonymousDecls<int> WAD, WithAnonymousDecls<char> WADC) {
+  return InstantiateWithAnonymousDeclsA(WAD) +
+         InstantiateWithAnonymousDeclsB(WAD) +
+         InstantiateWithAnonymousDeclsB2(WADC) +
+         InstantiateWithAnonymousDeclsD(WADC);
+}
 
 @import cxx_templates_common;
 
diff --git a/test/Modules/dependency-gen.m b/test/Modules/dependency-gen.m
index dec8384..d3d66bf 100644
--- a/test/Modules/dependency-gen.m
+++ b/test/Modules/dependency-gen.m
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t-mcp
 // RUN: mkdir -p %t-mcp
 
-// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
 // RUN: FileCheck %s < %t.d.1
 // CHECK: dependency-gen.m
 // CHECK: Inputs{{.}}diamond_top.h
@@ -10,7 +10,7 @@
 // CHECK-NOT: stdint.h
 
 
-// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
 // RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2
 // CHECK-SYS: dependency-gen.m
 // CHECK-SYS: Inputs{{.}}diamond_top.h
diff --git a/test/Modules/explicit-build-flags.cpp b/test/Modules/explicit-build-flags.cpp
new file mode 100644
index 0000000..6ced215
--- /dev/null
+++ b/test/Modules/explicit-build-flags.cpp
@@ -0,0 +1,49 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'module tmp { header "tmp.h" }' > %t/map
+// RUN: touch %t/tmp.h
+// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp.pcm
+
+// Can use the module.
+// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if an input file is newer. (This happens on
+// remote file systems.)
+// RUN: sleep 1
+// RUN: touch %t/tmp.h
+// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -D flags change.
+// RUN: %clang_cc1 -fmodules -DFOO=2 -DBAR=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+// RUN: %clang_cc1 -fmodules -DBAR=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -W flags change.
+// RUN: %clang_cc1 -fmodules -DBAR=2 -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -I flags change.
+// RUN: %clang_cc1 -fmodules -DBAR=2 -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -O flags change.
+// RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+//
+// RUN: %clang_cc1 -fmodules -DFOO=1 -O2 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp-O2.pcm
+// RUN: %clang_cc1 -fmodules -DBAR=2 -O0 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-O2.pcm -verify -I%t %s
+// RUN: %clang_cc1 -fmodules -DBAR=2 -Os -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp-O2.pcm -verify -I%t %s
+
+#include "tmp.h" // expected-no-diagnostics
+
+#ifndef BAR
+#if FOO != 1
+#error bad FOO from command line and module
+#endif
+#elif BAR == 1
+#if FOO != 2
+#error bad FOO from command line overriding module
+#endif
+#elif BAR == 2
+#ifdef FOO
+#error FOO leaked from module
+#endif
+#else
+#error bad BAR
+#endif
diff --git a/test/Modules/explicit-build.cpp b/test/Modules/explicit-build.cpp
new file mode 100644
index 0000000..8d8237f
--- /dev/null
+++ b/test/Modules/explicit-build.cpp
@@ -0,0 +1,155 @@
+// RUN: rm -rf %t
+
+// -------------------------------
+// Build chained modules A, B, and C
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a.pcm \
+// RUN:            2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b.pcm \
+// RUN:            2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/b.pcm \
+// RUN:            -fmodule-name=c -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/c.pcm \
+// RUN:            2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty
+//
+// CHECK-NO-IMPLICIT-BUILD-NOT: building module
+
+// -------------------------------
+// Build B with an implicit build of A
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/b-not-a.pcm \
+// RUN:            2>&1 | FileCheck --check-prefix=CHECK-B-NO-A %s
+//
+// CHECK-B-NO-A: While building module 'b':
+// CHECK-B-NO-A: building module 'a' as
+
+// -------------------------------
+// Check that we can use the explicitly-built A, B, and C modules.
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -verify %s -DHAVE_A
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -verify %s -DHAVE_A
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/b.pcm \
+// RUN:            -verify %s -DHAVE_A -DHAVE_B
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=%t/b.pcm \
+// RUN:            -verify %s -DHAVE_A -DHAVE_B
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=%t/b.pcm \
+// RUN:            -fmodule-file=%t/c.pcm \
+// RUN:            -verify %s -DHAVE_A -DHAVE_B -DHAVE_C
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=%t/c.pcm \
+// RUN:            -verify %s -DHAVE_A -DHAVE_B -DHAVE_C
+
+#if HAVE_A
+  #include "a.h"
+  static_assert(a == 1, "");
+#else
+  const int use_a = a; // expected-error {{undeclared identifier}}
+#endif
+
+#if HAVE_B
+  #include "b.h"
+  static_assert(b == 2, "");
+#else
+  const int use_b = b; // expected-error {{undeclared identifier}}
+#endif
+
+#if HAVE_C
+  #include "c.h"
+  static_assert(c == 3, "");
+#else
+  const int use_c = c; // expected-error {{undeclared identifier}}
+#endif
+
+#if HAVE_A && HAVE_B && HAVE_C
+// expected-no-diagnostics
+#endif
+
+// -------------------------------
+// Check that we can use a mixture of implicit and explicit modules.
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/b-not-a.pcm \
+// RUN:            -verify %s -DHAVE_A -DHAVE_B
+
+// -------------------------------
+// Try to use two different flavors of the 'a' module.
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=%t/b-not-a.pcm \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=%t/b-not-a.pcm \
+// RUN:            -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o %t/a-alt.pcm \
+// RUN:            2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=%t/a-alt.pcm \
+// RUN:            -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a-alt.pcm \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-map-file=%S/Inputs/explicit-build/module.modulemap \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-MULTIPLE-AS %s
+//
+// CHECK-MULTIPLE-AS: error: module 'a' is defined in both '{{.*}}/a{{.*}}.pcm' and '{{.*[/\\]}}a{{.*}}.pcm'
+
+// -------------------------------
+// Try to import a PCH with -fmodule-file=
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch \
+// RUN:            2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a.pch \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-A-AS-PCH %s
+//
+// CHECK-A-AS-PCH: fatal error: AST file '{{.*}}a.pch' was not built as a module
+
+// -------------------------------
+// Try to import a non-AST file with -fmodule-file=
+//
+// RUN: touch %t/not.pcm
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/not.pcm \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/nonexistent.pcm \
+// RUN:            %s 2>&1 | FileCheck --check-prefix=CHECK-BAD-FILE %s
+//
+// CHECK-BAD-FILE: fatal error: file '{{.*}}t.pcm' is not a precompiled module file
diff --git a/test/Modules/filename.cpp b/test/Modules/filename.cpp
new file mode 100644
index 0000000..66891a0
--- /dev/null
+++ b/test/Modules/filename.cpp
@@ -0,0 +1,9 @@
+// RUN: cd %S
+// RUN: %clang_cc1 -I. -fmodule-maps -fmodule-name=A  -fmodule-map-file=%S/Inputs/filename/module.map %s -E | FileCheck %s
+// REQUIRES: shell
+
+#include "Inputs/filename/a.h"
+
+// Make sure that headers that are referenced by module maps have __FILE__
+// reflect the include path they were found with.
+// CHECK: const char *p = "./Inputs/filename/a.h"
diff --git a/test/Modules/fmodules-validate-once-per-build-session.c b/test/Modules/fmodules-validate-once-per-build-session.c
index 346d5a7..dcbd0db 100644
--- a/test/Modules/fmodules-validate-once-per-build-session.c
+++ b/test/Modules/fmodules-validate-once-per-build-session.c
@@ -6,39 +6,53 @@
 // RUN: mkdir -p %t/modules-to-compare
 
 // ===
-// Create a module with system headers.
+// Create a module.  We will use -I or -isystem to determine whether to treat
+// foo.h as a system header.
 // RUN: echo 'void meow(void);' > %t/Inputs/foo.h
-// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/module.map
+// RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map
 
 // ===
 // Compile the module.
-// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm
+// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm
 
 // ===
 // Use it, and make sure that we did not recompile it.
-// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
+// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
 
 // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
+// RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
 
 // ===
 // Change the sources.
 // RUN: echo 'void meow2(void);' > %t/Inputs/foo.h
 
 // ===
-// Use the module, and make sure that we did not recompile it, even though the sources changed.
-// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// Use the module, and make sure that we did not recompile it if foo.h is a
+// system header, even though the sources changed.
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
+// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
+// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
 
 // RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
+// When foo.h is a user header, we will always validate it.
+// RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
 
 // ===
 // Recompile the module if the today's date is before 01 January 2030.
-// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s
+// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s
 // RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
 // RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
 
diff --git a/test/Modules/implementation-of-module.m b/test/Modules/implementation-of-module.m
new file mode 100644
index 0000000..b398404
--- /dev/null
+++ b/test/Modules/implementation-of-module.m
@@ -0,0 +1,29 @@
+// RUN: not %clang_cc1 -fmodule-implementation-of Foo -fmodule-name=Bar %s 2>&1 \
+// RUN:     | FileCheck -check-prefix=CHECK-IMPL-OF-ERR %s
+// CHECK-IMPL-OF-ERR: conflicting module names specified: '-fmodule-name=Bar' and '-fmodule-implementation-of Foo'
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN:     -fmodule-implementation-of category_right -fsyntax-only
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN:     -fmodule-implementation-of category_right -dM -E -o - 2>&1 | FileCheck %s
+// CHECK-NOT: __building_module
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN:     -fmodule-implementation-of category_left -verify
+
+// RUN: %clang_cc1 -x objective-c-header -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN:     -fmodule-implementation-of category_right -emit-pch -o %t.pch
+// RUN: %clang_cc1 -x objective-c-header -fmodules -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN:     -DWITH_PREFIX -include-pch %t.pch -fmodule-implementation-of category_right
+
+#ifndef WITH_PREFIX
+
+@import category_left; // expected-error{{@import of module 'category_left' in implementation of 'category_left'; use #import}}
+@import category_left.sub; // expected-error{{@import of module 'category_left.sub' in implementation of 'category_left'; use #import}}
+#import "category_right.h" // expected-error{{treating}}
+#import "category_right_sub.h" // expected-error{{treating}}
+
+#endif
+
diff --git a/test/Modules/include_next.c b/test/Modules/include_next.c
new file mode 100644
index 0000000..f2dafb4
--- /dev/null
+++ b/test/Modules/include_next.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/include_next/x -I%S/Inputs/include_next/y -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/include_next/x -I%S/Inputs/include_next/y -verify %s -fmodules -fmodules-cache-path=%t
+
+// expected-no-diagnostics
+#include "a.h"
+#include "subdir/b.h"
+_Static_assert(ax == 1, "");
+_Static_assert(ay == 2, "");
+_Static_assert(bx == 3, "");
+_Static_assert(by == 4, "");
diff --git a/test/Modules/incomplete-module.m b/test/Modules/incomplete-module.m
index 8edaea9..8181ae8 100644
--- a/test/Modules/incomplete-module.m
+++ b/test/Modules/incomplete-module.m
@@ -2,4 +2,8 @@
 
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -Wincomplete-module -fmodules -I %S/Inputs %s 2>&1 | FileCheck %s
-// CHECK: {{warning: header '.*incomplete_mod_missing.h' is included in module 'incomplete_mod' but not listed in module map}}
+// CHECK: warning: include of non-modular header inside module 'incomplete_mod'
+
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules-cache-path=%t -fmodules-strict-decluse -fmodules -I %S/Inputs %s 2>&1 | FileCheck %s -check-prefix=DECLUSE
+// DECLUSE: error: module incomplete_mod does not depend on a module exporting {{'.*incomplete_mod_missing.h'}}
diff --git a/test/Modules/inferred-framework-case.m b/test/Modules/inferred-framework-case.m
new file mode 100644
index 0000000..e511155
--- /dev/null
+++ b/test/Modules/inferred-framework-case.m
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify -DA
+// FIXME: PR20299 - getCanonicalName() is not implemented on Windows.
+// REQUIRES: shell
+
+@import MOdule; // expected-error{{module 'MOdule' not found}}
+@import Module;
diff --git a/test/Modules/load-after-failure.m b/test/Modules/load-after-failure.m
index f471fd8..38d4a36 100644
--- a/test/Modules/load-after-failure.m
+++ b/test/Modules/load-after-failure.m
@@ -1,4 +1,3 @@
-// REQUIRES: shell
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 
diff --git a/test/Modules/macro-hiding.cpp b/test/Modules/macro-hiding.cpp
new file mode 100644
index 0000000..b166f4b
--- /dev/null
+++ b/test/Modules/macro-hiding.cpp
@@ -0,0 +1,104 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DB1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA2 -DB1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DB1 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB2 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DC1 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2 -DD1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2 -DC1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DA1 -DA2 -DB1 -DB2 -DC1 -DD1
+//
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/macro-hiding %s -DE1
+
+#ifdef A1
+#include "a1.h"
+#endif
+
+#ifdef A2
+#include "a2.h"
+#endif
+
+#ifdef B1
+#include "b1.h"
+#endif
+
+#ifdef B2
+#include "b2.h"
+#endif
+
+#ifdef C1
+#include "c1.h"
+#endif
+
+#ifdef D1
+#include "d1.h"
+#endif
+
+#ifdef E1
+#include "e1.h"
+#endif
+
+#ifdef E2
+#include "e2.h"
+#endif
+
+#if defined(A1) || defined(B2) || defined(C1) || defined(D1) || defined(E1) || defined(E2)
+void h() { assert(true); }
+#else
+void assert() {}
+#endif
diff --git a/test/Modules/macro-reexport/a1.h b/test/Modules/macro-reexport/a1.h
new file mode 100644
index 0000000..3993331
--- /dev/null
+++ b/test/Modules/macro-reexport/a1.h
@@ -0,0 +1 @@
+#define assert(x) a
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o b/test/Modules/macro-reexport/a2.h
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o
copy to test/Modules/macro-reexport/a2.h
diff --git a/test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o b/test/Modules/macro-reexport/b1.h
similarity index 100%
copy from test/Driver/Inputs/mips_fsf_tree/lib/gcc/mips-mti-linux-gnu/4.9.0/fp64/crtbegin.o
copy to test/Modules/macro-reexport/b1.h
diff --git a/test/Modules/macro-reexport/b2.h b/test/Modules/macro-reexport/b2.h
new file mode 100644
index 0000000..2615045
--- /dev/null
+++ b/test/Modules/macro-reexport/b2.h
@@ -0,0 +1,2 @@
+#include "a2.h"
+#define assert(x) b
diff --git a/test/Modules/macro-reexport/c1.h b/test/Modules/macro-reexport/c1.h
new file mode 100644
index 0000000..b63c278
--- /dev/null
+++ b/test/Modules/macro-reexport/c1.h
@@ -0,0 +1,4 @@
+#pragma once
+
+#include "b1.h"
+#define assert(x) c
diff --git a/test/Modules/macro-reexport/d1.h b/test/Modules/macro-reexport/d1.h
new file mode 100644
index 0000000..99abd24
--- /dev/null
+++ b/test/Modules/macro-reexport/d1.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "c1.h"
+#undef assert
+#define assert(x) d
diff --git a/test/Modules/macro-reexport/d2.h b/test/Modules/macro-reexport/d2.h
new file mode 100644
index 0000000..688f2d9
--- /dev/null
+++ b/test/Modules/macro-reexport/d2.h
@@ -0,0 +1 @@
+#include "b2.h"
diff --git a/test/Modules/macro-reexport/e1.h b/test/Modules/macro-reexport/e1.h
new file mode 100644
index 0000000..6c6829d
--- /dev/null
+++ b/test/Modules/macro-reexport/e1.h
@@ -0,0 +1,2 @@
+#include "c1.h"
+#undef assert
diff --git a/test/Modules/macro-reexport/e2.h b/test/Modules/macro-reexport/e2.h
new file mode 100644
index 0000000..7bc0b49
--- /dev/null
+++ b/test/Modules/macro-reexport/e2.h
@@ -0,0 +1,2 @@
+#include "d1.h"
+#undef assert
diff --git a/test/Modules/macro-reexport/f1.h b/test/Modules/macro-reexport/f1.h
new file mode 100644
index 0000000..f8f6502
--- /dev/null
+++ b/test/Modules/macro-reexport/f1.h
@@ -0,0 +1,3 @@
+#include "e1.h"
+#include "d1.h"
+
diff --git a/test/Modules/macro-reexport/macro-reexport.cpp b/test/Modules/macro-reexport/macro-reexport.cpp
new file mode 100644
index 0000000..af2ec84
--- /dev/null
+++ b/test/Modules/macro-reexport/macro-reexport.cpp
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -DC1 -I. %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DC1 -I. -fmodules %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DD1 -I. %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DD1 -I. -fmodules %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DD2 -I. %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DD2 -I. -fmodules %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DF1 -I. %s -fmodules-cache-path=%t -verify
+// RUN: %clang_cc1 -fsyntax-only -DF1 -I. -fmodules %s -fmodules-cache-path=%t -verify
+
+#if defined(F1)
+#include "f1.h"
+void f() { return assert(true); } // expected-error {{undeclared identifier 'd'}}
+#include "e2.h" // undefines d1's macro
+void g() { return assert(true); } // expected-error {{undeclared identifier 'assert'}}
+#elif defined(D1)
+#include "e1.h" // undefines c1's macro but not d1's macro
+#include "d1.h"
+void f() { return assert(true); } // expected-error {{undeclared identifier 'd'}}
+#include "e2.h" // undefines d1's macro
+void g() { return assert(true); } // expected-error {{undeclared identifier 'assert'}}
+#elif defined(D2)
+#include "d2.h"
+void f() { return assert(true); } // expected-error {{undeclared identifier 'b'}}
+#else
+// e2 undefines d1's macro, which overrides c1's macro.
+#include "e2.h"
+#include "c1.h"
+void f() { return assert(true); } // expected-error {{undeclared identifier 'assert'}}
+#endif
diff --git a/test/Modules/macro-reexport/module.modulemap b/test/Modules/macro-reexport/module.modulemap
new file mode 100644
index 0000000..896bda0
--- /dev/null
+++ b/test/Modules/macro-reexport/module.modulemap
@@ -0,0 +1,23 @@
+module b {
+  module b2 { header "b2.h" export * }
+  module b1 { header "b1.h" export * }
+}
+module a {
+  module a1 { header "a1.h" export * }
+  module a2 { header "a2.h" export * }
+}
+module c {
+  module c1 { header "c1.h" export * }
+}
+module d {
+  module d1 { header "d1.h" export * }
+  module d2 { header "d2.h" export * }
+}
+module e {
+  module e1 { header "e1.h" export * }
+  module e2 { header "e2.h" export * }
+}
+module f {
+  module f1 { header "f1.h" export * }
+  module f2 { header "f2.h" export * }
+}
diff --git a/test/Modules/macros.c b/test/Modules/macros.c
index 7a7e570..92ea88a 100644
--- a/test/Modules/macros.c
+++ b/test/Modules/macros.c
@@ -130,8 +130,14 @@
 #  error TOP_RIGHT_UNDEF should still be defined
 #endif
 
+@import macros_bottom;
+
+TOP_DEF_RIGHT_UNDEF *TDRUf() { return TDRUp; }
+
 @import macros_right.undef;
 
+int TOP_DEF_RIGHT_UNDEF; // ok, no longer defined
+
 // FIXME: When macros_right.undef is built, macros_top is visible because
 // the state from building macros_right leaks through, so macros_right.undef
 // undefines macros_top's macro.
diff --git a/test/Modules/merge-typedefs.cpp b/test/Modules/merge-typedefs.cpp
new file mode 100644
index 0000000..607f8c5
--- /dev/null
+++ b/test/Modules/merge-typedefs.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x c++ -I%S/Inputs/merge-typedefs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-typedefs -verify %s
+
+#include "b2.h"
+#include "a1.h"
+
+// expected-no-diagnostics
+llvm::MachineDomTreeNode *p;
+foo2_t f2t;
diff --git a/test/Modules/merge-using-decls.cpp b/test/Modules/merge-using-decls.cpp
new file mode 100644
index 0000000..3b84d0e
--- /dev/null
+++ b/test/Modules/merge-using-decls.cpp
@@ -0,0 +1,69 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
+
+#if ORDER == 1
+#include "a.h"
+#include "b.h"
+#else
+#include "b.h"
+#include "a.h"
+#endif
+
+struct Y {
+  int value; // expected-note 0-1{{target of using}}
+  typedef int type; // expected-note 0-1{{target of using}}
+};
+
+template<typename T> int Use() {
+  int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
+  typedef typename T::type I;
+  typedef typename T::t I;
+  typedef int I;
+  return k;
+}
+
+template<typename T> int UseAll() {
+  return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
+}
+
+template int UseAll<YA>();
+template int UseAll<YB>();
+template int UseAll<Y>();
+
+#if ORDER == 1
+// Here, we're instantiating the definition from 'A' and merging the definition
+// from 'B' into it.
+
+// expected-error@b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
+// expected-error@b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
+
+// expected-error@b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+// expected-error@b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+// expected-error@b.h:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+// expected-error@b.h:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
+
+// expected-note@a.h:* +{{does not match}}
+#else
+// Here, we're instantiating the definition from 'B' and merging the definition
+// from 'A' into it.
+
+// expected-error@a.h:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
+// expected-error@a.h:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
+// expected-error@b.h:* 2{{'typename' keyword used on a non-type}}
+// expected-error@b.h:* 2{{dependent using declaration resolved to type without 'typename'}}
+
+// expected-error@a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-error@a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-error@a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-error@a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
+// expected-note@b.h:* 2{{definition has no member}}
+
+// expected-error@a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+// expected-error@a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+// expected-error@a.h:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+// expected-error@a.h:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
+
+// expected-note@b.h:* +{{does not match}}
+// expected-note@b.h:* +{{target of using}}
+#endif
diff --git a/test/Modules/modular_maps.cpp b/test/Modules/modular_maps.cpp
index 9c9aba8..484e727 100644
--- a/test/Modules/modular_maps.cpp
+++ b/test/Modules/modular_maps.cpp
@@ -1,8 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify
+// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -fmodule-map-file=%S/Inputs/modular_maps/modulec.map -I %S/Inputs/modular_maps %s -verify
+// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fmodule-map-file=%S/Inputs/modular_maps/modulec.map -fmodule-map-file=%S/Inputs/modular_maps/modulea.map -I %S/Inputs/modular_maps %s -verify
 
 #include "common.h"
 #include "a.h"
 #include "b.h" // expected-error {{private header}}
-const int v = a + c;
-const int val = a + b + c; // expected-error {{undeclared identifier}}
+@import C;
+const int v = a + c + x;
+const int val = a + b + c + x; // expected-error {{undeclared identifier}}
diff --git a/test/Modules/module_file_info.m b/test/Modules/module_file_info.m
index 3c10780..1b0a838 100644
--- a/test/Modules/module_file_info.m
+++ b/test/Modules/module_file_info.m
@@ -17,18 +17,18 @@
 
 // CHECK: Target options:
 // CHECK:     Triple:
-// CHECK:     CPU: 
-// CHECK:     ABI: 
+// CHECK:     CPU:
+// CHECK:     ABI:
 
 // CHECK: Diagnostic options:
 // CHECK:   IgnoreWarnings: Yes
-// CHECK:   Warning options:
+// CHECK:   Diagnostic flags:
 // CHECK:     -Wunused
 
 // CHECK: Header search options:
 // CHECK:   System root [-isysroot=]: '/'
 // CHECK:   Use builtin include directories [-nobuiltininc]: Yes
-// CHECK:   Use standard system include directories [-nostdinc]: Yes
+// CHECK:   Use standard system include directories [-nostdinc]: No
 // CHECK:   Use standard C++ include directories [-nostdinc++]: Yes
 // CHECK:   Use libc++ (rather than libstdc++) [-stdlib=]:
 
diff --git a/test/Modules/modules-with-same-name.m b/test/Modules/modules-with-same-name.m
index c90aa5d..d362f75 100644
--- a/test/Modules/modules-with-same-name.m
+++ b/test/Modules/modules-with-same-name.m
@@ -1,4 +1,3 @@
-// REQUIRES: shell
 // RUN: rm -rf %t
 
 // A from path 1
diff --git a/test/Modules/no-stale-modtime.m b/test/Modules/no-stale-modtime.m
index 2fb17b7..5351212 100644
--- a/test/Modules/no-stale-modtime.m
+++ b/test/Modules/no-stale-modtime.m
@@ -1,7 +1,6 @@
 // Ensure that when rebuilding a module we don't save its old modtime when
 // building modules that depend on it.
 
-// REQUIRES: shell
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // This could be replaced by diamond_*, except we want to modify the top header
@@ -13,18 +12,18 @@
 // RUN: echo 'module r { header "r.h" } module t { header "t.h" }' >> %t/module.map
 
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -I %t -fsyntax-only %s -Wmodule-build 2>&1 \
+// RUN:     -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
 // RUN: | FileCheck -check-prefix=REBUILD-ALL %s
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -I %t -fsyntax-only %s -Wmodule-build -verify
+// RUN:     -I %t -fsyntax-only %s -Rmodule-build -verify
 
 // Add an identifier to ensure everything depending on t is out of date
 // RUN: echo 'extern int a;' >> %t/t.h
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -I %t -fsyntax-only %s -Wmodule-build 2>&1 \
+// RUN:     -I %t -fsyntax-only %s -Rmodule-build 2>&1 \
 // RUN: | FileCheck -check-prefix=REBUILD-ALL %s
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \
-// RUN:     -I %t -fsyntax-only %s -Wmodule-build -verify
+// RUN:     -I %t -fsyntax-only %s -Rmodule-build -verify
 
 // REBUILD-ALL: building module 'b'
 // REBUILD-ALL: building module 'l'
diff --git a/test/Modules/odr.cpp b/test/Modules/odr.cpp
index 5ab10d2..120ca20 100644
--- a/test/Modules/odr.cpp
+++ b/test/Modules/odr.cpp
@@ -6,6 +6,9 @@
 };
 
 @import a;
+
+bool b = F<int>{0} == F<int>{1};
+
 @import b;
 
 // Trigger the declarations from a and b to be imported.
diff --git a/test/Modules/pch-used.m b/test/Modules/pch-used.m
index 56961ba..74f21f5 100644
--- a/test/Modules/pch-used.m
+++ b/test/Modules/pch-used.m
@@ -4,5 +4,6 @@
 // RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s
 
 void f() { SPXTrace(); }
+void g() { double x = DBL_MAX; }
 
 // CHECK: define internal void @SPXTrace
diff --git a/test/Modules/pr19692.cpp b/test/Modules/pr19692.cpp
new file mode 100644
index 0000000..6cc5153
--- /dev/null
+++ b/test/Modules/pr19692.cpp
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/pr19692 -verify %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/pr19692 -verify %s
+#include "TFoo.h"
+#include "stdint.h"
+
+int k = INT64_MAX; // expected-no-diagnostics
diff --git a/test/Modules/pr20399.cpp b/test/Modules/pr20399.cpp
new file mode 100644
index 0000000..4f4a025
--- /dev/null
+++ b/test/Modules/pr20399.cpp
@@ -0,0 +1,2 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-name=libGdml -emit-module -x c++ -std=c++11 %S/Inputs/PR20399/module.modulemap
diff --git a/test/Modules/pr20786.cpp b/test/Modules/pr20786.cpp
new file mode 100644
index 0000000..4c0426e
--- /dev/null
+++ b/test/Modules/pr20786.cpp
@@ -0,0 +1,2 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-name=TBranchProxy -emit-module -x c++ %S/Inputs/PR20786/module.modulemap
diff --git a/test/Modules/preprocess.m b/test/Modules/preprocess.m
new file mode 100644
index 0000000..5c32997
--- /dev/null
+++ b/test/Modules/preprocess.m
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -include %S/Inputs/preprocess-prefix.h -E %s | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -x objective-c-header -emit-pch %S/Inputs/preprocess-prefix.h -o %t.pch
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs -include-pch %t.pch -E %s | FileCheck -strict-whitespace %s
+#import "diamond_right.h"
+#import "diamond_right.h" // to check that imports get their own line
+void test() {
+  top_left_before();
+  left_and_right();
+}
+
+
+// CHECK: int left_and_right(int *);{{$}}
+// CHECK-NEXT: @import diamond_left; /* clang -E: implicit import for "{{.*}}diamond_left.h" */{{$}}
+
+// CHECK: @import diamond_right; /* clang -E: implicit import for "{{.*}}diamond_right.h" */{{$}}
+// CHECK: @import diamond_right; /* clang -E: implicit import for "{{.*}}diamond_right.h" */{{$}}
+// CHECK-NEXT: void test() {{{$}}
+// CHECK-NEXT:    top_left_before();{{$}}
+// CHECK-NEXT:    left_and_right();{{$}}
+// CHECK-NEXT: }{{$}}
diff --git a/test/Modules/rebuild.m b/test/Modules/rebuild.m
new file mode 100644
index 0000000..4d4d055
--- /dev/null
+++ b/test/Modules/rebuild.m
@@ -0,0 +1,45 @@
+// RUN: rm -rf %t
+
+// Build Module and set its timestamp
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved
+// RUN: wc -c %t/Module.pcm > %t/Module.size.saved
+
+// Build DependsOnModule
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved
+// RUN: cp %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+
+// Rebuild Module, reset its timestamp, and verify its size hasn't changed
+// RUN: rm %t/Module.pcm
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm
+// RUN: wc -c %t/Module.pcm > %t/Module.size
+// RUN: diff %t/Module.size %t/Module.size.saved
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
+
+// But the signature at least is expected to change, so we rebuild DependsOnModule.
+// NOTE: if we change how the signature is created, this test may need updating.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
+// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+
+// Rebuild Module, reset its timestamp, and verify its size hasn't changed
+// RUN: rm %t/Module.pcm
+// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
+// RUN: touch -m -a -t 201101010000 %t/Module.pcm
+// RUN: wc -c %t/Module.pcm > %t/Module.size
+// RUN: diff %t/Module.size %t/Module.size.saved
+// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
+
+// Verify again with Module pre-imported.
+// NOTE: if we change how the signature is created, this test may need updating.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
+// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
+// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
+
+#ifdef PREIMPORT
+@import Module;
+#endif
+@import DependsOnModule;
diff --git a/test/Modules/require-modular-includes.m b/test/Modules/require-modular-includes.m
index 835a352..302e4cd 100644
--- a/test/Modules/require-modular-includes.m
+++ b/test/Modules/require-modular-includes.m
@@ -1,5 +1,4 @@
 // RUN: rm -rf %t
-// REQUIRES: shell
 
 // Including a header from the imported module
 // RUN: echo '@import FromImportedModuleOK;' | \
diff --git a/test/Modules/resolution-change.m b/test/Modules/resolution-change.m
index 011782e..b725a64 100644
--- a/test/Modules/resolution-change.m
+++ b/test/Modules/resolution-change.m
@@ -11,11 +11,11 @@
 
 // Use the PCH with no way to resolve DependsOnA
 // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NODOA %s
-// CHECK-NODOA: module 'DependsOnA' imported by AST file '{{.*A.pch}}' not found
+// CHECK-NODOA: module 'DependsOnA' in AST file '{{.*DependsOnA.*pcm}}' (imported by AST file '{{.*A.pch}}') is not defined in any loaded module map
 
 // Use the PCH with no way to resolve A
 // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NOA %s
-// CHECK-NOA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' not found
+// CHECK-NOA: module 'A' in AST file '{{.*A.*pcm}}' (imported by AST file '{{.*DependsOnA.*pcm}}') is not defined in any loaded module map
 
 // Use the PCH and have it resolve the the other A
 // RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-WRONGA %s
diff --git a/test/Modules/stddef.c b/test/Modules/stddef.c
new file mode 100644
index 0000000..aefc90f
--- /dev/null
+++ b/test/Modules/stddef.c
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify -fno-modules-error-recovery
+
+#include "ptrdiff_t.h"
+
+ptrdiff_t pdt;
+
+size_t st; // expected-error {{must be imported}}
+// expected-note@stddef.h:* {{previous}}
+
+#include "include_again.h"
+
+size_t st2;
diff --git a/test/Modules/system_headers.m b/test/Modules/system_headers.m
index 39b13ca..8adc7e8 100644
--- a/test/Modules/system_headers.m
+++ b/test/Modules/system_headers.m
@@ -1,8 +1,13 @@
 // Test that system-headerness works for building modules.
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -isystem %S/Inputs -pedantic -Werror %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -isystem %S/Inputs -pedantic -Werror %s -verify -std=c11
 // expected-no-diagnostics
 
 @import warning;
 int i = bigger_than_int;
+
+#include <stddef.h>
+
+#define __need_size_t
+#include <stddef.h>
diff --git a/test/Modules/system_version.m b/test/Modules/system_version.m
index bc82bf8..55174ef 100644
--- a/test/Modules/system_version.m
+++ b/test/Modules/system_version.m
@@ -1,6 +1,5 @@
 // Test checking that we're hashing a system version file in the
 // module hash.
-// REQUIRES: shell
 
 // First, build a system root.
 // RUN: rm -rf %t
diff --git a/test/Modules/templates-2.mm b/test/Modules/templates-2.mm
new file mode 100644
index 0000000..b7ceafb
--- /dev/null
+++ b/test/Modules/templates-2.mm
@@ -0,0 +1,36 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs -verify %s -Wno-objc-root-class
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | FileCheck %s
+// expected-no-diagnostics
+
+@import templates_top;
+
+struct TestEmitDefaultedSpecialMembers {
+  EmitDefaultedSpecialMembers::SmallVector<char, 256> V;
+};
+
+@import templates_left;
+
+void testEmitDefaultedSpecialMembers() {
+  EmitDefaultedSpecialMembers::SmallString<256> V;
+  // CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC1Ev(
+  // CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED1Ev(
+}
+
+// CHECK-LABEL: define {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC1Ev(
+// CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC2Ev(
+
+// CHECK-LABEL: define {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED1Ev(
+// CHECK: call {{.*}} @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED2Ev(
+
+// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EED2Ev(
+// CHECK: call void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EED2Ev(
+// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EED2Ev(
+// CHECK: call void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcED2Ev(
+// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcED2Ev(
+
+// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallStringILj256EEC2Ev(
+// CHECK: call void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EEC2Ev(
+// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers11SmallVectorIcLj256EEC2Ev(
+// CHECK: call void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcEC2Ev(
+// CHECK-LABEL: define linkonce_odr void @_ZN27EmitDefaultedSpecialMembers15SmallVectorImplIcEC2Ev(
diff --git a/test/Modules/templates.mm b/test/Modules/templates.mm
index 645e171..d60b873 100644
--- a/test/Modules/templates.mm
+++ b/test/Modules/templates.mm
@@ -12,10 +12,11 @@
 
 @import templates_right;
 
-// CHECK: @list_left = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 8,
-// CHECK: @list_right = global { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 12,
-// CHECK: @_ZZ15testMixedStructvE1l = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 1,
-// CHECK: @_ZZ15testMixedStructvE1r = {{.*}} constant { %{{.*}}*, i32, [4 x i8] } { %{{.*}}* null, i32 2,
+// CHECK-DAG: @list_left = global %class.List { %"struct.List<int>::node"* null, i32 8 }, align 8
+// CHECK-DAG: @list_right = global %class.List { %"struct.List<int>::node"* null, i32 12 }, align 8
+// CHECK-DAG: @_ZZ15testMixedStructvE1l = {{.*}} constant %class.List { %{{.*}}* null, i32 1 }, align 8
+// CHECK-DAG: @_ZZ15testMixedStructvE1r = {{.*}} constant %class.List { %{{.*}}* null, i32 2 }, align 8
+// CHECK-DAG: @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE = external global
 
 void testTemplateClasses() {
   Vector<int> vec_int;
@@ -80,9 +81,9 @@
   // CHECK: call {{.*}}memcpy{{.*}}(i8* %{{.*}}, i8* bitcast ({{.*}}* @_ZZ15testMixedStructvE1r to i8*), i64 16,
   ListInt_right r{0, 2};
 
-  // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* nonnull %[[l]])
+  // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[l]])
   useListInt(l);
-  // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* nonnull %[[r]])
+  // CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[r]])
   useListInt(r);
 
   // CHECK: load i32* bitcast (i8* getelementptr inbounds (i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*)
@@ -100,3 +101,17 @@
 template struct ExplicitInstantiation<true, true>;
 
 void testDelayUpdatesImpl() { testDelayUpdates<int>(); }
+
+void testStaticDataMember() {
+  WithUndefinedStaticDataMember<int[]> load_it;
+
+  // CHECK-LABEL: define linkonce_odr i32* @_Z23getStaticDataMemberLeftv(
+  // CHECK: ret i32* getelementptr inbounds ([0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0)
+  (void) getStaticDataMemberLeft();
+
+  // CHECK-LABEL: define linkonce_odr i32* @_Z24getStaticDataMemberRightv(
+  // CHECK: ret i32* getelementptr inbounds ([0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0)
+  (void) getStaticDataMemberRight();
+}
+
+
diff --git a/test/Modules/textual-headers.cpp b/test/Modules/textual-headers.cpp
new file mode 100644
index 0000000..cab9991
--- /dev/null
+++ b/test/Modules/textual-headers.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-maps -fmodules-cache-path=%t -fmodules-strict-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-strict-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify -fno-modules-error-recovery
+
+#define GIMME_A_K
+#include "k.h"
+
+#define GIMME_AN_L
+#include "l.h" // expected-error {{module XG does not depend on a module exporting 'l.h'}}
+
+#include "m2.h" // expected-error {{module XG does not depend on a module exporting 'm2.h'}}
+const int use_m = m; // expected-error {{undeclared identifier}}
+
+#define GIMME_AN_M
+#include "m.h" // expected-error {{use of private header from outside its module: 'm.h'}}
+const int use_m_2 = m;
+
+const int g = k + l;
diff --git a/test/Modules/va_list.m b/test/Modules/va_list.m
new file mode 100644
index 0000000..5a30518
--- /dev/null
+++ b/test/Modules/va_list.m
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN:     -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
+// RUN:     -x objective-c-header %s -o %t.pch -emit-pch
+
+// Include the pch, as a sanity check.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN:     -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \
+// RUN:     -x objective-c %s -fsyntax-only
+
+// Repeat the previous emit-pch, but not we will have a global module index.
+// For some reason, this results in an identifier for __va_list_tag being
+// emitted into the pch.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN:     -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
+// RUN:     -x objective-c-header %s -o %t.pch -emit-pch
+
+// Include the pch, which now has __va_list_tag in it, which needs to be merged.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN:     -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \
+// RUN:     -x objective-c %s -fsyntax-only
+
+// rdar://18039719
+
+#ifdef PREFIX
+@import va_list_b;
+#endif
diff --git a/test/Modules/validate-system-headers.m b/test/Modules/validate-system-headers.m
index 48ea64c..8cdc886 100644
--- a/test/Modules/validate-system-headers.m
+++ b/test/Modules/validate-system-headers.m
@@ -5,39 +5,37 @@
 
 ////
 // Build a module using a system header
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
+// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
 // RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
 
 ////
 // Modify the system header, and confirm that we don't notice without -fmodules-validate-system-headers.
 // The pcm file in the cache should fail to validate.
 // RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
+// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
 // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
 
 ////
 // Now make sure we rebuild the module when -fmodules-validate-system-headers is set.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
+// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
 // RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
 
 
 ////
 // This should override -fmodules-validate-once-per-build-session
 // RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
+// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
 // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
 
 // Modify the system header...
 // RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
 
 // Don't recompile due to -fmodules-validate-once-per-build-session
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
+// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
 // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
 
 // Now add -fmodules-validate-system-headers and rebuild
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
+// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
 // RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
 
-// REQUIRES: shell
-
 @import Foo;
diff --git a/test/Modules/warn-unused-local-typedef.cpp b/test/Modules/warn-unused-local-typedef.cpp
new file mode 100644
index 0000000..60e0612
--- /dev/null
+++ b/test/Modules/warn-unused-local-typedef.cpp
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t
+// RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK_1
+// RUN: %clang -Wunused-local-typedef -c -x objective-c++ -fcxx-modules -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=CHECK_2 -allow-empty
+
+// For modules, the warning should only fire the first time, when the module is
+// built.
+// CHECK_1: warning: unused typedef
+// CHECK_2-NOT: warning: unused typedef
+@import warn_unused_local_typedef;
diff --git a/test/OpenMP/atomic_ast_print.cpp b/test/OpenMP/atomic_ast_print.cpp
new file mode 100644
index 0000000..e75d291
--- /dev/null
+++ b/test/OpenMP/atomic_ast_print.cpp
@@ -0,0 +1,176 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template <class T>
+T foo(T argc) {
+  T b = T();
+  T a = T();
+#pragma omp atomic
+  a++;
+#pragma omp atomic read
+  a = argc;
+#pragma omp atomic write
+  a = argc + argc;
+#pragma omp atomic update
+  a = a + argc;
+#pragma omp atomic capture
+  a = b++;
+#pragma omp atomic capture
+  {
+    a = b;
+    b++;
+  }
+#pragma omp atomic seq_cst
+  a++;
+#pragma omp atomic read seq_cst
+  a = argc;
+#pragma omp atomic seq_cst write
+  a = argc + argc;
+#pragma omp atomic update seq_cst
+  a = a + argc;
+#pragma omp atomic seq_cst capture
+  a = b++;
+#pragma omp atomic capture seq_cst
+  {
+    a = b;
+    b++;
+  }
+  return T();
+}
+
+// CHECK: int a = int();
+// CHECK-NEXT: #pragma omp atomic
+// CHECK-NEXT: a++;
+// CHECK-NEXT: #pragma omp atomic read
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic write
+// CHECK-NEXT: a = argc + argc;
+// CHECK-NEXT: #pragma omp atomic update
+// CHECK-NEXT: a = a + argc;
+// CHECK-NEXT: #pragma omp atomic capture
+// CHECK-NEXT: a = b++;
+// CHECK-NEXT: #pragma omp atomic capture
+// CHECK-NEXT: {
+// CHECK-NEXT: a = b;
+// CHECK-NEXT: b++;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp atomic seq_cst
+// CHECK-NEXT: a++;
+// CHECK-NEXT: #pragma omp atomic read seq_cst
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic seq_cst write
+// CHECK-NEXT: a = argc + argc;
+// CHECK-NEXT: #pragma omp atomic update seq_cst
+// CHECK-NEXT: a = a + argc;
+// CHECK-NEXT: #pragma omp atomic seq_cst capture
+// CHECK-NEXT: a = b++;
+// CHECK-NEXT: #pragma omp atomic capture seq_cst
+// CHECK-NEXT: {
+// CHECK-NEXT: a = b;
+// CHECK-NEXT: b++;
+// CHECK-NEXT: }
+// CHECK: T a = T();
+// CHECK-NEXT: #pragma omp atomic
+// CHECK-NEXT: a++;
+// CHECK-NEXT: #pragma omp atomic read
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic write
+// CHECK-NEXT: a = argc + argc;
+// CHECK-NEXT: #pragma omp atomic update
+// CHECK-NEXT: a = a + argc;
+// CHECK-NEXT: #pragma omp atomic capture
+// CHECK-NEXT: a = b++;
+// CHECK-NEXT: #pragma omp atomic capture
+// CHECK-NEXT: {
+// CHECK-NEXT: a = b;
+// CHECK-NEXT: b++;
+// CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp atomic seq_cst
+// CHECK-NEXT: a++;
+// CHECK-NEXT: #pragma omp atomic read seq_cst
+// CHECK-NEXT: a = argc;
+// CHECK-NEXT: #pragma omp atomic seq_cst write
+// CHECK-NEXT: a = argc + argc;
+// CHECK-NEXT: #pragma omp atomic update seq_cst
+// CHECK-NEXT: a = a + argc;
+// CHECK-NEXT: #pragma omp atomic seq_cst capture
+// CHECK-NEXT: a = b++;
+// CHECK-NEXT: #pragma omp atomic capture seq_cst
+// CHECK-NEXT: {
+// CHECK-NEXT: a = b;
+// CHECK-NEXT: b++;
+// CHECK-NEXT: }
+
+int main(int argc, char **argv) {
+  int b = 0;
+  int a = 0;
+// CHECK: int a = 0;
+#pragma omp atomic
+  a++;
+#pragma omp atomic read
+  a = argc;
+#pragma omp atomic write
+  a = argc + argc;
+#pragma omp atomic update
+  a = a + argc;
+#pragma omp atomic capture
+  a = b++;
+#pragma omp atomic capture
+  {
+    a = b;
+    b++;
+  }
+#pragma omp atomic seq_cst
+  a++;
+#pragma omp atomic read seq_cst
+  a = argc;
+#pragma omp atomic seq_cst write
+  a = argc + argc;
+#pragma omp atomic update seq_cst
+  a = a + argc;
+#pragma omp atomic seq_cst capture
+  a = b++;
+#pragma omp atomic capture seq_cst
+  {
+    a = b;
+    b++;
+  }
+  // CHECK-NEXT: #pragma omp atomic
+  // CHECK-NEXT: a++;
+  // CHECK-NEXT: #pragma omp atomic read
+  // CHECK-NEXT: a = argc;
+  // CHECK-NEXT: #pragma omp atomic write
+  // CHECK-NEXT: a = argc + argc;
+  // CHECK-NEXT: #pragma omp atomic update
+  // CHECK-NEXT: a = a + argc;
+  // CHECK-NEXT: #pragma omp atomic capture
+  // CHECK-NEXT: a = b++;
+  // CHECK-NEXT: #pragma omp atomic capture
+  // CHECK-NEXT: {
+  // CHECK-NEXT: a = b;
+  // CHECK-NEXT: b++;
+  // CHECK-NEXT: }
+  // CHECK-NEXT: #pragma omp atomic seq_cst
+  // CHECK-NEXT: a++;
+  // CHECK-NEXT: #pragma omp atomic read seq_cst
+  // CHECK-NEXT: a = argc;
+  // CHECK-NEXT: #pragma omp atomic seq_cst write
+  // CHECK-NEXT: a = argc + argc;
+  // CHECK-NEXT: #pragma omp atomic update seq_cst
+  // CHECK-NEXT: a = a + argc;
+  // CHECK-NEXT: #pragma omp atomic seq_cst capture
+  // CHECK-NEXT: a = b++;
+  // CHECK-NEXT: #pragma omp atomic capture seq_cst
+  // CHECK-NEXT: {
+  // CHECK-NEXT: a = b;
+  // CHECK-NEXT: b++;
+  // CHECK-NEXT: }
+  return foo(a);
+}
+
+#endif
diff --git a/test/OpenMP/atomic_messages.c b/test/OpenMP/atomic_messages.c
new file mode 100644
index 0000000..d2d3308
--- /dev/null
+++ b/test/OpenMP/atomic_messages.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+int foo() {
+L1:
+  foo();
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+    foo();
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+  }
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+    foo();
+  L2:
+    foo();
+  }
+
+  return 0;
+}
+
+struct S {
+  int a;
+};
+
+int readint() {
+  int a = 0, b = 0;
+// Test for atomic read
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected an expression statement}}
+  ;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  foo();
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  a += b;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected lvalue expression}}
+  a = 0;
+#pragma omp atomic read
+  a = b;
+  // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
+#pragma omp atomic read read
+  a = b;
+
+  return 0;
+}
+
+int readS() {
+  struct S a, b;
+  // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
+#pragma omp atomic read read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected expression of scalar type}}
+  a = b;
+
+  return a.a;
+}
diff --git a/test/OpenMP/atomic_messages.cpp b/test/OpenMP/atomic_messages.cpp
new file mode 100644
index 0000000..3965a77
--- /dev/null
+++ b/test/OpenMP/atomic_messages.cpp
@@ -0,0 +1,271 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+int foo() {
+L1:
+  foo();
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+    foo();
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+  }
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+    foo();
+  L2:
+    foo();
+  }
+
+  return 0;
+}
+
+struct S {
+  int a;
+  S &operator=(int v) {
+    a = v;
+    return *this;
+  }
+  S &operator+=(const S &s) {
+    a += s.a;
+    return *this;
+  }
+};
+
+template <class T>
+T read() {
+  T a = T(), b = T();
+// Test for atomic read
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected an expression statement}}
+  ;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  foo();
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  a += b;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected lvalue expression}}
+  a = 0;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  a = b;
+  // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
+#pragma omp atomic read read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  a = b;
+
+  return a;
+}
+
+int read() {
+  int a = 0, b = 0;
+// Test for atomic read
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected an expression statement}}
+  ;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  foo();
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected built-in assignment operator}}
+  a += b;
+#pragma omp atomic read
+  // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
+  // expected-note@+1 {{expected lvalue expression}}
+  a = 0;
+#pragma omp atomic read
+  a = b;
+  // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
+#pragma omp atomic read read
+  a = b;
+
+  // expected-note@+1 {{in instantiation of function template specialization 'read<S>' requested here}}
+  return read<int>() + read<S>().a;
+}
+
+template <class T>
+T write() {
+  T a, b = 0;
+// Test for atomic write
+#pragma omp atomic write
+  // expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
+#pragma omp atomic write write
+  a = b;
+
+  return T();
+}
+
+int write() {
+  int a, b = 0;
+// Test for atomic write
+#pragma omp atomic write
+  // expected-error@+1 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
+#pragma omp atomic write write
+  a = b;
+
+  return write<int>();
+}
+
+template <class T>
+T update() {
+  T a, b = 0;
+// Test for atomic update
+#pragma omp atomic update
+  // expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
+#pragma omp atomic update update
+  a += b;
+
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+
+  return T();
+}
+
+int update() {
+  int a, b = 0;
+// Test for atomic update
+#pragma omp atomic update
+  // expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
+#pragma omp atomic update update
+  a += b;
+
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+
+  return update<int>();
+}
+
+template <class T>
+T capture() {
+  T a, b = 0;
+// Test for atomic capture
+#pragma omp atomic capture
+  // expected-error@+1 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
+  ++a;
+#pragma omp atomic capture
+  // expected-error@+1 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
+#pragma omp atomic capture capture
+  a = ++b;
+
+  return T();
+}
+
+int capture() {
+  int a, b = 0;
+// Test for atomic capture
+#pragma omp atomic capture
+  // expected-error@+1 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
+  ++a;
+#pragma omp atomic capture
+  // expected-error@+1 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
+#pragma omp atomic capture capture
+  a = ++b;
+
+  return capture<int>();
+}
+
+template <class T>
+T seq_cst() {
+  T a, b = 0;
+// Test for atomic seq_cst
+#pragma omp atomic seq_cst
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}}
+#pragma omp atomic seq_cst seq_cst
+  a += b;
+
+#pragma omp atomic update seq_cst
+  // expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+
+  return T();
+}
+
+int seq_cst() {
+  int a, b = 0;
+// Test for atomic seq_cst
+#pragma omp atomic seq_cst
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}}
+#pragma omp atomic seq_cst seq_cst
+  a += b;
+
+#pragma omp atomic update seq_cst
+  // expected-error@+1 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  ;
+
+ return seq_cst<int>();
+}
+
+template <class T>
+T mixed() {
+  T a, b = T();
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 2 {{'read' clause used here}}
+#pragma omp atomic read write
+  a = b;
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 2 {{'write' clause used here}}
+#pragma omp atomic write read
+  a = b;
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 2 {{'update' clause used here}}
+#pragma omp atomic update read
+  a += b;
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 2 {{'capture' clause used here}}
+#pragma omp atomic capture read
+  a = ++b;
+  return T();
+}
+
+int mixed() {
+  int a, b = 0;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 {{'read' clause used here}}
+#pragma omp atomic read write
+  a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 {{'write' clause used here}}
+#pragma omp atomic write read
+  a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 {{'write' clause used here}}
+#pragma omp atomic write update
+  a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-note@+1 {{'write' clause used here}}
+#pragma omp atomic write capture
+  a = b;
+  // expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}}
+  return mixed<int>();
+}
+
diff --git a/test/OpenMP/barrier_ast_print.cpp b/test/OpenMP/barrier_ast_print.cpp
new file mode 100644
index 0000000..0ce344f
--- /dev/null
+++ b/test/OpenMP/barrier_ast_print.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+T tmain(T argc) {
+  static T a;
+#pragma omp barrier
+  return a + argc;
+}
+// CHECK:      static int a;
+// CHECK-NEXT: #pragma omp barrier
+// CHECK:      static char a;
+// CHECK-NEXT: #pragma omp barrier
+// CHECK:      static T a;
+// CHECK-NEXT: #pragma omp barrier
+
+int main(int argc, char **argv) {
+  static int a;
+// CHECK: static int a;
+#pragma omp barrier
+  // CHECK-NEXT: #pragma omp barrier
+  return tmain(argc) + tmain(argv[0][0]) + a;
+}
+
+#endif
diff --git a/test/OpenMP/barrier_messages.cpp b/test/OpenMP/barrier_messages.cpp
new file mode 100644
index 0000000..81ff84e
--- /dev/null
+++ b/test/OpenMP/barrier_messages.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+template <class T>
+T tmain(T argc) {
+#pragma omp barrier
+  ;
+#pragma omp barrier untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp barrier'}}
+#pragma omp barrier unknown // expected-warning {{extra tokens at the end of '#pragma omp barrier' are ignored}}
+  if (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp barrier
+    }
+  while (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp barrier
+    }
+  do
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp barrier
+  } while (argc);
+  switch (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp barrier
+  }
+  switch (argc) {
+#pragma omp barrier
+  case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp barrier
+  } break;
+  }
+  for (;;)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp barrier
+    }
+label:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+label1 : {
+#pragma omp barrier
+}
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+#pragma omp barrier
+  ;
+#pragma omp barrier untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp barrier'}}
+#pragma omp barrier unknown // expected-warning {{extra tokens at the end of '#pragma omp barrier' are ignored}}
+  if (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp barrier
+    }
+  while (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp barrier
+    }
+  do
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp barrier
+  } while (argc);
+  switch (argc)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp barrier
+  }
+  switch (argc) {
+#pragma omp barrier
+  case 1:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp barrier
+  } break;
+  }
+  for (;;)
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp barrier
+    }
+label:
+#pragma omp barrier // expected-error {{'#pragma omp barrier' cannot be an immediate substatement}}
+label1 : {
+#pragma omp barrier
+}
+
+  return tmain(argc);
+}
diff --git a/test/OpenMP/critical_ast_print.cpp b/test/OpenMP/critical_ast_print.cpp
new file mode 100644
index 0000000..98ece88
--- /dev/null
+++ b/test/OpenMP/critical_ast_print.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  static int a;
+// CHECK: static int a;
+#pragma omp critical
+  a=2;
+// CHECK-NEXT: #pragma omp critical
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: ++a;
+  ++a;
+#pragma omp critical  (the_name)
+  foo();
+// CHECK-NEXT: #pragma omp critical (the_name)
+// CHECK-NEXT: foo();
+// CHECK-NEXT: return 0;
+  return 0;
+}
+
+#endif
diff --git a/test/OpenMP/critical_codegen.cpp b/test/OpenMP/critical_codegen.cpp
new file mode 100644
index 0000000..dda532c
--- /dev/null
+++ b/test/OpenMP/critical_codegen.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK:       [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK:       [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
+// CHECK:       [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
+
+// CHECK:       define void [[FOO:@.+]]()
+
+void foo() {}
+
+// CHECK-LABEL: @main
+int main() {
+// CHECK:       [[A_ADDR:%.+]] = alloca i8
+  char a;
+
+// CHECK:       [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEFAULT_LOC:@.+]])
+// CHECK:       call void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[UNNAMED_LOCK]])
+// CHECK-NEXT:  store i8 2, i8* [[A_ADDR]]
+// CHECK-NEXT:  call void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[UNNAMED_LOCK]])
+#pragma omp critical
+  a = 2;
+// CHECK:       call void @__kmpc_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
+// CHECK-NEXT:  call void [[FOO]]()
+// CHECK-NEXT:  call void @__kmpc_end_critical([[IDENT_T_TY]]* [[DEFAULT_LOC]], i32 [[GTID]], [8 x i32]* [[THE_NAME_LOCK]])
+#pragma omp critical(the_name)
+  foo();
+// CHECK-NOT:   call void @__kmpc_critical
+// CHECK-NOT:   call void @__kmpc_end_critical
+  return a;
+}
+
+#endif
diff --git a/test/OpenMP/critical_messages.cpp b/test/OpenMP/critical_messages.cpp
new file mode 100644
index 0000000..08df9e0
--- /dev/null
+++ b/test/OpenMP/critical_messages.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+int foo();
+
+int main() {
+  #pragma omp critical
+  ;
+  #pragma omp critical untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}}
+  #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}
+  #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp critical (name // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp critical (name1)
+  foo();
+  {
+    #pragma omp critical
+  } // expected-error {{expected statement}}
+  #pragma omp critical (name) // expected-note {{previous 'critical' region starts here}}
+  #pragma omp critical
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    #pragma omp parallel
+    #pragma omp for
+    for (int j = 0; j < 10; j++) {
+      foo();
+      #pragma omp critical(name) // expected-error {{cannot nest 'critical' regions having the same name 'name'}}
+      foo();
+    }
+  }
+  #pragma omp critical (name)
+  #pragma omp critical
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    #pragma omp parallel
+    #pragma omp for
+    for (int j = 0; j < 10; j++) {
+      #pragma omp critical
+      foo();
+    }
+  }
+  #pragma omp critical (name)
+  #pragma omp critical
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    #pragma omp parallel
+    #pragma omp for
+    for (int j = 0; j < 10; j++) {
+      #pragma omp critical (nam)
+      foo();
+    }
+  }
+
+  return 0;
+}
+
+int foo() {
+  L1:
+    foo();
+  #pragma omp critical
+  {
+    foo();
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+  }
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+  #pragma omp critical
+  {
+    L2:
+    foo();
+  }
+
+  return 0;
+}
diff --git a/test/OpenMP/flush_ast_print.cpp b/test/OpenMP/flush_ast_print.cpp
new file mode 100644
index 0000000..7eb18f0
--- /dev/null
+++ b/test/OpenMP/flush_ast_print.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+T tmain(T argc) {
+  static T a;
+#pragma omp flush
+#pragma omp flush(a)
+  return a + argc;
+}
+// CHECK:      static int a;
+// CHECK-NEXT: #pragma omp flush
+// CHECK-NEXT: #pragma omp flush (a)
+// CHECK:      static char a;
+// CHECK-NEXT: #pragma omp flush
+// CHECK-NEXT: #pragma omp flush (a)
+// CHECK:      static T a;
+// CHECK-NEXT: #pragma omp flush
+// CHECK-NEXT: #pragma omp flush (a)
+
+int main(int argc, char **argv) {
+  static int a;
+// CHECK: static int a;
+#pragma omp flush
+#pragma omp flush(a)
+// CHECK-NEXT: #pragma omp flush
+// CHECK-NEXT: #pragma omp flush (a)
+  return tmain(argc) + tmain(argv[0][0]) + a;
+}
+
+#endif
diff --git a/test/OpenMP/flush_codegen.cpp b/test/OpenMP/flush_codegen.cpp
new file mode 100644
index 0000000..eb9c721
--- /dev/null
+++ b/test/OpenMP/flush_codegen.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -g -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template <class T>
+T tmain(T argc) {
+  static T a;
+#pragma omp flush
+#pragma omp flush(a)
+  return a + argc;
+}
+
+// CHECK-LABEL: @main
+int main() {
+  static int a;
+#pragma omp flush
+#pragma omp flush(a)
+  // CHECK: call void (%{{.+}}*, ...)* @__kmpc_flush(%{{.+}}* {{(@|%).+}}, i32 0)
+  // CHECK: call void (%{{.+}}*, ...)* @__kmpc_flush(%{{.+}}* {{(@|%).+}}, i32 0)
+  return tmain(a);
+  // CHECK: call {{.*}} [[TMAIN:@.+]](
+  // CHECK: ret
+}
+
+// CHECK: [[TMAIN]]
+// CHECK: call void (%{{.+}}*, ...)* @__kmpc_flush(%{{.+}}* {{(@|%).+}}, i32 0)
+// CHECK: call void (%{{.+}}*, ...)* @__kmpc_flush(%{{.+}}* {{(@|%).+}}, i32 0)
+// CHECK: ret
+
+#endif
diff --git a/test/OpenMP/flush_messages.cpp b/test/OpenMP/flush_messages.cpp
new file mode 100644
index 0000000..8c61680
--- /dev/null
+++ b/test/OpenMP/flush_messages.cpp
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+struct S1 { // expected-note 2 {{declared here}}
+  int a;
+};
+
+template <class T>
+T tmain(T argc) {
+#pragma omp flush
+  ;
+#pragma omp flush untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp flush'}}
+#pragma omp flush unknown // expected-warning {{extra tokens at the end of '#pragma omp flush' are ignored}}
+  if (argc)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp flush
+    }
+  while (argc)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp flush
+    }
+  do
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp flush
+  } while (argc);
+  switch (argc)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp flush
+  }
+  switch (argc) {
+#pragma omp flush
+  case 1:
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp flush
+  } break;
+  }
+  for (;;)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp flush
+    }
+label:
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+label1 : {
+#pragma omp flush
+}
+
+#pragma omp flush
+#pragma omp flush(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp flush()                             // expected-error {{expected expression}}
+#pragma omp flush(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp flush(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp flush(argc)
+#pragma omp flush(S1) // expected-error {{'S1' does not refer to a value}}
+#pragma omp flush(argc) flush(argc) // expected-warning {{extra tokens at the end of '#pragma omp flush' are ignored}}
+#pragma omp parallel flush(argc) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
+  ;
+  return T();
+}
+
+int main(int argc, char **argv) {
+#pragma omp flush
+  ;
+#pragma omp flush untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp flush'}}
+#pragma omp flush unknown // expected-warning {{extra tokens at the end of '#pragma omp flush' are ignored}}
+  if (argc)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp flush
+    }
+  while (argc)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp flush
+    }
+  do
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp flush
+  } while (argc);
+  switch (argc)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp flush
+  }
+  switch (argc) {
+#pragma omp flush
+  case 1:
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp flush
+  } break;
+  }
+  for (;;)
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp flush
+    }
+label:
+#pragma omp flush // expected-error {{'#pragma omp flush' cannot be an immediate substatement}}
+label1 : {
+#pragma omp flush
+}
+
+#pragma omp flush
+#pragma omp flush(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp flush()                             // expected-error {{expected expression}}
+#pragma omp flush(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp flush(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp flush(argc)
+#pragma omp flush(S1) // expected-error {{'S1' does not refer to a value}}
+#pragma omp flush(argc) flush(argc) // expected-warning {{extra tokens at the end of '#pragma omp flush' are ignored}}
+#pragma omp parallel flush(argc) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
+  ;
+  return tmain(argc);
+}
diff --git a/test/OpenMP/for_firstprivate_messages.cpp b/test/OpenMP/for_firstprivate_messages.cpp
index f1d21b8..6aa977b 100644
--- a/test/OpenMP/for_firstprivate_messages.cpp
+++ b/test/OpenMP/for_firstprivate_messages.cpp
@@ -14,7 +14,7 @@
 
 public:
   S2() : a(0) {}
-  S2(S2 &s2) : a(s2.a) {}
+  S2(const S2 &s2) : a(s2.a) {}
   static float S2s;
   static const float S2sc;
 };
@@ -26,23 +26,23 @@
   S3 &operator=(const S3 &s3);
 
 public:
-  S3() : a(0) {}
-  S3(S3 &s3) : a(s3.a) {}
+  S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
+  S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
 };
 const S3 c;
 const S3 ca[5];
 extern const int f;
-class S4 { // expected-note 2 {{'S4' declared here}}
+class S4 {
   int a;
   S4();
-  S4(const S4 &s4);
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note 4 {{'S5' declared here}}
+class S5 {
   int a;
-  S5(const S5 &s5) : a(s5.a) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
 
 public:
   S5() : a(0) {}
@@ -62,8 +62,8 @@
 
 template <class I, class C>
 int foomain(int argc, char **argv) {
-  I e(4); // expected-note {{'e' defined here}}
-  C g(5); // expected-note 2 {{'g' defined here}}
+  I e(4);
+  C g(5);
   int i;
   int &j = i; // expected-note {{'j' defined here}}
 #pragma omp parallel
@@ -107,7 +107,7 @@
   for (int k = 0; k < argc; ++k)
     ++k;
 #pragma omp parallel
-#pragma omp for firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (int k = 0; k < argc; ++k)
     ++k;
 #pragma omp parallel
@@ -138,7 +138,7 @@
   for (int k = 0; k < argc; ++k)
     ++k;
 #pragma omp parallel
-#pragma omp for lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel private(i) // expected-note {{defined as private}}
@@ -155,8 +155,8 @@
 int main(int argc, char **argv) {
   const int d = 5;
   const int da[5] = {0};
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note 2 {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   S3 m;
   S6 n(2);
   int i;
@@ -194,7 +194,7 @@
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel
-#pragma omp for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+#pragma omp for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'const S3'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel
@@ -235,7 +235,7 @@
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel
-#pragma omp for firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel
@@ -263,7 +263,7 @@
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel
-#pragma omp for lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel
@@ -291,3 +291,4 @@
 
   return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
 }
+
diff --git a/test/OpenMP/for_loop_messages.cpp b/test/OpenMP/for_loop_messages.cpp
index deed0ec..cb32484 100644
--- a/test/OpenMP/for_loop_messages.cpp
+++ b/test/OpenMP/for_loop_messages.cpp
@@ -11,6 +11,7 @@
 
 static int sii;
 #pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+static int globalii;
 
 int test_iteration_spaces() {
   const int N = 100;
@@ -311,6 +312,23 @@
   }
 
 #pragma omp parallel
+  {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be a variable with global storage without being explicitly marked as private}}
+#pragma omp for
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] = a[globalii];
+  }
+
+#pragma omp parallel
+  {
+// expected-error@+3 {{loop iteration variable in the associated loop of 'omp for' directive may not be a variable with global storage without being explicitly marked as private}}
+#pragma omp for collapse(2)
+    for (ii = 0; ii < 10; ii += 1)
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] += a[globalii] + ii;
+  }
+
+#pragma omp parallel
 // expected-error@+2 {{statement after '#pragma omp for' must be a for loop}}
 #pragma omp for
   for (auto &item : a) {
@@ -360,6 +378,8 @@
   Iter0 operator--() { return *this; }
   bool operator<(Iter0 a) { return true; }
 };
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
 int operator-(Iter0 a, Iter0 b) { return 0; }
 class Iter1 {
 public:
@@ -378,6 +398,7 @@
   GoodIter &operator=(const GoodIter &that) { return *this; }
   GoodIter &operator=(const Iter0 &that) { return *this; }
   GoodIter &operator+=(int x) { return *this; }
+  GoodIter &operator-=(int x) { return *this; }
   explicit GoodIter(void *) {}
   GoodIter operator++() { return *this; }
   GoodIter operator--() { return *this; }
@@ -388,11 +409,20 @@
   typedef int difference_type;
   typedef std::random_access_iterator_tag iterator_category;
 };
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
 int operator-(GoodIter a, GoodIter b) { return 0; }
+// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
 GoodIter operator-(GoodIter a) { return a; }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
 GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
 GoodIter operator+(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
 GoodIter operator-(int v, GoodIter a) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
 GoodIter operator+(int v, GoodIter a) { return GoodIter(); }
 
 int test_with_random_access_iterator() {
@@ -435,6 +465,8 @@
 #pragma omp for
   for (begin = GoodIter(0); begin < end; ++begin)
     ++begin;
+// expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 #pragma omp parallel
 #pragma omp for
   for (begin = begin0; begin < end; ++begin)
@@ -489,17 +521,22 @@
 #pragma omp for
   for (GoodIter I = begin; I >= end; I = 2 - I)
     ++I;
+// In the following example, we cannot update the loop variable using '+='
+// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
 #pragma omp parallel
 #pragma omp for
   for (Iter0 I = begin0; I < end0; ++I)
     ++I;
 #pragma omp parallel
 // Initializer is constructor without params.
+// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
 #pragma omp for
   for (Iter0 I; I < end0; ++I)
     ++I;
   Iter1 begin1, end1;
+// expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 #pragma omp parallel
 #pragma omp for
   for (Iter1 I = begin1; I < end1; ++I)
@@ -511,6 +548,8 @@
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
 #pragma omp parallel
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 // Initializer is constructor with all default params.
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
 #pragma omp for
@@ -678,3 +717,17 @@
   for (int i = 0; i < 16; ++i)
     ;
 }
+
+void test_ordered() {
+#pragma omp parallel
+#pragma omp for ordered ordered // expected-error {{directive '#pragma omp for' cannot contain more than one 'ordered' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
+void test_nowait() {
+#pragma omp parallel
+#pragma omp for nowait nowait // expected-error {{directive '#pragma omp for' cannot contain more than one 'nowait' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
diff --git a/test/OpenMP/for_misc_messages.c b/test/OpenMP/for_misc_messages.c
index 854898c..8a72180 100644
--- a/test/OpenMP/for_misc_messages.c
+++ b/test/OpenMP/for_misc_messages.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -triple x86_64-unknown-unknown -verify %s
 
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp for'}}
 #pragma omp for
@@ -190,6 +190,16 @@
 #pragma omp for collapse(5 - 5)
   for (i = 0; i < 16; ++i)
     ;
+#pragma omp parallel
+#pragma omp for collapse(2)
+  for (i = 0; i < 16; ++i)
+// expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
+    for (int j = 0; j < 16; ++j)
+// expected-error@+2 {{private variable cannot be reduction}}
+// expected-error@+1 {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+#pragma omp for reduction(+ : i, j)
+      for (int k = 0; k < 16; ++k)
+        i += j;
 }
 
 void test_private() {
@@ -359,5 +369,11 @@
   for (double fi = 0; fi < 10.0; fi++) {
     c[(int)fi] = a[(int)fi] + b[(int)fi];
   }
+
+  // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
+  #pragma omp for
+  for (__int128 ii = 0; ii < 10; ii++) {
+    c[ii] = a[ii] + b[ii];
+  }
 }
 
diff --git a/test/OpenMP/for_private_messages.cpp b/test/OpenMP/for_private_messages.cpp
index f7a4979..45c8683 100644
--- a/test/OpenMP/for_private_messages.cpp
+++ b/test/OpenMP/for_private_messages.cpp
@@ -24,16 +24,16 @@
   S3() : a(0) {}
 };
 const S3 ca[5];
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5() : a(0) {}
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
 
 public:
   S5(int v) : a(v) {}
@@ -109,8 +109,8 @@
 }
 
 int main(int argc, char **argv) {
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i;           // expected-note {{'j' defined here}}
 #pragma omp for private // expected-error {{expected '(' after 'private'}}
@@ -143,7 +143,7 @@
 #pragma omp for private(argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k)
     ++k;
-#pragma omp for private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+#pragma omp for private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (int k = 0; k < argc; ++k)
     ++k;
 #pragma omp for private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
diff --git a/test/OpenMP/for_simd_aligned_messages.cpp b/test/OpenMP/for_simd_aligned_messages.cpp
new file mode 100644
index 0000000..70131d5
--- /dev/null
+++ b/test/OpenMP/for_simd_aligned_messages.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp=libiomp5 %s
+
+struct B {
+  static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
+  static constexpr int bfoo() { return 8; }
+};
+namespace X {
+  B x; // expected-note {{'x' defined here}}
+};
+constexpr int bfoo() { return 4; }
+
+int **z;
+const int C1 = 1;
+const int C2 = 2;
+void test_aligned_colons(int *&rp)
+{
+  int *B = 0;
+  #pragma omp for simd aligned(B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
+  #pragma omp for simd aligned(B::ib:B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd aligned(B:B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
+  #pragma omp for simd aligned(z:B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd aligned(B:B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}}
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
+  #pragma omp for simd aligned(X::x : ::z)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
+  #pragma omp for simd aligned(B,rp,::z: X::x)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd aligned(::z)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{expected variable name}}
+  #pragma omp for simd aligned(B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+  #pragma omp for simd aligned(B::ib,B:C1+C2)
+  for (int i = 0; i < 10; ++i) ;
+}
+
+// expected-note@+1 {{'num' defined here}}
+template<int L, class T, class N> T test_template(T* arr, N num) {
+  N i;
+  T sum = (T)0;
+  T ind2 = - num * L;
+  // Negative number is passed as L.
+  // expected-error@+1 {{argument to 'aligned' clause must be a positive integer value}}
+  #pragma omp for simd aligned(arr:L)
+  for (i = 0; i < num; ++i) {
+    T cur = arr[(int)ind2];
+    ind2 += L;
+    sum += cur;
+  }
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp for simd aligned(num:4)
+  for (i = 0; i < num; ++i);
+  return T();
+}
+
+template<int LEN> int test_warn() {
+  int *ind2 = 0;
+  // expected-error@+1 {{argument to 'aligned' clause must be a positive integer value}}
+  #pragma omp for simd aligned(ind2:LEN)
+  for (int i = 0; i < 100; i++) {
+    ind2 += LEN;
+  }
+  return 0;
+}
+
+struct S1; // expected-note 2 {{declared here}}
+extern S1 a; // expected-note {{'a' declared here}}
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+};
+const S2 b; // expected-note 1 {{'b' defined here}}
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4();
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h; // expected-note 2 {{'h' defined here}}
+#pragma omp threadprivate(h)
+
+template<class I, class C> int foomain(I argc, C **argv) {
+  I e(argc);
+  I g(argc);
+  int i; // expected-note {{declared here}} expected-note {{'i' defined here}}
+  // expected-note@+2 {{declared here}}
+  // expected-note@+1 {{reference to 'i' is not a constant expression}}
+  int &j = i;
+  #pragma omp for simd aligned // expected-error {{expected '(' after 'aligned'}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned () // expected-error {{expected expression}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argv[1]) // expected-error {{expected variable name}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned(e, g)
+  for (I k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
+  #pragma omp for simd aligned(h)
+  for (I k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp for simd aligned(i)
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel
+  {
+    int *v = 0;
+    I i;
+    #pragma omp for simd aligned(v:16)
+    for (I k = 0; k < argc; ++k) { i = k; v += 2; }
+  }
+  float *f;
+  #pragma omp for simd aligned(f)
+  for (I k = 0; k < argc; ++k) ++k;
+  int v = 0;
+  // expected-note@+2 {{initializer of 'j' is not a constant expression}}
+  // expected-error@+1 {{expression is not an integral constant expression}}
+  #pragma omp for simd aligned(f:j)
+  for (I k = 0; k < argc; ++k) { ++k; v += j; }
+  #pragma omp for simd aligned(f)
+  for (I k = 0; k < argc; ++k) ++k;
+  return 0;
+}
+
+// expected-note@+1 2 {{'argc' defined here}}
+int main(int argc, char **argv) {
+  double darr[100];
+  // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
+  test_template<-4>(darr, 4);
+  test_warn<4>(); // ok
+  // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
+  test_warn<0>();
+
+  int i;
+  int &j = i;
+  #pragma omp for simd aligned // expected-error {{expected '(' after 'aligned'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned () // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp for simd aligned (argc)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}}
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}}
+  #pragma omp for simd aligned (a, b) 
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd aligned (argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
+  #pragma omp for simd aligned(h)
+  for (int k = 0; k < argc; ++k) ++k;
+  int *pargc = &argc;
+  foomain<int*,char>(pargc,argv);
+  return 0;
+}
+
diff --git a/test/OpenMP/for_simd_ast_print.cpp b/test/OpenMP/for_simd_ast_print.cpp
new file mode 100644
index 0000000..7597064
--- /dev/null
+++ b/test/OpenMP/for_simd_ast_print.cpp
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+int g_ind = 1;
+template<class T, class N> T reduct(T* arr, N num) {
+  N i;
+  N ind;
+  N myind;
+  T sum = (T)0;
+// CHECK: T sum = (T)0;
+#pragma omp for simd private(myind, g_ind), linear(ind), aligned(arr)
+// CHECK-NEXT: #pragma omp for simd private(myind,g_ind) linear(ind) aligned(arr)
+  for (i = 0; i < num; ++i) {
+    myind = ind;
+    T cur = arr[myind];
+    ind += g_ind;
+    sum += cur;
+  }
+}
+
+template<class T> struct S {
+  S(const T &a)
+    :m_a(a)
+  {}
+  T result(T *v) const {
+    T res;
+    T val;
+    T lin = 0;
+// CHECK: T res;
+// CHECK: T val;
+// CHECK: T lin = 0;
+    #pragma omp for simd private(val)  safelen(7) linear(lin : -5) lastprivate(res)
+// CHECK-NEXT: #pragma omp for simd private(val) safelen(7) linear(lin: -5) lastprivate(res)
+    for (T i = 7; i < m_a; ++i) {
+      val = v[i-7] + m_a;
+      res = val;
+      lin -= 5;
+    }
+    const T clen = 3;
+// CHECK: T clen = 3;
+    #pragma omp for simd safelen(clen-1)
+// CHECK-NEXT: #pragma omp for simd safelen(clen - 1)
+    for(T i = clen+2; i < 20; ++i) {
+// CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
+      v[i] = v[v-clen] + 1;
+// CHECK-NEXT: v[i] = v[v - clen] + 1;
+    }
+// CHECK-NEXT: }
+    return res;
+  }
+  ~S()
+  {}
+  T m_a;
+};
+
+template<int LEN> struct S2 {
+  static void func(int n, float *a, float *b, float *c) {
+    int k1 = 0, k2 = 0;
+#pragma omp for simd safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN)
+    for(int i = 0; i < n; i++) {
+      c[i] = a[i] + b[i];
+      c[k1] = a[k1] + b[k1];
+      c[k2] = a[k2] + b[k2];
+      k1 = k1 + LEN;
+      k2 = k2 + LEN;
+    }
+  }
+};
+
+// S2<4>::func is called below in main.
+// CHECK: template <int LEN = 4> struct S2 {
+// CHECK-NEXT: static void func(int n, float *a, float *b, float *c)     {
+// CHECK-NEXT:   int k1 = 0, k2 = 0;
+// CHECK-NEXT: #pragma omp for simd safelen(4) linear(k1,k2: 4) aligned(a: 4)
+// CHECK-NEXT:   for (int i = 0; i < n; i++) {
+// CHECK-NEXT:     c[i] = a[i] + b[i];
+// CHECK-NEXT:     c[k1] = a[k1] + b[k1];
+// CHECK-NEXT:     c[k2] = a[k2] + b[k2];
+// CHECK-NEXT:     k1 = k1 + 4;
+// CHECK-NEXT:     k2 = k2 + 4;
+// CHECK-NEXT:   }
+// CHECK-NEXT: }
+
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  int k1=0,k2=0;
+  static int *a;
+// CHECK: static int *a;
+#pragma omp for simd
+// CHECK-NEXT: #pragma omp for simd
+  for (int i=0; i < 2; ++i)*a=2;
+// CHECK-NEXT: for (int i = 0; i < 2; ++i)
+// CHECK-NEXT: *a = 2;
+#pragma omp  parallel
+#pragma omp for simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) ,firstprivate( g )
+  for (int i = 0; i < 10; ++i)
+  for (int j = 0; j < 10; ++j) {foo(); k1 += 8; k2 += 8;}
+// CHECK-NEXT: #pragma omp parallel
+// CHECK-NEXT: #pragma omp for simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) firstprivate(g)
+// CHECK-NEXT: for (int i = 0; i < 10; ++i)
+// CHECK-NEXT: for (int j = 0; j < 10; ++j) {
+// CHECK-NEXT: foo();
+// CHECK-NEXT: k1 += 8;
+// CHECK-NEXT: k2 += 8;
+// CHECK-NEXT: }
+  for (int i = 0; i < 10; ++i)foo();
+// CHECK-NEXT: for (int i = 0; i < 10; ++i)
+// CHECK-NEXT: foo();
+  const int CLEN = 4;
+// CHECK-NEXT: const int CLEN = 4;
+  #pragma omp for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 )
+// CHECK-NEXT: #pragma omp for simd aligned(a: CLEN) linear(a: CLEN) safelen(CLEN) collapse(1)
+  for (int i = 0; i < 10; ++i)foo();
+// CHECK-NEXT: for (int i = 0; i < 10; ++i)
+// CHECK-NEXT: foo();
+
+  float arr[16];
+  S2<4>::func(0,arr,arr,arr);
+  return (0);
+}
+
+#endif
diff --git a/test/OpenMP/for_simd_collapse_messages.cpp b/test/OpenMP/for_simd_collapse_messages.cpp
new file mode 100644
index 0000000..3b43f1f
--- /dev/null
+++ b/test/OpenMP/for_simd_collapse_messages.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N, int ST> // expected-note {{declared here}}
+T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
+  #pragma omp for simd collapse // expected-error {{expected '(' after 'collapse'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse () // expected-error {{expected expression}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+  // expected-error@+2 2 {{expression is not an integral constant expression}}
+  // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
+  #pragma omp for simd collapse (argc 
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{argument to 'collapse' clause must be a positive integer value}}
+  #pragma omp for simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp for simd', but found only 1}}
+  // expected-error@+3 2 {{directive '#pragma omp for simd' cannot contain more than one 'collapse' clause}}
+  // expected-error@+2 2 {{argument to 'collapse' clause must be a positive integer value}}
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp for simd collapse (foobool(argc)), collapse (true), collapse (-5)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse (S) // expected-error {{'S' does not refer to a value}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse (1)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse (N) // expected-error {{argument to 'collapse' clause must be a positive integer value}}
+  for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
+  foo(); // expected-error {{expected 2 for loops after '#pragma omp for simd'}}
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp for simd collapse // expected-error {{expected '(' after 'collapse'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd collapse () // expected-error {{expected expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+  #pragma omp for simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}  expected-note {{as specified in 'collapse' clause}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+  #pragma omp for simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{expression is not an integral constant expression}}
+  // expected-error@+2 2 {{directive '#pragma omp for simd' cannot contain more than one 'collapse' clause}}
+  // expected-error@+1 2 {{argument to 'collapse' clause must be a positive integer value}}
+  #pragma omp for simd collapse (foobool(argc)), collapse (true), collapse (-5) 
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+1 {{expression is not an integral constant expression}}
+  #pragma omp for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{statement after '#pragma omp for simd' must be a for loop}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
+  #pragma omp for simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
+  foo();
+  #pragma omp for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
+  foo(); // expected-error {{expected 2 for loops after '#pragma omp for simd'}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
+  return tmain<int, char, 1, 0>(argc, argv);
+}
+
diff --git a/test/OpenMP/for_simd_firstprivate_messages.cpp b/test/OpenMP/for_simd_firstprivate_messages.cpp
new file mode 100644
index 0000000..1345bfc
--- /dev/null
+++ b/test/OpenMP/for_simd_firstprivate_messages.cpp
@@ -0,0 +1,293 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(const S2 &s2) : a(s2.a) {}
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+  S3 &operator=(const S3 &s3);
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
+
+public:
+  S5() : a(0) {}
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+  S6() : a(0) {}
+
+public:
+  S6(const S6 &s6) : a(s6.a) {}
+  S6(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(int argc, char **argv) {
+  I e(4);
+  C g(5);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp parallel
+#pragma omp for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(a, b) // expected-error {{a firstprivate variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd linear(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;                      // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
+#pragma omp for simd firstprivate(i) // expected-error {{private variable cannot be firstprivate}}
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp for simd firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd firstprivate(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel private(i) // expected-note {{defined as private}}
+#pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
+#pragma omp for simd firstprivate(i)       // expected-error {{firstprivate variable must be shared}}
+  for (i = 0; i < argc; ++i)
+    foo();
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;
+  const int da[5] = {0};
+  S4 e(4);
+  S5 g(5);
+  S3 m;
+  S6 n(2);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp parallel
+#pragma omp for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate() // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(argc)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(ba) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(ca) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(da) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+  int xa;
+#pragma omp parallel
+#pragma omp for simd firstprivate(xa) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(S2::S2s) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(S2::S2sc) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd safelen(5)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(m) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(i) // expected-note {{defined as firstprivate}}
+  for (i = 0; i < argc; ++i)    // expected-error {{loop iteration variable in the associated loop of 'omp for simd' directive may not be firstprivate, predetermined as linear}}
+    foo();
+#pragma omp parallel shared(xa)
+#pragma omp for simd firstprivate(xa) // OK: may be firstprivate
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(n) firstprivate(n) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;                      // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
+#pragma omp for simd firstprivate(i) // expected-error {{private variable cannot be firstprivate}}
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel private(i) // expected-note {{defined as private}}
+#pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
+#pragma omp for simd firstprivate(i)       // expected-error {{firstprivate variable must be shared}}
+  for (i = 0; i < argc; ++i)
+    foo();
+
+  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
+}
diff --git a/test/OpenMP/for_simd_lastprivate_messages.cpp b/test/OpenMP/for_simd_lastprivate_messages.cpp
new file mode 100644
index 0000000..38651e5
--- /dev/null
+++ b/test/OpenMP/for_simd_lastprivate_messages.cpp
@@ -0,0 +1,266 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+  static float S2s; // expected-note {{static data member is predetermined as shared}}
+  static const float S2sc;
+};
+const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
+const S2 b;
+const S2 ba[5];
+class S3 { // expected-note 2 {{'S3' declared here}}
+  int a;
+  S3 &operator=(const S3 &s3);
+
+public:
+  S3() : a(0) {}
+  S3(S3 &s3) : a(s3.a) {}
+};
+const S3 c;         // expected-note {{global variable is predetermined as shared}}
+const S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
+extern const int f; // expected-note {{global variable is predetermined as shared}}
+class S4 {          // expected-note 3 {{'S4' declared here}}
+  int a;
+  S4();
+  S4(const S4 &s4);
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 { // expected-note {{'S5' declared here}}
+  int a;
+  S5() : a(0) {}
+
+public:
+  S5(const S5 &s5) : a(s5.a) {}
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+  S6() : a(0) {}
+
+public:
+  S6(const S6 &s6) : a(s6.a) {}
+  S6(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(int argc, char **argv) {
+  I e(4); // expected-note {{'e' defined here}}
+  I g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp parallel
+#pragma omp for simd lastprivate // expected-error {{expected '(' after 'lastprivate'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;                     // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
+#pragma omp for simd lastprivate(i) // expected-error {{lastprivate variable must be shared}}
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp for simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+#pragma omp for simd lastprivate(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
+  const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
+  S4 e(4);               // expected-note {{'e' defined here}}
+  S5 g(5);               // expected-note {{'g' defined here}}
+  S3 m;                  // expected-note 2 {{'m' defined here}}
+  S6 n(2);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp parallel
+#pragma omp for simd lastprivate // expected-error {{expected '(' after 'lastprivate'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate() // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(argc)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(argv[1]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(2 * 2) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(ba)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+  int xa;
+#pragma omp parallel
+#pragma omp for simd lastprivate(xa) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(i) // expected-note {{defined as lastprivate}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp for simd' directive may not be lastprivate, predetermined as linear}}
+    foo();
+#pragma omp parallel private(xa) // expected-note {{defined as private}}
+#pragma omp for simd lastprivate(xa)  // expected-error {{lastprivate variable must be shared}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}}
+#pragma omp for simd lastprivate(xa)        // expected-error {{lastprivate variable must be shared}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd lastprivate(n) firstprivate(n) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
+}
diff --git a/test/OpenMP/for_simd_linear_messages.cpp b/test/OpenMP/for_simd_linear_messages.cpp
new file mode 100644
index 0000000..9a935c3
--- /dev/null
+++ b/test/OpenMP/for_simd_linear_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+namespace X {
+  int x;
+};
+
+struct B {
+  static int ib; // expected-note {{'B::ib' declared here}}
+  static int bfoo() { return 8; }
+};
+
+int bfoo() { return 4; }
+
+int z;
+const int C1 = 1;
+const int C2 = 2;
+void test_linear_colons()
+{
+  int B = 0;
+  #pragma omp for simd linear(B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
+  #pragma omp for simd linear(B::ib:B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
+  #pragma omp for simd linear(B:ib)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
+  #pragma omp for simd linear(z:B:ib)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd linear(B:B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd linear(X::x : ::z)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd linear(B,::z, X::x)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd linear(::z)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{expected variable name}}
+  #pragma omp for simd linear(B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp for simd linear(B::ib,B:C1+C2)
+  for (int i = 0; i < 10; ++i) ;
+}
+
+template<int L, class T, class N> T test_template(T* arr, N num) {
+  N i;
+  T sum = (T)0;
+  T ind2 = - num * L; // expected-note {{'ind2' defined here}}
+  // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
+#pragma omp for simd linear(ind2:L)
+  for (i = 0; i < num; ++i) {
+    T cur = arr[(int)ind2];
+    ind2 += L;
+    sum += cur;
+  }
+  return T();
+}
+
+template<int LEN> int test_warn() {
+  int ind2 = 0;
+  // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
+  #pragma omp for simd linear(ind2:LEN)
+  for (int i = 0; i < 100; i++) {
+    ind2 += LEN;
+  }
+  return ind2;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+};
+const S2 b; // expected-note 2 {{'b' defined here}}
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4();
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template<class I, class C> int foomain(I argc, C **argv) {
+  I e(4);
+  I g(5);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+  #pragma omp for simd linear // expected-error {{expected '(' after 'linear'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear () // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc : 5)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{linear variable with incomplete type 'S1'}}
+  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  #pragma omp for simd linear (a, b:B::ib)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear(e, g)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear(i)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel
+  {
+    int v = 0;
+    int i;
+    #pragma omp for simd linear(v:i)
+    for (int k = 0; k < argc; ++k) { i = k; v += i; }
+  }
+  #pragma omp for simd linear(j) // expected-error {{arguments of OpenMP clause 'linear' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k) ++k;
+  int v = 0;
+  #pragma omp for simd linear(v:j)
+  for (int k = 0; k < argc; ++k) { ++k; v += j; }
+  #pragma omp for simd linear(i)
+  for (int k = 0; k < argc; ++k) ++k;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  double darr[100];
+  // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
+  test_template<-4>(darr, 4);
+  // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
+  test_warn<0>();
+
+  S4 e(4); // expected-note {{'e' defined here}}
+  S5 g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+  #pragma omp for simd linear // expected-error {{expected '(' after 'linear'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear () // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argc)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{linear variable with incomplete type 'S1'}}
+  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  #pragma omp for simd linear (a, b) 
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear (argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
+  // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
+  #pragma omp for simd linear(e, g)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel
+  {
+    int i;
+    #pragma omp for simd linear(i)
+    for (int k = 0; k < argc; ++k) ++k;
+    #pragma omp for simd linear(i : 4)
+    for (int k = 0; k < argc; ++k) { ++k; i += 4; }
+  }
+  #pragma omp for simd linear(j) // expected-error {{arguments of OpenMP clause 'linear' cannot be of reference type 'int &'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp for simd linear(i)
+  for (int k = 0; k < argc; ++k) ++k;
+
+  foomain<int,char>(argc,argv);
+  return 0;
+}
+
diff --git a/test/OpenMP/for_simd_loop_messages.cpp b/test/OpenMP/for_simd_loop_messages.cpp
new file mode 100644
index 0000000..403709f
--- /dev/null
+++ b/test/OpenMP/for_simd_loop_messages.cpp
@@ -0,0 +1,734 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
+
+class S {
+  int a;
+  S() : a(0) {}
+
+public:
+  S(int v) : a(v) {}
+  S(const S &s) : a(s.a) {}
+};
+
+static int sii;
+#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+static int globalii;
+
+int test_iteration_spaces() {
+  const int N = 100;
+  float a[N], b[N], c[N];
+  int ii, jj, kk;
+  float fii;
+  double dii;
+#pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; i += 1) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel
+#pragma omp for simd
+  for (char i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel
+#pragma omp for simd
+  for (char i = 0; i < 10; i += '\1') {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel
+#pragma omp for simd
+  for (long long i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel
+// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp for simd
+  for (long long i = 0; i < 10; i += 1.5) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel
+#pragma omp for simd
+  for (long long i = 0; i < 'z'; i += 1u) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp for simd
+  for (float fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp for simd
+  for (double fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp for simd
+  for (int &ref = ii; ref < 10; ref++) {
+  }
+#pragma omp parallel
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp for simd
+  for (int i; i < 10; i++)
+    c[i] = a[i];
+
+#pragma omp parallel
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp for simd
+  for (int i = 0, j = 0; i < 10; ++i)
+    c[i] = a[i];
+
+#pragma omp parallel
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp for simd
+  for (; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-warning@+3 {{expression result unused}}
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp for simd
+  for (ii + 1; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp for simd
+  for (c[ii] = 0; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// Ok to skip parenthesises.
+#pragma omp for simd
+  for (((ii)) = 0; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp for simd
+  for (int i = 0; i; i++)
+    c[i] = a[i];
+
+#pragma omp parallel
+// expected-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
+#pragma omp for simd
+  for (int i = 0; jj < kk; ii++)
+    c[i] = a[i];
+
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp for simd
+  for (int i = 0; !!i; i++)
+    c[i] = a[i];
+
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp for simd
+  for (int i = 0; i != 1; i++)
+    c[i] = a[i];
+
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp for simd
+  for (int i = 0;; i++)
+    c[i] = a[i];
+
+#pragma omp parallel
+// Ok.
+#pragma omp for simd
+  for (int i = 11; i > 10; i--)
+    c[i] = a[i];
+
+#pragma omp parallel
+// Ok.
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    c[i] = a[i];
+
+#pragma omp parallel
+// Ok.
+#pragma omp for simd
+  for (ii = 0; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ++jj)
+    c[ii] = a[jj];
+
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ++++ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// Ok but undefined behavior (in general, cannot check that incr
+// is really loop-invariant).
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii = ii + ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii = ii + 1.0f)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// Ok - step was converted to integer type.
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii = ii + (int)1.1f)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; jj = ii + 2)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-warning@+3 {{relational comparison result unused}}
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii<10; jj> kk + 2)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10;)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-warning@+3 {{expression result unused}}
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; !ii)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii ? ++ii : ++jj)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii = ii < 10)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii = ii + 0)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45))
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; (ii) < 10; ii -= 25)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; (ii < 10); ii -= 0)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; ii > 10; (ii += 0))
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; ii < 10; (ii) = (1 - 1) + (ii))
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for ((ii = 0); ii > 10; (ii -= 0))
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (ii = 0; (ii < 10); (ii -= 0))
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+2  {{defined as firstprivate}}
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be firstprivate, predetermined as linear}}
+#pragma omp for simd firstprivate(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+#pragma omp for simd linear(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+2  {{defined as private}}
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be private, predetermined as linear}}
+#pragma omp for simd private(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+// expected-note@+2  {{defined as lastprivate}}
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be lastprivate, predetermined as linear}}
+#pragma omp for simd lastprivate(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+#pragma omp parallel
+  {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be threadprivate or thread local, predetermined as linear}}
+#pragma omp for simd
+    for (sii = 0; sii < 10; sii += 1)
+      c[sii] = a[sii];
+  }
+
+#pragma omp parallel
+  {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be a variable with global storage without being explicitly marked as linear}}
+#pragma omp for simd
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] = a[globalii];
+  }
+
+#pragma omp parallel
+  {
+// expected-error@+3 {{loop iteration variable in the associated loop of 'omp for simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}}
+#pragma omp for simd collapse(2)
+    for (ii = 0; ii < 10; ii += 1)
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] += a[globalii] + ii;
+  }
+
+#pragma omp parallel
+// expected-error@+2 {{statement after '#pragma omp for simd' must be a for loop}}
+#pragma omp for simd
+  for (auto &item : a) {
+    item = item + 1;
+  }
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (unsigned i = 9; i < 10; i--) {
+    c[i] = a[i] + b[i];
+  }
+
+  int(*lb)[4] = nullptr;
+#pragma omp parallel
+#pragma omp for simd
+  for (int(*p)[4] = lb; p < lb + 8; ++p) {
+  }
+
+#pragma omp parallel
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (int a{0}; a < 10; ++a) {
+  }
+
+  return 0;
+}
+
+// Iterators allowed in openmp for-loops.
+namespace std {
+struct random_access_iterator_tag {};
+template <class Iter>
+struct iterator_traits {
+  typedef typename Iter::difference_type difference_type;
+  typedef typename Iter::iterator_category iterator_category;
+};
+template <class Iter>
+typename iterator_traits<Iter>::difference_type
+distance(Iter first, Iter last) { return first - last; }
+}
+class Iter0 {
+public:
+  Iter0() {}
+  Iter0(const Iter0 &) {}
+  Iter0 operator++() { return *this; }
+  Iter0 operator--() { return *this; }
+  bool operator<(Iter0 a) { return true; }
+};
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
+int operator-(Iter0 a, Iter0 b) { return 0; }
+class Iter1 {
+public:
+  Iter1(float f = 0.0f, double d = 0.0) {}
+  Iter1(const Iter1 &) {}
+  Iter1 operator++() { return *this; }
+  Iter1 operator--() { return *this; }
+  bool operator<(Iter1 a) { return true; }
+  bool operator>=(Iter1 a) { return false; }
+};
+class GoodIter {
+public:
+  GoodIter() {}
+  GoodIter(const GoodIter &) {}
+  GoodIter(int fst, int snd) {}
+  GoodIter &operator=(const GoodIter &that) { return *this; }
+  GoodIter &operator=(const Iter0 &that) { return *this; }
+  GoodIter &operator+=(int x) { return *this; }
+  explicit GoodIter(void *) {}
+  GoodIter operator++() { return *this; }
+  GoodIter operator--() { return *this; }
+  bool operator!() { return true; }
+  bool operator<(GoodIter a) { return true; }
+  bool operator<=(GoodIter a) { return true; }
+  bool operator>=(GoodIter a) { return false; }
+  typedef int difference_type;
+  typedef std::random_access_iterator_tag iterator_category;
+};
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
+int operator-(GoodIter a, GoodIter b) { return 0; }
+// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
+GoodIter operator-(GoodIter a) { return a; }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
+GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
+GoodIter operator+(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
+GoodIter operator-(int v, GoodIter a) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
+GoodIter operator+(int v, GoodIter a) { return GoodIter(); }
+
+int test_with_random_access_iterator() {
+  GoodIter begin, end;
+  Iter0 begin0, end0;
+#pragma omp parallel
+#pragma omp for simd
+  for (GoodIter I = begin; I < end; ++I)
+    ++I;
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp for simd
+  for (GoodIter &I = begin; I < end; ++I)
+    ++I;
+#pragma omp parallel
+#pragma omp for simd
+  for (GoodIter I = begin; I >= end; --I)
+    ++I;
+#pragma omp parallel
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (GoodIter I(begin); I < end; ++I)
+    ++I;
+#pragma omp parallel
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (GoodIter I(nullptr); I < end; ++I)
+    ++I;
+#pragma omp parallel
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (GoodIter I(0); I < end; ++I)
+    ++I;
+#pragma omp parallel
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (GoodIter I(1, 2); I < end; ++I)
+    ++I;
+#pragma omp parallel
+#pragma omp for simd
+  for (begin = GoodIter(0); begin < end; ++begin)
+    ++begin;
+#pragma omp parallel
+// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+#pragma omp for simd
+  for (begin = begin0; begin < end; ++begin)
+    ++begin;
+#pragma omp parallel
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp for simd
+  for (++begin; begin < end; ++begin)
+    ++begin;
+#pragma omp parallel
+#pragma omp for simd
+  for (begin = end; begin < end; ++begin)
+    ++begin;
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+#pragma omp for simd
+  for (GoodIter I = begin; I - I; ++I)
+    ++I;
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+#pragma omp for simd
+  for (GoodIter I = begin; begin < end; ++I)
+    ++I;
+#pragma omp parallel
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+#pragma omp for simd
+  for (GoodIter I = begin; !I; ++I)
+    ++I;
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (GoodIter I = begin; I >= end; I = I + 1)
+    ++I;
+#pragma omp parallel
+#pragma omp for simd
+  for (GoodIter I = begin; I >= end; I = I - 1)
+    ++I;
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
+#pragma omp for simd
+  for (GoodIter I = begin; I >= end; I = -I)
+    ++I;
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (GoodIter I = begin; I >= end; I = 2 + I)
+    ++I;
+#pragma omp parallel
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
+#pragma omp for simd
+  for (GoodIter I = begin; I >= end; I = 2 - I)
+    ++I;
+#pragma omp parallel
+// expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
+#pragma omp for simd
+  for (Iter0 I = begin0; I < end0; ++I)
+    ++I;
+#pragma omp parallel
+// Initializer is constructor without params.
+// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (Iter0 I; I < end0; ++I)
+    ++I;
+  Iter1 begin1, end1;
+#pragma omp parallel
+// expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+#pragma omp for simd
+  for (Iter1 I = begin1; I < end1; ++I)
+    ++I;
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (Iter1 I = begin1; I >= end1; ++I)
+    ++I;
+#pragma omp parallel
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+// Initializer is constructor with all default params.
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp for simd
+  for (Iter1 I; I < end1; ++I) {
+  }
+  return 0;
+}
+
+template <typename IT, int ST>
+class TC {
+public:
+  int dotest_lt(IT begin, IT end) {
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+    for (IT I = begin; I < end; I = I + ST) {
+      ++I;
+    }
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
+#pragma omp for simd
+    for (IT I = begin; I <= end; I += ST) {
+      ++I;
+    }
+#pragma omp parallel
+#pragma omp for simd
+    for (IT I = begin; I < end; ++I) {
+      ++I;
+    }
+  }
+
+  static IT step() {
+    return IT(ST);
+  }
+};
+template <typename IT, int ST = 0>
+int dotest_gt(IT begin, IT end) {
+#pragma omp parallel
+// expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (IT I = begin; I >= end; I = I + ST) {
+    ++I;
+  }
+#pragma omp parallel
+// expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (IT I = begin; I >= end; I += ST) {
+    ++I;
+  }
+
+#pragma omp parallel
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp for simd
+  for (IT I = begin; I >= end; ++I) {
+    ++I;
+  }
+
+#pragma omp parallel
+#pragma omp for simd
+  for (IT I = begin; I < end; I += TC<int, ST>::step()) {
+    ++I;
+  }
+}
+
+void test_with_template() {
+  GoodIter begin, end;
+  TC<GoodIter, 100> t1;
+  TC<GoodIter, -100> t2;
+  t1.dotest_lt(begin, end);
+  t2.dotest_lt(begin, end);         // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
+  dotest_gt(begin, end);            // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
+  dotest_gt<unsigned, -10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, -10>' requested here}}
+}
+
+void test_loop_break() {
+  const int N = 100;
+  float a[N], b[N], c[N];
+#pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+    for (int j = 0; j < 10; ++j) {
+      if (a[i] > b[j])
+        break; // OK in nested loop
+    }
+    switch (i) {
+    case 1:
+      b[i]++;
+      break;
+    default:
+      break;
+    }
+    if (c[i] > 10)
+      break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+
+    if (c[i] > 11)
+      break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+  }
+
+#pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; i++) {
+    for (int j = 0; j < 10; j++) {
+      c[i] = a[i] + b[i];
+      if (c[i] > 10) {
+        if (c[i] < 20) {
+          break; // OK
+        }
+      }
+    }
+  }
+}
+
+void test_loop_eh() {
+  const int N = 100;
+  float a[N], b[N], c[N];
+#pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+    try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
+      for (int j = 0; j < 10; ++j) {
+        if (a[i] > b[j])
+          throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+      }
+      throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+    }
+    catch (float f) {
+      if (f > 0.1)
+        throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+      return; // expected-error {{cannot return from OpenMP region}}
+    }
+    switch (i) {
+    case 1:
+      b[i]++;
+      break;
+    default:
+      break;
+    }
+    for (int j = 0; j < 10; j++) {
+      if (c[i] > 10)
+        throw c[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+    }
+  }
+  if (c[9] > 10)
+    throw c[9]; // OK
+
+#pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+    struct S {
+      void g() { throw 0; }
+    };
+  }
+}
+
+void test_loop_firstprivate_lastprivate() {
+  S s(4);
+#pragma omp parallel
+#pragma omp for simd lastprivate(s) firstprivate(s)
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
+void test_ordered() {
+#pragma omp parallel
+// expected-error@+1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp for simd'}}
+#pragma omp for simd ordered ordered // expected-error {{directive '#pragma omp for simd' cannot contain more than one 'ordered' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
+void test_nowait() {
+#pragma omp parallel
+#pragma omp for simd nowait nowait // expected-error {{directive '#pragma omp for simd' cannot contain more than one 'nowait' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
diff --git a/test/OpenMP/for_simd_misc_messages.c b/test/OpenMP/for_simd_misc_messages.c
new file mode 100644
index 0000000..870c37d
--- /dev/null
+++ b/test/OpenMP/for_simd_misc_messages.c
@@ -0,0 +1,659 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp for simd'}}
+#pragma omp for simd
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp for simd'}}
+#pragma omp for simd foo
+
+void test_no_clause() {
+  int i;
+#pragma omp for simd
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-error@+2 {{statement after '#pragma omp for simd' must be a for loop}}
+#pragma omp for simd
+  ++i;
+}
+
+void test_branch_protected_scope() {
+  int i = 0;
+L1:
+  ++i;
+
+  int x[24];
+
+#pragma omp parallel
+#pragma omp for simd
+  for (i = 0; i < 16; ++i) {
+    if (i == 5)
+      goto L1; // expected-error {{use of undeclared label 'L1'}}
+    else if (i == 6)
+      return; // expected-error {{cannot return from OpenMP region}}
+    else if (i == 7)
+      goto L2;
+    else if (i == 8) {
+    L2:
+      x[i]++;
+    }
+  }
+
+  if (x[0] == 0)
+    goto L2; // expected-error {{use of undeclared label 'L2'}}
+  else if (x[1] == 1)
+    goto L1;
+}
+
+void test_invalid_clause() {
+  int i;
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+#pragma omp for simd foo bar
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_non_identifiers() {
+  int i, x;
+
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+#pragma omp for simd;
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+#pragma omp for simd linear(x);
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+#pragma omp for simd private(x);
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+#pragma omp for simd, private(x);
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+extern int foo();
+void test_safelen() {
+  int i;
+// expected-error@+1 {{expected '('}}
+#pragma omp for simd safelen
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd safelen()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp for simd safelen 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(4
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(4,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(4, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd safelen(4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(4 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(4, , 4)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd safelen(4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp for simd safelen(4, 8)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp for simd safelen(2.5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp for simd safelen(foo())
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp for simd safelen(-5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp for simd safelen(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp for simd safelen(5 - 5)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_collapse() {
+  int i;
+#pragma omp parallel
+// expected-error@+1 {{expected '('}}
+#pragma omp for simd collapse
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd collapse(
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd collapse()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd collapse(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd collapse(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp for simd collapse 4)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4,
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4, )
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+// expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4 4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4, , 4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+#pragma omp for simd collapse(4)
+  for (int i1 = 0; i1 < 16; ++i1)
+    for (int i2 = 0; i2 < 16; ++i2)
+      for (int i3 = 0; i3 < 16; ++i3)
+        for (int i4 = 0; i4 < 16; ++i4)
+          foo();
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp for simd collapse(4, 8)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp for simd collapse(2.5)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp for simd collapse(foo())
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp for simd collapse(-5)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp for simd collapse(0)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp for simd collapse(5 - 5)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd collapse(2)
+  for (i = 0; i < 16; ++i)
+// expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
+    for (int j = 0; j < 16; ++j)
+// expected-error@+2 {{private variable cannot be reduction}}
+// expected-error@+1 {{OpenMP constructs may not be nested inside a simd region}}
+#pragma omp for simd reduction(+ : i, j)
+      for (int k = 0; k < 16; ++k)
+        i += j;
+}
+
+void test_linear() {
+  int i;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd linear(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd linear(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd linear(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd linear()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd linear(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp for simd linear(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{use of undeclared identifier 'x'}}
+#pragma omp for simd linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{use of undeclared identifier 'x'}}
+// expected-error@+1 {{use of undeclared identifier 'y'}}
+#pragma omp for simd linear(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{use of undeclared identifier 'x'}}
+// expected-error@+2 {{use of undeclared identifier 'y'}}
+// expected-error@+1 {{use of undeclared identifier 'z'}}
+#pragma omp for simd linear(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd linear(x :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd linear(x :, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd linear(x : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd linear(x : 2 * 2)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd linear(x : 1, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd linear(x : 1, y, z : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be linear}}
+#pragma omp for simd linear(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as private}}
+// expected-error@+1 {{private variable cannot be linear}}
+#pragma omp for simd private(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be private}}
+#pragma omp for simd linear(x) private(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-warning@+1 {{zero linear step (x and other variables in clause should probably be const)}}
+#pragma omp for simd linear(x, y : 0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be lastprivate}}
+#pragma omp for simd linear(x) lastprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-note@+2 {{defined as lastprivate}}
+// expected-error@+1 {{lastprivate variable cannot be linear}}
+#pragma omp for simd lastprivate(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_aligned() {
+  int i;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd aligned(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd aligned(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd aligned(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd aligned()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd aligned(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp for simd aligned(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{use of undeclared identifier 'x'}}
+#pragma omp for simd aligned(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{use of undeclared identifier 'x'}}
+// expected-error@+1 {{use of undeclared identifier 'y'}}
+#pragma omp for simd aligned(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{use of undeclared identifier 'x'}}
+// expected-error@+2 {{use of undeclared identifier 'y'}}
+// expected-error@+1 {{use of undeclared identifier 'z'}}
+#pragma omp for simd aligned(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int *x, y, z[25]; // expected-note 4 {{'y' defined here}}
+#pragma omp for simd aligned(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd aligned(z)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd aligned(x :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd aligned(x :, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd aligned(x : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp for simd aligned(x : 2 * 2)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd aligned(x : 1, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd aligned(x : 1, y, z : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp for simd aligned(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp for simd aligned(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as aligned}}
+// expected-error@+1 {{a variable cannot appear in more than one aligned clause}}
+#pragma omp for simd aligned(x) aligned(z, x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+3 {{defined as aligned}}
+// expected-error@+2 {{a variable cannot appear in more than one aligned clause}}
+// expected-error@+1 2 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp for simd aligned(x, y, z) aligned(y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+
+void test_private() {
+  int i;
+#pragma omp parallel
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp for simd private(
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp for simd private(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 2 {{expected expression}}
+#pragma omp for simd private(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd private()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd private(int)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected variable name}}
+#pragma omp for simd private(0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y, z;
+#pragma omp parallel
+#pragma omp for simd private(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd private(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd private(x, y, z)
+  for (i = 0; i < 16; ++i) {
+    x = y * i + z;
+  }
+}
+
+void test_lastprivate() {
+  int i;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd lastprivate(
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp for simd lastprivate(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 2 {{expected expression}}
+#pragma omp for simd lastprivate(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd lastprivate()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd lastprivate(int)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected variable name}}
+#pragma omp for simd lastprivate(0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y, z;
+#pragma omp parallel
+#pragma omp for simd lastprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd lastprivate(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd lastprivate(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_firstprivate() {
+  int i;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd firstprivate(
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp for simd firstprivate(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 2 {{expected expression}}
+#pragma omp for simd firstprivate(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd firstprivate()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp for simd firstprivate(int)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected variable name}}
+#pragma omp for simd firstprivate(0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y, z;
+#pragma omp parallel
+#pragma omp for simd lastprivate(x) firstprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd lastprivate(x, y) firstprivate(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp for simd lastprivate(x, y, z) firstprivate(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_loop_messages() {
+  float a[100], b[100], c[100];
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or pointer type}}
+#pragma omp for simd
+  for (float fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or pointer type}}
+#pragma omp for simd
+  for (double fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+}
+
diff --git a/test/OpenMP/for_simd_private_messages.cpp b/test/OpenMP/for_simd_private_messages.cpp
new file mode 100644
index 0000000..016a5ec
--- /dev/null
+++ b/test/OpenMP/for_simd_private_messages.cpp
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4(); // expected-note {{implicitly declared private here}}
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
+
+public:
+  S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(I argc, C **argv) {
+  I e(4);
+  I g(5);
+  int i;
+  int &j = i;           // expected-note {{'j' defined here}}
+#pragma omp for simd private // expected-error {{expected '(' after 'private'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(e, g)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp for simd'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;
+#pragma omp for simd private(i)
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp for simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i;           // expected-note {{'j' defined here}}
+#pragma omp for simd private // expected-error {{expected '(' after 'private'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp for simd'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int i;
+#pragma omp for simd private(i)
+    for (int k = 0; k < argc; ++k)
+      ++k;
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp for simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp for simd private(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+
+  return 0;
+}
+
diff --git a/test/OpenMP/for_simd_reduction_messages.cpp b/test/OpenMP/for_simd_reduction_messages.cpp
new file mode 100644
index 0000000..708973b
--- /dev/null
+++ b/test/OpenMP/for_simd_reduction_messages.cpp
@@ -0,0 +1,350 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+  S2 &operator+=(const S2 &arg) { return (*this); }
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+  static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
+  static const float S2sc;
+};
+const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
+S2 b;                     // expected-note 2 {{'b' defined here}}
+const S2 ba[5];           // expected-note 2 {{'ba' defined here}}
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+  S3 operator+=(const S3 &arg1) { return arg1; }
+};
+int operator+=(const S3 &arg1, const S3 &arg2) { return 5; }
+S3 c;               // expected-note 2 {{'c' defined here}}
+const S3 ca[5];     // expected-note 2 {{'ca' defined here}}
+extern const int f; // expected-note 4 {{'f' declared here}}
+class S4 {          // expected-note {{'S4' declared here}}
+  int a;
+  S4();
+  S4(const S4 &s4);
+  S4 &operator+=(const S4 &arg) { return (*this); }
+
+public:
+  S4(int v) : a(v) {}
+};
+S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {}
+  S5 &operator+=(const S5 &arg);
+
+public:
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+
+public:
+  S6() : a(6) {}
+  operator int() { return 6; }
+} o; // expected-note 2 {{'o' defined here}}
+
+S3 h, k;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class T>       // expected-note {{declared here}}
+T tmain(T argc) {        // expected-note 2 {{'argc' defined here}}
+  const T d = T();       // expected-note 4 {{'d' defined here}}
+  const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
+  T qa[5] = {T()};
+  T i;
+  T &j = i;                // expected-note 4 {{'j' defined here}}
+  S3 &p = k;               // expected-note 2 {{'p' defined here}}
+  const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
+  T &q = qa[(int)i];       // expected-note 2 {{'q' defined here}}
+  T fl;                    // expected-note {{'fl' defined here}}
+#pragma omp parallel
+#pragma omp for simd reduction // expected-error {{expected '(' after 'reduction'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(&& : argc)
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(^ : T) // expected-error {{'T' does not refer to a value}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(max : qa[1]) // expected-error 2 {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} expected-error {{a reduction variable with array type 'const float [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(k)
+#pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp for simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(fl)  // expected-note 2 {{defined as private}}
+#pragma omp for simd reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel reduction(* : fl) // expected-note 2 {{defined as reduction}}
+#pragma omp for simd reduction(+ : fl)      // expected-error 2 {{reduction variable must be shared}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;       // expected-note 2 {{'d' defined here}}
+  const int da[5] = {0}; // expected-note {{'da' defined here}}
+  int qa[5] = {0};
+  S4 e(4); // expected-note {{'e' defined here}}
+  S5 g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i;           // expected-note 2 {{'j' defined here}}
+  S3 &p = k;            // expected-note 2 {{'p' defined here}}
+  const int &r = da[i]; // expected-note {{'r' defined here}}
+  int &q = qa[i];       // expected-note {{'q' defined here}}
+  float fl;             // expected-note {{'fl' defined here}}
+#pragma omp parallel
+#pragma omp for simd reduction // expected-error {{expected '(' after 'reduction'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(~ : argc) // expected-error {{expected unqualified-id}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(&& : argc)
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(max : argv[1]) // expected-error {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(& : e, g) // expected-error {{reduction variable must have an accessible, unambiguous default constructor}} expected-error {{variable of type 'S5' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(k)
+#pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel
+#pragma omp for simd reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp for simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(fl)  // expected-note {{defined as private}}
+#pragma omp for simd reduction(+ : fl) // expected-error {{reduction variable must be shared}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}}
+#pragma omp for simd reduction(+ : fl)      // expected-error {{reduction variable must be shared}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+
+  return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
+}
diff --git a/test/OpenMP/for_simd_safelen_messages.cpp b/test/OpenMP/for_simd_safelen_messages.cpp
new file mode 100644
index 0000000..1a72964
--- /dev/null
+++ b/test/OpenMP/for_simd_safelen_messages.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N, int ST> // expected-note {{declared here}}
+T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
+  #pragma omp for simd safelen // expected-error {{expected '(' after 'safelen'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen () // expected-error {{expected expression}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+  // expected-error@+2 2 {{expression is not an integral constant expression}}
+  // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
+  #pragma omp for simd safelen (argc 
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+  #pragma omp for simd safelen (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen ((ST > 0) ? 1 + ST : 2)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+3 2 {{directive '#pragma omp for simd' cannot contain more than one 'safelen' clause}}
+  // expected-error@+2 2 {{argument to 'safelen' clause must be a positive integer value}}
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp for simd safelen (foobool(argc)), safelen (true), safelen (-5)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen (S) // expected-error {{'S' does not refer to a value}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen (4)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd safelen (N) // expected-error {{argument to 'safelen' clause must be a positive integer value}}
+  for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp for simd safelen // expected-error {{expected '(' after 'safelen'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd safelen () // expected-error {{expected expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{expression is not an integral constant expression}}
+  // expected-error@+2 2 {{directive '#pragma omp for simd' cannot contain more than one 'safelen' clause}}
+  // expected-error@+1 2 {{argument to 'safelen' clause must be a positive integer value}}
+  #pragma omp for simd safelen (foobool(argc)), safelen (true), safelen (-5) 
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd safelen (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+1 {{expression is not an integral constant expression}}
+  #pragma omp for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{statement after '#pragma omp for simd' must be a for loop}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
+  #pragma omp for simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
+  foo();
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
+  return tmain<int, char, 12, 4>(argc, argv);
+}
+
diff --git a/test/OpenMP/for_simd_schedule_messages.cpp b/test/OpenMP/for_simd_schedule_messages.cpp
new file mode 100644
index 0000000..8624359
--- /dev/null
+++ b/test/OpenMP/for_simd_schedule_messages.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N, int ST> // expected-note {{declared here}}
+T tmain(T argc, S **argv) {
+  #pragma omp for simd schedule // expected-error {{expected '(' after 'schedule'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule ( // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (auto_dynamic // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (runtime, 3)  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+  #pragma omp for simd schedule (guided argc
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{argument to 'schedule' clause must be a positive integer value}}
+  #pragma omp for simd schedule (static, ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (dynamic, 1)) // expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (guided, (ST > 0) ? 1 + ST : 2)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+2 2 {{directive '#pragma omp for simd' cannot contain more than one 'schedule' clause}}
+  // expected-error@+1 {{argument to 'schedule' clause must be a positive integer value}}
+  #pragma omp for simd schedule (static, foobool(argc)), schedule (dynamic, true), schedule (guided, -5)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (static, S) // expected-error {{'S' does not refer to a value}} expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  #pragma omp for simd schedule (guided, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (dynamic, 1)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp for simd schedule (static, N) // expected-error {{argument to 'schedule' clause must be a positive integer value}}
+  for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp for simd schedule // expected-error {{expected '(' after 'schedule'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule ( // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (auto_dynamic // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (runtime, 3)  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (guided, 4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (static, 2+2)) // expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (dynamic, foobool(1) > 0 ? 1 : 2)
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+2 2 {{directive '#pragma omp for simd' cannot contain more than one 'schedule' clause}}
+  // expected-error@+1 {{argument to 'schedule' clause must be a positive integer value}}
+  #pragma omp for simd schedule (guided, foobool(argc)), schedule (static, true), schedule (dynamic, -5)
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp for simd schedule (guided, S1) // expected-error {{'S1' does not refer to a value}} expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  #pragma omp for simd schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{statement after '#pragma omp for simd' must be a for loop}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
+  #pragma omp for simd schedule(dynamic, schedule(tmain<int, char, -1, -2>(argc, argv) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
+  return tmain<int, char, 1, 0>(argc, argv);
+}
+
diff --git a/test/OpenMP/master_ast_print.cpp b/test/OpenMP/master_ast_print.cpp
new file mode 100644
index 0000000..7ce4c10
--- /dev/null
+++ b/test/OpenMP/master_ast_print.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  static int a;
+// CHECK: static int a;
+#pragma omp parallel
+{
+#pragma omp master
+{
+  a=2;
+}
+}
+// CHECK-NEXT: #pragma omp parallel
+// CHECK-NEXT: {
+// CHECK-NEXT: #pragma omp master
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+// CHECK-NEXT: }
+  return (0);
+}
+
+#endif
diff --git a/test/OpenMP/master_messages.cpp b/test/OpenMP/master_messages.cpp
new file mode 100644
index 0000000..fbe35ac
--- /dev/null
+++ b/test/OpenMP/master_messages.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+int foo();
+
+int main() {
+  #pragma omp master
+  ;
+  #pragma omp master nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp master'}}
+  #pragma omp master unknown // expected-warning {{extra tokens at the end of '#pragma omp master' are ignored}}
+  foo();
+  {
+    #pragma omp master
+  } // expected-error {{expected statement}}
+  #pragma omp for
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
+    foo();
+  }
+  #pragma omp sections
+  {
+    foo();
+    #pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}}
+    foo();
+  }
+  #pragma omp single
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    #pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}}
+    foo();
+  }
+  #pragma omp master
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    #pragma omp master
+    foo();
+  }
+  #pragma omp for ordered
+  for (int i = 0; i < 10; ++i)
+  #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
+  {
+    foo();
+  }
+
+  return 0;
+}
+
+int foo() {
+  L1:
+    foo();
+  #pragma omp master
+  {
+    foo();
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+  }
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+  #pragma omp master
+  {
+    L2:
+    foo();
+  }
+
+  return 0;
+}
diff --git a/test/OpenMP/nesting_of_regions.cpp b/test/OpenMP/nesting_of_regions.cpp
index 2c58e0b..a948ca3 100644
--- a/test/OpenMP/nesting_of_regions.cpp
+++ b/test/OpenMP/nesting_of_regions.cpp
@@ -4,6 +4,7 @@
 
 template <class T>
 void foo() {
+  T a = T();
 // PARALLEL DIRECTIVE
 #pragma omp parallel
 #pragma omp for
@@ -14,6 +15,10 @@
   for (int i = 0; i < 10; ++i)
     ;
 #pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp parallel
 #pragma omp sections
   {
     bar();
@@ -26,15 +31,75 @@
 #pragma omp parallel
 #pragma omp single
   bar();
+
+#pragma omp parallel
+#pragma omp master
+  {
+    bar();
+  }
+#pragma omp parallel
+#pragma omp critical
+  {
+    bar();
+  }
 #pragma omp parallel
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i)
     ;
 #pragma omp parallel
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp parallel
 #pragma omp parallel sections
   {
     bar();
   }
+#pragma omp parallel
+#pragma omp task
+  {
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp barrier
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp parallel
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp parallel
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // SIMD DIRECTIVE
 #pragma omp simd
@@ -51,6 +116,12 @@
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
     for (int i = 0; i < 10; ++i)
       ;
@@ -78,17 +149,84 @@
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
     for (int i = 0; i < 10; ++i)
       ;
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
     {
       bar();
     }
   }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
 
 // FOR DIRECTIVE
 #pragma omp for
@@ -105,6 +243,12 @@
   }
 #pragma omp for
   for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -130,6 +274,21 @@
       bar();
     }
   }
+
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
 #pragma omp for
   for (int i = 0; i < 10; ++i) {
 #pragma omp parallel
@@ -155,11 +314,196 @@
   }
 #pragma omp for
   for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}}
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // OK
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target
+    ++a;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// FOR SIMD DIRECTIVE
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
 
 // SECTIONS DIRECTIVE
 #pragma omp sections
@@ -176,6 +520,12 @@
   }
 #pragma omp sections
   {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp sections
+  {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -196,14 +546,6 @@
   }
 #pragma omp sections
   {
-#pragma omp section
-    {
-#pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
-      bar();
-    }
-  }
-#pragma omp sections
-  {
 #pragma omp parallel
     {
 #pragma omp single // OK
@@ -221,23 +563,297 @@
   }
 #pragma omp sections
   {
+#pragma omp parallel
+    {
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp for // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp master // OK
+      {
+        bar();
+      }
+    }
+#pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}}
+    bar();
+  }
+#pragma omp sections
+  {
+#pragma omp parallel
+    {
+#pragma omp critical(A) // OK
+      {
+        bar();
+      }
+#pragma omp for // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp critical // OK
+      {
+        bar();
+      }
+    }
+#pragma omp critical(A) // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}
+    bar();
+  }
+#pragma omp sections
+  {
 #pragma omp parallel for
     for (int i = 0; i < 10; ++i)
       ;
   }
 #pragma omp sections
   {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp sections
+  {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp sections
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp taskyield
+  }
+#pragma omp sections
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}}
+  }
+#pragma omp sections
+  {
+#pragma omp taskwait
+  }
+#pragma omp sections
+  {
+#pragma omp flush
+  }
+#pragma omp sections
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp sections
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp sections
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp sections
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // SECTION DIRECTIVE
 #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
   {
     bar();
   }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp simd
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a section region}}
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+      bar();
+#pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
+      bar();
+#pragma omp critical
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel
+      {
+#pragma omp single // OK
+        {
+          bar();
+        }
+#pragma omp for // OK
+        for (int i = 0; i < 10; ++i)
+          ;
+#pragma omp for simd // OK
+        for (int i = 0; i < 10; ++i)
+          ;
+#pragma omp sections // OK
+        {
+          bar();
+        }
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel for
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel for simd
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel sections
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp task
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp taskyield
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}}
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp taskwait
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp flush
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp sections
+  {
+#pragma omp section
+#pragma omp target
+    ++a;
+  }
+#pragma omp sections
+  {
+#pragma omp section
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // SINGLE DIRECTIVE
 #pragma omp single
@@ -254,6 +870,12 @@
   }
 #pragma omp single
   {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp single
+  {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -267,6 +889,20 @@
   }
 #pragma omp single
   {
+#pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}}
+    {
+      bar();
+    }
+  }
+#pragma omp single
+  {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+#pragma omp single
+  {
 #pragma omp sections // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
     {
       bar();
@@ -283,6 +919,9 @@
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -297,11 +936,358 @@
   }
 #pragma omp single
   {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp single
+  {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp single
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp single
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}}
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp single
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp single
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// MASTER DIRECTIVE
+#pragma omp master
+  {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp parallel
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp master // OK, though second 'master' is redundant
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp parallel
+    {
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp for // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp sections // OK
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp master
+  {
+#pragma omp parallel for
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp parallel sections
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}}
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp master
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp master
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// CRITICAL DIRECTIVE
+#pragma omp critical
+  {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp parallel
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp master // OK, though second 'master' is redundant
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp parallel
+    {
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp for // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp sections // OK
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp parallel for
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp parallel sections
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'critical' region}}
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp critical(Tuzik)
+  {
+#pragma omp critical(grelka)
+    bar();
+  }
+#pragma omp critical(Belka) // expected-note {{previous 'critical' region starts here}}
+  {
+#pragma omp critical(Belka) // expected-error {{cannot nest 'critical' regions having the same name 'Belka'}}
+    {
+#pragma omp critical(Tuzik)
+      {
+#pragma omp parallel
+#pragma omp critical(grelka)
+        {
+          bar();
+        }
+      }
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp critical
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp critical
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // PARALLEL FOR DIRECTIVE
 #pragma omp parallel for
@@ -318,6 +1304,12 @@
   }
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -343,6 +1335,23 @@
       bar();
     }
   }
+
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp master // expected-error {{region cannot be closely nested inside 'parallel for' region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i) {
 #pragma omp parallel
@@ -354,6 +1363,9 @@
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -368,11 +1380,224 @@
   }
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}}
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp parallel for ordered
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // OK
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target
+    ++a;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// PARALLEL FOR SIMD DIRECTIVE
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+#pragma omp single
+      {
+        bar();
+      }
+#pragma omp for
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp for simd
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp sections
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
 
 // PARALLEL SECTIONS DIRECTIVE
 #pragma omp parallel sections
@@ -389,6 +1614,12 @@
   }
 #pragma omp parallel sections
   {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel sections
+  {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -417,6 +1648,22 @@
   }
 #pragma omp parallel sections
   {
+#pragma omp section
+    {
+#pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
+      bar();
+    }
+  }
+#pragma omp parallel sections
+  {
+#pragma omp section
+    {
+#pragma omp critical
+      bar();
+    }
+  }
+#pragma omp parallel sections
+  {
 #pragma omp parallel
     {
 #pragma omp single // OK
@@ -426,6 +1673,9 @@
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -440,14 +1690,669 @@
   }
 #pragma omp parallel sections
   {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel sections
+  {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp parallel sections
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp parallel sections
+  {
+#pragma omp taskyield
+  }
+#pragma omp parallel sections
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}}
+  }
+#pragma omp parallel sections
+  {
+#pragma omp taskwait
+  }
+#pragma omp parallel sections
+  {
+#pragma omp flush
+  }
+#pragma omp parallel sections
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp parallel sections
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp parallel sections
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp parallel sections
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// TASK DIRECTIVE
+#pragma omp task
+#pragma omp for // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp task
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a task region}}
+  {
+    bar();
+  }
+#pragma omp task
+#pragma omp single // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+  bar();
+#pragma omp task
+#pragma omp master // expected-error {{region cannot be closely nested inside 'task' region}}
+  bar();
+#pragma omp task
+#pragma omp critical
+  bar();
+
+#pragma omp task
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp parallel sections
+  {
+    bar();
+  }
+#pragma omp task
+#pragma omp task
+  {
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}}
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp task
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp task
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// ORDERED DIRECTIVE
+#pragma omp ordered
+  {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp ordered
+  {
+#pragma omp simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp ordered
+  {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp ordered
+  {
+#pragma omp parallel
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp ordered
+  {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp master // OK, though second 'ordered' is redundant
+    {
+      bar();
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp parallel for ordered
+    for (int j = 0; j < 10; ++j) {
+#pragma omp ordered // OK
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp parallel for simd ordered //expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
+    for (int j = 0; j < 10; ++j) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp parallel for
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp ordered
+  {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp ordered
+  {
+#pragma omp parallel sections
+    {
+      bar();
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp ordered
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp ordered
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'ordered' region}}
+    bar();
+  }
+#pragma omp ordered
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp ordered
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp ordered
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp ordered
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp ordered
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp ordered
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// ATOMIC DIRECTIVE
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    ++a;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    ++a;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    ++a;
+  }
+
+// TARGET DIRECTIVE
+#pragma omp target
+#pragma omp parallel
+  bar();
+#pragma omp target
+#pragma omp for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp sections
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target region}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp single
+  bar();
+
+#pragma omp target
+#pragma omp master
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp critical
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp parallel sections
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp task
+  {
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp barrier
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'target' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp target
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp target
+  {
+#pragma omp teams
+    ++a;
+  }
+#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
+  {
+    ++a;           // expected-note {{statement outside teams construct here}}
+#pragma omp teams  // expected-note {{nested teams construct here}}
+    ++a;
+  }
+
+// TEAMS DIRECTIVE
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel
+  bar();
+#pragma omp target
+#pragma omp teams
+#pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+  bar();
+
+#pragma omp target
+#pragma omp teams
+#pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel sections
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}}
+    ++a;
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}}
+    ++a;
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 }
 
 void foo() {
+  int a = 0;
 // PARALLEL DIRECTIVE
 #pragma omp parallel
 #pragma omp for
@@ -458,6 +2363,10 @@
   for (int i = 0; i < 10; ++i)
     ;
 #pragma omp parallel
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp parallel
 #pragma omp sections
   {
     bar();
@@ -476,14 +2385,69 @@
 #pragma omp single
   bar();
 #pragma omp parallel
+#pragma omp master
+  bar();
+#pragma omp parallel
+#pragma omp critical
+  bar();
+#pragma omp parallel
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i)
     ;
 #pragma omp parallel
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp parallel
 #pragma omp parallel sections
   {
     bar();
   }
+#pragma omp parallel
+#pragma omp task
+  {
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp barrier
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp parallel
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp parallel
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp parallel
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // SIMD DIRECTIVE
 #pragma omp simd
@@ -500,6 +2464,12 @@
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
     for (int i = 0; i < 10; ++i)
       ;
@@ -522,6 +2492,15 @@
   for (int i = 0; i < 10; ++i) {
 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
     bar();
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
@@ -531,11 +2510,64 @@
   }
 #pragma omp simd
   for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
     {
       bar();
     }
   }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
 
 // FOR DIRECTIVE
 #pragma omp for
@@ -552,6 +2584,12 @@
   }
 #pragma omp for
   for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -574,6 +2612,10 @@
   for (int i = 0; i < 10; ++i) {
 #pragma omp single // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
     bar();
+#pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
+    bar();
+#pragma omp critical
+    bar();
   }
 #pragma omp for
   for (int i = 0; i < 10; ++i) {
@@ -586,6 +2628,9 @@
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -600,11 +2645,189 @@
   }
 #pragma omp for
   for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}}
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // OK
+    bar();
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target
+    ++a;
+  }
+#pragma omp for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// FOR SIMD DIRECTIVE
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
 
 // SECTIONS DIRECTIVE
 #pragma omp sections
@@ -621,6 +2844,12 @@
   }
 #pragma omp sections
   {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp sections
+  {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -641,8 +2870,12 @@
   }
 #pragma omp sections
   {
+#pragma omp critical
+    bar();
 #pragma omp single // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
     bar();
+#pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}}
+    bar();
   }
 #pragma omp sections
   {
@@ -655,6 +2888,9 @@
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -669,17 +2905,260 @@
   }
 #pragma omp sections
   {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp sections
+  {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp sections
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp taskyield
+  }
+#pragma omp sections
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}}
+    bar();
+  }
+#pragma omp sections
+  {
+#pragma omp taskwait
+  }
+#pragma omp sections
+  {
+#pragma omp flush
+  }
+#pragma omp sections
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp sections
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp sections
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp sections
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // SECTION DIRECTIVE
 #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
   {
     bar();
   }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp simd
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a section region}}
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+      bar();
+#pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
+      bar();
+#pragma omp critical
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel
+      {
+#pragma omp single // OK
+        {
+          bar();
+        }
+#pragma omp for // OK
+        for (int i = 0; i < 10; ++i)
+          ;
+#pragma omp for simd // OK
+        for (int i = 0; i < 10; ++i)
+          ;
+#pragma omp sections // OK
+        {
+          bar();
+        }
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel for
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel for simd
+      for (int i = 0; i < 10; ++i)
+        ;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp parallel sections
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp task
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp taskyield
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}}
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp taskwait
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp flush
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+      bar();
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp atomic
+      ++a;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp target
+      ++a;
+    }
+  }
+#pragma omp sections
+  {
+#pragma omp section
+    {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+      ++a;
+    }
+  }
 
 // SINGLE DIRECTIVE
 #pragma omp single
@@ -696,6 +3175,12 @@
   }
 #pragma omp single
   {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp single
+  {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -706,6 +3191,10 @@
     {
       bar();
     }
+#pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}}
+    bar();
+#pragma omp critical
+    bar();
   }
 #pragma omp single
   {
@@ -725,6 +3214,9 @@
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -739,11 +3231,363 @@
   }
 #pragma omp single
   {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp single
+  {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp single
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp single
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}}
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp single
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp single
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp single
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// MASTER DIRECTIVE
+#pragma omp master
+  {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp parallel
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp master // OK, though second 'master' is redundant
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp parallel
+    {
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp for // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp sections // OK
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp master
+  {
+#pragma omp parallel for
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp master
+  {
+#pragma omp parallel sections
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp master
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}}
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp master
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp master
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp master
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// CRITICAL DIRECTIVE
+#pragma omp critical
+  {
+#pragma omp for // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp parallel
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp single // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp master // OK, though second 'master' is redundant
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp critical
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp parallel
+    {
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp for // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp sections // OK
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp parallel for
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp critical
+  {
+#pragma omp parallel sections
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'critical' region}}
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp critical(Belka)
+  {
+#pragma omp critical(Strelka)
+    bar();
+  }
+#pragma omp critical(Tuzik) // expected-note {{previous 'critical' region starts here}}
+  {
+#pragma omp critical(grelka) // expected-note {{previous 'critical' region starts here}}
+    {
+#pragma omp critical(Tuzik) // expected-error {{cannot nest 'critical' regions having the same name 'Tuzik'}}
+      {
+#pragma omp parallel
+#pragma omp critical(grelka) // expected-error {{cannot nest 'critical' regions having the same name 'grelka'}}
+        {
+          bar();
+        }
+      }
+    }
+  }
+#pragma omp critical
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp critical
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp critical
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp critical
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
 
 // PARALLEL FOR DIRECTIVE
 #pragma omp parallel for
@@ -760,6 +3604,13 @@
   }
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -784,6 +3635,14 @@
     {
       bar();
     }
+#pragma omp master // expected-error {{region cannot be closely nested inside 'parallel for' region}}
+    {
+      bar();
+    }
+#pragma omp critical
+    {
+      bar();
+    }
   }
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i) {
@@ -793,9 +3652,20 @@
       {
         bar();
       }
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp critical // OK
+      {
+        bar();
+      }
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -810,11 +3680,224 @@
   }
 #pragma omp parallel for
   for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}}
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp parallel for ordered
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // OK
+    bar();
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target
+    ++a;
+  }
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// PARALLEL FOR SIMD DIRECTIVE
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+#pragma omp single
+      {
+        bar();
+      }
+#pragma omp for
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp for simd
+      for (int i = 0; i < 10; ++i)
+        ;
+#pragma omp sections
+      {
+        bar();
+      }
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel for simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    {
+      bar();
+    }
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    bar();
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+    ++a;
+  }
 
 // PARALLEL SECTIONS DIRECTIVE
 #pragma omp parallel sections
@@ -831,6 +3914,12 @@
   }
 #pragma omp parallel sections
   {
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel sections
+  {
 #pragma omp parallel
     for (int i = 0; i < 10; ++i)
       ;
@@ -855,6 +3944,10 @@
     {
 #pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
       bar();
+#pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
+      bar();
+#pragma omp critical
+      bar();
     }
   }
 #pragma omp parallel sections
@@ -865,9 +3958,20 @@
       {
         bar();
       }
+#pragma omp master // OK
+      {
+        bar();
+      }
+#pragma omp critical // OK
+      {
+        bar();
+      }
 #pragma omp for // OK
       for (int i = 0; i < 10; ++i)
         ;
+#pragma omp for simd // OK
+      for (int i = 0; i < 10; ++i)
+        ;
 #pragma omp sections // OK
       {
         bar();
@@ -882,11 +3986,524 @@
   }
 #pragma omp parallel sections
   {
+#pragma omp parallel for simd
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp parallel sections
+  {
 #pragma omp parallel sections
     {
       bar();
     }
   }
+#pragma omp parallel sections
+  {
+#pragma omp task
+    {
+      bar();
+    }
+  }
+#pragma omp parallel sections
+  {
+#pragma omp taskyield
+  }
+#pragma omp parallel sections
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}}
+  }
+#pragma omp parallel sections
+  {
+#pragma omp taskwait
+  }
+#pragma omp parallel sections
+  {
+#pragma omp flush
+  }
+#pragma omp parallel sections
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp parallel sections
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp parallel sections
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp parallel sections
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// TASK DIRECTIVE
+#pragma omp task
+#pragma omp for // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp task
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a task region}}
+  {
+    bar();
+  }
+#pragma omp task
+#pragma omp single // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+  bar();
+#pragma omp task
+#pragma omp master // expected-error {{region cannot be closely nested inside 'task' region}}
+  bar();
+#pragma omp task
+#pragma omp critical
+  bar();
+#pragma omp task
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp task
+#pragma omp parallel sections
+  {
+    bar();
+  }
+#pragma omp task
+#pragma omp task
+  {
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}}
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp task
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp task
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp task
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
+
+// ATOMIC DIRECTIVE
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    for (int i = 0; i < 10; ++i)
+      ;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    {
+      bar();
+    }
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    bar();
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    ++a;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    ++a;
+  }
+#pragma omp atomic
+  // expected-error@+1 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
+  {
+#pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+    ++a;
+  }
+
+// TARGET DIRECTIVE
+#pragma omp target
+#pragma omp parallel
+  bar();
+#pragma omp target
+#pragma omp for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp sections
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target region}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp single
+  bar();
+
+#pragma omp target
+#pragma omp master
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp critical
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp parallel sections
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp task
+  {
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp taskyield
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp barrier
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp taskwait
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp flush
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'target' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp target
+  {
+#pragma omp atomic
+    ++a;
+  }
+#pragma omp target
+  {
+#pragma omp target
+    ++a;
+  }
+#pragma omp target
+  {
+#pragma omp teams
+    ++a;
+  }
+#pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
+  {
+    ++a;          // expected-note {{statement outside teams construct here}}
+#pragma omp teams // expected-note {{nested teams construct here}}
+    ++a;
+  }
+
+// TEAMS DIRECTIVE
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel
+  bar();
+#pragma omp target
+#pragma omp teams
+#pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}}
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}}
+  bar();
+
+#pragma omp target
+#pragma omp teams
+#pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    ;
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel sections
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+#pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}}
+  {
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
+    bar();
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}}
+    ++a;
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}}
+    ++a;
+  }
+#pragma omp target
+#pragma omp teams
+  {
+#pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}}
+    ++a;
+  }
   return foo<int>();
 }
 
diff --git a/test/OpenMP/ordered_ast_print.cpp b/test/OpenMP/ordered_ast_print.cpp
new file mode 100644
index 0000000..a443500
--- /dev/null
+++ b/test/OpenMP/ordered_ast_print.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+T tmain (T argc) {
+  T b = argc, c, d, e, f, g;
+  static T a;
+  #pragma omp for ordered
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered
+  {
+    a=2;
+  }
+  return (0);
+}
+
+// CHECK: static int a;
+// CHECK-NEXT: #pragma omp for ordered
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+
+// CHECK: static T a;
+// CHECK-NEXT: #pragma omp for ordered
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  static int a;
+// CHECK: static int a;
+  #pragma omp for ordered
+  for (int i =0 ; i < argc; ++i)
+  #pragma omp ordered
+  {
+    a=2;
+  }
+// CHECK-NEXT: #pragma omp for ordered
+// CHECK-NEXT: for (int i = 0; i < argc; ++i)
+// CHECK-NEXT: #pragma omp ordered
+// CHECK-NEXT: {
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: }
+  return tmain(argc);
+}
+
+#endif
diff --git a/test/OpenMP/ordered_messages.cpp b/test/OpenMP/ordered_messages.cpp
new file mode 100644
index 0000000..3f79df6
--- /dev/null
+++ b/test/OpenMP/ordered_messages.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
+
+int foo();
+
+template <class T>
+T foo() {
+  #pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+    L1:
+      foo();
+    #pragma omp ordered
+    {
+      foo();
+      goto L1; // expected-error {{use of undeclared label 'L1'}}
+    }
+  }
+  #pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    goto L2; // expected-error {{use of undeclared label 'L2'}}
+    #pragma omp ordered
+    {
+      L2:
+      foo();
+    }
+  }
+
+  return T();
+}
+
+int foo() {
+  #pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+    L1:
+      foo();
+    #pragma omp ordered
+    {
+      foo();
+      goto L1; // expected-error {{use of undeclared label 'L1'}}
+    }
+  }
+  #pragma omp for ordered
+  for (int i = 0; i < 10; ++i) {
+    foo();
+    goto L2; // expected-error {{use of undeclared label 'L2'}}
+    #pragma omp ordered
+    {
+      L2:
+      foo();
+    }
+  }
+
+  return foo<int>();
+}
diff --git a/test/OpenMP/parallel_codegen.cpp b/test/OpenMP/parallel_codegen.cpp
index d9ff5ac..e50ab43 100644
--- a/test/OpenMP/parallel_codegen.cpp
+++ b/test/OpenMP/parallel_codegen.cpp
@@ -39,7 +39,7 @@
 // CHECK:       [[ARGC_REF:%.+]] = getelementptr inbounds %struct.anon* [[AGG_CAPTURED]], i32 0, i32 0
 // CHECK-NEXT:  store i32* {{%[a-z0-9.]+}}, i32** [[ARGC_REF]]
 // CHECK-NEXT:  [[BITCAST:%.+]] = bitcast %struct.anon* [[AGG_CAPTURED]] to i8*
-// CHECK-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon*)* @__captured_stmt to void (i32*, i32*, ...)*), i8* [[BITCAST]])
+// CHECK-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon*)* @.omp_outlined. to void (i32*, i32*, ...)*), i8* [[BITCAST]])
 // CHECK-NEXT:  [[ARGV:%.+]] = load i8*** {{%[a-z0-9.]+}}
 // CHECK-NEXT:  [[RET:%.+]] = call {{[a-z]*[ ]?i32}} [[TMAIN:@.+tmain.+]](i8** [[ARGV]])
 // CHECK-NEXT:  ret i32 [[RET]]
@@ -55,13 +55,13 @@
 // CHECK-DEBUG-NEXT:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds %ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8]* [[LOC1]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]
 // CHECK-DEBUG-NEXT:  [[BITCAST:%.+]] = bitcast %struct.anon* [[AGG_CAPTURED]] to i8*
-// CHECK-DEBUG-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[LOC_2_ADDR]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon*)* @__captured_stmt to void (i32*, i32*, ...)*), i8* [[BITCAST]])
+// CHECK-DEBUG-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[LOC_2_ADDR]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon*)* @.omp_outlined. to void (i32*, i32*, ...)*), i8* [[BITCAST]])
 // CHECK-DEBUG-NEXT:  [[ARGV:%.+]] = load i8*** {{%[a-z0-9.]+}}
 // CHECK-DEBUG-NEXT:  [[RET:%.+]] = call i32 [[TMAIN:@.+tmain.+]](i8** [[ARGV]])
 // CHECK-DEBUG-NEXT:  ret i32 [[RET]]
 // CHECK-DEBUG-NEXT:  }
 
-// CHECK-LABEL: define internal void @__captured_stmt(i32* %.global_tid., i32* %.bound_tid., %struct.anon* %__context)
+// CHECK-LABEL: define internal void @.omp_outlined.(i32* %.global_tid., i32* %.bound_tid., %struct.anon* %__context)
 // CHECK:       [[CONTEXT_ADDR:%.+]] = alloca %struct.anon*
 // CHECK:       store %struct.anon* %__context, %struct.anon** [[CONTEXT_ADDR]]
 // CHECK:       [[CONTEXT_PTR:%.+]] = load %struct.anon** [[CONTEXT_ADDR]]
@@ -73,7 +73,7 @@
 // CHECK:       call void @{{.+terminate.*}}(
 // CHECK-NEXT:  unreachable
 // CHECK-NEXT:  }
-// CHECK-DEBUG-LABEL: define internal void @__captured_stmt(i32* %.global_tid., i32* %.bound_tid., %struct.anon* %__context)
+// CHECK-DEBUG-LABEL: define internal void @.omp_outlined.(i32* %.global_tid., i32* %.bound_tid., %struct.anon* %__context)
 // CHECK-DEBUG:       [[CONTEXT_ADDR:%.+]] = alloca %struct.anon*
 // CHECK-DEBUG:       store %struct.anon* %__context, %struct.anon** [[CONTEXT_ADDR]]
 // CHECK-DEBUG:       [[CONTEXT_PTR:%.+]] = load %struct.anon** [[CONTEXT_ADDR]]
@@ -96,7 +96,7 @@
 // CHECK:       [[ARGC_REF:%.+]] = getelementptr inbounds %struct.anon.0* [[AGG_CAPTURED]], i32 0, i32 0
 // CHECK-NEXT:  store i8*** {{%[a-z0-9.]+}}, i8**** [[ARGC_REF]]
 // CHECK-NEXT:  [[BITCAST:%.+]] = bitcast %struct.anon.0* [[AGG_CAPTURED]] to i8*
-// CHECK-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon.0*)* @__captured_stmt1 to void (i32*, i32*, ...)*), i8* [[BITCAST]])
+// CHECK-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon.0*)* @.omp_outlined.1 to void (i32*, i32*, ...)*), i8* [[BITCAST]])
 // CHECK-NEXT:  ret i32 0
 // CHECK-NEXT:  }
 // CHECK-DEBUG:       define linkonce_odr i32 [[TMAIN]](i8** %argc)
@@ -110,11 +110,11 @@
 // CHECK-DEBUG-NEXT:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds %ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]
 // CHECK-DEBUG-NEXT:  [[BITCAST:%.+]] = bitcast %struct.anon.0* [[AGG_CAPTURED]] to i8*
-// CHECK-DEBUG-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[LOC_2_ADDR]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon.0*)* @__captured_stmt1 to void (i32*, i32*, ...)*), i8* [[BITCAST]])
+// CHECK-DEBUG-NEXT:  call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)* @__kmpc_fork_call(%ident_t* [[LOC_2_ADDR]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, %struct.anon.0*)* @.omp_outlined.1 to void (i32*, i32*, ...)*), i8* [[BITCAST]])
 // CHECK-DEBUG-NEXT:  ret i32 0
 // CHECK-DEBUG-NEXT:  }
 
-// CHECK-LABEL: define internal void @__captured_stmt1(i32* %.global_tid., i32* %.bound_tid., %struct.anon.0* %__context)
+// CHECK-LABEL: define internal void @.omp_outlined.1(i32* %.global_tid., i32* %.bound_tid., %struct.anon.0* %__context)
 // CHECK:       [[CONTEXT_ADDR:%.+]] = alloca %struct.anon.0*
 // CHECK:       store %struct.anon.0* %__context, %struct.anon.0** [[CONTEXT_ADDR]]
 // CHECK:       [[CONTEXT_PTR:%.+]] = load %struct.anon.0** [[CONTEXT_ADDR]]
@@ -126,7 +126,7 @@
 // CHECK:       call void @{{.+terminate.*}}(
 // CHECK-NEXT:  unreachable
 // CHECK-NEXT:  }
-// CHECK-DEBUG-LABEL: define internal void @__captured_stmt1(i32* %.global_tid., i32* %.bound_tid., %struct.anon.0* %__context)
+// CHECK-DEBUG-LABEL: define internal void @.omp_outlined.1(i32* %.global_tid., i32* %.bound_tid., %struct.anon.0* %__context)
 // CHECK-DEBUG:       [[CONTEXT_ADDR:%.+]] = alloca %struct.anon.0*
 // CHECK-DEBUG:       store %struct.anon.0* %__context, %struct.anon.0** [[CONTEXT_ADDR]]
 // CHECK-DEBUG:       [[CONTEXT_PTR:%.+]] = load %struct.anon.0** [[CONTEXT_ADDR]]
diff --git a/test/OpenMP/parallel_firstprivate_codegen.cpp b/test/OpenMP/parallel_firstprivate_codegen.cpp
new file mode 100644
index 0000000..d15616d
--- /dev/null
+++ b/test/OpenMP/parallel_firstprivate_codegen.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+struct St {
+  int a, b;
+  St() : a(0), b(0) {}
+  St(const St &st) : a(st.a + st.b), b(0) {}
+  ~St() {}
+};
+
+volatile int g;
+
+template <class T>
+struct S {
+  T f;
+  S(T a) : f(a + g) {}
+  S() : f(g) {}
+  S(const S &s, St t = St()) : f(s.f + t.a) {}
+  operator T() { return T(); }
+  ~S() {}
+};
+
+// CHECK-DAG: [[S_FLOAT_TY:%.+]] = type { float }
+// CHECK-DAG: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
+// CHECK-DAG: [[ST_TY:%.+]] = type { i{{[0-9]+}}, i{{[0-9]+}} }
+// CHECK-DAG: [[CAP_MAIN_TY:%.+]] = type { [2 x i{{[0-9]+}}]*, i{{[0-9]+}}*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]* }
+// CHECK-DAG: [[CAP_TMAIN_TY:%.+]] = type { [2 x i{{[0-9]+}}]*, i{{[0-9]+}}*, [2 x [[S_INT_TY]]]*, [[S_INT_TY]]* }
+// CHECK-DAG: [[IMPLICIT_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 66, i32 0, i32 0, i8*
+
+template <typename T>
+T tmain() {
+  S<T> test;
+  T t_var = T();
+  T vec[] = {1, 2};
+  S<T> s_arr[] = {1, 2};
+  S<T> var(3);
+#pragma omp parallel firstprivate(t_var, vec, s_arr, var)
+  {
+    vec[0] = t_var;
+    s_arr[0] = var;
+  }
+  return T();
+}
+
+int main() {
+  S<float> test;
+  int t_var = 0;
+  int vec[] = {1, 2};
+  S<float> s_arr[] = {1, 2};
+  S<float> var(3);
+#pragma omp parallel firstprivate(t_var, vec, s_arr, var)
+  {
+    vec[0] = t_var;
+    s_arr[0] = var;
+  }
+  return tmain<int>();
+}
+
+// CHECK: define {{.*}}i{{[0-9]+}} @main()
+// CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
+// CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
+// CHECK: %{{.+}} = bitcast [[CAP_MAIN_TY]]*
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...)* @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[CAP_MAIN_TY]]*)* [[MAIN_MICROTASK:@.+]] to void
+// CHECK: = call {{.*}}i{{.+}} [[TMAIN_INT:@.+]]()
+// CHECK: call {{.*}} [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
+// CHECK: ret
+//
+// CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* [[GTID_ADDR:%.+]], i{{[0-9]+}}* %{{.+}}, [[CAP_MAIN_TY]]* %{{.+}})
+// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
+// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
+// CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_FLOAT_TY]]],
+// CHECK: [[VAR_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
+// CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
+// CHECK: [[T_VAR_PTR_REF:%.+]] = getelementptr inbounds [[CAP_MAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 1
+// CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}** [[T_VAR_PTR_REF]],
+// CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}* [[T_VAR_REF]],
+// CHECK: store i{{[0-9]+}} [[T_VAR_VAL]], i{{[0-9]+}}* [[T_VAR_PRIV]],
+// CHECK: [[VEC_PTR_REF:%.+]] = getelementptr inbounds [[CAP_MAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[VEC_REF:%.+]] = load [2 x i{{[0-9]+}}]** [[VEC_PTR_REF:%.+]],
+// CHECK: br label %[[VEC_PRIV_INIT:.+]]
+// CHECK: [[VEC_PRIV_INIT]]
+// CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*
+// CHECK: [[VEC_SRC:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_REF]] to i8*
+// CHECK: call void @llvm.memcpy.{{.+}}(i8* [[VEC_DEST]], i8* [[VEC_SRC]],
+// CHECK: br label %[[VEC_PRIV_INIT_END:.+]]
+// CHECK: [[VEC_PRIV_INIT_END]]
+// CHECK: [[S_ARR_REF_PTR:%.+]] = getelementptr inbounds [[CAP_MAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 2
+// CHECK: [[S_ARR_REF:%.+]] = load [2 x [[S_FLOAT_TY]]]** [[S_ARR_REF_PTR]],
+// CHECK: br label %[[S_ARR_PRIV_INIT:.+]]
+// CHECK: [[S_ARR_PRIV_INIT]]
+// CHECK: [[S_ARR_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]]* [[S_ARR_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[S_ARR_PRIV_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_FLOAT_TY]]]* [[S_ARR_PRIV]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[S_ARR_END:%.+]] = getelementptr [[S_FLOAT_TY]]* [[S_ARR_BEGIN]], i{{[0-9]+}} 2
+// CHECK: [[S_ARR_PRIV_END:%.+]] = getelementptr [[S_FLOAT_TY]]* [[S_ARR_PRIV_BEGIN]], i{{[0-9]+}} 2
+// CHECK: [[IS_EMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[S_ARR_PRIV_BEGIN]], [[S_ARR_PRIV_END]]
+// CHECK: br i1 [[IS_EMPTY]], label %[[S_ARR_BODY_DONE:.+]], label %[[S_ARR_BODY:.+]]
+// CHECK: [[S_ARR_BODY]]
+// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR:@.+]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
+// CHECK: call {{.*}} [[S_FLOAT_TY_COPY_CONSTR:@.+]]([[S_FLOAT_TY]]* {{.+}}, [[S_FLOAT_TY]]* {{.+}}, [[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: call {{.*}} [[ST_TY_DESTR:@.+]]([[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: br i1 {{.+}}, label %{{.+}}, label %[[S_ARR_BODY]]
+// CHECK: br label %[[S_ARR_PRIV_INIT_END:.+]]
+// CHECK: [[S_ARR_PRIV_INIT_END]]
+// CHECK: [[VAR_REF_PTR:%.+]] = getelementptr inbounds [[CAP_MAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 3
+// CHECK: [[VAR_REF:%.+]] = load [[S_FLOAT_TY]]** [[VAR_REF_PTR]],
+// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
+// CHECK: call {{.*}} [[S_FLOAT_TY_COPY_CONSTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]], [[S_FLOAT_TY]]* {{.*}} [[VAR_REF]], [[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: call {{.*}} [[ST_TY_DESTR]]([[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
+// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}* [[GTID_REF]]
+// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
+// CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
+// CHECK-DAG: call {{.*}} [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
+// CHECK: ret void
+
+// CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
+// CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
+// CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...)* @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[CAP_TMAIN_TY]]*)* [[TMAIN_MICROTASK:@.+]] to void
+// CHECK: call {{.*}} [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
+// CHECK: ret
+//
+// CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* [[GTID_ADDR:%.+]], i{{[0-9]+}}* %{{.+}}, [[CAP_TMAIN_TY]]* %{{.+}})
+// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
+// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
+// CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_INT_TY]]],
+// CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]],
+// CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_ADDR:%.+]],
+// CHECK: [[T_VAR_PTR_REF:%.+]] = getelementptr inbounds [[CAP_TMAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 1
+// CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}** [[T_VAR_PTR_REF]],
+// CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}* [[T_VAR_REF]],
+// CHECK: store i{{[0-9]+}} [[T_VAR_VAL]], i{{[0-9]+}}* [[T_VAR_PRIV]],
+// CHECK: [[VEC_PTR_REF:%.+]] = getelementptr inbounds [[CAP_TMAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[VEC_REF:%.+]] = load [2 x i{{[0-9]+}}]** [[VEC_PTR_REF:%.+]],
+// CHECK: br label %[[VEC_PRIV_INIT:.+]]
+// CHECK: [[VEC_PRIV_INIT]]
+// CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*
+// CHECK: [[VEC_SRC:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_REF]] to i8*
+// CHECK: call void @llvm.memcpy.{{.+}}(i8* [[VEC_DEST]], i8* [[VEC_SRC]],
+// CHECK: br label %[[VEC_PRIV_INIT_END:.+]]
+// CHECK: [[VEC_PRIV_INIT_END]]
+// CHECK: [[S_ARR_REF_PTR:%.+]] = getelementptr inbounds [[CAP_TMAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 2
+// CHECK: [[S_ARR_REF:%.+]] = load [2 x [[S_INT_TY]]]** [[S_ARR_REF_PTR]],
+// CHECK: br label %[[S_ARR_PRIV_INIT:.+]]
+// CHECK: [[S_ARR_PRIV_INIT]]
+// CHECK: [[S_ARR_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_INT_TY]]]* [[S_ARR_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[S_ARR_PRIV_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_INT_TY]]]* [[S_ARR_PRIV]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
+// CHECK: [[S_ARR_END:%.+]] = getelementptr [[S_INT_TY]]* [[S_ARR_BEGIN]], i{{[0-9]+}} 2
+// CHECK: [[S_ARR_PRIV_END:%.+]] = getelementptr [[S_INT_TY]]* [[S_ARR_PRIV_BEGIN]], i{{[0-9]+}} 2
+// CHECK: [[IS_EMPTY:%.+]] = icmp eq [[S_INT_TY]]* [[S_ARR_PRIV_BEGIN]], [[S_ARR_PRIV_END]]
+// CHECK: br i1 [[IS_EMPTY]], label %[[S_ARR_BODY_DONE:.+]], label %[[S_ARR_BODY:.+]]
+// CHECK: [[S_ARR_BODY]]
+// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
+// CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR:@.+]]([[S_INT_TY]]* {{.+}}, [[S_INT_TY]]* {{.+}}, [[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: call {{.*}} [[ST_TY_DESTR]]([[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: br i1 {{.+}}, label %{{.+}}, label %[[S_ARR_BODY]]
+// CHECK: br label %[[S_ARR_PRIV_INIT_END:.+]]
+// CHECK: [[S_ARR_PRIV_INIT_END]]
+// CHECK: [[VAR_REF_PTR:%.+]] = getelementptr inbounds [[CAP_TMAIN_TY]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 3
+// CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]** [[VAR_REF_PTR]],
+// CHECK: call {{.*}} [[ST_TY_DEFAULT_CONSTR]]([[ST_TY]]* [[ST_TY_TEMP:%.+]])
+// CHECK: call {{.*}} [[S_INT_TY_COPY_CONSTR]]([[S_INT_TY]]* [[VAR_PRIV]], [[S_INT_TY]]* {{.*}} [[VAR_REF]], [[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: call {{.*}} [[ST_TY_DESTR]]([[ST_TY]]* [[ST_TY_TEMP]])
+// CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}** [[GTID_ADDR_ADDR]]
+// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}* [[GTID_REF]]
+// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
+// CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])
+// CHECK-DAG: call {{.*}} [[S_INT_TY_DESTR]]([[S_INT_TY]]*
+// CHECK: ret void
+#endif
+
diff --git a/test/OpenMP/parallel_firstprivate_messages.cpp b/test/OpenMP/parallel_firstprivate_messages.cpp
index 9df45c6..7d1e359 100644
--- a/test/OpenMP/parallel_firstprivate_messages.cpp
+++ b/test/OpenMP/parallel_firstprivate_messages.cpp
@@ -13,7 +13,7 @@
   mutable int a;
 public:
   S2():a(0) { }
-  S2(S2 &s2):a(s2.a) { }
+  S2(const S2 &s2):a(s2.a) { }
   static float S2s;
   static const float S2sc;
 };
@@ -24,22 +24,22 @@
   int a;
 public:
   S3():a(0) { }
-  S3(S3 &s3):a(s3.a) { }
+  S3(const S3 &s3):a(s3.a) { }
 };
 const S3 c;
 const S3 ca[5];
 extern const int f;
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
   S4();
-  S4(const S4 &s4);
+  S4(const S4 &s4); // expected-note {{implicitly declared private here}}
 public:
   S4(int v):a(v) { }
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
   S5():a(0) {}
-  S5(const S5 &s5):a(s5.a) { }
+  S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
 public:
   S5(int v):a(v) { }
 };
@@ -50,8 +50,8 @@
 int main(int argc, char **argv) {
   const int d = 5;
   const int da[5] = { 0 };
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i; // expected-note {{'j' defined here}}
   #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
@@ -69,7 +69,7 @@
   #pragma omp parallel firstprivate(da)
   #pragma omp parallel firstprivate(S2::S2s)
   #pragma omp parallel firstprivate(S2::S2sc)
-  #pragma omp parallel firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+  #pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   #pragma omp parallel firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
   #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
   foo();
diff --git a/test/OpenMP/parallel_for_firstprivate_messages.cpp b/test/OpenMP/parallel_for_firstprivate_messages.cpp
index 99dd68f..b495873 100644
--- a/test/OpenMP/parallel_for_firstprivate_messages.cpp
+++ b/test/OpenMP/parallel_for_firstprivate_messages.cpp
@@ -14,7 +14,7 @@
 
 public:
   S2() : a(0) {}
-  S2(S2 &s2) : a(s2.a) {}
+  S2(const S2 &s2) : a(s2.a) {}
   static float S2s;
   static const float S2sc;
 };
@@ -27,22 +27,22 @@
 
 public:
   S3() : a(0) {}
-  S3(S3 &s3) : a(s3.a) {}
+  S3(const S3 &s3) : a(s3.a) {}
 };
 const S3 c;
 const S3 ca[5];
 extern const int f;
-class S4 { // expected-note 2 {{'S4' declared here}}
+class S4 {
   int a;
   S4();
-  S4(const S4 &s4);
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note 4 {{'S5' declared here}}
+class S5 {
   int a;
-  S5(const S5 &s5) : a(s5.a) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
 
 public:
   S5() : a(0) {}
@@ -62,8 +62,8 @@
 
 template <class I, class C>
 int foomain(int argc, char **argv) {
-  I e(4); // expected-note {{'e' defined here}}
-  C g(5); // expected-note 2 {{'g' defined here}}
+  I e(4);
+  C g(5);
   int i;
   int &j = i; // expected-note {{'j' defined here}}
 #pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
@@ -96,7 +96,7 @@
 #pragma omp parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k)
     ++k;
-#pragma omp parallel for firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (int k = 0; k < argc; ++k)
     ++k;
 #pragma omp parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
@@ -123,7 +123,7 @@
 #pragma omp parallel for firstprivate(i)
   for (int k = 0; k < argc; ++k)
     ++k;
-#pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel private(i)
@@ -140,8 +140,8 @@
 int main(int argc, char **argv) {
   const int d = 5;
   const int da[5] = {0};
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note 2 {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   S3 m;
   S6 n(2);
   int i;
@@ -201,7 +201,7 @@
 #pragma omp parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel for'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel for firstprivate(m) // OK
@@ -223,7 +223,7 @@
 #pragma omp parallel for firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel for lastprivate(n) firstprivate(n) // OK
diff --git a/test/OpenMP/parallel_for_loop_messages.cpp b/test/OpenMP/parallel_for_loop_messages.cpp
index f029ef4..c329997 100644
--- a/test/OpenMP/parallel_for_loop_messages.cpp
+++ b/test/OpenMP/parallel_for_loop_messages.cpp
@@ -11,6 +11,7 @@
 
 static int sii;
 #pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+static int globalii;
 
 int test_iteration_spaces() {
   const int N = 100;
@@ -263,6 +264,21 @@
       c[sii] = a[sii];
   }
 
+  {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be a variable with global storage without being explicitly marked as private}}
+#pragma omp parallel for
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] = a[globalii];
+  }
+
+  {
+// expected-error@+3 {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be a variable with global storage without being explicitly marked as private}}
+#pragma omp parallel for collapse(2)
+    for (ii = 0; ii < 10; ii += 1)
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] += a[globalii] + ii;
+  }
+
 // expected-error@+2 {{statement after '#pragma omp parallel for' must be a for loop}}
 #pragma omp parallel for
   for (auto &item : a) {
@@ -309,6 +325,8 @@
   Iter0 operator--() { return *this; }
   bool operator<(Iter0 a) { return true; }
 };
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
 int operator-(Iter0 a, Iter0 b) { return 0; }
 class Iter1 {
 public:
@@ -327,6 +345,7 @@
   GoodIter &operator=(const GoodIter &that) { return *this; }
   GoodIter &operator=(const Iter0 &that) { return *this; }
   GoodIter &operator+=(int x) { return *this; }
+  GoodIter &operator-=(int x) { return *this; }
   explicit GoodIter(void *) {}
   GoodIter operator++() { return *this; }
   GoodIter operator--() { return *this; }
@@ -337,11 +356,20 @@
   typedef int difference_type;
   typedef std::random_access_iterator_tag iterator_category;
 };
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
 int operator-(GoodIter a, GoodIter b) { return 0; }
+// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
 GoodIter operator-(GoodIter a) { return a; }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
 GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
 GoodIter operator+(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
 GoodIter operator-(int v, GoodIter a) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
 GoodIter operator+(int v, GoodIter a) { return GoodIter(); }
 
 int test_with_random_access_iterator() {
@@ -376,6 +404,8 @@
 #pragma omp parallel for
   for (begin = GoodIter(0); begin < end; ++begin)
     ++begin;
+// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 #pragma omp parallel for
   for (begin = begin0; begin < end; ++begin)
     ++begin;
@@ -419,15 +449,19 @@
 #pragma omp parallel for
   for (GoodIter I = begin; I >= end; I = 2 - I)
     ++I;
+// expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
 #pragma omp parallel for
   for (Iter0 I = begin0; I < end0; ++I)
     ++I;
 // Initializer is constructor without params.
+// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
 #pragma omp parallel for
   for (Iter0 I; I < end0; ++I)
     ++I;
   Iter1 begin1, end1;
+// expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 #pragma omp parallel for
   for (Iter1 I = begin1; I < end1; ++I)
     ++I;
@@ -436,6 +470,8 @@
 #pragma omp parallel for
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
 // Initializer is constructor with all default params.
 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
 #pragma omp parallel for
diff --git a/test/OpenMP/parallel_for_messages.cpp b/test/OpenMP/parallel_for_messages.cpp
index c9f4df4..e4ea0d5 100644
--- a/test/OpenMP/parallel_for_messages.cpp
+++ b/test/OpenMP/parallel_for_messages.cpp
@@ -6,65 +6,81 @@
 #pragma omp parallel for // expected-error {{unexpected OpenMP directive '#pragma omp parallel for'}}
 
 int main(int argc, char **argv) {
-  #pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for [ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for ] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for ) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for
-  for(int i = 0; i < argc; ++i) foo();
-  // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
-  #pragma omp parallel for unknown()
-  for(int i = 0; i < argc; ++i) foo();
-  L1:
-    for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for
-  for(int i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for
-    for(int i = 0; i < argc; ++i)
-  {
+#pragma omp parallel for { // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for] // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for } // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for
+  for (int i = 0; i < argc; ++i)
+    foo();
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
+#pragma omp parallel for unknown()
+  for (int i = 0; i < argc; ++i)
+    foo();
+L1:
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for
+  for (int i = 0; i < argc; ++i) {
     goto L1; // expected-error {{use of undeclared label 'L1'}}
     argc++;
   }
 
   for (int i = 0; i < 10; ++i) {
-    switch(argc) {
-     case (0):
-      #pragma omp parallel for
-      for(int i = 0; i < argc; ++i)
-      {
+    switch (argc) {
+    case (0):
+#pragma omp parallel for
+      for (int i = 0; i < argc; ++i) {
         foo();
         break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
         continue;
       }
-      default:
-       break;
+    default:
+      break;
     }
   }
-  #pragma omp parallel for default(none)
+#pragma omp parallel for default(none)
   for (int i = 0; i < 10; ++i)
-  ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+    ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
   goto L2; // expected-error {{use of undeclared label 'L2'}}
-  #pragma omp parallel for
-  for(int i = 0; i < argc; ++i) L2:foo();
-  #pragma omp parallel for
-  for(int i = 0; i < argc; ++i)
-  {
+#pragma omp parallel for
+  for (int i = 0; i < argc; ++i)
+  L2:
+  foo();
+#pragma omp parallel for
+  for (int i = 0; i < argc; ++i) {
     return 1; // expected-error {{cannot return from OpenMP region}}
   }
 
   [[]] // expected-error {{an attribute list cannot appear here}}
-  #pragma omp parallel for
-  for (int n = 0; n < 100; ++n) {}
+#pragma omp parallel for
+      for (int n = 0; n < 100; ++n) {
+  }
 
   return 0;
 }
 
+void test_ordered() {
+#pragma omp parallel for ordered ordered // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'ordered' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
diff --git a/test/OpenMP/parallel_for_misc_messages.c b/test/OpenMP/parallel_for_misc_messages.c
index b236a61..f07a0f2 100644
--- a/test/OpenMP/parallel_for_misc_messages.c
+++ b/test/OpenMP/parallel_for_misc_messages.c
@@ -165,6 +165,17 @@
 #pragma omp parallel for collapse(5 - 5)
   for (i = 0; i < 16; ++i)
     ;
+// expected-note@+1 {{defined as firstprivate}}
+#pragma omp parallel for collapse(2) firstprivate(i)
+  for (i = 0; i < 16; ++i)
+// expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
+    for (int j = 0; j < 16; ++j)
+// expected-error@+3 {{reduction variable must be shared}}
+// expected-error@+2 {{private variable cannot be reduction}}
+// expected-error@+1 {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+#pragma omp for reduction(+ : i, j)
+      for (int k = 0; k < 16; ++k)
+        i += j;
 }
 
 void test_private() {
diff --git a/test/OpenMP/parallel_for_private_messages.cpp b/test/OpenMP/parallel_for_private_messages.cpp
index 7366fe8..31b8458 100644
--- a/test/OpenMP/parallel_for_private_messages.cpp
+++ b/test/OpenMP/parallel_for_private_messages.cpp
@@ -24,16 +24,16 @@
   S3() : a(0) {}
 };
 const S3 ca[5];
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5() : a(0) {}
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
 
 public:
   S5(int v) : a(v) {}
@@ -109,8 +109,8 @@
 }
 
 int main(int argc, char **argv) {
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i;           // expected-note {{'j' defined here}}
 #pragma omp parallel for private // expected-error {{expected '(' after 'private'}}
@@ -143,7 +143,7 @@
 #pragma omp parallel for private(argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k)
     ++k;
-#pragma omp parallel for private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+#pragma omp parallel for private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (int k = 0; k < argc; ++k)
     ++k;
 #pragma omp parallel for private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
diff --git a/test/OpenMP/parallel_for_simd_aligned_messages.cpp b/test/OpenMP/parallel_for_simd_aligned_messages.cpp
new file mode 100644
index 0000000..ea4ec21
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_aligned_messages.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp=libiomp5 %s
+
+struct B {
+  static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
+  static constexpr int bfoo() { return 8; }
+};
+namespace X {
+  B x; // expected-note {{'x' defined here}}
+};
+constexpr int bfoo() { return 4; }
+
+int **z;
+const int C1 = 1;
+const int C2 = 2;
+void test_aligned_colons(int *&rp)
+{
+  int *B = 0;
+  #pragma omp parallel for simd aligned(B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
+  #pragma omp parallel for simd aligned(B::ib:B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd aligned(B:B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
+  #pragma omp parallel for simd aligned(z:B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd aligned(B:B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}}
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
+  #pragma omp parallel for simd aligned(X::x : ::z)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
+  #pragma omp parallel for simd aligned(B,rp,::z: X::x)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd aligned(::z)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{expected variable name}}
+  #pragma omp parallel for simd aligned(B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+  #pragma omp parallel for simd aligned(B::ib,B:C1+C2)
+  for (int i = 0; i < 10; ++i) ;
+}
+
+// expected-note@+1 {{'num' defined here}}
+template<int L, class T, class N> T test_template(T* arr, N num) {
+  N i;
+  T sum = (T)0;
+  T ind2 = - num * L;
+  // Negative number is passed as L.
+  // expected-error@+1 {{argument to 'aligned' clause must be a positive integer value}}
+  #pragma omp parallel for simd aligned(arr:L)
+  for (i = 0; i < num; ++i) {
+    T cur = arr[(int)ind2];
+    ind2 += L;
+    sum += cur;
+  }
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp parallel for simd aligned(num:4)
+  for (i = 0; i < num; ++i);
+  return T();
+}
+
+template<int LEN> int test_warn() {
+  int *ind2 = 0;
+  // expected-error@+1 {{argument to 'aligned' clause must be a positive integer value}}
+  #pragma omp parallel for simd aligned(ind2:LEN)
+  for (int i = 0; i < 100; i++) {
+    ind2 += LEN;
+  }
+  return 0;
+}
+
+struct S1; // expected-note 2 {{declared here}}
+extern S1 a; // expected-note {{'a' declared here}}
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+};
+const S2 b; // expected-note 1 {{'b' defined here}}
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4();
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h; // expected-note 2 {{'h' defined here}}
+#pragma omp threadprivate(h)
+
+template<class I, class C> int foomain(I argc, C **argv) {
+  I e(argc);
+  I g(argc);
+  int i; // expected-note {{declared here}} expected-note {{'i' defined here}}
+  // expected-note@+2 {{declared here}}
+  // expected-note@+1 {{reference to 'i' is not a constant expression}}
+  int &j = i;
+  #pragma omp parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned () // expected-error {{expected expression}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned(e, g)
+  for (I k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
+  #pragma omp parallel for simd aligned(h)
+  for (I k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp parallel for simd aligned(i)
+  for (I k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel
+  {
+    int *v = 0;
+    I i;
+    #pragma omp parallel for simd aligned(v:16)
+    for (I k = 0; k < argc; ++k) { i = k; v += 2; }
+  }
+  float *f;
+  #pragma omp parallel for simd aligned(f)
+  for (I k = 0; k < argc; ++k) ++k;
+  int v = 0;
+  // expected-note@+2 {{initializer of 'j' is not a constant expression}}
+  // expected-error@+1 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd aligned(f:j)
+  for (I k = 0; k < argc; ++k) { ++k; v += j; }
+  #pragma omp parallel for simd aligned(f)
+  for (I k = 0; k < argc; ++k) ++k;
+  return 0;
+}
+
+// expected-note@+1 2 {{'argc' defined here}}
+int main(int argc, char **argv) {
+  double darr[100];
+  // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
+  test_template<-4>(darr, 4);
+  test_warn<4>(); // ok
+  // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
+  test_warn<0>();
+
+  int i;
+  int &j = i;
+  #pragma omp parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned () // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
+  #pragma omp parallel for simd aligned (argc)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}}
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}}
+  #pragma omp parallel for simd aligned (a, b) 
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
+  #pragma omp parallel for simd aligned(h)
+  for (int k = 0; k < argc; ++k) ++k;
+  int *pargc = &argc;
+  foomain<int*,char>(pargc,argv);
+  return 0;
+}
+
diff --git a/test/OpenMP/parallel_for_simd_ast_print.cpp b/test/OpenMP/parallel_for_simd_ast_print.cpp
new file mode 100644
index 0000000..4192695
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_ast_print.cpp
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+int g_ind = 1;
+template<class T, class N> T reduct(T* arr, N num) {
+  N i;
+  N ind;
+  N myind;
+  T sum = (T)0;
+// CHECK: T sum = (T)0;
+#pragma omp parallel for simd private(myind, g_ind), linear(ind), aligned(arr)
+// CHECK-NEXT: #pragma omp parallel for simd private(myind,g_ind) linear(ind) aligned(arr)
+  for (i = 0; i < num; ++i) {
+    myind = ind;
+    T cur = arr[myind];
+    ind += g_ind;
+    sum += cur;
+  }
+}
+
+template<class T> struct S {
+  S(const T &a)
+    :m_a(a)
+  {}
+  T result(T *v) const {
+    T res;
+    T val;
+    T lin = 0;
+// CHECK: T res;
+// CHECK: T val;
+// CHECK: T lin = 0;
+    #pragma omp parallel for simd private(val)  safelen(7) linear(lin : -5) lastprivate(res)
+// CHECK-NEXT: #pragma omp parallel for simd private(val) safelen(7) linear(lin: -5) lastprivate(res)
+    for (T i = 7; i < m_a; ++i) {
+      val = v[i-7] + m_a;
+      res = val;
+      lin -= 5;
+    }
+    const T clen = 3;
+// CHECK: T clen = 3;
+    #pragma omp parallel for simd safelen(clen-1)
+// CHECK-NEXT: #pragma omp parallel for simd safelen(clen - 1)
+    for(T i = clen+2; i < 20; ++i) {
+// CHECK-NEXT: for (T i = clen + 2; i < 20; ++i) {
+      v[i] = v[v-clen] + 1;
+// CHECK-NEXT: v[i] = v[v - clen] + 1;
+    }
+// CHECK-NEXT: }
+    return res;
+  }
+  ~S()
+  {}
+  T m_a;
+};
+
+template<int LEN> struct S2 {
+  static void func(int n, float *a, float *b, float *c) {
+    int k1 = 0, k2 = 0;
+#pragma omp parallel for simd safelen(LEN) linear(k1,k2:LEN) aligned(a:LEN)
+    for(int i = 0; i < n; i++) {
+      c[i] = a[i] + b[i];
+      c[k1] = a[k1] + b[k1];
+      c[k2] = a[k2] + b[k2];
+      k1 = k1 + LEN;
+      k2 = k2 + LEN;
+    }
+  }
+};
+
+// S2<4>::func is called below in main.
+// CHECK: template <int LEN = 4> struct S2 {
+// CHECK-NEXT: static void func(int n, float *a, float *b, float *c)     {
+// CHECK-NEXT:   int k1 = 0, k2 = 0;
+// CHECK-NEXT: #pragma omp parallel for simd safelen(4) linear(k1,k2: 4) aligned(a: 4)
+// CHECK-NEXT:   for (int i = 0; i < n; i++) {
+// CHECK-NEXT:     c[i] = a[i] + b[i];
+// CHECK-NEXT:     c[k1] = a[k1] + b[k1];
+// CHECK-NEXT:     c[k2] = a[k2] + b[k2];
+// CHECK-NEXT:     k1 = k1 + 4;
+// CHECK-NEXT:     k2 = k2 + 4;
+// CHECK-NEXT:   }
+// CHECK-NEXT: }
+
+int main (int argc, char **argv) {
+  int b = argc, c, d, e, f, g;
+  int k1=0,k2=0;
+  static int *a;
+// CHECK: static int *a;
+#pragma omp parallel for simd
+// CHECK-NEXT: #pragma omp parallel for simd
+  for (int i=0; i < 2; ++i)*a=2;
+// CHECK-NEXT: for (int i = 0; i < 2; ++i)
+// CHECK-NEXT: *a = 2;
+#pragma omp  parallel
+#pragma omp parallel for simd private(argc, b),lastprivate(d,f) collapse(2) aligned(a : 4) ,firstprivate( g )
+  for (int i = 0; i < 10; ++i)
+  for (int j = 0; j < 10; ++j) {foo(); k1 += 8; k2 += 8;}
+// CHECK-NEXT: #pragma omp parallel
+// CHECK-NEXT: #pragma omp parallel for simd private(argc,b) lastprivate(d,f) collapse(2) aligned(a: 4) firstprivate(g)
+// CHECK-NEXT: for (int i = 0; i < 10; ++i)
+// CHECK-NEXT: for (int j = 0; j < 10; ++j) {
+// CHECK-NEXT: foo();
+// CHECK-NEXT: k1 += 8;
+// CHECK-NEXT: k2 += 8;
+// CHECK-NEXT: }
+  for (int i = 0; i < 10; ++i)foo();
+// CHECK-NEXT: for (int i = 0; i < 10; ++i)
+// CHECK-NEXT: foo();
+  const int CLEN = 4;
+// CHECK-NEXT: const int CLEN = 4;
+  #pragma omp parallel for simd aligned(a:CLEN) linear(a:CLEN) safelen(CLEN) collapse( 1 )
+// CHECK-NEXT: #pragma omp parallel for simd aligned(a: CLEN) linear(a: CLEN) safelen(CLEN) collapse(1)
+  for (int i = 0; i < 10; ++i)foo();
+// CHECK-NEXT: for (int i = 0; i < 10; ++i)
+// CHECK-NEXT: foo();
+
+  float arr[16];
+  S2<4>::func(0,arr,arr,arr);
+  return (0);
+}
+
+#endif
diff --git a/test/OpenMP/parallel_for_simd_collapse_messages.cpp b/test/OpenMP/parallel_for_simd_collapse_messages.cpp
new file mode 100644
index 0000000..b829497
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_collapse_messages.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N, int ST> // expected-note {{declared here}}
+T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
+  #pragma omp parallel for simd collapse // expected-error {{expected '(' after 'collapse'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse () // expected-error {{expected expression}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+  // expected-error@+2 2 {{expression is not an integral constant expression}}
+  // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
+  #pragma omp parallel for simd collapse (argc 
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{argument to 'collapse' clause must be a positive integer value}}
+  #pragma omp parallel for simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp parallel for simd', but found only 1}}
+  // expected-error@+3 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'collapse' clause}}
+  // expected-error@+2 2 {{argument to 'collapse' clause must be a positive integer value}}
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd collapse (foobool(argc)), collapse (true), collapse (-5)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse (S) // expected-error {{'S' does not refer to a value}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse (1)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse (N) // expected-error {{argument to 'collapse' clause must be a positive integer value}}
+  for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
+  foo(); // expected-error {{expected 2 for loops after '#pragma omp parallel for simd'}}
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp parallel for simd collapse // expected-error {{expected '(' after 'collapse'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd collapse () // expected-error {{expected expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+  #pragma omp parallel for simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}  expected-note {{as specified in 'collapse' clause}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+  #pragma omp parallel for simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{expression is not an integral constant expression}}
+  // expected-error@+2 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'collapse' clause}}
+  // expected-error@+1 2 {{argument to 'collapse' clause must be a positive integer value}}
+  #pragma omp parallel for simd collapse (foobool(argc)), collapse (true), collapse (-5) 
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+1 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{statement after '#pragma omp parallel for simd' must be a for loop}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
+  #pragma omp parallel for simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
+  foo();
+  #pragma omp parallel for simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
+  foo(); // expected-error {{expected 2 for loops after '#pragma omp parallel for simd'}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
+  return tmain<int, char, 1, 0>(argc, argv);
+}
+
diff --git a/test/OpenMP/parallel_for_simd_copyin_messages.cpp b/test/OpenMP/parallel_for_simd_copyin_messages.cpp
new file mode 100644
index 0000000..e0b7e63
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_copyin_messages.cpp
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2 &operator=(S2 &s2) { return *this; }
+};
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3 &operator=(S3 &s3) { return *this; }
+};
+class S4 { // expected-note {{'S4' declared here}}
+  int a;
+  S4();
+  S4 &operator=(const S4 &s4);
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 { // expected-note {{'S5' declared here}}
+  int a;
+  S5() : a(0) {}
+  S5 &operator=(const S5 &s5) { return *this; }
+
+public:
+  S5(int v) : a(v) {}
+};
+template <class T>
+class ST {
+public:
+  static T s;
+};
+
+S2 k;
+S3 h;
+S4 l(3); // expected-note {{'l' defined here}}
+S5 m(4); // expected-note {{'m' defined here}}
+#pragma omp threadprivate(h, k, l, m)
+
+int main(int argc, char **argv) {
+  int i;
+#pragma omp parallel for simd copyin // expected-error {{expected '(' after 'copyin'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin() // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(l) // expected-error {{copyin variable must have an accessible, unambiguous copy assignment operator}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(argv[1]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(i) // expected-error {{copyin variable must be threadprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(m) // expected-error {{copyin variable must have an accessible, unambiguous copy assignment operator}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd copyin(ST < int > ::s) // expected-error {{copyin variable must be threadprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+
+  return 0;
+}
diff --git a/test/OpenMP/parallel_for_simd_default_messages.cpp b/test/OpenMP/parallel_for_simd_default_messages.cpp
new file mode 100644
index 0000000..6675029
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_default_messages.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo();
+
+int main(int argc, char **argv) {
+  int i;
+#pragma omp parallel for simd default // expected-error {{expected '(' after 'default'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+    foo();
+#pragma omp parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'default' clause}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+
+#pragma omp parallel for simd default(none)
+  for (i = 0; i < argc; ++i)  // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+    foo();
+
+#pragma omp parallel default(none)
+#pragma omp parallel for simd default(shared)
+  for (i = 0; i < argc; ++i)
+    foo();
+
+  return 0;
+}
diff --git a/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp b/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
new file mode 100644
index 0000000..876d422
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
@@ -0,0 +1,250 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(const S2 &s2) : a(s2.a) {}
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+  S3 &operator=(const S3 &s3);
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
+
+public:
+  S5() : a(0) {}
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+  S6() : a(0) {}
+
+public:
+  S6(const S6 &s6) : a(s6.a) {}
+  S6(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(int argc, char **argv) {
+  I e(4);
+  C g(5);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd linear(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+  {
+    int v = 0;
+    int i;
+#pragma omp parallel for simd firstprivate(i)
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel for simd firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd firstprivate(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel private(i)
+#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
+    foo();
+#pragma omp parallel reduction(+ : i)
+#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
+    foo();
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;
+  const int da[5] = {0};
+  S4 e(4);
+  S5 g(5);
+  S3 m;
+  S6 n(2);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp parallel for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate() // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(argc)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(ba) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(ca) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(da) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+  int xa;
+#pragma omp parallel for simd firstprivate(xa) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(S2::S2s) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(S2::S2sc) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd safelen(5)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(m) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
+  for (i = 0; i < argc; ++i)    // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
+    foo();
+#pragma omp parallel for simd firstprivate(xa) // OK: may be firstprivate
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(n) firstprivate(n) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;
+#pragma omp parallel for simd firstprivate(i)
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel private(i)
+#pragma omp parallel for simd firstprivate(i) // expected-note {{defined as firstprivate}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
+    foo();
+#pragma omp parallel reduction(+ : i)
+#pragma omp parallel for simd firstprivate(i)  // expected-note {{defined as firstprivate}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
+    foo();
+
+  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
+}
diff --git a/test/OpenMP/parallel_for_simd_if_messages.cpp b/test/OpenMP/parallel_for_simd_if_messages.cpp
new file mode 100644
index 0000000..b91dd18
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_if_messages.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, class S> // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  T i;
+  #pragma omp parallel for simd if // expected-error {{expected '(' after 'if'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if () // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc > 0 ? argv[1] : argv[2])
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'if' clause}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (S) // expected-error {{'S' does not refer to a value}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if(argc)
+  for (i = 0; i < argc; ++i) foo();
+
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp parallel for simd if // expected-error {{expected '(' after 'if'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if () // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc > 0 ? argv[1] : argv[2])
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'if' clause}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+
+  return tmain(argc, argv);
+}
diff --git a/test/OpenMP/parallel_for_simd_lastprivate_messages.cpp b/test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
new file mode 100644
index 0000000..b620c7f
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_lastprivate_messages.cpp
@@ -0,0 +1,226 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+  static float S2s; // expected-note {{static data member is predetermined as shared}}
+  static const float S2sc;
+};
+const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
+const S2 b;
+const S2 ba[5];
+class S3 { // expected-note 2 {{'S3' declared here}}
+  int a;
+  S3 &operator=(const S3 &s3);
+
+public:
+  S3() : a(0) {}
+  S3(S3 &s3) : a(s3.a) {}
+};
+const S3 c;         // expected-note {{global variable is predetermined as shared}}
+const S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
+extern const int f; // expected-note {{global variable is predetermined as shared}}
+class S4 {          // expected-note 3 {{'S4' declared here}}
+  int a;
+  S4();
+  S4(const S4 &s4);
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 { // expected-note {{'S5' declared here}}
+  int a;
+  S5() : a(0) {}
+
+public:
+  S5(const S5 &s5) : a(s5.a) {}
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+  S6() : a(0) {}
+
+public:
+  S6(const S6 &s6) : a(s6.a) {}
+  S6(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(int argc, char **argv) {
+  I e(4); // expected-note {{'e' defined here}}
+  I g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i;                        // expected-note {{'j' defined here}}
+#pragma omp parallel for simd lastprivate // expected-error {{expected '(' after 'lastprivate'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd linear(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;
+#pragma omp parallel for simd lastprivate(i)
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel for simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd lastprivate(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
+  const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
+  S4 e(4);               // expected-note {{'e' defined here}}
+  S5 g(5);               // expected-note {{'g' defined here}}
+  S3 m;                  // expected-note 2 {{'m' defined here}}
+  S6 n(2);
+  int i;
+  int &j = i;                        // expected-note {{'j' defined here}}
+#pragma omp parallel for simd lastprivate // expected-error {{expected '(' after 'lastprivate'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate() // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(argc)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(argv[1]) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(2 * 2) // expected-error {{expected variable name}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(ba)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+  int xa;
+#pragma omp parallel for simd lastprivate(xa) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd safelen(5)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(i) // expected-note {{defined as lastprivate}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be lastprivate, predetermined as linear}}
+    foo();
+#pragma omp parallel private(xa)
+#pragma omp parallel for simd lastprivate(xa)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel reduction(+ : xa)
+#pragma omp parallel for simd lastprivate(xa)
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd lastprivate(n) firstprivate(n) // OK
+  for (i = 0; i < argc; ++i)
+    foo();
+  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
+}
diff --git a/test/OpenMP/parallel_for_simd_linear_messages.cpp b/test/OpenMP/parallel_for_simd_linear_messages.cpp
new file mode 100644
index 0000000..3918de2
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_linear_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+namespace X {
+  int x;
+};
+
+struct B {
+  static int ib; // expected-note {{'B::ib' declared here}}
+  static int bfoo() { return 8; }
+};
+
+int bfoo() { return 4; }
+
+int z;
+const int C1 = 1;
+const int C2 = 2;
+void test_linear_colons()
+{
+  int B = 0;
+  #pragma omp parallel for simd linear(B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
+  #pragma omp parallel for simd linear(B::ib:B:bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
+  #pragma omp parallel for simd linear(B:ib)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
+  #pragma omp parallel for simd linear(z:B:ib)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd linear(B:B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd linear(X::x : ::z)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd linear(B,::z, X::x)
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd linear(::z)
+  for (int i = 0; i < 10; ++i) ;
+  // expected-error@+1 {{expected variable name}}
+  #pragma omp parallel for simd linear(B::bfoo())
+  for (int i = 0; i < 10; ++i) ;
+  #pragma omp parallel for simd linear(B::ib,B:C1+C2)
+  for (int i = 0; i < 10; ++i) ;
+}
+
+template<int L, class T, class N> T test_template(T* arr, N num) {
+  N i;
+  T sum = (T)0;
+  T ind2 = - num * L; // expected-note {{'ind2' defined here}}
+  // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
+#pragma omp parallel for simd linear(ind2:L)
+  for (i = 0; i < num; ++i) {
+    T cur = arr[(int)ind2];
+    ind2 += L;
+    sum += cur;
+  }
+  return T();
+}
+
+template<int LEN> int test_warn() {
+  int ind2 = 0;
+  // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
+  #pragma omp parallel for simd linear(ind2:LEN)
+  for (int i = 0; i < 100; i++) {
+    ind2 += LEN;
+  }
+  return ind2;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+};
+const S2 b; // expected-note 2 {{'b' defined here}}
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4();
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template<class I, class C> int foomain(I argc, C **argv) {
+  I e(4);
+  I g(5);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+  #pragma omp parallel for simd linear // expected-error {{expected '(' after 'linear'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear () // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc : 5)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{linear variable with incomplete type 'S1'}}
+  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  #pragma omp parallel for simd linear (a, b:B::ib)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear(e, g)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear(i)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel
+  {
+    int v = 0;
+    int i;
+    #pragma omp parallel for simd linear(v:i)
+    for (int k = 0; k < argc; ++k) { i = k; v += i; }
+  }
+  #pragma omp parallel for simd linear(j) // expected-error {{arguments of OpenMP clause 'linear' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k) ++k;
+  int v = 0;
+  #pragma omp parallel for simd linear(v:j)
+  for (int k = 0; k < argc; ++k) { ++k; v += j; }
+  #pragma omp parallel for simd linear(i)
+  for (int k = 0; k < argc; ++k) ++k;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  double darr[100];
+  // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
+  test_template<-4>(darr, 4);
+  // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
+  test_warn<0>();
+
+  S4 e(4); // expected-note {{'e' defined here}}
+  S5 g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+  #pragma omp parallel for simd linear // expected-error {{expected '(' after 'linear'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear () // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argc)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{linear variable with incomplete type 'S1'}}
+  // expected-error@+1 {{const-qualified variable cannot be linear}}
+  #pragma omp parallel for simd linear (a, b) 
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear (argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k) ++k;
+  // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
+  // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
+  #pragma omp parallel for simd linear(e, g)
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel
+  {
+    int i;
+    #pragma omp parallel for simd linear(i)
+    for (int k = 0; k < argc; ++k) ++k;
+    #pragma omp parallel for simd linear(i : 4)
+    for (int k = 0; k < argc; ++k) { ++k; i += 4; }
+  }
+  #pragma omp parallel for simd linear(j) // expected-error {{arguments of OpenMP clause 'linear' cannot be of reference type 'int &'}}
+  for (int k = 0; k < argc; ++k) ++k;
+  #pragma omp parallel for simd linear(i)
+  for (int k = 0; k < argc; ++k) ++k;
+
+  foomain<int,char>(argc,argv);
+  return 0;
+}
+
diff --git a/test/OpenMP/parallel_for_simd_loop_messages.cpp b/test/OpenMP/parallel_for_simd_loop_messages.cpp
new file mode 100644
index 0000000..50acb10
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_loop_messages.cpp
@@ -0,0 +1,644 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
+
+class S {
+  int a;
+  S() : a(0) {}
+
+public:
+  S(int v) : a(v) {}
+  S(const S &s) : a(s.a) {}
+};
+
+static int sii;
+#pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+static int globalii;
+
+int test_iteration_spaces() {
+  const int N = 100;
+  float a[N], b[N], c[N];
+  int ii, jj, kk;
+  float fii;
+  double dii;
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; i += 1) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel for simd
+  for (char i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel for simd
+  for (char i = 0; i < 10; i += '\1') {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel for simd
+  for (long long i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+  }
+// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
+#pragma omp parallel for simd
+  for (long long i = 0; i < 10; i += 1.5) {
+    c[i] = a[i] + b[i];
+  }
+#pragma omp parallel for simd
+  for (long long i = 0; i < 'z'; i += 1u) {
+    c[i] = a[i] + b[i];
+  }
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp parallel for simd
+  for (float fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp parallel for simd
+  for (double fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp parallel for simd
+  for (int &ref = ii; ref < 10; ref++) {
+  }
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp parallel for simd
+  for (int i; i < 10; i++)
+    c[i] = a[i];
+
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp parallel for simd
+  for (int i = 0, j = 0; i < 10; ++i)
+    c[i] = a[i];
+
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp parallel for simd
+  for (; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+// expected-warning@+3 {{expression result unused}}
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp parallel for simd
+  for (ii + 1; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp parallel for simd
+  for (c[ii] = 0; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+// Ok to skip parenthesises.
+#pragma omp parallel for simd
+  for (((ii)) = 0; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp parallel for simd
+  for (int i = 0; i; i++)
+    c[i] = a[i];
+
+// expected-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
+#pragma omp parallel for simd
+  for (int i = 0; jj < kk; ii++)
+    c[i] = a[i];
+
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp parallel for simd
+  for (int i = 0; !!i; i++)
+    c[i] = a[i];
+
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp parallel for simd
+  for (int i = 0; i != 1; i++)
+    c[i] = a[i];
+
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
+#pragma omp parallel for simd
+  for (int i = 0;; i++)
+    c[i] = a[i];
+
+// Ok.
+#pragma omp parallel for simd
+  for (int i = 11; i > 10; i--)
+    c[i] = a[i];
+
+// Ok.
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i)
+    c[i] = a[i];
+
+// Ok.
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ++ii)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ++jj)
+    c[ii] = a[jj];
+
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ++++ii)
+    c[ii] = a[ii];
+
+// Ok but undefined behavior (in general, cannot check that incr
+// is really loop-invariant).
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii = ii + ii)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii = ii + 1.0f)
+    c[ii] = a[ii];
+
+// Ok - step was converted to integer type.
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii = ii + (int)1.1f)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; jj = ii + 2)
+    c[ii] = a[ii];
+
+// expected-warning@+3 {{relational comparison result unused}}
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii<10; jj> kk + 2)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10;)
+    c[ii] = a[ii];
+
+// expected-warning@+3 {{expression result unused}}
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; !ii)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii ? ++ii : ++jj)
+    c[ii] = a[ii];
+
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii = ii < 10)
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii = ii + 0)
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; ii = ii + (int)(0.8 - 0.45))
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; (ii) < 10; ii -= 25)
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; (ii < 10); ii -= 0)
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; ii > 10; (ii += 0))
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; ii < 10; (ii) = (1 - 1) + (ii))
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for ((ii = 0); ii > 10; (ii -= 0))
+    c[ii] = a[ii];
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (ii = 0; (ii < 10); (ii -= 0))
+    c[ii] = a[ii];
+
+// expected-note@+2  {{defined as firstprivate}}
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
+#pragma omp parallel for simd firstprivate(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+#pragma omp parallel for simd linear(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+// expected-note@+2 {{defined as private}}
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be private, predetermined as linear}}
+#pragma omp parallel for simd private(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+// expected-note@+2 {{defined as lastprivate}}
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be lastprivate, predetermined as linear}}
+#pragma omp parallel for simd lastprivate(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
+  {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
+#pragma omp parallel for simd
+    for (sii = 0; sii < 10; sii += 1)
+      c[sii] = a[sii];
+  }
+
+  {
+// expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be a variable with global storage without being explicitly marked as linear}}
+#pragma omp parallel for simd
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] = a[globalii];
+  }
+
+  {
+// expected-error@+3 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}}
+#pragma omp parallel for simd collapse(2)
+    for (ii = 0; ii < 10; ii += 1)
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] += a[globalii] + ii;
+  }
+
+// expected-error@+2 {{statement after '#pragma omp parallel for simd' must be a for loop}}
+#pragma omp parallel for simd
+  for (auto &item : a) {
+    item = item + 1;
+  }
+
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (unsigned i = 9; i < 10; i--) {
+    c[i] = a[i] + b[i];
+  }
+
+  int(*lb)[4] = nullptr;
+#pragma omp parallel for simd
+  for (int(*p)[4] = lb; p < lb + 8; ++p) {
+  }
+
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (int a{0}; a < 10; ++a) {
+  }
+
+  return 0;
+}
+
+// Iterators allowed in openmp for-loops.
+namespace std {
+struct random_access_iterator_tag {};
+template <class Iter>
+struct iterator_traits {
+  typedef typename Iter::difference_type difference_type;
+  typedef typename Iter::iterator_category iterator_category;
+};
+template <class Iter>
+typename iterator_traits<Iter>::difference_type
+distance(Iter first, Iter last) { return first - last; }
+}
+class Iter0 {
+public:
+  Iter0() {}
+  Iter0(const Iter0 &) {}
+  Iter0 operator++() { return *this; }
+  Iter0 operator--() { return *this; }
+  bool operator<(Iter0 a) { return true; }
+};
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
+int operator-(Iter0 a, Iter0 b) { return 0; }
+class Iter1 {
+public:
+  Iter1(float f = 0.0f, double d = 0.0) {}
+  Iter1(const Iter1 &) {}
+  Iter1 operator++() { return *this; }
+  Iter1 operator--() { return *this; }
+  bool operator<(Iter1 a) { return true; }
+  bool operator>=(Iter1 a) { return false; }
+};
+class GoodIter {
+public:
+  GoodIter() {}
+  GoodIter(const GoodIter &) {}
+  GoodIter(int fst, int snd) {}
+  GoodIter &operator=(const GoodIter &that) { return *this; }
+  GoodIter &operator=(const Iter0 &that) { return *this; }
+  GoodIter &operator+=(int x) { return *this; }
+  explicit GoodIter(void *) {}
+  GoodIter operator++() { return *this; }
+  GoodIter operator--() { return *this; }
+  bool operator!() { return true; }
+  bool operator<(GoodIter a) { return true; }
+  bool operator<=(GoodIter a) { return true; }
+  bool operator>=(GoodIter a) { return false; }
+  typedef int difference_type;
+  typedef std::random_access_iterator_tag iterator_category;
+};
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
+int operator-(GoodIter a, GoodIter b) { return 0; }
+// expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
+GoodIter operator-(GoodIter a) { return a; }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
+GoodIter operator-(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
+GoodIter operator+(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
+GoodIter operator-(int v, GoodIter a) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
+GoodIter operator+(int v, GoodIter a) { return GoodIter(); }
+
+int test_with_random_access_iterator() {
+  GoodIter begin, end;
+  Iter0 begin0, end0;
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I < end; ++I)
+    ++I;
+// expected-error@+2 {{variable must be of integer or random access iterator type}}
+#pragma omp parallel for simd
+  for (GoodIter &I = begin; I < end; ++I)
+    ++I;
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I >= end; --I)
+    ++I;
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (GoodIter I(begin); I < end; ++I)
+    ++I;
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (GoodIter I(nullptr); I < end; ++I)
+    ++I;
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (GoodIter I(0); I < end; ++I)
+    ++I;
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (GoodIter I(1, 2); I < end; ++I)
+    ++I;
+#pragma omp parallel for simd
+  for (begin = GoodIter(0); begin < end; ++begin)
+    ++begin;
+// expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
+// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+#pragma omp parallel for simd
+  for (begin = begin0; begin < end; ++begin)
+    ++begin;
+// expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
+#pragma omp parallel for simd
+  for (++begin; begin < end; ++begin)
+    ++begin;
+#pragma omp parallel for simd
+  for (begin = end; begin < end; ++begin)
+    ++begin;
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I - I; ++I)
+    ++I;
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; begin < end; ++I)
+    ++I;
+// expected-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; !I; ++I)
+    ++I;
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I >= end; I = I + 1)
+    ++I;
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I >= end; I = I - 1)
+    ++I;
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I >= end; I = -I)
+    ++I;
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I >= end; I = 2 + I)
+    ++I;
+// expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
+#pragma omp parallel for simd
+  for (GoodIter I = begin; I >= end; I = 2 - I)
+    ++I;
+// expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
+#pragma omp parallel for simd
+  for (Iter0 I = begin0; I < end0; ++I)
+    ++I;
+// Initializer is constructor without params.
+// expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (Iter0 I; I < end0; ++I)
+    ++I;
+  Iter1 begin1, end1;
+// expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+#pragma omp parallel for simd
+  for (Iter1 I = begin1; I < end1; ++I)
+    ++I;
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (Iter1 I = begin1; I >= end1; ++I)
+    ++I;
+// expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+// expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
+// Initializer is constructor with all default params.
+// expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
+#pragma omp parallel for simd
+  for (Iter1 I; I < end1; ++I) {
+  }
+  return 0;
+}
+
+template <typename IT, int ST>
+class TC {
+public:
+  int dotest_lt(IT begin, IT end) {
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+    for (IT I = begin; I < end; I = I + ST) {
+      ++I;
+    }
+// expected-note@+3 {{loop step is expected to be positive due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+    for (IT I = begin; I <= end; I += ST) {
+      ++I;
+    }
+#pragma omp parallel for simd
+    for (IT I = begin; I < end; ++I) {
+      ++I;
+    }
+  }
+
+  static IT step() {
+    return IT(ST);
+  }
+};
+template <typename IT, int ST = 0>
+int dotest_gt(IT begin, IT end) {
+// expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (IT I = begin; I >= end; I = I + ST) {
+    ++I;
+  }
+// expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (IT I = begin; I >= end; I += ST) {
+    ++I;
+  }
+
+// expected-note@+3 {{loop step is expected to be negative due to this condition}}
+// expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
+#pragma omp parallel for simd
+  for (IT I = begin; I >= end; ++I) {
+    ++I;
+  }
+
+#pragma omp parallel for simd
+  for (IT I = begin; I < end; I += TC<int, ST>::step()) {
+    ++I;
+  }
+}
+
+void test_with_template() {
+  GoodIter begin, end;
+  TC<GoodIter, 100> t1;
+  TC<GoodIter, -100> t2;
+  t1.dotest_lt(begin, end);
+  t2.dotest_lt(begin, end);         // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
+  dotest_gt(begin, end);            // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
+  dotest_gt<unsigned, -10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, -10>' requested here}}
+}
+
+void test_loop_break() {
+  const int N = 100;
+  float a[N], b[N], c[N];
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+    for (int j = 0; j < 10; ++j) {
+      if (a[i] > b[j])
+        break; // OK in nested loop
+    }
+    switch (i) {
+    case 1:
+      b[i]++;
+      break;
+    default:
+      break;
+    }
+    if (c[i] > 10)
+      break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+
+    if (c[i] > 11)
+      break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+  }
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; i++) {
+    for (int j = 0; j < 10; j++) {
+      c[i] = a[i] + b[i];
+      if (c[i] > 10) {
+        if (c[i] < 20) {
+          break; // OK
+        }
+      }
+    }
+  }
+}
+
+void test_loop_eh() {
+  const int N = 100;
+  float a[N], b[N], c[N];
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; i++) {
+    c[i] = a[i] + b[i];
+    try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
+      for (int j = 0; j < 10; ++j) {
+        if (a[i] > b[j])
+          throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+      }
+      throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+    } catch (float f) {
+      if (f > 0.1)
+        throw a[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+      return; // expected-error {{cannot return from OpenMP region}}
+    }
+    switch (i) {
+    case 1:
+      b[i]++;
+      break;
+    default:
+      break;
+    }
+    for (int j = 0; j < 10; j++) {
+      if (c[i] > 10)
+        throw c[i]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
+    }
+  }
+  if (c[9] > 10)
+    throw c[9]; // OK
+
+#pragma omp parallel for simd
+  for (int i = 0; i < 10; ++i) {
+    struct S {
+      void g() { throw 0; }
+    };
+  }
+}
+
+void test_loop_firstprivate_lastprivate() {
+  S s(4);
+#pragma omp parallel for simd lastprivate(s) firstprivate(s)
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
+void test_ordered() {
+// expected-error@+1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
+#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
+void test_nowait() {
+// expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}}
+#pragma omp parallel for simd nowait nowait // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'nowait' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
diff --git a/test/OpenMP/parallel_for_simd_messages.cpp b/test/OpenMP/parallel_for_simd_messages.cpp
new file mode 100644
index 0000000..67a025c
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_messages.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -std=c++11 -o - %s
+
+void foo() {
+}
+
+#pragma omp parallel for simd // expected-error {{unexpected OpenMP directive '#pragma omp parallel for simd'}}
+
+int main(int argc, char **argv) {
+#pragma omp parallel for simd { // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd] // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd } // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd
+  for (int i = 0; i < argc; ++i)
+    foo();
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+#pragma omp parallel for simd unknown()
+  for (int i = 0; i < argc; ++i)
+    foo();
+L1:
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd
+  for (int i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd
+  for (int i = 0; i < argc; ++i) {
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+    argc++;
+  }
+
+  for (int i = 0; i < 10; ++i) {
+    switch (argc) {
+    case (0):
+#pragma omp parallel for simd
+      for (int i = 0; i < argc; ++i) {
+        foo();
+        break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
+        continue;
+      }
+    default:
+      break;
+    }
+  }
+#pragma omp parallel for simd default(none)
+  for (int i = 0; i < 10; ++i)
+    ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+#pragma omp parallel for simd
+  for (int i = 0; i < argc; ++i)
+  L2:
+  foo();
+#pragma omp parallel for simd
+  for (int i = 0; i < argc; ++i) {
+    return 1; // expected-error {{cannot return from OpenMP region}}
+  }
+
+  [[]] // expected-error {{an attribute list cannot appear here}}
+#pragma omp parallel for simd
+      for (int n = 0; n < 100; ++n) {
+  }
+
+  return 0;
+}
+
+void test_ordered() {
+// expected-error@+1 2 {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
+#pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
+
diff --git a/test/OpenMP/parallel_for_simd_misc_messages.c b/test/OpenMP/parallel_for_simd_misc_messages.c
new file mode 100644
index 0000000..4cb0843
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_misc_messages.c
@@ -0,0 +1,657 @@
+// RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -verify %s
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel for simd'}}
+#pragma omp parallel for simd
+
+// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel for simd'}}
+#pragma omp parallel for simd foo
+
+void test_no_clause() {
+  int i;
+#pragma omp parallel for simd
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-error@+2 {{statement after '#pragma omp parallel for simd' must be a for loop}}
+#pragma omp parallel for simd
+  ++i;
+}
+
+void test_branch_protected_scope() {
+  int i = 0;
+L1:
+  ++i;
+
+  int x[24];
+
+#pragma omp parallel
+#pragma omp parallel for simd
+  for (i = 0; i < 16; ++i) {
+    if (i == 5)
+      goto L1; // expected-error {{use of undeclared label 'L1'}}
+    else if (i == 6)
+      return; // expected-error {{cannot return from OpenMP region}}
+    else if (i == 7)
+      goto L2;
+    else if (i == 8) {
+    L2:
+      x[i]++;
+    }
+  }
+
+  if (x[0] == 0)
+    goto L2; // expected-error {{use of undeclared label 'L2'}}
+  else if (x[1] == 1)
+    goto L1;
+}
+
+void test_invalid_clause() {
+  int i;
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+#pragma omp parallel for simd foo bar
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_non_identifiers() {
+  int i, x;
+
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+#pragma omp parallel for simd;
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+#pragma omp parallel for simd linear(x);
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+#pragma omp parallel for simd private(x);
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+#pragma omp parallel for simd, private(x);
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+extern int foo();
+void test_safelen() {
+  int i;
+// expected-error@+1 {{expected '('}}
+#pragma omp parallel for simd safelen
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd safelen()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp parallel for simd safelen 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(4
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(4,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(4, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd safelen(4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(4 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(4, , 4)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd safelen(4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd safelen(4, 8)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp parallel for simd safelen(2.5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp parallel for simd safelen(foo())
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp parallel for simd safelen(-5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp parallel for simd safelen(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp parallel for simd safelen(5 - 5)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_collapse() {
+  int i;
+#pragma omp parallel
+// expected-error@+1 {{expected '('}}
+#pragma omp parallel for simd collapse
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd collapse(
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd collapse()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd collapse(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd collapse(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp parallel for simd collapse 4)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4,
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4, )
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+// expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4 4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4, , 4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+#pragma omp parallel for simd collapse(4)
+  for (int i1 = 0; i1 < 16; ++i1)
+    for (int i2 = 0; i2 < 16; ++i2)
+      for (int i3 = 0; i3 < 16; ++i3)
+        for (int i4 = 0; i4 < 16; ++i4)
+          foo();
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp parallel for simd collapse(4, 8)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}}
+#pragma omp parallel
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp parallel for simd collapse(2.5)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp parallel for simd collapse(foo())
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp parallel for simd collapse(-5)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp parallel for simd collapse(0)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp parallel for simd collapse(5 - 5)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd collapse(2)
+  for (i = 0; i < 16; ++i)
+    for (int j = 0; j < 16; ++j)
+// expected-error@+1 {{OpenMP constructs may not be nested inside a simd region}}
+#pragma omp parallel for simd reduction(+ : i, j)
+      for (int k = 0; k < 16; ++k)
+        i += j;
+}
+
+void test_linear() {
+  int i;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd linear(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd linear(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd linear(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd linear()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd linear(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp parallel for simd linear(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{use of undeclared identifier 'x'}}
+#pragma omp parallel for simd linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{use of undeclared identifier 'x'}}
+// expected-error@+1 {{use of undeclared identifier 'y'}}
+#pragma omp parallel for simd linear(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{use of undeclared identifier 'x'}}
+// expected-error@+2 {{use of undeclared identifier 'y'}}
+// expected-error@+1 {{use of undeclared identifier 'z'}}
+#pragma omp parallel for simd linear(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd linear(x :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd linear(x :, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd linear(x : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd linear(x : 2 * 2)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd linear(x : 1, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd linear(x : 1, y, z : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be linear}}
+#pragma omp parallel for simd linear(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as private}}
+// expected-error@+1 {{private variable cannot be linear}}
+#pragma omp parallel for simd private(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be private}}
+#pragma omp parallel for simd linear(x) private(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-warning@+1 {{zero linear step (x and other variables in clause should probably be const)}}
+#pragma omp parallel for simd linear(x, y : 0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be lastprivate}}
+#pragma omp parallel for simd linear(x) lastprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-note@+2 {{defined as lastprivate}}
+// expected-error@+1 {{lastprivate variable cannot be linear}}
+#pragma omp parallel for simd lastprivate(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_aligned() {
+  int i;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd aligned(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd aligned(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd aligned(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd aligned()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd aligned(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp parallel for simd aligned(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{use of undeclared identifier 'x'}}
+#pragma omp parallel for simd aligned(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{use of undeclared identifier 'x'}}
+// expected-error@+1 {{use of undeclared identifier 'y'}}
+#pragma omp parallel for simd aligned(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{use of undeclared identifier 'x'}}
+// expected-error@+2 {{use of undeclared identifier 'y'}}
+// expected-error@+1 {{use of undeclared identifier 'z'}}
+#pragma omp parallel for simd aligned(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int *x, y, z[25]; // expected-note 4 {{'y' defined here}}
+#pragma omp parallel for simd aligned(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd aligned(z)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd aligned(x :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd aligned(x :, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd aligned(x : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel for simd aligned(x : 2 * 2)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd aligned(x : 1, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd aligned(x : 1, y, z : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp parallel for simd aligned(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp parallel for simd aligned(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+2 {{defined as aligned}}
+// expected-error@+1 {{a variable cannot appear in more than one aligned clause}}
+#pragma omp parallel for simd aligned(x) aligned(z, x)
+  for (i = 0; i < 16; ++i)
+    ;
+
+// expected-note@+3 {{defined as aligned}}
+// expected-error@+2 {{a variable cannot appear in more than one aligned clause}}
+// expected-error@+1 2 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp parallel for simd aligned(x, y, z) aligned(y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+
+void test_private() {
+  int i;
+#pragma omp parallel
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp parallel for simd private(
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp parallel for simd private(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 2 {{expected expression}}
+#pragma omp parallel for simd private(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd private()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd private(int)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected variable name}}
+#pragma omp parallel for simd private(0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y, z;
+#pragma omp parallel
+#pragma omp parallel for simd private(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd private(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd private(x, y, z)
+  for (i = 0; i < 16; ++i) {
+    x = y * i + z;
+  }
+}
+
+void test_lastprivate() {
+  int i;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd lastprivate(
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp parallel for simd lastprivate(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 2 {{expected expression}}
+#pragma omp parallel for simd lastprivate(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd lastprivate()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd lastprivate(int)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected variable name}}
+#pragma omp parallel for simd lastprivate(0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y, z;
+#pragma omp parallel
+#pragma omp parallel for simd lastprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd lastprivate(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd lastprivate(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_firstprivate() {
+  int i;
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd firstprivate(
+  for (i = 0; i < 16; ++i)
+    ;
+
+#pragma omp parallel
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp parallel for simd firstprivate(,
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 2 {{expected expression}}
+#pragma omp parallel for simd firstprivate(, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd firstprivate()
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected expression}}
+#pragma omp parallel for simd firstprivate(int)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+// expected-error@+1 {{expected variable name}}
+#pragma omp parallel for simd firstprivate(0)
+  for (i = 0; i < 16; ++i)
+    ;
+
+  int x, y, z;
+#pragma omp parallel
+#pragma omp parallel for simd lastprivate(x) firstprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd lastprivate(x, y) firstprivate(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp parallel
+#pragma omp parallel for simd lastprivate(x, y, z) firstprivate(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
+}
+
+void test_loop_messages() {
+  float a[100], b[100], c[100];
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or pointer type}}
+#pragma omp parallel for simd
+  for (float fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+#pragma omp parallel
+// expected-error@+2 {{variable must be of integer or pointer type}}
+#pragma omp parallel for simd
+  for (double fi = 0; fi < 10.0; fi++) {
+    c[(int)fi] = a[(int)fi] + b[(int)fi];
+  }
+}
+
diff --git a/test/OpenMP/parallel_for_simd_num_threads_messages.cpp b/test/OpenMP/parallel_for_simd_num_threads_messages.cpp
new file mode 100644
index 0000000..3d11d4f
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_num_threads_messages.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N> // expected-note {{declared here}}
+T tmain(T argc, S **argv) {
+  T i;
+  #pragma omp parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads () // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a positive integer value}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (S) // expected-error {{'S' does not refer to a value}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argc)
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (N) // expected-error {{argument to 'num_threads' clause must be a positive integer value}}
+  for (i = 0; i < argc; ++i) foo();
+
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads () // expected-error {{expected expression}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a positive integer value}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (S1) // expected-error {{'S1' does not refer to a value}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  for (i = 0; i < argc; ++i) foo();
+  #pragma omp parallel for simd num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}}
+  for (i = 0; i < argc; ++i) foo();
+
+  return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
+}
diff --git a/test/OpenMP/parallel_for_simd_private_messages.cpp b/test/OpenMP/parallel_for_simd_private_messages.cpp
new file mode 100644
index 0000000..67d8813
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_private_messages.cpp
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4(); // expected-note {{implicitly declared private here}}
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
+
+public:
+  S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class I, class C>
+int foomain(I argc, C **argv) {
+  I e(4);
+  I g(5);
+  int i;
+  int &j = i;           // expected-note {{'j' defined here}}
+#pragma omp parallel for simd private // expected-error {{expected '(' after 'private'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(e, g)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int v = 0;
+    int i;
+#pragma omp parallel for simd private(i)
+    for (int k = 0; k < argc; ++k) {
+      i = k;
+      v += i;
+    }
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel for simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i;           // expected-note {{'j' defined here}}
+#pragma omp parallel for simd private // expected-error {{expected '(' after 'private'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private() // expected-error {{expected expression}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argc)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(S1) // expected-error {{'S1' does not refer to a value}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(argv[1]) // expected-error {{expected variable name}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel
+  {
+    int i;
+#pragma omp parallel for simd private(i)
+    for (int k = 0; k < argc; ++k)
+      ++k;
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel private(i)
+#pragma omp parallel for simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
+  for (int k = 0; k < argc; ++k)
+    ++k;
+#pragma omp parallel for simd private(i)
+  for (int k = 0; k < argc; ++k)
+    ++k;
+
+  return 0;
+}
+
diff --git a/test/OpenMP/parallel_for_simd_proc_bind_messages.cpp b/test/OpenMP/parallel_for_simd_proc_bind_messages.cpp
new file mode 100644
index 0000000..bc1e0d2
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_proc_bind_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo();
+
+int main(int argc, char **argv) {
+  int i;
+#pragma omp parallel for simd proc_bind // expected-error {{expected '(' after 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd proc_bind( // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd proc_bind() // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd proc_bind(master // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd proc_bind(close), proc_bind(spread) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'proc_bind' clause}}
+  for (i = 0; i < argc; ++i)
+    foo();
+#pragma omp parallel for simd proc_bind(x) // expected-error {{expected 'master', 'close' or 'spread' in OpenMP clause 'proc_bind'}}
+  for (i = 0; i < argc; ++i)
+    foo();
+
+#pragma omp parallel for simd proc_bind(master)
+  for (i = 0; i < argc; ++i)
+    foo();
+
+#pragma omp parallel proc_bind(close)
+#pragma omp parallel for simd proc_bind(spread)
+  for (i = 0; i < argc; ++i)
+    foo();
+  return 0;
+}
diff --git a/test/OpenMP/parallel_for_simd_reduction_messages.cpp b/test/OpenMP/parallel_for_simd_reduction_messages.cpp
new file mode 100644
index 0000000..61690dd
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_reduction_messages.cpp
@@ -0,0 +1,295 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+  S2 &operator+=(const S2 &arg) { return (*this); }
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+  static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
+  static const float S2sc;
+};
+const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
+S2 b;                     // expected-note 2 {{'b' defined here}}
+const S2 ba[5];           // expected-note 2 {{'ba' defined here}}
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+  S3 operator+=(const S3 &arg1) { return arg1; }
+};
+int operator+=(const S3 &arg1, const S3 &arg2) { return 5; }
+S3 c;               // expected-note 2 {{'c' defined here}}
+const S3 ca[5];     // expected-note 2 {{'ca' defined here}}
+extern const int f; // expected-note 4 {{'f' declared here}}
+class S4 {          // expected-note {{'S4' declared here}}
+  int a;
+  S4();
+  S4(const S4 &s4);
+  S4 &operator+=(const S4 &arg) { return (*this); }
+
+public:
+  S4(int v) : a(v) {}
+};
+S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {}
+  S5 &operator+=(const S5 &arg);
+
+public:
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+
+public:
+  S6() : a(6) {}
+  operator int() { return 6; }
+} o; // expected-note 2 {{'o' defined here}}
+
+S3 h, k;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class T>       // expected-note {{declared here}}
+T tmain(T argc) {        // expected-note 2 {{'argc' defined here}}
+  const T d = T();       // expected-note 4 {{'d' defined here}}
+  const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
+  T qa[5] = {T()};
+  T i;
+  T &j = i;                        // expected-note 4 {{'j' defined here}}
+  S3 &p = k;                       // expected-note 2 {{'p' defined here}}
+  const T &r = da[(int)i];         // expected-note 2 {{'r' defined here}}
+  T &q = qa[(int)i];               // expected-note 2 {{'q' defined here}}
+  T fl;                            // expected-note {{'fl' defined here}}
+#pragma omp parallel for simd reduction // expected-error {{expected '(' after 'reduction'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(&& : argc)
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(^ : T) // expected-error {{'T' does not refer to a value}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(max : qa[1]) // expected-error 2 {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} expected-error {{a reduction variable with array type 'const float [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(k)
+#pragma omp parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp parallel for simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(fl)
+#pragma omp parallel for simd reduction(+ : fl)
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel reduction(* : fl)
+#pragma omp parallel for simd reduction(+ : fl)
+  for (int i = 0; i < 10; ++i)
+    foo();
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;       // expected-note 2 {{'d' defined here}}
+  const int da[5] = {0}; // expected-note {{'da' defined here}}
+  int qa[5] = {0};
+  S4 e(4); // expected-note {{'e' defined here}}
+  S5 g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i;                      // expected-note 2 {{'j' defined here}}
+  S3 &p = k;                       // expected-note 2 {{'p' defined here}}
+  const int &r = da[i];            // expected-note {{'r' defined here}}
+  int &q = qa[i];                  // expected-note {{'q' defined here}}
+  float fl;                        // expected-note {{'fl' defined here}}
+#pragma omp parallel for simd reduction // expected-error {{expected '(' after 'reduction'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(~ : argc) // expected-error {{expected unqualified-id}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(&& : argc)
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(max : argv[1]) // expected-error {{expected variable name}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(& : e, g) // expected-error {{reduction variable must have an accessible, unambiguous default constructor}} expected-error {{variable of type 'S5' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(k)
+#pragma omp parallel for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel for simd reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp parallel for simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel private(fl)
+#pragma omp parallel for simd reduction(+ : fl)
+  for (int i = 0; i < 10; ++i)
+    foo();
+#pragma omp parallel reduction(* : fl)
+#pragma omp parallel for simd reduction(+ : fl)
+  for (int i = 0; i < 10; ++i)
+    foo();
+
+  return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
+}
diff --git a/test/OpenMP/parallel_for_simd_safelen_messages.cpp b/test/OpenMP/parallel_for_simd_safelen_messages.cpp
new file mode 100644
index 0000000..3fef81c
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_safelen_messages.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N, int ST> // expected-note {{declared here}}
+T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
+  #pragma omp parallel for simd safelen // expected-error {{expected '(' after 'safelen'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen () // expected-error {{expected expression}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+  // expected-error@+2 2 {{expression is not an integral constant expression}}
+  // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
+  #pragma omp parallel for simd safelen (argc 
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+  #pragma omp parallel for simd safelen (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen (1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen ((ST > 0) ? 1 + ST : 2)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+3 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'safelen' clause}}
+  // expected-error@+2 2 {{argument to 'safelen' clause must be a positive integer value}}
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd safelen (foobool(argc)), safelen (true), safelen (-5)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen (S) // expected-error {{'S' does not refer to a value}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen (4)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd safelen (N) // expected-error {{argument to 'safelen' clause must be a positive integer value}}
+  for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp parallel for simd safelen // expected-error {{expected '(' after 'safelen'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd safelen () // expected-error {{expected expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{expression is not an integral constant expression}}
+  // expected-error@+2 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'safelen' clause}}
+  // expected-error@+1 2 {{argument to 'safelen' clause must be a positive integer value}}
+  #pragma omp parallel for simd safelen (foobool(argc)), safelen (true), safelen (-5) 
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd safelen (S1) // expected-error {{'S1' does not refer to a value}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+1 {{expression is not an integral constant expression}}
+  #pragma omp parallel for simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{statement after '#pragma omp parallel for simd' must be a for loop}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
+  #pragma omp parallel for simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
+  foo();
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}}
+  return tmain<int, char, 12, 4>(argc, argv);
+}
+
diff --git a/test/OpenMP/parallel_for_simd_schedule_messages.cpp b/test/OpenMP/parallel_for_simd_schedule_messages.cpp
new file mode 100644
index 0000000..9e153d9
--- /dev/null
+++ b/test/OpenMP/parallel_for_simd_schedule_messages.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, typename S, int N, int ST> // expected-note {{declared here}}
+T tmain(T argc, S **argv) {
+  #pragma omp parallel for simd schedule // expected-error {{expected '(' after 'schedule'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule ( // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (auto_dynamic // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (runtime, 3)  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+  #pragma omp parallel for simd schedule (guided argc
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{argument to 'schedule' clause must be a positive integer value}}
+  #pragma omp parallel for simd schedule (static, ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (dynamic, 1)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (guided, (ST > 0) ? 1 + ST : 2)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+2 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'schedule' clause}}
+  // expected-error@+1 {{argument to 'schedule' clause must be a positive integer value}}
+  #pragma omp parallel for simd schedule (static, foobool(argc)), schedule (dynamic, true), schedule (guided, -5)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (static, S) // expected-error {{'S' does not refer to a value}} expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  // expected-error@+1 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  #pragma omp parallel for simd schedule (guided, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (dynamic, 1)
+  for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  #pragma omp parallel for simd schedule (static, N) // expected-error {{argument to 'schedule' clause must be a positive integer value}}
+  for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp parallel for simd schedule // expected-error {{expected '(' after 'schedule'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule ( // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule () // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (auto // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (auto_dynamic // expected-error {{expected 'static', 'dynamic', 'guided', 'auto' or 'runtime' in OpenMP clause 'schedule'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (runtime, 3)  // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (guided, 4 // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (static, 2+2)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (dynamic, foobool(1) > 0 ? 1 : 2)
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+2 2 {{directive '#pragma omp parallel for simd' cannot contain more than one 'schedule' clause}}
+  // expected-error@+1 {{argument to 'schedule' clause must be a positive integer value}}
+  #pragma omp parallel for simd schedule (guided, foobool(argc)), schedule (static, true), schedule (dynamic, -5)
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  #pragma omp parallel for simd schedule (guided, S1) // expected-error {{'S1' does not refer to a value}} expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'char *'}}
+  #pragma omp parallel for simd schedule (static, argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+3 {{statement after '#pragma omp parallel for simd' must be a for loop}}
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
+  #pragma omp parallel for simd schedule(dynamic, schedule(tmain<int, char, -1, -2>(argc, argv) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
+  return tmain<int, char, 1, 0>(argc, argv);
+}
+
diff --git a/test/OpenMP/parallel_if_codegen.cpp b/test/OpenMP/parallel_if_codegen.cpp
new file mode 100644
index 0000000..44c874f
--- /dev/null
+++ b/test/OpenMP/parallel_if_codegen.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple %itanium_abi_triple -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple %itanium_abi_triple -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix=CHECK %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void fn1();
+void fn2();
+void fn3();
+void fn4();
+void fn5();
+void fn6();
+
+int Arg;
+
+// CHECK-LABEL: define void @{{.+}}gtid_test
+void gtid_test() {
+// CHECK:  call void {{.+}}* @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 1, {{.+}}* [[GTID_TEST_REGION1:@.+]] to void
+#pragma omp parallel
+#pragma omp parallel if (false)
+  gtid_test();
+// CHECK: ret void
+}
+
+// CHECK: define internal void [[GTID_TEST_REGION1]](i{{.+}}* [[GTID_PARAM:%.+]], i
+// CHECK: store i{{[0-9]+}}* [[GTID_PARAM]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]],
+// CHECK: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}** [[GTID_ADDR_REF]]
+// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}* [[GTID_ADDR]]
+// CHECK: call void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i{{.+}} [[GTID]])
+// CHECK: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}** [[GTID_ADDR_REF]]
+// CHECK: call void [[GTID_TEST_REGION2:@.+]](i{{[0-9]+}}* [[GTID_ADDR]]
+// CHECK: call void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, i{{.+}} [[GTID]])
+// CHECK: ret void
+
+// CHECK: define internal void [[GTID_TEST_REGION2]](
+// CHECK: call void @{{.+}}gtid_test
+// CHECK: ret void
+
+template <typename T>
+int tmain(T Arg) {
+#pragma omp parallel if (true)
+  fn1();
+#pragma omp parallel if (false)
+  fn2();
+#pragma omp parallel if (Arg)
+  fn3();
+  return 0;
+}
+
+// CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
+int main() {
+// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
+// CHECK: call void {{.+}} @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 1, void {{.+}}* [[CAP_FN4:@.+]] to void
+#pragma omp parallel if (true)
+  fn4();
+// CHECK: call void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN5:@.+]](i32* [[GTID_ADDR]],
+// CHECK: call void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+#pragma omp parallel if (false)
+  fn5();
+
+// CHECK: br i1 %{{.+}}, label %[[OMP_THEN:.+]], label %[[OMP_ELSE:.+]]
+// CHECK: [[OMP_THEN]]
+// CHECK: call void {{.+}} @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 1, void {{.+}}* [[CAP_FN6:@.+]] to void
+// CHECK: br label %[[OMP_END:.+]]
+// CHECK: [[OMP_ELSE]]
+// CHECK: call void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN6]](i32* [[GTID_ADDR]],
+// CHECK: call void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: br label %[[OMP_END]]
+// CHECK: [[OMP_END]]
+#pragma omp parallel if (Arg)
+  fn6();
+  // CHECK: = call {{.*}}i{{.+}} @{{.+}}tmain
+  return tmain(Arg);
+}
+
+// CHECK: define internal void [[CAP_FN4]]
+// CHECK: call void @{{.+}}fn4
+// CHECK: ret void
+
+// CHECK: define internal void [[CAP_FN5]]
+// CHECK: call void @{{.+}}fn5
+// CHECK: ret void
+
+// CHECK: define internal void [[CAP_FN6]]
+// CHECK: call void @{{.+}}fn6
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.+}} @{{.+}}tmain
+// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
+// CHECK: call void {{.+}} @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 1, void {{.+}}* [[CAP_FN1:@.+]] to void
+// CHECK: call void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN2:@.+]](i32* [[GTID_ADDR]],
+// CHECK: call void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: br i1 %{{.+}}, label %[[OMP_THEN:.+]], label %[[OMP_ELSE:.+]]
+// CHECK: [[OMP_THEN]]
+// CHECK: call void {{.+}} @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 1, void {{.+}}* [[CAP_FN3:@.+]] to void
+// CHECK: br label %[[OMP_END:.+]]
+// CHECK: [[OMP_ELSE]]
+// CHECK: call void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN3]](i32* [[GTID_ADDR]],
+// CHECK: call void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, i32 [[GTID]])
+// CHECK: br label %[[OMP_END]]
+// CHECK: [[OMP_END]]
+
+// CHECK: define internal void [[CAP_FN1]]
+// CHECK: call void @{{.+}}fn1
+// CHECK: ret void
+
+// CHECK: define internal void [[CAP_FN2]]
+// CHECK: call void @{{.+}}fn2
+// CHECK: ret void
+
+// CHECK: define internal void [[CAP_FN3]]
+// CHECK: call void @{{.+}}fn3
+// CHECK: ret void
+
+#endif
diff --git a/test/OpenMP/parallel_num_threads_codegen.cpp b/test/OpenMP/parallel_num_threads_codegen.cpp
new file mode 100644
index 0000000..4ccf789
--- /dev/null
+++ b/test/OpenMP/parallel_num_threads_codegen.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+// CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[S_TY:%.+]] = type { [[INTPTR_T_TY:i[0-9]+]], [[INTPTR_T_TY]], [[INTPTR_T_TY]] }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8]* [[STR]], i32 0, i32 0) }
+
+void foo();
+
+struct S {
+  intptr_t a, b, c;
+  S(intptr_t a) : a(a) {}
+  operator char() { return a; }
+  ~S() {}
+};
+
+template <typename T, int C>
+int tmain() {
+#pragma omp parallel num_threads(C)
+  foo();
+#pragma omp parallel num_threads(T(23))
+  foo();
+  return 0;
+}
+
+int main() {
+  S s(0);
+  char a = s;
+#pragma omp parallel num_threads(2)
+  foo();
+#pragma omp parallel num_threads(a)
+  foo();
+  return a + tmain<char, 5>() + tmain<S, 1>();
+}
+
+// CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
+// CHECK-DAG:   [[S_ADDR:%.+]] = alloca [[S_TY]]
+// CHECK-DAG:   [[A_ADDR:%.+]] = alloca i8
+// CHECK-DAG:   [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK-DAG:   call {{.*}} [[S_TY_CONSTR:@.+]]([[S_TY]]* [[S_ADDR]], [[INTPTR_T_TY]] 0)
+// CHECK:       [[S_CHAR_OP:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP:@.+]]([[S_TY]]* [[S_ADDR]])
+// CHECK:       store i8 [[S_CHAR_OP]], i8* [[A_ADDR]]
+// CHECK:       call void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 2)
+// CHECK:       call void {{.*}}* @__kmpc_fork_call(
+// CHECK:       [[A_VAL:%.+]] = load i8* [[A_ADDR]]
+// CHECK:       [[RES:%.+]] = sext i8 [[A_VAL]] to i32
+// CHECK:       call void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES]])
+// CHECK:       call void {{.*}}* @__kmpc_fork_call(
+// CHECK:       invoke{{.*}} [[INT_TY:i[0-9]+]] [[TMAIN_CHAR_5:@.+]]()
+// CHECK:       invoke{{.*}} [[INT_TY]] [[TMAIN_S_1:@.+]]()
+// CHECK:       call {{.*}} [[S_TY_DESTR:@.+]]([[S_TY]]* [[S_ADDR]])
+// CHECK:       ret [[INT_TY]]
+// CHECK:       }
+
+// CHECK:       define{{.*}} [[INT_TY]] [[TMAIN_CHAR_5]]()
+// CHECK:       [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK:       call void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 5)
+// CHECK:       call void {{.*}}* @__kmpc_fork_call(
+// CHECK:       call void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 23)
+// CHECK:       call void {{.*}}* @__kmpc_fork_call(
+// CHECK:       ret [[INT_TY]] 0
+// CHECK-NEXT:  }
+
+// CHECK:       define{{.*}} [[INT_TY]] [[TMAIN_S_1]]()
+// CHECK:       [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* [[DEF_LOC_2]])
+// CHECK:       call void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 1)
+// CHECK:       call void {{.*}}* @__kmpc_fork_call(
+// CHECK:       call {{.*}} [[S_TY_CONSTR]]([[S_TY]]* [[S_TEMP:%.+]], [[INTPTR_T_TY]] 23)
+// CHECK:       [[S_CHAR_OP:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP]]([[S_TY]]* [[S_TEMP]])
+// CHECK:       [[RES:%.+]] = sext {{.*}}i8 [[S_CHAR_OP]] to i32
+// CHECK:       call void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 [[GTID]], i32 [[RES]])
+// CHECK:       call {{.*}} [[S_TY_DESTR]]([[S_TY]]* [[S_TEMP]])
+// CHECK:       call void {{.*}}* @__kmpc_fork_call(
+// CHECK:       ret [[INT_TY]] 0
+// CHECK:       }
+
+#endif
diff --git a/test/OpenMP/parallel_private_codegen.cpp b/test/OpenMP/parallel_private_codegen.cpp
new file mode 100644
index 0000000..2db0674
--- /dev/null
+++ b/test/OpenMP/parallel_private_codegen.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template <class T>
+struct S {
+  T f;
+  S(T a) : f(a) {}
+  S() : f() {}
+  operator T() { return T(); }
+  ~S() {}
+};
+
+// CHECK: [[S_FLOAT_TY:%.+]] = type { float }
+// CHECK: [[CAP_MAIN_TY:%.+]] = type { [2 x i{{[0-9]+}}]*, i{{[0-9]+}}*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]* }
+// CHECK: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }
+// CHECK: [[CAP_TMAIN_TY:%.+]] = type { [2 x i{{[0-9]+}}]*, i{{[0-9]+}}*, [2 x [[S_INT_TY]]]*, [[S_INT_TY]]* }
+// CHECK: [[IMPLICIT_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 66, i32 0, i32 0, i8*
+template <typename T>
+T tmain() {
+  S<T> test;
+  T t_var;
+  T vec[] = {1, 2};
+  S<T> s_arr[] = {1, 2};
+  S<T> var(3);
+#pragma omp parallel private(t_var, vec, s_arr, var)
+  {
+    vec[0] = t_var;
+    s_arr[0] = var;
+  }
+  return T();
+}
+
+int main() {
+  S<float> test;
+  int t_var;
+  int vec[] = {1, 2};
+  S<float> s_arr[] = {1, 2};
+  S<float> var(3);
+#pragma omp parallel private(t_var, vec, s_arr, var)
+  {
+    vec[0] = t_var;
+    s_arr[0] = var;
+  }
+  return tmain<int>();
+}
+
+// CHECK: define i{{[0-9]+}} @main()
+// CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
+// CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
+// CHECK: %{{.+}} = bitcast [[CAP_MAIN_TY]]*
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...)* @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[CAP_MAIN_TY]]*)* [[MAIN_MICROTASK:@.+]] to void
+// CHECK: = call i{{.+}} [[TMAIN_INT:@.+]]()
+// CHECK: call void [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
+// CHECK: ret
+//
+// CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* [[GTID_ADDR:%.+]], i{{[0-9]+}}* %{{.+}}, [[CAP_MAIN_TY]]* %{{.+}})
+// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
+// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
+// CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_FLOAT_TY]]],
+// CHECK: [[VAR_PRIV:%.+]] = alloca [[S_FLOAT_TY]],
+// CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
+// CHECK-NOT: [[T_VAR_PRIV]]
+// CHECK-NOT: [[VEC_PRIV]]
+// CHECK: {{.+}}:
+// CHECK: [[S_ARR_PRIV_ITEM:%.+]] = phi [[S_FLOAT_TY]]*
+// CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR]]([[S_FLOAT_TY]]* [[S_ARR_PRIV_ITEM]])
+// CHECK-NOT: [[T_VAR_PRIV]]
+// CHECK-NOT: [[VEC_PRIV]]
+// CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
+// CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}** [[GTID_ADDR_REF]]
+// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}* [[GTID_REF]]
+// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
+// CHECK-DAG: call void [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
+// CHECK-DAG: call void [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
+// CHECK: ret void
+
+// CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
+// CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
+// CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...)* @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[CAP_TMAIN_TY]]*)* [[TMAIN_MICROTASK:@.+]] to void
+// CHECK: call void [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
+// CHECK: ret
+//
+// CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* [[GTID_ADDR:%.+]], i{{[0-9]+}}* %{{.+}}, [[CAP_TMAIN_TY]]* %{{.+}})
+// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
+// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
+// CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_INT_TY]]],
+// CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]],
+// CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
+// CHECK-NOT: [[T_VAR_PRIV]]
+// CHECK-NOT: [[VEC_PRIV]]
+// CHECK: {{.+}}:
+// CHECK: [[S_ARR_PRIV_ITEM:%.+]] = phi [[S_INT_TY]]*
+// CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR]]([[S_INT_TY]]* [[S_ARR_PRIV_ITEM]])
+// CHECK-NOT: [[T_VAR_PRIV]]
+// CHECK-NOT: [[VEC_PRIV]]
+// CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR]]([[S_INT_TY]]* [[VAR_PRIV]])
+// CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}** [[GTID_ADDR_REF]]
+// CHECK: [[GTID:%.+]] = load i{{[0-9]+}}* [[GTID_REF]]
+// CHECK: call void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
+// CHECK-DAG: call void [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])
+// CHECK-DAG: call void [[S_INT_TY_DESTR]]([[S_INT_TY]]*
+// CHECK: ret void
+#endif
+
diff --git a/test/OpenMP/parallel_private_messages.cpp b/test/OpenMP/parallel_private_messages.cpp
index 1cd86d2..14c5cbd 100644
--- a/test/OpenMP/parallel_private_messages.cpp
+++ b/test/OpenMP/parallel_private_messages.cpp
@@ -25,15 +25,15 @@
 const S3 c; // expected-note {{global variable is predetermined as shared}}
 const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
 extern const int f; // expected-note {{global variable is predetermined as shared}}
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 public:
   S4(int v):a(v) { }
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5():a(0) {}
+  S5():a(0) {} // expected-note {{implicitly declared private here}}
 public:
   S5(int v):a(v) { }
 };
@@ -44,8 +44,8 @@
 int main(int argc, char **argv) {
   const int d = 5; // expected-note {{constant variable is predetermined as shared}}
   const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}}
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g[] = {5, 6};
   int i;
   int &j = i; // expected-note {{'j' defined here}}
   #pragma omp parallel private // expected-error {{expected '(' after 'private'}}
@@ -62,7 +62,7 @@
   #pragma omp parallel private(ca) // expected-error {{shared variable cannot be private}}
   #pragma omp parallel private(da) // expected-error {{shared variable cannot be private}}
   #pragma omp parallel private(S2::S2s) // expected-error {{shared variable cannot be private}}
-  #pragma omp parallel private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+  #pragma omp parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   #pragma omp parallel private(threadvar) // expected-error {{threadprivate or thread local variable cannot be private}}
   #pragma omp parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
   foo();
diff --git a/test/OpenMP/parallel_sections_firstprivate_messages.cpp b/test/OpenMP/parallel_sections_firstprivate_messages.cpp
index ffd2b0c..2d27b1a 100644
--- a/test/OpenMP/parallel_sections_firstprivate_messages.cpp
+++ b/test/OpenMP/parallel_sections_firstprivate_messages.cpp
@@ -14,7 +14,7 @@
 
 public:
   S2() : a(0) {}
-  S2(S2 &s2) : a(s2.a) {}
+  S2(const S2 &s2) : a(s2.a) {}
   static float S2s;
   static const float S2sc;
 };
@@ -27,22 +27,22 @@
 
 public:
   S3() : a(0) {}
-  S3(S3 &s3) : a(s3.a) {}
+  S3(const S3 &s3) : a(s3.a) {}
 };
 const S3 c;
 const S3 ca[5];
 extern const int f;
-class S4 { // expected-note 2 {{'S4' declared here}}
+class S4 {
   int a;
   S4();
-  S4(const S4 &s4);
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note 4 {{'S5' declared here}}
+class S5 {
   int a;
-  S5(const S5 &s5) : a(s5.a) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
 
 public:
   S5() : a(0) {}
@@ -62,8 +62,8 @@
 
 template <class I, class C>
 int foomain(int argc, char **argv) {
-  I e(4); // expected-note {{'e' defined here}}
-  C g(5); // expected-note 2 {{'g' defined here}}
+  I e(4);
+  C g(5);
   int i;
   int &j = i;                              // expected-note {{'j' defined here}}
 #pragma omp parallel sections firstprivate // expected-error {{expected '(' after 'firstprivate'}}
@@ -106,7 +106,7 @@
   {
     foo();
   }
-#pragma omp parallel sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -138,7 +138,7 @@
   {
     foo();
   }
-#pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -158,8 +158,8 @@
 int main(int argc, char **argv) {
   const int d = 5;
   const int da[5] = {0};
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note 2 {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   S3 m;
   S6 n(2);
   int i;
@@ -237,7 +237,7 @@
   {
     foo();
   }
-#pragma omp parallel sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -262,7 +262,7 @@
   {
     foo();
   }
-#pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
diff --git a/test/OpenMP/parallel_sections_messages.cpp b/test/OpenMP/parallel_sections_messages.cpp
index f6ee2fc..f587509 100644
--- a/test/OpenMP/parallel_sections_messages.cpp
+++ b/test/OpenMP/parallel_sections_messages.cpp
@@ -83,4 +83,3 @@
 
   return 0;
 }
-
diff --git a/test/OpenMP/parallel_sections_private_messages.cpp b/test/OpenMP/parallel_sections_private_messages.cpp
index 9bcae83..e0b7488 100644
--- a/test/OpenMP/parallel_sections_private_messages.cpp
+++ b/test/OpenMP/parallel_sections_private_messages.cpp
@@ -24,16 +24,16 @@
   S3() : a(0) {}
 };
 const S3 ca[5];
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5() : a(0) {}
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
 
 public:
   S5(int v) : a(v) {}
@@ -96,7 +96,7 @@
   {
     foo();
   }
-#pragma omp parallel sections copyprivate(i) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
+#pragma omp parallel sections copyprivate(h) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
   {
     foo();
   }
@@ -124,8 +124,8 @@
 }
 
 int main(int argc, char **argv) {
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i;                         // expected-note {{'j' defined here}}
 #pragma omp parallel sections private // expected-error {{expected '(' after 'private'}}
@@ -168,7 +168,7 @@
   {
     foo();
   }
-#pragma omp parallel sections private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+#pragma omp parallel sections private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -176,7 +176,7 @@
   {
     foo();
   }
-#pragma omp parallel sections copyprivate(i) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
+#pragma omp parallel sections copyprivate(h) // expected-error {{unexpected OpenMP clause 'copyprivate' in directive '#pragma omp parallel sections'}}
   {
     foo();
   }
diff --git a/test/OpenMP/sections_firstprivate_messages.cpp b/test/OpenMP/sections_firstprivate_messages.cpp
index b030ce5..ecee459 100644
--- a/test/OpenMP/sections_firstprivate_messages.cpp
+++ b/test/OpenMP/sections_firstprivate_messages.cpp
@@ -14,7 +14,7 @@
 
 public:
   S2() : a(0) {}
-  S2(S2 &s2) : a(s2.a) {}
+  S2(const S2 &s2) : a(s2.a) {}
   static float S2s;
   static const float S2sc;
 };
@@ -27,22 +27,22 @@
 
 public:
   S3() : a(0) {}
-  S3(S3 &s3) : a(s3.a) {}
+  S3(const S3 &s3) : a(s3.a) {}
 };
 const S3 c;
 const S3 ca[5];
 extern const int f;
-class S4 { // expected-note 2 {{'S4' declared here}}
+class S4 {
   int a;
   S4();
-  S4(const S4 &s4);
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note 4 {{'S5' declared here}}
+class S5 {
   int a;
-  S5(const S5 &s5) : a(s5.a) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
 
 public:
   S5() : a(0) {}
@@ -62,8 +62,8 @@
 
 template <class I, class C>
 int foomain(int argc, char **argv) {
-  I e(4); // expected-note {{'e' defined here}}
-  C g(5); // expected-note 2 {{'g' defined here}}
+  I e(4);
+  C g(5);
   int i;
   int &j = i; // expected-note {{'j' defined here}}
 #pragma omp parallel
@@ -117,7 +117,7 @@
     foo();
   }
 #pragma omp parallel
-#pragma omp sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -153,7 +153,7 @@
     foo();
   }
 #pragma omp parallel
-#pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -173,8 +173,8 @@
 int main(int argc, char **argv) {
   const int d = 5;
   const int da[5] = {0};
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note 2 {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   S3 m;
   S6 n(2);
   int i;
@@ -271,7 +271,7 @@
     foo();
   }
 #pragma omp parallel
-#pragma omp sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp sections firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
@@ -301,7 +301,7 @@
     foo();
   }
 #pragma omp parallel
-#pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp sections lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
diff --git a/test/OpenMP/sections_misc_messages.c b/test/OpenMP/sections_misc_messages.c
index 977d154..0297513 100644
--- a/test/OpenMP/sections_misc_messages.c
+++ b/test/OpenMP/sections_misc_messages.c
@@ -24,7 +24,6 @@
     foo();
     foo(); // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}
   }
-
 }
 
 void test_branch_protected_scope() {
@@ -291,3 +290,10 @@
   }
 }
 
+void test_nowait() {
+#pragma omp parallel
+#pragma omp sections nowait nowait // expected-error {{directive '#pragma omp sections' cannot contain more than one 'nowait' clause}}
+  {
+    ;
+  }
+}
diff --git a/test/OpenMP/sections_private_messages.cpp b/test/OpenMP/sections_private_messages.cpp
index 7f5aa84..8b330bf 100644
--- a/test/OpenMP/sections_private_messages.cpp
+++ b/test/OpenMP/sections_private_messages.cpp
@@ -24,16 +24,16 @@
   S3() : a(0) {}
 };
 const S3 ca[5];
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5() : a(0) {}
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
 
 public:
   S5(int v) : a(v) {}
@@ -124,8 +124,8 @@
 }
 
 int main(int argc, char **argv) {
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i;                // expected-note {{'j' defined here}}
 #pragma omp sections private // expected-error {{expected '(' after 'private'}}
@@ -168,7 +168,7 @@
   {
     foo();
   }
-#pragma omp sections private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+#pragma omp sections private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   {
     foo();
   }
diff --git a/test/OpenMP/simd_aligned_messages.cpp b/test/OpenMP/simd_aligned_messages.cpp
index 84cf40c..dfa6b54 100644
--- a/test/OpenMP/simd_aligned_messages.cpp
+++ b/test/OpenMP/simd_aligned_messages.cpp
@@ -39,6 +39,7 @@
   // expected-error@+1 {{expected variable name}}
   #pragma omp simd aligned(B::bfoo())
   for (int i = 0; i < 10; ++i) ;
+  // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
   #pragma omp simd aligned(B::ib,B:C1+C2)
   for (int i = 0; i < 10; ++i) ;
 }
@@ -122,7 +123,7 @@
   for (I k = 0; k < argc; ++k) ++k;
   #pragma omp simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
   for (I k = 0; k < argc; ++k) ++k;
-  #pragma omp simd aligned (argc : 5)
+  #pragma omp simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
   for (I k = 0; k < argc; ++k) ++k;
   #pragma omp simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
   for (I k = 0; k < argc; ++k) ++k;
diff --git a/test/OpenMP/simd_codegen.cpp b/test/OpenMP/simd_codegen.cpp
new file mode 100644
index 0000000..b8073c2
--- /dev/null
+++ b/test/OpenMP/simd_codegen.cpp
@@ -0,0 +1,407 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -g -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}simple{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
+void simple(float *a, float *b, float *c, float *d) {
+  #pragma omp simd
+// CHECK: store i32 0, i32* [[OMP_IV:%[^,]+]]
+
+// CHECK: [[IV:%.+]] = load i32* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP1_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP:%.+]] = icmp slt i32 [[IV]], 6
+// CHECK-NEXT: br i1 [[CMP]], label %[[SIMPLE_LOOP1_BODY:.+]], label %[[SIMPLE_LOOP1_END:[^,]+]]
+  for (int i = 3; i < 32; i += 5) {
+// CHECK: [[SIMPLE_LOOP1_BODY]]
+// Start of body: calculate i from IV:
+// CHECK: [[IV1_1:%.+]] = load i32* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP1_ID]]
+// CHECK: [[CALC_I_1:%.+]] = mul nsw i32 [[IV1_1]], 5
+// CHECK-NEXT: [[CALC_I_2:%.+]] = add nsw i32 3, [[CALC_I_1]]
+// CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP1_ID]]
+// ... loop body ...
+// End of body: store into a[i]:
+// CHECK: store float [[RESULT:%.+]], float* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP1_ID]]
+    a[i] = b[i] * c[i] * d[i];
+// CHECK: [[IV1_2:%.+]] = load i32* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP1_ID]]
+// CHECK-NEXT: [[ADD1_2:%.+]] = add nsw i32 [[IV1_2]], 1
+// CHECK-NEXT: store i32 [[ADD1_2]], i32* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP1_ID]]
+// br label %{{.+}}, !llvm.loop !{{.+}}
+  }
+// CHECK: [[SIMPLE_LOOP1_END]]
+
+  #pragma omp simd
+// CHECK: store i32 0, i32* [[OMP_IV2:%[^,]+]]
+
+// CHECK: [[IV2:%.+]] = load i32* [[OMP_IV2]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP2_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP2:%.+]] = icmp slt i32 [[IV2]], 9
+// CHECK-NEXT: br i1 [[CMP2]], label %[[SIMPLE_LOOP2_BODY:.+]], label %[[SIMPLE_LOOP2_END:[^,]+]]
+  for (int i = 10; i > 1; i--) {
+// CHECK: [[SIMPLE_LOOP2_BODY]]
+// Start of body: calculate i from IV:
+// CHECK: [[IV2_0:%.+]] = load i32* [[OMP_IV2]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP2_ID]]
+// FIXME: It is interesting, why the following "mul 1" was not constant folded?
+// CHECK-NEXT: [[IV2_1:%.+]] = mul nsw i32 [[IV2_0]], 1
+// CHECK-NEXT: [[LC_I_1:%.+]] = sub nsw i32 10, [[IV2_1]]
+// CHECK-NEXT: store i32 [[LC_I_1]], i32* {{.+}}, !llvm.mem.parallel_loop_access ![[SIMPLE_LOOP2_ID]]
+    a[i]++;
+// CHECK: [[IV2_2:%.+]] = load i32* [[OMP_IV2]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP2_ID]]
+// CHECK-NEXT: [[ADD2_2:%.+]] = add nsw i32 [[IV2_2]], 1
+// CHECK-NEXT: store i32 [[ADD2_2]], i32* [[OMP_IV2]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP2_ID]]
+// br label {{.+}}, !llvm.loop ![[SIMPLE_LOOP2_ID]]
+  }
+// CHECK: [[SIMPLE_LOOP2_END]]
+
+  #pragma omp simd
+// CHECK: store i64 0, i64* [[OMP_IV3:%[^,]+]]
+
+// CHECK: [[IV3:%.+]] = load i64* [[OMP_IV3]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP3_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP3:%.+]] = icmp ult i64 [[IV3]], 4
+// CHECK-NEXT: br i1 [[CMP3]], label %[[SIMPLE_LOOP3_BODY:.+]], label %[[SIMPLE_LOOP3_END:[^,]+]]
+  for (unsigned long long it = 2000; it >= 600; it-=400) {
+// CHECK: [[SIMPLE_LOOP3_BODY]]
+// Start of body: calculate it from IV:
+// CHECK: [[IV3_0:%.+]] = load i64* [[OMP_IV3]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP3_ID]]
+// CHECK-NEXT: [[LC_IT_1:%.+]] = mul i64 [[IV3_0]], 400
+// CHECK-NEXT: [[LC_IT_2:%.+]] = sub i64 2000, [[LC_IT_1]]
+// CHECK-NEXT: store i64 [[LC_IT_2]], i64* {{.+}}, !llvm.mem.parallel_loop_access ![[SIMPLE_LOOP3_ID]]
+    a[it]++;
+// CHECK: [[IV3_2:%.+]] = load i64* [[OMP_IV3]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP3_ID]]
+// CHECK-NEXT: [[ADD3_2:%.+]] = add i64 [[IV3_2]], 1
+// CHECK-NEXT: store i64 [[ADD3_2]], i64* [[OMP_IV3]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP3_ID]]
+  }
+// CHECK: [[SIMPLE_LOOP3_END]]
+
+  #pragma omp simd
+// CHECK: store i32 0, i32* [[OMP_IV4:%[^,]+]]
+
+// CHECK: [[IV4:%.+]] = load i32* [[OMP_IV4]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP4_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP4:%.+]] = icmp slt i32 [[IV4]], 4
+// CHECK-NEXT: br i1 [[CMP4]], label %[[SIMPLE_LOOP4_BODY:.+]], label %[[SIMPLE_LOOP4_END:[^,]+]]
+  for (short it = 6; it <= 20; it-=-4) {
+// CHECK: [[SIMPLE_LOOP4_BODY]]
+// Start of body: calculate it from IV:
+// CHECK: [[IV4_0:%.+]] = load i32* [[OMP_IV4]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP4_ID]]
+// CHECK-NEXT: [[LC_IT_1:%.+]] = mul nsw i32 [[IV4_0]], 4
+// CHECK-NEXT: [[LC_IT_2:%.+]] = add nsw i32 6, [[LC_IT_1]]
+// CHECK-NEXT: [[LC_IT_3:%.+]] = trunc i32 [[LC_IT_2]] to i16
+// CHECK-NEXT: store i16 [[LC_IT_3]], i16* {{.+}}, !llvm.mem.parallel_loop_access ![[SIMPLE_LOOP4_ID]]
+
+// CHECK: [[IV4_2:%.+]] = load i32* [[OMP_IV4]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP4_ID]]
+// CHECK-NEXT: [[ADD4_2:%.+]] = add nsw i32 [[IV4_2]], 1
+// CHECK-NEXT: store i32 [[ADD4_2]], i32* [[OMP_IV4]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP4_ID]]
+  }
+// CHECK: [[SIMPLE_LOOP4_END]]
+
+  #pragma omp simd
+// CHECK: store i32 0, i32* [[OMP_IV5:%[^,]+]]
+
+// CHECK: [[IV5:%.+]] = load i32* [[OMP_IV5]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP5_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP5:%.+]] = icmp slt i32 [[IV5]], 26
+// CHECK-NEXT: br i1 [[CMP5]], label %[[SIMPLE_LOOP5_BODY:.+]], label %[[SIMPLE_LOOP5_END:[^,]+]]
+  for (unsigned char it = 'z'; it >= 'a'; it+=-1) {
+// CHECK: [[SIMPLE_LOOP5_BODY]]
+// Start of body: calculate it from IV:
+// CHECK: [[IV5_0:%.+]] = load i32* [[OMP_IV5]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP5_ID]]
+// CHECK-NEXT: [[IV5_1:%.+]] = mul nsw i32 [[IV5_0]], 1
+// CHECK-NEXT: [[LC_IT_1:%.+]] = sub nsw i32 122, [[IV5_1]]
+// CHECK-NEXT: [[LC_IT_2:%.+]] = trunc i32 [[LC_IT_1]] to i8
+// CHECK-NEXT: store i8 [[LC_IT_2]], i8* {{.+}}, !llvm.mem.parallel_loop_access ![[SIMPLE_LOOP5_ID]]
+
+// CHECK: [[IV5_2:%.+]] = load i32* [[OMP_IV5]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP5_ID]]
+// CHECK-NEXT: [[ADD5_2:%.+]] = add nsw i32 [[IV5_2]], 1
+// CHECK-NEXT: store i32 [[ADD5_2]], i32* [[OMP_IV5]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP5_ID]]
+  }
+// CHECK: [[SIMPLE_LOOP5_END]]
+
+  #pragma omp simd
+// FIXME: I think we would get wrong result using 'unsigned' in the loop below.
+// So we'll need to add zero trip test for 'unsigned' counters.
+//
+// CHECK: store i32 0, i32* [[OMP_IV6:%[^,]+]]
+
+// CHECK: [[IV6:%.+]] = load i32* [[OMP_IV6]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP6_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP6:%.+]] = icmp slt i32 [[IV6]], -8
+// CHECK-NEXT: br i1 [[CMP6]], label %[[SIMPLE_LOOP6_BODY:.+]], label %[[SIMPLE_LOOP6_END:[^,]+]]
+  for (int i=100; i<10; i+=10) {
+// CHECK: [[SIMPLE_LOOP6_BODY]]
+// Start of body: calculate i from IV:
+// CHECK: [[IV6_0:%.+]] = load i32* [[OMP_IV6]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP6_ID]]
+// CHECK-NEXT: [[LC_IT_1:%.+]] = mul nsw i32 [[IV6_0]], 10
+// CHECK-NEXT: [[LC_IT_2:%.+]] = add nsw i32 100, [[LC_IT_1]]
+// CHECK-NEXT: store i32 [[LC_IT_2]], i32* {{.+}}, !llvm.mem.parallel_loop_access ![[SIMPLE_LOOP6_ID]]
+
+// CHECK: [[IV6_2:%.+]] = load i32* [[OMP_IV6]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP6_ID]]
+// CHECK-NEXT: [[ADD6_2:%.+]] = add nsw i32 [[IV6_2]], 1
+// CHECK-NEXT: store i32 [[ADD6_2]], i32* [[OMP_IV6]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP6_ID]]
+  }
+// CHECK: [[SIMPLE_LOOP6_END]]
+
+  int A;
+  #pragma omp simd lastprivate(A)
+// Clause 'lastprivate' implementation is not completed yet.
+// Test checks that one iteration is separated in presence of lastprivate.
+//
+// CHECK: store i64 0, i64* [[OMP_IV7:%[^,]+]]
+// CHECK: br i1 true, label %[[SIMPLE_IF7_THEN:.+]], label %[[SIMPLE_IF7_END:[^,]+]]
+// CHECK: [[SIMPLE_IF7_THEN]]
+// CHECK: br label %[[SIMD_LOOP7_COND:[^,]+]]
+// CHECK: [[SIMD_LOOP7_COND]]
+// CHECK-NEXT: [[IV7:%.+]] = load i64* [[OMP_IV7]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP7_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP7:%.+]] = icmp slt i64 [[IV7]], 6
+// CHECK-NEXT: br i1 [[CMP7]], label %[[SIMPLE_LOOP7_BODY:.+]], label %[[SIMPLE_LOOP7_END:[^,]+]]
+  for (long long i = -10; i < 10; i += 3) {
+// CHECK: [[SIMPLE_LOOP7_BODY]]
+// Start of body: calculate i from IV:
+// CHECK: [[IV7_0:%.+]] = load i64* [[OMP_IV7]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP7_ID]]
+// CHECK-NEXT: [[LC_IT_1:%.+]] = mul nsw i64 [[IV7_0]], 3
+// CHECK-NEXT: [[LC_IT_2:%.+]] = add nsw i64 -10, [[LC_IT_1]]
+// CHECK-NEXT: store i64 [[LC_IT_2]], i64* {{.+}}, !llvm.mem.parallel_loop_access ![[SIMPLE_LOOP7_ID]]
+    A = i;
+// CHECK: [[IV7_2:%.+]] = load i64* [[OMP_IV7]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP7_ID]]
+// CHECK-NEXT: [[ADD7_2:%.+]] = add nsw i64 [[IV7_2]], 1
+// CHECK-NEXT: store i64 [[ADD7_2]], i64* [[OMP_IV7]]{{.*}}!llvm.mem.parallel_loop_access ![[SIMPLE_LOOP7_ID]]
+  }
+// CHECK: [[SIMPLE_LOOP7_END]]
+// Separated last iteration.
+// CHECK: [[IV7_4:%.+]] = load i64* [[OMP_IV7]]
+// CHECK-NEXT: [[LC_FIN_1:%.+]] = mul nsw i64 [[IV7_4]], 3
+// CHECK-NEXT: [[LC_FIN_2:%.+]] = add nsw i64 -10, [[LC_FIN_1]]
+// CHECK-NEXT: store i64 [[LC_FIN_2]], i64* [[ADDR_I:%[^,]+]]
+// CHECK: [[LOAD_I:%.+]] = load i64* [[ADDR_I]]
+// CHECK-NEXT: [[CONV_I:%.+]] = trunc i64 [[LOAD_I]] to i32
+//
+// CHECK: br label %[[SIMPLE_IF7_END]]
+// CHECK: [[SIMPLE_IF7_END]]
+//
+
+// CHECK: ret void
+}
+
+template <class T, unsigned K> T tfoo(T a) { return a + K; }
+
+template <typename T, unsigned N>
+int templ1(T a, T *z) {
+  #pragma omp simd collapse(N)
+  for (int i = 0; i < N * 2; i++) {
+    for (long long j = 0; j < (N + N + N + N); j += 2) {
+      z[i + j] = a + tfoo<T, N>(i + j);
+    }
+  }
+  return 0;
+}
+
+// Instatiation templ1<float,2>
+// CHECK-LABEL: define {{.*i32}} @{{.*}}templ1{{.*}}(float {{.+}}, float* {{.+}})
+// CHECK: store i64 0, i64* [[T1_OMP_IV:[^,]+]]
+// ...
+// CHECK: [[IV:%.+]] = load i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP1:%.+]] = icmp slt i64 [[IV]], 16
+// CHECK-NEXT: br i1 [[CMP1]], label %[[T1_BODY:.+]], label %[[T1_END:[^,]+]]
+// CHECK: [[T1_BODY]]
+// Loop counters i and j updates:
+// CHECK: [[IV1:%.+]] = load i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: [[I_1:%.+]] = sdiv i64 [[IV1]], 4
+// CHECK-NEXT: [[I_1_MUL1:%.+]] = mul nsw i64 [[I_1]], 1
+// CHECK-NEXT: [[I_1_ADD0:%.+]] = add nsw i64 0, [[I_1_MUL1]]
+// CHECK-NEXT: [[I_2:%.+]] = trunc i64 [[I_1_ADD0]] to i32
+// CHECK-NEXT: store i32 [[I_2]], i32* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK: [[IV2:%.+]] = load i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: [[J_1:%.+]] = srem i64 [[IV2]], 4
+// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1]], 2
+// CHECK-NEXT: [[J_2_ADD0:%.+]] = add nsw i64 0, [[J_2]]
+// CHECK-NEXT: store i64 [[J_2_ADD0]], i64* {{%.+}}{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// simd.for.inc:
+// CHECK: [[IV3:%.+]] = load i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: [[INC:%.+]] = add nsw i64 [[IV3]], 1
+// CHECK-NEXT: store i64 [[INC]], i64* [[T1_OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[T1_ID]]
+// CHECK-NEXT: br label {{%.+}}
+// CHECK: [[T1_END]]
+// CHECK: ret i32 0
+//
+void inst_templ1() {
+  float a;
+  float z[100];
+  templ1<float,2> (a, z);
+}
+
+
+typedef int MyIdx;
+
+class IterDouble {
+  double *Ptr;
+public:
+  IterDouble operator++ () const {
+    IterDouble n;
+    n.Ptr = Ptr + 1;
+    return n;
+  }
+  bool operator < (const IterDouble &that) const {
+    return Ptr < that.Ptr;
+  }
+  double & operator *() const {
+    return *Ptr;
+  }
+  MyIdx operator - (const IterDouble &that) const {
+    return (MyIdx) (Ptr - that.Ptr);
+  }
+  IterDouble operator + (int Delta) {
+    IterDouble re;
+    re.Ptr = Ptr + Delta;
+    return re;
+  }
+
+  ///~IterDouble() {}
+};
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}iter_simple{{.*}}
+void iter_simple(IterDouble ia, IterDouble ib, IterDouble ic) {
+//
+// CHECK: store i32 0, i32* [[IT_OMP_IV:%[^,]+]]
+// Calculate number of iterations before the loop body.
+// CHECK: [[DIFF1:%.+]] = call {{.*}}i32 @{{.*}}IterDouble{{.*}}
+// CHECK-NEXT: [[DIFF2:%.+]] = sub nsw i32 [[DIFF1]], 1
+// CHECK-NEXT: [[DIFF3:%.+]] = add nsw i32 [[DIFF2]], 1
+// CHECK-NEXT: [[DIFF4:%.+]] = sdiv i32 [[DIFF3]], 1
+// CHECK-NEXT: [[DIFF5:%.+]] = sub nsw i32 [[DIFF4]], 1
+// CHECK-NEXT: store i32 [[DIFF5]], i32* [[OMP_LAST_IT:%[^,]+]]{{.+}}
+  #pragma omp simd
+
+// CHECK: [[IV:%.+]] = load i32* [[IT_OMP_IV]]{{.+}} !llvm.mem.parallel_loop_access ![[ITER_LOOP_ID:[0-9]+]]
+// CHECK-NEXT: [[LAST_IT:%.+]] = load i32* [[OMP_LAST_IT]]{{.+}}!llvm.mem.parallel_loop_access ![[ITER_LOOP_ID]]
+// CHECK-NEXT: [[NUM_IT:%.+]] = add nsw i32 [[LAST_IT]], 1
+// CHECK-NEXT: [[CMP:%.+]] = icmp slt i32 [[IV]], [[NUM_IT]]
+// CHECK-NEXT: br i1 [[CMP]], label %[[IT_BODY:[^,]+]], label %[[IT_END:[^,]+]]
+  for (IterDouble i = ia; i < ib; ++i) {
+// CHECK: [[IT_BODY]]
+// Start of body: calculate i from index:
+// CHECK: [[IV1:%.+]] = load i32* [[IT_OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[ITER_LOOP_ID]]
+// Call of operator+ (i, IV).
+// CHECK: {{%.+}} = call {{.+}} @{{.*}}IterDouble{{.*}}!llvm.mem.parallel_loop_access ![[ITER_LOOP_ID]]
+// ... loop body ...
+   *i = *ic * 0.5;
+// Float multiply and save result.
+// CHECK: [[MULR:%.+]] = fmul double {{%.+}}, 5.000000e-01
+// CHECK-NEXT: call {{.+}} @{{.*}}IterDouble{{.*}}
+// CHECK: store double [[MULR:%.+]], double* [[RESULT_ADDR:%.+]], !llvm.mem.parallel_loop_access ![[ITER_LOOP_ID]]
+   ++ic;
+//
+// CHECK: [[IV2:%.+]] = load i32* [[IT_OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[ITER_LOOP_ID]]
+// CHECK-NEXT: [[ADD2:%.+]] = add nsw i32 [[IV2]], 1
+// CHECK-NEXT: store i32 [[ADD2]], i32* [[IT_OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[ITER_LOOP_ID]]
+// br label %{{.*}}, !llvm.loop ![[ITER_LOOP_ID]]
+  }
+// CHECK: [[IT_END]]
+// CHECK: ret void
+}
+
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}collapsed{{.*}}
+void collapsed(float *a, float *b, float *c, float *d) {
+  int i; // outer loop counter
+  unsigned j; // middle loop couter, leads to unsigned icmp in loop header.
+  // k declared in the loop init below
+  short l; // inner loop counter
+// CHECK: store i32 0, i32* [[OMP_IV:[^,]+]]
+//
+  #pragma omp simd collapse(4)
+
+// CHECK: [[IV:%.+]] = load i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID:[0-9]+]]
+// CHECK-NEXT: [[CMP:%.+]] = icmp ult i32 [[IV]], 120
+// CHECK-NEXT: br i1 [[CMP]], label %[[COLL1_BODY:[^,]+]], label %[[COLL1_END:[^,]+]]
+  for (i = 1; i < 3; i++) // 2 iterations
+    for (j = 2u; j < 5u; j++) //3 iterations
+      for (int k = 3; k <= 6; k++) // 4 iterations
+        for (l = 4; l < 9; ++l) // 5 iterations
+        {
+// CHECK: [[COLL1_BODY]]
+// Start of body: calculate i from index:
+// CHECK: [[IV1:%.+]] = load i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// Calculation of the loop counters values.
+// CHECK: [[CALC_I_1:%.+]] = udiv i32 [[IV1]], 60
+// CHECK-NEXT: [[CALC_I_1_MUL1:%.+]] = mul i32 [[CALC_I_1]], 1
+// CHECK-NEXT: [[CALC_I_2:%.+]] = add i32 1, [[CALC_I_1_MUL1]]
+// CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]
+// CHECK: [[IV1_2:%.+]] = load i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2]], 20
+// CHECK-NEXT: [[CALC_J_2:%.+]] = urem i32 [[CALC_J_1]], 3
+// CHECK-NEXT: [[CALC_J_2_MUL1:%.+]] = mul i32 [[CALC_J_2]], 1
+// CHECK-NEXT: [[CALC_J_3:%.+]] = add i32 2, [[CALC_J_2_MUL1]]
+// CHECK-NEXT: store i32 [[CALC_J_3]], i32* [[LC_J:.+]]
+// CHECK: [[IV1_3:%.+]] = load i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[CALC_K_1:%.+]] = udiv i32 [[IV1_3]], 5
+// CHECK-NEXT: [[CALC_K_2:%.+]] = urem i32 [[CALC_K_1]], 4
+// CHECK-NEXT: [[CALC_K_2_MUL1:%.+]] = mul i32 [[CALC_K_2]], 1
+// CHECK-NEXT: [[CALC_K_3:%.+]] = add i32 3, [[CALC_K_2_MUL1]]
+// CHECK-NEXT: store i32 [[CALC_K_3]], i32* [[LC_K:.+]]
+// CHECK: [[IV1_4:%.+]] = load i32* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[CALC_L_1:%.+]] = urem i32 [[IV1_4]], 5
+// CHECK-NEXT: [[CALC_L_1_MUL1:%.+]] = mul i32 [[CALC_L_1]], 1
+// CHECK-NEXT: [[CALC_L_2:%.+]] = add i32 4, [[CALC_L_1_MUL1]]
+// CHECK-NEXT: [[CALC_L_3:%.+]] = trunc i32 [[CALC_L_2]] to i16
+// CHECK-NEXT: store i16 [[CALC_L_3]], i16* [[LC_L:.+]]
+// ... loop body ...
+// End of body: store into a[i]:
+// CHECK: store float [[RESULT:%.+]], float* [[RESULT_ADDR:%.+]]{{.+}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+    float res = b[j] * c[k];
+    a[i] = res * d[l];
+// CHECK: [[IV2:%.+]] = load i32* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// CHECK-NEXT: [[ADD2:%.+]] = add i32 [[IV2]], 1
+// CHECK-NEXT: store i32 [[ADD2]], i32* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[COLL1_LOOP_ID]]
+// br label %{{[^,]+}}, !llvm.loop ![[COLL1_LOOP_ID]]
+// CHECK: [[COLL1_END]]
+  }
+// i,j,l are updated; k is not updated.
+// CHECK: store i32 3, i32* [[I:%[^,]+]]
+// CHECK-NEXT: store i32 5, i32* [[I:%[^,]+]]
+// CHECK-NEXT: store i16 9, i16* [[I:%[^,]+]]
+// CHECK: ret void
+}
+
+extern char foo();
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}widened{{.*}}
+void widened(float *a, float *b, float *c, float *d) {
+  int i; // outer loop counter
+  short j; // inner loop counter
+// Counter is widened to 64 bits.
+// CHECK: store i64 0, i64* [[OMP_IV:[^,]+]]
+//
+  #pragma omp simd collapse(2)
+
+// CHECK: [[IV:%.+]] = load i64* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID:[0-9]+]]
+// CHECK-NEXT: [[LI:%.+]] = load i64* [[OMP_LI:%[^,]+]]{{.+}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID]]
+// CHECK-NEXT: [[NUMIT:%.+]] = add nsw i64 [[LI]], 1
+// CHECK-NEXT: [[CMP:%.+]] = icmp slt i64 [[IV]], [[NUMIT]]
+// CHECK-NEXT: br i1 [[CMP]], label %[[WIDE1_BODY:[^,]+]], label %[[WIDE1_END:[^,]+]]
+  for (i = 1; i < 3; i++) // 2 iterations
+    for (j = 0; j < foo(); j++) // foo() iterations
+  {
+// CHECK: [[WIDE1_BODY]]
+// Start of body: calculate i from index:
+// CHECK: [[IV1:%.+]] = load i64* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID]]
+// Calculation of the loop counters values...
+// CHECK: store i32 {{[^,]+}}, i32* [[LC_I:.+]]
+// CHECK: [[IV1_2:%.+]] = load i64* [[OMP_IV]]{{.+}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID]]
+// CHECK: store i16 {{[^,]+}}, i16* [[LC_J:.+]]
+// ... loop body ...
+// End of body: store into a[i]:
+// CHECK: store float [[RESULT:%.+]], float* [[RESULT_ADDR:%.+]]{{.+}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID]]
+    float res = b[j] * c[j];
+    a[i] = res * d[i];
+// CHECK: [[IV2:%.+]] = load i64* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID]]
+// CHECK-NEXT: [[ADD2:%.+]] = add nsw i64 [[IV2]], 1
+// CHECK-NEXT: store i64 [[ADD2]], i64* [[OMP_IV]]{{.*}}!llvm.mem.parallel_loop_access ![[WIDE1_LOOP_ID]]
+// br label %{{[^,]+}}, !llvm.loop ![[WIDE1_LOOP_ID]]
+// CHECK: [[WIDE1_END]]
+  }
+// i,j are updated.
+// CHECK: store i32 3, i32* [[I:%[^,]+]]
+// CHECK: store i16
+// CHECK: ret void
+}
+
+#endif // HEADER
+
diff --git a/test/OpenMP/simd_loop_messages.cpp b/test/OpenMP/simd_loop_messages.cpp
index ea663fd..ce64842 100644
--- a/test/OpenMP/simd_loop_messages.cpp
+++ b/test/OpenMP/simd_loop_messages.cpp
@@ -2,6 +2,7 @@
 
 static int sii;
 #pragma omp threadprivate(sii) // expected-note {{defined as threadprivate or thread local}}
+static int globalii;
 
 int test_iteration_spaces() {
   const int N = 100;
@@ -257,6 +258,23 @@
       c[sii] = a[sii];
   }
 
+  #pragma omp parallel
+  {
+    // expected-error@+2 {{loop iteration variable in the associated loop of 'omp simd' directive may not be a variable with global storage without being explicitly marked as linear}}
+    #pragma omp simd
+    for (globalii = 0; globalii < 10; globalii+=1)
+      c[globalii] = a[globalii];
+  }
+
+  #pragma omp parallel
+  {
+// expected-error@+3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be a variable with global storage without being explicitly marked as lastprivate}}
+#pragma omp simd collapse(2)
+    for (ii = 0; ii < 10; ii += 1)
+    for (globalii = 0; globalii < 10; globalii += 1)
+      c[globalii] += a[globalii] + ii;
+  }
+
   // expected-error@+2 {{statement after '#pragma omp simd' must be a for loop}}
   #pragma omp simd
   for (auto &item : a) {
@@ -300,8 +318,10 @@
     Iter0(const Iter0 &) { }
     Iter0 operator ++() { return *this; }
     Iter0 operator --() { return *this; }
+    Iter0 operator + (int delta) { return *this; }
     bool operator <(Iter0 a) { return true; }
 };
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
 int operator -(Iter0 a, Iter0 b) { return 0; }
 class Iter1 {
   public:
@@ -330,10 +350,14 @@
     typedef int difference_type;
     typedef std::random_access_iterator_tag iterator_category;
 };
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
 int operator -(GoodIter a, GoodIter b) { return 0; }
+// expected-note@+1 2 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
 GoodIter operator -(GoodIter a) { return a; }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
 GoodIter operator -(GoodIter a, int v) { return GoodIter(); }
 GoodIter operator +(GoodIter a, int v) { return GoodIter(); }
+// expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
 GoodIter operator -(int v, GoodIter a) { return GoodIter(); }
 GoodIter operator +(int v, GoodIter a) { return GoodIter(); }
 
@@ -370,7 +394,7 @@
   for (begin = GoodIter(0); begin < end; ++begin)
     ++begin;
   #pragma omp simd
-  for (begin = begin0; begin < end; ++begin)
+  for (begin = GoodIter(1,2); begin < end; ++begin)
     ++begin;
   // expected-error@+2 {{initialization clause of OpenMP for loop must be of the form 'var = init' or 'T var = init'}}
   #pragma omp simd
@@ -415,12 +439,16 @@
   #pragma omp simd
   for (Iter0 I = begin0; I < end0; ++I)
     ++I;
+
   // Initializer is constructor without params.
   // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
   #pragma omp simd
   for (Iter0 I; I < end0; ++I)
     ++I;
+
   Iter1 begin1, end1;
+  // expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+  // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
   #pragma omp simd
   for (Iter1 I = begin1; I < end1; ++I)
     ++I;
@@ -429,11 +457,15 @@
   #pragma omp simd
   for (Iter1 I = begin1; I >= end1; ++I)
     ++I;
+
   // Initializer is constructor with all default params.
+  // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
+  // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
   // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
   #pragma omp simd
   for (Iter1 I; I < end1; ++I) {
   }
+
   return 0;
 }
 
diff --git a/test/OpenMP/simd_metadata.c b/test/OpenMP/simd_metadata.c
index a0588ad..9879d84 100644
--- a/test/OpenMP/simd_metadata.c
+++ b/test/OpenMP/simd_metadata.c
@@ -1,10 +1,23 @@
-// RUN: %clang_cc1 -fopenmp=libiomp5 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -triple powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 
-void h1(float *c, float *a, float *b, int size)
+void h1(float *c, float *a, double b[], int size)
 {
 // CHECK-LABEL: define void @h1
   int t = 0;
-#pragma omp simd safelen(16) linear(t)
+#pragma omp simd safelen(16) linear(t) aligned(c:32) aligned(a,b)
+// CHECK:         [[C_PTRINT:%.+]] = ptrtoint
+// CHECK-NEXT:    [[C_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[C_PTRINT]], 31
+// CHECK-NEXT:    [[C_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[C_MASKEDPTR]], 0
+// CHECK-NEXT:    call void @llvm.assume(i1 [[C_MASKCOND]])
+// CHECK:         [[A_PTRINT:%.+]] = ptrtoint
+// CHECK-NEXT:    [[A_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[A_PTRINT]], 15
+// CHECK-NEXT:    [[A_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[A_MASKEDPTR]], 0
+// CHECK-NEXT:    call void @llvm.assume(i1 [[A_MASKCOND]])
+// CHECK:         [[B_PTRINT:%.+]] = ptrtoint
+// CHECK-NEXT:    [[B_MASKEDPTR:%.+]] = and i{{[0-9]+}} [[B_PTRINT]], 15
+// CHECK-NEXT:    [[B_MASKCOND:%.+]] = icmp eq i{{[0-9]+}} [[B_MASKEDPTR]], 0
+// CHECK-NEXT:    call void @llvm.assume(i1 [[B_MASKCOND]])
   for (int i = 0; i < size; ++i) {
     c[i] = a[i] * a[i] + b[i] * b[t];
     ++t;
diff --git a/test/OpenMP/simd_misc_messages.c b/test/OpenMP/simd_misc_messages.c
index 67edc6d..f94bb38 100644
--- a/test/OpenMP/simd_misc_messages.c
+++ b/test/OpenMP/simd_misc_messages.c
@@ -9,26 +9,25 @@
 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}}
 #pragma omp simd safelen(4)
 
-void test_no_clause()
-{
+void test_no_clause() {
   int i;
-  #pragma omp simd
-  for (i = 0; i < 16; ++i) ;
+#pragma omp simd
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-error@+2 {{statement after '#pragma omp simd' must be a for loop}}
-  #pragma omp simd
+// expected-error@+2 {{statement after '#pragma omp simd' must be a for loop}}
+#pragma omp simd
   ++i;
 }
 
-void test_branch_protected_scope()
-{
+void test_branch_protected_scope() {
   int i = 0;
 L1:
   ++i;
 
   int x[24];
 
-  #pragma omp simd
+#pragma omp simd
   for (i = 0; i < 16; ++i) {
     if (i == 5)
       goto L1; // expected-error {{use of undeclared label 'L1'}}
@@ -37,7 +36,7 @@
     else if (i == 7)
       goto L2;
     else if (i == 8) {
-L2:
+    L2:
       x[i]++;
     }
   }
@@ -48,506 +47,632 @@
     goto L1;
 }
 
-void test_invalid_clause()
-{
+void test_invalid_clause() {
   int i;
-  // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  #pragma omp simd foo bar
-  for (i = 0; i < 16; ++i) ;
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+#pragma omp simd foo bar
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_non_identifiers()
-{
+void test_non_identifiers() {
   int i, x;
 
-  // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  #pragma omp simd;
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}}
-  // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  #pragma omp simd firstprivate(x);
-  for (i = 0; i < 16; ++i) ;
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+#pragma omp simd;
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}}
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+#pragma omp simd firstprivate(x);
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  #pragma omp simd private(x);
-  for (i = 0; i < 16; ++i) ;
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+#pragma omp simd private(x);
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  #pragma omp simd , private(x);
-  for (i = 0; i < 16; ++i) ;
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+#pragma omp simd, private(x);
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
 extern int foo();
-void test_safelen()
-{
+void test_safelen() {
   int i;
-  // expected-error@+1 {{expected '('}}
-  #pragma omp simd safelen
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd safelen()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(,)
-  for (i = 0; i < 16; ++i) ;
-  // expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  // expected-error@+1 {{expected '('}}
-  #pragma omp simd safelen 4)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(4
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(4,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(4,)
-  for (i = 0; i < 16; ++i) ;
-  // xxpected-error@+1 {{expected expression}}
-  #pragma omp simd safelen(4)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(4 4)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(4,,4)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd safelen(4)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}}
-  #pragma omp simd safelen(4,8)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expression is not an integer constant expression}}
-  #pragma omp simd safelen(2.5)
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{expression is not an integer constant expression}}
-  #pragma omp simd safelen(foo())
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
-  #pragma omp simd safelen(-5)
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
-  #pragma omp simd safelen(0)
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
-  #pragma omp simd safelen(5-5)
-  for (i = 0; i < 16; ++i);
+// expected-error@+1 {{expected '('}}
+#pragma omp simd safelen
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd safelen()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp simd safelen 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(4
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(4,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(4, )
+  for (i = 0; i < 16; ++i)
+    ;
+// xxpected-error@+1 {{expected expression}}
+#pragma omp simd safelen(4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(4 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(4, , 4)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd safelen(4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}}
+#pragma omp simd safelen(4, 8)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp simd safelen(2.5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp simd safelen(foo())
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp simd safelen(-5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp simd safelen(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'safelen' clause must be a positive integer value}}
+#pragma omp simd safelen(5 - 5)
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_collapse()
-{
+void test_collapse() {
   int i;
-  // expected-error@+1 {{expected '('}}
-  #pragma omp simd collapse
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd collapse(
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd collapse()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd collapse(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd collapse(,)
-  for (i = 0; i < 16; ++i) ;
-  // expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
-  // expected-error@+1 {{expected '('}}
-  #pragma omp simd collapse 4)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4,
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4,)
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  // xxpected-error@+1 {{expected expression}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4)
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4 4)
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4,,4)
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  #pragma omp simd collapse(4)
+// expected-error@+1 {{expected '('}}
+#pragma omp simd collapse
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd collapse(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd collapse()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd collapse(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd collapse(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
+// expected-error@+1 {{expected '('}}
+#pragma omp simd collapse 4)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4,
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4, )
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+// xxpected-error@+1 {{expected expression}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4 4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4, , 4)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+#pragma omp simd collapse(4)
   for (int i1 = 0; i1 < 16; ++i1)
     for (int i2 = 0; i2 < 16; ++i2)
       for (int i3 = 0; i3 < 16; ++i3)
         for (int i4 = 0; i4 < 16; ++i4)
           foo();
-  // expected-error@+2 {{expected ')'}}
-  // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
-  #pragma omp simd collapse(4,8)
-  for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
-  // expected-error@+1 {{expression is not an integer constant expression}}
-  #pragma omp simd collapse(2.5)
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{expression is not an integer constant expression}}
-  #pragma omp simd collapse(foo())
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
-  #pragma omp simd collapse(-5)
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
-  #pragma omp simd collapse(0)
-  for (i = 0; i < 16; ++i);
-  // expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
-  #pragma omp simd collapse(5-5)
-  for (i = 0; i < 16; ++i);
+// expected-error@+2 {{expected ')'}}
+// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
+#pragma omp simd collapse(4, 8)
+  for (i = 0; i < 16; ++i)
+    ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp simd collapse(2.5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expression is not an integer constant expression}}
+#pragma omp simd collapse(foo())
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp simd collapse(-5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp simd collapse(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument to 'collapse' clause must be a positive integer value}}
+#pragma omp simd collapse(5 - 5)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-note@+2 {{defined as reduction}}
+#pragma omp parallel
+#pragma omp simd collapse(2) reduction(+ : i)
+  for (i = 0; i < 16; ++i)
+    // expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
+    for (int j = 0; j < 16; ++j)
+// expected-error@+3 {{reduction variable must be shared}}
+// expected-error@+2 {{private variable cannot be reduction}}
+// expected-error@+1 {{OpenMP constructs may not be nested inside a simd region}}
+#pragma omp for reduction(+ : i, j)
+      for (int k = 0; k < 16; ++k)
+        i += j;
 }
 
-void test_linear()
-{
+void test_linear() {
   int i;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd linear(
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected expression}}
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd linear(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected expression}}
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd linear(,)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd linear()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd linear(int)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected variable name}}
-  #pragma omp simd linear(0)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{use of undeclared identifier 'x'}}
-  #pragma omp simd linear(x)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{use of undeclared identifier 'x'}}
-  // expected-error@+1 {{use of undeclared identifier 'y'}}
-  #pragma omp simd linear(x, y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+3 {{use of undeclared identifier 'x'}}
-  // expected-error@+2 {{use of undeclared identifier 'y'}}
-  // expected-error@+1 {{use of undeclared identifier 'z'}}
-  #pragma omp simd linear(x, y, z)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd linear(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd linear(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}}
+#pragma omp simd linear(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd linear()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd linear(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp simd linear(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{use of undeclared identifier 'x'}}
+#pragma omp simd linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{use of undeclared identifier 'x'}}
+// expected-error@+1 {{use of undeclared identifier 'y'}}
+#pragma omp simd linear(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{use of undeclared identifier 'x'}}
+// expected-error@+2 {{use of undeclared identifier 'y'}}
+// expected-error@+1 {{use of undeclared identifier 'z'}}
+#pragma omp simd linear(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
 
   int x, y;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd linear(x:)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd linear(x:,)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd linear(x:1)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd linear(x:2*2)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd linear(x:1,y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd linear(x:1,y,z:1)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd linear(x :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd linear(x :, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd linear(x : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd linear(x : 2 * 2)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd linear(x : 1, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd linear(x : 1, y, z : 1)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+2 {{defined as linear}}
-  // expected-error@+1 {{linear variable cannot be linear}}
-  #pragma omp simd linear(x) linear(x)
-  for (i = 0; i < 16; ++i) ;
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be linear}}
+#pragma omp simd linear(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+2 {{defined as private}}
-  // expected-error@+1 {{private variable cannot be linear}}
-  #pragma omp simd private(x) linear(x)
-  for (i = 0; i < 16; ++i) ;
+// expected-note@+2 {{defined as private}}
+// expected-error@+1 {{private variable cannot be linear}}
+#pragma omp simd private(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+2 {{defined as linear}}
-  // expected-error@+1 {{linear variable cannot be private}}
-  #pragma omp simd linear(x) private(x)
-  for (i = 0; i < 16; ++i) ;
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be private}}
+#pragma omp simd linear(x) private(x)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-warning@+1 {{zero linear step (x and other variables in clause should probably be const)}}
-  #pragma omp simd linear(x,y:0)
-  for (i = 0; i < 16; ++i) ;
+// expected-warning@+1 {{zero linear step (x and other variables in clause should probably be const)}}
+#pragma omp simd linear(x, y : 0)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+2 {{defined as linear}}
-  // expected-error@+1 {{linear variable cannot be lastprivate}}
-  #pragma omp simd linear(x) lastprivate(x)
-  for (i = 0; i < 16; ++i) ;
+// expected-note@+2 {{defined as linear}}
+// expected-error@+1 {{linear variable cannot be lastprivate}}
+#pragma omp simd linear(x) lastprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+2 {{defined as lastprivate}}
-  // expected-error@+1 {{lastprivate variable cannot be linear}}
-  #pragma omp simd lastprivate(x) linear(x) 
-  for (i = 0; i < 16; ++i) ;
-
+// expected-note@+2 {{defined as lastprivate}}
+// expected-error@+1 {{lastprivate variable cannot be linear}}
+#pragma omp simd lastprivate(x) linear(x)
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_aligned()
-{
+void test_aligned() {
   int i;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd aligned(
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected expression}}
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd aligned(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected expression}}
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd aligned(,)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd aligned()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd aligned(int)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected variable name}}
-  #pragma omp simd aligned(0)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{use of undeclared identifier 'x'}}
-  #pragma omp simd aligned(x)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{use of undeclared identifier 'x'}}
-  // expected-error@+1 {{use of undeclared identifier 'y'}}
-  #pragma omp simd aligned(x, y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+3 {{use of undeclared identifier 'x'}}
-  // expected-error@+2 {{use of undeclared identifier 'y'}}
-  // expected-error@+1 {{use of undeclared identifier 'z'}}
-  #pragma omp simd aligned(x, y, z)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd aligned(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd aligned(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected expression}}
+#pragma omp simd aligned(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd aligned()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd aligned(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp simd aligned(0)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{use of undeclared identifier 'x'}}
+#pragma omp simd aligned(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{use of undeclared identifier 'x'}}
+// expected-error@+1 {{use of undeclared identifier 'y'}}
+#pragma omp simd aligned(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{use of undeclared identifier 'x'}}
+// expected-error@+2 {{use of undeclared identifier 'y'}}
+// expected-error@+1 {{use of undeclared identifier 'z'}}
+#pragma omp simd aligned(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
 
   int *x, y, z[25]; // expected-note 4 {{'y' defined here}}
-  #pragma omp simd aligned(x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd aligned(z)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd aligned(x:)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd aligned(x:,)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd aligned(x:1)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd aligned(x:2*2)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd aligned(x:1,y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd aligned(x:1,y,z:1)
-  for (i = 0; i < 16; ++i) ;
+#pragma omp simd aligned(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd aligned(z)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd aligned(x :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd aligned(x :, )
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd aligned(x : 1)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd aligned(x : 2 * 2)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd aligned(x : 1, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd aligned(x : 1, y, z : 1)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
-  #pragma omp simd aligned(x, y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
-  #pragma omp simd aligned(x, y, z)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp simd aligned(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp simd aligned(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+2 {{defined as aligned}}
-  // expected-error@+1 {{a variable cannot appear in more than one aligned clause}}
-  #pragma omp simd aligned(x) aligned(z,x)
-  for (i = 0; i < 16; ++i) ;
+// expected-note@+2 {{defined as aligned}}
+// expected-error@+1 {{a variable cannot appear in more than one aligned clause}}
+#pragma omp simd aligned(x) aligned(z, x)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-note@+3 {{defined as aligned}}
-  // expected-error@+2 {{a variable cannot appear in more than one aligned clause}}
-  // expected-error@+1 2 {{argument of aligned clause should be array or pointer, not 'int'}}
-  #pragma omp simd aligned(x,y,z) aligned(y,z)
-  for (i = 0; i < 16; ++i) ;
+// expected-note@+3 {{defined as aligned}}
+// expected-error@+2 {{a variable cannot appear in more than one aligned clause}}
+// expected-error@+1 2 {{argument of aligned clause should be array or pointer, not 'int'}}
+#pragma omp simd aligned(x, y, z) aligned(y, z)
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_private()
-{
+void test_private() {
   int i;
-  // expected-error@+2 {{expected expression}}
-  // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
-  #pragma omp simd private(
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
-  // expected-error@+1 2 {{expected expression}}
-  #pragma omp simd private(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 2 {{expected expression}}
-  #pragma omp simd private(,)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd private()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd private(int)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected variable name}}
-  #pragma omp simd private(0)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+2 {{expected expression}}
+// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
+#pragma omp simd private(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp simd private(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 2 {{expected expression}}
+#pragma omp simd private(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd private()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd private(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp simd private(0)
+  for (i = 0; i < 16; ++i)
+    ;
 
   int x, y, z;
-  #pragma omp simd private(x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd private(x, y)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd private(x, y, z)
+#pragma omp simd private(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd private(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd private(x, y, z)
   for (i = 0; i < 16; ++i) {
     x = y * i + z;
   }
 }
 
-void test_firstprivate()
-{
+void test_firstprivate() {
   int i;
-  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
-  // expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}}
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd firstprivate(
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}}
+// expected-error@+1 {{expected expression}}
+#pragma omp simd firstprivate(
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_lastprivate()
-{
+void test_lastprivate() {
   int i;
-  // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd lastprivate(
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 {{expected expression}}
+#pragma omp simd lastprivate(
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
-  // expected-error@+1 2 {{expected expression}}
-  #pragma omp simd lastprivate(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 2 {{expected expression}}
-  #pragma omp simd lastprivate(,)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd lastprivate()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd lastprivate(int)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected variable name}}
-  #pragma omp simd lastprivate(0)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
+// expected-error@+1 2 {{expected expression}}
+#pragma omp simd lastprivate(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 2 {{expected expression}}
+#pragma omp simd lastprivate(, )
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd lastprivate()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd lastprivate(int)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp simd lastprivate(0)
+  for (i = 0; i < 16; ++i)
+    ;
 
   int x, y, z;
-  #pragma omp simd lastprivate(x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd lastprivate(x, y)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd lastprivate(x, y, z)
-  for (i = 0; i < 16; ++i) ;
+#pragma omp simd lastprivate(x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd lastprivate(x, y)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd lastprivate(x, y, z)
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_reduction()
-{
+void test_reduction() {
   int i, x, y;
-  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
-  // expected-error@+2 {{expected identifier}}
-  // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
-  #pragma omp simd reduction(
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected identifier}}
-  // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
-  #pragma omp simd reduction()
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected expression}}
-  // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
-  #pragma omp simd reduction(x)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected identifier}}
-  #pragma omp simd reduction(:x)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
-  // expected-error@+2 {{expected identifier}}
-  // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
-  #pragma omp simd reduction(,
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
-  // expected-error@+2 {{expected expression}}
-  // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
-  #pragma omp simd reduction(+
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expected identifier}}
+// expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp simd reduction(
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected identifier}}
+// expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp simd reduction()
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+2 {{expected expression}}
+// expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp simd reduction(x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected identifier}}
+#pragma omp simd reduction( : x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expected identifier}}
+// expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp simd reduction(,
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+// expected-error@+2 {{expected expression}}
+// expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
+#pragma omp simd reduction(+
+  for (i = 0; i < 16; ++i)
+    ;
 
-  // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
-  //
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd reduction(+:
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd reduction(+:)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd reduction(+:,y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected expression}}
-  #pragma omp simd reduction(+:x,+:y)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+2 {{expected identifier}}
-  // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
-  #pragma omp simd reduction(%:x)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
+//
+// expected-error@+1 {{expected expression}}
+#pragma omp simd reduction(+:
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd reduction(+ :)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd reduction(+ :, y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected expression}}
+#pragma omp simd reduction(+ : x, + : y)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected identifier}}
+#pragma omp simd reduction(% : x)
+  for (i = 0; i < 16; ++i)
+    ;
 
-  #pragma omp simd reduction(+:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(*:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(-:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(&:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(|:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(^:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(&&:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(||:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(max:x)
-  for (i = 0; i < 16; ++i) ;
-  #pragma omp simd reduction(min:x)
-  for (i = 0; i < 16; ++i) ;
-  struct X { int x; };
+#pragma omp simd reduction(+ : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(* : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(- : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(& : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(| : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(^ : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(&& : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(|| : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(max : x)
+  for (i = 0; i < 16; ++i)
+    ;
+#pragma omp simd reduction(min : x)
+  for (i = 0; i < 16; ++i)
+    ;
+  struct X {
+    int x;
+  };
   struct X X;
-  // expected-error@+1 {{expected variable name}}
-  #pragma omp simd reduction(+:X.x)
-  for (i = 0; i < 16; ++i) ;
-  // expected-error@+1 {{expected variable name}}
-  #pragma omp simd reduction(+:x+x)
-  for (i = 0; i < 16; ++i) ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp simd reduction(+ : X.x)
+  for (i = 0; i < 16; ++i)
+    ;
+// expected-error@+1 {{expected variable name}}
+#pragma omp simd reduction(+ : x + x)
+  for (i = 0; i < 16; ++i)
+    ;
 }
 
-void test_loop_messages()
-{
+void test_loop_messages() {
   float a[100], b[100], c[100];
-  // expected-error@+2 {{variable must be of integer or pointer type}}
-  #pragma omp simd
+// expected-error@+2 {{variable must be of integer or pointer type}}
+#pragma omp simd
   for (float fi = 0; fi < 10.0; fi++) {
     c[(int)fi] = a[(int)fi] + b[(int)fi];
   }
-  // expected-error@+2 {{variable must be of integer or pointer type}}
-  #pragma omp simd
+// expected-error@+2 {{variable must be of integer or pointer type}}
+#pragma omp simd
   for (double fi = 0; fi < 10.0; fi++) {
     c[(int)fi] = a[(int)fi] + b[(int)fi];
   }
diff --git a/test/OpenMP/simd_private_messages.cpp b/test/OpenMP/simd_private_messages.cpp
index e5e4fe5..56922e8 100644
--- a/test/OpenMP/simd_private_messages.cpp
+++ b/test/OpenMP/simd_private_messages.cpp
@@ -22,15 +22,15 @@
   S3():a(0) { }
 };
 const S3 ca[5];
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 public:
   S4(int v):a(v) { }
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5():a(0) {}
+  S5():a(0) {} // expected-note {{implicitly declared private here}}
 public:
   S5(int v):a(v) { }
 };
@@ -86,8 +86,8 @@
 }
 
 int main(int argc, char **argv) {
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i; // expected-note {{'j' defined here}}
   #pragma omp simd private // expected-error {{expected '(' after 'private'}}
@@ -110,7 +110,7 @@
   for (int k = 0; k < argc; ++k) ++k;
   #pragma omp simd private (argv[1]) // expected-error {{expected variable name}}
   for (int k = 0; k < argc; ++k) ++k;
-  #pragma omp simd private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+  #pragma omp simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   for (int k = 0; k < argc; ++k) ++k;
   #pragma omp simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
   for (int k = 0; k < argc; ++k) ++k;
diff --git a/test/OpenMP/single_copyprivate_messages.cpp b/test/OpenMP/single_copyprivate_messages.cpp
index f07ab12..7bb145c 100644
--- a/test/OpenMP/single_copyprivate_messages.cpp
+++ b/test/OpenMP/single_copyprivate_messages.cpp
@@ -155,3 +155,23 @@
 
   return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char>' requested here}}
 }
+
+extern void abort(void);
+
+void
+single(int a, int b) {
+#pragma omp single copyprivate(a) copyprivate(b)
+  {
+    a = b = 5;
+  }
+
+  if (a != b)
+    abort();
+}
+
+int parallel() {
+#pragma omp parallel
+  single(1, 2);
+
+  return 0;
+}
diff --git a/test/OpenMP/single_firstprivate_messages.cpp b/test/OpenMP/single_firstprivate_messages.cpp
index 6d49882..9f6f160 100644
--- a/test/OpenMP/single_firstprivate_messages.cpp
+++ b/test/OpenMP/single_firstprivate_messages.cpp
@@ -14,7 +14,7 @@
 
 public:
   S2() : a(0) {}
-  S2(S2 &s2) : a(s2.a) {}
+  S2(const S2 &s2) : a(s2.a) {}
   static float S2s;
   static const float S2sc;
 };
@@ -27,22 +27,22 @@
 
 public:
   S3() : a(0) {}
-  S3(S3 &s3) : a(s3.a) {}
+  S3(const S3 &s3) : a(s3.a) {}
 };
 const S3 c;
 const S3 ca[5];
 extern const int f;
-class S4 { // expected-note 2 {{'S4' declared here}}
+class S4 {
   int a;
   S4();
-  S4(const S4 &s4);
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note 4 {{'S5' declared here}}
+class S5 {
   int a;
-  S5(const S5 &s5) : a(s5.a) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
 
 public:
   S5() : a(0) {}
@@ -62,8 +62,8 @@
 
 template <class I, class C>
 int foomain(int argc, char **argv) {
-  I e(4); // expected-note {{'e' defined here}}
-  C g(5); // expected-note 2 {{'g' defined here}}
+  I e(4);
+  C g(5);
   int i;
   int &j = i; // expected-note {{'j' defined here}}
 #pragma omp parallel
@@ -97,7 +97,7 @@
 #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
   foo();
 #pragma omp parallel
-#pragma omp single firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   foo();
 #pragma omp parallel
 #pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
@@ -121,7 +121,7 @@
 #pragma omp single firstprivate(i)
   foo();
 #pragma omp parallel
-#pragma omp single firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   foo();
 #pragma omp parallel private(i)    // expected-note {{defined as private}}
 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
@@ -135,8 +135,8 @@
 int main(int argc, char **argv) {
   const int d = 5;
   const int da[5] = {0};
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note 2 {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   S3 m;
   S6 n(2);
   int i;
@@ -197,7 +197,7 @@
 #pragma omp single safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp single'}}
   foo();
 #pragma omp parallel
-#pragma omp single firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   foo();
 #pragma omp parallel
 #pragma omp single firstprivate(m) // OK
@@ -215,7 +215,7 @@
 #pragma omp single firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
   foo();
 #pragma omp parallel
-#pragma omp single firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
+#pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
   foo();
 #pragma omp parallel
 #pragma omp single firstprivate(n) // OK
diff --git a/test/OpenMP/single_misc_messages.c b/test/OpenMP/single_misc_messages.c
index 8667b50..7c10ca0 100644
--- a/test/OpenMP/single_misc_messages.c
+++ b/test/OpenMP/single_misc_messages.c
@@ -149,3 +149,8 @@
   foo();
 }
 
+void test_nowait() {
+#pragma omp single nowait nowait // expected-error {{directive '#pragma omp single' cannot contain more than one 'nowait' clause}}
+  for (int i = 0; i < 16; ++i)
+    ;
+}
diff --git a/test/OpenMP/single_private_messages.cpp b/test/OpenMP/single_private_messages.cpp
index 1414a92..8bdc48f 100644
--- a/test/OpenMP/single_private_messages.cpp
+++ b/test/OpenMP/single_private_messages.cpp
@@ -24,16 +24,16 @@
   S3() : a(0) {}
 };
 const S3 ca[5];
-class S4 { // expected-note {{'S4' declared here}}
+class S4 {
   int a;
-  S4();
+  S4(); // expected-note {{implicitly declared private here}}
 
 public:
   S4(int v) : a(v) {}
 };
-class S5 { // expected-note {{'S5' declared here}}
+class S5 {
   int a;
-  S5() : a(0) {}
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
 
 public:
   S5(int v) : a(v) {}
@@ -92,8 +92,8 @@
 }
 
 int main(int argc, char **argv) {
-  S4 e(4); // expected-note {{'e' defined here}}
-  S5 g(5); // expected-note {{'g' defined here}}
+  S4 e(4);
+  S5 g(5);
   int i;
   int &j = i;                // expected-note {{'j' defined here}}
 #pragma omp single private // expected-error {{expected '(' after 'private'}}
@@ -116,7 +116,7 @@
   foo();
 #pragma omp single private(argv[1]) // expected-error {{expected variable name}}
   foo();
-#pragma omp single private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
+#pragma omp single private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
   foo();
 #pragma omp single private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
   foo();
diff --git a/test/OpenMP/target_ast_print.cpp b/test/OpenMP/target_ast_print.cpp
new file mode 100644
index 0000000..c57c049
--- /dev/null
+++ b/test/OpenMP/target_ast_print.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <typename T, int C>
+T tmain(T argc, T *argv) {
+#pragma omp target
+  foo();
+#pragma omp target if (argc > 0)
+  foo();
+#pragma omp target if (C)
+  foo();
+  return 0;
+}
+
+// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: foo();
+// CHECK-NEXT: #pragma omp target if(argc > 0)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target if(5)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) {
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: foo();
+// CHECK-NEXT: #pragma omp target if(argc > 0)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target if(1)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: foo();
+// CHECK-NEXT: #pragma omp target if(argc > 0)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target if(C)
+// CHECK-NEXT: foo()
+
+// CHECK-LABEL: int main(int argc, char **argv) {
+int main (int argc, char **argv) {
+#pragma omp target
+// CHECK-NEXT: #pragma omp target
+  foo();
+// CHECK-NEXT: foo();
+#pragma omp target if (argc > 0)
+// CHECK-NEXT: #pragma omp target if(argc > 0)
+  foo();
+// CHECK-NEXT: foo();
+  return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
+}
+
+#endif
diff --git a/test/OpenMP/target_if_messages.cpp b/test/OpenMP/target_if_messages.cpp
new file mode 100644
index 0000000..50a9ed2
--- /dev/null
+++ b/test/OpenMP/target_if_messages.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, class S> // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  #pragma omp target if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if () // expected-error {{expected expression}}
+  #pragma omp target if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  #pragma omp target if (argc > 0 ? argv[1] : argv[2])
+  #pragma omp target if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause}}
+  #pragma omp target if (S) // expected-error {{'S' does not refer to a value}}
+  #pragma omp target if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if(argc)
+  foo();
+
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp target if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if () // expected-error {{expected expression}}
+  #pragma omp target if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  #pragma omp target if (argc > 0 ? argv[1] : argv[2])
+  #pragma omp target if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target' cannot contain more than one 'if' clause}}
+  #pragma omp target if (S1) // expected-error {{'S1' does not refer to a value}}
+  #pragma omp target if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+
+  return tmain(argc, argv);
+}
diff --git a/test/OpenMP/target_messages.cpp b/test/OpenMP/target_messages.cpp
new file mode 100644
index 0000000..fb49228
--- /dev/null
+++ b/test/OpenMP/target_messages.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -std=c++11 -o - %s
+
+void foo() {
+}
+
+#pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}}
+
+int main(int argc, char **argv) {
+  #pragma omp target { // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target ( // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target [ // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target ] // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target ) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target
+  // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}}
+  #pragma omp target unknown()
+  foo();
+  L1:
+    foo();
+  #pragma omp target
+  ;
+  #pragma omp target
+  {
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+    argc++;
+  }
+
+  for (int i = 0; i < 10; ++i) {
+    switch(argc) {
+     case (0):
+      #pragma omp target
+      {
+        foo();
+        break; // expected-error {{'break' statement not in loop or switch statement}}
+        continue; // expected-error {{'continue' statement not in loop statement}}
+      }
+      default:
+       break;
+    }
+  }
+
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+  #pragma omp target
+  L2:
+  foo();
+  #pragma omp target
+  {
+    return 1; // expected-error {{cannot return from OpenMP region}}
+  }
+
+  [[]] // expected-error {{an attribute list cannot appear here}}
+  #pragma omp target
+  for (int n = 0; n < 100; ++n) {}
+
+  return 0;
+}
+
diff --git a/test/OpenMP/task_ast_print.cpp b/test/OpenMP/task_ast_print.cpp
new file mode 100644
index 0000000..2b43c0b
--- /dev/null
+++ b/test/OpenMP/task_ast_print.cpp
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+struct S {
+  operator T() { return T(); }
+  static T TS;
+#pragma omp threadprivate(TS)
+};
+
+// CHECK:      template <class T = int> struct S {
+// CHECK:        static int TS;
+// CHECK-NEXT:   #pragma omp threadprivate(S<int>::TS)
+// CHECK-NEXT: }
+// CHECK:      template <class T = long> struct S {
+// CHECK:        static long TS;
+// CHECK-NEXT:   #pragma omp threadprivate(S<long>::TS)
+// CHECK-NEXT: }
+// CHECK:      template <class T> struct S {
+// CHECK:        static T TS;
+// CHECK-NEXT:   #pragma omp threadprivate(S::TS)
+// CHECK:      };
+
+template <typename T, int C>
+T tmain(T argc, T *argv) {
+  T b = argc, c, d, e, f, g;
+  static T a;
+  S<T> s;
+#pragma omp task untied
+  a = 2;
+#pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S<T>::TS > 0)
+  foo();
+#pragma omp task if (C) mergeable
+  foo();
+  return 0;
+}
+
+// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
+// CHECK-NEXT: int b = argc, c, d, e, f, g;
+// CHECK-NEXT: static int a;
+// CHECK-NEXT: S<int> s;
+// CHECK-NEXT: #pragma omp task untied
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<int>::TS > 0)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp task if(5) mergeable
+// CHECK-NEXT: foo()
+// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) {
+// CHECK-NEXT: long b = argc, c, d, e, f, g;
+// CHECK-NEXT: static long a;
+// CHECK-NEXT: S<long> s;
+// CHECK-NEXT: #pragma omp task untied
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<long>::TS > 0)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp task if(1) mergeable
+// CHECK-NEXT: foo()
+// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
+// CHECK-NEXT: T b = argc, c, d, e, f, g;
+// CHECK-NEXT: static T a;
+// CHECK-NEXT: S<T> s;
+// CHECK-NEXT: #pragma omp task untied
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp task if(C) mergeable
+// CHECK-NEXT: foo()
+
+enum Enum {};
+
+int main(int argc, char **argv) {
+  long x;
+  int b = argc, c, d, e, f, g;
+  static int a;
+#pragma omp threadprivate(a)
+  Enum ee;
+// CHECK: Enum ee;
+#pragma omp task untied mergeable
+  // CHECK-NEXT: #pragma omp task untied mergeable
+  a = 2;
+// CHECK-NEXT: a = 2;
+#pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0) final(a > 0)
+  // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) if(argc > 0) final(a > 0)
+  foo();
+  // CHECK-NEXT: foo();
+  return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
+}
+
+#endif
diff --git a/test/OpenMP/task_default_messages.cpp b/test/OpenMP/task_default_messages.cpp
new file mode 100644
index 0000000..8da6b1a
--- /dev/null
+++ b/test/OpenMP/task_default_messages.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -o - %s
+
+void foo();
+
+int main(int argc, char **argv) {
+#pragma omp task default                          // expected-error {{expected '(' after 'default'}}
+#pragma omp task default(                         // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task default()                        // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp task default(none                     // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task default(shared), default(shared) // expected-error {{directive '#pragma omp task' cannot contain more than one 'default' clause}}
+#pragma omp task default(x)                       // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+  foo();
+
+#pragma omp task default(none)
+  ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#pragma omp task default(none)
+#pragma omp task default(shared)
+  ++argc;
+  return 0;
+}
diff --git a/test/OpenMP/task_final_messages.cpp b/test/OpenMP/task_final_messages.cpp
new file mode 100644
index 0000000..0b52e6a
--- /dev/null
+++ b/test/OpenMP/task_final_messages.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, class S> // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  #pragma omp task final // expected-error {{expected '(' after 'final'}}
+  #pragma omp task final ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final () // expected-error {{expected expression}}
+  #pragma omp task final (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final (argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  #pragma omp task final (argc > 0 ? argv[1] : argv[2])
+  #pragma omp task final (foobool(argc)), final (true) // expected-error {{directive '#pragma omp task' cannot contain more than one 'final' clause}}
+  #pragma omp task final (S) // expected-error {{'S' does not refer to a value}}
+  #pragma omp task final (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final(argc)
+  foo();
+
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp task final // expected-error {{expected '(' after 'final'}}
+  #pragma omp task final ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final () // expected-error {{expected expression}}
+  #pragma omp task final (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final (argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  #pragma omp task final (argc > 0 ? argv[1] : argv[2])
+  #pragma omp task final (foobool(argc)), final (true) // expected-error {{directive '#pragma omp task' cannot contain more than one 'final' clause}}
+  #pragma omp task final (S1) // expected-error {{'S1' does not refer to a value}}
+  #pragma omp task final (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task final(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+
+  return tmain(argc, argv);
+}
diff --git a/test/OpenMP/task_firstprivate_messages.cpp b/test/OpenMP/task_firstprivate_messages.cpp
new file mode 100644
index 0000000..6c5ccfc
--- /dev/null
+++ b/test/OpenMP/task_firstprivate_messages.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(const S2 &s2) : a(s2.a) {}
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note 2 {{implicitly declared private here}}
+
+public:
+  S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+  const int d = 5;
+  const int da[5] = {0};
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i;                                               // expected-note {{'j' defined here}}
+#pragma omp task firstprivate                               // expected-error {{expected '(' after 'firstprivate'}}
+#pragma omp task firstprivate(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task firstprivate()                             // expected-error {{expected expression}}
+#pragma omp task firstprivate(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task firstprivate(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+#pragma omp task firstprivate(argc)
+#pragma omp task firstprivate(S1)            // expected-error {{'S1' does not refer to a value}}
+#pragma omp task firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+#pragma omp task firstprivate(argv[1])       // expected-error {{expected variable name}}
+#pragma omp task firstprivate(ba)
+#pragma omp task firstprivate(ca)
+#pragma omp task firstprivate(da)
+#pragma omp task firstprivate(S2::S2s)
+#pragma omp task firstprivate(S2::S2sc)
+#pragma omp task firstprivate(e, g)          // expected-error 2 {{calling a private constructor of class 'S4'}} expected-error 2 {{calling a private constructor of class 'S5'}}
+#pragma omp task firstprivate(h)             // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+#pragma omp task private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
+  foo();
+#pragma omp task shared(i)
+#pragma omp task firstprivate(i)
+#pragma omp task firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+  foo();
+
+  return 0;
+}
diff --git a/test/OpenMP/task_if_messages.cpp b/test/OpenMP/task_if_messages.cpp
new file mode 100644
index 0000000..51900c0
--- /dev/null
+++ b/test/OpenMP/task_if_messages.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+template <class T, class S> // expected-note {{declared here}}
+int tmain(T argc, S **argv) {
+  #pragma omp task if // expected-error {{expected '(' after 'if'}}
+  #pragma omp task if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if () // expected-error {{expected expression}}
+  #pragma omp task if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  #pragma omp task if (argc > 0 ? argv[1] : argv[2])
+  #pragma omp task if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp task' cannot contain more than one 'if' clause}}
+  #pragma omp task if (S) // expected-error {{'S' does not refer to a value}}
+  #pragma omp task if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if(argc)
+  foo();
+
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp task if // expected-error {{expected '(' after 'if'}}
+  #pragma omp task if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if () // expected-error {{expected expression}}
+  #pragma omp task if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  #pragma omp task if (argc > 0 ? argv[1] : argv[2])
+  #pragma omp task if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp task' cannot contain more than one 'if' clause}}
+  #pragma omp task if (S1) // expected-error {{'S1' does not refer to a value}}
+  #pragma omp task if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp task if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+
+  return tmain(argc, argv);
+}
diff --git a/test/OpenMP/task_messages.cpp b/test/OpenMP/task_messages.cpp
new file mode 100644
index 0000000..b02b43c
--- /dev/null
+++ b/test/OpenMP/task_messages.cpp
@@ -0,0 +1,285 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 -std=c++11 -o - %s
+
+void foo() {
+}
+
+#pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
+
+class S {
+  S(const S &s) { a = s.a + 12; } // expected-note 6 {{implicitly declared private here}}
+  int a;
+
+public:
+  S() : a(0) {}
+  S(int a) : a(a) {}
+  operator int() { return a; }
+  S &operator++() { return *this; }
+  S operator+(const S &) { return *this; }
+};
+
+class S1 {
+  int a;
+
+public:
+  S1() : a(0) {}
+  S1 &operator++() { return *this; }
+  S1(const S1 &) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}}
+};
+
+template <class T>
+int foo() {
+  T a;
+  T &b = a; // expected-note 4 {{'b' defined here}}
+  int r;
+  S1 s1;
+// expected-error@+1 2 {{call to deleted constructor of 'S1'}}
+#pragma omp task
+// expected-note@+1 2 {{predetermined as a firstprivate in a task construct here}}
+  ++s1;
+#pragma omp task default(none)
+#pragma omp task default(shared)
+  ++a;
+#pragma omp task default(none)
+#pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++a;
+#pragma omp task
+#pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++a;
+#pragma omp task default(shared)
+#pragma omp task
+  ++a;
+#pragma omp task
+#pragma omp parallel
+  ++a;
+// expected-error@+2 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'int &'}}
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
+#pragma omp task
+  // expected-note@+1 2 {{used here}}
+  ++b;
+// expected-error@+2 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'int &'}}
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
+#pragma omp task
+// expected-error@+2 {{calling a private constructor of class 'S'}}
+// expected-note@+1 2 {{used here}}
+#pragma omp parallel shared(a, b)
+  ++a, ++b;
+// expected-note@+1 3 {{defined as reduction}}
+#pragma omp parallel reduction(+ : r)
+// expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
+#pragma omp task firstprivate(r)
+  // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+  ++r;
+// expected-note@+1 2 {{defined as reduction}}
+#pragma omp parallel reduction(+ : r)
+#pragma omp task default(shared)
+  // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+  ++r;
+// expected-note@+1 2 {{defined as reduction}}
+#pragma omp parallel reduction(+ : r)
+#pragma omp task
+  // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+  ++r;
+#pragma omp parallel
+// expected-note@+1 3 {{defined as reduction}}
+#pragma omp for reduction(+ : r)
+  for (int i = 0; i < 10; ++i)
+// expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
+#pragma omp task firstprivate(r)
+    // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+    ++r;
+#pragma omp parallel
+// expected-note@+1 2 {{defined as reduction}}
+#pragma omp for reduction(+ : r)
+  for (int i = 0; i < 10; ++i)
+#pragma omp task default(shared)
+    // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+    ++r;
+#pragma omp parallel
+// expected-note@+1 2 {{defined as reduction}}
+#pragma omp for reduction(+ : r)
+  for (int i = 0; i < 10; ++i)
+#pragma omp task
+    // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
+    ++r;
+// expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
+#pragma omp task
+// expected-error@+2 {{reduction variable must be shared}}
+// expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+#pragma omp for reduction(+ : r)
+  ++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
+#pragma omp task untied untied
+  ++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
+#pragma omp task mergeable mergeable
+  ++r;
+  return a + b;
+}
+
+int main(int argc, char **argv) {
+  int a;
+  int &b = a; // expected-note 2 {{'b' defined here}}
+  S sa;
+  S &sb = sa; // expected-note 2 {{'sb' defined here}}
+  int r;
+#pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  foo();
+#pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  foo();
+#pragma omp task[ // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  foo();
+#pragma omp task] // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  foo();
+#pragma omp task) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  foo();
+#pragma omp task } // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
+  foo();
+#pragma omp task
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}}
+#pragma omp task unknown()
+  foo();
+L1:
+  foo();
+#pragma omp task
+  ;
+#pragma omp task
+  {
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+    argc++;
+  }
+
+  for (int i = 0; i < 10; ++i) {
+    switch (argc) {
+    case (0):
+#pragma omp task
+    {
+      foo();
+      break;    // expected-error {{'break' statement not in loop or switch statement}}
+      continue; // expected-error {{'continue' statement not in loop statement}}
+    }
+    default:
+      break;
+    }
+  }
+#pragma omp task default(none)
+  ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+#pragma omp task
+L2:
+  foo();
+#pragma omp task
+  {
+    return 1; // expected-error {{cannot return from OpenMP region}}
+  }
+
+  [[]] // expected-error {{an attribute list cannot appear here}}
+#pragma omp task
+      for (int n = 0; n < 100; ++n) {
+  }
+
+#pragma omp task default(none)
+#pragma omp task default(shared)
+  ++a;
+#pragma omp task default(none)
+#pragma omp task
+  ++a;
+#pragma omp task default(shared)
+#pragma omp task
+  ++a;
+#pragma omp task
+#pragma omp parallel
+  ++a;
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'int &'}}
+#pragma omp task
+  // expected-note@+1 {{used here}}
+  ++b;
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'int &'}}
+#pragma omp task
+// expected-note@+1 {{used here}}
+#pragma omp parallel shared(a, b)
+  ++a, ++b;
+#pragma omp task default(none)
+#pragma omp task default(shared)
+  ++sa;
+#pragma omp task default(none)
+#pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++sa;
+#pragma omp task
+#pragma omp task
+  // expected-error@+1 {{calling a private constructor of class 'S'}}
+  ++sa;
+#pragma omp task default(shared)
+#pragma omp task
+  ++sa;
+#pragma omp task
+#pragma omp parallel
+  ++sa;
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
+#pragma omp task
+  // expected-note@+1 {{used here}}
+  ++sb;
+// expected-error@+1 {{predetermined as a firstprivate in a task construct variable cannot be of reference type 'S &'}}
+#pragma omp task
+// expected-error@+2 {{calling a private constructor of class 'S'}}
+// expected-note@+1 {{used here}}
+#pragma omp parallel shared(sa, sb)
+  ++sa, ++sb;
+// expected-note@+1 2 {{defined as reduction}}
+#pragma omp parallel reduction(+ : r)
+// expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
+#pragma omp task firstprivate(r)
+  // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+  ++r;
+// expected-note@+1 {{defined as reduction}}
+#pragma omp parallel reduction(+ : r)
+#pragma omp task default(shared)
+  // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+  ++r;
+// expected-note@+1 {{defined as reduction}}
+#pragma omp parallel reduction(+ : r)
+#pragma omp task
+  // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+  ++r;
+#pragma omp parallel
+// expected-note@+1 2 {{defined as reduction}}
+#pragma omp for reduction(+ : r)
+  for (int i = 0; i < 10; ++i)
+// expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
+#pragma omp task firstprivate(r)
+    // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+    ++r;
+#pragma omp parallel
+// expected-note@+1 {{defined as reduction}}
+#pragma omp for reduction(+ : r)
+  for (int i = 0; i < 10; ++i)
+#pragma omp task default(shared)
+    // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+    ++r;
+#pragma omp parallel
+// expected-note@+1 {{defined as reduction}}
+#pragma omp for reduction(+ : r)
+  for (int i = 0; i < 10; ++i)
+#pragma omp task
+    // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
+    ++r;
+// expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
+#pragma omp task
+// expected-error@+2 {{reduction variable must be shared}}
+// expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
+#pragma omp for reduction(+ : r)
+  ++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
+#pragma omp task untied untied
+  ++r;
+// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
+#pragma omp task mergeable mergeable
+  ++r;
+  // expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}}
+  // expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}}
+  return foo<int>() + foo<S>();
+}
+
diff --git a/test/OpenMP/task_private_messages.cpp b/test/OpenMP/task_private_messages.cpp
new file mode 100644
index 0000000..9a3bb75
--- /dev/null
+++ b/test/OpenMP/task_private_messages.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  static float S2s; // expected-note {{static data member is predetermined as shared}}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+};
+const S3 c;         // expected-note {{global variable is predetermined as shared}}
+const S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
+extern const int f; // expected-note {{global variable is predetermined as shared}}
+class S4 {
+  int a;
+  S4(); // expected-note {{implicitly declared private here}}
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {} // expected-note {{implicitly declared private here}}
+
+public:
+  S5(int v) : a(v) {}
+};
+
+int threadvar;
+#pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+  const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
+  const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i;                                          // expected-note {{'j' defined here}}
+#pragma omp task private                               // expected-error {{expected '(' after 'private'}}
+#pragma omp task private(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task private()                             // expected-error {{expected expression}}
+#pragma omp task private(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task private(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+#pragma omp task private(argc argv)                    // expected-error {{expected ',' or ')' in 'private' clause}}
+#pragma omp task private(S1)                           // expected-error {{'S1' does not refer to a value}}
+#pragma omp task private(a, b, c, d, f)                // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
+#pragma omp task private(argv[1])                      // expected-error {{expected variable name}}
+#pragma omp task private(ba)
+#pragma omp task private(ca)           // expected-error {{shared variable cannot be private}}
+#pragma omp task private(da)           // expected-error {{shared variable cannot be private}}
+#pragma omp task private(S2::S2s)      // expected-error {{shared variable cannot be private}}
+#pragma omp task private(e, g)         // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+#pragma omp task private(threadvar)    // expected-error {{threadprivate or thread local variable cannot be private}}
+#pragma omp task shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
+  foo();
+#pragma omp task firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
+  foo();
+#pragma omp task private(i)
+#pragma omp task private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type 'int &'}}
+  foo();
+#pragma omp task firstprivate(i)
+  for (int k = 0; k < 10; ++k) {
+#pragma omp task private(i)
+    foo();
+  }
+
+  return 0;
+}
diff --git a/test/OpenMP/task_shared_messages.cpp b/test/OpenMP/task_shared_messages.cpp
new file mode 100644
index 0000000..7479237
--- /dev/null
+++ b/test/OpenMP/task_shared_messages.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4);
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {}
+
+public:
+  S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+  const int d = 5;
+  const int da[5] = {0};
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i;
+#pragma omp task shared                               // expected-error {{expected '(' after 'shared'}}
+  foo();
+#pragma omp task shared(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp task shared()                             // expected-error {{expected expression}}
+  foo();
+#pragma omp task shared(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp task shared(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp task shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  foo();
+#pragma omp task shared(argc)
+  foo();
+#pragma omp task shared(S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+#pragma omp task shared(a, b, c, d, f)
+  foo();
+#pragma omp task shared(argv[1]) // expected-error {{expected variable name}}
+  foo();
+#pragma omp task shared(ba)
+  foo();
+#pragma omp task shared(ca)
+  foo();
+#pragma omp task shared(da)
+  foo();
+#pragma omp task shared(e, g)
+  foo();
+#pragma omp task shared(h)             // expected-error {{threadprivate or thread local variable cannot be shared}}
+  foo();
+#pragma omp task private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
+  foo();
+#pragma omp task firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
+  foo();
+#pragma omp parallel private(i)
+#pragma omp task shared(i)
+#pragma omp task shared(j)
+  foo();
+#pragma omp parallel firstprivate(i)
+#pragma omp task shared(i)
+#pragma omp task shared(j)
+  foo();
+
+  return 0;
+}
diff --git a/test/OpenMP/taskwait_ast_print.cpp b/test/OpenMP/taskwait_ast_print.cpp
new file mode 100644
index 0000000..9942622
--- /dev/null
+++ b/test/OpenMP/taskwait_ast_print.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+T tmain(T argc) {
+  static T a;
+#pragma omp taskwait
+  return a + argc;
+}
+// CHECK:      static int a;
+// CHECK-NEXT: #pragma omp taskwait
+// CHECK:      static char a;
+// CHECK-NEXT: #pragma omp taskwait
+// CHECK:      static T a;
+// CHECK-NEXT: #pragma omp taskwait
+
+int main(int argc, char **argv) {
+  static int a;
+// CHECK: static int a;
+#pragma omp taskwait
+  // CHECK-NEXT: #pragma omp taskwait
+  return tmain(argc) + tmain(argv[0][0]) + a;
+}
+
+#endif
diff --git a/test/OpenMP/taskwait_messages.cpp b/test/OpenMP/taskwait_messages.cpp
new file mode 100644
index 0000000..f325c73
--- /dev/null
+++ b/test/OpenMP/taskwait_messages.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+template <class T>
+T tmain(T argc) {
+#pragma omp taskwait
+  ;
+#pragma omp taskwait untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp taskwait'}}
+#pragma omp taskwait unknown // expected-warning {{extra tokens at the end of '#pragma omp taskwait' are ignored}}
+  if (argc)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp taskwait
+    }
+  while (argc)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp taskwait
+    }
+  do
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp taskwait
+  } while (argc);
+  switch (argc)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp taskwait
+  }
+  switch (argc) {
+#pragma omp taskwait
+  case 1:
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp taskwait
+  } break;
+  }
+  for (;;)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp taskwait
+    }
+label:
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+label1 : {
+#pragma omp taskwait
+}
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+#pragma omp taskwait
+  ;
+#pragma omp taskwait untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp taskwait'}}
+#pragma omp taskwait unknown // expected-warning {{extra tokens at the end of '#pragma omp taskwait' are ignored}}
+  if (argc)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp taskwait
+    }
+  while (argc)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp taskwait
+    }
+  do
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp taskwait
+  } while (argc);
+  switch (argc)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp taskwait
+  }
+  switch (argc) {
+#pragma omp taskwait
+  case 1:
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp taskwait
+  } break;
+  }
+  for (;;)
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp taskwait
+    }
+label:
+#pragma omp taskwait // expected-error {{'#pragma omp taskwait' cannot be an immediate substatement}}
+label1 : {
+#pragma omp taskwait
+}
+
+  return tmain(argc);
+}
diff --git a/test/OpenMP/taskyield_ast_print.cpp b/test/OpenMP/taskyield_ast_print.cpp
new file mode 100644
index 0000000..4c3ca47
--- /dev/null
+++ b/test/OpenMP/taskyield_ast_print.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+T tmain(T argc) {
+  static T a;
+#pragma omp taskyield
+  return a + argc;
+}
+// CHECK:      static int a;
+// CHECK-NEXT: #pragma omp taskyield
+// CHECK:      static char a;
+// CHECK-NEXT: #pragma omp taskyield
+// CHECK:      static T a;
+// CHECK-NEXT: #pragma omp taskyield
+
+int main(int argc, char **argv) {
+  static int a;
+// CHECK: static int a;
+#pragma omp taskyield
+  // CHECK-NEXT: #pragma omp taskyield
+  return tmain(argc) + tmain(argv[0][0]) + a;
+}
+
+#endif
diff --git a/test/OpenMP/taskyield_messages.cpp b/test/OpenMP/taskyield_messages.cpp
new file mode 100644
index 0000000..7c35559
--- /dev/null
+++ b/test/OpenMP/taskyield_messages.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
+
+template <class T>
+T tmain(T argc) {
+#pragma omp taskyield
+  ;
+#pragma omp taskyield untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp taskyield'}}
+#pragma omp taskyield unknown // expected-warning {{extra tokens at the end of '#pragma omp taskyield' are ignored}}
+  if (argc)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp taskyield
+    }
+  while (argc)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp taskyield
+    }
+  do
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp taskyield
+  } while (argc);
+  switch (argc)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp taskyield
+  }
+  switch (argc) {
+#pragma omp taskyield
+  case 1:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp taskyield
+  } break;
+  }
+  for (;;)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp taskyield
+    }
+label:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+label1 : {
+#pragma omp taskyield
+}
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+#pragma omp taskyield
+  ;
+#pragma omp taskyield untied  // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp taskyield'}}
+#pragma omp taskyield unknown // expected-warning {{extra tokens at the end of '#pragma omp taskyield' are ignored}}
+  if (argc)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    if (argc) {
+#pragma omp taskyield
+    }
+  while (argc)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    while (argc) {
+#pragma omp taskyield
+    }
+  do
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    while (argc)
+      ;
+  do {
+#pragma omp taskyield
+  } while (argc);
+  switch (argc)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    switch (argc)
+    case 1:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+  switch (argc)
+  case 1: {
+#pragma omp taskyield
+  }
+  switch (argc) {
+#pragma omp taskyield
+  case 1:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    break;
+  default: {
+#pragma omp taskyield
+  } break;
+  }
+  for (;;)
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+    for (;;) {
+#pragma omp taskyield
+    }
+label:
+#pragma omp taskyield // expected-error {{'#pragma omp taskyield' cannot be an immediate substatement}}
+label1 : {
+#pragma omp taskyield
+}
+
+  return tmain(argc);
+}
diff --git a/test/OpenMP/teams_ast_print.cpp b/test/OpenMP/teams_ast_print.cpp
new file mode 100644
index 0000000..394ec73
--- /dev/null
+++ b/test/OpenMP/teams_ast_print.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {}
+
+template <class T>
+struct S {
+  operator T() {return T();}
+  static T TS;
+  #pragma omp threadprivate(TS)
+};
+
+// CHECK:      template <class T = int> struct S {
+// CHECK:        static int TS;
+// CHECK-NEXT:   #pragma omp threadprivate(S<int>::TS)
+// CHECK-NEXT: }
+// CHECK:      template <class T = long> struct S {
+// CHECK:        static long TS;
+// CHECK-NEXT:   #pragma omp threadprivate(S<long>::TS)
+// CHECK-NEXT: }
+// CHECK:      template <class T> struct S {
+// CHECK:        static T TS;
+// CHECK-NEXT:   #pragma omp threadprivate(S::TS)
+// CHECK:      };
+
+template <typename T, int C>
+T tmain(T argc, T *argv) {
+  T b = argc, c, d, e, f, g;
+  static T a;
+  S<T> s;
+#pragma omp target
+#pragma omp teams
+  a=2;
+#pragma omp target
+#pragma omp teams default(none), private(argc,b) firstprivate(argv) shared (d) reduction(+:c) reduction(max:e)
+  foo();
+#pragma omp target
+#pragma omp teams reduction(^:e, f) reduction(&& : g)
+  foo();
+  return 0;
+}
+
+// CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
+// CHECK-NEXT: int b = argc, c, d, e, f, g;
+// CHECK-NEXT: static int a;
+// CHECK-NEXT: S<int> s;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) {
+// CHECK-NEXT: long b = argc, c, d, e, f, g;
+// CHECK-NEXT: static long a;
+// CHECK-NEXT: S<long> s;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
+// CHECK-NEXT: foo()
+// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
+// CHECK-NEXT: T b = argc, c, d, e, f, g;
+// CHECK-NEXT: static T a;
+// CHECK-NEXT: S<T> s;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+// CHECK-NEXT: a = 2;
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e)
+// CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g)
+// CHECK-NEXT: foo()
+
+enum Enum { };
+
+int main (int argc, char **argv) {
+  long x;
+  int b = argc, c, d, e, f, g;
+  static int a;
+  #pragma omp threadprivate(a)
+  Enum ee;
+// CHECK: Enum ee;
+#pragma omp target
+#pragma omp teams
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams
+  a=2;
+// CHECK-NEXT: a = 2;
+#pragma omp target
+#pragma omp teams default(none), private(argc,b) firstprivate(argv) reduction(| : c, d) reduction(* : e)
+// CHECK-NEXT: #pragma omp target
+// CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) reduction(|: c,d) reduction(*: e)
+  foo();
+// CHECK-NEXT: foo();
+  return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
+}
+
+#endif
diff --git a/test/OpenMP/teams_default_messages.cpp b/test/OpenMP/teams_default_messages.cpp
new file mode 100644
index 0000000..4f5a267
--- /dev/null
+++ b/test/OpenMP/teams_default_messages.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo();
+
+int main(int argc, char **argv) {
+  #pragma omp target
+  #pragma omp teams default // expected-error {{expected '(' after 'default'}}
+  foo();
+  #pragma omp target
+  #pragma omp teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+  foo();
+  #pragma omp target
+  #pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
+  foo();
+  #pragma omp target
+  #pragma omp teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+  foo();
+
+  #pragma omp target
+  #pragma omp teams default(none)
+  ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+  #pragma omp target
+  #pragma omp teams default(none)
+  #pragma omp parallel default(shared)
+  ++argc;
+  return 0;
+}
diff --git a/test/OpenMP/teams_firstprivate_messages.cpp b/test/OpenMP/teams_firstprivate_messages.cpp
new file mode 100644
index 0000000..3d4a219
--- /dev/null
+++ b/test/OpenMP/teams_firstprivate_messages.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(const S2 &s2) : a(s2.a) {}
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4); // expected-note {{implicitly declared private here}}
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {} // expected-note {{implicitly declared private here}}
+public:
+  S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+  const int d = 5;
+  const int da[5] = {0};
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+#pragma omp target
+#pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate() // expected-error {{expected expression}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(argc)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(ba)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(ca)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(da)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(S2::S2s)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(S2::S2sc)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+  foo();
+#pragma omp target
+#pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
+  foo();
+#pragma omp target
+#pragma omp teams shared(i)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(i)
+  foo();
+#pragma omp target
+#pragma omp teams firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
+  foo();
+
+  return 0;
+}
diff --git a/test/OpenMP/teams_messages.cpp b/test/OpenMP/teams_messages.cpp
new file mode 100644
index 0000000..56ed548
--- /dev/null
+++ b/test/OpenMP/teams_messages.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -std=c++11 -o - %s
+
+void foo() {
+}
+
+#pragma omp teams // expected-error {{unexpected OpenMP directive '#pragma omp teams'}}
+
+int main(int argc, char **argv) {
+  #pragma omp target
+  #pragma omp teams { // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+  #pragma omp target
+  #pragma omp teams ( // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+  #pragma omp target
+  #pragma omp teams [ // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+  #pragma omp target
+  #pragma omp teams ] // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+  #pragma omp target
+  #pragma omp teams ) // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+  #pragma omp target
+  #pragma omp teams } // expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+  #pragma omp target
+  #pragma omp teams
+  foo();
+  // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  #pragma omp target
+  #pragma omp teams unknown()
+  foo();
+  L1:
+    foo();
+  #pragma omp target
+  #pragma omp teams
+  ;
+  #pragma omp target
+  #pragma omp teams
+  {
+    goto L1; // expected-error {{use of undeclared label 'L1'}}
+    argc++;
+  }
+
+  for (int i = 0; i < 10; ++i) {
+    switch(argc) {
+     case (0):
+      #pragma omp target
+      #pragma omp teams
+      {
+        foo();
+        break; // expected-error {{'break' statement not in loop or switch statement}}
+        continue; // expected-error {{'continue' statement not in loop statement}}
+      }
+      default:
+       break;
+    }
+  }
+  #pragma omp target
+  #pragma omp teams default(none)
+  ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+  goto L2; // expected-error {{use of undeclared label 'L2'}}
+  #pragma omp target
+  #pragma omp teams
+  L2:
+  foo();
+  #pragma omp target
+  #pragma omp teams
+  {
+    return 1; // expected-error {{cannot return from OpenMP region}}
+  }
+
+  [[]] // expected-error {{an attribute list cannot appear here}}
+  #pragma omp target
+  #pragma omp teams
+  for (int n = 0; n < 100; ++n) {}
+
+  return 0;
+}
+
diff --git a/test/OpenMP/teams_private_messages.cpp b/test/OpenMP/teams_private_messages.cpp
new file mode 100644
index 0000000..16ecb74
--- /dev/null
+++ b/test/OpenMP/teams_private_messages.cpp
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  static float S2s; // expected-note {{static data member is predetermined as shared}}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+};
+const S3 c; // expected-note {{global variable is predetermined as shared}}
+const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
+extern const int f; // expected-note {{global variable is predetermined as shared}}
+class S4 {
+  int a;
+  S4(); // expected-note {{implicitly declared private here}}
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {} // expected-note {{implicitly declared private here}}
+public:
+  S5(int v):a(v) { }
+};
+
+int threadvar;
+#pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+  const int d = 5; // expected-note {{constant variable is predetermined as shared}}
+  const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}}
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i; // expected-note {{'j' defined here}}
+  #pragma omp target
+  #pragma omp teams private // expected-error {{expected '(' after 'private'}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private () // expected-error {{expected expression}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private (argv[1]) // expected-error {{expected variable name}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(ba)
+  foo();
+  #pragma omp target
+  #pragma omp teams private(ca) // expected-error {{shared variable cannot be private}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(da) // expected-error {{shared variable cannot be private}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(S2::S2s) // expected-error {{shared variable cannot be private}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(threadvar) // expected-error {{threadprivate or thread local variable cannot be private}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
+  foo();
+  #pragma omp target
+  #pragma omp teams firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(i)
+  foo();
+  #pragma omp target
+  #pragma omp teams private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type 'int &'}}
+  foo();
+  #pragma omp target
+  #pragma omp teams firstprivate(i)
+  for (int k = 0; k < 10; ++k) {
+    #pragma omp parallel private(i)
+    foo();
+  }
+
+  return 0;
+}
diff --git a/test/OpenMP/teams_reduction_messages.cpp b/test/OpenMP/teams_reduction_messages.cpp
new file mode 100644
index 0000000..afedfc3
--- /dev/null
+++ b/test/OpenMP/teams_reduction_messages.cpp
@@ -0,0 +1,307 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+  S2 &operator+=(const S2 &arg) { return (*this); }
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+  static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
+  static const float S2sc;
+};
+const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
+S2 b;                     // expected-note 2 {{'b' defined here}}
+const S2 ba[5];           // expected-note 2 {{'ba' defined here}}
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(const S3 &s3) : a(s3.a) {}
+  S3 operator+=(const S3 &arg1) { return arg1; }
+};
+int operator+=(const S3 &arg1, const S3 &arg2) { return 5; }
+S3 c;               // expected-note 2 {{'c' defined here}}
+const S3 ca[5];     // expected-note 2 {{'ca' defined here}}
+extern const int f; // expected-note 4 {{'f' declared here}}
+class S4 {          // expected-note {{'S4' declared here}}
+  int a;
+  S4();
+  S4(const S4 &s4);
+  S4 &operator+=(const S4 &arg) { return (*this); }
+
+public:
+  S4(int v) : a(v) {}
+};
+S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {}
+  S5 &operator+=(const S5 &arg);
+
+public:
+  S5(int v) : a(v) {}
+};
+class S6 {
+  int a;
+
+public:
+  S6() : a(6) {}
+  operator int() { return 6; }
+} o; // expected-note 2 {{'o' defined here}}
+
+S3 h, k;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template <class T>       // expected-note {{declared here}}
+T tmain(T argc) {        // expected-note 2 {{'argc' defined here}}
+  const T d = T();       // expected-note 4 {{'d' defined here}}
+  const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
+  T qa[5] = {T()};
+  T i;
+  T &j = i;                    // expected-note 4 {{'j' defined here}}
+  S3 &p = k;                   // expected-note 2 {{'p' defined here}}
+  const T &r = da[(int)i];     // expected-note 2 {{'r' defined here}}
+  T &q = qa[(int)i];           // expected-note 2 {{'q' defined here}}
+  T fl;                        // expected-note {{'fl' defined here}}
+#pragma omp target
+#pragma omp teams reduction // expected-error {{expected '(' after 'reduction'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(&& : argc)
+  foo();
+#pragma omp target
+#pragma omp teams reduction(^ : T) // expected-error {{'T' does not refer to a value}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 3 {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(max : qa[1]) // expected-error 2 {{expected variable name}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}} expected-error {{a reduction variable with array type 'const float [5]'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  foo();
+#pragma omp parallel private(k)
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 3 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 3 {{previously referenced here}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp target
+#pragma omp teams reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for private(fl)
+  for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+    foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for reduction(- : fl)
+  for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+    foo();
+
+  return T();
+}
+
+int main(int argc, char **argv) {
+  const int d = 5;       // expected-note 2 {{'d' defined here}}
+  const int da[5] = {0}; // expected-note {{'da' defined here}}
+  int qa[5] = {0};
+  S4 e(4); // expected-note {{'e' defined here}}
+  S5 g(5); // expected-note {{'g' defined here}}
+  int i;
+  int &j = i;                  // expected-note 2 {{'j' defined here}}
+  S3 &p = k;                   // expected-note 2 {{'p' defined here}}
+  const int &r = da[i];        // expected-note {{'r' defined here}}
+  int &q = qa[i];              // expected-note {{'q' defined here}}
+  float fl;                    // expected-note {{'fl' defined here}}
+#pragma omp target
+#pragma omp teams reduction // expected-error {{expected '(' after 'reduction'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams' are ignored}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(~ : argc) // expected-error {{expected unqualified-id}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(&& : argc)
+  foo();
+#pragma omp target
+#pragma omp teams reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(min : a, b, c, d, f) // expected-error {{reduction variable with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(max : argv[1]) // expected-error {{expected variable name}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : ba) // expected-error {{a reduction variable with array type 'const S2 [5]'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(* : ca) // expected-error {{a reduction variable with array type 'const S3 [5]'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(- : da) // expected-error {{a reduction variable with array type 'const int [5]'}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(^ : fl) // expected-error {{variable of type 'float' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(& : e, g) // expected-error {{reduction variable must have an accessible, unambiguous default constructor}} expected-error {{variable of type 'S5' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : o) // expected-error {{variable of type 'class S6' is not valid for specified reduction operation}}
+  foo();
+#pragma omp target
+#pragma omp teams private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  foo();
+#pragma omp parallel private(k)
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
+  foo();
+#pragma omp target
+#pragma omp teams reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
+  foo();
+#pragma omp parallel shared(i)
+#pragma omp parallel reduction(min : i)
+#pragma omp target
+#pragma omp teams reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
+  foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for private(fl)
+  for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+    foo();
+#pragma omp target
+#pragma omp teams
+#pragma omp parallel for reduction(- : fl)
+  for (int i = 0; i < 10; ++i)
+#pragma omp target
+#pragma omp teams reduction(+ : fl)
+    foo();
+
+  return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
+}
diff --git a/test/OpenMP/teams_shared_messages.cpp b/test/OpenMP/teams_shared_messages.cpp
new file mode 100644
index 0000000..ce2f917
--- /dev/null
+++ b/test/OpenMP/teams_shared_messages.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 &s2):a(s2.a) { }
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 &s3):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4);
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 &s5):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+int main(int argc, char **argv) {
+  const int d = 5;
+  const int da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  int i;
+  int &j = i;
+  #pragma omp target
+  #pragma omp teams shared // expected-error {{expected '(' after 'shared'}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared () // expected-error {{expected expression}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (argc)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (a, b, c, d, f)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared (argv[1]) // expected-error {{expected variable name}}
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(ba)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(ca)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(da)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(e, g)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(h) // expected-error {{threadprivate or thread local variable cannot be shared}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
+  foo();
+  #pragma omp target
+  #pragma omp teams firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
+  foo();
+  #pragma omp target
+  #pragma omp teams private(i)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(i)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(j)
+  foo();
+  #pragma omp target
+  #pragma omp teams firstprivate(i)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(i)
+  foo();
+  #pragma omp target
+  #pragma omp teams shared(j)
+  foo();
+
+  return 0;
+}
diff --git a/test/OpenMP/threadprivate_codegen.cpp b/test/OpenMP/threadprivate_codegen.cpp
new file mode 100644
index 0000000..98b7917
--- /dev/null
+++ b/test/OpenMP/threadprivate_codegen.cpp
@@ -0,0 +1,707 @@
+// RUN: %clang_cc1 -verify -fopenmp=libiomp5 -DBODY -triple x86_64-unknown-unknown -x c++ -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp=libiomp5 -DBODY -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -g -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix=CHECK-DEBUG %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+// CHECK-DAG: [[IDENT:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[S1:%.+]] = type { [[INT:i[0-9]+]] }
+// CHECK-DAG: [[S2:%.+]] = type { [[INT]], double }
+// CHECK-DAG: [[S3:%.+]] = type { [[INT]], float }
+// CHECK-DAG: [[S4:%.+]] = type { [[INT]], [[INT]] }
+// CHECK-DAG: [[S5:%.+]] = type { [[INT]], [[INT]], [[INT]] }
+// CHECK-DAG: [[SMAIN:%.+]] = type { [[INT]], double, double }
+// CHECK-DEBUG-DAG: [[IDENT:%.+]] = type { i32, i32, i32, i32, i8* }
+// CHECK-DEBUG-DAG: [[S1:%.+]] = type { [[INT:i[0-9]+]] }
+// CHECK-DEBUG-DAG: [[S2:%.+]] = type { [[INT]], double }
+// CHECK-DEBUG-DAG: [[S3:%.+]] = type { [[INT]], float }
+// CHECK-DEBUG-DAG: [[S4:%.+]] = type { [[INT]], [[INT]] }
+// CHECK-DEBUG-DAG: [[S5:%.+]] = type { [[INT]], [[INT]], [[INT]] }
+// CHECK-DEBUG-DAG: [[SMAIN:%.+]] = type { [[INT]], double, double }
+
+struct S1 {
+  int a;
+  S1()
+      : a(0) {
+  }
+  S1(int a)
+      : a(a) {
+  }
+  S1(const S1 &s) {
+    a = 12 + s.a;
+  }
+  ~S1() {
+    a = 0;
+  }
+};
+
+struct S2 {
+  int a;
+  double b;
+  S2()
+      : a(0) {
+  }
+  S2(int a)
+      : a(a) {
+  }
+  S2(const S2 &s) {
+    a = 12 + s.a;
+  }
+  ~S2() {
+    a = 0;
+  }
+};
+
+struct S3 {
+  int a;
+  float b;
+  S3()
+      : a(0) {
+  }
+  S3(int a)
+      : a(a) {
+  }
+  S3(const S3 &s) {
+    a = 12 + s.a;
+  }
+  ~S3() {
+    a = 0;
+  }
+};
+
+struct S4 {
+  int a, b;
+  S4()
+      : a(0) {
+  }
+  S4(int a)
+      : a(a) {
+  }
+  S4(const S4 &s) {
+    a = 12 + s.a;
+  }
+  ~S4() {
+    a = 0;
+  }
+};
+
+struct S5 {
+  int a, b, c;
+  S5()
+      : a(0) {
+  }
+  S5(int a)
+      : a(a) {
+  }
+  S5(const S5 &s) {
+    a = 12 + s.a;
+  }
+  ~S5() {
+    a = 0;
+  }
+};
+
+// CHECK-DAG:  [[GS1:@.+]] = internal global [[S1]] zeroinitializer
+// CHECK-DAG:  [[GS1]].cache. = common global i8** null
+// CHECK-DAG:  [[DEFAULT_LOC:@.+]] = private unnamed_addr constant [[IDENT]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]+}} x i8]* {{@.+}}, i32 0, i32 0) }
+// CHECK-DAG:  [[GS2:@.+]] = internal global [[S2]] zeroinitializer
+// CHECK-DAG:  [[ARR_X:@.+]] = global [2 x [3 x [[S1]]]] zeroinitializer
+// CHECK-DAG:  [[ARR_X]].cache. = common global i8** null
+// CHECK-DAG:  [[SM:@.+]] = internal global [[SMAIN]] zeroinitializer
+// CHECK-DAG:  [[SM]].cache. = common global i8** null
+// CHECK-DAG:  [[STATIC_S:@.+]] = external global [[S3]]
+// CHECK-DAG:  [[STATIC_S]].cache. = common global i8** null
+// CHECK-DAG:  [[GS3:@.+]] = external global [[S5]]
+// CHECK-DAG:  [[GS3]].cache. = common global i8** null
+// CHECK-DAG:  [[ST_INT_ST:@.+]] = linkonce_odr global i32 23
+// CHECK-DAG:  [[ST_INT_ST]].cache. = common global i8** null
+// CHECK-DAG:  [[ST_FLOAT_ST:@.+]] = linkonce_odr global float 2.300000e+01
+// CHECK-DAG:  [[ST_FLOAT_ST]].cache. = common global i8** null
+// CHECK-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr global %struct.S4 zeroinitializer
+// CHECK-DAG:  [[ST_S4_ST]].cache. = common global i8** null
+// CHECK-NOT:  .cache. = common global i8** null
+// There is no cache for gs2 - it is not threadprivate. Check that there is only
+// 8 caches created (for Static::s, gs1, gs3, arr_x, main::sm, ST<int>::st,
+// ST<float>::st, ST<S4>::st)
+// CHECK-DEBUG-DAG: [[GS1:@.+]] = internal global [[S1]] zeroinitializer
+// CHECK-DEBUG-DAG: [[GS2:@.+]] = internal global [[S2]] zeroinitializer
+// CHECK-DEBUG-DAG: [[ARR_X:@.+]] = global [2 x [3 x [[S1]]]] zeroinitializer
+// CHECK-DEBUG-DAG: [[SM:@.+]] = internal global [[SMAIN]] zeroinitializer
+// CHECK-DEBUG-DAG: [[STATIC_S:@.+]] = external global [[S3]]
+// CHECK-DEBUG-DAG: [[GS3:@.+]] = external global [[S5]]
+// CHECK-DEBUG-DAG: [[ST_INT_ST:@.+]] = linkonce_odr global i32 23
+// CHECK-DEBUG-DAG: [[ST_FLOAT_ST:@.+]] = linkonce_odr global float 2.300000e+01
+// CHECK-DEBUG-DAG: [[ST_S4_ST:@.+]] = linkonce_odr global %struct.S4 zeroinitializer
+// CHECK-DEBUG-DAG: [[LOC1:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;;162;9;;\00"
+// CHECK-DEBUG-DAG: [[LOC2:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;;216;9;;\00"
+// CHECK-DEBUG-DAG: [[LOC3:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;;303;19;;\00"
+// CHECK-DEBUG-DAG: [[LOC4:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;328;9;;\00"
+// CHECK-DEBUG-DAG: [[LOC5:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;341;9;;\00"
+// CHECK-DEBUG-DAG: [[LOC6:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;358;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC7:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;375;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC8:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;401;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC9:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;422;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC10:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;437;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC11:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;454;27;;\00"
+// CHECK-DEBUG-DAG: [[LOC12:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;main;471;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC13:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;550;9;;\00"
+// CHECK-DEBUG-DAG: [[LOC14:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;567;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC15:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;593;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC16:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;614;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC17:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;629;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC18:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;646;27;;\00"
+// CHECK-DEBUG-DAG: [[LOC19:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;foobar;663;10;;\00"
+// CHECK-DEBUG-DAG: [[LOC20:@.*]] = private unnamed_addr constant [{{[0-9]+}} x i8] c";{{.*}}threadprivate_codegen.cpp;;275;9;;\00"
+
+struct Static {
+  static S3 s;
+#pragma omp threadprivate(s)
+};
+
+static S1 gs1(5);
+#pragma omp threadprivate(gs1)
+// CHECK:      define {{.*}} [[S1_CTOR:@.*]]([[S1]]* {{.*}},
+// CHECK:      define {{.*}} [[S1_DTOR:@.*]]([[S1]]* {{.*}})
+// CHECK:      define internal {{.*}}i8* [[GS1_CTOR:@\.__kmpc_global_ctor_\..*]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[S1]]*
+// CHECK-NEXT: call {{.*}} [[S1_CTOR]]([[S1]]* [[RES]], {{.*}} 5)
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      ret i8* [[ARG]]
+// CHECK-NEXT: }
+// CHECK:      define internal {{.*}}void [[GS1_DTOR:@\.__kmpc_global_dtor_\..*]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[S1]]*
+// CHECK-NEXT: call {{.*}} [[S1_DTOR]]([[S1]]* [[RES]])
+// CHECK-NEXT: ret void
+// CHECK-NEXT: }
+// CHECK:      define internal {{.*}}void [[GS1_INIT:@\.__omp_threadprivate_init_\..*]]()
+// CHECK:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[DEFAULT_LOC]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i8* (i8*)* [[GS1_CTOR]], i8* (i8*, i8*)* null, void (i8*)* [[GS1_DTOR]])
+// CHECK-NEXT: ret void
+// CHECK-NEXT: }
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR:%.*]] = alloca [[IDENT]]
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG:      store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC1]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG:      @__kmpc_global_thread_num
+// CHECK-DEBUG:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[KMPC_LOC_ADDR]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i8* (i8*)* [[GS1_CTOR:@\.__kmpc_global_ctor_\..*]], i8* (i8*, i8*)* null, void (i8*)* [[GS1_DTOR:@\.__kmpc_global_dtor_\..*]])
+// CHECK-DEBUG:      define internal {{.*}}i8* [[GS1_CTOR]](i8*)
+// CHECK-DEBUG:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK-DEBUG:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-DEBUG:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[S1]]*
+// CHECK-DEBUG-NEXT: call {{.*}} [[S1_CTOR:@.+]]([[S1]]* [[RES]], {{.*}} 5)
+// CHECK-DEBUG:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-DEBUG:      ret i8* [[ARG]]
+// CHECK-DEBUG-NEXT: }
+// CHECK-DEBUG:      define {{.*}} [[S1_CTOR]]([[S1]]* {{.*}},
+// CHECK-DEBUG:      define internal {{.*}}void [[GS1_DTOR]](i8*)
+// CHECK-DEBUG:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK-DEBUG:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-DEBUG:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[S1]]*
+// CHECK-DEBUG-NEXT: call {{.*}} [[S1_DTOR:@.+]]([[S1]]* [[RES]])
+// CHECK-DEBUG-NEXT: ret void
+// CHECK-DEBUG-NEXT: }
+// CHECK-DEBUG:      define {{.*}} [[S1_DTOR]]([[S1]]* {{.*}})
+static S2 gs2(27);
+// CHECK:      define {{.*}} [[S2_CTOR:@.*]]([[S2]]* {{.*}},
+// CHECK:      define {{.*}} [[S2_DTOR:@.*]]([[S2]]* {{.*}})
+// No another call for S2 constructor because it is not threadprivate
+// CHECK-NOT:  call {{.*}} [[S2_CTOR]]([[S2]]*
+// CHECK-DEBUG:      define {{.*}} [[S2_CTOR:@.*]]([[S2]]* {{.*}},
+// CHECK-DEBUG:      define {{.*}} [[S2_DTOR:@.*]]([[S2]]* {{.*}})
+// No another call for S2 constructor because it is not threadprivate
+// CHECK-DEBUG-NOT:  call {{.*}} [[S2_CTOR]]([[S2]]*
+S1 arr_x[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
+#pragma omp threadprivate(arr_x)
+// CHECK:      define internal {{.*}}i8* [[ARR_X_CTOR:@\.__kmpc_global_ctor_\..*]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [2 x [3 x [[S1]]]]*
+// CHECK:      [[ARR1:%.*]] = getelementptr inbounds [2 x [3 x [[S1]]]]* [[RES]], i{{.*}} 0, i{{.*}} 0
+// CHECK:      [[ARR:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR1]], i{{.*}} 0, i{{.*}} 0
+// CHECK:      invoke {{.*}} [[S1_CTOR]]([[S1]]* [[ARR]], [[INT]] {{.*}}1)
+// CHECK:      [[ARR_ELEMENT:%.*]] = getelementptr inbounds [[S1]]* [[ARR]], i{{.*}} 1
+// CHECK:      invoke {{.*}} [[S1_CTOR]]([[S1]]* [[ARR_ELEMENT]], [[INT]] {{.*}}2)
+// CHECK:      [[ARR_ELEMENT2:%.*]] = getelementptr inbounds [[S1]]* [[ARR_ELEMENT]], i{{.*}} 1
+// CHECK:      invoke {{.*}} [[S1_CTOR]]([[S1]]* [[ARR_ELEMENT2]], [[INT]] {{.*}}3)
+// CHECK:      [[ARR_ELEMENT3:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR1]], i{{.*}} 1
+// CHECK:      [[ARR_:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR_ELEMENT3]], i{{.*}} 0, i{{.*}} 0
+// CHECK:      invoke {{.*}} [[S1_CTOR]]([[S1]]* [[ARR_]], [[INT]] {{.*}}4)
+// CHECK:      [[ARR_ELEMENT:%.*]] = getelementptr inbounds [[S1]]* [[ARR_]], i{{.*}} 1
+// CHECK:      invoke {{.*}} [[S1_CTOR]]([[S1]]* [[ARR_ELEMENT]], [[INT]] {{.*}}5)
+// CHECK:      [[ARR_ELEMENT2:%.*]] = getelementptr inbounds [[S1]]* [[ARR_ELEMENT]], i{{.*}} 1
+// CHECK:      invoke {{.*}} [[S1_CTOR]]([[S1]]* [[ARR_ELEMENT2]], [[INT]] {{.*}}6)
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      ret i8* [[ARG]]
+// CHECK:      }
+// CHECK:      define internal {{.*}}void [[ARR_X_DTOR:@\.__kmpc_global_dtor_\..*]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[ARR_BEGIN:%.*]] = bitcast i8* [[ARG]] to [[S1]]*
+// CHECK-NEXT: [[ARR_CUR:%.*]] = getelementptr inbounds [[S1]]* [[ARR_BEGIN]], i{{.*}} 6
+// CHECK-NEXT: br label %[[ARR_LOOP:.*]]
+// CHECK:      {{.*}}[[ARR_LOOP]]{{.*}}
+// CHECK-NEXT: [[ARR_ELEMENTPAST:%.*]] = phi [[S1]]* [ [[ARR_CUR]], {{.*}} ], [ [[ARR_ELEMENT:%.*]], {{.*}} ]
+// CHECK-NEXT: [[ARR_ELEMENT:%.*]] = getelementptr inbounds [[S1]]* [[ARR_ELEMENTPAST]], i{{.*}} -1
+// CHECK-NEXT: invoke {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]])
+// CHECK:      [[ARR_DONE:%.*]] = icmp eq [[S1]]* [[ARR_ELEMENT]], [[ARR_BEGIN]]
+// CHECK-NEXT: br i1 [[ARR_DONE]], label %[[ARR_EXIT:.*]], label %[[ARR_LOOP]]
+// CHECK:      {{.*}}[[ARR_EXIT]]{{.*}}
+// CHECK-NEXT: ret void
+// CHECK:      }
+// CHECK:      define internal {{.*}}void [[ARR_X_INIT:@\.__omp_threadprivate_init_\..*]]()
+// CHECK:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[DEFAULT_LOC]], i8* bitcast ([2 x [3 x [[S1]]]]* [[ARR_X]] to i8*), i8* (i8*)* [[ARR_X_CTOR]], i8* (i8*, i8*)* null, void (i8*)* [[ARR_X_DTOR]])
+// CHECK-NEXT: ret void
+// CHECK-NEXT: }
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR:%.*]] = alloca [[IDENT]]
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG:      store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC2]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG:      @__kmpc_global_thread_num
+// CHECK-DEBUG:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[KMPC_LOC_ADDR]], i8* bitcast ([2 x [3 x [[S1]]]]* [[ARR_X]] to i8*), i8* (i8*)* [[ARR_X_CTOR:@\.__kmpc_global_ctor_\..*]], i8* (i8*, i8*)* null, void (i8*)* [[ARR_X_DTOR:@\.__kmpc_global_dtor_\..*]])
+// CHECK-DEBUG:      define internal {{.*}}i8* [[ARR_X_CTOR]](i8*)
+// CHECK-DEBUG:      }
+// CHECK-DEBUG:      define internal {{.*}}void [[ARR_X_DTOR]](i8*)
+// CHECK-DEBUG:      }
+extern S5 gs3;
+#pragma omp threadprivate(gs3)
+// No call for S5 constructor because gs3 has just declaration, not a definition.
+// CHECK-NOT:  call {{.*}}([[S5]]*
+// CHECK-DEBUG-NOT:  call {{.*}}([[S5]]*
+
+template <class T>
+struct ST {
+  static T st;
+#pragma omp threadprivate(st)
+};
+
+template <class T>
+T ST<T>::st(23);
+
+// CHECK-LABEL:  @main()
+// CHECK-DEBUG-LABEL: @main()
+int main() {
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR:%.*]] = alloca [[IDENT]]
+  int Res;
+  struct Smain {
+    int a;
+    double b, c;
+    Smain()
+        : a(0) {
+    }
+    Smain(int a)
+        : a(a) {
+    }
+    Smain(const Smain &s) {
+      a = 12 + s.a;
+    }
+    ~Smain() {
+      a = 0;
+    }
+  };
+
+  static Smain sm(gs1.a);
+// CHECK:      [[THREAD_NUM:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[DEFAULT_LOC]])
+// CHECK:      call {{.*}}i{{.*}} @__cxa_guard_acquire
+// CHECK:      call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[DEFAULT_LOC]])
+// CHECK:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[DEFAULT_LOC]], i8* bitcast ([[SMAIN]]* [[SM]] to i8*), i8* (i8*)* [[SM_CTOR:@\.__kmpc_global_ctor_\..+]], i8* (i8*, i8*)* null, void (i8*)* [[SM_DTOR:@\.__kmpc_global_dtor_\..+]])
+// CHECK:      [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[GS1]].cache.)
+// CHECK-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+// CHECK-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+// CHECK-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+// CHECK-NEXT: invoke {{.*}} [[SMAIN_CTOR:.*]]([[SMAIN]]* [[SM]], [[INT]] {{.*}}[[GS1_A]])
+// CHECK:      call {{.*}}void @__cxa_guard_release
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC3]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG-NEXT: [[THREAD_NUM:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[KMPC_LOC_ADDR]])
+// CHECK-DEBUG:      call {{.*}}i{{.*}} @__cxa_guard_acquire
+// CHECK-DEBUG:      call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[KMPC_LOC_ADDR]])
+// CHECK-DEBUG:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[KMPC_LOC_ADDR]], i8* bitcast ([[SMAIN]]* [[SM]] to i8*), i8* (i8*)* [[SM_CTOR:@\.__kmpc_global_ctor_\..+]], i8* (i8*, i8*)* null, void (i8*)* [[SM_DTOR:@\.__kmpc_global_dtor_\..+]])
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC3]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG:      [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+// CHECK-DEBUG-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+// CHECK-DEBUG-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+// CHECK-DEBUG-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+// CHECK-DEBUG-NEXT: invoke {{.*}} [[SMAIN_CTOR:.*]]([[SMAIN]]* [[SM]], [[INT]] {{.*}}[[GS1_A]])
+// CHECK-DEBUG:      call {{.*}}void @__cxa_guard_release
+#pragma omp threadprivate(sm)
+  // CHECK:      [[STATIC_S_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S3]]* [[STATIC_S]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[STATIC_S]].cache.)
+  // CHECK-NEXT: [[STATIC_S_ADDR:%.*]] = bitcast i8* [[STATIC_S_TEMP_ADDR]] to [[S3]]*
+  // CHECK-NEXT: [[STATIC_S_A_ADDR:%.*]] = getelementptr inbounds [[S3]]* [[STATIC_S_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[STATIC_S_A:%.*]] = load [[INT]]* [[STATIC_S_A_ADDR]]
+  // CHECK-NEXT: store [[INT]] [[STATIC_S_A]], [[INT]]* [[RES_ADDR:[^,]+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC5]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[STATIC_S_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S3]]* [[STATIC_S]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[STATIC_S_ADDR:%.*]] = bitcast i8* [[STATIC_S_TEMP_ADDR]] to [[S3]]*
+  // CHECK-DEBUG-NEXT: [[STATIC_S_A_ADDR:%.*]] = getelementptr inbounds [[S3]]* [[STATIC_S_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[STATIC_S_A:%.*]] = load [[INT]]* [[STATIC_S_A_ADDR]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[STATIC_S_A]], [[INT]]* [[RES_ADDR:[^,]+]]
+  Res = Static::s.a;
+  // CHECK:      [[SM_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[SMAIN]]* [[SM]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[SM]].cache.)
+  // CHECK-NEXT: [[SM_ADDR:%.*]] = bitcast i8* [[SM_TEMP_ADDR]] to [[SMAIN]]*
+  // CHECK-NEXT: [[SM_A_ADDR:%.*]] = getelementptr inbounds [[SMAIN]]* [[SM_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[SM_A:%.*]] = load [[INT]]* [[SM_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[SM_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC6]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[SM_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[SMAIN]]* [[SM]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[SM_ADDR:%.*]] = bitcast i8* [[SM_TEMP_ADDR]] to [[SMAIN]]*
+  // CHECK-DEBUG-NEXT: [[SM_A_ADDR:%.*]] = getelementptr inbounds [[SMAIN]]* [[SM_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[SM_A:%.*]] = load [[INT]]* [[SM_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[SM_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += sm.a;
+  // CHECK:      [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[GS1]].cache.)
+  // CHECK-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+  // CHECK-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS1_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC7]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+  // CHECK-DEBUG-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS1_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += gs1.a;
+  // CHECK:      [[GS2_A:%.*]] = load [[INT]]* getelementptr inbounds ([[S2]]* [[GS2]], i{{.*}} 0, i{{.*}} 0)
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS2_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[GS2_A:%.*]] = load [[INT]]* getelementptr inbounds ([[S2]]* [[GS2]], i{{.*}} 0, i{{.*}} 0)
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS2_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += gs2.a;
+  // CHECK:      [[GS3_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S5]]* [[GS3]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[GS3]].cache.)
+  // CHECK-NEXT: [[GS3_ADDR:%.*]] = bitcast i8* [[GS3_TEMP_ADDR]] to [[S5]]*
+  // CHECK-NEXT: [[GS3_A_ADDR:%.*]] = getelementptr inbounds [[S5]]* [[GS3_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[GS3_A:%.*]] = load [[INT]]* [[GS3_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS3_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC8]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[GS3_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S5]]* [[GS3]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[GS3_ADDR:%.*]] = bitcast i8* [[GS3_TEMP_ADDR]] to [[S5]]*
+  // CHECK-DEBUG-NEXT: [[GS3_A_ADDR:%.*]] = getelementptr inbounds [[S5]]* [[GS3_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[GS3_A:%.*]] = load [[INT]]* [[GS3_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS3_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += gs3.a;
+  // CHECK:      [[ARR_X_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([2 x [3 x [[S1]]]]* [[ARR_X]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ARR_X]].cache.)
+  // CHECK-NEXT: [[ARR_X_ADDR:%.*]] = bitcast i8* [[ARR_X_TEMP_ADDR]] to [2 x [3 x [[S1]]]]*
+  // CHECK-NEXT: [[ARR_X_1_ADDR:%.*]] = getelementptr inbounds [2 x [3 x [[S1]]]]* [[ARR_X_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-NEXT: [[ARR_X_1_1_ADDR:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR_X_1_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-NEXT: [[ARR_X_1_1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[ARR_X_1_1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[ARR_X_1_1_A:%.*]] = load [[INT]]* [[ARR_X_1_1_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ARR_X_1_1_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC9]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT:      [[ARR_X_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([2 x [3 x [[S1]]]]* [[ARR_X]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ARR_X_ADDR:%.*]] = bitcast i8* [[ARR_X_TEMP_ADDR]] to [2 x [3 x [[S1]]]]*
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_ADDR:%.*]] = getelementptr inbounds [2 x [3 x [[S1]]]]* [[ARR_X_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_1_ADDR:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR_X_1_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[ARR_X_1_1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_1_A:%.*]] = load [[INT]]* [[ARR_X_1_1_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ARR_X_1_1_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += arr_x[1][1].a;
+  // CHECK:      [[ST_INT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[INT]]* [[ST_INT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ST_INT_ST]].cache.)
+  // CHECK-NEXT: [[ST_INT_ST_ADDR:%.*]] = bitcast i8* [[ST_INT_ST_TEMP_ADDR]] to [[INT]]*
+  // CHECK-NEXT: [[ST_INT_ST_VAL:%.*]] = load [[INT]]* [[ST_INT_ST_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_INT_ST_VAL]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC10]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[ST_INT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[INT]]* [[ST_INT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ST_INT_ST_ADDR:%.*]] = bitcast i8* [[ST_INT_ST_TEMP_ADDR]] to [[INT]]*
+  // CHECK-DEBUG-NEXT: [[ST_INT_ST_VAL:%.*]] = load [[INT]]* [[ST_INT_ST_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_INT_ST_VAL]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += ST<int>::st;
+  // CHECK:      [[ST_FLOAT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast (float* [[ST_FLOAT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ST_FLOAT_ST]].cache.)
+  // CHECK-NEXT: [[ST_FLOAT_ST_ADDR:%.*]] = bitcast i8* [[ST_FLOAT_ST_TEMP_ADDR]] to float*
+  // CHECK-NEXT: [[ST_FLOAT_ST_VAL:%.*]] = load float* [[ST_FLOAT_ST_ADDR]]
+  // CHECK-NEXT: [[FLOAT_TO_INT_CONV:%.*]] = fptosi float [[ST_FLOAT_ST_VAL]] to [[INT]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[FLOAT_TO_INT_CONV]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC11]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[ST_FLOAT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast (float* [[ST_FLOAT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ST_FLOAT_ST_ADDR:%.*]] = bitcast i8* [[ST_FLOAT_ST_TEMP_ADDR]] to float*
+  // CHECK-DEBUG-NEXT: [[ST_FLOAT_ST_VAL:%.*]] = load float* [[ST_FLOAT_ST_ADDR]]
+  // CHECK-DEBUG-NEXT: [[FLOAT_TO_INT_CONV:%.*]] = fptosi float [[ST_FLOAT_ST_VAL]] to [[INT]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[FLOAT_TO_INT_CONV]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += static_cast<int>(ST<float>::st);
+  // CHECK:      [[ST_S4_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S4]]* [[ST_S4_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ST_S4_ST]].cache.)
+  // CHECK-NEXT: [[ST_S4_ST_ADDR:%.*]] = bitcast i8* [[ST_S4_ST_TEMP_ADDR]] to [[S4]]*
+  // CHECK-NEXT: [[ST_S4_ST_A_ADDR:%.*]] = getelementptr inbounds [[S4]]* [[ST_S4_ST_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[ST_S4_ST_A:%.*]] = load [[INT]]* [[ST_S4_ST_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_S4_ST_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC12]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S4]]* [[ST_S4_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_ADDR:%.*]] = bitcast i8* [[ST_S4_ST_TEMP_ADDR]] to [[S4]]*
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_A_ADDR:%.*]] = getelementptr inbounds [[S4]]* [[ST_S4_ST_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_A:%.*]] = load [[INT]]* [[ST_S4_ST_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_S4_ST_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += ST<S4>::st.a;
+  // CHECK:      [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: ret [[INT]] [[RES]]
+  // CHECK-DEBUG:      [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: ret [[INT]] [[RES]]
+  return Res;
+}
+// CHECK: }
+
+// CHECK:      define internal {{.*}}i8* [[SM_CTOR]](i8*)
+// CHECK:      [[THREAD_NUM:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[DEFAULT_LOC]])
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[SMAIN]]*
+// CHECK:      [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[GS1]].cache.)
+// CHECK-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+// CHECK-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+// CHECK-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+// CHECK-NEXT: call {{.*}} [[SMAIN_CTOR:@.+]]([[SMAIN]]* [[RES]], [[INT]] {{.*}}[[GS1_A]])
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-NEXT: ret i8* [[ARG]]
+// CHECK-NEXT: }
+// CHECK:      define {{.*}} [[SMAIN_CTOR]]([[SMAIN]]* {{.*}},
+// CHECK:      define internal {{.*}}void [[SM_DTOR]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[SMAIN]]*
+// CHECK-NEXT: call {{.*}} [[SMAIN_DTOR:@.+]]([[SMAIN]]* [[RES]])
+// CHECK-NEXT: ret void
+// CHECK-NEXT: }
+// CHECK:      define {{.*}} [[SMAIN_DTOR]]([[SMAIN]]* {{.*}})
+// CHECK-DEBUG:      define internal {{.*}}i8* [[SM_CTOR]](i8*)
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR:%.*]] = alloca [[IDENT]]
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC3]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG-NEXT: [[THREAD_NUM:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[KMPC_LOC_ADDR]])
+// CHECK-DEBUG:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK-DEBUG:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-DEBUG:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[SMAIN]]*
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC3]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG:      [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+// CHECK-DEBUG-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+// CHECK-DEBUG-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+// CHECK-DEBUG-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+// CHECK-DEBUG-NEXT: call {{.*}} [[SMAIN_CTOR:@.+]]([[SMAIN]]* [[RES]], [[INT]] {{.*}}[[GS1_A]])
+// CHECK-DEBUG:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-DEBUG-NEXT: ret i8* [[ARG]]
+// CHECK-DEBUG-NEXT: }
+// CHECK-DEBUG:      define {{.*}} [[SMAIN_CTOR]]([[SMAIN]]* {{.*}},
+// CHECK-DEBUG:      define internal {{.*}} [[SM_DTOR:@.+]](i8*)
+// CHECK-DEBUG:      call {{.*}} [[SMAIN_DTOR:@.+]]([[SMAIN]]*
+// CHECK-DEBUG:      }
+// CHECK-DEBUG:      define {{.*}} [[SMAIN_DTOR]]([[SMAIN]]* {{.*}})
+
+#endif
+
+#ifdef BODY
+// CHECK-LABEL:  @{{.*}}foobar{{.*}}()
+// CHECK-DEBUG-LABEL: @{{.*}}foobar{{.*}}()
+int foobar() {
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR:%.*]] = alloca [[IDENT]]
+  int Res;
+  // CHECK:      [[THREAD_NUM:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[DEFAULT_LOC]])
+  // CHECK:      [[STATIC_S_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S3]]* [[STATIC_S]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[STATIC_S]].cache.)
+  // CHECK-NEXT: [[STATIC_S_ADDR:%.*]] = bitcast i8* [[STATIC_S_TEMP_ADDR]] to [[S3]]*
+  // CHECK-NEXT: [[STATIC_S_A_ADDR:%.*]] = getelementptr inbounds [[S3]]* [[STATIC_S_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[STATIC_S_A:%.*]] = load [[INT]]* [[STATIC_S_A_ADDR]]
+  // CHECK-NEXT: store [[INT]] [[STATIC_S_A]], [[INT]]* [[RES_ADDR:[^,]+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC13]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[THREAD_NUM:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num([[IDENT]]* [[KMPC_LOC_ADDR]])
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC13]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[STATIC_S_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S3]]* [[STATIC_S]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[STATIC_S_ADDR:%.*]] = bitcast i8* [[STATIC_S_TEMP_ADDR]] to [[S3]]*
+  // CHECK-DEBUG-NEXT: [[STATIC_S_A_ADDR:%.*]] = getelementptr inbounds [[S3]]* [[STATIC_S_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[STATIC_S_A:%.*]] = load [[INT]]* [[STATIC_S_A_ADDR]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[STATIC_S_A]], [[INT]]* [[RES_ADDR:[^,]+]]
+  Res = Static::s.a;
+  // CHECK:      [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[GS1]].cache.)
+  // CHECK-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+  // CHECK-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS1_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC14]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[GS1_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S1]]* [[GS1]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[GS1_ADDR:%.*]] = bitcast i8* [[GS1_TEMP_ADDR]] to [[S1]]*
+  // CHECK-DEBUG-NEXT: [[GS1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[GS1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[GS1_A:%.*]] = load [[INT]]* [[GS1_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS1_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += gs1.a;
+  // CHECK:      [[GS2_A:%.*]] = load [[INT]]* getelementptr inbounds ([[S2]]* [[GS2]], i{{.*}} 0, i{{.*}} 0)
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS2_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[GS2_A:%.*]] = load [[INT]]* getelementptr inbounds ([[S2]]* [[GS2]], i{{.*}} 0, i{{.*}} 0)
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS2_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += gs2.a;
+  // CHECK:      [[GS3_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S5]]* [[GS3]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[GS3]].cache.)
+  // CHECK-NEXT: [[GS3_ADDR:%.*]] = bitcast i8* [[GS3_TEMP_ADDR]] to [[S5]]*
+  // CHECK-NEXT: [[GS3_A_ADDR:%.*]] = getelementptr inbounds [[S5]]* [[GS3_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[GS3_A:%.*]] = load [[INT]]* [[GS3_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS3_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC15]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[GS3_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S5]]* [[GS3]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[GS3_ADDR:%.*]] = bitcast i8* [[GS3_TEMP_ADDR]] to [[S5]]*
+  // CHECK-DEBUG-NEXT: [[GS3_A_ADDR:%.*]] = getelementptr inbounds [[S5]]* [[GS3_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[GS3_A:%.*]] = load [[INT]]* [[GS3_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[GS3_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += gs3.a;
+  // CHECK:      [[ARR_X_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([2 x [3 x [[S1]]]]* [[ARR_X]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ARR_X]].cache.)
+  // CHECK-NEXT: [[ARR_X_ADDR:%.*]] = bitcast i8* [[ARR_X_TEMP_ADDR]] to [2 x [3 x [[S1]]]]*
+  // CHECK-NEXT: [[ARR_X_1_ADDR:%.*]] = getelementptr inbounds [2 x [3 x [[S1]]]]* [[ARR_X_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-NEXT: [[ARR_X_1_1_ADDR:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR_X_1_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-NEXT: [[ARR_X_1_1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[ARR_X_1_1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[ARR_X_1_1_A:%.*]] = load [[INT]]* [[ARR_X_1_1_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ARR_X_1_1_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC16]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT:      [[ARR_X_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([2 x [3 x [[S1]]]]* [[ARR_X]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ARR_X_ADDR:%.*]] = bitcast i8* [[ARR_X_TEMP_ADDR]] to [2 x [3 x [[S1]]]]*
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_ADDR:%.*]] = getelementptr inbounds [2 x [3 x [[S1]]]]* [[ARR_X_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_1_ADDR:%.*]] = getelementptr inbounds [3 x [[S1]]]* [[ARR_X_1_ADDR]], i{{.*}} 0, i{{.*}} 1
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_1_A_ADDR:%.*]] = getelementptr inbounds [[S1]]* [[ARR_X_1_1_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[ARR_X_1_1_A:%.*]] = load [[INT]]* [[ARR_X_1_1_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ARR_X_1_1_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += arr_x[1][1].a;
+  // CHECK:      [[ST_INT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[INT]]* [[ST_INT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ST_INT_ST]].cache.)
+  // CHECK-NEXT: [[ST_INT_ST_ADDR:%.*]] = bitcast i8* [[ST_INT_ST_TEMP_ADDR]] to [[INT]]*
+  // CHECK-NEXT: [[ST_INT_ST_VAL:%.*]] = load [[INT]]* [[ST_INT_ST_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_INT_ST_VAL]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC17]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[ST_INT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[INT]]* [[ST_INT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ST_INT_ST_ADDR:%.*]] = bitcast i8* [[ST_INT_ST_TEMP_ADDR]] to [[INT]]*
+  // CHECK-DEBUG-NEXT: [[ST_INT_ST_VAL:%.*]] = load [[INT]]* [[ST_INT_ST_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_INT_ST_VAL]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += ST<int>::st;
+  // CHECK:      [[ST_FLOAT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast (float* [[ST_FLOAT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ST_FLOAT_ST]].cache.)
+  // CHECK-NEXT: [[ST_FLOAT_ST_ADDR:%.*]] = bitcast i8* [[ST_FLOAT_ST_TEMP_ADDR]] to float*
+  // CHECK-NEXT: [[ST_FLOAT_ST_VAL:%.*]] = load float* [[ST_FLOAT_ST_ADDR]]
+  // CHECK-NEXT: [[FLOAT_TO_INT_CONV:%.*]] = fptosi float [[ST_FLOAT_ST_VAL]] to [[INT]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[FLOAT_TO_INT_CONV]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC18]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[ST_FLOAT_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast (float* [[ST_FLOAT_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ST_FLOAT_ST_ADDR:%.*]] = bitcast i8* [[ST_FLOAT_ST_TEMP_ADDR]] to float*
+  // CHECK-DEBUG-NEXT: [[ST_FLOAT_ST_VAL:%.*]] = load float* [[ST_FLOAT_ST_ADDR]]
+  // CHECK-DEBUG-NEXT: [[FLOAT_TO_INT_CONV:%.*]] = fptosi float [[ST_FLOAT_ST_VAL]] to [[INT]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[FLOAT_TO_INT_CONV]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += static_cast<int>(ST<float>::st);
+  // CHECK:      [[ST_S4_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[DEFAULT_LOC]], i32 [[THREAD_NUM]], i8* bitcast ([[S4]]* [[ST_S4_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8*** [[ST_S4_ST]].cache.)
+  // CHECK-NEXT: [[ST_S4_ST_ADDR:%.*]] = bitcast i8* [[ST_S4_ST_TEMP_ADDR]] to [[S4]]*
+  // CHECK-NEXT: [[ST_S4_ST_A_ADDR:%.*]] = getelementptr inbounds [[S4]]* [[ST_S4_ST_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-NEXT: [[ST_S4_ST_A:%.*]] = load [[INT]]* [[ST_S4_ST_A_ADDR]]
+  // CHECK-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_S4_ST_A]]
+  // CHECK-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  // CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+  // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC19]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_TEMP_ADDR:%.*]] = call {{.*}}i8* @__kmpc_threadprivate_cached([[IDENT]]* [[KMPC_LOC_ADDR]], i32 [[THREAD_NUM]], i8* bitcast ([[S4]]* [[ST_S4_ST]] to i8*), i{{.*}} {{[0-9]+}}, i8***
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_ADDR:%.*]] = bitcast i8* [[ST_S4_ST_TEMP_ADDR]] to [[S4]]*
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_A_ADDR:%.*]] = getelementptr inbounds [[S4]]* [[ST_S4_ST_ADDR]], i{{.*}} 0, i{{.*}} 0
+  // CHECK-DEBUG-NEXT: [[ST_S4_ST_A:%.*]] = load [[INT]]* [[ST_S4_ST_A_ADDR]]
+  // CHECK-DEBUG-NEXT: [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: [[ADD:%.*]] = add {{.*}} [[INT]] [[RES]], [[ST_S4_ST_A]]
+  // CHECK-DEBUG-NEXT: store [[INT]] [[ADD]], [[INT]]* [[RES:.+]]
+  Res += ST<S4>::st.a;
+  // CHECK:      [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-NEXT: ret [[INT]] [[RES]]
+  // CHECK-DEBUG:      [[RES:%.*]] = load [[INT]]* [[RES_ADDR]]
+  // CHECK-DEBUG-NEXT: ret [[INT]] [[RES]]
+  return Res;
+}
+#endif
+
+// CHECK:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[DEFAULT_LOC]], i8* bitcast ([[S4]]* [[ST_S4_ST]] to i8*), i8* (i8*)* [[ST_S4_ST_CTOR:@\.__kmpc_global_ctor_\..+]], i8* (i8*, i8*)* null, void (i8*)* [[ST_S4_ST_DTOR:@\.__kmpc_global_dtor_\..+]])
+// CHECK:      define internal {{.*}}i8* [[ST_S4_ST_CTOR]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[S4]]*
+// CHECK-NEXT: call {{.*}} [[S4_CTOR:@.+]]([[S4]]* [[RES]], {{.*}} 23)
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK-NEXT: ret i8* [[ARG]]
+// CHECK-NEXT: }
+// CHECK:      define {{.*}} [[S4_CTOR]]([[S4]]* {{.*}},
+// CHECK:      define internal {{.*}}void [[ST_S4_ST_DTOR]](i8*)
+// CHECK:      store i8* %0, i8** [[ARG_ADDR:%.*]],
+// CHECK:      [[ARG:%.+]] = load i8** [[ARG_ADDR]]
+// CHECK:      [[RES:%.*]] = bitcast i8* [[ARG]] to [[S4]]*
+// CHECK-NEXT: call {{.*}} [[S4_DTOR:@.+]]([[S4]]* [[RES]])
+// CHECK-NEXT: ret void
+// CHECK-NEXT: }
+// CHECK:      define {{.*}} [[S4_DTOR]]([[S4]]* {{.*}})
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR:%.*]] = alloca [[IDENT]]
+// CHECK-DEBUG:      [[KMPC_LOC_ADDR_PSOURCE:%.*]] = getelementptr inbounds [[IDENT]]* [[KMPC_LOC_ADDR]], i{{.*}} 0, i{{.*}} 4
+// CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.*}} x i8]* [[LOC20]], i{{.*}} 0, i{{.*}} 0), i8** [[KMPC_LOC_ADDR_PSOURCE]]
+// CHECK-DEBUG:      @__kmpc_global_thread_num
+// CHECK-DEBUG:      call {{.*}}void @__kmpc_threadprivate_register([[IDENT]]* [[KMPC_LOC_ADDR]], i8* bitcast ([[S4]]* [[ST_S4_ST]] to i8*), i8* (i8*)* [[ST_S4_ST_CTOR:@\.__kmpc_global_ctor_\..+]], i8* (i8*, i8*)* null, void (i8*)* [[ST_S4_ST_DTOR:@\.__kmpc_global_dtor_\..+]])
+// CHECK-DEBUG:      define internal {{.*}}i8* [[ST_S4_ST_CTOR]](i8*)
+// CHECK-DEBUG:      }
+// CHECK-DEBUG:      define {{.*}} [[S4_CTOR:@.*]]([[S4]]* {{.*}},
+// CHECK-DEBUG:      define internal {{.*}}void [[ST_S4_ST_DTOR]](i8*)
+// CHECK-DEBUG:      }
+// CHECK-DEBUG:      define {{.*}} [[S4_DTOR:@.*]]([[S4]]* {{.*}})
+
+// CHECK:      define internal {{.*}}void {{@.*}}()
+// CHECK-DAG:  call {{.*}}void [[GS1_INIT]]()
+// CHECK-DAG:  call {{.*}}void [[ARR_X_INIT]]()
+// CHECK:      ret void
+// CHECK-DEBUG:      define internal {{.*}}void {{@.*}}()
+// CHECK-DEBUG:      ret void
diff --git a/test/PCH/chain-openmp-threadprivate.cpp b/test/PCH/chain-openmp-threadprivate.cpp
new file mode 100644
index 0000000..5187257
--- /dev/null
+++ b/test/PCH/chain-openmp-threadprivate.cpp
@@ -0,0 +1,26 @@
+// no PCH
+// RUN: %clang_cc1 -fopenmp=libiomp5 -emit-llvm -include %s -include %s %s -o - | FileCheck %s
+// with PCH
+// RUN: %clang_cc1 -fopenmp=libiomp5 -emit-llvm -chain-include %s -chain-include %s %s -o - | FileCheck %s
+#if !defined(PASS1)
+#define PASS1
+
+extern "C" int* malloc (int size);
+int *a = malloc(20);
+
+#elif !defined(PASS2)
+#define PASS2
+
+#pragma omp threadprivate(a)
+
+#else
+
+// CHECK: call {{.*}} @__kmpc_threadprivate_register(
+
+// CHECK-LABEL: foo
+int foo() {
+  return *a;
+  // CHECK: call {{.*}} @__kmpc_global_thread_num(
+  // CHECK: call {{.*}} @__kmpc_threadprivate_cached(
+}
+#endif
diff --git a/test/PCH/cxx-namespaces.cpp b/test/PCH/cxx-namespaces.cpp
index e0feaab..d1bf98b 100644
--- a/test/PCH/cxx-namespaces.cpp
+++ b/test/PCH/cxx-namespaces.cpp
@@ -4,12 +4,12 @@
 // Test with pch.
 // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-namespaces.h
 // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
-// RUN: %clang_cc1 -include-pch %t -fsyntax-only -ast-dump -ast-dump-lookups -ast-dump-filter N %s | FileCheck %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -ast-dump-lookups -ast-dump-filter N %s | FileCheck %s
 
 // Test with modules.
 // RUN: %clang_cc1 -fmodules -x c++-header -emit-pch -o %t %S/cxx-namespaces.h
 // RUN: %clang_cc1 -fmodules -include-pch %t -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fmodules -include-pch %t -fsyntax-only -ast-dump -ast-dump-lookups -ast-dump-filter N %s | FileCheck %s
+// RUN: %clang_cc1 -fmodules -include-pch %t -fsyntax-only -ast-dump-lookups -ast-dump-filter N %s | FileCheck %s
 
 // expected-no-diagnostics
 
diff --git a/test/PCH/cxx-traits.cpp b/test/PCH/cxx-traits.cpp
index ffdfccc..fc3e133 100644
--- a/test/PCH/cxx-traits.cpp
+++ b/test/PCH/cxx-traits.cpp
@@ -1,15 +1,66 @@
 // Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fms-extensions -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s
 
-// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h
-// RUN: %clang_cc1 -std=c++11 -include-pch %t -DPCH -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fms-extensions -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h
+// RUN: %clang_cc1 -fms-extensions -std=c++11 -include-pch %t -DPCH -fsyntax-only -verify %s
 
 #ifdef PCH
 // expected-no-diagnostics
 #endif
 
-bool _Is_pod_comparator = __is_pod<int>::__value;
-bool _Is_empty_check = __is_empty<int>::__value;
+bool _Is_pod_comparator = n::__is_pod<int>::__value;
+bool _Is_empty_check = n::__is_empty<int>::__value;
 
-bool default_construct_int = is_trivially_constructible<int>::value;
-bool copy_construct_int = is_trivially_constructible<int, const int&>::value;
+bool default_construct_int = n::is_trivially_constructible<int>::value;
+bool copy_construct_int = n::is_trivially_constructible<int, const int&>::value;
+
+// The built-ins should still work too:
+bool _is_abstract_result = __is_abstract(int);
+bool _is_arithmetic_result = __is_arithmetic(int);
+bool _is_array_result = __is_array(int);
+bool _is_base_of_result = __is_base_of(int, int);
+bool _is_class_result = __is_class(int);
+bool _is_complete_type_result = __is_complete_type(int);
+bool _is_compound_result = __is_compound(int);
+bool _is_const_result = __is_const(int);
+bool _is_constructible_result = __is_constructible(int);
+bool _is_convertible_result = __is_convertible(int, int);
+bool _is_convertible_to_result = __is_convertible_to(int, int);
+bool _is_destructible_result = __is_destructible(int);
+bool _is_empty_result = __is_empty(int);
+bool _is_enum_result = __is_enum(int);
+bool _is_floating_point_result = __is_floating_point(int);
+bool _is_final_result = __is_final(int);
+bool _is_function_result = __is_function(int);
+bool _is_fundamental_result = __is_fundamental(int);
+bool _is_integral_result = __is_integral(int);
+bool _is_interface_class_result = __is_interface_class(int);
+bool _is_literal_result = __is_literal(int);
+bool _is_lvalue_expr_result = __is_lvalue_expr(0);
+bool _is_lvalue_reference_result = __is_lvalue_reference(int);
+bool _is_member_function_pointer_result = __is_member_function_pointer(int);
+bool _is_member_object_pointer_result = __is_member_object_pointer(int);
+bool _is_member_pointer_result = __is_member_pointer(int);
+bool _is_nothrow_assignable_result = __is_nothrow_assignable(int, int);
+bool _is_nothrow_constructible_result = __is_nothrow_constructible(int);
+bool _is_nothrow_destructible_result = __is_nothrow_destructible(int);
+bool _is_object_result = __is_object(int);
+bool _is_pod_result = __is_pod(int);
+bool _is_pointer_result = __is_pointer(int);
+bool _is_polymorphic_result = __is_polymorphic(int);
+bool _is_reference_result = __is_reference(int);
+bool _is_rvalue_expr_result = __is_rvalue_expr(0);
+bool _is_rvalue_reference_result = __is_rvalue_reference(int);
+bool _is_same_result = __is_same(int, int);
+bool _is_scalar_result = __is_scalar(int);
+bool _is_sealed_result = __is_sealed(int);
+bool _is_signed_result = __is_signed(int);
+bool _is_standard_layout_result = __is_standard_layout(int);
+bool _is_trivial_result = __is_trivial(int);
+bool _is_trivially_assignable_result = __is_trivially_assignable(int, int);
+bool _is_trivially_constructible_result = __is_trivially_constructible(int);
+bool _is_trivially_copyable_result = __is_trivially_copyable(int);
+bool _is_union_result = __is_union(int);
+bool _is_unsigned_result = __is_unsigned(int);
+bool _is_void_result = __is_void(int);
+bool _is_volatile_result = __is_volatile(int);
diff --git a/test/PCH/cxx-traits.h b/test/PCH/cxx-traits.h
index e6f2feb..2132476 100644
--- a/test/PCH/cxx-traits.h
+++ b/test/PCH/cxx-traits.h
@@ -1,5 +1,7 @@
 // Header for PCH test cxx-traits.cpp
 
+namespace n {
+
 template<typename _Tp>
 struct __is_pod { // expected-warning {{keyword '__is_pod' will be made available as an identifier for the remainder of the translation unit}}
   enum { __value };
@@ -14,3 +16,54 @@
 struct is_trivially_constructible {
   static const bool value = __is_trivially_constructible(T, Args...);
 };
+
+struct __is_abstract {};  // expected-warning {{made available}}
+struct __is_arithmetic {};  // expected-warning {{made available}}
+struct __is_array {};  // expected-warning {{made available}}
+struct __is_base_of {};  // expected-warning {{made available}}
+struct __is_class {};  // expected-warning {{made available}}
+struct __is_complete_type {};  // expected-warning {{made available}}
+struct __is_compound {};  // expected-warning {{made available}}
+struct __is_const {};  // expected-warning {{made available}}
+struct __is_constructible {};  // expected-warning {{made available}}
+struct __is_convertible {};  // expected-warning {{made available}}
+struct __is_convertible_to {};  // expected-warning {{made available}}
+struct __is_destructible {};  // expected-warning {{made available}}
+struct __is_enum {};  // expected-warning {{made available}}
+struct __is_floating_point {};  // expected-warning {{made available}}
+struct __is_final {};  // expected-warning {{made available}}
+struct __is_function {};  // expected-warning {{made available}}
+struct __is_fundamental {};  // expected-warning {{made available}}
+struct __is_integral {};  // expected-warning {{made available}}
+struct __is_interface_class {};  // expected-warning {{made available}}
+struct __is_literal {};  // expected-warning {{made available}}
+struct __is_lvalue_expr {};  // expected-warning {{made available}}
+struct __is_lvalue_reference {};  // expected-warning {{made available}}
+struct __is_member_function_pointer {};  // expected-warning {{made available}}
+struct __is_member_object_pointer {};  // expected-warning {{made available}}
+struct __is_member_pointer {};  // expected-warning {{made available}}
+struct __is_nothrow_assignable {};  // expected-warning {{made available}}
+struct __is_nothrow_constructible {};  // expected-warning {{made available}}
+struct __is_nothrow_destructible {};  // expected-warning {{made available}}
+struct __is_object {};  // expected-warning {{made available}}
+struct __is_pointer {};  // expected-warning {{made available}}
+struct __is_polymorphic {};  // expected-warning {{made available}}
+struct __is_reference {};  // expected-warning {{made available}}
+struct __is_rvalue_expr {};  // expected-warning {{made available}}
+struct __is_rvalue_reference {};  // expected-warning {{made available}}
+struct __is_same {};  // expected-warning {{made available}}
+struct __is_scalar {};  // expected-warning {{made available}}
+struct __is_sealed {};  // expected-warning {{made available}}
+struct __is_signed {};  // expected-warning {{made available}}
+struct __is_standard_layout {};  // expected-warning {{made available}}
+struct __is_trivial {};  // expected-warning {{made available}}
+struct __is_trivially_assignable {};  // expected-warning {{made available}}
+struct __is_trivially_constructible {};  // expected-warning {{made available}}
+struct __is_trivially_copyable {};  // expected-warning {{made available}}
+struct __is_union {};  // expected-warning {{made available}}
+struct __is_unsigned {};  // expected-warning {{made available}}
+struct __is_void {};  // expected-warning {{made available}}
+struct __is_volatile {};  // expected-warning {{made available}}
+
+
+}
diff --git a/test/PCH/pragma-loop.cpp b/test/PCH/pragma-loop.cpp
index 6258b37..2640020 100644
--- a/test/PCH/pragma-loop.cpp
+++ b/test/PCH/pragma-loop.cpp
@@ -10,9 +10,14 @@
 // CHECK: #pragma clang loop unroll(disable)
 // CHECK: #pragma clang loop interleave(disable)
 // CHECK: #pragma clang loop vectorize(enable)
-// CHECK: #pragma clang loop unroll(enable)
+// CHECK: #pragma clang loop unroll(full)
 // CHECK: #pragma clang loop interleave(enable)
 // CHECK: #pragma clang loop vectorize(disable)
+// CHECK: #pragma unroll
+// CHECK: #pragma unroll (32)
+// CHECK: #pragma nounroll
+// CHECK: #pragma clang loop interleave_count(I)
+// CHECK: #pragma clang loop vectorize_width(V)
 
 #ifndef HEADER
 #define HEADER
@@ -45,14 +50,49 @@
     int i = 0;
 #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(enable)
-#pragma clang loop unroll(enable)
+#pragma clang loop unroll(full)
     while (i - 3 < Length) {
       List[i] = i;
       i++;
     }
   }
-};
 
+  inline void run4(int *List, int Length) {
+    int i = 0;
+#pragma unroll
+    while (i - 3 < Length) {
+      List[i] = i;
+      i++;
+    }
+  }
+
+  inline void run5(int *List, int Length) {
+    int i = 0;
+#pragma unroll 32
+    while (i - 3 < Length) {
+      List[i] = i;
+      i++;
+    }
+  }
+
+  inline void run6(int *List, int Length) {
+    int i = 0;
+#pragma nounroll
+    while (i - 3 < Length) {
+      List[i] = i;
+      i++;
+    }
+  }
+
+  template <int V, int I>
+  inline void run7(int *List, int Length) {
+#pragma clang loop vectorize_width(V)
+#pragma clang loop interleave_count(I)
+    for (int i = 0; i < Length; i++) {
+      List[i] = i;
+    }
+  }
+};
 #else
 
 void test() {
@@ -63,6 +103,10 @@
   pt.run1(List, 100);
   pt.run2(List, 100);
   pt.run3(List, 100);
+  pt.run4(List, 100);
+  pt.run5(List, 100);
+  pt.run6(List, 100);
+  pt.run7<2, 4>(List, 100);
 }
 
 #endif
diff --git a/test/PCH/pragma-optimize.c b/test/PCH/pragma-optimize.c
index 2206fe7..9570117 100644
--- a/test/PCH/pragma-optimize.c
+++ b/test/PCH/pragma-optimize.c
@@ -5,6 +5,12 @@
 // RUN: %clang_cc1 %s -emit-pch -o %t
 // RUN: %clang_cc1 %s -emit-llvm -include-pch %t -o - | FileCheck %s
 
+// The first run line creates a pch, and since at that point HEADER is not
+// defined, the only thing contained in the pch is the pragma. The second line
+// then includes that pch, so HEADER is defined and the actual code is compiled.
+// The check then makes sure that the pragma is in effect in the file that
+// includes the pch.
+
 // expected-no-diagnostics
 
 #ifndef HEADER
diff --git a/test/PCH/stmt-attrs.cpp b/test/PCH/stmt-attrs.cpp
index 3d7c7a2..170e349 100644
--- a/test/PCH/stmt-attrs.cpp
+++ b/test/PCH/stmt-attrs.cpp
@@ -1,24 +1,24 @@
-// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t.a %s

-// RUN: %clang_cc1 -std=c++11 -include-pch %t.a %s -ast-print -o - | FileCheck %s

-

-#ifndef HEADER

-#define HEADER

-

-inline void test(int i) {

-  switch (i) {

-    case 1:

-      // Notice that the NullStmt has two attributes.

-      // CHECK: {{\[\[clang::fallthrough\]\] \[\[clang::fallthrough\]\]}}

-      [[clang::fallthrough]] [[clang::fallthrough]];

-    case 2:

-      break;

-  }

-}

-

-#else

-

-void foo(void) {

-  test(1);

-}

-

-#endif

+// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t.a %s
+// RUN: %clang_cc1 -std=c++11 -include-pch %t.a %s -ast-print -o - | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+inline void test(int i) {
+  switch (i) {
+    case 1:
+      // Notice that the NullStmt has two attributes.
+      // CHECK: {{\[\[clang::fallthrough\]\] \[\[clang::fallthrough\]\]}}
+      [[clang::fallthrough]] [[clang::fallthrough]];
+    case 2:
+      break;
+  }
+}
+
+#else
+
+void foo(void) {
+  test(1);
+}
+
+#endif
diff --git a/test/PCH/verify_pch.m b/test/PCH/verify_pch.m
index dcfb286..e905f25 100644
--- a/test/PCH/verify_pch.m
+++ b/test/PCH/verify_pch.m
@@ -5,25 +5,25 @@
 // RUN: cp %s %t.h
 //
 // Precompile
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -x objective-c-header -emit-pch -o %t.pch %t.h
+// RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header -emit-pch -o %t.pch %t.h
 
 // Verify successfully
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch
+// RUN: %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch
 
 // Incompatible lang options ignored
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -x objective-c -fno-builtin -verify-pch %t.pch
+// RUN: %clang_cc1 -isystem %t/usr/include -x objective-c -fno-builtin -verify-pch %t.pch
 
 // Stale dependency
 // RUN: echo ' ' >> %t.h
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch 2> %t.log.2
+// RUN: not %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch 2> %t.log.2
 // RUN: FileCheck -check-prefix=CHECK-STALE-DEP %s < %t.log.2
 // CHECK-STALE-DEP: file '{{.*}}.h' has been modified since the precompiled header '{{.*}}.pch' was built
 
 // Stale dependency in system header
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -x objective-c-header -emit-pch -o %t.pch %t.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch
+// RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header -emit-pch -o %t.pch %t.h
+// RUN: %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch
 // RUN: echo ' ' >> %t/usr/include/sys_header.h
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch 2> %t.log.3
+// RUN: not %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch 2> %t.log.3
 // RUN: FileCheck -check-prefix=CHECK-STALE-SYS-H %s < %t.log.3
 // CHECK-STALE-SYS-H: file '{{.*}}sys_header.h' has been modified since the precompiled header '{{.*}}.pch' was built
 
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index a35d069..85ccdc5 100644
--- a/test/Parser/MicrosoftExtensions.cpp
+++ b/test/Parser/MicrosoftExtensions.cpp
@@ -118,7 +118,7 @@
 
 COM_CLASS_TEMPLATE_REF<int, __uuidof(struct_with_uuid)> good_template_arg;
 
-COM_CLASS_TEMPLATE<int, __uuidof(struct_with_uuid)> bad_template_arg; // expected-error {{non-type template argument of type 'const _GUID' cannot be converted to a value of type 'const GUID *' (aka 'const _GUID *')}}
+COM_CLASS_TEMPLATE<int, __uuidof(struct_with_uuid)> bad_template_arg; // expected-error {{non-type template argument of type 'const _GUID' is not a constant expression}}
 
 namespace PR16911 {
 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
@@ -208,12 +208,12 @@
 
 __interface MicrosoftInterface;
 __interface MicrosoftInterface {
-   void foo1() = 0;
+   void foo1() = 0; // expected-note {{overridden virtual function is here}}
    virtual void foo2() = 0;
 };
 
 __interface MicrosoftDerivedInterface : public MicrosoftInterface {
-  void foo1();
+  void foo1(); // expected-warning {{'foo1' overrides a member function but is not marked 'override'}}
   void foo2() override;
   void foo3();
 };
@@ -226,6 +226,11 @@
 }
 
 __int64 x7 = __int64(0);
+_int64 x8 = _int64(0);
+static_assert(sizeof(_int64) == 8, "");
+static_assert(sizeof(_int32) == 4, "");
+static_assert(sizeof(_int16) == 2, "");
+static_assert(sizeof(_int8) == 1, "");
 
 int __identifier(generic) = 3;
 int __identifier(int) = 4;
@@ -357,3 +362,7 @@
 void foo(void) {
   __declspec(align(16)) int *buffer = (int *)_alloca(9);
 }
+
+template <int *>
+struct NullptrArg {};
+NullptrArg<nullptr> a;
diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c
index 0b8147a..7adca61 100644
--- a/test/Parser/altivec.c
+++ b/test/Parser/altivec.c
@@ -61,15 +61,15 @@
 vector long int v_li;               // expected-warning {{Use of 'long' with '__vector' is deprecated}}
 vector signed long int v_sli;       // expected-warning {{Use of 'long' with '__vector' is deprecated}}
 vector unsigned long int v_uli;     // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector long double  vv_ld;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double  v_ld;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector long double  vv_ld;        // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double  v_ld;           // expected-error {{cannot use 'long double' with '__vector'}}
 vector bool v_b;                    // expected-warning {{type specifier missing, defaults to 'int'}}
 
 // These should have errors.
-__vector double vv_d1;               // expected-error {{cannot use 'double' with '__vector'}}
-vector double v_d2;                  // expected-error {{cannot use 'double' with '__vector'}}
-__vector long double  vv_ld3;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double  v_ld4;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector double vv_d1;               // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+vector double v_d2;                  // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+__vector long double  vv_ld3;        // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double  v_ld4;           // expected-error {{cannot use 'long double' with '__vector'}}
 vector bool float v_bf;              // expected-error {{cannot use 'float' with '__vector bool'}}
 vector bool double v_bd;             // expected-error {{cannot use 'double' with '__vector bool'}}
 vector bool pixel v_bp;              // expected-error {{cannot use '__pixel' with '__vector bool'}}
@@ -78,6 +78,11 @@
 vector bool long v_bl;               // expected-error {{cannot use 'long' with '__vector bool'}}
 vector bool long long v_bll;         // expected-error {{cannot use 'long long' with '__vector bool'}}
 
+// vector long is deprecated, but vector long long is not.
+vector long long v_ll;
+vector signed long long v_sll;
+vector unsigned long long v_ull;
+
 typedef char i8;
 typedef short i16;
 typedef int i32;
diff --git a/test/Parser/atomic.c b/test/Parser/atomic.c
index 432deeb..07a83dd 100644
--- a/test/Parser/atomic.c
+++ b/test/Parser/atomic.c
@@ -33,3 +33,6 @@
 
 typedef _Atomic int __attribute__((vector_size(16))) atomic_vector_int;
 typedef _Atomic(int __attribute__((vector_size(16)))) atomic_vector_int;
+
+struct S
+_Atomic atomic_s_no_missing_semicolon;
diff --git a/test/Parser/attr-availability.c b/test/Parser/attr-availability.c
index 06bebba..d812296 100644
--- a/test/Parser/attr-availability.c
+++ b/test/Parser/attr-availability.c
@@ -20,6 +20,8 @@
 
 void f7() __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
 
+void f8() __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+
 // rdar://10095131
 enum E{
     gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal for optional message in 'availability' attribute}}
diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c
index 3d69c72..b815b8d 100644
--- a/test/Parser/attributes.c
+++ b/test/Parser/attributes.c
@@ -95,3 +95,13 @@
 __attribute__((pure)) int testFundef6(int a) { return a; }
 
 void deprecatedTestFun(void) __attribute__((deprecated()));
+
+struct s {
+  int a;
+};
+
+// This test ensure compatibility with parsing GNU-style attributes
+// where the attribute is on a separate line from the elaborated type
+// specifier.
+struct s
+__attribute__((used)) bar;
diff --git a/test/Parser/c11-noreturn.c b/test/Parser/c11-noreturn.c
index e61901d..9b932ab 100644
--- a/test/Parser/c11-noreturn.c
+++ b/test/Parser/c11-noreturn.c
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
+// RUN: not %clang_cc1 -std=c99 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
 
 _Noreturn int f();
 int _Noreturn f(); // expected-note {{previous}}
 int f _Noreturn(); // expected-error {{expected ';'}} expected-error 2{{}}
-int f() _Noreturn; // expected-error {{expected ';'}} expected-warning {{does not declare anything}} expected-error {{'_Noreturn' can only appear on functions}}
+int f() _Noreturn; // expected-error {{'_Noreturn' keyword must precede function declarator}}
 
 _Noreturn char c1; // expected-error {{'_Noreturn' can only appear on functions}}
 char _Noreturn c2; // expected-error {{'_Noreturn' can only appear on functions}}
diff --git a/test/Parser/c1x-alignas.c b/test/Parser/c1x-alignas.c
index 5b29df2..ce8436c 100644
--- a/test/Parser/c1x-alignas.c
+++ b/test/Parser/c1x-alignas.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
+// RUN: not %clang_cc1 -std=c99 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s
 
 _Alignas(4) char c1;
 unsigned _Alignas(long) char c2;
diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp
index 565decc..f2ba28b 100644
--- a/test/Parser/cxx-altivec.cpp
+++ b/test/Parser/cxx-altivec.cpp
@@ -61,14 +61,14 @@
 vector long int v_li;               // expected-warning {{Use of 'long' with '__vector' is deprecated}}
 vector signed long int v_sli;       // expected-warning {{Use of 'long' with '__vector' is deprecated}}
 vector unsigned long int v_uli;     // expected-warning {{Use of 'long' with '__vector' is deprecated}}
-__vector long double  vv_ld;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double  v_ld;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector long double  vv_ld;        // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double  v_ld;           // expected-error {{cannot use 'long double' with '__vector'}}
 
 // These should have errors.
-__vector double vv_d1;               // expected-error {{cannot use 'double' with '__vector'}}
-vector double v_d2;                  // expected-error {{cannot use 'double' with '__vector'}}
-__vector long double  vv_ld3;        // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector long double  v_ld4;           // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+__vector double vv_d1;               // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+vector double v_d2;                  // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}}
+__vector long double  vv_ld3;        // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double  v_ld4;           // expected-error {{cannot use 'long double' with '__vector'}}
 vector bool v_b;                     // expected-error {{C++ requires a type specifier for all declarations}}
 vector bool float v_bf;              // expected-error {{cannot use 'float' with '__vector bool'}}
 vector bool double v_bd;             // expected-error {{cannot use 'double' with '__vector bool'}}
@@ -78,6 +78,11 @@
 vector bool long v_bl;               // expected-error {{cannot use 'long' with '__vector bool'}}
 vector bool long long v_bll;         // expected-error {{cannot use 'long long' with '__vector bool'}}
 
+// vector long is deprecated, but vector long long is not.
+vector long long v_ll;
+vector signed long long v_sll;
+vector unsigned long long v_ull;
+
 void f() {
   __vector unsigned int v = {0,0,0,0};
   __vector int v__cast = (__vector int)v;
diff --git a/test/Parser/cxx-ambig-init-templ.cpp b/test/Parser/cxx-ambig-init-templ.cpp
index ac79f77..1f69266 100644
--- a/test/Parser/cxx-ambig-init-templ.cpp
+++ b/test/Parser/cxx-ambig-init-templ.cpp
@@ -169,3 +169,9 @@
     enum E {};
   };
 }
+
+namespace PR20459 {
+  template <typename EncTraits> struct A {
+     void foo(int = EncTraits::template TypeEnc<int, int>::val); // ok
+  };
+}
diff --git a/test/Parser/cxx-casting.cpp b/test/Parser/cxx-casting.cpp
index 55309a1..d2c97b8 100644
--- a/test/Parser/cxx-casting.cpp
+++ b/test/Parser/cxx-casting.cpp
@@ -101,5 +101,11 @@
   (true ? (B(*)())f : p)();
 }
 
+void PR19751(int n) {
+  struct T { void operator++(int); };
+  (T())++; // ok, not an ill-formed cast to function type
+  (T())++n; // expected-error {{C-style cast from 'int' to 'T ()' is not allowed}}
+}
+
 // PR13619. Must be at end of file.
 int n = reinterpret_cast // expected-error {{expected '<'}} expected-error {{expected ';'}}
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 80cd828..b6eb1b4 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -139,6 +139,46 @@
   };
 }
 
+namespace DtorErrors {
+  struct A { ~A(); } a;
+  ~A::A() {} // expected-error {{'~' in destructor name should be after nested name specifier}} expected-note {{previous}}
+  A::~A() {} // expected-error {{redefinition}}
+
+  struct B { ~B(); } *b;
+  DtorErrors::~B::B() {} // expected-error {{'~' in destructor name should be after nested name specifier}}
+
+  void f() {
+    a.~A::A(); // expected-error {{'~' in destructor name should be after nested name specifier}}
+    b->~DtorErrors::~B::B(); // expected-error {{'~' in destructor name should be after nested name specifier}}
+  }
+}
+
+namespace BadFriend {
+  struct A {
+    friend int : 3; // expected-error {{friends can only be classes or functions}}
+    friend void f() = 123; // expected-error {{illegal initializer}}
+    friend virtual void f(); // expected-error {{'virtual' is invalid in friend declarations}}
+    friend void f() final; // expected-error {{'final' is invalid in friend declarations}}
+    friend void f() override; // expected-error {{'override' is invalid in friend declarations}}
+  };
+}
+
+class PR20760_a {
+  int a = ); // expected-warning {{extension}} expected-error {{expected expression}}
+  int b = }; // expected-warning {{extension}} expected-error {{expected expression}}
+  int c = ]; // expected-warning {{extension}} expected-error {{expected expression}}
+};
+class PR20760_b {
+  int d = d); // expected-warning {{extension}} expected-error {{expected ';'}}
+  int e = d]; // expected-warning {{extension}} expected-error {{expected ';'}}
+  int f = d // expected-warning {{extension}} expected-error {{expected ';'}}
+};
+
+namespace PR20887 {
+class X1 { a::operator=; }; // expected-error {{undeclared identifier 'a'}}
+class X2 { a::a; }; // expected-error {{undeclared identifier 'a'}}
+}
+
 // PR11109 must appear at the end of the source file
 class pr11109r3 { // expected-note{{to match this '{'}}
   public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}
diff --git a/test/Parser/cxx-default-args.cpp b/test/Parser/cxx-default-args.cpp
index 36abf0d..f0e2e69 100644
--- a/test/Parser/cxx-default-args.cpp
+++ b/test/Parser/cxx-default-args.cpp
@@ -31,3 +31,8 @@
   void f7(bool a = T1<int, bool>::V < 3);
   void f8(int = func<0,1<2>(0), int = 1<0, T1<int,int>(int) = 0);
 };
+
+// rdar://18508589
+struct S { 
+  void f(int &r = error);  // expected-error {{use of undeclared identifier 'error'}}
+};
diff --git a/test/Parser/cxx-template-argument.cpp b/test/Parser/cxx-template-argument.cpp
index bbd53b2..c9cc6b8 100644
--- a/test/Parser/cxx-template-argument.cpp
+++ b/test/Parser/cxx-template-argument.cpp
@@ -106,3 +106,8 @@
   { };
 
 }
+
+namespace PR18793 {
+  template<typename T, T> struct S {};
+  template<typename T> int g(S<T, (T())> *);
+}
diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp
index 8b2b120..bce1b7c 100644
--- a/test/Parser/cxx-template-decl.cpp
+++ b/test/Parser/cxx-template-decl.cpp
@@ -210,3 +210,18 @@
 }
 
 }
+
+namespace broken_baseclause {
+template<typename T>
+struct base { };
+
+struct t1 : base<int,
+  public:  // expected-error {{expected expression}}
+};  // expected-error {{expected class name}}
+// expected-error@-1 {{expected '{' after base class list}}
+struct t2 : base<int,
+  public  // expected-error {{expected expression}}
+};  // expected-error {{expected class name}}
+// expected-error@-1 {{expected '{' after base class list}}
+
+}
diff --git a/test/Parser/cxx-variadic-func.cpp b/test/Parser/cxx-variadic-func.cpp
index b9360d6..98a34d3 100644
--- a/test/Parser/cxx-variadic-func.cpp
+++ b/test/Parser/cxx-variadic-func.cpp
@@ -1,5 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only  %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 void f(...) {
-  int g(int(...));
+  // FIXME: There's no disambiguation here; this is unambiguous.
+  int g(int(...)); // expected-warning {{disambiguated}} expected-note {{paren}}
 }
+
+void h(int n..., int m); // expected-error {{expected ')'}} expected-note {{to match}}
diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp
index f8abc76..e366d85 100644
--- a/test/Parser/cxx0x-attributes.cpp
+++ b/test/Parser/cxx0x-attributes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat %s
 
 // Need std::initializer_list
 namespace std {
@@ -121,6 +121,7 @@
 [[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
+namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are incompatible with C++ standards before C++1z}}
 
 using [[]] alignas(4) [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
 using [[]] alignas(4) [[]] foobar = int; // expected-error {{an attribute list cannot appear here}} expected-error {{'alignas' attribute only applies to}}
@@ -172,7 +173,7 @@
 enum [[]] E1;
 enum [[]] E3 : int;
 enum [[]] {
-  k_123 [[]] = 123 // expected-error {{an attribute list cannot appear here}}
+  k_123 [[]] = 123 // expected-warning {{attributes on an enumerator declaration are incompatible with C++ standards before C++1z}}
 };
 enum [[]] E1 e; // expected-error {{an attribute list cannot appear here}}
 enum [[]] class E4 { }; // expected-error {{an attribute list cannot appear here}}
diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp
index a0334cd..994104f 100644
--- a/test/Parser/cxx0x-decl.cpp
+++ b/test/Parser/cxx0x-decl.cpp
@@ -116,9 +116,19 @@
   };
 }
 
+namespace ColonColonDecltype {
+  struct S { struct T {}; };
+  ::decltype(S())::T invalid; // expected-error {{expected unqualified-id}}
+}
+
 struct Base { virtual void f() = 0; virtual void g() = 0; virtual void h() = 0; };
 struct MemberComponentOrder : Base {
   void f() override __asm__("foobar") __attribute__(( )) {}
   void g() __attribute__(( )) override;
   void h() __attribute__(( )) override {}
 };
+
+void NoMissingSemicolonHere(struct S
+                            [3]);
+template<int ...N> void NoMissingSemicolonHereEither(struct S
+                                                     ... [N]);
diff --git a/test/Parser/cxx0x-in-cxx98.cpp b/test/Parser/cxx0x-in-cxx98.cpp
index 7249938..10cb4d2 100644
--- a/test/Parser/cxx0x-in-cxx98.cpp
+++ b/test/Parser/cxx0x-in-cxx98.cpp
@@ -28,3 +28,7 @@
 auto Auto::n = 0; // expected-warning {{'auto' type specifier is a C++11 extension}}
 auto Auto::m = 0; // expected-error {{no member named 'm' in 'Auto'}}
                   // expected-warning@-1 {{'auto' type specifier is a C++11 extension}}
+
+struct Conv { template<typename T> operator T(); };
+bool pr21367_a = new int && false;
+bool pr21367_b = &Conv::operator int && false;
diff --git a/test/Parser/cxx11-templates.cpp b/test/Parser/cxx11-templates.cpp
new file mode 100644
index 0000000..ed04952
--- /dev/null
+++ b/test/Parser/cxx11-templates.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct S {
+  template <typename Ty = char>
+  static_assert(sizeof(Ty) != 1, "Not a char"); // expected-error {{a static_assert declaration cannot be a template}}
+};
+
+template <typename Ty = char>
+static_assert(sizeof(Ty) != 1, "Not a char"); // expected-error {{a static_assert declaration cannot be a template}}
+
+namespace Ellipsis {
+  template<typename ...T> void f(T t..., int n); // expected-error {{must immediately precede declared identifier}}
+  template<typename ...T> void f(int n, T t...); // expected-error {{must immediately precede declared identifier}}
+  template<typename ...T> void f(int n, T t, ...); // expected-error {{unexpanded parameter pack}}
+  template<typename ...T> void f() {
+    f([]{
+      void g(T
+             t // expected-note {{place '...' immediately before declared identifier to declare a function parameter pack}}
+             ... // expected-warning {{'...' in this location creates a C-style varargs function, not a function parameter pack}}
+             // expected-note@-1 {{insert ',' before '...' to silence this warning}}
+             );
+      void h(T (&
+              ) // expected-note {{place '...' here to declare a function parameter pack}}
+             ... // expected-warning {{'...' in this location creates a C-style varargs function, not a function parameter pack}}
+             // expected-note@-1 {{insert ',' before '...' to silence this warning}}
+             );
+      void i(T (&), ...);
+    }...);
+  }
+  template<typename ...T> struct S {
+    void f(T t...); // expected-error {{must immediately precede declared identifier}}
+    void f(T ... // expected-note {{preceding '...' declares a function parameter pack}}
+           t...); // expected-warning-re {{'...' in this location creates a C-style varargs function{{$}}}}
+           // expected-note@-1 {{insert ',' before '...' to silence this warning}}
+  };
+
+  // FIXME: We should just issue a single error in this case pointing out where
+  // the '...' goes. It's tricky to recover correctly in this case, though,
+  // because the parameter is in scope in the default argument, so must be
+  // passed to Sema before we reach the ellipsis.
+  template<typename...T> void f(T n = 1 ...);
+  // expected-warning@-1 {{creates a C-style varargs}}
+  // expected-note@-2 {{place '...' immediately before declared identifier}}
+  // expected-note@-3 {{insert ','}}
+  // expected-error@-4 {{unexpanded parameter pack}}
+}
diff --git a/test/Parser/cxx1z-attributes.cpp b/test/Parser/cxx1z-attributes.cpp
new file mode 100644
index 0000000..f57b47d
--- /dev/null
+++ b/test/Parser/cxx1z-attributes.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s

+

+namespace [[]] foo {}

+namespace [[]] {}

+namespace [[]] bad = foo; // expected-error {{attributes cannot be specified on namespace alias}}

+

+namespace [[]] A::B {} // expected-error {{attributes cannot be specified on a nested namespace definition}}

+

+enum test {

+  bing [[]],

+  bar [[]] = 1,

+  baz [[]][[]],

+  quux [[]][[]] = 4

+};

diff --git a/test/Parser/cxx1z-fold-expressions.cpp b/test/Parser/cxx1z-fold-expressions.cpp
new file mode 100644
index 0000000..a908311
--- /dev/null
+++ b/test/Parser/cxx1z-fold-expressions.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+template<typename ...T> constexpr auto sum(T ...t) { return (... + t); }
+template<typename ...T> constexpr auto product(T ...t) { return (t * ...); }
+template<typename ...T> constexpr auto all(T ...t) { return (true && ... && t); }
+template<typename ...T> constexpr auto all2(T ...t) { return (t && ... && true); }
+
+int k1 = (1 + ... + 2); // expected-error {{does not contain any unexpanded parameter packs}}
+int k2 = (1 + ...); // expected-error {{does not contain any unexpanded parameter packs}}
+int k3 = (... + 2); // expected-error {{does not contain any unexpanded parameter packs}}
+
+template<int ...N> void bad1() { (N + ... + N); } // expected-error {{unexpanded parameter packs in both operands}}
+// FIXME: it would be reasonable to support this as an extension.
+template<int ...N> void bad2() { (2 * N + ... + 1); } // expected-error {{expression not permitted as operand}}
+template<int ...N> void bad3() { (2 + N * ... * 1); } // expected-error {{expression not permitted as operand}}
+template<int ...N, int ...M> void bad4(int (&...x)[N]) { (N + M * ... * 1); } // expected-error {{expression not permitted as operand}}
+template<int ...N, int ...M> void fixed4(int (&...x)[N]) { ((N + M) * ... * 1); }
+
+// Parens are mandatory.
+template<int ...N> void bad5() { N + ...; } // expected-error {{expected expression}} expected-error +{{}}
+template<int ...N> void bad6() { ... + N; } // expected-error {{expected expression}}
+template<int ...N> void bad7() { N + ... + N; } // expected-error {{expected expression}} expected-error +{{}}
+
+// Must have a fold-operator in the relevant places.
+template<int ...N> int bad8() { return (N + ... * 3); } // expected-error {{operators in fold expression must be the same}}
+template<int ...N> int bad9() { return (3 + ... * N); } // expected-error {{operators in fold expression must be the same}}
+template<int ...N> int bad10() { return (3 ? ... : N); } // expected-error +{{}} expected-note {{to match}}
+template<int ...N> int bad11() { return (N + ... 0); } // expected-error {{expected a foldable binary operator}} expected-error {{expected expression}}
+template<int ...N> int bad12() { return (... N); } // expected-error {{expected expression}}
diff --git a/test/Parser/cxx1z-nested-namespace-definition.cpp b/test/Parser/cxx1z-nested-namespace-definition.cpp
new file mode 100644
index 0000000..96f34c5
--- /dev/null
+++ b/test/Parser/cxx1z-nested-namespace-definition.cpp
@@ -0,0 +1,38 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT
+// RUN: %clang_cc1 -x c++ %t -DFIXIT
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -Wc++14-compat
+
+namespace foo1::foo2::foo3 {
+#if __cplusplus <= 201400L
+// expected-warning@-2 {{nested namespace definition is a C++1z extension; define each namespace separately}}
+#else
+// expected-warning@-4 {{nested namespace definition is incompatible with C++ standards before C++1z}}
+#endif
+  int foo(int x) { return x; }
+}
+
+#ifndef FIXIT
+inline namespace goo::bar { // expected-error {{nested namespace definition cannot be 'inline'}} expected-warning 0-1{{C++11 feature}}
+  int n;
+}
+
+int m = goo::bar::n;
+#endif
+
+int foo(int x) {
+  return foo1::foo2::foo3::foo(x);
+}
+
+namespace bar1 {
+  namespace bar2 {
+    namespace bar3 {
+      int bar(int x) { return x; }
+    }
+  }
+}
+
+int bar(int x) {
+  return bar1::bar2::bar3::bar(x);
+}
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c
index 39d9dc9..48936d5 100644
--- a/test/Parser/declarators.c
+++ b/test/Parser/declarators.c
@@ -7,6 +7,7 @@
 void f2(int [const *]);
 void f3(int [volatile const*]);
 int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */
+int f5(int [static]); /* expected-error {{'static' may not be used without an array size}} */
 
 char ((((*X))));
 
@@ -112,6 +113,7 @@
 struct EnumBitfield { // expected-warning {{struct without named members is a GNU extension}}
   enum E2 { e2 } : 4; // ok
   struct S { int n; }: // expected-error {{expected ';'}}
+                       // expected-warning@-1 {{declaration does not declare anything}}
 
 };
 
@@ -148,3 +150,5 @@
   A6;  // expected-error{{expected '= constant-expression' or end of enumerator definition}}
   A6a
 };
+
+int PR20634 = sizeof(struct { int n; } [5]);
diff --git a/test/Parser/eof2.cpp b/test/Parser/eof2.cpp
new file mode 100644
index 0000000..6a8b862
--- /dev/null
+++ b/test/Parser/eof2.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
+
+// CHECK: error: expected expression
+// CHECK: error: expected member name or ';' after declaration specifiers
+// CHECK: error: expected '}'
+// CHECK: note: to match this '{'
+// CHECK: error: expected ';' after class
+// CHECK: 4 errors generated.
+
+// Do not add anything to the end of this file.  This requires the whitespace
+// plus EOF after the '<' token.
+
+template <typename T>
+class a {
+  a< 
diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c
index 95d6fb3..64b4447 100644
--- a/test/Parser/expressions.c
+++ b/test/Parser/expressions.c
@@ -67,3 +67,9 @@
   int x3 = __alignof int;         // expected-error {{expected parentheses around type name in __alignof expression}}
   int x4 = _Alignof int;          // expected-error {{expected parentheses around type name in _Alignof expression}}
 }
+
+void callee(double, double);
+void test8() {
+  callee(foobar,   // expected-error {{use of undeclared identifier 'foobar'}}
+         fizbin);  // expected-error {{use of undeclared identifier 'fizbin'}}
+}
diff --git a/test/Parser/ms-inline-asm.c b/test/Parser/ms-inline-asm.c
index 564f008..72c96c3 100644
--- a/test/Parser/ms-inline-asm.c
+++ b/test/Parser/ms-inline-asm.c
@@ -45,6 +45,12 @@
     }
   }
 }
+void t11() {
+  do { __asm mov eax, 0 __asm { __asm mov edx, 1 } } while(0);
+}
+void t12() {
+  __asm jmp label // expected-error {{use of undeclared label 'label'}}
+}
 int t_fail() { // expected-note {{to match this}}
   __asm 
-  __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
+  __asm { // expected-error 2 {{expected}} expected-note {{to match this}}
diff --git a/test/Parser/nested-namespaces-recovery.cpp b/test/Parser/nested-namespaces-recovery.cpp
deleted file mode 100644
index d45938b..0000000
--- a/test/Parser/nested-namespaces-recovery.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: cp %s %t
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: not %clang_cc1 -x c++ -fixit %t
-// RUN: %clang_cc1 -x c++ %t
-
-namespace foo1::foo2::foo3 { // expected-error {{nested namespace definition must define each namespace separately}}
-  int foo(int x) { return x; }
-}
-
-int foo(int x) {
-  return foo1::foo2::foo3::foo(x);
-}
-
-namespace bar1 {
-  namespace bar2 {
-    namespace bar3 {
-      int bar(int x) { return x; }
-    }
-  }
-}
-
-int bar(int x) {
-  return bar1::bar2::bar3::bar(x);
-}
diff --git a/test/Parser/pragma-loop.cpp b/test/Parser/pragma-loop.cpp
index fad4feb..547d873 100644
--- a/test/Parser/pragma-loop.cpp
+++ b/test/Parser/pragma-loop.cpp
@@ -3,12 +3,85 @@
 // Note that this puts the expected lines before the directives to work around
 // limitations in the -verify mode.
 
+template <int V, int I>
+void test_nontype_template_param(int *List, int Length) {
+#pragma clang loop vectorize_width(V) interleave_count(I)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+
+#pragma clang loop vectorize_width(V + 4) interleave_count(I + 4)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
+template <int V>
+void test_nontype_template_vectorize(int *List, int Length) {
+  /* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop vectorize_width(V)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+
+  /* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop vectorize_width(V / 2)
+  for (int i = 0; i < Length; i++) {
+    List[i] += i;
+  }
+}
+
+template <int I>
+void test_nontype_template_interleave(int *List, int Length) {
+  /* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop interleave_count(I)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+
+  /* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop interleave_count(2 % I)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
+template <char V>
+void test_nontype_template_char(int *List, int Length) {
+  /* expected-error {{invalid argument of type 'char'; expected an integer type}} */ #pragma clang loop vectorize_width(V)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
+template <bool V>
+void test_nontype_template_bool(int *List, int Length) {
+  /* expected-error {{invalid argument of type 'bool'; expected an integer type}} */ #pragma clang loop vectorize_width(V)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
+template <int V, int I>
+void test_nontype_template_badarg(int *List, int Length) {
+  /* expected-error {{use of undeclared identifier 'Vec'}} */ #pragma clang loop vectorize_width(Vec) interleave_count(I)
+  /* expected-error {{use of undeclared identifier 'Int'}} */ #pragma clang loop vectorize_width(V) interleave_count(Int)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
+template <typename T>
+void test_type_template_vectorize(int *List, int Length) {
+  const T Value = -1;
+  /* expected-error {{invalid value '-1'; must be positive}} */ #pragma clang loop vectorize_width(Value)
+  for (int i = 0; i < Length; i++) {
+    List[i] = i;
+  }
+}
+
 void test(int *List, int Length) {
   int i = 0;
 
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
-#pragma clang loop unroll(enable)
+#pragma clang loop unroll(full)
   while (i + 1 < Length) {
     List[i] = i;
   }
@@ -43,74 +116,95 @@
     VList[j] = List[j];
   }
 
+  test_nontype_template_param<4, 8>(List, Length);
+
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
-/* expected-error {{expected ')'}} */ #pragma clang loop unroll(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(4
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave_count(4
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll_count(4
 
-/* expected-error {{missing argument to loop pragma 'vectorize'}} */ #pragma clang loop vectorize()
-/* expected-error {{missing argument to loop pragma 'interleave_count'}} */ #pragma clang loop interleave_count()
-/* expected-error {{missing argument to loop pragma 'unroll'}} */ #pragma clang loop unroll()
+/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize()
+/* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop interleave_count()
+/* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll()
 
-/* expected-error {{missing option}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, or unroll_count}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
 /* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize(enable) ,
-
   while (i-4 < Length) {
     List[i] = i;
   }
 
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(0)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(0)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop vectorize_width(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop interleave_count(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop unroll_count(0)
+
+/* expected-error {{expression is not an integral constant expression}} expected-note {{division by zero}} */ #pragma clang loop vectorize_width(10 / 0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop interleave_count(10 / 5 - 2)
   while (i-5 < Length) {
     List[i] = i;
   }
 
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(3000000000)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(3000000000)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(3000000000)
+test_nontype_template_vectorize<4>(List, Length);
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_vectorize<-1>(List, Length);
+test_nontype_template_interleave<8>(List, Length);
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_interleave<-1>(List, Length);
+
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_char<'A'>(List, Length); // Loop hint arg cannot be a char.
+/* expected-note {{in instantiation of function template specialization}} */ test_nontype_template_bool<true>(List, Length);  // Or a bool.
+/* expected-note {{in instantiation of function template specialization}} */ test_type_template_vectorize<int>(List, Length); // Or a template type.
+
+/* expected-error {{value '3000000000' is too large}} */ #pragma clang loop vectorize_width(3000000000)
+/* expected-error {{value '3000000000' is too large}} */ #pragma clang loop interleave_count(3000000000)
+/* expected-error {{value '3000000000' is too large}} */ #pragma clang loop unroll_count(3000000000)
   while (i-6 < Length) {
     List[i] = i;
   }
 
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(badvalue)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(badvalue)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(badvalue)
+/* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize_width(1 +) 1
+/* expected-warning {{extra tokens at end of '#pragma clang loop'}} */ #pragma clang loop vectorize_width(1) +1
+const int VV = 4;
+/* expected-error {{expected expression}} */ #pragma clang loop vectorize_width(VV +/ 2)
+/* expected-error {{use of undeclared identifier 'undefined'}} */ #pragma clang loop vectorize_width(VV+undefined)
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize_width(1+(^*/2 * ()
+/* expected-warning {{extra tokens at end of '#pragma clang loop' - ignored}} */ #pragma clang loop vectorize_width(1+(-0[0]))))))
+
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop vectorize_width(badvalue)
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop interleave_count(badvalue)
+/* expected-error {{use of undeclared identifier 'badvalue'}} */ #pragma clang loop unroll_count(badvalue)
   while (i-6 < Length) {
     List[i] = i;
   }
 
 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize(badidentifier)
 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop interleave(badidentifier)
-/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
+/* expected-error {{invalid argument; expected 'full' or 'disable'}} */ #pragma clang loop unroll(badidentifier)
   while (i-7 < Length) {
     List[i] = i;
   }
 
 // PR20069 - Loop pragma arguments that are not identifiers or numeric
 // constants crash FE.
-/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop vectorize(()
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize(()
 /* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop interleave(*)
-/* expected-error {{invalid argument; expected 'enable' or 'disable'}} */ #pragma clang loop unroll(=)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop vectorize_width(^)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop interleave_count(/)
-/* expected-error {{invalid argument; expected a positive integer value}} */ #pragma clang loop unroll_count(==)
+/* expected-error {{invalid argument; expected 'full' or 'disable'}} */ #pragma clang loop unroll(=)
+/* expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}} */ #pragma clang loop vectorize_width(^)
+/* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop interleave_count(/)
+/* expected-error {{expected expression}} expected-error {{expected expression}} */ #pragma clang loop unroll_count(==)
   while (i-8 < Length) {
     List[i] = i;
   }
 
 #pragma clang loop vectorize(enable)
-/* expected-error {{expected a for, while, or do-while loop to follow the '#pragma clang loop' directive}} */ int j = Length;
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma clang loop'}} */ int j = Length;
   List[0] = List[1];
 
   while (j-1 < Length) {
@@ -136,7 +230,7 @@
 #pragma clang loop vectorize(disable)
 /* expected-error {{duplicate directives 'interleave(disable)' and 'interleave(enable)'}} */ #pragma clang loop interleave(enable)
 #pragma clang loop interleave(disable)
-/* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(enable)'}} */ #pragma clang loop unroll(enable)
+/* expected-error {{duplicate directives 'unroll(disable)' and 'unroll(full)'}} */ #pragma clang loop unroll(full)
 #pragma clang loop unroll(disable)
   while (i-9 < Length) {
     List[i] = i;
@@ -162,5 +256,12 @@
     List[i] = i;
   }
 
+
+/* expected-error {{incompatible directives 'unroll(full)' and 'unroll_count(4)'}} */ #pragma clang loop unroll(full)
+#pragma clang loop unroll_count(4)
+  while (i-11 < Length) {
+    List[i] = i;
+  }
+
 #pragma clang loop interleave(enable)
 /* expected-error {{expected statement}} */ }
diff --git a/test/Parser/pragma-unroll.cpp b/test/Parser/pragma-unroll.cpp
new file mode 100644
index 0000000..2609457
--- /dev/null
+++ b/test/Parser/pragma-unroll.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+void test(int *List, int Length) {
+  int i = 0;
+
+#pragma unroll
+  while (i + 1 < Length) {
+    List[i] = i;
+  }
+
+#pragma nounroll
+  while (i < Length) {
+    List[i] = i;
+  }
+
+#pragma unroll 4
+  while (i - 1 < Length) {
+    List[i] = i;
+  }
+
+#pragma unroll(8)
+  while (i - 2 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{expected ')'}} */ #pragma unroll(4
+/* expected-error {{missing argument; expected an integer value}} */ #pragma unroll()
+/* expected-warning {{extra tokens at end of '#pragma unroll'}} */ #pragma unroll 1 2
+  while (i-6 < Length) {
+    List[i] = i;
+  }
+
+/* expected-warning {{extra tokens at end of '#pragma nounroll'}} */ #pragma nounroll 1
+  while (i-7 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{expected ')'}} */ #pragma unroll(()
+/* expected-error {{expected expression}} */ #pragma unroll -
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll(0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma unroll 0
+/* expected-error {{value '3000000000' is too large}} */ #pragma unroll(3000000000)
+/* expected-error {{value '3000000000' is too large}} */ #pragma unroll 3000000000
+  while (i-8 < Length) {
+    List[i] = i;
+  }
+
+#pragma unroll
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int j = Length;
+#pragma unroll 4
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma unroll'}} */ int k = Length;
+#pragma nounroll
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma nounroll'}} */ int l = Length;
+
+/* expected-error {{incompatible directives 'unroll(disable)' and '#pragma unroll(4)'}} */ #pragma unroll 4
+#pragma clang loop unroll(disable)
+  while (i-10 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{incompatible directives 'unroll(full)' and '#pragma unroll(4)'}} */ #pragma unroll(4)
+#pragma clang loop unroll(full)
+  while (i-11 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{incompatible directives '#pragma unroll' and '#pragma unroll(4)'}} */ #pragma unroll(4)
+#pragma unroll
+  while (i-11 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{incompatible directives '#pragma nounroll' and 'unroll_count(4)'}} */ #pragma clang loop unroll_count(4)
+#pragma nounroll
+  while (i-12 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{duplicate directives '#pragma nounroll' and '#pragma nounroll'}} */ #pragma nounroll
+#pragma nounroll
+  while (i-13 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{duplicate directives '#pragma unroll' and '#pragma unroll'}} */ #pragma unroll
+#pragma unroll
+  while (i-14 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{duplicate directives 'unroll(full)' and '#pragma unroll'}} */ #pragma unroll
+#pragma clang loop unroll(full)
+  while (i-15 < Length) {
+    List[i] = i;
+  }
+
+/* expected-error {{duplicate directives '#pragma unroll(4)' and '#pragma unroll(4)'}} */ #pragma unroll 4
+#pragma unroll(4)
+  while (i-16 < Length) {
+    List[i] = i;
+  }
+
+#pragma unroll
+/* expected-error {{expected statement}} */ }
diff --git a/test/Parser/vsx.c b/test/Parser/vsx.c
new file mode 100644
index 0000000..ead0981
--- /dev/null
+++ b/test/Parser/vsx.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -faltivec -target-feature +vsx -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -faltivec -target-feature +vsx -fsyntax-only -verify %s
+
+// Legitimate for VSX.
+__vector double vv_d1;
+vector double v_d2;
+
+// These should have errors.
+__vector long double  vv_ld3;        // expected-error {{cannot use 'long double' with '__vector'}}
+vector long double  v_ld4;           // expected-error {{cannot use 'long double' with '__vector'}}
diff --git a/test/Parser/warn-cuda-compat.cu b/test/Parser/warn-cuda-compat.cu
new file mode 100644
index 0000000..c3aad6f
--- /dev/null
+++ b/test/Parser/warn-cuda-compat.cu
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -Wno-cuda-compat -Werror %s
+// RUN: %clang_cc1 -Wcuda-compat -verify %s
+// RUN: %clang_cc1 -x c++ -Wcuda-compat -Werror %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+void test(int *List, int Length) {
+/* expected-warning {{argument to '#pragma unroll' should not be in parentheses in CUDA C/C++}} */#pragma unroll(4)
+  for (int i = 0; i < Length; ++i) {
+    List[i] = i;
+  }
+}
diff --git a/test/Preprocessor/_Pragma.c b/test/Preprocessor/_Pragma.c
index 15725a4..120e754 100644
--- a/test/Preprocessor/_Pragma.c
+++ b/test/Preprocessor/_Pragma.c
@@ -11,3 +11,5 @@
 #ifdef macro
 #error #define invalid
 #endif
+
+_Pragma( // expected-error{{_Pragma takes a parenthesized string literal}}
diff --git a/test/Preprocessor/aarch64-target-features.c b/test/Preprocessor/aarch64-target-features.c
index 4dc03e0..4e9e6c7 100644
--- a/test/Preprocessor/aarch64-target-features.c
+++ b/test/Preprocessor/aarch64-target-features.c
@@ -12,8 +12,11 @@
 // CHECK: __ARM_FEATURE_CLZ 1
 // CHECK-NOT: __ARM_FEATURE_CRC32 1
 // CHECK-NOT: __ARM_FEATURE_CRYPTO 1
+// CHECK: __ARM_FEATURE_DIRECTED_ROUNDING 1
 // CHECK: __ARM_FEATURE_DIV 1
 // CHECK: __ARM_FEATURE_FMA 1
+// CHECK: __ARM_FEATURE_IDIV 1
+// CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK: __ARM_FEATURE_UNALIGNED 1
 // CHECK: __ARM_FP 0xe
 // CHECK: __ARM_FP16_FORMAT_IEEE 1
@@ -25,12 +28,14 @@
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
 
-// RUN: %clang -target aarch64-none-linux-gnu -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s
-// RUN: %clang -target arm64-none-linux-gnu -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRYPTO %s
 // CHECK-CRYPTO: __ARM_FEATURE_CRYPTO 1
 
 // RUN: %clang -target aarch64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // RUN: %clang -target arm64-none-linux-gnu -mcrc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // CHECK-CRC32: __ARM_FEATURE_CRC32 1
 
 // RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
@@ -45,17 +50,60 @@
 // RUN: %clang -target arm64-none-linux-gnu -fshort-enums -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTENUMS %s
 // CHECK-SHORTENUMS: __ARM_SIZEOF_MINIMAL_ENUM 1
 
-// RUN: %clang -target aarch64-none-linux-gnu -mfpu=neon -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s
-// RUN: %clang -target arm64-none-linux-gnu -mfpu=neon -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+simd -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s
+// RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+simd -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NEON %s
 // CHECK-NEON: __ARM_NEON 1
 // CHECK-NEON: __ARM_NEON_FP 0xe
 
-// RUN: %clang -target aarch64-none-linux-gnu -mcpu=cortex-a53 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEATURE %s
-// RUN: %clang -target aarch64-none-linux-gnu -mcpu=cortex-a57 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEATURE %s
-// RUN: %clang -target aarch64-none-linux-gnu -mcpu=cyclone -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEATURE %s
-// CHECK-FEATURE: __ARM_FEATURE_CRC32 1
-// CHECK-FEATURE: __ARM_FEATURE_CRYPTO 1
-// CHECK-FEATURE: __ARM_NEON 1
-// CHECK-FEATURE: __ARM_NEON_FP 0xe
+// RUN: %clang -target aarch64 -march=arm64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
+// RUN: %clang -target aarch64 -march=aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
+// CHECK-ARCH-NOT-ACCEPT: error: the clang compiler does not support
 
+// RUN: %clang -target aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-GENERIC %s
+// RUN: %clang -target aarch64 -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-GENERIC %s
+// CHECK-GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon"
 
+// RUN: %clang -target aarch64 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MTUNE-CYCLONE %s
+// CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"
+
+// RUN: %clang -target aarch64 -mcpu=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-CYCLONE %s
+// RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A53 %s
+// RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A57 %s
+// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+// CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+
+// RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
+// CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
+
+// RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-1 %s
+// RUN: %clang -target aarch64 -march=armv8-a+nofp+nosimd+nocrc+nocrypto+fp+simd+crc+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-1 %s
+// RUN: %clang -target aarch64 -march=armv8-a+nofp+nosimd+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-2 %s
+// RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto+nofp+nosimd+nocrc+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-2 %s
+// RUN: %clang -target aarch64 -march=armv8-a+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MARCH-3 %s
+// CHECK-MARCH-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
+// CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-crc" "-target-feature" "-crypto"
+// CHECK-MARCH-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon"
+
+// RUN: %clang -target aarch64 -mcpu=cyclone+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-1 %s
+// RUN: %clang -target aarch64 -mcpu=cyclone+crypto+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-1 %s
+// RUN: %clang -target aarch64 -mcpu=generic+crc -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-2 %s
+// RUN: %clang -target aarch64 -mcpu=generic+nocrc+crc -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-2 %s
+// RUN: %clang -target aarch64 -mcpu=cortex-a53+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-3 %s
+// CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc"
+// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon"
+
+// RUN: %clang -target aarch64 -mcpu=cyclone+nocrc+nocrypto -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
+// RUN: %clang -target aarch64 -march=armv8-a -mcpu=cyclone+nocrc+nocrypto  -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
+// CHECK-MCPU-MARCH: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"
+
+// RUN: %clang -target aarch64 -mcpu=cortex-a53 -mtune=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MTUNE %s
+// RUN: %clang -target aarch64 -mtune=cyclone -mcpu=cortex-a53  -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MTUNE %s
+// CHECK-MCPU-MTUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
+
+// RUN: %clang -target aarch64 -mcpu=generic+neon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s
+// RUN: %clang -target aarch64 -mcpu=generic+noneon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s
+// RUN: %clang -target aarch64 -march=armv8-a+neon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s
+// RUN: %clang -target aarch64 -march=armv8-a+noneon -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-NEON %s
+// CHECK-ERROR-NEON: error: [no]neon is not accepted as modifier, please use [no]simd instead
diff --git a/test/Preprocessor/arm-acle-6.4.c b/test/Preprocessor/arm-acle-6.4.c
index a656f76..fc228d0 100644
--- a/test/Preprocessor/arm-acle-6.4.c
+++ b/test/Preprocessor/arm-acle-6.4.c
@@ -5,6 +5,8 @@
 // CHECK-CORTEX-M0-NOT: __ARM_ARCH_ISA_ARM
 // CHECK-CORTEX-M0: __ARM_ARCH_ISA_THUMB 1
 // CHECK-CORTEX-M0: __ARM_ARCH_PROFILE 'M'
+// CHECK-CORTEX-M0-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
+// CHECK-CORTEX-M0-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 
 // RUN: %clang -target arm-eabi -mcpu=arm810 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-ARM810
 
@@ -13,6 +15,8 @@
 // CHECK-ARM810: __ARM_ARCH_ISA_ARM 1
 // CHECK-ARM810-NOT: __ARM_ARCH_ISA_THUMB
 // CHECK-ARM810-NOT: __ARM_ARCH_PROFILE
+// CHECK-ARM810-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
+// CHECK-ARM810-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 
 // RUN: %clang -target arm-eabi -mcpu=arm7tdmi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-ARM7TDMI
 
@@ -29,6 +33,8 @@
 // CHECK-CORTEX-A7: __ARM_ARCH_ISA_ARM 1
 // CHECK-CORTEX-A7: __ARM_ARCH_ISA_THUMB 2
 // CHECK-CORTEX-A7: __ARM_ARCH_PROFILE 'A'
+// CHECK-CORTEX-A7-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
+// CHECK-CORTEX-A7-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 
 // RUN: %clang -target arm-eabi -mcpu=cortex-r4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-CORTEX-R4
 
diff --git a/test/Preprocessor/arm-acle-6.5.c b/test/Preprocessor/arm-acle-6.5.c
new file mode 100644
index 0000000..9db83b7
--- /dev/null
+++ b/test/Preprocessor/arm-acle-6.5.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target arm-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-DEFAULT
+
+// CHECK-DEFAULT-NOT: __ARM_FP
+
+// RUN: %clang -target arm-eabi -mfpu=vfp -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfp3-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=neon -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target arm-eabi -mfpu=vfp3 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+// RUN: %clang -target armv7-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP
+
+// CHECK-SP-DP: __ARM_FP 0xC
+
+// RUN: %clang -target arm-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=vfpv4-d16 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target arm-eabi -mfpu=crypto-neon-fp-armv8 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-SP-DP-HP
+
+// CHECK-SP-DP-HP: __ARM_FP 0xE
+
diff --git a/test/Preprocessor/arm-target-features.c b/test/Preprocessor/arm-target-features.c
index 08fe29a..8155e02 100644
--- a/test/Preprocessor/arm-target-features.c
+++ b/test/Preprocessor/arm-target-features.c
@@ -3,18 +3,24 @@
 // CHECK: __ARM_ARCH 8
 // CHECK: __ARM_ARCH_8A__ 1
 // CHECK: __ARM_FEATURE_CRC32 1
+// CHECK: __ARM_FEATURE_DIRECTED_ROUNDING 1
+// CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
 
 // RUN: %clang -target armv7a-none-linux-gnu -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V7 %s
 // CHECK-V7: __ARMEL__ 1
 // CHECK-V7: __ARM_ARCH 7
 // CHECK-V7: __ARM_ARCH_7A__ 1
 // CHECK-V7-NOT: __ARM_FEATURE_CRC32
+// CHECK-V7-NOT: __ARM_FEATURE_NUMERIC_MAXMIN                                   
+// CHECK-V7-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 
 // RUN: %clang -target armv8a -mfloat-abi=hard -x c -E -dM %s | FileCheck --check-prefix=CHECK-V8-BAREHF %s
 // CHECK-V8-BAREHF: __ARMEL__ 1
 // CHECK-V8-BAREHF: __ARM_ARCH 8
 // CHECK-V8-BAREHF: __ARM_ARCH_8A__ 1
 // CHECK-V8-BAREHF: __ARM_FEATURE_CRC32 1
+// CHECK-V8-BAREHF: __ARM_FEATURE_DIRECTED_ROUNDING 1
+// CHECK-V8-BAREHF: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK-V8-BAREHF: __ARM_NEON__ 1
 // CHECK-V8-BAREHF: __VFP_FP__ 1
 
@@ -149,6 +155,8 @@
 // A5:#define __ARM_ARCH 7
 // A5:#define __ARM_ARCH_7A__ 1
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
+// A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 
 // Test whether predefines are as expected when targeting cortex-a7.
 // RUN: %clang -target armv7 -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
@@ -199,6 +207,25 @@
 // RUN: %clang -target armv7 -mthumb -mcpu=cortex-a15 -x c -E -dM %s -o - | FileCheck --check-prefix=A15-THUMB %s
 // A15-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
 
+// Check that -mfpu works properly for Cortex-A17 (enabled by default).
+// RUN: %clang -target armv7-none-linux-gnueabi -mcpu=cortex-a17 -x c -E -dM %s -o - | FileCheck --check-prefix=DEFAULTFPU-A17 %s
+// RUN: %clang -target armv7-none-linux-gnueabi -mthumb -mcpu=cortex-a17 -x c -E -dM %s -o - | FileCheck --check-prefix=DEFAULTFPU-A17 %s
+// DEFAULTFPU-A17:#define __ARM_NEON__ 1
+// DEFAULTFPU-A17:#define __ARM_VFPV4__ 1
+
+// RUN: %clang -target armv7-none-linux-gnueabi -mcpu=cortex-a17 -mfpu=none -x c -E -dM %s -o - | FileCheck --check-prefix=FPUNONE-A17 %s
+// RUN: %clang -target armv7-none-linux-gnueabi -mthumb -mcpu=cortex-a17 -mfpu=none -x c -E -dM %s -o - | FileCheck --check-prefix=FPUNONE-A17 %s
+// FPUNONE-A17-NOT:#define __ARM_NEON__ 1
+// FPUNONE-A17-NOT:#define __ARM_VFPV4__ 1
+
+// Test whether predefines are as expected when targeting cortex-a17.
+// RUN: %clang -target armv7 -mcpu=cortex-a17 -x c -E -dM %s -o - | FileCheck --check-prefix=A17 %s
+// RUN: %clang -target armv7 -mthumb -mcpu=cortex-a17 -x c -E -dM %s -o - | FileCheck --check-prefix=A17 %s
+// A17:#define __ARM_ARCH 7
+// A17:#define __ARM_ARCH_7A__ 1
+// A17:#define __ARM_ARCH_EXT_IDIV__ 1
+// A17:#define __ARM_ARCH_PROFILE 'A'
+
 // Test whether predefines are as expected when targeting swift.
 // RUN: %clang -target armv7s -mcpu=swift -x c -E -dM %s -o - | FileCheck --check-prefix=SWIFT-ARM %s
 // SWIFT-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
@@ -232,6 +259,10 @@
 // RUN: %clang -target armv7 -mthumb -mcpu=cortex-m4 -x c -E -dM %s -o - | FileCheck --check-prefix=M4-THUMB %s
 // M4-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
 
+// Test whether predefines are as expected when targeting cortex-m7.
+// RUN: %clang -target armv7 -mthumb -mcpu=cortex-m7 -x c -E -dM %s -o - | FileCheck --check-prefix=M7-THUMB %s
+// M7-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
+
 // Test whether predefines are as expected when targeting krait.
 // RUN: %clang -target armv7 -mcpu=krait -x c -E -dM %s -o - | FileCheck --check-prefix=KRAIT-ARM %s
 // KRAIT-ARM:#define __ARM_ARCH_EXT_IDIV__ 1
diff --git a/test/Preprocessor/has_attribute.cpp b/test/Preprocessor/has_attribute.cpp
new file mode 100644
index 0000000..75f72c7
--- /dev/null
+++ b/test/Preprocessor/has_attribute.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -E %s -o - | FileCheck %s
+
+// CHECK: has_cxx11_carries_dep
+#if __has_cpp_attribute(carries_dependency)
+  int has_cxx11_carries_dep();
+#endif
+
+// CHECK: has_clang_fallthrough_1
+#if __has_cpp_attribute(clang::fallthrough)
+  int has_clang_fallthrough_1();
+#endif
+
+// CHECK: does_not_have_selectany
+#if !__has_cpp_attribute(selectany)
+  int does_not_have_selectany();
+#endif
+
+// The attribute name can be bracketed with double underscores.
+// CHECK: has_clang_fallthrough_2
+#if __has_cpp_attribute(clang::__fallthrough__)
+  int has_clang_fallthrough_2();
+#endif
+
+// The scope cannot be bracketed with double underscores.
+// CHECK: does_not_have___clang___fallthrough
+#if !__has_cpp_attribute(__clang__::fallthrough)
+  int does_not_have___clang___fallthrough();
+#endif
+
+// Test that C++11, target-specific attributes behave properly.
+
+// CHECK: does_not_have_mips16
+#if !__has_cpp_attribute(gnu::mips16)
+  int does_not_have_mips16();
+#endif
+
+// Test that the version numbers of attributes listed in SD-6 are supported
+// correctly.
+
+// CHECK: has_cxx11_carries_dep_vers
+#if __has_cpp_attribute(carries_dependency) == 200809
+  int has_cxx11_carries_dep_vers();
+#endif
+
+// CHECK: has_cxx11_noreturn_vers
+#if __has_cpp_attribute(noreturn) == 200809
+  int has_cxx11_noreturn_vers();
+#endif
+
+// CHECK: has_cxx14_deprecated_vers
+#if __has_cpp_attribute(deprecated) == 201309
+  int has_cxx14_deprecated_vers();
+#endif
diff --git a/test/Preprocessor/headermap-rel2.c b/test/Preprocessor/headermap-rel2.c
index 430854d..d61f338 100644
--- a/test/Preprocessor/headermap-rel2.c
+++ b/test/Preprocessor/headermap-rel2.c
@@ -1,8 +1,8 @@
 // This uses a headermap with this entry:
 //   someheader.h -> Product/someheader.h
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin13 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H
-// RUN: %clang_cc1 -triple x86_64-apple-darwin13 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out
+// RUN: %clang_cc1 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H
+// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> %t.out
 // RUN: FileCheck %s -input-file %t.out
 
 // CHECK: Product/someheader.h
diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c
index 3f15502..43492f8 100644
--- a/test/Preprocessor/init.c
+++ b/test/Preprocessor/init.c
@@ -80,7 +80,7 @@
 // COMMON:#define __ORDER_LITTLE_ENDIAN__ 1234
 // COMMON:#define __ORDER_PDP_ENDIAN__ 3412
 // COMMON:#define __STDC_HOSTED__ 1
-// COMMON:#define __STDC_VERSION__
+// COMMON:#define __STDC_VERSION__ 201112L
 // COMMON:#define __STDC__ 1
 // COMMON:#define __VERSION__
 // COMMON:#define __clang__ 1
@@ -219,7 +219,7 @@
 // RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=x86_64-w64-mingw32 < /dev/null | FileCheck -check-prefix SHORTWCHAR %s
 //
 // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2
-// SHORTWCHAR: #define __WCHAR_MAX__ 65535U
+// SHORTWCHAR: #define __WCHAR_MAX__ 65535
 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
 // SHORTWCHAR: #define __WCHAR_WIDTH__ 16
 //
@@ -274,37 +274,69 @@
 // AARCH64:#define __FLT_MIN_EXP__ (-125)
 // AARCH64:#define __FLT_MIN__ 1.17549435e-38F
 // AARCH64:#define __FLT_RADIX__ 2
+// AARCH64:#define __INT16_C_SUFFIX__ {{$}}
+// AARCH64:#define __INT16_FMTd__ "hd"
+// AARCH64:#define __INT16_FMTi__ "hi"
 // AARCH64:#define __INT16_MAX__ 32767
 // AARCH64:#define __INT16_TYPE__ short
+// AARCH64:#define __INT32_C_SUFFIX__ {{$}}
+// AARCH64:#define __INT32_FMTd__ "d"
+// AARCH64:#define __INT32_FMTi__ "i"
 // AARCH64:#define __INT32_MAX__ 2147483647
 // AARCH64:#define __INT32_TYPE__ int
 // AARCH64:#define __INT64_C_SUFFIX__ L
+// AARCH64:#define __INT64_FMTd__ "ld"
+// AARCH64:#define __INT64_FMTi__ "li"
 // AARCH64:#define __INT64_MAX__ 9223372036854775807L
 // AARCH64:#define __INT64_TYPE__ long int
+// AARCH64:#define __INT8_C_SUFFIX__ {{$}}
+// AARCH64:#define __INT8_FMTd__ "hhd"
+// AARCH64:#define __INT8_FMTi__ "hhi"
 // AARCH64:#define __INT8_MAX__ 127
-// AARCH64:#define __INT8_TYPE__ char
+// AARCH64:#define __INT8_TYPE__ signed char
+// AARCH64:#define __INTMAX_C_SUFFIX__ L
+// AARCH64:#define __INTMAX_FMTd__ "ld"
+// AARCH64:#define __INTMAX_FMTi__ "li"
 // AARCH64:#define __INTMAX_MAX__ 9223372036854775807L
 // AARCH64:#define __INTMAX_TYPE__ long int
 // AARCH64:#define __INTMAX_WIDTH__ 64
+// AARCH64:#define __INTPTR_FMTd__ "ld"
+// AARCH64:#define __INTPTR_FMTi__ "li"
 // AARCH64:#define __INTPTR_MAX__ 9223372036854775807L
 // AARCH64:#define __INTPTR_TYPE__ long int
 // AARCH64:#define __INTPTR_WIDTH__ 64
+// AARCH64:#define __INT_FAST16_FMTd__ "hd"
+// AARCH64:#define __INT_FAST16_FMTi__ "hi"
 // AARCH64:#define __INT_FAST16_MAX__ 32767
 // AARCH64:#define __INT_FAST16_TYPE__ short
+// AARCH64:#define __INT_FAST32_FMTd__ "d"
+// AARCH64:#define __INT_FAST32_FMTi__ "i"
 // AARCH64:#define __INT_FAST32_MAX__ 2147483647
 // AARCH64:#define __INT_FAST32_TYPE__ int
+// AARCH64:#define __INT_FAST64_FMTd__ "ld"
+// AARCH64:#define __INT_FAST64_FMTi__ "li"
 // AARCH64:#define __INT_FAST64_MAX__ 9223372036854775807L
 // AARCH64:#define __INT_FAST64_TYPE__ long int
+// AARCH64:#define __INT_FAST8_FMTd__ "hhd"
+// AARCH64:#define __INT_FAST8_FMTi__ "hhi"
 // AARCH64:#define __INT_FAST8_MAX__ 127
-// AARCH64:#define __INT_FAST8_TYPE__ char
+// AARCH64:#define __INT_FAST8_TYPE__ signed char
+// AARCH64:#define __INT_LEAST16_FMTd__ "hd"
+// AARCH64:#define __INT_LEAST16_FMTi__ "hi"
 // AARCH64:#define __INT_LEAST16_MAX__ 32767
 // AARCH64:#define __INT_LEAST16_TYPE__ short
+// AARCH64:#define __INT_LEAST32_FMTd__ "d"
+// AARCH64:#define __INT_LEAST32_FMTi__ "i"
 // AARCH64:#define __INT_LEAST32_MAX__ 2147483647
 // AARCH64:#define __INT_LEAST32_TYPE__ int
+// AARCH64:#define __INT_LEAST64_FMTd__ "ld"
+// AARCH64:#define __INT_LEAST64_FMTi__ "li"
 // AARCH64:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // AARCH64:#define __INT_LEAST64_TYPE__ long int
+// AARCH64:#define __INT_LEAST8_FMTd__ "hhd"
+// AARCH64:#define __INT_LEAST8_FMTi__ "hhi"
 // AARCH64:#define __INT_LEAST8_MAX__ 127
-// AARCH64:#define __INT_LEAST8_TYPE__ char
+// AARCH64:#define __INT_LEAST8_TYPE__ signed char
 // AARCH64:#define __INT_MAX__ 2147483647
 // AARCH64:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
 // AARCH64:#define __LDBL_DIG__ 33
@@ -327,6 +359,7 @@
 // AARCH64:#define __PTRDIFF_WIDTH__ 64
 // AARCH64:#define __SCHAR_MAX__ 127
 // AARCH64:#define __SHRT_MAX__ 32767
+// AARCH64:#define __SIG_ATOMIC_MAX__ 2147483647
 // AARCH64:#define __SIG_ATOMIC_WIDTH__ 32
 // AARCH64:#define __SIZEOF_DOUBLE__ 8
 // AARCH64:#define __SIZEOF_FLOAT__ 4
@@ -344,8 +377,8 @@
 // AARCH64:#define __SIZE_MAX__ 18446744073709551615UL
 // AARCH64:#define __SIZE_TYPE__ long unsigned int
 // AARCH64:#define __SIZE_WIDTH__ 64
-// AARCH64:#define __UINT16_C_SUFFIX__ U
-// AARCH64:#define __UINT16_MAX__ 65535U
+// AARCH64:#define __UINT16_C_SUFFIX__ {{$}}
+// AARCH64:#define __UINT16_MAX__ 65535
 // AARCH64:#define __UINT16_TYPE__ unsigned short
 // AARCH64:#define __UINT32_C_SUFFIX__ U
 // AARCH64:#define __UINT32_MAX__ 4294967295U
@@ -353,30 +386,31 @@
 // AARCH64:#define __UINT64_C_SUFFIX__ UL
 // AARCH64:#define __UINT64_MAX__ 18446744073709551615UL
 // AARCH64:#define __UINT64_TYPE__ long unsigned int
-// AARCH64:#define __UINT8_C_SUFFIX__ U
-// AARCH64:#define __UINT8_MAX__ 255U
+// AARCH64:#define __UINT8_C_SUFFIX__ {{$}}
+// AARCH64:#define __UINT8_MAX__ 255
 // AARCH64:#define __UINT8_TYPE__ unsigned char
+// AARCH64:#define __UINTMAX_C_SUFFIX__ UL
 // AARCH64:#define __UINTMAX_MAX__ 18446744073709551615UL
 // AARCH64:#define __UINTMAX_TYPE__ long unsigned int
 // AARCH64:#define __UINTMAX_WIDTH__ 64
 // AARCH64:#define __UINTPTR_MAX__ 18446744073709551615UL
 // AARCH64:#define __UINTPTR_TYPE__ long unsigned int
 // AARCH64:#define __UINTPTR_WIDTH__ 64
-// AARCH64:#define __UINT_FAST16_MAX__ 65535U
+// AARCH64:#define __UINT_FAST16_MAX__ 65535
 // AARCH64:#define __UINT_FAST16_TYPE__ unsigned short
 // AARCH64:#define __UINT_FAST32_MAX__ 4294967295U
 // AARCH64:#define __UINT_FAST32_TYPE__ unsigned int
 // AARCH64:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // AARCH64:#define __UINT_FAST64_TYPE__ long unsigned int
-// AARCH64:#define __UINT_FAST8_MAX__ 255U
+// AARCH64:#define __UINT_FAST8_MAX__ 255
 // AARCH64:#define __UINT_FAST8_TYPE__ unsigned char
-// AARCH64:#define __UINT_LEAST16_MAX__ 65535U
+// AARCH64:#define __UINT_LEAST16_MAX__ 65535
 // AARCH64:#define __UINT_LEAST16_TYPE__ unsigned short
 // AARCH64:#define __UINT_LEAST32_MAX__ 4294967295U
 // AARCH64:#define __UINT_LEAST32_TYPE__ unsigned int
 // AARCH64:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // AARCH64:#define __UINT_LEAST64_TYPE__ long unsigned int
-// AARCH64:#define __UINT_LEAST8_MAX__ 255U
+// AARCH64:#define __UINT_LEAST8_MAX__ 255
 // AARCH64:#define __UINT_LEAST8_TYPE__ unsigned char
 // AARCH64:#define __USER_LABEL_PREFIX__ _
 // AARCH64:#define __WCHAR_MAX__ 4294967295U
@@ -388,7 +422,6 @@
 // AARCH64:#define __aarch64__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64_be-none-none < /dev/null | FileCheck -check-prefix AARCH64-BE %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm64_be-none-none < /dev/null | FileCheck -check-prefix AARCH64-BE %s
 //
 // AARCH64-BE:#define _LP64 1
 // AARCH64-BE:#define __AARCH64EB__ 1
@@ -431,37 +464,69 @@
 // AARCH64-BE:#define __FLT_MIN_EXP__ (-125)
 // AARCH64-BE:#define __FLT_MIN__ 1.17549435e-38F
 // AARCH64-BE:#define __FLT_RADIX__ 2
+// AARCH64-BE:#define __INT16_C_SUFFIX__ {{$}}
+// AARCH64-BE:#define __INT16_FMTd__ "hd"
+// AARCH64-BE:#define __INT16_FMTi__ "hi"
 // AARCH64-BE:#define __INT16_MAX__ 32767
 // AARCH64-BE:#define __INT16_TYPE__ short
+// AARCH64-BE:#define __INT32_C_SUFFIX__ {{$}}
+// AARCH64-BE:#define __INT32_FMTd__ "d"
+// AARCH64-BE:#define __INT32_FMTi__ "i"
 // AARCH64-BE:#define __INT32_MAX__ 2147483647
 // AARCH64-BE:#define __INT32_TYPE__ int
 // AARCH64-BE:#define __INT64_C_SUFFIX__ L
+// AARCH64-BE:#define __INT64_FMTd__ "ld"
+// AARCH64-BE:#define __INT64_FMTi__ "li"
 // AARCH64-BE:#define __INT64_MAX__ 9223372036854775807L
 // AARCH64-BE:#define __INT64_TYPE__ long int
+// AARCH64-BE:#define __INT8_C_SUFFIX__ {{$}}
+// AARCH64-BE:#define __INT8_FMTd__ "hhd"
+// AARCH64-BE:#define __INT8_FMTi__ "hhi"
 // AARCH64-BE:#define __INT8_MAX__ 127
-// AARCH64-BE:#define __INT8_TYPE__ char
+// AARCH64-BE:#define __INT8_TYPE__ signed char
+// AARCH64-BE:#define __INTMAX_C_SUFFIX__ L
+// AARCH64-BE:#define __INTMAX_FMTd__ "ld"
+// AARCH64-BE:#define __INTMAX_FMTi__ "li"
 // AARCH64-BE:#define __INTMAX_MAX__ 9223372036854775807L
 // AARCH64-BE:#define __INTMAX_TYPE__ long int
 // AARCH64-BE:#define __INTMAX_WIDTH__ 64
+// AARCH64-BE:#define __INTPTR_FMTd__ "ld"
+// AARCH64-BE:#define __INTPTR_FMTi__ "li"
 // AARCH64-BE:#define __INTPTR_MAX__ 9223372036854775807L
 // AARCH64-BE:#define __INTPTR_TYPE__ long int
 // AARCH64-BE:#define __INTPTR_WIDTH__ 64
+// AARCH64-BE:#define __INT_FAST16_FMTd__ "hd"
+// AARCH64-BE:#define __INT_FAST16_FMTi__ "hi"
 // AARCH64-BE:#define __INT_FAST16_MAX__ 32767
 // AARCH64-BE:#define __INT_FAST16_TYPE__ short
+// AARCH64-BE:#define __INT_FAST32_FMTd__ "d"
+// AARCH64-BE:#define __INT_FAST32_FMTi__ "i"
 // AARCH64-BE:#define __INT_FAST32_MAX__ 2147483647
 // AARCH64-BE:#define __INT_FAST32_TYPE__ int
+// AARCH64-BE:#define __INT_FAST64_FMTd__ "ld"
+// AARCH64-BE:#define __INT_FAST64_FMTi__ "li"
 // AARCH64-BE:#define __INT_FAST64_MAX__ 9223372036854775807L
 // AARCH64-BE:#define __INT_FAST64_TYPE__ long int
+// AARCH64-BE:#define __INT_FAST8_FMTd__ "hhd"
+// AARCH64-BE:#define __INT_FAST8_FMTi__ "hhi"
 // AARCH64-BE:#define __INT_FAST8_MAX__ 127
-// AARCH64-BE:#define __INT_FAST8_TYPE__ char
+// AARCH64-BE:#define __INT_FAST8_TYPE__ signed char
+// AARCH64-BE:#define __INT_LEAST16_FMTd__ "hd"
+// AARCH64-BE:#define __INT_LEAST16_FMTi__ "hi"
 // AARCH64-BE:#define __INT_LEAST16_MAX__ 32767
 // AARCH64-BE:#define __INT_LEAST16_TYPE__ short
+// AARCH64-BE:#define __INT_LEAST32_FMTd__ "d"
+// AARCH64-BE:#define __INT_LEAST32_FMTi__ "i"
 // AARCH64-BE:#define __INT_LEAST32_MAX__ 2147483647
 // AARCH64-BE:#define __INT_LEAST32_TYPE__ int
+// AARCH64-BE:#define __INT_LEAST64_FMTd__ "ld"
+// AARCH64-BE:#define __INT_LEAST64_FMTi__ "li"
 // AARCH64-BE:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // AARCH64-BE:#define __INT_LEAST64_TYPE__ long int
+// AARCH64-BE:#define __INT_LEAST8_FMTd__ "hhd"
+// AARCH64-BE:#define __INT_LEAST8_FMTi__ "hhi"
 // AARCH64-BE:#define __INT_LEAST8_MAX__ 127
-// AARCH64-BE:#define __INT_LEAST8_TYPE__ char
+// AARCH64-BE:#define __INT_LEAST8_TYPE__ signed char
 // AARCH64-BE:#define __INT_MAX__ 2147483647
 // AARCH64-BE:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
 // AARCH64-BE:#define __LDBL_DIG__ 33
@@ -484,6 +549,7 @@
 // AARCH64-BE:#define __PTRDIFF_WIDTH__ 64
 // AARCH64-BE:#define __SCHAR_MAX__ 127
 // AARCH64-BE:#define __SHRT_MAX__ 32767
+// AARCH64-BE:#define __SIG_ATOMIC_MAX__ 2147483647
 // AARCH64-BE:#define __SIG_ATOMIC_WIDTH__ 32
 // AARCH64-BE:#define __SIZEOF_DOUBLE__ 8
 // AARCH64-BE:#define __SIZEOF_FLOAT__ 4
@@ -501,8 +567,8 @@
 // AARCH64-BE:#define __SIZE_MAX__ 18446744073709551615UL
 // AARCH64-BE:#define __SIZE_TYPE__ long unsigned int
 // AARCH64-BE:#define __SIZE_WIDTH__ 64
-// AARCH64-BE:#define __UINT16_C_SUFFIX__ U
-// AARCH64-BE:#define __UINT16_MAX__ 65535U
+// AARCH64-BE:#define __UINT16_C_SUFFIX__ {{$}}
+// AARCH64-BE:#define __UINT16_MAX__ 65535
 // AARCH64-BE:#define __UINT16_TYPE__ unsigned short
 // AARCH64-BE:#define __UINT32_C_SUFFIX__ U
 // AARCH64-BE:#define __UINT32_MAX__ 4294967295U
@@ -510,30 +576,31 @@
 // AARCH64-BE:#define __UINT64_C_SUFFIX__ UL
 // AARCH64-BE:#define __UINT64_MAX__ 18446744073709551615UL
 // AARCH64-BE:#define __UINT64_TYPE__ long unsigned int
-// AARCH64-BE:#define __UINT8_C_SUFFIX__ U
-// AARCH64-BE:#define __UINT8_MAX__ 255U
+// AARCH64-BE:#define __UINT8_C_SUFFIX__ {{$}}
+// AARCH64-BE:#define __UINT8_MAX__ 255
 // AARCH64-BE:#define __UINT8_TYPE__ unsigned char
+// AARCH64-BE:#define __UINTMAX_C_SUFFIX__ UL
 // AARCH64-BE:#define __UINTMAX_MAX__ 18446744073709551615UL
 // AARCH64-BE:#define __UINTMAX_TYPE__ long unsigned int
 // AARCH64-BE:#define __UINTMAX_WIDTH__ 64
 // AARCH64-BE:#define __UINTPTR_MAX__ 18446744073709551615UL
 // AARCH64-BE:#define __UINTPTR_TYPE__ long unsigned int
 // AARCH64-BE:#define __UINTPTR_WIDTH__ 64
-// AARCH64-BE:#define __UINT_FAST16_MAX__ 65535U
+// AARCH64-BE:#define __UINT_FAST16_MAX__ 65535
 // AARCH64-BE:#define __UINT_FAST16_TYPE__ unsigned short
 // AARCH64-BE:#define __UINT_FAST32_MAX__ 4294967295U
 // AARCH64-BE:#define __UINT_FAST32_TYPE__ unsigned int
 // AARCH64-BE:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // AARCH64-BE:#define __UINT_FAST64_TYPE__ long unsigned int
-// AARCH64-BE:#define __UINT_FAST8_MAX__ 255U
+// AARCH64-BE:#define __UINT_FAST8_MAX__ 255
 // AARCH64-BE:#define __UINT_FAST8_TYPE__ unsigned char
-// AARCH64-BE:#define __UINT_LEAST16_MAX__ 65535U
+// AARCH64-BE:#define __UINT_LEAST16_MAX__ 65535
 // AARCH64-BE:#define __UINT_LEAST16_TYPE__ unsigned short
 // AARCH64-BE:#define __UINT_LEAST32_MAX__ 4294967295U
 // AARCH64-BE:#define __UINT_LEAST32_TYPE__ unsigned int
 // AARCH64-BE:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // AARCH64-BE:#define __UINT_LEAST64_TYPE__ long unsigned int
-// AARCH64-BE:#define __UINT_LEAST8_MAX__ 255U
+// AARCH64-BE:#define __UINT_LEAST8_MAX__ 255
 // AARCH64-BE:#define __UINT_LEAST8_TYPE__ unsigned char
 // AARCH64-BE:#define __USER_LABEL_PREFIX__ _
 // AARCH64-BE:#define __WCHAR_MAX__ 4294967295U
@@ -588,37 +655,69 @@
 // AARCH64-NETBSD:#define __FLT_MIN_EXP__ (-125)
 // AARCH64-NETBSD:#define __FLT_MIN__ 1.17549435e-38F
 // AARCH64-NETBSD:#define __FLT_RADIX__ 2
+// AARCH64-NETBSD:#define __INT16_C_SUFFIX__ {{$}}
+// AARCH64-NETBSD:#define __INT16_FMTd__ "hd"
+// AARCH64-NETBSD:#define __INT16_FMTi__ "hi"
 // AARCH64-NETBSD:#define __INT16_MAX__ 32767
 // AARCH64-NETBSD:#define __INT16_TYPE__ short
+// AARCH64-NETBSD:#define __INT32_C_SUFFIX__ {{$}}
+// AARCH64-NETBSD:#define __INT32_FMTd__ "d"
+// AARCH64-NETBSD:#define __INT32_FMTi__ "i"
 // AARCH64-NETBSD:#define __INT32_MAX__ 2147483647
 // AARCH64-NETBSD:#define __INT32_TYPE__ int
 // AARCH64-NETBSD:#define __INT64_C_SUFFIX__ LL
+// AARCH64-NETBSD:#define __INT64_FMTd__ "lld"
+// AARCH64-NETBSD:#define __INT64_FMTi__ "lli"
 // AARCH64-NETBSD:#define __INT64_MAX__ 9223372036854775807L
 // AARCH64-NETBSD:#define __INT64_TYPE__ long long int
+// AARCH64-NETBSD:#define __INT8_C_SUFFIX__ {{$}}
+// AARCH64-NETBSD:#define __INT8_FMTd__ "hhd"
+// AARCH64-NETBSD:#define __INT8_FMTi__ "hhi"
 // AARCH64-NETBSD:#define __INT8_MAX__ 127
-// AARCH64-NETBSD:#define __INT8_TYPE__ char
+// AARCH64-NETBSD:#define __INT8_TYPE__ signed char
+// AARCH64-NETBSD:#define __INTMAX_C_SUFFIX__ LL
+// AARCH64-NETBSD:#define __INTMAX_FMTd__ "lld"
+// AARCH64-NETBSD:#define __INTMAX_FMTi__ "lli"
 // AARCH64-NETBSD:#define __INTMAX_MAX__ 9223372036854775807LL
 // AARCH64-NETBSD:#define __INTMAX_TYPE__ long long int
 // AARCH64-NETBSD:#define __INTMAX_WIDTH__ 64
+// AARCH64-NETBSD:#define __INTPTR_FMTd__ "ld"
+// AARCH64-NETBSD:#define __INTPTR_FMTi__ "li"
 // AARCH64-NETBSD:#define __INTPTR_MAX__ 9223372036854775807L
 // AARCH64-NETBSD:#define __INTPTR_TYPE__ long int
 // AARCH64-NETBSD:#define __INTPTR_WIDTH__ 64
+// AARCH64-NETBSD:#define __INT_FAST16_FMTd__ "hd"
+// AARCH64-NETBSD:#define __INT_FAST16_FMTi__ "hi"
 // AARCH64-NETBSD:#define __INT_FAST16_MAX__ 32767
 // AARCH64-NETBSD:#define __INT_FAST16_TYPE__ short
+// AARCH64-NETBSD:#define __INT_FAST32_FMTd__ "d"
+// AARCH64-NETBSD:#define __INT_FAST32_FMTi__ "i"
 // AARCH64-NETBSD:#define __INT_FAST32_MAX__ 2147483647
 // AARCH64-NETBSD:#define __INT_FAST32_TYPE__ int
+// AARCH64-NETBSD:#define __INT_FAST64_FMTd__ "ld"
+// AARCH64-NETBSD:#define __INT_FAST64_FMTi__ "li"
 // AARCH64-NETBSD:#define __INT_FAST64_MAX__ 9223372036854775807L
 // AARCH64-NETBSD:#define __INT_FAST64_TYPE__ long int
+// AARCH64-NETBSD:#define __INT_FAST8_FMTd__ "hhd"
+// AARCH64-NETBSD:#define __INT_FAST8_FMTi__ "hhi"
 // AARCH64-NETBSD:#define __INT_FAST8_MAX__ 127
-// AARCH64-NETBSD:#define __INT_FAST8_TYPE__ char
+// AARCH64-NETBSD:#define __INT_FAST8_TYPE__ signed char
+// AARCH64-NETBSD:#define __INT_LEAST16_FMTd__ "hd"
+// AARCH64-NETBSD:#define __INT_LEAST16_FMTi__ "hi"
 // AARCH64-NETBSD:#define __INT_LEAST16_MAX__ 32767
 // AARCH64-NETBSD:#define __INT_LEAST16_TYPE__ short
+// AARCH64-NETBSD:#define __INT_LEAST32_FMTd__ "d"
+// AARCH64-NETBSD:#define __INT_LEAST32_FMTi__ "i"
 // AARCH64-NETBSD:#define __INT_LEAST32_MAX__ 2147483647
 // AARCH64-NETBSD:#define __INT_LEAST32_TYPE__ int
+// AARCH64-NETBSD:#define __INT_LEAST64_FMTd__ "ld"
+// AARCH64-NETBSD:#define __INT_LEAST64_FMTi__ "li"
 // AARCH64-NETBSD:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // AARCH64-NETBSD:#define __INT_LEAST64_TYPE__ long int
+// AARCH64-NETBSD:#define __INT_LEAST8_FMTd__ "hhd"
+// AARCH64-NETBSD:#define __INT_LEAST8_FMTi__ "hhi"
 // AARCH64-NETBSD:#define __INT_LEAST8_MAX__ 127
-// AARCH64-NETBSD:#define __INT_LEAST8_TYPE__ char
+// AARCH64-NETBSD:#define __INT_LEAST8_TYPE__ signed char
 // AARCH64-NETBSD:#define __INT_MAX__ 2147483647
 // AARCH64-NETBSD:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
 // AARCH64-NETBSD:#define __LDBL_DIG__ 33
@@ -643,6 +742,7 @@
 // AARCH64-NETBSD:#define __PTRDIFF_WIDTH__ 64
 // AARCH64-NETBSD:#define __SCHAR_MAX__ 127
 // AARCH64-NETBSD:#define __SHRT_MAX__ 32767
+// AARCH64-NETBSD:#define __SIG_ATOMIC_MAX__ 2147483647
 // AARCH64-NETBSD:#define __SIG_ATOMIC_WIDTH__ 32
 // AARCH64-NETBSD:#define __SIZEOF_DOUBLE__ 8
 // AARCH64-NETBSD:#define __SIZEOF_FLOAT__ 4
@@ -659,39 +759,40 @@
 // AARCH64-NETBSD:#define __SIZE_MAX__ 18446744073709551615UL
 // AARCH64-NETBSD:#define __SIZE_TYPE__ long unsigned int
 // AARCH64-NETBSD:#define __SIZE_WIDTH__ 64
-// AARCH64-NETBSD:#define __UINT16_C_SUFFIX__ U
-// AARCH64-NETBSD:#define __UINT16_MAX__ 65535U
+// AARCH64-NETBSD:#define __UINT16_C_SUFFIX__ {{$}}
+// AARCH64-NETBSD:#define __UINT16_MAX__ 65535
 // AARCH64-NETBSD:#define __UINT16_TYPE__ unsigned short
 // AARCH64-NETBSD:#define __UINT32_C_SUFFIX__ U
 // AARCH64-NETBSD:#define __UINT32_MAX__ 4294967295U
 // AARCH64-NETBSD:#define __UINT32_TYPE__ unsigned int
-// AARCH64-NETBSD:#define __UINT64_C_SUFFIX__ UL
-// AARCH64-NETBSD:#define __UINT64_MAX__ 18446744073709551615UL
-// AARCH64-NETBSD:#define __UINT64_TYPE__ long unsigned int
-// AARCH64-NETBSD:#define __UINT8_C_SUFFIX__ U
-// AARCH64-NETBSD:#define __UINT8_MAX__ 255U
+// AARCH64-NETBSD:#define __UINT64_C_SUFFIX__ ULL
+// AARCH64-NETBSD:#define __UINT64_MAX__ 18446744073709551615ULL
+// AARCH64-NETBSD:#define __UINT64_TYPE__ long long unsigned int
+// AARCH64-NETBSD:#define __UINT8_C_SUFFIX__ {{$}}
+// AARCH64-NETBSD:#define __UINT8_MAX__ 255
 // AARCH64-NETBSD:#define __UINT8_TYPE__ unsigned char
+// AARCH64-NETBSD:#define __UINTMAX_C_SUFFIX__ ULL
 // AARCH64-NETBSD:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // AARCH64-NETBSD:#define __UINTMAX_TYPE__ long long unsigned int
 // AARCH64-NETBSD:#define __UINTMAX_WIDTH__ 64
 // AARCH64-NETBSD:#define __UINTPTR_MAX__ 18446744073709551615UL
 // AARCH64-NETBSD:#define __UINTPTR_TYPE__ long unsigned int
 // AARCH64-NETBSD:#define __UINTPTR_WIDTH__ 64
-// AARCH64-NETBSD:#define __UINT_FAST16_MAX__ 65535U
+// AARCH64-NETBSD:#define __UINT_FAST16_MAX__ 65535
 // AARCH64-NETBSD:#define __UINT_FAST16_TYPE__ unsigned short
 // AARCH64-NETBSD:#define __UINT_FAST32_MAX__ 4294967295U
 // AARCH64-NETBSD:#define __UINT_FAST32_TYPE__ unsigned int
 // AARCH64-NETBSD:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // AARCH64-NETBSD:#define __UINT_FAST64_TYPE__ long unsigned int
-// AARCH64-NETBSD:#define __UINT_FAST8_MAX__ 255U
+// AARCH64-NETBSD:#define __UINT_FAST8_MAX__ 255
 // AARCH64-NETBSD:#define __UINT_FAST8_TYPE__ unsigned char
-// AARCH64-NETBSD:#define __UINT_LEAST16_MAX__ 65535U
+// AARCH64-NETBSD:#define __UINT_LEAST16_MAX__ 65535
 // AARCH64-NETBSD:#define __UINT_LEAST16_TYPE__ unsigned short
 // AARCH64-NETBSD:#define __UINT_LEAST32_MAX__ 4294967295U
 // AARCH64-NETBSD:#define __UINT_LEAST32_TYPE__ unsigned int
 // AARCH64-NETBSD:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // AARCH64-NETBSD:#define __UINT_LEAST64_TYPE__ long unsigned int
-// AARCH64-NETBSD:#define __UINT_LEAST8_MAX__ 255U
+// AARCH64-NETBSD:#define __UINT_LEAST8_MAX__ 255
 // AARCH64-NETBSD:#define __UINT_LEAST8_TYPE__ unsigned char
 // AARCH64-NETBSD:#define __USER_LABEL_PREFIX__
 // AARCH64-NETBSD:#define __WCHAR_MAX__ 2147483647
@@ -700,6 +801,199 @@
 // AARCH64-NETBSD:#define __WINT_TYPE__ int
 // AARCH64-NETBSD:#define __WINT_WIDTH__ 32
 // AARCH64-NETBSD:#define __aarch64__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-freebsd11 < /dev/null | FileCheck -check-prefix AARCH64-FREEBSD %s
+//
+// AARCH64-FREEBSD:#define _LP64 1
+// AARCH64-FREEBSD-NOT:#define __AARCH64EB__ 1
+// AARCH64-FREEBSD:#define __AARCH64EL__ 1
+// AARCH64-FREEBSD-NOT:#define __AARCH_BIG_ENDIAN 1
+// AARCH64-FREEBSD:#define __ARM_64BIT_STATE 1
+// AARCH64-FREEBSD:#define __ARM_ARCH 8
+// AARCH64-FREEBSD:#define __ARM_ARCH_ISA_A64 1
+// AARCH64-FREEBSD-NOT:#define __ARM_BIG_ENDIAN 1
+// AARCH64-FREEBSD:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64-FREEBSD:#define __CHAR16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __CHAR32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __CHAR_BIT__ 8
+// AARCH64-FREEBSD:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64-FREEBSD:#define __DBL_DIG__ 15
+// AARCH64-FREEBSD:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64-FREEBSD:#define __DBL_HAS_DENORM__ 1
+// AARCH64-FREEBSD:#define __DBL_HAS_INFINITY__ 1
+// AARCH64-FREEBSD:#define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64-FREEBSD:#define __DBL_MANT_DIG__ 53
+// AARCH64-FREEBSD:#define __DBL_MAX_10_EXP__ 308
+// AARCH64-FREEBSD:#define __DBL_MAX_EXP__ 1024
+// AARCH64-FREEBSD:#define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64-FREEBSD:#define __DBL_MIN_10_EXP__ (-307)
+// AARCH64-FREEBSD:#define __DBL_MIN_EXP__ (-1021)
+// AARCH64-FREEBSD:#define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64-FREEBSD:#define __DECIMAL_DIG__ 36
+// AARCH64-FREEBSD:#define __ELF__ 1
+// AARCH64-FREEBSD:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64-FREEBSD:#define __FLT_DIG__ 6
+// AARCH64-FREEBSD:#define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64-FREEBSD:#define __FLT_EVAL_METHOD__ 0
+// AARCH64-FREEBSD:#define __FLT_HAS_DENORM__ 1
+// AARCH64-FREEBSD:#define __FLT_HAS_INFINITY__ 1
+// AARCH64-FREEBSD:#define __FLT_HAS_QUIET_NAN__ 1
+// AARCH64-FREEBSD:#define __FLT_MANT_DIG__ 24
+// AARCH64-FREEBSD:#define __FLT_MAX_10_EXP__ 38
+// AARCH64-FREEBSD:#define __FLT_MAX_EXP__ 128
+// AARCH64-FREEBSD:#define __FLT_MAX__ 3.40282347e+38F
+// AARCH64-FREEBSD:#define __FLT_MIN_10_EXP__ (-37)
+// AARCH64-FREEBSD:#define __FLT_MIN_EXP__ (-125)
+// AARCH64-FREEBSD:#define __FLT_MIN__ 1.17549435e-38F
+// AARCH64-FREEBSD:#define __FLT_RADIX__ 2
+// AARCH64-FREEBSD:#define __FreeBSD__ 11
+// AARCH64-FREEBSD:#define __INT16_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __INT16_FMTd__ "hd"
+// AARCH64-FREEBSD:#define __INT16_FMTi__ "hi"
+// AARCH64-FREEBSD:#define __INT16_MAX__ 32767
+// AARCH64-FREEBSD:#define __INT16_TYPE__ short
+// AARCH64-FREEBSD:#define __INT32_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __INT32_FMTd__ "d"
+// AARCH64-FREEBSD:#define __INT32_FMTi__ "i"
+// AARCH64-FREEBSD:#define __INT32_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __INT32_TYPE__ int
+// AARCH64-FREEBSD:#define __INT64_C_SUFFIX__ L
+// AARCH64-FREEBSD:#define __INT64_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INT64_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INT64_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INT64_TYPE__ long int
+// AARCH64-FREEBSD:#define __INT8_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __INT8_FMTd__ "hhd"
+// AARCH64-FREEBSD:#define __INT8_FMTi__ "hhi"
+// AARCH64-FREEBSD:#define __INT8_MAX__ 127
+// AARCH64-FREEBSD:#define __INT8_TYPE__ signed char
+// AARCH64-FREEBSD:#define __INTMAX_C_SUFFIX__ L
+// AARCH64-FREEBSD:#define __INTMAX_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INTMAX_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INTMAX_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INTMAX_TYPE__ long int
+// AARCH64-FREEBSD:#define __INTMAX_WIDTH__ 64
+// AARCH64-FREEBSD:#define __INTPTR_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INTPTR_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INTPTR_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INTPTR_TYPE__ long int
+// AARCH64-FREEBSD:#define __INTPTR_WIDTH__ 64
+// AARCH64-FREEBSD:#define __INT_FAST16_FMTd__ "hd"
+// AARCH64-FREEBSD:#define __INT_FAST16_FMTi__ "hi"
+// AARCH64-FREEBSD:#define __INT_FAST16_MAX__ 32767
+// AARCH64-FREEBSD:#define __INT_FAST16_TYPE__ short
+// AARCH64-FREEBSD:#define __INT_FAST32_FMTd__ "d"
+// AARCH64-FREEBSD:#define __INT_FAST32_FMTi__ "i"
+// AARCH64-FREEBSD:#define __INT_FAST32_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __INT_FAST32_TYPE__ int
+// AARCH64-FREEBSD:#define __INT_FAST64_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INT_FAST64_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INT_FAST64_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INT_FAST64_TYPE__ long int
+// AARCH64-FREEBSD:#define __INT_FAST8_FMTd__ "hhd"
+// AARCH64-FREEBSD:#define __INT_FAST8_FMTi__ "hhi"
+// AARCH64-FREEBSD:#define __INT_FAST8_MAX__ 127
+// AARCH64-FREEBSD:#define __INT_FAST8_TYPE__ signed char
+// AARCH64-FREEBSD:#define __INT_LEAST16_FMTd__ "hd"
+// AARCH64-FREEBSD:#define __INT_LEAST16_FMTi__ "hi"
+// AARCH64-FREEBSD:#define __INT_LEAST16_MAX__ 32767
+// AARCH64-FREEBSD:#define __INT_LEAST16_TYPE__ short
+// AARCH64-FREEBSD:#define __INT_LEAST32_FMTd__ "d"
+// AARCH64-FREEBSD:#define __INT_LEAST32_FMTi__ "i"
+// AARCH64-FREEBSD:#define __INT_LEAST32_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __INT_LEAST32_TYPE__ int
+// AARCH64-FREEBSD:#define __INT_LEAST64_FMTd__ "ld"
+// AARCH64-FREEBSD:#define __INT_LEAST64_FMTi__ "li"
+// AARCH64-FREEBSD:#define __INT_LEAST64_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __INT_LEAST64_TYPE__ long int
+// AARCH64-FREEBSD:#define __INT_LEAST8_FMTd__ "hhd"
+// AARCH64-FREEBSD:#define __INT_LEAST8_FMTi__ "hhi"
+// AARCH64-FREEBSD:#define __INT_LEAST8_MAX__ 127
+// AARCH64-FREEBSD:#define __INT_LEAST8_TYPE__ signed char
+// AARCH64-FREEBSD:#define __INT_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// AARCH64-FREEBSD:#define __LDBL_DIG__ 33
+// AARCH64-FREEBSD:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// AARCH64-FREEBSD:#define __LDBL_HAS_DENORM__ 1
+// AARCH64-FREEBSD:#define __LDBL_HAS_INFINITY__ 1
+// AARCH64-FREEBSD:#define __LDBL_HAS_QUIET_NAN__ 1
+// AARCH64-FREEBSD:#define __LDBL_MANT_DIG__ 113
+// AARCH64-FREEBSD:#define __LDBL_MAX_10_EXP__ 4932
+// AARCH64-FREEBSD:#define __LDBL_MAX_EXP__ 16384
+// AARCH64-FREEBSD:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// AARCH64-FREEBSD:#define __LDBL_MIN_10_EXP__ (-4931)
+// AARCH64-FREEBSD:#define __LDBL_MIN_EXP__ (-16381)
+// AARCH64-FREEBSD:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// AARCH64-FREEBSD:#define __LITTLE_ENDIAN__ 1
+// AARCH64-FREEBSD:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// AARCH64-FREEBSD:#define __LONG_MAX__ 9223372036854775807L
+// AARCH64-FREEBSD:#define __LP64__ 1
+// AARCH64-FREEBSD:#define __POINTER_WIDTH__ 64
+// AARCH64-FREEBSD:#define __PTRDIFF_TYPE__ long int
+// AARCH64-FREEBSD:#define __PTRDIFF_WIDTH__ 64
+// AARCH64-FREEBSD:#define __SCHAR_MAX__ 127
+// AARCH64-FREEBSD:#define __SHRT_MAX__ 32767
+// AARCH64-FREEBSD:#define __SIG_ATOMIC_MAX__ 2147483647
+// AARCH64-FREEBSD:#define __SIG_ATOMIC_WIDTH__ 32
+// AARCH64-FREEBSD:#define __SIZEOF_DOUBLE__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_FLOAT__ 4
+// AARCH64-FREEBSD:#define __SIZEOF_INT128__ 16
+// AARCH64-FREEBSD:#define __SIZEOF_INT__ 4
+// AARCH64-FREEBSD:#define __SIZEOF_LONG_DOUBLE__ 16
+// AARCH64-FREEBSD:#define __SIZEOF_LONG_LONG__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_LONG__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_POINTER__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_PTRDIFF_T__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_SHORT__ 2
+// AARCH64-FREEBSD:#define __SIZEOF_SIZE_T__ 8
+// AARCH64-FREEBSD:#define __SIZEOF_WCHAR_T__ 4
+// AARCH64-FREEBSD:#define __SIZEOF_WINT_T__ 4
+// AARCH64-FREEBSD:#define __SIZE_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __SIZE_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __SIZE_WIDTH__ 64
+// AARCH64-FREEBSD:#define __UINT16_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __UINT16_MAX__ 65535
+// AARCH64-FREEBSD:#define __UINT16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __UINT32_C_SUFFIX__ U
+// AARCH64-FREEBSD:#define __UINT32_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __UINT32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __UINT64_C_SUFFIX__ UL
+// AARCH64-FREEBSD:#define __UINT64_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINT64_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINT8_C_SUFFIX__ {{$}}
+// AARCH64-FREEBSD:#define __UINT8_MAX__ 255
+// AARCH64-FREEBSD:#define __UINT8_TYPE__ unsigned char
+// AARCH64-FREEBSD:#define __UINTMAX_C_SUFFIX__ UL
+// AARCH64-FREEBSD:#define __UINTMAX_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINTMAX_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINTMAX_WIDTH__ 64
+// AARCH64-FREEBSD:#define __UINTPTR_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINTPTR_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINTPTR_WIDTH__ 64
+// AARCH64-FREEBSD:#define __UINT_FAST16_MAX__ 65535
+// AARCH64-FREEBSD:#define __UINT_FAST16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __UINT_FAST32_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __UINT_FAST32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __UINT_FAST64_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINT_FAST64_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINT_FAST8_MAX__ 255
+// AARCH64-FREEBSD:#define __UINT_FAST8_TYPE__ unsigned char
+// AARCH64-FREEBSD:#define __UINT_LEAST16_MAX__ 65535
+// AARCH64-FREEBSD:#define __UINT_LEAST16_TYPE__ unsigned short
+// AARCH64-FREEBSD:#define __UINT_LEAST32_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __UINT_LEAST32_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
+// AARCH64-FREEBSD:#define __UINT_LEAST64_TYPE__ long unsigned int
+// AARCH64-FREEBSD:#define __UINT_LEAST8_MAX__ 255
+// AARCH64-FREEBSD:#define __UINT_LEAST8_TYPE__ unsigned char
+// AARCH64-FREEBSD:#define __USER_LABEL_PREFIX__
+// AARCH64-FREEBSD:#define __WCHAR_MAX__ 4294967295U
+// AARCH64-FREEBSD:#define __WCHAR_TYPE__ unsigned int
+// AARCH64-FREEBSD:#define __WCHAR_UNSIGNED__ 1
+// AARCH64-FREEBSD:#define __WCHAR_WIDTH__ 32
+// AARCH64-FREEBSD:#define __WINT_TYPE__ int
+// AARCH64-FREEBSD:#define __WINT_WIDTH__ 32
+// AARCH64-FREEBSD:#define __aarch64__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s
 //
@@ -742,37 +1036,69 @@
 // ARM:#define __FLT_MIN_EXP__ (-125)
 // ARM:#define __FLT_MIN__ 1.17549435e-38F
 // ARM:#define __FLT_RADIX__ 2
+// ARM:#define __INT16_C_SUFFIX__ {{$}}
+// ARM:#define __INT16_FMTd__ "hd"
+// ARM:#define __INT16_FMTi__ "hi"
 // ARM:#define __INT16_MAX__ 32767
 // ARM:#define __INT16_TYPE__ short
+// ARM:#define __INT32_C_SUFFIX__ {{$}}
+// ARM:#define __INT32_FMTd__ "d"
+// ARM:#define __INT32_FMTi__ "i"
 // ARM:#define __INT32_MAX__ 2147483647
 // ARM:#define __INT32_TYPE__ int
 // ARM:#define __INT64_C_SUFFIX__ LL
+// ARM:#define __INT64_FMTd__ "lld"
+// ARM:#define __INT64_FMTi__ "lli"
 // ARM:#define __INT64_MAX__ 9223372036854775807LL
 // ARM:#define __INT64_TYPE__ long long int
+// ARM:#define __INT8_C_SUFFIX__ {{$}}
+// ARM:#define __INT8_FMTd__ "hhd"
+// ARM:#define __INT8_FMTi__ "hhi"
 // ARM:#define __INT8_MAX__ 127
-// ARM:#define __INT8_TYPE__ char
+// ARM:#define __INT8_TYPE__ signed char
+// ARM:#define __INTMAX_C_SUFFIX__ LL
+// ARM:#define __INTMAX_FMTd__ "lld"
+// ARM:#define __INTMAX_FMTi__ "lli"
 // ARM:#define __INTMAX_MAX__ 9223372036854775807LL
 // ARM:#define __INTMAX_TYPE__ long long int
 // ARM:#define __INTMAX_WIDTH__ 64
+// ARM:#define __INTPTR_FMTd__ "ld"
+// ARM:#define __INTPTR_FMTi__ "li"
 // ARM:#define __INTPTR_MAX__ 2147483647L
 // ARM:#define __INTPTR_TYPE__ long int
 // ARM:#define __INTPTR_WIDTH__ 32
+// ARM:#define __INT_FAST16_FMTd__ "hd"
+// ARM:#define __INT_FAST16_FMTi__ "hi"
 // ARM:#define __INT_FAST16_MAX__ 32767
 // ARM:#define __INT_FAST16_TYPE__ short
+// ARM:#define __INT_FAST32_FMTd__ "d"
+// ARM:#define __INT_FAST32_FMTi__ "i"
 // ARM:#define __INT_FAST32_MAX__ 2147483647
 // ARM:#define __INT_FAST32_TYPE__ int
+// ARM:#define __INT_FAST64_FMTd__ "lld"
+// ARM:#define __INT_FAST64_FMTi__ "lli"
 // ARM:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // ARM:#define __INT_FAST64_TYPE__ long long int
+// ARM:#define __INT_FAST8_FMTd__ "hhd"
+// ARM:#define __INT_FAST8_FMTi__ "hhi"
 // ARM:#define __INT_FAST8_MAX__ 127
-// ARM:#define __INT_FAST8_TYPE__ char
+// ARM:#define __INT_FAST8_TYPE__ signed char
+// ARM:#define __INT_LEAST16_FMTd__ "hd"
+// ARM:#define __INT_LEAST16_FMTi__ "hi"
 // ARM:#define __INT_LEAST16_MAX__ 32767
 // ARM:#define __INT_LEAST16_TYPE__ short
+// ARM:#define __INT_LEAST32_FMTd__ "d"
+// ARM:#define __INT_LEAST32_FMTi__ "i"
 // ARM:#define __INT_LEAST32_MAX__ 2147483647
 // ARM:#define __INT_LEAST32_TYPE__ int
+// ARM:#define __INT_LEAST64_FMTd__ "lld"
+// ARM:#define __INT_LEAST64_FMTi__ "lli"
 // ARM:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // ARM:#define __INT_LEAST64_TYPE__ long long int
+// ARM:#define __INT_LEAST8_FMTd__ "hhd"
+// ARM:#define __INT_LEAST8_FMTi__ "hhi"
 // ARM:#define __INT_LEAST8_MAX__ 127
-// ARM:#define __INT_LEAST8_TYPE__ char
+// ARM:#define __INT_LEAST8_TYPE__ signed char
 // ARM:#define __INT_MAX__ 2147483647
 // ARM:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // ARM:#define __LDBL_DIG__ 15
@@ -797,6 +1123,7 @@
 // ARM:#define __REGISTER_PREFIX__
 // ARM:#define __SCHAR_MAX__ 127
 // ARM:#define __SHRT_MAX__ 32767
+// ARM:#define __SIG_ATOMIC_MAX__ 2147483647
 // ARM:#define __SIG_ATOMIC_WIDTH__ 32
 // ARM:#define __SIZEOF_DOUBLE__ 8
 // ARM:#define __SIZEOF_FLOAT__ 4
@@ -814,8 +1141,8 @@
 // ARM:#define __SIZE_TYPE__ unsigned int
 // ARM:#define __SIZE_WIDTH__ 32
 // ARM:#define __THUMB_INTERWORK__ 1
-// ARM:#define __UINT16_C_SUFFIX__ U
-// ARM:#define __UINT16_MAX__ 65535U
+// ARM:#define __UINT16_C_SUFFIX__ {{$}}
+// ARM:#define __UINT16_MAX__ 65535
 // ARM:#define __UINT16_TYPE__ unsigned short
 // ARM:#define __UINT32_C_SUFFIX__ U
 // ARM:#define __UINT32_MAX__ 4294967295U
@@ -823,30 +1150,31 @@
 // ARM:#define __UINT64_C_SUFFIX__ ULL
 // ARM:#define __UINT64_MAX__ 18446744073709551615ULL
 // ARM:#define __UINT64_TYPE__ long long unsigned int
-// ARM:#define __UINT8_C_SUFFIX__ U
-// ARM:#define __UINT8_MAX__ 255U
+// ARM:#define __UINT8_C_SUFFIX__ {{$}}
+// ARM:#define __UINT8_MAX__ 255
 // ARM:#define __UINT8_TYPE__ unsigned char
+// ARM:#define __UINTMAX_C_SUFFIX__ ULL
 // ARM:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // ARM:#define __UINTMAX_TYPE__ long long unsigned int
 // ARM:#define __UINTMAX_WIDTH__ 64
 // ARM:#define __UINTPTR_MAX__ 4294967295U
-// ARM:#define __UINTPTR_TYPE__ unsigned int
+// ARM:#define __UINTPTR_TYPE__ long unsigned int
 // ARM:#define __UINTPTR_WIDTH__ 32
-// ARM:#define __UINT_FAST16_MAX__ 65535U
+// ARM:#define __UINT_FAST16_MAX__ 65535
 // ARM:#define __UINT_FAST16_TYPE__ unsigned short
 // ARM:#define __UINT_FAST32_MAX__ 4294967295U
 // ARM:#define __UINT_FAST32_TYPE__ unsigned int
 // ARM:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // ARM:#define __UINT_FAST64_TYPE__ long long unsigned int
-// ARM:#define __UINT_FAST8_MAX__ 255U
+// ARM:#define __UINT_FAST8_MAX__ 255
 // ARM:#define __UINT_FAST8_TYPE__ unsigned char
-// ARM:#define __UINT_LEAST16_MAX__ 65535U
+// ARM:#define __UINT_LEAST16_MAX__ 65535
 // ARM:#define __UINT_LEAST16_TYPE__ unsigned short
 // ARM:#define __UINT_LEAST32_MAX__ 4294967295U
 // ARM:#define __UINT_LEAST32_TYPE__ unsigned int
 // ARM:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // ARM:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// ARM:#define __UINT_LEAST8_MAX__ 255U
+// ARM:#define __UINT_LEAST8_MAX__ 255
 // ARM:#define __UINT_LEAST8_TYPE__ unsigned char
 // ARM:#define __USER_LABEL_PREFIX__ _
 // ARM:#define __WCHAR_MAX__ 4294967295U
@@ -899,37 +1227,69 @@
 // ARM-BE:#define __FLT_MIN_EXP__ (-125)
 // ARM-BE:#define __FLT_MIN__ 1.17549435e-38F
 // ARM-BE:#define __FLT_RADIX__ 2
+// ARM-BE:#define __INT16_C_SUFFIX__ {{$}}
+// ARM-BE:#define __INT16_FMTd__ "hd"
+// ARM-BE:#define __INT16_FMTi__ "hi"
 // ARM-BE:#define __INT16_MAX__ 32767
 // ARM-BE:#define __INT16_TYPE__ short
+// ARM-BE:#define __INT32_C_SUFFIX__ {{$}}
+// ARM-BE:#define __INT32_FMTd__ "d"
+// ARM-BE:#define __INT32_FMTi__ "i"
 // ARM-BE:#define __INT32_MAX__ 2147483647
 // ARM-BE:#define __INT32_TYPE__ int
 // ARM-BE:#define __INT64_C_SUFFIX__ LL
+// ARM-BE:#define __INT64_FMTd__ "lld"
+// ARM-BE:#define __INT64_FMTi__ "lli"
 // ARM-BE:#define __INT64_MAX__ 9223372036854775807LL
 // ARM-BE:#define __INT64_TYPE__ long long int
+// ARM-BE:#define __INT8_C_SUFFIX__ {{$}}
+// ARM-BE:#define __INT8_FMTd__ "hhd"
+// ARM-BE:#define __INT8_FMTi__ "hhi"
 // ARM-BE:#define __INT8_MAX__ 127
-// ARM-BE:#define __INT8_TYPE__ char
+// ARM-BE:#define __INT8_TYPE__ signed char
+// ARM-BE:#define __INTMAX_C_SUFFIX__ LL
+// ARM-BE:#define __INTMAX_FMTd__ "lld"
+// ARM-BE:#define __INTMAX_FMTi__ "lli"
 // ARM-BE:#define __INTMAX_MAX__ 9223372036854775807LL
 // ARM-BE:#define __INTMAX_TYPE__ long long int
 // ARM-BE:#define __INTMAX_WIDTH__ 64
+// ARM-BE:#define __INTPTR_FMTd__ "ld"
+// ARM-BE:#define __INTPTR_FMTi__ "li"
 // ARM-BE:#define __INTPTR_MAX__ 2147483647L
 // ARM-BE:#define __INTPTR_TYPE__ long int
 // ARM-BE:#define __INTPTR_WIDTH__ 32
+// ARM-BE:#define __INT_FAST16_FMTd__ "hd"
+// ARM-BE:#define __INT_FAST16_FMTi__ "hi"
 // ARM-BE:#define __INT_FAST16_MAX__ 32767
 // ARM-BE:#define __INT_FAST16_TYPE__ short
+// ARM-BE:#define __INT_FAST32_FMTd__ "d"
+// ARM-BE:#define __INT_FAST32_FMTi__ "i"
 // ARM-BE:#define __INT_FAST32_MAX__ 2147483647
 // ARM-BE:#define __INT_FAST32_TYPE__ int
+// ARM-BE:#define __INT_FAST64_FMTd__ "lld"
+// ARM-BE:#define __INT_FAST64_FMTi__ "lli"
 // ARM-BE:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // ARM-BE:#define __INT_FAST64_TYPE__ long long int
+// ARM-BE:#define __INT_FAST8_FMTd__ "hhd"
+// ARM-BE:#define __INT_FAST8_FMTi__ "hhi"
 // ARM-BE:#define __INT_FAST8_MAX__ 127
-// ARM-BE:#define __INT_FAST8_TYPE__ char
+// ARM-BE:#define __INT_FAST8_TYPE__ signed char
+// ARM-BE:#define __INT_LEAST16_FMTd__ "hd"
+// ARM-BE:#define __INT_LEAST16_FMTi__ "hi"
 // ARM-BE:#define __INT_LEAST16_MAX__ 32767
 // ARM-BE:#define __INT_LEAST16_TYPE__ short
+// ARM-BE:#define __INT_LEAST32_FMTd__ "d"
+// ARM-BE:#define __INT_LEAST32_FMTi__ "i"
 // ARM-BE:#define __INT_LEAST32_MAX__ 2147483647
 // ARM-BE:#define __INT_LEAST32_TYPE__ int
+// ARM-BE:#define __INT_LEAST64_FMTd__ "lld"
+// ARM-BE:#define __INT_LEAST64_FMTi__ "lli"
 // ARM-BE:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // ARM-BE:#define __INT_LEAST64_TYPE__ long long int
+// ARM-BE:#define __INT_LEAST8_FMTd__ "hhd"
+// ARM-BE:#define __INT_LEAST8_FMTi__ "hhi"
 // ARM-BE:#define __INT_LEAST8_MAX__ 127
-// ARM-BE:#define __INT_LEAST8_TYPE__ char
+// ARM-BE:#define __INT_LEAST8_TYPE__ signed char
 // ARM-BE:#define __INT_MAX__ 2147483647
 // ARM-BE:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // ARM-BE:#define __LDBL_DIG__ 15
@@ -953,6 +1313,7 @@
 // ARM-BE:#define __REGISTER_PREFIX__
 // ARM-BE:#define __SCHAR_MAX__ 127
 // ARM-BE:#define __SHRT_MAX__ 32767
+// ARM-BE:#define __SIG_ATOMIC_MAX__ 2147483647
 // ARM-BE:#define __SIG_ATOMIC_WIDTH__ 32
 // ARM-BE:#define __SIZEOF_DOUBLE__ 8
 // ARM-BE:#define __SIZEOF_FLOAT__ 4
@@ -970,8 +1331,8 @@
 // ARM-BE:#define __SIZE_TYPE__ unsigned int
 // ARM-BE:#define __SIZE_WIDTH__ 32
 // ARM-BE:#define __THUMB_INTERWORK__ 1
-// ARM-BE:#define __UINT16_C_SUFFIX__ U
-// ARM-BE:#define __UINT16_MAX__ 65535U
+// ARM-BE:#define __UINT16_C_SUFFIX__ {{$}}
+// ARM-BE:#define __UINT16_MAX__ 65535
 // ARM-BE:#define __UINT16_TYPE__ unsigned short
 // ARM-BE:#define __UINT32_C_SUFFIX__ U
 // ARM-BE:#define __UINT32_MAX__ 4294967295U
@@ -979,30 +1340,31 @@
 // ARM-BE:#define __UINT64_C_SUFFIX__ ULL
 // ARM-BE:#define __UINT64_MAX__ 18446744073709551615ULL
 // ARM-BE:#define __UINT64_TYPE__ long long unsigned int
-// ARM-BE:#define __UINT8_C_SUFFIX__ U
-// ARM-BE:#define __UINT8_MAX__ 255U
+// ARM-BE:#define __UINT8_C_SUFFIX__ {{$}}
+// ARM-BE:#define __UINT8_MAX__ 255
 // ARM-BE:#define __UINT8_TYPE__ unsigned char
+// ARM-BE:#define __UINTMAX_C_SUFFIX__ ULL
 // ARM-BE:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // ARM-BE:#define __UINTMAX_TYPE__ long long unsigned int
 // ARM-BE:#define __UINTMAX_WIDTH__ 64
 // ARM-BE:#define __UINTPTR_MAX__ 4294967295U
-// ARM-BE:#define __UINTPTR_TYPE__ unsigned int
+// ARM-BE:#define __UINTPTR_TYPE__ long unsigned int
 // ARM-BE:#define __UINTPTR_WIDTH__ 32
-// ARM-BE:#define __UINT_FAST16_MAX__ 65535U
+// ARM-BE:#define __UINT_FAST16_MAX__ 65535
 // ARM-BE:#define __UINT_FAST16_TYPE__ unsigned short
 // ARM-BE:#define __UINT_FAST32_MAX__ 4294967295U
 // ARM-BE:#define __UINT_FAST32_TYPE__ unsigned int
 // ARM-BE:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // ARM-BE:#define __UINT_FAST64_TYPE__ long long unsigned int
-// ARM-BE:#define __UINT_FAST8_MAX__ 255U
+// ARM-BE:#define __UINT_FAST8_MAX__ 255
 // ARM-BE:#define __UINT_FAST8_TYPE__ unsigned char
-// ARM-BE:#define __UINT_LEAST16_MAX__ 65535U
+// ARM-BE:#define __UINT_LEAST16_MAX__ 65535
 // ARM-BE:#define __UINT_LEAST16_TYPE__ unsigned short
 // ARM-BE:#define __UINT_LEAST32_MAX__ 4294967295U
 // ARM-BE:#define __UINT_LEAST32_TYPE__ unsigned int
 // ARM-BE:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // ARM-BE:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// ARM-BE:#define __UINT_LEAST8_MAX__ 255U
+// ARM-BE:#define __UINT_LEAST8_MAX__ 255
 // ARM-BE:#define __UINT_LEAST8_TYPE__ unsigned char
 // ARM-BE:#define __USER_LABEL_PREFIX__ _
 // ARM-BE:#define __WCHAR_MAX__ 4294967295U
@@ -1058,37 +1420,69 @@
 // ARMEABISOFTFP:#define __FLT_MIN_EXP__ (-125)
 // ARMEABISOFTFP:#define __FLT_MIN__ 1.17549435e-38F
 // ARMEABISOFTFP:#define __FLT_RADIX__ 2
+// ARMEABISOFTFP:#define __INT16_C_SUFFIX__ {{$}}
+// ARMEABISOFTFP:#define __INT16_FMTd__ "hd"
+// ARMEABISOFTFP:#define __INT16_FMTi__ "hi"
 // ARMEABISOFTFP:#define __INT16_MAX__ 32767
 // ARMEABISOFTFP:#define __INT16_TYPE__ short
+// ARMEABISOFTFP:#define __INT32_C_SUFFIX__ {{$}}
+// ARMEABISOFTFP:#define __INT32_FMTd__ "d"
+// ARMEABISOFTFP:#define __INT32_FMTi__ "i"
 // ARMEABISOFTFP:#define __INT32_MAX__ 2147483647
 // ARMEABISOFTFP:#define __INT32_TYPE__ int
 // ARMEABISOFTFP:#define __INT64_C_SUFFIX__ LL
+// ARMEABISOFTFP:#define __INT64_FMTd__ "lld"
+// ARMEABISOFTFP:#define __INT64_FMTi__ "lli"
 // ARMEABISOFTFP:#define __INT64_MAX__ 9223372036854775807LL
 // ARMEABISOFTFP:#define __INT64_TYPE__ long long int
+// ARMEABISOFTFP:#define __INT8_C_SUFFIX__ {{$}}
+// ARMEABISOFTFP:#define __INT8_FMTd__ "hhd"
+// ARMEABISOFTFP:#define __INT8_FMTi__ "hhi"
 // ARMEABISOFTFP:#define __INT8_MAX__ 127
-// ARMEABISOFTFP:#define __INT8_TYPE__ char
+// ARMEABISOFTFP:#define __INT8_TYPE__ signed char
+// ARMEABISOFTFP:#define __INTMAX_C_SUFFIX__ LL
+// ARMEABISOFTFP:#define __INTMAX_FMTd__ "lld"
+// ARMEABISOFTFP:#define __INTMAX_FMTi__ "lli"
 // ARMEABISOFTFP:#define __INTMAX_MAX__ 9223372036854775807LL
 // ARMEABISOFTFP:#define __INTMAX_TYPE__ long long int
 // ARMEABISOFTFP:#define __INTMAX_WIDTH__ 64
+// ARMEABISOFTFP:#define __INTPTR_FMTd__ "ld"
+// ARMEABISOFTFP:#define __INTPTR_FMTi__ "li"
 // ARMEABISOFTFP:#define __INTPTR_MAX__ 2147483647L
 // ARMEABISOFTFP:#define __INTPTR_TYPE__ long int
 // ARMEABISOFTFP:#define __INTPTR_WIDTH__ 32
+// ARMEABISOFTFP:#define __INT_FAST16_FMTd__ "hd"
+// ARMEABISOFTFP:#define __INT_FAST16_FMTi__ "hi"
 // ARMEABISOFTFP:#define __INT_FAST16_MAX__ 32767
 // ARMEABISOFTFP:#define __INT_FAST16_TYPE__ short
+// ARMEABISOFTFP:#define __INT_FAST32_FMTd__ "d"
+// ARMEABISOFTFP:#define __INT_FAST32_FMTi__ "i"
 // ARMEABISOFTFP:#define __INT_FAST32_MAX__ 2147483647
 // ARMEABISOFTFP:#define __INT_FAST32_TYPE__ int
+// ARMEABISOFTFP:#define __INT_FAST64_FMTd__ "lld"
+// ARMEABISOFTFP:#define __INT_FAST64_FMTi__ "lli"
 // ARMEABISOFTFP:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // ARMEABISOFTFP:#define __INT_FAST64_TYPE__ long long int
+// ARMEABISOFTFP:#define __INT_FAST8_FMTd__ "hhd"
+// ARMEABISOFTFP:#define __INT_FAST8_FMTi__ "hhi"
 // ARMEABISOFTFP:#define __INT_FAST8_MAX__ 127
-// ARMEABISOFTFP:#define __INT_FAST8_TYPE__ char
+// ARMEABISOFTFP:#define __INT_FAST8_TYPE__ signed char
+// ARMEABISOFTFP:#define __INT_LEAST16_FMTd__ "hd"
+// ARMEABISOFTFP:#define __INT_LEAST16_FMTi__ "hi"
 // ARMEABISOFTFP:#define __INT_LEAST16_MAX__ 32767
 // ARMEABISOFTFP:#define __INT_LEAST16_TYPE__ short
+// ARMEABISOFTFP:#define __INT_LEAST32_FMTd__ "d"
+// ARMEABISOFTFP:#define __INT_LEAST32_FMTi__ "i"
 // ARMEABISOFTFP:#define __INT_LEAST32_MAX__ 2147483647
 // ARMEABISOFTFP:#define __INT_LEAST32_TYPE__ int
+// ARMEABISOFTFP:#define __INT_LEAST64_FMTd__ "lld"
+// ARMEABISOFTFP:#define __INT_LEAST64_FMTi__ "lli"
 // ARMEABISOFTFP:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // ARMEABISOFTFP:#define __INT_LEAST64_TYPE__ long long int
+// ARMEABISOFTFP:#define __INT_LEAST8_FMTd__ "hhd"
+// ARMEABISOFTFP:#define __INT_LEAST8_FMTi__ "hhi"
 // ARMEABISOFTFP:#define __INT_LEAST8_MAX__ 127
-// ARMEABISOFTFP:#define __INT_LEAST8_TYPE__ char
+// ARMEABISOFTFP:#define __INT_LEAST8_TYPE__ signed char
 // ARMEABISOFTFP:#define __INT_MAX__ 2147483647
 // ARMEABISOFTFP:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // ARMEABISOFTFP:#define __LDBL_DIG__ 15
@@ -1113,6 +1507,7 @@
 // ARMEABISOFTFP:#define __REGISTER_PREFIX__
 // ARMEABISOFTFP:#define __SCHAR_MAX__ 127
 // ARMEABISOFTFP:#define __SHRT_MAX__ 32767
+// ARMEABISOFTFP:#define __SIG_ATOMIC_MAX__ 2147483647
 // ARMEABISOFTFP:#define __SIG_ATOMIC_WIDTH__ 32
 // ARMEABISOFTFP:#define __SIZEOF_DOUBLE__ 8
 // ARMEABISOFTFP:#define __SIZEOF_FLOAT__ 4
@@ -1131,8 +1526,8 @@
 // ARMEABISOFTFP:#define __SIZE_WIDTH__ 32
 // ARMEABISOFTFP:#define __SOFTFP__ 1
 // ARMEABISOFTFP:#define __THUMB_INTERWORK__ 1
-// ARMEABISOFTFP:#define __UINT16_C_SUFFIX__ U
-// ARMEABISOFTFP:#define __UINT16_MAX__ 65535U
+// ARMEABISOFTFP:#define __UINT16_C_SUFFIX__ {{$}}
+// ARMEABISOFTFP:#define __UINT16_MAX__ 65535
 // ARMEABISOFTFP:#define __UINT16_TYPE__ unsigned short
 // ARMEABISOFTFP:#define __UINT32_C_SUFFIX__ U
 // ARMEABISOFTFP:#define __UINT32_MAX__ 4294967295U
@@ -1140,30 +1535,31 @@
 // ARMEABISOFTFP:#define __UINT64_C_SUFFIX__ ULL
 // ARMEABISOFTFP:#define __UINT64_MAX__ 18446744073709551615ULL
 // ARMEABISOFTFP:#define __UINT64_TYPE__ long long unsigned int
-// ARMEABISOFTFP:#define __UINT8_C_SUFFIX__ U
-// ARMEABISOFTFP:#define __UINT8_MAX__ 255U
+// ARMEABISOFTFP:#define __UINT8_C_SUFFIX__ {{$}}
+// ARMEABISOFTFP:#define __UINT8_MAX__ 255
 // ARMEABISOFTFP:#define __UINT8_TYPE__ unsigned char
+// ARMEABISOFTFP:#define __UINTMAX_C_SUFFIX__ ULL
 // ARMEABISOFTFP:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // ARMEABISOFTFP:#define __UINTMAX_TYPE__ long long unsigned int
 // ARMEABISOFTFP:#define __UINTMAX_WIDTH__ 64
 // ARMEABISOFTFP:#define __UINTPTR_MAX__ 4294967295U
-// ARMEABISOFTFP:#define __UINTPTR_TYPE__ unsigned int
+// ARMEABISOFTFP:#define __UINTPTR_TYPE__ long unsigned int
 // ARMEABISOFTFP:#define __UINTPTR_WIDTH__ 32
-// ARMEABISOFTFP:#define __UINT_FAST16_MAX__ 65535U
+// ARMEABISOFTFP:#define __UINT_FAST16_MAX__ 65535
 // ARMEABISOFTFP:#define __UINT_FAST16_TYPE__ unsigned short
 // ARMEABISOFTFP:#define __UINT_FAST32_MAX__ 4294967295U
 // ARMEABISOFTFP:#define __UINT_FAST32_TYPE__ unsigned int
 // ARMEABISOFTFP:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // ARMEABISOFTFP:#define __UINT_FAST64_TYPE__ long long unsigned int
-// ARMEABISOFTFP:#define __UINT_FAST8_MAX__ 255U
+// ARMEABISOFTFP:#define __UINT_FAST8_MAX__ 255
 // ARMEABISOFTFP:#define __UINT_FAST8_TYPE__ unsigned char
-// ARMEABISOFTFP:#define __UINT_LEAST16_MAX__ 65535U
+// ARMEABISOFTFP:#define __UINT_LEAST16_MAX__ 65535
 // ARMEABISOFTFP:#define __UINT_LEAST16_TYPE__ unsigned short
 // ARMEABISOFTFP:#define __UINT_LEAST32_MAX__ 4294967295U
 // ARMEABISOFTFP:#define __UINT_LEAST32_TYPE__ unsigned int
 // ARMEABISOFTFP:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // ARMEABISOFTFP:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// ARMEABISOFTFP:#define __UINT_LEAST8_MAX__ 255U
+// ARMEABISOFTFP:#define __UINT_LEAST8_MAX__ 255
 // ARMEABISOFTFP:#define __UINT_LEAST8_TYPE__ unsigned char
 // ARMEABISOFTFP:#define __USER_LABEL_PREFIX__
 // ARMEABISOFTFP:#define __WCHAR_MAX__ 4294967295U
@@ -1219,37 +1615,69 @@
 // ARMEABIHARDFP:#define __FLT_MIN_EXP__ (-125)
 // ARMEABIHARDFP:#define __FLT_MIN__ 1.17549435e-38F
 // ARMEABIHARDFP:#define __FLT_RADIX__ 2
+// ARMEABIHARDFP:#define __INT16_C_SUFFIX__ {{$}}
+// ARMEABIHARDFP:#define __INT16_FMTd__ "hd"
+// ARMEABIHARDFP:#define __INT16_FMTi__ "hi"
 // ARMEABIHARDFP:#define __INT16_MAX__ 32767
 // ARMEABIHARDFP:#define __INT16_TYPE__ short
+// ARMEABIHARDFP:#define __INT32_C_SUFFIX__ {{$}}
+// ARMEABIHARDFP:#define __INT32_FMTd__ "d"
+// ARMEABIHARDFP:#define __INT32_FMTi__ "i"
 // ARMEABIHARDFP:#define __INT32_MAX__ 2147483647
 // ARMEABIHARDFP:#define __INT32_TYPE__ int
 // ARMEABIHARDFP:#define __INT64_C_SUFFIX__ LL
+// ARMEABIHARDFP:#define __INT64_FMTd__ "lld"
+// ARMEABIHARDFP:#define __INT64_FMTi__ "lli"
 // ARMEABIHARDFP:#define __INT64_MAX__ 9223372036854775807LL
 // ARMEABIHARDFP:#define __INT64_TYPE__ long long int
+// ARMEABIHARDFP:#define __INT8_C_SUFFIX__ {{$}}
+// ARMEABIHARDFP:#define __INT8_FMTd__ "hhd"
+// ARMEABIHARDFP:#define __INT8_FMTi__ "hhi"
 // ARMEABIHARDFP:#define __INT8_MAX__ 127
-// ARMEABIHARDFP:#define __INT8_TYPE__ char
+// ARMEABIHARDFP:#define __INT8_TYPE__ signed char
+// ARMEABIHARDFP:#define __INTMAX_C_SUFFIX__ LL
+// ARMEABIHARDFP:#define __INTMAX_FMTd__ "lld"
+// ARMEABIHARDFP:#define __INTMAX_FMTi__ "lli"
 // ARMEABIHARDFP:#define __INTMAX_MAX__ 9223372036854775807LL
 // ARMEABIHARDFP:#define __INTMAX_TYPE__ long long int
 // ARMEABIHARDFP:#define __INTMAX_WIDTH__ 64
+// ARMEABIHARDFP:#define __INTPTR_FMTd__ "ld"
+// ARMEABIHARDFP:#define __INTPTR_FMTi__ "li"
 // ARMEABIHARDFP:#define __INTPTR_MAX__ 2147483647L
 // ARMEABIHARDFP:#define __INTPTR_TYPE__ long int
 // ARMEABIHARDFP:#define __INTPTR_WIDTH__ 32
+// ARMEABIHARDFP:#define __INT_FAST16_FMTd__ "hd"
+// ARMEABIHARDFP:#define __INT_FAST16_FMTi__ "hi"
 // ARMEABIHARDFP:#define __INT_FAST16_MAX__ 32767
 // ARMEABIHARDFP:#define __INT_FAST16_TYPE__ short
+// ARMEABIHARDFP:#define __INT_FAST32_FMTd__ "d"
+// ARMEABIHARDFP:#define __INT_FAST32_FMTi__ "i"
 // ARMEABIHARDFP:#define __INT_FAST32_MAX__ 2147483647
 // ARMEABIHARDFP:#define __INT_FAST32_TYPE__ int
+// ARMEABIHARDFP:#define __INT_FAST64_FMTd__ "lld"
+// ARMEABIHARDFP:#define __INT_FAST64_FMTi__ "lli"
 // ARMEABIHARDFP:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // ARMEABIHARDFP:#define __INT_FAST64_TYPE__ long long int
+// ARMEABIHARDFP:#define __INT_FAST8_FMTd__ "hhd"
+// ARMEABIHARDFP:#define __INT_FAST8_FMTi__ "hhi"
 // ARMEABIHARDFP:#define __INT_FAST8_MAX__ 127
-// ARMEABIHARDFP:#define __INT_FAST8_TYPE__ char
+// ARMEABIHARDFP:#define __INT_FAST8_TYPE__ signed char
+// ARMEABIHARDFP:#define __INT_LEAST16_FMTd__ "hd"
+// ARMEABIHARDFP:#define __INT_LEAST16_FMTi__ "hi"
 // ARMEABIHARDFP:#define __INT_LEAST16_MAX__ 32767
 // ARMEABIHARDFP:#define __INT_LEAST16_TYPE__ short
+// ARMEABIHARDFP:#define __INT_LEAST32_FMTd__ "d"
+// ARMEABIHARDFP:#define __INT_LEAST32_FMTi__ "i"
 // ARMEABIHARDFP:#define __INT_LEAST32_MAX__ 2147483647
 // ARMEABIHARDFP:#define __INT_LEAST32_TYPE__ int
+// ARMEABIHARDFP:#define __INT_LEAST64_FMTd__ "lld"
+// ARMEABIHARDFP:#define __INT_LEAST64_FMTi__ "lli"
 // ARMEABIHARDFP:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // ARMEABIHARDFP:#define __INT_LEAST64_TYPE__ long long int
+// ARMEABIHARDFP:#define __INT_LEAST8_FMTd__ "hhd"
+// ARMEABIHARDFP:#define __INT_LEAST8_FMTi__ "hhi"
 // ARMEABIHARDFP:#define __INT_LEAST8_MAX__ 127
-// ARMEABIHARDFP:#define __INT_LEAST8_TYPE__ char
+// ARMEABIHARDFP:#define __INT_LEAST8_TYPE__ signed char
 // ARMEABIHARDFP:#define __INT_MAX__ 2147483647
 // ARMEABIHARDFP:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // ARMEABIHARDFP:#define __LDBL_DIG__ 15
@@ -1274,6 +1702,7 @@
 // ARMEABIHARDFP:#define __REGISTER_PREFIX__
 // ARMEABIHARDFP:#define __SCHAR_MAX__ 127
 // ARMEABIHARDFP:#define __SHRT_MAX__ 32767
+// ARMEABIHARDFP:#define __SIG_ATOMIC_MAX__ 2147483647
 // ARMEABIHARDFP:#define __SIG_ATOMIC_WIDTH__ 32
 // ARMEABIHARDFP:#define __SIZEOF_DOUBLE__ 8
 // ARMEABIHARDFP:#define __SIZEOF_FLOAT__ 4
@@ -1292,8 +1721,8 @@
 // ARMEABIHARDFP:#define __SIZE_WIDTH__ 32
 // ARMEABIHARDFP-NOT:#define __SOFTFP__ 1
 // ARMEABIHARDFP:#define __THUMB_INTERWORK__ 1
-// ARMEABIHARDFP:#define __UINT16_C_SUFFIX__ U
-// ARMEABIHARDFP:#define __UINT16_MAX__ 65535U
+// ARMEABIHARDFP:#define __UINT16_C_SUFFIX__ {{$}}
+// ARMEABIHARDFP:#define __UINT16_MAX__ 65535
 // ARMEABIHARDFP:#define __UINT16_TYPE__ unsigned short
 // ARMEABIHARDFP:#define __UINT32_C_SUFFIX__ U
 // ARMEABIHARDFP:#define __UINT32_MAX__ 4294967295U
@@ -1301,30 +1730,31 @@
 // ARMEABIHARDFP:#define __UINT64_C_SUFFIX__ ULL
 // ARMEABIHARDFP:#define __UINT64_MAX__ 18446744073709551615ULL
 // ARMEABIHARDFP:#define __UINT64_TYPE__ long long unsigned int
-// ARMEABIHARDFP:#define __UINT8_C_SUFFIX__ U
-// ARMEABIHARDFP:#define __UINT8_MAX__ 255U
+// ARMEABIHARDFP:#define __UINT8_C_SUFFIX__ {{$}}
+// ARMEABIHARDFP:#define __UINT8_MAX__ 255
 // ARMEABIHARDFP:#define __UINT8_TYPE__ unsigned char
+// ARMEABIHARDFP:#define __UINTMAX_C_SUFFIX__ ULL
 // ARMEABIHARDFP:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // ARMEABIHARDFP:#define __UINTMAX_TYPE__ long long unsigned int
 // ARMEABIHARDFP:#define __UINTMAX_WIDTH__ 64
 // ARMEABIHARDFP:#define __UINTPTR_MAX__ 4294967295U
-// ARMEABIHARDFP:#define __UINTPTR_TYPE__ unsigned int
+// ARMEABIHARDFP:#define __UINTPTR_TYPE__ long unsigned int
 // ARMEABIHARDFP:#define __UINTPTR_WIDTH__ 32
-// ARMEABIHARDFP:#define __UINT_FAST16_MAX__ 65535U
+// ARMEABIHARDFP:#define __UINT_FAST16_MAX__ 65535
 // ARMEABIHARDFP:#define __UINT_FAST16_TYPE__ unsigned short
 // ARMEABIHARDFP:#define __UINT_FAST32_MAX__ 4294967295U
 // ARMEABIHARDFP:#define __UINT_FAST32_TYPE__ unsigned int
 // ARMEABIHARDFP:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // ARMEABIHARDFP:#define __UINT_FAST64_TYPE__ long long unsigned int
-// ARMEABIHARDFP:#define __UINT_FAST8_MAX__ 255U
+// ARMEABIHARDFP:#define __UINT_FAST8_MAX__ 255
 // ARMEABIHARDFP:#define __UINT_FAST8_TYPE__ unsigned char
-// ARMEABIHARDFP:#define __UINT_LEAST16_MAX__ 65535U
+// ARMEABIHARDFP:#define __UINT_LEAST16_MAX__ 65535
 // ARMEABIHARDFP:#define __UINT_LEAST16_TYPE__ unsigned short
 // ARMEABIHARDFP:#define __UINT_LEAST32_MAX__ 4294967295U
 // ARMEABIHARDFP:#define __UINT_LEAST32_TYPE__ unsigned int
 // ARMEABIHARDFP:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // ARMEABIHARDFP:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// ARMEABIHARDFP:#define __UINT_LEAST8_MAX__ 255U
+// ARMEABIHARDFP:#define __UINT_LEAST8_MAX__ 255
 // ARMEABIHARDFP:#define __UINT_LEAST8_TYPE__ unsigned char
 // ARMEABIHARDFP:#define __USER_LABEL_PREFIX__
 // ARMEABIHARDFP:#define __WCHAR_MAX__ 4294967295U
@@ -1378,37 +1808,69 @@
 // ARM-NETBSD:#define __FLT_MIN_EXP__ (-125)
 // ARM-NETBSD:#define __FLT_MIN__ 1.17549435e-38F
 // ARM-NETBSD:#define __FLT_RADIX__ 2
+// ARM-NETBSD:#define __INT16_C_SUFFIX__ {{$}}
+// ARM-NETBSD:#define __INT16_FMTd__ "hd"
+// ARM-NETBSD:#define __INT16_FMTi__ "hi"
 // ARM-NETBSD:#define __INT16_MAX__ 32767
 // ARM-NETBSD:#define __INT16_TYPE__ short
+// ARM-NETBSD:#define __INT32_C_SUFFIX__ {{$}}
+// ARM-NETBSD:#define __INT32_FMTd__ "d"
+// ARM-NETBSD:#define __INT32_FMTi__ "i"
 // ARM-NETBSD:#define __INT32_MAX__ 2147483647
 // ARM-NETBSD:#define __INT32_TYPE__ int
 // ARM-NETBSD:#define __INT64_C_SUFFIX__ LL
+// ARM-NETBSD:#define __INT64_FMTd__ "lld"
+// ARM-NETBSD:#define __INT64_FMTi__ "lli"
 // ARM-NETBSD:#define __INT64_MAX__ 9223372036854775807LL
 // ARM-NETBSD:#define __INT64_TYPE__ long long int
+// ARM-NETBSD:#define __INT8_C_SUFFIX__ {{$}}
+// ARM-NETBSD:#define __INT8_FMTd__ "hhd"
+// ARM-NETBSD:#define __INT8_FMTi__ "hhi"
 // ARM-NETBSD:#define __INT8_MAX__ 127
-// ARM-NETBSD:#define __INT8_TYPE__ char
+// ARM-NETBSD:#define __INT8_TYPE__ signed char
+// ARM-NETBSD:#define __INTMAX_C_SUFFIX__ LL
+// ARM-NETBSD:#define __INTMAX_FMTd__ "lld"
+// ARM-NETBSD:#define __INTMAX_FMTi__ "lli"
 // ARM-NETBSD:#define __INTMAX_MAX__ 9223372036854775807LL
 // ARM-NETBSD:#define __INTMAX_TYPE__ long long int
 // ARM-NETBSD:#define __INTMAX_WIDTH__ 64
+// ARM-NETBSD:#define __INTPTR_FMTd__ "ld"
+// ARM-NETBSD:#define __INTPTR_FMTi__ "li"
 // ARM-NETBSD:#define __INTPTR_MAX__ 2147483647L
 // ARM-NETBSD:#define __INTPTR_TYPE__ long int
 // ARM-NETBSD:#define __INTPTR_WIDTH__ 32
+// ARM-NETBSD:#define __INT_FAST16_FMTd__ "hd"
+// ARM-NETBSD:#define __INT_FAST16_FMTi__ "hi"
 // ARM-NETBSD:#define __INT_FAST16_MAX__ 32767
 // ARM-NETBSD:#define __INT_FAST16_TYPE__ short
+// ARM-NETBSD:#define __INT_FAST32_FMTd__ "d"
+// ARM-NETBSD:#define __INT_FAST32_FMTi__ "i"
 // ARM-NETBSD:#define __INT_FAST32_MAX__ 2147483647
 // ARM-NETBSD:#define __INT_FAST32_TYPE__ int
+// ARM-NETBSD:#define __INT_FAST64_FMTd__ "lld"
+// ARM-NETBSD:#define __INT_FAST64_FMTi__ "lli"
 // ARM-NETBSD:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // ARM-NETBSD:#define __INT_FAST64_TYPE__ long long int
+// ARM-NETBSD:#define __INT_FAST8_FMTd__ "hhd"
+// ARM-NETBSD:#define __INT_FAST8_FMTi__ "hhi"
 // ARM-NETBSD:#define __INT_FAST8_MAX__ 127
-// ARM-NETBSD:#define __INT_FAST8_TYPE__ char
+// ARM-NETBSD:#define __INT_FAST8_TYPE__ signed char
+// ARM-NETBSD:#define __INT_LEAST16_FMTd__ "hd"
+// ARM-NETBSD:#define __INT_LEAST16_FMTi__ "hi"
 // ARM-NETBSD:#define __INT_LEAST16_MAX__ 32767
 // ARM-NETBSD:#define __INT_LEAST16_TYPE__ short
+// ARM-NETBSD:#define __INT_LEAST32_FMTd__ "d"
+// ARM-NETBSD:#define __INT_LEAST32_FMTi__ "i"
 // ARM-NETBSD:#define __INT_LEAST32_MAX__ 2147483647
 // ARM-NETBSD:#define __INT_LEAST32_TYPE__ int
+// ARM-NETBSD:#define __INT_LEAST64_FMTd__ "lld"
+// ARM-NETBSD:#define __INT_LEAST64_FMTi__ "lli"
 // ARM-NETBSD:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // ARM-NETBSD:#define __INT_LEAST64_TYPE__ long long int
+// ARM-NETBSD:#define __INT_LEAST8_FMTd__ "hhd"
+// ARM-NETBSD:#define __INT_LEAST8_FMTi__ "hhi"
 // ARM-NETBSD:#define __INT_LEAST8_MAX__ 127
-// ARM-NETBSD:#define __INT_LEAST8_TYPE__ char
+// ARM-NETBSD:#define __INT_LEAST8_TYPE__ signed char
 // ARM-NETBSD:#define __INT_MAX__ 2147483647
 // ARM-NETBSD:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // ARM-NETBSD:#define __LDBL_DIG__ 15
@@ -1433,6 +1895,7 @@
 // ARM-NETBSD:#define __REGISTER_PREFIX__
 // ARM-NETBSD:#define __SCHAR_MAX__ 127
 // ARM-NETBSD:#define __SHRT_MAX__ 32767
+// ARM-NETBSD:#define __SIG_ATOMIC_MAX__ 2147483647
 // ARM-NETBSD:#define __SIG_ATOMIC_WIDTH__ 32
 // ARM-NETBSD:#define __SIZEOF_DOUBLE__ 8
 // ARM-NETBSD:#define __SIZEOF_FLOAT__ 4
@@ -1450,8 +1913,8 @@
 // ARM-NETBSD:#define __SIZE_TYPE__ long unsigned int
 // ARM-NETBSD:#define __SIZE_WIDTH__ 32
 // ARM-NETBSD:#define __THUMB_INTERWORK__ 1
-// ARM-NETBSD:#define __UINT16_C_SUFFIX__ U
-// ARM-NETBSD:#define __UINT16_MAX__ 65535U
+// ARM-NETBSD:#define __UINT16_C_SUFFIX__ {{$}}
+// ARM-NETBSD:#define __UINT16_MAX__ 65535
 // ARM-NETBSD:#define __UINT16_TYPE__ unsigned short
 // ARM-NETBSD:#define __UINT32_C_SUFFIX__ U
 // ARM-NETBSD:#define __UINT32_MAX__ 4294967295U
@@ -1459,30 +1922,31 @@
 // ARM-NETBSD:#define __UINT64_C_SUFFIX__ ULL
 // ARM-NETBSD:#define __UINT64_MAX__ 18446744073709551615ULL
 // ARM-NETBSD:#define __UINT64_TYPE__ long long unsigned int
-// ARM-NETBSD:#define __UINT8_C_SUFFIX__ U
-// ARM-NETBSD:#define __UINT8_MAX__ 255U
+// ARM-NETBSD:#define __UINT8_C_SUFFIX__ {{$}}
+// ARM-NETBSD:#define __UINT8_MAX__ 255
 // ARM-NETBSD:#define __UINT8_TYPE__ unsigned char
+// ARM-NETBSD:#define __UINTMAX_C_SUFFIX__ UL
 // ARM-NETBSD:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // ARM-NETBSD:#define __UINTMAX_TYPE__ long long unsigned int
 // ARM-NETBSD:#define __UINTMAX_WIDTH__ 64
 // ARM-NETBSD:#define __UINTPTR_MAX__ 4294967295U
-// ARM-NETBSD:#define __UINTPTR_TYPE__ unsigned int
+// ARM-NETBSD:#define __UINTPTR_TYPE__ long unsigned int
 // ARM-NETBSD:#define __UINTPTR_WIDTH__ 32
-// ARM-NETBSD:#define __UINT_FAST16_MAX__ 65535U
+// ARM-NETBSD:#define __UINT_FAST16_MAX__ 65535
 // ARM-NETBSD:#define __UINT_FAST16_TYPE__ unsigned short
 // ARM-NETBSD:#define __UINT_FAST32_MAX__ 4294967295U
 // ARM-NETBSD:#define __UINT_FAST32_TYPE__ unsigned int
 // ARM-NETBSD:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // ARM-NETBSD:#define __UINT_FAST64_TYPE__ long long unsigned int
-// ARM-NETBSD:#define __UINT_FAST8_MAX__ 255U
+// ARM-NETBSD:#define __UINT_FAST8_MAX__ 255
 // ARM-NETBSD:#define __UINT_FAST8_TYPE__ unsigned char
-// ARM-NETBSD:#define __UINT_LEAST16_MAX__ 65535U
+// ARM-NETBSD:#define __UINT_LEAST16_MAX__ 65535
 // ARM-NETBSD:#define __UINT_LEAST16_TYPE__ unsigned short
 // ARM-NETBSD:#define __UINT_LEAST32_MAX__ 4294967295U
 // ARM-NETBSD:#define __UINT_LEAST32_TYPE__ unsigned int
 // ARM-NETBSD:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // ARM-NETBSD:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// ARM-NETBSD:#define __UINT_LEAST8_MAX__ 255U
+// ARM-NETBSD:#define __UINT_LEAST8_MAX__ 255
 // ARM-NETBSD:#define __UINT_LEAST8_TYPE__ unsigned char
 // ARM-NETBSD:#define __USER_LABEL_PREFIX__
 // ARM-NETBSD:#define __WCHAR_MAX__ 2147483647
@@ -1493,12 +1957,13 @@
 // ARM-NETBSD:#define __arm 1
 // ARM-NETBSD:#define __arm__ 1
 
-// RUN: %clang -target arm -arch armv7s -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-NO-EABI %s
-// RUN: %clang -target arm -arch armv6m -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-NO-EABI %s
-// RUN: %clang -target arm -arch armv7m -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-NO-EABI %s
-// RUN: %clang -target arm -arch armv7em -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-NO-EABI %s
+// RUN: %clang -target arm-apple-darwin-eabi -arch armv7s -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-NO-EABI %s
+// RUN: %clang -target arm-apple-darwin-eabi -arch armv6m -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-EABI %s
+// RUN: %clang -target arm-apple-darwin-eabi -arch armv7m -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-EABI %s
+// RUN: %clang -target arm-apple-darwin-eabi -arch armv7em -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-EABI %s
 // RUN: %clang -target thumbv7-apple-darwin-eabi -arch armv7 -x c -E -dM %s -o - | FileCheck --check-prefix=ARM-DARWIN-NO-EABI %s
 // ARM-DARWIN-NO-EABI-NOT: #define __ARM_EABI__ 1
+// ARM-DARWIN-EABI: #define __ARM_EABI__ 1
 
 // Check that -mhwdiv works properly for targets which don't have the hwdiv feature enabled by default.
 
@@ -1589,37 +2054,69 @@
 // I386:#define __FLT_MIN_EXP__ (-125)
 // I386:#define __FLT_MIN__ 1.17549435e-38F
 // I386:#define __FLT_RADIX__ 2
+// I386:#define __INT16_C_SUFFIX__ {{$}}
+// I386:#define __INT16_FMTd__ "hd"
+// I386:#define __INT16_FMTi__ "hi"
 // I386:#define __INT16_MAX__ 32767
 // I386:#define __INT16_TYPE__ short
+// I386:#define __INT32_C_SUFFIX__ {{$}}
+// I386:#define __INT32_FMTd__ "d"
+// I386:#define __INT32_FMTi__ "i"
 // I386:#define __INT32_MAX__ 2147483647
 // I386:#define __INT32_TYPE__ int
 // I386:#define __INT64_C_SUFFIX__ LL
+// I386:#define __INT64_FMTd__ "lld"
+// I386:#define __INT64_FMTi__ "lli"
 // I386:#define __INT64_MAX__ 9223372036854775807LL
 // I386:#define __INT64_TYPE__ long long int
+// I386:#define __INT8_C_SUFFIX__ {{$}}
+// I386:#define __INT8_FMTd__ "hhd"
+// I386:#define __INT8_FMTi__ "hhi"
 // I386:#define __INT8_MAX__ 127
-// I386:#define __INT8_TYPE__ char
+// I386:#define __INT8_TYPE__ signed char
+// I386:#define __INTMAX_C_SUFFIX__ LL
+// I386:#define __INTMAX_FMTd__ "lld"
+// I386:#define __INTMAX_FMTi__ "lli"
 // I386:#define __INTMAX_MAX__ 9223372036854775807LL
 // I386:#define __INTMAX_TYPE__ long long int
 // I386:#define __INTMAX_WIDTH__ 64
+// I386:#define __INTPTR_FMTd__ "d"
+// I386:#define __INTPTR_FMTi__ "i"
 // I386:#define __INTPTR_MAX__ 2147483647
 // I386:#define __INTPTR_TYPE__ int
 // I386:#define __INTPTR_WIDTH__ 32
+// I386:#define __INT_FAST16_FMTd__ "hd"
+// I386:#define __INT_FAST16_FMTi__ "hi"
 // I386:#define __INT_FAST16_MAX__ 32767
 // I386:#define __INT_FAST16_TYPE__ short
+// I386:#define __INT_FAST32_FMTd__ "d"
+// I386:#define __INT_FAST32_FMTi__ "i"
 // I386:#define __INT_FAST32_MAX__ 2147483647
 // I386:#define __INT_FAST32_TYPE__ int
+// I386:#define __INT_FAST64_FMTd__ "lld"
+// I386:#define __INT_FAST64_FMTi__ "lli"
 // I386:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // I386:#define __INT_FAST64_TYPE__ long long int
+// I386:#define __INT_FAST8_FMTd__ "hhd"
+// I386:#define __INT_FAST8_FMTi__ "hhi"
 // I386:#define __INT_FAST8_MAX__ 127
-// I386:#define __INT_FAST8_TYPE__ char
+// I386:#define __INT_FAST8_TYPE__ signed char
+// I386:#define __INT_LEAST16_FMTd__ "hd"
+// I386:#define __INT_LEAST16_FMTi__ "hi"
 // I386:#define __INT_LEAST16_MAX__ 32767
 // I386:#define __INT_LEAST16_TYPE__ short
+// I386:#define __INT_LEAST32_FMTd__ "d"
+// I386:#define __INT_LEAST32_FMTi__ "i"
 // I386:#define __INT_LEAST32_MAX__ 2147483647
 // I386:#define __INT_LEAST32_TYPE__ int
+// I386:#define __INT_LEAST64_FMTd__ "lld"
+// I386:#define __INT_LEAST64_FMTi__ "lli"
 // I386:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // I386:#define __INT_LEAST64_TYPE__ long long int
+// I386:#define __INT_LEAST8_FMTd__ "hhd"
+// I386:#define __INT_LEAST8_FMTi__ "hhi"
 // I386:#define __INT_LEAST8_MAX__ 127
-// I386:#define __INT_LEAST8_TYPE__ char
+// I386:#define __INT_LEAST8_TYPE__ signed char
 // I386:#define __INT_MAX__ 2147483647
 // I386:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
 // I386:#define __LDBL_DIG__ 18
@@ -1645,6 +2142,7 @@
 // I386:#define __REGISTER_PREFIX__ 
 // I386:#define __SCHAR_MAX__ 127
 // I386:#define __SHRT_MAX__ 32767
+// I386:#define __SIG_ATOMIC_MAX__ 2147483647
 // I386:#define __SIG_ATOMIC_WIDTH__ 32
 // I386:#define __SIZEOF_DOUBLE__ 8
 // I386:#define __SIZEOF_FLOAT__ 4
@@ -1661,8 +2159,8 @@
 // I386:#define __SIZE_MAX__ 4294967295U
 // I386:#define __SIZE_TYPE__ unsigned int
 // I386:#define __SIZE_WIDTH__ 32
-// I386:#define __UINT16_C_SUFFIX__ U
-// I386:#define __UINT16_MAX__ 65535U
+// I386:#define __UINT16_C_SUFFIX__ {{$}}
+// I386:#define __UINT16_MAX__ 65535
 // I386:#define __UINT16_TYPE__ unsigned short
 // I386:#define __UINT32_C_SUFFIX__ U
 // I386:#define __UINT32_MAX__ 4294967295U
@@ -1670,30 +2168,31 @@
 // I386:#define __UINT64_C_SUFFIX__ ULL
 // I386:#define __UINT64_MAX__ 18446744073709551615ULL
 // I386:#define __UINT64_TYPE__ long long unsigned int
-// I386:#define __UINT8_C_SUFFIX__ U
-// I386:#define __UINT8_MAX__ 255U
+// I386:#define __UINT8_C_SUFFIX__ {{$}}
+// I386:#define __UINT8_MAX__ 255
 // I386:#define __UINT8_TYPE__ unsigned char
+// I386:#define __UINTMAX_C_SUFFIX__ ULL
 // I386:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // I386:#define __UINTMAX_TYPE__ long long unsigned int
 // I386:#define __UINTMAX_WIDTH__ 64
 // I386:#define __UINTPTR_MAX__ 4294967295U
 // I386:#define __UINTPTR_TYPE__ unsigned int
 // I386:#define __UINTPTR_WIDTH__ 32
-// I386:#define __UINT_FAST16_MAX__ 65535U
+// I386:#define __UINT_FAST16_MAX__ 65535
 // I386:#define __UINT_FAST16_TYPE__ unsigned short
 // I386:#define __UINT_FAST32_MAX__ 4294967295U
 // I386:#define __UINT_FAST32_TYPE__ unsigned int
 // I386:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // I386:#define __UINT_FAST64_TYPE__ long long unsigned int
-// I386:#define __UINT_FAST8_MAX__ 255U
+// I386:#define __UINT_FAST8_MAX__ 255
 // I386:#define __UINT_FAST8_TYPE__ unsigned char
-// I386:#define __UINT_LEAST16_MAX__ 65535U
+// I386:#define __UINT_LEAST16_MAX__ 65535
 // I386:#define __UINT_LEAST16_TYPE__ unsigned short
 // I386:#define __UINT_LEAST32_MAX__ 4294967295U
 // I386:#define __UINT_LEAST32_TYPE__ unsigned int
 // I386:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // I386:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// I386:#define __UINT_LEAST8_MAX__ 255U
+// I386:#define __UINT_LEAST8_MAX__ 255
 // I386:#define __UINT_LEAST8_TYPE__ unsigned char
 // I386:#define __USER_LABEL_PREFIX__ _
 // I386:#define __WCHAR_MAX__ 2147483647
@@ -1741,37 +2240,69 @@
 // I386-LINUX:#define __FLT_MIN_EXP__ (-125)
 // I386-LINUX:#define __FLT_MIN__ 1.17549435e-38F
 // I386-LINUX:#define __FLT_RADIX__ 2
+// I386-LINUX:#define __INT16_C_SUFFIX__ {{$}}
+// I386-LINUX:#define __INT16_FMTd__ "hd"
+// I386-LINUX:#define __INT16_FMTi__ "hi"
 // I386-LINUX:#define __INT16_MAX__ 32767
 // I386-LINUX:#define __INT16_TYPE__ short
+// I386-LINUX:#define __INT32_C_SUFFIX__ {{$}}
+// I386-LINUX:#define __INT32_FMTd__ "d"
+// I386-LINUX:#define __INT32_FMTi__ "i"
 // I386-LINUX:#define __INT32_MAX__ 2147483647
 // I386-LINUX:#define __INT32_TYPE__ int
 // I386-LINUX:#define __INT64_C_SUFFIX__ LL
+// I386-LINUX:#define __INT64_FMTd__ "lld"
+// I386-LINUX:#define __INT64_FMTi__ "lli"
 // I386-LINUX:#define __INT64_MAX__ 9223372036854775807LL
 // I386-LINUX:#define __INT64_TYPE__ long long int
+// I386-LINUX:#define __INT8_C_SUFFIX__ {{$}}
+// I386-LINUX:#define __INT8_FMTd__ "hhd"
+// I386-LINUX:#define __INT8_FMTi__ "hhi"
 // I386-LINUX:#define __INT8_MAX__ 127
-// I386-LINUX:#define __INT8_TYPE__ char
+// I386-LINUX:#define __INT8_TYPE__ signed char
+// I386-LINUX:#define __INTMAX_C_SUFFIX__ LL
+// I386-LINUX:#define __INTMAX_FMTd__ "lld"
+// I386-LINUX:#define __INTMAX_FMTi__ "lli"
 // I386-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL
 // I386-LINUX:#define __INTMAX_TYPE__ long long int
 // I386-LINUX:#define __INTMAX_WIDTH__ 64
+// I386-LINUX:#define __INTPTR_FMTd__ "d"
+// I386-LINUX:#define __INTPTR_FMTi__ "i"
 // I386-LINUX:#define __INTPTR_MAX__ 2147483647
 // I386-LINUX:#define __INTPTR_TYPE__ int
 // I386-LINUX:#define __INTPTR_WIDTH__ 32
+// I386-LINUX:#define __INT_FAST16_FMTd__ "hd"
+// I386-LINUX:#define __INT_FAST16_FMTi__ "hi"
 // I386-LINUX:#define __INT_FAST16_MAX__ 32767
 // I386-LINUX:#define __INT_FAST16_TYPE__ short
+// I386-LINUX:#define __INT_FAST32_FMTd__ "d"
+// I386-LINUX:#define __INT_FAST32_FMTi__ "i"
 // I386-LINUX:#define __INT_FAST32_MAX__ 2147483647
 // I386-LINUX:#define __INT_FAST32_TYPE__ int
+// I386-LINUX:#define __INT_FAST64_FMTd__ "lld"
+// I386-LINUX:#define __INT_FAST64_FMTi__ "lli"
 // I386-LINUX:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // I386-LINUX:#define __INT_FAST64_TYPE__ long long int
+// I386-LINUX:#define __INT_FAST8_FMTd__ "hhd"
+// I386-LINUX:#define __INT_FAST8_FMTi__ "hhi"
 // I386-LINUX:#define __INT_FAST8_MAX__ 127
-// I386-LINUX:#define __INT_FAST8_TYPE__ char
+// I386-LINUX:#define __INT_FAST8_TYPE__ signed char
+// I386-LINUX:#define __INT_LEAST16_FMTd__ "hd"
+// I386-LINUX:#define __INT_LEAST16_FMTi__ "hi"
 // I386-LINUX:#define __INT_LEAST16_MAX__ 32767
 // I386-LINUX:#define __INT_LEAST16_TYPE__ short
+// I386-LINUX:#define __INT_LEAST32_FMTd__ "d"
+// I386-LINUX:#define __INT_LEAST32_FMTi__ "i"
 // I386-LINUX:#define __INT_LEAST32_MAX__ 2147483647
 // I386-LINUX:#define __INT_LEAST32_TYPE__ int
+// I386-LINUX:#define __INT_LEAST64_FMTd__ "lld"
+// I386-LINUX:#define __INT_LEAST64_FMTi__ "lli"
 // I386-LINUX:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // I386-LINUX:#define __INT_LEAST64_TYPE__ long long int
+// I386-LINUX:#define __INT_LEAST8_FMTd__ "hhd"
+// I386-LINUX:#define __INT_LEAST8_FMTi__ "hhi"
 // I386-LINUX:#define __INT_LEAST8_MAX__ 127
-// I386-LINUX:#define __INT_LEAST8_TYPE__ char
+// I386-LINUX:#define __INT_LEAST8_TYPE__ signed char
 // I386-LINUX:#define __INT_MAX__ 2147483647
 // I386-LINUX:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
 // I386-LINUX:#define __LDBL_DIG__ 18
@@ -1797,6 +2328,7 @@
 // I386-LINUX:#define __REGISTER_PREFIX__ 
 // I386-LINUX:#define __SCHAR_MAX__ 127
 // I386-LINUX:#define __SHRT_MAX__ 32767
+// I386-LINUX:#define __SIG_ATOMIC_MAX__ 2147483647
 // I386-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
 // I386-LINUX:#define __SIZEOF_DOUBLE__ 8
 // I386-LINUX:#define __SIZEOF_FLOAT__ 4
@@ -1813,8 +2345,8 @@
 // I386-LINUX:#define __SIZE_MAX__ 4294967295U
 // I386-LINUX:#define __SIZE_TYPE__ unsigned int
 // I386-LINUX:#define __SIZE_WIDTH__ 32
-// I386-LINUX:#define __UINT16_C_SUFFIX__ U
-// I386-LINUX:#define __UINT16_MAX__ 65535U
+// I386-LINUX:#define __UINT16_C_SUFFIX__ {{$}}
+// I386-LINUX:#define __UINT16_MAX__ 65535
 // I386-LINUX:#define __UINT16_TYPE__ unsigned short
 // I386-LINUX:#define __UINT32_C_SUFFIX__ U
 // I386-LINUX:#define __UINT32_MAX__ 4294967295U
@@ -1822,30 +2354,31 @@
 // I386-LINUX:#define __UINT64_C_SUFFIX__ ULL
 // I386-LINUX:#define __UINT64_MAX__ 18446744073709551615ULL
 // I386-LINUX:#define __UINT64_TYPE__ long long unsigned int
-// I386-LINUX:#define __UINT8_C_SUFFIX__ U
-// I386-LINUX:#define __UINT8_MAX__ 255U
+// I386-LINUX:#define __UINT8_C_SUFFIX__ {{$}}
+// I386-LINUX:#define __UINT8_MAX__ 255
 // I386-LINUX:#define __UINT8_TYPE__ unsigned char
+// I386-LINUX:#define __UINTMAX_C_SUFFIX__ ULL
 // I386-LINUX:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // I386-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
 // I386-LINUX:#define __UINTMAX_WIDTH__ 64
 // I386-LINUX:#define __UINTPTR_MAX__ 4294967295U
 // I386-LINUX:#define __UINTPTR_TYPE__ unsigned int
 // I386-LINUX:#define __UINTPTR_WIDTH__ 32
-// I386-LINUX:#define __UINT_FAST16_MAX__ 65535U
+// I386-LINUX:#define __UINT_FAST16_MAX__ 65535
 // I386-LINUX:#define __UINT_FAST16_TYPE__ unsigned short
 // I386-LINUX:#define __UINT_FAST32_MAX__ 4294967295U
 // I386-LINUX:#define __UINT_FAST32_TYPE__ unsigned int
 // I386-LINUX:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // I386-LINUX:#define __UINT_FAST64_TYPE__ long long unsigned int
-// I386-LINUX:#define __UINT_FAST8_MAX__ 255U
+// I386-LINUX:#define __UINT_FAST8_MAX__ 255
 // I386-LINUX:#define __UINT_FAST8_TYPE__ unsigned char
-// I386-LINUX:#define __UINT_LEAST16_MAX__ 65535U
+// I386-LINUX:#define __UINT_LEAST16_MAX__ 65535
 // I386-LINUX:#define __UINT_LEAST16_TYPE__ unsigned short
 // I386-LINUX:#define __UINT_LEAST32_MAX__ 4294967295U
 // I386-LINUX:#define __UINT_LEAST32_TYPE__ unsigned int
 // I386-LINUX:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // I386-LINUX:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// I386-LINUX:#define __UINT_LEAST8_MAX__ 255U
+// I386-LINUX:#define __UINT_LEAST8_MAX__ 255
 // I386-LINUX:#define __UINT_LEAST8_TYPE__ unsigned char
 // I386-LINUX:#define __USER_LABEL_PREFIX__
 // I386-LINUX:#define __WCHAR_MAX__ 2147483647
@@ -1893,37 +2426,69 @@
 // I386-NETBSD:#define __FLT_MIN_EXP__ (-125)
 // I386-NETBSD:#define __FLT_MIN__ 1.17549435e-38F
 // I386-NETBSD:#define __FLT_RADIX__ 2
+// I386-NETBSD:#define __INT16_C_SUFFIX__ {{$}}
+// I386-NETBSD:#define __INT16_FMTd__ "hd"
+// I386-NETBSD:#define __INT16_FMTi__ "hi"
 // I386-NETBSD:#define __INT16_MAX__ 32767
 // I386-NETBSD:#define __INT16_TYPE__ short
+// I386-NETBSD:#define __INT32_C_SUFFIX__ {{$}}
+// I386-NETBSD:#define __INT32_FMTd__ "d"
+// I386-NETBSD:#define __INT32_FMTi__ "i"
 // I386-NETBSD:#define __INT32_MAX__ 2147483647
 // I386-NETBSD:#define __INT32_TYPE__ int
 // I386-NETBSD:#define __INT64_C_SUFFIX__ LL
+// I386-NETBSD:#define __INT64_FMTd__ "lld"
+// I386-NETBSD:#define __INT64_FMTi__ "lli"
 // I386-NETBSD:#define __INT64_MAX__ 9223372036854775807LL
 // I386-NETBSD:#define __INT64_TYPE__ long long int
+// I386-NETBSD:#define __INT8_C_SUFFIX__ {{$}}
+// I386-NETBSD:#define __INT8_FMTd__ "hhd"
+// I386-NETBSD:#define __INT8_FMTi__ "hhi"
 // I386-NETBSD:#define __INT8_MAX__ 127
-// I386-NETBSD:#define __INT8_TYPE__ char
+// I386-NETBSD:#define __INT8_TYPE__ signed char
+// I386-NETBSD:#define __INTMAX_C_SUFFIX__ LL
+// I386-NETBSD:#define __INTMAX_FMTd__ "lld"
+// I386-NETBSD:#define __INTMAX_FMTi__ "lli"
 // I386-NETBSD:#define __INTMAX_MAX__ 9223372036854775807LL
 // I386-NETBSD:#define __INTMAX_TYPE__ long long int
 // I386-NETBSD:#define __INTMAX_WIDTH__ 64
+// I386-NETBSD:#define __INTPTR_FMTd__ "d"
+// I386-NETBSD:#define __INTPTR_FMTi__ "i"
 // I386-NETBSD:#define __INTPTR_MAX__ 2147483647
 // I386-NETBSD:#define __INTPTR_TYPE__ int
 // I386-NETBSD:#define __INTPTR_WIDTH__ 32
+// I386-NETBSD:#define __INT_FAST16_FMTd__ "hd"
+// I386-NETBSD:#define __INT_FAST16_FMTi__ "hi"
 // I386-NETBSD:#define __INT_FAST16_MAX__ 32767
 // I386-NETBSD:#define __INT_FAST16_TYPE__ short
+// I386-NETBSD:#define __INT_FAST32_FMTd__ "d"
+// I386-NETBSD:#define __INT_FAST32_FMTi__ "i"
 // I386-NETBSD:#define __INT_FAST32_MAX__ 2147483647
 // I386-NETBSD:#define __INT_FAST32_TYPE__ int
+// I386-NETBSD:#define __INT_FAST64_FMTd__ "lld"
+// I386-NETBSD:#define __INT_FAST64_FMTi__ "lli"
 // I386-NETBSD:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // I386-NETBSD:#define __INT_FAST64_TYPE__ long long int
+// I386-NETBSD:#define __INT_FAST8_FMTd__ "hhd"
+// I386-NETBSD:#define __INT_FAST8_FMTi__ "hhi"
 // I386-NETBSD:#define __INT_FAST8_MAX__ 127
-// I386-NETBSD:#define __INT_FAST8_TYPE__ char
+// I386-NETBSD:#define __INT_FAST8_TYPE__ signed char
+// I386-NETBSD:#define __INT_LEAST16_FMTd__ "hd"
+// I386-NETBSD:#define __INT_LEAST16_FMTi__ "hi"
 // I386-NETBSD:#define __INT_LEAST16_MAX__ 32767
 // I386-NETBSD:#define __INT_LEAST16_TYPE__ short
+// I386-NETBSD:#define __INT_LEAST32_FMTd__ "d"
+// I386-NETBSD:#define __INT_LEAST32_FMTi__ "i"
 // I386-NETBSD:#define __INT_LEAST32_MAX__ 2147483647
 // I386-NETBSD:#define __INT_LEAST32_TYPE__ int
+// I386-NETBSD:#define __INT_LEAST64_FMTd__ "lld"
+// I386-NETBSD:#define __INT_LEAST64_FMTi__ "lli"
 // I386-NETBSD:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // I386-NETBSD:#define __INT_LEAST64_TYPE__ long long int
+// I386-NETBSD:#define __INT_LEAST8_FMTd__ "hhd"
+// I386-NETBSD:#define __INT_LEAST8_FMTi__ "hhi"
 // I386-NETBSD:#define __INT_LEAST8_MAX__ 127
-// I386-NETBSD:#define __INT_LEAST8_TYPE__ char
+// I386-NETBSD:#define __INT_LEAST8_TYPE__ signed char
 // I386-NETBSD:#define __INT_MAX__ 2147483647
 // I386-NETBSD:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
 // I386-NETBSD:#define __LDBL_DIG__ 18
@@ -1949,6 +2514,7 @@
 // I386-NETBSD:#define __REGISTER_PREFIX__ 
 // I386-NETBSD:#define __SCHAR_MAX__ 127
 // I386-NETBSD:#define __SHRT_MAX__ 32767
+// I386-NETBSD:#define __SIG_ATOMIC_MAX__ 2147483647
 // I386-NETBSD:#define __SIG_ATOMIC_WIDTH__ 32
 // I386-NETBSD:#define __SIZEOF_DOUBLE__ 8
 // I386-NETBSD:#define __SIZEOF_FLOAT__ 4
@@ -1965,8 +2531,8 @@
 // I386-NETBSD:#define __SIZE_MAX__ 4294967295U
 // I386-NETBSD:#define __SIZE_TYPE__ unsigned int
 // I386-NETBSD:#define __SIZE_WIDTH__ 32
-// I386-NETBSD:#define __UINT16_C_SUFFIX__ U
-// I386-NETBSD:#define __UINT16_MAX__ 65535U
+// I386-NETBSD:#define __UINT16_C_SUFFIX__ {{$}}
+// I386-NETBSD:#define __UINT16_MAX__ 65535
 // I386-NETBSD:#define __UINT16_TYPE__ unsigned short
 // I386-NETBSD:#define __UINT32_C_SUFFIX__ U
 // I386-NETBSD:#define __UINT32_MAX__ 4294967295U
@@ -1974,30 +2540,31 @@
 // I386-NETBSD:#define __UINT64_C_SUFFIX__ ULL
 // I386-NETBSD:#define __UINT64_MAX__ 18446744073709551615ULL
 // I386-NETBSD:#define __UINT64_TYPE__ long long unsigned int
-// I386-NETBSD:#define __UINT8_C_SUFFIX__ U
-// I386-NETBSD:#define __UINT8_MAX__ 255U
+// I386-NETBSD:#define __UINT8_C_SUFFIX__ {{$}}
+// I386-NETBSD:#define __UINT8_MAX__ 255
 // I386-NETBSD:#define __UINT8_TYPE__ unsigned char
+// I386-NETBSD:#define __UINTMAX_C_SUFFIX__ ULL
 // I386-NETBSD:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // I386-NETBSD:#define __UINTMAX_TYPE__ long long unsigned int
 // I386-NETBSD:#define __UINTMAX_WIDTH__ 64
 // I386-NETBSD:#define __UINTPTR_MAX__ 4294967295U
 // I386-NETBSD:#define __UINTPTR_TYPE__ unsigned int
 // I386-NETBSD:#define __UINTPTR_WIDTH__ 32
-// I386-NETBSD:#define __UINT_FAST16_MAX__ 65535U
+// I386-NETBSD:#define __UINT_FAST16_MAX__ 65535
 // I386-NETBSD:#define __UINT_FAST16_TYPE__ unsigned short
 // I386-NETBSD:#define __UINT_FAST32_MAX__ 4294967295U
 // I386-NETBSD:#define __UINT_FAST32_TYPE__ unsigned int
 // I386-NETBSD:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // I386-NETBSD:#define __UINT_FAST64_TYPE__ long long unsigned int
-// I386-NETBSD:#define __UINT_FAST8_MAX__ 255U
+// I386-NETBSD:#define __UINT_FAST8_MAX__ 255
 // I386-NETBSD:#define __UINT_FAST8_TYPE__ unsigned char
-// I386-NETBSD:#define __UINT_LEAST16_MAX__ 65535U
+// I386-NETBSD:#define __UINT_LEAST16_MAX__ 65535
 // I386-NETBSD:#define __UINT_LEAST16_TYPE__ unsigned short
 // I386-NETBSD:#define __UINT_LEAST32_MAX__ 4294967295U
 // I386-NETBSD:#define __UINT_LEAST32_TYPE__ unsigned int
 // I386-NETBSD:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // I386-NETBSD:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// I386-NETBSD:#define __UINT_LEAST8_MAX__ 255U
+// I386-NETBSD:#define __UINT_LEAST8_MAX__ 255
 // I386-NETBSD:#define __UINT_LEAST8_TYPE__ unsigned char
 // I386-NETBSD:#define __USER_LABEL_PREFIX__
 // I386-NETBSD:#define __WCHAR_MAX__ 2147483647
@@ -2065,37 +2632,69 @@
 // MIPS32BE:#define __FLT_MIN_EXP__ (-125)
 // MIPS32BE:#define __FLT_MIN__ 1.17549435e-38F
 // MIPS32BE:#define __FLT_RADIX__ 2
+// MIPS32BE:#define __INT16_C_SUFFIX__ {{$}}
+// MIPS32BE:#define __INT16_FMTd__ "hd"
+// MIPS32BE:#define __INT16_FMTi__ "hi"
 // MIPS32BE:#define __INT16_MAX__ 32767
 // MIPS32BE:#define __INT16_TYPE__ short
+// MIPS32BE:#define __INT32_C_SUFFIX__ {{$}}
+// MIPS32BE:#define __INT32_FMTd__ "d"
+// MIPS32BE:#define __INT32_FMTi__ "i"
 // MIPS32BE:#define __INT32_MAX__ 2147483647
 // MIPS32BE:#define __INT32_TYPE__ int
 // MIPS32BE:#define __INT64_C_SUFFIX__ LL
+// MIPS32BE:#define __INT64_FMTd__ "lld"
+// MIPS32BE:#define __INT64_FMTi__ "lli"
 // MIPS32BE:#define __INT64_MAX__ 9223372036854775807LL
 // MIPS32BE:#define __INT64_TYPE__ long long int
+// MIPS32BE:#define __INT8_C_SUFFIX__ {{$}}
+// MIPS32BE:#define __INT8_FMTd__ "hhd"
+// MIPS32BE:#define __INT8_FMTi__ "hhi"
 // MIPS32BE:#define __INT8_MAX__ 127
-// MIPS32BE:#define __INT8_TYPE__ char
+// MIPS32BE:#define __INT8_TYPE__ signed char
+// MIPS32BE:#define __INTMAX_C_SUFFIX__ LL
+// MIPS32BE:#define __INTMAX_FMTd__ "lld"
+// MIPS32BE:#define __INTMAX_FMTi__ "lli"
 // MIPS32BE:#define __INTMAX_MAX__ 9223372036854775807LL
 // MIPS32BE:#define __INTMAX_TYPE__ long long int
 // MIPS32BE:#define __INTMAX_WIDTH__ 64
+// MIPS32BE:#define __INTPTR_FMTd__ "ld"
+// MIPS32BE:#define __INTPTR_FMTi__ "li"
 // MIPS32BE:#define __INTPTR_MAX__ 2147483647L
 // MIPS32BE:#define __INTPTR_TYPE__ long int
 // MIPS32BE:#define __INTPTR_WIDTH__ 32
+// MIPS32BE:#define __INT_FAST16_FMTd__ "hd"
+// MIPS32BE:#define __INT_FAST16_FMTi__ "hi"
 // MIPS32BE:#define __INT_FAST16_MAX__ 32767
 // MIPS32BE:#define __INT_FAST16_TYPE__ short
+// MIPS32BE:#define __INT_FAST32_FMTd__ "d"
+// MIPS32BE:#define __INT_FAST32_FMTi__ "i"
 // MIPS32BE:#define __INT_FAST32_MAX__ 2147483647
 // MIPS32BE:#define __INT_FAST32_TYPE__ int
+// MIPS32BE:#define __INT_FAST64_FMTd__ "lld"
+// MIPS32BE:#define __INT_FAST64_FMTi__ "lli"
 // MIPS32BE:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // MIPS32BE:#define __INT_FAST64_TYPE__ long long int
+// MIPS32BE:#define __INT_FAST8_FMTd__ "hhd"
+// MIPS32BE:#define __INT_FAST8_FMTi__ "hhi"
 // MIPS32BE:#define __INT_FAST8_MAX__ 127
-// MIPS32BE:#define __INT_FAST8_TYPE__ char
+// MIPS32BE:#define __INT_FAST8_TYPE__ signed char
+// MIPS32BE:#define __INT_LEAST16_FMTd__ "hd"
+// MIPS32BE:#define __INT_LEAST16_FMTi__ "hi"
 // MIPS32BE:#define __INT_LEAST16_MAX__ 32767
 // MIPS32BE:#define __INT_LEAST16_TYPE__ short
+// MIPS32BE:#define __INT_LEAST32_FMTd__ "d"
+// MIPS32BE:#define __INT_LEAST32_FMTi__ "i"
 // MIPS32BE:#define __INT_LEAST32_MAX__ 2147483647
 // MIPS32BE:#define __INT_LEAST32_TYPE__ int
+// MIPS32BE:#define __INT_LEAST64_FMTd__ "lld"
+// MIPS32BE:#define __INT_LEAST64_FMTi__ "lli"
 // MIPS32BE:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // MIPS32BE:#define __INT_LEAST64_TYPE__ long long int
+// MIPS32BE:#define __INT_LEAST8_FMTd__ "hhd"
+// MIPS32BE:#define __INT_LEAST8_FMTi__ "hhi"
 // MIPS32BE:#define __INT_LEAST8_MAX__ 127
-// MIPS32BE:#define __INT_LEAST8_TYPE__ char
+// MIPS32BE:#define __INT_LEAST8_TYPE__ signed char
 // MIPS32BE:#define __INT_MAX__ 2147483647
 // MIPS32BE:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // MIPS32BE:#define __LDBL_DIG__ 15
@@ -2122,6 +2721,7 @@
 // MIPS32BE:#define __REGISTER_PREFIX__ 
 // MIPS32BE:#define __SCHAR_MAX__ 127
 // MIPS32BE:#define __SHRT_MAX__ 32767
+// MIPS32BE:#define __SIG_ATOMIC_MAX__ 2147483647
 // MIPS32BE:#define __SIG_ATOMIC_WIDTH__ 32
 // MIPS32BE:#define __SIZEOF_DOUBLE__ 8
 // MIPS32BE:#define __SIZEOF_FLOAT__ 4
@@ -2139,10 +2739,10 @@
 // MIPS32BE:#define __SIZE_TYPE__ unsigned int
 // MIPS32BE:#define __SIZE_WIDTH__ 32
 // MIPS32BE:#define __STDC_HOSTED__ 0
-// MIPS32BE:#define __STDC_VERSION__ 199901L
+// MIPS32BE:#define __STDC_VERSION__ 201112L
 // MIPS32BE:#define __STDC__ 1
-// MIPS32BE:#define __UINT16_C_SUFFIX__ U
-// MIPS32BE:#define __UINT16_MAX__ 65535U
+// MIPS32BE:#define __UINT16_C_SUFFIX__ {{$}}
+// MIPS32BE:#define __UINT16_MAX__ 65535
 // MIPS32BE:#define __UINT16_TYPE__ unsigned short
 // MIPS32BE:#define __UINT32_C_SUFFIX__ U
 // MIPS32BE:#define __UINT32_MAX__ 4294967295U
@@ -2150,30 +2750,31 @@
 // MIPS32BE:#define __UINT64_C_SUFFIX__ ULL
 // MIPS32BE:#define __UINT64_MAX__ 18446744073709551615ULL
 // MIPS32BE:#define __UINT64_TYPE__ long long unsigned int
-// MIPS32BE:#define __UINT8_C_SUFFIX__ U
-// MIPS32BE:#define __UINT8_MAX__ 255U
+// MIPS32BE:#define __UINT8_C_SUFFIX__ {{$}}
+// MIPS32BE:#define __UINT8_MAX__ 255
 // MIPS32BE:#define __UINT8_TYPE__ unsigned char
+// MIPS32BE:#define __UINTMAX_C_SUFFIX__ ULL
 // MIPS32BE:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // MIPS32BE:#define __UINTMAX_TYPE__ long long unsigned int
 // MIPS32BE:#define __UINTMAX_WIDTH__ 64
 // MIPS32BE:#define __UINTPTR_MAX__ 4294967295U
-// MIPS32BE:#define __UINTPTR_TYPE__ unsigned int
+// MIPS32BE:#define __UINTPTR_TYPE__ long unsigned int
 // MIPS32BE:#define __UINTPTR_WIDTH__ 32
-// MIPS32BE:#define __UINT_FAST16_MAX__ 65535U
+// MIPS32BE:#define __UINT_FAST16_MAX__ 65535
 // MIPS32BE:#define __UINT_FAST16_TYPE__ unsigned short
 // MIPS32BE:#define __UINT_FAST32_MAX__ 4294967295U
 // MIPS32BE:#define __UINT_FAST32_TYPE__ unsigned int
 // MIPS32BE:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // MIPS32BE:#define __UINT_FAST64_TYPE__ long long unsigned int
-// MIPS32BE:#define __UINT_FAST8_MAX__ 255U
+// MIPS32BE:#define __UINT_FAST8_MAX__ 255
 // MIPS32BE:#define __UINT_FAST8_TYPE__ unsigned char
-// MIPS32BE:#define __UINT_LEAST16_MAX__ 65535U
+// MIPS32BE:#define __UINT_LEAST16_MAX__ 65535
 // MIPS32BE:#define __UINT_LEAST16_TYPE__ unsigned short
 // MIPS32BE:#define __UINT_LEAST32_MAX__ 4294967295U
 // MIPS32BE:#define __UINT_LEAST32_TYPE__ unsigned int
 // MIPS32BE:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // MIPS32BE:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// MIPS32BE:#define __UINT_LEAST8_MAX__ 255U
+// MIPS32BE:#define __UINT_LEAST8_MAX__ 255
 // MIPS32BE:#define __UINT_LEAST8_TYPE__ unsigned char
 // MIPS32BE:#define __USER_LABEL_PREFIX__ _
 // MIPS32BE:#define __WCHAR_MAX__ 2147483647
@@ -2238,37 +2839,69 @@
 // MIPS32EL:#define __FLT_MIN_EXP__ (-125)
 // MIPS32EL:#define __FLT_MIN__ 1.17549435e-38F
 // MIPS32EL:#define __FLT_RADIX__ 2
+// MIPS32EL:#define __INT16_C_SUFFIX__ {{$}}
+// MIPS32EL:#define __INT16_FMTd__ "hd"
+// MIPS32EL:#define __INT16_FMTi__ "hi"
 // MIPS32EL:#define __INT16_MAX__ 32767
 // MIPS32EL:#define __INT16_TYPE__ short
+// MIPS32EL:#define __INT32_C_SUFFIX__ {{$}}
+// MIPS32EL:#define __INT32_FMTd__ "d"
+// MIPS32EL:#define __INT32_FMTi__ "i"
 // MIPS32EL:#define __INT32_MAX__ 2147483647
 // MIPS32EL:#define __INT32_TYPE__ int
 // MIPS32EL:#define __INT64_C_SUFFIX__ LL
+// MIPS32EL:#define __INT64_FMTd__ "lld"
+// MIPS32EL:#define __INT64_FMTi__ "lli"
 // MIPS32EL:#define __INT64_MAX__ 9223372036854775807LL
 // MIPS32EL:#define __INT64_TYPE__ long long int
+// MIPS32EL:#define __INT8_C_SUFFIX__ {{$}}
+// MIPS32EL:#define __INT8_FMTd__ "hhd"
+// MIPS32EL:#define __INT8_FMTi__ "hhi"
 // MIPS32EL:#define __INT8_MAX__ 127
-// MIPS32EL:#define __INT8_TYPE__ char
+// MIPS32EL:#define __INT8_TYPE__ signed char
+// MIPS32EL:#define __INTMAX_C_SUFFIX__ LL
+// MIPS32EL:#define __INTMAX_FMTd__ "lld"
+// MIPS32EL:#define __INTMAX_FMTi__ "lli"
 // MIPS32EL:#define __INTMAX_MAX__ 9223372036854775807LL
 // MIPS32EL:#define __INTMAX_TYPE__ long long int
 // MIPS32EL:#define __INTMAX_WIDTH__ 64
+// MIPS32EL:#define __INTPTR_FMTd__ "ld"
+// MIPS32EL:#define __INTPTR_FMTi__ "li"
 // MIPS32EL:#define __INTPTR_MAX__ 2147483647L
 // MIPS32EL:#define __INTPTR_TYPE__ long int
 // MIPS32EL:#define __INTPTR_WIDTH__ 32
+// MIPS32EL:#define __INT_FAST16_FMTd__ "hd"
+// MIPS32EL:#define __INT_FAST16_FMTi__ "hi"
 // MIPS32EL:#define __INT_FAST16_MAX__ 32767
 // MIPS32EL:#define __INT_FAST16_TYPE__ short
+// MIPS32EL:#define __INT_FAST32_FMTd__ "d"
+// MIPS32EL:#define __INT_FAST32_FMTi__ "i"
 // MIPS32EL:#define __INT_FAST32_MAX__ 2147483647
 // MIPS32EL:#define __INT_FAST32_TYPE__ int
+// MIPS32EL:#define __INT_FAST64_FMTd__ "lld"
+// MIPS32EL:#define __INT_FAST64_FMTi__ "lli"
 // MIPS32EL:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // MIPS32EL:#define __INT_FAST64_TYPE__ long long int
+// MIPS32EL:#define __INT_FAST8_FMTd__ "hhd"
+// MIPS32EL:#define __INT_FAST8_FMTi__ "hhi"
 // MIPS32EL:#define __INT_FAST8_MAX__ 127
-// MIPS32EL:#define __INT_FAST8_TYPE__ char
+// MIPS32EL:#define __INT_FAST8_TYPE__ signed char
+// MIPS32EL:#define __INT_LEAST16_FMTd__ "hd"
+// MIPS32EL:#define __INT_LEAST16_FMTi__ "hi"
 // MIPS32EL:#define __INT_LEAST16_MAX__ 32767
 // MIPS32EL:#define __INT_LEAST16_TYPE__ short
+// MIPS32EL:#define __INT_LEAST32_FMTd__ "d"
+// MIPS32EL:#define __INT_LEAST32_FMTi__ "i"
 // MIPS32EL:#define __INT_LEAST32_MAX__ 2147483647
 // MIPS32EL:#define __INT_LEAST32_TYPE__ int
+// MIPS32EL:#define __INT_LEAST64_FMTd__ "lld"
+// MIPS32EL:#define __INT_LEAST64_FMTi__ "lli"
 // MIPS32EL:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // MIPS32EL:#define __INT_LEAST64_TYPE__ long long int
+// MIPS32EL:#define __INT_LEAST8_FMTd__ "hhd"
+// MIPS32EL:#define __INT_LEAST8_FMTi__ "hhi"
 // MIPS32EL:#define __INT_LEAST8_MAX__ 127
-// MIPS32EL:#define __INT_LEAST8_TYPE__ char
+// MIPS32EL:#define __INT_LEAST8_TYPE__ signed char
 // MIPS32EL:#define __INT_MAX__ 2147483647
 // MIPS32EL:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // MIPS32EL:#define __LDBL_DIG__ 15
@@ -2296,6 +2929,7 @@
 // MIPS32EL:#define __REGISTER_PREFIX__ 
 // MIPS32EL:#define __SCHAR_MAX__ 127
 // MIPS32EL:#define __SHRT_MAX__ 32767
+// MIPS32EL:#define __SIG_ATOMIC_MAX__ 2147483647
 // MIPS32EL:#define __SIG_ATOMIC_WIDTH__ 32
 // MIPS32EL:#define __SIZEOF_DOUBLE__ 8
 // MIPS32EL:#define __SIZEOF_FLOAT__ 4
@@ -2312,8 +2946,8 @@
 // MIPS32EL:#define __SIZE_MAX__ 4294967295U
 // MIPS32EL:#define __SIZE_TYPE__ unsigned int
 // MIPS32EL:#define __SIZE_WIDTH__ 32
-// MIPS32EL:#define __UINT16_C_SUFFIX__ U
-// MIPS32EL:#define __UINT16_MAX__ 65535U
+// MIPS32EL:#define __UINT16_C_SUFFIX__ {{$}}
+// MIPS32EL:#define __UINT16_MAX__ 65535
 // MIPS32EL:#define __UINT16_TYPE__ unsigned short
 // MIPS32EL:#define __UINT32_C_SUFFIX__ U
 // MIPS32EL:#define __UINT32_MAX__ 4294967295U
@@ -2321,30 +2955,31 @@
 // MIPS32EL:#define __UINT64_C_SUFFIX__ ULL
 // MIPS32EL:#define __UINT64_MAX__ 18446744073709551615ULL
 // MIPS32EL:#define __UINT64_TYPE__ long long unsigned int
-// MIPS32EL:#define __UINT8_C_SUFFIX__ U
-// MIPS32EL:#define __UINT8_MAX__ 255U
+// MIPS32EL:#define __UINT8_C_SUFFIX__ {{$}}
+// MIPS32EL:#define __UINT8_MAX__ 255
 // MIPS32EL:#define __UINT8_TYPE__ unsigned char
+// MIPS32EL:#define __UINTMAX_C_SUFFIX__ ULL
 // MIPS32EL:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // MIPS32EL:#define __UINTMAX_TYPE__ long long unsigned int
 // MIPS32EL:#define __UINTMAX_WIDTH__ 64
 // MIPS32EL:#define __UINTPTR_MAX__ 4294967295U
-// MIPS32EL:#define __UINTPTR_TYPE__ unsigned int
+// MIPS32EL:#define __UINTPTR_TYPE__ long unsigned int
 // MIPS32EL:#define __UINTPTR_WIDTH__ 32
-// MIPS32EL:#define __UINT_FAST16_MAX__ 65535U
+// MIPS32EL:#define __UINT_FAST16_MAX__ 65535
 // MIPS32EL:#define __UINT_FAST16_TYPE__ unsigned short
 // MIPS32EL:#define __UINT_FAST32_MAX__ 4294967295U
 // MIPS32EL:#define __UINT_FAST32_TYPE__ unsigned int
 // MIPS32EL:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // MIPS32EL:#define __UINT_FAST64_TYPE__ long long unsigned int
-// MIPS32EL:#define __UINT_FAST8_MAX__ 255U
+// MIPS32EL:#define __UINT_FAST8_MAX__ 255
 // MIPS32EL:#define __UINT_FAST8_TYPE__ unsigned char
-// MIPS32EL:#define __UINT_LEAST16_MAX__ 65535U
+// MIPS32EL:#define __UINT_LEAST16_MAX__ 65535
 // MIPS32EL:#define __UINT_LEAST16_TYPE__ unsigned short
 // MIPS32EL:#define __UINT_LEAST32_MAX__ 4294967295U
 // MIPS32EL:#define __UINT_LEAST32_TYPE__ unsigned int
 // MIPS32EL:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // MIPS32EL:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// MIPS32EL:#define __UINT_LEAST8_MAX__ 255U
+// MIPS32EL:#define __UINT_LEAST8_MAX__ 255
 // MIPS32EL:#define __UINT_LEAST8_TYPE__ unsigned char
 // MIPS32EL:#define __USER_LABEL_PREFIX__ _
 // MIPS32EL:#define __WCHAR_MAX__ 2147483647
@@ -2410,37 +3045,69 @@
 // MIPS64BE:#define __FLT_MIN_EXP__ (-125)
 // MIPS64BE:#define __FLT_MIN__ 1.17549435e-38F
 // MIPS64BE:#define __FLT_RADIX__ 2
+// MIPS64BE:#define __INT16_C_SUFFIX__ {{$}}
+// MIPS64BE:#define __INT16_FMTd__ "hd"
+// MIPS64BE:#define __INT16_FMTi__ "hi"
 // MIPS64BE:#define __INT16_MAX__ 32767
 // MIPS64BE:#define __INT16_TYPE__ short
+// MIPS64BE:#define __INT32_C_SUFFIX__ {{$}}
+// MIPS64BE:#define __INT32_FMTd__ "d"
+// MIPS64BE:#define __INT32_FMTi__ "i"
 // MIPS64BE:#define __INT32_MAX__ 2147483647
 // MIPS64BE:#define __INT32_TYPE__ int
 // MIPS64BE:#define __INT64_C_SUFFIX__ LL
+// MIPS64BE:#define __INT64_FMTd__ "lld"
+// MIPS64BE:#define __INT64_FMTi__ "lli"
 // MIPS64BE:#define __INT64_MAX__ 9223372036854775807L
 // MIPS64BE:#define __INT64_TYPE__ long long int
+// MIPS64BE:#define __INT8_C_SUFFIX__ {{$}}
+// MIPS64BE:#define __INT8_FMTd__ "hhd"
+// MIPS64BE:#define __INT8_FMTi__ "hhi"
 // MIPS64BE:#define __INT8_MAX__ 127
-// MIPS64BE:#define __INT8_TYPE__ char
+// MIPS64BE:#define __INT8_TYPE__ signed char
+// MIPS64BE:#define __INTMAX_C_SUFFIX__ LL
+// MIPS64BE:#define __INTMAX_FMTd__ "lld"
+// MIPS64BE:#define __INTMAX_FMTi__ "lli"
 // MIPS64BE:#define __INTMAX_MAX__ 9223372036854775807LL
 // MIPS64BE:#define __INTMAX_TYPE__ long long int
 // MIPS64BE:#define __INTMAX_WIDTH__ 64
+// MIPS64BE:#define __INTPTR_FMTd__ "ld"
+// MIPS64BE:#define __INTPTR_FMTi__ "li"
 // MIPS64BE:#define __INTPTR_MAX__ 9223372036854775807L
 // MIPS64BE:#define __INTPTR_TYPE__ long int
 // MIPS64BE:#define __INTPTR_WIDTH__ 64
+// MIPS64BE:#define __INT_FAST16_FMTd__ "hd"
+// MIPS64BE:#define __INT_FAST16_FMTi__ "hi"
 // MIPS64BE:#define __INT_FAST16_MAX__ 32767
 // MIPS64BE:#define __INT_FAST16_TYPE__ short
+// MIPS64BE:#define __INT_FAST32_FMTd__ "d"
+// MIPS64BE:#define __INT_FAST32_FMTi__ "i"
 // MIPS64BE:#define __INT_FAST32_MAX__ 2147483647
 // MIPS64BE:#define __INT_FAST32_TYPE__ int
+// MIPS64BE:#define __INT_FAST64_FMTd__ "ld"
+// MIPS64BE:#define __INT_FAST64_FMTi__ "li"
 // MIPS64BE:#define __INT_FAST64_MAX__ 9223372036854775807L
 // MIPS64BE:#define __INT_FAST64_TYPE__ long int
+// MIPS64BE:#define __INT_FAST8_FMTd__ "hhd"
+// MIPS64BE:#define __INT_FAST8_FMTi__ "hhi"
 // MIPS64BE:#define __INT_FAST8_MAX__ 127
-// MIPS64BE:#define __INT_FAST8_TYPE__ char
+// MIPS64BE:#define __INT_FAST8_TYPE__ signed char
+// MIPS64BE:#define __INT_LEAST16_FMTd__ "hd"
+// MIPS64BE:#define __INT_LEAST16_FMTi__ "hi"
 // MIPS64BE:#define __INT_LEAST16_MAX__ 32767
 // MIPS64BE:#define __INT_LEAST16_TYPE__ short
+// MIPS64BE:#define __INT_LEAST32_FMTd__ "d"
+// MIPS64BE:#define __INT_LEAST32_FMTi__ "i"
 // MIPS64BE:#define __INT_LEAST32_MAX__ 2147483647
 // MIPS64BE:#define __INT_LEAST32_TYPE__ int
+// MIPS64BE:#define __INT_LEAST64_FMTd__ "ld"
+// MIPS64BE:#define __INT_LEAST64_FMTi__ "li"
 // MIPS64BE:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // MIPS64BE:#define __INT_LEAST64_TYPE__ long int
+// MIPS64BE:#define __INT_LEAST8_FMTd__ "hhd"
+// MIPS64BE:#define __INT_LEAST8_FMTi__ "hhi"
 // MIPS64BE:#define __INT_LEAST8_MAX__ 127
-// MIPS64BE:#define __INT_LEAST8_TYPE__ char
+// MIPS64BE:#define __INT_LEAST8_TYPE__ signed char
 // MIPS64BE:#define __INT_MAX__ 2147483647
 // MIPS64BE:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
 // MIPS64BE:#define __LDBL_DIG__ 33
@@ -2467,6 +3134,7 @@
 // MIPS64BE:#define __REGISTER_PREFIX__ 
 // MIPS64BE:#define __SCHAR_MAX__ 127
 // MIPS64BE:#define __SHRT_MAX__ 32767
+// MIPS64BE:#define __SIG_ATOMIC_MAX__ 2147483647
 // MIPS64BE:#define __SIG_ATOMIC_WIDTH__ 32
 // MIPS64BE:#define __SIZEOF_DOUBLE__ 8
 // MIPS64BE:#define __SIZEOF_FLOAT__ 4
@@ -2483,39 +3151,40 @@
 // MIPS64BE:#define __SIZE_MAX__ 18446744073709551615UL
 // MIPS64BE:#define __SIZE_TYPE__ long unsigned int
 // MIPS64BE:#define __SIZE_WIDTH__ 64
-// MIPS64BE:#define __UINT16_C_SUFFIX__ U
-// MIPS64BE:#define __UINT16_MAX__ 65535U
+// MIPS64BE:#define __UINT16_C_SUFFIX__ {{$}}
+// MIPS64BE:#define __UINT16_MAX__ 65535
 // MIPS64BE:#define __UINT16_TYPE__ unsigned short
 // MIPS64BE:#define __UINT32_C_SUFFIX__ U
 // MIPS64BE:#define __UINT32_MAX__ 4294967295U
 // MIPS64BE:#define __UINT32_TYPE__ unsigned int
-// MIPS64BE:#define __UINT64_C_SUFFIX__ UL
-// MIPS64BE:#define __UINT64_MAX__ 18446744073709551615UL
-// MIPS64BE:#define __UINT64_TYPE__ long unsigned int
-// MIPS64BE:#define __UINT8_C_SUFFIX__ U
-// MIPS64BE:#define __UINT8_MAX__ 255U
+// MIPS64BE:#define __UINT64_C_SUFFIX__ ULL
+// MIPS64BE:#define __UINT64_MAX__ 18446744073709551615ULL
+// MIPS64BE:#define __UINT64_TYPE__ long long unsigned int
+// MIPS64BE:#define __UINT8_C_SUFFIX__ {{$}}
+// MIPS64BE:#define __UINT8_MAX__ 255
 // MIPS64BE:#define __UINT8_TYPE__ unsigned char
+// MIPS64BE:#define __UINTMAX_C_SUFFIX__ ULL
 // MIPS64BE:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // MIPS64BE:#define __UINTMAX_TYPE__ long long unsigned int
 // MIPS64BE:#define __UINTMAX_WIDTH__ 64
 // MIPS64BE:#define __UINTPTR_MAX__ 18446744073709551615UL
 // MIPS64BE:#define __UINTPTR_TYPE__ long unsigned int
 // MIPS64BE:#define __UINTPTR_WIDTH__ 64
-// MIPS64BE:#define __UINT_FAST16_MAX__ 65535U
+// MIPS64BE:#define __UINT_FAST16_MAX__ 65535
 // MIPS64BE:#define __UINT_FAST16_TYPE__ unsigned short
 // MIPS64BE:#define __UINT_FAST32_MAX__ 4294967295U
 // MIPS64BE:#define __UINT_FAST32_TYPE__ unsigned int
 // MIPS64BE:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // MIPS64BE:#define __UINT_FAST64_TYPE__ long unsigned int
-// MIPS64BE:#define __UINT_FAST8_MAX__ 255U
+// MIPS64BE:#define __UINT_FAST8_MAX__ 255
 // MIPS64BE:#define __UINT_FAST8_TYPE__ unsigned char
-// MIPS64BE:#define __UINT_LEAST16_MAX__ 65535U
+// MIPS64BE:#define __UINT_LEAST16_MAX__ 65535
 // MIPS64BE:#define __UINT_LEAST16_TYPE__ unsigned short
 // MIPS64BE:#define __UINT_LEAST32_MAX__ 4294967295U
 // MIPS64BE:#define __UINT_LEAST32_TYPE__ unsigned int
 // MIPS64BE:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // MIPS64BE:#define __UINT_LEAST64_TYPE__ long unsigned int
-// MIPS64BE:#define __UINT_LEAST8_MAX__ 255U
+// MIPS64BE:#define __UINT_LEAST8_MAX__ 255
 // MIPS64BE:#define __UINT_LEAST8_TYPE__ unsigned char
 // MIPS64BE:#define __USER_LABEL_PREFIX__ _
 // MIPS64BE:#define __WCHAR_MAX__ 2147483647
@@ -2582,37 +3251,69 @@
 // MIPS64EL:#define __FLT_MIN_EXP__ (-125)
 // MIPS64EL:#define __FLT_MIN__ 1.17549435e-38F
 // MIPS64EL:#define __FLT_RADIX__ 2
+// MIPS64EL:#define __INT16_C_SUFFIX__ {{$}}
+// MIPS64EL:#define __INT16_FMTd__ "hd"
+// MIPS64EL:#define __INT16_FMTi__ "hi"
 // MIPS64EL:#define __INT16_MAX__ 32767
 // MIPS64EL:#define __INT16_TYPE__ short
+// MIPS64EL:#define __INT32_C_SUFFIX__ {{$}}
+// MIPS64EL:#define __INT32_FMTd__ "d"
+// MIPS64EL:#define __INT32_FMTi__ "i"
 // MIPS64EL:#define __INT32_MAX__ 2147483647
 // MIPS64EL:#define __INT32_TYPE__ int
 // MIPS64EL:#define __INT64_C_SUFFIX__ LL
+// MIPS64EL:#define __INT64_FMTd__ "lld"
+// MIPS64EL:#define __INT64_FMTi__ "lli"
 // MIPS64EL:#define __INT64_MAX__ 9223372036854775807L
 // MIPS64EL:#define __INT64_TYPE__ long long int
+// MIPS64EL:#define __INT8_C_SUFFIX__ {{$}}
+// MIPS64EL:#define __INT8_FMTd__ "hhd"
+// MIPS64EL:#define __INT8_FMTi__ "hhi"
 // MIPS64EL:#define __INT8_MAX__ 127
-// MIPS64EL:#define __INT8_TYPE__ char
+// MIPS64EL:#define __INT8_TYPE__ signed char
+// MIPS64EL:#define __INTMAX_C_SUFFIX__ LL
+// MIPS64EL:#define __INTMAX_FMTd__ "lld"
+// MIPS64EL:#define __INTMAX_FMTi__ "lli"
 // MIPS64EL:#define __INTMAX_MAX__ 9223372036854775807LL
 // MIPS64EL:#define __INTMAX_TYPE__ long long int
 // MIPS64EL:#define __INTMAX_WIDTH__ 64
+// MIPS64EL:#define __INTPTR_FMTd__ "ld"
+// MIPS64EL:#define __INTPTR_FMTi__ "li"
 // MIPS64EL:#define __INTPTR_MAX__ 9223372036854775807L
 // MIPS64EL:#define __INTPTR_TYPE__ long int
 // MIPS64EL:#define __INTPTR_WIDTH__ 64
+// MIPS64EL:#define __INT_FAST16_FMTd__ "hd"
+// MIPS64EL:#define __INT_FAST16_FMTi__ "hi"
 // MIPS64EL:#define __INT_FAST16_MAX__ 32767
 // MIPS64EL:#define __INT_FAST16_TYPE__ short
+// MIPS64EL:#define __INT_FAST32_FMTd__ "d"
+// MIPS64EL:#define __INT_FAST32_FMTi__ "i"
 // MIPS64EL:#define __INT_FAST32_MAX__ 2147483647
 // MIPS64EL:#define __INT_FAST32_TYPE__ int
+// MIPS64EL:#define __INT_FAST64_FMTd__ "ld"
+// MIPS64EL:#define __INT_FAST64_FMTi__ "li"
 // MIPS64EL:#define __INT_FAST64_MAX__ 9223372036854775807L
 // MIPS64EL:#define __INT_FAST64_TYPE__ long int
+// MIPS64EL:#define __INT_FAST8_FMTd__ "hhd"
+// MIPS64EL:#define __INT_FAST8_FMTi__ "hhi"
 // MIPS64EL:#define __INT_FAST8_MAX__ 127
-// MIPS64EL:#define __INT_FAST8_TYPE__ char
+// MIPS64EL:#define __INT_FAST8_TYPE__ signed char
+// MIPS64EL:#define __INT_LEAST16_FMTd__ "hd"
+// MIPS64EL:#define __INT_LEAST16_FMTi__ "hi"
 // MIPS64EL:#define __INT_LEAST16_MAX__ 32767
 // MIPS64EL:#define __INT_LEAST16_TYPE__ short
+// MIPS64EL:#define __INT_LEAST32_FMTd__ "d"
+// MIPS64EL:#define __INT_LEAST32_FMTi__ "i"
 // MIPS64EL:#define __INT_LEAST32_MAX__ 2147483647
 // MIPS64EL:#define __INT_LEAST32_TYPE__ int
+// MIPS64EL:#define __INT_LEAST64_FMTd__ "ld"
+// MIPS64EL:#define __INT_LEAST64_FMTi__ "li"
 // MIPS64EL:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // MIPS64EL:#define __INT_LEAST64_TYPE__ long int
+// MIPS64EL:#define __INT_LEAST8_FMTd__ "hhd"
+// MIPS64EL:#define __INT_LEAST8_FMTi__ "hhi"
 // MIPS64EL:#define __INT_LEAST8_MAX__ 127
-// MIPS64EL:#define __INT_LEAST8_TYPE__ char
+// MIPS64EL:#define __INT_LEAST8_TYPE__ signed char
 // MIPS64EL:#define __INT_MAX__ 2147483647
 // MIPS64EL:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
 // MIPS64EL:#define __LDBL_DIG__ 33
@@ -2640,6 +3341,7 @@
 // MIPS64EL:#define __REGISTER_PREFIX__ 
 // MIPS64EL:#define __SCHAR_MAX__ 127
 // MIPS64EL:#define __SHRT_MAX__ 32767
+// MIPS64EL:#define __SIG_ATOMIC_MAX__ 2147483647
 // MIPS64EL:#define __SIG_ATOMIC_WIDTH__ 32
 // MIPS64EL:#define __SIZEOF_DOUBLE__ 8
 // MIPS64EL:#define __SIZEOF_FLOAT__ 4
@@ -2656,39 +3358,40 @@
 // MIPS64EL:#define __SIZE_MAX__ 18446744073709551615UL
 // MIPS64EL:#define __SIZE_TYPE__ long unsigned int
 // MIPS64EL:#define __SIZE_WIDTH__ 64
-// MIPS64EL:#define __UINT16_C_SUFFIX__ U
-// MIPS64EL:#define __UINT16_MAX__ 65535U
+// MIPS64EL:#define __UINT16_C_SUFFIX__ {{$}}
+// MIPS64EL:#define __UINT16_MAX__ 65535
 // MIPS64EL:#define __UINT16_TYPE__ unsigned short
 // MIPS64EL:#define __UINT32_C_SUFFIX__ U
 // MIPS64EL:#define __UINT32_MAX__ 4294967295U
 // MIPS64EL:#define __UINT32_TYPE__ unsigned int
-// MIPS64EL:#define __UINT64_C_SUFFIX__ UL
-// MIPS64EL:#define __UINT64_MAX__ 18446744073709551615UL
-// MIPS64EL:#define __UINT64_TYPE__ long unsigned int
-// MIPS64EL:#define __UINT8_C_SUFFIX__ U
-// MIPS64EL:#define __UINT8_MAX__ 255U
+// MIPS64EL:#define __UINT64_C_SUFFIX__ ULL
+// MIPS64EL:#define __UINT64_MAX__ 18446744073709551615ULL
+// MIPS64EL:#define __UINT64_TYPE__ long long unsigned int
+// MIPS64EL:#define __UINT8_C_SUFFIX__ {{$}}
+// MIPS64EL:#define __UINT8_MAX__ 255
 // MIPS64EL:#define __UINT8_TYPE__ unsigned char
+// MIPS64EL:#define __UINTMAX_C_SUFFIX__ ULL
 // MIPS64EL:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // MIPS64EL:#define __UINTMAX_TYPE__ long long unsigned int
 // MIPS64EL:#define __UINTMAX_WIDTH__ 64
 // MIPS64EL:#define __UINTPTR_MAX__ 18446744073709551615UL
 // MIPS64EL:#define __UINTPTR_TYPE__ long unsigned int
 // MIPS64EL:#define __UINTPTR_WIDTH__ 64
-// MIPS64EL:#define __UINT_FAST16_MAX__ 65535U
+// MIPS64EL:#define __UINT_FAST16_MAX__ 65535
 // MIPS64EL:#define __UINT_FAST16_TYPE__ unsigned short
 // MIPS64EL:#define __UINT_FAST32_MAX__ 4294967295U
 // MIPS64EL:#define __UINT_FAST32_TYPE__ unsigned int
 // MIPS64EL:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // MIPS64EL:#define __UINT_FAST64_TYPE__ long unsigned int
-// MIPS64EL:#define __UINT_FAST8_MAX__ 255U
+// MIPS64EL:#define __UINT_FAST8_MAX__ 255
 // MIPS64EL:#define __UINT_FAST8_TYPE__ unsigned char
-// MIPS64EL:#define __UINT_LEAST16_MAX__ 65535U
+// MIPS64EL:#define __UINT_LEAST16_MAX__ 65535
 // MIPS64EL:#define __UINT_LEAST16_TYPE__ unsigned short
 // MIPS64EL:#define __UINT_LEAST32_MAX__ 4294967295U
 // MIPS64EL:#define __UINT_LEAST32_TYPE__ unsigned int
 // MIPS64EL:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // MIPS64EL:#define __UINT_LEAST64_TYPE__ long unsigned int
-// MIPS64EL:#define __UINT_LEAST8_MAX__ 255U
+// MIPS64EL:#define __UINT_LEAST8_MAX__ 255
 // MIPS64EL:#define __UINT_LEAST8_TYPE__ unsigned char
 // MIPS64EL:#define __USER_LABEL_PREFIX__ _
 // MIPS64EL:#define __WCHAR_MAX__ 2147483647
@@ -2911,38 +3614,69 @@
 // MSP430:#define __FLT_MIN_EXP__ (-125)
 // MSP430:#define __FLT_MIN__ 1.17549435e-38F
 // MSP430:#define __FLT_RADIX__ 2
+// MSP430:#define __INT16_C_SUFFIX__ {{$}}
+// MSP430:#define __INT16_FMTd__ "hd"
+// MSP430:#define __INT16_FMTi__ "hi"
 // MSP430:#define __INT16_MAX__ 32767
 // MSP430:#define __INT16_TYPE__ short
 // MSP430:#define __INT32_C_SUFFIX__ L
+// MSP430:#define __INT32_FMTd__ "ld"
+// MSP430:#define __INT32_FMTi__ "li"
 // MSP430:#define __INT32_MAX__ 2147483647L
 // MSP430:#define __INT32_TYPE__ long int
 // MSP430:#define __INT64_C_SUFFIX__ LL
+// MSP430:#define __INT64_FMTd__ "lld"
+// MSP430:#define __INT64_FMTi__ "lli"
 // MSP430:#define __INT64_MAX__ 9223372036854775807LL
 // MSP430:#define __INT64_TYPE__ long long int
+// MSP430:#define __INT8_C_SUFFIX__ {{$}}
+// MSP430:#define __INT8_FMTd__ "hhd"
+// MSP430:#define __INT8_FMTi__ "hhi"
 // MSP430:#define __INT8_MAX__ 127
-// MSP430:#define __INT8_TYPE__ char
+// MSP430:#define __INT8_TYPE__ signed char
+// MSP430:#define __INTMAX_C_SUFFIX__ LL
+// MSP430:#define __INTMAX_FMTd__ "lld"
+// MSP430:#define __INTMAX_FMTi__ "lli"
 // MSP430:#define __INTMAX_MAX__ 9223372036854775807LL
 // MSP430:#define __INTMAX_TYPE__ long long int
 // MSP430:#define __INTMAX_WIDTH__ 64
+// MSP430:#define __INTPTR_FMTd__ "d"
+// MSP430:#define __INTPTR_FMTi__ "i"
 // MSP430:#define __INTPTR_MAX__ 32767
 // MSP430:#define __INTPTR_TYPE__ int
 // MSP430:#define __INTPTR_WIDTH__ 16
+// MSP430:#define __INT_FAST16_FMTd__ "hd"
+// MSP430:#define __INT_FAST16_FMTi__ "hi"
 // MSP430:#define __INT_FAST16_MAX__ 32767
 // MSP430:#define __INT_FAST16_TYPE__ short
+// MSP430:#define __INT_FAST32_FMTd__ "ld"
+// MSP430:#define __INT_FAST32_FMTi__ "li"
 // MSP430:#define __INT_FAST32_MAX__ 2147483647L
 // MSP430:#define __INT_FAST32_TYPE__ long int
+// MSP430:#define __INT_FAST64_FMTd__ "lld"
+// MSP430:#define __INT_FAST64_FMTi__ "lli"
 // MSP430:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // MSP430:#define __INT_FAST64_TYPE__ long long int
+// MSP430:#define __INT_FAST8_FMTd__ "hhd"
+// MSP430:#define __INT_FAST8_FMTi__ "hhi"
 // MSP430:#define __INT_FAST8_MAX__ 127
-// MSP430:#define __INT_FAST8_TYPE__ char
+// MSP430:#define __INT_FAST8_TYPE__ signed char
+// MSP430:#define __INT_LEAST16_FMTd__ "hd"
+// MSP430:#define __INT_LEAST16_FMTi__ "hi"
 // MSP430:#define __INT_LEAST16_MAX__ 32767
 // MSP430:#define __INT_LEAST16_TYPE__ short
+// MSP430:#define __INT_LEAST32_FMTd__ "ld"
+// MSP430:#define __INT_LEAST32_FMTi__ "li"
 // MSP430:#define __INT_LEAST32_MAX__ 2147483647L
 // MSP430:#define __INT_LEAST32_TYPE__ long int
+// MSP430:#define __INT_LEAST64_FMTd__ "lld"
+// MSP430:#define __INT_LEAST64_FMTi__ "lli"
 // MSP430:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // MSP430:#define __INT_LEAST64_TYPE__ long long int
+// MSP430:#define __INT_LEAST8_FMTd__ "hhd"
+// MSP430:#define __INT_LEAST8_FMTi__ "hhi"
 // MSP430:#define __INT_LEAST8_MAX__ 127
-// MSP430:#define __INT_LEAST8_TYPE__ char
+// MSP430:#define __INT_LEAST8_TYPE__ signed char
 // MSP430:#define __INT_MAX__ 32767
 // MSP430:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // MSP430:#define __LDBL_DIG__ 15
@@ -2967,6 +3701,7 @@
 // MSP430:#define __PTRDIFF_WIDTH__ 16 
 // MSP430:#define __SCHAR_MAX__ 127
 // MSP430:#define __SHRT_MAX__ 32767
+// MSP430:#define __SIG_ATOMIC_MAX__ 2147483647
 // MSP430:#define __SIG_ATOMIC_WIDTH__ 32
 // MSP430:#define __SIZEOF_DOUBLE__ 8
 // MSP430:#define __SIZEOF_FLOAT__ 4
@@ -2980,11 +3715,11 @@
 // MSP430:#define __SIZEOF_SIZE_T__ 2
 // MSP430:#define __SIZEOF_WCHAR_T__ 2
 // MSP430:#define __SIZEOF_WINT_T__ 2
-// MSP430:#define __SIZE_MAX__ 65535U
+// MSP430:#define __SIZE_MAX__ 65535
 // MSP430:#define __SIZE_TYPE__ unsigned int
 // MSP430:#define __SIZE_WIDTH__ 16
 // MSP430:#define __UINT16_C_SUFFIX__ U
-// MSP430:#define __UINT16_MAX__ 65535U
+// MSP430:#define __UINT16_MAX__ 65535
 // MSP430:#define __UINT16_TYPE__ unsigned short
 // MSP430:#define __UINT32_C_SUFFIX__ UL
 // MSP430:#define __UINT32_MAX__ 4294967295UL
@@ -2992,30 +3727,31 @@
 // MSP430:#define __UINT64_C_SUFFIX__ ULL
 // MSP430:#define __UINT64_MAX__ 18446744073709551615ULL
 // MSP430:#define __UINT64_TYPE__ long long unsigned int
-// MSP430:#define __UINT8_C_SUFFIX__ U
-// MSP430:#define __UINT8_MAX__ 255U
+// MSP430:#define __UINT8_C_SUFFIX__ {{$}}
+// MSP430:#define __UINT8_MAX__ 255
 // MSP430:#define __UINT8_TYPE__ unsigned char
+// MSP430:#define __UINTMAX_C_SUFFIX__ ULL
 // MSP430:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // MSP430:#define __UINTMAX_TYPE__ long long unsigned int
 // MSP430:#define __UINTMAX_WIDTH__ 64
-// MSP430:#define __UINTPTR_MAX__ 65535U
-// MSP430:#define __UINTPTR_TYPE__ unsigned short
+// MSP430:#define __UINTPTR_MAX__ 65535
+// MSP430:#define __UINTPTR_TYPE__ unsigned int
 // MSP430:#define __UINTPTR_WIDTH__ 16
-// MSP430:#define __UINT_FAST16_MAX__ 65535U
+// MSP430:#define __UINT_FAST16_MAX__ 65535
 // MSP430:#define __UINT_FAST16_TYPE__ unsigned short
 // MSP430:#define __UINT_FAST32_MAX__ 4294967295UL
 // MSP430:#define __UINT_FAST32_TYPE__ long unsigned int
 // MSP430:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // MSP430:#define __UINT_FAST64_TYPE__ long long unsigned int
-// MSP430:#define __UINT_FAST8_MAX__ 255U
+// MSP430:#define __UINT_FAST8_MAX__ 255
 // MSP430:#define __UINT_FAST8_TYPE__ unsigned char
-// MSP430:#define __UINT_LEAST16_MAX__ 65535U
+// MSP430:#define __UINT_LEAST16_MAX__ 65535
 // MSP430:#define __UINT_LEAST16_TYPE__ unsigned short
 // MSP430:#define __UINT_LEAST32_MAX__ 4294967295UL
 // MSP430:#define __UINT_LEAST32_TYPE__ long unsigned int
 // MSP430:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // MSP430:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// MSP430:#define __UINT_LEAST8_MAX__ 255U
+// MSP430:#define __UINT_LEAST8_MAX__ 255
 // MSP430:#define __UINT_LEAST8_TYPE__ unsigned char
 // MSP430:#define __USER_LABEL_PREFIX__ _
 // MSP430:#define __WCHAR_MAX__ 32767
@@ -3063,37 +3799,69 @@
 // NVPTX32:#define __FLT_MIN_EXP__ (-125)
 // NVPTX32:#define __FLT_MIN__ 1.17549435e-38F
 // NVPTX32:#define __FLT_RADIX__ 2
+// NVPTX32:#define __INT16_C_SUFFIX__ {{$}}
+// NVPTX32:#define __INT16_FMTd__ "hd"
+// NVPTX32:#define __INT16_FMTi__ "hi"
 // NVPTX32:#define __INT16_MAX__ 32767
 // NVPTX32:#define __INT16_TYPE__ short
+// NVPTX32:#define __INT32_C_SUFFIX__ {{$}}
+// NVPTX32:#define __INT32_FMTd__ "d"
+// NVPTX32:#define __INT32_FMTi__ "i"
 // NVPTX32:#define __INT32_MAX__ 2147483647
 // NVPTX32:#define __INT32_TYPE__ int
 // NVPTX32:#define __INT64_C_SUFFIX__ LL
+// NVPTX32:#define __INT64_FMTd__ "lld"
+// NVPTX32:#define __INT64_FMTi__ "lli"
 // NVPTX32:#define __INT64_MAX__ 9223372036854775807L
 // NVPTX32:#define __INT64_TYPE__ long long int
+// NVPTX32:#define __INT8_C_SUFFIX__ {{$}}
+// NVPTX32:#define __INT8_FMTd__ "hhd"
+// NVPTX32:#define __INT8_FMTi__ "hhi"
 // NVPTX32:#define __INT8_MAX__ 127
-// NVPTX32:#define __INT8_TYPE__ char
+// NVPTX32:#define __INT8_TYPE__ signed char
+// NVPTX32:#define __INTMAX_C_SUFFIX__ LL
+// NVPTX32:#define __INTMAX_FMTd__ "lld"
+// NVPTX32:#define __INTMAX_FMTi__ "lli"
 // NVPTX32:#define __INTMAX_MAX__ 9223372036854775807LL
 // NVPTX32:#define __INTMAX_TYPE__ long long int
 // NVPTX32:#define __INTMAX_WIDTH__ 64
-// NVPTX32:#define __INTPTR_MAX__ 4294967295U
-// NVPTX32:#define __INTPTR_TYPE__ unsigned int
+// NVPTX32:#define __INTPTR_FMTd__ "d"
+// NVPTX32:#define __INTPTR_FMTi__ "i"
+// NVPTX32:#define __INTPTR_MAX__ 2147483647
+// NVPTX32:#define __INTPTR_TYPE__ int
 // NVPTX32:#define __INTPTR_WIDTH__ 32
+// NVPTX32:#define __INT_FAST16_FMTd__ "hd"
+// NVPTX32:#define __INT_FAST16_FMTi__ "hi"
 // NVPTX32:#define __INT_FAST16_MAX__ 32767
 // NVPTX32:#define __INT_FAST16_TYPE__ short
+// NVPTX32:#define __INT_FAST32_FMTd__ "d"
+// NVPTX32:#define __INT_FAST32_FMTi__ "i"
 // NVPTX32:#define __INT_FAST32_MAX__ 2147483647
 // NVPTX32:#define __INT_FAST32_TYPE__ int
+// NVPTX32:#define __INT_FAST64_FMTd__ "ld"
+// NVPTX32:#define __INT_FAST64_FMTi__ "li"
 // NVPTX32:#define __INT_FAST64_MAX__ 9223372036854775807L
 // NVPTX32:#define __INT_FAST64_TYPE__ long int
+// NVPTX32:#define __INT_FAST8_FMTd__ "hhd"
+// NVPTX32:#define __INT_FAST8_FMTi__ "hhi"
 // NVPTX32:#define __INT_FAST8_MAX__ 127
-// NVPTX32:#define __INT_FAST8_TYPE__ char
+// NVPTX32:#define __INT_FAST8_TYPE__ signed char
+// NVPTX32:#define __INT_LEAST16_FMTd__ "hd"
+// NVPTX32:#define __INT_LEAST16_FMTi__ "hi"
 // NVPTX32:#define __INT_LEAST16_MAX__ 32767
 // NVPTX32:#define __INT_LEAST16_TYPE__ short
+// NVPTX32:#define __INT_LEAST32_FMTd__ "d"
+// NVPTX32:#define __INT_LEAST32_FMTi__ "i"
 // NVPTX32:#define __INT_LEAST32_MAX__ 2147483647
 // NVPTX32:#define __INT_LEAST32_TYPE__ int
+// NVPTX32:#define __INT_LEAST64_FMTd__ "ld"
+// NVPTX32:#define __INT_LEAST64_FMTi__ "li"
 // NVPTX32:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // NVPTX32:#define __INT_LEAST64_TYPE__ long int
+// NVPTX32:#define __INT_LEAST8_FMTd__ "hhd"
+// NVPTX32:#define __INT_LEAST8_FMTi__ "hhi"
 // NVPTX32:#define __INT_LEAST8_MAX__ 127
-// NVPTX32:#define __INT_LEAST8_TYPE__ char
+// NVPTX32:#define __INT_LEAST8_TYPE__ signed char
 // NVPTX32:#define __INT_MAX__ 2147483647
 // NVPTX32:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // NVPTX32:#define __LDBL_DIG__ 15
@@ -3120,6 +3888,7 @@
 // NVPTX32:#define __PTX__ 1
 // NVPTX32:#define __SCHAR_MAX__ 127
 // NVPTX32:#define __SHRT_MAX__ 32767
+// NVPTX32:#define __SIG_ATOMIC_MAX__ 2147483647
 // NVPTX32:#define __SIG_ATOMIC_WIDTH__ 32
 // NVPTX32:#define __SIZEOF_DOUBLE__ 8
 // NVPTX32:#define __SIZEOF_FLOAT__ 4
@@ -3136,39 +3905,40 @@
 // NVPTX32:#define __SIZE_MAX__ 4294967295U
 // NVPTX32:#define __SIZE_TYPE__ unsigned int
 // NVPTX32:#define __SIZE_WIDTH__ 32
-// NVPTX32:#define __UINT16_C_SUFFIX__ U
-// NVPTX32:#define __UINT16_MAX__ 65535U
+// NVPTX32:#define __UINT16_C_SUFFIX__ {{$}}
+// NVPTX32:#define __UINT16_MAX__ 65535
 // NVPTX32:#define __UINT16_TYPE__ unsigned short
 // NVPTX32:#define __UINT32_C_SUFFIX__ U
 // NVPTX32:#define __UINT32_MAX__ 4294967295U
 // NVPTX32:#define __UINT32_TYPE__ unsigned int
-// NVPTX32:#define __UINT64_C_SUFFIX__ UL
-// NVPTX32:#define __UINT64_MAX__ 18446744073709551615UL
-// NVPTX32:#define __UINT64_TYPE__ long unsigned int
-// NVPTX32:#define __UINT8_C_SUFFIX__ U
-// NVPTX32:#define __UINT8_MAX__ 255U
+// NVPTX32:#define __UINT64_C_SUFFIX__ ULL
+// NVPTX32:#define __UINT64_MAX__ 18446744073709551615ULL
+// NVPTX32:#define __UINT64_TYPE__ long long unsigned int
+// NVPTX32:#define __UINT8_C_SUFFIX__ {{$}}
+// NVPTX32:#define __UINT8_MAX__ 255
 // NVPTX32:#define __UINT8_TYPE__ unsigned char
+// NVPTX32:#define __UINTMAX_C_SUFFIX__ ULL
 // NVPTX32:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // NVPTX32:#define __UINTMAX_TYPE__ long long unsigned int
 // NVPTX32:#define __UINTMAX_WIDTH__ 64
 // NVPTX32:#define __UINTPTR_MAX__ 4294967295U
 // NVPTX32:#define __UINTPTR_TYPE__ unsigned int
 // NVPTX32:#define __UINTPTR_WIDTH__ 32
-// NVPTX32:#define __UINT_FAST16_MAX__ 65535U
+// NVPTX32:#define __UINT_FAST16_MAX__ 65535
 // NVPTX32:#define __UINT_FAST16_TYPE__ unsigned short
 // NVPTX32:#define __UINT_FAST32_MAX__ 4294967295U
 // NVPTX32:#define __UINT_FAST32_TYPE__ unsigned int
 // NVPTX32:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // NVPTX32:#define __UINT_FAST64_TYPE__ long unsigned int
-// NVPTX32:#define __UINT_FAST8_MAX__ 255U
+// NVPTX32:#define __UINT_FAST8_MAX__ 255
 // NVPTX32:#define __UINT_FAST8_TYPE__ unsigned char
-// NVPTX32:#define __UINT_LEAST16_MAX__ 65535U
+// NVPTX32:#define __UINT_LEAST16_MAX__ 65535
 // NVPTX32:#define __UINT_LEAST16_TYPE__ unsigned short
 // NVPTX32:#define __UINT_LEAST32_MAX__ 4294967295U
 // NVPTX32:#define __UINT_LEAST32_TYPE__ unsigned int
 // NVPTX32:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // NVPTX32:#define __UINT_LEAST64_TYPE__ long unsigned int
-// NVPTX32:#define __UINT_LEAST8_MAX__ 255U
+// NVPTX32:#define __UINT_LEAST8_MAX__ 255
 // NVPTX32:#define __UINT_LEAST8_TYPE__ unsigned char
 // NVPTX32:#define __USER_LABEL_PREFIX__ _
 // NVPTX32:#define __WCHAR_MAX__ 2147483647
@@ -3215,37 +3985,69 @@
 // NVPTX64:#define __FLT_MIN_EXP__ (-125)
 // NVPTX64:#define __FLT_MIN__ 1.17549435e-38F
 // NVPTX64:#define __FLT_RADIX__ 2
+// NVPTX64:#define __INT16_C_SUFFIX__ {{$}}
+// NVPTX64:#define __INT16_FMTd__ "hd"
+// NVPTX64:#define __INT16_FMTi__ "hi"
 // NVPTX64:#define __INT16_MAX__ 32767
 // NVPTX64:#define __INT16_TYPE__ short
+// NVPTX64:#define __INT32_C_SUFFIX__ {{$}}
+// NVPTX64:#define __INT32_FMTd__ "d"
+// NVPTX64:#define __INT32_FMTi__ "i"
 // NVPTX64:#define __INT32_MAX__ 2147483647
 // NVPTX64:#define __INT32_TYPE__ int
 // NVPTX64:#define __INT64_C_SUFFIX__ LL
+// NVPTX64:#define __INT64_FMTd__ "lld"
+// NVPTX64:#define __INT64_FMTi__ "lli"
 // NVPTX64:#define __INT64_MAX__ 9223372036854775807L
 // NVPTX64:#define __INT64_TYPE__ long long int
+// NVPTX64:#define __INT8_C_SUFFIX__ {{$}}
+// NVPTX64:#define __INT8_FMTd__ "hhd"
+// NVPTX64:#define __INT8_FMTi__ "hhi"
 // NVPTX64:#define __INT8_MAX__ 127
-// NVPTX64:#define __INT8_TYPE__ char
+// NVPTX64:#define __INT8_TYPE__ signed char
+// NVPTX64:#define __INTMAX_C_SUFFIX__ LL
+// NVPTX64:#define __INTMAX_FMTd__ "lld"
+// NVPTX64:#define __INTMAX_FMTi__ "lli"
 // NVPTX64:#define __INTMAX_MAX__ 9223372036854775807LL
 // NVPTX64:#define __INTMAX_TYPE__ long long int
 // NVPTX64:#define __INTMAX_WIDTH__ 64
-// NVPTX64:#define __INTPTR_MAX__ 18446744073709551615ULL
-// NVPTX64:#define __INTPTR_TYPE__ long long unsigned int
+// NVPTX64:#define __INTPTR_FMTd__ "lld"
+// NVPTX64:#define __INTPTR_FMTi__ "lli"
+// NVPTX64:#define __INTPTR_MAX__ 9223372036854775807LL
+// NVPTX64:#define __INTPTR_TYPE__ long long int
 // NVPTX64:#define __INTPTR_WIDTH__ 64
+// NVPTX64:#define __INT_FAST16_FMTd__ "hd"
+// NVPTX64:#define __INT_FAST16_FMTi__ "hi"
 // NVPTX64:#define __INT_FAST16_MAX__ 32767
 // NVPTX64:#define __INT_FAST16_TYPE__ short
+// NVPTX64:#define __INT_FAST32_FMTd__ "d"
+// NVPTX64:#define __INT_FAST32_FMTi__ "i"
 // NVPTX64:#define __INT_FAST32_MAX__ 2147483647
 // NVPTX64:#define __INT_FAST32_TYPE__ int
+// NVPTX64:#define __INT_FAST64_FMTd__ "ld"
+// NVPTX64:#define __INT_FAST64_FMTi__ "li"
 // NVPTX64:#define __INT_FAST64_MAX__ 9223372036854775807L
 // NVPTX64:#define __INT_FAST64_TYPE__ long int
+// NVPTX64:#define __INT_FAST8_FMTd__ "hhd"
+// NVPTX64:#define __INT_FAST8_FMTi__ "hhi"
 // NVPTX64:#define __INT_FAST8_MAX__ 127
-// NVPTX64:#define __INT_FAST8_TYPE__ char
+// NVPTX64:#define __INT_FAST8_TYPE__ signed char
+// NVPTX64:#define __INT_LEAST16_FMTd__ "hd"
+// NVPTX64:#define __INT_LEAST16_FMTi__ "hi"
 // NVPTX64:#define __INT_LEAST16_MAX__ 32767
 // NVPTX64:#define __INT_LEAST16_TYPE__ short
+// NVPTX64:#define __INT_LEAST32_FMTd__ "d"
+// NVPTX64:#define __INT_LEAST32_FMTi__ "i"
 // NVPTX64:#define __INT_LEAST32_MAX__ 2147483647
 // NVPTX64:#define __INT_LEAST32_TYPE__ int
+// NVPTX64:#define __INT_LEAST64_FMTd__ "ld"
+// NVPTX64:#define __INT_LEAST64_FMTi__ "li"
 // NVPTX64:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // NVPTX64:#define __INT_LEAST64_TYPE__ long int
+// NVPTX64:#define __INT_LEAST8_FMTd__ "hhd"
+// NVPTX64:#define __INT_LEAST8_FMTi__ "hhi"
 // NVPTX64:#define __INT_LEAST8_MAX__ 127
-// NVPTX64:#define __INT_LEAST8_TYPE__ char
+// NVPTX64:#define __INT_LEAST8_TYPE__ signed char
 // NVPTX64:#define __INT_MAX__ 2147483647
 // NVPTX64:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // NVPTX64:#define __LDBL_DIG__ 15
@@ -3272,6 +4074,7 @@
 // NVPTX64:#define __PTX__ 1
 // NVPTX64:#define __SCHAR_MAX__ 127
 // NVPTX64:#define __SHRT_MAX__ 32767
+// NVPTX64:#define __SIG_ATOMIC_MAX__ 2147483647
 // NVPTX64:#define __SIG_ATOMIC_WIDTH__ 32
 // NVPTX64:#define __SIZEOF_DOUBLE__ 8
 // NVPTX64:#define __SIZEOF_FLOAT__ 4
@@ -3288,39 +4091,40 @@
 // NVPTX64:#define __SIZE_MAX__ 18446744073709551615UL
 // NVPTX64:#define __SIZE_TYPE__ long long unsigned int
 // NVPTX64:#define __SIZE_WIDTH__ 64
-// NVPTX64:#define __UINT16_C_SUFFIX__ U
-// NVPTX64:#define __UINT16_MAX__ 65535U
+// NVPTX64:#define __UINT16_C_SUFFIX__ {{$}}
+// NVPTX64:#define __UINT16_MAX__ 65535
 // NVPTX64:#define __UINT16_TYPE__ unsigned short
 // NVPTX64:#define __UINT32_C_SUFFIX__ U
 // NVPTX64:#define __UINT32_MAX__ 4294967295U
 // NVPTX64:#define __UINT32_TYPE__ unsigned int
-// NVPTX64:#define __UINT64_C_SUFFIX__ UL
-// NVPTX64:#define __UINT64_MAX__ 18446744073709551615UL
-// NVPTX64:#define __UINT64_TYPE__ long unsigned int
-// NVPTX64:#define __UINT8_C_SUFFIX__ U
-// NVPTX64:#define __UINT8_MAX__ 255U
+// NVPTX64:#define __UINT64_C_SUFFIX__ ULL
+// NVPTX64:#define __UINT64_MAX__ 18446744073709551615ULL
+// NVPTX64:#define __UINT64_TYPE__ long long unsigned int
+// NVPTX64:#define __UINT8_C_SUFFIX__ {{$}}
+// NVPTX64:#define __UINT8_MAX__ 255
 // NVPTX64:#define __UINT8_TYPE__ unsigned char
+// NVPTX64:#define __UINTMAX_C_SUFFIX__ ULL
 // NVPTX64:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // NVPTX64:#define __UINTMAX_TYPE__ long long unsigned int
 // NVPTX64:#define __UINTMAX_WIDTH__ 64
-// NVPTX64:#define __UINTPTR_MAX__ 18446744073709551615UL
-// NVPTX64:#define __UINTPTR_TYPE__ long unsigned int
+// NVPTX64:#define __UINTPTR_MAX__ 18446744073709551615ULL
+// NVPTX64:#define __UINTPTR_TYPE__ long long unsigned int
 // NVPTX64:#define __UINTPTR_WIDTH__ 64
-// NVPTX64:#define __UINT_FAST16_MAX__ 65535U
+// NVPTX64:#define __UINT_FAST16_MAX__ 65535
 // NVPTX64:#define __UINT_FAST16_TYPE__ unsigned short
 // NVPTX64:#define __UINT_FAST32_MAX__ 4294967295U
 // NVPTX64:#define __UINT_FAST32_TYPE__ unsigned int
 // NVPTX64:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // NVPTX64:#define __UINT_FAST64_TYPE__ long unsigned int
-// NVPTX64:#define __UINT_FAST8_MAX__ 255U
+// NVPTX64:#define __UINT_FAST8_MAX__ 255
 // NVPTX64:#define __UINT_FAST8_TYPE__ unsigned char
-// NVPTX64:#define __UINT_LEAST16_MAX__ 65535U
+// NVPTX64:#define __UINT_LEAST16_MAX__ 65535
 // NVPTX64:#define __UINT_LEAST16_TYPE__ unsigned short
 // NVPTX64:#define __UINT_LEAST32_MAX__ 4294967295U
 // NVPTX64:#define __UINT_LEAST32_TYPE__ unsigned int
 // NVPTX64:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // NVPTX64:#define __UINT_LEAST64_TYPE__ long unsigned int
-// NVPTX64:#define __UINT_LEAST8_MAX__ 255U
+// NVPTX64:#define __UINT_LEAST8_MAX__ 255
 // NVPTX64:#define __UINT_LEAST8_TYPE__ unsigned char
 // NVPTX64:#define __USER_LABEL_PREFIX__ _
 // NVPTX64:#define __WCHAR_MAX__ 2147483647
@@ -3371,37 +4175,69 @@
 // PPC603E:#define __FLT_MIN_EXP__ (-125)
 // PPC603E:#define __FLT_MIN__ 1.17549435e-38F
 // PPC603E:#define __FLT_RADIX__ 2
+// PPC603E:#define __INT16_C_SUFFIX__ {{$}}
+// PPC603E:#define __INT16_FMTd__ "hd"
+// PPC603E:#define __INT16_FMTi__ "hi"
 // PPC603E:#define __INT16_MAX__ 32767
 // PPC603E:#define __INT16_TYPE__ short
+// PPC603E:#define __INT32_C_SUFFIX__ {{$}}
+// PPC603E:#define __INT32_FMTd__ "d"
+// PPC603E:#define __INT32_FMTi__ "i"
 // PPC603E:#define __INT32_MAX__ 2147483647
 // PPC603E:#define __INT32_TYPE__ int
 // PPC603E:#define __INT64_C_SUFFIX__ LL
+// PPC603E:#define __INT64_FMTd__ "lld"
+// PPC603E:#define __INT64_FMTi__ "lli"
 // PPC603E:#define __INT64_MAX__ 9223372036854775807LL
 // PPC603E:#define __INT64_TYPE__ long long int
+// PPC603E:#define __INT8_C_SUFFIX__ {{$}}
+// PPC603E:#define __INT8_FMTd__ "hhd"
+// PPC603E:#define __INT8_FMTi__ "hhi"
 // PPC603E:#define __INT8_MAX__ 127
-// PPC603E:#define __INT8_TYPE__ char
+// PPC603E:#define __INT8_TYPE__ signed char
+// PPC603E:#define __INTMAX_C_SUFFIX__ LL
+// PPC603E:#define __INTMAX_FMTd__ "lld"
+// PPC603E:#define __INTMAX_FMTi__ "lli"
 // PPC603E:#define __INTMAX_MAX__ 9223372036854775807LL
 // PPC603E:#define __INTMAX_TYPE__ long long int
 // PPC603E:#define __INTMAX_WIDTH__ 64
+// PPC603E:#define __INTPTR_FMTd__ "ld"
+// PPC603E:#define __INTPTR_FMTi__ "li"
 // PPC603E:#define __INTPTR_MAX__ 2147483647L
 // PPC603E:#define __INTPTR_TYPE__ long int
 // PPC603E:#define __INTPTR_WIDTH__ 32
+// PPC603E:#define __INT_FAST16_FMTd__ "hd"
+// PPC603E:#define __INT_FAST16_FMTi__ "hi"
 // PPC603E:#define __INT_FAST16_MAX__ 32767
 // PPC603E:#define __INT_FAST16_TYPE__ short
+// PPC603E:#define __INT_FAST32_FMTd__ "d"
+// PPC603E:#define __INT_FAST32_FMTi__ "i"
 // PPC603E:#define __INT_FAST32_MAX__ 2147483647
 // PPC603E:#define __INT_FAST32_TYPE__ int
+// PPC603E:#define __INT_FAST64_FMTd__ "lld"
+// PPC603E:#define __INT_FAST64_FMTi__ "lli"
 // PPC603E:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // PPC603E:#define __INT_FAST64_TYPE__ long long int
+// PPC603E:#define __INT_FAST8_FMTd__ "hhd"
+// PPC603E:#define __INT_FAST8_FMTi__ "hhi"
 // PPC603E:#define __INT_FAST8_MAX__ 127
-// PPC603E:#define __INT_FAST8_TYPE__ char
+// PPC603E:#define __INT_FAST8_TYPE__ signed char
+// PPC603E:#define __INT_LEAST16_FMTd__ "hd"
+// PPC603E:#define __INT_LEAST16_FMTi__ "hi"
 // PPC603E:#define __INT_LEAST16_MAX__ 32767
 // PPC603E:#define __INT_LEAST16_TYPE__ short
+// PPC603E:#define __INT_LEAST32_FMTd__ "d"
+// PPC603E:#define __INT_LEAST32_FMTi__ "i"
 // PPC603E:#define __INT_LEAST32_MAX__ 2147483647
 // PPC603E:#define __INT_LEAST32_TYPE__ int
+// PPC603E:#define __INT_LEAST64_FMTd__ "lld"
+// PPC603E:#define __INT_LEAST64_FMTi__ "lli"
 // PPC603E:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // PPC603E:#define __INT_LEAST64_TYPE__ long long int
+// PPC603E:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC603E:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC603E:#define __INT_LEAST8_MAX__ 127
-// PPC603E:#define __INT_LEAST8_TYPE__ char
+// PPC603E:#define __INT_LEAST8_TYPE__ signed char
 // PPC603E:#define __INT_MAX__ 2147483647
 // PPC603E:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC603E:#define __LDBL_DIG__ 31
@@ -3429,6 +4265,7 @@
 // PPC603E:#define __REGISTER_PREFIX__
 // PPC603E:#define __SCHAR_MAX__ 127
 // PPC603E:#define __SHRT_MAX__ 32767
+// PPC603E:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC603E:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC603E:#define __SIZEOF_DOUBLE__ 8
 // PPC603E:#define __SIZEOF_FLOAT__ 4
@@ -3445,8 +4282,8 @@
 // PPC603E:#define __SIZE_MAX__ 4294967295U
 // PPC603E:#define __SIZE_TYPE__ long unsigned int
 // PPC603E:#define __SIZE_WIDTH__ 32
-// PPC603E:#define __UINT16_C_SUFFIX__ U
-// PPC603E:#define __UINT16_MAX__ 65535U
+// PPC603E:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC603E:#define __UINT16_MAX__ 65535
 // PPC603E:#define __UINT16_TYPE__ unsigned short
 // PPC603E:#define __UINT32_C_SUFFIX__ U
 // PPC603E:#define __UINT32_MAX__ 4294967295U
@@ -3454,30 +4291,31 @@
 // PPC603E:#define __UINT64_C_SUFFIX__ ULL
 // PPC603E:#define __UINT64_MAX__ 18446744073709551615ULL
 // PPC603E:#define __UINT64_TYPE__ long long unsigned int
-// PPC603E:#define __UINT8_C_SUFFIX__ U
-// PPC603E:#define __UINT8_MAX__ 255U
+// PPC603E:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC603E:#define __UINT8_MAX__ 255
 // PPC603E:#define __UINT8_TYPE__ unsigned char
+// PPC603E:#define __UINTMAX_C_SUFFIX__ ULL
 // PPC603E:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // PPC603E:#define __UINTMAX_TYPE__ long long unsigned int
 // PPC603E:#define __UINTMAX_WIDTH__ 64
 // PPC603E:#define __UINTPTR_MAX__ 4294967295U
-// PPC603E:#define __UINTPTR_TYPE__ unsigned int
+// PPC603E:#define __UINTPTR_TYPE__ long unsigned int
 // PPC603E:#define __UINTPTR_WIDTH__ 32
-// PPC603E:#define __UINT_FAST16_MAX__ 65535U
+// PPC603E:#define __UINT_FAST16_MAX__ 65535
 // PPC603E:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC603E:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC603E:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC603E:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // PPC603E:#define __UINT_FAST64_TYPE__ long long unsigned int
-// PPC603E:#define __UINT_FAST8_MAX__ 255U
+// PPC603E:#define __UINT_FAST8_MAX__ 255
 // PPC603E:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC603E:#define __UINT_LEAST16_MAX__ 65535U
+// PPC603E:#define __UINT_LEAST16_MAX__ 65535
 // PPC603E:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC603E:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC603E:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC603E:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // PPC603E:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// PPC603E:#define __UINT_LEAST8_MAX__ 255U
+// PPC603E:#define __UINT_LEAST8_MAX__ 255
 // PPC603E:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC603E:#define __USER_LABEL_PREFIX__ _
 // PPC603E:#define __WCHAR_MAX__ 2147483647
@@ -3535,37 +4373,69 @@
 // PPC64:#define __FLT_MIN_EXP__ (-125)
 // PPC64:#define __FLT_MIN__ 1.17549435e-38F
 // PPC64:#define __FLT_RADIX__ 2
+// PPC64:#define __INT16_C_SUFFIX__ {{$}}
+// PPC64:#define __INT16_FMTd__ "hd"
+// PPC64:#define __INT16_FMTi__ "hi"
 // PPC64:#define __INT16_MAX__ 32767
 // PPC64:#define __INT16_TYPE__ short
+// PPC64:#define __INT32_C_SUFFIX__ {{$}}
+// PPC64:#define __INT32_FMTd__ "d"
+// PPC64:#define __INT32_FMTi__ "i"
 // PPC64:#define __INT32_MAX__ 2147483647
 // PPC64:#define __INT32_TYPE__ int
 // PPC64:#define __INT64_C_SUFFIX__ L
+// PPC64:#define __INT64_FMTd__ "ld"
+// PPC64:#define __INT64_FMTi__ "li"
 // PPC64:#define __INT64_MAX__ 9223372036854775807L
 // PPC64:#define __INT64_TYPE__ long int
+// PPC64:#define __INT8_C_SUFFIX__ {{$}}
+// PPC64:#define __INT8_FMTd__ "hhd"
+// PPC64:#define __INT8_FMTi__ "hhi"
 // PPC64:#define __INT8_MAX__ 127
-// PPC64:#define __INT8_TYPE__ char
+// PPC64:#define __INT8_TYPE__ signed char
+// PPC64:#define __INTMAX_C_SUFFIX__ L
+// PPC64:#define __INTMAX_FMTd__ "ld"
+// PPC64:#define __INTMAX_FMTi__ "li"
 // PPC64:#define __INTMAX_MAX__ 9223372036854775807L
 // PPC64:#define __INTMAX_TYPE__ long int
 // PPC64:#define __INTMAX_WIDTH__ 64
+// PPC64:#define __INTPTR_FMTd__ "ld"
+// PPC64:#define __INTPTR_FMTi__ "li"
 // PPC64:#define __INTPTR_MAX__ 9223372036854775807L
 // PPC64:#define __INTPTR_TYPE__ long int
 // PPC64:#define __INTPTR_WIDTH__ 64
+// PPC64:#define __INT_FAST16_FMTd__ "hd"
+// PPC64:#define __INT_FAST16_FMTi__ "hi"
 // PPC64:#define __INT_FAST16_MAX__ 32767
 // PPC64:#define __INT_FAST16_TYPE__ short
+// PPC64:#define __INT_FAST32_FMTd__ "d"
+// PPC64:#define __INT_FAST32_FMTi__ "i"
 // PPC64:#define __INT_FAST32_MAX__ 2147483647
 // PPC64:#define __INT_FAST32_TYPE__ int
+// PPC64:#define __INT_FAST64_FMTd__ "ld"
+// PPC64:#define __INT_FAST64_FMTi__ "li"
 // PPC64:#define __INT_FAST64_MAX__ 9223372036854775807L
 // PPC64:#define __INT_FAST64_TYPE__ long int
+// PPC64:#define __INT_FAST8_FMTd__ "hhd"
+// PPC64:#define __INT_FAST8_FMTi__ "hhi"
 // PPC64:#define __INT_FAST8_MAX__ 127
-// PPC64:#define __INT_FAST8_TYPE__ char
+// PPC64:#define __INT_FAST8_TYPE__ signed char
+// PPC64:#define __INT_LEAST16_FMTd__ "hd"
+// PPC64:#define __INT_LEAST16_FMTi__ "hi"
 // PPC64:#define __INT_LEAST16_MAX__ 32767
 // PPC64:#define __INT_LEAST16_TYPE__ short
+// PPC64:#define __INT_LEAST32_FMTd__ "d"
+// PPC64:#define __INT_LEAST32_FMTi__ "i"
 // PPC64:#define __INT_LEAST32_MAX__ 2147483647
 // PPC64:#define __INT_LEAST32_TYPE__ int
+// PPC64:#define __INT_LEAST64_FMTd__ "ld"
+// PPC64:#define __INT_LEAST64_FMTi__ "li"
 // PPC64:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // PPC64:#define __INT_LEAST64_TYPE__ long int
+// PPC64:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC64:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC64:#define __INT_LEAST8_MAX__ 127
-// PPC64:#define __INT_LEAST8_TYPE__ char
+// PPC64:#define __INT_LEAST8_TYPE__ signed char
 // PPC64:#define __INT_MAX__ 2147483647
 // PPC64:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC64:#define __LDBL_DIG__ 31
@@ -3594,6 +4464,7 @@
 // PPC64:#define __REGISTER_PREFIX__ 
 // PPC64:#define __SCHAR_MAX__ 127
 // PPC64:#define __SHRT_MAX__ 32767
+// PPC64:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC64:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC64:#define __SIZEOF_DOUBLE__ 8
 // PPC64:#define __SIZEOF_FLOAT__ 4
@@ -3610,8 +4481,8 @@
 // PPC64:#define __SIZE_MAX__ 18446744073709551615UL
 // PPC64:#define __SIZE_TYPE__ long unsigned int
 // PPC64:#define __SIZE_WIDTH__ 64
-// PPC64:#define __UINT16_C_SUFFIX__ U
-// PPC64:#define __UINT16_MAX__ 65535U
+// PPC64:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC64:#define __UINT16_MAX__ 65535
 // PPC64:#define __UINT16_TYPE__ unsigned short
 // PPC64:#define __UINT32_C_SUFFIX__ U
 // PPC64:#define __UINT32_MAX__ 4294967295U
@@ -3619,30 +4490,31 @@
 // PPC64:#define __UINT64_C_SUFFIX__ UL
 // PPC64:#define __UINT64_MAX__ 18446744073709551615UL
 // PPC64:#define __UINT64_TYPE__ long unsigned int
-// PPC64:#define __UINT8_C_SUFFIX__ U
-// PPC64:#define __UINT8_MAX__ 255U
+// PPC64:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC64:#define __UINT8_MAX__ 255
 // PPC64:#define __UINT8_TYPE__ unsigned char
+// PPC64:#define __UINTMAX_C_SUFFIX__ UL
 // PPC64:#define __UINTMAX_MAX__ 18446744073709551615UL
 // PPC64:#define __UINTMAX_TYPE__ long unsigned int
 // PPC64:#define __UINTMAX_WIDTH__ 64
 // PPC64:#define __UINTPTR_MAX__ 18446744073709551615UL
 // PPC64:#define __UINTPTR_TYPE__ long unsigned int
 // PPC64:#define __UINTPTR_WIDTH__ 64
-// PPC64:#define __UINT_FAST16_MAX__ 65535U
+// PPC64:#define __UINT_FAST16_MAX__ 65535
 // PPC64:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC64:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC64:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC64:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // PPC64:#define __UINT_FAST64_TYPE__ long unsigned int
-// PPC64:#define __UINT_FAST8_MAX__ 255U
+// PPC64:#define __UINT_FAST8_MAX__ 255
 // PPC64:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC64:#define __UINT_LEAST16_MAX__ 65535U
+// PPC64:#define __UINT_LEAST16_MAX__ 65535
 // PPC64:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC64:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC64:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC64:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // PPC64:#define __UINT_LEAST64_TYPE__ long unsigned int
-// PPC64:#define __UINT_LEAST8_MAX__ 255U
+// PPC64:#define __UINT_LEAST8_MAX__ 255
 // PPC64:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC64:#define __USER_LABEL_PREFIX__ _
 // PPC64:#define __WCHAR_MAX__ 2147483647
@@ -3702,37 +4574,69 @@
 // PPC64LE:#define __FLT_MIN_EXP__ (-125)
 // PPC64LE:#define __FLT_MIN__ 1.17549435e-38F
 // PPC64LE:#define __FLT_RADIX__ 2
+// PPC64LE:#define __INT16_C_SUFFIX__ {{$}}
+// PPC64LE:#define __INT16_FMTd__ "hd"
+// PPC64LE:#define __INT16_FMTi__ "hi"
 // PPC64LE:#define __INT16_MAX__ 32767
 // PPC64LE:#define __INT16_TYPE__ short
+// PPC64LE:#define __INT32_C_SUFFIX__ {{$}}
+// PPC64LE:#define __INT32_FMTd__ "d"
+// PPC64LE:#define __INT32_FMTi__ "i"
 // PPC64LE:#define __INT32_MAX__ 2147483647
 // PPC64LE:#define __INT32_TYPE__ int
 // PPC64LE:#define __INT64_C_SUFFIX__ L
+// PPC64LE:#define __INT64_FMTd__ "ld"
+// PPC64LE:#define __INT64_FMTi__ "li"
 // PPC64LE:#define __INT64_MAX__ 9223372036854775807L
 // PPC64LE:#define __INT64_TYPE__ long int
+// PPC64LE:#define __INT8_C_SUFFIX__ {{$}}
+// PPC64LE:#define __INT8_FMTd__ "hhd"
+// PPC64LE:#define __INT8_FMTi__ "hhi"
 // PPC64LE:#define __INT8_MAX__ 127
-// PPC64LE:#define __INT8_TYPE__ char
+// PPC64LE:#define __INT8_TYPE__ signed char
+// PPC64LE:#define __INTMAX_C_SUFFIX__ L
+// PPC64LE:#define __INTMAX_FMTd__ "ld"
+// PPC64LE:#define __INTMAX_FMTi__ "li"
 // PPC64LE:#define __INTMAX_MAX__ 9223372036854775807L
 // PPC64LE:#define __INTMAX_TYPE__ long int
 // PPC64LE:#define __INTMAX_WIDTH__ 64
+// PPC64LE:#define __INTPTR_FMTd__ "ld"
+// PPC64LE:#define __INTPTR_FMTi__ "li"
 // PPC64LE:#define __INTPTR_MAX__ 9223372036854775807L
 // PPC64LE:#define __INTPTR_TYPE__ long int
 // PPC64LE:#define __INTPTR_WIDTH__ 64
+// PPC64LE:#define __INT_FAST16_FMTd__ "hd"
+// PPC64LE:#define __INT_FAST16_FMTi__ "hi"
 // PPC64LE:#define __INT_FAST16_MAX__ 32767
 // PPC64LE:#define __INT_FAST16_TYPE__ short
+// PPC64LE:#define __INT_FAST32_FMTd__ "d"
+// PPC64LE:#define __INT_FAST32_FMTi__ "i"
 // PPC64LE:#define __INT_FAST32_MAX__ 2147483647
 // PPC64LE:#define __INT_FAST32_TYPE__ int
+// PPC64LE:#define __INT_FAST64_FMTd__ "ld"
+// PPC64LE:#define __INT_FAST64_FMTi__ "li"
 // PPC64LE:#define __INT_FAST64_MAX__ 9223372036854775807L
 // PPC64LE:#define __INT_FAST64_TYPE__ long int
+// PPC64LE:#define __INT_FAST8_FMTd__ "hhd"
+// PPC64LE:#define __INT_FAST8_FMTi__ "hhi"
 // PPC64LE:#define __INT_FAST8_MAX__ 127
-// PPC64LE:#define __INT_FAST8_TYPE__ char
+// PPC64LE:#define __INT_FAST8_TYPE__ signed char
+// PPC64LE:#define __INT_LEAST16_FMTd__ "hd"
+// PPC64LE:#define __INT_LEAST16_FMTi__ "hi"
 // PPC64LE:#define __INT_LEAST16_MAX__ 32767
 // PPC64LE:#define __INT_LEAST16_TYPE__ short
+// PPC64LE:#define __INT_LEAST32_FMTd__ "d"
+// PPC64LE:#define __INT_LEAST32_FMTi__ "i"
 // PPC64LE:#define __INT_LEAST32_MAX__ 2147483647
 // PPC64LE:#define __INT_LEAST32_TYPE__ int
+// PPC64LE:#define __INT_LEAST64_FMTd__ "ld"
+// PPC64LE:#define __INT_LEAST64_FMTi__ "li"
 // PPC64LE:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // PPC64LE:#define __INT_LEAST64_TYPE__ long int
+// PPC64LE:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC64LE:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC64LE:#define __INT_LEAST8_MAX__ 127
-// PPC64LE:#define __INT_LEAST8_TYPE__ char
+// PPC64LE:#define __INT_LEAST8_TYPE__ signed char
 // PPC64LE:#define __INT_MAX__ 2147483647
 // PPC64LE:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC64LE:#define __LDBL_DIG__ 31
@@ -3762,6 +4666,7 @@
 // PPC64LE:#define __REGISTER_PREFIX__ 
 // PPC64LE:#define __SCHAR_MAX__ 127
 // PPC64LE:#define __SHRT_MAX__ 32767
+// PPC64LE:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC64LE:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC64LE:#define __SIZEOF_DOUBLE__ 8
 // PPC64LE:#define __SIZEOF_FLOAT__ 4
@@ -3778,8 +4683,8 @@
 // PPC64LE:#define __SIZE_MAX__ 18446744073709551615UL
 // PPC64LE:#define __SIZE_TYPE__ long unsigned int
 // PPC64LE:#define __SIZE_WIDTH__ 64
-// PPC64LE:#define __UINT16_C_SUFFIX__ U
-// PPC64LE:#define __UINT16_MAX__ 65535U
+// PPC64LE:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC64LE:#define __UINT16_MAX__ 65535
 // PPC64LE:#define __UINT16_TYPE__ unsigned short
 // PPC64LE:#define __UINT32_C_SUFFIX__ U
 // PPC64LE:#define __UINT32_MAX__ 4294967295U
@@ -3787,30 +4692,31 @@
 // PPC64LE:#define __UINT64_C_SUFFIX__ UL
 // PPC64LE:#define __UINT64_MAX__ 18446744073709551615UL
 // PPC64LE:#define __UINT64_TYPE__ long unsigned int
-// PPC64LE:#define __UINT8_C_SUFFIX__ U
-// PPC64LE:#define __UINT8_MAX__ 255U
+// PPC64LE:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC64LE:#define __UINT8_MAX__ 255
 // PPC64LE:#define __UINT8_TYPE__ unsigned char
+// PPC64LE:#define __UINTMAX_C_SUFFIX__ UL
 // PPC64LE:#define __UINTMAX_MAX__ 18446744073709551615UL
 // PPC64LE:#define __UINTMAX_TYPE__ long unsigned int
 // PPC64LE:#define __UINTMAX_WIDTH__ 64
 // PPC64LE:#define __UINTPTR_MAX__ 18446744073709551615UL
 // PPC64LE:#define __UINTPTR_TYPE__ long unsigned int
 // PPC64LE:#define __UINTPTR_WIDTH__ 64
-// PPC64LE:#define __UINT_FAST16_MAX__ 65535U
+// PPC64LE:#define __UINT_FAST16_MAX__ 65535
 // PPC64LE:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC64LE:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC64LE:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC64LE:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // PPC64LE:#define __UINT_FAST64_TYPE__ long unsigned int
-// PPC64LE:#define __UINT_FAST8_MAX__ 255U
+// PPC64LE:#define __UINT_FAST8_MAX__ 255
 // PPC64LE:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC64LE:#define __UINT_LEAST16_MAX__ 65535U
+// PPC64LE:#define __UINT_LEAST16_MAX__ 65535
 // PPC64LE:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC64LE:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC64LE:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC64LE:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // PPC64LE:#define __UINT_LEAST64_TYPE__ long unsigned int
-// PPC64LE:#define __UINT_LEAST8_MAX__ 255U
+// PPC64LE:#define __UINT_LEAST8_MAX__ 255
 // PPC64LE:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC64LE:#define __USER_LABEL_PREFIX__ _
 // PPC64LE:#define __WCHAR_MAX__ 2147483647
@@ -4050,37 +4956,69 @@
 // PPC64-LINUX:#define __FLT_MIN_EXP__ (-125)
 // PPC64-LINUX:#define __FLT_MIN__ 1.17549435e-38F
 // PPC64-LINUX:#define __FLT_RADIX__ 2
+// PPC64-LINUX:#define __INT16_C_SUFFIX__ {{$}}
+// PPC64-LINUX:#define __INT16_FMTd__ "hd"
+// PPC64-LINUX:#define __INT16_FMTi__ "hi"
 // PPC64-LINUX:#define __INT16_MAX__ 32767
 // PPC64-LINUX:#define __INT16_TYPE__ short
+// PPC64-LINUX:#define __INT32_C_SUFFIX__ {{$}}
+// PPC64-LINUX:#define __INT32_FMTd__ "d"
+// PPC64-LINUX:#define __INT32_FMTi__ "i"
 // PPC64-LINUX:#define __INT32_MAX__ 2147483647
 // PPC64-LINUX:#define __INT32_TYPE__ int
 // PPC64-LINUX:#define __INT64_C_SUFFIX__ L
+// PPC64-LINUX:#define __INT64_FMTd__ "ld"
+// PPC64-LINUX:#define __INT64_FMTi__ "li"
 // PPC64-LINUX:#define __INT64_MAX__ 9223372036854775807L
 // PPC64-LINUX:#define __INT64_TYPE__ long int
+// PPC64-LINUX:#define __INT8_C_SUFFIX__ {{$}}
+// PPC64-LINUX:#define __INT8_FMTd__ "hhd"
+// PPC64-LINUX:#define __INT8_FMTi__ "hhi"
 // PPC64-LINUX:#define __INT8_MAX__ 127
-// PPC64-LINUX:#define __INT8_TYPE__ char
+// PPC64-LINUX:#define __INT8_TYPE__ signed char
+// PPC64-LINUX:#define __INTMAX_C_SUFFIX__ L
+// PPC64-LINUX:#define __INTMAX_FMTd__ "ld"
+// PPC64-LINUX:#define __INTMAX_FMTi__ "li"
 // PPC64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L
 // PPC64-LINUX:#define __INTMAX_TYPE__ long int
 // PPC64-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC64-LINUX:#define __INTPTR_FMTd__ "ld"
+// PPC64-LINUX:#define __INTPTR_FMTi__ "li"
 // PPC64-LINUX:#define __INTPTR_MAX__ 9223372036854775807L
 // PPC64-LINUX:#define __INTPTR_TYPE__ long int
 // PPC64-LINUX:#define __INTPTR_WIDTH__ 64
+// PPC64-LINUX:#define __INT_FAST16_FMTd__ "hd"
+// PPC64-LINUX:#define __INT_FAST16_FMTi__ "hi"
 // PPC64-LINUX:#define __INT_FAST16_MAX__ 32767
 // PPC64-LINUX:#define __INT_FAST16_TYPE__ short
+// PPC64-LINUX:#define __INT_FAST32_FMTd__ "d"
+// PPC64-LINUX:#define __INT_FAST32_FMTi__ "i"
 // PPC64-LINUX:#define __INT_FAST32_MAX__ 2147483647
 // PPC64-LINUX:#define __INT_FAST32_TYPE__ int
+// PPC64-LINUX:#define __INT_FAST64_FMTd__ "ld"
+// PPC64-LINUX:#define __INT_FAST64_FMTi__ "li"
 // PPC64-LINUX:#define __INT_FAST64_MAX__ 9223372036854775807L
 // PPC64-LINUX:#define __INT_FAST64_TYPE__ long int
+// PPC64-LINUX:#define __INT_FAST8_FMTd__ "hhd"
+// PPC64-LINUX:#define __INT_FAST8_FMTi__ "hhi"
 // PPC64-LINUX:#define __INT_FAST8_MAX__ 127
-// PPC64-LINUX:#define __INT_FAST8_TYPE__ char
+// PPC64-LINUX:#define __INT_FAST8_TYPE__ signed char
+// PPC64-LINUX:#define __INT_LEAST16_FMTd__ "hd"
+// PPC64-LINUX:#define __INT_LEAST16_FMTi__ "hi"
 // PPC64-LINUX:#define __INT_LEAST16_MAX__ 32767
 // PPC64-LINUX:#define __INT_LEAST16_TYPE__ short
+// PPC64-LINUX:#define __INT_LEAST32_FMTd__ "d"
+// PPC64-LINUX:#define __INT_LEAST32_FMTi__ "i"
 // PPC64-LINUX:#define __INT_LEAST32_MAX__ 2147483647
 // PPC64-LINUX:#define __INT_LEAST32_TYPE__ int
+// PPC64-LINUX:#define __INT_LEAST64_FMTd__ "ld"
+// PPC64-LINUX:#define __INT_LEAST64_FMTi__ "li"
 // PPC64-LINUX:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // PPC64-LINUX:#define __INT_LEAST64_TYPE__ long int
+// PPC64-LINUX:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC64-LINUX:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC64-LINUX:#define __INT_LEAST8_MAX__ 127
-// PPC64-LINUX:#define __INT_LEAST8_TYPE__ char
+// PPC64-LINUX:#define __INT_LEAST8_TYPE__ signed char
 // PPC64-LINUX:#define __INT_MAX__ 2147483647
 // PPC64-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC64-LINUX:#define __LDBL_DIG__ 31
@@ -4109,6 +5047,7 @@
 // PPC64-LINUX:#define __REGISTER_PREFIX__
 // PPC64-LINUX:#define __SCHAR_MAX__ 127
 // PPC64-LINUX:#define __SHRT_MAX__ 32767
+// PPC64-LINUX:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC64-LINUX:#define __SIZEOF_DOUBLE__ 8
 // PPC64-LINUX:#define __SIZEOF_FLOAT__ 4
@@ -4125,8 +5064,8 @@
 // PPC64-LINUX:#define __SIZE_MAX__ 18446744073709551615UL
 // PPC64-LINUX:#define __SIZE_TYPE__ long unsigned int
 // PPC64-LINUX:#define __SIZE_WIDTH__ 64
-// PPC64-LINUX:#define __UINT16_C_SUFFIX__ U
-// PPC64-LINUX:#define __UINT16_MAX__ 65535U
+// PPC64-LINUX:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC64-LINUX:#define __UINT16_MAX__ 65535
 // PPC64-LINUX:#define __UINT16_TYPE__ unsigned short
 // PPC64-LINUX:#define __UINT32_C_SUFFIX__ U
 // PPC64-LINUX:#define __UINT32_MAX__ 4294967295U
@@ -4134,30 +5073,31 @@
 // PPC64-LINUX:#define __UINT64_C_SUFFIX__ UL
 // PPC64-LINUX:#define __UINT64_MAX__ 18446744073709551615UL
 // PPC64-LINUX:#define __UINT64_TYPE__ long unsigned int
-// PPC64-LINUX:#define __UINT8_C_SUFFIX__ U
-// PPC64-LINUX:#define __UINT8_MAX__ 255U
+// PPC64-LINUX:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC64-LINUX:#define __UINT8_MAX__ 255
 // PPC64-LINUX:#define __UINT8_TYPE__ unsigned char
+// PPC64-LINUX:#define __UINTMAX_C_SUFFIX__ UL
 // PPC64-LINUX:#define __UINTMAX_MAX__ 18446744073709551615UL
 // PPC64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
 // PPC64-LINUX:#define __UINTMAX_WIDTH__ 64
 // PPC64-LINUX:#define __UINTPTR_MAX__ 18446744073709551615UL
 // PPC64-LINUX:#define __UINTPTR_TYPE__ long unsigned int
 // PPC64-LINUX:#define __UINTPTR_WIDTH__ 64
-// PPC64-LINUX:#define __UINT_FAST16_MAX__ 65535U
+// PPC64-LINUX:#define __UINT_FAST16_MAX__ 65535
 // PPC64-LINUX:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC64-LINUX:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC64-LINUX:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC64-LINUX:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // PPC64-LINUX:#define __UINT_FAST64_TYPE__ long unsigned int
-// PPC64-LINUX:#define __UINT_FAST8_MAX__ 255U
+// PPC64-LINUX:#define __UINT_FAST8_MAX__ 255
 // PPC64-LINUX:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC64-LINUX:#define __UINT_LEAST16_MAX__ 65535U
+// PPC64-LINUX:#define __UINT_LEAST16_MAX__ 65535
 // PPC64-LINUX:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC64-LINUX:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC64-LINUX:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC64-LINUX:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // PPC64-LINUX:#define __UINT_LEAST64_TYPE__ long unsigned int
-// PPC64-LINUX:#define __UINT_LEAST8_MAX__ 255U
+// PPC64-LINUX:#define __UINT_LEAST8_MAX__ 255
 // PPC64-LINUX:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC64-LINUX:#define __USER_LABEL_PREFIX__
 // PPC64-LINUX:#define __WCHAR_MAX__ 2147483647
@@ -4170,6 +5110,15 @@
 // PPC64-LINUX:#define __powerpc__ 1
 // PPC64-LINUX:#define __ppc64__ 1
 // PPC64-LINUX:#define __ppc__ 1
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu < /dev/null | FileCheck -check-prefix PPC64-ELFv1 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -target-abi elfv1 < /dev/null | FileCheck -check-prefix PPC64-ELFv1 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -target-abi elfv2 < /dev/null | FileCheck -check-prefix PPC64-ELFv2 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-linux-gnu < /dev/null | FileCheck -check-prefix PPC64-ELFv2 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-linux-gnu -target-abi elfv1 < /dev/null | FileCheck -check-prefix PPC64-ELFv1 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-linux-gnu -target-abi elfv2 < /dev/null | FileCheck -check-prefix PPC64-ELFv2 %s
+// PPC64-ELFv1:#define _CALL_ELF 1
+// PPC64-ELFv2:#define _CALL_ELF 2
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC %s
 //
@@ -4211,37 +5160,69 @@
 // PPC:#define __FLT_MIN_EXP__ (-125)
 // PPC:#define __FLT_MIN__ 1.17549435e-38F
 // PPC:#define __FLT_RADIX__ 2
+// PPC:#define __INT16_C_SUFFIX__ {{$}}
+// PPC:#define __INT16_FMTd__ "hd"
+// PPC:#define __INT16_FMTi__ "hi"
 // PPC:#define __INT16_MAX__ 32767
 // PPC:#define __INT16_TYPE__ short
+// PPC:#define __INT32_C_SUFFIX__ {{$}}
+// PPC:#define __INT32_FMTd__ "d"
+// PPC:#define __INT32_FMTi__ "i"
 // PPC:#define __INT32_MAX__ 2147483647
 // PPC:#define __INT32_TYPE__ int
 // PPC:#define __INT64_C_SUFFIX__ LL
+// PPC:#define __INT64_FMTd__ "lld"
+// PPC:#define __INT64_FMTi__ "lli"
 // PPC:#define __INT64_MAX__ 9223372036854775807LL
 // PPC:#define __INT64_TYPE__ long long int
+// PPC:#define __INT8_C_SUFFIX__ {{$}}
+// PPC:#define __INT8_FMTd__ "hhd"
+// PPC:#define __INT8_FMTi__ "hhi"
 // PPC:#define __INT8_MAX__ 127
-// PPC:#define __INT8_TYPE__ char
+// PPC:#define __INT8_TYPE__ signed char
+// PPC:#define __INTMAX_C_SUFFIX__ LL
+// PPC:#define __INTMAX_FMTd__ "lld"
+// PPC:#define __INTMAX_FMTi__ "lli"
 // PPC:#define __INTMAX_MAX__ 9223372036854775807LL
 // PPC:#define __INTMAX_TYPE__ long long int
 // PPC:#define __INTMAX_WIDTH__ 64
+// PPC:#define __INTPTR_FMTd__ "ld"
+// PPC:#define __INTPTR_FMTi__ "li"
 // PPC:#define __INTPTR_MAX__ 2147483647L
 // PPC:#define __INTPTR_TYPE__ long int
 // PPC:#define __INTPTR_WIDTH__ 32
+// PPC:#define __INT_FAST16_FMTd__ "hd"
+// PPC:#define __INT_FAST16_FMTi__ "hi"
 // PPC:#define __INT_FAST16_MAX__ 32767
 // PPC:#define __INT_FAST16_TYPE__ short
+// PPC:#define __INT_FAST32_FMTd__ "d"
+// PPC:#define __INT_FAST32_FMTi__ "i"
 // PPC:#define __INT_FAST32_MAX__ 2147483647
 // PPC:#define __INT_FAST32_TYPE__ int
+// PPC:#define __INT_FAST64_FMTd__ "lld"
+// PPC:#define __INT_FAST64_FMTi__ "lli"
 // PPC:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // PPC:#define __INT_FAST64_TYPE__ long long int
+// PPC:#define __INT_FAST8_FMTd__ "hhd"
+// PPC:#define __INT_FAST8_FMTi__ "hhi"
 // PPC:#define __INT_FAST8_MAX__ 127
-// PPC:#define __INT_FAST8_TYPE__ char
+// PPC:#define __INT_FAST8_TYPE__ signed char
+// PPC:#define __INT_LEAST16_FMTd__ "hd"
+// PPC:#define __INT_LEAST16_FMTi__ "hi"
 // PPC:#define __INT_LEAST16_MAX__ 32767
 // PPC:#define __INT_LEAST16_TYPE__ short
+// PPC:#define __INT_LEAST32_FMTd__ "d"
+// PPC:#define __INT_LEAST32_FMTi__ "i"
 // PPC:#define __INT_LEAST32_MAX__ 2147483647
 // PPC:#define __INT_LEAST32_TYPE__ int
+// PPC:#define __INT_LEAST64_FMTd__ "lld"
+// PPC:#define __INT_LEAST64_FMTi__ "lli"
 // PPC:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // PPC:#define __INT_LEAST64_TYPE__ long long int
+// PPC:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC:#define __INT_LEAST8_MAX__ 127
-// PPC:#define __INT_LEAST8_TYPE__ char
+// PPC:#define __INT_LEAST8_TYPE__ signed char
 // PPC:#define __INT_MAX__ 2147483647
 // PPC:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC:#define __LDBL_DIG__ 31
@@ -4269,6 +5250,7 @@
 // PPC:#define __REGISTER_PREFIX__ 
 // PPC:#define __SCHAR_MAX__ 127
 // PPC:#define __SHRT_MAX__ 32767
+// PPC:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC:#define __SIZEOF_DOUBLE__ 8
 // PPC:#define __SIZEOF_FLOAT__ 4
@@ -4285,8 +5267,8 @@
 // PPC:#define __SIZE_MAX__ 4294967295U
 // PPC:#define __SIZE_TYPE__ long unsigned int
 // PPC:#define __SIZE_WIDTH__ 32
-// PPC:#define __UINT16_C_SUFFIX__ U
-// PPC:#define __UINT16_MAX__ 65535U
+// PPC:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC:#define __UINT16_MAX__ 65535
 // PPC:#define __UINT16_TYPE__ unsigned short
 // PPC:#define __UINT32_C_SUFFIX__ U
 // PPC:#define __UINT32_MAX__ 4294967295U
@@ -4294,30 +5276,31 @@
 // PPC:#define __UINT64_C_SUFFIX__ ULL
 // PPC:#define __UINT64_MAX__ 18446744073709551615ULL
 // PPC:#define __UINT64_TYPE__ long long unsigned int
-// PPC:#define __UINT8_C_SUFFIX__ U
-// PPC:#define __UINT8_MAX__ 255U
+// PPC:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC:#define __UINT8_MAX__ 255
 // PPC:#define __UINT8_TYPE__ unsigned char
+// PPC:#define __UINTMAX_C_SUFFIX__ ULL
 // PPC:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // PPC:#define __UINTMAX_TYPE__ long long unsigned int
 // PPC:#define __UINTMAX_WIDTH__ 64
 // PPC:#define __UINTPTR_MAX__ 4294967295U
-// PPC:#define __UINTPTR_TYPE__ unsigned int
+// PPC:#define __UINTPTR_TYPE__ long unsigned int
 // PPC:#define __UINTPTR_WIDTH__ 32
-// PPC:#define __UINT_FAST16_MAX__ 65535U
+// PPC:#define __UINT_FAST16_MAX__ 65535
 // PPC:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // PPC:#define __UINT_FAST64_TYPE__ long long unsigned int
-// PPC:#define __UINT_FAST8_MAX__ 255U
+// PPC:#define __UINT_FAST8_MAX__ 255
 // PPC:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC:#define __UINT_LEAST16_MAX__ 65535U
+// PPC:#define __UINT_LEAST16_MAX__ 65535
 // PPC:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // PPC:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// PPC:#define __UINT_LEAST8_MAX__ 255U
+// PPC:#define __UINT_LEAST8_MAX__ 255
 // PPC:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC:#define __USER_LABEL_PREFIX__ _
 // PPC:#define __WCHAR_MAX__ 2147483647
@@ -4367,37 +5350,69 @@
 // PPC-LINUX:#define __FLT_MIN_EXP__ (-125)
 // PPC-LINUX:#define __FLT_MIN__ 1.17549435e-38F
 // PPC-LINUX:#define __FLT_RADIX__ 2
+// PPC-LINUX:#define __INT16_C_SUFFIX__ {{$}}
+// PPC-LINUX:#define __INT16_FMTd__ "hd"
+// PPC-LINUX:#define __INT16_FMTi__ "hi"
 // PPC-LINUX:#define __INT16_MAX__ 32767
 // PPC-LINUX:#define __INT16_TYPE__ short
+// PPC-LINUX:#define __INT32_C_SUFFIX__ {{$}}
+// PPC-LINUX:#define __INT32_FMTd__ "d"
+// PPC-LINUX:#define __INT32_FMTi__ "i"
 // PPC-LINUX:#define __INT32_MAX__ 2147483647
 // PPC-LINUX:#define __INT32_TYPE__ int
 // PPC-LINUX:#define __INT64_C_SUFFIX__ LL
+// PPC-LINUX:#define __INT64_FMTd__ "lld"
+// PPC-LINUX:#define __INT64_FMTi__ "lli"
 // PPC-LINUX:#define __INT64_MAX__ 9223372036854775807LL
 // PPC-LINUX:#define __INT64_TYPE__ long long int
+// PPC-LINUX:#define __INT8_C_SUFFIX__ {{$}}
+// PPC-LINUX:#define __INT8_FMTd__ "hhd"
+// PPC-LINUX:#define __INT8_FMTi__ "hhi"
 // PPC-LINUX:#define __INT8_MAX__ 127
-// PPC-LINUX:#define __INT8_TYPE__ char
+// PPC-LINUX:#define __INT8_TYPE__ signed char
+// PPC-LINUX:#define __INTMAX_C_SUFFIX__ LL
+// PPC-LINUX:#define __INTMAX_FMTd__ "lld"
+// PPC-LINUX:#define __INTMAX_FMTi__ "lli"
 // PPC-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL
 // PPC-LINUX:#define __INTMAX_TYPE__ long long int
 // PPC-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC-LINUX:#define __INTPTR_FMTd__ "d"
+// PPC-LINUX:#define __INTPTR_FMTi__ "i"
 // PPC-LINUX:#define __INTPTR_MAX__ 2147483647
 // PPC-LINUX:#define __INTPTR_TYPE__ int
 // PPC-LINUX:#define __INTPTR_WIDTH__ 32
+// PPC-LINUX:#define __INT_FAST16_FMTd__ "hd"
+// PPC-LINUX:#define __INT_FAST16_FMTi__ "hi"
 // PPC-LINUX:#define __INT_FAST16_MAX__ 32767
 // PPC-LINUX:#define __INT_FAST16_TYPE__ short
+// PPC-LINUX:#define __INT_FAST32_FMTd__ "d"
+// PPC-LINUX:#define __INT_FAST32_FMTi__ "i"
 // PPC-LINUX:#define __INT_FAST32_MAX__ 2147483647
 // PPC-LINUX:#define __INT_FAST32_TYPE__ int
+// PPC-LINUX:#define __INT_FAST64_FMTd__ "lld"
+// PPC-LINUX:#define __INT_FAST64_FMTi__ "lli"
 // PPC-LINUX:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // PPC-LINUX:#define __INT_FAST64_TYPE__ long long int
+// PPC-LINUX:#define __INT_FAST8_FMTd__ "hhd"
+// PPC-LINUX:#define __INT_FAST8_FMTi__ "hhi"
 // PPC-LINUX:#define __INT_FAST8_MAX__ 127
-// PPC-LINUX:#define __INT_FAST8_TYPE__ char
+// PPC-LINUX:#define __INT_FAST8_TYPE__ signed char
+// PPC-LINUX:#define __INT_LEAST16_FMTd__ "hd"
+// PPC-LINUX:#define __INT_LEAST16_FMTi__ "hi"
 // PPC-LINUX:#define __INT_LEAST16_MAX__ 32767
 // PPC-LINUX:#define __INT_LEAST16_TYPE__ short
+// PPC-LINUX:#define __INT_LEAST32_FMTd__ "d"
+// PPC-LINUX:#define __INT_LEAST32_FMTi__ "i"
 // PPC-LINUX:#define __INT_LEAST32_MAX__ 2147483647
 // PPC-LINUX:#define __INT_LEAST32_TYPE__ int
+// PPC-LINUX:#define __INT_LEAST64_FMTd__ "lld"
+// PPC-LINUX:#define __INT_LEAST64_FMTi__ "lli"
 // PPC-LINUX:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // PPC-LINUX:#define __INT_LEAST64_TYPE__ long long int
+// PPC-LINUX:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC-LINUX:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC-LINUX:#define __INT_LEAST8_MAX__ 127
-// PPC-LINUX:#define __INT_LEAST8_TYPE__ char
+// PPC-LINUX:#define __INT_LEAST8_TYPE__ signed char
 // PPC-LINUX:#define __INT_MAX__ 2147483647
 // PPC-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC-LINUX:#define __LDBL_DIG__ 31
@@ -4425,6 +5440,7 @@
 // PPC-LINUX:#define __REGISTER_PREFIX__
 // PPC-LINUX:#define __SCHAR_MAX__ 127
 // PPC-LINUX:#define __SHRT_MAX__ 32767
+// PPC-LINUX:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC-LINUX:#define __SIZEOF_DOUBLE__ 8
 // PPC-LINUX:#define __SIZEOF_FLOAT__ 4
@@ -4441,8 +5457,8 @@
 // PPC-LINUX:#define __SIZE_MAX__ 4294967295U
 // PPC-LINUX:#define __SIZE_TYPE__ unsigned int
 // PPC-LINUX:#define __SIZE_WIDTH__ 32
-// PPC-LINUX:#define __UINT16_C_SUFFIX__ U
-// PPC-LINUX:#define __UINT16_MAX__ 65535U
+// PPC-LINUX:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC-LINUX:#define __UINT16_MAX__ 65535
 // PPC-LINUX:#define __UINT16_TYPE__ unsigned short
 // PPC-LINUX:#define __UINT32_C_SUFFIX__ U
 // PPC-LINUX:#define __UINT32_MAX__ 4294967295U
@@ -4450,30 +5466,31 @@
 // PPC-LINUX:#define __UINT64_C_SUFFIX__ ULL
 // PPC-LINUX:#define __UINT64_MAX__ 18446744073709551615ULL
 // PPC-LINUX:#define __UINT64_TYPE__ long long unsigned int
-// PPC-LINUX:#define __UINT8_C_SUFFIX__ U
-// PPC-LINUX:#define __UINT8_MAX__ 255U
+// PPC-LINUX:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC-LINUX:#define __UINT8_MAX__ 255
 // PPC-LINUX:#define __UINT8_TYPE__ unsigned char
+// PPC-LINUX:#define __UINTMAX_C_SUFFIX__ ULL
 // PPC-LINUX:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // PPC-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
 // PPC-LINUX:#define __UINTMAX_WIDTH__ 64
 // PPC-LINUX:#define __UINTPTR_MAX__ 4294967295U
 // PPC-LINUX:#define __UINTPTR_TYPE__ unsigned int
 // PPC-LINUX:#define __UINTPTR_WIDTH__ 32
-// PPC-LINUX:#define __UINT_FAST16_MAX__ 65535U
+// PPC-LINUX:#define __UINT_FAST16_MAX__ 65535
 // PPC-LINUX:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC-LINUX:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC-LINUX:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC-LINUX:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // PPC-LINUX:#define __UINT_FAST64_TYPE__ long long unsigned int
-// PPC-LINUX:#define __UINT_FAST8_MAX__ 255U
+// PPC-LINUX:#define __UINT_FAST8_MAX__ 255
 // PPC-LINUX:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC-LINUX:#define __UINT_LEAST16_MAX__ 65535U
+// PPC-LINUX:#define __UINT_LEAST16_MAX__ 65535
 // PPC-LINUX:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC-LINUX:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC-LINUX:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC-LINUX:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // PPC-LINUX:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// PPC-LINUX:#define __UINT_LEAST8_MAX__ 255U
+// PPC-LINUX:#define __UINT_LEAST8_MAX__ 255
 // PPC-LINUX:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC-LINUX:#define __USER_LABEL_PREFIX__
 // PPC-LINUX:#define __WCHAR_MAX__ 2147483647
@@ -4523,37 +5540,69 @@
 // PPC-DARWIN:#define __FLT_MIN_EXP__ (-125)
 // PPC-DARWIN:#define __FLT_MIN__ 1.17549435e-38F
 // PPC-DARWIN:#define __FLT_RADIX__ 2
+// PPC-DARWIN:#define __INT16_C_SUFFIX__ {{$}}
+// PPC-DARWIN:#define __INT16_FMTd__ "hd"
+// PPC-DARWIN:#define __INT16_FMTi__ "hi"
 // PPC-DARWIN:#define __INT16_MAX__ 32767
 // PPC-DARWIN:#define __INT16_TYPE__ short
+// PPC-DARWIN:#define __INT32_C_SUFFIX__ {{$}}
+// PPC-DARWIN:#define __INT32_FMTd__ "d"
+// PPC-DARWIN:#define __INT32_FMTi__ "i"
 // PPC-DARWIN:#define __INT32_MAX__ 2147483647
 // PPC-DARWIN:#define __INT32_TYPE__ int
 // PPC-DARWIN:#define __INT64_C_SUFFIX__ LL
+// PPC-DARWIN:#define __INT64_FMTd__ "lld"
+// PPC-DARWIN:#define __INT64_FMTi__ "lli"
 // PPC-DARWIN:#define __INT64_MAX__ 9223372036854775807LL
 // PPC-DARWIN:#define __INT64_TYPE__ long long int
+// PPC-DARWIN:#define __INT8_C_SUFFIX__ {{$}}
+// PPC-DARWIN:#define __INT8_FMTd__ "hhd"
+// PPC-DARWIN:#define __INT8_FMTi__ "hhi"
 // PPC-DARWIN:#define __INT8_MAX__ 127
-// PPC-DARWIN:#define __INT8_TYPE__ char
+// PPC-DARWIN:#define __INT8_TYPE__ signed char
+// PPC-DARWIN:#define __INTMAX_C_SUFFIX__ LL
+// PPC-DARWIN:#define __INTMAX_FMTd__ "lld"
+// PPC-DARWIN:#define __INTMAX_FMTi__ "lli"
 // PPC-DARWIN:#define __INTMAX_MAX__ 9223372036854775807LL
 // PPC-DARWIN:#define __INTMAX_TYPE__ long long int
 // PPC-DARWIN:#define __INTMAX_WIDTH__ 64
+// PPC-DARWIN:#define __INTPTR_FMTd__ "ld"
+// PPC-DARWIN:#define __INTPTR_FMTi__ "li"
 // PPC-DARWIN:#define __INTPTR_MAX__ 2147483647L
 // PPC-DARWIN:#define __INTPTR_TYPE__ long int
 // PPC-DARWIN:#define __INTPTR_WIDTH__ 32
+// PPC-DARWIN:#define __INT_FAST16_FMTd__ "hd"
+// PPC-DARWIN:#define __INT_FAST16_FMTi__ "hi"
 // PPC-DARWIN:#define __INT_FAST16_MAX__ 32767
 // PPC-DARWIN:#define __INT_FAST16_TYPE__ short
+// PPC-DARWIN:#define __INT_FAST32_FMTd__ "d"
+// PPC-DARWIN:#define __INT_FAST32_FMTi__ "i"
 // PPC-DARWIN:#define __INT_FAST32_MAX__ 2147483647
 // PPC-DARWIN:#define __INT_FAST32_TYPE__ int
+// PPC-DARWIN:#define __INT_FAST64_FMTd__ "lld"
+// PPC-DARWIN:#define __INT_FAST64_FMTi__ "lli"
 // PPC-DARWIN:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // PPC-DARWIN:#define __INT_FAST64_TYPE__ long long int
+// PPC-DARWIN:#define __INT_FAST8_FMTd__ "hhd"
+// PPC-DARWIN:#define __INT_FAST8_FMTi__ "hhi"
 // PPC-DARWIN:#define __INT_FAST8_MAX__ 127
-// PPC-DARWIN:#define __INT_FAST8_TYPE__ char
+// PPC-DARWIN:#define __INT_FAST8_TYPE__ signed char
+// PPC-DARWIN:#define __INT_LEAST16_FMTd__ "hd"
+// PPC-DARWIN:#define __INT_LEAST16_FMTi__ "hi"
 // PPC-DARWIN:#define __INT_LEAST16_MAX__ 32767
 // PPC-DARWIN:#define __INT_LEAST16_TYPE__ short
+// PPC-DARWIN:#define __INT_LEAST32_FMTd__ "d"
+// PPC-DARWIN:#define __INT_LEAST32_FMTi__ "i"
 // PPC-DARWIN:#define __INT_LEAST32_MAX__ 2147483647
 // PPC-DARWIN:#define __INT_LEAST32_TYPE__ int
+// PPC-DARWIN:#define __INT_LEAST64_FMTd__ "lld"
+// PPC-DARWIN:#define __INT_LEAST64_FMTi__ "lli"
 // PPC-DARWIN:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // PPC-DARWIN:#define __INT_LEAST64_TYPE__ long long int
+// PPC-DARWIN:#define __INT_LEAST8_FMTd__ "hhd"
+// PPC-DARWIN:#define __INT_LEAST8_FMTi__ "hhi"
 // PPC-DARWIN:#define __INT_LEAST8_MAX__ 127
-// PPC-DARWIN:#define __INT_LEAST8_TYPE__ char
+// PPC-DARWIN:#define __INT_LEAST8_TYPE__ signed char
 // PPC-DARWIN:#define __INT_MAX__ 2147483647
 // PPC-DARWIN:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
 // PPC-DARWIN:#define __LDBL_DIG__ 31
@@ -4584,6 +5633,7 @@
 // PPC-DARWIN:#define __REGISTER_PREFIX__ 
 // PPC-DARWIN:#define __SCHAR_MAX__ 127
 // PPC-DARWIN:#define __SHRT_MAX__ 32767
+// PPC-DARWIN:#define __SIG_ATOMIC_MAX__ 2147483647
 // PPC-DARWIN:#define __SIG_ATOMIC_WIDTH__ 32
 // PPC-DARWIN:#define __SIZEOF_DOUBLE__ 8
 // PPC-DARWIN:#define __SIZEOF_FLOAT__ 4
@@ -4601,10 +5651,10 @@
 // PPC-DARWIN:#define __SIZE_TYPE__ long unsigned int
 // PPC-DARWIN:#define __SIZE_WIDTH__ 32
 // PPC-DARWIN:#define __STDC_HOSTED__ 0
-// PPC-DARWIN:#define __STDC_VERSION__ 199901L
+// PPC-DARWIN:#define __STDC_VERSION__ 201112L
 // PPC-DARWIN:#define __STDC__ 1
-// PPC-DARWIN:#define __UINT16_C_SUFFIX__ U
-// PPC-DARWIN:#define __UINT16_MAX__ 65535U
+// PPC-DARWIN:#define __UINT16_C_SUFFIX__ {{$}}
+// PPC-DARWIN:#define __UINT16_MAX__ 65535
 // PPC-DARWIN:#define __UINT16_TYPE__ unsigned short
 // PPC-DARWIN:#define __UINT32_C_SUFFIX__ U
 // PPC-DARWIN:#define __UINT32_MAX__ 4294967295U
@@ -4612,30 +5662,31 @@
 // PPC-DARWIN:#define __UINT64_C_SUFFIX__ ULL
 // PPC-DARWIN:#define __UINT64_MAX__ 18446744073709551615ULL
 // PPC-DARWIN:#define __UINT64_TYPE__ long long unsigned int
-// PPC-DARWIN:#define __UINT8_C_SUFFIX__ U
-// PPC-DARWIN:#define __UINT8_MAX__ 255U
+// PPC-DARWIN:#define __UINT8_C_SUFFIX__ {{$}}
+// PPC-DARWIN:#define __UINT8_MAX__ 255
 // PPC-DARWIN:#define __UINT8_TYPE__ unsigned char
+// PPC-DARWIN:#define __UINTMAX_C_SUFFIX__ ULL
 // PPC-DARWIN:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // PPC-DARWIN:#define __UINTMAX_TYPE__ long long unsigned int
 // PPC-DARWIN:#define __UINTMAX_WIDTH__ 64
 // PPC-DARWIN:#define __UINTPTR_MAX__ 4294967295U
-// PPC-DARWIN:#define __UINTPTR_TYPE__ unsigned int
+// PPC-DARWIN:#define __UINTPTR_TYPE__ long unsigned int
 // PPC-DARWIN:#define __UINTPTR_WIDTH__ 32
-// PPC-DARWIN:#define __UINT_FAST16_MAX__ 65535U
+// PPC-DARWIN:#define __UINT_FAST16_MAX__ 65535
 // PPC-DARWIN:#define __UINT_FAST16_TYPE__ unsigned short
 // PPC-DARWIN:#define __UINT_FAST32_MAX__ 4294967295U
 // PPC-DARWIN:#define __UINT_FAST32_TYPE__ unsigned int
 // PPC-DARWIN:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // PPC-DARWIN:#define __UINT_FAST64_TYPE__ long long unsigned int
-// PPC-DARWIN:#define __UINT_FAST8_MAX__ 255U
+// PPC-DARWIN:#define __UINT_FAST8_MAX__ 255
 // PPC-DARWIN:#define __UINT_FAST8_TYPE__ unsigned char
-// PPC-DARWIN:#define __UINT_LEAST16_MAX__ 65535U
+// PPC-DARWIN:#define __UINT_LEAST16_MAX__ 65535
 // PPC-DARWIN:#define __UINT_LEAST16_TYPE__ unsigned short
 // PPC-DARWIN:#define __UINT_LEAST32_MAX__ 4294967295U
 // PPC-DARWIN:#define __UINT_LEAST32_TYPE__ unsigned int
 // PPC-DARWIN:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // PPC-DARWIN:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// PPC-DARWIN:#define __UINT_LEAST8_MAX__ 255U
+// PPC-DARWIN:#define __UINT_LEAST8_MAX__ 255
 // PPC-DARWIN:#define __UINT_LEAST8_TYPE__ unsigned char
 // PPC-DARWIN:#define __USER_LABEL_PREFIX__ _
 // PPC-DARWIN:#define __WCHAR_MAX__ 2147483647
@@ -4681,37 +5732,69 @@
 // S390X:#define __FLT_MIN_EXP__ (-125)
 // S390X:#define __FLT_MIN__ 1.17549435e-38F
 // S390X:#define __FLT_RADIX__ 2
+// S390X:#define __INT16_C_SUFFIX__ {{$}}
+// S390X:#define __INT16_FMTd__ "hd"
+// S390X:#define __INT16_FMTi__ "hi"
 // S390X:#define __INT16_MAX__ 32767
 // S390X:#define __INT16_TYPE__ short
+// S390X:#define __INT32_C_SUFFIX__ {{$}}
+// S390X:#define __INT32_FMTd__ "d"
+// S390X:#define __INT32_FMTi__ "i"
 // S390X:#define __INT32_MAX__ 2147483647
 // S390X:#define __INT32_TYPE__ int
 // S390X:#define __INT64_C_SUFFIX__ LL
+// S390X:#define __INT64_FMTd__ "lld"
+// S390X:#define __INT64_FMTi__ "lli"
 // S390X:#define __INT64_MAX__ 9223372036854775807LL
 // S390X:#define __INT64_TYPE__ long long int
+// S390X:#define __INT8_C_SUFFIX__ {{$}}
+// S390X:#define __INT8_FMTd__ "hhd"
+// S390X:#define __INT8_FMTi__ "hhi"
 // S390X:#define __INT8_MAX__ 127
-// S390X:#define __INT8_TYPE__ char
+// S390X:#define __INT8_TYPE__ signed char
+// S390X:#define __INTMAX_C_SUFFIX__ LL
+// S390X:#define __INTMAX_FMTd__ "lld"
+// S390X:#define __INTMAX_FMTi__ "lli"
 // S390X:#define __INTMAX_MAX__ 9223372036854775807LL
 // S390X:#define __INTMAX_TYPE__ long long int
 // S390X:#define __INTMAX_WIDTH__ 64
+// S390X:#define __INTPTR_FMTd__ "ld"
+// S390X:#define __INTPTR_FMTi__ "li"
 // S390X:#define __INTPTR_MAX__ 9223372036854775807L
 // S390X:#define __INTPTR_TYPE__ long int
 // S390X:#define __INTPTR_WIDTH__ 64
+// S390X:#define __INT_FAST16_FMTd__ "hd"
+// S390X:#define __INT_FAST16_FMTi__ "hi"
 // S390X:#define __INT_FAST16_MAX__ 32767
 // S390X:#define __INT_FAST16_TYPE__ short
+// S390X:#define __INT_FAST32_FMTd__ "d"
+// S390X:#define __INT_FAST32_FMTi__ "i"
 // S390X:#define __INT_FAST32_MAX__ 2147483647
 // S390X:#define __INT_FAST32_TYPE__ int
+// S390X:#define __INT_FAST64_FMTd__ "ld"
+// S390X:#define __INT_FAST64_FMTi__ "li"
 // S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
 // S390X:#define __INT_FAST64_TYPE__ long int
+// S390X:#define __INT_FAST8_FMTd__ "hhd"
+// S390X:#define __INT_FAST8_FMTi__ "hhi"
 // S390X:#define __INT_FAST8_MAX__ 127
-// S390X:#define __INT_FAST8_TYPE__ char
+// S390X:#define __INT_FAST8_TYPE__ signed char
+// S390X:#define __INT_LEAST16_FMTd__ "hd"
+// S390X:#define __INT_LEAST16_FMTi__ "hi"
 // S390X:#define __INT_LEAST16_MAX__ 32767
 // S390X:#define __INT_LEAST16_TYPE__ short
+// S390X:#define __INT_LEAST32_FMTd__ "d"
+// S390X:#define __INT_LEAST32_FMTi__ "i"
 // S390X:#define __INT_LEAST32_MAX__ 2147483647
 // S390X:#define __INT_LEAST32_TYPE__ int
+// S390X:#define __INT_LEAST64_FMTd__ "ld"
+// S390X:#define __INT_LEAST64_FMTi__ "li"
 // S390X:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // S390X:#define __INT_LEAST64_TYPE__ long int
+// S390X:#define __INT_LEAST8_FMTd__ "hhd"
+// S390X:#define __INT_LEAST8_FMTi__ "hhi"
 // S390X:#define __INT_LEAST8_MAX__ 127
-// S390X:#define __INT_LEAST8_TYPE__ char
+// S390X:#define __INT_LEAST8_TYPE__ signed char
 // S390X:#define __INT_MAX__ 2147483647
 // S390X:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
 // S390X:#define __LDBL_DIG__ 33
@@ -4734,6 +5817,7 @@
 // S390X:#define __PTRDIFF_WIDTH__ 64
 // S390X:#define __SCHAR_MAX__ 127
 // S390X:#define __SHRT_MAX__ 32767
+// S390X:#define __SIG_ATOMIC_MAX__ 2147483647
 // S390X:#define __SIG_ATOMIC_WIDTH__ 32
 // S390X:#define __SIZEOF_DOUBLE__ 8
 // S390X:#define __SIZEOF_FLOAT__ 4
@@ -4749,39 +5833,40 @@
 // S390X:#define __SIZEOF_WINT_T__ 4
 // S390X:#define __SIZE_TYPE__ long unsigned int
 // S390X:#define __SIZE_WIDTH__ 64
-// S390X:#define __UINT16_C_SUFFIX__ U
-// S390X:#define __UINT16_MAX__ 65535U
+// S390X:#define __UINT16_C_SUFFIX__ {{$}}
+// S390X:#define __UINT16_MAX__ 65535
 // S390X:#define __UINT16_TYPE__ unsigned short
 // S390X:#define __UINT32_C_SUFFIX__ U
 // S390X:#define __UINT32_MAX__ 4294967295U
 // S390X:#define __UINT32_TYPE__ unsigned int
-// S390X:#define __UINT64_C_SUFFIX__ UL
-// S390X:#define __UINT64_MAX__ 18446744073709551615UL
-// S390X:#define __UINT64_TYPE__ long unsigned int
-// S390X:#define __UINT8_C_SUFFIX__ U
-// S390X:#define __UINT8_MAX__ 255U
+// S390X:#define __UINT64_C_SUFFIX__ ULL
+// S390X:#define __UINT64_MAX__ 18446744073709551615ULL
+// S390X:#define __UINT64_TYPE__ long long unsigned int
+// S390X:#define __UINT8_C_SUFFIX__ {{$}}
+// S390X:#define __UINT8_MAX__ 255
 // S390X:#define __UINT8_TYPE__ unsigned char
+// S390X:#define __UINTMAX_C_SUFFIX__ ULL
 // S390X:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // S390X:#define __UINTMAX_TYPE__ long long unsigned int
 // S390X:#define __UINTMAX_WIDTH__ 64
 // S390X:#define __UINTPTR_MAX__ 18446744073709551615UL
 // S390X:#define __UINTPTR_TYPE__ long unsigned int
 // S390X:#define __UINTPTR_WIDTH__ 64
-// S390X:#define __UINT_FAST16_MAX__ 65535U
+// S390X:#define __UINT_FAST16_MAX__ 65535
 // S390X:#define __UINT_FAST16_TYPE__ unsigned short
 // S390X:#define __UINT_FAST32_MAX__ 4294967295U
 // S390X:#define __UINT_FAST32_TYPE__ unsigned int
 // S390X:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // S390X:#define __UINT_FAST64_TYPE__ long unsigned int
-// S390X:#define __UINT_FAST8_MAX__ 255U
+// S390X:#define __UINT_FAST8_MAX__ 255
 // S390X:#define __UINT_FAST8_TYPE__ unsigned char
-// S390X:#define __UINT_LEAST16_MAX__ 65535U
+// S390X:#define __UINT_LEAST16_MAX__ 65535
 // S390X:#define __UINT_LEAST16_TYPE__ unsigned short
 // S390X:#define __UINT_LEAST32_MAX__ 4294967295U
 // S390X:#define __UINT_LEAST32_TYPE__ unsigned int
 // S390X:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // S390X:#define __UINT_LEAST64_TYPE__ long unsigned int
-// S390X:#define __UINT_LEAST8_MAX__ 255U
+// S390X:#define __UINT_LEAST8_MAX__ 255
 // S390X:#define __UINT_LEAST8_TYPE__ unsigned char
 // S390X:#define __USER_LABEL_PREFIX__ _
 // S390X:#define __WCHAR_MAX__ 2147483647
@@ -4829,37 +5914,69 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __INT16_C_SUFFIX__ {{$}}
+// SPARC:#define __INT16_FMTd__ "hd"
+// SPARC:#define __INT16_FMTi__ "hi"
 // SPARC:#define __INT16_MAX__ 32767
 // SPARC:#define __INT16_TYPE__ short
+// SPARC:#define __INT32_C_SUFFIX__ {{$}}
+// SPARC:#define __INT32_FMTd__ "d"
+// SPARC:#define __INT32_FMTi__ "i"
 // SPARC:#define __INT32_MAX__ 2147483647
 // SPARC:#define __INT32_TYPE__ int
 // SPARC:#define __INT64_C_SUFFIX__ LL
+// SPARC:#define __INT64_FMTd__ "lld"
+// SPARC:#define __INT64_FMTi__ "lli"
 // SPARC:#define __INT64_MAX__ 9223372036854775807LL
 // SPARC:#define __INT64_TYPE__ long long int
+// SPARC:#define __INT8_C_SUFFIX__ {{$}}
+// SPARC:#define __INT8_FMTd__ "hhd"
+// SPARC:#define __INT8_FMTi__ "hhi"
 // SPARC:#define __INT8_MAX__ 127
-// SPARC:#define __INT8_TYPE__ char
+// SPARC:#define __INT8_TYPE__ signed char
+// SPARC:#define __INTMAX_C_SUFFIX__ LL
+// SPARC:#define __INTMAX_FMTd__ "lld"
+// SPARC:#define __INTMAX_FMTi__ "lli"
 // SPARC:#define __INTMAX_MAX__ 9223372036854775807LL
 // SPARC:#define __INTMAX_TYPE__ long long int
 // SPARC:#define __INTMAX_WIDTH__ 64
+// SPARC:#define __INTPTR_FMTd__ "ld"
+// SPARC:#define __INTPTR_FMTi__ "li"
 // SPARC:#define __INTPTR_MAX__ 2147483647L
 // SPARC:#define __INTPTR_TYPE__ long int
 // SPARC:#define __INTPTR_WIDTH__ 32
+// SPARC:#define __INT_FAST16_FMTd__ "hd"
+// SPARC:#define __INT_FAST16_FMTi__ "hi"
 // SPARC:#define __INT_FAST16_MAX__ 32767
 // SPARC:#define __INT_FAST16_TYPE__ short
+// SPARC:#define __INT_FAST32_FMTd__ "d"
+// SPARC:#define __INT_FAST32_FMTi__ "i"
 // SPARC:#define __INT_FAST32_MAX__ 2147483647
 // SPARC:#define __INT_FAST32_TYPE__ int
+// SPARC:#define __INT_FAST64_FMTd__ "lld"
+// SPARC:#define __INT_FAST64_FMTi__ "lli"
 // SPARC:#define __INT_FAST64_MAX__ 9223372036854775807LL
 // SPARC:#define __INT_FAST64_TYPE__ long long int
+// SPARC:#define __INT_FAST8_FMTd__ "hhd"
+// SPARC:#define __INT_FAST8_FMTi__ "hhi"
 // SPARC:#define __INT_FAST8_MAX__ 127
-// SPARC:#define __INT_FAST8_TYPE__ char
+// SPARC:#define __INT_FAST8_TYPE__ signed char
+// SPARC:#define __INT_LEAST16_FMTd__ "hd"
+// SPARC:#define __INT_LEAST16_FMTi__ "hi"
 // SPARC:#define __INT_LEAST16_MAX__ 32767
 // SPARC:#define __INT_LEAST16_TYPE__ short
+// SPARC:#define __INT_LEAST32_FMTd__ "d"
+// SPARC:#define __INT_LEAST32_FMTi__ "i"
 // SPARC:#define __INT_LEAST32_MAX__ 2147483647
 // SPARC:#define __INT_LEAST32_TYPE__ int
+// SPARC:#define __INT_LEAST64_FMTd__ "lld"
+// SPARC:#define __INT_LEAST64_FMTi__ "lli"
 // SPARC:#define __INT_LEAST64_MAX__ 9223372036854775807LL
 // SPARC:#define __INT_LEAST64_TYPE__ long long int
+// SPARC:#define __INT_LEAST8_FMTd__ "hhd"
+// SPARC:#define __INT_LEAST8_FMTi__ "hhi"
 // SPARC:#define __INT_LEAST8_MAX__ 127
-// SPARC:#define __INT_LEAST8_TYPE__ char
+// SPARC:#define __INT_LEAST8_TYPE__ signed char
 // SPARC:#define __INT_MAX__ 2147483647
 // SPARC:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
 // SPARC:#define __LDBL_DIG__ 15
@@ -4883,6 +6000,7 @@
 // SPARC:#define __REGISTER_PREFIX__
 // SPARC:#define __SCHAR_MAX__ 127
 // SPARC:#define __SHRT_MAX__ 32767
+// SPARC:#define __SIG_ATOMIC_MAX__ 2147483647
 // SPARC:#define __SIG_ATOMIC_WIDTH__ 32
 // SPARC:#define __SIZEOF_DOUBLE__ 8
 // SPARC:#define __SIZEOF_FLOAT__ 4
@@ -4899,8 +6017,8 @@
 // SPARC:#define __SIZE_MAX__ 4294967295U
 // SPARC:#define __SIZE_TYPE__ long unsigned int
 // SPARC:#define __SIZE_WIDTH__ 32
-// SPARC:#define __UINT16_C_SUFFIX__ U
-// SPARC:#define __UINT16_MAX__ 65535U
+// SPARC:#define __UINT16_C_SUFFIX__ {{$}}
+// SPARC:#define __UINT16_MAX__ 65535
 // SPARC:#define __UINT16_TYPE__ unsigned short
 // SPARC:#define __UINT32_C_SUFFIX__ U
 // SPARC:#define __UINT32_MAX__ 4294967295U
@@ -4908,30 +6026,31 @@
 // SPARC:#define __UINT64_C_SUFFIX__ ULL
 // SPARC:#define __UINT64_MAX__ 18446744073709551615ULL
 // SPARC:#define __UINT64_TYPE__ long long unsigned int
-// SPARC:#define __UINT8_C_SUFFIX__ U
-// SPARC:#define __UINT8_MAX__ 255U
+// SPARC:#define __UINT8_C_SUFFIX__ {{$}}
+// SPARC:#define __UINT8_MAX__ 255
 // SPARC:#define __UINT8_TYPE__ unsigned char
+// SPARC:#define __UINTMAX_C_SUFFIX__ ULL
 // SPARC:#define __UINTMAX_MAX__ 18446744073709551615ULL
 // SPARC:#define __UINTMAX_TYPE__ long long unsigned int
 // SPARC:#define __UINTMAX_WIDTH__ 64
 // SPARC:#define __UINTPTR_MAX__ 4294967295U
-// SPARC:#define __UINTPTR_TYPE__ unsigned int
+// SPARC:#define __UINTPTR_TYPE__ long unsigned int
 // SPARC:#define __UINTPTR_WIDTH__ 32
-// SPARC:#define __UINT_FAST16_MAX__ 65535U
+// SPARC:#define __UINT_FAST16_MAX__ 65535
 // SPARC:#define __UINT_FAST16_TYPE__ unsigned short
 // SPARC:#define __UINT_FAST32_MAX__ 4294967295U
 // SPARC:#define __UINT_FAST32_TYPE__ unsigned int
 // SPARC:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
 // SPARC:#define __UINT_FAST64_TYPE__ long long unsigned int
-// SPARC:#define __UINT_FAST8_MAX__ 255U
+// SPARC:#define __UINT_FAST8_MAX__ 255
 // SPARC:#define __UINT_FAST8_TYPE__ unsigned char
-// SPARC:#define __UINT_LEAST16_MAX__ 65535U
+// SPARC:#define __UINT_LEAST16_MAX__ 65535
 // SPARC:#define __UINT_LEAST16_TYPE__ unsigned short
 // SPARC:#define __UINT_LEAST32_MAX__ 4294967295U
 // SPARC:#define __UINT_LEAST32_TYPE__ unsigned int
 // SPARC:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
 // SPARC:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// SPARC:#define __UINT_LEAST8_MAX__ 255U
+// SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__ _
 // SPARC:#define __VERSION__ "4.2.1 Compatible
@@ -4982,30 +6101,56 @@
 // TCE:#define __FLT_MIN_EXP__ (-125)
 // TCE:#define __FLT_MIN__ 1.17549435e-38F
 // TCE:#define __FLT_RADIX__ 2
+// TCE:#define __INT16_C_SUFFIX__ {{$}}
+// TCE:#define __INT16_FMTd__ "hd"
+// TCE:#define __INT16_FMTi__ "hi"
 // TCE:#define __INT16_MAX__ 32767
 // TCE:#define __INT16_TYPE__ short
+// TCE:#define __INT32_C_SUFFIX__ {{$}}
+// TCE:#define __INT32_FMTd__ "d"
+// TCE:#define __INT32_FMTi__ "i"
 // TCE:#define __INT32_MAX__ 2147483647
 // TCE:#define __INT32_TYPE__ int
+// TCE:#define __INT8_C_SUFFIX__ {{$}}
+// TCE:#define __INT8_FMTd__ "hhd"
+// TCE:#define __INT8_FMTi__ "hhi"
 // TCE:#define __INT8_MAX__ 127
-// TCE:#define __INT8_TYPE__ char
+// TCE:#define __INT8_TYPE__ signed char
+// TCE:#define __INTMAX_C_SUFFIX__ L
+// TCE:#define __INTMAX_FMTd__ "ld"
+// TCE:#define __INTMAX_FMTi__ "li"
 // TCE:#define __INTMAX_MAX__ 2147483647L
 // TCE:#define __INTMAX_TYPE__ long int
 // TCE:#define __INTMAX_WIDTH__ 32
+// TCE:#define __INTPTR_FMTd__ "d"
+// TCE:#define __INTPTR_FMTi__ "i"
 // TCE:#define __INTPTR_MAX__ 2147483647
 // TCE:#define __INTPTR_TYPE__ int
 // TCE:#define __INTPTR_WIDTH__ 32
+// TCE:#define __INT_FAST16_FMTd__ "hd"
+// TCE:#define __INT_FAST16_FMTi__ "hi"
 // TCE:#define __INT_FAST16_MAX__ 32767
 // TCE:#define __INT_FAST16_TYPE__ short
+// TCE:#define __INT_FAST32_FMTd__ "d"
+// TCE:#define __INT_FAST32_FMTi__ "i"
 // TCE:#define __INT_FAST32_MAX__ 2147483647
 // TCE:#define __INT_FAST32_TYPE__ int
+// TCE:#define __INT_FAST8_FMTd__ "hhd"
+// TCE:#define __INT_FAST8_FMTi__ "hhi"
 // TCE:#define __INT_FAST8_MAX__ 127
-// TCE:#define __INT_FAST8_TYPE__ char
+// TCE:#define __INT_FAST8_TYPE__ signed char
+// TCE:#define __INT_LEAST16_FMTd__ "hd"
+// TCE:#define __INT_LEAST16_FMTi__ "hi"
 // TCE:#define __INT_LEAST16_MAX__ 32767
 // TCE:#define __INT_LEAST16_TYPE__ short
+// TCE:#define __INT_LEAST32_FMTd__ "d"
+// TCE:#define __INT_LEAST32_FMTi__ "i"
 // TCE:#define __INT_LEAST32_MAX__ 2147483647
 // TCE:#define __INT_LEAST32_TYPE__ int
+// TCE:#define __INT_LEAST8_FMTd__ "hhd"
+// TCE:#define __INT_LEAST8_FMTi__ "hhi"
 // TCE:#define __INT_LEAST8_MAX__ 127
-// TCE:#define __INT_LEAST8_TYPE__ char
+// TCE:#define __INT_LEAST8_TYPE__ signed char
 // TCE:#define __INT_MAX__ 2147483647
 // TCE:#define __LDBL_DENORM_MIN__ 1.40129846e-45L
 // TCE:#define __LDBL_DIG__ 6
@@ -5028,6 +6173,7 @@
 // TCE:#define __PTRDIFF_WIDTH__ 32
 // TCE:#define __SCHAR_MAX__ 127
 // TCE:#define __SHRT_MAX__ 32767
+// TCE:#define __SIG_ATOMIC_MAX__ 2147483647
 // TCE:#define __SIG_ATOMIC_WIDTH__ 32
 // TCE:#define __SIZEOF_DOUBLE__ 4
 // TCE:#define __SIZEOF_FLOAT__ 4
@@ -5046,32 +6192,33 @@
 // TCE:#define __SIZE_WIDTH__ 32
 // TCE:#define __TCE_V1__ 1
 // TCE:#define __TCE__ 1
-// TCE:#define __UINT16_C_SUFFIX__ U
-// TCE:#define __UINT16_MAX__ 65535U
+// TCE:#define __UINT16_C_SUFFIX__ {{$}}
+// TCE:#define __UINT16_MAX__ 65535
 // TCE:#define __UINT16_TYPE__ unsigned short
 // TCE:#define __UINT32_C_SUFFIX__ U
 // TCE:#define __UINT32_MAX__ 4294967295U
 // TCE:#define __UINT32_TYPE__ unsigned int
-// TCE:#define __UINT8_C_SUFFIX__ U
-// TCE:#define __UINT8_MAX__ 255U
+// TCE:#define __UINT8_C_SUFFIX__ {{$}}
+// TCE:#define __UINT8_MAX__ 255
 // TCE:#define __UINT8_TYPE__ unsigned char
+// TCE:#define __UINTMAX_C_SUFFIX__ UL
 // TCE:#define __UINTMAX_MAX__ 4294967295UL
 // TCE:#define __UINTMAX_TYPE__ long unsigned int
 // TCE:#define __UINTMAX_WIDTH__ 32
 // TCE:#define __UINTPTR_MAX__ 4294967295U
 // TCE:#define __UINTPTR_TYPE__ unsigned int
 // TCE:#define __UINTPTR_WIDTH__ 32
-// TCE:#define __UINT_FAST16_MAX__ 65535U
+// TCE:#define __UINT_FAST16_MAX__ 65535
 // TCE:#define __UINT_FAST16_TYPE__ unsigned short
 // TCE:#define __UINT_FAST32_MAX__ 4294967295U
 // TCE:#define __UINT_FAST32_TYPE__ unsigned int
-// TCE:#define __UINT_FAST8_MAX__ 255U
+// TCE:#define __UINT_FAST8_MAX__ 255
 // TCE:#define __UINT_FAST8_TYPE__ unsigned char
-// TCE:#define __UINT_LEAST16_MAX__ 65535U
+// TCE:#define __UINT_LEAST16_MAX__ 65535
 // TCE:#define __UINT_LEAST16_TYPE__ unsigned short
 // TCE:#define __UINT_LEAST32_MAX__ 4294967295U
 // TCE:#define __UINT_LEAST32_TYPE__ unsigned int
-// TCE:#define __UINT_LEAST8_MAX__ 255U
+// TCE:#define __UINT_LEAST8_MAX__ 255
 // TCE:#define __UINT_LEAST8_TYPE__ unsigned char
 // TCE:#define __USER_LABEL_PREFIX__ _
 // TCE:#define __WCHAR_MAX__ 2147483647
@@ -5086,6 +6233,7 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none < /dev/null | FileCheck -check-prefix X86_64 %s
 //
 // X86_64:#define _LP64 1
+// X86_64-NOT:#define _LP32 1
 // X86_64:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // X86_64:#define __CHAR16_TYPE__ unsigned short
 // X86_64:#define __CHAR32_TYPE__ unsigned int
@@ -5119,37 +6267,69 @@
 // X86_64:#define __FLT_MIN_EXP__ (-125)
 // X86_64:#define __FLT_MIN__ 1.17549435e-38F
 // X86_64:#define __FLT_RADIX__ 2
+// X86_64:#define __INT16_C_SUFFIX__ {{$}}
+// X86_64:#define __INT16_FMTd__ "hd"
+// X86_64:#define __INT16_FMTi__ "hi"
 // X86_64:#define __INT16_MAX__ 32767
 // X86_64:#define __INT16_TYPE__ short
+// X86_64:#define __INT32_C_SUFFIX__ {{$}}
+// X86_64:#define __INT32_FMTd__ "d"
+// X86_64:#define __INT32_FMTi__ "i"
 // X86_64:#define __INT32_MAX__ 2147483647
 // X86_64:#define __INT32_TYPE__ int
 // X86_64:#define __INT64_C_SUFFIX__ L
+// X86_64:#define __INT64_FMTd__ "ld"
+// X86_64:#define __INT64_FMTi__ "li"
 // X86_64:#define __INT64_MAX__ 9223372036854775807L
 // X86_64:#define __INT64_TYPE__ long int
+// X86_64:#define __INT8_C_SUFFIX__ {{$}}
+// X86_64:#define __INT8_FMTd__ "hhd"
+// X86_64:#define __INT8_FMTi__ "hhi"
 // X86_64:#define __INT8_MAX__ 127
-// X86_64:#define __INT8_TYPE__ char
+// X86_64:#define __INT8_TYPE__ signed char
+// X86_64:#define __INTMAX_C_SUFFIX__ L
+// X86_64:#define __INTMAX_FMTd__ "ld"
+// X86_64:#define __INTMAX_FMTi__ "li"
 // X86_64:#define __INTMAX_MAX__ 9223372036854775807L
 // X86_64:#define __INTMAX_TYPE__ long int
 // X86_64:#define __INTMAX_WIDTH__ 64
+// X86_64:#define __INTPTR_FMTd__ "ld"
+// X86_64:#define __INTPTR_FMTi__ "li"
 // X86_64:#define __INTPTR_MAX__ 9223372036854775807L
 // X86_64:#define __INTPTR_TYPE__ long int
 // X86_64:#define __INTPTR_WIDTH__ 64
+// X86_64:#define __INT_FAST16_FMTd__ "hd"
+// X86_64:#define __INT_FAST16_FMTi__ "hi"
 // X86_64:#define __INT_FAST16_MAX__ 32767
 // X86_64:#define __INT_FAST16_TYPE__ short
+// X86_64:#define __INT_FAST32_FMTd__ "d"
+// X86_64:#define __INT_FAST32_FMTi__ "i"
 // X86_64:#define __INT_FAST32_MAX__ 2147483647
 // X86_64:#define __INT_FAST32_TYPE__ int
+// X86_64:#define __INT_FAST64_FMTd__ "ld"
+// X86_64:#define __INT_FAST64_FMTi__ "li"
 // X86_64:#define __INT_FAST64_MAX__ 9223372036854775807L
 // X86_64:#define __INT_FAST64_TYPE__ long int
+// X86_64:#define __INT_FAST8_FMTd__ "hhd"
+// X86_64:#define __INT_FAST8_FMTi__ "hhi"
 // X86_64:#define __INT_FAST8_MAX__ 127
-// X86_64:#define __INT_FAST8_TYPE__ char
+// X86_64:#define __INT_FAST8_TYPE__ signed char
+// X86_64:#define __INT_LEAST16_FMTd__ "hd"
+// X86_64:#define __INT_LEAST16_FMTi__ "hi"
 // X86_64:#define __INT_LEAST16_MAX__ 32767
 // X86_64:#define __INT_LEAST16_TYPE__ short
+// X86_64:#define __INT_LEAST32_FMTd__ "d"
+// X86_64:#define __INT_LEAST32_FMTi__ "i"
 // X86_64:#define __INT_LEAST32_MAX__ 2147483647
 // X86_64:#define __INT_LEAST32_TYPE__ int
+// X86_64:#define __INT_LEAST64_FMTd__ "ld"
+// X86_64:#define __INT_LEAST64_FMTi__ "li"
 // X86_64:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // X86_64:#define __INT_LEAST64_TYPE__ long int
+// X86_64:#define __INT_LEAST8_FMTd__ "hhd"
+// X86_64:#define __INT_LEAST8_FMTi__ "hhi"
 // X86_64:#define __INT_LEAST8_MAX__ 127
-// X86_64:#define __INT_LEAST8_TYPE__ char
+// X86_64:#define __INT_LEAST8_TYPE__ signed char
 // X86_64:#define __INT_MAX__ 2147483647
 // X86_64:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
 // X86_64:#define __LDBL_DIG__ 18
@@ -5168,6 +6348,7 @@
 // X86_64:#define __LONG_LONG_MAX__ 9223372036854775807LL
 // X86_64:#define __LONG_MAX__ 9223372036854775807L
 // X86_64:#define __LP64__ 1
+// X86_64-NOT:#define __ILP32__ 1
 // X86_64:#define __MMX__ 1
 // X86_64:#define __NO_MATH_INLINES 1
 // X86_64:#define __POINTER_WIDTH__ 64
@@ -5176,6 +6357,7 @@
 // X86_64:#define __REGISTER_PREFIX__ 
 // X86_64:#define __SCHAR_MAX__ 127
 // X86_64:#define __SHRT_MAX__ 32767
+// X86_64:#define __SIG_ATOMIC_MAX__ 2147483647
 // X86_64:#define __SIG_ATOMIC_WIDTH__ 32
 // X86_64:#define __SIZEOF_DOUBLE__ 8
 // X86_64:#define __SIZEOF_FLOAT__ 4
@@ -5196,8 +6378,8 @@
 // X86_64:#define __SSE2__ 1
 // X86_64:#define __SSE_MATH__ 1
 // X86_64:#define __SSE__ 1
-// X86_64:#define __UINT16_C_SUFFIX__ U
-// X86_64:#define __UINT16_MAX__ 65535U
+// X86_64:#define __UINT16_C_SUFFIX__ {{$}}
+// X86_64:#define __UINT16_MAX__ 65535
 // X86_64:#define __UINT16_TYPE__ unsigned short
 // X86_64:#define __UINT32_C_SUFFIX__ U
 // X86_64:#define __UINT32_MAX__ 4294967295U
@@ -5205,30 +6387,31 @@
 // X86_64:#define __UINT64_C_SUFFIX__ UL
 // X86_64:#define __UINT64_MAX__ 18446744073709551615UL
 // X86_64:#define __UINT64_TYPE__ long unsigned int
-// X86_64:#define __UINT8_C_SUFFIX__ U
-// X86_64:#define __UINT8_MAX__ 255U
+// X86_64:#define __UINT8_C_SUFFIX__ {{$}}
+// X86_64:#define __UINT8_MAX__ 255
 // X86_64:#define __UINT8_TYPE__ unsigned char
+// X86_64:#define __UINTMAX_C_SUFFIX__ UL
 // X86_64:#define __UINTMAX_MAX__ 18446744073709551615UL
 // X86_64:#define __UINTMAX_TYPE__ long unsigned int
 // X86_64:#define __UINTMAX_WIDTH__ 64
 // X86_64:#define __UINTPTR_MAX__ 18446744073709551615UL
 // X86_64:#define __UINTPTR_TYPE__ long unsigned int
 // X86_64:#define __UINTPTR_WIDTH__ 64
-// X86_64:#define __UINT_FAST16_MAX__ 65535U
+// X86_64:#define __UINT_FAST16_MAX__ 65535
 // X86_64:#define __UINT_FAST16_TYPE__ unsigned short
 // X86_64:#define __UINT_FAST32_MAX__ 4294967295U
 // X86_64:#define __UINT_FAST32_TYPE__ unsigned int
 // X86_64:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // X86_64:#define __UINT_FAST64_TYPE__ long unsigned int
-// X86_64:#define __UINT_FAST8_MAX__ 255U
+// X86_64:#define __UINT_FAST8_MAX__ 255
 // X86_64:#define __UINT_FAST8_TYPE__ unsigned char
-// X86_64:#define __UINT_LEAST16_MAX__ 65535U
+// X86_64:#define __UINT_LEAST16_MAX__ 65535
 // X86_64:#define __UINT_LEAST16_TYPE__ unsigned short
 // X86_64:#define __UINT_LEAST32_MAX__ 4294967295U
 // X86_64:#define __UINT_LEAST32_TYPE__ unsigned int
 // X86_64:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // X86_64:#define __UINT_LEAST64_TYPE__ long unsigned int
-// X86_64:#define __UINT_LEAST8_MAX__ 255U
+// X86_64:#define __UINT_LEAST8_MAX__ 255
 // X86_64:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64:#define __USER_LABEL_PREFIX__ _
 // X86_64:#define __WCHAR_MAX__ 2147483647
@@ -5241,6 +6424,207 @@
 // X86_64:#define __x86_64 1
 // X86_64:#define __x86_64__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64h-none-none < /dev/null | FileCheck -check-prefix X86_64H %s
+//
+// X86_64H:#define __x86_64 1
+// X86_64H:#define __x86_64__ 1
+// X86_64H:#define __x86_64h 1
+// X86_64H:#define __x86_64h__ 1
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -check-prefix X32 %s
+//
+// X32:#define _ILP32 1
+// X32-NOT:#define _LP64 1
+// X32:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// X32:#define __CHAR16_TYPE__ unsigned short
+// X32:#define __CHAR32_TYPE__ unsigned int
+// X32:#define __CHAR_BIT__ 8
+// X32:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// X32:#define __DBL_DIG__ 15
+// X32:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// X32:#define __DBL_HAS_DENORM__ 1
+// X32:#define __DBL_HAS_INFINITY__ 1
+// X32:#define __DBL_HAS_QUIET_NAN__ 1
+// X32:#define __DBL_MANT_DIG__ 53
+// X32:#define __DBL_MAX_10_EXP__ 308
+// X32:#define __DBL_MAX_EXP__ 1024
+// X32:#define __DBL_MAX__ 1.7976931348623157e+308
+// X32:#define __DBL_MIN_10_EXP__ (-307)
+// X32:#define __DBL_MIN_EXP__ (-1021)
+// X32:#define __DBL_MIN__ 2.2250738585072014e-308
+// X32:#define __DECIMAL_DIG__ 21
+// X32:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// X32:#define __FLT_DIG__ 6
+// X32:#define __FLT_EPSILON__ 1.19209290e-7F
+// X32:#define __FLT_EVAL_METHOD__ 0
+// X32:#define __FLT_HAS_DENORM__ 1
+// X32:#define __FLT_HAS_INFINITY__ 1
+// X32:#define __FLT_HAS_QUIET_NAN__ 1
+// X32:#define __FLT_MANT_DIG__ 24
+// X32:#define __FLT_MAX_10_EXP__ 38
+// X32:#define __FLT_MAX_EXP__ 128
+// X32:#define __FLT_MAX__ 3.40282347e+38F
+// X32:#define __FLT_MIN_10_EXP__ (-37)
+// X32:#define __FLT_MIN_EXP__ (-125)
+// X32:#define __FLT_MIN__ 1.17549435e-38F
+// X32:#define __FLT_RADIX__ 2
+// X32:#define __ILP32__ 1
+// X32-NOT:#define __LP64__ 1
+// X32:#define __INT16_C_SUFFIX__ {{$}}
+// X32:#define __INT16_FMTd__ "hd"
+// X32:#define __INT16_FMTi__ "hi"
+// X32:#define __INT16_MAX__ 32767
+// X32:#define __INT16_TYPE__ short
+// X32:#define __INT32_C_SUFFIX__ {{$}}
+// X32:#define __INT32_FMTd__ "d"
+// X32:#define __INT32_FMTi__ "i"
+// X32:#define __INT32_MAX__ 2147483647
+// X32:#define __INT32_TYPE__ int
+// X32:#define __INT64_C_SUFFIX__ L
+// X32:#define __INT64_FMTd__ "lld"
+// X32:#define __INT64_FMTi__ "lli"
+// X32:#define __INT64_MAX__ 9223372036854775807L
+// X32:#define __INT64_TYPE__ long long int
+// X32:#define __INT8_C_SUFFIX__ {{$}}
+// X32:#define __INT8_FMTd__ "hhd"
+// X32:#define __INT8_FMTi__ "hhi"
+// X32:#define __INT8_MAX__ 127
+// X32:#define __INT8_TYPE__ signed char
+// X32:#define __INTMAX_C_SUFFIX__ LL
+// X32:#define __INTMAX_FMTd__ "lld"
+// X32:#define __INTMAX_FMTi__ "lli"
+// X32:#define __INTMAX_MAX__ 9223372036854775807L
+// X32:#define __INTMAX_TYPE__ long long int
+// X32:#define __INTMAX_WIDTH__ 64
+// X32:#define __INTPTR_FMTd__ "d"
+// X32:#define __INTPTR_FMTi__ "i"
+// X32:#define __INTPTR_MAX__ 2147483647
+// X32:#define __INTPTR_TYPE__ int
+// X32:#define __INTPTR_WIDTH__ 32
+// X32:#define __INT_FAST16_FMTd__ "hd"
+// X32:#define __INT_FAST16_FMTi__ "hi"
+// X32:#define __INT_FAST16_MAX__ 32767
+// X32:#define __INT_FAST16_TYPE__ short
+// X32:#define __INT_FAST32_FMTd__ "d"
+// X32:#define __INT_FAST32_FMTi__ "i"
+// X32:#define __INT_FAST32_MAX__ 2147483647
+// X32:#define __INT_FAST32_TYPE__ int
+// X32:#define __INT_FAST64_FMTd__ "lld"
+// X32:#define __INT_FAST64_FMTi__ "lli"
+// X32:#define __INT_FAST64_MAX__ 9223372036854775807L
+// X32:#define __INT_FAST64_TYPE__ long long int
+// X32:#define __INT_FAST8_FMTd__ "hhd"
+// X32:#define __INT_FAST8_FMTi__ "hhi"
+// X32:#define __INT_FAST8_MAX__ 127
+// X32:#define __INT_FAST8_TYPE__ signed char
+// X32:#define __INT_LEAST16_FMTd__ "hd"
+// X32:#define __INT_LEAST16_FMTi__ "hi"
+// X32:#define __INT_LEAST16_MAX__ 32767
+// X32:#define __INT_LEAST16_TYPE__ short
+// X32:#define __INT_LEAST32_FMTd__ "d"
+// X32:#define __INT_LEAST32_FMTi__ "i"
+// X32:#define __INT_LEAST32_MAX__ 2147483647
+// X32:#define __INT_LEAST32_TYPE__ int
+// X32:#define __INT_LEAST64_FMTd__ "lld"
+// X32:#define __INT_LEAST64_FMTi__ "lli"
+// X32:#define __INT_LEAST64_MAX__ 9223372036854775807L
+// X32:#define __INT_LEAST64_TYPE__ long long int
+// X32:#define __INT_LEAST8_FMTd__ "hhd"
+// X32:#define __INT_LEAST8_FMTi__ "hhi"
+// X32:#define __INT_LEAST8_MAX__ 127
+// X32:#define __INT_LEAST8_TYPE__ signed char
+// X32:#define __INT_MAX__ 2147483647
+// X32:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+// X32:#define __LDBL_DIG__ 18
+// X32:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
+// X32:#define __LDBL_HAS_DENORM__ 1
+// X32:#define __LDBL_HAS_INFINITY__ 1
+// X32:#define __LDBL_HAS_QUIET_NAN__ 1
+// X32:#define __LDBL_MANT_DIG__ 64
+// X32:#define __LDBL_MAX_10_EXP__ 4932
+// X32:#define __LDBL_MAX_EXP__ 16384
+// X32:#define __LDBL_MAX__ 1.18973149535723176502e+4932L
+// X32:#define __LDBL_MIN_10_EXP__ (-4931)
+// X32:#define __LDBL_MIN_EXP__ (-16381)
+// X32:#define __LDBL_MIN__ 3.36210314311209350626e-4932L
+// X32:#define __LITTLE_ENDIAN__ 1
+// X32:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// X32:#define __LONG_MAX__ 2147483647L
+// X32:#define __MMX__ 1
+// X32:#define __NO_MATH_INLINES 1
+// X32:#define __POINTER_WIDTH__ 32
+// X32:#define __PTRDIFF_TYPE__ int
+// X32:#define __PTRDIFF_WIDTH__ 32
+// X32:#define __REGISTER_PREFIX__ 
+// X32:#define __SCHAR_MAX__ 127
+// X32:#define __SHRT_MAX__ 32767
+// X32:#define __SIG_ATOMIC_MAX__ 2147483647
+// X32:#define __SIG_ATOMIC_WIDTH__ 32
+// X32:#define __SIZEOF_DOUBLE__ 8
+// X32:#define __SIZEOF_FLOAT__ 4
+// X32:#define __SIZEOF_INT__ 4
+// X32:#define __SIZEOF_LONG_DOUBLE__ 16
+// X32:#define __SIZEOF_LONG_LONG__ 8
+// X32:#define __SIZEOF_LONG__ 4
+// X32:#define __SIZEOF_POINTER__ 4
+// X32:#define __SIZEOF_PTRDIFF_T__ 4
+// X32:#define __SIZEOF_SHORT__ 2
+// X32:#define __SIZEOF_SIZE_T__ 4
+// X32:#define __SIZEOF_WCHAR_T__ 4
+// X32:#define __SIZEOF_WINT_T__ 4
+// X32:#define __SIZE_MAX__ 4294967295U
+// X32:#define __SIZE_TYPE__ unsigned int
+// X32:#define __SIZE_WIDTH__ 32
+// X32:#define __SSE2_MATH__ 1
+// X32:#define __SSE2__ 1
+// X32:#define __SSE_MATH__ 1
+// X32:#define __SSE__ 1
+// X32:#define __UINT16_C_SUFFIX__ {{$}}
+// X32:#define __UINT16_MAX__ 65535
+// X32:#define __UINT16_TYPE__ unsigned short
+// X32:#define __UINT32_C_SUFFIX__ U
+// X32:#define __UINT32_MAX__ 4294967295U
+// X32:#define __UINT32_TYPE__ unsigned int
+// X32:#define __UINT64_C_SUFFIX__ UL
+// X32:#define __UINT64_MAX__ 18446744073709551615ULL
+// X32:#define __UINT64_TYPE__ long long unsigned int
+// X32:#define __UINT8_C_SUFFIX__ {{$}}
+// X32:#define __UINT8_MAX__ 255
+// X32:#define __UINT8_TYPE__ unsigned char
+// X32:#define __UINTMAX_C_SUFFIX__ ULL
+// X32:#define __UINTMAX_MAX__ 18446744073709551615ULL
+// X32:#define __UINTMAX_TYPE__ long long unsigned int
+// X32:#define __UINTMAX_WIDTH__ 64
+// X32:#define __UINTPTR_MAX__ 4294967295U
+// X32:#define __UINTPTR_TYPE__ unsigned int
+// X32:#define __UINTPTR_WIDTH__ 32
+// X32:#define __UINT_FAST16_MAX__ 65535
+// X32:#define __UINT_FAST16_TYPE__ unsigned short
+// X32:#define __UINT_FAST32_MAX__ 4294967295U
+// X32:#define __UINT_FAST32_TYPE__ unsigned int
+// X32:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
+// X32:#define __UINT_FAST64_TYPE__ long long unsigned int
+// X32:#define __UINT_FAST8_MAX__ 255
+// X32:#define __UINT_FAST8_TYPE__ unsigned char
+// X32:#define __UINT_LEAST16_MAX__ 65535
+// X32:#define __UINT_LEAST16_TYPE__ unsigned short
+// X32:#define __UINT_LEAST32_MAX__ 4294967295U
+// X32:#define __UINT_LEAST32_TYPE__ unsigned int
+// X32:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
+// X32:#define __UINT_LEAST64_TYPE__ long long unsigned int
+// X32:#define __UINT_LEAST8_MAX__ 255
+// X32:#define __UINT_LEAST8_TYPE__ unsigned char
+// X32:#define __USER_LABEL_PREFIX__ _
+// X32:#define __WCHAR_MAX__ 2147483647
+// X32:#define __WCHAR_TYPE__ int
+// X32:#define __WCHAR_WIDTH__ 32
+// X32:#define __WINT_TYPE__ int
+// X32:#define __WINT_WIDTH__ 32
+// X32:#define __amd64 1
+// X32:#define __amd64__ 1
+// X32:#define __x86_64 1
+// X32:#define __x86_64__ 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -check-prefix X86_64-LINUX %s
 //
 // X86_64-LINUX:#define _LP64 1
@@ -5277,37 +6661,69 @@
 // X86_64-LINUX:#define __FLT_MIN_EXP__ (-125)
 // X86_64-LINUX:#define __FLT_MIN__ 1.17549435e-38F
 // X86_64-LINUX:#define __FLT_RADIX__ 2
+// X86_64-LINUX:#define __INT16_C_SUFFIX__ {{$}}
+// X86_64-LINUX:#define __INT16_FMTd__ "hd"
+// X86_64-LINUX:#define __INT16_FMTi__ "hi"
 // X86_64-LINUX:#define __INT16_MAX__ 32767
 // X86_64-LINUX:#define __INT16_TYPE__ short
+// X86_64-LINUX:#define __INT32_C_SUFFIX__ {{$}}
+// X86_64-LINUX:#define __INT32_FMTd__ "d"
+// X86_64-LINUX:#define __INT32_FMTi__ "i"
 // X86_64-LINUX:#define __INT32_MAX__ 2147483647
 // X86_64-LINUX:#define __INT32_TYPE__ int
 // X86_64-LINUX:#define __INT64_C_SUFFIX__ L
+// X86_64-LINUX:#define __INT64_FMTd__ "ld"
+// X86_64-LINUX:#define __INT64_FMTi__ "li"
 // X86_64-LINUX:#define __INT64_MAX__ 9223372036854775807L
 // X86_64-LINUX:#define __INT64_TYPE__ long int
+// X86_64-LINUX:#define __INT8_C_SUFFIX__ {{$}}
+// X86_64-LINUX:#define __INT8_FMTd__ "hhd"
+// X86_64-LINUX:#define __INT8_FMTi__ "hhi"
 // X86_64-LINUX:#define __INT8_MAX__ 127
-// X86_64-LINUX:#define __INT8_TYPE__ char
+// X86_64-LINUX:#define __INT8_TYPE__ signed char
+// X86_64-LINUX:#define __INTMAX_C_SUFFIX__ L
+// X86_64-LINUX:#define __INTMAX_FMTd__ "ld"
+// X86_64-LINUX:#define __INTMAX_FMTi__ "li"
 // X86_64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L
 // X86_64-LINUX:#define __INTMAX_TYPE__ long int
 // X86_64-LINUX:#define __INTMAX_WIDTH__ 64
+// X86_64-LINUX:#define __INTPTR_FMTd__ "ld"
+// X86_64-LINUX:#define __INTPTR_FMTi__ "li"
 // X86_64-LINUX:#define __INTPTR_MAX__ 9223372036854775807L
 // X86_64-LINUX:#define __INTPTR_TYPE__ long int
 // X86_64-LINUX:#define __INTPTR_WIDTH__ 64
+// X86_64-LINUX:#define __INT_FAST16_FMTd__ "hd"
+// X86_64-LINUX:#define __INT_FAST16_FMTi__ "hi"
 // X86_64-LINUX:#define __INT_FAST16_MAX__ 32767
 // X86_64-LINUX:#define __INT_FAST16_TYPE__ short
+// X86_64-LINUX:#define __INT_FAST32_FMTd__ "d"
+// X86_64-LINUX:#define __INT_FAST32_FMTi__ "i"
 // X86_64-LINUX:#define __INT_FAST32_MAX__ 2147483647
 // X86_64-LINUX:#define __INT_FAST32_TYPE__ int
+// X86_64-LINUX:#define __INT_FAST64_FMTd__ "ld"
+// X86_64-LINUX:#define __INT_FAST64_FMTi__ "li"
 // X86_64-LINUX:#define __INT_FAST64_MAX__ 9223372036854775807L
 // X86_64-LINUX:#define __INT_FAST64_TYPE__ long int
+// X86_64-LINUX:#define __INT_FAST8_FMTd__ "hhd"
+// X86_64-LINUX:#define __INT_FAST8_FMTi__ "hhi"
 // X86_64-LINUX:#define __INT_FAST8_MAX__ 127
-// X86_64-LINUX:#define __INT_FAST8_TYPE__ char
+// X86_64-LINUX:#define __INT_FAST8_TYPE__ signed char
+// X86_64-LINUX:#define __INT_LEAST16_FMTd__ "hd"
+// X86_64-LINUX:#define __INT_LEAST16_FMTi__ "hi"
 // X86_64-LINUX:#define __INT_LEAST16_MAX__ 32767
 // X86_64-LINUX:#define __INT_LEAST16_TYPE__ short
+// X86_64-LINUX:#define __INT_LEAST32_FMTd__ "d"
+// X86_64-LINUX:#define __INT_LEAST32_FMTi__ "i"
 // X86_64-LINUX:#define __INT_LEAST32_MAX__ 2147483647
 // X86_64-LINUX:#define __INT_LEAST32_TYPE__ int
+// X86_64-LINUX:#define __INT_LEAST64_FMTd__ "ld"
+// X86_64-LINUX:#define __INT_LEAST64_FMTi__ "li"
 // X86_64-LINUX:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // X86_64-LINUX:#define __INT_LEAST64_TYPE__ long int
+// X86_64-LINUX:#define __INT_LEAST8_FMTd__ "hhd"
+// X86_64-LINUX:#define __INT_LEAST8_FMTi__ "hhi"
 // X86_64-LINUX:#define __INT_LEAST8_MAX__ 127
-// X86_64-LINUX:#define __INT_LEAST8_TYPE__ char
+// X86_64-LINUX:#define __INT_LEAST8_TYPE__ signed char
 // X86_64-LINUX:#define __INT_MAX__ 2147483647
 // X86_64-LINUX:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
 // X86_64-LINUX:#define __LDBL_DIG__ 18
@@ -5334,6 +6750,7 @@
 // X86_64-LINUX:#define __REGISTER_PREFIX__ 
 // X86_64-LINUX:#define __SCHAR_MAX__ 127
 // X86_64-LINUX:#define __SHRT_MAX__ 32767
+// X86_64-LINUX:#define __SIG_ATOMIC_MAX__ 2147483647
 // X86_64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
 // X86_64-LINUX:#define __SIZEOF_DOUBLE__ 8
 // X86_64-LINUX:#define __SIZEOF_FLOAT__ 4
@@ -5354,8 +6771,8 @@
 // X86_64-LINUX:#define __SSE2__ 1
 // X86_64-LINUX:#define __SSE_MATH__ 1
 // X86_64-LINUX:#define __SSE__ 1
-// X86_64-LINUX:#define __UINT16_C_SUFFIX__ U
-// X86_64-LINUX:#define __UINT16_MAX__ 65535U
+// X86_64-LINUX:#define __UINT16_C_SUFFIX__ {{$}}
+// X86_64-LINUX:#define __UINT16_MAX__ 65535
 // X86_64-LINUX:#define __UINT16_TYPE__ unsigned short
 // X86_64-LINUX:#define __UINT32_C_SUFFIX__ U
 // X86_64-LINUX:#define __UINT32_MAX__ 4294967295U
@@ -5363,30 +6780,31 @@
 // X86_64-LINUX:#define __UINT64_C_SUFFIX__ UL
 // X86_64-LINUX:#define __UINT64_MAX__ 18446744073709551615UL
 // X86_64-LINUX:#define __UINT64_TYPE__ long unsigned int
-// X86_64-LINUX:#define __UINT8_C_SUFFIX__ U
-// X86_64-LINUX:#define __UINT8_MAX__ 255U
+// X86_64-LINUX:#define __UINT8_C_SUFFIX__ {{$}}
+// X86_64-LINUX:#define __UINT8_MAX__ 255
 // X86_64-LINUX:#define __UINT8_TYPE__ unsigned char
+// X86_64-LINUX:#define __UINTMAX_C_SUFFIX__ UL
 // X86_64-LINUX:#define __UINTMAX_MAX__ 18446744073709551615UL
 // X86_64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
 // X86_64-LINUX:#define __UINTMAX_WIDTH__ 64
 // X86_64-LINUX:#define __UINTPTR_MAX__ 18446744073709551615UL
 // X86_64-LINUX:#define __UINTPTR_TYPE__ long unsigned int
 // X86_64-LINUX:#define __UINTPTR_WIDTH__ 64
-// X86_64-LINUX:#define __UINT_FAST16_MAX__ 65535U
+// X86_64-LINUX:#define __UINT_FAST16_MAX__ 65535
 // X86_64-LINUX:#define __UINT_FAST16_TYPE__ unsigned short
 // X86_64-LINUX:#define __UINT_FAST32_MAX__ 4294967295U
 // X86_64-LINUX:#define __UINT_FAST32_TYPE__ unsigned int
 // X86_64-LINUX:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // X86_64-LINUX:#define __UINT_FAST64_TYPE__ long unsigned int
-// X86_64-LINUX:#define __UINT_FAST8_MAX__ 255U
+// X86_64-LINUX:#define __UINT_FAST8_MAX__ 255
 // X86_64-LINUX:#define __UINT_FAST8_TYPE__ unsigned char
-// X86_64-LINUX:#define __UINT_LEAST16_MAX__ 65535U
+// X86_64-LINUX:#define __UINT_LEAST16_MAX__ 65535
 // X86_64-LINUX:#define __UINT_LEAST16_TYPE__ unsigned short
 // X86_64-LINUX:#define __UINT_LEAST32_MAX__ 4294967295U
 // X86_64-LINUX:#define __UINT_LEAST32_TYPE__ unsigned int
 // X86_64-LINUX:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // X86_64-LINUX:#define __UINT_LEAST64_TYPE__ long unsigned int
-// X86_64-LINUX:#define __UINT_LEAST8_MAX__ 255U
+// X86_64-LINUX:#define __UINT_LEAST8_MAX__ 255
 // X86_64-LINUX:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-LINUX:#define __USER_LABEL_PREFIX__
 // X86_64-LINUX:#define __WCHAR_MAX__ 2147483647
@@ -5441,37 +6859,69 @@
 // X86_64-NETBSD:#define __FLT_MIN_EXP__ (-125)
 // X86_64-NETBSD:#define __FLT_MIN__ 1.17549435e-38F
 // X86_64-NETBSD:#define __FLT_RADIX__ 2
+// X86_64-NETBSD:#define __INT16_C_SUFFIX__ {{$}}
+// X86_64-NETBSD:#define __INT16_FMTd__ "hd"
+// X86_64-NETBSD:#define __INT16_FMTi__ "hi"
 // X86_64-NETBSD:#define __INT16_MAX__ 32767
 // X86_64-NETBSD:#define __INT16_TYPE__ short
+// X86_64-NETBSD:#define __INT32_C_SUFFIX__ {{$}}
+// X86_64-NETBSD:#define __INT32_FMTd__ "d"
+// X86_64-NETBSD:#define __INT32_FMTi__ "i"
 // X86_64-NETBSD:#define __INT32_MAX__ 2147483647
 // X86_64-NETBSD:#define __INT32_TYPE__ int
 // X86_64-NETBSD:#define __INT64_C_SUFFIX__ L
+// X86_64-NETBSD:#define __INT64_FMTd__ "ld"
+// X86_64-NETBSD:#define __INT64_FMTi__ "li"
 // X86_64-NETBSD:#define __INT64_MAX__ 9223372036854775807L
 // X86_64-NETBSD:#define __INT64_TYPE__ long int
+// X86_64-NETBSD:#define __INT8_C_SUFFIX__ {{$}}
+// X86_64-NETBSD:#define __INT8_FMTd__ "hhd"
+// X86_64-NETBSD:#define __INT8_FMTi__ "hhi"
 // X86_64-NETBSD:#define __INT8_MAX__ 127
-// X86_64-NETBSD:#define __INT8_TYPE__ char
+// X86_64-NETBSD:#define __INT8_TYPE__ signed char
+// X86_64-NETBSD:#define __INTMAX_C_SUFFIX__ L
+// X86_64-NETBSD:#define __INTMAX_FMTd__ "ld"
+// X86_64-NETBSD:#define __INTMAX_FMTi__ "li"
 // X86_64-NETBSD:#define __INTMAX_MAX__ 9223372036854775807L
 // X86_64-NETBSD:#define __INTMAX_TYPE__ long int
 // X86_64-NETBSD:#define __INTMAX_WIDTH__ 64
+// X86_64-NETBSD:#define __INTPTR_FMTd__ "ld"
+// X86_64-NETBSD:#define __INTPTR_FMTi__ "li"
 // X86_64-NETBSD:#define __INTPTR_MAX__ 9223372036854775807L
 // X86_64-NETBSD:#define __INTPTR_TYPE__ long int
 // X86_64-NETBSD:#define __INTPTR_WIDTH__ 64
+// X86_64-NETBSD:#define __INT_FAST16_FMTd__ "hd"
+// X86_64-NETBSD:#define __INT_FAST16_FMTi__ "hi"
 // X86_64-NETBSD:#define __INT_FAST16_MAX__ 32767
 // X86_64-NETBSD:#define __INT_FAST16_TYPE__ short
+// X86_64-NETBSD:#define __INT_FAST32_FMTd__ "d"
+// X86_64-NETBSD:#define __INT_FAST32_FMTi__ "i"
 // X86_64-NETBSD:#define __INT_FAST32_MAX__ 2147483647
 // X86_64-NETBSD:#define __INT_FAST32_TYPE__ int
+// X86_64-NETBSD:#define __INT_FAST64_FMTd__ "ld"
+// X86_64-NETBSD:#define __INT_FAST64_FMTi__ "li"
 // X86_64-NETBSD:#define __INT_FAST64_MAX__ 9223372036854775807L
 // X86_64-NETBSD:#define __INT_FAST64_TYPE__ long int
+// X86_64-NETBSD:#define __INT_FAST8_FMTd__ "hhd"
+// X86_64-NETBSD:#define __INT_FAST8_FMTi__ "hhi"
 // X86_64-NETBSD:#define __INT_FAST8_MAX__ 127
-// X86_64-NETBSD:#define __INT_FAST8_TYPE__ char
+// X86_64-NETBSD:#define __INT_FAST8_TYPE__ signed char
+// X86_64-NETBSD:#define __INT_LEAST16_FMTd__ "hd"
+// X86_64-NETBSD:#define __INT_LEAST16_FMTi__ "hi"
 // X86_64-NETBSD:#define __INT_LEAST16_MAX__ 32767
 // X86_64-NETBSD:#define __INT_LEAST16_TYPE__ short
+// X86_64-NETBSD:#define __INT_LEAST32_FMTd__ "d"
+// X86_64-NETBSD:#define __INT_LEAST32_FMTi__ "i"
 // X86_64-NETBSD:#define __INT_LEAST32_MAX__ 2147483647
 // X86_64-NETBSD:#define __INT_LEAST32_TYPE__ int
+// X86_64-NETBSD:#define __INT_LEAST64_FMTd__ "ld"
+// X86_64-NETBSD:#define __INT_LEAST64_FMTi__ "li"
 // X86_64-NETBSD:#define __INT_LEAST64_MAX__ 9223372036854775807L
 // X86_64-NETBSD:#define __INT_LEAST64_TYPE__ long int
+// X86_64-NETBSD:#define __INT_LEAST8_FMTd__ "hhd"
+// X86_64-NETBSD:#define __INT_LEAST8_FMTi__ "hhi"
 // X86_64-NETBSD:#define __INT_LEAST8_MAX__ 127
-// X86_64-NETBSD:#define __INT_LEAST8_TYPE__ char
+// X86_64-NETBSD:#define __INT_LEAST8_TYPE__ signed char
 // X86_64-NETBSD:#define __INT_MAX__ 2147483647
 // X86_64-NETBSD:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
 // X86_64-NETBSD:#define __LDBL_DIG__ 18
@@ -5498,6 +6948,7 @@
 // X86_64-NETBSD:#define __REGISTER_PREFIX__ 
 // X86_64-NETBSD:#define __SCHAR_MAX__ 127
 // X86_64-NETBSD:#define __SHRT_MAX__ 32767
+// X86_64-NETBSD:#define __SIG_ATOMIC_MAX__ 2147483647
 // X86_64-NETBSD:#define __SIG_ATOMIC_WIDTH__ 32
 // X86_64-NETBSD:#define __SIZEOF_DOUBLE__ 8
 // X86_64-NETBSD:#define __SIZEOF_FLOAT__ 4
@@ -5518,8 +6969,8 @@
 // X86_64-NETBSD:#define __SSE2__ 1
 // X86_64-NETBSD:#define __SSE_MATH__ 1
 // X86_64-NETBSD:#define __SSE__ 1
-// X86_64-NETBSD:#define __UINT16_C_SUFFIX__ U
-// X86_64-NETBSD:#define __UINT16_MAX__ 65535U
+// X86_64-NETBSD:#define __UINT16_C_SUFFIX__ {{$}}
+// X86_64-NETBSD:#define __UINT16_MAX__ 65535
 // X86_64-NETBSD:#define __UINT16_TYPE__ unsigned short
 // X86_64-NETBSD:#define __UINT32_C_SUFFIX__ U
 // X86_64-NETBSD:#define __UINT32_MAX__ 4294967295U
@@ -5527,30 +6978,31 @@
 // X86_64-NETBSD:#define __UINT64_C_SUFFIX__ UL
 // X86_64-NETBSD:#define __UINT64_MAX__ 18446744073709551615UL
 // X86_64-NETBSD:#define __UINT64_TYPE__ long unsigned int
-// X86_64-NETBSD:#define __UINT8_C_SUFFIX__ U
-// X86_64-NETBSD:#define __UINT8_MAX__ 255U
+// X86_64-NETBSD:#define __UINT8_C_SUFFIX__ {{$}}
+// X86_64-NETBSD:#define __UINT8_MAX__ 255
 // X86_64-NETBSD:#define __UINT8_TYPE__ unsigned char
+// X86_64-NETBSD:#define __UINTMAX_C_SUFFIX__ UL
 // X86_64-NETBSD:#define __UINTMAX_MAX__ 18446744073709551615UL
 // X86_64-NETBSD:#define __UINTMAX_TYPE__ long unsigned int
 // X86_64-NETBSD:#define __UINTMAX_WIDTH__ 64
 // X86_64-NETBSD:#define __UINTPTR_MAX__ 18446744073709551615UL
 // X86_64-NETBSD:#define __UINTPTR_TYPE__ long unsigned int
 // X86_64-NETBSD:#define __UINTPTR_WIDTH__ 64
-// X86_64-NETBSD:#define __UINT_FAST16_MAX__ 65535U
+// X86_64-NETBSD:#define __UINT_FAST16_MAX__ 65535
 // X86_64-NETBSD:#define __UINT_FAST16_TYPE__ unsigned short
 // X86_64-NETBSD:#define __UINT_FAST32_MAX__ 4294967295U
 // X86_64-NETBSD:#define __UINT_FAST32_TYPE__ unsigned int
 // X86_64-NETBSD:#define __UINT_FAST64_MAX__ 18446744073709551615UL
 // X86_64-NETBSD:#define __UINT_FAST64_TYPE__ long unsigned int
-// X86_64-NETBSD:#define __UINT_FAST8_MAX__ 255U
+// X86_64-NETBSD:#define __UINT_FAST8_MAX__ 255
 // X86_64-NETBSD:#define __UINT_FAST8_TYPE__ unsigned char
-// X86_64-NETBSD:#define __UINT_LEAST16_MAX__ 65535U
+// X86_64-NETBSD:#define __UINT_LEAST16_MAX__ 65535
 // X86_64-NETBSD:#define __UINT_LEAST16_TYPE__ unsigned short
 // X86_64-NETBSD:#define __UINT_LEAST32_MAX__ 4294967295U
 // X86_64-NETBSD:#define __UINT_LEAST32_TYPE__ unsigned int
 // X86_64-NETBSD:#define __UINT_LEAST64_MAX__ 18446744073709551615UL
 // X86_64-NETBSD:#define __UINT_LEAST64_TYPE__ long unsigned int
-// X86_64-NETBSD:#define __UINT_LEAST8_MAX__ 255U
+// X86_64-NETBSD:#define __UINT_LEAST8_MAX__ 255
 // X86_64-NETBSD:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-NETBSD:#define __USER_LABEL_PREFIX__
 // X86_64-NETBSD:#define __WCHAR_MAX__ 2147483647
@@ -5565,16 +7017,20 @@
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null | FileCheck -check-prefix SPARCV9 %s
 // SPARCV9:#define __INT64_TYPE__ long int
+// SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int
 // SPARCV9:#define __INTPTR_TYPE__ long int
 // SPARCV9:#define __LONG_MAX__ 9223372036854775807L
 // SPARCV9:#define __LP64__ 1
 // SPARCV9:#define __SIZEOF_LONG__ 8
 // SPARCV9:#define __SIZEOF_POINTER__ 8
+// SPARCV9:#define __UINTPTR_TYPE__ long unsigned int
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-openbsd < /dev/null | FileCheck -check-prefix SPARC64-OBSD %s
 // SPARC64-OBSD:#define __INT64_TYPE__ long long int
+// SPARC64-OBSD:#define __INTMAX_C_SUFFIX__ LL
 // SPARC64-OBSD:#define __INTMAX_TYPE__ long long int
+// SPARC64-OBSD:#define __UINTMAX_C_SUFFIX__ ULL
 // SPARC64-OBSD:#define __UINTMAX_TYPE__ long long unsigned int
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-pc-kfreebsd-gnu < /dev/null | FileCheck -check-prefix KFREEBSD-DEFINE %s
diff --git a/test/Preprocessor/line-directive.c b/test/Preprocessor/line-directive.c
index 0dd658f..2ebe87e 100644
--- a/test/Preprocessor/line-directive.c
+++ b/test/Preprocessor/line-directive.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -pedantic %s
 // RUN: not %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC'
 // RUN: not %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
 
diff --git a/test/Preprocessor/macro_paste_bad.c b/test/Preprocessor/macro_paste_bad.c
index ec10006..2377724 100644
--- a/test/Preprocessor/macro_paste_bad.c
+++ b/test/Preprocessor/macro_paste_bad.c
@@ -34,3 +34,11 @@
 
 #define LOG_ON_ERROR(x) x ## #y; // expected-error {{'#' is not followed by a macro parameter}}
 LOG_ON_ERROR(0);
+
+#define PR21379A(x) printf ##x // expected-note {{macro 'PR21379A' defined here}}
+PR21379A(0 {, }) // expected-error {{too many arguments provided to function-like macro invocation}}
+                 // expected-note@-1 {{parentheses are required around macro argument containing braced initializer list}}
+
+#define PR21379B(x) printf #x // expected-note {{macro 'PR21379B' defined here}}
+PR21379B(0 {, }) // expected-error {{too many arguments provided to function-like macro invocation}}
+                 // expected-note@-1 {{parentheses are required around macro argument containing braced initializer list}}
diff --git a/test/Preprocessor/predefined-arch-macros.c b/test/Preprocessor/predefined-arch-macros.c
index cba458e..5bdbdbc 100644
--- a/test/Preprocessor/predefined-arch-macros.c
+++ b/test/Preprocessor/predefined-arch-macros.c
@@ -562,6 +562,70 @@
 // CHECK_CORE_AVX2_M64: #define __x86_64 1
 // CHECK_CORE_AVX2_M64: #define __x86_64__ 1
 //
+// RUN: %clang -march=broadwell -m32 -E -dM %s -o - 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_BROADWELL_M32
+// CHECK_BROADWELL_M32: #define __ADX__ 1
+// CHECK_BROADWELL_M32: #define __AES__ 1
+// CHECK_BROADWELL_M32: #define __AVX2__ 1
+// CHECK_BROADWELL_M32: #define __AVX__ 1
+// CHECK_BROADWELL_M32: #define __BMI2__ 1
+// CHECK_BROADWELL_M32: #define __BMI__ 1
+// CHECK_BROADWELL_M32: #define __F16C__ 1
+// CHECK_BROADWELL_M32: #define __FMA__ 1
+// CHECK_BROADWELL_M32: #define __LZCNT__ 1
+// CHECK_BROADWELL_M32: #define __MMX__ 1
+// CHECK_BROADWELL_M32: #define __PCLMUL__ 1
+// CHECK_BROADWELL_M32: #define __POPCNT__ 1
+// CHECK_BROADWELL_M32: #define __RDRND__ 1
+// CHECK_BROADWELL_M32: #define __RDSEED__ 1
+// CHECK_BROADWELL_M32: #define __RTM__ 1
+// CHECK_BROADWELL_M32: #define __SSE2__ 1
+// CHECK_BROADWELL_M32: #define __SSE3__ 1
+// CHECK_BROADWELL_M32: #define __SSE4_1__ 1
+// CHECK_BROADWELL_M32: #define __SSE4_2__ 1
+// CHECK_BROADWELL_M32: #define __SSE__ 1
+// CHECK_BROADWELL_M32: #define __SSSE3__ 1
+// CHECK_BROADWELL_M32: #define __corei7 1
+// CHECK_BROADWELL_M32: #define __corei7__ 1
+// CHECK_BROADWELL_M32: #define __i386 1
+// CHECK_BROADWELL_M32: #define __i386__ 1
+// CHECK_BROADWELL_M32: #define __tune_corei7__ 1
+// CHECK_BROADWELL_M32: #define i386 1
+// RUN: %clang -march=broadwell -m64 -E -dM %s -o - 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_BROADWELL_M64
+// CHECK_BROADWELL_M64: #define __ADX__ 1
+// CHECK_BROADWELL_M64: #define __AES__ 1
+// CHECK_BROADWELL_M64: #define __AVX2__ 1
+// CHECK_BROADWELL_M64: #define __AVX__ 1
+// CHECK_BROADWELL_M64: #define __BMI2__ 1
+// CHECK_BROADWELL_M64: #define __BMI__ 1
+// CHECK_BROADWELL_M64: #define __F16C__ 1
+// CHECK_BROADWELL_M64: #define __FMA__ 1
+// CHECK_BROADWELL_M64: #define __LZCNT__ 1
+// CHECK_BROADWELL_M64: #define __MMX__ 1
+// CHECK_BROADWELL_M64: #define __PCLMUL__ 1
+// CHECK_BROADWELL_M64: #define __POPCNT__ 1
+// CHECK_BROADWELL_M64: #define __RDRND__ 1
+// CHECK_BROADWELL_M64: #define __RDSEED__ 1
+// CHECK_BROADWELL_M64: #define __RTM__ 1
+// CHECK_BROADWELL_M64: #define __SSE2_MATH__ 1
+// CHECK_BROADWELL_M64: #define __SSE2__ 1
+// CHECK_BROADWELL_M64: #define __SSE3__ 1
+// CHECK_BROADWELL_M64: #define __SSE4_1__ 1
+// CHECK_BROADWELL_M64: #define __SSE4_2__ 1
+// CHECK_BROADWELL_M64: #define __SSE_MATH__ 1
+// CHECK_BROADWELL_M64: #define __SSE__ 1
+// CHECK_BROADWELL_M64: #define __SSSE3__ 1
+// CHECK_BROADWELL_M64: #define __amd64 1
+// CHECK_BROADWELL_M64: #define __amd64__ 1
+// CHECK_BROADWELL_M64: #define __corei7 1
+// CHECK_BROADWELL_M64: #define __corei7__ 1
+// CHECK_BROADWELL_M64: #define __tune_corei7__ 1
+// CHECK_BROADWELL_M64: #define __x86_64 1
+// CHECK_BROADWELL_M64: #define __x86_64__ 1
+//
 // RUN: %clang -march=knl -m32 -E -dM %s -o - 2>&1 \
 // RUN:     -target i386-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_KNL_M32
@@ -594,6 +658,7 @@
 // CHECK_KNL_M32: #define __knl__ 1
 // CHECK_KNL_M32: #define __tune_knl__ 1
 // CHECK_KNL_M32: #define i386 1
+
 // RUN: %clang -march=knl -m64 -E -dM %s -o - 2>&1 \
 // RUN:     -target i386-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_KNL_M64
@@ -630,6 +695,77 @@
 // CHECK_KNL_M64: #define __x86_64 1
 // CHECK_KNL_M64: #define __x86_64__ 1
 //
+// RUN: %clang -march=skx -m32 -E -dM %s -o - 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_SKX_M32
+// CHECK_SKX_M32: #define __AES__ 1
+// CHECK_SKX_M32: #define __AVX2__ 1
+// CHECK_SKX_M32: #define __AVX512BW__ 1
+// CHECK_SKX_M32: #define __AVX512CD__ 1
+// CHECK_SKX_M32: #define __AVX512DQ__ 1
+// CHECK_SKX_M32: #define __AVX512F__ 1
+// CHECK_SKX_M32: #define __AVX512VL__ 1
+// CHECK_SKX_M32: #define __AVX__ 1
+// CHECK_SKX_M32: #define __BMI2__ 1
+// CHECK_SKX_M32: #define __BMI__ 1
+// CHECK_SKX_M32: #define __F16C__ 1
+// CHECK_SKX_M32: #define __FMA__ 1
+// CHECK_SKX_M32: #define __LZCNT__ 1
+// CHECK_SKX_M32: #define __MMX__ 1
+// CHECK_SKX_M32: #define __PCLMUL__ 1
+// CHECK_SKX_M32: #define __POPCNT__ 1
+// CHECK_SKX_M32: #define __RDRND__ 1
+// CHECK_SKX_M32: #define __RTM__ 1
+// CHECK_SKX_M32: #define __SSE2__ 1
+// CHECK_SKX_M32: #define __SSE3__ 1
+// CHECK_SKX_M32: #define __SSE4_1__ 1
+// CHECK_SKX_M32: #define __SSE4_2__ 1
+// CHECK_SKX_M32: #define __SSE__ 1
+// CHECK_SKX_M32: #define __SSSE3__ 1
+// CHECK_SKX_M32: #define __i386 1
+// CHECK_SKX_M32: #define __i386__ 1
+// CHECK_SKX_M32: #define __skx 1
+// CHECK_SKX_M32: #define __skx__ 1
+// CHECK_SKX_M32: #define __tune_skx__ 1
+// CHECK_SKX_M32: #define i386 1
+
+// RUN: %clang -march=skx -m64 -E -dM %s -o - 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_SKX_M64
+// CHECK_SKX_M64: #define __AES__ 1
+// CHECK_SKX_M64: #define __AVX2__ 1
+// CHECK_SKX_M64: #define __AVX512BW__ 1
+// CHECK_SKX_M64: #define __AVX512CD__ 1
+// CHECK_SKX_M64: #define __AVX512DQ__ 1
+// CHECK_SKX_M64: #define __AVX512F__ 1
+// CHECK_SKX_M64: #define __AVX512VL__ 1
+// CHECK_SKX_M64: #define __AVX__ 1
+// CHECK_SKX_M64: #define __BMI2__ 1
+// CHECK_SKX_M64: #define __BMI__ 1
+// CHECK_SKX_M64: #define __F16C__ 1
+// CHECK_SKX_M64: #define __FMA__ 1
+// CHECK_SKX_M64: #define __LZCNT__ 1
+// CHECK_SKX_M64: #define __MMX__ 1
+// CHECK_SKX_M64: #define __PCLMUL__ 1
+// CHECK_SKX_M64: #define __POPCNT__ 1
+// CHECK_SKX_M64: #define __RDRND__ 1
+// CHECK_SKX_M64: #define __RTM__ 1
+// CHECK_SKX_M64: #define __SSE2_MATH__ 1
+// CHECK_SKX_M64: #define __SSE2__ 1
+// CHECK_SKX_M64: #define __SSE3__ 1
+// CHECK_SKX_M64: #define __SSE4_1__ 1
+// CHECK_SKX_M64: #define __SSE4_2__ 1
+// CHECK_SKX_M64: #define __SSE_MATH__ 1
+// CHECK_SKX_M64: #define __SSE__ 1
+// CHECK_SKX_M64: #define __SSSE3__ 1
+// CHECK_SKX_M64: #define __amd64 1
+// CHECK_SKX_M64: #define __amd64__ 1
+// CHECK_SKX_M64: #define __skx 1
+// CHECK_SKX_M64: #define __skx__ 1
+// CHECK_SKX_M64: #define __tune_skx__ 1
+// CHECK_SKX_M64: #define __x86_64 1
+// CHECK_SKX_M64: #define __x86_64__ 1
+//
 // RUN: %clang -march=atom -m32 -E -dM %s -o - 2>&1 \
 // RUN:     -target i386-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_ATOM_M32
@@ -1206,8 +1342,11 @@
 // CHECK_BTVER2_M32-NOT: #define __3dNOW__ 1
 // CHECK_BTVER2_M32: #define __AES__ 1
 // CHECK_BTVER2_M32: #define __AVX__ 1
+// CHECK_BTVER2_M32: #define __BMI__ 1
+// CHECK_BTVER2_M32: #define __F16C__ 1
 // CHECK_BTVER2_M32: #define __LZCNT__ 1
 // CHECK_BTVER2_M32: #define __MMX__ 1
+// CHECK_BTVER2_M32: #define __PCLMUL__ 1
 // CHECK_BTVER2_M32: #define __POPCNT__ 1
 // CHECK_BTVER2_M32: #define __PRFCHW__ 1
 // CHECK_BTVER2_M32: #define __SSE2_MATH__ 1
@@ -1229,8 +1368,11 @@
 // CHECK_BTVER2_M64-NOT: #define __3dNOW__ 1
 // CHECK_BTVER2_M64: #define __AES__ 1
 // CHECK_BTVER2_M64: #define __AVX__ 1
+// CHECK_BTVER2_M64: #define __BMI__ 1
+// CHECK_BTVER2_M64: #define __F16C__ 1
 // CHECK_BTVER2_M64: #define __LZCNT__ 1
 // CHECK_BTVER2_M64: #define __MMX__ 1
+// CHECK_BTVER2_M64: #define __PCLMUL__ 1
 // CHECK_BTVER2_M64: #define __POPCNT__ 1
 // CHECK_BTVER2_M64: #define __PRFCHW__ 1
 // CHECK_BTVER2_M64: #define __SSE2_MATH__ 1
@@ -1382,6 +1524,7 @@
 // CHECK_BDVER3_M32: #define __F16C__ 1
 // CHECK_BDVER3_M32: #define __FMA4__ 1
 // CHECK_BDVER3_M32: #define __FMA__ 1
+// CHECK_BDVER3_M32: #define __FSGSBASE__ 1
 // CHECK_BDVER3_M32: #define __LZCNT__ 1
 // CHECK_BDVER3_M32: #define __MMX__ 1
 // CHECK_BDVER3_M32: #define __PCLMUL__ 1
@@ -1414,6 +1557,7 @@
 // CHECK_BDVER3_M64: #define __F16C__ 1
 // CHECK_BDVER3_M64: #define __FMA4__ 1
 // CHECK_BDVER3_M64: #define __FMA__ 1
+// CHECK_BDVER3_M64: #define __FSGSBASE__ 1
 // CHECK_BDVER3_M64: #define __LZCNT__ 1
 // CHECK_BDVER3_M64: #define __MMX__ 1
 // CHECK_BDVER3_M64: #define __PCLMUL__ 1
@@ -1450,6 +1594,7 @@
 // CHECK_BDVER4_M32: #define __F16C__ 1
 // CHECK_BDVER4_M32: #define __FMA4__ 1
 // CHECK_BDVER4_M32: #define __FMA__ 1
+// CHECK_BDVER4_M32: #define __FSGSBASE__ 1
 // CHECK_BDVER4_M32: #define __LZCNT__ 1
 // CHECK_BDVER4_M32: #define __MMX__ 1
 // CHECK_BDVER4_M32: #define __PCLMUL__ 1
@@ -1484,6 +1629,7 @@
 // CHECK_BDVER4_M64: #define __F16C__ 1
 // CHECK_BDVER4_M64: #define __FMA4__ 1
 // CHECK_BDVER4_M64: #define __FMA__ 1
+// CHECK_BDVER4_M64: #define __FSGSBASE__ 1
 // CHECK_BDVER4_M64: #define __LZCNT__ 1
 // CHECK_BDVER4_M64: #define __MMX__ 1
 // CHECK_BDVER4_M64: #define __PCLMUL__ 1
@@ -1516,3 +1662,10 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK_PPC_VSX_M64
 //
 // CHECK_PPC_VSX_M64: #define __VSX__
+//
+// RUN: %clang -mpower8-vector -E -dM %s -o - 2>&1 \
+// RUN:     -target powerpc64-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_PPC_POWER8_VECTOR_M64
+//
+// CHECK_PPC_POWER8_VECTOR_M64: #define __POWER8_VECTOR__
+//
diff --git a/test/Preprocessor/predefined-exceptions.m b/test/Preprocessor/predefined-exceptions.m
index c13f429..0791075 100644
--- a/test/Preprocessor/predefined-exceptions.m
+++ b/test/Preprocessor/predefined-exceptions.m
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -x objective-c -fobjc-exceptions -fexceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-NOCXX %s 
 // CHECK-OBJC-NOCXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
-// CHECK-OBJC-NOCXX-NOT: #define __EXCEPTIONS 1
+// CHECK-OBJC-NOCXX: #define __EXCEPTIONS 1
 
 // RUN: %clang_cc1 -x objective-c++ -fobjc-exceptions -fexceptions -fcxx-exceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-CXX %s 
 // CHECK-OBJC-CXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c
index 3e0b8a0..a32f4a1 100644
--- a/test/Preprocessor/predefined-macros.c
+++ b/test/Preprocessor/predefined-macros.c
@@ -1,71 +1,86 @@
 // This test verifies that the correct macros are predefined.
 //
 // RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \
-// RUN:     -fmsc-version=1300 -o - | FileCheck %s --check-prefix=CHECK-MS
+// RUN:     -fms-compatibility-version=13.00 -o - | FileCheck %s --check-prefix=CHECK-MS
 // CHECK-MS: #define _INTEGRAL_MAX_BITS 64
 // CHECK-MS: #define _MSC_EXTENSIONS 1
 // CHECK-MS: #define _MSC_VER 1300
 // CHECK-MS: #define _M_IX86 600
 // CHECK-MS: #define _M_IX86_FP
 // CHECK-MS: #define _WIN32 1
-// CHECK-MS-NOT: #define __GNUC__
 // CHECK-MS-NOT: #define __STRICT_ANSI__
+// CHECK-MS-NOT: GCC
+// CHECK-MS-NOT: GNU
+// CHECK-MS-NOT: GXX
+//
+// RUN: %clang_cc1 %s -E -dM -triple x86_64-pc-win32 -fms-extensions -fms-compatibility \
+// RUN:     -fms-compatibility-version=13.00 -o - | FileCheck %s --check-prefix=CHECK-MS64
+// CHECK-MS64: #define _INTEGRAL_MAX_BITS 64
+// CHECK-MS64: #define _MSC_EXTENSIONS 1
+// CHECK-MS64: #define _MSC_VER 1300
+// CHECK-MS64: #define _M_AMD64 1
+// CHECK-MS64: #define _M_X64 1
+// CHECK-MS64: #define _WIN64 1
+// CHECK-MS64-NOT: #define __STRICT_ANSI__
+// CHECK-MS64-NOT: GCC
+// CHECK-MS64-NOT: GNU
+// CHECK-MS64-NOT: GXX
 //
 // RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-compatibility \
 // RUN:     -o - | FileCheck %s --check-prefix=CHECK-MS-STDINT
-// CHECK-MS-STDINT-NOT:#define __INT16_MAX__ 32767
-// CHECK-MS-STDINT-NOT:#define __INT32_MAX__ 2147483647
-// CHECK-MS-STDINT-NOT:#define __INT64_MAX__ 9223372036854775807LL
-// CHECK-MS-STDINT-NOT:#define __INT8_MAX__ 127
-// CHECK-MS-STDINT-NOT:#define __INTPTR_MAX__ 2147483647
-// CHECK-MS-STDINT-NOT:#define __INT_FAST16_MAX__ 32767
-// CHECK-MS-STDINT-NOT:#define __INT_FAST16_TYPE__ short
-// CHECK-MS-STDINT-NOT:#define __INT_FAST32_MAX__ 2147483647
-// CHECK-MS-STDINT-NOT:#define __INT_FAST32_TYPE__ int
-// CHECK-MS-STDINT-NOT:#define __INT_FAST64_MAX__ 9223372036854775807LL
-// CHECK-MS-STDINT-NOT:#define __INT_FAST64_TYPE__ long long int
-// CHECK-MS-STDINT-NOT:#define __INT_FAST8_MAX__ 127
-// CHECK-MS-STDINT-NOT:#define __INT_FAST8_TYPE__ char
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST16_MAX__ 32767
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST16_TYPE__ short
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST32_MAX__ 2147483647
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST32_TYPE__ int
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST64_MAX__ 9223372036854775807LL
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST64_TYPE__ long long int
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST8_MAX__ 127
-// CHECK-MS-STDINT-NOT:#define __INT_LEAST8_TYPE__ char
+// CHECK-MS-STDINT:#define __INT16_MAX__ 32767
+// CHECK-MS-STDINT:#define __INT32_MAX__ 2147483647
+// CHECK-MS-STDINT:#define __INT64_MAX__ 9223372036854775807LL
+// CHECK-MS-STDINT:#define __INT8_MAX__ 127
+// CHECK-MS-STDINT:#define __INTPTR_MAX__ 2147483647
+// CHECK-MS-STDINT:#define __INT_FAST16_MAX__ 32767
+// CHECK-MS-STDINT:#define __INT_FAST16_TYPE__ short
+// CHECK-MS-STDINT:#define __INT_FAST32_MAX__ 2147483647
+// CHECK-MS-STDINT:#define __INT_FAST32_TYPE__ int
+// CHECK-MS-STDINT:#define __INT_FAST64_MAX__ 9223372036854775807LL
+// CHECK-MS-STDINT:#define __INT_FAST64_TYPE__ long long int
+// CHECK-MS-STDINT:#define __INT_FAST8_MAX__ 127
+// CHECK-MS-STDINT:#define __INT_FAST8_TYPE__ signed char
+// CHECK-MS-STDINT:#define __INT_LEAST16_MAX__ 32767
+// CHECK-MS-STDINT:#define __INT_LEAST16_TYPE__ short
+// CHECK-MS-STDINT:#define __INT_LEAST32_MAX__ 2147483647
+// CHECK-MS-STDINT:#define __INT_LEAST32_TYPE__ int
+// CHECK-MS-STDINT:#define __INT_LEAST64_MAX__ 9223372036854775807LL
+// CHECK-MS-STDINT:#define __INT_LEAST64_TYPE__ long long int
+// CHECK-MS-STDINT:#define __INT_LEAST8_MAX__ 127
+// CHECK-MS-STDINT:#define __INT_LEAST8_TYPE__ signed char
 // CHECK-MS-STDINT-NOT:#define __UINT16_C_SUFFIX__ U
-// CHECK-MS-STDINT-NOT:#define __UINT16_MAX__ 65535U
-// CHECK-MS-STDINT-NOT:#define __UINT16_TYPE__ unsigned short
-// CHECK-MS-STDINT-NOT:#define __UINT32_C_SUFFIX__ U
-// CHECK-MS-STDINT-NOT:#define __UINT32_MAX__ 4294967295U
-// CHECK-MS-STDINT-NOT:#define __UINT32_TYPE__ unsigned int
-// CHECK-MS-STDINT-NOT:#define __UINT64_C_SUFFIX__ ULL
-// CHECK-MS-STDINT-NOT:#define __UINT64_MAX__ 18446744073709551615ULL
-// CHECK-MS-STDINT-NOT:#define __UINT64_TYPE__ long long unsigned int
+// CHECK-MS-STDINT:#define __UINT16_MAX__ 65535
+// CHECK-MS-STDINT:#define __UINT16_TYPE__ unsigned short
+// CHECK-MS-STDINT:#define __UINT32_C_SUFFIX__ U
+// CHECK-MS-STDINT:#define __UINT32_MAX__ 4294967295U
+// CHECK-MS-STDINT:#define __UINT32_TYPE__ unsigned int
+// CHECK-MS-STDINT:#define __UINT64_C_SUFFIX__ ULL
+// CHECK-MS-STDINT:#define __UINT64_MAX__ 18446744073709551615ULL
+// CHECK-MS-STDINT:#define __UINT64_TYPE__ long long unsigned int
 // CHECK-MS-STDINT-NOT:#define __UINT8_C_SUFFIX__ U
-// CHECK-MS-STDINT-NOT:#define __UINT8_MAX__ 255U
-// CHECK-MS-STDINT-NOT:#define __UINT8_TYPE__ unsigned char
-// CHECK-MS-STDINT-NOT:#define __UINTMAX_MAX__ 18446744073709551615ULL
-// CHECK-MS-STDINT-NOT:#define __UINTPTR_MAX__ 4294967295U
-// CHECK-MS-STDINT-NOT:#define __UINTPTR_TYPE__ unsigned int
-// CHECK-MS-STDINT-NOT:#define __UINTPTR_WIDTH__ 32
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST16_MAX__ 65535U
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST16_TYPE__ unsigned short
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST32_MAX__ 4294967295U
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST32_TYPE__ unsigned int
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST64_TYPE__ long long unsigned int
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST8_MAX__ 255U
-// CHECK-MS-STDINT-NOT:#define __UINT_FAST8_TYPE__ unsigned char
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST16_MAX__ 65535U
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST16_TYPE__ unsigned short
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST32_MAX__ 4294967295U
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST32_TYPE__ unsigned int
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST64_TYPE__ long long unsigned int
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST8_MAX__ 255U
-// CHECK-MS-STDINT-NOT:#define __UINT_LEAST8_TYPE__ unsigned char
+// CHECK-MS-STDINT:#define __UINT8_MAX__ 255
+// CHECK-MS-STDINT:#define __UINT8_TYPE__ unsigned char
+// CHECK-MS-STDINT:#define __UINTMAX_MAX__ 18446744073709551615ULL
+// CHECK-MS-STDINT:#define __UINTPTR_MAX__ 4294967295U
+// CHECK-MS-STDINT:#define __UINTPTR_TYPE__ unsigned int
+// CHECK-MS-STDINT:#define __UINTPTR_WIDTH__ 32
+// CHECK-MS-STDINT:#define __UINT_FAST16_MAX__ 65535
+// CHECK-MS-STDINT:#define __UINT_FAST16_TYPE__ unsigned short
+// CHECK-MS-STDINT:#define __UINT_FAST32_MAX__ 4294967295U
+// CHECK-MS-STDINT:#define __UINT_FAST32_TYPE__ unsigned int
+// CHECK-MS-STDINT:#define __UINT_FAST64_MAX__ 18446744073709551615ULL
+// CHECK-MS-STDINT:#define __UINT_FAST64_TYPE__ long long unsigned int
+// CHECK-MS-STDINT:#define __UINT_FAST8_MAX__ 255
+// CHECK-MS-STDINT:#define __UINT_FAST8_TYPE__ unsigned char
+// CHECK-MS-STDINT:#define __UINT_LEAST16_MAX__ 65535
+// CHECK-MS-STDINT:#define __UINT_LEAST16_TYPE__ unsigned short
+// CHECK-MS-STDINT:#define __UINT_LEAST32_MAX__ 4294967295U
+// CHECK-MS-STDINT:#define __UINT_LEAST32_TYPE__ unsigned int
+// CHECK-MS-STDINT:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL
+// CHECK-MS-STDINT:#define __UINT_LEAST64_TYPE__ long long unsigned int
+// CHECK-MS-STDINT:#define __UINT_LEAST8_MAX__ 255
+// CHECK-MS-STDINT:#define __UINT_LEAST8_TYPE__ unsigned char
 //
 // RUN: %clang_cc1 %s -E -dM -ffast-math -o - \
 // RUN:   | FileCheck %s --check-prefix=CHECK-FAST-MATH
diff --git a/test/Preprocessor/stdint.c b/test/Preprocessor/stdint.c
index b92cfe7..c7189f6 100644
--- a/test/Preprocessor/stdint.c
+++ b/test/Preprocessor/stdint.c
@@ -1,20 +1,20 @@
 // RUN: %clang_cc1 -E -ffreestanding -triple=arm-none-none %s | FileCheck -check-prefix ARM %s
 //
-// ARM:typedef signed long long int int64_t;
-// ARM:typedef unsigned long long int uint64_t;
+// ARM:typedef long long int int64_t;
+// ARM:typedef long long unsigned int uint64_t;
 // ARM:typedef int64_t int_least64_t;
 // ARM:typedef uint64_t uint_least64_t;
 // ARM:typedef int64_t int_fast64_t;
 // ARM:typedef uint64_t uint_fast64_t;
 //
-// ARM:typedef signed int int32_t;
+// ARM:typedef int int32_t;
 // ARM:typedef unsigned int uint32_t;
 // ARM:typedef int32_t int_least32_t;
 // ARM:typedef uint32_t uint_least32_t;
 // ARM:typedef int32_t int_fast32_t;
 // ARM:typedef uint32_t uint_fast32_t;
 // 
-// ARM:typedef signed short int16_t;
+// ARM:typedef short int16_t;
 // ARM:typedef unsigned short uint16_t;
 // ARM:typedef int16_t int_least16_t;
 // ARM:typedef uint16_t uint_least16_t;
@@ -108,21 +108,21 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=i386-none-none %s | FileCheck -check-prefix I386 %s
 //
-// I386:typedef signed long long int int64_t;
-// I386:typedef unsigned long long int uint64_t;
+// I386:typedef long long int int64_t;
+// I386:typedef long long unsigned int uint64_t;
 // I386:typedef int64_t int_least64_t;
 // I386:typedef uint64_t uint_least64_t;
 // I386:typedef int64_t int_fast64_t;
 // I386:typedef uint64_t uint_fast64_t;
 //
-// I386:typedef signed int int32_t;
+// I386:typedef int int32_t;
 // I386:typedef unsigned int uint32_t;
 // I386:typedef int32_t int_least32_t;
 // I386:typedef uint32_t uint_least32_t;
 // I386:typedef int32_t int_fast32_t;
 // I386:typedef uint32_t uint_fast32_t;
 //
-// I386:typedef signed short int16_t;
+// I386:typedef short int16_t;
 // I386:typedef unsigned short uint16_t;
 // I386:typedef int16_t int_least16_t;
 // I386:typedef uint16_t uint_least16_t;
@@ -215,21 +215,21 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=mips-none-none %s | FileCheck -check-prefix MIPS %s
 //
-// MIPS:typedef signed long long int int64_t;
-// MIPS:typedef unsigned long long int uint64_t;
+// MIPS:typedef long long int int64_t;
+// MIPS:typedef long long unsigned int uint64_t;
 // MIPS:typedef int64_t int_least64_t;
 // MIPS:typedef uint64_t uint_least64_t;
 // MIPS:typedef int64_t int_fast64_t;
 // MIPS:typedef uint64_t uint_fast64_t;
 //
-// MIPS:typedef signed int int32_t;
+// MIPS:typedef int int32_t;
 // MIPS:typedef unsigned int uint32_t;
 // MIPS:typedef int32_t int_least32_t;
 // MIPS:typedef uint32_t uint_least32_t;
 // MIPS:typedef int32_t int_fast32_t;
 // MIPS:typedef uint32_t uint_fast32_t;
 //
-// MIPS:typedef signed short int16_t;
+// MIPS:typedef short int16_t;
 // MIPS:typedef unsigned short uint16_t;
 // MIPS:typedef int16_t int_least16_t;
 // MIPS:typedef uint16_t uint_least16_t;
@@ -322,21 +322,21 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=mips64-none-none %s | FileCheck -check-prefix MIPS64 %s
 //
-// MIPS64:typedef signed long long int int64_t;
-// MIPS64:typedef unsigned long long int uint64_t;
+// MIPS64:typedef long long int int64_t;
+// MIPS64:typedef long long unsigned int uint64_t;
 // MIPS64:typedef int64_t int_least64_t;
 // MIPS64:typedef uint64_t uint_least64_t;
 // MIPS64:typedef int64_t int_fast64_t;
 // MIPS64:typedef uint64_t uint_fast64_t;
 //
-// MIPS64:typedef signed int int32_t;
+// MIPS64:typedef int int32_t;
 // MIPS64:typedef unsigned int uint32_t;
 // MIPS64:typedef int32_t int_least32_t;
 // MIPS64:typedef uint32_t uint_least32_t;
 // MIPS64:typedef int32_t int_fast32_t;
 // MIPS64:typedef uint32_t uint_fast32_t;
 //
-// MIPS64:typedef signed short int16_t;
+// MIPS64:typedef short int16_t;
 // MIPS64:typedef unsigned short uint16_t;
 // MIPS64:typedef int16_t int_least16_t;
 // MIPS64:typedef uint16_t uint_least16_t;
@@ -429,14 +429,14 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=msp430-none-none %s | FileCheck -check-prefix MSP430 %s
 //
-// MSP430:typedef signed long int int32_t;
-// MSP430:typedef unsigned long int uint32_t;
+// MSP430:typedef long int int32_t;
+// MSP430:typedef long unsigned int uint32_t;
 // MSP430:typedef int32_t int_least32_t;
 // MSP430:typedef uint32_t uint_least32_t;
 // MSP430:typedef int32_t int_fast32_t;
 // MSP430:typedef uint32_t uint_fast32_t;
 //
-// MSP430:typedef signed short int16_t;
+// MSP430:typedef short int16_t;
 // MSP430:typedef unsigned short uint16_t;
 // MSP430:typedef int16_t int_least16_t;
 // MSP430:typedef uint16_t uint_least16_t;
@@ -529,21 +529,21 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=powerpc64-none-none %s | FileCheck -check-prefix PPC64 %s
 //
-// PPC64:typedef signed long int int64_t;
-// PPC64:typedef unsigned long int uint64_t;
+// PPC64:typedef long int int64_t;
+// PPC64:typedef long unsigned int uint64_t;
 // PPC64:typedef int64_t int_least64_t;
 // PPC64:typedef uint64_t uint_least64_t;
 // PPC64:typedef int64_t int_fast64_t;
 // PPC64:typedef uint64_t uint_fast64_t;
 //
-// PPC64:typedef signed int int32_t;
+// PPC64:typedef int int32_t;
 // PPC64:typedef unsigned int uint32_t;
 // PPC64:typedef int32_t int_least32_t;
 // PPC64:typedef uint32_t uint_least32_t;
 // PPC64:typedef int32_t int_fast32_t;
 // PPC64:typedef uint32_t uint_fast32_t;
 //
-// PPC64:typedef signed short int16_t;
+// PPC64:typedef short int16_t;
 // PPC64:typedef unsigned short uint16_t;
 // PPC64:typedef int16_t int_least16_t;
 // PPC64:typedef uint16_t uint_least16_t;
@@ -634,24 +634,131 @@
 // PPC64:INTMAX_C_(0) 0L
 // PPC64:UINTMAX_C_(0) 0UL
 //
+// RUN: %clang_cc1 -E -ffreestanding -triple=powerpc64-none-netbsd %s | FileCheck -check-prefix PPC64-NETBSD %s
+//
+// PPC64-NETBSD:typedef long long int int64_t;
+// PPC64-NETBSD:typedef long long unsigned int uint64_t;
+// PPC64-NETBSD:typedef int64_t int_least64_t;
+// PPC64-NETBSD:typedef uint64_t uint_least64_t;
+// PPC64-NETBSD:typedef int64_t int_fast64_t;
+// PPC64-NETBSD:typedef uint64_t uint_fast64_t;
+//
+// PPC64-NETBSD:typedef int int32_t;
+// PPC64-NETBSD:typedef unsigned int uint32_t;
+// PPC64-NETBSD:typedef int32_t int_least32_t;
+// PPC64-NETBSD:typedef uint32_t uint_least32_t;
+// PPC64-NETBSD:typedef int32_t int_fast32_t;
+// PPC64-NETBSD:typedef uint32_t uint_fast32_t;
+//
+// PPC64-NETBSD:typedef short int16_t;
+// PPC64-NETBSD:typedef unsigned short uint16_t;
+// PPC64-NETBSD:typedef int16_t int_least16_t;
+// PPC64-NETBSD:typedef uint16_t uint_least16_t;
+// PPC64-NETBSD:typedef int16_t int_fast16_t;
+// PPC64-NETBSD:typedef uint16_t uint_fast16_t;
+//
+// PPC64-NETBSD:typedef signed char int8_t;
+// PPC64-NETBSD:typedef unsigned char uint8_t;
+// PPC64-NETBSD:typedef int8_t int_least8_t;
+// PPC64-NETBSD:typedef uint8_t uint_least8_t;
+// PPC64-NETBSD:typedef int8_t int_fast8_t;
+// PPC64-NETBSD:typedef uint8_t uint_fast8_t;
+//
+// PPC64-NETBSD:typedef int64_t intptr_t;
+// PPC64-NETBSD:typedef uint64_t uintptr_t;
+//
+// PPC64-NETBSD:typedef long long int intmax_t;
+// PPC64-NETBSD:typedef long long unsigned int uintmax_t;
+//
+// PPC64-NETBSD:INT8_MAX_ 127
+// PPC64-NETBSD:INT8_MIN_ (-127 -1)
+// PPC64-NETBSD:UINT8_MAX_ 255
+// PPC64-NETBSD:INT_LEAST8_MIN_ (-127 -1)
+// PPC64-NETBSD:INT_LEAST8_MAX_ 127
+// PPC64-NETBSD:UINT_LEAST8_MAX_ 255
+// PPC64-NETBSD:INT_FAST8_MIN_ (-127 -1)
+// PPC64-NETBSD:INT_FAST8_MAX_ 127
+// PPC64-NETBSD:UINT_FAST8_MAX_ 255
+//
+// PPC64-NETBSD:INT16_MAX_ 32767
+// PPC64-NETBSD:INT16_MIN_ (-32767 -1)
+// PPC64-NETBSD:UINT16_MAX_ 65535
+// PPC64-NETBSD:INT_LEAST16_MIN_ (-32767 -1)
+// PPC64-NETBSD:INT_LEAST16_MAX_ 32767
+// PPC64-NETBSD:UINT_LEAST16_MAX_ 65535
+// PPC64-NETBSD:INT_FAST16_MIN_ (-32767 -1)
+// PPC64-NETBSD:INT_FAST16_MAX_ 32767
+// PPC64-NETBSD:UINT_FAST16_MAX_ 65535
+//
+// PPC64-NETBSD:INT32_MAX_ 2147483647
+// PPC64-NETBSD:INT32_MIN_ (-2147483647 -1)
+// PPC64-NETBSD:UINT32_MAX_ 4294967295U
+// PPC64-NETBSD:INT_LEAST32_MIN_ (-2147483647 -1)
+// PPC64-NETBSD:INT_LEAST32_MAX_ 2147483647
+// PPC64-NETBSD:UINT_LEAST32_MAX_ 4294967295U
+// PPC64-NETBSD:INT_FAST32_MIN_ (-2147483647 -1)
+// PPC64-NETBSD:INT_FAST32_MAX_ 2147483647
+// PPC64-NETBSD:UINT_FAST32_MAX_ 4294967295U
+//
+// PPC64-NETBSD:INT64_MAX_ 9223372036854775807LL
+// PPC64-NETBSD:INT64_MIN_ (-9223372036854775807LL -1)
+// PPC64-NETBSD:UINT64_MAX_ 18446744073709551615ULL
+// PPC64-NETBSD:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// PPC64-NETBSD:INT_LEAST64_MAX_ 9223372036854775807LL
+// PPC64-NETBSD:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// PPC64-NETBSD:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// PPC64-NETBSD:INT_FAST64_MAX_ 9223372036854775807LL
+// PPC64-NETBSD:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// PPC64-NETBSD:INTPTR_MIN_ (-9223372036854775807LL -1)
+// PPC64-NETBSD:INTPTR_MAX_ 9223372036854775807LL
+// PPC64-NETBSD:UINTPTR_MAX_ 18446744073709551615ULL
+// PPC64-NETBSD:PTRDIFF_MIN_ (-9223372036854775807LL -1)
+// PPC64-NETBSD:PTRDIFF_MAX_ 9223372036854775807LL
+// PPC64-NETBSD:SIZE_MAX_ 18446744073709551615ULL
+//
+// PPC64-NETBSD:INTMAX_MIN_ (-9223372036854775807LL -1)
+// PPC64-NETBSD:INTMAX_MAX_ 9223372036854775807LL
+// PPC64-NETBSD:UINTMAX_MAX_ 18446744073709551615ULL
+//
+// PPC64-NETBSD:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// PPC64-NETBSD:SIG_ATOMIC_MAX_ 2147483647
+// PPC64-NETBSD:WINT_MIN_ (-2147483647 -1)
+// PPC64-NETBSD:WINT_MAX_ 2147483647
+//
+// PPC64-NETBSD:WCHAR_MAX_ 2147483647
+// PPC64-NETBSD:WCHAR_MIN_ (-2147483647 -1)
+//
+// PPC64-NETBSD:INT8_C_(0) 0
+// PPC64-NETBSD:UINT8_C_(0) 0U
+// PPC64-NETBSD:INT16_C_(0) 0
+// PPC64-NETBSD:UINT16_C_(0) 0U
+// PPC64-NETBSD:INT32_C_(0) 0
+// PPC64-NETBSD:UINT32_C_(0) 0U
+// PPC64-NETBSD:INT64_C_(0) 0LL
+// PPC64-NETBSD:UINT64_C_(0) 0ULL
+//
+// PPC64-NETBSD:INTMAX_C_(0) 0LL
+// PPC64-NETBSD:UINTMAX_C_(0) 0ULL
+//
 // RUN: %clang_cc1 -E -ffreestanding -triple=powerpc-none-none %s | FileCheck -check-prefix PPC %s
 //
 //
-// PPC:typedef signed long long int int64_t;
-// PPC:typedef unsigned long long int uint64_t;
+// PPC:typedef long long int int64_t;
+// PPC:typedef long long unsigned int uint64_t;
 // PPC:typedef int64_t int_least64_t;
 // PPC:typedef uint64_t uint_least64_t;
 // PPC:typedef int64_t int_fast64_t;
 // PPC:typedef uint64_t uint_fast64_t;
 //
-// PPC:typedef signed int int32_t;
+// PPC:typedef int int32_t;
 // PPC:typedef unsigned int uint32_t;
 // PPC:typedef int32_t int_least32_t;
 // PPC:typedef uint32_t uint_least32_t;
 // PPC:typedef int32_t int_fast32_t;
 // PPC:typedef uint32_t uint_fast32_t;
 //
-// PPC:typedef signed short int16_t;
+// PPC:typedef short int16_t;
 // PPC:typedef unsigned short uint16_t;
 // PPC:typedef int16_t int_least16_t;
 // PPC:typedef uint16_t uint_least16_t;
@@ -744,21 +851,21 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=s390x-none-none %s | FileCheck -check-prefix S390X %s
 //
-// S390X:typedef signed long long int int64_t;
-// S390X:typedef unsigned long long int uint64_t;
+// S390X:typedef long long int int64_t;
+// S390X:typedef long long unsigned int uint64_t;
 // S390X:typedef int64_t int_least64_t;
 // S390X:typedef uint64_t uint_least64_t;
 // S390X:typedef int64_t int_fast64_t;
 // S390X:typedef uint64_t uint_fast64_t;
 //
-// S390X:typedef signed int int32_t;
+// S390X:typedef int int32_t;
 // S390X:typedef unsigned int uint32_t;
 // S390X:typedef int32_t int_least32_t;
 // S390X:typedef uint32_t uint_least32_t;
 // S390X:typedef int32_t int_fast32_t;
 // S390X:typedef uint32_t uint_fast32_t;
 //
-// S390X:typedef signed short int16_t;
+// S390X:typedef short int16_t;
 // S390X:typedef unsigned short uint16_t;
 // S390X:typedef int16_t int_least16_t;
 // S390X:typedef uint16_t uint_least16_t;
@@ -851,21 +958,21 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=sparc-none-none %s | FileCheck -check-prefix SPARC %s
 //
-// SPARC:typedef signed long long int int64_t;
-// SPARC:typedef unsigned long long int uint64_t;
+// SPARC:typedef long long int int64_t;
+// SPARC:typedef long long unsigned int uint64_t;
 // SPARC:typedef int64_t int_least64_t;
 // SPARC:typedef uint64_t uint_least64_t;
 // SPARC:typedef int64_t int_fast64_t;
 // SPARC:typedef uint64_t uint_fast64_t;
 //
-// SPARC:typedef signed int int32_t;
+// SPARC:typedef int int32_t;
 // SPARC:typedef unsigned int uint32_t;
 // SPARC:typedef int32_t int_least32_t;
 // SPARC:typedef uint32_t uint_least32_t;
 // SPARC:typedef int32_t int_fast32_t;
 // SPARC:typedef uint32_t uint_fast32_t;
 //
-// SPARC:typedef signed short int16_t;
+// SPARC:typedef short int16_t;
 // SPARC:typedef unsigned short uint16_t;
 // SPARC:typedef int16_t int_least16_t;
 // SPARC:typedef uint16_t uint_least16_t;
@@ -958,14 +1065,14 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=tce-none-none %s | FileCheck -check-prefix TCE %s
 //
-// TCE:typedef signed int int32_t;
+// TCE:typedef int int32_t;
 // TCE:typedef unsigned int uint32_t;
 // TCE:typedef int32_t int_least32_t;
 // TCE:typedef uint32_t uint_least32_t;
 // TCE:typedef int32_t int_fast32_t;
 // TCE:typedef uint32_t uint_fast32_t;
 //
-// TCE:typedef signed short int16_t;
+// TCE:typedef short int16_t;
 // TCE:typedef unsigned short uint16_t;
 // TCE:typedef int16_t int_least16_t;
 // TCE:typedef uint16_t uint_least16_t;
@@ -1059,21 +1166,21 @@
 // RUN: %clang_cc1 -E -ffreestanding -triple=x86_64-none-none %s | FileCheck -check-prefix X86_64 %s
 //
 //
-// X86_64:typedef signed long int int64_t;
-// X86_64:typedef unsigned long int uint64_t;
+// X86_64:typedef long int int64_t;
+// X86_64:typedef long unsigned int uint64_t;
 // X86_64:typedef int64_t int_least64_t;
 // X86_64:typedef uint64_t uint_least64_t;
 // X86_64:typedef int64_t int_fast64_t;
 // X86_64:typedef uint64_t uint_fast64_t;
 //
-// X86_64:typedef signed int int32_t;
+// X86_64:typedef int int32_t;
 // X86_64:typedef unsigned int uint32_t;
 // X86_64:typedef int32_t int_least32_t;
 // X86_64:typedef uint32_t uint_least32_t;
 // X86_64:typedef int32_t int_fast32_t;
 // X86_64:typedef uint32_t uint_fast32_t;
 //
-// X86_64:typedef signed short int16_t;
+// X86_64:typedef short int16_t;
 // X86_64:typedef unsigned short uint16_t;
 // X86_64:typedef int16_t int_least16_t;
 // X86_64:typedef uint16_t uint_least16_t;
@@ -1173,27 +1280,27 @@
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=i386-mingw32 %s | FileCheck -check-prefix I386_MINGW32 %s
 //
-// I386_MINGW32:WCHAR_MAX_ 65535U
-// I386_MINGW32:WCHAR_MIN_ 0U
+// I386_MINGW32:WCHAR_MAX_ 65535
+// I386_MINGW32:WCHAR_MIN_ 0
 //
 //
 // RUN: %clang_cc1 -E -ffreestanding -triple=xcore-none-none %s | FileCheck -check-prefix XCORE %s
 //
-// XCORE:typedef signed long long int int64_t;
-// XCORE:typedef unsigned long long int uint64_t;
+// XCORE:typedef long long int int64_t;
+// XCORE:typedef long long unsigned int uint64_t;
 // XCORE:typedef int64_t int_least64_t;
 // XCORE:typedef uint64_t uint_least64_t;
 // XCORE:typedef int64_t int_fast64_t;
 // XCORE:typedef uint64_t uint_fast64_t;
 //
-// XCORE:typedef signed int int32_t;
+// XCORE:typedef int int32_t;
 // XCORE:typedef unsigned int uint32_t;
 // XCORE:typedef int32_t int_least32_t;
 // XCORE:typedef uint32_t uint_least32_t;
 // XCORE:typedef int32_t int_fast32_t;
 // XCORE:typedef uint32_t uint_fast32_t;
 //
-// XCORE:typedef signed short int16_t;
+// XCORE:typedef short int16_t;
 // XCORE:typedef unsigned short uint16_t;
 // XCORE:typedef int16_t int_least16_t;
 // XCORE:typedef uint16_t uint_least16_t;
@@ -1269,7 +1376,7 @@
 // XCORE:WINT_MIN_ 0U
 // XCORE:WINT_MAX_ 4294967295U
 //
-// XCORE:WCHAR_MAX_ 255U
+// XCORE:WCHAR_MAX_ 255
 // XCORE:WCHAR_MIN_ 0
 //
 // XCORE:INT8_C_(0) 0
diff --git a/test/Preprocessor/x86_target_features.c b/test/Preprocessor/x86_target_features.c
index 7bc5cd8..806eeec 100644
--- a/test/Preprocessor/x86_target_features.c
+++ b/test/Preprocessor/x86_target_features.c
@@ -114,6 +114,51 @@
 // AVX512PF: #define __SSE__ 1
 // AVX512PF: #define __SSSE3__ 1
 
+// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512dq -x c -E -dM -o - %s | FileCheck --check-prefix=AVX512DQ %s
+
+// AVX512DQ: #define __AVX2__ 1
+// AVX512DQ: #define __AVX512DQ__ 1
+// AVX512DQ: #define __AVX512F__ 1
+// AVX512DQ: #define __AVX__ 1
+// AVX512DQ: #define __SSE2_MATH__ 1
+// AVX512DQ: #define __SSE2__ 1
+// AVX512DQ: #define __SSE3__ 1
+// AVX512DQ: #define __SSE4_1__ 1
+// AVX512DQ: #define __SSE4_2__ 1
+// AVX512DQ: #define __SSE_MATH__ 1
+// AVX512DQ: #define __SSE__ 1
+// AVX512DQ: #define __SSSE3__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512bw -x c -E -dM -o - %s | FileCheck --check-prefix=AVX512BW %s
+
+// AVX512BW: #define __AVX2__ 1
+// AVX512BW: #define __AVX512BW__ 1
+// AVX512BW: #define __AVX512F__ 1
+// AVX512BW: #define __AVX__ 1
+// AVX512BW: #define __SSE2_MATH__ 1
+// AVX512BW: #define __SSE2__ 1
+// AVX512BW: #define __SSE3__ 1
+// AVX512BW: #define __SSE4_1__ 1
+// AVX512BW: #define __SSE4_2__ 1
+// AVX512BW: #define __SSE_MATH__ 1
+// AVX512BW: #define __SSE__ 1
+// AVX512BW: #define __SSSE3__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mavx512vl -x c -E -dM -o - %s | FileCheck --check-prefix=AVX512VL %s
+
+// AVX512VL: #define __AVX2__ 1
+// AVX512VL: #define __AVX512F__ 1
+// AVX512VL: #define __AVX512VL__ 1
+// AVX512VL: #define __AVX__ 1
+// AVX512VL: #define __SSE2_MATH__ 1
+// AVX512VL: #define __SSE2__ 1
+// AVX512VL: #define __SSE3__ 1
+// AVX512VL: #define __SSE4_1__ 1
+// AVX512VL: #define __SSE4_2__ 1
+// AVX512VL: #define __SSE_MATH__ 1
+// AVX512VL: #define __SSE__ 1
+// AVX512VL: #define __SSSE3__ 1
+
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavx512pf -mno-avx512f -x c -E -dM -o - %s | FileCheck --check-prefix=AVX512F2 %s
 
 // AVX512F2: #define __AVX2__ 1
@@ -236,3 +281,11 @@
 
 // NO3DNOWPRFCHW: #define __PRFCHW__ 1
 
+// RUN: %clang -target i386-unknown-unknown -march=atom -madx -x c -E -dM -o - %s | FileCheck --check-prefix=ADX %s
+
+// ADX: #define __ADX__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mrdseed -x c -E -dM -o - %s | FileCheck --check-prefix=RDSEED %s
+
+// RDSEED: #define __RDSEED__ 1
+
diff --git a/test/Profile/Inputs/c-general.profdata.v1 b/test/Profile/Inputs/c-general.profdata.v1
new file mode 100644
index 0000000..e7dedcb
--- /dev/null
+++ b/test/Profile/Inputs/c-general.profdata.v1
Binary files differ
diff --git a/test/Profile/c-general.c b/test/Profile/c-general.c
index 442fdd3..79707ad 100644
--- a/test/Profile/c-general.c
+++ b/test/Profile/c-general.c
@@ -5,6 +5,9 @@
 // RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
 
+// Also check compatibility with older profiles.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%S/Inputs/c-general.profdata.v1 | FileCheck -check-prefix=PGOUSE %s
+
 // PGOGEN: @[[SLC:__llvm_profile_counters_simple_loops]] = hidden global [4 x i64] zeroinitializer
 // PGOGEN: @[[IFC:__llvm_profile_counters_conditionals]] = hidden global [11 x i64] zeroinitializer
 // PGOGEN: @[[EEC:__llvm_profile_counters_early_exits]] = hidden global [9 x i64] zeroinitializer
diff --git a/test/Rewriter/finally.m b/test/Rewriter/finally.m
index f46b4b0..e60ba9e 100644
--- a/test/Rewriter/finally.m
+++ b/test/Rewriter/finally.m
@@ -3,7 +3,7 @@
 int main() {
   @try {
     printf("executing try"); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
-        // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+        // expected-note{{include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
     return(0); // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
   } @finally {
     printf("executing finally");
diff --git a/test/Rewriter/lit.local.cfg b/test/Rewriter/lit.local.cfg
index 5bbc711..69b733b 100644
--- a/test/Rewriter/lit.local.cfg
+++ b/test/Rewriter/lit.local.cfg
@@ -1,2 +1,3 @@
-if config.root.clang_rewriter == 0:
+# The Objective-C rewriters are currently grouped with ARCMT.
+if config.root.clang_arcmt == 0:
     config.unsupported = True
diff --git a/test/Rewriter/rewrite-block-literal.mm b/test/Rewriter/rewrite-block-literal.mm
index 43f5811..cde6efc 100644
--- a/test/Rewriter/rewrite-block-literal.mm
+++ b/test/Rewriter/rewrite-block-literal.mm
@@ -70,7 +70,7 @@
 void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
 
 // CHECK: static __global_block_block_impl_0 __global_global_block_block_impl_0((void *)__global_block_block_func_0, &__global_block_block_desc_0_DATA);
-// CHECK: void (*global_block)(void) = (void (*)())&__global_global_block_block_impl_0;
+// CHECK: void (*global_block)(void) = ((void (*)())&__global_global_block_block_impl_0);
 
 typedef void (^void_block_t)(void);
 
diff --git a/test/Rewriter/rewrite-modern-block.mm b/test/Rewriter/rewrite-modern-block.mm
index 2302965..926ee36 100644
--- a/test/Rewriter/rewrite-modern-block.mm
+++ b/test/Rewriter/rewrite-modern-block.mm
@@ -63,3 +63,6 @@
     options &= ~(1 | 2);
 }
 @end
+
+// rdar://18799145
+int Test18799145() { return ^(){return 0;}(); }
diff --git a/test/Rewriter/rewrite-modern-captured-nested-bvar.mm b/test/Rewriter/rewrite-modern-captured-nested-bvar.mm
index a8fd180..be7548c 100644
--- a/test/Rewriter/rewrite-modern-captured-nested-bvar.mm
+++ b/test/Rewriter/rewrite-modern-captured-nested-bvar.mm
@@ -32,4 +32,4 @@
 
 // CHECK 2: (__Block_byref_BYREF_VAR_CHECK_0 *)BYREF_VAR_CHECK
 // CHECK: {(void*)0,(__Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, 0, sizeof(__Block_byref_BYREF_VAR_CHECK_0), 'a'}
-// CHECK: __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (__Block_byref_d_1 *)&d, 570425344));
+// CHECK: __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (__Block_byref_d_1 *)&d, 570425344)));
diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c
index 4272b2d..6469d84 100644
--- a/test/Sema/128bitint.c
+++ b/test/Sema/128bitint.c
@@ -16,10 +16,10 @@
 __int128 i = (__int128)0;
 unsigned __int128 u = (unsigned __int128)-1;
 
-long long SignedTooBig = 123456789012345678901234567890; // expected-error {{constant is larger than the largest unsigned integer type}}
+long long SignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}}
 __int128_t Signed128 = 123456789012345678901234567890i128;
 long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}}
-unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-error {{constant is larger than the largest unsigned integer type}}
+unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}}
 __uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
 unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}}
 
diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c
index b199644..e703230 100644
--- a/test/Sema/MicrosoftExtensions.c
+++ b/test/Sema/MicrosoftExtensions.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
 
 
 struct A
@@ -39,9 +39,26 @@
   NESTED1;  // expected-warning {{anonymous structs are a Microsoft extension}}
 };
 
+struct nested2 PR20573 = { .a = 3 };
+
+struct nested3 {
+  long d;
+  struct nested4 { // expected-warning {{anonymous structs are a Microsoft extension}}
+    long e;
+  };
+  union nested5 { // expected-warning {{anonymous unions are a Microsoft extension}}
+    long f;
+  };
+};
+
+typedef union nested6 {
+  long f;
+} NESTED6;
+
 struct test {
   int c;
   struct nested2;   // expected-warning {{anonymous structs are a Microsoft extension}}
+  NESTED6;   // expected-warning {{anonymous unions are a Microsoft extension}}
 };
 
 void foo()
@@ -87,6 +104,14 @@
   AA; // expected-warning {{anonymous structs are a Microsoft extension}}
 } BB;
 
+struct anon_fault {
+  struct undefined; // expected-warning {{anonymous structs are a Microsoft extension}}
+                    // expected-error@-1 {{field has incomplete type 'struct undefined'}}
+                    // expected-note@-2 {{forward declaration of 'struct undefined'}}
+};
+
+const int anon_falt_size = sizeof(struct anon_fault);
+
 __declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' has been explicitly marked deprecated here}}
 struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{'DS1' has been explicitly marked deprecated here}}
 
diff --git a/test/Sema/align_value.c b/test/Sema/align_value.c
new file mode 100644
index 0000000..92b84db
--- /dev/null
+++ b/test/Sema/align_value.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef double * __attribute__((align_value(64))) aligned_double;
+
+void foo(aligned_double x, double * y __attribute__((align_value(32)))) { };
+
+// expected-error@+1 {{requested alignment is not a power of 2}}
+typedef double * __attribute__((align_value(63))) aligned_double1;
+
+// expected-error@+1 {{requested alignment is not a power of 2}}
+typedef double * __attribute__((align_value(-2))) aligned_double2;
+
+// expected-error@+1 {{attribute takes one argument}}
+typedef double * __attribute__((align_value(63, 4))) aligned_double3;
+
+// expected-error@+1 {{attribute takes one argument}}
+typedef double * __attribute__((align_value())) aligned_double3a;
+
+// expected-error@+1 {{attribute takes one argument}}
+typedef double * __attribute__((align_value)) aligned_double3b;
+
+// expected-error@+1 {{'align_value' attribute requires integer constant}}
+typedef double * __attribute__((align_value(4.5))) aligned_double4;
+
+// expected-warning@+1 {{'align_value' attribute only applies to a pointer or reference ('int' is invalid)}}
+typedef int __attribute__((align_value(32))) aligned_int;
+
+typedef double * __attribute__((align_value(32*2))) aligned_double5;
+
+// expected-warning@+1 {{'align_value' attribute only applies to variables and typedefs}}
+void foo() __attribute__((align_value(32)));
+
diff --git a/test/Sema/anonymous-struct-union-c11.c b/test/Sema/anonymous-struct-union-c11.c
index 229ee52..712e29e 100644
--- a/test/Sema/anonymous-struct-union-c11.c
+++ b/test/Sema/anonymous-struct-union-c11.c
@@ -1,8 +1,8 @@
 // Check for warnings in non-C11 mode:
-// RUN: %clang_cc1 -fsyntax-only -verify -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wc11-extensions %s
 
 // Expect no warnings in C11 mode:
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -pedantic -Werror %s
 
 struct s {
   int a;
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c
index 35d3175..652383e 100644
--- a/test/Sema/anonymous-struct-union.c
+++ b/test/Sema/anonymous-struct-union.c
@@ -37,7 +37,7 @@
 
 struct Redecl {
   int x; // expected-note{{previous declaration is here}}
-  struct y { };
+  struct y { }; // expected-warning{{declaration does not declare anything}}
 
   union {
     int x; // expected-error{{member of anonymous union redeclares 'x'}}
@@ -108,3 +108,13 @@
   struct { int i; };
   int a[];
 };
+
+// PR20930
+struct s3 {
+  struct { int A __attribute__((deprecated)); }; // expected-note {{'A' has been explicitly marked deprecated here}}
+};
+
+void deprecated_anonymous_struct_member(void) {
+  struct s3 s;
+  s.A = 1; // expected-warning {{'A' is deprecated}}
+}
diff --git a/test/Sema/arm-darwin-aapcs.cpp b/test/Sema/arm-darwin-aapcs.cpp
index 1359a1d..3a6082a 100644
--- a/test/Sema/arm-darwin-aapcs.cpp
+++ b/test/Sema/arm-darwin-aapcs.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple thumbv7-apple-ios -target-abi aapcs -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbv7m-apple-macho -target-abi aapcs -verify -fsyntax-only
 // expected-no-diagnostics
 
 // ARM's AAPCS normally has size_t defined as unsigned int, but on Darwin
diff --git a/test/Sema/arm64-inline-asm.c b/test/Sema/arm64-inline-asm.c
index 08eb669..d8e16a6 100644
--- a/test/Sema/arm64-inline-asm.c
+++ b/test/Sema/arm64-inline-asm.c
@@ -1,9 +1,9 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 void foo() {
   asm volatile("USE(%0)" :: "z"(0LL));
   asm volatile("USE(%x0)" :: "z"(0LL));
   asm volatile("USE(%w0)" :: "z"(0));
 
+  asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
 }
diff --git a/test/Sema/arm64-neon-args.c b/test/Sema/arm64-neon-args.c
index 315a704..a6c4f13 100644
--- a/test/Sema/arm64-neon-args.c
+++ b/test/Sema/arm64-neon-args.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-apple-darwin -target-feature +neon -fsyntax-only -ffreestanding -verify %s
-// RUN: %clang_cc1 -triple arm64_be-none-linux-gnu -target-feature +neon -fsyntax-only -ffreestanding -verify %s
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon -fsyntax-only -ffreestanding -verify %s
 
 #include <arm_neon.h>
 
diff --git a/test/Sema/arm_acle.c b/test/Sema/arm_acle.c
index 9a70f85..ec0d558 100644
--- a/test/Sema/arm_acle.c
+++ b/test/Sema/arm_acle.c
@@ -1,6 +1,22 @@
 // RUN: %clang_cc1 -triple armv8 -target-cpu cortex-a57 -fsyntax-only -ffreestanding -verify %s
 
 #include <arm_acle.h>
+/*
+ * Memory barrier intrinsics
+ * Argument for dmb, dsb, isb must be compile-time constant,
+ * otherwise an error should be raised.
+ */
+void test_dmb_const_diag(const unsigned int t) {
+  return __dmb(t);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
+}
+
+void test_dsb_const_diag(const unsigned int t) {
+  return __dsb(t);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
+}
+
+void test_isb_const_diag(const unsigned int t) {
+  return __isb(t);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
+}
 
 /*
  * Saturating intrinsics
@@ -14,3 +30,19 @@
 int32_t test_usat_const_diag(int32_t t, const int32_t v) {
   return __usat(t, v);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
 }
+
+/*
+ * Prefetch intrinsics
+ */
+void test_pldx_const_diag(int32_t i) {
+  __pldx(i, 0, 0, 0);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
+}
+
+/*
+ * DBG intrinsic
+ * First argument for DBG intrinsic must be compile-time constant,
+ * otherwise an error should be raised.
+ */
+void test_dbg_const_diag(unsigned int t) {
+  __dbg(t);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
+}
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index 4cc5e41..7cb4815 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wgnu -Wc11-extensions -verify %s
+// RUN: %clang_cc1 -std=gnu99 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -std=gnu99 -fsyntax-only -Wgnu -Wc11-extensions -verify %s
 // REQUIRES: LP64
 
 extern int foof() = 1; // expected-error{{illegal initializer (only variables can be initialized)}}
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 22b7497..13ae25f 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -107,6 +107,7 @@
 
   register int r asm ("cx");
   register int rr asm ("rr_asm"); // expected-error{{unknown register name 'rr_asm' in asm}}
+  register int rrr asm ("%"); // expected-error{{unknown register name '%' in asm}}
 }
 
 // This is just an assert because of the boolean conversion.
@@ -157,3 +158,9 @@
 };
 register struct foo bar asm("sp"); // expected-error {{bad type for named register variable}}
 register float baz asm("sp"); // expected-error {{bad type for named register variable}}
+
+double f_output_constraint(void) {
+  double result;
+  __asm("foo1": "=f" (result)); // expected-error {{invalid output constraint '=f' in asm}}
+  return result;
+}
diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c
index 2066e18..4b2b431 100644
--- a/test/Sema/ast-print.c
+++ b/test/Sema/ast-print.c
@@ -18,3 +18,30 @@
   // CHECK: return b->b;
   return b->b;
 }
+
+int arr(int a[static 3]) {
+  // CHECK: int a[static 3]
+  return a[2];
+}
+
+int rarr(int a[restrict static 3]) {
+  // CHECK: int a[restrict static 3]
+  return a[2];
+}
+
+int varr(int n, int a[static n]) {
+  // CHECK: int a[static n]
+  return a[2];
+}
+
+int rvarr(int n, int a[restrict static n]) {
+  // CHECK: int a[restrict static n]
+  return a[2];
+}
+
+typedef struct {
+  int f;
+} T __attribute__ ((__aligned__));
+
+// CHECK: struct __attribute__((visibility("default"))) S;
+struct __attribute__((visibility("default"))) S;
diff --git a/test/Sema/atomic-compare.c b/test/Sema/atomic-compare.c
new file mode 100644
index 0000000..2eed091
--- /dev/null
+++ b/test/Sema/atomic-compare.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void f(_Atomic(int) a, _Atomic(int) b) {
+  if (a > b)      {} // no warning
+  if (a < b)      {} // no warning
+  if (a >= b)     {} // no warning
+  if (a <= b)     {} // no warning
+  if (a == b)     {} // no warning
+  if (a != b)     {} // no warning
+
+  if (a == 0) {} // no warning
+  if (a > 0) {} // no warning
+  if (a > 1) {} // no warning
+  if (a > 2) {} // no warning
+
+  if (!a > 0) {}  // no warning
+  if (!a > 1)     {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}
+  if (!a > 2)     {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}
+  if (!a > b)     {} // no warning
+  if (!a > -1)    {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}
+}
diff --git a/test/Sema/atomic-expr.c b/test/Sema/atomic-expr.c
index 5602d54..997ee90 100644
--- a/test/Sema/atomic-expr.c
+++ b/test/Sema/atomic-expr.c
@@ -58,3 +58,6 @@
   return x ? data1 : y;
 }
 
+int func_14 () {
+  return data1 == 0;
+}
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index 320abc5..e21c3fd 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -1,11 +1,8 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=i686-linux-gnu -std=c11
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
-typedef enum memory_order {
-  memory_order_relaxed, memory_order_consume, memory_order_acquire,
-  memory_order_release, memory_order_acq_rel, memory_order_seq_cst
-} memory_order;
+#include <stdatomic.h>
 
 struct S { char c[3]; };
 
@@ -40,6 +37,14 @@
 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
 
+_Static_assert(atomic_is_lock_free((atomic_char*)0), "");
+_Static_assert(atomic_is_lock_free((atomic_short*)0), "");
+_Static_assert(atomic_is_lock_free((atomic_int*)0), "");
+_Static_assert(atomic_is_lock_free((atomic_long*)0), "");
+// expected-error@+1 {{__int128 is not supported on this target}}
+_Static_assert(atomic_is_lock_free((_Atomic(__int128)*)0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(atomic_is_lock_free(0 + (atomic_char*)0), "");
+
 char i8;
 short i16;
 int i32;
@@ -171,6 +176,62 @@
   __c11_atomic_init(&const_atomic, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
   __c11_atomic_store(&const_atomic, 0, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
   __c11_atomic_load(&const_atomic, memory_order_acquire); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
+
+  // Ensure the <stdatomic.h> macros behave appropriately.
+  atomic_int n = ATOMIC_VAR_INIT(123);
+  atomic_init(&n, 456);
+  atomic_init(&n, (void*)0); // expected-warning {{passing 'void *' to parameter of type 'int'}}
+
+  const atomic_wchar_t cawt;
+  atomic_init(&cawt, L'x'); // expected-error {{non-const}}
+  atomic_wchar_t awt;
+  atomic_init(&awt, L'x');
+
+  int x = kill_dependency(12);
+
+  atomic_thread_fence(); // expected-error {{too few arguments to function call}}
+  atomic_thread_fence(memory_order_seq_cst);
+  atomic_signal_fence(memory_order_seq_cst);
+  void (*pfn)(memory_order) = &atomic_thread_fence;
+  pfn = &atomic_signal_fence;
+
+  int k = atomic_load_explicit(&n, memory_order_relaxed);
+  atomic_store_explicit(&n, k, memory_order_relaxed);
+  atomic_store(&n, atomic_load(&n));
+
+  k = atomic_exchange(&n, 72);
+  k = atomic_exchange_explicit(&n, k, memory_order_release);
+
+  atomic_compare_exchange_strong(&n, k, k); // expected-warning {{take the address with &}}
+  atomic_compare_exchange_weak(&n, &k, k);
+  atomic_compare_exchange_strong_explicit(&n, &k, k, memory_order_seq_cst); // expected-error {{too few arguments}}
+  atomic_compare_exchange_weak_explicit(&n, &k, k, memory_order_seq_cst, memory_order_acquire);
+
+  atomic_fetch_add(&k, n); // expected-error {{must be a pointer to _Atomic}}
+  k = atomic_fetch_add(&n, k);
+  k = atomic_fetch_sub(&n, k);
+  k = atomic_fetch_and(&n, k);
+  k = atomic_fetch_or(&n, k);
+  k = atomic_fetch_xor(&n, k);
+  k = atomic_fetch_add_explicit(&n, k, memory_order_acquire);
+  k = atomic_fetch_sub_explicit(&n, k, memory_order_release);
+  k = atomic_fetch_and_explicit(&n, k, memory_order_acq_rel);
+  k = atomic_fetch_or_explicit(&n, k, memory_order_consume);
+  k = atomic_fetch_xor_explicit(&n, k, memory_order_relaxed);
+
+  // C11 7.17.1/4: atomic_flag is a structure type.
+  struct atomic_flag must_be_struct = ATOMIC_FLAG_INIT;
+  // C11 7.17.8/5 implies that it is also a typedef type.
+  atomic_flag guard = ATOMIC_FLAG_INIT;
+  _Bool old_val = atomic_flag_test_and_set(&guard);
+  if (old_val) atomic_flag_clear(&guard);
+
+  old_val = (atomic_flag_test_and_set)(&guard);
+  if (old_val) (atomic_flag_clear)(&guard);
+
+  const atomic_flag const_guard;
+  atomic_flag_test_and_set(&const_guard); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const atomic_bool *' (aka 'const _Atomic(_Bool) *') invalid)}}
+  atomic_flag_clear(&const_guard); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const atomic_bool *' (aka 'const _Atomic(_Bool) *') invalid)}}
 }
 
 _Atomic(int*) PR12527_a;
@@ -403,3 +464,5 @@
   (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acq_rel, memory_order_relaxed);
   (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
 }
+
+
diff --git a/test/Sema/attr-bounded.c b/test/Sema/attr-bounded.c
index bf71fed..3108fbd 100644
--- a/test/Sema/attr-bounded.c
+++ b/test/Sema/attr-bounded.c
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 -fsyntax-only %s

-// Make sure OpenBSD's bounded extension is accepted.

-

-typedef long ssize_t;

-typedef unsigned long size_t;

-typedef struct FILE FILE;

-

-ssize_t read(int, void *, size_t)

-    __attribute__((__bounded__(__buffer__,2,3)));

-int readlink(const char *, char *, size_t)

-    __attribute__((__bounded__(__string__,2,3)));

-size_t fread(void *, size_t, size_t, FILE *)

-    __attribute__((__bounded__(__size__,1,3,2)));

-char *getwd(char *)

-    __attribute__((__bounded__(__minbytes__,1,1024)));
\ No newline at end of file
+// RUN: %clang_cc1 -fsyntax-only %s
+// Make sure OpenBSD's bounded extension is accepted.
+
+typedef long ssize_t;
+typedef unsigned long size_t;
+typedef struct FILE FILE;
+
+ssize_t read(int, void *, size_t)
+    __attribute__((__bounded__(__buffer__,2,3)));
+int readlink(const char *, char *, size_t)
+    __attribute__((__bounded__(__string__,2,3)));
+size_t fread(void *, size_t, size_t, FILE *)
+    __attribute__((__bounded__(__size__,1,3,2)));
+char *getwd(char *)
+    __attribute__((__bounded__(__minbytes__,1,1024)));
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c
index c9e3dd5..2e3e722 100644
--- a/test/Sema/attr-deprecated.c
+++ b/test/Sema/attr-deprecated.c
@@ -121,6 +121,6 @@
   __attribute((deprecated)) foo_dep e, f;
 };
 
-typedef int test23_ty __attribute((deprecated)); // expected-note {{previous definition is here}}
-typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}} expected-warning {{redefinition of typedef 'test23_ty' is a C11 feature}}
+typedef int test23_ty __attribute((deprecated));
+typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}}
 test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
diff --git a/test/Sema/attr-msp430.c b/test/Sema/attr-msp430.c
index d08cd8e..26b2d8f 100644
--- a/test/Sema/attr-msp430.c
+++ b/test/Sema/attr-msp430.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple msp430-unknown-unknown -fsyntax-only -verify %s

-

-int i;

-void f(void) __attribute__((interrupt(i))); /* expected-error {{'interrupt' attribute requires an integer constant}} */

-

-void f2(void) __attribute__((interrupt(12)));

+// RUN: %clang_cc1 -triple msp430-unknown-unknown -fsyntax-only -verify %s
+
+int i;
+void f(void) __attribute__((interrupt(i))); /* expected-error {{'interrupt' attribute requires an integer constant}} */
+
+void f2(void) __attribute__((interrupt(12)));
diff --git a/test/Sema/attr-naked.c b/test/Sema/attr-naked.c
index 55c6b32..6b1344a 100644
--- a/test/Sema/attr-naked.c
+++ b/test/Sema/attr-naked.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple i686-pc-linux
 
 int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}}
 
@@ -10,3 +10,41 @@
 
 void t2() __attribute__((naked(2))); // expected-error {{'naked' attribute takes no arguments}}
 
+__attribute__((naked)) int t3() { // expected-note{{attribute is here}}
+  return 42; // expected-error{{non-ASM statement in naked function is not supported}}
+}
+
+__attribute__((naked)) int t4() {
+  asm("movl $42, %eax");
+  asm("retl");
+}
+
+__attribute__((naked)) int t5(int x) {
+  asm("movl x, %eax");
+  asm("retl");
+}
+
+__attribute__((naked)) void t6() {
+  ;
+}
+
+__attribute__((naked)) void t7() {
+  asm("movl $42, %eax");
+  ;
+}
+
+extern int x, y;
+
+__attribute__((naked)) void t8(int z) { // expected-note{{attribute is here}}
+  __asm__ ("movl $42, %1"
+           : "=r"(x),
+             "=r"(z) // expected-error{{parameter references not allowed in naked functions}}
+           );
+}
+
+__attribute__((naked)) void t9(int z) { // expected-note{{attribute is here}}
+  __asm__ ("movl %eax, %1"
+           : : "r"(x),
+               "r"(z) // expected-error{{parameter references not allowed in naked functions}}
+           );
+}
diff --git a/test/Sema/attr-nonnull.c b/test/Sema/attr-nonnull.c
new file mode 100644
index 0000000..f8de317
--- /dev/null
+++ b/test/Sema/attr-nonnull.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void f1(int *a1, int *a2, int *a3, int *a4, int *a5, int *a6, int *a7,
+        int *a8, int *a9, int *a10, int *a11, int *a12, int *a13, int *a14,
+        int *a15, int *a16) __attribute__((nonnull(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)));
+
+void f2(void) __attribute__((nonnull())); // expected-warning {{'nonnull' attribute applied to function with no pointer arguments}}
diff --git a/test/Sema/attr-ownership.c b/test/Sema/attr-ownership.c
index 2aa9f9f..d2e48c6 100644
--- a/test/Sema/attr-ownership.c
+++ b/test/Sema/attr-ownership.c
@@ -17,3 +17,8 @@
 
 void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_takes(foo, 2)));
 void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3)));  // expected-error {{'ownership_holds' and 'ownership_takes' attributes are not compatible}}
+
+void f15(int, int)
+  __attribute__((ownership_returns(foo, 1)))  // expected-note {{declared with index 1 here}}
+  __attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
+void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
diff --git a/test/Sema/big-endian-neon-initializers.c b/test/Sema/big-endian-neon-initializers.c
index ffe3109..c706d00 100644
--- a/test/Sema/big-endian-neon-initializers.c
+++ b/test/Sema/big-endian-neon-initializers.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple arm64_be -target-feature +neon -verify -fsyntax-only -ffreestanding
+// RUN: %clang_cc1 %s -triple aarch64_be -target-feature +neon -verify -fsyntax-only -ffreestanding
 // RUN: %clang_cc1 %s -triple armebv7 -target-cpu cortex-a8 -verify -fsyntax-only -ffreestanding
 
 #include <arm_neon.h>
diff --git a/test/Sema/bitfield.c b/test/Sema/bitfield.c
index ab05a77..a4629c6 100644
--- a/test/Sema/bitfield.c
+++ b/test/Sema/bitfield.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify 
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c11
 enum e0; // expected-note{{forward declaration of 'enum e0'}}
 
 struct a {
@@ -54,3 +54,22 @@
   (void) sizeof(t->var ? t->bitX : t->bitY); // not a bitfield designator in C
   (void) sizeof(t->var ? t->bitX : t->bitX); // not a bitfield designator in C
 }
+
+typedef unsigned Unsigned;
+typedef signed Signed;
+
+struct Test5 { unsigned n : 2; } t5;
+typedef __typeof__(t5.n) Unsigned; // Bitfield is unsigned
+typedef __typeof__(+t5.n) Signed;  // ... but promotes to signed.
+
+typedef __typeof__(t5.n + 0) Signed; // Arithmetic promotes.
+
+typedef __typeof__(+(t5.n = 0)) Signed;  // FIXME: Assignment should not; the result
+typedef __typeof__(+(t5.n += 0)) Signed; // is a non-bit-field lvalue of type unsigned.
+typedef __typeof__(+(t5.n *= 0)) Signed;
+
+typedef __typeof__(+(++t5.n)) Signed; // FIXME: Increment is equivalent to compound-assignment.
+typedef __typeof__(+(--t5.n)) Signed; // This should not promote to signed.
+
+typedef __typeof__(+(t5.n++)) Unsigned; // Post-increment is underspecified, but seems to
+typedef __typeof__(+(t5.n--)) Unsigned; // also act like compound-assignment.
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index b4732b5..0ca4f20 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -190,7 +190,7 @@
 
 // rdar://7072507
 int test19() {
-  goto L0;       // expected-error {{goto into protected scope}}
+  goto L0;       // expected-error {{cannot jump}}
   
   __block int x; // expected-note {{jump bypasses setup of __block variable}}
 L0:
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 6b4d998..08e9249 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -82,7 +82,7 @@
   int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
   
   int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
-  // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+  // expected-note{{include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
 }
 
 typedef void (^bptr)(void);
diff --git a/test/Sema/builtin-assume-aligned.c b/test/Sema/builtin-assume-aligned.c
new file mode 100644
index 0000000..33c1b74
--- /dev/null
+++ b/test/Sema/builtin-assume-aligned.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int test1(int *a) {
+  a = __builtin_assume_aligned(a, 32, 0ull);
+  return a[0];
+}
+
+int test2(int *a) {
+  a = __builtin_assume_aligned(a, 32, 0);
+  return a[0];
+}
+
+int test3(int *a) {
+  a = __builtin_assume_aligned(a, 32);
+  return a[0];
+}
+
+int test4(int *a) {
+  a = __builtin_assume_aligned(a, -32); // expected-error {{requested alignment is not a power of 2}}
+  // FIXME: The line below produces {{requested alignment is not a power of 2}}
+  // on i386-freebsd, but not on x86_64-linux (for example).
+  // a = __builtin_assume_aligned(a, 1ULL << 63);
+  return a[0];
+}
+
+int test5(int *a, unsigned *b) {
+  a = __builtin_assume_aligned(a, 32, b); // expected-warning {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
+  return a[0];
+}
+
+int test6(int *a) {
+  a = __builtin_assume_aligned(a, 32, 0, 0); // expected-error {{too many arguments to function call, expected at most 3, have 4}}
+  return a[0];
+}
+
+int test7(int *a) {
+  a = __builtin_assume_aligned(a, 31); // expected-error {{requested alignment is not a power of 2}}
+  return a[0];
+}
+
+int test8(int *a, int j) {
+  a = __builtin_assume_aligned(a, j); // expected-error {{must be a constant integer}}
+  return a[0];
+}
+
+void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
+int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
+void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
+
+int j __attribute__((assume_aligned(8))); // expected-warning {{'assume_aligned' attribute only applies to functions and methods}}
+void *test_no_fn_proto() __attribute__((assume_aligned(32))); // no-warning
+void *test_with_fn_proto(void) __attribute__((assume_aligned(128))); // no-warning
+
+void *test_no_fn_proto() __attribute__((assume_aligned(31))); // expected-error {{requested alignment is not a power of 2}}
+void *test_no_fn_proto() __attribute__((assume_aligned(32, 73))); // no-warning
+
+void *test_no_fn_proto() __attribute__((assume_aligned)); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
+void *test_no_fn_proto() __attribute__((assume_aligned())); // expected-error {{'assume_aligned' attribute takes at least 1 argument}}
+void *test_no_fn_proto() __attribute__((assume_aligned(32, 45, 37))); // expected-error {{'assume_aligned' attribute takes no more than 2 arguments}}
+
diff --git a/test/Sema/builtin-assume.c b/test/Sema/builtin-assume.c
new file mode 100644
index 0000000..512eeec
--- /dev/null
+++ b/test/Sema/builtin-assume.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+int foo(int *a, int i) {
+#ifdef _MSC_VER
+  __assume(i != 4);
+  __assume(++i > 2); //expected-warning {{the argument to '__assume' has side effects that will be discarded}}
+
+  int test = sizeof(struct{char qq[(__assume(i != 5), 7)];});
+#else
+  __builtin_assume(i != 4);
+  __builtin_assume(++i > 2); //expected-warning {{the argument to '__builtin_assume' has side effects that will be discarded}}
+
+  int test = sizeof(struct{char qq[(__builtin_assume(i != 5), 7)];});
+#endif
+  return a[i];
+}
+
diff --git a/test/Sema/builtin-object-size.c b/test/Sema/builtin-object-size.c
index 0abc27b..b1bda06 100644
--- a/test/Sema/builtin-object-size.c
+++ b/test/Sema/builtin-object-size.c
@@ -23,6 +23,32 @@
 // rdar://6252231 - cannot call vsnprintf with va_list on x86_64
 void f4(const char *fmt, ...) {
  __builtin_va_list args;
- __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args);
+ __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args); // expected-warning {{'__builtin___vsnprintf_chk' will always overflow destination buffer}}
 }
 
+// rdar://18334276
+typedef __typeof__(sizeof(int)) size_t;
+void * memcset(void *restrict dst, int src, size_t n);
+void * memcpy(void *restrict dst, const void *restrict src, size_t n);
+
+#define memset(dest, src, len) __builtin___memset_chk(dest, src, len, __builtin_object_size(dest, 0))
+#define memcpy(dest, src, len) __builtin___memcpy_chk(dest, src, len, __builtin_object_size(dest, 0))
+#define memcpy1(dest, src, len) __builtin___memcpy_chk(dest, src, len, __builtin_object_size(dest, 4))
+#define NULL ((void *)0)
+
+void f5(void)
+{
+  char buf[10];
+  memset((void *)0x100000000ULL, 0, 0x1000);
+  memcpy((char *)NULL + 0x10000, buf, 0x10);
+  memcpy1((char *)NULL + 0x10000, buf, 0x10); // expected-error {{argument should be a value from 0 to 3}}
+}
+
+// rdar://18431336
+void f6(void)
+{
+  char b[5];
+  char buf[10];
+  __builtin___memccpy_chk (buf, b, '\0', sizeof(b), __builtin_object_size (buf, 0));
+  __builtin___memccpy_chk (b, buf, '\0', sizeof(buf), __builtin_object_size (b, 0));  // expected-warning {{'__builtin___memccpy_chk' will always overflow destination buffer}}
+}
diff --git a/test/Sema/builtins-arm.c b/test/Sema/builtins-arm.c
index 6c367d3..37604dc 100644
--- a/test/Sema/builtins-arm.c
+++ b/test/Sema/builtins-arm.c
@@ -30,6 +30,7 @@
   __builtin_va_list ptr = "x";
   *ptr = '0'; // expected-error {{incomplete type 'void' is not assignable}}
 }
+#endif
 
 void test3() {
   __builtin_arm_dsb(16); // expected-error {{argument should be a value from 0 to 15}}
@@ -37,4 +38,11 @@
   __builtin_arm_isb(18); // expected-error {{argument should be a value from 0 to 15}}
 }
 
-#endif
+void test4() {
+  __builtin_arm_prefetch(0, 2, 0); // expected-error {{argument should be a value from 0 to 1}}
+  __builtin_arm_prefetch(0, 0, 2); // expected-error {{argument should be a value from 0 to 1}}
+}
+
+void test5() {
+  __builtin_arm_dbg(16); // expected-error {{argument should be a value from 0 to 15}}
+}
diff --git a/test/Sema/builtins-arm64.c b/test/Sema/builtins-arm64.c
index f2bdc9d..2779984 100644
--- a/test/Sema/builtins-arm64.c
+++ b/test/Sema/builtins-arm64.c
@@ -16,3 +16,16 @@
 void test_clear_cache_no_args() {
   __clear_cache(); // expected-error {{too few arguments to function call}}
 }
+
+void test_memory_barriers() {
+  __builtin_arm_dmb(16); // expected-error {{argument should be a value from 0 to 15}}
+  __builtin_arm_dsb(17); // expected-error {{argument should be a value from 0 to 15}}
+  __builtin_arm_isb(18); // expected-error {{argument should be a value from 0 to 15}}
+}
+
+void test_prefetch() {
+  __builtin_arm_prefetch(0, 2, 0, 0, 0); // expected-error {{argument should be a value from 0 to 1}}
+  __builtin_arm_prefetch(0, 0, 3, 0, 0); // expected-error {{argument should be a value from 0 to 2}}
+  __builtin_arm_prefetch(0, 0, 0, 2, 0); // expected-error {{argument should be a value from 0 to 1}}
+  __builtin_arm_prefetch(0, 0, 0, 0, 2); // expected-error {{argument should be a value from 0 to 1}}
+}
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index 7647100..0e2925e 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wno-string-plus-int -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wstrlcpy-strlcat-size -Wno-string-plus-int -triple=i686-apple-darwin9
 // This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
 
 int test1(float a, int b) {
@@ -66,6 +66,11 @@
   __sync_fetch_and_add_4(ptr, val);
 }
 
+void test9_4(volatile int* ptr, int val) {
+  // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}}
+  __sync_fetch_and_nand(ptr, val);
+}
+
 // rdar://7236819
 void test10(void) __attribute__((noreturn));
 
@@ -184,12 +189,12 @@
   void *ptr;
 
   ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src), sizeof(dst));
-  result = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst));
-  result = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst));
+  result = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst));
+  result = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst));
 
   ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src));      // expected-error {{too few arguments to function call}}
-  ptr = __builtin___strlcpy_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
-  ptr = __builtin___strlcat_chk(dst, src, sizeof(src), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
+  ptr = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
+  ptr = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
 }
 
 void no_ms_builtins() {
@@ -202,3 +207,44 @@
   __builtin_operator_new(0); // expected-error {{'__builtin_operator_new' is only available in C++}}
   __builtin_operator_delete(0); // expected-error {{'__builtin_operator_delete' is only available in C++}}
 }
+
+// rdar://18259539
+size_t strlcpy(char * restrict dst, const char * restrict src, size_t size);
+size_t strlcat(char * restrict dst, const char * restrict src, size_t size);
+
+void Test19(void)
+{
+        static char b[40];
+        static char buf[20];
+
+        strlcpy(buf, b, sizeof(b)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} \\
+                                    // expected-note {{change size argument to be the size of the destination}}
+        __builtin___strlcpy_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcpy_chk' call appears to be size of the source; expected the size of the destination}} \
+                                    // expected-note {{change size argument to be the size of the destination}} \
+				    // expected-warning {{'__builtin___strlcpy_chk' will always overflow destination buffer}}
+
+        strlcat(buf, b, sizeof(b)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} \
+                                    // expected-note {{change size argument to be the size of the destination}}
+				    
+        __builtin___strlcat_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcat_chk' call appears to be size of the source; expected the size of the destination}} \
+                                                                                   // expected-note {{change size argument to be the size of the destination}} \
+				                                                   // expected-warning {{'__builtin___strlcat_chk' will always overflow destination buffer}}
+}
+
+// rdar://11076881
+char * Test20(char *p, const char *in, unsigned n)
+{
+    static char buf[10];
+
+    __builtin___memcpy_chk (&buf[6], in, 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'__builtin___memcpy_chk' will always overflow destination buffer}}
+
+    __builtin___memcpy_chk (p, "abcde", n, __builtin_object_size (p, 0));
+
+    __builtin___memcpy_chk (&buf[5], "abcde", 5, __builtin_object_size (&buf[5], 0));
+
+    __builtin___memcpy_chk (&buf[5], "abcde", n, __builtin_object_size (&buf[5], 0));
+
+    __builtin___memcpy_chk (&buf[6], "abcde", 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'__builtin___memcpy_chk' will always overflow destination buffer}}
+
+    return buf;
+}
diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c
index f9fa9fe..6a8be5a 100644
--- a/test/Sema/callingconv.c
+++ b/test/Sema/callingconv.c
@@ -10,7 +10,7 @@
 void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
 }
 
-void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}}
+void __attribute__((fastcall)) test0() {
 }
 
 void __attribute__((fastcall)) test1(void) {
diff --git a/test/Sema/constructor-attribute.c b/test/Sema/constructor-attribute.c
index 1bb69fc..3a537d4 100644
--- a/test/Sema/constructor-attribute.c
+++ b/test/Sema/constructor-attribute.c
@@ -5,6 +5,7 @@
 int f() __attribute__((constructor(1)));
 int f() __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}}
 int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}}
+int f() __attribute__((constructor(0x100000000))); // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
 
 int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}}
 int f() __attribute__((destructor));
diff --git a/test/Sema/decl-microsoft-call-conv.c b/test/Sema/decl-microsoft-call-conv.c
new file mode 100644
index 0000000..5a83b38
--- /dev/null
+++ b/test/Sema/decl-microsoft-call-conv.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple i686-pc-win32 -verify %s
+
+// It's important that this is a .c file.
+
+// This is fine, as CrcGenerateTable*() has a prototype.
+void __fastcall CrcGenerateTableFastcall(void);
+void __fastcall CrcGenerateTableFastcall();
+void __fastcall CrcGenerateTableFastcall() {}
+void __stdcall CrcGenerateTableStdcall(void);
+void __stdcall CrcGenerateTableStdcall();
+void __stdcall CrcGenerateTableStdcall() {}
+void __thiscall CrcGenerateTableThiscall(void);
+void __thiscall CrcGenerateTableThiscall();
+void __thiscall CrcGenerateTableThiscall() {}
+void __pascal CrcGenerateTablePascal(void);
+void __pascal CrcGenerateTablePascal();
+void __pascal CrcGenerateTablePascal() {}
+void __vectorcall CrcGenerateTableVectorcall(void);
+void __vectorcall CrcGenerateTableVectorcall();
+void __vectorcall CrcGenerateTableVectorcall() {}
+
+void __fastcall CrcGenerateTableNoProtoFastcall(); // expected-error{{function with no prototype cannot use the fastcall calling convention}}
+void __stdcall CrcGenerateTableNoProtoStdcall(); // expected-warning{{function with no prototype cannot use the stdcall calling convention}}
+void __thiscall CrcGenerateTableNoProtoThiscall(); // expected-error{{function with no prototype cannot use the thiscall calling convention}}
+void __pascal CrcGenerateTableNoProtoPascal(); // expected-error{{function with no prototype cannot use the pascal calling convention}}
+void __vectorcall CrcGenerateTableNoProtoVectorcall(); // expected-error{{function with no prototype cannot use the vectorcall calling convention}}
+
+void __fastcall CrcGenerateTableNoProtoDefFastcall() {}
+void __stdcall CrcGenerateTableNoProtoDefStdcall() {}
+void __thiscall CrcGenerateTableNoProtoDefThiscall() {}
+void __pascal CrcGenerateTableNoProtoDefPascal() {}
+void __vectorcall CrcGenerateTableNoProtoDefVectorcall() {}
+
+// Regular calling convention is fine.
+void CrcGenerateTableNoProto() {}
diff --git a/test/Sema/dllexport.c b/test/Sema/dllexport.c
index c6d04dc..76b6f6d 100644
--- a/test/Sema/dllexport.c
+++ b/test/Sema/dllexport.c
@@ -39,11 +39,19 @@
                              int GlobalRedecl2;
 
                       extern int GlobalRedecl3; // expected-note{{previous declaration is here}}
+int useGlobalRedecl3() { return GlobalRedecl3; }
 __declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}
 
+                      extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
+__declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}}
+
+
 // External linkage is required.
 __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}
 
+// Thread local variables are invalid.
+__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
+
 // Export in local scope.
 void functionScope() {
   __declspec(dllexport)        int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}}
@@ -86,11 +94,18 @@
                       void redecl3() {}
 
                       void redecl4(); // expected-note{{previous declaration is here}}
+void useRedecl4() { redecl4(); }
 __declspec(dllexport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
 
                       void redecl5(); // expected-note{{previous declaration is here}}
+void useRedecl5() { redecl5(); }
 __declspec(dllexport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllexport' attribute}}
 
+// Allow with a warning if the decl hasn't been used yet.
+                      void redecl6(); // expected-note{{previous declaration is here}}
+__declspec(dllexport) void redecl6(); // expected-warning{{redeclaration of 'redecl6' should not add 'dllexport' attribute}}
+
+
 // External linkage is required.
 __declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
 
diff --git a/test/Sema/dllimport.c b/test/Sema/dllimport.c
index 2702453..ac88382 100644
--- a/test/Sema/dllimport.c
+++ b/test/Sema/dllimport.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -verify -std=c99 %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -verify -std=c11 %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -verify -std=c11 %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c99 %s
+// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -verify -std=c99 -DMS %s
+// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -verify -std=c11 -DMS %s
+// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -verify -std=c11 -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c99 -DGNU %s
 
 // Invalid usage.
 __declspec(dllimport) typedef int typedef1; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
@@ -64,16 +64,27 @@
 __declspec(dllimport) extern int GlobalRedecl3; // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
                       extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
 
+// Adding an attribute on redeclaration.
                       extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
+int useGlobalRedecl4() { return GlobalRedecl4; }
 __declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}}
 
+// Allow with a warning if the decl hasn't been used yet.
+                      extern int GlobalRedecl5; // expected-note{{previous declaration is here}}
+__declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclaration of 'GlobalRedecl5' should not add 'dllimport' attribute}}
+
+
 // External linkage is required.
 __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}}
 
+// Thread local variables are invalid.
+__declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
+
 // Import in local scope.
 __declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}}
 __declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}}
 __declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}}
+__declspec(dllimport) float LocalRedecl4;
 void functionScope() {
   __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
   int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
@@ -84,6 +95,9 @@
   __declspec(dllimport) extern int ExternLocalVarDecl;
   __declspec(dllimport) extern int ExternLocalVarDef = 1; // expected-error{{definition of dllimport data}}
   __declspec(dllimport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllimport'}}
+
+  // Local extern redeclaration does not drop the attribute.
+  extern float LocalRedecl4;
 }
 
 
@@ -108,6 +122,10 @@
 __declspec(dllimport) void def() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
 
 // Import inline function.
+#ifdef GNU
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+#endif
 __declspec(dllimport) inline void inlineFunc1() {}
 inline void __attribute__((dllimport)) inlineFunc2() {}
 
@@ -124,14 +142,29 @@
                       void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
 
                       void redecl4(); // expected-note{{previous declaration is here}}
+void useRedecl4() { redecl4(); }
 __declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}}
 
-// Inline redeclarations are fine.
-__declspec(dllimport) void redecl5();
-                      inline void redecl5() {}
+// Allow with a warning if the decl hasn't been used yet.
+                      void redecl5(); // expected-note{{previous declaration is here}}
+__declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}}
 
-                      void redecl6(); // expected-note{{previous declaration is here}}
-__declspec(dllimport) inline void redecl6() {} // expected-error{{redeclaration of 'redecl6' cannot add 'dllimport' attribute}}
+
+// Inline redeclarations.
+#ifdef GNU
+// expected-warning@+3{{'redecl6' redeclared inline; 'dllimport' attribute ignored}}
+#endif
+__declspec(dllimport) void redecl6();
+                      inline void redecl6() {}
+
+#ifdef MS
+// expected-note@+5{{previous declaration is here}}
+// expected-warning@+5{{redeclaration of 'redecl7' should not add 'dllimport' attribute}}
+#else
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+#endif
+                      void redecl7();
+__declspec(dllimport) inline void redecl7() {}
 
 // External linkage is required.
 __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}}
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index 2fb17e4..17b1aa2 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -244,6 +244,10 @@
   if ("help")
     (void) 0;
 
-  if (test22)
+  if (test22) // expected-warning {{address of function 'test22' will always evaluate to 'true'}} \
+	      // expected-note {{prefix with the address-of operator to silence this warning}}
+    (void) 0;
+
+  if (&test22)
     (void) 0;
 }
diff --git a/test/Sema/format-strings-c90.c b/test/Sema/format-strings-c90.c
index 66ca507..874d33e 100644
--- a/test/Sema/format-strings-c90.c
+++ b/test/Sema/format-strings-c90.c
@@ -1,4 +1,4 @@
-/* RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -pedantic -std=c89 %s
+/* RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-non-iso -std=c89 %s
  */
 
 int scanf(const char * restrict, ...);
diff --git a/test/Sema/format-strings-darwin.c b/test/Sema/format-strings-darwin.c
index 5daf3e5..46e717e 100644
--- a/test/Sema/format-strings-darwin.c
+++ b/test/Sema/format-strings-darwin.c
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -pedantic -DALLOWED %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 -pedantic -DALLOWED %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-non-iso -DALLOWED %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 -Wformat-non-iso -DALLOWED %s
 
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -pedantic %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -Wformat-non-iso %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -Wformat-non-iso %s
 
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -pedantic %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -Wformat-non-iso %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -Wformat-non-iso %s
 
 int printf(const char *restrict, ...);
 int scanf(const char * restrict, ...) ;
diff --git a/test/Sema/format-strings-gnu.c b/test/Sema/format-strings-gnu.c
index f491085..fc524e9 100644
--- a/test/Sema/format-strings-gnu.c
+++ b/test/Sema/format-strings-gnu.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -DMS %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -DMS %s
 
 // RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -DALLOWED %s
 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -DALLOWED %s
@@ -23,6 +23,10 @@
   // expected-warning@-6 {{length modifier 'L' results in undefined behavior or no effect with 'd' conversion specifier}}
   // expected-note@-7 {{did you mean to use 'll'?}}
 #endif
+
+#ifndef MS
+  printf("%Z\n", quiteLong); // expected-warning{{invalid conversion specifier 'Z'}}
+#endif
 }
 
 void testAlwaysInvalid() {
diff --git a/test/Sema/format-strings-ms.c b/test/Sema/format-strings-ms.c
index b89ee42..42676e7 100644
--- a/test/Sema/format-strings-ms.c
+++ b/test/Sema/format-strings-ms.c
@@ -1,25 +1,88 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
 
 int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
+int scanf(const char * restrict, ...) ;
+typedef unsigned short wchar_t;
+
+#ifdef NON_ISO_WARNING
+
+// Split off this test to reduce the warning noise in the rest of the file.
+void non_iso_warning_test(__int32 i32, __int64 i64, wchar_t c, void *p) {
+  printf("%Id", i32); // expected-warning{{'I' length modifier is not supported by ISO C}}
+  printf("%I32d", i32); // expected-warning{{'I32' length modifier is not supported by ISO C}}
+  printf("%I64d", i64); // expected-warning{{'I64' length modifier is not supported by ISO C}}
+  printf("%wc", c); // expected-warning{{'w' length modifier is not supported by ISO C}}
+  printf("%Z", p); // expected-warning{{'Z' conversion specifier is not supported by ISO C}}
+}
+
+#else
 
 void signed_test() {
   short val = 30;
-  printf("val = %I64d\n", val); // expected-warning{{'I64' length modifier is not supported by ISO C}} \
-                                // expected-warning{{format specifies type '__int64' (aka 'long long') but the argument has type 'short'}}
+  printf("val = %I64d\n", val); // expected-warning{{format specifies type '__int64' (aka 'long long') but the argument has type 'short'}}
   long long bigval = 30;
-  printf("val = %I32d\n", bigval); // expected-warning{{'I32' length modifier is not supported by ISO C}} \
-                                   // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
-  printf("val = %Id\n", bigval); // expected-warning{{'I' length modifier is not supported by ISO C}} \
-                                 // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
+  printf("val = %I32d\n", bigval); // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
+  printf("val = %Id\n", bigval); // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
 }
 
 void unsigned_test() {
   unsigned short val = 30;
-  printf("val = %I64u\n", val); // expected-warning{{'I64' length modifier is not supported by ISO C}} \
-                                // expected-warning{{format specifies type 'unsigned __int64' (aka 'unsigned long long') but the argument has type 'unsigned short'}}
+  printf("val = %I64u\n", val); // expected-warning{{format specifies type 'unsigned __int64' (aka 'unsigned long long') but the argument has type 'unsigned short'}}
   unsigned long long bigval = 30;
-  printf("val = %I32u\n", bigval); // expected-warning{{'I32' length modifier is not supported by ISO C}} \
-                                   // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
-  printf("val = %Iu\n", bigval); // expected-warning{{'I' length modifier is not supported by ISO C}} \
-                                 // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
+  printf("val = %I32u\n", bigval); // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
+  printf("val = %Iu\n", bigval); // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
 }
+
+void w_test(wchar_t c, wchar_t *s) {
+  printf("%wc", c);
+  printf("%wC", c);
+  printf("%C", c);
+  printf("%ws", s);
+  printf("%wS", s);
+  printf("%S", s);
+  scanf("%wc", &c);
+  scanf("%wC", &c);
+  scanf("%C", &c);
+  scanf("%ws", s);
+  scanf("%wS", s);
+  scanf("%S", s);
+
+  double bad;
+  printf("%wc", bad); // expected-warning{{format specifies type 'wint_t' (aka 'int') but the argument has type 'double'}}
+  printf("%wC", bad); // expected-warning{{format specifies type 'wchar_t' (aka 'unsigned short') but the argument has type 'double'}}
+  printf("%C", bad); // expected-warning{{format specifies type 'wchar_t' (aka 'unsigned short') but the argument has type 'double'}}
+  printf("%ws", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}}
+  printf("%wS", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}}
+  printf("%S", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}}
+  scanf("%wc", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
+  scanf("%wC", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
+  scanf("%C", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
+  scanf("%ws", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
+  scanf("%wS", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
+  scanf("%S", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
+
+}
+
+void h_test(char c, char* s) {
+  double bad;
+  printf("%hc", bad); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
+  printf("%hC", bad); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
+  printf("%hs", bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double'}}
+  printf("%hS", bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double'}}
+  scanf("%hc", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
+  scanf("%hC", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
+  scanf("%hs", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
+  scanf("%hS", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
+}
+
+void z_test(void *p) {
+  printf("%Z", p);
+  printf("%hZ", p);
+  printf("%lZ", p);
+  printf("%wZ", p);
+  printf("%hhZ", p); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 'Z' conversion specifier}}
+  scanf("%Z", p); // expected-warning{{invalid conversion specifier 'Z'}}
+}
+
+#endif
diff --git a/test/Sema/format-strings-non-iso.c b/test/Sema/format-strings-non-iso.c
index ee45946..429658c 100644
--- a/test/Sema/format-strings-non-iso.c
+++ b/test/Sema/format-strings-non-iso.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i686-linux-gnu -fsyntax-only -verify -std=c99 -pedantic %s
+// RUN: %clang_cc1 -triple i686-linux-gnu -fsyntax-only -verify -std=c99 -Wformat-non-iso %s
 
 int printf(const char *restrict, ...);
 int scanf(const char * restrict, ...);
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index e31644a..0d827e4 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -217,7 +217,7 @@
   printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
   printf("%d%d\n", x); // expected-warning{{more '%' conversions than data arguments}}
   printf("%d\n", x, x); // expected-warning{{data argument not used by format string}}
-  printf("%W%d%Z\n", x, x, x); // expected-warning{{invalid conversion specifier 'W'}} expected-warning{{invalid conversion specifier 'Z'}}
+  printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 'W'}}
   printf("%"); // expected-warning{{incomplete format specifier}}
   printf("%.d", x); // no-warning
   printf("%.", x);  // expected-warning{{incomplete format specifier}}
diff --git a/test/Sema/gnu-attributes.c b/test/Sema/gnu-attributes.c
new file mode 100644
index 0000000..653fae8
--- /dev/null
+++ b/test/Sema/gnu-attributes.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct s {};
+
+// FIXME: should warn that declaration attribute in type position is
+// being applied to the declaration instead?
+struct s __attribute__((used)) foo;
+
+// FIXME: Should warn that type attribute in declaration position is
+// being applied to the type instead?
+struct s  *bar __attribute__((address_space(1)));
+
+// Should not warn because type attribute is in type position.
+struct s *__attribute__((address_space(1))) baz;
+
+// Should not warn because declaration attribute is in declaration position.
+struct s *quux __attribute__((used));
diff --git a/test/Sema/implicit-builtin-decl.c b/test/Sema/implicit-builtin-decl.c
index bfc1907..3c2ff94 100644
--- a/test/Sema/implicit-builtin-decl.c
+++ b/test/Sema/implicit-builtin-decl.c
@@ -3,7 +3,7 @@
 
 void f() {
   int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
-  // expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
+  // expected-note{{include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
   // expected-note{{'malloc' is a builtin with type 'void *}}
 }
 
diff --git a/test/Sema/inline-asm-validate-aarch64.c b/test/Sema/inline-asm-validate-aarch64.c
new file mode 100644
index 0000000..1364b64
--- /dev/null
+++ b/test/Sema/inline-asm-validate-aarch64.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+typedef unsigned char uint8_t;
+
+uint8_t constraint_r(uint8_t *addr) {
+  uint8_t byte;
+
+  __asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory");
+// CHECK: warning: value size does not match register size specified by the constraint and modifier
+// CHECK: note: use constraint modifier "w"
+// CHECK: fix-it:{{.*}}:{8:26-8:28}:"%w0"
+
+  return byte;
+}
+
+uint8_t constraint_r_symbolic(uint8_t *addr) {
+  uint8_t byte;
+
+  __asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
+// CHECK: warning: value size does not match register size specified by the constraint and modifier
+// CHECK: note: use constraint modifier "w"
+// CHECK: fix-it:{{.*}}:{19:26-19:31}:"%w[s0]"
+
+  return byte;
+}
+
+#define PERCENT "%"
+
+uint8_t constraint_r_symbolic_macro(uint8_t *addr) {
+  uint8_t byte;
+
+  __asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
+// CHECK: warning: value size does not match register size specified by the constraint and modifier
+// CHECK: note: use constraint modifier "w"
+// CHECK-NOT: fix-it
+
+  return byte;
+}
diff --git a/test/Sema/inline-asm-validate.c b/test/Sema/inline-asm-validate.c
index c32dedb..73335e7 100644
--- a/test/Sema/inline-asm-validate.c
+++ b/test/Sema/inline-asm-validate.c
@@ -1,9 +1,8 @@
 // RUN: %clang_cc1 -triple arm64-apple-macosx10.8.0 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 unsigned t, r, *p;
 
 int foo (void) {
-  __asm__ __volatile__( "stxr   %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory");
+  __asm__ __volatile__( "stxr   %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning{{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
   return 1;
 }
diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c
index 66504aa..4c6948f 100644
--- a/test/Sema/ms-inline-asm.c
+++ b/test/Sema/ms-inline-asm.c
@@ -1,5 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only
 
 void t1(void) { 
  __asm __asm // expected-error {{__asm used with no assembly instructions}}
@@ -29,7 +29,7 @@
   }
   f();
   __asm {
-    mov eax, TYPE bar // expected-error {{unable to lookup expression}}
+    mov eax, TYPE bar // expected-error {{unable to lookup expression}} expected-error {{use of undeclared label 'bar'}}
   }
 }
 
@@ -60,13 +60,13 @@
   }
 
   // expected-error@+1 {{cannot use base register with variable reference}}
-  __asm mov eax, arr[ebp + 1 + (2 * 5) - 3 + 1<<1]
+  __asm { mov eax, arr[ebp + 1 + (2 * 5) - 3 + 1<<1] }
   // expected-error@+1 {{cannot use index register with variable reference}}
-  __asm mov eax, arr[esi * 4]
+  __asm { mov eax, arr[esi * 4] }
   // expected-error@+1 {{cannot use more than one symbol in memory operand}}
-  __asm mov eax, arr[i]
+  __asm { mov eax, arr[i] }
   // expected-error@+1 {{cannot use more than one symbol in memory operand}}
-  __asm mov eax, global[i]
+  __asm { mov eax, global[i] }
 
   // FIXME: Why don't we diagnose this?
   // expected-Xerror@+1 {{cannot reference multiple local variables in assembly operand}}
@@ -80,22 +80,77 @@
 } A;
 
 void t3() {
-  __asm mov eax, [eax] UndeclaredId // expected-error {{unknown token in expression}}
+  __asm { mov eax, [eax] UndeclaredId } // expected-error {{unknown token in expression}} expected-error {{use of undeclared label 'UndeclaredId'}}
 
   // FIXME: Only emit one diagnostic here.
+  // expected-error@+3 {{use of undeclared label 'A'}}
   // expected-error@+2 {{unexpected type name 'A': expected expression}}
   // expected-error@+1 {{unknown token in expression}}
-  __asm mov eax, [eax] A
+  __asm { mov eax, [eax] A }
 }
 
 void t4() {
   // The dot in the "intel dot operator" is optional in MSVC.  MSVC also does
   // global field lookup, but we don't.
-  __asm mov eax, [0] A.a
-  __asm mov eax, [0].A.a
-  __asm mov eax, [0].a    // expected-error {{Unable to lookup field reference!}}
-  __asm mov eax, fs:[0] A.a
-  __asm mov eax, fs:[0].A.a
-  __asm mov eax, fs:[0].a // expected-error {{Unable to lookup field reference!}}
-  __asm mov eax, fs:[0]. A.a  // expected-error {{Unexpected token type!}}
+  __asm { mov eax, [0] A.a }
+  __asm { mov eax, [0].A.a }
+  __asm { mov eax, [0].a } // expected-error {{Unable to lookup field reference!}}
+  __asm { mov eax, fs:[0] A.a }
+  __asm { mov eax, fs:[0].A.a }
+  __asm { mov eax, fs:[0].a } // expected-error {{Unable to lookup field reference!}}
+  __asm { mov eax, fs:[0]. A.a } // expected-error {{Unexpected token type!}}
+}
+
+void test_operand_size() {
+  __asm { call word t4 } // expected-error {{Expected 'PTR' or 'ptr' token!}}
+}
+
+__declspec(naked) int t5(int x) { // expected-note {{attribute is here}}
+  asm { movl eax, x } // expected-error {{parameter references not allowed in naked functions}} expected-error {{use of undeclared label 'x'}}
+  asm { retl }
+}
+
+int y;
+__declspec(naked) int t6(int x) {
+  asm { mov eax, y } // No error.
+  asm { ret }
+}
+
+void t7() {
+  __asm {
+    foo: // expected-note {{inline assembly label 'foo' declared here}}
+    mov eax, 0
+  }
+  goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+}
+
+void t8() {
+  __asm foo: // expected-note {{inline assembly label 'foo' declared here}}
+  __asm mov eax, 0
+  goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+}
+
+void t9() {
+  goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+  __asm {
+    foo: // expected-note {{inline assembly label 'foo' declared here}}
+    mov eax, 0
+  }
+}
+
+void t10() {
+  goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
+  __asm foo: // expected-note {{inline assembly label 'foo' declared here}}
+  __asm mov eax, 0
+}
+
+void t11() {
+foo:
+  __asm mov eax, foo // expected-error {{use of undeclared label 'foo'}} expected-warning {{unused label 'foo'}}
+}
+
+void t12() {
+  __asm foo:
+  __asm bar: // expected-warning {{unused label 'bar'}}
+  __asm jmp foo
 }
diff --git a/test/Sema/ms_bitfield_layout.c b/test/Sema/ms_bitfield_layout.c
index 8444f46..293df77 100644
--- a/test/Sema/ms_bitfield_layout.c
+++ b/test/Sema/ms_bitfield_layout.c
@@ -1,265 +1,265 @@
-// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \

-// RUN:            | FileCheck %s

-// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \

-// RUN:            | FileCheck %s

-

-typedef struct A {

-	char x;

-	int a : 22;

-	int : 0;

-	int c : 10;

-	char b : 3;

-	char d: 4;

-	short y;

-} A;

-

-// CHECK: Type: struct A

-// CHECK:   Size:128

-// CHECK:   Alignment:32

-// CHECK:   FieldOffsets: [0, 32, 64, 64, 96, 99, 112]>

-

-typedef struct B {

-	char x;

-	int : 0;

-	short a : 4;

-	char y;

-} B;

-

-// CHECK: Type: struct B

-// CHECK:   Size:48

-// CHECK:   Alignment:16

-// CHECK:   FieldOffsets: [0, 8, 16, 32]>

-

-typedef struct C {

-	char x;

-	short a : 4;

-	int : 0;

-	char y;

-} C;

-

-// CHECK: Type: struct C

-// CHECK:   Size:64

-// CHECK:   Alignment:32

-// CHECK:   FieldOffsets: [0, 16, 32, 32]>

-

-typedef struct D {

-	char x;

-	short : 0;

-	int : 0;

-	char y;

-} D;

-

-// CHECK: Type: struct D

-// CHECK:   Size:16

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8, 8, 8]>

-

-typedef union E {

-	char x;

-	long long a : 3;

-	int b : 3;

-	long long : 0;

-	short y;

-} E;

-

-// CHECK: Type: union E

-// CHECK:   Size:64

-// CHECK:   Alignment:16

-// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>

-

-typedef struct F {

-	char x;

-	char a : 3;

-	char b : 3;

-	char c : 3;

-	short d : 6;

-	short e : 6;

-	short f : 6;

-	short g : 11;

-	short h : 11;

-	short i : 11;

-	short y;

-} F;

-

-// CHECK: Type: struct F

-// CHECK:   Size:128

-// CHECK:   Alignment:16

-// CHECK:   FieldOffsets: [0, 8, 11, 16, 32, 38, 48, 64, 80, 96, 112]>

-

-typedef union G {

-	char x;

-	int a : 3;

-	int : 0;

-	long long : 0;

-	short y;

-} G;

-

-// CHECK: Type: union G

-// CHECK:   Size:32

-// CHECK:   Alignment:16

-// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>

-

-typedef struct H {

-	unsigned short a : 1;

-	unsigned char : 0;

-	unsigned long : 0;

-	unsigned short c : 1;

-} H;

-

-// CHECK: Type: struct H

-// CHECK:   Size:32

-// CHECK:   Alignment:16

-// CHECK:   FieldOffsets: [0, 16, 16, 16]>

-

-typedef struct I {

-	short : 8;

-	__declspec(align(16)) short : 8;

-} I;

-

-// CHECK: Type: struct I

-// CHECK:   Size:16

-// CHECK:   Alignment:16

-// CHECK:   FieldOffsets: [0, 8]

-

-#pragma pack(push, 1)

-

-typedef struct A1 {

-	char x;

-	int a : 22;

-	int : 0;

-	int c : 10;

-	char b : 3;

-	char d: 4;

-	short y;

-} A1;

-

-// CHECK: Type: struct A1

-// CHECK:   Size:96

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8, 40, 40, 72, 75, 80]>

-

-typedef struct B1 {

-	char x;

-	int : 0;

-	short a : 4;

-	char y;

-} B1;

-

-// CHECK: Type: struct B1

-// CHECK:   Size:32

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8, 8, 24]>

-

-typedef struct C1 {

-	char x;

-	short a : 4;

-	int : 0;

-	char y;

-} C1;

-

-// CHECK: Type: struct C1

-// CHECK:   Size:32

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8, 24, 24]>

-

-typedef struct D1 {

-	char x;

-	short : 0;

-	int : 0;

-	char y;

-} D1;

-

-// CHECK: Type: struct D1

-// CHECK:   Size:16

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8, 8, 8]>

-

-typedef union E1 {

-	char x;

-	long long a : 3;

-	int b : 3;

-	long long : 0;

-	short y;

-} E1;

-

-// CHECK: Type: union E1

-// CHECK:   Size:64

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>

-

-typedef struct F1 {

-	char x;

-	char a : 3;

-	char b : 3;

-	char c : 3;

-	short d : 6;

-	short e : 6;

-	short f : 6;

-	short g : 11;

-	short h : 11;

-	short i : 11;

-	short y;

-} F1;

-

-// CHECK: Type: struct F1

-// CHECK:   Size:120

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8, 11, 16, 24, 30, 40, 56, 72, 88, 104]>

-

-typedef union G1 {

-	char x;

-	int a : 3;

-	int : 0;

-	long long : 0;

-	short y;

-} G1;

-

-// CHECK: Type: union G1

-// CHECK:   Size:32

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>

-

-typedef struct H1 {

-	unsigned long a : 1;

-	unsigned char : 0;

-	unsigned long : 0;

-	unsigned long c : 1;

-} H1;

-

-// CHECK: Type: struct H1

-// CHECK:   Size:64

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 32, 32, 32]>

-

-typedef struct I1 {

-	short : 8;

-	__declspec(align(16)) short : 8;

-} I1;

-

-// CHECK: Type: struct I1

-// CHECK:   Size:16

-// CHECK:   Alignment:8

-// CHECK:   FieldOffsets: [0, 8]

-

-#pragma pack(pop)

-

-int x[

-sizeof(A ) +

-sizeof(B ) +

-sizeof(C ) +

-sizeof(D ) +

-sizeof(E ) +

-sizeof(F ) +

-sizeof(G ) +

-sizeof(H ) +

-sizeof(I ) +

-sizeof(A1) +

-sizeof(B1) +

-sizeof(C1) +

-sizeof(D1) +

-sizeof(E1) +

-sizeof(F1) +

-sizeof(G1) +

-sizeof(H1) +

-sizeof(I1) +

-0];

+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \
+// RUN:            | FileCheck %s
+// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \
+// RUN:            | FileCheck %s
+
+typedef struct A {
+	char x;
+	int a : 22;
+	int : 0;
+	int c : 10;
+	char b : 3;
+	char d: 4;
+	short y;
+} A;
+
+// CHECK: Type: struct A
+// CHECK:   Size:128
+// CHECK:   Alignment:32
+// CHECK:   FieldOffsets: [0, 32, 64, 64, 96, 99, 112]>
+
+typedef struct B {
+	char x;
+	int : 0;
+	short a : 4;
+	char y;
+} B;
+
+// CHECK: Type: struct B
+// CHECK:   Size:48
+// CHECK:   Alignment:16
+// CHECK:   FieldOffsets: [0, 8, 16, 32]>
+
+typedef struct C {
+	char x;
+	short a : 4;
+	int : 0;
+	char y;
+} C;
+
+// CHECK: Type: struct C
+// CHECK:   Size:64
+// CHECK:   Alignment:32
+// CHECK:   FieldOffsets: [0, 16, 32, 32]>
+
+typedef struct D {
+	char x;
+	short : 0;
+	int : 0;
+	char y;
+} D;
+
+// CHECK: Type: struct D
+// CHECK:   Size:16
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8, 8, 8]>
+
+typedef union E {
+	char x;
+	long long a : 3;
+	int b : 3;
+	long long : 0;
+	short y;
+} E;
+
+// CHECK: Type: union E
+// CHECK:   Size:64
+// CHECK:   Alignment:16
+// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct F {
+	char x;
+	char a : 3;
+	char b : 3;
+	char c : 3;
+	short d : 6;
+	short e : 6;
+	short f : 6;
+	short g : 11;
+	short h : 11;
+	short i : 11;
+	short y;
+} F;
+
+// CHECK: Type: struct F
+// CHECK:   Size:128
+// CHECK:   Alignment:16
+// CHECK:   FieldOffsets: [0, 8, 11, 16, 32, 38, 48, 64, 80, 96, 112]>
+
+typedef union G {
+	char x;
+	int a : 3;
+	int : 0;
+	long long : 0;
+	short y;
+} G;
+
+// CHECK: Type: union G
+// CHECK:   Size:32
+// CHECK:   Alignment:16
+// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct H {
+	unsigned short a : 1;
+	unsigned char : 0;
+	unsigned long : 0;
+	unsigned short c : 1;
+} H;
+
+// CHECK: Type: struct H
+// CHECK:   Size:32
+// CHECK:   Alignment:16
+// CHECK:   FieldOffsets: [0, 16, 16, 16]>
+
+typedef struct I {
+	short : 8;
+	__declspec(align(16)) short : 8;
+} I;
+
+// CHECK: Type: struct I
+// CHECK:   Size:16
+// CHECK:   Alignment:16
+// CHECK:   FieldOffsets: [0, 8]
+
+#pragma pack(push, 1)
+
+typedef struct A1 {
+	char x;
+	int a : 22;
+	int : 0;
+	int c : 10;
+	char b : 3;
+	char d: 4;
+	short y;
+} A1;
+
+// CHECK: Type: struct A1
+// CHECK:   Size:96
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8, 40, 40, 72, 75, 80]>
+
+typedef struct B1 {
+	char x;
+	int : 0;
+	short a : 4;
+	char y;
+} B1;
+
+// CHECK: Type: struct B1
+// CHECK:   Size:32
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8, 8, 24]>
+
+typedef struct C1 {
+	char x;
+	short a : 4;
+	int : 0;
+	char y;
+} C1;
+
+// CHECK: Type: struct C1
+// CHECK:   Size:32
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8, 24, 24]>
+
+typedef struct D1 {
+	char x;
+	short : 0;
+	int : 0;
+	char y;
+} D1;
+
+// CHECK: Type: struct D1
+// CHECK:   Size:16
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8, 8, 8]>
+
+typedef union E1 {
+	char x;
+	long long a : 3;
+	int b : 3;
+	long long : 0;
+	short y;
+} E1;
+
+// CHECK: Type: union E1
+// CHECK:   Size:64
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct F1 {
+	char x;
+	char a : 3;
+	char b : 3;
+	char c : 3;
+	short d : 6;
+	short e : 6;
+	short f : 6;
+	short g : 11;
+	short h : 11;
+	short i : 11;
+	short y;
+} F1;
+
+// CHECK: Type: struct F1
+// CHECK:   Size:120
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8, 11, 16, 24, 30, 40, 56, 72, 88, 104]>
+
+typedef union G1 {
+	char x;
+	int a : 3;
+	int : 0;
+	long long : 0;
+	short y;
+} G1;
+
+// CHECK: Type: union G1
+// CHECK:   Size:32
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 0, 0, 0, 0]>
+
+typedef struct H1 {
+	unsigned long a : 1;
+	unsigned char : 0;
+	unsigned long : 0;
+	unsigned long c : 1;
+} H1;
+
+// CHECK: Type: struct H1
+// CHECK:   Size:64
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 32, 32, 32]>
+
+typedef struct I1 {
+	short : 8;
+	__declspec(align(16)) short : 8;
+} I1;
+
+// CHECK: Type: struct I1
+// CHECK:   Size:16
+// CHECK:   Alignment:8
+// CHECK:   FieldOffsets: [0, 8]
+
+#pragma pack(pop)
+
+int x[
+sizeof(A ) +
+sizeof(B ) +
+sizeof(C ) +
+sizeof(D ) +
+sizeof(E ) +
+sizeof(F ) +
+sizeof(G ) +
+sizeof(H ) +
+sizeof(I ) +
+sizeof(A1) +
+sizeof(B1) +
+sizeof(C1) +
+sizeof(D1) +
+sizeof(E1) +
+sizeof(F1) +
+sizeof(G1) +
+sizeof(H1) +
+sizeof(I1) +
+0];
diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c
index 0e92654..de47e96 100644
--- a/test/Sema/nonnull.c
+++ b/test/Sema/nonnull.c
@@ -15,7 +15,7 @@
 
 int main(void) {
 	Class *obj;
-	Class_init(0, "Hello World"); // expected-warning {{null passed to a callee which requires a non-null argument}}
+	Class_init(0, "Hello World"); // expected-warning {{null passed to a callee that requires a non-null argument}}
 	Class_init(obj, "Hello World");
 }
 
@@ -27,7 +27,7 @@
 void baz3(__attribute__((nonnull)) int x); // expected-warning {{'nonnull' attribute only applies to pointer arguments}}
 
 void test_baz() {
-  baz(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+  baz(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   baz2(0); // no-warning
   baz3(0); // no-warning
 }
@@ -38,7 +38,8 @@
 
 int i __attribute__((nonnull)); // expected-warning {{'nonnull' attribute only applies to functions, methods, and parameters}}
 int j __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
-void *test_no_fn_proto() __attribute__((returns_nonnull));  // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
+void *test_no_fn_proto() __attribute__((returns_nonnull)); // no-warning
+void *test_with_fn_proto(void) __attribute__((returns_nonnull)); // no-warning
 
 __attribute__((returns_nonnull))
 void *test_bad_returns_null(void) {
@@ -46,10 +47,97 @@
 }
 
 void PR18795(int (*g)(const char *h, ...) __attribute__((nonnull(1))) __attribute__((nonnull))) {
-  g(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+  g(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
 }
 void PR18795_helper() {
-  PR18795(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+  PR18795(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
 }
 
+void vararg1(int n, ...) __attribute__((nonnull(2)));
+void vararg1_test() {
+  vararg1(0);
+  vararg1(1, (void*)0); // expected-warning{{null passed}}
+  vararg1(2, (void*)0, (void*)0); // expected-warning{{null passed}}
+  vararg1(2, (void*)&vararg1, (void*)0);
+}
+
+void vararg2(int n, ...) __attribute__((nonnull, nonnull, nonnull));
+void vararg2_test() {
+  vararg2(0);
+  vararg2(1, (void*)0); // expected-warning{{null passed}}
+  vararg2(2, (void*)0, (void*)0); // expected-warning 2{{null passed}}
+}
+
+void vararg3(int n, ...) __attribute__((nonnull, nonnull(2), nonnull(3)));
+void vararg3_test() {
+  vararg3(0);
+  vararg3(1, (void*)0); // expected-warning{{null passed}}
+  vararg3(2, (void*)0, (void*)0); // expected-warning 2{{null passed}}
+}
+
+void redecl(void *, void *);
+void redecl(void *, void *) __attribute__((nonnull(1)));
+void redecl(void *, void *) __attribute__((nonnull(2)));
+void redecl(void *, void *);
+void redecl_test(void *p) {
+  redecl(p, 0); // expected-warning{{null passed}}
+  redecl(0, p); // expected-warning{{null passed}}
+}
+
+// rdar://18712242
+#define NULL (void*)0
+__attribute__((__nonnull__))
+int evil_nonnull_func(int* pointer, void * pv)
+{
+   if (pointer == NULL) {  // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+     return 0;
+   } else {
+     return *pointer;
+   } 
+
+   pointer = pv;
+   if (!pointer)
+     return 0;
+   else
+     return *pointer;
+
+   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+}
+
+void set_param_to_null(int**);
+int another_evil_nonnull_func(int* pointer, char ch, void * pv) __attribute__((nonnull(1, 3)));
+int another_evil_nonnull_func(int* pointer, char ch, void * pv) {
+   if (pointer == NULL) { // expected-warning {{comparison of nonnull parameter 'pointer' equal to a null pointer is false on first encounter}}
+     return 0;
+   } else {
+     return *pointer;
+   } 
+
+   set_param_to_null(&pointer);
+   if (!pointer)
+     return 0;
+   else
+     return *pointer;
+
+   if (pv == NULL) {} // expected-warning {{comparison of nonnull parameter 'pv' equal to a null pointer is false on first encounter}}
+}
+
+extern void *returns_null(void**);
+extern void FOO();
+extern void FEE();
+
+extern void *pv;
+__attribute__((__nonnull__))
+void yet_another_evil_nonnull_func(int* pointer)
+{
+ while (pv) {
+   // This comparison will not be optimized away.
+   if (pointer) {  // expected-warning {{nonnull parameter 'pointer' will evaluate to 'true' on first encounter}}
+     FOO();
+   } else {
+     FEE();
+   } 
+   pointer = returns_null(&pv);
+ }
+}
 
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp
index ac2694f..324d9b5 100644
--- a/test/Sema/parentheses.cpp
+++ b/test/Sema/parentheses.cpp
@@ -47,7 +47,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:32-[[@LINE-6]]:32}:")"
 
-  (void)(s << 5 == 1); // expected-warning {{overloaded operator << has lower precedence than comparison operator}} \
+  (void)(s << 5 == 1); // expected-warning {{overloaded operator << has higher precedence than comparison operator}} \
                        // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
                        // expected-note {{place parentheses around comparison expression to evaluate it first}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
@@ -55,7 +55,7 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
 
-  (void)(s >> 5 == 1); // expected-warning {{overloaded operator >> has lower precedence than comparison operator}} \
+  (void)(s >> 5 == 1); // expected-warning {{overloaded operator >> has higher precedence than comparison operator}} \
                        // expected-note {{place parentheses around the '>>' expression to silence this warning}} \
                        // expected-note {{place parentheses around comparison expression to evaluate it first}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
@@ -113,3 +113,105 @@
     (void)(i-- ? true : false); // no-warning
   }
 }
+
+namespace PR20735 {
+  struct X {
+    static int state;
+    static int get();
+    int get_num();
+    int num;
+  };
+  namespace ns {
+    int num = 0;
+    int get();
+  }
+  void test(X x) {
+    if (5 & x.get_num() != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:29-[[@LINE-6]]:29}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:24-[[@LINE-9]]:24}:")"
+
+    if (5 & x.num != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:18-[[@LINE-9]]:18}:")"
+
+    if (5 & x.state != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:25-[[@LINE-6]]:25}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
+
+    if (5 & x.get() != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:25-[[@LINE-6]]:25}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
+
+    if (5 & X::state != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:26-[[@LINE-6]]:26}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:21-[[@LINE-9]]:21}:")"
+
+    if (5 & X::get() != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:26-[[@LINE-6]]:26}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:21-[[@LINE-9]]:21}:")"
+
+    if (5 & ns::get() != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:27-[[@LINE-6]]:27}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:22-[[@LINE-9]]:22}:")"
+
+    if (5 & ns::num != 0) {}
+    // expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
+    // expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
+    // expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
+    // CHECK: place parentheses around the '!=' expression to silence this warning
+    // fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+    // fix-it:"{{.*}}":{[[@LINE-6]]:25-[[@LINE-6]]:25}:")"
+    // CHECK: place parentheses around the & expression to evaluate it first
+    // fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
+    // fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
+  }
+}
diff --git a/test/Sema/pragma-section.c b/test/Sema/pragma-section.c
index 02f3e77..2906fab 100644
--- a/test/Sema/pragma-section.c
+++ b/test/Sema/pragma-section.c
@@ -8,6 +8,8 @@
 #pragma data_seg()
 int c = 1;
 __declspec(allocate(".my_const")) int d = 1; // expected-error {{'d' causes a section type conflict with 'a'}}
+#pragma data_seg("\u") // expected-error {{\u used with no following hex digits}}
+#pragma data_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma data_seg'}}
 
 #pragma section(".my_seg", execute) // expected-note 2 {{#pragma entered her}}
 __declspec(allocate(".my_seg")) int int_my_seg;
diff --git a/test/Sema/scope-check.c b/test/Sema/scope-check.c
index a9494d3..fa37d10 100644
--- a/test/Sema/scope-check.c
+++ b/test/Sema/scope-check.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu99 %s -Wno-unreachable-code
 
 int test1(int x) {
-  goto L;    // expected-error{{goto into protected scope}}
+  goto L;    // expected-error{{cannot jump from this goto statement to its label}}
   int a[x];  // expected-note {{jump bypasses initialization of variable length array}}
   int b[x];  // expected-note {{jump bypasses initialization of variable length array}}
   L:
@@ -9,7 +9,7 @@
 }
 
 int test2(int x) {
-  goto L;            // expected-error{{goto into protected scope}}
+  goto L;            // expected-error{{cannot jump from this goto statement to its label}}
   typedef int a[x];  // expected-note {{jump bypasses initialization of VLA typedef}}
   L:
   return sizeof(a);
@@ -18,14 +18,14 @@
 void test3clean(int*);
 
 int test3() {
-  goto L;            // expected-error{{goto into protected scope}}
+  goto L;            // expected-error{{cannot jump from this goto statement to its label}}
 int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of variable with __attribute__((cleanup))}}
 L:
   return a;
 }
 
 int test4(int x) {
-  goto L;       // expected-error{{goto into protected scope}}
+  goto L;       // expected-error{{cannot jump from this goto statement to its label}}
 int a[x];       // expected-note {{jump bypasses initialization of variable length array}}
   test4(x);
 L:
@@ -50,7 +50,7 @@
   switch (x) {
   case 1: ;
     int a[x];       // expected-note {{jump bypasses initialization of variable length array}}
-  case 2:           // expected-error {{switch case is in protected scope}}
+  case 2:           // expected-error {{cannot jump from switch statement to this case label}}
     a[1] = 2;
     break;
   }
@@ -58,17 +58,17 @@
 
 int test8(int x) {
   // For statement.
-  goto L2;     // expected-error {{goto into protected scope}}
+  goto L2;     // expected-error {{cannot jump from this goto statement to its label}}
   for (int arr[x];   // expected-note {{jump bypasses initialization of variable length array}}  
        ; ++x)
     L2:;
 
   // Statement expressions.
-  goto L3;   // expected-error {{goto into protected scope}}
+  goto L3;   // expected-error {{cannot jump from this goto statement to its label}}
   int Y = ({  int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
            L3: 4; });
   
-  goto L4; // expected-error {{goto into protected scope}}
+  goto L4; // expected-error {{cannot jump from this goto statement to its label}}
   {
     int A[x],  // expected-note {{jump bypasses initialization of variable length array}}
         B[x];  // expected-note {{jump bypasses initialization of variable length array}}
@@ -91,7 +91,7 @@
     int A[x], B = ({ if (x)
                        goto L7;
                      else 
-                       goto L8;  // expected-error {{goto into protected scope}}
+                       goto L8;  // expected-error {{cannot jump from this goto statement to its label}}
                      4; }),
         C[x];   // expected-note {{jump bypasses initialization of variable length array}}
   L8:; // bad
@@ -103,7 +103,7 @@
                goto L9;
              else
                // FIXME:
-               goto L10;  // fixme-error {{goto into protected scope}}
+               goto L10;  // fixme-error {{cannot jump from this goto statement to its label}}
            4; })];
   L10:; // bad
   }
@@ -123,7 +123,7 @@
   }
   
   // Statement expressions 2.
-  goto L1;     // expected-error {{goto into protected scope}}
+  goto L1;     // expected-error {{cannot jump from this goto statement to its label}}
   return x == ({
                  int a[x];   // expected-note {{jump bypasses initialization of variable length array}}  
                L1:
@@ -133,7 +133,7 @@
 void test9(int n, void *P) {
   int Y;
   int Z = 4;
-  goto *P;  // expected-error {{indirect goto might cross protected scopes}}
+  goto *P;  // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}}
 
 L2: ;
   int a[n]; // expected-note {{jump bypasses initialization of variable length array}}
@@ -151,14 +151,14 @@
 }
 
 void test10(int n, void *P) {
-  goto L0;     // expected-error {{goto into protected scope}}
+  goto L0;     // expected-error {{cannot jump from this goto statement to its label}}
   typedef int A[n];  // expected-note {{jump bypasses initialization of VLA typedef}}
 L0:
   
-  goto L1;      // expected-error {{goto into protected scope}}
+  goto L1;      // expected-error {{cannot jump from this goto statement to its label}}
   A b, c[10];        // expected-note 2 {{jump bypasses initialization of variable length array}}
 L1:
-  goto L2;     // expected-error {{goto into protected scope}}
+  goto L2;     // expected-error {{cannot jump from this goto statement to its label}}
   A d[n];      // expected-note {{jump bypasses initialization of variable length array}}
 L2:
   return;
@@ -171,7 +171,7 @@
     case 2: 
     case 3:;
       int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
-    case 4:       // expected-error {{switch case is in protected scope}}
+    case 4:       // expected-error {{cannot jump from switch statement to this case label}}
       return;
     }
   };
@@ -185,7 +185,7 @@
   L1:
     goto L2;
   L2:
-    goto L3;    // expected-error {{goto into protected scope}}
+    goto L3;    // expected-error {{cannot jump from this goto statement to its label}}
     int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
   L3:
     goto L4;
@@ -220,7 +220,7 @@
 void test15(int n, void *pc) {
   static const void *addrs[] = { &&L1, &&L2 };
 
-  goto *pc; // expected-error {{indirect goto might cross protected scope}}
+  goto *pc; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}}
 
  L1:
   {
diff --git a/test/Sema/sentinel-attribute.c b/test/Sema/sentinel-attribute.c
index 46f1350..1beae87 100644
--- a/test/Sema/sentinel-attribute.c
+++ b/test/Sema/sentinel-attribute.c
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -fsyntax-only %s -fdiagnostics-parseable-fixits 2>&1 | \
+// RUN:         FileCheck %s --check-prefix=C
+// RUN: not %clang_cc1 -fsyntax-only %s -fdiagnostics-parseable-fixits -x c++ -std=c++11 2>&1 | \
+// RUN:         FileCheck %s --check-prefix=CXX11
 int x __attribute__((sentinel)); //expected-warning{{'sentinel' attribute only applies to functions, methods and blocks}}
 
-void f1(int a, ...) __attribute__ ((sentinel));
+void f1(int a, ...) __attribute__ ((sentinel)); // expected-note {{function has been explicitly marked sentinel here}}
 void f2(int a, ...) __attribute__ ((sentinel(1)));
 
 void f3(int a, ...) __attribute__ ((sentinel("hello"))); //expected-error{{'sentinel' attribute requires parameter 1 to be an integer constant}}
@@ -13,3 +17,10 @@
 
 
 void f6() __attribute__((__sentinel__));  // expected-warning {{'sentinel' attribute requires named arguments}}
+
+void g() {
+  // The integer literal zero is not a sentinel.
+  f1(1, 0); // expected-warning {{missing sentinel in function call}}
+// C: fix-it:{{.*}}:{23:10-23:10}:", (void*) 0"
+// CXX11: fix-it:{{.*}}:{23:10-23:10}:", nullptr"
+}
diff --git a/test/Sema/sizeof-struct-non-zero-as-member.cl b/test/Sema/sizeof-struct-non-zero-as-member.cl
new file mode 100644
index 0000000..b64c036
--- /dev/null
+++ b/test/Sema/sizeof-struct-non-zero-as-member.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -triple r600 -target-cpu verde -S -emit-llvm -o - %s
+// expected-no-diagnostics
+
+// Record lowering was crashing on SI and newer targets, because it
+// was using the wrong size for test::ptr.  Since global memory
+// has 64-bit pointers, sizeof(test::ptr) should be 8.
+
+struct test_as0 {int *ptr;};
+constant int as0[sizeof(struct test_as0) == 4 ? 1 : -1] = { 0 };
+
+struct test_as1 {global int *ptr;};
+constant int as1[sizeof(struct test_as1) == 8 ? 1 : -1] = { 0 };
+
+struct test_as2 {constant int *ptr;};
+constant int as2[sizeof(struct test_as2) == 8 ? 1 : -1] = { 0 };
+
+struct test_as3 {local int *ptr;};
+constant int as3[sizeof(struct test_as3) == 4 ? 1 : -1] = { 0 };
diff --git a/test/Sema/statements.c b/test/Sema/statements.c
index 8cd30b0..9ab5715 100644
--- a/test/Sema/statements.c
+++ b/test/Sema/statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify  -triple x86_64-pc-linux-gnu
 
 typedef unsigned __uint32_t;
 
diff --git a/test/Sema/static-array.c b/test/Sema/static-array.c
index 5ca693b..304485d 100644
--- a/test/Sema/static-array.c
+++ b/test/Sema/static-array.c
@@ -11,13 +11,13 @@
 
   cat0(0);
 
-  cat(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+  cat(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}}
   cat(b);
   cat(c);
   cat(p);
 
-  vat(1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+  vat(1, 0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   vat(3, b);
 }
 
diff --git a/test/Sema/stdcall-fastcall.c b/test/Sema/stdcall-fastcall.c
index dea1fc5..256f558 100644
--- a/test/Sema/stdcall-fastcall.c
+++ b/test/Sema/stdcall-fastcall.c
@@ -6,7 +6,7 @@
 
 // Different CC qualifiers are not compatible
 void __attribute__((stdcall, fastcall)) foo3(void); // expected-error{{fastcall and stdcall attributes are not compatible}}
-void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}}
+void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}} expected-warning{{function with no prototype cannot use the stdcall calling convention}}
 void __attribute__((fastcall)) foo4(void); // expected-error{{function declared 'fastcall' here was previously declared 'stdcall'}}
 
 // rdar://8876096
diff --git a/test/Sema/struct-packed-align.c b/test/Sema/struct-packed-align.c
index 166d5eb..291de67 100644
--- a/test/Sema/struct-packed-align.c
+++ b/test/Sema/struct-packed-align.c
@@ -127,9 +127,11 @@
   nt start_lba;
 };
 
+#if defined(_WIN32) && !defined(__declspec) // _MSC_VER is unavailable in cc1.
+// Alignment doesn't affect packing in MS mode.
+extern int n1[sizeof(struct nS) == 16 ? 1 : -1];
+extern int n2[__alignof(struct nS) == 8 ? 1 : -1];
+#else
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
-
-
-
-
+#endif
diff --git a/test/Sema/switch-1.c b/test/Sema/switch-1.c
index ce1e7dc..5191c92 100644
--- a/test/Sema/switch-1.c
+++ b/test/Sema/switch-1.c
@@ -20,3 +20,8 @@
   return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
 			     // expected-warning {{expression result unused}}
 }
+
+// rdar://18405357
+unsigned long long l = 65536 * 65536; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
+unsigned long long l2 = 65536 * (unsigned)65536;
+unsigned long long l3 = 65536 * 65536ULL;
diff --git a/test/Sema/switch.c b/test/Sema/switch.c
index 092378d..7aa695d 100644
--- a/test/Sema/switch.c
+++ b/test/Sema/switch.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default -triple x86_64-linux-gnu %s
 void f (int z) { 
   while (z) { 
     default: z--;            // expected-error {{statement not in switch}}
@@ -375,3 +375,13 @@
   }
 }
 
+void PR11778(char c, int n, long long ll) {
+  // Do not reject this; we don't have duplicate case values because we
+  // check for duplicates in the promoted type.
+  switch (c) case 1: case 257: ; // expected-warning {{overflow}}
+
+  switch (n) case 0x100000001LL: case 1: ; // expected-warning {{overflow}} expected-error {{duplicate}} expected-note {{previous}}
+  switch ((int)ll) case 0x100000001LL: case 1: ; // expected-warning {{overflow}} expected-error {{duplicate}} expected-note {{previous}}
+  switch ((long long)n) case 0x100000001LL: case 1: ;
+  switch (ll) case 0x100000001LL: case 1: ;
+}
diff --git a/test/Sema/types.c b/test/Sema/types.c
index 778a5fe..1ed8dae 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 %s -pedantic -verify -triple=x86_64-apple-darwin9
+// RUN: %clang_cc1 %s -pedantic -verify -triple=mips64-linux-gnu
+// RUN: %clang_cc1 %s -pedantic -verify -triple=x86_64-unknown-linux
+// RUN: %clang_cc1 %s -pedantic -verify -triple=x86_64-unknown-linux-gnux32
 
 // rdar://6097662
 typedef int (*T)[2];
@@ -27,12 +30,12 @@
   int __int128; // expected-error {{cannot combine with previous}} expected-warning {{does not declare anything}}
 }
 // __int128_t is __int128; __uint128_t is unsigned __int128.
-typedef __int128 check_int_128; // expected-note {{here}}
-typedef __int128_t check_int_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef __int128 check_int_128;
+typedef __int128_t check_int_128; // expected-note {{here}}
 typedef int check_int_128; // expected-error {{different types ('int' vs '__int128_t' (aka '__int128'))}}
 
-typedef unsigned __int128 check_uint_128; // expected-note {{here}}
-typedef __uint128_t check_uint_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef unsigned __int128 check_uint_128;
+typedef __uint128_t check_uint_128; // expected-note {{here}}
 typedef int check_uint_128; // expected-error {{different types ('int' vs '__uint128_t' (aka 'unsigned __int128'))}}
 
 // Array type merging should convert array size to whatever matches the target
diff --git a/test/Sema/warn-absolute-value-header.c b/test/Sema/warn-absolute-value-header.c
index e3bf9ee..0c7c3a8 100644
--- a/test/Sema/warn-absolute-value-header.c
+++ b/test/Sema/warn-absolute-value-header.c
@@ -31,6 +31,6 @@
   (void)abs(d);
   // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
   // expected-note@-2{{use function 'fabs' instead}}
-  // expected-note@-3{{please include the header <math.h> or explicitly provide a declaration for 'fabs'}}
+  // expected-note@-3{{include the header <math.h> or explicitly provide a declaration for 'fabs'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"fabs"
 }
diff --git a/test/Sema/warn-documentation-almost-trailing.c b/test/Sema/warn-documentation-almost-trailing.c
index fa17cac..9ff71a3 100644
--- a/test/Sema/warn-documentation-almost-trailing.c
+++ b/test/Sema/warn-documentation-almost-trailing.c
@@ -9,6 +9,5 @@
   int y; /*< comment */ // expected-warning {{not a Doxygen trailing comment}}
 };
 
-// CHECK: fix-it:"{{.*}}":{8:10-8:13}:"///<"
-// CHECK: fix-it:"{{.*}}":{9:10-9:13}:"/**<"
-
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:10-[[@LINE-4]]:13}:"///<"
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:10-[[@LINE-4]]:13}:"/**<"
diff --git a/test/Sema/warn-string-conversion.c b/test/Sema/warn-string-conversion.c
new file mode 100644
index 0000000..708dd54
--- /dev/null
+++ b/test/Sema/warn-string-conversion.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s
+
+#define assert(EXPR) (void)(EXPR);
+
+// Expection for common assert form.
+void test1() {
+  assert(0 && "foo");
+  assert("foo" && 0);
+  assert(0 || "foo"); // expected-warning {{string literal}}
+}
+
+void test2() {
+  if ("hi") {}           // expected-warning {{string literal}}
+  while ("hello") {}     // expected-warning {{string literal}}
+  for (;"howdy";) {}     // expected-warning {{string literal}}
+  do { } while ("hey");  // expected-warning {{string literal}}
+}
diff --git a/test/Sema/warn-tautological-compare.c b/test/Sema/warn-tautological-compare.c
new file mode 100644
index 0000000..2856edd
--- /dev/null
+++ b/test/Sema/warn-tautological-compare.c
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify  %s
+// rdar://18716393
+
+extern int a[] __attribute__((weak));
+int b[] = {8,13,21};
+struct {
+  int x[10];
+} c;
+const char str[] = "text";
+
+void ignore() {
+  if (!a) {}
+}
+void test() {
+  if (!b) {} // expected-warning {{address of array 'b' will always evaluate to 'true'}}
+  if (b == 0) {} // expected-warning {{comparison of array 'b' equal to a null pointer is always false}}
+  if (!c.x) {} // expected-warning {{address of array 'c.x' will always evaluate to 'true'}}
+  if (c.x == 0) {} // expected-warning {{comparison of array 'c.x' equal to a null pointer is always false}}
+  if (!str) {} // expected-warning {{address of array 'str' will always evaluate to 'true'}}
+  if (0 == str) {} // expected-warning {{comparison of array 'str' equal to a null pointer is always false}}
+}
+
+int array[2];
+int test1()
+{
+  if (!array) { // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+    return array[0];
+  } else if (array != 0) { // expected-warning {{comparison of array 'array' not equal to a null pointer is always true}}
+    return array[1];
+  }
+  if (array == 0) // expected-warning {{comparison of array 'array' equal to a null pointer is always false}}
+    return 1;
+  return 0;
+}
+
+#define NULL (void*)0
+
+int test2(int* pointer, char ch, void * pv) {
+   if (!&pointer) {  // expected-warning {{address of 'pointer' will always evaluate to 'true'}}
+     return 0;
+   }
+
+   if (&pointer) {  // expected-warning {{address of 'pointer' will always evaluate to 'true'}}
+     return 0;
+   }
+
+   if (&pointer == NULL) {} // expected-warning {{comparison of address of 'pointer' equal to a null pointer is always false}}
+
+   if (&pointer != NULL) {} // expected-warning {{comparison of address of 'pointer' not equal to a null pointer is always true}}
+
+   return 1;
+}
+
+void test3() {
+   if (array) { } // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+   if (array != 0) {} // expected-warning {{comparison of array 'array' not equal to a null pointer is always true}}
+   if (!array) { } // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+   if (array == 0) {} // expected-warning {{comparison of array 'array' equal to a null pointer is always false}}
+
+   if (array[0] &&
+       array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+
+   if (array[0] ||
+       array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+
+   if (array[0] &&
+       !array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+   if (array[0] ||
+       !array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+
+   if (array && // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+       array[0]) {}
+   if (!array || // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+       array[0]) {}
+
+   if (array ||  // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+       (!array && array[0])) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
+ }
+
+
diff --git a/test/Sema/warn-thread-safety-analysis.c b/test/Sema/warn-thread-safety-analysis.c
index 6d41e40..55e6e70 100644
--- a/test/Sema/warn-thread-safety-analysis.c
+++ b/test/Sema/warn-thread-safety-analysis.c
@@ -117,12 +117,12 @@
   mutex_unlock(foo_.mu_);
 
   mutex_exclusive_lock(&mu1);
-  mutex_shared_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using shared access, expected exclusive access}}
-  mutex_exclusive_unlock(&mu1);
+  mutex_shared_unlock(&mu1);     // expected-warning {{releasing mutex 'mu1' using shared access, expected exclusive access}}
+  mutex_exclusive_unlock(&mu1);  // expected-warning {{releasing mutex 'mu1' that was not held}}
 
   mutex_shared_lock(&mu1);
   mutex_exclusive_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using exclusive access, expected shared access}}
-  mutex_shared_unlock(&mu1);
+  mutex_shared_unlock(&mu1);    // expected-warning {{releasing mutex 'mu1' that was not held}}
 
   return 0;
 }
diff --git a/test/Sema/wchar.c b/test/Sema/wchar.c
index 74e482a..a45a14d 100644
--- a/test/Sema/wchar.c
+++ b/test/Sema/wchar.c
@@ -8,9 +8,9 @@
   #define WCHAR_T_TYPE unsigned short
 #elif defined(__arm) || defined(__aarch64__)
   #define WCHAR_T_TYPE unsigned int
-#elif defined(__sun) || defined(__AuroraUX__)
+#elif defined(__sun)
   #define WCHAR_T_TYPE long
-#else /* Solaris or AuroraUX. */
+#else /* Solaris. */
   #define WCHAR_T_TYPE int
 #endif
  
diff --git a/test/SemaCUDA/implicit-intrinsic.cu b/test/SemaCUDA/implicit-intrinsic.cu
new file mode 100644
index 0000000..3d24aa7
--- /dev/null
+++ b/test/SemaCUDA/implicit-intrinsic.cu
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+// expected-no-diagnostics
+__device__ void __threadfence_system() {
+  // This shouldn't produce an error, since __nvvm_membar_sys is inferred to
+  // be __host__ __device__ and thus callable from device code.
+  __nvvm_membar_sys();
+}
diff --git a/test/SemaCUDA/implicit-member-target-collision-cxx11.cu b/test/SemaCUDA/implicit-member-target-collision-cxx11.cu
new file mode 100644
index 0000000..f038c37
--- /dev/null
+++ b/test/SemaCUDA/implicit-member-target-collision-cxx11.cu
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+//------------------------------------------------------------------------------
+// Test 1: collision between two bases
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+
+struct B1_with_device_ctor {
+  __device__ B1_with_device_ctor() {}
+};
+
+struct C1_with_collision : A1_with_host_ctor, B1_with_device_ctor {
+};
+
+// expected-note@-3 {{candidate constructor (the implicit default constructor) not viable}}
+// expected-note@-4 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+
+void hostfoo1() {
+  C1_with_collision c; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 2: collision between two fields
+
+struct C2_with_collision {
+  A1_with_host_ctor aa;
+  B1_with_device_ctor bb;
+};
+
+// expected-note@-5 {{candidate constructor (the implicit default constructor}} not viable
+// expected-note@-6 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
+// expected-note@-7 {{candidate constructor (the implicit copy constructor}} not viable
+// expected-note@-8 {{candidate constructor (the implicit move constructor}} not viable
+
+void hostfoo2() {
+  C2_with_collision c; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 3: collision between a field and a base
+
+struct C3_with_collision : A1_with_host_ctor {
+  B1_with_device_ctor bb;
+};
+
+// expected-note@-4 {{candidate constructor (the implicit default constructor}} not viable
+// expected-note@-5 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
+// expected-note@-6 {{candidate constructor (the implicit copy constructor}} not viable
+// expected-note@-7 {{candidate constructor (the implicit move constructor}} not viable
+
+void hostfoo3() {
+  C3_with_collision c; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 4: collision on resolving a copy ctor
+
+struct A4_with_host_copy_ctor {
+  A4_with_host_copy_ctor() {}
+  A4_with_host_copy_ctor(const A4_with_host_copy_ctor&) {}
+};
+
+struct B4_with_device_copy_ctor {
+  B4_with_device_copy_ctor() {}
+  __device__ B4_with_device_copy_ctor(const B4_with_device_copy_ctor&) {}
+};
+
+struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor {
+};
+
+// expected-note@-3 {{candidate constructor (the implicit default constructor}} not viable
+// expected-note@-4 {{implicit copy constructor inferred target collision}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor}} not viable
+
+void hostfoo4() {
+  C4_with_collision c;
+  C4_with_collision c2 = c; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 5: collision on resolving a move ctor
+
+struct A5_with_host_move_ctor {
+  A5_with_host_move_ctor() {}
+  A5_with_host_move_ctor(A5_with_host_move_ctor&&) {}
+// expected-note@-1 {{copy constructor is implicitly deleted because 'A5_with_host_move_ctor' has a user-declared move constructor}}
+};
+
+struct B5_with_device_move_ctor {
+  B5_with_device_move_ctor() {}
+  __device__ B5_with_device_move_ctor(B5_with_device_move_ctor&&) {}
+};
+
+struct C5_with_collision : A5_with_host_move_ctor, B5_with_device_move_ctor {
+};
+// expected-note@-2 {{deleted}}
+
+void hostfoo5() {
+  C5_with_collision c;
+  // What happens here:
+  // This tries to find the move ctor. Since the move ctor is deleted due to
+  // collision, it then looks for a copy ctor. But copy ctors are implicitly
+  // deleted when move ctors are declared explicitly.
+  C5_with_collision c2(static_cast<C5_with_collision&&>(c)); // expected-error {{call to implicitly-deleted}}
+}
diff --git a/test/SemaCUDA/implicit-member-target-collision.cu b/test/SemaCUDA/implicit-member-target-collision.cu
new file mode 100644
index 0000000..25cdccb
--- /dev/null
+++ b/test/SemaCUDA/implicit-member-target-collision.cu
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+//------------------------------------------------------------------------------
+// Test 1: collision between two bases
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+
+struct B1_with_device_ctor {
+  __device__ B1_with_device_ctor() {}
+};
+
+struct C1_with_collision : A1_with_host_ctor, B1_with_device_ctor {
+};
+
+// expected-note@-3 {{candidate constructor (the implicit default constructor}} not viable
+// expected-note@-4 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor}} not viable
+
+void hostfoo1() {
+  C1_with_collision c; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 2: collision between two fields
+
+struct C2_with_collision {
+  A1_with_host_ctor aa;
+  B1_with_device_ctor bb;
+};
+
+// expected-note@-5 {{candidate constructor (the implicit default constructor}} not viable
+// expected-note@-6 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
+// expected-note@-7 {{candidate constructor (the implicit copy constructor}} not viable
+
+void hostfoo2() {
+  C2_with_collision c; // expected-error {{no matching constructor}}
+
+}
+
+//------------------------------------------------------------------------------
+// Test 3: collision between a field and a base
+
+struct C3_with_collision : A1_with_host_ctor {
+  B1_with_device_ctor bb;
+};
+
+// expected-note@-4 {{candidate constructor (the implicit default constructor}} not viable
+// expected-note@-5 {{implicit default constructor inferred target collision: call to both __host__ and __device__ members}}
+// expected-note@-6 {{candidate constructor (the implicit copy constructor}} not viable
+
+void hostfoo3() {
+  C3_with_collision c; // expected-error {{no matching constructor}}
+}
diff --git a/test/SemaCUDA/implicit-member-target.cu b/test/SemaCUDA/implicit-member-target.cu
new file mode 100644
index 0000000..87b05e6
--- /dev/null
+++ b/test/SemaCUDA/implicit-member-target.cu
@@ -0,0 +1,184 @@
+// RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+//------------------------------------------------------------------------------
+// Test 1: infer default ctor to be host.
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+
+// The implicit default constructor is inferred to be host because it only needs
+// to invoke a single host constructor (A1_with_host_ctor's). So we'll encounter
+// an error when calling it from a __device__ function, but not from a __host__
+// function.
+struct B1_with_implicit_default_ctor : A1_with_host_ctor {
+};
+
+// expected-note@-3 {{call to __host__ function from __device__}}
+// expected-note@-4 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-5 {{candidate constructor (the implicit move constructor) not viable}}
+
+void hostfoo() {
+  B1_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo() {
+  B1_with_implicit_default_ctor b; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 2: infer default ctor to be device.
+
+struct A2_with_device_ctor {
+  __device__ A2_with_device_ctor() {}
+};
+
+struct B2_with_implicit_default_ctor : A2_with_device_ctor {
+};
+
+// expected-note@-3 {{call to __device__ function from __host__}}
+// expected-note@-4 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-5 {{candidate constructor (the implicit move constructor) not viable}}
+
+void hostfoo2() {
+  B2_with_implicit_default_ctor b;  // expected-error {{no matching constructor}}
+}
+
+__device__ void devicefoo2() {
+  B2_with_implicit_default_ctor b;
+}
+
+//------------------------------------------------------------------------------
+// Test 3: infer copy ctor
+
+struct A3_with_device_ctors {
+  __host__ A3_with_device_ctors() {}
+  __device__ A3_with_device_ctors(const A3_with_device_ctors&) {}
+};
+
+struct B3_with_implicit_ctors : A3_with_device_ctors {
+};
+
+// expected-note@-3 {{copy constructor of 'B3_with_implicit_ctors' is implicitly deleted}}
+
+void hostfoo3() {
+  B3_with_implicit_ctors b;  // this is OK because the inferred default ctor
+                             // here is __host__
+  B3_with_implicit_ctors b2 = b; // expected-error {{call to implicitly-deleted copy constructor}}
+
+}
+
+//------------------------------------------------------------------------------
+// Test 4: infer default ctor from a field, not a base
+
+struct A4_with_host_ctor {
+  A4_with_host_ctor() {}
+};
+
+struct B4_with_implicit_default_ctor {
+  A4_with_host_ctor field;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+
+void hostfoo4() {
+  B4_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo4() {
+  B4_with_implicit_default_ctor b; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 5: copy ctor with non-const param
+
+struct A5_copy_ctor_constness {
+  __host__ A5_copy_ctor_constness() {}
+  __host__ A5_copy_ctor_constness(A5_copy_ctor_constness&) {}
+};
+
+struct B5_copy_ctor_constness : A5_copy_ctor_constness {
+};
+
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable: call to __host__ function from __device__ function}}
+// expected-note@-4 {{candidate constructor (the implicit default constructor) not viable}}
+
+void hostfoo5(B5_copy_ctor_constness& b_arg) {
+  B5_copy_ctor_constness b = b_arg;
+}
+
+__device__ void devicefoo5(B5_copy_ctor_constness& b_arg) {
+  B5_copy_ctor_constness b = b_arg; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 6: explicitly defaulted ctor: since they are spelled out, they have
+// a host/device designation explicitly so no inference needs to be done.
+
+struct A6_with_device_ctor {
+  __device__ A6_with_device_ctor() {}
+};
+
+struct B6_with_defaulted_ctor : A6_with_device_ctor {
+  __host__ B6_with_defaulted_ctor() = default;
+};
+
+// expected-note@-3 {{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+
+__device__ void devicefoo6() {
+  B6_with_defaulted_ctor b; // expected-error {{no matching constructor}}
+}
+
+//------------------------------------------------------------------------------
+// Test 7: copy assignment operator
+
+struct A7_with_copy_assign {
+  A7_with_copy_assign() {}
+  __device__ A7_with_copy_assign& operator=(const A7_with_copy_assign&) {}
+};
+
+struct B7_with_copy_assign : A7_with_copy_assign {
+};
+
+// expected-note@-3 {{copy assignment operator of 'B7_with_copy_assign' is implicitly deleted}}
+
+void hostfoo7() {
+  B7_with_copy_assign b1, b2;
+  b1 = b2; // expected-error {{object of type 'B7_with_copy_assign' cannot be assigned because its copy assignment operator is implicitly deleted}}
+}
+
+//------------------------------------------------------------------------------
+// Test 8: move assignment operator
+
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template <class T> struct remove_reference { typedef T type; };
+template <class T> struct remove_reference<T&> { typedef T type; };
+template <class T> struct remove_reference<T&&> { typedef T type; };
+
+template <class T> typename remove_reference<T>::type&& move(T&& t);
+}
+}
+
+struct A8_with_move_assign {
+  A8_with_move_assign() {}
+  __device__ A8_with_move_assign& operator=(A8_with_move_assign&&) {}
+  __device__ A8_with_move_assign& operator=(const A8_with_move_assign&) {}
+};
+
+struct B8_with_move_assign : A8_with_move_assign {
+};
+
+// expected-note@-3 {{copy assignment operator of 'B8_with_move_assign' is implicitly deleted because base class 'A8_with_move_assign' has no copy assignment operator}}
+
+void hostfoo8() {
+  B8_with_move_assign b1, b2;
+  b1 = std::move(b2); // expected-error {{object of type 'B8_with_move_assign' cannot be assigned because its copy assignment operator is implicitly deleted}}
+}
diff --git a/test/SemaCUDA/launch_bounds.cu b/test/SemaCUDA/launch_bounds.cu
index bed7658..8edc41b 100644
--- a/test/SemaCUDA/launch_bounds.cu
+++ b/test/SemaCUDA/launch_bounds.cu
@@ -6,9 +6,6 @@
 __launch_bounds__(128) void Test2(void);
 
 __launch_bounds__(1, 2, 3) void Test3(void); // expected-error {{'launch_bounds' attribute takes no more than 2 arguments}}
-
-// FIXME: the error should read that the attribute takes exactly one or two arguments, but there
-// is no support for such a diagnostic currently.
-__launch_bounds__() void Test4(void); // expected-error {{'launch_bounds' attribute takes no more than 2 arguments}}
+__launch_bounds__() void Test4(void); // expected-error {{'launch_bounds' attribute takes at least 1 argument}}
 
 int Test5 __launch_bounds__(128, 7); // expected-warning {{'launch_bounds' attribute only applies to functions and methods}}
diff --git a/test/SemaCUDA/method-target.cu b/test/SemaCUDA/method-target.cu
new file mode 100644
index 0000000..4fa2907
--- /dev/null
+++ b/test/SemaCUDA/method-target.cu
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+//------------------------------------------------------------------------------
+// Test 1: host method called from device function
+
+struct S1 {
+  void method() {}
+};
+
+__device__ void foo1(S1& s) {
+  s.method(); // expected-error {{reference to __host__ function 'method' in __device__ function}}
+}
+
+//------------------------------------------------------------------------------
+// Test 2: host method called from device function, for overloaded method
+
+struct S2 {
+  void method(int) {} // expected-note {{candidate function not viable: call to __host__ function from __device__ function}}
+  void method(float) {} // expected-note {{candidate function not viable: call to __host__ function from __device__ function}}
+};
+
+__device__ void foo2(S2& s, int i, float f) {
+  s.method(f); // expected-error {{no matching member function}}
+}
+
+//------------------------------------------------------------------------------
+// Test 3: device method called from host function
+
+struct S3 {
+  __device__ void method() {}
+};
+
+void foo3(S3& s) {
+  s.method(); // expected-error {{reference to __device__ function 'method' in __host__ function}}
+}
+
+//------------------------------------------------------------------------------
+// Test 4: device method called from host&device function
+
+struct S4 {
+  __device__ void method() {}
+};
+
+__host__ __device__ void foo4(S4& s) {
+  s.method(); // expected-error {{reference to __device__ function 'method' in __host__ __device__ function}}
+}
+
+//------------------------------------------------------------------------------
+// Test 5: overloaded operators
+
+struct S5 {
+  S5() {}
+  S5& operator=(const S5&) {return *this;} // expected-note {{candidate function not viable}}
+};
+
+__device__ void foo5(S5& s, S5& t) {
+  s = t; // expected-error {{no viable overloaded '='}}
+}
+
+//------------------------------------------------------------------------------
+// Test 6: call method through pointer
+
+struct S6 {
+  void method() {}
+};
+
+__device__ void foo6(S6* s) {
+  s->method(); // expected-error {{reference to __host__ function 'method' in __device__ function}}
+}
diff --git a/test/SemaCXX/Inputs/header-with-pragma-optimize-off.h b/test/SemaCXX/Inputs/header-with-pragma-optimize-off.h
new file mode 100644
index 0000000..ac50206
--- /dev/null
+++ b/test/SemaCXX/Inputs/header-with-pragma-optimize-off.h
@@ -0,0 +1,5 @@
+
+// Open an "off" region in this header.
+#pragma clang optimize off
+
+// Let the "off" region fall through to anything including this header.
diff --git a/test/SemaCXX/Inputs/override-system-header.h b/test/SemaCXX/Inputs/override-system-header.h
new file mode 100644
index 0000000..9831ab7
--- /dev/null
+++ b/test/SemaCXX/Inputs/override-system-header.h
@@ -0,0 +1,6 @@
+// override-system-header.h to test out 'override' warning.
+// rdar://18295240
+#define END_COM_MAP virtual unsigned AddRef(void) = 0;
+
+#define STDMETHOD(method)        virtual void method
+#define IFACEMETHOD(method)         STDMETHOD(method)
diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp
index fb7d975..56486b8 100644
--- a/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -34,7 +34,7 @@
 
   int jump_over_variable_init(bool b) {
     if (b)
-      goto foo; // expected-warning {{goto into protected scope}}
+      goto foo; // expected-warning {{jump from this goto statement to its label is a Microsoft extension}}
     C c; // expected-note {{jump bypasses variable initialization}}
   foo:
     return 1;
@@ -45,7 +45,7 @@
 };
 
 void jump_over_var_with_dtor() {
-  goto end; // expected-warning{{goto into protected scope}}
+  goto end; // expected-warning{{jump from this goto statement to its label is a Microsoft extension}}
   Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
  end:
     ;
@@ -55,14 +55,14 @@
     switch (c) {
     case 0:
       int x = 56; // expected-note {{jump bypasses variable initialization}}
-    case 1:       // expected-error {{switch case is in protected scope}}
+    case 1:       // expected-error {{cannot jump}}
       x = 10;
     }
   }
 
  
 void exception_jump() {
-  goto l2; // expected-error {{goto into protected scope}}
+  goto l2; // expected-error {{cannot jump}}
   try { // expected-note {{jump bypasses initialization of try block}}
      l2: ;
   } catch(int) {
@@ -71,7 +71,7 @@
 
 int jump_over_indirect_goto() {
   static void *ps[] = { &&a0 };
-  goto *&&a0; // expected-warning {{goto into protected scope}}
+  goto *&&a0; // expected-warning {{jump from this goto statement to its label is a Microsoft extension}}
   int a = 3; // expected-note {{jump bypasses variable initialization}}
  a0:
   return 0;
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp
index 3b54c28..ec3dfce 100644
--- a/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/test/SemaCXX/MicrosoftExtensions.cpp
@@ -176,29 +176,6 @@
    b = reinterpret_cast<bool>(ptr); // expected-error {{cast from pointer to smaller type 'bool' loses information}}
 }
 
-namespace friend_as_a_forward_decl {
-
-class A {
-  class Nested {
-    friend class B;
-    B* b;
-  };
-  B* b;
-};
-B* global_b;
-
-
-void f()
-{
-  class Local {
-    friend class Z;
-    Z* b;
-  };
-  Z* b;
-}
-
-}
-
 struct PR11150 {
   class X {
     virtual void f() = 0;
@@ -395,14 +372,15 @@
 
   // expected-note@+2 {{overridden virtual function is here}}
   // expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
-  virtual void SealedFunction() sealed;
+  virtual void SealedFunction() sealed; // expected-note {{overridden virtual function is here}}
 };
 
 // expected-note@+2 {{'SealedType' declared here}}
 // expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
 struct SealedType sealed : SomeBase {
-  // expected-error@+1 {{declaration of 'SealedFunction' overrides a 'sealed' function}}
-  virtual void SealedFunction();
+  // expected-error@+2 {{declaration of 'SealedFunction' overrides a 'sealed' function}}
+  // FIXME. warning can be suppressed if we're also issuing error for overriding a 'final' function.
+  virtual void SealedFunction(); // expected-warning {{'SealedFunction' overrides a member function but is not marked 'override'}}
 
   // expected-warning@+1 {{'override' keyword is a C++11 extension}}
   virtual void OverrideMe() override;
diff --git a/test/SemaCXX/MicrosoftSuper.cpp b/test/SemaCXX/MicrosoftSuper.cpp
new file mode 100644
index 0000000..13138ca
--- /dev/null
+++ b/test/SemaCXX/MicrosoftSuper.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 %s -fsyntax-only -fms-extensions -std=c++11 -verify
+
+struct Errors {
+  using __super::foo; // expected-error {{'__super' cannot be used with a using declaration}}
+  __super::XXX x; // expected-error {{invalid use of '__super', Errors has no base classes}} expected-error {{expected}}
+
+  void foo() {
+    // expected-note@+4 {{replace parentheses with an initializer to declare a variable}}
+    // expected-warning@+3 {{empty parentheses interpreted as a function declaration}}
+    // expected-error@+2 {{C++ requires a type specifier for all declarations}}
+    // expected-error@+1 {{use of '__super' inside a lambda is unsupported}}
+    auto lambda = []{ __super::foo(); };
+  }
+};
+
+struct Base1 {
+  void foo(int) {}
+
+  static void static_foo() {}
+
+  typedef int XXX;
+};
+
+struct Derived : Base1 {
+  __super::XXX x;
+  typedef __super::XXX Type;
+
+  enum E {
+    X = sizeof(__super::XXX)
+  };
+
+  void foo() {
+    __super::foo(1);
+
+    if (true) {
+      __super::foo(1);
+    }
+
+    return __super::foo(1);
+  }
+
+  static void bar() {
+    __super::static_foo();
+  }
+};
+
+struct Outer {
+  struct Inner : Base1 {
+    static const int x = sizeof(__super::XXX);
+  };
+};
+
+struct Base2 {
+  void foo(char) {}
+};
+
+struct MemberFunctionInMultipleBases : Base1, Base2 {
+  void foo() {
+    __super::foo('x');
+  }
+};
+
+struct Base3 {
+  void foo(int) {}
+  void foo(char) {}
+};
+
+struct OverloadedMemberFunction : Base3 {
+  void foo() {
+    __super::foo('x');
+  }
+};
+
+struct PointerToMember : Base1 {
+  template <void (Base1::*MP)(int)>
+  struct Wrapper {
+    static void bar() {}
+  };
+
+  void baz();
+};
+
+void PointerToMember::baz() {
+  Wrapper<&__super::foo>::bar();
+}
+
+template <typename T>
+struct BaseTemplate {
+  typedef int XXX;
+
+  void foo() {}
+};
+
+struct DerivedFromKnownSpecialization : BaseTemplate<int> {
+  __super::XXX a;
+  typedef __super::XXX b;
+
+  void test() {
+    __super::XXX c;
+    typedef __super::XXX d;
+
+    __super::foo();
+  }
+};
+
+template <typename T>
+struct DerivedFromDependentBase : BaseTemplate<T> {
+  typename __super::XXX a;
+  typedef typename __super::XXX b;
+
+  __super::XXX c;         // expected-error {{missing 'typename'}}
+  typedef __super::XXX d; // expected-error {{missing 'typename'}}
+
+  void test() {
+    typename __super::XXX e;
+    typedef typename __super::XXX f;
+
+    __super::XXX g;         // expected-error {{missing 'typename'}}
+    typedef __super::XXX h; // expected-error {{missing 'typename'}}
+
+    __super::foo();
+  }
+};
+
+template <typename T>
+struct DerivedFromTemplateParameter : T {
+  typename __super::XXX a;
+  typedef typename __super::XXX b;
+
+  __super::XXX c;         // expected-error {{missing 'typename'}}
+  typedef __super::XXX d; // expected-error {{missing 'typename'}}
+
+  void test() {
+    typename __super::XXX e;
+    typedef typename __super::XXX f;
+
+    __super::XXX g;         // expected-error {{missing 'typename'}}
+    typedef __super::XXX h; // expected-error {{missing 'typename'}}
+
+    __super::foo(1);
+  }
+};
+
+void instantiate() {
+  DerivedFromDependentBase<int> d;
+  d.test();
+  DerivedFromTemplateParameter<Base1> t;
+  t.test();
+}
diff --git a/test/SemaCXX/PR10177.cpp b/test/SemaCXX/PR10177.cpp
index 8d745de..e361ff3 100644
--- a/test/SemaCXX/PR10177.cpp
+++ b/test/SemaCXX/PR10177.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++1y -verify %s -DCXX1Y
+
+#ifndef CXX1Y
 
 template<typename T, typename U, U> using alias_ref = T;
 template<typename T, typename U, U> void func_ref() {}
@@ -9,22 +12,29 @@
   static int a;
 };
 
-template<int N> struct S; // expected-note 2{{here}}
+template<int N> struct S; // expected-note 6{{here}}
 
 template<int N>
-int U<N>::a = S<N>::kError; // expected-error 2{{undefined}}
+int U<N>::a = S<N>::kError; // expected-error 6{{undefined}}
 
 template<typename T>
 void f() {
-  // FIXME: The standard suggests that U<0>::a is odr-used by this expression,
-  // but it's not entirely clear that's the right behaviour.
-  (void)alias_ref<int, int&, U<0>::a>();
+  (void)alias_ref<int, int&, U<0>::a>(); // expected-note {{here}}
   (void)func_ref<int, int&, U<1>::a>(); // expected-note {{here}}
   (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}}
 };
 
+
+template<int N>
+void fi() {
+  (void)alias_ref<int, int&, U<N>::a>(); // expected-note {{here}}
+  (void)func_ref<int, int&, U<N+1>::a>(); // expected-note {{here}}
+  (void)class_ref<int, int&, U<N+2>::a>(); // expected-note {{here}}
+};
+
 int main() {
-  f<int>(); // expected-note 2{{here}}
+  f<int>();   // NOTE: Non-dependent name uses are type-checked at template definition time.
+  fi<10>();   // expected-note 3{{here}}
 }
 
 namespace N {
@@ -38,3 +48,12 @@
   }
   int j = f<int>();
 }
+
+#else
+// expected-no-diagnostics
+
+namespace { template<typename> extern int n; }
+template<typename T> int g() { return n<int>; }
+
+#endif
+
diff --git a/test/SemaCXX/PR20705.cpp b/test/SemaCXX/PR20705.cpp
new file mode 100644
index 0000000..be2676e
--- /dev/null
+++ b/test/SemaCXX/PR20705.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template <typename T>
+struct X {};
+auto b = []() {
+  struct S {
+    static typename X<decltype(int)>::type Run(){};
+    // expected-error@-1 4{{}}
+  };
+  return 5;
+}();
+
+template <typename T1, typename T2>
+class PC {
+};
+
+template <typename T>
+class P {
+  static typename PC<T, Invalid>::Type Foo();
+  // expected-error@-1 4{{}}
+};
diff --git a/test/SemaCXX/align_value.cpp b/test/SemaCXX/align_value.cpp
new file mode 100644
index 0000000..5198682
--- /dev/null
+++ b/test/SemaCXX/align_value.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef double * __attribute__((align_value(64))) aligned_double;
+
+void foo(aligned_double x, double * y __attribute__((align_value(32))),
+         double & z __attribute__((align_value(128)))) { };
+
+template <typename T, int Q>
+struct x {
+  typedef T* aligned_int __attribute__((align_value(32+8*Q)));
+  aligned_int V;
+
+  void foo(aligned_int a, T &b __attribute__((align_value(sizeof(T)*4))));
+};
+
+x<float, 4> y;
+
+template <typename T, int Q>
+struct nope {
+  // expected-error@+1 {{requested alignment is not a power of 2}}
+  void foo(T &b __attribute__((align_value(sizeof(T)+1))));
+};
+
+// expected-note@+1 {{in instantiation of template class 'nope<long double, 4>' requested here}}
+nope<long double, 4> y2;
+
diff --git a/test/SemaCXX/arrow-operator.cpp b/test/SemaCXX/arrow-operator.cpp
index 173ff72..3e32a6b 100644
--- a/test/SemaCXX/arrow-operator.cpp
+++ b/test/SemaCXX/arrow-operator.cpp
@@ -52,14 +52,15 @@
 
 class Worker {
  public:
-  void DoSomething();
+  void DoSomething(); // expected-note {{'DoSomething' declared here}}
   void Chuck();
 };
 
 void test() {
   wrapped_ptr<Worker> worker(new Worker);
   worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}}
-  worker.DoSamething(); // expected-error {{no member named 'DoSamething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'}}
+  worker.DoSamething(); // expected-error {{no member named 'DoSamething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} \
+                        // expected-error {{no member named 'DoSamething' in 'arrow_suggest::Worker'; did you mean 'DoSomething'?}}
   worker.Chuck(); // expected-error {{no member named 'Chuck' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean 'Check'?}}
 }
 
diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp
index 4851571..baece3c 100644
--- a/test/SemaCXX/ast-print.cpp
+++ b/test/SemaCXX/ast-print.cpp
@@ -208,3 +208,8 @@
   }
 }
 }
+
+namespace {
+// CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S;
+struct [[gnu::visibility("hidden")]] S;
+}
diff --git a/test/SemaCXX/atomic-type.cpp b/test/SemaCXX/atomic-type.cpp
new file mode 100644
index 0000000..ae18eab
--- /dev/null
+++ b/test/SemaCXX/atomic-type.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -verify -pedantic %s -std=c++98
+// RUN: %clang_cc1 -verify -pedantic %s -std=c++11
+
+template<typename T> struct atomic {
+  _Atomic(T) value;
+
+  void f() _Atomic; // expected-error {{expected ';' at end of declaration list}}
+};
+
+template<typename T> struct user {
+  struct inner { char n[sizeof(T)]; };
+  atomic<inner> i;
+};
+
+user<int> u;
+
+// Test overloading behavior of atomics.
+struct A { };
+
+int &ovl1(_Atomic(int));
+int &ovl1(_Atomic int); // ok, redeclaration
+long &ovl1(_Atomic(long));
+float &ovl1(_Atomic(float));
+double &ovl1(_Atomic(A const *const *));
+double &ovl1(A const *const *_Atomic);
+short &ovl1(_Atomic(A **));
+
+void test_overloading(int i, float f, _Atomic(int) ai, _Atomic(float) af,
+                      long l, _Atomic(long) al, A const *const *acc,
+                      A const ** ac, A **a) {
+  int& ir1 = ovl1(i);
+  int& ir2 = ovl1(ai);
+  long& lr1 = ovl1(l);
+  long& lr2 = ovl1(al);
+  float &fr1 = ovl1(f);
+  float &fr2 = ovl1(af);
+  double &dr1 = ovl1(acc);
+  double &dr2 = ovl1(ac);
+  short &sr1 = ovl1(a);
+}
+
+typedef int (A::*fp)() _Atomic; // expected-error {{expected ';' after top level declarator}} expected-warning {{does not declare anything}}
+
+typedef _Atomic(int(A::*)) atomic_mem_ptr_to_int;
+typedef int(A::*_Atomic atomic_mem_ptr_to_int);
+
+typedef _Atomic(int)(A::*mem_ptr_to_atomic_int);
+typedef _Atomic int(A::*mem_ptr_to_atomic_int);
+
+typedef _Atomic(int)&atomic_int_ref;
+typedef _Atomic int &atomic_int_ref;
+typedef _Atomic atomic_int_ref atomic_int_ref; // expected-warning {{'_Atomic' qualifier on reference type 'atomic_int_ref' (aka '_Atomic(int) &') has no effect}}
+
+typedef int &_Atomic atomic_reference_to_int; // expected-error {{'_Atomic' qualifier may not be applied to a reference}}
+typedef _Atomic(int &) atomic_reference_to_int; // expected-error {{_Atomic cannot be applied to reference type 'int &'}}
+
+struct S {
+  _Atomic union { int n; }; // expected-warning {{anonymous union cannot be '_Atomic'}}
+};
+
+namespace copy_init {
+  struct X {
+    X(int);
+    int n;
+  };
+  _Atomic(X) y = X(0);
+  _Atomic(X) z(X(0));
+  void f() { y = X(0); }
+
+  _Atomic(X) e1(0); // expected-error {{cannot initialize}}
+#if __cplusplus >= 201103L
+  _Atomic(X) e2{0}; // expected-error {{illegal initializer}}
+  _Atomic(X) a{X(0)};
+#endif
+
+  struct Y {
+    _Atomic(X) a;
+    _Atomic(int) b;
+  };
+  Y y1 = { X(0), 4 };
+  Y y2 = { 0, 4 }; // expected-error {{cannot initialize}}
+  // FIXME: It's not really clear if we should allow these. Generally, C++11
+  // allows extraneous braces around initializers.
+  Y y3 = { { X(0) }, { 4 } }; // expected-error 2{{illegal initializer type}}
+}
diff --git a/test/SemaCXX/atomic-type.cxx b/test/SemaCXX/atomic-type.cxx
deleted file mode 100644
index 947bb3c..0000000
--- a/test/SemaCXX/atomic-type.cxx
+++ /dev/null
@@ -1,58 +0,0 @@
-// RUN: %clang_cc1 -verify -pedantic %s
-
-template<typename T> struct atomic {
-  _Atomic(T) value;
-
-  void f() _Atomic; // expected-error {{expected ';' at end of declaration list}}
-};
-
-template<typename T> struct user {
-  struct inner { char n[sizeof(T)]; };
-  atomic<inner> i;
-};
-
-user<int> u;
-
-// Test overloading behavior of atomics.
-struct A { };
-
-int &ovl1(_Atomic(int));
-int &ovl1(_Atomic int); // ok, redeclaration
-long &ovl1(_Atomic(long));
-float &ovl1(_Atomic(float));
-double &ovl1(_Atomic(A const *const *));
-double &ovl1(A const *const *_Atomic);
-short &ovl1(_Atomic(A **));
-
-void test_overloading(int i, float f, _Atomic(int) ai, _Atomic(float) af,
-                      long l, _Atomic(long) al, A const *const *acc,
-                      A const ** ac, A **a) {
-  int& ir1 = ovl1(i);
-  int& ir2 = ovl1(ai);
-  long& lr1 = ovl1(l);
-  long& lr2 = ovl1(al);
-  float &fr1 = ovl1(f);
-  float &fr2 = ovl1(af);
-  double &dr1 = ovl1(acc);
-  double &dr2 = ovl1(ac);
-  short &sr1 = ovl1(a);
-}
-
-typedef int (A::*fp)() _Atomic; // expected-error {{expected ';' after top level declarator}} expected-warning {{does not declare anything}}
-
-typedef _Atomic(int(A::*)) atomic_mem_ptr_to_int;
-typedef int(A::*_Atomic atomic_mem_ptr_to_int);
-
-typedef _Atomic(int)(A::*mem_ptr_to_atomic_int);
-typedef _Atomic int(A::*mem_ptr_to_atomic_int);
-
-typedef _Atomic(int)&atomic_int_ref;
-typedef _Atomic int &atomic_int_ref;
-typedef _Atomic atomic_int_ref atomic_int_ref; // ok, qualifiers on references ignored in this case.
-
-typedef int &_Atomic atomic_reference_to_int; // expected-error {{'_Atomic' qualifier may not be applied to a reference}}
-typedef _Atomic(int &) atomic_reference_to_int; // expected-error {{_Atomic cannot be applied to reference type 'int &'}}
-
-struct S {
-  _Atomic union { int n; }; // expected-warning {{anonymous union cannot be '_Atomic'}}
-};
diff --git a/test/SemaCXX/attr-gnu.cpp b/test/SemaCXX/attr-gnu.cpp
new file mode 100644
index 0000000..b4e9f46
--- /dev/null
+++ b/test/SemaCXX/attr-gnu.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -fms-compatibility -verify %s
+
+void f() {
+  // GNU-style attributes are prohibited in this position.
+  auto P = new int * __attribute__((vector_size(8))); // expected-error {{an attribute list cannot appear here}} \
+                                                      // expected-error {{invalid vector element type 'int *'}}
+
+  // Ensure that MS type attribute keywords are still supported in this
+  // position.
+  auto P2 = new int * __sptr; // Ok
+}
+
+void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 feature, not permitted in C++}}
+
+namespace {
+class B {
+public:
+  virtual void test() {}
+  virtual void test2() {}
+  virtual void test3() {}
+};
+
+class D : public B {
+public:
+  void test() __attribute__((deprecated)) final {} // expected-warning {{GCC does not allow an attribute in this position on a function declaration}}
+  void test2() [[]] override {} // Ok
+  void test3() __attribute__((cf_unknown_transfer)) override {} // Ok, not known to GCC.
+};
+}
diff --git a/test/SemaCXX/attr-nodebug.cpp b/test/SemaCXX/attr-nodebug.cpp
index b441da2..fd35722 100644
--- a/test/SemaCXX/attr-nodebug.cpp
+++ b/test/SemaCXX/attr-nodebug.cpp
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -std=c++11 -verify -fsyntax-only
 // Note: most of the 'nodebug' tests are in attr-nodebug.c.
 
 // expected-no-diagnostics
 class c {
   void t3() __attribute__((nodebug));
 };
+
+[[gnu::nodebug]] void f() {}
diff --git a/test/SemaCXX/attr-nonnull.cpp b/test/SemaCXX/attr-nonnull.cpp
index 8af49d9..8fce997 100644
--- a/test/SemaCXX/attr-nonnull.cpp
+++ b/test/SemaCXX/attr-nonnull.cpp
@@ -27,8 +27,8 @@
   __attribute__((nonnull(2))) void f2(int i, int * const &p);
 
   void test_f1() {
-    f1(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
-    f2(0, 0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+    f1(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
+    f2(0, 0); // expected-warning{{null passed to a callee that requires a non-null argument}}
   }
 }
 
diff --git a/test/SemaCXX/attr-print.cpp b/test/SemaCXX/attr-print.cpp
index a07eeff..337a6fb 100644
--- a/test/SemaCXX/attr-print.cpp
+++ b/test/SemaCXX/attr-print.cpp
@@ -22,3 +22,12 @@
 
 // CHECK: int small __attribute__((mode(byte)));
 int small __attribute__((mode(byte)));
+
+// CHECK: int v __attribute__((visibility("hidden")));
+int v __attribute__((visibility("hidden")));
+
+// CHECK: class __attribute__((consumable("unknown"))) AttrTester1
+class __attribute__((consumable(unknown))) AttrTester1 {
+  // CHECK: void callableWhen() __attribute__((callable_when("unconsumed", "consumed")));
+  void callableWhen()  __attribute__((callable_when("unconsumed", "consumed")));
+};
diff --git a/test/SemaCXX/attributed-auto-deduction.cpp b/test/SemaCXX/attributed-auto-deduction.cpp
new file mode 100644
index 0000000..b0cae18
--- /dev/null
+++ b/test/SemaCXX/attributed-auto-deduction.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple armv7 -std=c++14 -x c++ %s -fsyntax-only
+// expected-no-diagnostics
+
+void deduce() {
+  auto single_int = [](int i) __attribute__ (( pcs("aapcs") )) {
+    return i;
+  };
+  auto multiple_int = [](int i) __attribute__ (( pcs("aapcs") ))
+                                __attribute__ (( pcs("aapcs") )) {
+    return i;
+  };
+
+  auto single_void = []() __attribute__ (( pcs("aapcs") )) { };
+  auto multiple_void = []() __attribute__ (( pcs("aapcs") ))
+                            __attribute__ (( pcs("aapcs") )) { };
+}
+
+auto ( __attribute__ (( pcs("aapcs") )) single_attribute() ) { }
+auto ( ( __attribute__ (( pcs("aapcs") )) ( ( __attribute__ (( pcs("aapcs") )) multiple_attributes() ) ) ) ) { }
+
diff --git a/test/SemaCXX/bitfield.cpp b/test/SemaCXX/bitfield.cpp
new file mode 100644
index 0000000..083c28f
--- /dev/null
+++ b/test/SemaCXX/bitfield.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -verify
+
+// expected-no-diagnostics
+
+namespace PromotionVersusMutation {
+  typedef unsigned Unsigned;
+  typedef signed Signed;
+
+  struct T { unsigned n : 2; } t;
+
+  typedef __typeof__(t.n) Unsigned; // Bitfield is unsigned
+  typedef __typeof__(+t.n) Signed;  // ... but promotes to signed.
+
+  typedef __typeof__(t.n + 0) Signed; // Arithmetic promotes.
+
+  typedef __typeof__(t.n = 0) Unsigned;  // Assignment produces an lvalue...
+  typedef __typeof__(t.n += 0) Unsigned;
+  typedef __typeof__(t.n *= 0) Unsigned;
+  typedef __typeof__(+(t.n = 0)) Signed;  // ... which is a bit-field.
+  typedef __typeof__(+(t.n += 0)) Signed;
+  typedef __typeof__(+(t.n *= 0)) Signed;
+
+  typedef __typeof__(++t.n) Unsigned; // Increment is equivalent to compound-assignment.
+  typedef __typeof__(--t.n) Unsigned;
+  typedef __typeof__(+(++t.n)) Signed;
+  typedef __typeof__(+(--t.n)) Signed;
+
+  typedef __typeof__(t.n++) Unsigned; // Post-increment's result has the type
+  typedef __typeof__(t.n--) Unsigned; // of the operand...
+  typedef __typeof__(+(t.n++)) Unsigned; // ... and is not a bit-field (because
+  typedef __typeof__(+(t.n--)) Unsigned; // it's not a glvalue).
+}
diff --git a/test/SemaCXX/blocks.cpp b/test/SemaCXX/blocks.cpp
index a2672d1..0521802 100644
--- a/test/SemaCXX/blocks.cpp
+++ b/test/SemaCXX/blocks.cpp
@@ -100,3 +100,48 @@
       });
   }
 }
+
+
+// rdar://16356628
+//
+// Ensure that we can end function bodies while parsing an
+// expression that requires an explicitly-tracked cleanup object
+// (i.e. a block literal).
+
+// The nested function body in this test case is a template
+// instantiation.  The template function has to be constexpr because
+// we'll otherwise delay its instantiation to the end of the
+// translation unit.
+namespace test6a {
+  template <class T> constexpr int func() { return 0; }
+  void run(void (^)(), int);
+
+  void test() {
+    int aCapturedVar = 0;
+    run(^{ (void) aCapturedVar; }, func<int>());
+  }
+}
+
+// The nested function body in this test case is a method of a local
+// class.
+namespace test6b {
+  void run(void (^)(), void (^)());
+  void test() {
+    int aCapturedVar = 0;
+    run(^{ (void) aCapturedVar; },
+        ^{ struct A { static void foo() {} };
+            A::foo(); });
+  }
+}
+
+// The nested function body in this test case is a lambda invocation
+// function.
+namespace test6c {
+  void run(void (^)(), void (^)());
+  void test() {
+    int aCapturedVar = 0;
+    run(^{ (void) aCapturedVar; },
+        ^{ struct A { static void foo() {} };
+            A::foo(); });
+  }
+}
diff --git a/test/SemaCXX/builtin-assume-aligned-tmpl.cpp b/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
new file mode 100644
index 0000000..0909070
--- /dev/null
+++ b/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<int z>
+int test9(int *a) {
+  a = (int *) __builtin_assume_aligned(a, z + 1); // expected-error {{requested alignment is not a power of 2}}
+  return a[0];
+}
+
+void test9i(int *a) {
+  test9<42>(a); // expected-note {{in instantiation of function template specialization 'test9<42>' requested here}}
+}
+
+template<typename T>
+int test10(int *a, T z) {
+  a = (int *) __builtin_assume_aligned(a, z + 1); // expected-error {{must be a constant integer}}
+  return a[0];
+}
+
+int test10i(int *a) {
+  return test10(a, 42); // expected-note {{in instantiation of function template specialization 'test10<int>' requested here}}
+}
+
+template <int q>
+void *atest() __attribute__((assume_aligned(q))); // expected-error {{requested alignment is not a power of 2}}
+
+template <int q, int o>
+void *atest2() __attribute__((assume_aligned(q, o))); // expected-error {{requested alignment is not a power of 2}}
+
+void test20() {
+  atest<31>(); // expected-note {{in instantiation of function template specialization 'atest<31>' requested here}}
+  atest<32>();
+
+  atest2<31, 5>(); // expected-note {{in instantiation of function template specialization 'atest2<31, 5>' requested here}}
+  atest2<32, 4>();
+}
+
+// expected-error@+1 {{invalid application of 'sizeof' to a function type}}
+template<typename T> __attribute__((assume_aligned(sizeof(int(T()))))) T *f();
+void test21() {
+  void *p = f<void>(); // expected-note {{in instantiation of function template specialization 'f<void>' requested here}}
+}
+
+// expected-error@+1 {{functional-style cast from 'void' to 'int' is not allowed}}
+template<typename T> __attribute__((assume_aligned(sizeof((int(T())))))) T *g();
+void test23() {
+  void *p = g<void>(); // expected-note {{in instantiation of function template specialization 'g<void>' requested here}}
+}
+
+template <typename T, int o>
+T *atest3() __attribute__((assume_aligned(31, o))); // expected-error {{requested alignment is not a power of 2}}
+
+template <typename T, int o>
+T *atest4() __attribute__((assume_aligned(32, o)));
+
+void test22() {
+  atest3<int, 5>();
+  atest4<int, 5>();
+}
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to functions and methods}}
+class __attribute__((assume_aligned(32))) x {
+  int y;
+};
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return values that are pointers or references}}
+x foo() __attribute__((assume_aligned(32)));
+
+struct s1 {
+  static const int x = 32;
+};
+
+struct s2 {
+  static const int x = 64;
+};
+
+struct s3 {
+  static const int x = 63;
+};
+
+template <typename X>
+void *atest5() __attribute__((assume_aligned(X::x))); // expected-error {{requested alignment is not a power of 2}}
+void test24() {
+  atest5<s1>();
+  atest5<s2>();
+  atest5<s3>(); // expected-note {{in instantiation of function template specialization 'atest5<s3>' requested here}}
+}
+
diff --git a/test/SemaCXX/builtin-assume-aligned.cpp b/test/SemaCXX/builtin-assume-aligned.cpp
new file mode 100644
index 0000000..48bd841
--- /dev/null
+++ b/test/SemaCXX/builtin-assume-aligned.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -triple x86_64-linux-gnu %s
+
+int n;
+constexpr int *p = 0;
+// expected-error@+1 {{must be initialized by a constant expression}}
+constexpr int *k = (int *) __builtin_assume_aligned(p, 16, n = 5);
+
+constexpr void *l = __builtin_assume_aligned(p, 16);
+
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{cast from 'void *' is not allowed in a constant expression}}
+constexpr int *c = (int *) __builtin_assume_aligned(p, 16);
+
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{alignment of the base pointee object (4 bytes) is less than the asserted 16 bytes}}
+constexpr void *m = __builtin_assume_aligned(&n, 16);
+
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{offset of the aligned pointer from the base pointee object (-2 bytes) is not a multiple of the asserted 4 bytes}}
+constexpr void *q1 = __builtin_assume_aligned(&n, 4, 2);
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{offset of the aligned pointer from the base pointee object (2 bytes) is not a multiple of the asserted 4 bytes}}
+constexpr void *q2 = __builtin_assume_aligned(&n, 4, -2);
+constexpr void *q3 = __builtin_assume_aligned(&n, 4, 4);
+constexpr void *q4 = __builtin_assume_aligned(&n, 4, -4);
+
+static char ar1[6];
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{alignment of the base pointee object (1 byte) is less than the asserted 16 bytes}}
+constexpr void *r1 = __builtin_assume_aligned(&ar1[2], 16);
+
+static char ar2[6] __attribute__((aligned(32)));
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{offset of the aligned pointer from the base pointee object (2 bytes) is not a multiple of the asserted 16 bytes}}
+constexpr void *r2 = __builtin_assume_aligned(&ar2[2], 16);
+constexpr void *r3 = __builtin_assume_aligned(&ar2[2], 16, 2);
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{offset of the aligned pointer from the base pointee object (1 byte) is not a multiple of the asserted 16 bytes}}
+constexpr void *r4 = __builtin_assume_aligned(&ar2[2], 16, 1);
+
+constexpr int* x = __builtin_constant_p((int*)0xFF) ? (int*)0xFF : (int*)0xFF;
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{value of the aligned pointer (255) is not a multiple of the asserted 32 bytes}}
+constexpr void *s1 = __builtin_assume_aligned(x, 32);
+// expected-error@+2 {{must be initialized by a constant expression}}
+// expected-note@+1 {{value of the aligned pointer (250) is not a multiple of the asserted 32 bytes}}
+constexpr void *s2 = __builtin_assume_aligned(x, 32, 5);
+constexpr void *s3 = __builtin_assume_aligned(x, 32, -1);
+
diff --git a/test/SemaCXX/complex-folding.cpp b/test/SemaCXX/complex-folding.cpp
new file mode 100644
index 0000000..1c2f9c7
--- /dev/null
+++ b/test/SemaCXX/complex-folding.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify
+//
+// Test the constant folding of builtin complex numbers.
+
+static_assert((0.0 + 0.0j) == (0.0 + 0.0j));
+static_assert((0.0 + 0.0j) != (0.0 + 0.0j)); // expected-error {{static_assert}}
+
+static_assert((0.0 + 0.0j) == 0.0);
+static_assert(0.0 == (0.0 + 0.0j));
+static_assert(0.0 == 0.0j);
+static_assert((0.0 + 1.0j) != 0.0);
+static_assert(1.0 != (0.0 + 0.0j));
+static_assert(0.0 != 1.0j);
+
+// Walk around the complex plane stepping between angular differences and
+// equality.
+static_assert((1.0 + 0.0j) == (0.0 + 0.0j)); // expected-error {{static_assert}}
+static_assert((1.0 + 0.0j) == (1.0 + 0.0j));
+static_assert((1.0 + 1.0j) == (1.0 + 0.0j)); // expected-error {{static_assert}}
+static_assert((1.0 + 1.0j) == (1.0 + 1.0j));
+static_assert((0.0 + 1.0j) == (1.0 + 1.0j)); // expected-error {{static_assert}}
+static_assert((0.0 + 1.0j) == (0.0 + 1.0j));
+static_assert((-1.0 + 1.0j) == (0.0 + 1.0j)); // expected-error {{static_assert}}
+static_assert((-1.0 + 1.0j) == (-1.0 + 1.0j));
+static_assert((-1.0 + 0.0j) == (-1.0 + 1.0j)); // expected-error {{static_assert}}
+static_assert((-1.0 + 0.0j) == (-1.0 + 0.0j));
+static_assert((-1.0 - 1.0j) == (-1.0 + 0.0j)); // expected-error {{static_assert}}
+static_assert((-1.0 - 1.0j) == (-1.0 - 1.0j));
+static_assert((0.0 - 1.0j) == (-1.0 - 1.0j)); // expected-error {{static_assert}}
+static_assert((0.0 - 1.0j) == (0.0 - 1.0j));
+static_assert((1.0 - 1.0j) == (0.0 - 1.0j)); // expected-error {{static_assert}}
+static_assert((1.0 - 1.0j) == (1.0 - 1.0j));
+
+// Test basic mathematical folding of both complex and real operands.
+static_assert(((1.0 + 0.5j) + (0.25 - 0.75j)) == (1.25 - 0.25j));
+static_assert(((1.0 + 0.5j) + 0.25) == (1.25 + 0.5j));
+static_assert((1.0 + (0.25 - 0.75j)) == (1.25 - 0.75j));
+
+static_assert(((1.0 + 0.5j) - (0.25 - 0.75j)) == (0.75 + 1.25j));
+static_assert(((1.0 + 0.5j) - 0.25) == (0.75 + 0.5j));
+static_assert((1.0 - (0.25 - 0.75j)) == (0.75 + 0.75j));
+
+static_assert(((1.25 + 0.5j) * (0.25 - 0.75j)) == (0.6875 - 0.8125j));
+static_assert(((1.25 + 0.5j) * 0.25) == (0.3125 + 0.125j));
+static_assert((1.25 * (0.25 - 0.75j)) == (0.3125 - 0.9375j));
+
+static_assert(((1.25 + 0.5j) / (0.25 - 0.75j)) == (-0.1 + 1.7j));
+static_assert(((1.25 + 0.5j) / 0.25) == (5.0 + 2.0j));
+static_assert((1.25 / (0.25 - 0.75j)) == (0.5 + 1.5j));
+
+// Test that infinities are preserved, don't turn into NaNs, and do form zeros
+// when the divisor.
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * 1.0)) == 1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) * 1.0)) == 1);
+static_assert(__builtin_isinf_sign(__real__(1.0 * (__builtin_inf() + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__imag__(1.0 * (1.0 + __builtin_inf() * 1.0j))) == 1);
+
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * (1.0 + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (__builtin_inf() + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * (__builtin_inf() + 1.0j))) == 1);
+
+static_assert(__builtin_isinf_sign(__real__((1.0 + __builtin_inf() * 1.0j) * (1.0 + 1.0j))) == -1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) * (1.0 + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (1.0 + __builtin_inf() * 1.0j))) == -1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + 1.0j) * (1.0 + __builtin_inf() * 1.0j))) == 1);
+
+static_assert(__builtin_isinf_sign(__real__((1.0 + __builtin_inf() * 1.0j) * (1.0 + __builtin_inf() * 1.0j))) == -1);
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + __builtin_inf() * 1.0j) * (__builtin_inf() + __builtin_inf() * 1.0j))) == -1);
+
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / (1.0 + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__imag__(1.0 + (__builtin_inf() * 1.0j) / (1.0 + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / (1.0 + 1.0j))) == 1);
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / 1.0)) == 1);
+static_assert(__builtin_isinf_sign(__imag__(1.0 + (__builtin_inf() * 1.0j) / 1.0)) == 1);
+static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / 1.0)) == 1);
+
+static_assert(((1.0 + 1.0j) / (__builtin_inf() + 1.0j)) == (0.0 + 0.0j));
+static_assert(((1.0 + 1.0j) / (1.0 + __builtin_inf() * 1.0j)) == (0.0 + 0.0j));
+static_assert(((1.0 + 1.0j) / (__builtin_inf() + __builtin_inf() * 1.0j)) == (0.0 + 0.0j));
+static_assert(((1.0 + 1.0j) / __builtin_inf()) == (0.0 + 0.0j));
+
+static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) / (0.0 + 0.0j))) == 1);
+static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) / 0.0)) == 1);
+
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / (0.0 + 0.0j))) == 1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) / (0.0 + 0.0j))) == 1);
+static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / (0.0 + 0.0j))) == 1);
+static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / 0.0)) == 1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) / 0.0)) == 1);
+static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / 0.0)) == 1);
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index 09d93fa..d50dd0b 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -95,11 +95,13 @@
 }
 
 namespace CaseStatements {
+  int x;
   void f(int n) {
     switch (n) {
     case MemberZero().zero: // expected-error {{did you mean to call it with no arguments?}} expected-note {{previous}}
     case id(0): // expected-error {{duplicate case value '0'}}
       return;
+    case __builtin_constant_p(true) ? (__SIZE_TYPE__)&x : 0:; // expected-error {{constant}}
     }
   }
 }
@@ -602,7 +604,7 @@
 constexpr int fn(const A &a) { return a.k; }
 static_assert(fn(A(4,5)) == 9, "");
 
-struct B { int n; int m; } constexpr b = { 0, b.n }; // expected-warning {{uninitialized}}
+struct B { int n; int m; } constexpr b = { 0, b.n };
 struct C {
   constexpr C(C *this_) : m(42), n(this_->m) {} // ok
   int m, n;
@@ -1177,7 +1179,7 @@
   void f() {
     extern constexpr int i; // expected-error {{constexpr variable declaration must be a definition}}
     constexpr int j = 0;
-    constexpr int k; // expected-error {{default initialization of an object of const type}}
+    constexpr int k; // expected-error {{default initialization of an object of const type}} expected-note{{add an explicit initializer to initialize 'k'}}
   }
 }
 
@@ -1326,6 +1328,49 @@
   struct C { B b; };
   constexpr C c[3] = {};
   constexpr int k = c[1].b.a.n; // expected-error {{constant expression}} expected-note {{mutable}}
+
+  struct D { int x; mutable int y; }; // expected-note {{here}}
+  constexpr D d1 = { 1, 2 };
+  int l = ++d1.y;
+  constexpr D d2 = d1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in call}}
+
+  struct E {
+    union {
+      int a;
+      mutable int b; // expected-note {{here}}
+    };
+  };
+  constexpr E e1 = {{1}};
+  constexpr E e2 = e1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in call}}
+
+  struct F {
+    union U { };
+    mutable U u;
+    struct X { };
+    mutable X x;
+    struct Y : X { X x; U u; };
+    mutable Y y;
+    int n;
+  };
+  // This is OK; we don't actually read any mutable state here.
+  constexpr F f1 = {};
+  constexpr F f2 = f1;
+
+  struct G {
+    struct X {};
+    union U { X a; };
+    mutable U u; // expected-note {{here}}
+  };
+  constexpr G g1 = {};
+  constexpr G g2 = g1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in call}}
+  constexpr G::U gu1 = {};
+  constexpr G::U gu2 = gu1;
+
+  union H {
+    mutable G::X gx; // expected-note {{here}}
+  };
+  constexpr H h1 = {};
+  constexpr H h2 = h1; // expected-error {{constant}} expected-note {{mutable}} expected-note {{in call}}
 }
 
 namespace Fold {
@@ -1443,7 +1488,7 @@
 
 namespace NamespaceAlias {
   constexpr int f() {
-    namespace NS = NamespaceAlias; // expected-warning {{use of this statement in a constexpr function is a C++1y extension}}
+    namespace NS = NamespaceAlias; // expected-warning {{use of this statement in a constexpr function is a C++14 extension}}
     return &NS::f != nullptr;
   }
 }
@@ -1700,7 +1745,7 @@
   template <typename T> struct X : T {
     constexpr X() {}
     double d = 0.0;
-    constexpr int f() { return sizeof(T); } // expected-warning {{will not be implicitly 'const' in C++1y}}
+    constexpr int f() { return sizeof(T); } // expected-warning {{will not be implicitly 'const' in C++14}}
   };
 
   // Virtual f(), not OK.
@@ -1715,17 +1760,17 @@
 }
 
 namespace ConstexprConstructorRecovery {
-  class X { 
-  public: 
-      enum E : short { 
-          headers = 0x1, 
-          middlefile = 0x2, 
-          choices = 0x4 
-      }; 
-      constexpr X() noexcept {}; 
-  protected: 
+  class X {
+  public:
+      enum E : short {
+          headers = 0x1,
+          middlefile = 0x2,
+          choices = 0x4
+      };
+      constexpr X() noexcept {};
+  protected:
       E val{0}; // expected-error {{cannot initialize a member subobject of type 'ConstexprConstructorRecovery::X::E' with an rvalue of type 'int'}}
-  }; 
+  };
   constexpr X x{};
 }
 
@@ -1799,8 +1844,9 @@
 namespace BadDefaultInit {
   template<int N> struct X { static const int n = N; };
 
-  struct A { // expected-note {{subexpression}}
-    int k = X<A().k>::n; // expected-error {{defaulted default constructor of 'A' cannot be used}} expected-error {{not a constant expression}} expected-note {{in call to 'A()'}}
+  struct A {
+    int k = // expected-error {{cannot use defaulted default constructor of 'A' within the class outside of member functions because 'k' has an initializer}}
+        X<A().k>::n; // expected-error {{not a constant expression}} expected-note {{implicit default constructor for 'BadDefaultInit::A' first required here}}
   };
 
   // FIXME: The "constexpr constructor must initialize all members" diagnostic
@@ -1892,3 +1938,20 @@
   };
   void test() { constexpr Test t; }
 }
+
+void PR21327(int a, int b) {
+  static_assert(&a + 1 != &b, ""); // expected-error {{constant expression}}
+}
+
+namespace EmptyClass {
+  struct E1 {} e1;
+  union E2 {} e2; // expected-note {{here}}
+  struct E3 : E1 {} e3;
+
+  // The defaulted copy constructor for an empty class does not read any
+  // members. The defaulted copy constructor for an empty union reads the
+  // object representation.
+  constexpr E1 e1b(e1);
+  constexpr E2 e2b(e2); // expected-error {{constant expression}} expected-note{{read of non-const}} expected-note {{in call}}
+  constexpr E3 e3b(e3);
+}
diff --git a/test/SemaCXX/constant-expression-cxx1y.cpp b/test/SemaCXX/constant-expression-cxx1y.cpp
index 521526d..e8925f3 100644
--- a/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -719,8 +719,7 @@
 namespace modify_temporary_during_construction {
   struct A { int &&temporary; int x; int y; };
   constexpr int f(int &r) { r *= 9; return r - 12; }
-  // FIXME: The 'uninitialized' warning here is bogus.
-  constexpr A a = { 6, f(a.temporary), a.temporary }; // expected-warning {{uninitialized}} expected-note {{temporary created here}}
+  constexpr A a = { 6, f(a.temporary), a.temporary }; // expected-note {{temporary created here}}
   static_assert(a.x == 42, "");
   static_assert(a.y == 54, "");
   constexpr int k = a.temporary++; // expected-error {{constant expression}} expected-note {{outside the expression that created the temporary}}
@@ -911,3 +910,31 @@
   constexpr int ARR[] = { 1, 2, 3, 4, 5 };
   static_assert(sum(ARR) == 15, "");
 }
+
+namespace EmptyClass {
+  struct E1 {} e1;
+  union E2 {} e2; // expected-note 4{{here}}
+  struct E3 : E1 {} e3;
+
+  template<typename E>
+  constexpr int f(E &a, int kind) {
+    switch (kind) {
+    case 0: { E e(a); return 0; } // expected-note {{read}} expected-note {{in call}}
+    case 1: { E e(static_cast<E&&>(a)); return 0; } // expected-note {{read}} expected-note {{in call}}
+    case 2: { E e; e = a; return 0; } // expected-note {{read}} expected-note {{in call}}
+    case 3: { E e; e = static_cast<E&&>(a); return 0; } // expected-note {{read}} expected-note {{in call}}
+    }
+  }
+  constexpr int test1 = f(e1, 0);
+  constexpr int test2 = f(e2, 0); // expected-error {{constant expression}} expected-note {{in call}}
+  constexpr int test3 = f(e3, 0);
+  constexpr int test4 = f(e1, 1);
+  constexpr int test5 = f(e2, 1); // expected-error {{constant expression}} expected-note {{in call}}
+  constexpr int test6 = f(e3, 1);
+  constexpr int test7 = f(e1, 2);
+  constexpr int test8 = f(e2, 2); // expected-error {{constant expression}} expected-note {{in call}}
+  constexpr int test9 = f(e3, 2);
+  constexpr int testa = f(e1, 3);
+  constexpr int testb = f(e2, 3); // expected-error {{constant expression}} expected-note {{in call}}
+  constexpr int testc = f(e3, 3);
+}
diff --git a/test/SemaCXX/constexpr-value-init.cpp b/test/SemaCXX/constexpr-value-init.cpp
index 9ad1129..3657c18 100644
--- a/test/SemaCXX/constexpr-value-init.cpp
+++ b/test/SemaCXX/constexpr-value-init.cpp
@@ -14,7 +14,7 @@
   constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}}
 }
 
-constexpr B b1; // expected-error {{requires a user-provided default constructor}}
+constexpr B b1; // expected-error {{without a user-provided default constructor}} expected-note {{add an explicit initializer to initialize 'b1'}}
 constexpr B b2 = B(); // ok
 static_assert(b2.a.a == 1, "");
 static_assert(b2.a.b == 2, "");
@@ -23,9 +23,9 @@
   int c;
 };
 struct D : C { int d; };
-constexpr C c1; // expected-error {{requires a user-provided default constructor}}
+constexpr C c1; // expected-error {{without a user-provided default constructor}} expected-note{{add an explicit initializer to initialize 'c1'}}
 constexpr C c2 = C(); // ok
-constexpr D d1; // expected-error {{requires a user-provided default constructor}}
+constexpr D d1; // expected-error {{without a user-provided default constructor}} expected-note{{add an explicit initializer to initialize 'd1'}}
 constexpr D d2 = D(); // ok with DR1452
 static_assert(D().c == 0, "");
 static_assert(D().d == 0, "");
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 40ac33b..ede23a2 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -Wbind-to-temporary-copy -verify %s 
 class X { 
 public:
   operator bool();
diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp
index 852bbba..b8f0e07 100644
--- a/test/SemaCXX/conversion.cpp
+++ b/test/SemaCXX/conversion.cpp
@@ -90,6 +90,18 @@
     ;
   do ;
   while(NULL_COND(true));
+
+#define NULL_WRAPPER NULL_COND(false)
+  if (NULL_WRAPPER)
+    ;
+  while (NULL_WRAPPER)
+    ;
+  for (; NULL_WRAPPER;)
+    ;
+  do
+    ;
+  while (NULL_WRAPPER);
+
   int *ip = NULL;
   int (*fp)() = NULL;
   struct foo {
@@ -137,3 +149,11 @@
     return NULL;
   }
 }
+
+namespace test7 {
+  bool fun() {
+    bool x = nullptr; // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
+    if (nullptr) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
+    return nullptr; // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
+  }
+}
diff --git a/test/SemaCXX/crashes.cpp b/test/SemaCXX/crashes.cpp
index 1570d12..6ae476f 100644
--- a/test/SemaCXX/crashes.cpp
+++ b/test/SemaCXX/crashes.cpp
@@ -231,3 +231,9 @@
   };
   void C2::f() {}
 }
+
+namespace pr20660 {
+ appendList(int[]...);     // expected-error {{C++ requires a type specifier for all declarations}}
+ appendList(int[]...) { }  // expected-error {{C++ requires a type specifier for all declarations}}
+}
+
diff --git a/test/SemaCXX/cxx-deprecated.cpp b/test/SemaCXX/cxx-deprecated.cpp
new file mode 100644
index 0000000..47accd4
--- /dev/null
+++ b/test/SemaCXX/cxx-deprecated.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
+
+namespace [[deprecated]] {}  // expected-warning {{'deprecated' attribute on anonymous namespace ignored}}
+
+namespace [[deprecated]] N { // expected-note 4{{'N' has been explicitly marked deprecated here}}
+  int X;
+  int Y = X; // Ok
+  int f();
+}
+
+int N::f() { // Ok
+  return Y; // Ok
+}
+
+void f() {
+  int Y = N::f(); // expected-warning {{'N' is deprecated}}
+  using N::X; // expected-warning {{'N' is deprecated}}
+  int Z = X; //Ok
+}
+
+void g() {
+  using namespace N; // expected-warning {{'N' is deprecated}}
+  int Z = Y; // Ok
+}
+
+namespace M = N; // expected-warning {{'N' is deprecated}}
diff --git a/test/SemaCXX/cxx0x-compat.cpp b/test/SemaCXX/cxx0x-compat.cpp
index a58a7f8..bcf0cf1 100644
--- a/test/SemaCXX/cxx0x-compat.cpp
+++ b/test/SemaCXX/cxx0x-compat.cpp
@@ -41,9 +41,15 @@
 #define _x + 1
 char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}}
 
+template<int ...N> int f() { // expected-warning {{C++11 extension}}
+  return (N + ...); // expected-warning {{C++1z extension}}
+}
+
 #else
 
-auto init_capture = [a(0)] {}; // expected-warning {{initialized lambda captures are incompatible with C++ standards before C++1y}}
+auto init_capture = [a(0)] {}; // expected-warning {{initialized lambda captures are incompatible with C++ standards before C++14}}
 static_assert(true); // expected-warning {{incompatible with C++ standards before C++1z}}
 
+template<int ...N> int f() { return (N + ...); } // expected-warning {{incompatible with C++ standards before C++1z}}
+
 #endif
diff --git a/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
index 07a7842..375cf4a 100644
--- a/test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -25,7 +25,7 @@
   non_const_copy ncc2 = ncc;
   ncc = ncc2;
   const non_const_copy cncc{};
-  const non_const_copy cncc1; // expected-error {{default initialization of an object of const type 'const non_const_copy' requires a user-provided default constructor}}
+  const non_const_copy cncc1; // expected-error {{default initialization of an object of const type 'const non_const_copy' without a user-provided default constructor}} expected-note {{add an explicit initializer to initialize 'cncc1'}}
   non_const_copy ncc3 = cncc; // expected-error {{no matching}}
   ncc = cncc; // expected-error {{no viable overloaded}}
 };
diff --git a/test/SemaCXX/cxx0x-initializer-references.cpp b/test/SemaCXX/cxx0x-initializer-references.cpp
index 9096c8a..d1a9ed3 100644
--- a/test/SemaCXX/cxx0x-initializer-references.cpp
+++ b/test/SemaCXX/cxx0x-initializer-references.cpp
@@ -118,3 +118,9 @@
   F f2 { { 0 } }; // expected-error {{chosen constructor is explicit}}
   F f3 { { { 0 } } }; // expected-error {{chosen constructor is explicit}}
 }
+
+namespace PR20844 {
+  struct A {};
+  struct B { operator A&(); } b;
+  A &a{b}; // expected-error {{excess elements}} expected-note {{in initialization of temporary of type 'PR20844::A'}}
+}
diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
index db6614d..70f7c64 100644
--- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -238,3 +238,24 @@
   S s[3] = { {1, 2, 3}, {4, 5} }; // ok
   S *p = new S[3] { {1, 2, 3}, {4, 5} }; // ok
 }
+
+namespace ListInitInstantiate {
+  struct A {
+    A(std::initializer_list<A>);
+    A(std::initializer_list<int>);
+  };
+  struct B : A {
+    B(int);
+  };
+  template<typename T> struct X {
+    X();
+    A a;
+  };
+  template<typename T> X<T>::X() : a{B{0}, B{1}} {}
+
+  X<int> x;
+
+  int f(const A&);
+  template<typename T> void g() { int k = f({0}); }
+  template void g<int>();
+}
diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp
index f7bfc11..5604374 100644
--- a/test/SemaCXX/cxx11-ast-print.cpp
+++ b/test/SemaCXX/cxx11-ast-print.cpp
@@ -15,7 +15,7 @@
 // CHECK: const char *operator "" _quux(const char *);
 const char *operator"" _quux(const char *);
 
-// CHECK: template <char...> const char *operator "" _fritz();
+// CHECK: template <char ...> const char *operator "" _fritz();
 template<char...> const char *operator"" _fritz();
 
 // CHECK: const char *p1 = "bar1"_foo;
diff --git a/test/SemaCXX/cxx1y-constexpr-not-const.cpp b/test/SemaCXX/cxx1y-constexpr-not-const.cpp
index 3f100b8..071b39c 100644
--- a/test/SemaCXX/cxx1y-constexpr-not-const.cpp
+++ b/test/SemaCXX/cxx1y-constexpr-not-const.cpp
@@ -14,5 +14,5 @@
 // expected-error@6 {{non-constexpr declaration of 'f' follows constexpr declaration}}
 // expected-note@5 {{previous}}
 #else
-// expected-warning@5 {{'constexpr' non-static member function will not be implicitly 'const' in C++1y; add 'const' to avoid a change in behavior}}
+// expected-warning@5 {{'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior}}
 #endif
diff --git a/test/SemaCXX/cxx1y-generic-lambdas.cpp b/test/SemaCXX/cxx1y-generic-lambdas.cpp
index dc85748..8e07b80 100644
--- a/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ b/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -859,11 +859,13 @@
 struct X1 {  
   struct X2 {
     enum { E = [](auto i) { return i; }(3) }; //expected-error{{inside of a constant expression}}\
-                                          //expected-error{{not an integral constant}}
+                                          //expected-error{{not an integral constant}}\
+                                          //expected-note{{non-literal type}}
     int L = ([] (int i) { return i; })(2);
     void foo(int i = ([] (int i) { return i; })(2)) { }
     int B : ([](int i) { return i; })(3); //expected-error{{inside of a constant expression}}\
-                                          //expected-error{{not an integral constant}}
+                                          //expected-error{{not an integral constant}}\
+                                          //expected-note{{non-literal type}}
     int arr[([](int i) { return i; })(3)]; //expected-error{{inside of a constant expression}}\
                                            //expected-error{{must have a constant size}}
     int (*fp)(int) = [](int i) { return i; };
@@ -871,9 +873,10 @@
     int L2 = ([](auto i) { return i; })(2);
     void fooG(int i = ([] (auto i) { return i; })(2)) { }
     int BG : ([](auto i) { return i; })(3); //expected-error{{inside of a constant expression}}  \
-                                             //expected-error{{not an integral constant}}
+                                            //expected-error{{not an integral constant}}\
+                                            //expected-note{{non-literal type}}
     int arrG[([](auto i) { return i; })(3)]; //expected-error{{inside of a constant expression}}\
-                                           //expected-error{{must have a constant size}}
+                                             //expected-error{{must have a constant size}}
     int (*fpG)(int) = [](auto i) { return i; };
     void fooptrG(int (*fp)(char) = [](auto c) { return 0; }) { }
   };
@@ -887,14 +890,16 @@
     int L = ([] (T i) { return i; })(2);
     void foo(int i = ([] (int i) { return i; })(2)) { }
     int B : ([](T i) { return i; })(3); //expected-error{{inside of a constant expression}}\
-                                          //expected-error{{not an integral constant}}
+                                        //expected-error{{not an integral constant}}\
+                                        //expected-note{{non-literal type}}
     int arr[([](T i) { return i; })(3)]; //expected-error{{inside of a constant expression}}\
-                                           //expected-error{{must have a constant size}}
+                                         //expected-error{{must have a constant size}}
     int (*fp)(T) = [](T i) { return i; };
     void fooptr(T (*fp)(char) = [](char c) { return 0; }) { }
     int L2 = ([](auto i) { return i; })(2);
     void fooG(T i = ([] (auto i) { return i; })(2)) { }
-    int BG : ([](auto i) { return i; })(3); //expected-error{{not an integral constant}}
+    int BG : ([](auto i) { return i; })(3); //expected-error{{not an integral constant}}\
+                                            //expected-note{{non-literal type}}
     int arrG[([](auto i) { return i; })(3)]; //expected-error{{must have a constant size}}
     int (*fpG)(T) = [](auto i) { return i; };
     void fooptrG(T (*fp)(char) = [](auto c) { return 0; }) { }
diff --git a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index 1e5e834..f6f77f0 100644
--- a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -58,13 +58,13 @@
     template<typename T, typename T0> static CONST T b = T(100);
     template<typename T> static CONST T b<T,int>;
   };
-  template<typename T, typename T0> CONST T B4::a; // expected-error {{default initialization of an object of const type 'const int'}}
+  template<typename T, typename T0> CONST T B4::a; // expected-error {{default initialization of an object of const type 'const int'}} expected-note {{add an explicit initializer to initialize 'a<int, char>'}}
   template<typename T> CONST T B4::a<T,int>;
   template CONST int B4::a<int,char>; // expected-note {{in instantiation of}}
   template CONST int B4::a<int,int>;
 
   template<typename T, typename T0> CONST T B4::b;
-  template<typename T> CONST T B4::b<T,int>; // expected-error {{default initialization of an object of const type 'const int'}}
+  template<typename T> CONST T B4::b<T,int>; // expected-error {{default initialization of an object of const type 'const int'}} expected-note {{add an explicit initializer to initialize 'b<int, int>'}}
   template CONST int B4::b<int,char>;
   template CONST int B4::b<int,int>; // expected-note {{in instantiation of}}
 }
diff --git a/test/SemaCXX/cxx98-compat-flags.cpp b/test/SemaCXX/cxx98-compat-flags.cpp
index 6dc24be..f90ad34 100644
--- a/test/SemaCXX/cxx98-compat-flags.cpp
+++ b/test/SemaCXX/cxx98-compat-flags.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s
 
 template<typename T> int TemplateFn(T) { return 0; }
 void LocalTemplateArg() {
diff --git a/test/SemaCXX/cxx98-compat-pedantic.cpp b/test/SemaCXX/cxx98-compat-pedantic.cpp
index b74dcb4..38bc341 100644
--- a/test/SemaCXX/cxx98-compat-pedantic.cpp
+++ b/test/SemaCXX/cxx98-compat-pedantic.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98
 
 // RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-c++98-c++11-compat-pedantic -DCXX1Y2
 
@@ -49,5 +49,32 @@
 
 int k = 0b1001;
 #ifdef CXX1Y
-// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++1y}}
+// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++14}}
 #endif
+
+namespace CopyCtorIssues {
+  struct Private {
+    Private();
+  private:
+    Private(const Private&); // expected-note {{declared private here}}
+  };
+  struct NoViable {
+    NoViable();
+    NoViable(NoViable&); // expected-note {{not viable}}
+  };
+  struct Ambiguous {
+    Ambiguous();
+    Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
+    Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
+  };
+  struct Deleted {
+    Private p; // expected-note {{implicitly deleted}}
+  };
+
+  const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+  const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+#if !CXX98
+  const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
+#endif
+  const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
+}
diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp
index 96af954..029e909 100644
--- a/test/SemaCXX/cxx98-compat.cpp
+++ b/test/SemaCXX/cxx98-compat.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat -verify %s -DCXX1YCOMPAT
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -Wc++98-compat -verify %s -DCXX14COMPAT
 
 namespace std {
   struct type_info;
@@ -225,31 +225,6 @@
 int SFINAEAccessControl(...) { return 0; }
 int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); // expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
 
-namespace CopyCtorIssues {
-  struct Private {
-    Private();
-  private:
-    Private(const Private&); // expected-note {{declared private here}}
-  };
-  struct NoViable {
-    NoViable();
-    NoViable(NoViable&); // expected-note {{not viable}}
-  };
-  struct Ambiguous {
-    Ambiguous();
-    Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
-    Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
-  };
-  struct Deleted {
-    Private p; // expected-note {{implicitly deleted}}
-  };
-
-  const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
-  const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
-  const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
-  const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
-}
-
 namespace UnionOrAnonStructMembers {
   struct NonTrivCtor {
     NonTrivCtor(); // expected-note 2{{user-provided default constructor}}
@@ -286,18 +261,18 @@
 template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
 
 void JumpDiagnostics(int n) {
-  goto DirectJump; // expected-warning {{goto would jump into protected scope in C++98}}
+  goto DirectJump; // expected-warning {{jump from this goto statement to its label is incompatible with C++98}}
   TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
 
 DirectJump:
   void *Table[] = {&&DirectJump, &&Later};
-  goto *Table[n]; // expected-warning {{indirect goto might cross protected scopes in C++98}}
+  goto *Table[n]; // expected-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++98}}
 
   TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
-Later: // expected-note {{possible target of indirect goto}}
+Later: // expected-note {{possible target of indirect goto statement}}
   switch (n) {
     TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
-  default: // expected-warning {{switch case would be in a protected scope in C++98}}
+  default: // expected-warning {{jump from switch statement to this case label is incompatible with C++98}}
     return;
   }
 }
@@ -373,10 +348,10 @@
 }
 
 template<typename T> T var = T(10);
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
+#ifdef CXX14COMPAT
+// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
 #else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
+// expected-warning@-4 {{variable templates are a C++14 extension}}
 #endif
 
 // No diagnostic for specializations of variable templates; we will have
@@ -388,27 +363,27 @@
 
 class A {
   template<typename T> static T var = T(10);
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
+#ifdef CXX14COMPAT
+// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
 #else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
+// expected-warning@-4 {{variable templates are a C++14 extension}}
 #endif
 
-  template<typename T> static T* var<T*> = new T(); 
+  template<typename T> static T* var<T*> = new T();
 };
 
 struct B {  template<typename T> static T v; };
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
+#ifdef CXX14COMPAT
+// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
 #else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
+// expected-warning@-4 {{variable templates are a C++14 extension}}
 #endif
 
 template<typename T> T B::v = T();
-#ifdef CXX1YCOMPAT
-// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++1y}}
+#ifdef CXX14COMPAT
+// expected-warning@-2 {{variable templates are incompatible with C++ standards before C++14}}
 #else
-// expected-warning@-4 {{variable templates are a C++1y extension}}
+// expected-warning@-4 {{variable templates are a C++14 extension}}
 #endif
 
 template<typename T> T* B::v<T*> = new T();
@@ -416,6 +391,6 @@
 template int B::v<int>;
 float fsvar = B::v<float>;
 
-#ifdef CXX1YCOMPAT
-int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++1y}}
+#ifdef CXX14COMPAT
+int digit_seps = 123'456; // expected-warning {{digit separators are incompatible with C++ standards before C++14}}
 #endif
diff --git a/test/SemaCXX/decl-init-ref.cpp b/test/SemaCXX/decl-init-ref.cpp
index 2d0c9cb..42b9286 100644
--- a/test/SemaCXX/decl-init-ref.cpp
+++ b/test/SemaCXX/decl-init-ref.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-uninitialized
 
 struct A {};
 
diff --git a/test/SemaCXX/decl-microsoft-call-conv.cpp b/test/SemaCXX/decl-microsoft-call-conv.cpp
index eb6c850..a4b68cd 100644
--- a/test/SemaCXX/decl-microsoft-call-conv.cpp
+++ b/test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -10,6 +10,7 @@
 void __cdecl    free_func_cdecl(); // expected-note 2 {{previous declaration is here}}
 void __stdcall  free_func_stdcall(); // expected-note 2 {{previous declaration is here}}
 void __fastcall free_func_fastcall(); // expected-note 2 {{previous declaration is here}}
+void __vectorcall free_func_vectorcall(); // expected-note 2 {{previous declaration is here}}
 
 void __cdecl    free_func_default();
 void __stdcall  free_func_default(); // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
@@ -27,6 +28,10 @@
 void __stdcall  free_func_fastcall(); // expected-error {{function declared 'stdcall' here was previously declared 'fastcall'}}
 void            free_func_fastcall();
 
+void __cdecl    free_func_vectorcall(); // expected-error {{function declared 'cdecl' here was previously declared 'vectorcall'}}
+void __stdcall  free_func_vectorcall(); // expected-error {{function declared 'stdcall' here was previously declared 'vectorcall'}}
+void            free_func_vectorcall();
+
 // Overloaded functions may have different calling conventions
 void __fastcall free_func_default(int);
 void __cdecl    free_func_default(int *);
@@ -45,6 +50,8 @@
   void __cdecl    member_cdecl2(); // expected-note {{previous declaration is here}}
   void __thiscall member_thiscall1();
   void __thiscall member_thiscall2(); // expected-note {{previous declaration is here}}
+  void __vectorcall member_vectorcall1();
+  void __vectorcall member_vectorcall2(); // expected-note {{previous declaration is here}}
 
   // Typedefs carrying the __cdecl convention are adjusted to __thiscall.
   void_fun_t           member_typedef_default; // expected-note {{previous declaration is here}}
@@ -83,6 +90,9 @@
 void            S::member_thiscall1() {}
 void __cdecl    S::member_thiscall2() {} // expected-error {{function declared 'cdecl' here was previously declared 'thiscall'}}
 
+void            S::member_vectorcall1() {}
+void __cdecl    S::member_vectorcall2() {} // expected-error {{function declared 'cdecl' here was previously declared 'vectorcall'}}
+
 void            S::static_member_default1() {}
 void __cdecl    S::static_member_default2() {}
 void __stdcall  S::static_member_default3() {} // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
@@ -143,9 +153,10 @@
 void multi_attribute(int x) { __builtin_unreachable(); }
 
 
+// expected-error@+3 {{vectorcall and cdecl attributes are not compatible}}
 // expected-error@+2 {{stdcall and cdecl attributes are not compatible}}
 // expected-error@+1 {{fastcall and cdecl attributes are not compatible}}
-void __cdecl __cdecl __stdcall __cdecl __fastcall multi_cc(int x);
+void __cdecl __cdecl __stdcall __cdecl __fastcall __vectorcall multi_cc(int x);
 
 template <typename T> void __stdcall StdcallTemplate(T) {}
 template <> void StdcallTemplate<int>(int) {}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index b661776..6001001 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -62,3 +62,12 @@
     j(2, 3); // expected-error{{too many arguments to function call, expected at most single argument 'f', have 2}}
   }
 }
+
+int pr20055_f(int x = 0, int y = UNDEFINED); // expected-error{{use of undeclared identifier}}
+int pr20055_v = pr20055_f(0);
+
+void PR20769() { void PR20769(int = 1); }
+void PR20769(int = 2);
+
+void PR20769_b(int = 1);
+void PR20769_b() { void PR20769_b(int = 2); }
diff --git a/test/SemaCXX/dependent-noexcept-unevaluated.cpp b/test/SemaCXX/dependent-noexcept-unevaluated.cpp
index 0a3a8bb..fad8d09 100644
--- a/test/SemaCXX/dependent-noexcept-unevaluated.cpp
+++ b/test/SemaCXX/dependent-noexcept-unevaluated.cpp
@@ -23,7 +23,7 @@
 {
     T data[N];
 
-    void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
+  void swap(array& a) noexcept(noexcept(::swap(declval<T&>(), declval<T&>())));
 };
 
 struct DefaultOnly
@@ -38,3 +38,4 @@
 {
     array<DefaultOnly, 1> a, b;
 }
+
diff --git a/test/SemaCXX/deprecated.cpp b/test/SemaCXX/deprecated.cpp
index 2fe6d59..5fcf213 100644
--- a/test/SemaCXX/deprecated.cpp
+++ b/test/SemaCXX/deprecated.cpp
@@ -35,7 +35,7 @@
 #endif
 }
 
-struct S { int n; };
+struct S { int n; void operator+(int); };
 struct T : private S {
   S::n;
 #if __cplusplus < 201103L
@@ -43,6 +43,12 @@
 #else
   // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
 #endif
+  S::operator+;
+#if __cplusplus < 201103L
+  // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+  // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
 };
 
 #if __cplusplus >= 201103L
diff --git a/test/SemaCXX/devirtualize-vtable-marking.cpp b/test/SemaCXX/devirtualize-vtable-marking.cpp
new file mode 100644
index 0000000..fc3e8ce
--- /dev/null
+++ b/test/SemaCXX/devirtualize-vtable-marking.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+template <typename T> struct OwnPtr {
+  T *p;
+  ~OwnPtr() {
+    // expected-error@+1 {{invalid application of 'sizeof'}}
+    static_assert(sizeof(T) > 0, "incomplete T");
+    delete p;
+  }
+};
+
+namespace use_vtable_for_vcall {
+struct Incomplete; // expected-note {{forward declaration}}
+struct A {
+  virtual ~A() {}
+  virtual void m() {}
+};
+struct B : A { // expected-note {{in instantiation}}
+  B();
+  virtual void m() { }
+  virtual void m2() { static_cast<A *>(this)->m(); }
+  OwnPtr<Incomplete> m_sqlError;
+};
+
+B *f() {
+  return new B();
+}
+}
+
+namespace dont_mark_qualified_vcall {
+struct Incomplete;
+struct A {
+  virtual ~A() {}
+  virtual void m() {}
+};
+struct B : A {
+  B();
+  // Previously we would mark B's vtable referenced to devirtualize this call to
+  // A::m, even though it's not a virtual call.
+  virtual void m() { A::m(); }
+  OwnPtr<Incomplete> m_sqlError;
+};
+
+B *f() {
+  return new B();
+}
+}
diff --git a/test/SemaCXX/dllexport.cpp b/test/SemaCXX/dllexport.cpp
index 9a53e27..5d002ac 100644
--- a/test/SemaCXX/dllexport.cpp
+++ b/test/SemaCXX/dllexport.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -verify -std=c++11 -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -verify -std=c++1y -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -verify -std=c++1y %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s
+// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s
+// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Exported {};
@@ -53,7 +53,12 @@
                              int GlobalRedecl2;
 
                       extern int GlobalRedecl3; // expected-note{{previous declaration is here}}
-__declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}
+__declspec(dllexport) extern int GlobalRedecl3; // expected-warning{{redeclaration of 'GlobalRedecl3' should not add 'dllexport' attribute}}
+
+extern "C" {
+                      extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
+__declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}}
+}
 
 // External linkage is required.
 __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}
@@ -64,6 +69,9 @@
 __declspec(dllexport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllexport'}}
 __declspec(dllexport) auto ExternalAutoTypeGlobal = External();
 
+// Thread local variables are invalid.
+__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
+
 // Export in local scope.
 void functionScope() {
   __declspec(dllexport)        int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}}
@@ -186,10 +194,15 @@
                       void redecl2() {}
 
                       void redecl3(); // expected-note{{previous declaration is here}}
-__declspec(dllexport) void redecl3(); // expected-error{{redeclaration of 'redecl3' cannot add 'dllexport' attribute}}
+__declspec(dllexport) void redecl3(); // expected-warning{{redeclaration of 'redecl3' should not add 'dllexport' attribute}}
 
+extern "C" {
                       void redecl4(); // expected-note{{previous declaration is here}}
-__declspec(dllexport) inline void redecl4() {} // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
+__declspec(dllexport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllexport' attribute}}
+}
+
+                      void redecl5(); // expected-note{{previous declaration is here}}
+__declspec(dllexport) inline void redecl5() {} // expected-warning{{redeclaration of 'redecl5' should not add 'dllexport' attribute}}
 
 // Friend functions
 struct FuncFriend {
@@ -200,8 +213,8 @@
 };
 __declspec(dllexport) void friend1() {}
                       void friend2() {}
-__declspec(dllexport) void friend3() {} // expected-error{{redeclaration of 'friend3' cannot add 'dllexport' attribute}}
-__declspec(dllexport) inline void friend4() {} // expected-error{{redeclaration of 'friend4' cannot add 'dllexport' attribute}}
+__declspec(dllexport) void friend3() {} // expected-warning{{redeclaration of 'friend3' should not add 'dllexport' attribute}}
+__declspec(dllexport) inline void friend4() {} // expected-warning{{redeclaration of 'friend4' should not add 'dllexport' attribute}}
 
 // Implicit declarations can be redeclared with dllexport.
 __declspec(dllexport) void* operator new(__SIZE_TYPE__ n);
@@ -314,6 +327,10 @@
 // Classes
 //===----------------------------------------------------------------------===//
 
+namespace {
+  struct __declspec(dllexport) AnonymousClass {}; // expected-error{{(anonymous namespace)::AnonymousClass' must have external linkage when declared 'dllexport'}}
+}
+
 class __declspec(dllexport) ClassDecl;
 
 class __declspec(dllexport) ClassDef {};
@@ -327,6 +344,49 @@
 template <typename T> struct ExpliciallySpecializedClassTemplate {};
 template <> struct __declspec(dllexport) ExpliciallySpecializedClassTemplate<int> { void f() {} };
 
+// Don't instantiate class members of implicitly instantiated templates, even if they are exported.
+struct IncompleteType;
+template <typename T> struct __declspec(dllexport) ImplicitlyInstantiatedExportedTemplate {
+  int f() { return sizeof(T); } // no-error
+};
+ImplicitlyInstantiatedExportedTemplate<IncompleteType> implicitlyInstantiatedExportedTemplate;
+
+// Don't instantiate class members of templates with explicit instantiation declarations, even if they are exported.
+struct IncompleteType2;
+template <typename T> struct __declspec(dllexport) ExportedTemplateWithExplicitInstantiationDecl {
+  int f() { return sizeof(T); } // no-error
+};
+extern template struct ExportedTemplateWithExplicitInstantiationDecl<IncompleteType2>;
+
+// Instantiate class members for explicitly instantiated exported templates.
+struct IncompleteType3; // expected-note{{forward declaration of 'IncompleteType3'}}
+template <typename T> struct __declspec(dllexport) ExplicitlyInstantiatedExportedTemplate {
+  int f() { return sizeof(T); } // expected-error{{invalid application of 'sizeof' to an incomplete type 'IncompleteType3'}}
+};
+template struct ExplicitlyInstantiatedExportedTemplate<IncompleteType3>; // expected-note{{in instantiation of member function 'ExplicitlyInstantiatedExportedTemplate<IncompleteType3>::f' requested here}}
+
+// In MS mode, instantiate members of class templates that are base classes of exported classes.
+#ifdef MS
+  // expected-note@+3{{forward declaration of 'IncompleteType4'}}
+  // expected-note@+3{{in instantiation of member function 'BaseClassTemplateOfExportedClass<IncompleteType4>::f' requested here}}
+#endif
+struct IncompleteType4;
+template <typename T> struct BaseClassTemplateOfExportedClass {
+#ifdef MS
+  // expected-error@+2{{invalid application of 'sizeof' to an incomplete type 'IncompleteType4'}}
+#endif
+  int f() { return sizeof(T); };
+};
+struct __declspec(dllexport) ExportedBaseClass : public BaseClassTemplateOfExportedClass<IncompleteType4> {};
+
+// Don't instantiate members of explicitly exported class templates that are base classes of exported classes.
+struct IncompleteType5;
+template <typename T> struct __declspec(dllexport) ExportedBaseClassTemplateOfExportedClass {
+  int f() { return sizeof(T); }; // no-error
+};
+struct __declspec(dllexport) ExportedBaseClass2 : public ExportedBaseClassTemplateOfExportedClass<IncompleteType5> {};
+
+
 
 //===----------------------------------------------------------------------===//
 // Classes with template base classes
@@ -370,7 +430,7 @@
 
 #ifdef MS
 // expected-note@+4{{class template 'ClassTemplate<double>' was instantiated here}}
-// expected-warning@+4{{propagating dll attribute to already instantiated base class template without dll attribute is unsupported}}
+// expected-warning@+4{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}}
 // expected-note@+3{{attribute is here}}
 #endif
 class DerivedFromTemplateD : public ClassTemplate<double> {};
@@ -378,14 +438,14 @@
 
 #ifdef MS
 // expected-note@+4{{class template 'ClassTemplate<bool>' was instantiated here}}
-// expected-warning@+4{{propagating dll attribute to already instantiated base class template with different dll attribute is unsupported}}
+// expected-warning@+4{{propagating dll attribute to already instantiated base class template with different dll attribute is not supported}}
 // expected-note@+3{{attribute is here}}
 #endif
 class __declspec(dllimport) DerivedFromTemplateB : public ClassTemplate<bool> {};
 class __declspec(dllexport) DerivedFromTemplateB2 : public ClassTemplate<bool> {};
 
 #ifdef MS
-// expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is unsupported}}
+// expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}}
 // expected-note@+2{{attribute is here}}
 #endif
 struct __declspec(dllexport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {};
@@ -397,7 +457,7 @@
 struct __declspec(dllexport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {};
 
 #ifdef MS
-// expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is unsupported}}
+// expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}}
 // expected-note@+2{{attribute is here}}
 #endif
 struct __declspec(dllexport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {};
diff --git a/test/SemaCXX/dllimport.cpp b/test/SemaCXX/dllimport.cpp
index 855893c..eb6a554 100644
--- a/test/SemaCXX/dllimport.cpp
+++ b/test/SemaCXX/dllimport.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -verify -std=c++11 -DMS %s
-// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -verify -std=c++1y -DMS %s
-// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -verify -std=c++1y %s
-// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-win32     -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DMS %s
+// RUN: %clang_cc1 -triple x86_64-win32   -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DMS %s
+// RUN: %clang_cc1 -triple i686-mingw32   -fsyntax-only -verify -std=c++1y -Wunsupported-dll-base-class-template -DGNU %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
@@ -75,7 +75,12 @@
                       extern int GlobalRedecl3; // expected-warning{{'GlobalRedecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
 
                       extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
-__declspec(dllimport) extern int GlobalRedecl4; // expected-error{{redeclaration of 'GlobalRedecl4' cannot add 'dllimport' attribute}}
+__declspec(dllimport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllimport' attribute}}
+
+extern "C" {
+                      extern int GlobalRedecl5; // expected-note{{previous declaration is here}}
+__declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclaration of 'GlobalRedecl5' should not add 'dllimport' attribute}}
+}
 
 // External linkage is required.
 __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}}
@@ -86,6 +91,9 @@
 __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-error{{'InternalAutoTypeGlobal' must have external linkage when declared 'dllimport'}}
                                                                 // expected-error@-1{{definition of dllimport data}}
 
+// Thread local variables are invalid.
+__declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
+
 // Import in local scope.
 __declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}}
 __declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}}
@@ -183,7 +191,6 @@
 #endif // __has_feature(cxx_variable_templates)
 
 
-
 //===----------------------------------------------------------------------===//
 // Functions
 //===----------------------------------------------------------------------===//
@@ -202,13 +209,23 @@
 extern "C" __declspec(dllimport) void externC();
 
 // Import inline function.
+#ifdef GNU
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+#endif
 __declspec(dllimport) inline void inlineFunc1() {}
 inline void __attribute__((dllimport)) inlineFunc2() {}
 
+#ifdef GNU
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 __declspec(dllimport) inline void inlineDecl();
                              void inlineDecl() {}
 
 __declspec(dllimport) void inlineDef();
+#ifdef GNU
+// expected-warning@+2{{'inlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
                inline void inlineDef() {}
 
 // Redeclarations
@@ -224,10 +241,20 @@
                       void redecl3() {} // expected-warning{{'redecl3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
 
                       void redecl4(); // expected-note{{previous declaration is here}}
-__declspec(dllimport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllimport' attribute}}
+__declspec(dllimport) void redecl4(); // expected-warning{{redeclaration of 'redecl4' should not add 'dllimport' attribute}}
 
+extern "C" {
                       void redecl5(); // expected-note{{previous declaration is here}}
-__declspec(dllimport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllimport' attribute}}
+__declspec(dllimport) void redecl5(); // expected-warning{{redeclaration of 'redecl5' should not add 'dllimport' attribute}}
+}
+
+#ifdef MS
+                      void redecl6(); // expected-note{{previous declaration is here}}
+__declspec(dllimport) inline void redecl6() {} // expected-warning{{redeclaration of 'redecl6' should not add 'dllimport' attribute}}
+#else
+                      void redecl6();
+__declspec(dllimport) inline void redecl6() {} // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
 
 // Friend functions
 struct FuncFriend {
@@ -235,13 +262,28 @@
   friend __declspec(dllimport) void friend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   friend __declspec(dllimport) void friend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   friend                       void friend4(); // expected-note{{previous declaration is here}}
-  friend                       void friend5(); // expected-note{{previous declaration is here}}
+#ifdef MS
+// expected-note@+2{{previous declaration is here}}
+#endif
+  friend                       void friend5();
 };
 __declspec(dllimport) void friend1();
                       void friend2(); // expected-warning{{'friend2' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
                       void friend3() {} // expected-warning{{'friend3' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
-__declspec(dllimport) void friend4(); // expected-error{{redeclaration of 'friend4' cannot add 'dllimport' attribute}}
-__declspec(dllimport) inline void friend5() {} // expected-error{{redeclaration of 'friend5' cannot add 'dllimport' attribute}}
+__declspec(dllimport) void friend4(); // expected-warning{{redeclaration of 'friend4' should not add 'dllimport' attribute}}
+#ifdef MS
+__declspec(dllimport) inline void friend5() {} // expected-warning{{redeclaration of 'friend5' should not add 'dllimport' attribute}}
+#else
+__declspec(dllimport) inline void friend5() {} // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
+
+
+void __declspec(dllimport) friend6(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
+void __declspec(dllimport) friend7();
+struct FuncFriend2 {
+  friend void friend6(); // expected-warning{{'friend6' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+  friend void ::friend7();
+};
 
 // Implicit declarations can be redeclared with dllimport.
 __declspec(dllimport) void* operator new(__SIZE_TYPE__ n);
@@ -257,7 +299,11 @@
 // here which is irrelevant. But because the delete keyword is parsed later
 // there is currently no straight-forward way to avoid this diagnostic.
 __declspec(dllimport) void deletedFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}} expected-error{{dllimport cannot be applied to non-inline function definition}}
+#ifdef MS
 __declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
+#else
+__declspec(dllimport) inline void deletedInlineFunc() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
 
 
 
@@ -273,6 +319,12 @@
 template<typename T> __declspec(dllimport) void funcTmplDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
 
 // Import inline function template.
+#ifdef GNU
+// expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+6{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+9{{'inlineFuncTmplDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 template<typename T> __declspec(dllimport) inline void inlineFuncTmpl1() {}
 template<typename T> inline void __attribute__((dllimport)) inlineFuncTmpl2() {}
 
@@ -295,8 +347,10 @@
 template<typename T>                       void funcTmplRedecl4(); // expected-note{{previous declaration is here}}
 template<typename T> __declspec(dllimport) void funcTmplRedecl4(); // expected-error{{redeclaration of 'funcTmplRedecl4' cannot add 'dllimport' attribute}}
 
+#ifdef MS
 template<typename T>                       void funcTmplRedecl5(); // expected-note{{previous declaration is here}}
 template<typename T> __declspec(dllimport) inline void funcTmplRedecl5() {} // expected-error{{redeclaration of 'funcTmplRedecl5' cannot add 'dllimport' attribute}}
+#endif
 
 // Function template friends
 struct FuncTmplFriend {
@@ -304,6 +358,9 @@
   template<typename T> friend __declspec(dllimport) void funcTmplFriend2(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   template<typename T> friend __declspec(dllimport) void funcTmplFriend3(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   template<typename T> friend                       void funcTmplFriend4(); // expected-note{{previous declaration is here}}
+#ifdef GNU
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
   template<typename T> friend __declspec(dllimport) inline void funcTmplFriend5();
 };
 template<typename T> __declspec(dllimport) void funcTmplFriend1();
@@ -322,6 +379,9 @@
 template<typename T> void funcTmpl() {}
 template<typename T> inline void inlineFuncTmpl() {}
 template<typename T> __declspec(dllimport) void importedFuncTmplDecl();
+#ifdef GNU
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template<typename T> __declspec(dllimport) inline void importedFuncTmpl() {}
 
 // Import implicit instantiation of an imported function template.
@@ -340,7 +400,9 @@
 // declared inline.
 template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Imported>();
 template<> __declspec(dllimport) void importedFuncTmpl<ExplicitSpec_Def_Imported>() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
+#ifdef MS
 template<> __declspec(dllimport) inline void importedFuncTmpl<ExplicitSpec_InlineDef_Imported>() {}
+#endif
 
 // Not importing specialization of an imported function template without
 // explicit dllimport.
@@ -349,16 +411,25 @@
 
 // Import explicit instantiation declaration of a non-imported function template.
 extern template __declspec(dllimport) void funcTmpl<ExplicitDecl_Imported>();
+#ifdef GNU
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 extern template __declspec(dllimport) void inlineFuncTmpl<ExplicitDecl_Imported>();
 
 // Import explicit instantiation definition of a non-imported function template.
 template __declspec(dllimport) void funcTmpl<ExplicitInst_Imported>();
+#ifdef GNU
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template __declspec(dllimport) void inlineFuncTmpl<ExplicitInst_Imported>();
 
 // Import specialization of a non-imported function template. A definition must
 // be declared inline.
 template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Imported>();
 template<> __declspec(dllimport) void funcTmpl<ExplicitSpec_Def_Imported>() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
+#ifdef GNU
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template<> __declspec(dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {}
 
 
@@ -373,16 +444,28 @@
     __declspec(dllimport) void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   };
 
+#ifdef GNU
+// expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+6{{'dllimport' attribute ignored on inline function}}
+#endif
   __declspec(dllimport)                void normalDecl();
   __declspec(dllimport)                void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   __declspec(dllimport)                void normalInclass() {}
   __declspec(dllimport)                void normalInlineDef();
   __declspec(dllimport)         inline void normalInlineDecl();
+#ifdef GNU
+// expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+6{{'dllimport' attribute ignored on inline function}}
+#endif
   __declspec(dllimport) virtual        void virtualDecl();
   __declspec(dllimport) virtual        void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   __declspec(dllimport) virtual        void virtualInclass() {}
   __declspec(dllimport) virtual        void virtualInlineDef();
   __declspec(dllimport) virtual inline void virtualInlineDecl();
+#ifdef GNU
+// expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+6{{'dllimport' attribute ignored on inline function}}
+#endif
   __declspec(dllimport) static         void staticDecl();
   __declspec(dllimport) static         void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
   __declspec(dllimport) static         void staticInclass() {}
@@ -408,12 +491,21 @@
 
        void ImportMembers::Nested::normalDef() {} // expected-warning{{'ImportMembers::Nested::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
        void ImportMembers::normalDef() {} // expected-warning{{'ImportMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+#ifdef GNU
+// expected-warning@+2{{'ImportMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 inline void ImportMembers::normalInlineDef() {}
        void ImportMembers::normalInlineDecl() {}
        void ImportMembers::virtualDef() {} // expected-warning{{'ImportMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+#ifdef GNU
+// expected-warning@+2{{'ImportMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 inline void ImportMembers::virtualInlineDef() {}
        void ImportMembers::virtualInlineDecl() {}
        void ImportMembers::staticDef() {} // expected-warning{{'ImportMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+#ifdef GNU
+// expected-warning@+2{{'ImportMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 inline void ImportMembers::staticInlineDef() {}
        void ImportMembers::staticInlineDecl() {}
 
@@ -426,13 +518,15 @@
 struct ImportMemberDefs {
   __declspec(dllimport)                void normalDef();
   __declspec(dllimport)                void normalInlineDef();
-  __declspec(dllimport)         inline void normalInlineDecl();
   __declspec(dllimport) virtual        void virtualDef();
   __declspec(dllimport) virtual        void virtualInlineDef();
-  __declspec(dllimport) virtual inline void virtualInlineDecl();
   __declspec(dllimport) static         void staticDef();
   __declspec(dllimport) static         void staticInlineDef();
+#ifdef MS
+  __declspec(dllimport)         inline void normalInlineDecl();
+  __declspec(dllimport) virtual inline void virtualInlineDecl();
   __declspec(dllimport) static  inline void staticInlineDecl();
+#endif
 
   __declspec(dllimport) static         int  StaticField;
   __declspec(dllimport) static  const  int  StaticConstField;
@@ -440,14 +534,16 @@
 };
 
 __declspec(dllimport)        void ImportMemberDefs::normalDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
+__declspec(dllimport)        void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
+__declspec(dllimport)        void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
+#ifdef MS
 __declspec(dllimport) inline void ImportMemberDefs::normalInlineDef() {}
 __declspec(dllimport)        void ImportMemberDefs::normalInlineDecl() {}
-__declspec(dllimport)        void ImportMemberDefs::virtualDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
 __declspec(dllimport) inline void ImportMemberDefs::virtualInlineDef() {}
 __declspec(dllimport)        void ImportMemberDefs::virtualInlineDecl() {}
-__declspec(dllimport)        void ImportMemberDefs::staticDef() {} // expected-error{{dllimport cannot be applied to non-inline function definition}}
 __declspec(dllimport) inline void ImportMemberDefs::staticInlineDef() {}
 __declspec(dllimport)        void ImportMemberDefs::staticInlineDecl() {}
+#endif
 
 __declspec(dllimport)        int  ImportMemberDefs::StaticField; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
 __declspec(dllimport) const  int  ImportMemberDefs::StaticConstField = 1; // expected-error{{definition of dllimport static field not allowed}} expected-note{{attribute is here}}
@@ -467,6 +563,7 @@
 
 // Import deleted member functions.
 struct ImportDeleted {
+#ifdef MS
   __declspec(dllimport) ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
   __declspec(dllimport) ~ImportDeleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
   __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
@@ -474,6 +571,15 @@
   __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
   __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
   __declspec(dllimport) void deleted() = delete; // expected-error{{attribute 'dllimport' cannot be applied to a deleted function}}
+#else
+  __declspec(dllimport) ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+  __declspec(dllimport) ~ImportDeleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+  __declspec(dllimport) ImportDeleted(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+  __declspec(dllimport) ImportDeleted& operator=(const ImportDeleted&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+  __declspec(dllimport) ImportDeleted(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+  __declspec(dllimport) ImportDeleted& operator=(ImportDeleted&&) = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+  __declspec(dllimport) void deleted() = delete; // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
 };
 
 
@@ -488,6 +594,14 @@
 
 // Import defaulted member functions.
 struct ImportDefaulted {
+#ifdef GNU
+  // expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+#endif
   __declspec(dllimport) ImportDefaulted() = default;
   __declspec(dllimport) ~ImportDefaulted() = default;
   __declspec(dllimport) ImportDefaulted(const ImportDefaulted&) = default;
@@ -502,6 +616,10 @@
   __declspec(dllimport) ImportDefaultedDefs();
   __declspec(dllimport) ~ImportDefaultedDefs(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
 
+#ifdef GNU
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+// expected-note@+2{{previous declaration is here}}
+#endif
   __declspec(dllimport) inline ImportDefaultedDefs(const ImportDefaultedDefs&);
   __declspec(dllimport) ImportDefaultedDefs& operator=(const ImportDefaultedDefs&);
 
@@ -516,6 +634,10 @@
 ImportDefaultedDefs::~ImportDefaultedDefs() = default; // expected-warning{{'ImportDefaultedDefs::~ImportDefaultedDefs' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
 
 // Import inline declaration and definition.
+#ifdef GNU
+// expected-error@+3{{redeclaration of 'ImportDefaultedDefs::ImportDefaultedDefs' cannot add 'dllimport' attribute}}
+// expected-warning@+3{{'ImportDefaultedDefs::operator=' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 __declspec(dllimport) ImportDefaultedDefs::ImportDefaultedDefs(const ImportDefaultedDefs&) = default;
 inline ImportDefaultedDefs& ImportDefaultedDefs::operator=(const ImportDefaultedDefs&) = default;
 
@@ -526,15 +648,21 @@
 // Redeclarations cannot add dllimport.
 struct MemberRedecl {
                  void normalDef();         // expected-note{{previous declaration is here}}
-                 void normalInlineDef();   // expected-note{{previous declaration is here}}
           inline void normalInlineDecl();  // expected-note{{previous declaration is here}}
   virtual        void virtualDef();        // expected-note{{previous declaration is here}}
-  virtual        void virtualInlineDef();  // expected-note{{previous declaration is here}}
   virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}}
   static         void staticDef();         // expected-note{{previous declaration is here}}
-  static         void staticInlineDef();   // expected-note{{previous declaration is here}}
   static  inline void staticInlineDecl();  // expected-note{{previous declaration is here}}
 
+#ifdef MS
+  // expected-note@+4{{previous declaration is here}}
+  // expected-note@+4{{previous declaration is here}}
+  // expected-note@+4{{previous declaration is here}}
+#endif
+                 void normalInlineDef();
+  virtual        void virtualInlineDef();
+  static         void staticInlineDef();
+
   static         int  StaticField;         // expected-note{{previous declaration is here}}
   static  const  int  StaticConstField;    // expected-note{{previous declaration is here}}
   constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
@@ -542,17 +670,26 @@
 
 __declspec(dllimport)        void MemberRedecl::normalDef() {}         // expected-error{{redeclaration of 'MemberRedecl::normalDef' cannot add 'dllimport' attribute}}
                                                                        // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-__declspec(dllimport) inline void MemberRedecl::normalInlineDef() {}   // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}}
 __declspec(dllimport)        void MemberRedecl::normalInlineDecl() {}  // expected-error{{redeclaration of 'MemberRedecl::normalInlineDecl' cannot add 'dllimport' attribute}}
 __declspec(dllimport)        void MemberRedecl::virtualDef() {}        // expected-error{{redeclaration of 'MemberRedecl::virtualDef' cannot add 'dllimport' attribute}}
                                                                        // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-__declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {}  // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}}
 __declspec(dllimport)        void MemberRedecl::virtualInlineDecl() {} // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDecl' cannot add 'dllimport' attribute}}
 __declspec(dllimport)        void MemberRedecl::staticDef() {}         // expected-error{{redeclaration of 'MemberRedecl::staticDef' cannot add 'dllimport' attribute}}
                                                                        // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-__declspec(dllimport) inline void MemberRedecl::staticInlineDef() {}   // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}}
 __declspec(dllimport)        void MemberRedecl::staticInlineDecl() {}  // expected-error{{redeclaration of 'MemberRedecl::staticInlineDecl' cannot add 'dllimport' attribute}}
 
+#ifdef MS
+__declspec(dllimport) inline void MemberRedecl::normalInlineDef() {}   // expected-error{{redeclaration of 'MemberRedecl::normalInlineDef' cannot add 'dllimport' attribute}}
+__declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {}  // expected-error{{redeclaration of 'MemberRedecl::virtualInlineDef' cannot add 'dllimport' attribute}}
+__declspec(dllimport) inline void MemberRedecl::staticInlineDef() {}   // expected-error{{redeclaration of 'MemberRedecl::staticInlineDef' cannot add 'dllimport' attribute}}
+#else
+__declspec(dllimport) inline void MemberRedecl::normalInlineDef() {}   // expected-warning{{'dllimport' attribute ignored on inline function}}
+__declspec(dllimport) inline void MemberRedecl::virtualInlineDef() {}  // expected-warning{{'dllimport' attribute ignored on inline function}}
+__declspec(dllimport) inline void MemberRedecl::staticInlineDef() {}   // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
+
+
+
 __declspec(dllimport)        int  MemberRedecl::StaticField = 1;       // expected-error{{redeclaration of 'MemberRedecl::StaticField' cannot add 'dllimport' attribute}}
                                                                        // expected-error@-1{{definition of dllimport static field not allowed}}
                                                                        // expected-note@-2{{attribute is here}}
@@ -572,13 +709,20 @@
 struct ImportMemberTmpl {
   template<typename T> __declspec(dllimport)               void normalDecl();
   template<typename T> __declspec(dllimport)               void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  template<typename T> __declspec(dllimport)               void normalInclass() {}
   template<typename T> __declspec(dllimport)               void normalInlineDef();
-  template<typename T> __declspec(dllimport)        inline void normalInlineDecl();
   template<typename T> __declspec(dllimport) static        void staticDecl();
   template<typename T> __declspec(dllimport) static        void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  template<typename T> __declspec(dllimport) static        void staticInclass() {}
   template<typename T> __declspec(dllimport) static        void staticInlineDef();
+
+#ifdef GNU
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+#endif
+  template<typename T> __declspec(dllimport)               void normalInclass() {}
+  template<typename T> __declspec(dllimport)        inline void normalInlineDecl();
+  template<typename T> __declspec(dllimport) static        void staticInclass() {}
   template<typename T> __declspec(dllimport) static inline void staticInlineDecl();
 
 #if __has_feature(cxx_variable_templates)
@@ -594,12 +738,17 @@
 };
 
 template<typename T>        void ImportMemberTmpl::normalDef() {} // expected-warning{{'ImportMemberTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
-template<typename T> inline void ImportMemberTmpl::normalInlineDef() {}
 template<typename T>        void ImportMemberTmpl::normalInlineDecl() {}
 template<typename T>        void ImportMemberTmpl::staticDef() {} // expected-warning{{'ImportMemberTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
-template<typename T> inline void ImportMemberTmpl::staticInlineDef() {}
 template<typename T>        void ImportMemberTmpl::staticInlineDecl() {}
 
+#ifdef GNU
+// expected-warning@+3{{ImportMemberTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+// expected-warning@+3{{ImportMemberTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
+template<typename T> inline void ImportMemberTmpl::normalInlineDef() {}
+template<typename T> inline void ImportMemberTmpl::staticInlineDef() {}
+
 #if __has_feature(cxx_variable_templates)
 template<typename T>        int  ImportMemberTmpl::StaticFieldDef; // expected-error{{definition of dllimport static field not allowed}}
 template<typename T> const  int  ImportMemberTmpl::StaticConstFieldDef = 1; // expected-error{{definition of dllimport static field not allowed}}
@@ -610,12 +759,17 @@
 // Redeclarations cannot add dllimport.
 struct MemTmplRedecl {
   template<typename T>               void normalDef();         // expected-note{{previous declaration is here}}
-  template<typename T>               void normalInlineDef();   // expected-note{{previous declaration is here}}
   template<typename T>        inline void normalInlineDecl();  // expected-note{{previous declaration is here}}
   template<typename T> static        void staticDef();         // expected-note{{previous declaration is here}}
-  template<typename T> static        void staticInlineDef();   // expected-note{{previous declaration is here}}
   template<typename T> static inline void staticInlineDecl();  // expected-note{{previous declaration is here}}
 
+#ifdef MS
+// expected-note@+3{{previous declaration is here}}
+// expected-note@+3{{previous declaration is here}}
+#endif
+  template<typename T>               void normalInlineDef();
+  template<typename T> static        void staticInlineDef();
+
 #if __has_feature(cxx_variable_templates)
   template<typename T> static        int  StaticField;         // expected-note{{previous declaration is here}}
   template<typename T> static const  int  StaticConstField;    // expected-note{{previous declaration is here}}
@@ -625,11 +779,19 @@
 
 template<typename T> __declspec(dllimport)        void MemTmplRedecl::normalDef() {}        // expected-error{{redeclaration of 'MemTmplRedecl::normalDef' cannot add 'dllimport' attribute}}
                                                                                             // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
+#ifdef MS
 template<typename T> __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {}  // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDef' cannot add 'dllimport' attribute}}
+#else
+template<typename T> __declspec(dllimport) inline void MemTmplRedecl::normalInlineDef() {}  // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
 template<typename T> __declspec(dllimport)        void MemTmplRedecl::normalInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::normalInlineDecl' cannot add 'dllimport' attribute}}
 template<typename T> __declspec(dllimport)        void MemTmplRedecl::staticDef() {}        // expected-error{{redeclaration of 'MemTmplRedecl::staticDef' cannot add 'dllimport' attribute}}
                                                                                             // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
+#ifdef MS
 template<typename T> __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {}  // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDef' cannot add 'dllimport' attribute}}
+#else
+template<typename T> __declspec(dllimport) inline void MemTmplRedecl::staticInlineDef() {}  // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
 template<typename T> __declspec(dllimport)        void MemTmplRedecl::staticInlineDecl() {} // expected-error{{redeclaration of 'MemTmplRedecl::staticInlineDecl' cannot add 'dllimport' attribute}}
 
 #if __has_feature(cxx_variable_templates)
@@ -648,8 +810,14 @@
 
 struct MemFunTmpl {
   template<typename T>                              void normalDef() {}
+#ifdef GNU
+  // expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
   template<typename T> __declspec(dllimport)        void importedNormal() {}
   template<typename T>                       static void staticDef() {}
+#ifdef GNU
+  // expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
   template<typename T> __declspec(dllimport) static void importedStatic() {}
 };
 
@@ -673,16 +841,24 @@
 // Import specialization of an imported member function template.
 template<> __declspec(dllimport) void MemFunTmpl::importedNormal<ExplicitSpec_Imported>();
 template<> __declspec(dllimport) void MemFunTmpl::importedNormal<ExplicitSpec_Def_Imported>() {} // error on mingw
+#ifdef GNU
+  // expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template<> __declspec(dllimport) inline void MemFunTmpl::importedNormal<ExplicitSpec_InlineDef_Imported>() {}
-#ifndef MSABI
-// expected-error@-3{{dllimport cannot be applied to non-inline function definition}}
+#if 1
+// FIXME: This should not be an error when targeting MSVC. (PR21406)
+// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
 #endif
 
 template<> __declspec(dllimport) void MemFunTmpl::importedStatic<ExplicitSpec_Imported>();
 template<> __declspec(dllimport) void MemFunTmpl::importedStatic<ExplicitSpec_Def_Imported>() {} // error on mingw
+#ifdef GNU
+  // expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template<> __declspec(dllimport) inline void MemFunTmpl::importedStatic<ExplicitSpec_InlineDef_Imported>() {}
-#ifndef MSABI
-// expected-error@-3{{dllimport cannot be applied to non-inline function definition}}
+#if 1
+// FIXME: This should not be an error when targeting MSVC. (PR21406)
+// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
 #endif
 
 // Not importing specialization of an imported member function template without
@@ -693,27 +869,43 @@
 
 // Import explicit instantiation declaration of a non-imported member function
 // template.
+#ifdef GNU
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+#endif
 extern template __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitDecl_Imported>();
 extern template __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitDecl_Imported>();
 
 // Import explicit instantiation definition of a non-imported member function
 // template.
+#ifdef GNU
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+3{{'dllimport' attribute ignored on inline function}}
+#endif
 template __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitInst_Imported>();
 template __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitInst_Imported>();
 
 // Import specialization of a non-imported member function template.
 template<> __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitSpec_Imported>();
 template<> __declspec(dllimport) void MemFunTmpl::normalDef<ExplicitSpec_Def_Imported>() {} // error on mingw
+#ifdef GNU
+  // expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template<> __declspec(dllimport) inline void MemFunTmpl::normalDef<ExplicitSpec_InlineDef_Imported>() {}
-#ifndef MSABI
-// expected-error@-3{{dllimport cannot be applied to non-inline function definition}}
+#if 1
+// FIXME: This should not be an error when targeting MSVC. (PR21406)
+// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
 #endif
 
 template<> __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitSpec_Imported>();
 template<> __declspec(dllimport) void MemFunTmpl::staticDef<ExplicitSpec_Def_Imported>() {} // error on mingw
+#ifdef GNU
+  // expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
 template<> __declspec(dllimport) inline void MemFunTmpl::staticDef<ExplicitSpec_InlineDef_Imported>() {}
-#ifndef MSABI
-// expected-error@-3{{dllimport cannot be applied to non-inline function definition}}
+#if 1
+// FIXME: This should not be an error when targeting MSVC. (PR21406)
+// expected-error@-7{{dllimport cannot be applied to non-inline function definition}}
 #endif
 
 
@@ -773,18 +965,27 @@
 struct ImportClassTmplMembers {
   __declspec(dllimport)                void normalDecl();
   __declspec(dllimport)                void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  __declspec(dllimport)                void normalInclass() {}
   __declspec(dllimport)                void normalInlineDef();
-  __declspec(dllimport)         inline void normalInlineDecl();
   __declspec(dllimport) virtual        void virtualDecl();
   __declspec(dllimport) virtual        void virtualDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  __declspec(dllimport) virtual        void virtualInclass() {}
   __declspec(dllimport) virtual        void virtualInlineDef();
-  __declspec(dllimport) virtual inline void virtualInlineDecl();
   __declspec(dllimport) static         void staticDecl();
   __declspec(dllimport) static         void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  __declspec(dllimport) static         void staticInclass() {}
   __declspec(dllimport) static         void staticInlineDef();
+
+#ifdef GNU
+// expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+// expected-warning@+7{{'dllimport' attribute ignored on inline function}}
+#endif
+  __declspec(dllimport)                void normalInclass() {}
+  __declspec(dllimport)         inline void normalInlineDecl();
+  __declspec(dllimport) virtual        void virtualInclass() {}
+  __declspec(dllimport) virtual inline void virtualInlineDecl();
+  __declspec(dllimport) static         void staticInclass() {}
   __declspec(dllimport) static  inline void staticInlineDecl();
 
 protected:
@@ -807,12 +1008,21 @@
 // NB: MSVC is inconsistent here and disallows *InlineDef on class templates,
 // but allows it on classes. We allow both.
 template<typename T>        void ImportClassTmplMembers<T>::normalDef() {} // expected-warning{{'ImportClassTmplMembers::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+#ifdef GNU
+// expected-warning@+2{{'ImportClassTmplMembers::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 template<typename T> inline void ImportClassTmplMembers<T>::normalInlineDef() {}
 template<typename T>        void ImportClassTmplMembers<T>::normalInlineDecl() {}
 template<typename T>        void ImportClassTmplMembers<T>::virtualDef() {} // expected-warning{{'ImportClassTmplMembers::virtualDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+#ifdef GNU
+// expected-warning@+2{{'ImportClassTmplMembers::virtualInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 template<typename T> inline void ImportClassTmplMembers<T>::virtualInlineDef() {}
 template<typename T>        void ImportClassTmplMembers<T>::virtualInlineDecl() {}
 template<typename T>        void ImportClassTmplMembers<T>::staticDef() {} // expected-warning{{'ImportClassTmplMembers::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
+#ifdef GNU
+// expected-warning@+2{{'ImportClassTmplMembers::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
 template<typename T> inline void ImportClassTmplMembers<T>::staticInlineDef() {}
 template<typename T>        void ImportClassTmplMembers<T>::staticInlineDecl() {}
 
@@ -825,15 +1035,21 @@
 template<typename T>
 struct CTMR /*ClassTmplMemberRedecl*/ {
                  void normalDef();         // expected-note{{previous declaration is here}}
-                 void normalInlineDef();   // expected-note{{previous declaration is here}}
           inline void normalInlineDecl();  // expected-note{{previous declaration is here}}
   virtual        void virtualDef();        // expected-note{{previous declaration is here}}
-  virtual        void virtualInlineDef();  // expected-note{{previous declaration is here}}
   virtual inline void virtualInlineDecl(); // expected-note{{previous declaration is here}}
   static         void staticDef();         // expected-note{{previous declaration is here}}
-  static         void staticInlineDef();   // expected-note{{previous declaration is here}}
   static  inline void staticInlineDecl();  // expected-note{{previous declaration is here}}
 
+#ifdef MS
+// expected-note@+4{{previous declaration is here}}
+// expected-note@+4{{previous declaration is here}}
+// expected-note@+4{{previous declaration is here}}
+#endif
+                 void normalInlineDef();
+  virtual        void virtualInlineDef();
+  static         void staticInlineDef();
+
   static         int  StaticField;         // expected-note{{previous declaration is here}}
   static  const  int  StaticConstField;    // expected-note{{previous declaration is here}}
   constexpr static int ConstexprField = 1; // expected-note{{previous declaration is here}}
@@ -841,17 +1057,24 @@
 
 template<typename T> __declspec(dllimport)        void CTMR<T>::normalDef() {}         // expected-error{{redeclaration of 'CTMR::normalDef' cannot add 'dllimport' attribute}}
                                                                                        // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-template<typename T> __declspec(dllimport) inline void CTMR<T>::normalInlineDef() {}   // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}}
 template<typename T> __declspec(dllimport)        void CTMR<T>::normalInlineDecl() {}  // expected-error{{redeclaration of 'CTMR::normalInlineDecl' cannot add 'dllimport' attribute}}
 template<typename T> __declspec(dllimport)        void CTMR<T>::virtualDef() {}        // expected-error{{redeclaration of 'CTMR::virtualDef' cannot add 'dllimport' attribute}}
                                                                                        // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-template<typename T> __declspec(dllimport) inline void CTMR<T>::virtualInlineDef() {}  // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}}
 template<typename T> __declspec(dllimport)        void CTMR<T>::virtualInlineDecl() {} // expected-error{{redeclaration of 'CTMR::virtualInlineDecl' cannot add 'dllimport' attribute}}
 template<typename T> __declspec(dllimport)        void CTMR<T>::staticDef() {}         // expected-error{{redeclaration of 'CTMR::staticDef' cannot add 'dllimport' attribute}}
                                                                                        // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-template<typename T> __declspec(dllimport) inline void CTMR<T>::staticInlineDef() {}   // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}}
 template<typename T> __declspec(dllimport)        void CTMR<T>::staticInlineDecl() {}  // expected-error{{redeclaration of 'CTMR::staticInlineDecl' cannot add 'dllimport' attribute}}
 
+#ifdef MS
+template<typename T> __declspec(dllimport) inline void CTMR<T>::normalInlineDef() {}   // expected-error{{redeclaration of 'CTMR::normalInlineDef' cannot add 'dllimport' attribute}}
+template<typename T> __declspec(dllimport) inline void CTMR<T>::virtualInlineDef() {}  // expected-error{{redeclaration of 'CTMR::virtualInlineDef' cannot add 'dllimport' attribute}}
+template<typename T> __declspec(dllimport) inline void CTMR<T>::staticInlineDef() {}   // expected-error{{redeclaration of 'CTMR::staticInlineDef' cannot add 'dllimport' attribute}}
+#else
+template<typename T> __declspec(dllimport) inline void CTMR<T>::normalInlineDef() {}   // expected-warning{{'dllimport' attribute ignored on inline function}}
+template<typename T> __declspec(dllimport) inline void CTMR<T>::virtualInlineDef() {}  // expected-warning{{'dllimport' attribute ignored on inline function}}
+template<typename T> __declspec(dllimport) inline void CTMR<T>::staticInlineDef() {}   // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
+
 template<typename T> __declspec(dllimport)        int  CTMR<T>::StaticField = 1;       // expected-error{{redeclaration of 'CTMR::StaticField' cannot add 'dllimport' attribute}}
                                                                                        // expected-warning@-1{{definition of dllimport static field}}
                                                                                        // expected-note@-2{{attribute is here}}
@@ -872,13 +1095,20 @@
 struct ImportClsTmplMemTmpl {
   template<typename U> __declspec(dllimport)               void normalDecl();
   template<typename U> __declspec(dllimport)               void normalDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  template<typename U> __declspec(dllimport)               void normalInclass() {}
   template<typename U> __declspec(dllimport)               void normalInlineDef();
-  template<typename U> __declspec(dllimport)        inline void normalInlineDecl();
   template<typename U> __declspec(dllimport) static        void staticDecl();
   template<typename U> __declspec(dllimport) static        void staticDef(); // expected-note{{previous declaration is here}} expected-note{{previous attribute is here}}
-  template<typename U> __declspec(dllimport) static        void staticInclass() {}
   template<typename U> __declspec(dllimport) static        void staticInlineDef();
+
+#ifdef GNU
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+  // expected-warning@+5{{'dllimport' attribute ignored on inline function}}
+#endif
+  template<typename U> __declspec(dllimport)               void normalInclass() {}
+  template<typename U> __declspec(dllimport)        inline void normalInlineDecl();
+  template<typename U> __declspec(dllimport) static        void staticInclass() {}
   template<typename U> __declspec(dllimport) static inline void staticInlineDecl();
 
 #if __has_feature(cxx_variable_templates)
@@ -894,12 +1124,17 @@
 };
 
 template<typename T> template<typename U>        void ImportClsTmplMemTmpl<T>::normalDef() {} // expected-warning{{'ImportClsTmplMemTmpl::normalDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
-template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::normalInlineDef() {}
 template<typename T> template<typename U>        void ImportClsTmplMemTmpl<T>::normalInlineDecl() {}
 template<typename T> template<typename U>        void ImportClsTmplMemTmpl<T>::staticDef() {} // expected-warning{{'ImportClsTmplMemTmpl::staticDef' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
-template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::staticInlineDef() {}
 template<typename T> template<typename U>        void ImportClsTmplMemTmpl<T>::staticInlineDecl() {}
 
+#ifdef GNU
+// expected-warning@+3{{'ImportClsTmplMemTmpl::normalInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+// expected-warning@+3{{'ImportClsTmplMemTmpl::staticInlineDef' redeclared inline; 'dllimport' attribute ignored}}
+#endif
+template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::normalInlineDef() {}
+template<typename T> template<typename U> inline void ImportClsTmplMemTmpl<T>::staticInlineDef() {}
+
 #if __has_feature(cxx_variable_templates)
 template<typename T> template<typename U>        int  ImportClsTmplMemTmpl<T>::StaticFieldDef; // expected-warning{{definition of dllimport static field}}
 template<typename T> template<typename U> const  int  ImportClsTmplMemTmpl<T>::StaticConstFieldDef = 1; // expected-warning{{definition of dllimport static field}}
@@ -911,12 +1146,17 @@
 template<typename T>
 struct CTMTR /*ClassTmplMemberTmplRedecl*/ {
   template<typename U>               void normalDef();         // expected-note{{previous declaration is here}}
-  template<typename U>               void normalInlineDef();   // expected-note{{previous declaration is here}}
   template<typename U>        inline void normalInlineDecl();  // expected-note{{previous declaration is here}}
   template<typename U> static        void staticDef();         // expected-note{{previous declaration is here}}
-  template<typename U> static        void staticInlineDef();   // expected-note{{previous declaration is here}}
   template<typename U> static inline void staticInlineDecl();  // expected-note{{previous declaration is here}}
 
+#ifdef MS
+  // expected-note@+3{{previous declaration is here}}
+  // expected-note@+3{{previous declaration is here}}
+#endif
+  template<typename U>               void normalInlineDef();
+  template<typename U> static        void staticInlineDef();
+
 #if __has_feature(cxx_variable_templates)
   template<typename U> static        int  StaticField;         // expected-note{{previous declaration is here}}
   template<typename U> static const  int  StaticConstField;    // expected-note{{previous declaration is here}}
@@ -926,13 +1166,19 @@
 
 template<typename T> template<typename U> __declspec(dllimport)        void CTMTR<T>::normalDef() {}         // expected-error{{redeclaration of 'CTMTR::normalDef' cannot add 'dllimport' attribute}}
                                                                                                              // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::normalInlineDef() {}   // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}}
 template<typename T> template<typename U> __declspec(dllimport)        void CTMTR<T>::normalInlineDecl() {}  // expected-error{{redeclaration of 'CTMTR::normalInlineDecl' cannot add 'dllimport' attribute}}
 template<typename T> template<typename U> __declspec(dllimport)        void CTMTR<T>::staticDef() {}         // expected-error{{redeclaration of 'CTMTR::staticDef' cannot add 'dllimport' attribute}}
                                                                                                              // expected-error@-1{{dllimport cannot be applied to non-inline function definition}}
-template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::staticInlineDef() {}   // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}}
 template<typename T> template<typename U> __declspec(dllimport)        void CTMTR<T>::staticInlineDecl() {}  // expected-error{{redeclaration of 'CTMTR::staticInlineDecl' cannot add 'dllimport' attribute}}
 
+#ifdef MS
+template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::normalInlineDef() {}   // expected-error{{redeclaration of 'CTMTR::normalInlineDef' cannot add 'dllimport' attribute}}
+template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::staticInlineDef() {}   // expected-error{{redeclaration of 'CTMTR::staticInlineDef' cannot add 'dllimport' attribute}}
+#else
+template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::normalInlineDef() {}   // expected-warning{{'dllimport' attribute ignored on inline function}}
+template<typename T> template<typename U> __declspec(dllimport) inline void CTMTR<T>::staticInlineDef() {}   // expected-warning{{'dllimport' attribute ignored on inline function}}
+#endif
+
 #if __has_feature(cxx_variable_templates)
 template<typename T> template<typename U> __declspec(dllimport)        int  CTMTR<T>::StaticField = 1;       // expected-error{{redeclaration of 'CTMTR::StaticField' cannot add 'dllimport' attribute}}
                                                                                                              // expected-warning@-1{{definition of dllimport static field}}
@@ -951,6 +1197,10 @@
 // Classes
 //===----------------------------------------------------------------------===//
 
+namespace {
+  struct __declspec(dllimport) AnonymousClass {}; // expected-error{{(anonymous namespace)::AnonymousClass' must have external linkage when declared 'dllimport'}}
+}
+
 class __declspec(dllimport) ClassDecl;
 
 class __declspec(dllimport) ClassDef { };
@@ -974,7 +1224,7 @@
 // expected-error@+4{{attribute 'dllimport' cannot be applied to member of 'dllexport' class}}
 // expected-error@+4{{attribute 'dllexport' cannot be applied to member of 'dllexport' class}}
 #endif
-class __declspec(dllexport) ExportClassWithDllMember {
+template <typename T> class __declspec(dllexport) ExportClassWithDllMember {
   void __declspec(dllimport) foo();
   void __declspec(dllexport) bar();
 };
@@ -1026,7 +1276,7 @@
 
 #ifdef MS
 // expected-note@+4{{class template 'ClassTemplate<double>' was instantiated here}}
-// expected-warning@+4{{propagating dll attribute to already instantiated base class template without dll attribute is unsupported}}
+// expected-warning@+4{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}}
 // expected-note@+3{{attribute is here}}
 #endif
 class DerivedFromTemplateD : public ClassTemplate<double> {};
@@ -1034,7 +1284,7 @@
 
 #ifdef MS
 // expected-note@+4{{class template 'ClassTemplate<bool>' was instantiated here}}
-// expected-warning@+4{{propagating dll attribute to already instantiated base class template with different dll attribute is unsupported}}
+// expected-warning@+4{{propagating dll attribute to already instantiated base class template with different dll attribute is not supported}}
 // expected-note@+3{{attribute is here}}
 #endif
 class __declspec(dllexport) DerivedFromTemplateB : public ClassTemplate<bool> {};
@@ -1061,7 +1311,7 @@
 template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate<int>;
 
 #ifdef MS
-// expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is unsupported}}
+// expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}}
 // expected-note@+2{{attribute is here}}
 #endif
 struct __declspec(dllimport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {};
@@ -1073,7 +1323,7 @@
 struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {};
 
 #ifdef MS
-// expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is unsupported}}
+// expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}}
 // expected-note@+2{{attribute is here}}
 #endif
 struct __declspec(dllimport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {};
diff --git a/test/SemaCXX/enum-bitfield.cpp b/test/SemaCXX/enum-bitfield.cpp
index 63445ca..ec849b7 100644
--- a/test/SemaCXX/enum-bitfield.cpp
+++ b/test/SemaCXX/enum-bitfield.cpp
@@ -16,3 +16,15 @@
   enum E : int(2);
   enum E : Z(); // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'Z'}}
 };
+
+namespace pr18587 {
+struct A {
+  enum class B {
+    C
+  };
+};
+const int C = 4;
+struct D {
+  A::B : C;
+};
+}
diff --git a/test/SemaCXX/exceptions.cpp b/test/SemaCXX/exceptions.cpp
index c2ca9f9..9646a9c 100644
--- a/test/SemaCXX/exceptions.cpp
+++ b/test/SemaCXX/exceptions.cpp
@@ -35,37 +35,37 @@
 void jumps() {
 l1:
   goto l5;
-  goto l4; // expected-error {{goto into protected scope}}
-  goto l3; // expected-error {{goto into protected scope}}
-  goto l2; // expected-error {{goto into protected scope}}
+  goto l4; // expected-error {{cannot jump}}
+  goto l3; // expected-error {{cannot jump}}
+  goto l2; // expected-error {{cannot jump}}
   goto l1;
   try { // expected-note 4 {{jump bypasses initialization of try block}}
   l2:
     goto l5;
-    goto l4; // expected-error {{goto into protected scope}}
-    goto l3; // expected-error {{goto into protected scope}}
+    goto l4; // expected-error {{cannot jump}}
+    goto l3; // expected-error {{cannot jump}}
     goto l2;
     goto l1;
   } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}}
   l3:
     goto l5;
-    goto l4; // expected-error {{goto into protected scope}}
+    goto l4; // expected-error {{cannot jump}}
     goto l3;
-    goto l2; // expected-error {{goto into protected scope}}
+    goto l2; // expected-error {{cannot jump}}
     goto l1;
   } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}}
   l4:
     goto l5;
     goto l4;
-    goto l3; // expected-error {{goto into protected scope}}
-    goto l2; // expected-error {{goto into protected scope}}
+    goto l3; // expected-error {{cannot jump}}
+    goto l2; // expected-error {{cannot jump}}
     goto l1;
   }
 l5:
   goto l5;
-  goto l4; // expected-error {{goto into protected scope}}
-  goto l3; // expected-error {{goto into protected scope}}
-  goto l2; // expected-error {{goto into protected scope}}
+  goto l4; // expected-error {{cannot jump}}
+  goto l3; // expected-error {{cannot jump}}
+  goto l2; // expected-error {{cannot jump}}
   goto l1;
 }
 
diff --git a/test/SemaCXX/explicit.cpp b/test/SemaCXX/explicit.cpp
index aa28bd8..155141c 100644
--- a/test/SemaCXX/explicit.cpp
+++ b/test/SemaCXX/explicit.cpp
@@ -86,7 +86,7 @@
     // Y is an aggregate, so aggregate-initialization is performed and the
     // conversion function is not considered.
     const Y y10{z}; // expected-error {{excess elements}}
-    const Y& y11{z}; // expected-error {{no viable conversion from 'Z' to 'const Y'}}
+    const Y& y11{z}; // expected-error {{excess elements}} expected-note {{in initialization of temporary of type 'const Y'}}
     const int& y12{z};
 
     // X is not an aggregate, so constructors are considered.
diff --git a/test/SemaCXX/flexible-array-test.cpp b/test/SemaCXX/flexible-array-test.cpp
index e58f19a..2d74fa5 100644
--- a/test/SemaCXX/flexible-array-test.cpp
+++ b/test/SemaCXX/flexible-array-test.cpp
@@ -14,6 +14,12 @@
   v = avalue;
 }
 
+struct Rec {
+  union { // expected-warning-re {{variable sized type '{{.*}}' not at the end of a struct or class is a GNU extension}}
+    int u0[];
+  };
+  int x;
+} rec;
 
 struct inotify_event
 {
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp
index 329be63..2f777fb 100644
--- a/test/SemaCXX/for-range-examples.cpp
+++ b/test/SemaCXX/for-range-examples.cpp
@@ -227,3 +227,15 @@
     for (e [[deprecated]] : arr) { e = 0; } // expected-warning {{deprecated}} expected-note {{here}} expected-warning {{extension}}
   }
 }
+
+namespace pr18587 {
+  class Arg {};
+  struct Cont {
+    int *begin();
+    int *end();
+  };
+  void AddAllArgs(Cont &x) {
+    for (auto Arg: x) {
+    }
+  }
+}
diff --git a/test/SemaCXX/format-strings.cpp b/test/SemaCXX/format-strings.cpp
index 299aa81..4177570 100644
--- a/test/SemaCXX/format-strings.cpp
+++ b/test/SemaCXX/format-strings.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -pedantic -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -fblocks %s
 
 #include <stdarg.h>
 
diff --git a/test/SemaCXX/goto.cpp b/test/SemaCXX/goto.cpp
index 042ec3c..2d37ea9 100644
--- a/test/SemaCXX/goto.cpp
+++ b/test/SemaCXX/goto.cpp
@@ -109,7 +109,7 @@
     ~S() {}
   };
   void g(const S& s) {
-    goto done; // expected-error {{goto into protected scope}}
+    goto done; // expected-error {{cannot jump}}
     const S s2(s); // expected-note {{jump bypasses variable initialization}}
   done:
     ;
@@ -119,7 +119,7 @@
 namespace test12 {
   struct A { A(); A(const A&); ~A(); };
   void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: weird location
-    goto lbl; // expected-error {{goto into protected scope}}
+    goto lbl; // expected-error {{cannot jump}}
     (void) ^{ (void) a; };
   lbl:
     return;
diff --git a/test/SemaCXX/implicit-exception-spec.cpp b/test/SemaCXX/implicit-exception-spec.cpp
index e26f985..ff3d685 100644
--- a/test/SemaCXX/implicit-exception-spec.cpp
+++ b/test/SemaCXX/implicit-exception-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 -Wall %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 -Wall -Wno-unused-local-typedefs %s
 
 template<bool b> struct ExceptionIf { static int f(); };
 template<> struct ExceptionIf<false> { typedef int f; };
@@ -17,42 +17,43 @@
   // is false.
   bool ThrowSomething() noexcept(false);
   struct ConstExpr {
-    bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{cannot be used by non-static data member initializer}}
+    bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{cannot use defaulted default constructor of 'ConstExpr' within the class outside of member functions}}
+  // expected-note@-1 {{implicit default constructor for 'InClassInitializers::ConstExpr' first required here}}
   };
-  // We can use it now.
-  bool w = noexcept(ConstExpr());
 
   // Much more obviously broken: we can't parse the initializer without already
   // knowing whether it produces a noexcept expression.
   struct TemplateArg {
-    int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{cannot be used by non-static data member initializer}}
+    int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{cannot use defaulted default constructor of 'TemplateArg' within the class outside of member functions}}
+    // expected-note@-1 {{implicit default constructor for 'InClassInitializers::TemplateArg' first required here}}
   };
-  bool x = noexcept(TemplateArg());
 
   // And within a nested class.
-  struct Nested { // expected-error {{cannot be used by non-static data member initializer}}
+  struct Nested { // expected-note {{implicit default constructor for 'InClassInitializers::Nested::Inner' first required here}}
     struct Inner {
+      // expected-error@+1 {{cannot use defaulted default constructor of 'Inner' within 'Nested' outside of member functions}}
       int n = ExceptionIf<noexcept(Nested())>::f(); // expected-note {{implicit default constructor for 'InClassInitializers::Nested' first required here}}
     } inner;
   };
 
-  struct Nested2 {
+  struct Nested2 { // expected-error {{implicit default constructor for 'InClassInitializers::Nested2' must explicitly initialize the member 'inner' which does not have a default constructor}}
     struct Inner;
-    int n = Inner().n; // expected-error {{cannot be used by non-static data member initializer}}
-    struct Inner {
+    int n = Inner().n; // expected-note {{implicit default constructor for 'InClassInitializers::Nested2::Inner' first required here}}
+    struct Inner { // expected-note {{declared here}}
+      // expected-error@+1 {{cannot use defaulted default constructor of 'Inner' within 'Nested2' outside of member functions}}
       int n = ExceptionIf<noexcept(Nested2())>::f();
-    } inner;
+      // expected-note@-1 {{implicit default constructor for 'InClassInitializers::Nested2' first required here}}
+    } inner; // expected-note {{member is declared here}}
   };
 }
 
 namespace ExceptionSpecification {
-  // A type is permitted to be used in a dynamic exception specification when it
-  // is still being defined, but isn't complete within such an exception
-  // specification.
-  struct Nested { // expected-note {{not complete}}
+  // FIXME: This diagnostic is quite useless; we should indicate whose
+  // exception specification we were looking for and why.
+  struct Nested {
     struct T {
-      T() noexcept(!noexcept(Nested())); // expected-error{{incomplete type}}
-    } t;
+      T() noexcept(!noexcept(Nested()));
+    } t; // expected-error{{exception specification is not available until end of class definition}}
   };
 }
 
diff --git a/test/SemaCXX/issue547.cpp b/test/SemaCXX/issue547.cpp
index bfec6e0..2a9dd13 100644
--- a/test/SemaCXX/issue547.cpp
+++ b/test/SemaCXX/issue547.cpp
@@ -27,32 +27,32 @@
 };
 
 template<typename R, typename ...Args>
-struct classify_function<R(Args......)> {
+struct classify_function<R(Args..., ...)> {
   static const unsigned value = 5;
 };
 
 template<typename R, typename ...Args>
-struct classify_function<R(Args......) const> {
+struct classify_function<R(Args..., ...) const> {
   static const unsigned value = 6;
 };
 
 template<typename R, typename ...Args>
-struct classify_function<R(Args......) volatile> {
+struct classify_function<R(Args..., ...) volatile> {
   static const unsigned value = 7;
 };
 
 template<typename R, typename ...Args>
-struct classify_function<R(Args......) const volatile> {
+struct classify_function<R(Args..., ...) const volatile> {
   static const unsigned value = 8;
 };
 
 template<typename R, typename ...Args>
-struct classify_function<R(Args......) &&> {
+struct classify_function<R(Args..., ...) &&> {
   static const unsigned value = 9;
 };
 
 template<typename R, typename ...Args>
-struct classify_function<R(Args......) const &> {
+struct classify_function<R(Args..., ...) const &> {
   static const unsigned value = 10;
 };
 
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index 9a53e46..1346c3d 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -363,3 +363,65 @@
 void PR19249() {
   auto x = [&x]{}; // expected-error {{cannot appear in its own init}}
 }
+
+namespace PR20731 {
+template <class L, int X = sizeof(L)>
+void Job(L l);
+
+template <typename... Args>
+void Logger(Args &&... args) {
+  auto len = Invalid_Function((args)...);
+  // expected-error@-1 {{use of undeclared identifier 'Invalid_Function'}}
+  Job([len]() {});
+}
+
+void GetMethod() {
+  Logger();
+  // expected-note@-1 {{in instantiation of function template specialization 'PR20731::Logger<>' requested here}}
+}
+
+template <typename T>
+struct A {
+  T t;
+  // expected-error@-1 {{field has incomplete type 'void'}}
+};
+
+template <typename F>
+void g(F f) {
+  auto a = A<decltype(f())>{};
+  // expected-note@-1 {{in instantiation of template class 'PR20731::A<void>' requested here}}
+  auto xf = [a, f]() {};
+  int x = sizeof(xf);
+};
+void f() {
+  g([] {});
+  // expected-note-re@-1 {{in instantiation of function template specialization 'PR20731::g<(lambda at {{.*}}>' requested here}}
+}
+
+template <class _Rp> struct function {
+  template <class _Fp>
+  function(_Fp) {
+    static_assert(sizeof(_Fp) > 0, "Type must be complete.");
+  }
+};
+
+template <typename T> void p(T t) {
+  auto l = some_undefined_function(t);
+  // expected-error@-1 {{use of undeclared identifier 'some_undefined_function'}}
+  function<void()>(([l]() {}));
+}
+void q() { p(0); }
+// expected-note@-1 {{in instantiation of function template specialization 'PR20731::p<int>' requested here}}
+}
+
+namespace lambda_in_default_mem_init {
+  template<typename T> void f() {
+    struct S { int n = []{ return 0; }(); };
+  }
+  template void f<int>();
+
+  template<typename T> void g() {
+    struct S { int n = [](int n){ return n; }(0); };
+  }
+  template void g<int>();
+}
diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist-system-header.cpp b/test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
similarity index 100%
rename from test/SemaCXX/cxx0x-initializer-stdinitializerlist-system-header.cpp
rename to test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
diff --git a/test/SemaCXX/libstdcxx_pair_swap_hack.cpp b/test/SemaCXX/libstdcxx_pair_swap_hack.cpp
new file mode 100644
index 0000000..02431e0
--- /dev/null
+++ b/test/SemaCXX/libstdcxx_pair_swap_hack.cpp
@@ -0,0 +1,74 @@
+// This is a test for an egregious hack in Clang that works around
+// an issue with GCC's <utility> implementation. std::pair::swap
+// has an exception specification that makes an unqualified call to
+// swap. This is invalid, because it ends up calling itself with
+// the wrong number of arguments.
+//
+// The same problem afflicts a bunch of other class templates. Those
+// affected are array, pair, priority_queue, stack, and queue.
+
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=array
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=pair
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=priority_queue
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=stack
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=queue
+
+// MSVC's standard library uses a very similar pattern that relies on delayed
+// parsing of exception specifications.
+//
+// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify -fexceptions -fcxx-exceptions -DCLASS=array -DMSVC
+
+#ifdef BE_THE_HEADER
+
+#pragma GCC system_header
+namespace std {
+  template<typename T> void swap(T &, T &);
+  template<typename T> void do_swap(T &a, T &b) noexcept(noexcept(swap(a, b))) {
+    swap(a, b);
+  }
+
+  template<typename A, typename B> struct CLASS {
+#ifdef MSVC
+    void swap(CLASS &other) noexcept(noexcept(do_swap(member, other.member)));
+#endif
+    A member;
+#ifndef MSVC
+    void swap(CLASS &other) noexcept(noexcept(swap(member, other.member)));
+#endif
+  };
+
+//  template<typename T> void do_swap(T &, T &);
+//  template<typename A> struct vector {
+//    void swap(vector &other) noexcept(noexcept(do_swap(member, other.member)));
+//    A member;
+//  };
+}
+
+#else
+
+#define BE_THE_HEADER
+#include __FILE__
+
+struct X {};
+using PX = std::CLASS<X, X>;
+using PI = std::CLASS<int, int>;
+void swap(X &, X &) noexcept;
+PX px;
+PI pi;
+
+static_assert(noexcept(px.swap(px)), "");
+static_assert(!noexcept(pi.swap(pi)), "");
+
+namespace sad {
+  template<typename T> void swap(T &, T &);
+
+  template<typename A, typename B> struct CLASS {
+    void swap(CLASS &other) noexcept(noexcept(swap(*this, other))); // expected-error {{too many arguments}} expected-note {{declared here}}
+  };
+
+  CLASS<int, int> pi;
+
+  static_assert(!noexcept(pi.swap(pi)), ""); // expected-note {{in instantiation of}}
+}
+
+#endif
diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp
index d8a00b3..5acb480 100644
--- a/test/SemaCXX/member-init.cpp
+++ b/test/SemaCXX/member-init.cpp
@@ -14,7 +14,10 @@
 bool b();
 int k;
 struct Recurse {
-  int &n = b() ? Recurse().n : k; // expected-error {{defaulted default constructor of 'Recurse' cannot be used by non-static data member initializer which appears before end of class definition}}
+  int &n = // expected-error {{cannot use defaulted default constructor of 'Recurse' within the class outside of member functions because 'n' has an initializer}}
+      b() ?
+      Recurse().n : // expected-note {{implicit default constructor for 'Recurse' first required here}}
+      k;
 };
 
 struct UnknownBound {
@@ -110,3 +113,75 @@
 
   struct Y { int b = f(); };
 }
+
+namespace template_valid {
+// Valid, we shouldn't build a CXXDefaultInitExpr until A's ctor definition.
+struct A {
+  A();
+  template <typename T>
+  struct B { int m1 = sizeof(A) + sizeof(T); };
+  B<int> m2;
+};
+A::A() {}
+}
+
+namespace template_default_ctor {
+struct A {
+  template <typename T>
+  struct B {
+    int m1 = 0; // expected-error {{cannot use defaulted default constructor of 'B' within 'A' outside of member functions because 'm1' has an initializer}}
+  };
+  // expected-note@+1 {{implicit default constructor for 'template_default_ctor::A::B<int>' first required here}}
+  enum { NOE = noexcept(B<int>()) };
+};
+}
+
+namespace default_ctor {
+struct A {
+  struct B {
+    int m1 = 0; // expected-error {{cannot use defaulted default constructor of 'B' within 'A' outside of member functions because 'm1' has an initializer}}
+  };
+  // expected-note@+1 {{implicit default constructor for 'default_ctor::A::B' first required here}}
+  enum { NOE = noexcept(B()) };
+};
+}
+
+namespace member_template {
+struct A {
+  template <typename T>
+  struct B {
+    struct C {
+      int m1 = 0; // expected-error {{cannot use defaulted default constructor of 'C' within 'A' outside of member functions because 'm1' has an initializer}}
+    };
+    template <typename U>
+    struct D {
+      int m1 = 0; // expected-error {{cannot use defaulted default constructor of 'D' within 'A' outside of member functions because 'm1' has an initializer}}
+    };
+  };
+  enum {
+    // expected-note@+1 {{implicit default constructor for 'member_template::A::B<int>::C' first required here}}
+    NOE1 = noexcept(B<int>::C()),
+    // expected-note@+1 {{implicit default constructor for 'member_template::A::B<int>::D<int>' first required here}}
+    NOE2 = noexcept(B<int>::D<int>())
+  };
+};
+}
+
+namespace explicit_instantiation {
+template<typename T> struct X {
+  X(); // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X<float>::n' requested here}}
+  int n = T::error; // expected-error {{type 'float' cannot be used prior to '::' because it has no members}}
+};
+template struct X<int>; // ok
+template<typename T> X<T>::X() {}
+template struct X<float>; // expected-note {{in instantiation of member function 'explicit_instantiation::X<float>::X' requested here}}
+}
+
+namespace local_class {
+template<typename T> void f() {
+  struct X { // expected-note {{in instantiation of default member initializer 'local_class::f()::X::n' requested here}}
+    int n = T::error; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+  };
+}
+void g() { f<int>(); } // expected-note {{in instantiation of function template specialization 'local_class::f<int>' requested here}}
+}
diff --git a/test/SemaCXX/member-pointer-ms.cpp b/test/SemaCXX/member-pointer-ms.cpp
index e7c4ae9..39cf601 100644
--- a/test/SemaCXX/member-pointer-ms.cpp
+++ b/test/SemaCXX/member-pointer-ms.cpp
@@ -249,6 +249,25 @@
 struct D : virtual B {};
 }
 #ifdef VMB
+
+namespace PR20017 {
+template <typename T>
+struct A {
+  int T::*f();
+};
+
+struct B;
+
+auto a = &A<B>::f;
+
+struct B {};
+
+void q() {
+  A<B> b;
+  (b.*a)();
+}
+}
+
 #pragma pointers_to_members(full_generality, multiple_inheritance)
 struct TrulySingleInheritance;
 static_assert(sizeof(int TrulySingleInheritance::*) == kMultipleDataSize, "");
diff --git a/test/SemaCXX/microsoft-varargs-diagnostics.cpp b/test/SemaCXX/microsoft-varargs-diagnostics.cpp
new file mode 100644
index 0000000..0b76fdd
--- /dev/null
+++ b/test/SemaCXX/microsoft-varargs-diagnostics.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify
+
+extern "C" {
+typedef char * va_list;
+}
+
+void test_no_arguments(int i, ...) {
+  __va_start(); // expected-error{{too few arguments to function call, expected at least 3, have 0}}
+}
+
+void test_one_argument(int i, ...) {
+  va_list ap;
+  __va_start(&ap); // expected-error{{too few arguments to function call, expected at least 3, have 1}}
+}
+
+void test_two_arguments(int i, ...) {
+  va_list ap;
+  __va_start(&ap, &i); // expected-error{{too few arguments to function call, expected at least 3, have 2}}
+}
+
+void test_non_last_argument(int i, int j, ...) {
+  va_list ap;
+  __va_start(&ap, &i, 4);
+  // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
+  // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
+}
+
+void test_stack_allocated(int i, ...) {
+  va_list ap;
+  int j;
+  __va_start(&ap, &j, 4);
+  // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
+  // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
+}
+
+void test_non_pointer_addressof(int i, ...) {
+  va_list ap;
+  __va_start(&ap, 1, 4);
+  // expected-error@-1{{passing 'int' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int' vs 'const char *')}}
+  // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
+}
+
diff --git a/test/SemaCXX/microsoft-varargs.cpp b/test/SemaCXX/microsoft-varargs.cpp
new file mode 100644
index 0000000..35f31a9
--- /dev/null
+++ b/test/SemaCXX/microsoft-varargs.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify
+// expected-no-diagnostics
+
+extern "C" {
+typedef char * va_list;
+void __va_start(va_list *, ...);
+}
+
+int test___va_start(int i, ...) {
+  va_list ap;
+  __va_start(&ap, ( &reinterpret_cast<const char &>(i) ),
+             ( (sizeof(i) + 4 - 1) & ~(4 - 1) ),
+             ( &reinterpret_cast<const char &>(i) ));
+  return (*(int *)((ap += ( (sizeof(int) + 4 - 1) & ~(4 - 1) ) + ( ((va_list)0 - (ap)) & (__alignof(int) - 1) )) - ( (sizeof(int) + 4 - 1) & ~(4 - 1) )));
+}
+
+int builtin(int i, ...) {
+  __builtin_va_list ap;
+  __builtin_va_start(ap, i);
+  return __builtin_va_arg(ap, int);
+}
+
diff --git a/test/SemaCXX/ms-friend-lookup.cpp b/test/SemaCXX/ms-friend-lookup.cpp
new file mode 100644
index 0000000..c63160f
--- /dev/null
+++ b/test/SemaCXX/ms-friend-lookup.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -std=c++11 -Wmicrosoft -fms-compatibility -verify
+// RUN: not %clang_cc1 %s -triple i686-pc-win32 -std=c++11 -Wmicrosoft -fms-compatibility -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+
+struct X;
+namespace name_at_tu_scope {
+struct Y {
+  friend struct X; // expected-warning-re {{unqualified friend declaration {{.*}} is a Microsoft extension}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:"::"
+};
+}
+
+namespace enclosing_friend_decl {
+struct B;
+namespace ns {
+struct A {
+  friend struct B; // expected-warning-re {{unqualified friend declaration {{.*}} is a Microsoft extension}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:"enclosing_friend_decl::"
+protected:
+  A();
+};
+}
+struct B {
+  static void f() { ns::A x; }
+};
+}
+
+namespace enclosing_friend_qualified {
+struct B;
+namespace ns {
+struct A {
+  friend struct enclosing_friend_qualified::B; // Adding name specifiers fixes it.
+protected:
+  A();
+};
+}
+struct B {
+  static void f() { ns::A x; }
+};
+}
+
+namespace enclosing_friend_no_tag {
+struct B;
+namespace ns {
+struct A {
+  friend B; // Removing the tag decl fixes it.
+protected:
+  A();
+};
+}
+struct B {
+  static void f() { ns::A x; }
+};
+}
+
+namespace enclosing_friend_func {
+void f();
+namespace ns {
+struct A {
+  // Amusingly, in MSVC, this declares ns::f(), and doesn't find the outer f().
+  friend void f();
+protected:
+  A(); // expected-note {{declared protected here}}
+};
+}
+void f() { ns::A x; } // expected-error {{calling a protected constructor of class 'enclosing_friend_func::ns::A'}}
+}
+
+namespace test_nns_fixit_hint {
+namespace name1 {
+namespace name2 {
+struct X;
+struct name2;
+namespace name3 {
+struct Y {
+  friend struct X; // expected-warning-re {{unqualified friend declaration {{.*}} is a Microsoft extension}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:17-[[@LINE-1]]:17}:"name1::name2::"
+};
+}
+}
+}
+}
+
+// A friend declaration injects a forward declaration into the nearest enclosing
+// non-member scope.
+namespace friend_as_a_forward_decl {
+
+class A {
+  class Nested {
+    friend class B;
+    B *b;
+  };
+  B *b;
+};
+B *global_b;
+
+void f() {
+  class Local {
+    friend class Z;
+    Z *b;
+  };
+  Z *b;
+}
+
+}
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index e18b58b..63615ec 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -35,12 +35,12 @@
   namespace A2 { }
 
   // These all point to A1.
-  namespace B = A1; // expected-note {{previous definition is here}}
+  namespace B = A1;
   namespace B = A1;
   namespace C = B;
-  namespace B = C;
+  namespace B = C; // expected-note {{previously defined as an alias for 'A1'}}
 
-  namespace B = A2; // expected-error {{redefinition of 'B' as different kind of symbol}}
+  namespace B = A2; // expected-error {{redefinition of 'B' as an alias for a different namespace}}
 }
 
 namespace I { 
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index bfbf9c4..bdeb00d 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -311,3 +311,102 @@
 
 namespace TypedefNamespace { typedef int F; };
 TypedefNamespace::F::NonexistentName BadNNSWithCXXScopeSpec; // expected-error {{'F' (aka 'int') is not a class, namespace, or scoped enumeration}}
+
+namespace PR18587 {
+
+struct C1 {
+  int a, b, c;
+  typedef int C2;
+  struct B1 {
+    struct B2 {
+      int a, b, c;
+    };
+  };
+};
+struct C2 { static const unsigned N1 = 1; };
+struct B1 {
+  enum E1 { B2 = 2 };
+  static const int B3 = 3;
+};
+const int N1 = 2;
+
+// Function declarators
+struct S1a { int f(C1::C2); };
+struct S1b { int f(C1:C2); };  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+
+struct S2a {
+  C1::C2 f(C1::C2);
+};
+struct S2c {
+  C1::C2 f(C1:C2);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+
+struct S3a {
+  int f(C1::C2), C2 : N1;
+  int g : B1::B2;
+};
+struct S3b {
+  int g : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+
+// Inside square brackets
+struct S4a {
+  int f[C2::N1];
+};
+struct S4b {
+  int f[C2:N1];  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+
+struct S5a {
+  int f(int xx[B1::B3 ? C2::N1 : B1::B2]);
+};
+struct S5b {
+  int f(int xx[B1::B3 ? C2::N1 : B1:B2]);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+struct S5c {
+  int f(int xx[B1:B3 ? C2::N1 : B1::B2]);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+
+// Bit fields
+struct S6a {
+  C1::C2 m1 : B1::B2;
+};
+struct S6c {
+  C1::C2 m1 : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+struct S6d {
+  int C2:N1;
+};
+struct S6e {
+  static const int N = 3;
+  B1::E1 : N;
+};
+struct S6g {
+  C1::C2 : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+  B1::E1 : B1:B2;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+
+// Template parameters
+template <int N> struct T1 {
+  int a,b,c;
+  static const unsigned N1 = N;
+  typedef unsigned C1;
+};
+T1<C2::N1> var_1a;
+T1<C2:N1> var_1b;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+template<int N> int F() {}
+int (*X1)() = (B1::B2 ? F<1> : F<2>);
+int (*X2)() = (B1:B2 ? F<1> : F<2>);  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+
+// Bit fields + templates
+struct S7a {
+  T1<B1::B2>::C1 m1 : T1<B1::B2>::N1;
+};
+struct S7b {
+  T1<B1:B2>::C1 m1 : T1<B1::B2>::N1;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+struct S7c {
+  T1<B1::B2>::C1 m1 : T1<B1:B2>::N1;  // expected-error{{unexpected ':' in nested name specifier; did you mean '::'?}}
+};
+
+}
diff --git a/test/SemaCXX/nonnull.cpp b/test/SemaCXX/nonnull.cpp
index 9ff6d11..97b5455 100644
--- a/test/SemaCXX/nonnull.cpp
+++ b/test/SemaCXX/nonnull.cpp
@@ -13,3 +13,8 @@
   }
 };
 
+namespace Template {
+  template<typename T> __attribute__((nonnull)) void f(T t);
+  void g() { f((void*)0); } // expected-warning {{null passed to a callee that requires a non-null argument}}
+  void h() { f(0); }
+}
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp
index 28798a4..7d765b4 100644
--- a/test/SemaCXX/nullptr.cpp
+++ b/test/SemaCXX/nullptr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -ffreestanding %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -ffreestanding -Wno-null-conversion %s
 #include <stdint.h>
 
 typedef decltype(nullptr) nullptr_t;
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index da28eef..19ce144 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -590,3 +590,21 @@
   } callable;
   callable();  // expected-error{{no matching function for call}}
 }
+
+namespace PR20218 {
+  void f(void (*const &)()); // expected-note 2{{candidate}}
+  void f(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}}
+  void g(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}}
+  void g(void (*const &)()); // expected-note 2{{candidate}}
+
+  void x();
+  typedef void (&fr)();
+  struct Y { operator fr(); } y;
+
+  void h() {
+    f(x); // expected-error {{ambiguous}}
+    g(x); // expected-error {{ambiguous}}
+    f(y); // expected-error {{ambiguous}}
+    g(y); // expected-error {{ambiguous}}
+  }
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index feb7c71..369e9eb 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -519,3 +519,15 @@
   int x = a;
   int y = b;
 }
+
+namespace NoADLForMemberOnlyOperators {
+  template<typename T> struct A { typename T::error e; }; // expected-error {{type 'char' cannot be used prior to '::'}}
+  template<typename T> struct B { int n; };
+
+  void f(B<A<void> > b1, B<A<int> > b2, B<A<char> > b3) {
+    b1 = b1; // ok, does not instantiate A<void>.
+    (void)b1->n; // expected-error {{is not a pointer}}
+    b2[3]; // expected-error {{does not provide a subscript}}
+    b3 / 0; // expected-note {{in instantiation of}} expected-error {{invalid operands to}}
+  }
+}
diff --git a/test/SemaCXX/override-in-system-header.cpp b/test/SemaCXX/override-in-system-header.cpp
new file mode 100644
index 0000000..689585e
--- /dev/null
+++ b/test/SemaCXX/override-in-system-header.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 -isystem %S/Inputs %s -verify
+// expected-no-diagnostics
+// rdar://18295240
+
+#include <override-system-header.h>
+
+struct A
+{
+  virtual void x();
+  END_COM_MAP;
+  IFACEMETHOD(Initialize)();
+};
+ 
+struct B : A
+{
+  virtual void x() override;
+  END_COM_MAP;
+  IFACEMETHOD(Initialize)();
+};
diff --git a/test/SemaCXX/pragma-init_seg.cpp b/test/SemaCXX/pragma-init_seg.cpp
new file mode 100644
index 0000000..e18d0e6
--- /dev/null
+++ b/test/SemaCXX/pragma-init_seg.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0
+
+#ifndef __APPLE__
+#pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
+#pragma init_seg( // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
+#pragma init_seg asdf // expected-warning {{missing '('}}
+#pragma init_seg) // expected-warning {{missing '('}}
+#pragma init_seg("a" "b") // no warning
+#pragma init_seg("a", "b") // expected-warning {{missing ')'}}
+#pragma init_seg("a") asdf // expected-warning {{extra tokens at end of '#pragma init_seg'}}
+#pragma init_seg("\x") // expected-error {{\x used with no following hex digits}}
+#pragma init_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma init_seg'}}
+
+#pragma init_seg(compiler)
+#else
+#pragma init_seg(compiler) // expected-warning {{'#pragma init_seg' is only supported when targeting a Microsoft environment}}
+#endif
+
+int f();
+int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}}
diff --git a/test/SemaCXX/pragma-optimize.cpp b/test/SemaCXX/pragma-optimize.cpp
index 0f03b81..0a9f041 100644
--- a/test/SemaCXX/pragma-optimize.cpp
+++ b/test/SemaCXX/pragma-optimize.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x c++ -std=c++11 -triple x86_64-unknown-linux -emit-llvm -O2 < %s | FileCheck %s
+// RUN: %clang_cc1 -I %S/Inputs -x c++ -std=c++11 -triple x86_64-unknown-linux -emit-llvm -O2 < %s | FileCheck %s
 
 #pragma clang optimize off
 
@@ -96,11 +96,50 @@
 // CHECK-DAG: @_Z6thriceIiET_S0_{{.*}} [[ATTRTHRICEINT:#[0-9]+]]
 
 
+// Test that we can re-open and re-close an "off" region after the first one,
+// and that this works as expected.
+
+#pragma clang optimize off
+
+int another_optnone(int x) {
+    return x << 1;
+}
+// CHECK-DAG: @_Z15another_optnonei{{.*}} [[ATTRANOTHEROPTNONE:#[0-9]+]]
+
+#pragma clang optimize on
+
+int another_normal(int x) {
+    return x << 2;
+}
+// CHECK-DAG: @_Z14another_normali{{.*}} [[ATTRANOTHERNORMAL:#[0-9]+]]
+
+
+// Test that we can re-open an "off" region by including a header with the
+// pragma and that this works as expected (i.e. the off region "falls through"
+// the end of the header into this file).
+
+#include <header-with-pragma-optimize-off.h>
+
+int yet_another_optnone(int x) {
+    return x << 3;
+}
+// CHECK-DAG: @_Z19yet_another_optnonei{{.*}} [[ATTRYETANOTHEROPTNONE:#[0-9]+]]
+
+#pragma clang optimize on
+
+int yet_another_normal(int x) {
+    return x << 4;
+}
+// CHECK-DAG: @_Z18yet_another_normali{{.*}} [[ATTRYETANOTHERNORMAL:#[0-9]+]]
+
+
 // Check for both noinline and optnone on each function that should have them.
 // CHECK-DAG: attributes [[ATTRBAR]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
 // CHECK-DAG: attributes [[ATTRCREATED]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
 // CHECK-DAG: attributes [[ATTRMETHOD]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
 // CHECK-DAG: attributes [[ATTRTHRICEFLOAT]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
+// CHECK-DAG: attributes [[ATTRANOTHEROPTNONE]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
+// CHECK-DAG: attributes [[ATTRYETANOTHEROPTNONE]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
 
 // Check that the other functions do NOT have optnone.
 // CHECK-DAG-NOT: attributes [[ATTRFOO]] = { {{.*}}optnone{{.*}} }
@@ -111,3 +150,5 @@
 // CHECK-DAG-NOT: attributes [[ATTRCONTAINER2]] = { {{.*}}optnone{{.*}} }
 // CHECK-DAG-NOT: attributes [[ATTRCONTAINER3]] = { {{.*}}optnone{{.*}} }
 // CHECK-DAG-NOT: attributes [[ATTRTHRICEINT]] = { {{.*}}optnone{{.*}} }
+// CHECK-DAG-NOT: attributes [[ATTRANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
+// CHECK-DAG-NOT: attributes [[ATTRYETANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
diff --git a/test/SemaCXX/predefined-expr.cpp b/test/SemaCXX/predefined-expr.cpp
index 257d44c..f4a155d 100644
--- a/test/SemaCXX/predefined-expr.cpp
+++ b/test/SemaCXX/predefined-expr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1y -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -std=c++1y -fblocks -fsyntax-only -triple %itanium_abi_triple -verify %s
 // PR16946
 // expected-no-diagnostics
 
@@ -33,10 +33,9 @@
   ();
 
   ^{
-    // FIXME: This is obviously wrong.
-    static_assert(sizeof(__func__) == 1, "__baz_block_invoke");
-    static_assert(sizeof(__FUNCTION__) == 1, "__baz_block_invoke");
-    static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__baz_block_invoke");
+    static_assert(sizeof(__func__) == 27, "___Z3bazIiEiv_block_invoke");
+    static_assert(sizeof(__FUNCTION__) == 27, "___Z3bazIiEiv_block_invoke");
+    static_assert(sizeof(__PRETTY_FUNCTION__) == 27, "___Z3bazIiEiv_block_invoke");
   }
   ();
 
@@ -65,10 +64,9 @@
   ();
 
   ^{
-    // FIXME: This is obviously wrong.
-    static_assert(sizeof(__func__) == 1, "__main_block_invoke");
-    static_assert(sizeof(__FUNCTION__) == 1, "__main_block_invoke");
-    static_assert(sizeof(__PRETTY_FUNCTION__) == 1, "__main_block_invoke");
+    static_assert(sizeof(__func__) == 20, "__main_block_invoke");
+    static_assert(sizeof(__FUNCTION__) == 20, "__main_block_invoke");
+    static_assert(sizeof(__PRETTY_FUNCTION__) == 20, "__main_block_invoke");
   }
   ();
 
diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp
index 16bb86c..61b45c5 100644
--- a/test/SemaCXX/return-noreturn.cpp
+++ b/test/SemaCXX/return-noreturn.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
-// RUN: %clang_cc1 %s -fsyntax-only -std=c++11 -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
+// RUN: %clang_cc1 %s -fsyntax-only -fcxx-exceptions -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
+// RUN: %clang_cc1 %s -fsyntax-only -fcxx-exceptions -std=c++11 -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
 
 // A destructor may be marked noreturn and should still influence the CFG.
 void pr6884_abort() __attribute__((noreturn));
@@ -146,3 +146,119 @@
     PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}}
 }
 
+struct NoReturn {
+  ~NoReturn() __attribute__((noreturn));
+  operator bool() const;
+};
+struct Return {
+  ~Return();
+  operator bool() const;
+};
+
+int testTernaryUnconditionalNoreturn() {
+  true ? NoReturn() : NoReturn();
+}
+
+int testTernaryStaticallyConditionalNoretrunOnTrue() {
+  true ? NoReturn() : Return();
+}
+
+int testTernaryStaticallyConditionalRetrunOnTrue() {
+  true ? Return() : NoReturn();
+} // expected-warning {{control reaches end of non-void function}}
+
+int testTernaryStaticallyConditionalNoretrunOnFalse() {
+  false ? Return() : NoReturn();
+}
+
+int testTernaryStaticallyConditionalRetrunOnFalse() {
+  false ? NoReturn() : Return();
+} // expected-warning {{control reaches end of non-void function}}
+
+int testTernaryConditionalNoreturnTrueBranch(bool value) {
+  value ? (NoReturn() || NoReturn()) : Return();
+} // expected-warning {{control may reach end of non-void function}}
+
+int testTernaryConditionalNoreturnFalseBranch(bool value) {
+  value ? Return() : (NoReturn() || NoReturn());
+} // expected-warning {{control may reach end of non-void function}}
+
+int testConditionallyExecutedComplexTernaryTrueBranch(bool value) {
+  value || (true ? NoReturn() : true);
+} // expected-warning {{control may reach end of non-void function}}
+
+int testConditionallyExecutedComplexTernaryFalseBranch(bool value) {
+  value || (false ? true : NoReturn());
+} // expected-warning {{control may reach end of non-void function}}
+
+int testStaticallyExecutedLogicalOrBranch() {
+  false || NoReturn();
+}
+
+int testStaticallyExecutedLogicalAndBranch() {
+  true && NoReturn();
+}
+
+int testStaticallySkippedLogicalOrBranch() {
+  true || NoReturn();
+} // expected-warning {{control reaches end of non-void function}}
+
+int testStaticallySkppedLogicalAndBranch() {
+  false && NoReturn();
+} // expected-warning {{control reaches end of non-void function}}
+
+int testConditionallyExecutedComplexLogicalBranch(bool value) {
+  value || (true && NoReturn());
+} // expected-warning {{control may reach end of non-void function}}
+
+int testConditionallyExecutedComplexLogicalBranch2(bool value) {
+  (true && value) || (true && NoReturn());
+} // expected-warning {{control may reach end of non-void function}}
+
+int testConditionallyExecutedComplexLogicalBranch3(bool value) {
+  (false && (Return() || true)) || (true && NoReturn());
+}
+
+int testConditionallyExecutedComplexLogicalBranch4(bool value) {
+  false || ((Return() || true) && (true && NoReturn()));
+}
+
+#if __cplusplus >= 201103L
+namespace LambdaVsTemporaryDtor {
+  struct Y { ~Y(); };
+  struct X { template<typename T> X(T, Y = Y()) {} };
+
+  struct Fatal { ~Fatal() __attribute__((noreturn)); };
+  struct FatalCopy { FatalCopy(); FatalCopy(const FatalCopy&, Fatal F = Fatal()); };
+
+  void foo();
+
+  int bar() {
+    X work([](){ Fatal(); });
+    foo();
+  } // expected-warning {{control reaches end of non-void function}}
+
+  int baz() {
+    FatalCopy fc;
+    X work([fc](){});
+    foo();
+  } // ok, initialization of lambda does not return
+}
+#endif
+
+// Ensure that function-try-blocks also check for return values properly.
+int functionTryBlock1(int s) try {
+  return 0;
+} catch (...) {
+} // expected-warning {{control may reach end of non-void function}}
+
+int functionTryBlock2(int s) try {
+} catch (...) {
+  return 0;
+} // expected-warning {{control may reach end of non-void function}}
+
+int functionTryBlock3(int s) try {
+  return 0;
+} catch (...) {
+  return 0;
+} // ok, both paths return.
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp
index dc15dc8..ac70099 100644
--- a/test/SemaCXX/scope-check.cpp
+++ b/test/SemaCXX/scope-check.cpp
@@ -32,7 +32,7 @@
 
   int f(bool b) {
     if (b)
-      goto foo; // expected-error {{goto into protected scope}}
+      goto foo; // expected-error {{cannot jump}}
     C c; // expected-note {{jump bypasses variable initialization}}
   foo:
     return 1;
@@ -79,7 +79,7 @@
 
     C c0;
 
-    goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+    goto *ip; // expected-error {{cannot jump}}
     C c1; // expected-note {{jump bypasses variable initialization}}
   lbl1: // expected-note {{possible target of indirect goto}}
     return 0;
@@ -103,7 +103,7 @@
     if (ip[1]) {
       D d; // expected-note {{jump exits scope of variable with non-trivial destructor}}
       ip += 2;
-      goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+      goto *ip; // expected-error {{cannot jump}}
     }
     return 1;
   }
@@ -153,13 +153,13 @@
     switch (c) {
     case 0:
       int x = 56; // expected-note {{jump bypasses variable initialization}}
-    case 1:       // expected-error {{switch case is in protected scope}}
+    case 1:       // expected-error {{cannot jump}}
       x = 10;
     }
   }
 
   void test2() {
-    goto l2;     // expected-error {{goto into protected scope}}
+    goto l2;     // expected-error {{cannot jump}}
   l1: int x = 5; // expected-note {{jump bypasses variable initialization}}
   l2: x++;
   }
@@ -208,7 +208,7 @@
 namespace test10 {
   int test() {
     static void *ps[] = { &&a0 };
-    goto *&&a0; // expected-error {{goto into protected scope}}
+    goto *&&a0; // expected-error {{cannot jump}}
     int a = 3; // expected-note {{jump bypasses variable initialization}}
   a0:
     return 0;
@@ -225,7 +225,7 @@
     static void *ips[] = { &&l0 };
   l0:  // expected-note {{possible target of indirect goto}}
     C c0 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}}
-    goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+    goto *ip; // expected-error {{cannot jump}}
   }
 }
 
@@ -240,7 +240,7 @@
   l0: // expected-note {{possible target of indirect goto}}
     const C &c1 = 42; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
     const C &c2 = c0;
-    goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+    goto *ip; // expected-error {{cannot jump}}
   }
 }
 
@@ -254,7 +254,7 @@
     static void *ips[] = { &&l0 };
   l0: // expected-note {{possible target of indirect goto}}
     const int &c1 = C(1).i; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
-    goto *ip;  // expected-error {{indirect goto might cross protected scopes}}
+    goto *ip;  // expected-error {{cannot jump}}
   }
 }
 
@@ -276,21 +276,21 @@
 // PR14225
 namespace test15 {
   void f1() try {
-    goto x; // expected-error {{goto into protected scope}}
+    goto x; // expected-error {{cannot jump}}
   } catch(...) {  // expected-note {{jump bypasses initialization of catch block}}
     x: ;
   }
   void f2() try {  // expected-note {{jump bypasses initialization of try block}}
     x: ;
   } catch(...) {
-    goto x; // expected-error {{goto into protected scope}}
+    goto x; // expected-error {{cannot jump}}
   }
 }
 
 namespace test16 {
   struct S { int n; };
   int f() {
-    goto x; // expected-error {{goto into protected scope}}
+    goto x; // expected-error {{cannot jump}}
     const S &s = S(); // expected-note {{jump bypasses variable initialization}}
 x:  return s.n;
   }
@@ -300,7 +300,7 @@
 namespace test17 {
   struct S { int get(); private: int n; };
   int f() {
-    goto x; // expected-error {{goto into protected scope}}
+    goto x; // expected-error {{cannot jump}}
     S s = {}; // expected-note {{jump bypasses variable initialization}}
 x:  return s.get();
   }
@@ -321,7 +321,7 @@
     void *p = &&x;
   x: // expected-note {{possible target of indirect goto}}
     B b = { 0, A() }; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
-    goto *p; // expected-error {{indirect goto might cross protected scopes}}
+    goto *p; // expected-error {{cannot jump}}
   }
 }
 
@@ -342,7 +342,7 @@
     A a;
   x: // expected-note {{possible target of indirect goto}}
     std::initializer_list<A> il = { a }; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
-    goto *p; // expected-error {{indirect goto might cross protected scopes}}
+    goto *p; // expected-error {{cannot jump}}
   }
 }
 
@@ -370,14 +370,14 @@
       a,
       { A() } // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
     };
-    goto *p; // expected-error {{indirect goto might cross protected scopes}}
+    goto *p; // expected-error {{cannot jump}}
   }
 }
 #endif
 
 namespace test21 {
   template<typename T> void f() {
-  goto x; // expected-error {{protected scope}}
+  goto x; // expected-error {{cannot jump}}
     T t; // expected-note {{bypasses}}
  x: return;
   }
@@ -428,7 +428,7 @@
   void test(nexist, int c) { // expected-error {{}}
     nexist_fn(); // expected-error {{}}
     goto nexist_label; // expected-error {{use of undeclared label}}
-    goto a0; // expected-error {{goto into protected scope}}
+    goto a0; // expected-error {{cannot jump}}
     int a = 0; // expected-note {{jump bypasses variable initialization}}
     a0:;
 
@@ -436,7 +436,7 @@
     case $: // expected-error {{}}
     case 0:
       int x = 56; // expected-note {{jump bypasses variable initialization}}
-    case 1: // expected-error {{switch case is in protected scope}}
+    case 1: // expected-error {{cannot jump}}
       x = 10;
     }
   }
diff --git a/test/SemaCXX/statements.cpp b/test/SemaCXX/statements.cpp
index 6d04c84..953a4a8 100644
--- a/test/SemaCXX/statements.cpp
+++ b/test/SemaCXX/statements.cpp
@@ -10,7 +10,7 @@
 };
 
 void test2() {
-  goto later;  // expected-error {{goto into protected scope}}
+  goto later;  // expected-error {{cannot jump}}
   X x;         // expected-note {{jump bypasses variable initialization}} 
 later:
   ;
diff --git a/test/SemaCXX/trailing-return-0x.cpp b/test/SemaCXX/trailing-return-0x.cpp
index cf5e659..c6b22c5 100644
--- a/test/SemaCXX/trailing-return-0x.cpp
+++ b/test/SemaCXX/trailing-return-0x.cpp
@@ -17,8 +17,8 @@
     return 0;
 }
 
-auto g(); // expected-error{{return without trailing return type; deduced return types are a C++1y extension}}
-decltype(auto) g2(); // expected-warning{{extension}} expected-error-re{{{{^}}deduced return types are a C++1y extension}}
+auto g(); // expected-error{{return without trailing return type; deduced return types are a C++14 extension}}
+decltype(auto) g2(); // expected-warning{{extension}} expected-error-re{{{{^}}deduced return types are a C++14 extension}}
 auto badness = g2();
 
 int h() -> int; // expected-error{{trailing return type must specify return type 'auto', not 'int'}}
@@ -75,14 +75,14 @@
 namespace PR12053 {
   template <typename T>
   auto f1(T t) -> decltype(f1(t)) {} // expected-note{{candidate template ignored}}
-  
+
   void test_f1() {
     f1(0); // expected-error{{no matching function for call to 'f1'}}
   }
-  
+
   template <typename T>
   auto f2(T t) -> decltype(f2(&t)) {} // expected-note{{candidate template ignored}}
-  
+
   void test_f2() {
     f2(0); // expected-error{{no matching function for call to 'f2'}}
   }
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 3b94ef0..4833c14 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -146,6 +146,10 @@
   ThreeArgCtor(int*, char*, int);
 };
 
+struct VariadicCtor {
+  template<typename...T> VariadicCtor(T...);
+};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -1968,6 +1972,10 @@
   // PR19178
   { int arr[F(__is_constructible(Abstract))]; }
   { int arr[F(__is_nothrow_constructible(Abstract))]; }
+
+  // PR20228
+  { int arr[T(__is_constructible(VariadicCtor,
+                                 int, int, int, int, int, int, int, int, int))]; }
 }
 
 // Instantiation of __is_trivially_constructible
diff --git a/test/SemaCXX/types_compatible_p.cpp b/test/SemaCXX/types_compatible_p.cpp
index ebff53f..29e0640 100644
--- a/test/SemaCXX/types_compatible_p.cpp
+++ b/test/SemaCXX/types_compatible_p.cpp
@@ -4,5 +4,6 @@
 // Test that GNU C extension __builtin_types_compatible_p() is not available in C++ mode.
 
 int f() {
-  return __builtin_types_compatible_p(int, const int); // expected-error{{}}
+  return __builtin_types_compatible_p(int, const int); // expected-error{{expected '(' for function-style cast or type construction}} \
+                                                       // expected-error{{expected expression}}
 }
diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp
new file mode 100644
index 0000000..984d68b
--- /dev/null
+++ b/test/SemaCXX/typo-correction-delayed.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
+
+struct A {};
+struct B {};
+struct D {
+  A fizbin;  // expected-note 2 {{declared here}}
+  A foobar;  // expected-note 2 {{declared here}}
+  B roxbin;  // expected-note 2 {{declared here}}
+  B toobad;  // expected-note 2 {{declared here}}
+  void BooHoo();
+  void FoxBox();
+};
+
+void something(A, B);
+void test() {
+  D obj;
+  something(obj.fixbin,   // expected-error {{did you mean 'fizbin'?}}
+            obj.toobat);  // expected-error {{did you mean 'toobad'?}}
+  something(obj.toobat,   // expected-error {{did you mean 'foobar'?}}
+            obj.fixbin);  // expected-error {{did you mean 'roxbin'?}}
+  something(obj.fixbin,   // expected-error {{did you mean 'fizbin'?}}
+            obj.fixbin);  // expected-error {{did you mean 'roxbin'?}}
+  something(obj.toobat,   // expected-error {{did you mean 'foobar'?}}
+            obj.toobat);  // expected-error {{did you mean 'toobad'?}}
+  // Both members could be corrected to methods, but that isn't valid.
+  something(obj.boohoo,   // expected-error-re {{no member named 'boohoo' in 'D'{{$}}}}
+            obj.foxbox);  // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
+  // The first argument has a usable correction but the second doesn't.
+  something(obj.boobar,   // expected-error-re {{no member named 'boobar' in 'D'{{$}}}}
+            obj.foxbox);  // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
+}
+
+// Ensure the delayed typo correction does the right thing when trying to
+// recover using a seemingly-valid correction for which a valid expression to
+// replace the TypoExpr cannot be created (but which does have a second
+// correction candidate that would be a valid and usable correction).
+class Foo {
+public:
+  template <> void testIt();  // expected-error {{no function template matches}}
+  void textIt();  // expected-note {{'textIt' declared here}}
+};
+void testMemberExpr(Foo *f) {
+  f->TestIt();  // expected-error {{no member named 'TestIt' in 'Foo'; did you mean 'textIt'?}}
+}
+
+void callee(double, double);
+void testNoCandidates() {
+  callee(xxxxxx,   // expected-error-re {{use of undeclared identifier 'xxxxxx'{{$}}}}
+         zzzzzz);  // expected-error-re {{use of undeclared identifier 'zzzzzz'{{$}}}}
+}
diff --git a/test/SemaCXX/typo-correction-pt2.cpp b/test/SemaCXX/typo-correction-pt2.cpp
index 88a7073..5d3f123 100644
--- a/test/SemaCXX/typo-correction-pt2.cpp
+++ b/test/SemaCXX/typo-correction-pt2.cpp
@@ -28,7 +28,7 @@
 };
 struct B : A {
   using A::CreateFoo;
-  void CreateFoo(int, int);
+  void CreateFoo(int, int);  // expected-note {{'CreateFoo' declared here}}
 };
 void f(B &x) {
   x.Createfoo(0,0);  // expected-error {{no member named 'Createfoo' in 'PR13387::B'; did you mean 'CreateFoo'?}}
@@ -300,3 +300,35 @@
     (void)static_cast<void(TypoB::*)(int)>(&TypoA::private_memfn);  // expected-error{{no member named 'private_memfn' in 'PR19681::TypoA'; did you mean '::PR19681::TypoB::private_memfn'?}}
   }
 }
+
+namespace testWantFunctionLikeCasts {
+  long test(bool a) {
+    if (a)
+      return struc(5.7);  // expected-error-re {{use of undeclared identifier 'struc'{{$}}}}
+    else
+      return lon(8.0);  // expected-error {{use of undeclared identifier 'lon'; did you mean 'long'?}}
+  }
+}
+
+namespace testCXXDeclarationSpecifierParsing {
+namespace test {
+  struct SomeSettings {};  // expected-note {{'test::SomeSettings' declared here}}
+}
+class Test {};
+int bar() {
+  Test::SomeSettings some_settings; // expected-error {{no type named 'SomeSettings' in 'testCXXDeclarationSpecifierParsing::Test'; did you mean 'test::SomeSettings'?}}
+}
+}
+
+namespace testNonStaticMemberHandling {
+struct Foo {
+  bool usesMetadata;  // expected-note {{'usesMetadata' declared here}}
+};
+int test(Foo f) {
+  if (UsesMetadata)  // expected-error-re {{use of undeclared identifier 'UsesMetadata'{{$}}}}
+    return 5;
+  if (f.UsesMetadata)  // expected-error {{no member named 'UsesMetadata' in 'testNonStaticMemberHandling::Foo'; did you mean 'usesMetadata'?}}
+    return 11;
+  return 0;
+}
+};
diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp
index e8160b0..4f19283 100644
--- a/test/SemaCXX/typo-correction.cpp
+++ b/test/SemaCXX/typo-correction.cpp
@@ -209,11 +209,12 @@
   };
 
   void foo(); // expected-note{{'foo' declared here}}
-  void g(void(*)());
-  void g(bool(S<int>::*)() const);
+  void g(void(*)()); // expected-note{{candidate function not viable}}
+  void g(bool(S<int>::*)() const); // expected-note{{candidate function not viable}}
 
   void test() {
-    g(&S<int>::tempalte f<int>); // expected-error{{did you mean 'template'?}}
+    g(&S<int>::tempalte f<int>); // expected-error{{did you mean 'template'?}} \
+                                 // expected-error{{no matching function for call to 'g'}}
     g(&S<int>::opeartor bool); // expected-error{{did you mean 'operator'?}}
     g(&S<int>::foo); // expected-error{{no member named 'foo' in 'PR13051::S<int>'; did you mean simply 'foo'?}}
   }
@@ -247,7 +248,7 @@
 
   struct S1 {
     void method(A*);  // no note here
-    void method(B*);
+    void method(B*);  // expected-note{{'method' declared here}}
   };
 
   void test1() {
@@ -258,15 +259,15 @@
 
   struct S2 {
     S2();
-    void method(A*) const;  // expected-note{{candidate function not viable}}
+    void method(A*) const;
    private:
-    void method(B*);  // expected-note{{candidate function not viable}}
+    void method(B*);
   };
 
   void test2() {
     B b;
     const S2 s;
-    s.methodd(&b);  // expected-error{{no member named 'methodd' in 'b6956809_test1::S2'; did you mean 'method'}}  expected-error{{no matching member function for call to 'method'}}
+    s.methodd(&b);  // expected-error-re{{no member named 'methodd' in 'b6956809_test1::S2'{{$}}}}
   }
 }
 
@@ -274,7 +275,7 @@
   template<typename T> struct Err { typename T::error n; };  // expected-error{{type 'void *' cannot be used prior to '::' because it has no members}}
   struct S {
     template<typename T> typename Err<T>::type method(T);  // expected-note{{in instantiation of template class 'b6956809_test2::Err<void *>' requested here}}
-    template<typename T> int method(T *);
+    template<typename T> int method(T *);  // expected-note{{'method' declared here}}
   };
 
   void test() {
diff --git a/test/SemaCXX/undefined-internal.cpp b/test/SemaCXX/undefined-internal.cpp
index f32036a..d829380 100644
--- a/test/SemaCXX/undefined-internal.cpp
+++ b/test/SemaCXX/undefined-internal.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy %s
 
 // Make sure we don't produce invalid IR.
 // RUN: %clang_cc1 -emit-llvm-only %s
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp
index 677a141..96dc011 100644
--- a/test/SemaCXX/uninitialized.cpp
+++ b/test/SemaCXX/uninitialized.cpp
@@ -1,9 +1,22 @@
 // RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -std=c++11 -verify %s
 
+// definitions for std::move
+namespace std {
+inline namespace foo {
+template <class T> struct remove_reference { typedef T type; };
+template <class T> struct remove_reference<T&> { typedef T type; };
+template <class T> struct remove_reference<T&&> { typedef T type; };
+
+template <class T> typename remove_reference<T>::type&& move(T&& t);
+}
+}
+
 int foo(int x);
 int bar(int* x);
 int boo(int& x);
 int far(const int& x);
+int moved(int&& x);
+int &ref(int x);
 
 // Test self-references within initializers which are guaranteed to be
 // uninitialized.
@@ -24,6 +37,20 @@
 int l = k ? l : l;  // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}}
 int m = 1 + (k ? m : m);  // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}}
 int n = -n;  // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
+const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
+int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
+int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}}
+int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}}
+int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}}
+int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
+int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}}
+int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}}
+int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}}
+int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}}
 
 void test_stuff () {
   int a = a; // no-warning: used to signal intended lack of initialization.
@@ -44,6 +71,21 @@
   int l = k ? l : l;  // expected-warning {{variable 'l' is uninitialized when used within its own initialization}}
   int m = 1 + (k ? m : m);  // expected-warning {{'m' is uninitialized when used within its own initialization}}
   int n = -n;  // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+  int o = std::move(o);  // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
+  const int p = std::move(p);  // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
+  int q = moved(std::move(q));  // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+  int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+  int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+  int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
+  int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}}
+  int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}}
+  int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}}
+  int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
+  int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}}
+  int z = ++ref(z);                              // expected-warning {{variable 'z' is uninitialized when used within its own initialization}}
+  int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}}
+  int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}}
+
 
   for (;;) {
     int a = a; // no-warning: used to signal intended lack of initialization.
@@ -64,9 +106,64 @@
     int l = k ? l : l;  // expected-warning {{variable 'l' is uninitialized when used within its own initialization}}
     int m = 1 + (k ? m : m);  // expected-warning {{'m' is uninitialized when used within its own initialization}}
     int n = -n;  // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+    int o = std::move(o);  // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
+    const int p = std::move(p);  // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
+    int q = moved(std::move(q));  // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+    int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+    int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+    int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
+    int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}}
+    int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}}
+    int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}}
+    int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
+    int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}}
+    int z = ++ref(z);                              // expected-warning {{variable 'z' is uninitialized when used within its own initialization}}
+    int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}}
+    int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}}
+
   }
 }
 
+// Also test similar constructs in a field's initializer.
+struct S {
+  int x;
+  int y;
+  const int z = 5;
+  void *ptr;
+
+  S(bool (*)[1]) : x(x) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(bool (*)[3]) : x(x + x) {} // expected-warning 2{{field 'x' is uninitialized when used here}}
+  S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(bool (*)[5]) : x(foo(x)) {} // expected-warning {{field 'x' is uninitialized when used here}}
+
+  // These don't actually require the value of x and so shouldn't warn.
+  S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363
+  S(char (*)[2]) : ptr(&ptr) {}
+  S(char (*)[3]) : x(bar(&x)) {}
+  S(char (*)[4]) : x(boo(x)) {}
+  S(char (*)[5]) : x(far(x)) {}
+  S(char (*)[6]) : x(__alignof__(x)) {}
+
+  S(int (*)[1]) : x(0), y(x ? y : y) {} // expected-warning 2{{field 'y' is uninitialized when used here}}
+  S(int (*)[2]) : x(0), y(1 + (x ? y : y)) {} // expected-warning 2{{field 'y' is uninitialized when used here}}
+  S(int (*)[3]) : x(-x) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[4]) : x(std::move(x)) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[5]) : z(std::move(z)) {} // expected-warning {{field 'z' is uninitialized when used here}}
+  S(int (*)[6]) : x(moved(std::move(x))) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[7]) : x(0), y(std::move((x ? x : (18, y)))) {} // expected-warning {{field 'y' is uninitialized when used here}}
+  S(int (*)[8]) : x(0), y(x ?: y) {} // expected-warning {{field 'y' is uninitialized when used here}}
+  S(int (*)[9]) : x(0), y(y ?: x) {} // expected-warning {{field 'y' is uninitialized when used here}}
+  S(int (*)[10]) : x(0), y((foo(y), x)) {} // expected-warning {{field 'y' is uninitialized when used here}}
+  S(int (*)[11]) : x(0), y(x += y) {} // expected-warning {{field 'y' is uninitialized when used here}}
+  S(int (*)[12]) : x(x += 10) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[13]) : x(x++) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[14]) : x(0), y(((x ? (y, x) : (77, y))++, sizeof(y))) {} // expected-warning {{field 'y' is uninitialized when used here}}
+  S(int (*)[15]) : x(++ref(x)) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[16]) : x((ref(x) += 10)) {} // expected-warning {{field 'x' is uninitialized when used here}}
+  S(int (*)[17]) : x(0), y(y ? x : x) {} // expected-warning {{field 'y' is uninitialized when used here}}
+};
+
 // Test self-references with record types.
 class A {
   // Non-POD class.
@@ -76,7 +173,7 @@
     static int count;
     int get() const { return num; }
     int get2() { return num; }
-    void set(int x) { num = x; }
+    int set(int x) { num = x; return num; }
     static int zero() { return 0; }
 
     A() {}
@@ -84,13 +181,20 @@
     A(int x) {}
     A(int *x) {}
     A(A *a) {}
+    A(A &&a) {}
     ~A();
+    bool operator!();
+    bool operator!=(const A&);
 };
 
+bool operator!=(int, const A&);
+
 A getA() { return A(); }
 A getA(int x) { return A(); }
 A getA(A* a) { return A(); }
 A getA(A a) { return A(); }
+A moveA(A&& a) { return A(); }
+A const_refA(const A& a) { return A(); }
 
 void setupA(bool x) {
   A a1;
@@ -127,9 +231,36 @@
   A *a26 = new A(a26->get());    // expected-warning {{variable 'a26' is uninitialized when used within its own initialization}}
   A *a27 = new A(a27->get2());  // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}}
   A *a28 = new A(a28->num);  // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}}
+
+  const A a29(a29);  // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}}
+  const A a30 = a30;  // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}}
+
+  A a31 = std::move(a31);  // expected-warning {{variable 'a31' is uninitialized when used within its own initialization}}
+  A a32 = moveA(std::move(a32));  // expected-warning {{variable 'a32' is uninitialized when used within its own initialization}}
+  A a33 = A(std::move(a33));   // expected-warning {{variable 'a33' is uninitialized when used within its own initialization}}
+  A a34(std::move(a34));   // expected-warning {{variable 'a34' is uninitialized when used within its own initialization}}
+  A a35 = std::move(x ? a34 : (37, a35));  // expected-warning {{variable 'a35' is uninitialized when used within its own initialization}}
+
+  A a36 = const_refA(a36);
+  A a37(const_refA(a37));
+
+  A a38({a38});  // expected-warning {{variable 'a38' is uninitialized when used within its own initialization}}
+  A a39 = {a39};  // expected-warning {{variable 'a39' is uninitialized when used within its own initialization}}
+  A a40 = A({a40});  // expected-warning {{variable 'a40' is uninitialized when used within its own initialization}}
+
+  A a41 = !a41;  // expected-warning {{variable 'a41' is uninitialized when used within its own initialization}}
+  A a42 = !(a42);  // expected-warning {{variable 'a42' is uninitialized when used within its own initialization}}
+  A a43 = a43 != a42;  // expected-warning {{variable 'a43' is uninitialized when used within its own initialization}}
+  A a44 = a43 != a44;  // expected-warning {{variable 'a44' is uninitialized when used within its own initialization}}
+  A a45 = a45 != a45;  // expected-warning 2{{variable 'a45' is uninitialized when used within its own initialization}}
+  A a46 = 0 != a46;  // expected-warning {{variable 'a46' is uninitialized when used within its own initialization}}
+
+  A a47(a47.set(a47.num));  // expected-warning 2{{variable 'a47' is uninitialized when used within its own initialization}}
+  A a48(a47.set(a48.num));  // expected-warning {{variable 'a48' is uninitialized when used within its own initialization}}
+  A a49(a47.set(a48.num));
 }
 
-bool x;
+bool cond;
 
 A a1;
 A a2(a1.get());
@@ -149,8 +280,8 @@
 A a15 = getA(a15.num);  // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}}
 A a16(&a16.num);  // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}}
 A a17(a17.get2());  // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}}
-A a18 = x ? a18 : a17;  // expected-warning {{variable 'a18' is uninitialized when used within its own initialization}}
-A a19 = getA(x ? a19 : a17);  // expected-warning {{variable 'a19' is uninitialized when used within its own initialization}}
+A a18 = cond ? a18 : a17;  // expected-warning {{variable 'a18' is uninitialized when used within its own initialization}}
+A a19 = getA(cond ? a19 : a17);  // expected-warning {{variable 'a19' is uninitialized when used within its own initialization}}
 A a20{a20};  // expected-warning {{variable 'a20' is uninitialized when used within its own initialization}}
 A a21 = {a21};  // expected-warning {{variable 'a21' is uninitialized when used within its own initialization}}
 
@@ -163,6 +294,101 @@
 A *a27 = new A(a27->get2());  // expected-warning {{variable 'a27' is uninitialized when used within its own initialization}}
 A *a28 = new A(a28->num);  // expected-warning {{variable 'a28' is uninitialized when used within its own initialization}}
 
+const A a29(a29);  // expected-warning {{variable 'a29' is uninitialized when used within its own initialization}}
+const A a30 = a30;  // expected-warning {{variable 'a30' is uninitialized when used within its own initialization}}
+
+A a31 = std::move(a31);  // expected-warning {{variable 'a31' is uninitialized when used within its own initialization}}
+A a32 = moveA(std::move(a32));  // expected-warning {{variable 'a32' is uninitialized when used within its own initialization}}
+A a33 = A(std::move(a33));   // expected-warning {{variable 'a33' is uninitialized when used within its own initialization}}
+A a34(std::move(a34));   // expected-warning {{variable 'a34' is uninitialized when used within its own initialization}}
+A a35 = std::move(x ? a34 : (37, a35));  // expected-warning {{variable 'a35' is uninitialized when used within its own initialization}}
+
+A a36 = const_refA(a36);
+A a37(const_refA(a37));
+
+A a38({a38});  // expected-warning {{variable 'a38' is uninitialized when used within its own initialization}}
+A a39 = {a39};  // expected-warning {{variable 'a39' is uninitialized when used within its own initialization}}
+A a40 = A({a40});  // expected-warning {{variable 'a40' is uninitialized when used within its own initialization}}
+
+A a41 = !a41;  // expected-warning {{variable 'a41' is uninitialized when used within its own initialization}}
+A a42 = !(a42);  // expected-warning {{variable 'a42' is uninitialized when used within its own initialization}}
+A a43 = a43 != a42;  // expected-warning {{variable 'a43' is uninitialized when used within its own initialization}}
+A a44 = a43 != a44;  // expected-warning {{variable 'a44' is uninitialized when used within its own initialization}}
+A a45 = a45 != a45;  // expected-warning 2{{variable 'a45' is uninitialized when used within its own initialization}}
+
+A a46 = 0 != a46;  // expected-warning {{variable 'a46' is uninitialized when used within its own initialization}}
+
+A a47(a47.set(a47.num));  // expected-warning 2{{variable 'a47' is uninitialized when used within its own initialization}}
+A a48(a47.set(a48.num));  // expected-warning {{variable 'a48' is uninitialized when used within its own initialization}}
+A a49(a47.set(a48.num));
+
+class T {
+  A a, a2;
+  const A c_a;
+  A* ptr_a;
+
+  T() {}
+  T(bool (*)[1]) : a() {}
+  T(bool (*)[2]) : a2(a.get()) {}
+  T(bool (*)[3]) : a2(a) {}
+  T(bool (*)[4]) : a(&a) {}
+  T(bool (*)[5]) : a(a.zero()) {}
+  T(bool (*)[6]) : a(a.ONE) {}
+  T(bool (*)[7]) : a(getA()) {}
+  T(bool (*)[8]) : a2(getA(a.TWO)) {}
+  T(bool (*)[9]) : a(getA(&a)) {}
+  T(bool (*)[10]) : a(a.count) {}
+
+  T(bool (*)[11]) : a(a) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[12]) : a(a.get()) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[13]) : a(a.num) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[14]) : a(A(a)) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[15]) : a(getA(a.num)) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[16]) : a(&a.num) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[17]) : a(a.get2()) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[18]) : a2(cond ? a2 : a) {}  // expected-warning {{field 'a2' is uninitialized when used here}}
+  T(bool (*)[19]) : a2(cond ? a2 : a) {}  // expected-warning {{field 'a2' is uninitialized when used here}}
+  T(bool (*)[20]) : a{a} {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[21]) : a({a}) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+
+  T(bool (*)[22]) : ptr_a(new A(ptr_a->count)) {}
+  T(bool (*)[23]) : ptr_a(new A(ptr_a->ONE)) {}
+  T(bool (*)[24]) : ptr_a(new A(ptr_a->TWO)) {}
+  T(bool (*)[25]) : ptr_a(new A(ptr_a->zero())) {}
+
+  T(bool (*)[26]) : ptr_a(new A(ptr_a->get())) {}  // expected-warning {{field 'ptr_a' is uninitialized when used here}}
+  T(bool (*)[27]) : ptr_a(new A(ptr_a->get2())) {}  // expected-warning {{field 'ptr_a' is uninitialized when used here}}
+  T(bool (*)[28]) : ptr_a(new A(ptr_a->num)) {}  // expected-warning {{field 'ptr_a' is uninitialized when used here}}
+
+  T(bool (*)[29]) : c_a(c_a) {}  // expected-warning {{field 'c_a' is uninitialized when used here}}
+  T(bool (*)[30]) : c_a(A(c_a)) {}  // expected-warning {{field 'c_a' is uninitialized when used here}}
+
+  T(bool (*)[31]) : a(std::move(a)) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[32]) : a(moveA(std::move(a))) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[33]) : a(A(std::move(a))) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[34]) : a(A(std::move(a))) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[35]) : a2(std::move(x ? a : (37, a2))) {}  // expected-warning {{field 'a2' is uninitialized when used here}}
+
+  T(bool (*)[36]) : a(const_refA(a)) {}
+  T(bool (*)[37]) : a(A(const_refA(a))) {}
+
+  T(bool (*)[38]) : a({a}) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[39]) : a{a} {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[40]) : a({a}) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+
+  T(bool (*)[41]) : a(!a) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[42]) : a(!(a)) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+  T(bool (*)[43]) : a(), a2(a2 != a) {}  // expected-warning {{field 'a2' is uninitialized when used here}}
+  T(bool (*)[44]) : a(), a2(a != a2) {}  // expected-warning {{field 'a2' is uninitialized when used here}}
+  T(bool (*)[45]) : a(a != a) {}  // expected-warning 2{{field 'a' is uninitialized when used here}}
+  T(bool (*)[46]) : a(0 != a) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+
+  T(bool (*)[47]) : a2(a2.set(a2.num)) {}  // expected-warning 2{{field 'a2' is uninitialized when used here}}
+  T(bool (*)[48]) : a2(a.set(a2.num)) {}  // expected-warning {{field 'a2' is uninitialized when used here}}
+  T(bool (*)[49]) : a2(a.set(a.num)) {}
+
+};
+
 struct B {
   // POD struct.
   int x;
@@ -173,13 +399,14 @@
 B getB(int x) { return B(); };
 B getB(int *x) { return B(); };
 B getB(B *b) { return B(); };
+B moveB(B &&b) { return B(); };
 
 B* getPtrB() { return 0; };
 B* getPtrB(int x) { return 0; };
 B* getPtrB(int *x) { return 0; };
 B* getPtrB(B **b) { return 0; };
 
-void setupB() {
+void setupB(bool x) {
   B b1;
   B b2(b1);
   B b3 = { 5, &b3.x };
@@ -209,6 +436,14 @@
 
   B b17 = { b17.x = 5, b17.y = 0 };
   B b18 = { b18.x + 1, b18.y };  // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}}
+
+  const B b19 = b19;  // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}}
+  const B b20(b20);  // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}}
+
+  B b21 = std::move(b21);  // expected-warning {{variable 'b21' is uninitialized when used within its own initialization}}
+  B b22 = moveB(std::move(b22));  // expected-warning {{variable 'b22' is uninitialized when used within its own initialization}}
+  B b23 = B(std::move(b23));   // expected-warning {{variable 'b23' is uninitialized when used within its own initialization}}
+  B b24 = std::move(x ? b23 : (18, b24));  // expected-warning {{variable 'b24' is uninitialized when used within its own initialization}}
 }
 
 B b1;
@@ -234,25 +469,50 @@
 B b17 = { b17.x = 5, b17.y = 0 };
 B b18 = { b18.x + 1, b18.y };  // expected-warning 2{{variable 'b18' is uninitialized when used within its own initialization}}
 
+const B b19 = b19;  // expected-warning {{variable 'b19' is uninitialized when used within its own initialization}}
+const B b20(b20);  // expected-warning {{variable 'b20' is uninitialized when used within its own initialization}}
 
-// Also test similar constructs in a field's initializer.
-struct S {
-  int x;
-  void *ptr;
+B b21 = std::move(b21);  // expected-warning {{variable 'b21' is uninitialized when used within its own initialization}}
+B b22 = moveB(std::move(b22));  // expected-warning {{variable 'b22' is uninitialized when used within its own initialization}}
+B b23 = B(std::move(b23));   // expected-warning {{variable 'b23' is uninitialized when used within its own initialization}}
+B b24 = std::move(x ? b23 : (18, b24));  // expected-warning {{variable 'b24' is uninitialized when used within its own initialization}}
 
-  S(bool (*)[1]) : x(x) {} // expected-warning {{field 'x' is uninitialized when used here}}
-  S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field 'x' is uninitialized when used here}}
-  S(bool (*)[3]) : x(x + x) {} // expected-warning 2{{field 'x' is uninitialized when used here}}
-  S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field 'x' is uninitialized when used here}}
-  S(bool (*)[5]) : x(foo(x)) {} // expected-warning {{field 'x' is uninitialized when used here}}
+class U {
+  B b1, b2;
+  B *ptr1, *ptr2;
+  const B constb = {};
 
-  // These don't actually require the value of x and so shouldn't warn.
-  S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363
-  S(char (*)[2]) : ptr(&ptr) {}
-  S(char (*)[3]) : x(__alignof__(x)) {}
-  S(char (*)[4]) : x(bar(&x)) {}
-  S(char (*)[5]) : x(boo(x)) {}
-  S(char (*)[6]) : x(far(x)) {}
+  U() {}
+  U(bool (*)[1]) : b1() {}
+  U(bool (*)[2]) : b2(b1) {}
+  U(bool (*)[3]) : b1{ 5, &b1.x } {}
+  U(bool (*)[4]) : b1(getB()) {}
+  U(bool (*)[5]) : b1(getB(&b1)) {}
+  U(bool (*)[6]) : b1(getB(&b1.x)) {}
+
+  U(bool (*)[7]) : b1(b1) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+  U(bool (*)[8]) : b1(getB(b1.x)) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+  U(bool (*)[9]) : b1(getB(b1.y)) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+  U(bool (*)[10]) : b1(getB(-b1.x)) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+
+  U(bool (*)[11]) : ptr1(0) {}
+  U(bool (*)[12]) : ptr1(0), ptr2(ptr1) {}
+  U(bool (*)[13]) : ptr1(getPtrB()) {}
+  U(bool (*)[14]) : ptr1(getPtrB(&ptr1)) {}
+
+  U(bool (*)[15]) : ptr1(getPtrB(ptr1->x)) {}  // expected-warning {{field 'ptr1' is uninitialized when used here}}
+  U(bool (*)[16]) : ptr2(getPtrB(ptr2->y)) {}  // expected-warning {{field 'ptr2' is uninitialized when used here}}
+
+  U(bool (*)[17]) : b1 { b1.x = 5, b1.y = 0 } {}
+  U(bool (*)[18]) : b1 { b1.x + 1, b1.y } {}  // expected-warning 2{{field 'b1' is uninitialized when used here}}
+
+  U(bool (*)[19]) : constb(constb) {}  // expected-warning {{field 'constb' is uninitialized when used here}}
+  U(bool (*)[20]) : constb(B(constb)) {}  // expected-warning {{field 'constb' is uninitialized when used here}}
+
+  U(bool (*)[21]) : b1(std::move(b1)) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+  U(bool (*)[22]) : b1(moveB(std::move(b1))) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+  U(bool (*)[23]) : b1(B(std::move(b1))) {}  // expected-warning {{field 'b1' is uninitialized when used here}}
+  U(bool (*)[24]) : b2(std::move(x ? b1 : (18, b2))) {}  // expected-warning {{field 'b2' is uninitialized when used here}}
 };
 
 struct C { char a[100], *e; } car = { .e = car.a };
@@ -360,6 +620,8 @@
     E(char (*)[12]) : a((b + c, c, a)) {} // expected-warning {{field 'a' is uninitialized when used here}}
     E(char (*)[13]) : a((a, a, a, a)) {} // expected-warning {{field 'a' is uninitialized when used here}}
     E(char (*)[14]) : a((b, c, c)) {}
+    E(char (*)[15]) : a(b ?: a) {} // expected-warning {{field 'a' is uninitialized when used here}}
+    E(char (*)[16]) : a(a ?: b) {} // expected-warning {{field 'a' is uninitialized when used here}}
   };
 
   struct F {
@@ -385,6 +647,11 @@
     G(char (*)[7]) : f3(f3->*f_ptr) {} // expected-warning {{field 'f3' is uninitialized when used here}}
     G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field 'f3' is uninitialized when used here}}
   };
+
+  struct H {
+    H() : a(a) {}  // expected-warning {{field 'a' is uninitialized when used here}}
+    const A a;
+  };
 }
 
 namespace statics {
@@ -406,6 +673,21 @@
   static int l = k ? l : l;  // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}}
   static int m = 1 + (k ? m : m);  // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}}
   static int n = -n;  // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
+  static int o = std::move(o); // expected-warning {{variable 'o' is uninitialized when used within its own initialization}}
+  static const int p = std::move(p); // expected-warning {{variable 'p' is uninitialized when used within its own initialization}}
+  static int q = moved(std::move(q)); // expected-warning {{variable 'q' is uninitialized when used within its own initialization}}
+  static int r = std::move((p ? q : (18, r))); // expected-warning {{variable 'r' is uninitialized when used within its own initialization}}
+  static int s = r ?: s; // expected-warning {{variable 's' is uninitialized when used within its own initialization}}
+  static int t = t ?: s; // expected-warning {{variable 't' is uninitialized when used within its own initialization}}
+  static int u = (foo(u), s); // expected-warning {{variable 'u' is uninitialized when used within its own initialization}}
+  static int v = (u += v); // expected-warning {{variable 'v' is uninitialized when used within its own initialization}}
+  static int w = (w += 10); // expected-warning {{variable 'w' is uninitialized when used within its own initialization}}
+  static int x = x++; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
+  static int y = ((s ? (y, v) : (77, y))++, sizeof(y)); // expected-warning {{variable 'y' is uninitialized when used within its own initialization}}
+  static int z = ++ref(z); // expected-warning {{variable 'z' is uninitialized when used within its own initialization}}
+  static int aa = (ref(aa) += 10); // expected-warning {{variable 'aa' is uninitialized when used within its own initialization}}
+  static int bb = bb ? x : y; // expected-warning {{variable 'bb' is uninitialized when used within its own initialization}}
+
 
   void test() {
     static int a = a; // no-warning: used to signal intended lack of initialization.
@@ -426,7 +708,22 @@
     static int l = k ? l : l;  // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}}
     static int m = 1 + (k ? m : m);  // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}}
     static int n = -n;  // expected-warning {{static variable 'n' is suspiciously used within its own initialization}}
-   for (;;) {
+    static int o = std::move(o);  // expected-warning {{static variable 'o' is suspiciously used within its own initialization}}
+    static const int p = std::move(p);  // expected-warning {{static variable 'p' is suspiciously used within its own initialization}}
+    static int q = moved(std::move(q));  // expected-warning {{static variable 'q' is suspiciously used within its own initialization}}
+    static int r = std::move((p ? q : (18, r)));  // expected-warning {{static variable 'r' is suspiciously used within its own initialization}}
+    static int s = r ?: s;  // expected-warning {{static variable 's' is suspiciously used within its own initialization}}
+    static int t = t ?: s;  // expected-warning {{static variable 't' is suspiciously used within its own initialization}}
+    static int u = (foo(u), s);  // expected-warning {{static variable 'u' is suspiciously used within its own initialization}}
+    static int v = (u += v);  // expected-warning {{static variable 'v' is suspiciously used within its own initialization}}
+    static int w = (w += 10);  // expected-warning {{static variable 'w' is suspiciously used within its own initialization}}
+    static int x = x++;  // expected-warning {{static variable 'x' is suspiciously used within its own initialization}}
+    static int y = ((s ? (y, v) : (77, y))++, sizeof(y));  // expected-warning {{static variable 'y' is suspiciously used within its own initialization}}
+    static int z = ++ref(z); // expected-warning {{static variable 'z' is suspiciously used within its own initialization}}
+    static int aa = (ref(aa) += 10); // expected-warning {{static variable 'aa' is suspiciously used within its own initialization}}
+    static int bb = bb ? x : y; // expected-warning {{static variable 'bb' is suspiciously used within its own initialization}}
+
+    for (;;) {
       static int a = a; // no-warning: used to signal intended lack of initialization.
       static int b = b + 1; // expected-warning {{static variable 'b' is suspiciously used within its own initialization}}
       static int c = (c + c); // expected-warning 2{{static variable 'c' is suspiciously used within its own initialization}}
@@ -445,6 +742,20 @@
       static int l = k ? l : l;  // expected-warning 2{{static variable 'l' is suspiciously used within its own initialization}}
       static int m = 1 + (k ? m : m); // expected-warning 2{{static variable 'm' is suspiciously used within its own initialization}}
       static int n = -n;  // expected-warning {{static variable 'n' is suspiciously used within its own initialization}}
+      static int o = std::move(o);  // expected-warning {{static variable 'o' is suspiciously used within its own initialization}}
+      static const int p = std::move(p);  // expected-warning {{static variable 'p' is suspiciously used within its own initialization}}
+      static int q = moved(std::move(q));  // expected-warning {{static variable 'q' is suspiciously used within its own initialization}}
+      static int r = std::move((p ? q : (18, r)));  // expected-warning {{static variable 'r' is suspiciously used within its own initialization}}
+      static int s = r ?: s;  // expected-warning {{static variable 's' is suspiciously used within its own initialization}}
+      static int t = t ?: s;  // expected-warning {{static variable 't' is suspiciously used within its own initialization}}
+      static int u = (foo(u), s);  // expected-warning {{static variable 'u' is suspiciously used within its own initialization}}
+      static int v = (u += v);  // expected-warning {{static variable 'v' is suspiciously used within its own initialization}}
+      static int w = (w += 10);  // expected-warning {{static variable 'w' is suspiciously used within its own initialization}}
+      static int x = x++;  // expected-warning {{static variable 'x' is suspiciously used within its own initialization}}
+      static int y = ((s ? (y, v) : (77, y))++, sizeof(y));  // expected-warning {{static variable 'y' is suspiciously used within its own initialization}}
+      static int z = ++ref(z); // expected-warning {{static variable 'z' is suspiciously used within its own initialization}}
+      static int aa = (ref(aa) += 10); // expected-warning {{static variable 'aa' is suspiciously used within its own initialization}}
+      static int bb = bb ? x : y; // expected-warning {{static variable 'bb' is suspiciously used within its own initialization}}
     }
   }
 }
@@ -473,13 +784,21 @@
   int &b(b); // expected-warning{{reference 'b' is not yet bound to a value when used within its own initialization}}
   int &c = a ? b : c; // expected-warning{{reference 'c' is not yet bound to a value when used within its own initialization}}
   int &d{d}; // expected-warning{{reference 'd' is not yet bound to a value when used within its own initialization}}
+  int &e = d ?: e; // expected-warning{{reference 'e' is not yet bound to a value when used within its own initialization}}
+  int &f = f ?: d; // expected-warning{{reference 'f' is not yet bound to a value when used within its own initialization}}
+
+  int &return_ref1(int);
+  int &return_ref2(int&);
+
+  int &g = return_ref1(g); // expected-warning{{reference 'g' is not yet bound to a value when used within its own initialization}}
+  int &h = return_ref2(h); // expected-warning{{reference 'h' is not yet bound to a value when used within its own initialization}}
 
   struct S {
     S() : a(a) {} // expected-warning{{reference 'a' is not yet bound to a value when used here}}
     int &a;
   };
 
-  void f() {
+  void test() {
     int &a = a; // expected-warning{{reference 'a' is not yet bound to a value when used within its own initialization}}
     int &b(b); // expected-warning{{reference 'b' is not yet bound to a value when used within its own initialization}}
     int &c = a ? b : c; // expected-warning{{reference 'c' is not yet bound to a value when used within its own initialization}}
@@ -529,6 +848,7 @@
 }
 
 namespace record_fields {
+  bool x;
   struct A {
     A() {}
     A get();
@@ -541,6 +861,7 @@
   A const_ref(const A&);
   A pointer(A*);
   A normal(A);
+  A rref(A&&);
 
   struct B {
     A a;
@@ -553,9 +874,13 @@
     B(char (*)[7]) : a(const_ref(a)) {}
     B(char (*)[8]) : a(pointer(&a)) {}
     B(char (*)[9]) : a(normal(a)) {}  // expected-warning {{uninitialized}}
+    B(char (*)[10]) : a(std::move(a)) {}  // expected-warning {{uninitialized}}
+    B(char (*)[11]) : a(A(std::move(a))) {}  // expected-warning {{uninitialized}}
+    B(char (*)[12]) : a(rref(std::move(a))) {}  // expected-warning {{uninitialized}}
+    B(char (*)[13]) : a(std::move(x ? a : (25, a))) {}  // expected-warning 2{{uninitialized}}
   };
   struct C {
-    C() {} // expected-note4{{in this constructor}}
+    C() {} // expected-note9{{in this constructor}}
     A a1 = a1;  // expected-warning {{uninitialized}}
     A a2 = a2.get();  // expected-warning {{uninitialized}}
     A a3 = a3.num();
@@ -565,8 +890,13 @@
     A a7 = const_ref(a7);
     A a8 = pointer(&a8);
     A a9 = normal(a9);  // expected-warning {{uninitialized}}
+    const A a10 = a10;  // expected-warning {{uninitialized}}
+    A a11 = std::move(a11);  // expected-warning {{uninitialized}}
+    A a12 = A(std::move(a12));  // expected-warning {{uninitialized}}
+    A a13 = rref(std::move(a13));  // expected-warning {{uninitialized}}
+    A a14 = std::move(x ? a13 : (22, a14));  // expected-warning {{uninitialized}}
   };
-  struct D {  // expected-note4{{in the implicit default constructor}}
+  struct D {  // expected-note9{{in the implicit default constructor}}
     A a1 = a1;  // expected-warning {{uninitialized}}
     A a2 = a2.get();  // expected-warning {{uninitialized}}
     A a3 = a3.num();
@@ -576,6 +906,11 @@
     A a7 = const_ref(a7);
     A a8 = pointer(&a8);
     A a9 = normal(a9);  // expected-warning {{uninitialized}}
+    const A a10 = a10;  // expected-warning {{uninitialized}}
+    A a11 = std::move(a11);  // expected-warning {{uninitialized}}
+    A a12 = A(std::move(a12));  // expected-warning {{uninitialized}}
+    A a13 = rref(std::move(a13));  // expected-warning {{uninitialized}}
+    A a14 = std::move(x ? a13 : (22, a14));  // expected-warning {{uninitialized}}
   };
   D d;
   struct E {
@@ -588,6 +923,11 @@
     A a7 = const_ref(a7);
     A a8 = pointer(&a8);
     A a9 = normal(a9);
+    const A a10 = a10;
+    A a11 = std::move(a11);
+    A a12 = A(std::move(a12));
+    A a13 = rref(std::move(a13));
+    A a14 = std::move(x ? a13 : (22, a14));
   };
 }
 
@@ -710,6 +1050,20 @@
     int d = a + b + c;
     R() : a(c = 5), b(c), c(a) {}
   };
+
+  // FIXME: Use the CFG-based analysis to give a sometimes uninitialized
+  // warning on y.
+  struct T {
+    int x;
+    int y;
+    T(bool b)
+        : x(b ? (y = 5) : (1 + y)),  // expected-warning{{field 'y' is uninitialized when used here}}
+          y(y + 1) {}
+    T(int b)
+        : x(!b ? (1 + y) : (y = 5)),  // expected-warning{{field 'y' is uninitialized when used here}}
+          y(y + 1) {}
+  };
+
 }
 
 namespace base_class {
@@ -728,3 +1082,223 @@
     C() : A(y = 4), x(y) {}
   };
 }
+
+namespace delegating_constructor {
+  struct A {
+    A(int);
+    A(int&, int);
+
+    A(char (*)[1]) : A(x) {}
+    // expected-warning@-1 {{field 'x' is uninitialized when used here}}
+    A(char (*)[2]) : A(x, x) {}
+    // expected-warning@-1 {{field 'x' is uninitialized when used here}}
+
+    A(char (*)[3]) : A(x, 0) {}
+
+    int x;
+  };
+}
+
+namespace init_list {
+  int num = 5;
+  struct A { int i1, i2; };
+  struct B { A a1, a2; };
+
+  A a1{1,2};
+  A a2{a2.i1 + 2};  // expected-warning{{uninitialized}}
+  A a3 = {a3.i1 + 2};  // expected-warning{{uninitialized}}
+  A a4 = A{a4.i2 + 2};  // expected-warning{{uninitialized}}
+
+  B b1 = { {}, {} };
+  B b2 = { {}, b2.a1 };
+  B b3 = { b3.a1 };  // expected-warning{{uninitialized}}
+  B b4 = { {}, b4.a2} ;  // expected-warning{{uninitialized}}
+  B b5 = { b5.a2 };  // expected-warning{{uninitialized}}
+
+  B b6 = { {b6.a1.i1} };  // expected-warning{{uninitialized}}
+  B b7 = { {0, b7.a1.i1} };
+  B b8 = { {}, {b8.a1.i1} };
+  B b9 = { {}, {0, b9.a1.i1} };
+
+  B b10 = { {b10.a1.i2} };  // expected-warning{{uninitialized}}
+  B b11 = { {0, b11.a1.i2} };  // expected-warning{{uninitialized}}
+  B b12 = { {}, {b12.a1.i2} };
+  B b13 = { {}, {0, b13.a1.i2} };
+
+  B b14 = { {b14.a2.i1} };  // expected-warning{{uninitialized}}
+  B b15 = { {0, b15.a2.i1} };  // expected-warning{{uninitialized}}
+  B b16 = { {}, {b16.a2.i1} };  // expected-warning{{uninitialized}}
+  B b17 = { {}, {0, b17.a2.i1} };
+
+  B b18 = { {b18.a2.i2} };  // expected-warning{{uninitialized}}
+  B b19 = { {0, b19.a2.i2} };  // expected-warning{{uninitialized}}
+  B b20 = { {}, {b20.a2.i2} };  // expected-warning{{uninitialized}}
+  B b21 = { {}, {0, b21.a2.i2} };  // expected-warning{{uninitialized}}
+
+  B b22 = { {b18.a2.i2 + 5} };
+
+  struct C {int a; int& b; int c; };
+  C c1 = { 0, num, 0 };
+  C c2 = { 1, num, c2.b };
+  C c3 = { c3.b, num };  // expected-warning{{uninitialized}}
+  C c4 = { 0, c4.b, 0 };  // expected-warning{{uninitialized}}
+  C c5 = { 0, c5.c, 0 };
+  C c6 = { c6.b, num, 0 };  // expected-warning{{uninitialized}}
+  C c7 = { 0, c7.a, 0 };
+
+  struct D {int &a; int &b; };
+  D d1 = { num, num };
+  D d2 = { num, d2.a };
+  D d3 = { d3.b, num };  // expected-warning{{uninitialized}}
+
+  // Same as above in member initializer form.
+  struct Awrapper {
+    A a1{1,2};
+    A a2{a2.i1 + 2};  // expected-warning{{uninitialized}}
+    A a3 = {a3.i1 + 2};  // expected-warning{{uninitialized}}
+    A a4 = A{a4.i2 + 2};  // expected-warning{{uninitialized}}
+    Awrapper() {}  // expected-note 3{{in this constructor}}
+    Awrapper(int) :
+      a1{1,2},
+      a2{a2.i1 + 2},  // expected-warning{{uninitialized}}
+      a3{a3.i1 + 2},  // expected-warning{{uninitialized}}
+      a4{a4.i2 + 2}  // expected-warning{{uninitialized}}
+    {}
+  };
+
+  struct Bwrapper {
+    B b1 = { {}, {} };
+    B b2 = { {}, b2.a1 };
+    B b3 = { b3.a1 };  // expected-warning{{uninitialized}}
+    B b4 = { {}, b4.a2} ;  // expected-warning{{uninitialized}}
+    B b5 = { b5.a2 };  // expected-warning{{uninitialized}}
+
+    B b6 = { {b6.a1.i1} };  // expected-warning{{uninitialized}}
+    B b7 = { {0, b7.a1.i1} };
+    B b8 = { {}, {b8.a1.i1} };
+    B b9 = { {}, {0, b9.a1.i1} };
+
+    B b10 = { {b10.a1.i2} };  // expected-warning{{uninitialized}}
+    B b11 = { {0, b11.a1.i2} };  // expected-warning{{uninitialized}}
+    B b12 = { {}, {b12.a1.i2} };
+    B b13 = { {}, {0, b13.a1.i2} };
+
+    B b14 = { {b14.a2.i1} };  // expected-warning{{uninitialized}}
+    B b15 = { {0, b15.a2.i1} };  // expected-warning{{uninitialized}}
+    B b16 = { {}, {b16.a2.i1} };  // expected-warning{{uninitialized}}
+    B b17 = { {}, {0, b17.a2.i1} };
+
+    B b18 = { {b18.a2.i2} };  // expected-warning{{uninitialized}}
+    B b19 = { {0, b19.a2.i2} };  // expected-warning{{uninitialized}}
+    B b20 = { {}, {b20.a2.i2} };  // expected-warning{{uninitialized}}
+    B b21 = { {}, {0, b21.a2.i2} };  // expected-warning{{uninitialized}}
+
+    B b22 = { {b18.a2.i2 + 5} };
+    Bwrapper() {}  // expected-note 13{{in this constructor}}
+    Bwrapper(int) :
+      b1{ {}, {} },
+      b2{ {}, b2.a1 },
+      b3{ b3.a1 },  // expected-warning{{uninitialized}}
+      b4{ {}, b4.a2}, // expected-warning{{uninitialized}}
+      b5{ b5.a2 },  // expected-warning{{uninitialized}}
+
+      b6{ {b6.a1.i1} },  // expected-warning{{uninitialized}}
+      b7{ {0, b7.a1.i1} },
+      b8{ {}, {b8.a1.i1} },
+      b9{ {}, {0, b9.a1.i1} },
+
+      b10{ {b10.a1.i2} },  // expected-warning{{uninitialized}}
+      b11{ {0, b11.a1.i2} },  // expected-warning{{uninitialized}}
+      b12{ {}, {b12.a1.i2} },
+      b13{ {}, {0, b13.a1.i2} },
+
+      b14{ {b14.a2.i1} },  // expected-warning{{uninitialized}}
+      b15{ {0, b15.a2.i1} },  // expected-warning{{uninitialized}}
+      b16{ {}, {b16.a2.i1} },  // expected-warning{{uninitialized}}
+      b17{ {}, {0, b17.a2.i1} },
+
+      b18{ {b18.a2.i2} },  // expected-warning{{uninitialized}}
+      b19{ {0, b19.a2.i2} },  // expected-warning{{uninitialized}}
+      b20{ {}, {b20.a2.i2} },  // expected-warning{{uninitialized}}
+      b21{ {}, {0, b21.a2.i2} },  // expected-warning{{uninitialized}}
+
+      b22{ {b18.a2.i2 + 5} }
+    {}
+  };
+
+  struct Cwrapper {
+    C c1 = { 0, num, 0 };
+    C c2 = { 1, num, c2.b };
+    C c3 = { c3.b, num };  // expected-warning{{uninitialized}}
+    C c4 = { 0, c4.b, 0 };  // expected-warning{{uninitialized}}
+    C c5 = { 0, c5.c, 0 };
+    C c6 = { c6.b, num, 0 };  // expected-warning{{uninitialized}}
+    C c7 = { 0, c7.a, 0 };
+
+    Cwrapper() {} // expected-note 3{{in this constructor}}
+    Cwrapper(int) :
+      c1{ 0, num, 0 },
+      c2{ 1, num, c2.b },
+      c3{ c3.b, num },  // expected-warning{{uninitialized}}
+      c4{ 0, c4.b, 0 },  // expected-warning{{uninitialized}}
+      c5{ 0, c5.c, 0 },
+      c6{ c6.b, num, 0 },  // expected-warning{{uninitialized}}
+      c7{ 0, c7.a, 0 }
+    {}
+  };
+
+  struct Dwrapper {
+    D d1 = { num, num };
+    D d2 = { num, d2.a };
+    D d3 = { d3.b, num }; // expected-warning{{uninitialized}}
+    Dwrapper() {}  // expected-note{{in this constructor}}
+    Dwrapper(int) :
+      d1{ num, num },
+      d2{ num, d2.a },
+      d3{ d3.b, num } // expected-warning{{uninitialized}}
+    {}
+  };
+}
+
+namespace template_class {
+class Foo {
+ public:
+    int *Create() { return nullptr; }
+};
+
+template <typename T>
+class A {
+public:
+  // Don't warn on foo here.
+  A() : ptr(foo->Create()) {}
+
+private:
+  Foo *foo = new Foo;
+  int *ptr;
+};
+
+template <typename T>
+class B {
+public:
+  // foo is uninitialized here, but class B is never instantiated.
+  B() : ptr(foo->Create()) {}
+
+private:
+  Foo *foo;
+  int *ptr;
+};
+
+template <typename T>
+class C {
+public:
+  C() : ptr(foo->Create()) {}
+  // expected-warning@-1 {{field 'foo' is uninitialized when used here}}
+private:
+  Foo *foo;
+  int *ptr;
+};
+
+C<int> c;
+// expected-note@-1 {{in instantiation of member function 'template_class::C<int>::C' requested here}}
+
+}
diff --git a/test/SemaCXX/unknown-type-name.cpp b/test/SemaCXX/unknown-type-name.cpp
index f2c84df..9d28c31 100644
--- a/test/SemaCXX/unknown-type-name.cpp
+++ b/test/SemaCXX/unknown-type-name.cpp
@@ -27,7 +27,7 @@
 template<typename T>
 struct A {
   typedef T type;
-  
+
   type f();
 
   type g();
@@ -93,14 +93,14 @@
 template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}}
 template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}}
 
-template<typename T> int junk1(T::junk); // expected-warning{{variable templates are a C++1y extension}}
+template<typename T> int junk1(T::junk); // expected-warning{{variable templates are a C++14 extension}}
 template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
 template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}}
 template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}
 
 // FIXME: We can tell this was intended to be a function because it does not
 //        have a dependent nested name specifier.
-template<typename T> int i(T::type, int()); // expected-warning{{variable templates are a C++1y extension}}
+template<typename T> int i(T::type, int()); // expected-warning{{variable templates are a C++14 extension}}
 
 // FIXME: We know which type specifier should have been specified here. Provide
 //        a fix-it to add 'typename A<T>::type'
diff --git a/test/SemaCXX/vararg-non-pod.cpp b/test/SemaCXX/vararg-non-pod.cpp
index 56dafc4..66da996 100644
--- a/test/SemaCXX/vararg-non-pod.cpp
+++ b/test/SemaCXX/vararg-non-pod.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs
 
+// Check that the warning is still there under -fms-compatibility.
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs -fms-compatibility
+
 extern char version[];
 
 class C {
diff --git a/test/SemaCXX/warn-absolute-value-header.cpp b/test/SemaCXX/warn-absolute-value-header.cpp
index 96e6a31..925be38 100644
--- a/test/SemaCXX/warn-absolute-value-header.cpp
+++ b/test/SemaCXX/warn-absolute-value-header.cpp
@@ -16,25 +16,25 @@
   (void)abs(d);
   // expected-warning@-1{{using integer absolute value function 'abs' when argument is of floating point type}}
   // expected-note@-2{{use function 'std::abs' instead}}
-  // expected-note@-3{{please include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
+  // expected-note@-3{{include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"std::abs"
 
   (void)fabsf(d);
   // expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
   // expected-note@-2{{use function 'std::abs' instead}}
-  // expected-note@-3{{please include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
+  // expected-note@-3{{include the header <cmath> or explicitly provide a declaration for 'std::abs'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:14}:"std::abs"
 
   // Suggest including cstdlib
   (void)abs(ll);
   // expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
   // expected-note@-2{{use function 'std::abs' instead}}
-  // expected-note@-3{{please include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
+  // expected-note@-3{{include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:12}:"std::abs"
   (void)fabsf(ll);
   // expected-warning@-1{{using floating point absolute value function 'fabsf' when argument is of integer type}}
   // expected-note@-2{{use function 'std::abs' instead}}
-  // expected-note@-3{{please include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
+  // expected-note@-3{{include the header <cstdlib> or explicitly provide a declaration for 'std::abs'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:14}:"std::abs"
 
   // Proper function already called, no warnings.
diff --git a/test/SemaCXX/warn-bool-conversion.cpp b/test/SemaCXX/warn-bool-conversion.cpp
index b462894..b0c8d0d 100644
--- a/test/SemaCXX/warn-bool-conversion.cpp
+++ b/test/SemaCXX/warn-bool-conversion.cpp
@@ -118,3 +118,30 @@
     // expected-warning@-1{{address of 'S::a' will always evaluate to 'true'}}
   }
 }
+
+namespace macros {
+  #define assert(x) if (x) {}
+  #define zero_on_null(x) ((x) ? *(x) : 0)
+
+  int array[5];
+  void fun();
+  int x;
+
+  void test() {
+    assert(array);
+    assert(array && "expecting null pointer");
+    // expected-warning@-1{{address of array 'array' will always evaluate to 'true'}}
+
+    assert(fun);
+    assert(fun && "expecting null pointer");
+    // expected-warning@-1{{address of function 'fun' will always evaluate to 'true'}}
+    // expected-note@-2 {{prefix with the address-of operator to silence this warning}}
+
+    // TODO: warn on assert(&x) while not warning on zero_on_null(&x)
+    zero_on_null(&x);
+    assert(zero_on_null(&x));
+    assert(&x);
+    assert(&x && "expecting null pointer");
+    // expected-warning@-1{{address of 'x' will always evaluate to 'true'}}
+  }
+}
diff --git a/test/SemaCXX/warn-global-constructors.cpp b/test/SemaCXX/warn-global-constructors.cpp
index 90d8558..8568264 100644
--- a/test/SemaCXX/warn-global-constructors.cpp
+++ b/test/SemaCXX/warn-global-constructors.cpp
@@ -120,3 +120,9 @@
   };
   E e;
 }
+
+namespace pr20420 {
+// No warning is expected. This used to crash.
+void *array_storage[1];
+const int &global_reference = *(int *)array_storage;
+}
diff --git a/test/SemaCXX/warn-overloaded-virtual.cpp b/test/SemaCXX/warn-overloaded-virtual.cpp
index 629d59d..6204826 100644
--- a/test/SemaCXX/warn-overloaded-virtual.cpp
+++ b/test/SemaCXX/warn-overloaded-virtual.cpp
@@ -48,8 +48,8 @@
 void Base::foo(int) { }
 
 struct Derived : public Base {
-  virtual void foo(int);   
-  void foo(int, int);   
+  virtual void foo(int);
+  void foo(int, int);
 };
 }
 
@@ -138,3 +138,21 @@
     // expected-warning@-1{{hides overloaded virtual functions}}
   };
 }
+
+namespace {
+struct base {
+  void f(char) {}
+};
+
+struct derived : base {
+  void f(int) {}
+};
+
+void foo(derived &d) {
+  d.f('1'); // FIXME: this should warn about calling (anonymous namespace)::derived::f(int)
+            // instead of (anonymous namespace)::base::f(char).
+            // Note: this should be under a new diagnostic flag and eventually moved to a
+            // new test case since it's not strictly related to virtual functions.
+  d.f(12);  // This should not warn.
+}
+}
diff --git a/test/SemaCXX/warn-tautological-compare.cpp b/test/SemaCXX/warn-tautological-compare.cpp
index b44f3f9..7d5b4b1 100644
--- a/test/SemaCXX/warn-tautological-compare.cpp
+++ b/test/SemaCXX/warn-tautological-compare.cpp
@@ -136,3 +136,43 @@
     // expected-warning@-1{{comparison of address of 'S::a' equal to a null pointer is always false}}
   }
 }
+
+namespace macros {
+  #define assert(x) if (x) {}
+  int array[5];
+  void fun();
+  int x;
+
+  void test() {
+    assert(array == 0);
+    // expected-warning@-1{{comparison of array 'array' equal to a null pointer is always false}}
+    assert(array != 0);
+    // expected-warning@-1{{comparison of array 'array' not equal to a null pointer is always true}}
+    assert(array == 0 && "expecting null pointer");
+    // expected-warning@-1{{comparison of array 'array' equal to a null pointer is always false}}
+    assert(array != 0 && "expecting non-null pointer");
+    // expected-warning@-1{{comparison of array 'array' not equal to a null pointer is always true}}
+
+    assert(fun == 0);
+    // expected-warning@-1{{comparison of function 'fun' equal to a null pointer is always false}}
+    // expected-note@-2{{prefix with the address-of operator to silence this warning}}
+    assert(fun != 0);
+    // expected-warning@-1{{comparison of function 'fun' not equal to a null pointer is always true}}
+    // expected-note@-2{{prefix with the address-of operator to silence this warning}}
+    assert(fun == 0 && "expecting null pointer");
+    // expected-warning@-1{{comparison of function 'fun' equal to a null pointer is always false}}
+    // expected-note@-2{{prefix with the address-of operator to silence this warning}}
+    assert(fun != 0 && "expecting non-null pointer");
+    // expected-warning@-1{{comparison of function 'fun' not equal to a null pointer is always true}}
+    // expected-note@-2{{prefix with the address-of operator to silence this warning}}
+
+    assert(&x == 0);
+    // expected-warning@-1{{comparison of address of 'x' equal to a null pointer is always false}}
+    assert(&x != 0);
+    // expected-warning@-1{{comparison of address of 'x' not equal to a null pointer is always true}}
+    assert(&x == 0 && "expecting null pointer");
+    // expected-warning@-1{{comparison of address of 'x' equal to a null pointer is always false}}
+    assert(&x != 0 && "expecting non-null pointer");
+    // expected-warning@-1{{comparison of address of 'x' not equal to a null pointer is always true}}
+  }
+}
diff --git a/test/SemaCXX/warn-tautological-undefined-compare.cpp b/test/SemaCXX/warn-tautological-undefined-compare.cpp
index ce05bfc..9321c0e 100644
--- a/test/SemaCXX/warn-tautological-undefined-compare.cpp
+++ b/test/SemaCXX/warn-tautological-undefined-compare.cpp
@@ -110,3 +110,31 @@
     // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}}
   }
 }
+
+namespace macros {
+  #define assert(x) if (x) {}
+
+  void test(int &x) {
+    assert(&x != 0);
+    // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}}
+    assert(&x == 0);
+    // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}}
+    assert(&x != 0 && "Expecting valid reference");
+    // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to true}}
+    assert(&x == 0 && "Expecting invalid reference");
+    // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false}}
+  }
+
+  class S {
+    void test() {
+      assert(this != 0);
+      // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true}}
+      assert(this == 0);
+      // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false}}
+      assert(this != 0 && "Expecting valid reference");
+      // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to true}}
+      assert(this == 0 && "Expecting invalid reference");
+      // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false}}
+    }
+  };
+}
diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp
index 34a33aa..091e473 100644
--- a/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wno-thread-safety-negative -fcxx-exceptions %s
 
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 -Wc++98-compat %s
 // FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
@@ -36,6 +36,9 @@
   bool ReaderTryLock() __attribute__((shared_trylock_function(true)));
   void LockWhen(const int &cond) __attribute__((exclusive_lock_function));
 
+  // for negative capabilities
+  const Mutex& operator!() const { return *this; }
+
   void AssertHeld()       ASSERT_EXCLUSIVE_LOCK();
   void AssertReaderHeld() ASSERT_SHARED_LOCK();
 };
@@ -60,6 +63,12 @@
   void Release() UNLOCK_FUNCTION();
 };
 
+class __attribute__((scoped_lockable)) DoubleMutexLock {
+public:
+  DoubleMutexLock(Mutex *mu1, Mutex *mu2)
+      __attribute__((exclusive_lock_function(mu1, mu2)));
+  ~DoubleMutexLock() __attribute__((unlock_function));
+};
 
 // The universal lock, written "*", allows checking to be selectively turned
 // off for a particular piece of code.
@@ -95,6 +104,37 @@
 };
 
 
+// For testing operator overloading
+template <class K, class T>
+class MyMap {
+public:
+  T& operator[](const K& k);
+};
+
+
+// For testing handling of containers.
+template <class T>
+class MyContainer {
+public:
+  MyContainer();
+
+  typedef T* iterator;
+  typedef const T* const_iterator;
+
+  T* begin();
+  T* end();
+
+  const T* cbegin();
+  const T* cend();
+
+  T&       operator[](int i);
+  const T& operator[](int i) const;
+
+private:
+  T* ptr_;
+};
+
+
 
 Mutex sls_mu;
 
@@ -1628,6 +1668,12 @@
     a = b+1;
     b = a+1;
   }
+
+  void foo5() {
+    DoubleMutexLock mulock(&mu1, &mu2);
+    a = b + 1;
+    b = a + 1;
+  }
 };
 
 } // end namespace test_scoped_lockable
@@ -2280,6 +2326,15 @@
   (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock();
   (a > 0 ? fooArray[1] : fooArray[b]).a = 0;
   (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock();
+}
+
+
+void test2() {
+  Foo *fooArray;
+  Bar bar;
+  int a;
+  int b;
+  int c;
 
   bar.getFoo().mu_.Lock();
   bar.getFooey().a = 0; // \
@@ -2295,20 +2350,20 @@
 
   bar.getFoo3(a, b).mu_.Lock();
   bar.getFoo3(a, c).a = 0;  // \
-    // expected-warning {{writing variable 'a' requires holding mutex 'bar.getFoo3(a,c).mu_' exclusively}} \
-    // expected-note {{'bar.getFoo3(a,b).mu_'}}
+    // expected-warning {{writing variable 'a' requires holding mutex 'bar.getFoo3(a, c).mu_' exclusively}} \
+    // expected-note {{found near match 'bar.getFoo3(a, b).mu_'}}
   bar.getFoo3(a, b).mu_.Unlock();
 
   getBarFoo(bar, a).mu_.Lock();
   getBarFoo(bar, b).a = 0;  // \
-    // expected-warning {{writing variable 'a' requires holding mutex 'getBarFoo(bar,b).mu_' exclusively}} \
-    // expected-note {{'getBarFoo(bar,a).mu_'}}
+    // expected-warning {{writing variable 'a' requires holding mutex 'getBarFoo(bar, b).mu_' exclusively}} \
+    // expected-note {{found near match 'getBarFoo(bar, a).mu_'}}
   getBarFoo(bar, a).mu_.Unlock();
 
   (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock();
   (a > 0 ? fooArray[b] : fooArray[c]).a = 0; // \
-    // expected-warning {{writing variable 'a' requires holding mutex '((a#_)#_#fooArray[b]).mu_' exclusively}} \
-    // expected-note {{'((a#_)#_#fooArray[_]).mu_'}}
+    // expected-warning {{writing variable 'a' requires holding mutex '((0 < a) ? fooArray[b] : fooArray[c]).mu_' exclusively}} \
+    // expected-note {{found near match '((0 < a) ? fooArray[1] : fooArray[b]).mu_'}}
   (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock();
 }
 
@@ -4378,3 +4433,418 @@
 };
 
 }  // end namespace ThreadAttributesOnLambdas
+
+
+
+namespace AttributeExpressionCornerCases {
+
+class Foo {
+  int a GUARDED_BY(getMu());
+
+  Mutex* getMu()   LOCK_RETURNED("");
+  Mutex* getUniv() LOCK_RETURNED("*");
+
+  void test1() {
+    a = 0;
+  }
+
+  void test2() EXCLUSIVE_LOCKS_REQUIRED(getUniv()) {
+    a = 0;
+  }
+
+  void foo(Mutex* mu) EXCLUSIVE_LOCKS_REQUIRED(mu);
+
+  void test3() {
+    foo(nullptr);
+  }
+};
+
+
+class MapTest {
+  struct MuCell { Mutex* mu; };
+
+  MyMap<MyString, Mutex*> map;
+  MyMap<MyString, MuCell> mapCell;
+
+  int a GUARDED_BY(map["foo"]);
+  int b GUARDED_BY(mapCell["foo"].mu);
+
+  void test() {
+    map["foo"]->Lock();
+    a = 0;
+    map["foo"]->Unlock();
+  }
+
+  void test2() {
+    mapCell["foo"].mu->Lock();
+    b = 0;
+    mapCell["foo"].mu->Unlock();
+  }
+};
+
+
+class PreciseSmartPtr {
+  SmartPtr<Mutex> mu;
+  int val GUARDED_BY(mu);
+
+  static bool compare(PreciseSmartPtr& a, PreciseSmartPtr &b) {
+    a.mu->Lock();
+    bool result = (a.val == b.val);   // expected-warning {{reading variable 'val' requires holding mutex 'b.mu'}} \
+                                      // expected-note {{found near match 'a.mu'}}
+    a.mu->Unlock();
+    return result;
+  }
+};
+
+
+class SmartRedeclare {
+  SmartPtr<Mutex> mu;
+  int val GUARDED_BY(mu);
+
+  void test()  EXCLUSIVE_LOCKS_REQUIRED(mu);
+  void test2() EXCLUSIVE_LOCKS_REQUIRED(mu.get());
+  void test3() EXCLUSIVE_LOCKS_REQUIRED(mu.get());
+};
+
+
+void SmartRedeclare::test() EXCLUSIVE_LOCKS_REQUIRED(mu.get()) {
+  val = 0;
+}
+
+void SmartRedeclare::test2() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+  val = 0;
+}
+
+void SmartRedeclare::test3() {
+  val = 0;
+}
+
+
+namespace CustomMutex {
+
+
+class LOCKABLE BaseMutex { };
+class DerivedMutex : public BaseMutex { };
+
+void customLock(const BaseMutex *m)   EXCLUSIVE_LOCK_FUNCTION(m);
+void customUnlock(const BaseMutex *m) UNLOCK_FUNCTION(m);
+
+static struct DerivedMutex custMu;
+
+static void doSomethingRequiringLock() EXCLUSIVE_LOCKS_REQUIRED(custMu) { }
+
+void customTest() {
+  customLock(reinterpret_cast<BaseMutex*>(&custMu));  // ignore casts
+  doSomethingRequiringLock();
+  customUnlock(reinterpret_cast<BaseMutex*>(&custMu));
+}
+
+} // end namespace CustomMutex
+
+} // end AttributeExpressionCornerCases
+
+
+namespace ScopedLockReturnedInvalid {
+
+class Opaque;
+
+Mutex* getMutex(Opaque* o) LOCK_RETURNED("");
+
+void test(Opaque* o) {
+  MutexLock lock(getMutex(o));
+}
+
+}  // end namespace ScopedLockReturnedInvalid
+
+
+namespace NegativeRequirements {
+
+class Bar {
+  Mutex mu;
+  int a GUARDED_BY(mu);
+
+public:
+  void baz() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
+    mu.Lock();
+    a = 0;
+    mu.Unlock();
+  }
+};
+
+
+class Foo {
+  Mutex mu;
+  int a GUARDED_BY(mu);
+
+public:
+  void foo() {
+    mu.Lock();    // warning?  needs !mu?
+    baz();        // expected-warning {{cannot call function 'baz' while mutex 'mu' is held}}
+    bar();
+    mu.Unlock();
+  }
+
+  void bar() {
+    bar2();       // expected-warning {{calling function 'bar2' requires holding  '!mu'}}
+  }
+
+  void bar2() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
+    baz();
+  }
+
+  void baz() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
+    mu.Lock();
+    a = 0;
+    mu.Unlock();
+  }
+
+  void test() {
+    Bar b;
+    b.baz();     // no warning -- in different class.
+  }
+};
+
+}   // end namespace NegativeRequirements
+
+
+namespace NegativeThreadRoles {
+
+typedef int __attribute__((capability("role"))) ThreadRole;
+
+void acquire(ThreadRole R) __attribute__((exclusive_lock_function(R))) __attribute__((no_thread_safety_analysis)) {}
+void release(ThreadRole R) __attribute__((unlock_function(R))) __attribute__((no_thread_safety_analysis)) {}
+
+ThreadRole FlightControl, Logger;
+
+extern void enque_log_msg(const char *msg);
+void log_msg(const char *msg) {
+  enque_log_msg(msg);
+}
+
+void dispatch_log(const char *msg) __attribute__((requires_capability(!FlightControl))) {}
+void dispatch_log2(const char *msg) __attribute__((requires_capability(Logger))) {}
+
+void flight_control_entry(void) __attribute__((requires_capability(FlightControl))) {
+  dispatch_log("wrong"); /* expected-warning {{cannot call function 'dispatch_log' while mutex 'FlightControl' is held}} */
+  dispatch_log2("also wrong"); /* expected-warning {{calling function 'dispatch_log2' requires holding role 'Logger' exclusively}} */
+}
+
+void spawn_fake_flight_control_thread(void) {
+  acquire(FlightControl);
+  flight_control_entry();
+  release(FlightControl);
+}
+
+extern const char *deque_log_msg(void) __attribute__((requires_capability(Logger)));
+void logger_entry(void) __attribute__((requires_capability(Logger))) {
+  const char *msg;
+
+  while ((msg = deque_log_msg())) {
+    dispatch_log(msg);
+  }
+}
+
+void spawn_fake_logger_thread(void) {
+  acquire(Logger);
+  logger_entry();
+  release(Logger);
+}
+
+int main(void) {
+  spawn_fake_flight_control_thread();
+  spawn_fake_logger_thread();
+
+  for (;;)
+    ; /* Pretend to dispatch things. */
+
+  return 0;
+}
+
+} // end namespace NegativeThreadRoles
+
+
+namespace AssertSharedExclusive {
+
+void doSomething();
+
+class Foo {
+  Mutex mu;
+  int a GUARDED_BY(mu);
+
+  void test() SHARED_LOCKS_REQUIRED(mu) {
+    mu.AssertHeld();
+    if (a > 0)
+      doSomething();
+  }
+};
+
+} // end namespace AssertSharedExclusive
+
+
+namespace RangeBasedForAndReferences {
+
+class Foo {
+  struct MyStruct {
+    int a;
+  };
+
+  Mutex mu;
+  int a GUARDED_BY(mu);
+  MyContainer<int>  cntr  GUARDED_BY(mu);
+  MyStruct s GUARDED_BY(mu);
+  int arr[10] GUARDED_BY(mu);
+
+  void nonref_test() {
+    int b = a;             // expected-warning {{reading variable 'a' requires holding mutex 'mu'}}
+    b = 0;                 // no warning
+  }
+
+  void auto_test() {
+    auto b = a;            // expected-warning {{reading variable 'a' requires holding mutex 'mu'}}
+    b = 0;                 // no warning
+    auto &c = a;           // no warning
+    c = 0;                 // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
+  }
+
+  void ref_test() {
+    int &b = a;
+    int &c = b;
+    int &d = c;
+    b = 0;                 // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
+    c = 0;                 // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
+    d = 0;                 // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
+
+    MyStruct &rs = s;
+    rs.a = 0;              // expected-warning {{writing variable 's' requires holding mutex 'mu' exclusively}}
+
+    int (&rarr)[10] = arr;
+    rarr[2] = 0;           // expected-warning {{writing variable 'arr' requires holding mutex 'mu' exclusively}}
+  }
+
+  void ptr_test() {
+    int *b = &a;
+    *b = 0;                // no expected warning yet
+  }
+
+  void for_test() {
+    int total = 0;
+    for (int i : cntr) {   // expected-warning2 {{reading variable 'cntr' requires holding mutex 'mu'}}
+      total += i;
+    }
+  }
+};
+
+
+} // end namespace RangeBasedForAndReferences
+
+
+
+namespace PassByRefTest {
+
+class Foo {
+public:
+  Foo() : a(0), b(0) { }
+
+  int a;
+  int b;
+
+  void operator+(const Foo& f);
+
+  void operator[](const Foo& g);
+};
+
+template<class T>
+T&& mymove(T& f);
+
+
+// test top-level functions
+void copy(Foo f);
+void write1(Foo& f);
+void write2(int a, Foo& f);
+void read1(const Foo& f);
+void read2(int a, const Foo& f);
+void destroy(Foo&& f);
+
+void operator/(const Foo& f, const Foo& g);
+void operator*(const Foo& f, const Foo& g);
+
+
+
+
+class Bar {
+public:
+  Mutex mu;
+  Foo           foo   GUARDED_BY(mu);
+  Foo           foo2  GUARDED_BY(mu);
+  Foo*          foop  PT_GUARDED_BY(mu);
+  SmartPtr<Foo> foosp PT_GUARDED_BY(mu);
+
+  // test methods.
+  void mwrite1(Foo& f);
+  void mwrite2(int a, Foo& f);
+  void mread1(const Foo& f);
+  void mread2(int a, const Foo& f);
+
+  // static methods
+  static void smwrite1(Foo& f);
+  static void smwrite2(int a, Foo& f);
+  static void smread1(const Foo& f);
+  static void smread2(int a, const Foo& f);
+
+  void operator<<(const Foo& f);
+
+  void test1() {
+    copy(foo);             // expected-warning {{reading variable 'foo' requires holding mutex 'mu'}}
+    write1(foo);           // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    write2(10, foo);       // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    read1(foo);            // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    read2(10, foo);        // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    destroy(mymove(foo));  // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+
+    mwrite1(foo);           // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    mwrite2(10, foo);       // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    mread1(foo);            // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    mread2(10, foo);        // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+
+    smwrite1(foo);           // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    smwrite2(10, foo);       // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    smread1(foo);            // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+    smread2(10, foo);        // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+
+    foo + foo2;              // expected-warning {{reading variable 'foo' requires holding mutex 'mu'}} \
+                             // expected-warning {{passing variable 'foo2' by reference requires holding mutex 'mu'}}
+    foo / foo2;              // expected-warning {{reading variable 'foo' requires holding mutex 'mu'}} \
+                             // expected-warning {{passing variable 'foo2' by reference requires holding mutex 'mu'}}
+    foo * foo2;              // expected-warning {{reading variable 'foo' requires holding mutex 'mu'}} \
+                             // expected-warning {{passing variable 'foo2' by reference requires holding mutex 'mu'}}
+    foo[foo2];               // expected-warning {{reading variable 'foo' requires holding mutex 'mu'}} \
+                             // expected-warning {{passing variable 'foo2' by reference requires holding mutex 'mu'}}
+    (*this) << foo;          // expected-warning {{passing variable 'foo' by reference requires holding mutex 'mu'}}
+
+    copy(*foop);             // expected-warning {{reading the value pointed to by 'foop' requires holding mutex 'mu'}}
+    write1(*foop);           // expected-warning {{passing the value that 'foop' points to by reference requires holding mutex 'mu'}}
+    write2(10, *foop);       // expected-warning {{passing the value that 'foop' points to by reference requires holding mutex 'mu'}}
+    read1(*foop);            // expected-warning {{passing the value that 'foop' points to by reference requires holding mutex 'mu'}}
+    read2(10, *foop);        // expected-warning {{passing the value that 'foop' points to by reference requires holding mutex 'mu'}}
+    destroy(mymove(*foop));  // expected-warning {{passing the value that 'foop' points to by reference requires holding mutex 'mu'}}
+
+    copy(*foosp);             // expected-warning {{reading the value pointed to by 'foosp' requires holding mutex 'mu'}}
+    write1(*foosp);           // expected-warning {{reading the value pointed to by 'foosp' requires holding mutex 'mu'}}
+    write2(10, *foosp);       // expected-warning {{reading the value pointed to by 'foosp' requires holding mutex 'mu'}}
+    read1(*foosp);            // expected-warning {{reading the value pointed to by 'foosp' requires holding mutex 'mu'}}
+    read2(10, *foosp);        // expected-warning {{reading the value pointed to by 'foosp' requires holding mutex 'mu'}}
+    destroy(mymove(*foosp));  // expected-warning {{reading the value pointed to by 'foosp' requires holding mutex 'mu'}}
+
+    // TODO -- these requires better smart pointer handling.
+    copy(*foosp.get());
+    write1(*foosp.get());
+    write2(10, *foosp.get());
+    read1(*foosp.get());
+    read2(10, *foosp.get());
+    destroy(mymove(*foosp.get()));
+  }
+};
+
+
+}  // end namespace PassByRefTest
+
diff --git a/test/SemaCXX/warn-thread-safety-negative.cpp b/test/SemaCXX/warn-thread-safety-negative.cpp
new file mode 100644
index 0000000..f88233a
--- /dev/null
+++ b/test/SemaCXX/warn-thread-safety-negative.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wthread-safety-negative -fcxx-exceptions %s
+
+// FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 -Wc++98-compat %s
+// FIXME: should also run  %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+
+#define LOCKABLE            __attribute__ ((lockable))
+#define SCOPED_LOCKABLE     __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x)       __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR         __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x)    __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR      __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)    __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)       __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define ASSERT_EXCLUSIVE_LOCK(...)      __attribute__ ((assert_exclusive_lock(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...)         __attribute__ ((assert_shared_lock(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)    __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...)            __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x)    __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+  __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+  __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS  __attribute__ ((no_thread_safety_analysis))
+
+
+class  __attribute__((lockable)) Mutex {
+ public:
+  void Lock() __attribute__((exclusive_lock_function));
+  void ReaderLock() __attribute__((shared_lock_function));
+  void Unlock() __attribute__((unlock_function));
+  bool TryLock() __attribute__((exclusive_trylock_function(true)));
+  bool ReaderTryLock() __attribute__((shared_trylock_function(true)));
+  void LockWhen(const int &cond) __attribute__((exclusive_lock_function));
+
+  // for negative capabilities
+  const Mutex& operator!() const { return *this; }
+
+  void AssertHeld()       ASSERT_EXCLUSIVE_LOCK();
+  void AssertReaderHeld() ASSERT_SHARED_LOCK();
+};
+
+
+namespace SimpleTest {
+
+class Bar {
+  Mutex mu;
+  int a GUARDED_BY(mu);
+
+public:
+  void baz() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
+    mu.Lock();
+    a = 0;
+    mu.Unlock();
+  }
+};
+
+
+class Foo {
+  Mutex mu;
+  int a GUARDED_BY(mu);
+
+public:
+  void foo() {
+    mu.Lock();    // expected-warning {{acquiring mutex 'mu' requires negative capability '!mu'}}
+    baz();        // expected-warning {{cannot call function 'baz' while mutex 'mu' is held}}
+    bar();
+    mu.Unlock();
+  }
+
+  void bar() {
+    baz();        // expected-warning {{calling function 'baz' requires holding  '!mu'}}
+  }
+
+  void baz() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
+    mu.Lock();
+    a = 0;
+    mu.Unlock();
+  }
+
+  void test() {
+    Bar b;
+    b.baz();     // no warning -- in different class.
+  }
+
+  void test2() {
+    mu.Lock();   // expected-warning {{acquiring mutex 'mu' requires negative capability '!mu'}}
+    a = 0;
+    mu.Unlock();
+    baz();       // no warning -- !mu in set.
+  }
+
+  void test3() EXCLUSIVE_LOCKS_REQUIRED(!mu) {
+    mu.Lock();
+    a = 0;
+    mu.Unlock();
+    baz();       // no warning -- !mu in set.
+  }
+};
+
+}  // end namespace SimpleTest
diff --git a/test/SemaCXX/warn-thread-safety-verbose.cpp b/test/SemaCXX/warn-thread-safety-verbose.cpp
new file mode 100644
index 0000000..4e19f30
--- /dev/null
+++ b/test/SemaCXX/warn-thread-safety-verbose.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wthread-safety -Wthread-safety-beta -Wthread-safety-verbose -Wno-thread-safety-negative -fcxx-exceptions %s
+
+#define LOCKABLE            __attribute__ ((lockable))
+#define SCOPED_LOCKABLE     __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x)       __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR         __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x)    __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR      __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...)    __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...)       __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define ASSERT_EXCLUSIVE_LOCK(...)      __attribute__ ((assert_exclusive_lock(__VA_ARGS__)))
+#define ASSERT_SHARED_LOCK(...)         __attribute__ ((assert_shared_lock(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...)    __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...)            __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x)    __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+  __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+  __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS  __attribute__ ((no_thread_safety_analysis))
+
+
+class  __attribute__((lockable)) Mutex {
+ public:
+  void Lock() __attribute__((exclusive_lock_function));
+  void ReaderLock() __attribute__((shared_lock_function));
+  void Unlock() __attribute__((unlock_function));
+  bool TryLock() __attribute__((exclusive_trylock_function(true)));
+  bool ReaderTryLock() __attribute__((shared_trylock_function(true)));
+  void LockWhen(const int &cond) __attribute__((exclusive_lock_function));
+
+  // for negative capabilities
+  const Mutex& operator!() const { return *this; }
+
+  void AssertHeld()       ASSERT_EXCLUSIVE_LOCK();
+  void AssertReaderHeld() ASSERT_SHARED_LOCK();
+};
+
+
+class Test {
+  Mutex mu;
+  int a GUARDED_BY(mu);  // expected-note3 {{Guarded_by declared here.}}
+
+  void foo1() EXCLUSIVE_LOCKS_REQUIRED(mu);
+  void foo2() SHARED_LOCKS_REQUIRED(mu);
+  void foo3() LOCKS_EXCLUDED(mu);
+
+  void test1() {  // expected-note {{Thread warning in function 'test1'}}
+    a = 0;        // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
+  }
+
+  void test2() {  // expected-note {{Thread warning in function 'test2'}}
+    int b = a;    // expected-warning {{reading variable 'a' requires holding mutex 'mu'}}
+  }
+
+  void test3() {  // expected-note {{Thread warning in function 'test3'}}
+    foo1();       // expected-warning {{calling function 'foo1' requires holding mutex 'mu' exclusively}}
+  }
+
+  void test4() {  // expected-note {{Thread warning in function 'test4'}}
+    foo2();       // expected-warning {{calling function 'foo2' requires holding mutex 'mu'}}
+  }
+
+  void test5() {  // expected-note {{Thread warning in function 'test5'}}
+    mu.ReaderLock();
+    foo1();       // expected-warning {{calling function 'foo1' requires holding mutex 'mu' exclusively}}
+    mu.Unlock();
+  }
+
+  void test6() {  // expected-note {{Thread warning in function 'test6'}}
+    mu.ReaderLock();
+    a = 0;        // expected-warning {{writing variable 'a' requires holding mutex 'mu' exclusively}}
+    mu.Unlock();
+  }
+
+  void test7() {  // expected-note {{Thread warning in function 'test7'}}
+    mu.Lock();
+    foo3();       // expected-warning {{cannot call function 'foo3' while mutex 'mu' is held}}
+    mu.Unlock();
+  }
+};
+
diff --git a/test/SemaCXX/warn-undefined-bool-conversion.cpp b/test/SemaCXX/warn-undefined-bool-conversion.cpp
index 1f8baa0..24099f7 100644
--- a/test/SemaCXX/warn-undefined-bool-conversion.cpp
+++ b/test/SemaCXX/warn-undefined-bool-conversion.cpp
@@ -95,3 +95,27 @@
     // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true}}
   }
 }
+
+namespace macros {
+  #define assert(x) if (x) {}
+  #define zero_on_null(x) ((x) ? *(x) : 0)
+
+  void test(int &x) {
+    // TODO: warn on assert(&x) but not on zero_on_null(&x)
+    zero_on_null(&x);
+    assert(zero_on_null(&x));
+    assert(&x);
+
+    assert(&x && "Expecting valid reference");
+    // expected-warning@-1{{reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true}}
+  }
+
+  class S {
+    void test() {
+      assert(this);
+
+      assert(this && "Expecting invalid reference");
+      // expected-warning@-1{{'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true}}
+    }
+  };
+}
diff --git a/test/SemaCXX/warn-unused-comparison.cpp b/test/SemaCXX/warn-unused-comparison.cpp
index 3afad58..a24b5a2 100644
--- a/test/SemaCXX/warn-unused-comparison.cpp
+++ b/test/SemaCXX/warn-unused-comparison.cpp
@@ -83,6 +83,8 @@
 #define EQ(x,y) (x) == (y)
   EQ(x, 5);
 #undef EQ
+
+  (void)sizeof(1 < 2, true); // No warning; unevaluated context.
 }
 
 namespace PR10291 {
diff --git a/test/SemaCXX/warn-unused-filescoped.cpp b/test/SemaCXX/warn-unused-filescoped.cpp
index df4c47e..18defee 100644
--- a/test/SemaCXX/warn-unused-filescoped.cpp
+++ b/test/SemaCXX/warn-unused-filescoped.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-c++11-extensions -std=c++98 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++11 %s
 
 #ifdef HEADER
 
diff --git a/test/SemaCXX/warn-unused-local-typedef-serialize.cpp b/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
new file mode 100644
index 0000000..aa2c48b
--- /dev/null
+++ b/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang -x c++-header -c -Wunused-local-typedef %s -o %t.gch -Werror
+// RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s
+
+#ifndef BE_THE_SOURCE
+inline void myfun() {
+// The warning should fire every time the pch file is used, not when it's built.
+// CHECK: warning: unused typedef
+  typedef int a;
+}
+#endif
diff --git a/test/SemaCXX/warn-unused-local-typedef-x86asm.cpp b/test/SemaCXX/warn-unused-local-typedef-x86asm.cpp
new file mode 100644
index 0000000..d7792c0
--- /dev/null
+++ b/test/SemaCXX/warn-unused-local-typedef-x86asm.cpp
@@ -0,0 +1,16 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -std=c++11 -Wunused-local-typedef -verify -fasm-blocks %s
+// expected-no-diagnostics
+void use_in_asm() {
+  typedef struct {
+    int a;
+    int b;
+  } A;
+  __asm mov eax, [eax].A.b
+
+  using Alias = struct {
+    int a;
+    int b;
+  };
+  __asm mov eax, [eax].Alias.b
+}
diff --git a/test/SemaCXX/warn-unused-local-typedef.cpp b/test/SemaCXX/warn-unused-local-typedef.cpp
new file mode 100644
index 0000000..a940653
--- /dev/null
+++ b/test/SemaCXX/warn-unused-local-typedef.cpp
@@ -0,0 +1,242 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-local-typedef -verify -std=c++1y %s
+
+struct S {
+  typedef int Foo;  // no diag
+};
+
+namespace N {
+  typedef int Foo;  // no diag
+  typedef int Foo2;  // no diag
+}
+
+template <class T> class Vec {};
+
+typedef int global_foo;  // no diag
+
+void f() {
+  typedef int foo0;  // expected-warning {{unused typedef 'foo0'}}
+  using foo0alias = int ;  // expected-warning {{unused type alias 'foo0alias'}}
+
+  typedef int foo1 __attribute__((unused));  // no diag
+
+  typedef int foo2;
+  {
+    typedef int foo2;  // expected-warning {{unused typedef 'foo2'}}
+  }
+  typedef foo2 foo3; // expected-warning {{unused typedef 'foo3'}}
+
+  typedef int foo2_2;  // expected-warning {{unused typedef 'foo2_2'}}
+  {
+    typedef int foo2_2;
+    typedef foo2_2 foo3_2; // expected-warning {{unused typedef 'foo3_2'}}
+  }
+
+  typedef int foo4;
+  foo4 the_thing;
+
+  typedef int* foo5;
+  typedef foo5* foo6;  // no diag
+  foo6 *myptr;
+
+  struct S2 {
+    typedef int Foo; // no diag
+    typedef int Foo2; // expected-warning {{unused typedef 'Foo2'}}
+
+    struct Deeper {
+      typedef int DeepFoo;  // expected-warning {{unused typedef 'DeepFoo'}}
+    };
+  };
+
+  S2::Foo s2foo;
+
+  typedef struct {} foostruct; // expected-warning {{unused typedef 'foostruct'}}
+
+  typedef struct {} foostruct2; // no diag
+  foostruct2 fs2;
+
+  typedef int vecint;  // no diag
+  Vec<vecint> v;
+
+  N::Foo nfoo;
+
+  typedef int ConstExprInt;
+  static constexpr int a = (ConstExprInt)4;
+}
+
+int printf(char const *, ...);
+
+void test() {
+  typedef signed long int superint; // no diag
+  printf("%f", (superint) 42);
+
+  typedef signed long int superint2; // no diag
+  printf("%f", static_cast<superint2>(42));
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-local-typedef"
+  typedef int trungl_bot_was_here; // no diag
+#pragma clang diagnostic pop
+
+  typedef int foo; // expected-warning {{unused typedef 'foo'}}
+}
+
+template <class T>
+void template_fun(T t) {
+  typedef int foo; // expected-warning {{unused typedef 'foo'}}
+  typedef int bar; // no-diag
+  bar asdf;
+
+  struct S2 {
+    typedef int Foo; // no diag
+
+    typedef int Foo2; // expected-warning {{unused typedef 'Foo2'}}
+
+    typedef int Foo3; // no diag
+  };
+
+  typename S2::Foo s2foo;
+  typename T::Foo s3foo;
+
+  typedef typename S2::Foo3 TTSF;  // expected-warning {{unused typedef 'TTSF'}}
+}
+void template_fun_user() {
+  struct Local {
+    typedef int Foo; // no-diag
+    typedef int Bar; // expected-warning {{unused typedef 'Bar'}}
+  } p;
+  template_fun(p);
+}
+
+void typedef_in_nested_name() {
+  typedef struct {
+    typedef int Foo;
+  } A;
+  A::Foo adsf;
+
+  using A2 = struct {
+    typedef int Foo;
+  };
+  A2::Foo adsf2;
+}
+
+auto sneaky() {
+  struct S {
+    // Local typedefs can be used after the scope they were in has closed:
+    typedef int t;
+
+    // Even if they aren't, this could be an inline function that could be used
+    // in another TU, so this shouldn't warn either:
+    typedef int s;
+
+  private:
+    typedef int p; // expected-warning{{unused typedef 'p'}}
+  };
+  return S();
+}
+auto x = sneaky();
+decltype(x)::t y;
+
+static auto static_sneaky() {
+  struct S {
+    typedef int t;
+    // This function has internal linkage, so we can warn:
+    typedef int s; // expected-warning {{unused typedef 's'}}
+  };
+  return S();
+}
+auto sx = static_sneaky();
+decltype(sx)::t sy;
+
+auto sneaky_with_friends() {
+  struct S {
+  private:
+    friend class G;
+    // Can't warn if we have friends:
+    typedef int p;
+  };
+  return S();
+}
+
+namespace {
+auto nstatic_sneaky() {
+  struct S {
+    typedef int t;
+    // This function has internal linkage, so we can warn:
+    typedef int s; // expected-warning {{unused typedef 's'}}
+  };
+  return S();
+}
+auto nsx = nstatic_sneaky();
+decltype(nsx)::t nsy;
+}
+
+// Like sneaky(), but returning pointer to local type
+template<typename T>
+struct remove_reference { typedef T type; };
+template<typename T> struct remove_reference<T&> { typedef T type; };
+auto pointer_sneaky() {
+  struct S {
+    typedef int t;
+    typedef int s;
+  };
+  return (S*)nullptr;
+}
+remove_reference<decltype(*pointer_sneaky())>::type::t py;
+
+// Like sneaky(), but returning templated struct referencing local type.
+template <class T> struct container { int a; T t; };
+auto template_sneaky() {
+  struct S {
+    typedef int t;
+    typedef int s;
+  };
+  return container<S>();
+}
+auto tx = template_sneaky();
+decltype(tx.t)::t ty;
+
+// Like sneaky(), but doing its sneakiness by returning a member function
+// pointer.
+auto sneaky_memfun() {
+  struct S {
+    typedef int type;
+    int n;
+  };
+  return &S::n;
+}
+
+template <class T> void sneaky_memfun_g(int T::*p) {
+  typename T::type X;
+}
+
+void sneaky_memfun_h() {
+  sneaky_memfun_g(sneaky_memfun());
+}
+
+void typedefs_in_constructors() {
+  struct A {};
+  struct B : public A {
+    // Neither of these two should warn:
+    typedef A INHERITED;
+    B() : INHERITED() {}
+
+    typedef B SELF;
+    B(int) : SELF() {}
+  };
+}
+
+void *operator new(__SIZE_TYPE__, void *p) throw() { return p; }
+void placement_new_and_delete() {
+  struct MyStruct { };
+  char memory[sizeof(MyStruct)];
+  void *p = memory;
+
+  typedef MyStruct A_t1;
+  MyStruct *a = new (p) A_t1();
+
+  typedef MyStruct A_t2;
+  a->~A_t2();
+}
+
+// This should not disable any warnings:
+#pragma clang diagnostic ignored "-Wunused-local-typedef"
diff --git a/test/SemaCXX/warn-unused-private-field-delayed-template.cpp b/test/SemaCXX/warn-unused-private-field-delayed-template.cpp
new file mode 100644
index 0000000..7cafcca
--- /dev/null
+++ b/test/SemaCXX/warn-unused-private-field-delayed-template.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fdelayed-template-parsing -Wunused-private-field -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++11 %s
+// expected-no-diagnostics
+
+class EverythingMayBeUsed {
+  int x;
+public:
+  template <class T>
+  void f() {
+    x = 0;
+  }
+};
diff --git a/test/SemaCXX/warn-unused-result.cpp b/test/SemaCXX/warn-unused-result.cpp
index 581af09..1af0a01 100644
--- a/test/SemaCXX/warn-unused-result.cpp
+++ b/test/SemaCXX/warn-unused-result.cpp
@@ -94,3 +94,50 @@
 };
 
 }
+
+namespace PR18571 {
+// Unevaluated contexts should not trigger unused result warnings.
+template <typename T>
+auto foo(T) -> decltype(f(), bool()) { // Should not warn.
+  return true;
+}
+
+void g() {
+  foo(1);
+}
+}
+
+namespace std {
+class type_info { };
+}
+
+namespace {
+// The typeid expression operand is evaluated only when the expression type is
+// a glvalue of polymorphic class type.
+
+struct B {
+  virtual void f() {}
+};
+
+struct D : B {
+  void f() override {}
+};
+
+struct C {};
+
+void g() {
+  // The typeid expression operand is evaluated only when the expression type is
+  // a glvalue of polymorphic class type; otherwise the expression operand is not
+  // evaluated and should not trigger a diagnostic.
+  D d;
+  C c;
+  (void)typeid(f(), c); // Should not warn.
+  (void)typeid(f(), d); // expected-warning {{ignoring return value}}
+
+  // The sizeof expression operand is never evaluated.
+  (void)sizeof(f(), c); // Should not warn.
+
+   // The noexcept expression operand is never evaluated.
+  (void)noexcept(f(), false); // Should not warn.
+}
+}
diff --git a/test/SemaCXX/warn-unused-value-cxx11.cpp b/test/SemaCXX/warn-unused-value-cxx11.cpp
new file mode 100644
index 0000000..115ddf3
--- /dev/null
+++ b/test/SemaCXX/warn-unused-value-cxx11.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wunused-value %s
+// expected-no-diagnostics
+
+void f() __attribute__((const));
+
+namespace PR18571 {
+// Unevaluated contexts should not trigger unused result warnings.
+template <typename T>
+auto foo(T) -> decltype(f(), bool()) { // Should not warn.
+  return true;
+}
+
+void g() {
+  foo(1);
+}
+}
diff --git a/test/SemaObjC/arc-jump-block.m b/test/SemaObjC/arc-jump-block.m
index 9b06c5a..418d296 100644
--- a/test/SemaObjC/arc-jump-block.m
+++ b/test/SemaObjC/arc-jump-block.m
@@ -21,15 +21,15 @@
     case 0:
         dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; }); // expected-note 3 {{jump enters lifetime of block which strongly captures a variable}}
         break;
-    case 2:  // expected-error {{switch case is in protected scope}}
+    case 2:  // expected-error {{cannot jump}}
         dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; }); // expected-note 2 {{jump enters lifetime of block which strongly captures a variable}}
         break;
-    case 3: // expected-error {{switch case is in protected scope}}
+    case 3: // expected-error {{cannot jump}}
         {
           dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
           break;
         }
-    case 4: // expected-error {{switch case is in protected scope}}
+    case 4: // expected-error {{cannot jump}}
         break;
     }
 
@@ -90,7 +90,7 @@
     (void) ^{ (void) obj; };
     return 0;
 
-  default: // expected-error {{switch case is in protected scope}}
+  default: // expected-error {{cannot jump}}
     return 1;
   }
 }
diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m
index ba7c09f..54a7db7 100644
--- a/test/SemaObjC/arc.m
+++ b/test/SemaObjC/arc.m
@@ -129,7 +129,7 @@
     ;
     id x; // expected-note {{jump bypasses initialization of retaining variable}}
 
-  case 1: // expected-error {{switch case is in protected scope}}
+  case 1: // expected-error {{cannot jump}}
     break;
   }
 }
diff --git a/test/SemaObjC/attr-availability-1.m b/test/SemaObjC/attr-availability-1.m
new file mode 100644
index 0000000..063407a
--- /dev/null
+++ b/test/SemaObjC/attr-availability-1.m
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -std=c++03 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s
+// rdar://18490958
+
+@protocol P
+- (void)proto_method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note 2 {{'proto_method' has been explicitly marked deprecated here}}
+@end
+
+@interface A <P>
+- (void)method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}}
+
+- (void)overridden __attribute__((availability(macosx,introduced=10_3))); // expected-note{{overridden method is here}}
+- (void)overridden2 __attribute__((availability(macosx,introduced=10_3)));
+- (void)overridden3 __attribute__((availability(macosx,deprecated=10_3)));
+- (void)overridden4 __attribute__((availability(macosx,deprecated=10_3))); // expected-note{{overridden method is here}}
+- (void)overridden5 __attribute__((availability(macosx,unavailable)));
+- (void)overridden6 __attribute__((availability(macosx,introduced=10_3))); // expected-note{{overridden method is here}}
+@end
+
+// rdar://11475360
+@interface B : A
+- (void)method; // NOTE: we expect 'method' to *not* inherit availability.
+- (void)overridden __attribute__((availability(macosx,introduced=10_4))); // expected-warning{{overriding method introduced after overridden method on OS X (10_4 vs. 10_3)}}
+- (void)overridden2 __attribute__((availability(macosx,introduced=10_2)));
+- (void)overridden3 __attribute__((availability(macosx,deprecated=10_4)));
+- (void)overridden4 __attribute__((availability(macosx,deprecated=10_2))); // expected-warning{{overriding method deprecated before overridden method on OS X (10_3 vs. 10_2)}}
+- (void)overridden5 __attribute__((availability(macosx,introduced=10_3)));
+- (void)overridden6 __attribute__((availability(macosx,unavailable))); // expected-warning{{overriding method cannot be unavailable on OS X when its overridden method is available}}
+@end
+
+void f(A *a, B *b) {
+  [a method]; // expected-warning{{'method' is deprecated: first deprecated in OS X 10.2}}
+  [b method]; // no-warning
+  [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}}
+  [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}}
+}
+
+// Test case for <rdar://problem/11627873>.  Warn about
+// using a deprecated method when that method is re-implemented in a
+// subclass where the redeclared method is not deprecated.
+@interface C
+- (void) method __attribute__((availability(macosx,introduced=10_1,deprecated=10_2))); // expected-note {{'method' has been explicitly marked deprecated here}}
+@end
+
+@interface D : C
+- (void) method;
+@end
+
+@interface E : D
+- (void) method;
+@end
+
+@implementation D
+- (void) method {
+  [super method]; // expected-warning {{'method' is deprecated: first deprecated in OS X 10.2}}
+}
+@end
+
+@implementation E
+- (void) method {
+  [super method]; // no-warning
+}
+@end
+
+// rdar://18059669
+@class NSMutableArray;
+
+@interface NSDictionary
++ (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1)));
+@end
+
+@class NSString;
+
+extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10_0 ,deprecated=10_8,message="" )));
+id NSNibOwner, topNibObjects;
+
+@interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
+
+-(void)__attribute__((ibaction))importFromSIE:(id)sender;
+
+@end
+
+@implementation AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
+
+-(void)__attribute__((ibaction))importFromSIE:(id)sender {
+
+ NSMutableArray *topNibObjects;
+ NSDictionary *nibLoadDict = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, NSNibTopLevelObjects, ((void *)0)];
+}
+
+@end
+
+@interface Mixed
+- (void)Meth1 __attribute__((availability(macosx,introduced=10.3_0))); // expected-warning {{use same version number separators '_' or '.'}}
+- (void)Meth2 __attribute__((availability(macosx,introduced=10_3.1))); // expected-warning {{use same version number separators '_' or '.'}}
+@end
+
+// rdar://18804883
+@protocol P18804883
+- (void)proto_method __attribute__((availability(macosx,introduced=10_1,deprecated=NA))); // means nothing (not deprecated)
+@end
+
+@interface A18804883 <P18804883>
+- (void)interface_method __attribute__((availability(macosx,introduced=NA))); // expected-note {{'interface_method' has been explicitly marked unavailable here}}
+- (void)strange_method __attribute__((availability(macosx,introduced=NA,deprecated=NA)));  // expected-note {{'strange_method' has been explicitly marked unavailable here}}
+- (void) always_available __attribute__((availability(macosx,deprecated=NA)));
+@end
+
+void foo (A18804883* pa) {
+  [pa interface_method]; // expected-error {{'interface_method' is unavailable: not available on OS X}}
+  [pa proto_method];
+  [pa strange_method]; // expected-error {{'strange_method' is unavailable: not available on OS X}}
+  [pa always_available];
+}
+
diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m
index 7990b12..c455bc7 100644
--- a/test/SemaObjC/attr-availability.m
+++ b/test/SemaObjC/attr-availability.m
@@ -60,3 +60,30 @@
 }
 @end
 
+// rdar://18059669
+@class NSMutableArray;
+
+@interface NSDictionary
++ (instancetype)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1)));
+@end
+
+@class NSString;
+
+extern NSString *NSNibTopLevelObjects __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.8,message="" )));
+id NSNibOwner, topNibObjects;
+
+@interface AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
+
+-(void)__attribute__((ibaction))importFromSIE:(id)sender;
+
+@end
+
+@implementation AppDelegate (SIEImport) // expected-error {{cannot find interface declaration for 'AppDelegate'}}
+
+-(void)__attribute__((ibaction))importFromSIE:(id)sender {
+
+ NSMutableArray *topNibObjects;
+ NSDictionary *nibLoadDict = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topNibObjects, NSNibTopLevelObjects, ((void *)0)];
+}
+
+@end
diff --git a/test/SemaObjC/attr-deprecated.m b/test/SemaObjC/attr-deprecated.m
index 9dba48e..4d54d5d 100644
--- a/test/SemaObjC/attr-deprecated.m
+++ b/test/SemaObjC/attr-deprecated.m
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
 
 @interface A {
   int X __attribute__((deprecated)); // expected-note 2 {{'X' has been explicitly marked deprecated here}}
 }
 + (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been explicitly marked deprecated here}}
-- (void)f __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}
+- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been explicitly marked deprecated here}}
 @end
 
 @implementation A
@@ -54,7 +54,7 @@
 
 void t2(id a)
 {
-  [a f];
+  [a f]; // expected-warning {{'f' is deprecated}}
 }
 
 void t3(A<P>* a)
@@ -192,3 +192,69 @@
 }
 
 @end
+
+// rdar://16068470
+@interface TestBase
+@property (nonatomic, strong) id object __attribute__((deprecated("deprecated"))); // expected-note {{'object' has been explicitly marked deprecated here}} \
+expected-note {{property 'object' is declared deprecated here}} \
+expected-note {{'setObject:' has been explicitly marked deprecated here}} \
+expected-note {{property declared here}}
+@end
+
+@interface TestDerived : TestBase
+@property (nonatomic, strong) id object; //expected-warning {{auto property synthesis will not synthesize property 'object'; it will be implemented by its superclass}}
+@end
+
+@interface TestUse @end
+
+@implementation TestBase @end
+
+@implementation TestDerived @end // expected-note {{detected while default synthesizing properties in class implementation}}
+
+@implementation TestUse
+
+- (void) use
+{
+    TestBase *base = (id)0;
+    TestDerived *derived = (id)0;
+    id object = (id)0;
+
+    base.object = object; // expected-warning {{'object' is deprecated: deprecated}}
+    derived.object = object;
+
+    [base setObject:object];  // expected-warning {{'setObject:' is deprecated: deprecated}}
+    [derived setObject:object];
+}
+
+@end
+
+// rdar://18848183
+@interface NSString
+- (const char *)cString __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" ))); // expected-note {{'cString' has been explicitly marked deprecated here}}
+@end
+
+id PID = 0;
+const char * func() {
+  return [PID cString]; // expected-warning {{'cString' is deprecated: first deprecated in OS X 10.4}}
+}
+
+// rdar://18960378
+@interface NSObject
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface NSLocale
+- (instancetype)init __attribute__((unavailable));
+@end
+
+@interface PLBatteryProperties : NSObject
++ (id)properties;
+@end
+
+@implementation PLBatteryProperties
++ (id)properties {
+    return [[self alloc] init];
+}
+@end
+
diff --git a/test/SemaObjC/autoreleasepool.m b/test/SemaObjC/autoreleasepool.m
index 45c749e..c88f1ba 100644
--- a/test/SemaObjC/autoreleasepool.m
+++ b/test/SemaObjC/autoreleasepool.m
@@ -7,7 +7,7 @@
 
 @implementation AUTORP
 - (void) unregisterTask:(id) task {
-  goto L;	// expected-error {{goto into protected scope}}
+  goto L;	// expected-error {{cannot jump}}
 
   @autoreleasepool { // expected-note {{jump bypasses auto release push of @autoreleasepool block}}
         void *tmp = objc_autoreleasepool_push();
diff --git a/test/SemaObjC/builtin_objc_lib_functions.m b/test/SemaObjC/builtin_objc_lib_functions.m
index d8713dd..2496bf2 100644
--- a/test/SemaObjC/builtin_objc_lib_functions.m
+++ b/test/SemaObjC/builtin_objc_lib_functions.m
@@ -1,29 +1,29 @@
 // RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
 // rdar://8592641
 Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getClass' with type 'id (const char *)'}} \
-					  // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
+					  // expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
 
 // rdar://8735023
 Class f1() { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getMetaClass' with type 'id (const char *)'}} \
-					  // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}
+					  // expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}
 
 void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{implicitly declaring library function 'objc_enumerationMutation' with type 'void (id)'}} \
-						   // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_enumerationMutation'}}
+						   // expected-note {{include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_enumerationMutation'}}
 
 long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{implicitly declaring library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
-    // expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSend_fpret'}}
+    // expected-note {{include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSend_fpret'}}
 
 id f4(struct objc_super *super, SEL op) { // expected-warning {{declaration of 'struct objc_super' will not be visible outside of this function}}
   return objc_msgSendSuper(super, op); // expected-warning {{implicitly declaring library function 'objc_msgSendSuper' with type 'id (struct objc_super *, SEL, ...)'}} \
-					// expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
+					// expected-note {{include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
 }
 
 id f5(id val, id *dest) {
   return objc_assign_strongCast(val, dest); // expected-warning {{implicitly declaring library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
-					    // expected-note {{please include the header <objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
+					    // expected-note {{include the header <objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
 }
 
 int f6(Class exceptionClass, id exception) {
   return objc_exception_match(exceptionClass, exception); // expected-warning {{implicitly declaring library function 'objc_exception_match' with type 'int (id, id)'}} \
-  							  // expected-note {{please include the header <objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
+  							  // expected-note {{include the header <objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
 }
diff --git a/test/SemaObjC/builtin_objc_nslog.m b/test/SemaObjC/builtin_objc_nslog.m
index c940b16..cc6f194 100644
--- a/test/SemaObjC/builtin_objc_nslog.m
+++ b/test/SemaObjC/builtin_objc_nslog.m
@@ -4,10 +4,10 @@
 
 void f1(id arg) {
   NSLog(@"%@", arg); // expected-warning {{implicitly declaring library function 'NSLog' with type 'void (id, ...)'}} \
-  // expected-note {{please include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLog'}}
+  // expected-note {{include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLog'}}
 }
 
 void f2(id str, va_list args) {
   NSLogv(@"%@", args); // expected-warning {{implicitly declaring library function 'NSLogv' with type }} \
-  // expected-note {{please include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLogv'}}
+  // expected-note {{include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLogv'}}
 }
diff --git a/test/SemaObjC/class-property-access.m b/test/SemaObjC/class-property-access.m
index a4c188c..d57b986 100644
--- a/test/SemaObjC/class-property-access.m
+++ b/test/SemaObjC/class-property-access.m
@@ -41,8 +41,8 @@
     (void)Subclass.classMethod;
 
     // also okay
-    [RootClass property];
-    [Subclass property];
+    (void)[RootClass property];
+    (void)[Subclass property];
     [RootClass method];
     [Subclass method];
     [RootClass classMethod];
diff --git a/test/SemaObjC/compare-qualified-class.m b/test/SemaObjC/compare-qualified-class.m
index 60ef851..a525615 100644
--- a/test/SemaObjC/compare-qualified-class.m
+++ b/test/SemaObjC/compare-qualified-class.m
@@ -28,3 +28,38 @@
            classA == classD; // expected-warning {{comparison of distinct pointer types ('Class<SomeProtocol>' and 'Class<SomeProtocol1>')}}
 }
 
+// rdar://18491222
+@protocol NSObject @end
+
+@interface NSObject @end
+@protocol ProtocolX <NSObject>
+@end
+
+@protocol ProtocolY <NSObject>
+@end
+
+@interface ClassA : NSObject
+@end
+
+@interface ClassB : ClassA <ProtocolY, ProtocolX>
+@end
+
+@interface OtherClass : NSObject
+@property (nonatomic, copy) ClassB<ProtocolX> *aProperty;
+- (ClassA<ProtocolY> *)aMethod;
+- (ClassA<ProtocolY> *)anotherMethod;
+@end
+
+@implementation OtherClass
+- (ClassA<ProtocolY> *)aMethod {
+    // This does not work, even though ClassB subclasses from A and conforms to Y
+    // because the property type explicity adds ProtocolX conformance
+    // even though ClassB already conforms to ProtocolX
+    return self.aProperty;
+}
+- (ClassA<ProtocolY> *)anotherMethod {
+    // This works, even though all it is doing is removing an explicit
+    // protocol conformance that ClassB already conforms to
+    return (ClassB *)self.aProperty;
+}
+@end
diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m
index 049a095..71e108c 100644
--- a/test/SemaObjC/conditional-expr.m
+++ b/test/SemaObjC/conditional-expr.m
@@ -96,15 +96,15 @@
   return a ? x : p;
 }
 
-void f8(int a, A<P0> *x, A *y) {
-  [ (a ? x : y ) intProp ];
+int f8(int a, A<P0> *x, A *y) {
+  return [ (a ? x : y ) intProp ];
 }
 
 void f9(int a, A<P0> *x, A<P1> *y) {
-  id l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
-  A<P0> *l1 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
-  A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
-  [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+  id l0 = (a ? x : y );     // Ok. y is of A<P1> object type and A is qualified by P0.
+  A<P0> *l1 = (a ? x : y ); // Ok. y is of A<P1> object type and A is qualified by P0.
+  A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible pointer types initializing 'A<P1> *' with an expression of type 'A<P0> *'}}
+  (void)[ (a ? x : y ) intProp ]; // Ok. Common type is A<P0> * and P0's property intProp is accessed.
 }
 
 void f10(int a, id<P0> x, id y) {
@@ -116,5 +116,5 @@
 }
 
 void f12(int a, A<P0> *x, A<P1> *y) {
-  A<P1>* l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+  A<P1>* l0 = (a ? x : y ); // expected-warning {{incompatible pointer types initializing 'A<P1> *' with an expression of type 'A<P0> *'}}
 }
diff --git a/test/SemaObjC/debugger-support.m b/test/SemaObjC/debugger-support.m
index 21c096e..5dbc3ee 100644
--- a/test/SemaObjC/debugger-support.m
+++ b/test/SemaObjC/debugger-support.m
@@ -9,6 +9,6 @@
   // CHECK-NEXT: [[RESULT:%.*]] = alloca [[A:%.*]], align 4
   // CHECK-NEXT: store i8* {{%.*}}, i8** [[X]],
   // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]],
-  // CHECK-NEXT: [[T1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+  // CHECK-NEXT: [[T1:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_
   // CHECK-NEXT: [[T2:%.*]] = call { i64, i64 } bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to { i64, i64 } (i8*, i8*)*)(i8* [[T0]], i8* [[T1]])
 }
diff --git a/test/SemaObjC/default-synthesize-1.m b/test/SemaObjC/default-synthesize-1.m
index f9f2e72..731aa86 100644
--- a/test/SemaObjC/default-synthesize-1.m
+++ b/test/SemaObjC/default-synthesize-1.m
@@ -124,3 +124,20 @@
                              // expected-note {{detected while default synthesizing properties in class implementation}}
 @synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}}
 @end
+
+// rdar://17774815
+@interface ZXParsedResult
+@property (nonatomic, copy, readonly) NSString *description; // expected-note {{property declared here}}
+@end
+
+@interface ZXCalendarParsedResult : ZXParsedResult
+
+@property (nonatomic, copy, readonly) NSString *description; // expected-warning {{auto property synthesis will not synthesize property 'description'; it will be implemented by its superclass}}
+
+@end
+
+@implementation ZXCalendarParsedResult // expected-note {{detected while default synthesizing properties in class implementation}}
+- (NSString *) Meth {
+    return _description; // expected-error {{use of undeclared identifier '_description'}}
+}
+@end
diff --git a/test/SemaObjC/default-synthesize-3.m b/test/SemaObjC/default-synthesize-3.m
index c915974..dce9eda 100644
--- a/test/SemaObjC/default-synthesize-3.m
+++ b/test/SemaObjC/default-synthesize-3.m
@@ -44,7 +44,7 @@
 @interface NSObject @end
 @protocol Foo
 @property (readonly) char isFoo; // expected-note {{property declared here}}
-@property (readonly) char isNotFree;
+@property (readonly) char isNotFree;  // expected-note {{property declared here}}
 @end
 
 @interface Bar : NSObject <Foo>
@@ -66,10 +66,10 @@
 @property (readwrite) char isFoo; // expected-warning {{auto property synthesis will not synthesize property 'isFoo' because it is 'readwrite' but it will be synthesized 'readonly' via another property}}
 @property char Property1; // expected-warning {{auto property synthesis will not synthesize property 'Property1' because it cannot share an ivar with another synthesized property}}
 @property char Property2;
-@property (readwrite) char isNotFree;
+@property (readwrite) char isNotFree; // expected-warning {{auto property synthesis will not synthesize property 'isNotFree'}}
 @end
 
-@implementation Baz {
+@implementation Baz { // expected-note {{detected while default synthesizing properties in class implementation}}
     char _isFoo;
     char _isNotFree;
 }
@@ -90,9 +90,9 @@
 @end
 
 @interface B
-@property (readonly) id prop;
-@property (readonly) id prop1;
-@property (readonly) id prop2;
+@property (readonly) id prop;  // expected-note {{property declared here}}
+@property (readonly) id prop1;  // expected-note {{property declared here}}
+@property (readonly) id prop2;  // expected-note {{property declared here}}
 @end
 
 @interface B()
@@ -104,12 +104,12 @@
 @end
 
 @interface S : B<P1>
-@property (assign,readwrite) id prop;
-@property (assign,readwrite) id prop1;
-@property (assign,readwrite) id prop2;
+@property (assign,readwrite) id prop; // expected-warning {{auto property synthesis will not synthesize property 'prop'}}
+@property (assign,readwrite) id prop1; // expected-warning {{auto property synthesis will not synthesize property 'prop1'}}
+@property (assign,readwrite) id prop2; // expected-warning {{auto property synthesis will not synthesize property 'prop2'}}
 @end
 
-@implementation S
+@implementation S // expected-note 3 {{detected while default synthesizing properties in class implementation}}
 @end
 
 // rdar://14085456
diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m
index 9356b9f..3f0ae02 100644
--- a/test/SemaObjC/default-synthesize.m
+++ b/test/SemaObjC/default-synthesize.m
@@ -97,10 +97,10 @@
 }
 @end
 
-@interface SubClass : TopClass <TopProtocol> 
+@interface SubClass : TopClass <TopProtocol>
 @end
 
-@implementation SubClass @end 
+@implementation SubClass @end
 
 // rdar://7920807
 @interface C @end
@@ -138,3 +138,39 @@
  
 @implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}}
 @end
+
+// rdar://18152478
+@protocol NSObject @end
+@protocol TMSourceManagerDelegate<NSObject>
+@end
+
+@protocol TMSourceManager <NSObject>
+@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;
+@end
+
+@interface TMSourceManager
+@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;
+@end
+
+@protocol TMTimeZoneManager <TMSourceManager>
+@end
+
+@interface TimeZoneManager : TMSourceManager <TMTimeZoneManager>
+@end
+
+@implementation TimeZoneManager
+@end
+
+// rdar://18179833
+@protocol BaseProt
+@property (assign) id prot;
+@end
+
+@interface Base<BaseProt>
+@end
+
+@interface I : Base<BaseProt>
+@end
+
+@implementation I
+@end
diff --git a/test/SemaObjC/encode-typeof-test.m b/test/SemaObjC/encode-typeof-test.m
index 2cda973..fe8f29c 100644
--- a/test/SemaObjC/encode-typeof-test.m
+++ b/test/SemaObjC/encode-typeof-test.m
@@ -24,3 +24,22 @@
     int i;
     typeof(@encode(typeof(i))) e = @encode(typeof(Intf)); // expected-warning {{initializer-string for char array is too long}}
 }
+
+// rdar://9255564
+typedef short short8 __attribute__((ext_vector_type(8)));
+
+struct foo {
+ char a;
+ int b;
+ long c;
+ short8 d;
+ int array[4];
+ short int bitfield1:5;
+ unsigned short bitfield2:11;
+ char *string;
+};
+
+const char *RetEncode () {
+ return @encode(struct foo); // expected-warning {{encoding of 'struct foo' type is incomplete because 'short8' (vector of 8 'short' values) component has unknown encoding}}
+}
+
diff --git a/test/SemaObjC/error-missing-getter.m b/test/SemaObjC/error-missing-getter.m
index 3dce858..13dc8e5 100644
--- a/test/SemaObjC/error-missing-getter.m
+++ b/test/SemaObjC/error-missing-getter.m
@@ -27,7 +27,8 @@
     if (TestClass.setterOnly) { // expected-error {{no getter method for read from property}}
       TestClass.setterOnly = 1;
     }
-    func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}}
+    func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}} \
+                                       // expected-error {{use of undeclared identifier 'x'}}
     int i = TestClass.setterOnly + 1;  // expected-error {{no getter method for read from property}}
     return TestClass.setterOnly + 1;   // expected-error {{no getter method for read from property}}
 }
diff --git a/test/SemaObjC/format-cstrings-warning.m b/test/SemaObjC/format-cstrings-warning.m
new file mode 100644
index 0000000..28fa7ce
--- /dev/null
+++ b/test/SemaObjC/format-cstrings-warning.m
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -Wcstring-format-directive -verify -fsyntax-only %s
+// rdar://18182443
+
+typedef __builtin_va_list __darwin_va_list;
+typedef __builtin_va_list va_list;
+
+@interface NSString 
+@end
+
+va_list argList;
+
+@interface NSString (NSStringExtensionMethods)
+- (NSString *)stringByAppendingFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
+- (instancetype)initWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); // expected-note 2 {{method 'initWithFormat:' declared here}}
+- (instancetype)initWithFormat:(NSString *)format arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0)));
+- (instancetype)initWithFormat:(NSString *)format locale:(id)locale, ... __attribute__((format(__NSString__, 1, 3)));
+- (instancetype)initWithFormat:(NSString *)format locale:(id)locale arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0)));
++ (instancetype)stringWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); // expected-note {{method 'stringWithFormat:' declared here}}
++ (instancetype)localizedStringWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); // expected-note {{method 'localizedStringWithFormat:' declared here}}
+- (void)MyRandomMethod:(NSString *)format locale:(id)locale arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0))); // expected-note {{method 'MyRandomMethod:locale:arguments:' declared here}}
+@end
+
+@interface NSMutableString : NSString
+@end
+
+@interface NSMutableString (NSMutableStringExtensionMethods)
+
+- (void)appendFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
+
+@end
+
+NSString *ns(NSString *pns) {
+  [pns initWithFormat: @"Number %d length %c name %s", 1, 'a', "something"]; // expected-warning {{using %s directive in NSString which is being passed as a formatting argument to the formatting method}}
+  [NSString localizedStringWithFormat : @"Hello%s", " There"]; // expected-warning {{using %s directive in NSString which is being passed as a formatting argument to the formatting method}}
+  [pns initWithFormat : @"Hello%s %d %d", "Hello", 1, 2]; // expected-warning {{using %s directive in NSString which is being passed as a formatting argument to the formatting method}}
+  [pns MyRandomMethod : @"Hello%s %d %d" locale:0 arguments: argList];  // expected-warning {{using %s directive in NSString which is being passed as a formatting argument to the formatting method}}
+  return [NSString stringWithFormat : @"Hello%s", " There"]; // expected-warning {{using %s directive in NSString which is being passed as a formatting argument to the formatting method}}
+}
+
+
+typedef const struct __CFString * CFStringRef;
+typedef struct __CFString * CFMutableStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+
+
+typedef const struct __CFDictionary * CFDictionaryRef;
+
+
+extern
+CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...) __attribute__((format(CFString, 3, 4)));
+
+extern
+CFStringRef CFStringCreateWithFormatAndArguments(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) __attribute__((format(CFString, 3, 0))); // expected-note {{'CFStringCreateWithFormatAndArguments' declared here}}
+
+extern
+void CFStringAppendFormat(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, ...) __attribute__((format(CFString, 3, 4)));
+
+extern
+void CFStringAppendFormatAndArguments(CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments) __attribute__((format(CFString, 3, 0))); // expected-note {{'CFStringAppendFormatAndArguments' declared here}}
+
+void Test1(va_list argList) {
+  CFAllocatorRef alloc;
+  CFStringCreateWithFormatAndArguments (alloc, 0, (CFStringRef)@"%s\n", argList); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
+  CFStringAppendFormatAndArguments ((CFMutableStringRef)@"AAAA", 0, (CFStringRef)"Hello %s there %d\n", argList); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
+  CFStringCreateWithFormatAndArguments (alloc, 0, (CFStringRef)@"%c\n", argList);
+  CFStringAppendFormatAndArguments ((CFMutableStringRef)@"AAAA", 0, (CFStringRef)"%d\n", argList);
+}
+
+extern void MyNSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); // expected-note {{'MyNSLog' declared here}}
+extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2))); // expected-note {{'MyCFStringCreateWithFormat' declared here}}
+extern void XMyNSLog(int, NSString *format, ...) __attribute__((format(__NSString__, 2, 3))); // expected-note {{'XMyNSLog' declared here}}
+
+void Test2() {
+  MyNSLog(@"%s\n", "Hello"); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
+
+  MyCFStringCreateWithFormat((CFStringRef)@"%s", "Hello"); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
+  XMyNSLog(4, @"%s\n", "Hello"); // expected-warning {{using %s directive in CFString which is being passed as a formatting argument to the formatting CFfunction}}
+}
+
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index 49567a7..f4c528c 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -243,7 +243,7 @@
 
 // <rdar://problem/13557053>
 void testTypeOf(NSInteger dW, NSInteger dH) {
-  NSLog(@"dW %d  dH %d",({ __typeof__(dW) __a = (dW); __a < 0 ? -__a : __a; }),({ __typeof__(dH) __a = (dH); __a < 0 ? -__a : __a; })); // expected-warning 2 {{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}}
+  NSLog(@"dW %d  dH %d",({ __typeof__(dW) __a = (dW); __a < 0 ? -__a : __a; }),({ __typeof__(dH) __a = (dH); __a < 0 ? -__a : __a; })); // expected-warning 2 {{format specifies type 'int' but the argument has type 'long'}}
 }
 
 void testUnicode() {
diff --git a/test/SemaObjC/iboutlet.m b/test/SemaObjC/iboutlet.m
index 63eac9a..7d656a5 100644
--- a/test/SemaObjC/iboutlet.m
+++ b/test/SemaObjC/iboutlet.m
@@ -6,12 +6,10 @@
 
 @class NSView;
 
-#define IBOutlet __attribute__((iboutlet))
-
-@interface I
+IB_DESIGNABLE @interface I
 @property (getter = MyGetter, readonly, assign) IBOutlet NSView *myView; // expected-warning {{readonly IBOutlet property 'myView' when auto-synthesized may not work correctly with 'nib' loader}} expected-note {{property should be changed to be readwrite}}
 
-@property (readonly) IBOutlet NSView *myView1; // expected-warning {{readonly IBOutlet property 'myView1' when auto-synthesized may not work correctly with 'nib' loader}} expected-note {{property should be changed to be readwrite}}
+IBInspectable @property (readonly) IBOutlet NSView *myView1; // expected-warning {{readonly IBOutlet property 'myView1' when auto-synthesized may not work correctly with 'nib' loader}} expected-note {{property should be changed to be readwrite}}
 
 @property (getter = MyGetter, READONLY) IBOutlet NSView *myView2; // expected-warning {{readonly IBOutlet property 'myView2' when auto-synthesized may not work correctly with 'nib' loader}}
 
diff --git a/test/SemaObjC/ivar-lookup-resolution-builtin.m b/test/SemaObjC/ivar-lookup-resolution-builtin.m
index dd11b51..94ed325 100644
--- a/test/SemaObjC/ivar-lookup-resolution-builtin.m
+++ b/test/SemaObjC/ivar-lookup-resolution-builtin.m
@@ -29,7 +29,7 @@
 - (int) InstMethod
 {
   return index;	// expected-warning {{implicitly declaring library function 'index'}}	\
-                // expected-note {{please include the header <strings.h> or explicitly provide a declaration for 'index'}} \
+                // expected-note {{include the header <strings.h> or explicitly provide a declaration for 'index'}} \
                 // expected-warning {{incompatible pointer to integer conversion returning}}
 }
 + (int) ClassMethod
diff --git a/test/SemaObjC/ivar-lookup.m b/test/SemaObjC/ivar-lookup.m
index 938c8eb..57f432c 100644
--- a/test/SemaObjC/ivar-lookup.m
+++ b/test/SemaObjC/ivar-lookup.m
@@ -99,9 +99,9 @@
   };
   struct S {
     __typeof(myStatus) __in;  // fails.
-    struct S1 {
+    struct S1 { // expected-warning {{declaration does not declare anything}}
       __typeof(myStatus) __in;  // fails.
-      struct S {
+      struct S { // expected-warning {{declaration does not declare anything}}
         __typeof(myStatus) __in;  // fails.
       };
     };
diff --git a/test/SemaObjC/nonnull.m b/test/SemaObjC/nonnull.m
index a345edd..cacca07 100644
--- a/test/SemaObjC/nonnull.m
+++ b/test/SemaObjC/nonnull.m
@@ -31,16 +31,16 @@
 {
   func1(cp1, cp2, i1);
   
-  func1(0, cp2, i1);  // expected-warning {{null passed to a callee which requires a non-null argument}}
-  func1(cp1, 0, i1);  // expected-warning {{null passed to a callee which requires a non-null argument}}
+  func1(0, cp2, i1);  // expected-warning {{null passed to a callee that requires a non-null argument}}
+  func1(cp1, 0, i1);  // expected-warning {{null passed to a callee that requires a non-null argument}}
   func1(cp1, cp2, 0);
   
   
-  func3(0, i2, cp3, i3); // expected-warning {{null passed to a callee which requires a non-null argument}}
-  func3(cp3, i2, 0, i3);  // expected-warning {{null passed to a callee which requires a non-null argument}}
+  func3(0, i2, cp3, i3); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  func3(cp3, i2, 0, i3);  // expected-warning {{null passed to a callee that requires a non-null argument}}
   
-  func4(0, cp1); // expected-warning {{null passed to a callee which requires a non-null argument}}
-  func4(cp1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+  func4(0, cp1); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  func4(cp1, 0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   
   // Shouldn't these emit warnings?  Clang doesn't, and neither does GCC.  It
   // seems that the checking should handle Objective-C pointers.
@@ -64,7 +64,7 @@
 void _dispatch_queue_push_list(dispatch_object_t _head); // no warning
 
 void func6(dispatch_object_t _head) {
-  _dispatch_queue_push_list(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+  _dispatch_queue_push_list(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   _dispatch_queue_push_list(_head._do);  // no warning
 }
 
@@ -91,10 +91,10 @@
 @implementation IMP
 - (void) Meth {
   NSObject *object;
-  [object doSomethingWithNonNullPointer:NULL:1:NULL]; // expected-warning 2 {{null passed to a callee which requires a non-null argument}}
-  [object doSomethingWithNonNullPointer:vp:1:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}}
-  [NSObject doSomethingClassyWithNonNullPointer:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}}
-  DoSomethingNotNull(NULL); // expected-warning {{null passed to a callee which requires a non-null argument}}
+  [object doSomethingWithNonNullPointer:NULL:1:NULL]; // expected-warning 2 {{null passed to a callee that requires a non-null argument}}
+  [object doSomethingWithNonNullPointer:vp:1:NULL]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+  [NSObject doSomethingClassyWithNonNullPointer:NULL]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+  DoSomethingNotNull(NULL); // expected-warning {{null passed to a callee that requires a non-null argument}}
   [object doSomethingWithNonNullPointer:vp:1:vp];
 }
 - (void*) testRetNull {
@@ -111,15 +111,15 @@
 @end
 
 void test(TestNonNullParameters *f) {
-  [f doNotPassNullParameter:0]; // expected-warning {{null passed to a callee which requires a non-null argument}}
+  [f doNotPassNullParameter:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
   [f doNotPassNullParameterArgIndex:0]; // no-warning
-  [f doNotPassNullOnMethod:0]; // expected-warning {{null passed to a callee which requires a non-null argument}}
+  [f doNotPassNullOnMethod:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
 }
 
 
 void PR18795(int (^g)(const char *h, ...) __attribute__((nonnull(1))) __attribute__((nonnull))) {
-  g(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+  g(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
 }
 void PR18795_helper() {
-  PR18795(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+  PR18795(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
 }
diff --git a/test/SemaObjC/objc-asm-attribute-neg-test.m b/test/SemaObjC/objc-asm-attribute-neg-test.m
new file mode 100644
index 0000000..2fb6643
--- /dev/null
+++ b/test/SemaObjC/objc-asm-attribute-neg-test.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://16462586
+
+__attribute__((objc_runtime_name)) // expected-error {{'objc_runtime_name' attribute takes one argument}}
+@interface BInterface
+@end
+
+__attribute__((objc_runtime_name(123))) // expected-error {{'objc_runtime_name' attribute requires a string}}
+@protocol BProtocol1
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.Protocol")))
+@protocol Protocol
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@interface Message <Protocol> { 
+__attribute__((objc_runtime_name("MySecretNamespace.Message"))) // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
+  id MyIVAR;
+}
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@property int MyProperty; // expected-error {{prefix attribute must be followed by an interface or protocol}}}}
+
+- (int) getMyProperty __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
+
+- (void) setMyProperty : (int) arg __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
+
+@end
+
+__attribute__((objc_runtime_name("MySecretNamespace.ForwardClass")))
+@class ForwardClass; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+__attribute__((objc_runtime_name("MySecretNamespace.ForwardProtocol")))
+@protocol ForwardProtocol;
+
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+@implementation Message // expected-error {{prefix attribute must be followed by an interface or protocol}}
+__attribute__((objc_runtime_name("MySecretNamespace.Message")))
+- (id) MyMethod {
+  return MyIVAR;
+}
+@end
diff --git a/test/SemaObjC/objc-cf-audited-warning.m b/test/SemaObjC/objc-cf-audited-warning.m
new file mode 100644
index 0000000..db78229
--- /dev/null
+++ b/test/SemaObjC/objc-cf-audited-warning.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1  -fobjc-arc -verify %s
+// rdar://18222007
+
+#if __has_feature(arc_cf_code_audited)
+#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
+#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
+#endif
+#define CF_BRIDGED_TYPE(T)              __attribute__((objc_bridge(T)))
+
+typedef const struct CF_BRIDGED_TYPE(NSURL) __CFURL * CFURLRef;
+typedef signed long long CFIndex;
+typedef unsigned char           Boolean;
+typedef unsigned char                   UInt8;
+typedef const struct __CFAllocator * CFAllocatorRef;
+const CFAllocatorRef kCFAllocatorDefault;
+
+CF_IMPLICIT_BRIDGING_ENABLED
+CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory); // expected-note {{passing argument to parameter 'buffer' here}}
+CF_IMPLICIT_BRIDGING_DISABLED
+
+void saveImageToJPG(const char *filename)
+{
+    CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, filename, 10, 0); // expected-warning {{passing 'const char *' to parameter of type 'const UInt8 *' (aka 'const unsigned char *') converts between pointers to integer types with different sign}}
+}
diff --git a/test/SemaObjC/objc-dictionary-literal.m b/test/SemaObjC/objc-dictionary-literal.m
index 9d86d88..f9fd57f 100644
--- a/test/SemaObjC/objc-dictionary-literal.m
+++ b/test/SemaObjC/objc-dictionary-literal.m
@@ -3,6 +3,8 @@
 // RUN: %clang_cc1  -fsyntax-only -triple i386-apple-macosx10.9.0 -fobjc-runtime=macosx-fragile-10.9.0 -fobjc-subscripting-legacy-runtime -verify %s
 // rdar://15363492
 
+#define nil ((void *)0)
+
 @interface NSNumber
 + (NSNumber *)numberWithChar:(char)value;
 + (NSNumber *)numberWithInt:(int)value;
@@ -15,6 +17,7 @@
 @interface NSDictionary
 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
 - (void)setObject:(id)object forKeyedSubscript:(id)key;
+- (id)objectForKeyedSubscript:(id)key;
 @end
 
 @interface NSString<NSCopying>
@@ -25,12 +28,24 @@
 - (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;
 @end
 
+void *pvoid;
 int main() {
 	NSDictionary *dict = @{ @"name":@666 };
         dict[@"name"] = @666;
 
         dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}}
 
+        // rdar://18254621
+        [@{@"foo" : @"bar"} objectForKeyedSubscript:nil];
+        (void)@{@"foo" : @"bar"}[nil];
+        [@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid];
+        (void)@{@"foo" : @"bar"}[pvoid];
+
+	[@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"];
+        @{@"foo" : @"bar"}[nil] = @"gorf";
+	[@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"];
+        @{@"foo" : @"bar"}[pvoid] = @"gorf";
+
 	return 0;
 }
 
diff --git a/test/SemaObjC/property-noninherited-availability-attr.m b/test/SemaObjC/property-noninherited-availability-attr.m
index 793ceb6..dfa72d1 100644
--- a/test/SemaObjC/property-noninherited-availability-attr.m
+++ b/test/SemaObjC/property-noninherited-availability-attr.m
@@ -21,13 +21,13 @@
 
 void test(Foo *y, Bar *x, id<myProtocol> z) {
   y.myProperty = 0; // expected-warning {{'myProperty' is deprecated: first deprecated in OS X 10.8}}
-  [y myProperty];   // expected-warning {{'myProperty' is deprecated: first deprecated in OS X 10.8}} 
+  (void)[y myProperty];   // expected-warning {{'myProperty' is deprecated: first deprecated in OS X 10.8}} 
 
   x.myProperty = 1; // no-warning
-  [x myProperty]; // no-warning
+  (void)[x myProperty]; // no-warning
 
   x.myProtocolProperty = 0; // no-warning
 
-  [x myProtocolProperty]; // no-warning
-  [z myProtocolProperty]; // expected-warning {{'myProtocolProperty' is deprecated: first deprecated in OS X 10.8}}
+  (void)[x myProtocolProperty]; // no-warning
+  (void)[z myProtocolProperty]; // expected-warning {{'myProtocolProperty' is deprecated: first deprecated in OS X 10.8}}
 }
diff --git a/test/SemaObjC/property-user-setter.m b/test/SemaObjC/property-user-setter.m
index e84fad2..7674c2b 100644
--- a/test/SemaObjC/property-user-setter.m
+++ b/test/SemaObjC/property-user-setter.m
@@ -124,15 +124,16 @@
 @synthesize t, T;
 @synthesize Pxyz, pxyz;
 - (id) Meth {
-  self.P = 0;
-  self.q = 0;
+  self.P = 0; // expected-warning {{property 'P' not found on object of type 'rdar11363363 *'; did you mean to access property p?}}
+  self.q = 0; // expected-warning {{property 'q' not found on object of type 'rdar11363363 *'; did you mean to access property Q?}}
 // rdar://11528439
   self.t = 0; // expected-error {{synthesized properties 't' and 'T' both claim setter 'setT:'}}
   self.T = 0; // expected-error {{synthesized properties 'T' and 't' both claim setter 'setT:'}}
   self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}}
   self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}}
-  self.R = 0;
-  return self.R; // expected-error {{no getter method for read from property}}
+  self.r = 0;
+  return self.R; // expected-error {{no getter method for read from property}} \
+                 // expected-warning {{property 'R' not found on object of type 'rdar11363363 *'; did you mean to access property r?}}
 }
 @end
 
diff --git a/test/SemaObjC/protocol-expr-1.m b/test/SemaObjC/protocol-expr-1.m
index 94a0d9e..5ff3db4 100644
--- a/test/SemaObjC/protocol-expr-1.m
+++ b/test/SemaObjC/protocol-expr-1.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // expected-no-diagnostics
 
-@protocol fproto;
+@protocol fproto @end
 
 @protocol p1 
 @end
diff --git a/test/SemaObjC/protocol-expr-neg-1.m b/test/SemaObjC/protocol-expr-neg-1.m
index 58ac8c0..aed56c0 100644
--- a/test/SemaObjC/protocol-expr-neg-1.m
+++ b/test/SemaObjC/protocol-expr-neg-1.m
@@ -2,7 +2,7 @@
 
 @class Protocol;
 
-@protocol fproto;
+@protocol fproto; // expected-note {{'fproto' declared here}}
 
 @protocol p1 
 @end
@@ -12,8 +12,23 @@
 int main()
 {
 	Protocol *proto = @protocol(p1);
-        Protocol *fproto = @protocol(fproto);
+        Protocol *fproto = @protocol(fproto); // expected-warning {{@protocol is using a forward protocol declaration of fproto}}
 	Protocol *pp = @protocol(i); // expected-error {{cannot find protocol declaration for 'i'}}
 	Protocol *p1p = @protocol(cl); // expected-error {{cannot find protocol declaration for 'cl'}}
 }
 
+// rdar://17768630
+@protocol SuperProtocol; // expected-note {{'SuperProtocol' declared here}}
+@protocol TestProtocol; // expected-note {{'TestProtocol' declared here}}
+
+@interface I
+- (int) conformsToProtocol : (Protocol *)protocl;
+@end
+
+int doesConform(id foo) {
+  return [foo conformsToProtocol:@protocol(TestProtocol)]; // expected-warning {{@protocol is using a forward protocol declaration of TestProtocol}}
+}
+
+int doesConformSuper(id foo) {
+  return [foo conformsToProtocol:@protocol(SuperProtocol)]; // expected-warning {{@protocol is using a forward protocol declaration of SuperProtocol}}
+}
diff --git a/test/SemaObjC/protocols-suppress-conformance.m b/test/SemaObjC/protocols-suppress-conformance.m
index 299e44e..a6604b7 100644
--- a/test/SemaObjC/protocols-suppress-conformance.m
+++ b/test/SemaObjC/protocols-suppress-conformance.m
@@ -5,7 +5,7 @@
 __attribute__((objc_protocol_requires_explicit_implementation))
 @protocol Protocol
 - (void) theBestOfTimes; // expected-note {{method 'theBestOfTimes' declared here}}
-@property (readonly) id theWorstOfTimes; // expected-note {{property declared here}}
+@property (readonly) id theWorstOfTimes; // expected-note {{property declared here}} 
 @end
 
 // In this example, ClassA adopts the protocol.  We won't
@@ -13,14 +13,14 @@
 // be adopted later by a subclass.
 @interface ClassA <Protocol>
 - (void) theBestOfTimes;
-@property (readonly) id theWorstOfTimes;
+@property (readonly) id theWorstOfTimes; // expected-note {{property declared here}}
 @end
 
 // This class subclasses ClassA (which also adopts 'Protocol').
 @interface ClassB : ClassA <Protocol>
 @end
 
-@implementation ClassB // expected-warning {{property 'theWorstOfTimes' requires method 'theWorstOfTimes' to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation}}
+@implementation ClassB // expected-warning {{property 'theWorstOfTimes' requires method 'theWorstOfTimes' to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation}} 
 @end
 
 @interface ClassB_Good : ClassA <Protocol>
@@ -32,7 +32,7 @@
 @end
 
 @interface ClassB_AlsoGood : ClassA <Protocol>
-@property (readonly) id theWorstOfTimes;
+@property (readonly) id theWorstOfTimes; // expected-warning {{auto property synthesis will not synthesize property 'theWorstOfTimes'; it will be implemented by its superclass}}
 @end
 
 // Default synthesis acts as if @dynamic
@@ -40,7 +40,7 @@
 // it is declared in ClassA.  This is okay, since
 // the author of ClassB_AlsoGood needs explicitly
 // write @property in the @interface.
-@implementation ClassB_AlsoGood // no-warning
+@implementation ClassB_AlsoGood  // expected-note {{detected while default synthesizing properties in class implementation}}
 - (void) theBestOfTimes {}
 @end
 
diff --git a/test/SemaObjC/resolve-method-in-global-pool.m b/test/SemaObjC/resolve-method-in-global-pool.m
new file mode 100644
index 0000000..523856d
--- /dev/null
+++ b/test/SemaObjC/resolve-method-in-global-pool.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// expected-no-diagnostics
+
+// rdar://16808765
+
+@interface NSObject 
++ (void)clsMethod:(int*)arg;
+@end
+
+@class NSDictionary;
+@class NSError;
+
+@interface Foo : NSObject
+- (void)getDonuts:(void (^)(NSDictionary *, NSError *))replyBlock;
+- (void)getCake:(int*)arg, ...;
+@end
+
+@protocol Protocol
+@required
+- (void)getDonuts:(void (^)(NSDictionary *))replyBlock;
+- (void)getCake:(float*)arg, ...;
++ (void)clsMethod:(float*)arg;
+@end
+
+@implementation Foo
+{
+  float g;
+}
+
+- (void)getDonuts:(void (^)(NSDictionary *, NSError *))replyBlock {
+    [(id) 0 getDonuts:^(NSDictionary *replyDict) { }];
+}
+
+- (void) getCake:(int*)arg, ... {
+    [(id)0 getCake: &g, 1,3.14];
+}
+@end
+
+void func( Class c, float g ) {
+    [c clsMethod: &g];
+}
+
+// rdar://18095772
+@protocol NSKeyedArchiverDelegate @end
+
+@interface NSKeyedArchiver
+@property (assign) id <NSKeyedArchiverDelegate> delegate;
+@end
+
+@interface NSConnection
+@property (assign) id delegate;
+@end
+
+extern id NSApp;
+
+@interface AppDelegate
+@end
+
+AppDelegate* GetDelegate()
+{
+    return [NSApp delegate];
+}
diff --git a/test/SemaObjC/scope-check.m b/test/SemaObjC/scope-check.m
index e19ba47..b52e7a0 100644
--- a/test/SemaObjC/scope-check.m
+++ b/test/SemaObjC/scope-check.m
@@ -3,9 +3,9 @@
 @class A, B, C;
 
 void test1() {
-  goto L; // expected-error{{goto into protected scope}}
-  goto L2; // expected-error{{goto into protected scope}}
-  goto L3; // expected-error{{goto into protected scope}}
+  goto L; // expected-error{{cannot jump}}
+  goto L2; // expected-error{{cannot jump}}
+  goto L3; // expected-error{{cannot jump}}
   @try {   // expected-note {{jump bypasses initialization of @try block}}
 L: ;
   } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
@@ -17,11 +17,11 @@
   }
   
   @try {
-    goto L4; // expected-error{{goto into protected scope}}
-    goto L5; // expected-error{{goto into protected scope}}
+    goto L4; // expected-error{{cannot jump}}
+    goto L5; // expected-error{{cannot jump}}
   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
   L5: ;
-    goto L6; // expected-error{{goto into protected scope}}
+    goto L6; // expected-error{{cannot jump}}
   } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
   L6: ;
   } @finally { // expected-note {{jump bypasses initialization of @finally block}}
@@ -32,12 +32,12 @@
   @try { // expected-note 2 {{jump bypasses initialization of @try block}}
   L7: ;
   } @catch (C *c) {
-    goto L7; // expected-error{{goto into protected scope}}
+    goto L7; // expected-error{{cannot jump}}
   } @finally {
-    goto L7; // expected-error{{goto into protected scope}}
+    goto L7; // expected-error{{cannot jump}}
   }
   
-  goto L8;  // expected-error{{goto into protected scope}}
+  goto L8;  // expected-error{{cannot jump}}
   @try { 
   } @catch (A *c) {
   } @catch (B *c) {
@@ -47,7 +47,7 @@
   
   // rdar://6810106
   id X;
-  goto L9;    // expected-error{{goto into protected scope}}
+  goto L9;    // expected-error{{cannot jump}}
   goto L10;   // ok
   @synchronized    // expected-note {{jump bypasses initialization of @synchronized block}}
   ( ({ L10: ; X; })) {
@@ -79,7 +79,7 @@
 + (void) hello {
 
   @try {
-    goto blargh;     // expected-error {{goto into protected scope}}
+    goto blargh;     // expected-error {{cannot jump}}
   } @catch (...) {   // expected-note {{jump bypasses initialization of @catch block}}
   blargh: ;
   }
@@ -87,14 +87,14 @@
 
 + (void)meth2 {
     int n; void *P;
-    goto L0;     // expected-error {{goto into protected scope}}
+    goto L0;     // expected-error {{cannot jump}}
     typedef int A[n];  // expected-note {{jump bypasses initialization of VLA typedef}}
   L0:
     
-    goto L1;      // expected-error {{goto into protected scope}}
+    goto L1;      // expected-error {{cannot jump}}
     A b, c[10];        // expected-note 2 {{jump bypasses initialization of variable length array}}
   L1:
-    goto L2;     // expected-error {{goto into protected scope}}
+    goto L2;     // expected-error {{cannot jump}}
     A d[n];      // expected-note {{jump bypasses initialization of variable length array}}
   L2:
     return;
diff --git a/test/SemaObjC/super-property-notation.m b/test/SemaObjC/super-property-notation.m
index aa67f0a..2b13a5c 100644
--- a/test/SemaObjC/super-property-notation.m
+++ b/test/SemaObjC/super-property-notation.m
@@ -30,7 +30,7 @@
 
 // rdar://13349296
 __attribute__((objc_root_class)) @interface ClassBase 
-@property (nonatomic, retain) ClassBase * foo;
+@property (nonatomic, retain) ClassBase * foo; // expected-note {{property declared here}}
 @end
 
 @implementation ClassBase 
@@ -41,10 +41,10 @@
 @end
 
 @interface ClassDerived : ClassBase 
-@property (nonatomic, retain) ClassDerived * foo;
+@property (nonatomic, retain) ClassDerived * foo; // expected-warning {{auto property synthesis will not synthesize property 'foo'; it will be implemented by its superclass}}
 @end
 
-@implementation ClassDerived
+@implementation ClassDerived // expected-note {{detected while default synthesizing properties in class implementation}}
 - (void) Meth:(ClassBase*)foo {
   super.foo = foo; // must work with no warning
   [super setFoo:foo]; // works with no warning
diff --git a/test/SemaObjC/unused.m b/test/SemaObjC/unused.m
index 16a3899..6ea3fe8 100644
--- a/test/SemaObjC/unused.m
+++ b/test/SemaObjC/unused.m
@@ -81,3 +81,26 @@
   rdar15596883_foo();
 }
 
+@interface PropertyObject : NSObject 
+@property int length;
+@end
+
+@protocol P
+@property int property;
+@end
+
+void test3(PropertyObject *o)
+{
+  [o length]; // expected-warning {{property access result unused - getters should not be used for side effects}}
+  (void)[o length];
+}
+
+void test4(id o)
+{
+  [o length]; // No warning.
+}
+
+void test5(id <P> p)
+{
+    [p property]; // expected-warning {{property access result unused - getters should not be used for side effects}}
+}
diff --git a/test/SemaObjC/warn-category-method-deprecated.m b/test/SemaObjC/warn-category-method-deprecated.m
new file mode 100644
index 0000000..349a27a
--- /dev/null
+++ b/test/SemaObjC/warn-category-method-deprecated.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s
+// rdar://18013929
+
+@protocol P
+- (void)meth;
+@end
+
+@interface I <P>
+@end
+
+@interface I(cat)
+- (void)meth __attribute__((deprecated)); // expected-note {{'meth' has been explicitly marked deprecated here}}
+@end
+
+void foo(I *i) {
+  [i meth]; // expected-warning {{'meth' is deprecated}}
+}
diff --git a/test/SemaObjC/warn-explicit-call-initialize.m b/test/SemaObjC/warn-explicit-call-initialize.m
new file mode 100644
index 0000000..99fdf53
--- /dev/null
+++ b/test/SemaObjC/warn-explicit-call-initialize.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1  -fsyntax-only  -triple x86_64-apple-darwin10 -verify %s
+// rdar://16628028
+
+@interface NSObject
++ (void)initialize; // expected-note 2 {{method 'initialize' declared here}}
+@end
+
+@interface I : NSObject 
++ (void)initialize; // expected-note {{method 'initialize' declared here}}
++ (void)SomeRandomMethod;
+@end
+
+@implementation I
+- (void) Meth { 
+  [I initialize];     // expected-warning {{explicit call to +initialize results in duplicate call to +initialize}} 
+  [NSObject initialize]; // expected-warning {{explicit call to +initialize results in duplicate call to +initialize}}
+}
++ (void)initialize {
+  [super initialize];
+}
++ (void)SomeRandomMethod { // expected-note {{method 'SomeRandomMethod' declared here}}
+  [super initialize]; // expected-warning {{explicit call to [super initialize] should only be in implementation of +initialize}}
+}
+@end
+
diff --git a/test/SemaObjC/warn-strict-selector-match.m b/test/SemaObjC/warn-strict-selector-match.m
index 34f1712..9f22e73 100644
--- a/test/SemaObjC/warn-strict-selector-match.m
+++ b/test/SemaObjC/warn-strict-selector-match.m
@@ -29,8 +29,7 @@
 }
 
 @protocol MyObject
-- (id)initWithData:(Object *)data;	// expected-note {{using}} \
-					// expected-note {{passing argument to parameter 'data' here}}
+- (id)initWithData:(Object *)data;	// expected-note {{using}} 
 @end
 
 @protocol SomeOther
@@ -54,8 +53,7 @@
 }
 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
 {
-    NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}} \
-    expected-warning {{sending 'id<MyObject,MyCoding>' to parameter of incompatible type 'Object *'}}
+    NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}} 
     return result;
 }
 @end
diff --git a/test/SemaObjCXX/property-invalid-type.mm b/test/SemaObjCXX/property-invalid-type.mm
new file mode 100644
index 0000000..5b8a848
--- /dev/null
+++ b/test/SemaObjCXX/property-invalid-type.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I
+{
+  A* response; // expected-error {{unknown type name 'A'}}
+}
+@end
+@interface I ()
+@property A* response;  // expected-error {{unknown type name 'A'}}
+@property  int helper;
+@end
+@implementation I
+@synthesize response;
+- (void) foo :(A*) a   // expected-error {{expected a type}}
+{
+  self.response = a;
+}
+@end
+
+void foo(I *i)
+{
+  i.helper;
+}
diff --git a/test/SemaObjCXX/synchronized.mm b/test/SemaObjCXX/synchronized.mm
new file mode 100644
index 0000000..37305c5
--- /dev/null
+++ b/test/SemaObjCXX/synchronized.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface PBXTrackableTaskManager @end
+@implementation PBXTrackableTaskManager @end
+
+struct x {
+  operator PBXTrackableTaskManager *() const { return 0; }
+} a;
+
+struct y {
+  operator int *() const { return 0; }
+} b;
+
+void test1() {
+  @synchronized (a) {
+  }
+
+  @synchronized (b) {  // expected-error {{@synchronized requires an Objective-C object type ('struct y' invalid)}}
+  }
+}
diff --git a/test/SemaOpenCL/address-spaces.cl b/test/SemaOpenCL/address-spaces.cl
index b188ea4..7026d1b 100644
--- a/test/SemaOpenCL/address-spaces.cl
+++ b/test/SemaOpenCL/address-spaces.cl
@@ -12,14 +12,16 @@
   ip = &ci; // expected-error {{assigning '__constant int *' to 'int *' changes address space of pointer}}
 }
 
-void explicit_cast(global int* g, local int* l, constant int* c, private int* p)
+void explicit_cast(global int* g, local int* l, constant int* c, private int* p, const constant int *cc)
 {
   g = (global int*) l;    // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
   g = (global int*) c;    // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
+  g = (global int*) cc;   // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
   g = (global int*) p;    // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
 
   l = (local int*) g;     // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
   l = (local int*) c;     // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
+  l = (local int*) cc;    // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
   l = (local int*) p;     // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
 
   c = (constant int*) g;  // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}}
@@ -29,6 +31,7 @@
   p = (private int*) g;   // expected-error {{casting '__global int *' to type 'int *' changes address space of pointer}}
   p = (private int*) l;   // expected-error {{casting '__local int *' to type 'int *' changes address space of pointer}}
   p = (private int*) c;   // expected-error {{casting '__constant int *' to type 'int *' changes address space of pointer}}
+  p = (private int*) cc;  // expected-error {{casting 'const __constant int *' to type 'int *' changes address space of pointer}}
 }
 
 void ok_explicit_casts(global int *g, global int* g2, local int* l, local int* l2, private int* p, private int* p2)
diff --git a/test/SemaOpenCL/extern.cl b/test/SemaOpenCL/extern.cl
index ee5e072..b2e4857 100644
--- a/test/SemaOpenCL/extern.cl
+++ b/test/SemaOpenCL/extern.cl
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -emit-llvm %s -o - -verify | FileCheck %s
+// RUN: %clang_cc1 -x cl -cl-std=CL1.2 -emit-llvm -ffake-address-space-map %s -o - -verify | FileCheck %s
 // expected-no-diagnostics
 
-// CHECK: @foo = external global float
+// CHECK: @foo = external addrspace(3) constant float
 extern constant float foo;
 
 kernel void test(global float* buf) {
diff --git a/test/SemaTemplate/canonical-expr-type.cpp b/test/SemaTemplate/canonical-expr-type.cpp
index 4770c4f..f8d7d7e 100644
--- a/test/SemaTemplate/canonical-expr-type.cpp
+++ b/test/SemaTemplate/canonical-expr-type.cpp
@@ -47,3 +47,11 @@
   void f0(type2);
   void f0(type3); // expected-error{{redeclared}}
 };
+
+// Test canonicalization doesn't conflate different literal suffixes.
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0L)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0LL)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0.f)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0.)]) {}
+template<typename T> void literal_suffix(int (&)[sizeof(T() + 0.l)]) {}
diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp
index b721aab..c67361b 100644
--- a/test/SemaTemplate/class-template-decl.cpp
+++ b/test/SemaTemplate/class-template-decl.cpp
@@ -57,7 +57,7 @@
   template<typename T> class X; // expected-error{{expression}}
 }
 
-template<typename T> class X1 var; // expected-warning{{variable templates are a C++1y extension}} \
+template<typename T> class X1 var; // expected-warning{{variable templates are a C++14 extension}} \
                                    // expected-error {{variable has incomplete type 'class X1'}} \
                                    // expected-note {{forward declaration of 'X1'}}
 
diff --git a/test/SemaTemplate/crash.cpp b/test/SemaTemplate/crash.cpp
new file mode 100644
index 0000000..428e95c
--- /dev/null
+++ b/test/SemaTemplate/crash.cpp
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -verify %s -std=c++11
+
+// PR17730
+template <typename T>
+void S<T>::mem1();
+
+template <typename T>
+void S<T>::mem2() {
+    const int I = sizeof(T);
+      (void)I;
+}
diff --git a/test/SemaTemplate/cxx1z-fold-expressions.cpp b/test/SemaTemplate/cxx1z-fold-expressions.cpp
new file mode 100644
index 0000000..8bb7911
--- /dev/null
+++ b/test/SemaTemplate/cxx1z-fold-expressions.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+template<typename ...T> constexpr auto sum(T ...t) { return (... + t); }
+template<typename ...T> constexpr auto product(T ...t) { return (t * ...); }
+template<typename ...T> constexpr auto all(T ...t) { return (true && ... && t); }
+template<typename ...T> constexpr auto dumb(T ...t) { return (false && ... && t); }
+
+static_assert(sum(1, 2, 3, 4, 5) == 15);
+static_assert(product(1, 2, 3, 4, 5) == 120);
+static_assert(!all(true, true, false, true, false));
+static_assert(all(true, true, true, true, true));
+static_assert(!dumb(true, true, true, true, true));
+
+struct S {
+  int a, b, c, d, e;
+};
+template<typename ...T> constexpr auto increment_all(T &...t) {
+  (++t, ...);
+}
+constexpr bool check() {
+  S s = { 1, 2, 3, 4, 5 };
+  increment_all(s.a, s.b, s.c, s.d, s.e);
+  return s.a == 2 && s.b == 3 && s.c == 4 && s.d == 5 && s.e == 6;
+}
+static_assert(check());
+
+template<int ...N> void empty() {
+  static_assert((N + ...) == 0);
+  static_assert((N * ...) == 1);
+  static_assert((N | ...) == 0);
+  static_assert((N & ...) == -1);
+  static_assert((N || ...) == false);
+  static_assert((N && ...) == true);
+  (N, ...);
+}
+template void empty<>();
+
+// An empty fold-expression isn't a null pointer just because it's an integer
+// with value 0.
+template<int ...N> void null_ptr() {
+  void *p = (N + ...); // expected-error {{rvalue of type 'int'}}
+  void *q = (N | ...); // expected-error {{rvalue of type 'int'}}
+}
+template void null_ptr<>(); // expected-note {{in instantiation of}}
+
+template<int ...N> void bad_empty() {
+  (N - ...); // expected-error {{empty expansion for operator '-' with no fallback}}
+  (N / ...); // expected-error {{empty expansion for operator '/' with no fallback}}
+  (N % ...); // expected-error {{empty expansion for operator '%' with no fallback}}
+  (N = ...); // expected-error {{empty expansion for operator '=' with no fallback}}
+}
+template void bad_empty<>(); // expected-note {{in instantiation of}}
+
+template<int ...N> void empty_with_base() {
+  extern int k;
+  (k = ... = N); // expected-warning{{unused}}
+
+  void (k = ... = N); // expected-error {{expected ')'}} expected-note {{to match}}
+  void ((k = ... = N));
+  (void) (k = ... = N);
+}
+template void empty_with_base<>(); // expected-note {{in instantiation of}}
+template void empty_with_base<1>();
+
+struct A {
+  struct B {
+    struct C {
+      struct D {
+        int e;
+      } d;
+    } c;
+  } b;
+} a;
+template<typename T, typename ...Ts> constexpr decltype(auto) apply(T &t, Ts ...ts) {
+  return (t.*....*ts);
+}
+static_assert(&apply(a, &A::b, &A::B::c, &A::B::C::d, &A::B::C::D::e) == &a.b.c.d.e);
diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp
index aecb5ee..c59f10d 100644
--- a/test/SemaTemplate/deduction.cpp
+++ b/test/SemaTemplate/deduction.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
 
 // Template argument deduction with template template parameters.
 template<typename T, template<T> class A> 
@@ -107,7 +107,7 @@
 }
 
 namespace test0 {
-  template <class T> void make(const T *(*fn)()); // expected-note {{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'char'}}
+  template <class T> void make(const T *(*fn)()); // expected-note {{candidate template ignored: can't deduce a type for 'T' that would make 'const T' equal 'char'}}
   char *char_maker();
   void test() {
     make(char_maker); // expected-error {{no matching function for call to 'make'}}
@@ -162,3 +162,43 @@
     foo(a);
   }
 }
+
+namespace PR21536 {
+  template<typename ...T> struct X;
+  template<typename A, typename ...B> struct S {
+    static_assert(sizeof...(B) == 1, "");
+    void f() {
+      using T = A;
+      using T = int;
+
+      using U = X<B...>;
+      using U = X<int>;
+    }
+  };
+  template<typename ...T> void f(S<T...>);
+  void g() { f(S<int, int>()); }
+}
+
+namespace PR19372 {
+  template <template<typename...> class C, typename ...Us> struct BindBack {
+    template <typename ...Ts> using apply = C<Ts..., Us...>;
+  };
+  template <typename, typename...> struct Y;
+  template <typename ...Ts> using Z = Y<Ts...>;
+
+  using T = BindBack<Z, int>::apply<>;
+  using T = Z<int>;
+
+  using U = BindBack<Z, int, int>::apply<char>;
+  using U = Z<char, int, int>;
+
+  namespace BetterReduction {
+    template<typename ...> struct S;
+    template<typename ...A> using X = S<A...>; // expected-note {{parameter}}
+    template<typename ...A> using Y = X<A..., A...>;
+    template<typename ...A> using Z = X<A..., 1, 2, 3>; // expected-error {{must be a type}}
+
+    using T = Y<int>;
+    using T = S<int, int>;
+  }
+}
diff --git a/test/SemaTemplate/dependent-type-identity.cpp b/test/SemaTemplate/dependent-type-identity.cpp
index a796834..5b9da5d 100644
--- a/test/SemaTemplate/dependent-type-identity.cpp
+++ b/test/SemaTemplate/dependent-type-identity.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // This test concerns the identity of dependent types within the
 // canonical type system. This corresponds to C++ [temp.type], which
@@ -122,3 +122,24 @@
   template struct A<int>;
   template struct A<int[1]>;
 }
+
+namespace PR21289 {
+  template<typename T> using X = int;
+  template<typename T, decltype(sizeof(0))> using Y = int;
+  template<typename ...Ts> struct S {};
+  template<typename ...Ts> void f() {
+    // This is a dependent type. It is *not* S<int>, even though it canonically
+    // contains no template parameters.
+    using Type = S<X<Ts>...>;
+    Type s;
+    using Type = S<int, int, int>;
+  }
+  void g() { f<void, void, void>(); }
+
+  template<typename ...Ts> void h(S<int>) {}
+  // Pending a core issue, it's not clear if these are redeclarations, but they
+  // are probably intended to be... even though substitution can succeed for one
+  // of them but fail for the other!
+  template<typename ...Ts> void h(S<X<Ts>...>) {} // expected-note {{previous}}
+  template<typename ...Ts> void h(S<Y<Ts, sizeof(Ts)>...>) {} // expected-error {{redefinition}}
+}
diff --git a/test/SemaTemplate/derived.cpp b/test/SemaTemplate/derived.cpp
index ce20cea..cbd004c 100644
--- a/test/SemaTemplate/derived.cpp
+++ b/test/SemaTemplate/derived.cpp
@@ -4,8 +4,8 @@
 template<typename T> class vector2 {};
 template<typename T> class vector : vector2<T> {};
 
-template<typename T> void Foo2(vector2<const T*> V) {}  // expected-note{{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'int'}}
-template<typename T> void Foo(vector<const T*> V) {} // expected-note {{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'int'}}
+template<typename T> void Foo2(vector2<const T*> V) {}  // expected-note{{candidate template ignored: can't deduce a type for 'T' that would make 'const T' equal 'int'}}
+template<typename T> void Foo(vector<const T*> V) {} // expected-note {{candidate template ignored: can't deduce a type for 'T' that would make 'const T' equal 'int'}}
 
 void test() {
   Foo2(vector2<int*>());  // expected-error{{no matching function for call to 'Foo2'}}
diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp
index c28c5d1..71121ad 100644
--- a/test/SemaTemplate/explicit-instantiation.cpp
+++ b/test/SemaTemplate/explicit-instantiation.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions -std=c++11 %s
 
 template void *; // expected-error{{expected unqualified-id}}
 
@@ -13,8 +14,8 @@
   
   T f0(T x) {
     return x + 1;  // expected-error{{invalid operands}}
-  } 
-  T* f0(T*, T*) { return T(); } // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}}
+  }
+  T *f0(T *, T *) { return T(); } // expected-warning 0-1 {{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} expected-error 0-1 {{cannot initialize return object of type 'int *' with an rvalue of type 'int'}}
 
   template <typename U> T f0(T, U) { return T(); } // expected-note-re {{candidate template ignored: could not match 'int (int, U){{( __attribute__\(\(thiscall\)\))?}}' against 'int (int){{( __attribute__\(\(thiscall\)\))?}} const'}} \
                                                    // expected-note {{candidate template ignored: could not match 'int' against 'int *'}}
@@ -25,7 +26,7 @@
 
 template int X0<int>::value;
 
-struct NotDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor)}}
+struct NotDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor)}} expected-note 0-1 {{candidate constructor (the implicit move constructor)}}
   NotDefaultConstructible(int); // expected-note{{candidate constructor}}
 };
 
@@ -149,3 +150,17 @@
   template int C<int>::b<int>;
   template int D::c<int>;
 }
+
+// expected-note@+1 3-4 {{explicit instantiation refers here}}
+template <class T> void Foo(T i) throw(T) { throw i; }
+// expected-error@+1 {{exception specification in explicit instantiation does not match instantiated one}}
+template void Foo(int a) throw(char);
+// expected-error@+1 {{exception specification in explicit instantiation does not match instantiated one}}
+template void Foo(double a) throw();
+// expected-error@+1 1 {{exception specification in explicit instantiation does not match instantiated one}}
+template void Foo(long a) throw(long, char);
+template void Foo(float a);
+#if __cplusplus >= 201103L
+// expected-error@+1 0-1 {{exception specification in explicit instantiation does not match instantiated one}}
+template void Foo(double a) noexcept;
+#endif
diff --git a/test/SemaTemplate/instantiate-decl-init.cpp b/test/SemaTemplate/instantiate-decl-init.cpp
index 9658fc1..f5daa79 100644
--- a/test/SemaTemplate/instantiate-decl-init.cpp
+++ b/test/SemaTemplate/instantiate-decl-init.cpp
@@ -45,3 +45,23 @@
   NonTrivial array[N];
 }
 template<> void f1<2>();
+
+namespace PR20346 {
+  struct S { short inner_s; };
+
+  struct outer_struct {
+    wchar_t arr[32];
+    S outer_s;
+  };
+
+  template <class T>
+  void OpenFileSession() {
+    // Ensure that we don't think the ImplicitValueInitExpr generated here
+    // during the initial parse only initializes the first array element!
+    outer_struct asdfasdf = {};
+  };
+
+  void foo() {
+    OpenFileSession<int>();
+  }
+}
diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
index a376f0e..f62ef61 100644
--- a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -58,6 +58,13 @@
     S().f<S>(); // ok
     S().f<int>(); // expected-note {{instantiation of exception spec}}
   }
+
+  template<typename T>
+  struct U {
+    void f() noexcept(T::error);
+    void (g)() noexcept(T::error);
+  };
+  U<int> uint; // ok
 }
 
 namespace core_19754_example {
@@ -137,3 +144,37 @@
   };
   void X::g() {} // expected-note {{in instantiation of}}
 }
+
+namespace Variadic {
+  template<bool B> void check() { static_assert(B, ""); }
+  template<bool B, bool B2, bool ...Bs> void check() { static_assert(B, ""); check<B2, Bs...>(); }
+
+  template<typename ...T> void consume(T...);
+
+  template<typename ...T> void f(void (*...p)() throw (T)) {
+    void (*q[])() = { p... };
+    consume((p(),0)...);
+  }
+  template<bool ...B> void g(void (*...p)() noexcept (B)) {
+    consume((p(),0)...);
+    check<noexcept(p()) == B ...>();
+  }
+  template<typename ...T> void i() {
+    consume([]() throw(T) {} ...);
+    consume([]() noexcept(sizeof(T) == 4) {} ...);
+  }
+  template<bool ...B> void j() {
+    consume([](void (*p)() noexcept(B)) {
+      void (*q)() noexcept = p; // expected-error {{not superset of source}}
+    } ...);
+  }
+
+  void z() {
+    f<int, char, double>(nullptr, nullptr, nullptr);
+    g<true, false, true>(nullptr, nullptr, nullptr);
+    i<int, long, short>();
+    j<true, true>();
+    j<true, false>(); // expected-note {{in instantiation of}}
+  }
+
+}
diff --git a/test/SemaTemplate/instantiate-exception-spec.cpp b/test/SemaTemplate/instantiate-exception-spec.cpp
index 993ee8d..d341172 100644
--- a/test/SemaTemplate/instantiate-exception-spec.cpp
+++ b/test/SemaTemplate/instantiate-exception-spec.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s -DERRORS
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %s
 
+#ifdef ERRORS
 template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
 struct Incomplete; // expected-note{{forward}}
 
@@ -7,3 +9,20 @@
   f1(int_p);
   f1(incomplete_p); // expected-note{{instantiation of}}
 }
+#endif
+
+template<typename T> void f(void (*p)() throw(T)) {
+#ifdef ERRORS
+  void (*q)() throw(char) = p; // expected-error {{target exception spec}}
+
+  extern void (*p2)() throw(T);
+  void (*q2)() throw(char) = p2; // expected-error {{target exception spec}}
+
+  extern void (*p3)() throw(char);
+  void (*q3)() throw(T) = p3; // expected-error {{target exception spec}}
+
+  void (*q4)() throw(T) = p2; // ok
+#endif
+  p();
+}
+void g() { f<int>(0); } // expected-note {{instantiation of}}
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index e777243..820ee38 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s  -triple x86_64-pc-linux-gnu
 template<int I, int J>
 struct Bitfields {
   int simple : I; // expected-error{{bit-field 'simple' has zero width}}
diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp
index 22c70be..e9be60d 100644
--- a/test/SemaTemplate/instantiate-init.cpp
+++ b/test/SemaTemplate/instantiate-init.cpp
@@ -115,6 +115,7 @@
   struct A { explicit A(int); }; // expected-note{{here}}
   template<typename T> struct B { T a { 0 }; };
   B<A> b;
+  // expected-note@+1 {{in instantiation of default member initializer}}
   template<typename T> struct C { T a = { 0 }; }; // expected-error{{explicit}}
   C<A> c; // expected-note{{here}}
 }
@@ -133,3 +134,12 @@
   	fun(in);
   }
 }
+
+namespace ReturnStmtIsInitialization {
+  struct X {
+    X() {}
+    X(const X &) = delete;
+  };
+  template<typename T> X f() { return {}; }
+  auto &&x = f<void>();
+}
diff --git a/test/SemaTemplate/instantiate-non-dependent-types.cpp b/test/SemaTemplate/instantiate-non-dependent-types.cpp
index a0005c56..432b905 100644
--- a/test/SemaTemplate/instantiate-non-dependent-types.cpp
+++ b/test/SemaTemplate/instantiate-non-dependent-types.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 template<typename T>
 struct X1 {
   static void member() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
@@ -11,4 +12,41 @@
   typedef instantiate<&X1<int>::member> i; // expected-note{{in instantiation of}}
 };
 
-X2<int> x; 
+X2<int> x;
+
+template <class T, class A> class C {
+public:
+  int i;
+  void f(T &t) {
+    T *q = new T();
+    t.T::~T();
+    q->~T();
+    // expected-error@+2 {{'int' is not a class, namespace, or scoped enumeration}}
+    // expected-error@+1 {{no member named '~Colors' in 'Colors'}}
+    q->A::~A();
+    // expected-error@+2 {{no member named '~int' in 'Q'}}
+    // expected-error@+1 {{no member named '~Colors' in 'Q'}}
+    q->~A();
+
+    delete q;
+  }
+};
+
+class Q {
+public:
+  Q() {}
+  ~Q() {}
+};
+
+enum Colors {red, green, blue};
+
+C<Q, int> dummy;
+C<Q, Colors> dummyColors;
+int main() {
+  Q qinst;
+  // expected-note@+1 {{in instantiation of member function 'C<Q, int>::f' requested here}}
+  dummy.f(qinst);
+  // expected-note@+1 {{in instantiation of member function 'C<Q, Colors>::f' requested here}}
+  dummyColors.f(qinst);
+}
+
diff --git a/test/SemaTemplate/instantiate-scope.cpp b/test/SemaTemplate/instantiate-scope.cpp
new file mode 100644
index 0000000..7331056
--- /dev/null
+++ b/test/SemaTemplate/instantiate-scope.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+template<typename ...T> struct X {
+  void f(int);
+  void f(...);
+  static int n;
+};
+
+template<typename T, typename U> using A = T;
+
+// These definitions are OK, X<A<T, decltype(...)>...> is equivalent to X<T...>
+// so this defines the member of the primary template.
+template<typename ...T>
+void X<A<T, decltype(f(T()))>...>::f(int) {} // expected-error {{undeclared}}
+
+template<typename ...T>
+int X<A<T, decltype(f(T()))>...>::n = 0; // expected-error {{undeclared}}
+
+struct Y {}; void f(Y);
+
+void g() {
+  // OK, substitution succeeds.
+  X<Y>().f(0);
+  X<Y>::n = 1;
+
+  // Error, substitution fails; this should not be treated as a SFINAE-able
+  // condition, so we don't select X<void>::f(...).
+  X<void>().f(0); // expected-note {{instantiation of}}
+  X<void>::n = 1; // expected-note {{instantiation of}}
+}
diff --git a/test/SemaTemplate/instantiate-typeof.cpp b/test/SemaTemplate/instantiate-typeof.cpp
index 92873cb..f4d7847 100644
--- a/test/SemaTemplate/instantiate-typeof.cpp
+++ b/test/SemaTemplate/instantiate-typeof.cpp
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
 
 // Make sure we correctly treat __typeof as potentially-evaluated when appropriate
 template<typename T> void f(T n) {
-  int buffer[n]; // expected-note {{declared here}}
-  [] { __typeof(buffer) x; }(); // expected-error {{variable 'buffer' with variably modified type cannot be captured in a lambda expression}}
+  int buffer[n];
+  [&buffer] { __typeof(buffer) x; }();
 }
 int main() {
-  f<int>(1); // expected-note {{in instantiation}}
+  f<int>(1);
 }
diff --git a/test/SemaTemplate/lookup-dependent-bases.cpp b/test/SemaTemplate/lookup-dependent-bases.cpp
index 61fca4a..f7867d8 100644
--- a/test/SemaTemplate/lookup-dependent-bases.cpp
+++ b/test/SemaTemplate/lookup-dependent-bases.cpp
@@ -1,20 +1,55 @@
 // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
-// expected-no-diagnostics
 
-class C {
-public:
-   static void foo2() {  }
+namespace basic {
+struct C {
+  static void foo2() {}
 };
-template <class T>
-class A {
-public:
-   typedef C D;
+template <typename T>
+struct A {
+  typedef C D;
 };
 
-template <class T>
-class B : public A<T> {
-public:
-   void foo() {
-    D::foo2();
-   }
+template <typename T>
+struct B : A<T> {
+  void foo() {
+    D::foo2(); // expected-warning {{use of undeclared identifier 'D'; unqualified lookup into dependent bases of class template 'B' is a Microsoft extension}}
+  }
 };
+
+template struct B<int>; // Instantiation has no warnings.
+}
+
+namespace nested_nodep_base {
+// There are limits to our hacks, MSVC accepts this, but we don't.
+struct A {
+  struct D { static void foo2(); };
+};
+template <typename T>
+struct B : T {
+  struct C {
+    void foo() {
+      D::foo2(); // expected-error {{use of undeclared identifier 'D'}}
+    }
+  };
+};
+
+template struct B<A>; // Instantiation has no warnings.
+}
+
+namespace nested_dep_base {
+// We actually accept this because the inner class has a dependent base even
+// though it isn't a template.
+struct A {
+  struct D { static void foo2(); };
+};
+template <typename T>
+struct B {
+  struct C : T {
+    void foo() {
+      D::foo2(); // expected-warning {{use of undeclared identifier 'D'; unqualified lookup into dependent bases of class template 'C' is a Microsoft extension}}
+    }
+  };
+};
+
+template struct B<A>; // Instantiation has no warnings.
+}
diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp
index 40f73c0..979782f 100644
--- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -220,7 +220,8 @@
   int    *bar() { return &b; }     // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}} expected-warning {{lookup into dependent bases}}
   int     baz() { return T::b; }   // expected-error {{no member named 'b' in 'PR16014::A'}}
   int T::*qux() { return &T::b; }  // expected-error {{no member named 'b' in 'PR16014::A'}}
-  int T::*fuz() { return &U::a; }  // expected-error {{use of undeclared identifier 'U'}}
+  int T::*fuz() { return &U::a; }  // expected-error {{use of undeclared identifier 'U'}} \
+  // expected-warning {{unqualified lookup into dependent bases of class template 'C'}}
 };
 
 template struct B<A>;
@@ -249,7 +250,8 @@
     ::UndefClass::undef(); // expected-error {{no member named 'UndefClass' in the global namespace}}
   }
   void baz() {
-    B::qux(); // expected-error {{use of undeclared identifier 'B'}}
+    B::qux(); // expected-error {{use of undeclared identifier 'B'}} \
+    // expected-warning {{unqualified lookup into dependent bases of class template 'A'}}
   }
 };
 
@@ -460,3 +462,31 @@
   int x = f<NameFromBase>();
 };
 }
+
+namespace function_template_undef_impl {
+template<class T>
+void f() {
+  Undef::staticMethod(); // expected-error {{use of undeclared identifier 'Undef'}}
+  UndefVar.method(); // expected-error {{use of undeclared identifier 'UndefVar'}}
+}
+}
+
+namespace PR20716 {
+template <template <typename T> class A>
+struct B : A<int>
+{
+  XXX x; // expected-error {{unknown type name}}
+};
+
+template <typename T>
+struct C {};
+
+template <typename T>
+using D = C<T>;
+
+template <typename T>
+struct E : D<T>
+{
+  XXX x; // expected-error {{unknown type name}}
+};
+}
diff --git a/test/SemaTemplate/pack-deduction.cpp b/test/SemaTemplate/pack-deduction.cpp
index f3f969e..84eefa6 100644
--- a/test/SemaTemplate/pack-deduction.cpp
+++ b/test/SemaTemplate/pack-deduction.cpp
@@ -37,3 +37,31 @@
   template<typename ...Ts> int g(X<Ts...>, decltype(f(Ts()...)));
   int n = g<int, int>(X<int, int, int>(), 0);
 }
+
+namespace PR14615 {
+  namespace comment0 {
+    template <class A, class...> struct X {};
+    template <class... B> struct X<int, B...> {
+      typedef int type;
+      struct valid {};
+    };
+    template <typename A, typename... B, typename T = X<A, B...>,
+              typename = typename T::valid>
+    typename T::type check(int);
+    int i = check<int, char>(1);
+  }
+
+  namespace comment2 {
+    template <class...> struct X;
+    template <typename... B, typename X<B...>::type I = 0>
+    char check(B...); // expected-note {{undefined template 'PR14615::comment2::X<char, int>'}}
+    void f() { check<char>(1, 2); } // expected-error {{no matching function}}
+  }
+
+  namespace comment3 {
+    template <class...> struct X;
+    template <typename... B, typename X<B...>::type I = (typename X<B...>::type)0>
+    char check(B...); // expected-note {{undefined template 'PR14615::comment3::X<char, int>'}}
+    void f() { check<char>(1, 2); } // expected-error {{no matching function}}
+  }
+}
diff --git a/test/SemaTemplate/temp_arg_nontype_cxx11.cpp b/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
index d773c64..15c9c25 100644
--- a/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
+++ b/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
@@ -8,3 +8,18 @@
     f<int[3], int*, nullptr>(); // expected-note{{in instantiation of}}
   }
 }
+
+namespace CanonicalNullptr {
+  template<typename T> struct get { typedef T type; };
+  struct X {};
+  template<typename T, typename get<T *>::type P = nullptr> struct A {};
+  template<typename T, typename get<decltype((T(), nullptr))>::type P = nullptr> struct B {};
+  template<typename T, typename get<T X::*>::type P = nullptr> struct C {};
+
+  template<typename T> A<T> MakeA();
+  template<typename T> B<T> MakeB();
+  template<typename T> C<T> MakeC();
+  A<int> a = MakeA<int>();
+  B<int> b = MakeB<int>();
+  C<int> c = MakeC<int>();
+}
diff --git a/test/SemaTemplate/virtual-member-functions.cpp b/test/SemaTemplate/virtual-member-functions.cpp
index 1a01808..a23bf4e 100644
--- a/test/SemaTemplate/virtual-member-functions.cpp
+++ b/test/SemaTemplate/virtual-member-functions.cpp
@@ -44,7 +44,7 @@
 
 template<typename T>
 struct HasOutOfLineKey {
-  HasOutOfLineKey() { } 
+  HasOutOfLineKey() { } // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::f' requested here}}
   virtual T *f(float *fp);
 };
 
@@ -53,7 +53,7 @@
   return fp; // expected-error{{cannot initialize return object of type 'int *' with an lvalue of type 'float *'}}
 }
 
-HasOutOfLineKey<int> out_of_line; // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::f' requested here}}
+HasOutOfLineKey<int> out_of_line; // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::HasOutOfLineKey' requested here}}
 
 namespace std {
   class type_info;
@@ -102,3 +102,53 @@
   Y* f(X<void>* x) { return dynamic_cast<Y*>(x); } // expected-note {{in instantiation of member function 'DynamicCast::X<void>::foo' requested here}}
   Y* f2(X<void>* x) { return dynamic_cast<Y*>(x); }
 }
+
+namespace avoid_using_vtable {
+// We shouldn't emit the vtable for this code, in any ABI.  If we emit the
+// vtable, we emit an implicit virtual dtor, which calls ~RefPtr, which requires
+// a complete type for DeclaredOnly.
+//
+// Previously we would reference the vtable in the MS C++ ABI, even though we
+// don't need to emit either the ctor or the dtor.  In the Itanium C++ ABI, the
+// 'trace' method is the key function, so even though we use the vtable, we
+// don't emit it.
+
+template <typename T>
+struct RefPtr {
+  T *m_ptr;
+  ~RefPtr() { m_ptr->deref(); }
+};
+struct DeclaredOnly;
+struct Base {
+  virtual ~Base();
+};
+
+struct AvoidVTable : Base {
+  RefPtr<DeclaredOnly> m_insertionStyle;
+  virtual void trace();
+  AvoidVTable();
+};
+// Don't call the dtor, because that will emit an implicit dtor, and require a
+// complete type for DeclaredOnly.
+void foo() { new AvoidVTable; }
+}
+
+namespace vtable_uses_incomplete {
+// Opposite of the previous test that avoids a vtable, this one tests that we
+// use the vtable when the ctor is defined inline.
+template <typename T>
+struct RefPtr {
+  T *m_ptr;
+  ~RefPtr() { m_ptr->deref(); }  // expected-error {{member access into incomplete type 'vtable_uses_incomplete::DeclaredOnly'}}
+};
+struct DeclaredOnly; // expected-note {{forward declaration of 'vtable_uses_incomplete::DeclaredOnly'}}
+struct Base {
+  virtual ~Base();
+};
+
+struct UsesVTable : Base {
+  RefPtr<DeclaredOnly> m_insertionStyle;
+  virtual void trace();
+  UsesVTable() {} // expected-note {{in instantiation of member function 'vtable_uses_incomplete::RefPtr<vtable_uses_incomplete::DeclaredOnly>::~RefPtr' requested here}}
+};
+}
diff --git a/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp b/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp
index d7ec3f6..6a97f31 100644
--- a/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp
+++ b/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp
@@ -11,6 +11,3 @@
 invalid;
 
 // REQUIRES: shell
-// PR15590
-// XFAIL: win64
-// XFAIL: mingw
diff --git a/test/Tooling/auto-detect-from-source-parent.cpp b/test/Tooling/auto-detect-from-source-parent.cpp
index 5f27d5a..830d09d 100644
--- a/test/Tooling/auto-detect-from-source-parent.cpp
+++ b/test/Tooling/auto-detect-from-source-parent.cpp
@@ -1,12 +1,8 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/abc/def/ijk/qwe
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/abc/def/ijk/qwe/test.cpp\",\"file\":\"%t/abc/def/ijk/qwe/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/abc/def/ijk/qwe/test.cpp\",\"file\":\"%/t/abc/def/ijk/qwe/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/abc/def/ijk/qwe/test.cpp"
 // RUN: not clang-check "%t/abc/def/ijk/qwe/test.cpp" 2>&1 | FileCheck %s
 
 // CHECK: C++ requires
 invalid;
-
-// REQUIRES: shell
-// PR15590
-// XFAIL: win64
diff --git a/test/Tooling/auto-detect-from-source.cpp b/test/Tooling/auto-detect-from-source.cpp
index 6ff39ac..12a660d 100644
--- a/test/Tooling/auto-detect-from-source.cpp
+++ b/test/Tooling/auto-detect-from-source.cpp
@@ -1,12 +1,8 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check "%t/test.cpp" 2>&1 | FileCheck %s
 
 // CHECK: C++ requires
 invalid;
-
-// REQUIRES: shell
-// PR15590
-// XFAIL: win64
diff --git a/test/Tooling/clang-check-autodetect-dir.cpp b/test/Tooling/clang-check-autodetect-dir.cpp
index 8ef3f3d..b84f3fe 100644
--- a/test/Tooling/clang-check-autodetect-dir.cpp
+++ b/test/Tooling/clang-check-autodetect-dir.cpp
@@ -1,13 +1,9 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/abc/def
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check -p "%t/abc/def" "%t/test.cpp" 2>&1|FileCheck %s
 // FIXME: Make the above easier.
 
 // CHECK: C++ requires
 invalid;
-
-// REQUIRES: shell
-// PR15590
-// XFAIL: win64
diff --git a/test/Tooling/clang-check-pwd.cpp b/test/Tooling/clang-check-pwd.cpp
index d85b9b1..3ce196b 100644
--- a/test/Tooling/clang-check-pwd.cpp
+++ b/test/Tooling/clang-check-pwd.cpp
@@ -12,6 +12,3 @@
 invalid;
 
 // REQUIRES: shell
-// PR15590
-// XFAIL: win64
-// XFAIL: mingw
diff --git a/test/Tooling/lit.local.cfg b/test/Tooling/lit.local.cfg
new file mode 100644
index 0000000..da2a68b
--- /dev/null
+++ b/test/Tooling/lit.local.cfg
@@ -0,0 +1,2 @@
+if config.root.clang_staticanalyzer == 0:
+    config.unsupported = True
diff --git a/test/Tooling/pch.cpp b/test/Tooling/pch.cpp
index 40bc1e9..5da49ea 100644
--- a/test/Tooling/pch.cpp
+++ b/test/Tooling/pch.cpp
@@ -9,7 +9,6 @@
 // the test file with an unrelated include as second translation unit.
 // Test for an non-empty file after clang-check is executed.
 // RUN: clang-check -ast-dump "%S/Inputs/pch.cpp" "%s" -- -include-pch %t1 -I "%S" -c >%t2 2>&1
-// REQUIRES: shell
 // RUN: test -s %t2
 
 #include "Inputs/pch-fail.h"
diff --git a/test/VFS/external-names.c b/test/VFS/external-names.c
index aa0bd67..52d0a8c 100644
--- a/test/VFS/external-names.c
+++ b/test/VFS/external-names.c
@@ -29,7 +29,7 @@
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -triple %itanium_abi_triple -g -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-DEBUG-EXTERNAL %s
 // CHECK-DEBUG-EXTERNAL: ![[Num:[0-9]*]] = metadata !{metadata !"{{.*}}Inputs{{.}}external-names.h
-// CHECK-DEBUG-EXTERNAL: metadata !{i32 {{[0-9]*}}, metadata ![[Num]]{{.*}}DW_TAG_file_type
+// CHECK-DEBUG-EXTERNAL: metadata !{metadata !"0x29", metadata ![[Num]]{{.*}}DW_TAG_file_type
 
 // RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -triple %itanium_abi_triple -g -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-DEBUG %s
 // CHECK-DEBUG-NOT: Inputs
diff --git a/test/VFS/umbrella-mismatch.m b/test/VFS/umbrella-mismatch.m
index c731294..f3a4ab3 100644
--- a/test/VFS/umbrella-mismatch.m
+++ b/test/VFS/umbrella-mismatch.m
@@ -1,6 +1,5 @@
 // RUN: rm -rf %t
-// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%S/Inputs:g" %S/Inputs/vfsoverlay.yaml > %t.yaml
-// REQUIRES: shell
+// RUN: sed -e "s;INPUT_DIR;%/S/Inputs;g" -e "s;OUT_DIR;%/S/Inputs;g" %S/Inputs/vfsoverlay.yaml > %t.yaml
 
 // RUN: %clang_cc1 -Werror -fmodules -fmodules-cache-path=%t -ivfsoverlay %t.yaml -F %S/Inputs -fsyntax-only %s -verify
 // RUN: %clang_cc1 -Werror -fmodules -fmodules-cache-path=%t -F %S/Inputs -fsyntax-only %s -verify
diff --git a/test/lit.cfg b/test/lit.cfg
index 11e8e0b..4567f17 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -73,7 +73,6 @@
 
 # safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
 #                  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
-#                  'IOS_SIMULATOR_DEPLOYMENT_TARGET',
 #                  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
 #                  'VC80COMNTOOLS')
 possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
@@ -115,11 +114,6 @@
     if symbolizer in os.environ:
         config.environment[symbolizer] = os.environ[symbolizer]
 
-# Propagate options for sanitizers.
-for options in ['ASAN_OPTIONS']:
-    if options in os.environ:
-        config.environment[options] = os.environ[options]
-
 ###
 
 # Check that the object root is known.
@@ -223,7 +217,8 @@
     # FIXME: Rather than just getting the version, we should have clang print
     # out its resource dir here in an easy to scrape form.
     cmd = subprocess.Popen([clang, '-print-file-name=include'],
-                           stdout=subprocess.PIPE)
+                           stdout=subprocess.PIPE,
+                           env=config.environment)
     if not cmd.stdout:
       lit_config.fatal("Couldn't find the include dir for Clang ('%s')" % clang)
     dir = cmd.stdout.read().strip()
@@ -258,7 +253,8 @@
     # -win32 is not supported for non-x86 targets; use a default.
     return 'i686-pc-win32'
 
-config.substitutions.append( ('%clang_cc1', '%s -cc1 -internal-isystem %s'
+config.substitutions.append( ('%clang_cc1',
+                              '%s -cc1 -internal-isystem %s -nostdsysteminc'
                               % (config.clang,
                                  getClangBuiltinIncludeDir(config.clang))) )
 config.substitutions.append( ('%clang_cpp', ' ' + config.clang +
@@ -272,6 +268,13 @@
 config.substitutions.append( ('%itanium_abi_triple', makeItaniumABITriple(config.target_triple)) )
 config.substitutions.append( ('%ms_abi_triple', makeMSABITriple(config.target_triple)) )
 
+# The host triple might not be set, at least if we're compiling clang from
+# an already installed llvm.
+if config.host_triple and config.host_triple != '@LLVM_HOST_TRIPLE@':
+    config.substitutions.append( ('%target_itanium_abi_host_triple', '--target=%s' % makeItaniumABITriple(config.host_triple)) )
+else:
+    config.substitutions.append( ('%target_itanium_abi_host_triple', '') )
+
 # FIXME: Find nicer way to prohibit this.
 config.substitutions.append(
     (' clang ', """*** Do not use 'clang' in tests, use '%clang'. ***""") )
@@ -334,6 +337,10 @@
 
 # Set available features we allow tests to conditionalize on.
 #
+# Enabled/disabled features
+if config.clang_staticanalyzer != 0:
+    config.available_features.add("staticanalyzer")
+
 # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
 if platform.system() not in ['FreeBSD']:
     config.available_features.add('crash-recovery')
@@ -419,7 +426,8 @@
             '--assertion-mode',
             '--targets-built',
             ],
-        stdout=subprocess.PIPE
+        stdout=subprocess.PIPE,
+        env=config.environment
         )
     # 1st line corresponds to --assertion-mode, "ON" or "OFF".
     line = cmd.stdout.readline().strip().decode('ascii')
@@ -446,6 +454,10 @@
 if (config.llvm_use_sanitizer == "Memory" or
         config.llvm_use_sanitizer == "MemoryWithOrigins"):
     config.available_features.add("msan")
+if config.llvm_use_sanitizer == "Undefined":
+    config.available_features.add("ubsan")
+else:
+    config.available_features.add("not_ubsan")
 
 # Check if we should run long running tests.
 if lit_config.params.get("run_long_tests", None) == "true":
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index 2a28c00..1f0b960 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -16,7 +16,6 @@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.clang_arcmt = @ENABLE_CLANG_ARCMT@
 config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@
-config.clang_rewriter = @ENABLE_CLANG_REWRITER@
 config.clang_examples = @ENABLE_CLANG_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.host_arch = "@HOST_ARCH@"