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
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 60 of file BackendDiagnosticHandler.h.

Constructor & Destructor Documentation

◆ BackendDiagnosticConsumer()

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

Definition at line 62 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 150 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 552 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 75 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 71 of file BackendDiagnosticHandler.h.


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