]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/CodeGen/ModuleBuilder.h
Update clang to trunk r290819 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / CodeGen / ModuleBuilder.h
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
19 namespace llvm {
20   class Constant;
21   class LLVMContext;
22   class Module;
23   class StringRef;
24 }
25
26 namespace clang {
27   class CodeGenOptions;
28   class CoverageSourceInfo;
29   class Decl;
30   class DiagnosticsEngine;
31   class GlobalDecl;
32   class HeaderSearchOptions;
33   class LangOptions;
34   class PreprocessorOptions;
35
36 namespace CodeGen {
37   class CodeGenModule;
38 }
39
40 /// The primary public interface to the Clang code generator.
41 ///
42 /// This is not really an abstract interface.
43 class CodeGenerator : public ASTConsumer {
44   virtual void anchor();
45
46 public:
47   /// Return an opaque reference to the CodeGenModule object, which can
48   /// be used in various secondary APIs.  It is valid as long as the
49   /// CodeGenerator exists.
50   CodeGen::CodeGenModule &CGM();
51
52   /// Return the module that this code generator is building into.
53   ///
54   /// This may return null after HandleTranslationUnit is called;
55   /// this signifies that there was an error generating code.  A
56   /// diagnostic will have been generated in this case, and the module
57   /// will be deleted.
58   ///
59   /// It will also return null if the module is released.
60   llvm::Module *GetModule();
61
62   /// Release ownership of the module to the caller.
63   ///
64   /// It is illegal to call methods other than GetModule on the
65   /// CodeGenerator after releasing its module.
66   llvm::Module *ReleaseModule();
67
68   /// Given a mangled name, return a declaration which mangles that way
69   /// which has been added to this code generator via a Handle method.
70   ///
71   /// This may return null if there was no matching declaration.
72   const Decl *GetDeclForMangledName(llvm::StringRef MangledName);
73
74   /// Return the LLVM address of the given global entity.
75   ///
76   /// \param isForDefinition If true, the caller intends to define the
77   ///   entity; the object returned will be an llvm::GlobalValue of
78   ///   some sort.  If false, the caller just intends to use the entity;
79   ///   the object returned may be any sort of constant value, and the
80   ///   code generator will schedule the entity for emission if a
81   ///   definition has been registered with this code generator.
82   llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition);
83 };
84
85 /// CreateLLVMCodeGen - Create a CodeGenerator instance.
86 /// It is the responsibility of the caller to call delete on
87 /// the allocated CodeGenerator instance.
88 CodeGenerator *CreateLLVMCodeGen(DiagnosticsEngine &Diags,
89                                  llvm::StringRef ModuleName,
90                                  const HeaderSearchOptions &HeaderSearchOpts,
91                                  const PreprocessorOptions &PreprocessorOpts,
92                                  const CodeGenOptions &CGO,
93                                  llvm::LLVMContext& C,
94                                  CoverageSourceInfo *CoverageInfo = nullptr);
95
96 } // end namespace clang
97
98 #endif