aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Option
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2014-11-24 09:08:18 +0000
committerDimitry Andric <dim@FreeBSD.org>2014-11-24 09:08:18 +0000
commit5ca98fd98791947eba83a1ed3f2c8191ef7afa6c (patch)
treef5944309621cee4fe0976be6f9ac619b7ebfc4c2 /include/llvm/Option
parent68bcb7db193e4bc81430063148253d30a791023e (diff)
Notes
Diffstat (limited to 'include/llvm/Option')
-rw-r--r--include/llvm/Option/Arg.h13
-rw-r--r--include/llvm/Option/ArgList.h43
-rw-r--r--include/llvm/Option/OptParser.td1
-rw-r--r--include/llvm/Option/OptSpecifier.h2
-rw-r--r--include/llvm/Option/Option.h2
5 files changed, 36 insertions, 25 deletions
diff --git a/include/llvm/Option/Arg.h b/include/llvm/Option/Arg.h
index 6b8ed3f7d2b11..dcaa5405ba7ca 100644
--- a/include/llvm/Option/Arg.h
+++ b/include/llvm/Option/Arg.h
@@ -27,10 +27,7 @@ class ArgList;
/// \brief A concrete instance of a particular driver option.
///
/// The Arg class encodes just enough information to be able to
-/// derive the argument values efficiently. In addition, Arg
-/// instances have an intrusive double linked list which is used by
-/// ArgList to provide efficient iteration over all instances of a
-/// particular option.
+/// derive the argument values efficiently.
class Arg {
Arg(const Arg &) LLVM_DELETED_FUNCTION;
void operator=(const Arg &) LLVM_DELETED_FUNCTION;
@@ -63,14 +60,14 @@ private:
public:
Arg(const Option Opt, StringRef Spelling, unsigned Index,
- const Arg *BaseArg = 0);
+ const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index,
- const char *Value0, const Arg *BaseArg = 0);
+ const char *Value0, const Arg *BaseArg = nullptr);
Arg(const Option Opt, StringRef Spelling, unsigned Index,
- const char *Value0, const char *Value1, const Arg *BaseArg = 0);
+ const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
~Arg();
- const Option getOption() const { return Opt; }
+ const Option &getOption() const { return Opt; }
StringRef getSpelling() const { return Spelling; }
unsigned getIndex() const { return Index; }
diff --git a/include/llvm/Option/ArgList.h b/include/llvm/Option/ArgList.h
index 06ba679c2b553..d46b0e892faf9 100644
--- a/include/llvm/Option/ArgList.h
+++ b/include/llvm/Option/ArgList.h
@@ -15,6 +15,7 @@
#include "llvm/Option/OptSpecifier.h"
#include "llvm/Option/Option.h"
#include <list>
+#include <memory>
#include <string>
#include <vector>
@@ -105,10 +106,14 @@ private:
arglist_type Args;
protected:
- ArgList();
+ // Default ctor provided explicitly as it is not provided implicitly due to
+ // the presence of the (deleted) copy ctor above.
+ ArgList() { }
+ // Virtual to provide a vtable anchor and because -Wnon-virtua-dtor warns, not
+ // because this type is ever actually destroyed polymorphically.
+ virtual ~ArgList();
public:
- virtual ~ArgList();
/// @name Arg Access
/// @{
@@ -145,6 +150,12 @@ public:
return arg_iterator(Args.end(), *this);
}
+ iterator_range<arg_iterator> filtered(OptSpecifier Id0 = 0U,
+ OptSpecifier Id1 = 0U,
+ OptSpecifier Id2 = 0U) const {
+ return make_range(filtered_begin(Id0, Id1, Id2), filtered_end());
+ }
+
/// @}
/// @name Arg Removal
/// @{
@@ -160,16 +171,16 @@ public:
///
/// \p Claim Whether the argument should be claimed, if it exists.
bool hasArgNoClaim(OptSpecifier Id) const {
- return getLastArgNoClaim(Id) != 0;
+ return getLastArgNoClaim(Id) != nullptr;
}
bool hasArg(OptSpecifier Id) const {
- return getLastArg(Id) != 0;
+ return getLastArg(Id) != nullptr;
}
bool hasArg(OptSpecifier Id0, OptSpecifier Id1) const {
- return getLastArg(Id0, Id1) != 0;
+ return getLastArg(Id0, Id1) != nullptr;
}
bool hasArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const {
- return getLastArg(Id0, Id1, Id2) != 0;
+ return getLastArg(Id0, Id1, Id2) != nullptr;
}
/// getLastArg - Return the last argument matching \p Id, or null.
@@ -307,11 +318,11 @@ public:
InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);
~InputArgList();
- virtual const char *getArgString(unsigned Index) const {
+ const char *getArgString(unsigned Index) const override {
return ArgStrings[Index];
}
- virtual unsigned getNumInputArgStrings() const {
+ unsigned getNumInputArgStrings() const override {
return NumInputArgStrings;
}
@@ -323,7 +334,8 @@ public:
unsigned MakeIndex(StringRef String0) const;
unsigned MakeIndex(StringRef String0, StringRef String1) const;
- virtual const char *MakeArgString(StringRef Str) const;
+ using ArgList::MakeArgString;
+ const char *MakeArgString(StringRef Str) const override;
/// @}
};
@@ -334,18 +346,18 @@ class DerivedArgList : public ArgList {
const InputArgList &BaseArgs;
/// The list of arguments we synthesized.
- mutable arglist_type SynthesizedArgs;
+ mutable SmallVector<std::unique_ptr<Arg>, 16> SynthesizedArgs;
public:
/// Construct a new derived arg list from \p BaseArgs.
DerivedArgList(const InputArgList &BaseArgs);
~DerivedArgList();
- virtual const char *getArgString(unsigned Index) const {
+ const char *getArgString(unsigned Index) const override {
return BaseArgs.getArgString(Index);
}
- virtual unsigned getNumInputArgStrings() const {
+ unsigned getNumInputArgStrings() const override {
return BaseArgs.getNumInputArgStrings();
}
@@ -358,11 +370,10 @@ public:
/// AddSynthesizedArg - Add a argument to the list of synthesized arguments
/// (to be freed).
- void AddSynthesizedArg(Arg *A) {
- SynthesizedArgs.push_back(A);
- }
+ void AddSynthesizedArg(Arg *A);
- virtual const char *MakeArgString(StringRef Str) const;
+ using ArgList::MakeArgString;
+ const char *MakeArgString(StringRef Str) const override;
/// AddFlagArg - Construct a new FlagArg for the given option \p Id and
/// append it to the argument list.
diff --git a/include/llvm/Option/OptParser.td b/include/llvm/Option/OptParser.td
index 963389f0bc6fd..dbf240d748051 100644
--- a/include/llvm/Option/OptParser.td
+++ b/include/llvm/Option/OptParser.td
@@ -75,6 +75,7 @@ class OptionGroup<string name> {
string Name = name;
string HelpText = ?;
OptionGroup Group = ?;
+ list<OptionFlag> Flags = [];
}
// Define the option class.
diff --git a/include/llvm/Option/OptSpecifier.h b/include/llvm/Option/OptSpecifier.h
index 02bc6b175edba..b7caa6e85a7d6 100644
--- a/include/llvm/Option/OptSpecifier.h
+++ b/include/llvm/Option/OptSpecifier.h
@@ -10,6 +10,8 @@
#ifndef LLVM_OPTION_OPTSPECIFIER_H
#define LLVM_OPTION_OPTSPECIFIER_H
+#include "llvm/Support/Compiler.h"
+
namespace llvm {
namespace opt {
class Option;
diff --git a/include/llvm/Option/Option.h b/include/llvm/Option/Option.h
index 03d4774829fbc..b2cfacbaf344b 100644
--- a/include/llvm/Option/Option.h
+++ b/include/llvm/Option/Option.h
@@ -73,7 +73,7 @@ public:
~Option();
bool isValid() const {
- return Info != 0;
+ return Info != nullptr;
}
unsigned getID() const {