-
-
Save MaliusArth/876db831fca43288bfa6fb78ab6921df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "clang/Tooling/CommonOptionsParser.h" | |
#include "clang/Tooling/Tooling.h" | |
// Declares llvm::cl:extrahelp. | |
#include "llvm/Support/Signals.h" | |
#include "llvm/Support/PrettyStackTrace.h" | |
#include "llvm/Support/Process.h" | |
#include "llvm/Support/CommandLine.h" | |
#include "clang/Frontend/ASTUnit.h" | |
#include "clang/Basic/FileManager.h" | |
#include "clang/Basic/FileSystemOptions.h" | |
#include "clang/Basic/DiagnosticOptions.h" | |
#include "clang/CodeGen/CGFunctionInfo.h" | |
#include "clang/CodeGen/CodeGenAction.h" | |
#include "llvm/ADT/ArrayRef.h" | |
#include "llvm/ADT/SmallString.h" | |
#include "llvm/ADT/StringRef.h" | |
#include "llvm/ExecutionEngine/ExecutionEngine.h" | |
#include "llvm/ExecutionEngine/GenericValue.h" | |
#include "llvm/IR/Argument.h" | |
#include "llvm/IR/BasicBlock.h" | |
#include "llvm/IR/IRBuilder.h" | |
#include "llvm/IR/LLVMContext.h" | |
#include "llvm/IR/Module.h" | |
#include "llvm/Support/TargetSelect.h" | |
#include "llvm/Target/TargetMachine.h" | |
#include "llvm/Support/MemoryBuffer.h" | |
#include "llvm/Support/Error.h" | |
#include "llvm/Support/FileSystem.h" | |
// System #includes | |
#include <cassert> | |
#include <memory> | |
#include <string> | |
namespace | |
{ | |
// CommonOptionsParser declares HelpMessage with a description of the common | |
// command-line options related to the compilation database and input files. | |
// It's nice to have this help message in all tools. | |
static llvm::cl::extrahelp | |
commonHelp(clang::tooling::CommonOptionsParser::HelpMessage); | |
static llvm::cl::OptionCategory coolCategory("cool Options"); | |
} // namespace | |
#define DEBUG_TYPE "CoolTool" | |
int main(int argc_, const char **argv_) | |
{ | |
::llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. | |
::clang::tooling::CommonOptionsParser optionsParser(argc_, argv_, coolCategory); | |
::clang::tooling::ClangTool tool(optionsParser.getCompilations(), | |
optionsParser.getSourcePathList()); | |
std::unique_ptr<clang::tooling::FrontendActionFactory> llvm_only_action_factory = | |
clang::tooling::newFrontendActionFactory<clang::EmitLLVMOnlyAction>(); | |
auto llvm_only_action_result = tool.run(llvm_only_action_factory.get()); | |
return llvm_only_action_result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment