clang 24.0.0git
clang::BackendDiagnosticConsumer Class Reference

Owns the state needed to translate LLVM backend diagnostics into clang diagnostics, and implements the translation itself. More...

#include "clang/CodeGenUtils/BackendDiagnosticHandler.h"

Public Member Functions

 BackendDiagnosticConsumer (DiagnosticsEngine &Diags, const CodeGenOptions &CodeGenOpts)
void setSourceManager (SourceManager *SM)
 The SourceManager used to translate backend-reported file:line:col locations back into clang SourceLocations.
void setCurLinkModule (llvm::Module *M)
 Set the module currently being linked in, used to name DK_Linker diagnostics.
void addFunctionSourceLocation (StringRef MangledName, FullSourceLoc Loc)
 Record the source location of the function with the given mangled name, used to approximate a location for backend diagnostics (e.g.
std::optional< FullSourceLoc > getFunctionSourceLocation (const llvm::Function &F) const
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 files, which identifies none of them.
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.
std::unique_ptr< llvm::DiagnosticHandler > createDiagnosticHandler ()
 Create an llvm::DiagnosticHandler that forwards diagnostics to this consumer.
void handleDiagnostics (const llvm::DiagnosticInfo &DI)
 This is invoked when the backend needs to report something to the user.

Detailed Description

Owns the state needed to translate LLVM backend diagnostics into clang diagnostics, and implements the translation itself.

This is not itself an llvm::DiagnosticHandler so that it can be installed/updated independently of the llvm::LLVMContext's handler lifetime; use BackendDiagnosticConsumer::createDiagnosticHandler() to get an llvm::DiagnosticHandler that forwards into it.

Definition at line 65 of file BackendDiagnosticHandler.h.

Constructor & Destructor Documentation

◆ BackendDiagnosticConsumer()

clang::BackendDiagnosticConsumer::BackendDiagnosticConsumer ( DiagnosticsEngine & Diags,
const CodeGenOptions & CodeGenOpts )
inline

Definition at line 67 of file BackendDiagnosticHandler.h.

Member Function Documentation

◆ addFunctionSourceLocation()

void BackendDiagnosticConsumer::addFunctionSourceLocation ( StringRef MangledName,
FullSourceLoc Loc )

Record the source location of the function with the given mangled name, used to approximate a location for backend diagnostics (e.g.

stack-size warnings) that don't carry debug-info locations of their own.

Definition at line 133 of file BackendDiagnosticHandler.cpp.

References llvm::hash_value().

◆ createDiagnosticHandler()

std::unique_ptr< llvm::DiagnosticHandler > BackendDiagnosticConsumer::createDiagnosticHandler ( )

Create an llvm::DiagnosticHandler that forwards diagnostics to this consumer.

The returned handler must not outlive this consumer.

Definition at line 129 of file BackendDiagnosticHandler.cpp.

◆ getBestLocationFromDebugLoc()

const FullSourceLoc BackendDiagnosticConsumer::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.

Definition at line 165 of file BackendDiagnosticHandler.cpp.

References clang::Column, getFunctionSourceLocation(), clang::SourceLocation::isInvalid(), and clang::Line.

◆ getFunctionSourceLocation()

std::optional< FullSourceLoc > BackendDiagnosticConsumer::getFunctionSourceLocation ( const llvm::Function & F) const

Definition at line 141 of file BackendDiagnosticHandler.cpp.

References clang::Function, and llvm::hash_value().

Referenced by getBestLocationFromDebugLoc().

◆ handleDiagnostics()

void BackendDiagnosticConsumer::handleDiagnostics ( const llvm::DiagnosticInfo & DI)

This is invoked when the backend needs to report something to the user.

Definition at line 564 of file BackendDiagnosticHandler.cpp.

References clang::cast(), ComputeDiagID, and ComputeDiagRemarkID.

◆ setCurLinkModule()

void clang::BackendDiagnosticConsumer::setCurLinkModule ( llvm::Module * M)
inline

Set the module currently being linked in, used to name DK_Linker diagnostics.

Definition at line 80 of file BackendDiagnosticHandler.h.

Referenced by clang::linkInModules().

◆ setDIFileSources()

void clang::BackendDiagnosticConsumer::setDIFileSources ( llvm::DenseMap< const llvm::DIFile *, OptionalFileEntryRef > Sources)
inline

Set the source file of each DIFile that clang created, or std::nullopt for a DIFile shared by several files, which identifies none of them.

Debug locations in other DIFiles, e.g. from LLVM IR input, are matched to source files by name.

Definition at line 95 of file BackendDiagnosticHandler.h.

◆ setSourceManager()

void clang::BackendDiagnosticConsumer::setSourceManager ( SourceManager * SM)
inline

The SourceManager used to translate backend-reported file:line:col locations back into clang SourceLocations.

May be null (e.g. when compiling a raw LLVM IR input file with no clang AST), in which case diagnostics are still reported, just without clang-level source locations.

Definition at line 76 of file BackendDiagnosticHandler.h.

Referenced by cir::CIRGenAction::ExecuteAction().


The documentation for this class was generated from the following files: