1 //===--- Tool.h - The LLVM Compiler Driver ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Tool abstract base class - an interface to tool descriptions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_LLVMC2_TOOL_H
15 #define LLVM_TOOLS_LLVMC2_TOOL_H
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/System/Path.h"
28 typedef std::vector<llvm::sys::Path> PathVector;
29 typedef llvm::StringSet<> InputLanguagesSet;
32 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
37 virtual Action GenerateAction (const PathVector& inFiles,
38 const llvm::sys::Path& outFile,
39 const InputLanguagesSet& InLangs) const = 0;
41 virtual Action GenerateAction (const llvm::sys::Path& inFile,
42 const llvm::sys::Path& outFile,
43 const InputLanguagesSet& InLangs) const = 0;
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;
50 virtual bool IsLast() const = 0;
51 virtual bool IsJoin() const = 0;
54 /// JoinTool - A Tool that has an associated input file list.
55 class JoinTool : public Tool {
57 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
58 void ClearJoinList() { JoinList_.clear(); }
59 bool JoinListEmpty() const { return JoinList_.empty(); }
61 Action GenerateAction(const llvm::sys::Path& outFile,
62 const InputLanguagesSet& InLangs) const {
63 return GenerateAction(JoinList_, outFile, InLangs);
65 // We shouldn't shadow base class's version of GenerateAction.
66 using Tool::GenerateAction;
74 #endif //LLVM_TOOLS_LLVMC2_TOOL_H