Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp	(revision 79237)
+++ lib/Frontend/InitHeaderSearch.cpp	(working copy)
@@ -15,6 +15,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/System/Path.h"
@@ -101,26 +102,67 @@
     AddPath(at, Angled, false, true, false);
 }
 
+#if defined(_MSC_VER)
+const char* getVSCommonToolsDir() {
+  const char* vs90comntools = getenv("VS90COMNTOOLS");
+  const char* vs80comntools = getenv("VS80COMNTOOLS");
+  const char* vscomntools = NULL;
+    // If we have both vc80 and vc90, pick version we were compiled with. 
+  if (vs90comntools && vs80comntools) {
+    #if (_MSC_VER >= 1500)  // VC90
+        vscomntools = vs90comntools;
+    #elif (_MSC_VER == 1400) // VC80
+        vscomntools = vs80comntools;
+    #else
+        vscomntools = vs90comntools;
+    #endif
+  }
+  else if (vs90comntools)
+    vscomntools = vs90comntools;
+  else if (vs80comntools)
+    vscomntools = vs80comntools;
+  return(vscomntools);
+}
+#endif
 
 void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang) {
   // FIXME: temporary hack: hard-coded paths.
   // FIXME: get these from the target?
 
 #ifdef LLVM_ON_WIN32
-  if (Lang.CPlusPlus) {
-    // Mingw32 GCC version 4
-    AddPath("c:/mingw/lib/gcc/mingw32/4.3.0/include/c++",
-            System, true, false, false);
-    AddPath("c:/mingw/lib/gcc/mingw32/4.3.0/include/c++/mingw32",
-            System, true, false, false);
-    AddPath("c:/mingw/lib/gcc/mingw32/4.3.0/include/c++/backward",
-            System, true, false, false);
-  }
 
-  // Mingw32 GCC version 4
-  AddPath("C:/mingw/include", System, false, false, false);
+#if defined(_MSC_VER)
+  if (const char *VSToolsDirPtr = getVSCommonToolsDir()) {
+    llvm::StringRef VSToolsDir(VSToolsDirPtr);
+    if (VSToolsDir.endswith("Common7\\Tools\\"))
+      VSToolsDir = VSToolsDir.slice(0, VSToolsDir.size() -
+        strlen("Common7\\Tools\\"));
+    std::string VSDir = VSToolsDir;
+    if (VSToolsDir.back() != '\\' && VSToolsDir.back() != '/')
+      VSDir += '\\';
+    VSDir += "VC\\include";
+    AddPath(VSDir, System, false, false, false);
+  }
+  else {
+      // Default install paths.
+    AddPath("C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include",
+      System, false, false, false);
+    AddPath("C:\\Program Files\\Microsoft Visual Studio 8\\VC\\include",
+      System, false, false, false);
+      // For some clang developers.
+    AddPath("G:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include",
+      System, false, false, false);
+  }
+#elif defined(__CYGWIN__)
+    AddPath("/usr/include", System, false, false, false);
+    AddPath("C:\\cygwin\\usr\\include", System, false, false, false);
 #else
+    AddPath("/usr/include", System, false, false, false);
+    AddPath("C:\\MinGW\\include", System, false, false, false);
+#endif
 
+#else
+
   if (Lang.CPlusPlus) {
     AddPath("/usr/include/c++/4.2.1", System, true, false, false);
     AddPath("/usr/include/c++/4.2.1/i686-apple-darwin10", System, true, false,
