LLVM  7.0.0svn
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. More...
 DebugLoc (const MDNode *N)
 Construct from an MDNode. More...
 operator bool () const
 Check for null. More...
bool hasTrivialDestructor () const
 Check whether this has a trivial destructor. More...
unsigned getLine () const
unsigned getCol () const
MDNodegetScope () const
DILocationgetInlinedAt () const
MDNodegetInlinedAtScope () const
 Get the fully inlined-at scope for a DebugLoc. More...
DebugLoc getFnDebugLoc () const
 Find the debug info location for the start of the function. More...
MDNodegetAsMDNode () const
 Return this as a bar MDNode. More...
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] More...
DILocationget () const
 Get the underlying DILocation. More...
 operator DILocation * () const
DILocationoperator-> () const
DILocationoperator* () const

Static Public Member Functions

static DebugLoc get (unsigned Line, unsigned Col, const MDNode *Scope, const MDNode *InlinedAt=nullptr)
 Create a new DebugLoc. More...
static DebugLoc appendInlinedAt (DebugLoc DL, DILocation *InlinedAt, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode *> &Cache, bool ReplaceLast=false)
 Rebuild the entire inlined-at chain for this instruction so that the top of the chain now is inlined-at the new call site. More...

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 34 of file DebugLoc.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 83 of file DebugLoc.h.

Constructor & Destructor Documentation

◆ DebugLoc() [1/3]

llvm::DebugLoc::DebugLoc ( )

Referenced by dump(), get(), and getFnDebugLoc().

◆ DebugLoc() [2/3]

DebugLoc::DebugLoc ( const DILocation L)

Construct from an DILocation.

Definition at line 18 of file DebugLoc.cpp.

◆ DebugLoc() [3/3]

DebugLoc::DebugLoc ( const MDNode N)

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 19 of file DebugLoc.cpp.

Member Function Documentation

◆ appendInlinedAt()

DebugLoc DebugLoc::appendInlinedAt ( DebugLoc  DL,
DILocation InlinedAt,
LLVMContext Ctx,
DenseMap< const MDNode *, MDNode *> &  Cache,
bool  ReplaceLast = false 

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

InlinedAtThe new outermost inlined-at in the chain.
ReplaceLastReplace the last location in the inlined-at chain.

Definition at line 69 of file DebugLoc.cpp.

References llvm::MDNode::getDistinct(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and llvm::reverse().

Referenced by fixupLineNumbers().

◆ dump()

LLVM_DUMP_METHOD void DebugLoc::dump ( ) const

Definition at line 102 of file DebugLoc.cpp.

References llvm::dbgs(), DebugLoc(), getCol(), getInlinedAt(), and getLine().

Referenced by operator!=().

◆ get() [1/2]

DILocation * DebugLoc::get ( ) const

◆ get() [2/2]

DebugLoc DebugLoc::get ( unsigned  Line,
unsigned  Col,
const MDNode Scope,
const MDNode InlinedAt = nullptr 

Create a new DebugLoc.

Create a new DebugLoc at the specified line/col and scope/inline. This forwards to DILocation::get().

If !Scope, returns a default-constructed DebugLoc.

FIXME: Remove this. Users should use DILocation::get().

Definition at line 58 of file DebugLoc.cpp.

References DebugLoc(), llvm::MDNode::get(), and llvm::MDNode::getContext().

◆ getAsMDNode()

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

Return this as a bar MDNode.

Definition at line 113 of file DebugLoc.h.

Referenced by getParentPad(), and getSubprogram().

◆ 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 49 of file DebugLoc.cpp.

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

Referenced by llvm::CodeViewDebug::beginFunctionImpl().

◆ getInlinedAt()

DILocation * DebugLoc::getInlinedAt ( ) const

Definition at line 40 of file DebugLoc.cpp.

References assert().

Referenced by dump(), print(), and printDebugLoc().

◆ 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 45 of file DebugLoc.cpp.

Referenced by getFnDebugLoc().

◆ getLine()

unsigned DebugLoc::getLine ( ) const

◆ getScope()

MDNode * DebugLoc::getScope ( ) const

◆ hasTrivialDestructor()

bool llvm::DebugLoc::hasTrivialDestructor ( ) const

Check whether this has a trivial destructor.

Definition at line 70 of file DebugLoc.h.

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

Referenced by llvm::MachineInstr::addImplicitDefUseOperands(), llvm::SDNode::SDNode(), and llvm::MachineInstr::setDebugLoc().

◆ operator bool()

llvm::DebugLoc::operator bool ( ) const

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 67 of file DebugLoc.h.

◆ operator DILocation *()

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

Definition at line 56 of file DebugLoc.h.

◆ operator!=()

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

Definition at line 116 of file DebugLoc.h.

References dump(), and print().

◆ operator*()

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

Definition at line 58 of file DebugLoc.h.

◆ operator->()

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

Definition at line 57 of file DebugLoc.h.

◆ operator==()

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

Definition at line 115 of file DebugLoc.h.

◆ print()

void DebugLoc::print ( raw_ostream OS) const

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

Definition at line 117 of file DebugLoc.cpp.

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

Referenced by operator!=(), and llvm::MachineInstr::print().

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