1 //===--- CodeGen/ModuleBuilder.h - Build LLVM from ASTs ---------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file defines the ModuleBuilder interface. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_CODEGEN_MODULEBUILDER_H 15 #define LLVM_CLANG_CODEGEN_MODULEBUILDER_H 16 17 #include "clang/AST/ASTConsumer.h" 18 #include <string> 19 20 namespace llvm { 21 class LLVMContext; 22 class Module; 23 } 24 25 namespace clang { 26 class DiagnosticsEngine; 27 class CoverageSourceInfo; 28 class LangOptions; 29 class HeaderSearchOptions; 30 class PreprocessorOptions; 31 class CodeGenOptions; 32 class Decl; 33 34 class CodeGenerator : public ASTConsumer { 35 virtual void anchor(); 36 public: 37 virtual llvm::Module* GetModule() = 0; 38 virtual llvm::Module* ReleaseModule() = 0; 39 virtual const Decl *GetDeclForMangledName(llvm::StringRef MangledName) = 0; 40 }; 41 42 /// CreateLLVMCodeGen - Create a CodeGenerator instance. 43 /// It is the responsibility of the caller to call delete on 44 /// the allocated CodeGenerator instance. 45 CodeGenerator *CreateLLVMCodeGen(DiagnosticsEngine &Diags, 46 const std::string &ModuleName, 47 const HeaderSearchOptions &HeaderSearchOpts, 48 const PreprocessorOptions &PreprocessorOpts, 49 const CodeGenOptions &CGO, 50 llvm::LLVMContext& C, 51 CoverageSourceInfo *CoverageInfo = nullptr); 52 } 53 54 #endif 55