[cfe-commits] r166245 - in /cfe/trunk: include/clang/Driver/Arg.h include/clang/Driver/ArgList.h include/clang/Driver/OptTable.h include/clang/Driver/Option.h lib/Driver/Arg.cpp lib/Driver/ArgList.cpp lib/Driver/Driver.cpp lib/Driver/OptTable.cpp lib/Driver/Option.cpp lib/Driver/ToolChains.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Oct 18 15:42:31 PDT 2012
Author: akirtzidis
Date: Thu Oct 18 17:42:31 2012
New Revision: 166245
URL: http://llvm.org/viewvc/llvm-project?rev=166245&view=rev
Log:
Revert r166223 and the subsequent commits that depend on it, r166230 & r166235.
This seems to have introduced assertion hit when building compiler-rt.
Modified:
cfe/trunk/include/clang/Driver/Arg.h
cfe/trunk/include/clang/Driver/ArgList.h
cfe/trunk/include/clang/Driver/OptTable.h
cfe/trunk/include/clang/Driver/Option.h
cfe/trunk/lib/Driver/Arg.cpp
cfe/trunk/lib/Driver/ArgList.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/OptTable.cpp
cfe/trunk/lib/Driver/Option.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
Modified: cfe/trunk/include/clang/Driver/Arg.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Arg.h?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Arg.h (original)
+++ cfe/trunk/include/clang/Driver/Arg.h Thu Oct 18 17:42:31 2012
@@ -15,8 +15,6 @@
#ifndef CLANG_DRIVER_ARG_H_
#define CLANG_DRIVER_ARG_H_
-#include "clang/Driver/Option.h"
-
#include "Util.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
@@ -25,6 +23,7 @@
namespace clang {
namespace driver {
class ArgList;
+ class Option;
/// \brief A concrete instance of a particular driver option.
///
@@ -39,7 +38,7 @@
private:
/// \brief The option this argument is an instance of.
- const Option Opt;
+ const Option *Opt;
/// \brief The argument this argument was derived from (during tool chain
/// argument translation), if any.
@@ -61,14 +60,14 @@
SmallVector<const char *, 2> Values;
public:
- Arg(const Option Opt, unsigned Index, const Arg *BaseArg = 0);
- Arg(const Option Opt, unsigned Index,
+ Arg(const Option *Opt, unsigned Index, const Arg *BaseArg = 0);
+ Arg(const Option *Opt, unsigned Index,
const char *Value0, const Arg *BaseArg = 0);
- Arg(const Option Opt, unsigned Index,
+ Arg(const Option *Opt, unsigned Index,
const char *Value0, const char *Value1, const Arg *BaseArg = 0);
~Arg();
- const Option getOption() const { return Opt; }
+ const Option &getOption() const { return *Opt; }
unsigned getIndex() const { return Index; }
/// \brief Return the base argument which generated this arg.
Modified: cfe/trunk/include/clang/Driver/ArgList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ArgList.h?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Thu Oct 18 17:42:31 2012
@@ -11,7 +11,6 @@
#define CLANG_DRIVER_ARGLIST_H_
#include "clang/Basic/LLVM.h"
-#include "clang/Driver/Option.h"
#include "clang/Driver/OptSpecifier.h"
#include "clang/Driver/Util.h"
#include "llvm/ADT/SmallVector.h"
@@ -375,14 +374,14 @@
/// AddFlagArg - Construct a new FlagArg for the given option \p Id and
/// append it to the argument list.
- void AddFlagArg(const Arg *BaseArg, const Option Opt) {
+ void AddFlagArg(const Arg *BaseArg, const Option *Opt) {
append(MakeFlagArg(BaseArg, Opt));
}
/// AddPositionalArg - Construct a new Positional arg for the given option
/// \p Id, with the provided \p Value and append it to the argument
/// list.
- void AddPositionalArg(const Arg *BaseArg, const Option Opt,
+ void AddPositionalArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) {
append(MakePositionalArg(BaseArg, Opt, Value));
}
@@ -391,7 +390,7 @@
/// AddSeparateArg - Construct a new Positional arg for the given option
/// \p Id, with the provided \p Value and append it to the argument
/// list.
- void AddSeparateArg(const Arg *BaseArg, const Option Opt,
+ void AddSeparateArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) {
append(MakeSeparateArg(BaseArg, Opt, Value));
}
@@ -399,28 +398,28 @@
/// AddJoinedArg - Construct a new Positional arg for the given option
/// \p Id, with the provided \p Value and append it to the argument list.
- void AddJoinedArg(const Arg *BaseArg, const Option Opt,
+ void AddJoinedArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) {
append(MakeJoinedArg(BaseArg, Opt, Value));
}
/// MakeFlagArg - Construct a new FlagArg for the given option \p Id.
- Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const;
+ Arg *MakeFlagArg(const Arg *BaseArg, const Option *Opt) const;
/// MakePositionalArg - Construct a new Positional arg for the
/// given option \p Id, with the provided \p Value.
- Arg *MakePositionalArg(const Arg *BaseArg, const Option Opt,
+ Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) const;
/// MakeSeparateArg - Construct a new Positional arg for the
/// given option \p Id, with the provided \p Value.
- Arg *MakeSeparateArg(const Arg *BaseArg, const Option Opt,
+ Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) const;
/// MakeJoinedArg - Construct a new Positional arg for the
/// given option \p Id, with the provided \p Value.
- Arg *MakeJoinedArg(const Arg *BaseArg, const Option Opt,
+ Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) const;
/// @}
Modified: cfe/trunk/include/clang/Driver/OptTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/OptTable.h?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/OptTable.h (original)
+++ cfe/trunk/include/clang/Driver/OptTable.h Thu Oct 18 17:42:31 2012
@@ -47,6 +47,15 @@
const Info *OptionInfos;
unsigned NumOptionInfos;
+ /// \brief The lazily constructed options table, indexed by option::ID - 1.
+ mutable Option **Options;
+
+ /// \brief Prebound input option instance.
+ const Option *TheInputOption;
+
+ /// \brief Prebound unknown option instance.
+ const Option *TheUnknownOption;
+
/// The index of the first option which can be parsed (i.e., is not a
/// special option like 'input' or 'unknown', and is not an option group).
unsigned FirstSearchableIndex;
@@ -58,6 +67,8 @@
return OptionInfos[id - 1];
}
+ Option *CreateOption(unsigned id) const;
+
protected:
OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos);
public:
@@ -70,7 +81,17 @@
/// if necessary.
///
/// \return The option, or null for the INVALID option id.
- const Option getOption(OptSpecifier Opt) const;
+ const Option *getOption(OptSpecifier Opt) const {
+ unsigned id = Opt.getID();
+ if (id == 0)
+ return 0;
+
+ assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
+ Option *&Entry = Options[id - 1];
+ if (!Entry)
+ Entry = CreateOption(id);
+ return Entry;
+ }
/// \brief Lookup the name of the given option.
const char *getOptionName(OptSpecifier id) const {
Modified: cfe/trunk/include/clang/Driver/Option.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Thu Oct 18 17:42:31 2012
@@ -21,20 +21,15 @@
class ArgList;
namespace options {
- /// Base flags for all options. Custom flags may be added after.
enum DriverFlag {
- HelpHidden = (1 << 0),
- RenderAsInput = (1 << 1),
- RenderJoined = (1 << 2),
- RenderSeparate = (1 << 3)
- };
-
- /// Flags specifically for clang options.
- enum ClangFlags {
- DriverOption = (1 << 4),
- LinkerInput = (1 << 5),
- NoArgumentUnused = (1 << 6),
- NoForward = (1 << 7),
+ DriverOption = (1 << 0),
+ HelpHidden = (1 << 1),
+ LinkerInput = (1 << 2),
+ NoArgumentUnused = (1 << 3),
+ NoForward = (1 << 4),
+ RenderAsInput = (1 << 5),
+ RenderJoined = (1 << 6),
+ RenderSeparate = (1 << 7),
Unsupported = (1 << 8),
CC1Option = (1 << 9)
};
@@ -73,7 +68,7 @@
RenderValuesStyle
};
- protected:
+ private:
const OptTable::Info *Info;
const OptTable *Owner;
@@ -81,38 +76,17 @@
Option(const OptTable::Info *Info, const OptTable *Owner);
~Option();
- bool isValid() const {
- return Info != 0;
- }
-
- unsigned getID() const {
- assert(Info && "Must have a valid info!");
- return Info->ID;
- }
-
- OptionClass getKind() const {
- assert(Info && "Must have a valid info!");
- return OptionClass(Info->Kind);
- }
-
- StringRef getName() const {
- assert(Info && "Must have a valid info!");
- return Info->Name;
- }
+ unsigned getID() const { return Info->ID; }
+ OptionClass getKind() const { return OptionClass(Info->Kind); }
+ StringRef getName() const { return Info->Name; }
+ const Option *getGroup() const { return Owner->getOption(Info->GroupID); }
+ const Option *getAlias() const { return Owner->getOption(Info->AliasID); }
- const Option getGroup() const {
- assert(Info && "Must have a valid info!");
- assert(Owner && "Must have a valid owner!");
- return Owner->getOption(Info->GroupID);
- }
+ unsigned getNumArgs() const { return Info->Param; }
- const Option getAlias() const {
- assert(Info && "Must have a valid info!");
- assert(Owner && "Must have a valid owner!");
- return Owner->getOption(Info->AliasID);
- }
+ bool isUnsupported() const { return Info->Flags & options::Unsupported; }
- unsigned getNumArgs() const { return Info->Param; }
+ bool isLinkerInput() const { return Info->Flags & options::LinkerInput; }
bool hasNoOptAsInput() const { return Info->Flags & options::RenderAsInput;}
@@ -140,23 +114,32 @@
llvm_unreachable("Unexpected kind!");
}
- /// Test if this option has the flag \a Val.
- bool hasFlag(unsigned Val) const {
- return Info->Flags & Val;
+ bool isDriverOption() const { return Info->Flags & options::DriverOption; }
+
+ bool hasNoArgumentUnused() const {
+ return Info->Flags & options::NoArgumentUnused;
+ }
+
+ bool hasNoForward() const { return Info->Flags & options::NoForward; }
+
+ bool isCC1Option() const { return Info->Flags & options::CC1Option; }
+
+ bool hasForwardToGCC() const {
+ return !hasNoForward() && !isDriverOption() && !isLinkerInput();
}
/// getUnaliasedOption - Return the final option this option
/// aliases (itself, if the option has no alias).
- const Option getUnaliasedOption() const {
- const Option Alias = getAlias();
- if (Alias.isValid()) return Alias.getUnaliasedOption();
- return *this;
+ const Option *getUnaliasedOption() const {
+ const Option *Alias = getAlias();
+ if (Alias) return Alias->getUnaliasedOption();
+ return this;
}
/// getRenderName - Return the name to use when rendering this
/// option.
StringRef getRenderName() const {
- return getUnaliasedOption().getName();
+ return getUnaliasedOption()->getName();
}
/// matches - Predicate for whether this option is part of the
Modified: cfe/trunk/lib/Driver/Arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Arg.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Arg.cpp (original)
+++ cfe/trunk/lib/Driver/Arg.cpp Thu Oct 18 17:42:31 2012
@@ -16,19 +16,19 @@
using namespace clang::driver;
-Arg::Arg(const Option _Opt, unsigned _Index, const Arg *_BaseArg)
+Arg::Arg(const Option *_Opt, unsigned _Index, const Arg *_BaseArg)
: Opt(_Opt), BaseArg(_BaseArg), Index(_Index),
Claimed(false), OwnsValues(false) {
}
-Arg::Arg(const Option _Opt, unsigned _Index,
+Arg::Arg(const Option *_Opt, unsigned _Index,
const char *Value0, const Arg *_BaseArg)
: Opt(_Opt), BaseArg(_BaseArg), Index(_Index),
Claimed(false), OwnsValues(false) {
Values.push_back(Value0);
}
-Arg::Arg(const Option _Opt, unsigned _Index,
+Arg::Arg(const Option *_Opt, unsigned _Index,
const char *Value0, const char *Value1, const Arg *_BaseArg)
: Opt(_Opt), BaseArg(_BaseArg), Index(_Index),
Claimed(false), OwnsValues(false) {
@@ -47,7 +47,7 @@
llvm::errs() << "<";
llvm::errs() << " Opt:";
- Opt.dump();
+ Opt->dump();
llvm::errs() << " Index:" << Index;
@@ -104,7 +104,7 @@
Output.push_back(Args.MakeArgString(OS.str()));
break;
}
-
+
case Option::RenderJoinedStyle:
Output.push_back(Args.GetOrMakeJoinedArgString(
getIndex(), getOption().getName(), getValue(Args, 0)));
Modified: cfe/trunk/lib/Driver/ArgList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ArgList.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ArgList.cpp (original)
+++ cfe/trunk/lib/Driver/ArgList.cpp Thu Oct 18 17:42:31 2012
@@ -362,13 +362,13 @@
return BaseArgs.MakeArgString(Str);
}
-Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option Opt) const {
- Arg *A = new Arg(Opt, BaseArgs.MakeIndex(Opt.getName()), BaseArg);
+Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option *Opt) const {
+ Arg *A = new Arg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg);
SynthesizedArgs.push_back(A);
return A;
}
-Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option Opt,
+Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) const {
unsigned Index = BaseArgs.MakeIndex(Value);
Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index), BaseArg);
@@ -376,19 +376,19 @@
return A;
}
-Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option Opt,
+Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) const {
- unsigned Index = BaseArgs.MakeIndex(Opt.getName(), Value);
+ unsigned Index = BaseArgs.MakeIndex(Opt->getName(), Value);
Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index + 1), BaseArg);
SynthesizedArgs.push_back(A);
return A;
}
-Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option Opt,
+Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
StringRef Value) const {
- unsigned Index = BaseArgs.MakeIndex(Opt.getName().str() + Value.str());
+ unsigned Index = BaseArgs.MakeIndex(Opt->getName().str() + Value.str());
Arg *A = new Arg(Opt, Index,
- BaseArgs.getArgString(Index) + Opt.getName().size(),
+ BaseArgs.getArgString(Index) + Opt->getName().size(),
BaseArg);
SynthesizedArgs.push_back(A);
return A;
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct 18 17:42:31 2012
@@ -98,7 +98,7 @@
for (ArgList::const_iterator it = Args->begin(), ie = Args->end();
it != ie; ++it) {
Arg *A = *it;
- if (A->getOption().hasFlag(options::Unsupported)) {
+ if (A->getOption().isUnsupported()) {
Diag(clang::diag::err_drv_unsupported_opt) << A->getAsString(*Args);
continue;
}
@@ -1033,7 +1033,7 @@
} else
Inputs.push_back(std::make_pair(Ty, A));
- } else if (A->getOption().hasFlag(options::LinkerInput)) {
+ } else if (A->getOption().isLinkerInput()) {
// Just treat as object type, we could make a special type for this if
// necessary.
Inputs.push_back(std::make_pair(types::TY_Object, A));
@@ -1300,7 +1300,7 @@
// DiagnosticsEngine, so that extra values, position, and so on could be
// printed.
if (!A->isClaimed()) {
- if (A->getOption().hasFlag(options::NoArgumentUnused))
+ if (A->getOption().hasNoArgumentUnused())
continue;
// Suppress the warning automatically if this is just a flag, and it is an
Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Thu Oct 18 17:42:31 2012
@@ -11,7 +11,6 @@
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
#include "clang/Driver/Option.h"
-#include "clang/Driver/Options.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
@@ -80,16 +79,22 @@
OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos)
: OptionInfos(_OptionInfos), NumOptionInfos(_NumOptionInfos),
- FirstSearchableIndex(0)
+ Options(new Option*[NumOptionInfos]),
+ TheInputOption(0), TheUnknownOption(0), FirstSearchableIndex(0)
{
// Explicitly zero initialize the error to work around a bug in array
// value-initialization on MinGW with gcc 4.3.5.
+ memset(Options, 0, sizeof(*Options) * NumOptionInfos);
// Find start of normal options.
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned Kind = getInfo(i + 1).Kind;
if (Kind == Option::InputClass) {
+ assert(!TheInputOption && "Cannot have multiple input options!");
+ TheInputOption = getOption(i + 1);
} else if (Kind == Option::UnknownClass) {
+ assert(!TheUnknownOption && "Cannot have multiple input options!");
+ TheUnknownOption = getOption(i + 1);
} else if (Kind != Option::GroupClass) {
FirstSearchableIndex = i;
break;
@@ -110,8 +115,8 @@
// Check that options are in order.
for (unsigned i = FirstSearchableIndex+1, e = getNumOptions(); i != e; ++i) {
if (!(getInfo(i) < getInfo(i + 1))) {
- getOption(i).dump();
- getOption(i + 1).dump();
+ getOption(i)->dump();
+ getOption(i + 1)->dump();
llvm_unreachable("Options are not in order!");
}
}
@@ -119,27 +124,26 @@
}
OptTable::~OptTable() {
-}
-
-const Option OptTable::getOption(OptSpecifier Opt) const {
- unsigned id = Opt.getID();
- if (id == 0)
- return Option(0, 0);
- assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID.");
- return Option(&getInfo(id), this);
+ for (unsigned i = 0, e = getNumOptions(); i != e; ++i)
+ delete Options[i];
+ delete[] Options;
}
bool OptTable::isOptionHelpHidden(OptSpecifier id) const {
return getInfo(id).Flags & options::HelpHidden;
}
+Option *OptTable::CreateOption(unsigned id) const {
+ return new Option(&getInfo(id), this);
+}
+
Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const {
unsigned Prev = Index;
const char *Str = Args.getArgString(Index);
// Anything that doesn't start with '-' is an input, as is '-' itself.
if (Str[0] != '-' || Str[1] == '\0')
- return new Arg(getOption(options::OPT_INPUT), Index++, Str);
+ return new Arg(TheInputOption, Index++, Str);
const Info *Start = OptionInfos + FirstSearchableIndex;
const Info *End = OptionInfos + getNumOptions();
@@ -165,7 +169,7 @@
break;
// See if this option matches.
- if (Arg *A = getOption(Start - OptionInfos + 1).accept(Args, Index))
+ if (Arg *A = getOption(Start - OptionInfos + 1)->accept(Args, Index))
return A;
// Otherwise, see if this argument was missing values.
@@ -173,7 +177,7 @@
return 0;
}
- return new Arg(getOption(options::OPT_UNKNOWN), Index++, Str);
+ return new Arg(TheUnknownOption, Index++, Str);
}
InputArgList *OptTable::ParseArgs(const char* const *ArgBegin,
Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Thu Oct 18 17:42:31 2012
@@ -23,8 +23,7 @@
// Multi-level aliases are not supported, and alias options cannot
// have groups. This just simplifies option tracking, it is not an
// inherent limitation.
- assert(!Info || (!getAlias().isValid() || (!getAlias().getAlias().isValid() &&
- !getGroup().isValid())) &&
+ assert((!getAlias() || (!getAlias()->getAlias() && !getGroup())) &&
"Multi-level aliases and aliases with groups are unsupported.");
}
@@ -50,16 +49,16 @@
llvm::errs() << " Name:\"" << getName() << '"';
- const Option Group = getGroup();
- if (Group.isValid()) {
+ const Option *Group = getGroup();
+ if (Group) {
llvm::errs() << " Group:";
- Group.dump();
+ Group->dump();
}
- const Option Alias = getAlias();
- if (Alias.isValid()) {
+ const Option *Alias = getAlias();
+ if (Alias) {
llvm::errs() << " Alias:";
- Alias.dump();
+ Alias->dump();
}
if (getKind() == MultiArgClass)
@@ -70,17 +69,17 @@
bool Option::matches(OptSpecifier Opt) const {
// Aliases are never considered in matching, look through them.
- const Option Alias = getAlias();
- if (Alias.isValid())
- return Alias.matches(Opt);
+ const Option *Alias = getAlias();
+ if (Alias)
+ return Alias->matches(Opt);
// Check exact match.
if (getID() == Opt.getID())
return true;
- const Option Group = getGroup();
- if (Group.isValid())
- return Group.matches(Opt);
+ const Option *Group = getGroup();
+ if (Group)
+ return Group->matches(Opt);
return false;
}
@@ -156,7 +155,7 @@
// FIXME: Avoid strlen.
if (getName().size() != strlen(Args.getArgString(Index))) {
const char *Value = Args.getArgString(Index) + getName().size();
- return new Arg(*this, Index++, Value);
+ return new Arg(this, Index++, Value);
}
// Otherwise it must be separate.
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct 18 17:42:31 2012
@@ -485,7 +485,7 @@
}
// When using the define to indicate the simulator, we force
// 10.6 macosx target.
- const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
+ const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
OSXVersion = Args.MakeJoinedArg(0, O, "10.6");
Args.append(OSXVersion);
break;
@@ -559,21 +559,21 @@
}
if (!OSXTarget.empty()) {
- const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
+ const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
OSXVersion = Args.MakeJoinedArg(0, O, OSXTarget);
Args.append(OSXVersion);
} else if (!iOSTarget.empty()) {
- const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
+ const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
iOSVersion = Args.MakeJoinedArg(0, O, iOSTarget);
Args.append(iOSVersion);
} else if (!iOSSimTarget.empty()) {
- const Option O = Opts.getOption(
+ const Option *O = Opts.getOption(
options::OPT_mios_simulator_version_min_EQ);
iOSSimVersion = Args.MakeJoinedArg(0, O, iOSSimTarget);
Args.append(iOSSimVersion);
} else {
// Otherwise, assume we are targeting OS X.
- const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
+ const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
OSXVersion = Args.MakeJoinedArg(0, O, MacosxVersionMin);
Args.append(OSXVersion);
}
@@ -737,7 +737,7 @@
getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
<< A->getAsString(Args);
continue;
- } else if (XarchArg->getOption().hasFlag(options::DriverOption)) {
+ } else if (XarchArg->getOption().isDriverOption()) {
getDriver().Diag(diag::err_drv_invalid_Xarch_argument_isdriver)
<< A->getAsString(Args);
continue;
@@ -751,7 +751,7 @@
// Linker input arguments require custom handling. The problem is that we
// have already constructed the phase actions, so we can not treat them as
// "input arguments".
- if (A->getOption().hasFlag(options::LinkerInput)) {
+ if (A->getOption().isLinkerInput()) {
// Convert the argument into individual Zlinker_input_args.
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {
DAL->AddSeparateArg(OriginalArg,
@@ -835,8 +835,8 @@
// how the driver driver works.
if (BoundArch) {
StringRef Name = BoundArch;
- const Option MCpu = Opts.getOption(options::OPT_mcpu_EQ);
- const Option MArch = Opts.getOption(options::OPT_march_EQ);
+ const Option *MCpu = Opts.getOption(options::OPT_mcpu_EQ);
+ const Option *MArch = Opts.getOption(options::OPT_march_EQ);
// This code must be kept in sync with LLVM's getArchTypeForDarwinArch,
// which defines the list of which architectures we accept.
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 18 17:42:31 2012
@@ -200,12 +200,6 @@
CmdArgs.push_back(Args.MakeArgString(ProfileRT));
}
-static bool forwardToGCC(const Option &O) {
- return !O.hasFlag(options::NoForward) &&
- !O.hasFlag(options::DriverOption) &&
- !O.hasFlag(options::LinkerInput);
-}
-
void Clang::AddPreprocessingOptions(Compilation &C,
const Driver &D,
const ArgList &Args,
@@ -3201,7 +3195,7 @@
for (ArgList::const_iterator
it = Args.begin(), ie = Args.end(); it != ie; ++it) {
Arg *A = *it;
- if (forwardToGCC(A->getOption())) {
+ if (A->getOption().hasForwardToGCC()) {
// Don't forward any -g arguments to assembly steps.
if (isa<AssembleJobAction>(JA) &&
A->getOption().matches(options::OPT_g_Group))
@@ -3426,7 +3420,7 @@
for (ArgList::const_iterator
it = Args.begin(), ie = Args.end(); it != ie; ++it) {
Arg *A = *it;
- if (forwardToGCC(A->getOption())) {
+ if (A->getOption().hasForwardToGCC()) {
// Don't forward any -g arguments to assembly steps.
if (isa<AssembleJobAction>(JA) &&
A->getOption().matches(options::OPT_g_Group))
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=166245&r1=166244&r2=166245&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Oct 18 17:42:31 2012
@@ -2330,7 +2330,7 @@
// Issue errors on arguments that are not valid for CC1.
for (ArgList::iterator I = Args->begin(), E = Args->end();
I != E; ++I) {
- if (!(*I)->getOption().hasFlag(options::CC1Option)) {
+ if (!(*I)->getOption().isCC1Option()) {
Diags.Report(diag::err_drv_unknown_argument) << (*I)->getAsString(*Args);
Success = false;
}
More information about the cfe-commits
mailing list