Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 1 | //===--- ModuleBuilder.cpp - Emit LLVM Code from ASTs ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 5b12ab8 | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This builds an AST and converts it to LLVM Code. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/CodeGen/ModuleBuilder.h" |
David Blaikie | 48ad6dc | 2013-07-13 21:08:14 +0000 | [diff] [blame] | 15 | #include "CGDebugInfo.h" |
Chandler Carruth | 5553d0d | 2014-01-07 11:51:46 +0000 | [diff] [blame] | 16 | #include "CodeGenModule.h" |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 17 | #include "clang/AST/ASTContext.h" |
Daniel Dunbar | 221fa94 | 2008-08-11 04:54:23 +0000 | [diff] [blame] | 18 | #include "clang/AST/DeclObjC.h" |
| 19 | #include "clang/AST/Expr.h" |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 20 | #include "clang/Basic/Diagnostic.h" |
| 21 | #include "clang/Basic/TargetInfo.h" |
Saleem Abdulrasool | 10a4972 | 2016-04-08 16:52:00 +0000 | [diff] [blame] | 22 | #include "clang/Frontend/CodeGenOptions.h" |
Reid Kleckner | e43f0fe | 2013-05-08 13:44:39 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/StringRef.h" |
Chandler Carruth | ffd5551 | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 24 | #include "llvm/IR/DataLayout.h" |
| 25 | #include "llvm/IR/LLVMContext.h" |
| 26 | #include "llvm/IR/Module.h" |
Ahmed Charles | dfca6f9 | 2014-03-09 11:36:40 +0000 | [diff] [blame] | 27 | #include <memory> |
Chris Lattner | 984fac5 | 2009-03-26 05:00:52 +0000 | [diff] [blame] | 28 | using namespace clang; |
Ted Kremenek | 2c674f6 | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 29 | |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 30 | namespace { |
Benjamin Kramer | 337e3a5 | 2009-11-28 19:45:26 +0000 | [diff] [blame] | 31 | class CodeGeneratorImpl : public CodeGenerator { |
David Blaikie | 9c902b5 | 2011-09-25 23:23:43 +0000 | [diff] [blame] | 32 | DiagnosticsEngine &Diags; |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 33 | ASTContext *Ctx; |
Adrian Prantl | e74f525 | 2015-06-30 02:26:03 +0000 | [diff] [blame] | 34 | const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info. |
| 35 | const PreprocessorOptions &PreprocessorOpts; // Only used for debug info. |
Chandler Carruth | bc55fe2 | 2009-11-12 17:24:48 +0000 | [diff] [blame] | 36 | const CodeGenOptions CodeGenOpts; // Intentionally copied in. |
Richard Smith | 7f5755c | 2014-08-01 22:42:16 +0000 | [diff] [blame] | 37 | |
| 38 | unsigned HandlingTopLevelDecls; |
Reid Kleckner | ea53dba | 2016-04-22 18:46:33 +0000 | [diff] [blame^] | 39 | |
| 40 | /// Use this when emitting decls to block re-entrant decl emission. It will |
| 41 | /// emit all deferred decls on scope exit. Set EmitDeferred to false if decl |
| 42 | /// emission must be deferred longer, like at the end of a tag definition. |
Richard Smith | 7f5755c | 2014-08-01 22:42:16 +0000 | [diff] [blame] | 43 | struct HandlingTopLevelDeclRAII { |
| 44 | CodeGeneratorImpl &Self; |
Reid Kleckner | ea53dba | 2016-04-22 18:46:33 +0000 | [diff] [blame^] | 45 | bool EmitDeferred; |
| 46 | HandlingTopLevelDeclRAII(CodeGeneratorImpl &Self, |
| 47 | bool EmitDeferred = true) |
| 48 | : Self(Self), EmitDeferred(EmitDeferred) { |
Richard Smith | 7f5755c | 2014-08-01 22:42:16 +0000 | [diff] [blame] | 49 | ++Self.HandlingTopLevelDecls; |
| 50 | } |
| 51 | ~HandlingTopLevelDeclRAII() { |
Reid Kleckner | ea53dba | 2016-04-22 18:46:33 +0000 | [diff] [blame^] | 52 | unsigned Level = --Self.HandlingTopLevelDecls; |
| 53 | if (Level == 0 && EmitDeferred) |
Richard Smith | 7f5755c | 2014-08-01 22:42:16 +0000 | [diff] [blame] | 54 | Self.EmitDeferredDecls(); |
| 55 | } |
| 56 | }; |
| 57 | |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 58 | CoverageSourceInfo *CoverageInfo; |
| 59 | |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 60 | protected: |
Ahmed Charles | b898432 | 2014-03-07 20:03:18 +0000 | [diff] [blame] | 61 | std::unique_ptr<llvm::Module> M; |
| 62 | std::unique_ptr<CodeGen::CodeGenModule> Builder; |
| 63 | |
Hans Wennborg | 2b0d014 | 2014-12-18 19:19:00 +0000 | [diff] [blame] | 64 | private: |
| 65 | SmallVector<CXXMethodDecl *, 8> DeferredInlineMethodDefinitions; |
| 66 | |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 67 | public: |
Adrian Prantl | e74f525 | 2015-06-30 02:26:03 +0000 | [diff] [blame] | 68 | CodeGeneratorImpl(DiagnosticsEngine &diags, const std::string &ModuleName, |
| 69 | const HeaderSearchOptions &HSO, |
| 70 | const PreprocessorOptions &PPO, const CodeGenOptions &CGO, |
| 71 | llvm::LLVMContext &C, |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 72 | CoverageSourceInfo *CoverageInfo = nullptr) |
Adrian Prantl | e74f525 | 2015-06-30 02:26:03 +0000 | [diff] [blame] | 73 | : Diags(diags), Ctx(nullptr), HeaderSearchOpts(HSO), |
| 74 | PreprocessorOpts(PPO), CodeGenOpts(CGO), HandlingTopLevelDecls(0), |
Mehdi Amini | 557c20a | 2016-03-13 21:05:23 +0000 | [diff] [blame] | 75 | CoverageInfo(CoverageInfo), M(new llvm::Module(ModuleName, C)) { |
| 76 | C.setDiscardValueNames(CGO.DiscardValueNames); |
| 77 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 78 | |
Alexander Kornienko | 34eb207 | 2015-04-11 02:00:23 +0000 | [diff] [blame] | 79 | ~CodeGeneratorImpl() override { |
Hans Wennborg | 0c0a8c8 | 2014-12-19 23:35:11 +0000 | [diff] [blame] | 80 | // There should normally not be any leftover inline method definitions. |
| 81 | assert(DeferredInlineMethodDefinitions.empty() || |
| 82 | Diags.hasErrorOccurred()); |
Hans Wennborg | 2b0d014 | 2014-12-18 19:19:00 +0000 | [diff] [blame] | 83 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 84 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 85 | llvm::Module* GetModule() override { |
Daniel Dunbar | 30c514e | 2008-10-21 19:55:09 +0000 | [diff] [blame] | 86 | return M.get(); |
| 87 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 88 | |
Alp Toker | fb8d02b | 2014-06-05 22:10:59 +0000 | [diff] [blame] | 89 | const Decl *GetDeclForMangledName(StringRef MangledName) override { |
| 90 | GlobalDecl Result; |
| 91 | if (!Builder->lookupRepresentativeDecl(MangledName, Result)) |
| 92 | return nullptr; |
| 93 | const Decl *D = Result.getCanonicalDecl().getDecl(); |
| 94 | if (auto FD = dyn_cast<FunctionDecl>(D)) { |
| 95 | if (FD->hasBody(FD)) |
| 96 | return FD; |
| 97 | } else if (auto TD = dyn_cast<TagDecl>(D)) { |
| 98 | if (auto Def = TD->getDefinition()) |
| 99 | return Def; |
| 100 | } |
| 101 | return D; |
| 102 | } |
| 103 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 104 | llvm::Module *ReleaseModule() override { return M.release(); } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 105 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 106 | void Initialize(ASTContext &Context) override { |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 107 | Ctx = &Context; |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 108 | |
Douglas Gregor | e8bbc12 | 2011-09-02 00:18:52 +0000 | [diff] [blame] | 109 | M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple()); |
James Y Knight | b214cbc | 2016-03-04 19:00:41 +0000 | [diff] [blame] | 110 | M->setDataLayout(Ctx->getTargetInfo().getDataLayout()); |
Mehdi Amini | ca3cf9e | 2015-07-24 16:04:29 +0000 | [diff] [blame] | 111 | Builder.reset(new CodeGen::CodeGenModule(Context, HeaderSearchOpts, |
| 112 | PreprocessorOpts, CodeGenOpts, |
| 113 | *M, Diags, CoverageInfo)); |
Hans Wennborg | 75958c4 | 2013-08-08 00:17:41 +0000 | [diff] [blame] | 114 | |
Peter Collingbourne | dc13453 | 2016-01-16 00:31:22 +0000 | [diff] [blame] | 115 | for (auto &&Lib : CodeGenOpts.DependentLibraries) |
Nico Weber | 6622029 | 2016-03-02 17:28:48 +0000 | [diff] [blame] | 116 | Builder->AddDependentLib(Lib); |
Peter Collingbourne | dc13453 | 2016-01-16 00:31:22 +0000 | [diff] [blame] | 117 | for (auto &&Opt : CodeGenOpts.LinkerOptions) |
Nico Weber | 6622029 | 2016-03-02 17:28:48 +0000 | [diff] [blame] | 118 | Builder->AppendLinkerOptions(Opt); |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 119 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 120 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 121 | void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override { |
David Blaikie | 4a9ec7b | 2013-08-19 21:02:26 +0000 | [diff] [blame] | 122 | if (Diags.hasErrorOccurred()) |
| 123 | return; |
| 124 | |
Rafael Espindola | df88f6f | 2012-03-08 15:51:03 +0000 | [diff] [blame] | 125 | Builder->HandleCXXStaticMemberVarInstantiation(VD); |
Rafael Espindola | 189fa74 | 2012-03-05 10:54:55 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 128 | bool HandleTopLevelDecl(DeclGroupRef DG) override { |
David Blaikie | 4a9ec7b | 2013-08-19 21:02:26 +0000 | [diff] [blame] | 129 | if (Diags.hasErrorOccurred()) |
| 130 | return true; |
| 131 | |
Richard Smith | 7f5755c | 2014-08-01 22:42:16 +0000 | [diff] [blame] | 132 | HandlingTopLevelDeclRAII HandlingDecl(*this); |
| 133 | |
Douglas Gregor | 6e6ad60 | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 134 | // Make sure to emit all elements of a Decl. |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 135 | for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) |
| 136 | Builder->EmitTopLevelDecl(*I); |
Hans Wennborg | dfcb7d6 | 2014-06-06 17:36:17 +0000 | [diff] [blame] | 137 | |
Richard Smith | 7f5755c | 2014-08-01 22:42:16 +0000 | [diff] [blame] | 138 | return true; |
| 139 | } |
| 140 | |
| 141 | void EmitDeferredDecls() { |
Richard Smith | c9cbde7 | 2014-08-13 21:15:09 +0000 | [diff] [blame] | 142 | if (DeferredInlineMethodDefinitions.empty()) |
| 143 | return; |
| 144 | |
Richard Smith | 1ba0a07 | 2014-08-01 20:39:36 +0000 | [diff] [blame] | 145 | // Emit any deferred inline method definitions. Note that more deferred |
| 146 | // methods may be added during this loop, since ASTConsumer callbacks |
| 147 | // can be invoked if AST inspection results in declarations being added. |
Richard Smith | c9cbde7 | 2014-08-13 21:15:09 +0000 | [diff] [blame] | 148 | HandlingTopLevelDeclRAII HandlingDecl(*this); |
| 149 | for (unsigned I = 0; I != DeferredInlineMethodDefinitions.size(); ++I) |
Richard Smith | 1ba0a07 | 2014-08-01 20:39:36 +0000 | [diff] [blame] | 150 | Builder->EmitTopLevelDecl(DeferredInlineMethodDefinitions[I]); |
Richard Smith | 455768e | 2014-08-01 20:09:39 +0000 | [diff] [blame] | 151 | DeferredInlineMethodDefinitions.clear(); |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 152 | } |
Daniel Dunbar | fce4be8 | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 153 | |
Stephan Bergmann | 17d7d14 | 2016-03-30 06:27:31 +0000 | [diff] [blame] | 154 | void HandleInlineFunctionDefinition(FunctionDecl *D) override { |
Hans Wennborg | a926d84 | 2014-05-23 20:37:38 +0000 | [diff] [blame] | 155 | if (Diags.hasErrorOccurred()) |
| 156 | return; |
| 157 | |
| 158 | assert(D->doesThisDeclarationHaveABody()); |
| 159 | |
Stephan Bergmann | 17d7d14 | 2016-03-30 06:27:31 +0000 | [diff] [blame] | 160 | // Handle friend functions. |
| 161 | if (D->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend)) { |
| 162 | if (Ctx->getTargetInfo().getCXXABI().isMicrosoft() |
| 163 | && !D->getLexicalDeclContext()->isDependentContext()) |
| 164 | Builder->EmitTopLevelDecl(D); |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | // Otherwise, must be a method. |
| 169 | auto MD = cast<CXXMethodDecl>(D); |
| 170 | |
Hans Wennborg | dfcb7d6 | 2014-06-06 17:36:17 +0000 | [diff] [blame] | 171 | // We may want to emit this definition. However, that decision might be |
| 172 | // based on computing the linkage, and we have to defer that in case we |
| 173 | // are inside of something that will change the method's final linkage, |
| 174 | // e.g. |
| 175 | // typedef struct { |
| 176 | // void bar(); |
| 177 | // void foo() { bar(); } |
| 178 | // } A; |
Stephan Bergmann | 17d7d14 | 2016-03-30 06:27:31 +0000 | [diff] [blame] | 179 | DeferredInlineMethodDefinitions.push_back(MD); |
Alex Lorenz | ee02499 | 2014-08-04 18:41:51 +0000 | [diff] [blame] | 180 | |
Justin Bogner | 94d384e | 2014-11-18 00:34:46 +0000 | [diff] [blame] | 181 | // Provide some coverage mapping even for methods that aren't emitted. |
| 182 | // Don't do this for templated classes though, as they may not be |
| 183 | // instantiable. |
Stephan Bergmann | 17d7d14 | 2016-03-30 06:27:31 +0000 | [diff] [blame] | 184 | if (!MD->getParent()->getDescribedClassTemplate()) |
| 185 | Builder->AddDeferredUnusedCoverageMapping(MD); |
Hans Wennborg | a926d84 | 2014-05-23 20:37:38 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Chris Lattner | a5e4d30 | 2008-02-06 04:51:19 +0000 | [diff] [blame] | 188 | /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 189 | /// to (e.g. struct, union, enum, class) is completed. This allows the |
| 190 | /// client hack on the type, which can occur at any point in the file |
| 191 | /// (because these can be defined in declspecs). |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 192 | void HandleTagDeclDefinition(TagDecl *D) override { |
David Blaikie | 4a9ec7b | 2013-08-19 21:02:26 +0000 | [diff] [blame] | 193 | if (Diags.hasErrorOccurred()) |
| 194 | return; |
| 195 | |
Reid Kleckner | ea53dba | 2016-04-22 18:46:33 +0000 | [diff] [blame^] | 196 | // Don't allow re-entrant calls to CodeGen triggered by PCH |
| 197 | // deserialization to emit deferred decls. |
| 198 | HandlingTopLevelDeclRAII HandlingDecl(*this, /*EmitDeferred=*/false); |
| 199 | |
Chris Lattner | 68be606 | 2008-02-06 05:08:19 +0000 | [diff] [blame] | 200 | Builder->UpdateCompletedType(D); |
Hans Wennborg | 56fc62b | 2014-07-17 20:25:23 +0000 | [diff] [blame] | 201 | |
| 202 | // For MSVC compatibility, treat declarations of static data members with |
| 203 | // inline initializers as definitions. |
David Majnemer | 3f02150 | 2015-10-08 04:53:31 +0000 | [diff] [blame] | 204 | if (Ctx->getTargetInfo().getCXXABI().isMicrosoft()) { |
Hans Wennborg | 56fc62b | 2014-07-17 20:25:23 +0000 | [diff] [blame] | 205 | for (Decl *Member : D->decls()) { |
| 206 | if (VarDecl *VD = dyn_cast<VarDecl>(Member)) { |
| 207 | if (Ctx->isMSStaticDataMemberInlineDefinition(VD) && |
| 208 | Ctx->DeclMustBeEmitted(VD)) { |
| 209 | Builder->EmitGlobal(VD); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | } |
Alexey Bataev | c5b1d32 | 2016-03-04 09:22:22 +0000 | [diff] [blame] | 214 | // For OpenMP emit declare reduction functions, if required. |
| 215 | if (Ctx->getLangOpts().OpenMP) { |
| 216 | for (Decl *Member : D->decls()) { |
| 217 | if (auto *DRD = dyn_cast<OMPDeclareReductionDecl>(Member)) { |
| 218 | if (Ctx->DeclMustBeEmitted(DRD)) |
| 219 | Builder->EmitGlobal(DRD); |
| 220 | } |
| 221 | } |
| 222 | } |
Chris Lattner | a5e4d30 | 2008-02-06 04:51:19 +0000 | [diff] [blame] | 223 | } |
Ted Kremenek | 7db4f60 | 2008-08-07 19:47:41 +0000 | [diff] [blame] | 224 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 225 | void HandleTagDeclRequiredDefinition(const TagDecl *D) override { |
David Blaikie | 4a9ec7b | 2013-08-19 21:02:26 +0000 | [diff] [blame] | 226 | if (Diags.hasErrorOccurred()) |
| 227 | return; |
| 228 | |
Reid Kleckner | ea53dba | 2016-04-22 18:46:33 +0000 | [diff] [blame^] | 229 | // Don't allow re-entrant calls to CodeGen triggered by PCH |
| 230 | // deserialization to emit deferred decls. |
| 231 | HandlingTopLevelDeclRAII HandlingDecl(*this, /*EmitDeferred=*/false); |
| 232 | |
David Blaikie | 48ad6dc | 2013-07-13 21:08:14 +0000 | [diff] [blame] | 233 | if (CodeGen::CGDebugInfo *DI = Builder->getModuleDebugInfo()) |
| 234 | if (const RecordDecl *RD = dyn_cast<RecordDecl>(D)) |
David Blaikie | b2e86eb | 2013-08-15 20:49:17 +0000 | [diff] [blame] | 235 | DI->completeRequiredType(RD); |
David Blaikie | 48ad6dc | 2013-07-13 21:08:14 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 238 | void HandleTranslationUnit(ASTContext &Ctx) override { |
Manman Ren | 581c2b9 | 2016-01-28 23:29:02 +0000 | [diff] [blame] | 239 | // Release the Builder when there is no error. |
| 240 | if (!Diags.hasErrorOccurred() && Builder) |
| 241 | Builder->Release(); |
| 242 | |
| 243 | // If there are errors before or when releasing the Builder, reset |
| 244 | // the module to stop here before invoking the backend. |
Ted Kremenek | 7db4f60 | 2008-08-07 19:47:41 +0000 | [diff] [blame] | 245 | if (Diags.hasErrorOccurred()) { |
Rafael Espindola | c0ff744 | 2013-12-09 14:59:08 +0000 | [diff] [blame] | 246 | if (Builder) |
| 247 | Builder->clear(); |
Ted Kremenek | 7db4f60 | 2008-08-07 19:47:41 +0000 | [diff] [blame] | 248 | M.reset(); |
| 249 | return; |
| 250 | } |
Daniel Dunbar | e017ecc | 2009-12-19 17:50:07 +0000 | [diff] [blame] | 251 | } |
Douglas Gregor | beecd58 | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 252 | |
David Majnemer | 929025d | 2016-01-26 19:30:26 +0000 | [diff] [blame] | 253 | void AssignInheritanceModel(CXXRecordDecl *RD) override { |
| 254 | if (Diags.hasErrorOccurred()) |
| 255 | return; |
| 256 | |
| 257 | Builder->RefreshTypeCacheForClass(RD); |
| 258 | } |
| 259 | |
Craig Topper | 4f12f10 | 2014-03-12 06:41:41 +0000 | [diff] [blame] | 260 | void CompleteTentativeDefinition(VarDecl *D) override { |
Douglas Gregor | beecd58 | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 261 | if (Diags.hasErrorOccurred()) |
| 262 | return; |
| 263 | |
| 264 | Builder->EmitTentativeDefinition(D); |
| 265 | } |
Douglas Gregor | 88d292c | 2010-05-13 16:44:06 +0000 | [diff] [blame] | 266 | |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 267 | void HandleVTable(CXXRecordDecl *RD) override { |
Douglas Gregor | 88d292c | 2010-05-13 16:44:06 +0000 | [diff] [blame] | 268 | if (Diags.hasErrorOccurred()) |
| 269 | return; |
| 270 | |
Nico Weber | b6a5d05 | 2015-01-15 04:07:35 +0000 | [diff] [blame] | 271 | Builder->EmitVTable(RD); |
Douglas Gregor | 88d292c | 2010-05-13 16:44:06 +0000 | [diff] [blame] | 272 | } |
Chris Lattner | adf1f51 | 2008-02-06 02:01:47 +0000 | [diff] [blame] | 273 | }; |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 274 | } |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 275 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 276 | void CodeGenerator::anchor() { } |
| 277 | |
Adrian Prantl | e74f525 | 2015-06-30 02:26:03 +0000 | [diff] [blame] | 278 | CodeGenerator *clang::CreateLLVMCodeGen( |
| 279 | DiagnosticsEngine &Diags, const std::string &ModuleName, |
| 280 | const HeaderSearchOptions &HeaderSearchOpts, |
| 281 | const PreprocessorOptions &PreprocessorOpts, const CodeGenOptions &CGO, |
| 282 | llvm::LLVMContext &C, CoverageSourceInfo *CoverageInfo) { |
| 283 | return new CodeGeneratorImpl(Diags, ModuleName, HeaderSearchOpts, |
| 284 | PreprocessorOpts, CGO, C, CoverageInfo); |
Chris Lattner | f97fe38 | 2007-05-24 06:29:05 +0000 | [diff] [blame] | 285 | } |