Add clang -cc1 parsing for header search options.

llvm-svn: 89916
This commit is contained in:
Daniel Dunbar 2009-11-26 02:13:54 +00:00
parent 8928899413
commit cbc693579c
2 changed files with 42 additions and 2 deletions

View File

@ -355,6 +355,46 @@ static void ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args) {
}
static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
using namespace cc1options;
Opts.Sysroot = getLastArgValue(Args, OPT_isysroot);
Opts.Verbose = Args.hasArg(OPT_v);
Opts.UseStandardIncludes = !Args.hasArg(OPT_nostdinc);
Opts.BuiltinIncludePath = "";
if (!Args.hasArg(OPT_fno_builtin))
Opts.BuiltinIncludePath = "FIXME"; // FIXME: Get builtin include path!
// Add -I... and -F... options in order.
for (arg_iterator it = Args.filtered_begin(OPT_I, OPT_F),
ie = Args.filtered_end(); it != ie; ++it)
Opts.AddPath(it->getValue(Args), frontend::Angled, true,
/*IsFramework=*/ it->getOption().matches(OPT_F));
// Add -iprefix/-iwith-prefix/-iwithprefixbefore options.
llvm::StringRef Prefix = ""; // FIXME: This isn't the correct default prefix.
for (arg_iterator it = Args.filtered_begin(OPT_iprefix, OPT_iwithprefix,
OPT_iwithprefixbefore),
ie = Args.filtered_end(); it != ie; ++it) {
if (it->getOption().matches(OPT_iprefix))
Prefix = it->getValue(Args);
else if (it->getOption().matches(OPT_iwithprefix))
Opts.AddPath(Prefix.str() + it->getValue(Args),
frontend::System, false, false);
else
Opts.AddPath(Prefix.str() + it->getValue(Args),
frontend::Angled, false, false);
}
for (arg_iterator it = Args.filtered_begin(OPT_idirafter),
ie = Args.filtered_end(); it != ie; ++it)
Opts.AddPath(it->getValue(Args), frontend::After, true, false);
for (arg_iterator it = Args.filtered_begin(OPT_iquote),
ie = Args.filtered_end(); it != ie; ++it)
Opts.AddPath(it->getValue(Args), frontend::Quoted, true, false);
for (arg_iterator it = Args.filtered_begin(OPT_isystem),
ie = Args.filtered_end(); it != ie; ++it)
Opts.AddPath(it->getValue(Args), frontend::System, true, false);
// FIXME: Need options for the various environment variables!
}
static void ParseLangArgs(LangOptions &Opts, ArgList &Args) {

View File

@ -302,13 +302,13 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
/// User specified include entries.
for (unsigned i = 0, e = Opts.UserEntries.size(); i != e; ++i) {
const HeaderSearchOptions::Entry &E = Opts.UserEntries[i];
if (E.IsFramework && (E.Group != frontend::Angled || E.IsUserSupplied))
if (E.IsFramework && (E.Group != frontend::Angled || !E.IsUserSupplied))
llvm::llvm_report_error("Invalid option set!");
if (E.IsUserSupplied) {
if (E.Group == frontend::After) {
Res.push_back("-idirafter");
} else if (E.Group == frontend::Quoted) {
Res.push_back("-iquoted");
Res.push_back("-iquote");
} else if (E.Group == frontend::System) {
Res.push_back("-isystem");
} else {