public static T SetDebugLocation <T>(this T value, DILocation location) where T : Value { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (location == null) { return(value); } if (value is Instructions.Instruction instruction) { if (!location.Scope.SubProgram.Describes(instruction.ContainingBlock.ContainingFunction)) { throw new ArgumentException("Location does not describe the function containing the provided instruction", nameof(location)); } NativeMethods.LLVMSetDILocation(value.ValueHandle, location.MetadataHandle); } return(value); }
private void EmitLocation(IAstNode?node) { DILocalScope?scope = null; if (LexicalBlocks.Count > 0) { scope = LexicalBlocks.Peek( ); } else if (InstructionBuilder.InsertFunction != null && InstructionBuilder.InsertFunction.DISubProgram != null) { scope = InstructionBuilder.InsertFunction.DISubProgram; } DILocation?loc = null; if (scope != null) { loc = new DILocation(InstructionBuilder.Context , ( uint )(node?.Location.StartLine ?? 0) , ( uint )(node?.Location.StartColumn ?? 0) , scope ); } InstructionBuilder.SetDebugLocation(loc); }