Merge with CLANG upstream r155088.

Conflicts:
	lib/Basic/Targets.cpp

Change-Id: Id80f069ae25e623967b705e9fa11cfd94dd2461c
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..c75db3f
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,32 @@
+LOCAL_PATH := $(call my-dir)
+CLANG_ROOT_PATH := $(LOCAL_PATH)
+
+include $(CLEAR_VARS)
+
+subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
+  lib/Analysis \
+  lib/AST \
+  lib/ARCMigrate \
+  lib/Basic \
+  lib/CodeGen \
+  lib/Driver \
+  lib/Edit \
+  lib/Frontend \
+  lib/FrontendTool \
+  lib/Headers \
+  lib/Index \
+  lib/Lex \
+  lib/Parse \
+  lib/Rewrite \
+  lib/Sema \
+  lib/Serialization \
+  lib/StaticAnalyzer/Checkers \
+  lib/StaticAnalyzer/Core \
+  lib/StaticAnalyzer/Frontend \
+  tools/driver \
+  utils/TableGen \
+  ))
+
+include $(LOCAL_PATH)/clang.mk
+
+include $(subdirs)
diff --git a/MODULE_LICENSE_BSD_LIKE b/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_BSD_LIKE
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..369204e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,62 @@
+==============================================================================
+LLVM Release License
+==============================================================================
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2007-2011 University of Illinois at Urbana-Champaign.
+All rights reserved.
+
+Developed by:
+
+    LLVM Team
+
+    University of Illinois at Urbana-Champaign
+
+    http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimers.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimers in the
+      documentation and/or other materials provided with the distribution.
+
+    * Neither the names of the LLVM Team, University of Illinois at
+      Urbana-Champaign, nor the names of its contributors may be used to
+      endorse or promote products derived from this Software without specific
+      prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+The LLVM software contains code written by third parties.  Such software will
+have its own individual LICENSE.TXT file in the directory in which it appears.
+This file will describe the copyrights, license, and restrictions which apply
+to that code.
+
+The disclaimer of warranty in the University of Illinois Open Source License
+applies to all code in the LLVM Distribution, and nothing in any of the
+other licenses gives permission to use the names of the LLVM Team or the
+University of Illinois to endorse or promote products derived from this
+Software.
+
+The following pieces of software have additional or alternate copyrights,
+licenses, and/or restrictions:
+
+Program             Directory
+-------             ---------
+<none yet>
diff --git a/README.android b/README.android
new file mode 100644
index 0000000..7f8033d
--- /dev/null
+++ b/README.android
@@ -0,0 +1,41 @@
+/*
+ * README.android describes in high-level the LLVM changes that we cannot push
+ * upstream to the llvm.org repository:
+ *  - Changes due to Android's build system.
+ *  - Changes due to Android's toolchain.
+ *  - Changes due to the limitations in Android-based consumer electronics.
+ *
+ * Some of them are to-dos. If and when they are done, there will no longer be
+ * merge conflicts with upstream on those parts.
+ *
+ * The file contains useful hints when we try to resolve future 3-way merge
+ * conflicts.
+ */
+
+* For Honeycomb: Synced to upstream r112347
+* For Honeycomb MR1: Synced to upstream r119349
+* For Honeycomb MR2: Synced to upstream r119349
+* For Ice Cream Sandwich: Synced to upstream r135574
+* For Ice Cream Sandwich MR1: Synced to upstream r142531
+* For Ice Cream Sandwich MR2: Synced to upstream r146715
+* For Jellybean: Synced to upstream r153220
+
+* Recent downstreaming on 2012/3/24: Synced to r153220 (sliao & srhines for merge questions)
+* Recent downstreaming on 2012/3/5: Synced to r152062 (srhines & sliao for merge questions)
+* Recent downstreaming on 2011/12/17: Synced to r146715 (loganchien & sliao for merge questions)
+* Recent downstreaming on 2011/11/26: Synced to r145117 (loganchien & sliao for merge questions)
+* Recent downstreaming on 2011/11/17: Synced to r144605 (loganchien & sliao for merge questions)
+* Recent downstreaming on 2011/11/14: Synced to r144355 (srhines for merge questions)
+* Recent downstreaming on 2011/10/22: Synced to r142531 (sliao & loganchien for merge questions)
+* Recent downstreaming on 2011/7/21:  Synced to r135574 (sliao & loganchien for merge questions)
+* Recent downstreaming on 2011/7/18:  Synced to r135359 (sliao for merge questions)
+* Recent downstreaming on 2011/7/2:   Synced to r134305 (sliao for merge questions)
+* Recent downstreaming on 2011/6/30:  Synced to r133721 (sliao for merge questions)
+* Recent downstreaming on 2011/6/22:  Synced to r133163 (sliao for merge questions)
+* Recent downstreaming on 2011/4/8:   Synced to r129173 (sliao for merge questions)
+* Recent downstreaming on 2011/3/11:  Synced from r119349 to r127120 (sliao for merge questions)
+
+* We add Android's *.mk files that are specific to Android's build system.
+
+* Changes for enabling both host and device builds.
+
diff --git a/clang-host-build.mk b/clang-host-build.mk
new file mode 100644
index 0000000..e0ba2e6
--- /dev/null
+++ b/clang-host-build.mk
@@ -0,0 +1,38 @@
+LOCAL_CFLAGS :=	\
+	-pedantic	\
+	-Wcast-qual	\
+	-Wno-long-long	\
+	$(LOCAL_CFLAGS)
+
+LOCAL_CPPFLAGS := \
+	-Wno-sign-promo \
+	$(LOCAL_CPPFLAGS)
+
+# Make sure bionic is first so we can include system headers.
+LOCAL_C_INCLUDES :=	\
+	$(CLANG_ROOT_PATH)/include	\
+        $(CLANG_ROOT_PATH)/lib/CodeGen    \
+	$(LOCAL_C_INCLUDES)
+
+LLVM_ROOT_PATH := external/llvm
+include $(LLVM_ROOT_PATH)/llvm.mk
+
+ifneq ($(LLVM_HOST_BUILD_MK),)
+include $(LLVM_HOST_BUILD_MK)
+endif
+
+###########################################################
+## Commands for running tblgen to compile a td file
+###########################################################
+define transform-host-clang-td-to-out
+@mkdir -p $(dir $@)
+@echo "Host Clang TableGen: $(TBLGEN_LOCAL_MODULE) (gen-$(1)) <= $<"
+$(hide) $(CLANG_TBLGEN) \
+	-I $(dir $<)	\
+	-I $(LLVM_ROOT_PATH)/include	\
+	-I $(LLVM_ROOT_PATH)/host/include	\
+	-I $(LLVM_ROOT_PATH)/lib/Target	\
+	$(if $(strip $(CLANG_ROOT_PATH)),-I $(CLANG_ROOT_PATH)/include,)	\
+	-gen-$(strip $(1))	\
+	-o $@ $<
+endef
diff --git a/clang-tblgen-rules.mk b/clang-tblgen-rules.mk
new file mode 100644
index 0000000..030ed2b
--- /dev/null
+++ b/clang-tblgen-rules.mk
@@ -0,0 +1,157 @@
+###########################################################
+## TableGen: Compile .td files to .inc.
+###########################################################
+ifeq ($(LOCAL_MODULE_CLASS),)
+    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+endif
+
+ifneq ($(strip $(TBLGEN_TABLES)),)
+
+intermediates := $(call local-intermediates-dir)
+
+ifneq ($(findstring AttrImpl.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/AST/AttrImpl.inc
+$(intermediates)/include/clang/AST/AttrImpl.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/AST/AttrImpl.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-impl)
+endif
+
+ifneq ($(findstring AttrList.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Basic/AttrList.inc
+$(intermediates)/include/clang/Basic/AttrList.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Basic/AttrList.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-list)
+endif
+
+ifneq ($(findstring AttrSpellings.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Lex/AttrSpellings.inc
+$(intermediates)/include/clang/Lex/AttrSpellings.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Lex/AttrSpellings.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-spelling-list)
+endif
+
+ifneq ($(findstring AttrPCHRead.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Serialization/AttrPCHRead.inc
+$(intermediates)/include/clang/Serialization/AttrPCHRead.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Serialization/AttrPCHRead.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-pch-read)
+endif
+
+ifneq ($(findstring AttrPCHWrite.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Serialization/AttrPCHWrite.inc
+$(intermediates)/include/clang/Serialization/AttrPCHWrite.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Serialization/AttrPCHWrite.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-pch-write)
+endif
+
+ifneq ($(findstring AttrLateParsed.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Parse/AttrLateParsed.inc
+$(intermediates)/include/clang/Parse/AttrLateParsed.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Parse/AttrLateParsed.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-late-parsed-list)
+endif
+
+ifneq ($(findstring Attrs.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/AST/Attrs.inc
+$(intermediates)/include/clang/AST/Attrs.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/AST/Attrs.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-classes)
+endif
+
+ifneq ($(findstring AttrParsedAttrKinds.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Sema/AttrParsedAttrKinds.inc
+$(intermediates)/include/clang/Sema/AttrParsedAttrKinds.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Sema/AttrParsedAttrKinds.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-parsed-attr-kinds)
+endif
+
+ifneq ($(findstring AttrParsedAttrList.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Sema/AttrParsedAttrList.inc
+$(intermediates)/include/clang/Sema/AttrParsedAttrList.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Sema/AttrParsedAttrList.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-parsed-attr-list)
+endif
+
+ifneq ($(findstring AttrTemplateInstantiate.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Sema/AttrTemplateInstantiate.inc
+$(intermediates)/include/clang/Sema/AttrTemplateInstantiate.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Sema/AttrTemplateInstantiate.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Attr.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-attr-template-instantiate)
+endif
+
+ifneq ($(findstring Checkers.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/Checkers.inc
+$(intermediates)/Checkers.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/Checkers.inc: \
+  $(CLANG_ROOT_PATH)/lib/StaticAnalyzer/Checkers/Checkers.td \
+  $(CLANG_ROOT_PATH)/include/clang/StaticAnalyzer/Checkers/CheckerBase.td \
+  $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-sa-checkers)
+endif
+
+ifneq ($(filter Diagnostic%Kinds.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/include/clang/Basic/,$(filter Diagnostic%Kinds.inc,$(TBLGEN_TABLES)))
+$(intermediates)/include/clang/Basic/Diagnostic%Kinds.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Basic/Diagnostic%Kinds.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Diagnostic.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc,%,$(@F)))
+endif
+
+ifneq ($(findstring DiagnosticGroups.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Basic/DiagnosticGroups.inc
+$(intermediates)/include/clang/Basic/DiagnosticGroups.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Basic/DiagnosticGroups.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Diagnostic.td $(CLANG_ROOT_PATH)/include/clang/Basic/DiagnosticGroups.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-diag-groups)
+endif
+
+ifneq ($(findstring DiagnosticIndexName.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Basic/DiagnosticIndexName.inc
+$(intermediates)/include/clang/Basic/DiagnosticIndexName.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Basic/DiagnosticIndexName.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Diagnostic.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-diag-groups)
+endif
+
+ifneq ($(findstring DeclNodes.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/AST/DeclNodes.inc
+$(intermediates)/include/clang/AST/DeclNodes.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/AST/DeclNodes.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/DeclNodes.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-decl-nodes)
+endif
+
+ifneq ($(findstring StmtNodes.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/AST/StmtNodes.inc
+$(intermediates)/include/clang/AST/StmtNodes.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/AST/StmtNodes.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/StmtNodes.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,clang-stmt-nodes)
+endif
+
+ifneq ($(findstring arm_neon.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Basic/arm_neon.inc
+$(intermediates)/include/clang/Basic/arm_neon.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Basic/arm_neon.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/arm_neon.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,arm-neon-sema)
+endif
+
+ifneq ($(findstring Options.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Driver/Options.inc
+$(intermediates)/include/clang/Driver/Options.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Driver/Options.inc: $(CLANG_ROOT_PATH)/include/clang/Driver/Options.td $(CLANG_ROOT_PATH)/include/clang/Driver/OptParser.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,opt-parser-defs)
+endif
+
+ifneq ($(findstring CC1Options.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Driver/CC1Options.inc
+$(intermediates)/include/clang/Driver/CC1Options.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Driver/CC1Options.inc: $(CLANG_ROOT_PATH)/include/clang/Driver/CC1Options.td $(CLANG_ROOT_PATH)/include/clang/Driver/OptParser.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,opt-parser-defs)
+endif
+
+ifneq ($(findstring CC1AsOptions.inc,$(TBLGEN_TABLES)),)
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Driver/CC1AsOptions.inc
+$(intermediates)/include/clang/Driver/CC1AsOptions.inc: TBLGEN_LOCAL_MODULE := $(LOCAL_MODULE)
+$(intermediates)/include/clang/Driver/CC1AsOptions.inc: $(CLANG_ROOT_PATH)/include/clang/Driver/CC1AsOptions.td $(CLANG_ROOT_PATH)/include/clang/Driver/OptParser.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,opt-parser-defs)
+endif
+
+LOCAL_C_INCLUDES += $(intermediates)/include
+
+endif
diff --git a/clang-version-inc.mk b/clang-version-inc.mk
new file mode 100644
index 0000000..3a01fb8
--- /dev/null
+++ b/clang-version-inc.mk
@@ -0,0 +1,35 @@
+###########################################################
+## Generate clang/Basic/Version.inc
+###########################################################
+ifeq ($(LOCAL_MODULE_CLASS),)
+    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+endif
+
+intermediates := $(call local-intermediates-dir)
+
+LLVMVersion := $(shell grep PACKAGE_VERSION $(LLVM_ROOT_PATH)/host/include/llvm/Config/config.h | sed -e 's/\#define PACKAGE_VERSION "\(.*\)"/\1/g')
+
+# Compute the Clang version from the LLVM version, unless specified explicitly.
+# (Copy from include/clang/Basic/Makefile)
+CLANG_VERSION := $(subst svn,,$(LLVMVersion))
+CLANG_VERSION_COMPONENTS := $(subst ., ,$(CLANG_VERSION))
+CLANG_VERSION_MAJOR := $(word 1,$(CLANG_VERSION_COMPONENTS))
+CLANG_VERSION_MINOR := $(word 2,$(CLANG_VERSION_COMPONENTS))
+CLANG_VERSION_PATCHLEVEL := $(word 3,$(CLANG_VERSION_COMPONENTS))
+ifeq ($(CLANG_VERSION_PATCHLEVEL),)
+    CLANG_HAS_VERSION_PATCHLEVEL := 0
+else
+    CLANG_HAS_VERSION_PATCHLEVEL := 1
+endif
+
+LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Basic/Version.inc
+$(intermediates)/include/clang/Basic/Version.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Version.inc.in
+	@echo "Updating Clang version info."
+	@mkdir -p $(dir $@)
+	$(hide) sed -e "s#@CLANG_VERSION@#$(CLANG_VERSION)#g" \
+	-e "s#@CLANG_VERSION_MAJOR@#$(CLANG_VERSION_MAJOR)#g" \
+	-e "s#@CLANG_VERSION_MINOR@#$(CLANG_VERSION_MINOR)#g" \
+	-e "s#@CLANG_VERSION_PATCHLEVEL@#$(CLANG_VERSION_PATCHLEVEL)#g" \
+	-e "s#@CLANG_HAS_VERSION_PATCHLEVEL@#$(CLANG_HAS_VERSION_PATCHLEVEL)#g" \
+	$< > $@
+
diff --git a/clang.mk b/clang.mk
new file mode 100644
index 0000000..f1084a5
--- /dev/null
+++ b/clang.mk
@@ -0,0 +1,9 @@
+ifeq ($(CLANG_ROOT_PATH),)
+$(error Must set variable CLANG_ROOT_PATH before including this! $(LOCAL_PATH))
+endif
+
+CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
+
+CLANG_HOST_BUILD_MK := $(CLANG_ROOT_PATH)/clang-host-build.mk
+CLANG_TBLGEN_RULES_MK := $(CLANG_ROOT_PATH)/clang-tblgen-rules.mk
+CLANG_VERSION_INC_MK := $(CLANG_ROOT_PATH)/clang-version-inc.mk
diff --git a/gen_diff.sh b/gen_diff.sh
new file mode 100755
index 0000000..a914a41
--- /dev/null
+++ b/gen_diff.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Copyright 2011 Google Inc. All Rights Reserved.
+
+function usage() {
+  echo Usage: $0 "[PATH_TO_YOUR_LLVM_DIRECTORY]"
+  echo This will generate a diff of both Clang and LLVM in the files
+  echo diff_clang.txt
+  echo diff_llvm.txt
+}
+
+BASE_LLVM_DIR_ONCE=0
+BASE_LLVM_DIR=$LLVMDIR/llvm
+
+ARGS=`getopt -o h --long help -- "$@"`
+eval set -- "$ARGS"
+
+while true; do
+  case "$1" in
+  -h|--help)
+    usage
+    exit 0
+    ;;
+  --)
+    shift;
+    break
+    ;;
+  *)
+    echo "Internal error!"
+    exit 1
+    ;;
+  esac
+done
+
+for ARG; do
+  if [ $BASE_LLVM_DIR_ONCE -eq 1 ]; then
+    usage
+    exit 1
+  fi
+  BASE_LLVM_DIR_ONCE=1
+  BASE_LLVM_DIR=$ARG
+done
+
+BASE_CLANG_DIR=$BASE_LLVM_DIR/tools/clang
+echo "Using BASE_LLVM_DIR = $BASE_LLVM_DIR"
+echo "Using BASE_CLANG_DIR = $BASE_CLANG_DIR"
+
+ANDROID_LLVM_DIR=$PWD/../llvm
+ANDROID_CLANG_DIR=$PWD
+echo "Using ANDROID_LLVM_DIR = $ANDROID_LLVM_DIR"
+echo "Using ANDROID_CLANG_DIR = $ANDROID_CLANG_DIR"
+
+DIFF_FLAGS="-x .git -r"
+
+diff $DIFF_FLAGS $BASE_CLANG_DIR $ANDROID_CLANG_DIR > diff_clang.txt
+diff $DIFF_FLAGS $BASE_LLVM_DIR $ANDROID_LLVM_DIR > diff_llvm.txt
+
+exit 0
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 7b615c1..5549354 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -2444,10 +2444,10 @@
   static int getPointAccessorIdx(char c) {
     switch (c) {
     default: return -1;
-    case 'x': return 0;
-    case 'y': return 1;
-    case 'z': return 2;
-    case 'w': return 3;
+    case 'x': case 'r': return 0;
+    case 'y': case 'g': return 1;
+    case 'z': case 'b': return 2;
+    case 'w': case 'a': return 3;
     }
   }
   static int getNumericAccessorIdx(char c) {
diff --git a/include/clang/Config/config.h b/include/clang/Config/config.h
new file mode 100644
index 0000000..b37d42a
--- /dev/null
+++ b/include/clang/Config/config.h
@@ -0,0 +1,19 @@
+/* tools/clang/include/clang/Config/config.h.  Generated from config.h.in by configure.  */
+/* include/clang/Config/config.h.in. */
+
+#ifndef ANDROID_CONFIG_H
+#define ANDROID_CONFIG_H
+
+/* Bug report URL. */
+#define BUG_REPORT_URL "http://llvm.org/bugs/"
+
+/* Relative directory for resource files */
+#define CLANG_RESOURCE_DIR ""
+
+/* Directory where gcc is installed. */
+#define GCC_INSTALL_PREFIX ""
+
+/* Directories clang will search for headers */
+#define C_INCLUDE_DIRS ""
+
+#endif
diff --git a/lib/ARCMigrate/Android.mk b/lib/ARCMigrate/Android.mk
new file mode 100644
index 0000000..657a975
--- /dev/null
+++ b/lib/ARCMigrate/Android.mk
@@ -0,0 +1,46 @@
+LOCAL_PATH := $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  Attrs.inc \
+  AttrList.inc \
+  AttrParsedAttrList.inc    \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticGroups.inc \
+  DiagnosticSemaKinds.inc \
+  StmtNodes.inc
+
+clang_arc_migrate_SRC_FILES := \
+  ARCMT.cpp \
+  ARCMTActions.cpp \
+  FileRemapper.cpp \
+  ObjCMT.cpp \
+  PlistReporter.cpp \
+  TransAPIUses.cpp \
+  TransARCAssign.cpp \
+  TransAutoreleasePool.cpp \
+  TransBlockObjCVariable.cpp \
+  TransEmptyStatementsAndDealloc.cpp \
+  TransformActions.cpp \
+  Transforms.cpp \
+  TransGCAttrs.cpp \
+  TransGCCalls.cpp \
+  TransProperties.cpp \
+  TransRetainReleaseDealloc.cpp \
+  TransUnbridgedCasts.cpp \
+  TransUnusedInitDelegate.cpp \
+  TransZeroOutPropsInDealloc.cpp
+
+LOCAL_SRC_FILES := $(clang_arc_migrate_SRC_FILES)
+
+LOCAL_MODULE := libclangARCMigrate
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/AST/Android.mk b/lib/AST/Android.mk
new file mode 100644
index 0000000..6e52ada
--- /dev/null
+++ b/lib/AST/Android.mk
@@ -0,0 +1,77 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES :=    \
+	AttrImpl.inc	\
+	AttrList.inc	\
+	Attrs.inc	\
+	DeclNodes.inc	\
+	DiagnosticASTKinds.inc	\
+	DiagnosticCommonKinds.inc	\
+	DiagnosticSemaKinds.inc	\
+	StmtNodes.inc
+
+clang_ast_SRC_FILES :=	\
+	APValue.cpp	\
+	ASTConsumer.cpp	\
+	ASTContext.cpp	\
+	ASTDiagnostic.cpp	\
+	ASTImporter.cpp	\
+	AttrImpl.cpp	\
+	CXXInheritance.cpp	\
+	Decl.cpp	\
+	DeclarationName.cpp	\
+	DeclBase.cpp	\
+	DeclCXX.cpp	\
+	DeclFriend.cpp	\
+	DeclGroup.cpp	\
+	DeclObjC.cpp	\
+	DeclPrinter.cpp	\
+	DeclTemplate.cpp	\
+	DumpXML.cpp	\
+	Expr.cpp	\
+	ExprClassification.cpp	\
+	ExprConstant.cpp	\
+	ExprCXX.cpp	\
+	ExternalASTSource.cpp	\
+	InheritViz.cpp	\
+	ItaniumCXXABI.cpp	\
+	ItaniumMangle.cpp	\
+	LambdaMangleContext.cpp	\
+	Mangle.cpp	\
+	MicrosoftCXXABI.cpp	\
+	MicrosoftMangle.cpp	\
+	NestedNameSpecifier.cpp	\
+        NSAPI.cpp       \
+	ParentMap.cpp	\
+	RecordLayout.cpp	\
+	RecordLayoutBuilder.cpp	\
+	SelectorLocationsKind.cpp \
+	Stmt.cpp	\
+	StmtDumper.cpp	\
+	StmtIterator.cpp	\
+	StmtPrinter.cpp	\
+	StmtProfile.cpp	\
+	StmtViz.cpp	\
+	TemplateBase.cpp	\
+	TemplateName.cpp	\
+	Type.cpp	\
+	TypeLoc.cpp	\
+	TypePrinter.cpp \
+	VTTBuilder.cpp \
+	VTableBuilder.cpp
+
+LOCAL_SRC_FILES := $(clang_ast_SRC_FILES)
+
+LOCAL_MODULE:= libclangAST
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Analysis/Android.mk b/lib/Analysis/Android.mk
new file mode 100644
index 0000000..f5e3779
--- /dev/null
+++ b/lib/Analysis/Android.mk
@@ -0,0 +1,45 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticAnalysisKinds.inc \
+  StmtNodes.inc
+
+clang_analysis_SRC_FILES := \
+  AnalysisDeclContext.cpp \
+  CallGraph.cpp \
+  CFG.cpp \
+  CFGReachabilityAnalysis.cpp \
+  CFGStmtMap.cpp \
+  CocoaConventions.cpp \
+  Dominators.cpp \
+  FormatString.cpp \
+  LiveVariables.cpp \
+  PostOrderCFGView.cpp \
+  PrintfFormatString.cpp \
+  ProgramPoint.cpp \
+  PseudoConstantAnalysis.cpp \
+  ReachableCode.cpp \
+  ScanfFormatString.cpp \
+  ThreadSafety.cpp \
+  UninitializedValues.cpp
+
+
+LOCAL_SRC_FILES := $(clang_analysis_SRC_FILES)
+
+LOCAL_MODULE:= libclangAnalysis
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Analysis/NOTICE b/lib/Analysis/NOTICE
new file mode 100644
index 0000000..369204e
--- /dev/null
+++ b/lib/Analysis/NOTICE
@@ -0,0 +1,62 @@
+==============================================================================
+LLVM Release License
+==============================================================================
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2007-2011 University of Illinois at Urbana-Champaign.
+All rights reserved.
+
+Developed by:
+
+    LLVM Team
+
+    University of Illinois at Urbana-Champaign
+
+    http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimers.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimers in the
+      documentation and/or other materials provided with the distribution.
+
+    * Neither the names of the LLVM Team, University of Illinois at
+      Urbana-Champaign, nor the names of its contributors may be used to
+      endorse or promote products derived from this Software without specific
+      prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+The LLVM software contains code written by third parties.  Such software will
+have its own individual LICENSE.TXT file in the directory in which it appears.
+This file will describe the copyrights, license, and restrictions which apply
+to that code.
+
+The disclaimer of warranty in the University of Illinois Open Source License
+applies to all code in the LLVM Distribution, and nothing in any of the
+other licenses gives permission to use the names of the LLVM Team or the
+University of Illinois to endorse or promote products derived from this
+Software.
+
+The following pieces of software have additional or alternate copyrights,
+licenses, and/or restrictions:
+
+Program             Directory
+-------             ---------
+<none yet>
diff --git a/lib/Basic/Android.mk b/lib/Basic/Android.mk
new file mode 100644
index 0000000..14ab8c1
--- /dev/null
+++ b/lib/Basic/Android.mk
@@ -0,0 +1,50 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  DiagnosticASTKinds.inc \
+  DiagnosticAnalysisKinds.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticDriverKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  DiagnosticGroups.inc \
+  DiagnosticIndexName.inc \
+  DiagnosticLexKinds.inc \
+  DiagnosticParseKinds.inc \
+  DiagnosticSemaKinds.inc \
+  DiagnosticSerializationKinds.inc \
+  arm_neon.inc
+
+clang_basic_SRC_FILES := \
+  Builtins.cpp \
+  ConvertUTF.c \
+  Diagnostic.cpp \
+  DiagnosticIDs.cpp \
+  FileManager.cpp \
+  FileSystemStatCache.cpp \
+  IdentifierTable.cpp \
+  LangOptions.cpp \
+  Module.cpp \
+  SourceLocation.cpp \
+  SourceManager.cpp \
+  TargetInfo.cpp \
+  Targets.cpp \
+  TokenKinds.cpp \
+  Version.cpp \
+  VersionTuple.cpp
+
+LOCAL_SRC_FILES := $(clang_basic_SRC_FILES)
+
+LOCAL_MODULE:= libclangBasic
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 1eceaaa..71badbe 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -2731,7 +2731,7 @@
                                  bool Enabled) const {
     if (Name == "soft-float" || Name == "soft-float-abi" ||
         Name == "vfp2" || Name == "vfp3" || Name == "neon" || Name == "d16" ||
-        Name == "neonfp") {
+        Name == "neonfp" || Name == "long64") {
       Features[Name] = Enabled;
     } else
       return false;
@@ -2753,6 +2753,8 @@
         FPU = VFP3FPU;
       else if (Features[i] == "+neon")
         FPU = NeonFPU;
+      else if (Features[i] == "+long64")
+        LongWidth = LongAlign = 64;  // RenderScript uses a 64-bit long type
     }
 
     // Remove front-end specific options which the backend handles differently.
diff --git a/lib/CodeGen/Android.mk b/lib/CodeGen/Android.mk
new file mode 100644
index 0000000..bf35b68
--- /dev/null
+++ b/lib/CodeGen/Android.mk
@@ -0,0 +1,68 @@
+LOCAL_PATH:= $(call my-dir)
+
+clang_codegen_TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  StmtNodes.inc \
+  arm_neon.inc
+
+clang_codegen_SRC_FILES := \
+  BackendUtil.cpp \
+  CGBlocks.cpp \
+  CGBuiltin.cpp \
+  CGCUDANV.cpp \
+  CGCUDARuntime.cpp \
+  CGCXX.cpp \
+  CGCXXABI.cpp \
+  CGCall.cpp \
+  CGClass.cpp \
+  CGCleanup.cpp \
+  CGDebugInfo.cpp \
+  CGDecl.cpp \
+  CGDeclCXX.cpp \
+  CGException.cpp \
+  CGExpr.cpp \
+  CGExprAgg.cpp \
+  CGExprCXX.cpp \
+  CGExprComplex.cpp \
+  CGExprConstant.cpp \
+  CGExprScalar.cpp \
+  CGObjC.cpp \
+  CGObjCGNU.cpp \
+  CGObjCMac.cpp \
+  CGObjCRuntime.cpp \
+  CGOpenCLRuntime.cpp \
+  CGRTTI.cpp \
+  CGRecordLayoutBuilder.cpp \
+  CGStmt.cpp \
+  CGVTT.cpp \
+  CGVTables.cpp \
+  CodeGenAction.cpp \
+  CodeGenFunction.cpp \
+  CodeGenModule.cpp \
+  CodeGenTBAA.cpp \
+  CodeGenTypes.cpp \
+  ItaniumCXXABI.cpp \
+  MicrosoftCXXABI.cpp \
+  ModuleBuilder.cpp \
+  TargetInfo.cpp
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_MODULE:= libclangCodeGen
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(clang_codegen_SRC_FILES)
+TBLGEN_TABLES := $(clang_codegen_TBLGEN_TABLES)
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(LLVM_GEN_INTRINSICS_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Driver/Android.mk b/lib/Driver/Android.mk
new file mode 100644
index 0000000..e2c8181
--- /dev/null
+++ b/lib/Driver/Android.mk
@@ -0,0 +1,45 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  DiagnosticCommonKinds.inc \
+  DiagnosticDriverKinds.inc \
+  Options.inc \
+  CC1Options.inc \
+  CC1AsOptions.inc
+
+clang_driver_SRC_FILES := \
+  Action.cpp \
+  Arg.cpp \
+  ArgList.cpp \
+  CC1Options.cpp \
+  CC1AsOptions.cpp \
+  Compilation.cpp \
+  Driver.cpp \
+  DriverOptions.cpp \
+  Job.cpp \
+  Option.cpp \
+  OptTable.cpp \
+  Phases.cpp \
+  Tool.cpp \
+  ToolChain.cpp \
+  ToolChains.cpp \
+  Tools.cpp \
+  Types.cpp \
+  WindowsToolChain.cpp
+
+LOCAL_SRC_FILES := $(clang_driver_SRC_FILES)
+
+LOCAL_MODULE := libclangDriver
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Edit/Android.mk b/lib/Edit/Android.mk
new file mode 100644
index 0000000..3975b86
--- /dev/null
+++ b/lib/Edit/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH:= $(call my-dir)
+
+clang_edit_SRC_FILES := \
+  Commit.cpp \
+  EditedSource.cpp \
+  RewriteObjCFoundationAPI.cpp
+
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  Attrs.inc \
+  AttrList.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  StmtNodes.inc
+
+LOCAL_SRC_FILES := $(clang_edit_SRC_FILES)
+
+LOCAL_MODULE:= libclangEdit
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Frontend/Android.mk b/lib/Frontend/Android.mk
new file mode 100644
index 0000000..63a726f
--- /dev/null
+++ b/lib/Frontend/Android.mk
@@ -0,0 +1,63 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  AttrParsedAttrList.inc \
+  CC1Options.inc \
+  DiagnosticASTKinds.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticDriverKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  DiagnosticLexKinds.inc \
+  DiagnosticSemaKinds.inc \
+  DeclNodes.inc \
+  StmtNodes.inc
+
+clang_frontend_SRC_FILES := \
+  ASTConsumers.cpp \
+  ASTMerge.cpp \
+  ASTUnit.cpp \
+  CacheTokens.cpp \
+  ChainedDiagnosticConsumer.cpp \
+  ChainedIncludesSource.cpp \
+  CompilerInstance.cpp \
+  CompilerInvocation.cpp \
+  CreateInvocationFromCommandLine.cpp \
+  DependencyFile.cpp \
+  DependencyGraph.cpp \
+  DiagnosticRenderer.cpp \
+  FrontendAction.cpp \
+  FrontendActions.cpp \
+  FrontendOptions.cpp \
+  HeaderIncludeGen.cpp \
+  InitHeaderSearch.cpp \
+  InitPreprocessor.cpp \
+  LangStandards.cpp \
+  LayoutOverrideSource.cpp \
+  LogDiagnosticPrinter.cpp \
+  MultiplexConsumer.cpp \
+  PrintPreprocessedOutput.cpp \
+  SerializedDiagnosticPrinter.cpp \
+  TextDiagnostic.cpp \
+  TextDiagnosticBuffer.cpp \
+  TextDiagnosticPrinter.cpp \
+  Warnings.cpp \
+  VerifyDiagnosticConsumer.cpp
+
+LOCAL_SRC_FILES := $(clang_frontend_SRC_FILES)
+
+LOCAL_MODULE:= libclangFrontend
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/FrontendTool/Android.mk b/lib/FrontendTool/Android.mk
new file mode 100644
index 0000000..2496f6b
--- /dev/null
+++ b/lib/FrontendTool/Android.mk
@@ -0,0 +1,24 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_MODULE:= libclangFrontendTool
+
+LOCAL_MODULE_TAGS := optional
+
+TBLGEN_TABLES := \
+  DiagnosticCommonKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  CC1Options.inc
+
+clang_frontend_tool_SRC_FILES := \
+  ExecuteCompilerInvocation.cpp
+
+LOCAL_SRC_FILES := $(clang_frontend_tool_SRC_FILES)
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Headers/Android.mk b/lib/Headers/Android.mk
new file mode 100644
index 0000000..b91abaf
--- /dev/null
+++ b/lib/Headers/Android.mk
@@ -0,0 +1,9 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+$(TARGET_OUT_HEADERS)/clang/arm_neon.h: TBLGEN_LOCAL_MODULE := arm_neon.h
+$(TARGET_OUT_HEADERS)/clang/arm_neon.h: $(CLANG_ROOT_PATH)/include/clang/Basic/arm_neon.td $(CLANG_TBLGEN)
+	$(call transform-host-clang-td-to-out,arm-neon)
+
+$(CLANG): $(TARGET_OUT_HEADERS)/clang/arm_neon.h
diff --git a/lib/Index/Android.mk b/lib/Index/Android.mk
new file mode 100644
index 0000000..a6a9746
--- /dev/null
+++ b/lib/Index/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_MODULE:= libclangIndex
+
+LOCAL_MODULE_TAGS := optional
+
+TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  DiagnosticCommonKinds.inc \
+  DeclNodes.inc \
+  StmtNodes.inc
+
+clang_index_SRC_FILES := \
+  ASTLocation.cpp \
+  Analyzer.cpp \
+  DeclReferenceMap.cpp \
+  Entity.cpp \
+  GlobalCallGraph.cpp \
+  GlobalSelector.cpp \
+  Handlers.cpp \
+  IndexProvider.cpp \
+  Indexer.cpp \
+  Program.cpp \
+  SelectorMap.cpp
+
+LOCAL_SRC_FILES := $(clang_index_SRC_FILES)
+
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Lex/Android.mk b/lib/Lex/Android.mk
new file mode 100644
index 0000000..96909d2
--- /dev/null
+++ b/lib/Lex/Android.mk
@@ -0,0 +1,45 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := \
+  DiagnosticLexKinds.inc \
+  DiagnosticCommonKinds.inc \
+  AttrSpellings.inc
+
+clang_lex_SRC_FILES := \
+  HeaderMap.cpp \
+  HeaderSearch.cpp \
+  Lexer.cpp \
+  LiteralSupport.cpp \
+  MacroArgs.cpp \
+  MacroInfo.cpp \
+  ModuleMap.cpp \
+  PPCaching.cpp \
+  PPCallbacks.cpp \
+  PPDirectives.cpp \
+  PPExpressions.cpp \
+  PPLexerChange.cpp \
+  PPMacroExpansion.cpp \
+  PTHLexer.cpp \
+  Pragma.cpp \
+  PreprocessingRecord.cpp \
+  Preprocessor.cpp \
+  PreprocessorLexer.cpp \
+  ScratchBuffer.cpp \
+  TokenConcatenation.cpp \
+  TokenLexer.cpp
+
+LOCAL_SRC_FILES := $(clang_lex_SRC_FILES)
+
+LOCAL_MODULE:= libclangLex
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Parse/Android.mk b/lib/Parse/Android.mk
new file mode 100644
index 0000000..aac6500
--- /dev/null
+++ b/lib/Parse/Android.mk
@@ -0,0 +1,42 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES :=  \
+	AttrList.inc  \
+	AttrLateParsed.inc  \
+	AttrParsedAttrList.inc  \
+	Attrs.inc  \
+	DeclNodes.inc  \
+	DiagnosticParseKinds.inc  \
+        DiagnosticCommonKinds.inc  \
+	StmtNodes.inc
+
+clang_parse_SRC_FILES :=  \
+	ParseAST.cpp  \
+	ParseCXXInlineMethods.cpp  \
+	ParseDecl.cpp  \
+	ParseDeclCXX.cpp  \
+	ParseExpr.cpp  \
+	ParseExprCXX.cpp  \
+	ParseInit.cpp  \
+	ParseObjc.cpp  \
+	ParsePragma.cpp  \
+	ParseStmt.cpp  \
+	ParseTemplate.cpp  \
+	ParseTentative.cpp  \
+	Parser.cpp
+
+LOCAL_SRC_FILES := $(clang_parse_SRC_FILES)
+
+LOCAL_MODULE:= libclangParse
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Rewrite/Android.mk b/lib/Rewrite/Android.mk
new file mode 100644
index 0000000..5a7eec9
--- /dev/null
+++ b/lib/Rewrite/Android.mk
@@ -0,0 +1,40 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_MODULE:= libclangRewrite
+
+LOCAL_MODULE_TAGS := optional
+
+TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  AttrParsedAttrList.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  DeclNodes.inc \
+  StmtNodes.inc
+
+clang_rewrite_SRC_FILES := \
+  DeltaTree.cpp \
+  FixItRewriter.cpp \
+  FrontendActions.cpp \
+  HTMLPrint.cpp \
+  HTMLRewrite.cpp \
+  RewriteMacros.cpp \
+  RewriteModernObjC.cpp \
+  RewriteObjC.cpp \
+  RewriteRope.cpp \
+  RewriteTest.cpp \
+  Rewriter.cpp \
+  TokenRewriter.cpp
+
+LOCAL_SRC_FILES := $(clang_rewrite_SRC_FILES)
+
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Sema/Android.mk b/lib/Sema/Android.mk
new file mode 100644
index 0000000..4669f86
--- /dev/null
+++ b/lib/Sema/Android.mk
@@ -0,0 +1,73 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES :=    \
+	AttrList.inc	\
+	Attrs.inc	\
+	AttrParsedAttrKinds.inc    \
+	AttrParsedAttrList.inc    \
+	AttrTemplateInstantiate.inc	\
+	DeclNodes.inc	\
+	DiagnosticASTKinds.inc	\
+	DiagnosticSemaKinds.inc	\
+	DiagnosticParseKinds.inc	\
+	DiagnosticCommonKinds.inc	\
+	StmtNodes.inc	\
+	arm_neon.inc
+
+clang_sema_SRC_FILES :=	\
+	AnalysisBasedWarnings.cpp	\
+	AttributeList.cpp	\
+	CodeCompleteConsumer.cpp	\
+	DeclSpec.cpp	\
+	IdentifierResolver.cpp	\
+	DelayedDiagnostic.cpp \
+	JumpDiagnostics.cpp	\
+	Scope.cpp \
+	Sema.cpp	\
+	SemaAccess.cpp	\
+	SemaAttr.cpp	\
+	SemaCXXScopeSpec.cpp	\
+	SemaCast.cpp \
+	SemaChecking.cpp	\
+	SemaCodeComplete.cpp	\
+	SemaConsumer.cpp	\
+	SemaDecl.cpp	\
+	SemaDeclAttr.cpp	\
+	SemaDeclCXX.cpp	\
+	SemaDeclObjC.cpp	\
+	SemaExceptionSpec.cpp	\
+	SemaExpr.cpp	\
+	SemaExprCXX.cpp	\
+	SemaExprMember.cpp \
+	SemaExprObjC.cpp	\
+	SemaFixItUtils.cpp \
+	SemaInit.cpp	\
+	SemaLambda.cpp	\
+	SemaLookup.cpp	\
+	SemaObjCProperty.cpp	\
+	SemaOverload.cpp	\
+	SemaPseudoObject.cpp	\
+	SemaStmt.cpp	\
+	SemaTemplate.cpp	\
+	SemaTemplateDeduction.cpp	\
+	SemaTemplateInstantiate.cpp	\
+	SemaTemplateInstantiateDecl.cpp	\
+	SemaTemplateVariadic.cpp	\
+	SemaType.cpp	\
+	TargetAttributesSema.cpp
+
+LOCAL_SRC_FILES := $(clang_sema_SRC_FILES)
+
+LOCAL_MODULE:= libclangSema
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp
index 6c84caa..9a121c4 100644
--- a/lib/Sema/SemaExprMember.cpp
+++ b/lib/Sema/SemaExprMember.cpp
@@ -256,6 +256,20 @@
   llvm_unreachable("unexpected instance member access kind");
 }
 
+/// Determine whether input char is from rgba component set.
+static bool
+IsRGBA(char c) {
+  switch (c) {
+  case 'r':
+  case 'g':
+  case 'b':
+  case 'a':
+    return true;
+  default:
+    return false;
+  }
+}
+
 /// Check an ext-vector component access expression.
 ///
 /// VK should be set in advance to the value kind of the base
@@ -295,7 +309,12 @@
     HalvingSwizzle = true;
   } else if (!HexSwizzle &&
              (Idx = vecType->getPointAccessorIdx(*compStr)) != -1) {
+    bool HasRGBA = IsRGBA(*compStr);
     do {
+      // If we mix/match rgba with xyzw, break to signal that we encountered
+      // an illegal name.
+      if (HasRGBA != IsRGBA(*compStr))
+        break;
       if (HasIndex[Idx]) HasRepeated = true;
       HasIndex[Idx] = true;
       compStr++;
diff --git a/lib/Serialization/Android.mk b/lib/Serialization/Android.mk
new file mode 100644
index 0000000..1df628c
--- /dev/null
+++ b/lib/Serialization/Android.mk
@@ -0,0 +1,43 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_MODULE:= libclangSerialization
+
+LOCAL_MODULE_TAGS := optional
+
+TBLGEN_TABLES := \
+  AttrList.inc \
+  AttrParsedAttrList.inc \
+  AttrPCHRead.inc \
+  AttrPCHWrite.inc \
+  Attrs.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  DiagnosticSemaKinds.inc \
+  DiagnosticSerializationKinds.inc \
+  StmtNodes.inc
+
+clang_serialization_SRC_FILES :=\
+  GeneratePCH.cpp \
+  ASTCommon.cpp \
+  ASTReader.cpp \
+  ASTReaderDecl.cpp \
+  ASTReaderStmt.cpp \
+  ASTWriter.cpp \
+  ASTWriterDecl.cpp \
+  ASTWriterStmt.cpp \
+  Module.cpp \
+  ModuleManager.cpp
+
+LOCAL_SRC_FILES := $(clang_serialization_SRC_FILES)
+
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/StaticAnalyzer/Checkers/Android.mk b/lib/StaticAnalyzer/Checkers/Android.mk
new file mode 100644
index 0000000..902a44b
--- /dev/null
+++ b/lib/StaticAnalyzer/Checkers/Android.mk
@@ -0,0 +1,92 @@
+LOCAL_PATH:= $(call my-dir)
+
+clang_static_analyzer_checkers_TBLGEN_TABLES := \
+  AttrKinds.inc \
+  AttrList.inc \
+  AttrParsedAttrList.inc \
+  Attrs.inc \
+  Checkers.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  StmtNodes.inc
+
+clang_static_analyzer_checkers_SRC_FILES := \
+  AdjustedReturnValueChecker.cpp \
+  AnalyzerStatsChecker.cpp \
+  ArrayBoundChecker.cpp \
+  ArrayBoundCheckerV2.cpp \
+  AttrNonNullChecker.cpp \
+  BasicObjCFoundationChecks.cpp \
+  BoolAssignmentChecker.cpp \
+  BuiltinFunctionChecker.cpp \
+  CStringChecker.cpp \
+  CStringSyntaxChecker.cpp \
+  CallAndMessageChecker.cpp \
+  CastSizeChecker.cpp \
+  CastToStructChecker.cpp \
+  CheckObjCDealloc.cpp \
+  CheckObjCInstMethSignature.cpp \
+  CheckSecuritySyntaxOnly.cpp \
+  CheckSizeofPointer.cpp \
+  CheckerDocumentation.cpp \
+  ChrootChecker.cpp \
+  ClangCheckers.cpp \
+  DeadStoresChecker.cpp \
+  DebugCheckers.cpp \
+  DereferenceChecker.cpp \
+  DivZeroChecker.cpp \
+  FixedAddressChecker.cpp \
+  GenericTaintChecker.cpp \
+  IdempotentOperationChecker.cpp \
+  IteratorsChecker.cpp \
+  LLVMConventionsChecker.cpp \
+  MacOSKeychainAPIChecker.cpp \
+  MacOSXAPIChecker.cpp \
+  MallocChecker.cpp \
+  MallocOverflowSecurityChecker.cpp \
+  MallocSizeofChecker.cpp \
+  NSAutoreleasePoolChecker.cpp \
+  NSErrorChecker.cpp \
+  NoReturnFunctionChecker.cpp \
+  OSAtomicChecker.cpp \
+  ObjCAtSyncChecker.cpp \
+  ObjCContainersASTChecker.cpp \
+  ObjCContainersChecker.cpp \
+  ObjCSelfInitChecker.cpp \
+  ObjCUnusedIVarsChecker.cpp \
+  PointerArithChecker.cpp \
+  PointerSubChecker.cpp \
+  PthreadLockChecker.cpp \
+  RetainCountChecker.cpp \
+  ReturnPointerRangeChecker.cpp \
+  ReturnUndefChecker.cpp \
+  StackAddrEscapeChecker.cpp \
+  StreamChecker.cpp \
+  TaintTesterChecker.cpp \
+  UndefBranchChecker.cpp \
+  UndefCapturedBlockVarChecker.cpp \
+  UndefResultChecker.cpp \
+  UndefinedArraySubscriptChecker.cpp \
+  UndefinedAssignmentChecker.cpp \
+  UnixAPIChecker.cpp \
+  UnreachableCodeChecker.cpp \
+  VirtualCallChecker.cpp \
+  VLASizeChecker.cpp
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := $(clang_static_analyzer_checkers_TBLGEN_TABLES)
+
+LOCAL_SRC_FILES := $(clang_static_analyzer_checkers_SRC_FILES)
+
+LOCAL_MODULE:= libclangStaticAnalyzerCheckers
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/StaticAnalyzer/Core/Android.mk b/lib/StaticAnalyzer/Core/Android.mk
new file mode 100644
index 0000000..9437340
--- /dev/null
+++ b/lib/StaticAnalyzer/Core/Android.mk
@@ -0,0 +1,63 @@
+LOCAL_PATH:= $(call my-dir)
+
+clang_static_analyzer_core_TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  StmtNodes.inc
+
+clang_static_analyzer_core_SRC_FILES := \
+  AnalysisManager.cpp \
+  BasicConstraintManager.cpp \
+  BasicValueFactory.cpp \
+  BlockCounter.cpp \
+  BugReporter.cpp \
+  BugReporterVisitors.cpp \
+  Checker.cpp \
+  CheckerContext.cpp \
+  CheckerHelpers.cpp \
+  CheckerManager.cpp \
+  CheckerRegistry.cpp \
+  CoreEngine.cpp \
+  Environment.cpp \
+  ExplodedGraph.cpp \
+  ExprEngine.cpp \
+  ExprEngineC.cpp \
+  ExprEngineCXX.cpp \
+  ExprEngineCallAndReturn.cpp \
+  ExprEngineObjC.cpp \
+  HTMLDiagnostics.cpp \
+  MemRegion.cpp \
+  ObjCMessage.cpp \
+  PathDiagnostic.cpp \
+  PlistDiagnostics.cpp \
+  ProgramState.cpp \
+  RangeConstraintManager.cpp \
+  RegionStore.cpp \
+  SValBuilder.cpp \
+  SVals.cpp \
+  SimpleConstraintManager.cpp \
+  SimpleSValBuilder.cpp \
+  Store.cpp \
+  SubEngine.cpp \
+  SymbolManager.cpp \
+  TextPathDiagnostics.cpp
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := $(clang_static_analyzer_core_TBLGEN_TABLES)
+
+LOCAL_SRC_FILES := $(clang_static_analyzer_core_SRC_FILES)
+
+LOCAL_MODULE:= libclangStaticAnalyzerCore
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/StaticAnalyzer/Frontend/Android.mk b/lib/StaticAnalyzer/Frontend/Android.mk
new file mode 100644
index 0000000..89f010f
--- /dev/null
+++ b/lib/StaticAnalyzer/Frontend/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH:= $(call my-dir)
+
+clang_static_analyzer_frontend_C_INCLUDES := \
+  $(CLANG_ROOT_PATH)/lib/StaticAnalyzer/Checkers
+
+clang_static_analyzer_frontend_TBLGEN_TABLES := \
+  AttrList.inc \
+  Attrs.inc \
+  DeclNodes.inc \
+  DiagnosticCommonKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  StmtNodes.inc
+
+clang_static_analyzer_frontend_SRC_FILES := \
+  AnalysisConsumer.cpp \
+  CheckerRegistration.cpp \
+  FrontendActions.cpp
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+TBLGEN_TABLES := $(clang_static_analyzer_frontend_TBLGEN_TABLES)
+
+LOCAL_SRC_FILES := $(clang_static_analyzer_frontend_SRC_FILES)
+
+LOCAL_C_INCLUDES := $(clang_static_analyzer_frontend_C_INCLUDES)
+
+LOCAL_MODULE:= libclangStaticAnalyzerFrontend
+
+LOCAL_MODULE_TAGS := optional
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(CLANG_VERSION_INC_MK)
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/lib/include b/lib/include
new file mode 120000
index 0000000..74ea861
--- /dev/null
+++ b/lib/include
@@ -0,0 +1 @@
+Headers/
\ No newline at end of file
diff --git a/tools/driver/Android.mk b/tools/driver/Android.mk
new file mode 100644
index 0000000..05bc0e0
--- /dev/null
+++ b/tools/driver/Android.mk
@@ -0,0 +1,100 @@
+LOCAL_PATH:= $(call my-dir)
+
+# For the host only
+# =====================================================
+include $(CLEAR_VARS)
+include $(CLEAR_TBLGEN_VARS)
+
+LOCAL_MODULE := clang
+
+LOCAL_MODULE_TAGS := optional tests
+
+LOCAL_MODULE_CLASS := EXECUTABLES
+
+TBLGEN_TABLES := \
+  DiagnosticCommonKinds.inc \
+  DiagnosticDriverKinds.inc \
+  DiagnosticFrontendKinds.inc \
+  CC1Options.inc \
+  CC1AsOptions.inc
+
+clang_SRC_FILES := \
+  cc1_main.cpp \
+  cc1as_main.cpp \
+  driver.cpp
+
+LOCAL_SRC_FILES := $(clang_SRC_FILES)
+
+LOCAL_STATIC_LIBRARIES := \
+  libclangFrontendTool \
+  libclangFrontend \
+  libclangARCMigrate \
+  libclangDriver \
+  libclangSerialization \
+  libclangCodeGen \
+  libclangParse \
+  libclangSema \
+  libclangStaticAnalyzerFrontend \
+  libclangStaticAnalyzerCheckers \
+  libclangStaticAnalyzerCore \
+  libclangAnalysis \
+  libclangIndex \
+  libclangRewrite \
+  libclangEdit \
+  libclangAST \
+  libclangLex \
+  libclangBasic \
+  libLLVMARMAsmParser \
+  libLLVMARMCodeGen \
+  libLLVMARMDisassembler \
+  libLLVMARMDesc \
+  libLLVMARMInfo \
+  libLLVMMipsCodeGen \
+  libLLVMMipsAsmPrinter \
+  libLLVMMipsDesc \
+  libLLVMMipsInfo \
+  libLLVMX86Info \
+  libLLVMX86AsmParser \
+  libLLVMX86CodeGen \
+  libLLVMX86Disassembler \
+  libLLVMX86Desc \
+  libLLVMX86AsmPrinter \
+  libLLVMX86Utils \
+  libLLVMAsmParser \
+  libLLVMAsmPrinter \
+  libLLVMBitReader \
+  libLLVMBitWriter \
+  libLLVMSelectionDAG \
+  libLLVMipo \
+  libLLVMipa \
+  libLLVMInstCombine \
+  libLLVMInstrumentation \
+  libLLVMCodeGen \
+  libLLVMLinker \
+  libLLVMMC \
+  libLLVMMCParser \
+  libLLVMScalarOpts \
+  libLLVMTransformUtils \
+  libLLVMVectorize \
+  libLLVMAnalysis \
+  libLLVMCore \
+  libLLVMSupport \
+  libLLVMTarget
+
+LOCAL_LDLIBS += -lpthread -lm -ldl
+
+include $(CLANG_HOST_BUILD_MK)
+include $(CLANG_TBLGEN_RULES_MK)
+include $(BUILD_HOST_EXECUTABLE)
+
+# Make sure if clang (i.e. $(LOCAL_MODULE)) get installed,
+# clang++ will get installed as well.
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
+    $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(CLANG_CXX)
+# the additional dependency is needed when you run mm/mmm.
+$(LOCAL_MODULE) : $(CLANG_CXX)
+
+# Symlink for clang++
+$(CLANG_CXX) : $(LOCAL_INSTALLED_MODULE)
+	@echo "Symlink $@ -> $<"
+	$(hide) ln -sf $(notdir $<) $@
diff --git a/utils/TableGen/Android.mk b/utils/TableGen/Android.mk
new file mode 100644
index 0000000..de873e9
--- /dev/null
+++ b/utils/TableGen/Android.mk
@@ -0,0 +1,33 @@
+LOCAL_PATH:= $(call my-dir)
+
+clang_tablegen_SRC_FILES := \
+  ClangASTNodesEmitter.cpp \
+  ClangAttrEmitter.cpp \
+  ClangDiagnosticsEmitter.cpp \
+  ClangSACheckersEmitter.cpp \
+  NeonEmitter.cpp \
+  OptParserEmitter.cpp \
+  TableGen.cpp
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := clang-tblgen
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(clang_tablegen_SRC_FILES)
+
+REQUIRES_EH := 1
+REQUIRES_RTTI := 1
+
+LOCAL_STATIC_LIBRARIES := \
+  libLLVMTableGen \
+  libLLVMSupport
+
+LOCAL_LDLIBS += -lm
+ifeq ($(HOST_OS),windows)
+  LOCAL_LDLIBS += -limagehlp -lpsapi
+else
+  LOCAL_LDLIBS += -lpthread -ldl
+endif
+
+include $(LLVM_HOST_BUILD_MK)
+include $(BUILD_HOST_EXECUTABLE)