Lift builtin-include-path logic out of ASTUnit::LoadFromCommandLine and fix CIndex to pass in the right directory (previously it was using the path to the main executable, which generally is wrong).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91238 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp
index 0b1971f..8b12c0b 100644
--- a/tools/index-test/index-test.cpp
+++ b/tools/index-test/index-test.cpp
@@ -223,9 +223,12 @@
   for (unsigned i = 0, e = CompilerArgs.size(); i != e; ++i)
     Args.push_back(CompilerArgs[i].c_str());
 
+  void *MainAddr = (void*) (intptr_t) CreateFromSource;
+  llvm::sys::Path ResourcesPath(
+    CompilerInvocation::GetBuiltinIncludePath(Argv0, MainAddr));
+  ResourcesPath.eraseComponent();
   return ASTUnit::LoadFromCommandLine(Args.data(), Args.data() + Args.size(),
-                                      Diags, Argv0,
-                                      (void*) (intptr_t) CreateFromSource);
+                                      Diags, ResourcesPath.str());
 }
 
 int main(int argc, char **argv) {