Merge remote-tracking branch 'origin/master' into bradnelson/pnacl-in-pnacl
diff --git a/include/clang/Frontend/CodeGenOptions.def b/include/clang/Frontend/CodeGenOptions.def
index 8e0c78a..ea3a21b 100644
--- a/include/clang/Frontend/CodeGenOptions.def
+++ b/include/clang/Frontend/CodeGenOptions.def
@@ -86,7 +86,7 @@
 ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy) 
 CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is
                                         ///< enabled.
-VALUE_CODEGENOPT(OptimizationLevel, 3, 0) ///< The -O[0-4] option specified.
+VALUE_CODEGENOPT(OptimizationLevel, 32, 0) ///< The -O[0-4] option specified.
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
 
 CODEGENOPT(ProfileInstrGenerate , 1, 0) ///< Instrument code to generate
@@ -148,7 +148,7 @@
 VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
 
 /// The kind of generated debug info.
-ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 3, NoDebugInfo)
+ENUM_CODEGENOPT(DebugInfo, DebugInfoKind, 32, NoDebugInfo)
 
 /// Dwarf version.
 VALUE_CODEGENOPT(DwarfVersion, 3, 0)
diff --git a/lib/Basic/Makefile b/lib/Basic/Makefile
index fe2c515..cc72f2a 100644
--- a/lib/Basic/Makefile
+++ b/lib/Basic/Makefile
@@ -16,17 +16,25 @@
 
 include $(CLANG_LEVEL)/Makefile
 
-SVN_REVISION := $(strip \
-        $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(PROJ_SRC_DIR)/../..))
+#SVN_REVISION := $(strip \
+#        $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(PROJ_SRC_DIR)/../..))
 
-SVN_REPOSITORY := $(strip \
-        $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(PROJ_SRC_DIR)/../..))
+#SVN_REPOSITORY := $(strip \
+#        $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(PROJ_SRC_DIR)/../..))
 
-LLVM_REVISION := $(strip \
-        $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)))
+SVN_REVISION := 123
 
-LLVM_REPOSITORY := $(strip \
-        $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(LLVM_SRC_ROOT)))
+SVN_REPOSITORY := 456
+
+#LLVM_REVISION := $(strip \
+#        $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)))
+
+#LLVM_REPOSITORY := $(strip \
+#        $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(LLVM_SRC_ROOT)))
+
+LLVM_REVISION := 123
+
+LLVM_REPOSITORY := 456
 
 CPP.Defines += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include \
          -DSVN_REVISION='"$(SVN_REVISION)"' -DSVN_REPOSITORY='"$(SVN_REPOSITORY)"' \
diff --git a/tools/arcmt-test/arcmt-test.cpp b/tools/arcmt-test/arcmt-test.cpp
index 7be4ed6..3edf3b6 100644
--- a/tools/arcmt-test/arcmt-test.cpp
+++ b/tools/arcmt-test/arcmt-test.cpp
@@ -336,7 +336,14 @@
 // Command line processing.
 //===----------------------------------------------------------------------===//
 
