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
17 #include "llvm/CompilerDriver/Action.h"
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringSet.h"
21 #include "llvm/System/Path.h"
29 typedef std::vector<llvm::sys::Path> PathVector;
30 typedef llvm::StringSet<> InputLanguagesSet;
33 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
38 virtual Action GenerateAction (const PathVector& inFiles,
40 const llvm::sys::Path& TempDir,
41 const InputLanguagesSet& InLangs,
42 const LanguageMap& LangMap) const = 0;
44 virtual Action GenerateAction (const llvm::sys::Path& inFile,
46 const llvm::sys::Path& TempDir,
47 const InputLanguagesSet& InLangs,
48 const LanguageMap& LangMap) const = 0;
50 virtual const char* Name() const = 0;
51 virtual const char** InputLanguages() const = 0;
52 virtual const char* OutputLanguage() const = 0;
54 virtual bool IsJoin() const = 0;
57 /// OutFileName - Generate the output file name.
58 llvm::sys::Path OutFilename(const llvm::sys::Path& In,
59 const llvm::sys::Path& TempDir,
61 const char* OutputSuffix) const;
64 /// JoinTool - A Tool that has an associated input file list.
65 class JoinTool : public Tool {
67 void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
68 void ClearJoinList() { JoinList_.clear(); }
69 bool JoinListEmpty() const { return JoinList_.empty(); }
71 Action GenerateAction(bool HasChildren,
72 const llvm::sys::Path& TempDir,
73 const InputLanguagesSet& InLangs,
74 const LanguageMap& LangMap) const {
75 return GenerateAction(JoinList_, HasChildren, TempDir, InLangs, LangMap);
77 // We shouldn't shadow base class's version of GenerateAction.
78 using Tool::GenerateAction;
86 #endif //LLVM_TOOLS_LLVMC2_TOOL_H