19#ifndef LLVM_CLANG_CODEGENUTILS_BACKENDDIAGNOSTICHANDLER_H
20#define LLVM_CLANG_CODEGENUTILS_BACKENDDIAGNOSTICHANDLER_H
24#include "llvm/ADT/ArrayRef.h"
25#include "llvm/ADT/DenseMap.h"
26#include "llvm/ADT/Hashing.h"
27#include "llvm/ADT/StringRef.h"
28#include "llvm/IR/DiagnosticHandler.h"
37class DiagnosticInfoDontCall;
38class DiagnosticInfoInlineAsm;
39class DiagnosticInfoMisExpect;
40class DiagnosticInfoOptimizationBase;
41class DiagnosticInfoOptimizationFailure;
42class DiagnosticInfoResourceLimit;
43class DiagnosticInfoSrcMgr;
44class DiagnosticInfoStackSize;
45class DiagnosticInfoUnsupported;
46class DiagnosticInfoUnsupportedTargetIntrinsic;
47class DiagnosticInfoWithLocationBase;
50class OptimizationRemarkAnalysisAliasing;
51class OptimizationRemarkAnalysisFPCommute;
69 : Diags(Diags), CodeGenOpts(CodeGenOpts) {}
88 std::optional<FullSourceLoc>
96 llvm::DenseMap<const llvm::DIFile *, OptionalFileEntryRef> Sources) {
97 DIFileSources = std::move(Sources);
104 bool &BadDebugInfo, StringRef &Filename,
119 bool InlineAsmDiagHandler(
const llvm::DiagnosticInfoInlineAsm &D);
121 void SrcMgrDiagHandler(
const llvm::DiagnosticInfoSrcMgr &D);
125 bool StackSizeDiagHandler(
const llvm::DiagnosticInfoStackSize &D);
129 bool ResourceLimitDiagHandler(
const llvm::DiagnosticInfoResourceLimit &D);
131 void UnsupportedDiagHandler(
const llvm::DiagnosticInfoUnsupported &D);
133 void UnsupportedTargetIntrinsicDiagHandler(
134 const llvm::DiagnosticInfoUnsupportedTargetIntrinsic &D);
138 void EmitOptimizationMessage(
const llvm::DiagnosticInfoOptimizationBase &D,
140 void OptimizationRemarkHandler(
const llvm::DiagnosticInfoOptimizationBase &D);
142 OptimizationRemarkHandler(
const llvm::OptimizationRemarkAnalysisFPCommute &D);
144 OptimizationRemarkHandler(
const llvm::OptimizationRemarkAnalysisAliasing &D);
146 OptimizationFailureHandler(
const llvm::DiagnosticInfoOptimizationFailure &D);
147 void DontCallDiagHandler(
const llvm::DiagnosticInfoDontCall &D);
150 void MisExpectDiagHandler(
const llvm::DiagnosticInfoMisExpect &D);
160 llvm::Module *CurLinkModule =
nullptr;
170 std::vector<std::pair<llvm::hash_code, FullSourceLoc>> ManglingFullSourceLocs;
172 llvm::DenseMap<const llvm::DIFile *, OptionalFileEntryRef> DIFileSources;
Defines interfaces for clang::FileEntry and clang::FileEntryRef.
Defines the clang::SourceLocation class and associated facilities.
BackendDiagnosticConsumer(DiagnosticsEngine &Diags, const CodeGenOptions &CodeGenOpts)
void addFunctionSourceLocation(StringRef MangledName, FullSourceLoc Loc)
Record the source location of the function with the given mangled name, used to approximate a locatio...
void setCurLinkModule(llvm::Module *M)
Set the module currently being linked in, used to name DK_Linker diagnostics.
std::unique_ptr< llvm::DiagnosticHandler > createDiagnosticHandler()
Create an llvm::DiagnosticHandler that forwards diagnostics to this consumer.
void setSourceManager(SourceManager *SM)
The SourceManager used to translate backend-reported file:line:col locations back into clang SourceLo...
std::optional< FullSourceLoc > getFunctionSourceLocation(const llvm::Function &F) const
void handleDiagnostics(const llvm::DiagnosticInfo &DI)
This is invoked when the backend needs to report something to the user.
void setDIFileSources(llvm::DenseMap< const llvm::DIFile *, OptionalFileEntryRef > Sources)
Set the source file of each DIFile that clang created, or std::nullopt for a DIFile shared by several...
const FullSourceLoc getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithLocationBase &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.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Concrete class used by the front-end to report problems and issues.
A SourceLocation and its associated SourceManager.
This class handles loading and caching of source files into memory.
Top level wrappers for InstallAPI frontend operations.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Diagnostic wrappers for TextAPI types for error reporting.