clang 24.0.0git
BackendConsumer.h
Go to the documentation of this file.
1//===--- BackendConsumer.h - LLVM BackendConsumer Header File -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_LIB_CODEGEN_BACKENDCONSUMER_H
10#define LLVM_CLANG_LIB_CODEGEN_BACKENDCONSUMER_H
11
16
17#include "llvm/Support/Timer.h"
18
19namespace clang {
20class ASTContext;
21class CodeGenAction;
23
25 virtual void anchor();
27 DiagnosticsEngine &Diags;
28 const CodeGenOptions &CodeGenOpts;
29 const TargetOptions &TargetOpts;
30 const LangOptions &LangOpts;
31 std::unique_ptr<raw_pwrite_stream> AsmOutStream;
32 ASTContext *Context = nullptr;
34
35 llvm::Timer LLVMIRGeneration;
36 unsigned LLVMIRGenerationRefCount = 0;
37
38 bool TimerIsEnabled = false;
39
40 BackendAction Action;
41
42 std::unique_ptr<CodeGenerator> Gen;
43
45
46 // Translates LLVM backend diagnostics into clang diagnostics; shared with
47 // CIR so that both LLVM-emitting pipelines report backend diagnostics
48 // through the same mechanism.
49 BackendDiagnosticConsumer DiagConsumer;
50
51public:
54 llvm::LLVMContext &C, SmallVector<LinkModule, 4> LinkModules,
55 StringRef InFile, std::unique_ptr<raw_pwrite_stream> OS,
56 CoverageSourceInfo *CoverageInfo,
57 llvm::Module *CurLinkModule = nullptr);
58
59 llvm::Module *getModule() const;
60 std::unique_ptr<llvm::Module> takeModule();
61
63
65 void Initialize(ASTContext &Ctx) override;
66 bool HandleTopLevelDecl(DeclGroupRef D) override;
68 void HandleInterestingDecl(DeclGroupRef D) override;
69 void HandleTranslationUnit(ASTContext &C) override;
70 void HandleTagDeclDefinition(TagDecl *D) override;
71 void HandleTagDeclRequiredDefinition(const TagDecl *D) override;
72 void CompleteTentativeDefinition(VarDecl *D) override;
74 void AssignInheritanceModel(CXXRecordDecl *RD) override;
75 void HandleVTable(CXXRecordDecl *RD) override;
76
77 // Links each entry in LinkModules into our module. Returns true on error.
78 bool LinkInModules(llvm::Module *M);
79 /// Create an llvm::DiagnosticHandler that routes LLVM backend diagnostics
80 /// through this consumer's clang diagnostics.
81 std::unique_ptr<llvm::DiagnosticHandler> createDiagnosticHandler();
82};
83
84} // namespace clang
85#endif
ASTConsumer()=default
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:239
llvm::Module * getModule() const
void CompleteExternalDeclaration(DeclaratorDecl *D) override
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
void HandleVTable(CXXRecordDecl *RD) override
Callback involved at the end of a translation unit to notify the consumer that a vtable for the given...
void HandleTagDeclDefinition(TagDecl *D) override
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
void Initialize(ASTContext &Ctx) override
Initialize - This is called to initialize the consumer, providing the ASTContext.
void HandleInlineFunctionDefinition(FunctionDecl *D) override
This callback is invoked each time an inline (method or friend) function definition in a class is com...
void HandleTagDeclRequiredDefinition(const TagDecl *D) override
This callback is invoked the first time each TagDecl is required to be complete.
void HandleInterestingDecl(DeclGroupRef D) override
HandleInterestingDecl - Handle the specified interesting declaration.
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
std::unique_ptr< llvm::DiagnosticHandler > createDiagnosticHandler()
Create an llvm::DiagnosticHandler that routes LLVM backend diagnostics through this consumer's clang ...
std::unique_ptr< llvm::Module > takeModule()
void AssignInheritanceModel(CXXRecordDecl *RD) override
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
void HandleTranslationUnit(ASTContext &C) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
void CompleteTentativeDefinition(VarDecl *D) override
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
bool LinkInModules(llvm::Module *M)
CodeGenerator * getCodeGenerator()
BackendConsumer(CompilerInstance &CI, BackendAction Action, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, llvm::LLVMContext &C, SmallVector< LinkModule, 4 > LinkModules, StringRef InFile, std::unique_ptr< raw_pwrite_stream > OS, CoverageSourceInfo *CoverageInfo, llvm::Module *CurLinkModule=nullptr)
Owns the state needed to translate LLVM backend diagnostics into clang diagnostics,...
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
The primary public interface to the Clang code generator.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Stores additional source code information like skipped ranges which is required by the coverage mappi...
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:781
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:241
Represents a function declaration or definition.
Definition Decl.h:2059
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3852
Options for controlling the target.
Represents a variable declaration or definition.
Definition Decl.h:933
Top level wrappers for InstallAPI frontend operations.
BackendAction
Definition BackendUtil.h:31