Merge "Define __le32__ for target le32-none-ndk" into release_31
diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def
index 20c2345..9c2a7f5 100644
--- a/include/clang/Basic/LangOptions.def
+++ b/include/clang/Basic/LangOptions.def
@@ -77,7 +77,7 @@
 LANGOPT(ObjCExceptions    , 1, 0, "Objective-C exceptions")
 LANGOPT(CXXExceptions     , 1, 0, "C++ exceptions")
 LANGOPT(SjLjExceptions    , 1, 0, "setjmp-longjump exception handling")
-LANGOPT(CXXMissingReturnSemantics, 1, 0, "C++ missing return semantics")
+LANGOPT(CXXMissingReturnSemantics, 1, 1, "C++ missing return semantics")
 LANGOPT(TraditionalCPP    , 1, 0, "traditional CPP emulation")
 LANGOPT(RTTI              , 1, 1, "run-time type information")
 LANGOPT(MSBitfields       , 1, 0, "Microsoft-compatible structure layout")
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 9a20615..0903207 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2260,8 +2260,8 @@
   }
 
   if (!Args.hasFlag(options::OPT_fglobal_ctor_const_promotion,
-                    options::OPT_fno_global_ctor_const_promotion, false)) {
-    CmdArgs.push_back("-backend-option");
+                    options::OPT_fno_global_ctor_const_promotion, !isAndroid)) {
+    CmdArgs.push_back("-mllvm");
     CmdArgs.push_back("-disable-global-ctor-const-promotion");
   }
 
diff --git a/test/CodeGenCXX/android-global-ctor-promotion.cpp b/test/CodeGenCXX/android-global-ctor-promotion.cpp
new file mode 100644
index 0000000..2a0fa0d
--- /dev/null
+++ b/test/CodeGenCXX/android-global-ctor-promotion.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -mllvm -disable-global-ctor-const-promotion \
+// RUN:     -emit-llvm -O2 -o - %s \
+// RUN:   | FileCheck %s
+
+class Boolean {
+private:
+  bool val;
+public:
+  Boolean(bool b): val(b) { }
+};
+
+extern const Boolean TRUE;
+extern const Boolean FALSE;
+
+const Boolean TRUE(true);
+const Boolean FALSE(false);
+
+// CHECK:     @TRUE = global %class.Boolean { i8 1 }, align 1
+// CHECK-NOT: @TRUE = constant %class.Boolean { i8 1 }, align 1
+// CHECK:     @FALSE = global %class.Boolean zeroinitializer, align 1
+// CHECK-NOT: @FALSE = constant %class.Boolean zeroinitializer, align 1
diff --git a/test/CodeGenCXX/android-missing-return.cpp b/test/CodeGenCXX/android-missing-return.cpp
new file mode 100644
index 0000000..6a4e122
--- /dev/null
+++ b/test/CodeGenCXX/android-missing-return.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fno-cxx-missing-return-semantics \
+// RUN:     -emit-llvm -O2 -o - %s \
+// RUN:   | FileCheck %s
+
+// CHECK: @_Z9no_return
+int no_return() {
+  // CHECK-NOT: call void @llvm.trap
+  // CHECK: ret i32 undef
+}
diff --git a/test/Driver/android-options.cpp b/test/Driver/android-options.cpp
new file mode 100644
index 0000000..501eb12
--- /dev/null
+++ b/test/Driver/android-options.cpp
@@ -0,0 +1,23 @@
+// This file checks Android-specific toolchain options.
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target arm-linux-androideabi \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT-GLOBAL-CTOR
+// CHECK-DEFAULT-GLOBAL-CTOR: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-DEFAULT-GLOBAL-CTOR: "-mllvm"
+// CHECK-DEFAULT-GLOBAL-CTOR: "-disable-global-ctor-const-promotion"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fglobal-ctor-const-promotion \
+// RUN:     -target arm-linux-androideabi \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ENABLE-GLOBAL-CTOR
+// CHECK-ENABLE-GLOBAL-CTOR: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-ENABLE-GLOBAL-CTOR-NOT: "-disable-global-ctor-const-promotion"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -fno-global-ctor-const-promotion \
+// RUN:     -target arm-linux-androideabi \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLE-GLOBAL-CTOR
+// CHECK-DISABLE-GLOBAL-CTOR: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-DISABLE-GLOBAL-CTOR: "-mllvm"
+// CHECK-DISABLE-GLOBAL-CTOR: "-disable-global-ctor-const-promotion"