1 //===--- Tools.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
18 #include "StringSet.h"
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include "llvm/System/Path.h"
28 typedef std::vector<llvm::sys::Path> PathVector;
31 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
36 virtual Action GenerateAction (const PathVector& inFiles,
37 const llvm::sys::Path& outFile,
38 const StringSet<>& InLangs) const = 0;
40 virtual Action GenerateAction (const llvm::sys::Path& inFile,
41 const llvm::sys::Path& outFile,
42 const StringSet<>& InLangs) const = 0;
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;
49 virtual bool IsLast() const = 0;
50 virtual bool IsJoin() const = 0;
53 /// JoinTool - A Tool that has an associated input file list.
54 class JoinTool : public Tool {
56 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
57 void ClearJoinList() { JoinList_.clear(); }
58 bool JoinListEmpty() const { return JoinList_.empty(); }
60 Action GenerateAction(const llvm::sys::Path& outFile,
61 const StringSet<>& InLangs) const {
62 return GenerateAction(JoinList_, outFile, InLangs);
64 // We shouldn't shadow base class's version of GenerateAction.
65 using Tool::GenerateAction;
73 #endif //LLVM_TOOLS_LLVMC2_TOOL_H