[cfe-commits] r88981 - in /cfe/trunk: include/clang/Frontend/HeaderSearchOptions.h lib/Frontend/InitHeaderSearch.cpp tools/clang-cc/Options.cpp tools/clang-cc/Options.h tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 16 14:38:40 PST 2009
Author: ddunbar
Date: Mon Nov 16 16:38:40 2009
New Revision: 88981
URL: http://llvm.org/viewvc/llvm-project?rev=88981&view=rev
Log:
Store more information in HeaderSearchOptions so that its initialization is not
language dependent.
Modified:
cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
cfe/trunk/tools/clang-cc/Options.cpp
cfe/trunk/tools/clang-cc/Options.h
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h?rev=88981&r1=88980&r2=88981&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h Mon Nov 16 16:38:40 2009
@@ -59,11 +59,11 @@
/// environment variable for gcc.
std::string EnvIncPath;
- /// A (system-path) delimited list of include paths to be added from the
- /// environment following the user specified includes and the \see EnvIncPath
- /// includes (but prior to builtin and standard includes). This is parsed in
- /// the same manner as the CPATH environment variable for gcc.
- std::string LangEnvIncPath;
+ /// Per-language environmental include paths, see \see EnvIncPath.
+ std::string CEnvIncPath;
+ std::string ObjCEnvIncPath;
+ std::string CXXEnvIncPath;
+ std::string ObjCXXEnvIncPath;
/// If non-empty, the path to the compiler builtin include directory, which
/// will be searched following the user and environment includes.
Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=88981&r1=88980&r2=88981&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Mon Nov 16 16:38:40 2009
@@ -636,7 +636,14 @@
// Add entries from CPATH and friends.
Init.AddDelimitedPaths(HSOpts.EnvIncPath.c_str());
- Init.AddDelimitedPaths(HSOpts.LangEnvIncPath.c_str());
+ if (Lang.CPlusPlus && Lang.ObjC1)
+ Init.AddDelimitedPaths(HSOpts.ObjCXXEnvIncPath.c_str());
+ else if (Lang.CPlusPlus)
+ Init.AddDelimitedPaths(HSOpts.CXXEnvIncPath.c_str());
+ else if (Lang.ObjC1)
+ Init.AddDelimitedPaths(HSOpts.ObjCEnvIncPath.c_str());
+ else
+ Init.AddDelimitedPaths(HSOpts.CEnvIncPath.c_str());
if (!HSOpts.BuiltinIncludePath.empty()) {
// Ignore the sys root, we *always* look for clang headers relative to
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=88981&r1=88980&r2=88981&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Mon Nov 16 16:38:40 2009
@@ -910,8 +910,7 @@
}
void clang::InitializeHeaderSearchOptions(HeaderSearchOptions &Opts,
- llvm::StringRef BuiltinIncludePath,
- const LangOptions &Lang) {
+ llvm::StringRef BuiltinIncludePath) {
using namespace headersearchoptions;
Opts.Sysroot = isysroot;
@@ -993,19 +992,14 @@
Opts.EnvIncPath = Env;
// Add language specific environment paths.
- if (Lang.CPlusPlus && Lang.ObjC1) {
- if (const char *Env = getenv("OBJCPLUS_INCLUDE_PATH"))
- Opts.LangEnvIncPath = Env;
- } else if (Lang.CPlusPlus) {
- if (const char *Env = getenv("CPLUS_INCLUDE_PATH"))
- Opts.LangEnvIncPath = Env;
- } else if (Lang.ObjC1) {
- if (const char *Env = getenv("OBJC_INCLUDE_PATH"))
- Opts.LangEnvIncPath = Env;
- } else {
- if (const char *Env = getenv("C_INCLUDE_PATH"))
- Opts.LangEnvIncPath = Env;
- }
+ if (const char *Env = getenv("OBJCPLUS_INCLUDE_PATH"))
+ Opts.ObjCXXEnvIncPath = Env;
+ if (const char *Env = getenv("CPLUS_INCLUDE_PATH"))
+ Opts.CXXEnvIncPath = Env;
+ if (const char *Env = getenv("OBJC_INCLUDE_PATH"))
+ Opts.CEnvIncPath = Env;
+ if (const char *Env = getenv("C_INCLUDE_PATH"))
+ Opts.CEnvIncPath = Env;
if (!nobuiltininc)
Opts.BuiltinIncludePath = BuiltinIncludePath;
Modified: cfe/trunk/tools/clang-cc/Options.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.h?rev=88981&r1=88980&r2=88981&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.h (original)
+++ cfe/trunk/tools/clang-cc/Options.h Mon Nov 16 16:38:40 2009
@@ -40,8 +40,7 @@
void InitializeFrontendOptions(FrontendOptions &Opts);
void InitializeHeaderSearchOptions(HeaderSearchOptions &Opts,
- llvm::StringRef BuiltinIncludePath,
- const LangOptions &Lang);
+ llvm::StringRef BuiltinIncludePath);
void InitializeLangOptions(LangOptions &Options,
FrontendOptions::InputKind LK,
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=88981&r1=88980&r2=88981&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon Nov 16 16:38:40 2009
@@ -52,7 +52,7 @@
using namespace clang;
//===----------------------------------------------------------------------===//
-// Utility Methods
+// Main driver
//===----------------------------------------------------------------------===//
std::string GetBuiltinIncludePath(const char *Argv0) {
@@ -74,9 +74,14 @@
return P.str();
}
-//===----------------------------------------------------------------------===//
-// Main driver
-//===----------------------------------------------------------------------===//
+static void LLVMErrorHandler(void *UserData, const std::string &Message) {
+ Diagnostic &Diags = *static_cast<Diagnostic*>(UserData);
+
+ Diags.Report(diag::err_fe_error_backend) << Message;
+
+ // We cannot recover from llvm errors.
+ exit(1);
+}
/// ClangFrontendTimer - The front-end activities should charge time to it with
/// TimeRegion. The -ftime-report option controls whether this will do
@@ -144,15 +149,6 @@
}
}
-static void LLVMErrorHandler(void *UserData, const std::string &Message) {
- Diagnostic &Diags = *static_cast<Diagnostic*>(UserData);
-
- Diags.Report(diag::err_fe_error_backend) << Message;
-
- // We cannot recover from llvm errors.
- exit(1);
-}
-
static TargetInfo *
ConstructCompilerInvocation(CompilerInvocation &Opts, Diagnostic &Diags,
const char *Argv0, bool &IsAST) {
@@ -194,8 +190,7 @@
// Initialize the header search options.
InitializeHeaderSearchOptions(Opts.getHeaderSearchOpts(),
- GetBuiltinIncludePath(Argv0),
- Opts.getLangOpts());
+ GetBuiltinIncludePath(Argv0));
// Initialize the other preprocessor options.
InitializePreprocessorOptions(Opts.getPreprocessorOpts());
More information about the cfe-commits
mailing list