[cfe-commits] r67181 - in /cfe/trunk: include/clang/Driver/Option.h include/clang/Driver/Options.def lib/Driver/OptTable.cpp lib/Driver/Option.cpp
Daniel Dunbar
daniel at zuster.org
Wed Mar 18 01:01:15 PDT 2009
Author: ddunbar
Date: Wed Mar 18 03:01:15 2009
New Revision: 67181
URL: http://llvm.org/viewvc/llvm-project?rev=67181&view=rev
Log:
Driver: Add "d" flag to Options.def for options which are completely
handled by driver.
- This is not very precise, we use it to drive the "forward-to-gcc"
predicate, when trying to talk to a generic gcc tool.
- Slightly better than what ccc was doing, and should be good
enough. Platforms which want a robust driver should implement a
proper tool chain.
Modified:
cfe/trunk/include/clang/Driver/Option.h
cfe/trunk/include/clang/Driver/Options.def
cfe/trunk/lib/Driver/OptTable.cpp
cfe/trunk/lib/Driver/Option.cpp
Modified: cfe/trunk/include/clang/Driver/Option.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=67181&r1=67180&r2=67181&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Wed Mar 18 03:01:15 2009
@@ -82,6 +82,9 @@
/// Always render this option joined with its value.
bool ForceJoinedRender : 1;
+ /// Forward to generic GCC tools.
+ bool ForwardToGCC : 1;
+
protected:
Option(OptionClass Kind, options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
@@ -100,14 +103,17 @@
bool isLinkerInput() const { return LinkerInput; }
void setLinkerInput(bool Value) { LinkerInput = Value; }
- bool isNoOptAsInput() const { return NoOptAsInput; }
+ bool hasNoOptAsInput() const { return NoOptAsInput; }
void setNoOptAsInput(bool Value) { NoOptAsInput = Value; }
-
- bool isForceSeparateRender() const { return ForceSeparateRender; }
+
+ bool hasForceSeparateRender() const { return ForceSeparateRender; }
void setForceSeparateRender(bool Value) { ForceSeparateRender = Value; }
-
- bool isForceJoinedRender() const { return ForceJoinedRender; }
+
+ bool hasForceJoinedRender() const { return ForceJoinedRender; }
void setForceJoinedRender(bool Value) { ForceJoinedRender = Value; }
+
+ bool hasForwardToGCC() const { return ForwardToGCC; }
+ void setForwardToGCC(bool Value) { ForwardToGCC = Value; }
/// getUnaliasedOption - Return the final option this option
/// aliases (itself, if the option has no alias).
Modified: cfe/trunk/include/clang/Driver/Options.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.def?rev=67181&r1=67180&r2=67181&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.def (original)
+++ cfe/trunk/include/clang/Driver/Options.def Wed Mar 18 03:01:15 2009
@@ -48,11 +48,14 @@
// INVALID if the option is not an alias.
// The sixth value is a string containing option flags. Valid values:
-// l: The option is a linker input.
+// d: The option is a "driver" option, and should not be forwarded to
+// gcc.
//
// i: The option should not render the name when rendered as an
// input.
//
+// l: The option is a linker input.
+//
// u: The option is unsupported, and the driver will reject command
// lines that use it.
//
@@ -175,7 +178,7 @@
OPTION("--pass-exit-codes", _pass_exit_codes, Flag, INVALID, pass_exit_codes, "", 0)
OPTION("--pedantic-errors", _pedantic_errors, Flag, INVALID, pedantic_errors, "", 0)
OPTION("--pedantic", _pedantic, Flag, INVALID, pedantic, "", 0)
-OPTION("--pipe", _pipe, Flag, INVALID, pipe, "", 0)
+OPTION("--pipe", _pipe, Flag, INVALID, pipe, "d", 0)
OPTION("--prefix=", _prefix_EQ, Joined, INVALID, B, "S", 0)
OPTION("--prefix", _prefix, Separate, INVALID, B, "", 0)
OPTION("--preprocess", _preprocess, Flag, INVALID, E, "", 0)
@@ -221,7 +224,7 @@
OPTION("-CC", CC, Flag, INVALID, INVALID, "", 0)
OPTION("-C", C, Flag, INVALID, INVALID, "", 0)
OPTION("-D", D, JoinedOrSeparate, INVALID, INVALID, "", 0)
-OPTION("-E", E, Flag, INVALID, INVALID, "", 0)
+OPTION("-E", E, Flag, INVALID, INVALID, "d", 0)
OPTION("-F", F, JoinedOrSeparate, INVALID, INVALID, "", 0)
OPTION("-H", H, Flag, INVALID, INVALID, "", 0)
OPTION("-I-", I_, Flag, I_Group, INVALID, "", 0)
@@ -237,14 +240,14 @@
OPTION("-MT", MT, JoinedOrSeparate, M_Group, INVALID, "", 0)
OPTION("-Mach", Mach, Flag, INVALID, INVALID, "", 0)
OPTION("-M", M, Flag, M_Group, INVALID, "", 0)
-OPTION("-ObjC++", ObjCXX, Flag, INVALID, INVALID, "", 0)
-OPTION("-ObjC", ObjC, Flag, INVALID, INVALID, "", 0)
+OPTION("-ObjC++", ObjCXX, Flag, INVALID, INVALID, "d", 0)
+OPTION("-ObjC", ObjC, Flag, INVALID, INVALID, "d", 0)
OPTION("-O", O, Joined, INVALID, INVALID, "", 0)
OPTION("-P", P, Flag, INVALID, INVALID, "", 0)
OPTION("-Qn", Qn, Flag, INVALID, INVALID, "", 0)
OPTION("-Q", Q, Flag, INVALID, INVALID, "", 0)
OPTION("-R", R, Flag, INVALID, INVALID, "", 0)
-OPTION("-S", S, Flag, INVALID, INVALID, "", 0)
+OPTION("-S", S, Flag, INVALID, INVALID, "d", 0)
OPTION("-Tbss", Tbss, JoinedOrSeparate, T_Group, INVALID, "", 0)
OPTION("-Tdata", Tdata, JoinedOrSeparate, T_Group, INVALID, "", 0)
OPTION("-Ttext", Ttext, JoinedOrSeparate, T_Group, INVALID, "", 0)
@@ -277,19 +280,19 @@
OPTION("-all_load", all__load, Flag, INVALID, INVALID, "", 0)
OPTION("-allowable_client", allowable__client, Separate, INVALID, INVALID, "", 0)
OPTION("-ansi", ansi, Flag, a_Group, INVALID, "", 0)
-OPTION("-arch", arch, Separate, INVALID, INVALID, "", 0)
+OPTION("-arch", arch, Separate, INVALID, INVALID, "d", 0)
OPTION("-a", a, Joined, a_Group, INVALID, "", 0)
OPTION("-bind_at_load", bind__at__load, Flag, INVALID, INVALID, "", 0)
OPTION("-bundle_loader", bundle__loader, Separate, INVALID, INVALID, "", 0)
OPTION("-bundle", bundle, Flag, INVALID, INVALID, "", 0)
OPTION("-b", b, JoinedOrSeparate, INVALID, INVALID, "u", 0)
OPTION("-client_name", client__name, JoinedOrSeparate, INVALID, INVALID, "", 0)
-OPTION("-combine", combine, Flag, INVALID, INVALID, "u", 0)
+OPTION("-combine", combine, Flag, INVALID, INVALID, "du", 0)
OPTION("-compatibility_version", compatibility__version, JoinedOrSeparate, INVALID, INVALID, "", 0)
OPTION("-coverage", coverage, Flag, INVALID, INVALID, "", 0)
OPTION("-cpp-precomp", cpp_precomp, Flag, INVALID, INVALID, "", 0)
OPTION("-current_version", current__version, JoinedOrSeparate, INVALID, INVALID, "", 0)
-OPTION("-c", c, Flag, INVALID, INVALID, "", 0)
+OPTION("-c", c, Flag, INVALID, INVALID, "d", 0)
OPTION("-dA", dA, Flag, d_Group, INVALID, "", 0)
OPTION("-dM", dM, Flag, d_Group, INVALID, "", 0)
OPTION("-dead_strip", dead__strip, Flag, INVALID, INVALID, "", 0)
@@ -366,7 +369,7 @@
OPTION("-fprofile-arcs", fprofile_arcs, Flag, f_Group, INVALID, "", 0)
OPTION("-fprofile-generate", fprofile_generate, Flag, f_Group, INVALID, "", 0)
OPTION("-framework", framework, Separate, INVALID, INVALID, "l", 0)
-OPTION("-fsyntax-only", fsyntax_only, Flag, INVALID, INVALID, "", 0)
+OPTION("-fsyntax-only", fsyntax_only, Flag, INVALID, INVALID, "d", 0)
OPTION("-ftemplate-depth-", ftemplate_depth_, Joined, f_Group, INVALID, "", 0)
OPTION("-fterminated-vtables", fterminated_vtables, Flag, f_Group, INVALID, "", 0)
OPTION("-ftime-report", ftime_report, Flag, clang_f_Group, INVALID, "", 0)
@@ -442,7 +445,7 @@
OPTION("-m", m_Separate, Separate, m_Group, INVALID, "", 0)
OPTION("-m", m_Joined, Joined, m_Group, INVALID, "", 0)
OPTION("-no-cpp-precomp", no_cpp_precomp, Flag, INVALID, INVALID, "", 0)
-OPTION("-no-integrated-cpp", no_integrated_cpp, Flag, INVALID, INVALID, "", 0)
+OPTION("-no-integrated-cpp", no_integrated_cpp, Flag, INVALID, INVALID, "d", 0)
OPTION("-no_dead_strip_inits_and_terms", no__dead__strip__inits__and__terms, Flag, INVALID, INVALID, "", 0)
OPTION("-nodefaultlibs", nodefaultlibs, Flag, INVALID, INVALID, "", 0)
OPTION("-nofixprebinding", nofixprebinding, Flag, INVALID, INVALID, "", 0)
@@ -453,7 +456,7 @@
OPTION("-nostdinc", nostdinc, Flag, INVALID, INVALID, "", 0)
OPTION("-nostdlib", nostdlib, Flag, INVALID, INVALID, "", 0)
OPTION("-object", object, Flag, INVALID, INVALID, "", 0)
-OPTION("-o", o, JoinedOrSeparate, INVALID, INVALID, "i", 0)
+OPTION("-o", o, JoinedOrSeparate, INVALID, INVALID, "di", 0)
OPTION("-pagezero_size", pagezero__size, Flag, INVALID, INVALID, "", 0)
OPTION("-pass-exit-codes", pass_exit_codes, Flag, INVALID, INVALID, "", 0)
OPTION("-pedantic-errors", pedantic_errors, Flag, pedantic_Group, INVALID, "", 0)
@@ -477,7 +480,7 @@
OPTION("-read_only_relocs", read__only__relocs, Separate, INVALID, INVALID, "", 0)
OPTION("-remap", remap, Flag, INVALID, INVALID, "", 0)
OPTION("-r", r, JoinedOrSeparate, INVALID, INVALID, "", 0)
-OPTION("-save-temps", save_temps, Flag, INVALID, INVALID, "", 0)
+OPTION("-save-temps", save_temps, Flag, INVALID, INVALID, "d", 0)
OPTION("-sectalign", sectalign, MultiArg, INVALID, INVALID, "", 3)
OPTION("-sectcreate", sectcreate, MultiArg, INVALID, INVALID, "", 3)
OPTION("-sectobjectsymbols", sectobjectsymbols, MultiArg, INVALID, INVALID, "", 2)
@@ -523,5 +526,5 @@
OPTION("-whatsloaded", whatsloaded, Flag, INVALID, INVALID, "", 0)
OPTION("-whyload", whyload, Flag, INVALID, INVALID, "", 0)
OPTION("-w", w, Flag, INVALID, INVALID, "", 0)
-OPTION("-x", x, JoinedOrSeparate, INVALID, INVALID, "", 0)
+OPTION("-x", x, JoinedOrSeparate, INVALID, INVALID, "d", 0)
OPTION("-y", y, Joined, INVALID, INVALID, "", 0)
Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=67181&r1=67180&r2=67181&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Wed Mar 18 03:01:15 2009
@@ -29,7 +29,7 @@
static Info OptionInfos[] = {
// The InputOption info
- { "<input>", "", Option::InputClass, OPT_INVALID, OPT_INVALID, 0 },
+ { "<input>", "d", Option::InputClass, OPT_INVALID, OPT_INVALID, 0 },
// The UnknownOption info
{ "<unknown>", "", Option::UnknownClass, OPT_INVALID, OPT_INVALID, 0 },
@@ -107,14 +107,24 @@
for (const char *s = info.Flags; *s; ++s) {
switch (*s) {
default: assert(0 && "Invalid option flag.");
- case 'J': Opt->setForceJoinedRender(true); break;
- case 'S': Opt->setForceSeparateRender(true); break;
+ case 'J':
+ assert(info.Kind == Option::SeparateClass && "Invalid option.");
+ Opt->setForceJoinedRender(true); break;
+ case 'S':
+ assert(info.Kind == Option::JoinedClass && "Invalid option.");
+ Opt->setForceSeparateRender(true); break;
+ case 'd': Opt->setForwardToGCC(false); break;
case 'i': Opt->setNoOptAsInput(true); break;
case 'l': Opt->setLinkerInput(true); break;
case 'u': Opt->setUnsupported(true); break;
}
}
+ // Linker inputs shouldn't be forwarded to GCC as arguments (they
+ // will, however, be forwarded as inputs).
+ if (Opt->isLinkerInput())
+ Opt->setForwardToGCC(false);
+
return Opt;
}
Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=67181&r1=67180&r2=67181&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Wed Mar 18 03:01:15 2009
@@ -20,7 +20,8 @@
const OptionGroup *_Group, const Option *_Alias)
: Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
- ForceSeparateRender(false), ForceJoinedRender(false)
+ ForceSeparateRender(false), ForceJoinedRender(false),
+ ForwardToGCC(true)
{
// Multi-level aliases are not supported, and alias options cannot
More information about the cfe-commits
mailing list