Add methods to StringMap to erase entries by key.
[oota-llvm.git] / tools / llvmc2 / Tool.h
1 //===--- Tool.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
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringSet.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   typedef llvm::StringSet<> InputLanguagesSet;
30
31   /// Tool - A class
32   class Tool : public llvm::RefCountedBaseVPTR<Tool> {
33   public:
34
35     virtual ~Tool() {}
36
37     virtual Action GenerateAction (const PathVector& inFiles,
38                                    const llvm::sys::Path& outFile,
39                                    const InputLanguagesSet& InLangs) const = 0;
40
41     virtual Action GenerateAction (const llvm::sys::Path& inFile,
42                                    const llvm::sys::Path& outFile,
43                                    const InputLanguagesSet& InLangs) const = 0;
44
45     virtual const char*  Name() const = 0;
46     virtual const char** InputLanguages() const = 0;
47     virtual const char*  OutputLanguage() const = 0;
48     virtual const char*  OutputSuffix() const = 0;
49
50     virtual bool IsLast() const = 0;
51     virtual bool IsJoin() const = 0;
52   };
53
54   /// JoinTool - A Tool that has an associated input file list.
55   class JoinTool : public Tool {
56   public:
57     void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
58     void ClearJoinList() { JoinList_.clear(); }
59     bool JoinListEmpty() const { return JoinList_.empty(); }
60
61     Action GenerateAction(const llvm::sys::Path& outFile,
62                           const InputLanguagesSet& InLangs) const {
63       return GenerateAction(JoinList_, outFile, InLangs);
64     }
65     // We shouldn't shadow base class's version of GenerateAction.
66     using Tool::GenerateAction;
67
68   private:
69     PathVector JoinList_;
70   };
71
72 }
73
74 #endif //LLVM_TOOLS_LLVMC2_TOOL_H