diff options
Diffstat (limited to 'include/clang/Driver/ArgList.h')
-rw-r--r-- | include/clang/Driver/ArgList.h | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h index a9c890b0b899..dcb60381a467 100644 --- a/include/clang/Driver/ArgList.h +++ b/include/clang/Driver/ArgList.h @@ -14,8 +14,14 @@ #include "clang/Driver/Util.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include <list> +#include <string> + +namespace llvm { + class Twine; +} namespace clang { namespace driver { @@ -64,17 +70,17 @@ namespace driver { const_iterator begin() const { return Args.begin(); } const_iterator end() const { return Args.end(); } - + const_reverse_iterator rbegin() const { return Args.rbegin(); } const_reverse_iterator rend() const { return Args.rend(); } /// hasArg - Does the arg list contain any option matching \arg Id. /// /// \arg Claim Whether the argument should be claimed, if it exists. - bool hasArg(options::ID Id, bool Claim=true) const { + bool hasArg(options::ID Id, bool Claim=true) const { return getLastArg(Id, Claim) != 0; } - bool hasArg(options::ID Id0, options::ID Id1, bool Claim=true) const { + bool hasArg(options::ID Id0, options::ID Id1, bool Claim=true) const { return getLastArg(Id0, Id1, Claim) != 0; } @@ -104,15 +110,15 @@ namespace driver { /// AddAllArgs - Render all arguments matching the given ids. void AddAllArgs(ArgStringList &Output, options::ID Id0) const; - void AddAllArgs(ArgStringList &Output, options::ID Id0, + void AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1) const; - void AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1, + void AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1, options::ID Id2) const; /// AddAllArgValues - Render the argument values of all arguments /// matching the given ids. void AddAllArgValues(ArgStringList &Output, options::ID Id0) const; - void AddAllArgValues(ArgStringList &Output, options::ID Id0, + void AddAllArgValues(ArgStringList &Output, options::ID Id0, options::ID Id1) const; /// AddAllArgsTranslated - Render all the arguments matching the @@ -122,7 +128,7 @@ namespace driver { /// \param Joined - If true, render the argument as joined with /// the option specifier. void AddAllArgsTranslated(ArgStringList &Output, options::ID Id0, - const char *Translation, + const char *Translation, bool Joined = false) const; /// ClaimAllArgs - Claim all arguments which match the given @@ -135,7 +141,14 @@ namespace driver { /// MakeArgString - Construct a constant string pointer whose /// lifetime will match that of the ArgList. - virtual const char *MakeArgString(const char *Str) const = 0; + virtual const char *MakeArgString(llvm::StringRef Str) const = 0; + const char *MakeArgString(const char *Str) const { + return MakeArgString(llvm::StringRef(Str)); + } + const char *MakeArgString(std::string Str) const { + return MakeArgString(llvm::StringRef(Str)); + } + const char *MakeArgString(const llvm::Twine &Str) const; /// @} }; @@ -167,8 +180,8 @@ namespace driver { InputArgList(const ArgList &); ~InputArgList(); - virtual const char *getArgString(unsigned Index) const { - return ArgStrings[Index]; + virtual const char *getArgString(unsigned Index) const { + return ArgStrings[Index]; } /// getNumInputArgStrings - Return the number of original input @@ -180,10 +193,10 @@ namespace driver { public: /// MakeIndex - Get an index for the given string(s). - unsigned MakeIndex(const char *String0) const; - unsigned MakeIndex(const char *String0, const char *String1) const; + unsigned MakeIndex(llvm::StringRef String0) const; + unsigned MakeIndex(llvm::StringRef String0, llvm::StringRef String1) const; - virtual const char *MakeArgString(const char *Str) const; + virtual const char *MakeArgString(llvm::StringRef Str) const; /// @} }; @@ -211,13 +224,13 @@ namespace driver { ~DerivedArgList(); virtual const char *getArgString(unsigned Index) const { - return BaseArgs.getArgString(Index); + return BaseArgs.getArgString(Index); } /// @name Arg Synthesis /// @{ - virtual const char *MakeArgString(const char *Str) const; + virtual const char *MakeArgString(llvm::StringRef Str) const; /// MakeFlagArg - Construct a new FlagArg for the given option /// \arg Id. @@ -225,18 +238,18 @@ namespace driver { /// MakePositionalArg - Construct a new Positional arg for the /// given option \arg Id, with the provided \arg Value. - Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt, - const char *Value) const; + Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt, + llvm::StringRef Value) const; /// MakeSeparateArg - Construct a new Positional arg for the /// given option \arg Id, with the provided \arg Value. - Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt, - const char *Value) const; + Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt, + llvm::StringRef Value) const; /// MakeJoinedArg - Construct a new Positional arg for the /// given option \arg Id, with the provided \arg Value. - Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt, - const char *Value) const; + Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt, + llvm::StringRef Value) const; /// @} }; |