zcov: / include/clang/Driver/Action.h


Files: 1 Branches Taken: 26.3% 5 / 19
Generated: 2010-02-10 01:31 Branches Executed: 47.4% 9 / 19
Line Coverage: 95.5% 42 / 44


Programs: 8 Runs 12072


       1                 : //===--- Action.h - Abstract compilation steps ------------------*- C++ -*-===//
       2                 : //
       3                 : //                     The LLVM Compiler Infrastructure
       4                 : //
       5                 : // This file is distributed under the University of Illinois Open Source
       6                 : // License. See LICENSE.TXT for details.
       7                 : //
       8                 : //===----------------------------------------------------------------------===//
       9                 : 
      10                 : #ifndef CLANG_DRIVER_ACTION_H_
      11                 : #define CLANG_DRIVER_ACTION_H_
      12                 : 
      13                 : #include "llvm/ADT/SmallVector.h"
      14                 : 
      15                 : #include "clang/Driver/Types.h"
      16                 : #include "clang/Driver/Util.h"
      17                 : 
      18                 : #include "llvm/Support/Casting.h"
      19                 : using llvm::isa;
      20                 : using llvm::cast;
      21                 : using llvm::cast_or_null;
      22                 : using llvm::dyn_cast;
      23                 : using llvm::dyn_cast_or_null;
      24                 : 
      25                 : namespace clang {
      26                 : namespace driver {
      27                 :   class Arg;
      28                 : 
      29                 : /// Action - Represent an abstract compilation step to perform.
      30                 : ///
      31                 : /// An action represents an edge in the compilation graph; typically
      32                 : /// it is a job to transform an input using some tool.
      33                 : ///
      34                 : /// The current driver is hard wired to expect actions which produce a
      35                 : /// single primary output, at least in terms of controlling the
      36                 : /// compilation. Actions can produce auxiliary files, but can only
      37                 : /// produce a single output to feed into subsequent actions.
      38                 : class Action {
      39                 : public:
      40                 :   typedef ActionList::size_type size_type;
      41                 :   typedef ActionList::iterator iterator;
      42                 :   typedef ActionList::const_iterator const_iterator;
      43                 : 
      44                 :   enum ActionClass {
      45                 :     InputClass = 0,
      46                 :     BindArchClass,
      47                 :     PreprocessJobClass,
      48                 :     PrecompileJobClass,
      49                 :     AnalyzeJobClass,
      50                 :     CompileJobClass,
      51                 :     AssembleJobClass,
      52                 :     LinkJobClass,
      53                 :     LipoJobClass,
      54                 : 
      55                 :     JobClassFirst=PreprocessJobClass,
      56                 :     JobClassLast=LipoJobClass
      57                 :   };
      58                 : 
      59                 :   static const char *getClassName(ActionClass AC);
      60                 : 
      61                 : private:
      62                 :   ActionClass Kind;
      63                 : 
      64                 :   /// The output type of this action.
      65                 :   types::ID Type;
      66                 : 
      67                 :   ActionList Inputs;
      68                 : 
      69                 : protected:
      70              241:   Action(ActionClass _Kind, types::ID _Type) : Kind(_Kind), Type(_Type) {}
      71              484:   Action(ActionClass _Kind, Action *Input, types::ID _Type)
      72              484:     : Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1) {}
      73               35:   Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
      74               35:     : Kind(_Kind), Type(_Type), Inputs(_Inputs) {}
      75                 : public:
      76                 :   virtual ~Action();
      77                 : 
      78                0:   const char *getClassName() const { return Action::getClassName(getKind()); }
      79                 : 
      80             4357:   ActionClass getKind() const { return Kind; }
      81             2571:   types::ID getType() const { return Type; }
      82                 : 
      83              152:   ActionList &getInputs() { return Inputs; }
      84              263:   const ActionList &getInputs() const { return Inputs; }
      85                 : 
      86              250:   size_type size() const { return Inputs.size(); }
      87                 : 
      88               59:   iterator begin() { return Inputs.begin(); }
      89               50:   iterator end() { return Inputs.end(); }
      90              301:   const_iterator begin() const { return Inputs.begin(); }
      91                 :   const_iterator end() const { return Inputs.end(); }
      92                 : 
      93                 :   static bool classof(const Action *) { return true; }
      94                 : };
      95                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
                        0: branch 5 not taken
                        0: branch 6 not taken
      96                0: class InputAction : public Action {
      97                 :   const Arg &Input;
      98                 : public:
      99                 :   InputAction(const Arg &_Input, types::ID _Type);
     100                 : 
     101              243:   const Arg &getInputArg() const { return Input; }
     102                 : 
     103              861:   static bool classof(const Action *A) {
     104              861:     return A->getKind() == InputClass;
     105                 :   }
     106                 :   static bool classof(const InputAction *) { return true; }
     107                 : };
     108                 : 
                       54: branch 1 taken
                        0: branch 2 not taken
                        0: branch 5 not taken
                        0: branch 6 not taken
     109               54: class BindArchAction : public Action {
     110                 :   /// The architecture to bind, or 0 if the default architecture
     111                 :   /// should be bound.
     112                 :   const char *ArchName;
     113                 : 
     114                 : public:
     115                 :   BindArchAction(Action *Input, const char *_ArchName);
     116                 : 
     117              136:   const char *getArchName() const { return ArchName; }
     118                 : 
     119              437:   static bool classof(const Action *A) {
     120              437:     return A->getKind() == BindArchClass;
     121                 :   }
     122                 :   static bool classof(const BindArchAction *) { return true; }
     123                 : };
     124                 : 
                        0: branch 1 not taken
                      181: branch 2 taken
                        0: branch 5 not taken
                        0: branch 6 not taken
                        0: branch 9 not taken
                        0: branch 10 not taken
     125              181: class JobAction : public Action {
     126                 : protected:
     127                 :   JobAction(ActionClass Kind, Action *Input, types::ID Type);
     128                 :   JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
     129                 : 
     130                 : public:
     131              263:   static bool classof(const Action *A) {
     132                 :     return (A->getKind() >= JobClassFirst &&
                      263: branch 1 taken
                        0: branch 2 not taken
                      263: branch 4 taken
                        0: branch 5 not taken
     133              263:             A->getKind() <= JobClassLast);
     134                 :   }
     135                 :   static bool classof(const JobAction *) { return true; }
     136                 : };
     137                 : 
                       29: branch 1 taken
     138               29: class PreprocessJobAction : public JobAction {
     139                 : public:
     140                 :   PreprocessJobAction(Action *Input, types::ID OutputType);
     141                 : 
     142              840:   static bool classof(const Action *A) {
     143              840:     return A->getKind() == PreprocessJobClass;
     144                 :   }
     145                 :   static bool classof(const PreprocessJobAction *) { return true; }
     146                 : };
     147                 : 
     148                6: class PrecompileJobAction : public JobAction {
     149                 : public:
     150                 :   PrecompileJobAction(Action *Input, types::ID OutputType);
     151                 : 
     152              504:   static bool classof(const Action *A) {
     153              504:     return A->getKind() == PrecompileJobClass;
     154                 :   }
     155                 :   static bool classof(const PrecompileJobAction *) { return true; }
     156                 : };
     157                 : 
     158                1: class AnalyzeJobAction : public JobAction {
     159                 : public:
     160                 :   AnalyzeJobAction(Action *Input, types::ID OutputType);
     161                 : 
     162              381:   static bool classof(const Action *A) {
     163              381:     return A->getKind() == AnalyzeJobClass;
     164                 :   }
     165                 :   static bool classof(const AnalyzeJobAction *) { return true; }
     166                 : };
     167                 : 
     168              121: class CompileJobAction : public JobAction {
     169                 : public:
     170                 :   CompileJobAction(Action *Input, types::ID OutputType);
     171                 : 
     172              297:   static bool classof(const Action *A) {
     173              297:     return A->getKind() == CompileJobClass;
     174                 :   }
     175                 :   static bool classof(const CompileJobAction *) { return true; }
     176                 : };
     177                 : 
     178                7: class AssembleJobAction : public JobAction {
     179                 : public:
     180                 :   AssembleJobAction(Action *Input, types::ID OutputType);
     181                 : 
     182              143:   static bool classof(const Action *A) {
     183              143:     return A->getKind() == AssembleJobClass;
     184                 :   }
     185                 :   static bool classof(const AssembleJobAction *) { return true; }
     186                 : };
     187                 : 
     188               13: class LinkJobAction : public JobAction {
     189                 : public:
     190                 :   LinkJobAction(ActionList &Inputs, types::ID Type);
     191                 : 
     192                 :   static bool classof(const Action *A) {
     193                 :     return A->getKind() == LinkJobClass;
     194                 :   }
     195                 :   static bool classof(const LinkJobAction *) { return true; }
     196                 : };
     197                 : 
     198                4: class LipoJobAction : public JobAction {
     199                 : public:
     200                 :   LipoJobAction(ActionList &Inputs, types::ID Type);
     201                 : 
     202              218:   static bool classof(const Action *A) {
     203              218:     return A->getKind() == LipoJobClass;
     204                 :   }
     205                 :   static bool classof(const LipoJobAction *) { return true; }
     206                 : };
     207                 : 
     208                 : } // end namespace driver
     209                 : } // end namespace clang
     210                 : 
     211                 : #endif

Generated: 2010-02-10 01:31 by zcov