+// @LOCALMOD-BEGIN
+#if defined(__native_client__)
+int main(int argc, char **argv_alt) {
+  const char **argv = const_cast<const char **>(argv_alt);
+#else
 int main(int argc, const char **argv) {
+#endif
+// @LOCALMOD-END
   void *MainAddr = (void*) (intptr_t) GetExecutablePath;
   llvm::sys::PrintStackTraceOnErrorSignal();
 
diff --git a/tools/c-arcmt-test/c-arcmt-test.c b/tools/c-arcmt-test/c-arcmt-test.c
index 3bbb2d5..928a586 100644
--- a/tools/c-arcmt-test/c-arcmt-test.c
+++ b/tools/c-arcmt-test/c-arcmt-test.c
@@ -106,7 +106,14 @@
   fflush(stderr);
 }
 
+// @LOCALMOD-BEGIN
+#if defined(__native_client__)
+int main(int argc, char **argv_alt) {
+  const char **argv = (const char**) argv_alt;
+#else
 int main(int argc, const char **argv) {
+#endif
+// @LOCALMOD-END
   thread_info client_data;
 
   atexit(flush_atexit);
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 56e4101..aeed634 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -4169,7 +4169,14 @@
   fflush(stderr);
 }
 
+// @LOCALMOD-BEGIN
+#if defined(__native_client__)
+int main(int argc, char **argv_alt) {
+  const char **argv = (const char **) argv_alt;
+#else
 int main(int argc, const char **argv) {
+#endif
+// @LOCALMOD-END
   thread_info client_data;
 
   atexit(flush_atexit);
diff --git a/tools/clang-check/ClangCheck.cpp b/tools/clang-check/ClangCheck.cpp
index d92a8d5..13ca36e 100644
--- a/tools/clang-check/ClangCheck.cpp
+++ b/tools/clang-check/ClangCheck.cpp
@@ -147,7 +147,14 @@
 
 } // namespace
 
+// @LOCALMOD-BEGIN
+#if defined(__native_client__)
+int main(int argc, char **argv_alt) {
+  const char **argv = const_cast<const char **>(argv_alt);
+#else
 int main(int argc, const char **argv) {
+#endif
+// @LOCALMOD-END
   llvm::sys::PrintStackTraceOnErrorSignal();
   CommonOptionsParser OptionsParser(argc, argv, ClangCheckCategory);
   ClangTool Tool(OptionsParser.getCompilations(),
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp
index cacc51f..1b60ed3 100644
--- a/tools/clang-format/ClangFormat.cpp
+++ b/tools/clang-format/ClangFormat.cpp
@@ -263,7 +263,14 @@
   OS << clang::getClangToolFullVersion("clang-format") << '\n';
 }
 
+// @LOCALMOD-BEGIN
+#if defined(__native_client__)
+int main(int argc, char **argv_alt) {
+  const char **argv = const_cast<const char**>(argv_alt);
+#else
 int main(int argc, const char **argv) {
+#endif
+// @LOCALMOD-END
   llvm::sys::PrintStackTraceOnErrorSignal();
 
   // Hide unrelated options.
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index e93fa80..3e15908 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -375,7 +375,15 @@
   return 1;
 }
 
+// @LOCALMOD-BEGIN
+#if defined(__native_client__)
+int main(int argc_, char **argv_alt_) {
+  const char **argv_ = const_cast<const char **>(argv_alt_);
+#else
+=======
 int main(int argc_, const char **argv_) {
+#endif
+// @LOCALMOD-END
   llvm::sys::PrintStackTraceOnErrorSignal();
   llvm::PrettyStackTraceProgram X(argc_, argv_);
 
diff --git a/tools/libclang/CIndexer.cpp b/tools/libclang/CIndexer.cpp
index 91154cc..a65ca3c 100644
--- a/tools/libclang/CIndexer.cpp
+++ b/tools/libclang/CIndexer.cpp
@@ -37,6 +37,9 @@
 
 #ifdef LLVM_ON_WIN32
 #include <windows.h>
+// @LOCALMOD-BEGIN
+#elif defined(__native_client__)
+// @LOCALMOD-END
 #else
 #include <dlfcn.h>
 #endif
@@ -69,6 +72,10 @@
 #endif
 
   LibClangPath += llvm::sys::path::parent_path(path);
+// @LOCALMOD-BEGIN
+#elif defined(__native_client__)
+  // Nothing for now.
+// @LOCALMOD-END
 #else
   // This silly cast below avoids a C++ warning.
   Dl_info info;
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index 81cff5a..24bdb8d 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -23,6 +23,14 @@
 #include "clang/AST/Type.h"
 #include "clang/Frontend/ASTUnit.h"
 
+// @LOCALMOD-BEGIN
+#if defined(__pnacl__)
+#define LLONG_MAX 9223372036854775807LL
+#define LLONG_MIN (-LLONG_MAX-1)
+#define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
+#endif
+// @LOCALMOD-END
+
 using namespace clang;
 
 static CXTypeKind GetBuiltinTypeKind(const BuiltinType *BT) {
diff --git a/tools/libclang/Makefile b/tools/libclang/Makefile
index 97f663c..804cb5e 100644
--- a/tools/libclang/Makefile
+++ b/tools/libclang/Makefile
@@ -12,8 +12,12 @@
 
 EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/libclang.exports
 
-LINK_LIBS_IN_SHARED = 1
-SHARED_LIBRARY = 1
+# @LOCALMOD-BEGIN
+ifneq ($(HOST_OS),NativeClient)
+  LINK_LIBS_IN_SHARED = 1
+  SHARED_LIBRARY = 1
+endif
+# @LOCALMOD-END
 
 include $(CLANG_LEVEL)/../../Makefile.config
 LINK_COMPONENTS := AsmParser BitReader Core MC MCParser Option Support
diff --git a/unittests/Makefile b/unittests/Makefile
index 1e6a508..4e45394 100644
--- a/unittests/Makefile
+++ b/unittests/Makefile
@@ -10,6 +10,15 @@
 # If CLANG_LEVEL is not set, then we are the top-level Makefile. Otherwise, we
 # are being included from a subdirectory makefile.
 
+ifeq ($(HOST_OS),NativeClient)
+all:
+	echo skipping
+
+install:
+	echo skipping
+
+else
+
 ifndef CLANG_LEVEL
 
 IS_UNITTEST_LEVEL := 1
@@ -33,3 +42,4 @@
 include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
 
 endif  # IS_UNITTEST_LEVEL
+endif