Make it possible to use the generalised 'case' construct in the cmd_line property.
[oota-llvm.git] / tools / llvmc2 / Tool.h
1 //===--- Tools.h - The LLVM Compiler Driver ---------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Tool abstract base class - an interface to tool descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TOOLS_LLVMC2_TOOL_H
15 #define LLVM_TOOLS_LLVMC2_TOOL_H
16
17 #include "Action.h"
18 #include "StringSet.h"
19
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include "llvm/System/Path.h"
22
23 #include <string>
24 #include <vector>
25
26 namespace llvmc {
27
28   typedef std::vector<llvm::sys::Path> PathVector;
29
30   /// Tool - A class
31   class Tool : public llvm::RefCountedBaseVPTR<Tool> {
32   public:
33
34     virtual ~Tool() {}
35
36     virtual Action GenerateAction (const PathVector& inFiles,
37                                    const llvm::sys::Path& outFile,
38                                    const StringSet<>& InLangs) const = 0;
39
40     virtual Action GenerateAction (const llvm::sys::Path& inFile,
41                                    const llvm::sys::Path& outFile,
42                                    const StringSet<>& InLangs) const = 0;
43
44     virtual const char* Name() const = 0;
45     virtual const char* InputLanguage() const = 0;
46     virtual const char* OutputLanguage() const = 0;
47     virtual const char* OutputSuffix() const = 0;
48
49     virtual bool IsLast() const = 0;
50     virtual bool IsJoin() const = 0;
51   };
52
53   /// JoinTool - A Tool that has an associated input file list.
54   class JoinTool : public Tool {
55   public:
56     void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
57     void ClearJoinList() { JoinList_.clear(); }
58     bool JoinListEmpty() const { return JoinList_.empty(); }
59
60     Action GenerateAction(const llvm::sys::Path& outFile,
61                           const StringSet<>& InLangs) const {
62       return GenerateAction(JoinList_, outFile, InLangs);
63     }
64     // We shouldn't shadow base class's version of GenerateAction.
65     using Tool::GenerateAction;
66
67   private:
68     PathVector JoinList_;
69   };
70
71 }
72
73 #endif //LLVM_TOOLS_LLVMC2_TOOL_H