aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-03 03:16:03 +0000
committerChris Lattner <sabre@nondot.org>2008-03-03 03:16:03 +0000
commitdcaa0962401a59c5888a12f6e00e27f5e1d29c5b (patch)
tree3a23de5ed6842a7c5313bb6c21e7afcda461dc50
parent4a308e01b47c605315ad6a3053f904eac401e2f1 (diff)
Find clang headers in the clang headers dir, search it before
the system headers dir. This produces an annoying warning: clang.cpp:883: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object I'm not sure how to remove it. :( git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47836 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/clang.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 36a7f16d7c..0f6e7fad57 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -43,6 +43,7 @@
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/System/Path.h"
#include <memory>
#include <fstream>
using namespace clang;
@@ -805,8 +806,8 @@ static void AddEnvVarPaths(const char *Name, HeaderSearch &Headers) {
/// InitializeIncludePaths - Process the -I options and set them in the
/// HeaderSearch object.
-static void InitializeIncludePaths(HeaderSearch &Headers, FileManager &FM,
- const LangOptions &Lang) {
+static void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers,
+ FileManager &FM, const LangOptions &Lang) {
// Handle -F... options.
for (unsigned i = 0, e = F_dirs.size(); i != e; ++i)
AddPath(F_dirs[i], Angled, false, true, true, Headers);
@@ -877,6 +878,16 @@ static void InitializeIncludePaths(HeaderSearch &Headers, FileManager &FM,
else
AddEnvVarPaths("C_INCLUDE_PATH", Headers);
+ // Add the clang headers, which are relative to the clang driver.
+ llvm::sys::Path MainExecutablePath =
+ llvm::sys::Path::GetMainExecutable(Argv0, (void*)InitializeIncludePaths);
+ if (!MainExecutablePath.isEmpty()) {
+ MainExecutablePath.eraseComponent(); // Remove /clang from foo/bin/clang
+ MainExecutablePath.eraseComponent(); // Remove /bin from foo/bin
+ MainExecutablePath.appendComponent("Headers"); // Get foo/Headers
+ AddPath(MainExecutablePath.c_str(), System, false, false, false, Headers);
+ }
+
// FIXME: temporary hack: hard-coded paths.
// FIXME: get these from the target?
if (!nostdinc) {
@@ -1230,7 +1241,7 @@ static bool isSerializedFile(const std::string& InFile) {
int main(int argc, char **argv) {
- llvm::cl::ParseCommandLineOptions(argc, argv, " llvm cfe\n");
+ llvm::cl::ParseCommandLineOptions(argc, argv, " llvm clang cfe\n");
llvm::sys::PrintStackTraceOnErrorSignal();
// If no input was specified, read from stdin.
@@ -1290,7 +1301,7 @@ int main(int argc, char **argv) {
// Process the -I options and set them in the HeaderInfo.
HeaderSearch HeaderInfo(FileMgr);
DiagClient->setHeaderSearch(HeaderInfo);
- InitializeIncludePaths(HeaderInfo, FileMgr, LangInfo);
+ InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo);
// Get information about the targets being compiled for. Note that this
// pointer and the TargetInfoImpl objects are never deleted by this toy