#ifndef LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
#define LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
#include "llvm/CompilerDriver/Action.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Path.h"
#include <string>
#include <vector>
#include <utility>
namespace llvmc {
class LanguageMap;
typedef std::vector<std::pair<unsigned, std::string> > ArgsVector;
typedef std::vector<llvm::sys::Path> PathVector;
typedef std::vector<std::string> StrVector;
typedef llvm::StringSet<> InputLanguagesSet;
class Tool : public llvm::RefCountedBaseVPTR {
public:
virtual ~Tool() {}
virtual int GenerateAction (Action& Out,
const PathVector& inFiles,
const bool HasChildren,
const llvm::sys::Path& TempDir,
const InputLanguagesSet& InLangs,
const LanguageMap& LangMap) const = 0;
virtual int GenerateAction (Action& Out,
const llvm::sys::Path& inFile,
const bool HasChildren,
const llvm::sys::Path& TempDir,
const InputLanguagesSet& InLangs,
const LanguageMap& LangMap) const = 0;
virtual const char* Name() const = 0;
virtual const char** InputLanguages() const = 0;
virtual const char** OutputLanguages() const = 0;
virtual bool IsJoin() const = 0;
virtual bool WorksOnEmpty() const = 0;
protected:
llvm::sys::Path OutFilename(const llvm::sys::Path& In,
const llvm::sys::Path& TempDir,
bool StopCompilation,
const char* OutputSuffix) const;
StrVector SortArgs(ArgsVector& Args) const;
};
class JoinTool : public Tool {
public:
void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
void ClearJoinList() { JoinList_.clear(); }
bool JoinListEmpty() const { return JoinList_.empty(); }
int GenerateAction(Action& Out,
const bool HasChildren,
const llvm::sys::Path& TempDir,
const InputLanguagesSet& InLangs,
const LanguageMap& LangMap) const {
return GenerateAction(Out, JoinList_, HasChildren, TempDir, InLangs,
LangMap);
}
using Tool::GenerateAction;
private:
PathVector JoinList_;
};
}
#endif // LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H