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


Files: 1 Branches Taken: 8.3% 1 / 12
Generated: 2010-02-10 01:31 Branches Executed: 16.7% 2 / 12
Line Coverage: 91.3% 21 / 23


Programs: 8 Runs 12072


       1                 : //===--- Job.h - Commands to Execute ----------------------------*- 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_JOB_H_
      11                 : #define CLANG_DRIVER_JOB_H_
      12                 : 
      13                 : #include "clang/Driver/Util.h"
      14                 : #include "llvm/ADT/SmallVector.h"
      15                 : 
      16                 : #include "llvm/Support/Casting.h"
      17                 : using llvm::isa;
      18                 : using llvm::cast;
      19                 : using llvm::cast_or_null;
      20                 : using llvm::dyn_cast;
      21                 : using llvm::dyn_cast_or_null;
      22                 : 
      23                 : namespace clang {
      24                 : namespace driver {
      25                 : class Command;
      26                 : class Tool;
      27                 : 
      28                 : class Job {
      29                 : public:
      30                 :   enum JobClass {
      31                 :     CommandClass,
      32                 :     PipedJobClass,
      33                 :     JobListClass
      34                 :   };
      35                 : 
      36                 : private:
      37                 :   JobClass Kind;
      38                 : 
      39                 : protected:
      40              498:   Job(JobClass _Kind) : Kind(_Kind) {}
      41                 : public:
      42                 :   virtual ~Job();
      43                 : 
      44             1696:   JobClass getKind() const { return Kind; }
      45                 : 
      46                 :   /// addCommand - Append a command to the current job, which must be
      47                 :   /// either a piped job or a job list.
      48                 :   void addCommand(Command *C);
      49                 : 
      50                 :   static bool classof(const Job *) { return true; }
      51                 : };
      52                 : 
      53                 :   /// Command - An executable path/name and argument vector to
      54                 :   /// execute.
                        0: branch 2 not taken
                        0: branch 3 not taken
                        0: branch 7 not taken
                        0: branch 8 not taken
      55                0: class Command : public Job {
      56                 :   /// Source - The action which caused the creation of this job.
      57                 :   const Action &Source;
      58                 : 
      59                 :   /// Tool - The tool which caused the creation of this job.
      60                 :   const Tool &Creator;
      61                 : 
      62                 :   /// The executable to run.
      63                 :   const char *Executable;
      64                 : 
      65                 :   /// The list of program arguments (not including the implicit first
      66                 :   /// argument, which will be the executable).
      67                 :   ArgStringList Arguments;
      68                 : 
      69                 : public:
      70                 :   Command(const Action &_Source, const Tool &_Creator, const char *_Executable,
      71                 :           const ArgStringList &_Arguments);
      72                 : 
      73                 :   /// getSource - Return the Action which caused the creation of this job.
      74                5:   const Action &getSource() const { return Source; }
      75                 : 
      76                 :   /// getCreator - Return the Tool which caused the creation of this job.
      77                9:   const Tool &getCreator() const { return Creator; }
      78                 : 
      79              372:   const char *getExecutable() const { return Executable; }
      80                 : 
      81              753:   const ArgStringList &getArguments() const { return Arguments; }
      82                 : 
      83              701:   static bool classof(const Job *J) {
      84              701:     return J->getKind() == CommandClass;
      85                 :   }
      86                 :   static bool classof(const Command *) { return true; }
      87                 : };
      88                 : 
      89                 :   /// PipedJob - A list of Commands which should be executed together
      90                 :   /// with their standard inputs and outputs connected.
                        0: branch 2 not taken
                        0: branch 3 not taken
                        0: branch 7 not taken
                        0: branch 8 not taken
      91                0: class PipedJob : public Job {
      92                 : public:
      93                 :   typedef llvm::SmallVector<Command*, 4> list_type;
      94                 :   typedef list_type::size_type size_type;
      95                 :   typedef list_type::iterator iterator;
      96                 :   typedef list_type::const_iterator const_iterator;
      97                 : 
      98                 : private:
      99                 :   list_type Commands;
     100                 : 
     101                 : public:
     102                 :   PipedJob();
     103                 : 
     104               12:   void addCommand(Command *C) { Commands.push_back(C); }
     105                 : 
     106                 :   const list_type &getCommands() const { return Commands; }
     107                 : 
     108               10:   size_type size() const { return Commands.size(); }
     109                 :   iterator begin() { return Commands.begin(); }
     110               12:   const_iterator begin() const { return Commands.begin(); }
     111                 :   iterator end() { return Commands.end(); }
     112                4:   const_iterator end() const { return Commands.end(); }
     113                 : 
     114              523:   static bool classof(const Job *J) {
     115              523:     return J->getKind() == PipedJobClass;
     116                 :   }
     117                 :   static bool classof(const PipedJob *) { return true; }
     118                 : };
     119                 : 
     120                 :   /// JobList - A sequence of jobs to perform.
                        0: branch 2 not taken
                      248: branch 3 taken
                        0: branch 7 not taken
                        0: branch 8 not taken
     121              248: class JobList : public Job {
     122                 : public:
     123                 :   typedef llvm::SmallVector<Job*, 4> list_type;
     124                 :   typedef list_type::size_type size_type;
     125                 :   typedef list_type::iterator iterator;
     126                 :   typedef list_type::const_iterator const_iterator;
     127                 : 
     128                 : private:
     129                 :   list_type Jobs;
     130                 : 
     131                 : public:
     132                 :   JobList();
     133                 : 
     134              237:   void addJob(Job *J) { Jobs.push_back(J); }
     135                 : 
     136                 :   const list_type &getJobs() const { return Jobs; }
     137                 : 
     138                9:   size_type size() const { return Jobs.size(); }
     139                 :   iterator begin() { return Jobs.begin(); }
     140              253:   const_iterator begin() const { return Jobs.begin(); }
     141                 :   iterator end() { return Jobs.end(); }
     142              235:   const_iterator end() const { return Jobs.end(); }
     143                 : 
     144              472:   static bool classof(const Job *J) {
     145              472:     return J->getKind() == JobListClass;
     146                 :   }
     147                 :   static bool classof(const JobList *) { return true; }
     148                 : };
     149                 : 
     150                 : } // end namespace driver
     151                 : } // end namespace clang
     152                 : 
     153                 : #endif

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