LLVM 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::DebugLoc Class Reference

A debug info location. More...

#include "llvm/IR/DebugLoc.h"

Public Types

enum  { ReplaceLastInlinedAt = true }
 

Public Member Functions

 DebugLoc ()=default
 
 DebugLoc (const DILocation *L)
 Construct from an DILocation.
 
 DebugLoc (const MDNode *N)
 Construct from an MDNode.
 
 operator bool () const
 Check for null.
 
bool hasTrivialDestructor () const
 Check whether this has a trivial destructor.
 
unsigned getLine () const
 
unsigned getCol () const
 
MDNodegetScope () const
 
DILocationgetInlinedAt () const
 
MDNodegetInlinedAtScope () const
 Get the fully inlined-at scope for a DebugLoc.
 
DebugLoc getFnDebugLoc () const
 Find the debug info location for the start of the function.
 
MDNodegetAsMDNode () const
 Return this as a bar MDNode.
 
bool isImplicitCode () const
 Check if the DebugLoc corresponds to an implicit code.
 
void setImplicitCode (bool ImplicitCode)
 
bool operator== (const DebugLoc &DL) const
 
bool operator!= (const DebugLoc &DL) const
 
void dump () const
 
void print (raw_ostream &OS) const
 prints source location /path/to/file.exe:line:col @[inlined at]
 
DILocationget () const
 Get the underlying DILocation.
 
 operator DILocation * () const
 
DILocationoperator-> () const
 
DILocationoperator* () const
 

Static Public Member Functions

static DebugLoc appendInlinedAt (const DebugLoc &DL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
 Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-at the new call site.
 
static DebugLoc replaceInlinedAtSubprogram (const DebugLoc &DL, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
 Rebuild the entire inline-at chain by replacing the subprogram at the end of the chain with NewSP.
 

Detailed Description

A debug info location.

This class is a wrapper around a tracking reference to an DILocation pointer.

To avoid extra includes, DebugLoc doubles the DILocation API with a one based on relatively opaque MDNode pointers.

Definition at line 33 of file DebugLoc.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ReplaceLastInlinedAt 

Definition at line 71 of file DebugLoc.h.

Constructor & Destructor Documentation

◆ DebugLoc() [1/3]

llvm::DebugLoc::DebugLoc ( )
default

Referenced by getFnDebugLoc().

◆ DebugLoc() [2/3]

DebugLoc::DebugLoc ( const DILocation L)

Construct from an DILocation.

Definition at line 17 of file DebugLoc.cpp.

◆ DebugLoc() [3/3]

DebugLoc::DebugLoc ( const MDNode N)
explicit

Construct from an MDNode.

Note: if N is not an DILocation, a verifier check will fail, and accessors will crash. However, construction from other nodes is supported in order to handle forward references when reading textual IR.

Definition at line 18 of file DebugLoc.cpp.

Member Function Documentation

◆ appendInlinedAt()

DebugLoc DebugLoc::appendInlinedAt ( const DebugLoc DL,
DILocation InlinedAt,
LLVMContext Ctx,
DenseMap< const MDNode *, MDNode * > &  Cache 
)
static

Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-at the new call site.

Parameters
InlinedAtThe new outermost inlined-at in the chain.

Definition at line 110 of file DebugLoc.cpp.

References DL, llvm::MDNode::getDistinct(), llvm::Last, llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::reverse().

Referenced by inlineDebugLoc().

◆ dump()

LLVM_DUMP_METHOD void DebugLoc::dump ( ) const

Definition at line 140 of file DebugLoc.cpp.

References llvm::dbgs(), and print().

◆ get()

DILocation * DebugLoc::get ( ) const

◆ getAsMDNode()

MDNode * llvm::DebugLoc::getAsMDNode ( ) const
inline

Return this as a bar MDNode.

Definition at line 106 of file DebugLoc.h.

Referenced by llvm::Instruction::eraseMetadataIf(), and llvm::Instruction::getMetadata().

◆ getCol()

unsigned DebugLoc::getCol ( ) const

◆ getFnDebugLoc()

DebugLoc DebugLoc::getFnDebugLoc ( ) const

Find the debug info location for the start of the function.

Walk up the scope chain of given debug loc and find line number info for the function.

FIXME: Remove this. Users should use DILocation/DILocalScope API to find the subprogram, and then DILocation::get().

Definition at line 48 of file DebugLoc.cpp.

References DebugLoc(), llvm::MDNode::get(), llvm::getDISubprogram(), and getInlinedAtScope().

◆ getInlinedAt()

DILocation * DebugLoc::getInlinedAt ( ) const

◆ getInlinedAtScope()

MDNode * DebugLoc::getInlinedAtScope ( ) const

Get the fully inlined-at scope for a DebugLoc.

Gets the inlined-at scope for a DebugLoc.

Definition at line 44 of file DebugLoc.cpp.

Referenced by getFnDebugLoc().

◆ getLine()

unsigned DebugLoc::getLine ( ) const

◆ getScope()

MDNode * DebugLoc::getScope ( ) const

Definition at line 34 of file DebugLoc.cpp.

References assert(), and get().

Referenced by llvm::DwarfDebug::beginInstruction(), llvm::getDebugValueLoc(), inlineDebugLoc(), and print().

◆ hasTrivialDestructor()

bool llvm::DebugLoc::hasTrivialDestructor ( ) const
inline

Check whether this has a trivial destructor.

Definition at line 69 of file DebugLoc.h.

References llvm::TypedTrackingMDRef< T >::hasTrivialDestructor().

Referenced by llvm::SDNode::SDNode().

◆ isImplicitCode()

bool DebugLoc::isImplicitCode ( ) const

Check if the DebugLoc corresponds to an implicit code.

Definition at line 57 of file DebugLoc.cpp.

References get().

◆ operator bool()

llvm::DebugLoc::operator bool ( ) const
inlineexplicit

Check for null.

Check for null in a way that is safe with broken debug info. Unlike the conversion to DILocation, this doesn't require that Loc is of the right type. Important for cases like llvm::StripDebugInfo() and Instruction::hasMetadata().

Definition at line 66 of file DebugLoc.h.

◆ operator DILocation *()

llvm::DebugLoc::operator DILocation * ( ) const
inline

Definition at line 55 of file DebugLoc.h.

References get().

◆ operator!=()

bool llvm::DebugLoc::operator!= ( const DebugLoc DL) const
inline

Definition at line 113 of file DebugLoc.h.

References DL.

◆ operator*()

DILocation & llvm::DebugLoc::operator* ( ) const
inline

Definition at line 57 of file DebugLoc.h.

References get().

◆ operator->()

DILocation * llvm::DebugLoc::operator-> ( ) const
inline

Definition at line 56 of file DebugLoc.h.

References get().

◆ operator==()

bool llvm::DebugLoc::operator== ( const DebugLoc DL) const
inline

Definition at line 112 of file DebugLoc.h.

References DL.

◆ print()

void DebugLoc::print ( raw_ostream OS) const

prints source location /path/to/file.exe:line:col @[inlined at]

Definition at line 143 of file DebugLoc.cpp.

References getCol(), getInlinedAt(), getLine(), getScope(), and OS.

Referenced by dump().

◆ replaceInlinedAtSubprogram()

DebugLoc DebugLoc::replaceInlinedAtSubprogram ( const DebugLoc DL,
DISubprogram NewSP,
LLVMContext Ctx,
DenseMap< const MDNode *, MDNode * > &  Cache 
)
static

◆ setImplicitCode()

void DebugLoc::setImplicitCode ( bool  ImplicitCode)

Definition at line 64 of file DebugLoc.cpp.

References get().


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