]> granicus.if.org Git - clang/commitdiff
Driver: Change OptTable::ParseArg to take any ArgList.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 11 Jun 2010 22:00:17 +0000 (22:00 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 11 Jun 2010 22:00:17 +0000 (22:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105839 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/ArgList.h
include/clang/Driver/OptTable.h
include/clang/Driver/Option.h
lib/Driver/OptTable.cpp
lib/Driver/Option.cpp

index 35648930a560a0d55c012dcea886132a62b5dd93..862b369feaa3bc7052e83fa75d0647a16a291c42 100644 (file)
@@ -179,6 +179,11 @@ namespace driver {
     /// getArgString - Return the input argument string at \arg Index.
     virtual const char *getArgString(unsigned Index) const = 0;
 
+    /// getNumInputArgStrings - Return the number of original argument strings,
+    /// which are guaranteed to be the first strings in the argument string
+    /// list.
+    virtual unsigned getNumInputArgStrings() const = 0;
+
     /// @}
     /// @name Argument Lookup Utilities
     /// @{
@@ -258,6 +263,9 @@ namespace driver {
   };
 
   class InputArgList : public ArgList  {
+    InputArgList(const ArgList &); // DO NOT IMPLEMENT
+    void operator=(const ArgList &); // DO NOT IMPLEMENT
+
   private:
     /// The internal list of arguments.
     arglist_type ActualArgs;
@@ -281,16 +289,15 @@ namespace driver {
 
   public:
     InputArgList(const char **ArgBegin, const char **ArgEnd);
-    InputArgList(const ArgList &);
     ~InputArgList();
 
     virtual const char *getArgString(unsigned Index) const {
       return ArgStrings[Index];
     }
 
-    /// getNumInputArgStrings - Return the number of original input
-    /// argument strings.
-    unsigned getNumInputArgStrings() const { return NumInputArgStrings; }
+    virtual unsigned getNumInputArgStrings() const {
+      return NumInputArgStrings;
+    }
 
     /// @name Arg Synthesis
     /// @{
@@ -331,6 +338,10 @@ namespace driver {
       return BaseArgs.getArgString(Index);
     }
 
+    virtual unsigned getNumInputArgStrings() const {
+      return BaseArgs.getNumInputArgStrings();
+    }
+
     /// @name Arg Synthesis
     /// @{
 
index edae75c9f057faa084ab25086a46bee5c133828f..e4a2eba578b882c2505b2faeff834ec8fe822830 100644 (file)
@@ -33,6 +33,7 @@ namespace options {
 }
 
   class Arg;
+  class ArgList;
   class InputArgList;
   class Option;
 
@@ -150,7 +151,7 @@ namespace options {
     /// \return - The parsed argument, or 0 if the argument is missing values
     /// (in which case Index still points at the conceptual next argument string
     /// to parse).
-    Arg *ParseOneArg(const InputArgList &Args, unsigned &Index) const;
+    Arg *ParseOneArg(const ArgList &Args, unsigned &Index) const;
 
     /// ParseArgs - Parse an list of arguments into an InputArgList.
     ///
index f91ac55fb034962c7af0c8fdfdc119b76f805985..0864382cb3a63bf4a36c9fd781b7f366c6bc3019 100644 (file)
@@ -21,7 +21,7 @@ using llvm::dyn_cast_or_null;
 namespace clang {
 namespace driver {
   class Arg;
-  class InputArgList;
+  class ArgList;
   class OptionGroup;
 
   /// Option - Abstract representation for a single form of driver
@@ -154,7 +154,7 @@ namespace driver {
     /// If the option accepts the current argument, accept() sets
     /// Index to the position where argument parsing should resume
     /// (even if the argument is missing values).
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const = 0;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const = 0;
 
     void dump() const;
 
@@ -167,7 +167,7 @@ namespace driver {
   public:
     OptionGroup(OptSpecifier ID, const char *Name, const OptionGroup *Group);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::GroupClass;
@@ -182,7 +182,7 @@ namespace driver {
   public:
     InputOption(OptSpecifier ID);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::InputClass;
@@ -195,7 +195,7 @@ namespace driver {
   public:
     UnknownOption(OptSpecifier ID);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::UnknownClass;
@@ -210,7 +210,7 @@ namespace driver {
     FlagOption(OptSpecifier ID, const char *Name, const OptionGroup *Group,
                const Option *Alias);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::FlagClass;
@@ -223,7 +223,7 @@ namespace driver {
     JoinedOption(OptSpecifier ID, const char *Name, const OptionGroup *Group,
                  const Option *Alias);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::JoinedClass;
@@ -236,7 +236,7 @@ namespace driver {
     SeparateOption(OptSpecifier ID, const char *Name,
                    const OptionGroup *Group, const Option *Alias);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::SeparateClass;
@@ -249,7 +249,7 @@ namespace driver {
     CommaJoinedOption(OptSpecifier ID, const char *Name,
                       const OptionGroup *Group, const Option *Alias);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::CommaJoinedClass;
@@ -270,7 +270,7 @@ namespace driver {
 
     unsigned getNumArgs() const { return NumArgs; }
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::MultiArgClass;
@@ -285,7 +285,7 @@ namespace driver {
     JoinedOrSeparateOption(OptSpecifier ID, const char *Name,
                            const OptionGroup *Group, const Option *Alias);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::JoinedOrSeparateClass;
@@ -300,7 +300,7 @@ namespace driver {
     JoinedAndSeparateOption(OptSpecifier ID, const char *Name,
                             const OptionGroup *Group, const Option *Alias);
 
-    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
+    virtual Arg *accept(const ArgList &Args, unsigned &Index) const;
 
     static bool classof(const Option *O) {
       return O->getKind() == Option::JoinedAndSeparateClass;
index cc9820e1e74fe32c3ceb679e9f45113ce0d0b254..618ba8e9964e158f2ec779007913de2a0627e27e 100644 (file)
@@ -182,7 +182,7 @@ Option *OptTable::CreateOption(unsigned id) const {
   return Opt;
 }
 
-Arg *OptTable::ParseOneArg(const InputArgList &Args, unsigned &Index) const {
+Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index) const {
   unsigned Prev = Index;
   const char *Str = Args.getArgString(Index);
 
index 26b30de17d98becb8b0c04d7307bec66e0bd55fc..dd48af8018ac455e2f207d69b93b73f153de7d85 100644 (file)
@@ -113,7 +113,7 @@ OptionGroup::OptionGroup(OptSpecifier ID, const char *Name,
   : Option(Option::GroupClass, ID, Name, Group, 0) {
 }
 
-Arg *OptionGroup::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *OptionGroup::accept(const ArgList &Args, unsigned &Index) const {
   assert(0 && "accept() should never be called on an OptionGroup");
   return 0;
 }
@@ -122,7 +122,7 @@ InputOption::InputOption(OptSpecifier ID)
   : Option(Option::InputClass, ID, "<input>", 0, 0) {
 }
 
-Arg *InputOption::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *InputOption::accept(const ArgList &Args, unsigned &Index) const {
   assert(0 && "accept() should never be called on an InputOption");
   return 0;
 }
@@ -131,7 +131,7 @@ UnknownOption::UnknownOption(OptSpecifier ID)
   : Option(Option::UnknownClass, ID, "<unknown>", 0, 0) {
 }
 
-Arg *UnknownOption::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *UnknownOption::accept(const ArgList &Args, unsigned &Index) const {
   assert(0 && "accept() should never be called on an UnknownOption");
   return 0;
 }
@@ -141,7 +141,7 @@ FlagOption::FlagOption(OptSpecifier ID, const char *Name,
   : Option(Option::FlagClass, ID, Name, Group, Alias) {
 }
 
-Arg *FlagOption::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *FlagOption::accept(const ArgList &Args, unsigned &Index) const {
   // Matches iff this is an exact match.
   // FIXME: Avoid strlen.
   if (strlen(getName()) != strlen(Args.getArgString(Index)))
@@ -155,7 +155,7 @@ JoinedOption::JoinedOption(OptSpecifier ID, const char *Name,
   : Option(Option::JoinedClass, ID, Name, Group, Alias) {
 }
 
-Arg *JoinedOption::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *JoinedOption::accept(const ArgList &Args, unsigned &Index) const {
   // Always matches.
   const char *Value = Args.getArgString(Index) + strlen(getName());
   return new Arg(getUnaliasedOption(), Index++, Value);
@@ -167,7 +167,7 @@ CommaJoinedOption::CommaJoinedOption(OptSpecifier ID, const char *Name,
   : Option(Option::CommaJoinedClass, ID, Name, Group, Alias) {
 }
 
-Arg *CommaJoinedOption::accept(const InputArgList &Args,
+Arg *CommaJoinedOption::accept(const ArgList &Args,
                                unsigned &Index) const {
   // Always matches.
   const char *Str = Args.getArgString(Index) + strlen(getName());
@@ -202,7 +202,7 @@ SeparateOption::SeparateOption(OptSpecifier ID, const char *Name,
   : Option(Option::SeparateClass, ID, Name, Group, Alias) {
 }
 
-Arg *SeparateOption::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *SeparateOption::accept(const ArgList &Args, unsigned &Index) const {
   // Matches iff this is an exact match.
   // FIXME: Avoid strlen.
   if (strlen(getName()) != strlen(Args.getArgString(Index)))
@@ -222,7 +222,7 @@ MultiArgOption::MultiArgOption(OptSpecifier ID, const char *Name,
   assert(NumArgs > 1  && "Invalid MultiArgOption!");
 }
 
-Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const {
+Arg *MultiArgOption::accept(const ArgList &Args, unsigned &Index) const {
   // Matches iff this is an exact match.
   // FIXME: Avoid strlen.
   if (strlen(getName()) != strlen(Args.getArgString(Index)))
@@ -246,7 +246,7 @@ JoinedOrSeparateOption::JoinedOrSeparateOption(OptSpecifier ID,
   : Option(Option::JoinedOrSeparateClass, ID, Name, Group, Alias) {
 }
 
-Arg *JoinedOrSeparateOption::accept(const InputArgList &Args,
+Arg *JoinedOrSeparateOption::accept(const ArgList &Args,
                                     unsigned &Index) const {
   // If this is not an exact match, it is a joined arg.
   // FIXME: Avoid strlen.
@@ -270,7 +270,7 @@ JoinedAndSeparateOption::JoinedAndSeparateOption(OptSpecifier ID,
   : Option(Option::JoinedAndSeparateClass, ID, Name, Group, Alias) {
 }
 
-Arg *JoinedAndSeparateOption::accept(const InputArgList &Args,
+Arg *JoinedAndSeparateOption::accept(const ArgList &Args,
                                      unsigned &Index) const {
   // Always matches.