Index: tools/clang/lib/Tooling/CustomToolInit.h
===================================================================
--- tools/clang/lib/Tooling/CustomToolInit.h	(revision 0)
+++ tools/clang/lib/Tooling/CustomToolInit.h	(revision 0)
@@ -0,0 +1,32 @@
+//===--- CustomToolInit.h -------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file contains a hook to supply a custom tool initialization routine.
+//
+//  The mechanism can be used by IDEs or non-public code bases to integrate with
+//  their build system. Currently we support statically linking in an
+//  implementation of \c customToolInit and enabling it with
+//  -DUSE_CUSTOM_TOOL_INIT when compiling the Tooling library.
+//
+//  FIXME: The strategy forward is to provide a plugin system that can load
+//  custom compilation databases and make enabling that a build option.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_CLANG_LIB_TOOLING_CUSTOMTOOLINIT_H_
+#define LLVM_TOOLS_CLANG_LIB_TOOLING_CUSTOMTOOLINIT_H_
+
+/// \brief Performs a custom initialization of a tool.
+///
+/// This function provides a hook for custom initialization of a clang tool. It
+/// receives command-line arguments and can change them if needed.
+/// If the initialization fails (say, custom command-line arguments are invalid)
+/// this function should terminate the process.
+void customToolInit(int argc, const char **argv);
+
+#endif  // LLVM_TOOLS_CLANG_LIB_TOOLING_CUSTOMTOOLINIT_H_
Index: tools/clang/lib/Tooling/CustomCompilationDatabase.h
===================================================================
--- tools/clang/lib/Tooling/CustomCompilationDatabase.h	(revision 160362)
+++ tools/clang/lib/Tooling/CustomCompilationDatabase.h	(working copy)
@@ -19,6 +19,8 @@
 //  custom compilation databases and make enabling that a build option.
 //
 //===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_CLANG_LIB_TOOLING_CUSTOMCOMPILATIONDATABASE_H_
+#define LLVM_TOOLS_CLANG_LIB_TOOLING_CUSTOMCOMPILATIONDATABASE_H_
 
 #include "llvm/ADT/StringRef.h"
 
@@ -35,3 +37,5 @@
 /// parents. If a compilation database cannot be found or loaded, returns NULL.
 clang::tooling::CompilationDatabase *findCompilationDatabaseForDirectory(
   llvm::StringRef Directory);
+
+#endif // LLVM_TOOLS_CLANG_LIB_TOOLING_CUSTOMCOMPILATIONDATABASE_H_
Index: tools/clang/lib/Tooling/CommandLineClangTool.cpp
===================================================================
--- tools/clang/lib/Tooling/CommandLineClangTool.cpp	(revision 160362)
+++ tools/clang/lib/Tooling/CommandLineClangTool.cpp	(working copy)
@@ -25,6 +25,10 @@
 #include "clang/Tooling/CommandLineClangTool.h"
 #include "clang/Tooling/Tooling.h"
 
+#ifdef USE_CUSTOM_TOOL_INIT
+#include "clang/Tooling/CustomToolInit.h"
+#endif
+
 using namespace clang::tooling;
 using namespace llvm;
 
@@ -58,6 +62,9 @@
 }
 
 void CommandLineClangTool::initialize(int argc, const char **argv) {
+#ifdef USE_CUSTOM_TOOL_INIT
+  customToolInit(argc, argv);
+#endif
   Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, argv));
   cl::ParseCommandLineOptions(argc, argv);
   if (!Compilations) {
