24 #include "llvm/ADT/SmallString.h"
25 #include "llvm/Bitcode/ReaderWriter.h"
26 #include "llvm/IR/DebugInfo.h"
27 #include "llvm/IR/DiagnosticInfo.h"
28 #include "llvm/IR/DiagnosticPrinter.h"
29 #include "llvm/IR/LLVMContext.h"
30 #include "llvm/IR/Module.h"
31 #include "llvm/IRReader/IRReader.h"
32 #include "llvm/Linker/Linker.h"
33 #include "llvm/Pass.h"
34 #include "llvm/Support/MemoryBuffer.h"
35 #include "llvm/Support/SourceMgr.h"
36 #include "llvm/Support/Timer.h"
38 using namespace clang;
43 virtual void anchor();
49 std::unique_ptr<raw_pwrite_stream> AsmOutStream;
52 Timer LLVMIRGeneration;
54 std::unique_ptr<CodeGenerator> Gen;
61 llvm::Module *CurLinkModule =
nullptr;
69 bool TimePasses,
const std::string &InFile,
70 const SmallVectorImpl<std::pair<unsigned, llvm::Module *>> &LinkModules,
71 std::unique_ptr<raw_pwrite_stream> OS, LLVMContext &C,
73 : Diags(Diags), Action(Action), CodeGenOpts(CodeGenOpts),
74 TargetOpts(TargetOpts), LangOpts(LangOpts),
75 AsmOutStream(std::move(OS)),
Context(nullptr),
76 LLVMIRGeneration(
"LLVM IR Generation Time"),
78 CodeGenOpts, C, CoverageInfo)) {
79 llvm::TimePassesIsEnabled = TimePasses;
80 for (
auto &
I : LinkModules)
81 this->LinkModules.push_back(
82 std::make_pair(
I.first, std::unique_ptr<llvm::Module>(
I.second)));
84 llvm::Module *
getModule()
const {
return Gen->GetModule(); }
86 return std::unique_ptr<llvm::Module>(Gen->ReleaseModule());
89 for (
auto &
I : LinkModules)
94 Gen->HandleCXXStaticMemberVarInstantiation(VD);
98 assert(!
Context &&
"initialized multiple times");
102 if (llvm::TimePassesIsEnabled)
103 LLVMIRGeneration.startTimer();
105 Gen->Initialize(Ctx);
107 if (llvm::TimePassesIsEnabled)
108 LLVMIRGeneration.stopTimer();
114 "LLVM IR generation of declaration");
116 if (llvm::TimePassesIsEnabled)
117 LLVMIRGeneration.startTimer();
119 Gen->HandleTopLevelDecl(D);
121 if (llvm::TimePassesIsEnabled)
122 LLVMIRGeneration.stopTimer();
130 "LLVM IR generation of inline function");
131 if (llvm::TimePassesIsEnabled)
132 LLVMIRGeneration.startTimer();
134 Gen->HandleInlineFunctionDefinition(D);
136 if (llvm::TimePassesIsEnabled)
137 LLVMIRGeneration.stopTimer();
142 PrettyStackTraceString CrashInfo(
"Per-file LLVM IR generation");
143 if (llvm::TimePassesIsEnabled)
144 LLVMIRGeneration.startTimer();
146 Gen->HandleTranslationUnit(C);
148 if (llvm::TimePassesIsEnabled)
149 LLVMIRGeneration.stopTimer();
158 LLVMContext &Ctx = getModule()->getContext();
159 LLVMContext::InlineAsmDiagHandlerTy OldHandler =
160 Ctx.getInlineAsmDiagnosticHandler();
161 void *OldContext = Ctx.getInlineAsmDiagnosticContext();
162 Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler,
this);
164 LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
165 Ctx.getDiagnosticHandler();
166 void *OldDiagnosticContext = Ctx.getDiagnosticContext();
167 Ctx.setDiagnosticHandler(DiagnosticHandler,
this);
170 for (
auto &
I : LinkModules) {
171 unsigned LinkFlags =
I.first;
172 CurLinkModule =
I.second.get();
173 if (Linker::linkModules(*getModule(), std::move(
I.second), LinkFlags))
177 EmbedBitcode(getModule(), CodeGenOpts, llvm::MemoryBufferRef());
181 getModule(),
Action, std::move(AsmOutStream));
183 Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
185 Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
191 "LLVM IR generation of declaration");
192 Gen->HandleTagDeclDefinition(D);
196 Gen->HandleTagDeclRequiredDefinition(D);
200 Gen->CompleteTentativeDefinition(D);
204 Gen->AssignInheritanceModel(RD);
208 Gen->HandleVTable(RD);
212 unsigned LocCookie) {
225 getBestLocationFromDebugLoc(
const llvm::DiagnosticInfoWithDebugLocBase &D,
226 bool &BadDebugInfo, StringRef &
Filename,
227 unsigned &
Line,
unsigned &Column)
const;
229 void InlineAsmDiagHandler2(
const llvm::SMDiagnostic &,
232 void DiagnosticHandlerImpl(
const llvm::DiagnosticInfo &DI);
236 bool InlineAsmDiagHandler(
const llvm::DiagnosticInfoInlineAsm &D);
240 bool StackSizeDiagHandler(
const llvm::DiagnosticInfoStackSize &D);
242 void UnsupportedDiagHandler(
const llvm::DiagnosticInfoUnsupported &D);
246 void EmitOptimizationMessage(
const llvm::DiagnosticInfoOptimizationBase &D,
249 OptimizationRemarkHandler(
const llvm::DiagnosticInfoOptimizationRemark &D);
250 void OptimizationRemarkHandler(
251 const llvm::DiagnosticInfoOptimizationRemarkMissed &D);
252 void OptimizationRemarkHandler(
253 const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D);
254 void OptimizationRemarkHandler(
255 const llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute &D);
256 void OptimizationRemarkHandler(
257 const llvm::DiagnosticInfoOptimizationRemarkAnalysisAliasing &D);
258 void OptimizationFailureHandler(
259 const llvm::DiagnosticInfoOptimizationFailure &D);
262 void BackendConsumer::anchor() {}
272 const llvm::SourceMgr &LSM = *D.getSourceMgr();
276 const MemoryBuffer *LBuf =
277 LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(D.getLoc()));
281 std::unique_ptr<llvm::MemoryBuffer> CBuf =
282 llvm::MemoryBuffer::getMemBufferCopy(LBuf->getBuffer(),
283 LBuf->getBufferIdentifier());
288 unsigned Offset = D.getLoc().getPointer() - LBuf->getBufferStart();
304 StringRef Message = D.getMessage();
305 if (Message.startswith(
"error: "))
306 Message = Message.substr(7);
310 if (D.getLoc() != SMLoc())
314 switch (D.getKind()) {
315 case llvm::SourceMgr::DK_Error:
316 DiagID = diag::err_fe_inline_asm;
318 case llvm::SourceMgr::DK_Warning:
319 DiagID = diag::warn_fe_inline_asm;
321 case llvm::SourceMgr::DK_Note:
322 DiagID = diag::note_fe_inline_asm;
329 Diags.Report(LocCookie, DiagID).AddString(Message);
331 if (D.getLoc().isValid()) {
335 for (
const std::pair<unsigned, unsigned> &Range : D.getRanges()) {
336 unsigned Column = D.getColumnNo();
347 Diags.Report(Loc, DiagID).AddString(Message);
350 #define ComputeDiagID(Severity, GroupName, DiagID) \
352 switch (Severity) { \
353 case llvm::DS_Error: \
354 DiagID = diag::err_fe_##GroupName; \
356 case llvm::DS_Warning: \
357 DiagID = diag::warn_fe_##GroupName; \
359 case llvm::DS_Remark: \
360 llvm_unreachable("'remark' severity not expected"); \
362 case llvm::DS_Note: \
363 DiagID = diag::note_fe_##GroupName; \
368 #define ComputeDiagRemarkID(Severity, GroupName, DiagID) \
370 switch (Severity) { \
371 case llvm::DS_Error: \
372 DiagID = diag::err_fe_##GroupName; \
374 case llvm::DS_Warning: \
375 DiagID = diag::warn_fe_##GroupName; \
377 case llvm::DS_Remark: \
378 DiagID = diag::remark_fe_##GroupName; \
380 case llvm::DS_Note: \
381 DiagID = diag::note_fe_##GroupName; \
390 std::string Message = D.getMsgStr().str();
398 Diags.Report(LocCookie, DiagID).AddString(Message);
405 Diags.Report(Loc, DiagID).AddString(Message);
413 if (D.getSeverity() != llvm::DS_Warning)
418 if (
const Decl *ND = Gen->GetDeclForMangledName(D.getFunction().getName())) {
420 Diags.Report(ND->getASTContext().getFullLoc(ND->getLocation()),
421 diag::warn_fe_frame_larger_than)
422 <<
static_cast<uint32_t
>(D.getStackSize()) << Decl::castToDeclContext(ND);
430 const llvm::DiagnosticInfoWithDebugLocBase &D,
bool &BadDebugInfo, StringRef &
Filename,
431 unsigned &
Line,
unsigned &Column)
const {
436 if (D.isLocationAvailable()) {
437 D.getLocation(&Filename, &Line, &Column);
439 if (FE && Line > 0) {
452 if (
const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName()))
453 Loc = FD->getASTContext().getFullLoc(FD->getLocation());
455 if (DILoc.
isInvalid() && D.isLocationAvailable())
460 Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
461 << Filename << Line << Column;
467 const llvm::DiagnosticInfoUnsupported &D) {
469 assert(D.getSeverity() == llvm::DS_Error);
472 unsigned Line, Column;
474 FullSourceLoc Loc = getBestLocationFromDebugLoc(D, BadDebugInfo, Filename,
477 Diags.Report(Loc, diag::err_fe_backend_unsupported) << D.getMessage().str();
484 Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
485 << Filename << Line << Column;
489 const llvm::DiagnosticInfoOptimizationBase &D,
unsigned DiagID) {
491 assert(D.getSeverity() == llvm::DS_Remark ||
492 D.getSeverity() == llvm::DS_Warning);
495 unsigned Line, Column;
496 bool BadDebugInfo =
false;
497 FullSourceLoc Loc = getBestLocationFromDebugLoc(D, BadDebugInfo, Filename,
500 Diags.Report(Loc, DiagID)
509 Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
510 << Filename << Line << Column;
514 const llvm::DiagnosticInfoOptimizationRemark &D) {
517 if (CodeGenOpts.OptimizationRemarkPattern &&
518 CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName()))
519 EmitOptimizationMessage(D, diag::remark_fe_backend_optimization_remark);
523 const llvm::DiagnosticInfoOptimizationRemarkMissed &D) {
527 if (CodeGenOpts.OptimizationRemarkMissedPattern &&
528 CodeGenOpts.OptimizationRemarkMissedPattern->match(D.getPassName()))
529 EmitOptimizationMessage(D,
530 diag::remark_fe_backend_optimization_remark_missed);
534 const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D) {
539 if (D.shouldAlwaysPrint() ||
540 (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
541 CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName())))
542 EmitOptimizationMessage(
543 D, diag::remark_fe_backend_optimization_remark_analysis);
547 const llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute &D) {
552 if (D.shouldAlwaysPrint() ||
553 (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
554 CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName())))
555 EmitOptimizationMessage(
556 D, diag::remark_fe_backend_optimization_remark_analysis_fpcommute);
560 const llvm::DiagnosticInfoOptimizationRemarkAnalysisAliasing &D) {
565 if (D.shouldAlwaysPrint() ||
566 (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
567 CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName())))
568 EmitOptimizationMessage(
569 D, diag::remark_fe_backend_optimization_remark_analysis_aliasing);
573 const llvm::DiagnosticInfoOptimizationFailure &D) {
574 EmitOptimizationMessage(D, diag::warn_fe_backend_optimization_failure);
580 unsigned DiagID = diag::err_fe_inline_asm;
581 llvm::DiagnosticSeverity
Severity = DI.getSeverity();
583 switch (DI.getKind()) {
584 case llvm::DK_InlineAsm:
585 if (InlineAsmDiagHandler(cast<DiagnosticInfoInlineAsm>(DI)))
589 case llvm::DK_StackSize:
590 if (StackSizeDiagHandler(cast<DiagnosticInfoStackSize>(DI)))
595 assert(CurLinkModule);
597 if (Severity != DS_Error)
599 DiagID = diag::err_fe_cannot_link_module;
601 case llvm::DK_OptimizationRemark:
604 OptimizationRemarkHandler(cast<DiagnosticInfoOptimizationRemark>(DI));
606 case llvm::DK_OptimizationRemarkMissed:
609 OptimizationRemarkHandler(cast<DiagnosticInfoOptimizationRemarkMissed>(DI));
611 case llvm::DK_OptimizationRemarkAnalysis:
614 OptimizationRemarkHandler(
615 cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI));
617 case llvm::DK_OptimizationRemarkAnalysisFPCommute:
620 OptimizationRemarkHandler(
621 cast<DiagnosticInfoOptimizationRemarkAnalysisFPCommute>(DI));
623 case llvm::DK_OptimizationRemarkAnalysisAliasing:
626 OptimizationRemarkHandler(
627 cast<DiagnosticInfoOptimizationRemarkAnalysisAliasing>(DI));
629 case llvm::DK_OptimizationFailure:
632 OptimizationFailureHandler(cast<DiagnosticInfoOptimizationFailure>(DI));
634 case llvm::DK_Unsupported:
635 UnsupportedDiagHandler(cast<DiagnosticInfoUnsupported>(DI));
642 std::string MsgStorage;
644 raw_string_ostream Stream(MsgStorage);
645 DiagnosticPrinterRawOStream DP(Stream);
649 if (DiagID == diag::err_fe_cannot_link_module) {
650 Diags.Report(diag::err_fe_cannot_link_module)
651 << CurLinkModule->getModuleIdentifier() << MsgStorage;
657 Diags.Report(Loc, DiagID).AddString(MsgStorage);
662 : Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext),
663 OwnsVMContext(!_VMContext) {}
679 if (!LinkModules.empty())
687 return std::move(TheModule);
691 OwnsVMContext =
false;
695 static std::unique_ptr<raw_pwrite_stream>
712 llvm_unreachable(
"Invalid action!");
715 std::unique_ptr<ASTConsumer>
718 std::unique_ptr<raw_pwrite_stream> OS =
GetOutputStream(CI, InFile, BA);
723 if (LinkModules.empty())
725 const std::string &LinkBCFile =
I.second;
730 << LinkBCFile << BCBuf.getError().message();
735 ErrorOr<std::unique_ptr<llvm::Module>> ModuleOrErr =
736 getLazyBitcodeModule(std::move(*BCBuf), *VMContext);
737 if (std::error_code EC = ModuleOrErr.getError()) {
751 std::unique_ptr<PPCallbacks>(CoverageInfo));
758 std::move(OS), *VMContext, CoverageInfo));
760 return std::move(Result);
765 unsigned LocCookie) {
766 SM.print(
nullptr, llvm::errs());
770 switch (SM.getKind()) {
771 case llvm::SourceMgr::DK_Error:
772 DiagID = diag::err_fe_inline_asm;
774 case llvm::SourceMgr::DK_Warning:
775 DiagID = diag::warn_fe_inline_asm;
777 case llvm::SourceMgr::DK_Note:
778 DiagID = diag::note_fe_inline_asm;
782 Diags->Report(DiagID).AddString(
"cannot compile inline asm");
790 std::unique_ptr<raw_pwrite_stream> OS =
798 llvm::MemoryBuffer *MainFile = SM.
getBuffer(FID, &Invalid);
805 VMContext->enableDebugTypeODRUniquing();
807 llvm::SMDiagnostic Err;
808 TheModule = parseIR(MainFile->getMemBufferRef(), Err, *VMContext);
814 if (Err.getLineNo() > 0) {
815 assert(Err.getColumnNo() >= 0);
817 Err.getLineNo(), Err.getColumnNo() + 1);
821 StringRef Msg = Err.getMessage();
822 if (Msg.startswith(
"error: "))
832 if (TheModule->getTargetTriple() != TargetOpts.
Triple) {
834 diag::warn_fe_override_module)
836 TheModule->setTargetTriple(TargetOpts.
Triple);
840 MainFile->getMemBufferRef());
842 LLVMContext &Ctx = TheModule->getContext();
848 TheModule.get(), BA, std::move(OS));
858 void EmitAssemblyAction::anchor() { }
862 void EmitBCAction::anchor() { }
866 void EmitLLVMAction::anchor() { }
870 void EmitLLVMOnlyAction::anchor() { }
874 void EmitCodeGenOnlyAction::anchor() { }
878 void EmitObjAction::anchor() { }
void EmitOptimizationMessage(const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID)
Specialized handlers for optimization remarks.
Defines the clang::ASTContext interface.
LangOptions & getLangOpts()
void HandleInlineFunctionDefinition(FunctionDecl *D) override
This callback is invoked each time an inline (method or friend) function definition in a class is com...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
PreprocessorOptions & getPreprocessorOpts()
static void InlineAsmDiagHandler(const llvm::SMDiagnostic &SM, void *Context, unsigned LocCookie)
Implements support for file system lookup, file system caching, and directory search management...
bool hasIRSupport() const override
Does this action support use with IR files?
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Defines the clang::FileManager interface and associated types.
Emit human-readable LLVM assembly.
Run CodeGen, but don't emit anything.
void EndSourceFileAction() override
Callback at the end of processing a single input.
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer...
Defines the SourceManager interface.
CompilerInstance & getCompilerInstance() const
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
Stores additional source code information like skipped ranges which is required by the coverage mappi...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void HandleTagDeclRequiredDefinition(const TagDecl *D) override
This callback is invoked the first time each TagDecl is required to be complete.
std::unique_ptr< llvm::Module > takeModule()
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
TargetInfo & getTarget() const
Don't emit anything (benchmarking mode)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
SourceManager & getSourceManager() const
Return the current source manager.
Options for controlling the target.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
void HandleTagDeclDefinition(TagDecl *D) override
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
InputKind getCurrentFileKind() const
bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D)
Specialized handler for StackSize diagnostic.
#define ComputeDiagRemarkID(Severity, GroupName, DiagID)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
void OptimizationFailureHandler(const llvm::DiagnosticInfoOptimizationFailure &D)
void CompleteTentativeDefinition(VarDecl *D) override
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
CodeGenOptions & getCodeGenOpts()
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const TargetInfo & getTargetInfo() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
FrontendOptions & getFrontendOpts()
Concrete class used by the front-end to report problems and issues.
void DiagnosticHandlerImpl(const llvm::DiagnosticInfo &DI)
This function is invoked when the backend needs to report something to the user.
CodeGenerator * CreateLLVMCodeGen(DiagnosticsEngine &Diags, llvm::StringRef ModuleName, const HeaderSearchOptions &HeaderSearchOpts, const PreprocessorOptions &PreprocessorOpts, const CodeGenOptions &CGO, llvm::LLVMContext &C, CoverageSourceInfo *CoverageInfo=nullptr)
CreateLLVMCodeGen - Create a CodeGenerator instance.
void OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationRemark &D)
static void DiagnosticHandler(const llvm::DiagnosticInfo &DI, void *Context)
static void BitcodeInlineAsmDiagHandler(const llvm::SMDiagnostic &SM, void *Context, unsigned LocCookie)
HeaderSearchOptions & getHeaderSearchOpts()
SourceLocation translateFileLineCol(const FileEntry *SourceFile, unsigned Line, unsigned Col) const
Get the source location for the given file:line:col triplet.
const FullSourceLoc getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithDebugLocBase &D, bool &BadDebugInfo, StringRef &Filename, unsigned &Line, unsigned &Column) const
Get the best possible source location to represent a diagnostic that may have associated debug info...
detail::InMemoryDirectory::const_iterator I
Preprocessor & getPreprocessor() const
Return the current preprocessor.
void releaseLinkModules()
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
A little helper class used to produce diagnostics.
BackendConsumer * BEConsumer
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
EmitLLVMAction(llvm::LLVMContext *_VMContext=nullptr)
~CodeGenAction() override
CodeGenAction(unsigned _Act, llvm::LLVMContext *_VMContext=nullptr)
Create a new code generation action.
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
FileManager & getFileManager() const
unsigned ShowTimers
Show timers for individual actions.
Defines the clang::Preprocessor interface.
Emit native object files.
EmitObjAction(llvm::LLVMContext *_VMContext=nullptr)
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
The result type of a method or function.
static std::unique_ptr< raw_pwrite_stream > GetOutputStream(CompilerInstance &CI, StringRef InFile, BackendAction Action)
EmitBCAction(llvm::LLVMContext *_VMContext=nullptr)
static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic &D, SourceManager &CSM)
ConvertBackendLocation - Convert a location in a temporary llvm::SourceMgr buffer to be a valid FullS...
Emit native assembly files.
void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D)
Specialized handler for unsupported backend feature diagnostic.
EmitCodeGenOnlyAction(llvm::LLVMContext *_VMContext=nullptr)
void AssignInheritanceModel(CXXRecordDecl *RD) override
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
const StringRef getCurrentFile() const
BackendConsumer(BackendAction Action, DiagnosticsEngine &Diags, const HeaderSearchOptions &HeaderSearchOpts, const PreprocessorOptions &PPOpts, const CodeGenOptions &CodeGenOpts, const TargetOptions &TargetOpts, const LangOptions &LangOpts, bool TimePasses, const std::string &InFile, const SmallVectorImpl< std::pair< unsigned, llvm::Module * >> &LinkModules, std::unique_ptr< raw_pwrite_stream > OS, LLVMContext &C, CoverageSourceInfo *CoverageInfo=nullptr)
Cached information about one file (either on disk or in the virtual file system). ...
std::unique_ptr< raw_pwrite_stream > createNullOutputFile()
#define ComputeDiagID(Severity, GroupName, DiagID)
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
FileID getMainFileID() const
Returns the FileID of the main source file.
llvm::Module * getModule() const
EmitLLVMOnlyAction(llvm::LLVMContext *_VMContext=nullptr)
std::string ThinLTOIndexFile
Name of the function summary index file to use for ThinLTO function importing.
std::unique_ptr< llvm::Module > takeModule()
Take the generated LLVM module, for use after the action has been run.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts, llvm::MemoryBufferRef Buf)
FileManager & getFileManager() const
Return the current file manager to the caller.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false, bool ShouldCloseOpenFile=true)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
void InlineAsmDiagHandler2(const llvm::SMDiagnostic &, SourceLocation LocCookie)
InlineAsmDiagHandler2 - This function is invoked when the backend hits an error parsing inline asm...
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 Initialize(ASTContext &Ctx) override
Initialize - This is called to initialize the consumer, providing the ASTContext. ...
void addLinkModule(llvm::Module *Mod, unsigned LinkFlags)
setLinkModule - Set the link module to be used by this action.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
std::unique_ptr< raw_pwrite_stream > createDefaultOutputFile(bool Binary=true, StringRef BaseInput="", StringRef Extension="")
Create the default output file (from the invocation's options) and add it to the list of tracked outp...
SourceManager & getSourceManager()
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
EmitAssemblyAction(llvm::LLVMContext *_VMContext=nullptr)
Represents a C++ struct/union/class.
llvm::LLVMContext * takeLLVMContext()
Take the LLVM context used by this action.
void EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts, const TargetOptions &TOpts, const LangOptions &LOpts, const llvm::DataLayout &TDesc, llvm::Module *M, BackendAction Action, std::unique_ptr< raw_pwrite_stream > OS)
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
Defines the clang::TargetInfo interface.
A SourceLocation and its associated SourceManager.
std::vector< std::pair< unsigned, std::string > > LinkBitcodeFiles
The name of the bitcode file to link before optzns.
void HandleTranslationUnit(ASTContext &C) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
A trivial tuple used to represent a source range.
const llvm::DataLayout & getDataLayout() const
std::string Triple
If given, the name of the target triple to compile for.
TargetOptions & getTargetOpts()
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
This class handles loading and caching of source files into memory.
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...