sun::codegen::DebugInfoBuilder
class · Source (opens in a new tab)
class sun::codegen::DebugInfoBuilderBuilds source-level debug metadata for generated LLVM code.
Public Functions
- DebugInfoBuilder
- attachExpressionLocation
- clearLocation
- declareLocal
- declareParameter
- declareThisParameter
- enabled
- enterFunction
- exitFunction
- finalize
- getFile
- popLexicalBlock
- pushLexicalBlock
- resolveType
- stripFromModule
DebugInfoBuilder
public · function · Source (opens in a new tab)
sun::codegen::DebugInfoBuilder::DebugInfoBuilder(llvm::Module *module, bool enabled, bool optimized=false)Build debug metadata, recording whether the generated code is optimized.
attachExpressionLocation
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::attachExpressionLocation(llvm::IRBuilderBase &builder, const sun::support::Position &loc)Set the builder's debug location for the expression about to be emitted: scoped to the insert-point function's subprogram, or cleared when that function has none.
Call once per expression dispatch.
Related: sun::support::Position
clearLocation
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::clearLocation(llvm::IRBuilderBase &builder)Drop the builder's debug location.
Required when switching the insert point into a function that has no subprogram (wrappers, init functions): such functions must carry no debug locations at all.
declareLocal
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::declareLocal(llvm::IRBuilderBase &builder, llvm::AllocaInst *alloca, const std::string &name, const TypePtr &type, const sun::support::Position &loc)Emits debug metadata identifying a local variable and its storage.
Related: TypePtr, sun::support::Position
declareParameter
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::declareParameter(llvm::IRBuilderBase &builder, llvm::AllocaInst *alloca, const std::string &name, const TypePtr &type, const sun::support::Position &loc, unsigned argNo, bool artificial=false)Emits debug metadata identifying a function parameter and its storage.
Related: TypePtr, sun::support::Position
declareThisParameter
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::declareThisParameter(llvm::IRBuilderBase &builder, llvm::AllocaInst *alloca, const TypePtr &classType)'this' receiver: a pointer to the class struct, marked artificial.
Related: TypePtr
enabled
public · function · Source (opens in a new tab)
bool sun::codegen::DebugInfoBuilder::enabled() constReports whether debug metadata generation is enabled.
enterFunction
public · function · Source (opens in a new tab)
DISubprogram * sun::codegen::DebugInfoBuilder::enterFunction(llvm::IRBuilderBase &builder, llvm::Function *func, const std::string &name, const sun::support::Position &loc)Create a DISubprogram for a defined function, attach it, push its scope, and clear the builder's inherited debug location.
Related: sun::support::Position
exitFunction
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::exitFunction(llvm::Function *func)Pop scopes down through this function's subprogram and finalize it.
finalize
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::finalize()Completes debug metadata construction before the module is emitted.
getFile
public · function · Source (opens in a new tab)
DIFile * sun::codegen::DebugInfoBuilder::getFile(const std::optional< std::string > &path)Returns debug metadata for a source file, creating it when necessary.
popLexicalBlock
public · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::popLexicalBlock()Leaves the current lexical block in debug metadata.
pushLexicalBlock
public · function · Source (opens in a new tab)
bool sun::codegen::DebugInfoBuilder::pushLexicalBlock(llvm::IRBuilderBase &builder, const sun::support::Position &loc)Open a DILexicalBlock under the current scope so variables declared in source blocks (if/else, loops, try/catch) get block-accurate visibility.
Returns true when a block was pushed (caller must pair with popLexicalBlock); false when disabled or the insert point is in a function without a subprogram.
Related: sun::support::Position
resolveType
public · function · Source (opens in a new tab)
DIType * sun::codegen::DebugInfoBuilder::resolveType(const TypePtr &type)Returns debug metadata describing the supplied semantic type.
Related: TypePtr
stripFromModule
public · function · static · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::stripFromModule(llvm::Module &module)Remove all debug metadata a module carries (e.g.
inherited from linked .moon bundles built with -g), including the module flags that would make emitObjectFile treat it as a debug build.
Private Functions
currentLocalScope
private · function · Source (opens in a new tab)
DILocalScope * sun::codegen::DebugInfoBuilder::currentLocalScope(llvm::Function *func) constReturns the debug scope active within the supplied function.
declareVariable
private · function · Source (opens in a new tab)
void sun::codegen::DebugInfoBuilder::declareVariable(llvm::IRBuilderBase &builder, llvm::AllocaInst *alloca, llvm::DILocalVariable *var, const sun::support::Position &loc, llvm::DILocalScope *scope)Associates a debug variable with its generated storage and source scope.
Related: sun::support::Position
ensureCompileUnit
private · function · Source (opens in a new tab)
DICompileUnit * sun::codegen::DebugInfoBuilder::ensureCompileUnit(const std::optional< std::string > &hint)Creates the debug compilation unit when one is not already present.
pointerTo
private · function · Source (opens in a new tab)
DIType * sun::codegen::DebugInfoBuilder::pointerTo(llvm::DIType *pointee)Creates debug metadata for a pointer to the supplied type.
resolveTypeImpl
private · function · Source (opens in a new tab)
DIType * sun::codegen::DebugInfoBuilder::resolveTypeImpl(const sun::types::Type &type)Constructs debug metadata describing a semantic type.
Related: sun::types::Type
structFor
private · function · Source (opens in a new tab)
DIType * sun::codegen::DebugInfoBuilder::structFor(const std::string &name, llvm::StructType *st, const std::vector< std::pair< std::string, llvm::DIType * > > &members)Creates debug metadata describing the fields of an LLVM structure.
Private Fields
cu_
private · variable · Source (opens in a new tab)
llvm::DICompileUnit* sun::codegen::DebugInfoBuilder::cu_ = nullptrNo documentation comment.
di_
private · variable · Source (opens in a new tab)
std::unique_ptr<llvm::DIBuilder> sun::codegen::DebugInfoBuilder::di_No documentation comment.
fileCache_
private · variable · Source (opens in a new tab)
std::map<std::string, llvm::DIFile*> sun::codegen::DebugInfoBuilder::fileCache_No documentation comment.
finalized_
private · variable · Source (opens in a new tab)
bool sun::codegen::DebugInfoBuilder::finalized_ = falseNo documentation comment.
module_
private · variable · Source (opens in a new tab)
llvm::Module* sun::codegen::DebugInfoBuilder::module_ = nullptrNo documentation comment.
optimized_
private · variable · Source (opens in a new tab)
bool sun::codegen::DebugInfoBuilder::optimized_ = falseNo documentation comment.
scopeStack_
private · variable · Source (opens in a new tab)
std::vector<llvm::DIScope*> sun::codegen::DebugInfoBuilder::scopeStack_No documentation comment.
typeCache_
private · variable · Source (opens in a new tab)
std::map<const sun::types::Type*, llvm::DIType*> sun::codegen::DebugInfoBuilder::typeCache_No documentation comment.
Related: sun::types::Type