forked from OSchip/llvm-project
[LLVM-C] Correct The Current Debug Location Accessors (Again)
Summary: Resubmitting D60484 with the conflicting Go bindings renamed to avoid collisions. Reviewers: whitequark, deadalnix Subscribers: hiraditya, llvm-commits, sammccall Tags: #llvm Differential Revision: https://reviews.llvm.org/D60511 llvm-svn: 358086
This commit is contained in:
parent
aae424a2d2
commit
cce47418c9
|
@ -50,7 +50,7 @@ void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD) {
|
||||||
unwrap<Instruction>(Inst)->setMetadata(KindID, N);
|
unwrap<Instruction>(Inst)->setMetadata(KindID, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
|
void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
|
||||||
unsigned Col, LLVMMetadataRef Scope,
|
unsigned Col, LLVMMetadataRef Scope,
|
||||||
LLVMMetadataRef InlinedAt) {
|
LLVMMetadataRef InlinedAt) {
|
||||||
unwrap(Bref)->SetCurrentDebugLocation(
|
unwrap(Bref)->SetCurrentDebugLocation(
|
||||||
|
@ -58,7 +58,7 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
|
||||||
InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr));
|
InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMDebugLocMetadata LLVMGetCurrentDebugLocation2(LLVMBuilderRef Bref) {
|
LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref) {
|
||||||
const auto& Loc = unwrap(Bref)->getCurrentDebugLocation();
|
const auto& Loc = unwrap(Bref)->getCurrentDebugLocation();
|
||||||
const auto* InlinedAt = Loc.getInlinedAt();
|
const auto* InlinedAt = Loc.getInlinedAt();
|
||||||
const LLVMDebugLocMetadata md{
|
const LLVMDebugLocMetadata md{
|
||||||
|
|
|
@ -43,11 +43,11 @@ void LLVMAddNamedMetadataOperand2(LLVMModuleRef M, const char *name,
|
||||||
LLVMMetadataRef Val);
|
LLVMMetadataRef Val);
|
||||||
void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD);
|
void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD);
|
||||||
|
|
||||||
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
|
void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
|
||||||
unsigned Col, LLVMMetadataRef Scope,
|
unsigned Col, LLVMMetadataRef Scope,
|
||||||
LLVMMetadataRef InlinedAt);
|
LLVMMetadataRef InlinedAt);
|
||||||
|
|
||||||
struct LLVMDebugLocMetadata LLVMGetCurrentDebugLocation2(LLVMBuilderRef Bref);
|
struct LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1301,11 +1301,11 @@ type DebugLoc struct {
|
||||||
InlinedAt Metadata
|
InlinedAt Metadata
|
||||||
}
|
}
|
||||||
func (b Builder) SetCurrentDebugLocation(line, col uint, scope, inlinedAt Metadata) {
|
func (b Builder) SetCurrentDebugLocation(line, col uint, scope, inlinedAt Metadata) {
|
||||||
C.LLVMSetCurrentDebugLocation2(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
|
C.LLVMGoSetCurrentDebugLocation(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
|
||||||
}
|
}
|
||||||
// Get current debug location. Please do not call this function until setting debug location with SetCurrentDebugLocation()
|
// Get current debug location. Please do not call this function until setting debug location with SetCurrentDebugLocation()
|
||||||
func (b Builder) GetCurrentDebugLocation() (loc DebugLoc) {
|
func (b Builder) GetCurrentDebugLocation() (loc DebugLoc) {
|
||||||
md := C.LLVMGetCurrentDebugLocation2(b.C)
|
md := C.LLVMGoGetCurrentDebugLocation(b.C)
|
||||||
loc.Line = uint(md.Line)
|
loc.Line = uint(md.Line)
|
||||||
loc.Col = uint(md.Col)
|
loc.Col = uint(md.Col)
|
||||||
loc.Scope = Metadata{C: md.Scope}
|
loc.Scope = Metadata{C: md.Scope}
|
||||||
|
|
|
@ -3510,10 +3510,43 @@ void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
|
||||||
void LLVMDisposeBuilder(LLVMBuilderRef Builder);
|
void LLVMDisposeBuilder(LLVMBuilderRef Builder);
|
||||||
|
|
||||||
/* Metadata */
|
/* Metadata */
|
||||||
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
|
|
||||||
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
|
/**
|
||||||
|
* Get location information used by debugging information.
|
||||||
|
*
|
||||||
|
* @see llvm::IRBuilder::getCurrentDebugLocation()
|
||||||
|
*/
|
||||||
|
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set location information used by debugging information.
|
||||||
|
*
|
||||||
|
* To clear the location metadata of the given instruction, pass NULL to \p Loc.
|
||||||
|
*
|
||||||
|
* @see llvm::IRBuilder::SetCurrentDebugLocation()
|
||||||
|
*/
|
||||||
|
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to set the debug location for the given instruction using the
|
||||||
|
* current debug location for the given builder. If the builder has no current
|
||||||
|
* debug location, this function is a no-op.
|
||||||
|
*
|
||||||
|
* @see llvm::IRBuilder::SetInstDebugLocation()
|
||||||
|
*/
|
||||||
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
|
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated: Passing the NULL location will crash.
|
||||||
|
* Use LLVMGetCurrentDebugLocation2 instead.
|
||||||
|
*/
|
||||||
|
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
|
||||||
|
/**
|
||||||
|
* Deprecated: Returning the NULL location will crash.
|
||||||
|
* Use LLVMGetCurrentDebugLocation2 instead.
|
||||||
|
*/
|
||||||
|
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
|
||||||
|
|
||||||
/* Terminators */
|
/* Terminators */
|
||||||
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
|
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
|
||||||
LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
|
LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
|
||||||
|
|
|
@ -451,6 +451,15 @@ unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location);
|
||||||
*/
|
*/
|
||||||
LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location);
|
LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "inline at" location associated with this debug location.
|
||||||
|
* \param Location The debug location.
|
||||||
|
*
|
||||||
|
* @see DILocation::getInlinedAt()
|
||||||
|
*/
|
||||||
|
LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a type array.
|
* Create a type array.
|
||||||
* \param Builder The DIBuilder.
|
* \param Builder The DIBuilder.
|
||||||
|
|
|
@ -3006,6 +3006,17 @@ void LLVMDisposeBuilder(LLVMBuilderRef Builder) {
|
||||||
|
|
||||||
/*--.. Metadata builders ...................................................--*/
|
/*--.. Metadata builders ...................................................--*/
|
||||||
|
|
||||||
|
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder) {
|
||||||
|
return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc) {
|
||||||
|
if (Loc)
|
||||||
|
unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap<MDNode>(Loc)));
|
||||||
|
else
|
||||||
|
unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
|
||||||
|
}
|
||||||
|
|
||||||
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L) {
|
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L) {
|
||||||
MDNode *Loc =
|
MDNode *Loc =
|
||||||
L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
|
L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
|
||||||
|
@ -3022,7 +3033,6 @@ void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) {
|
||||||
unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
|
unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--.. Instruction builders ................................................--*/
|
/*--.. Instruction builders ................................................--*/
|
||||||
|
|
||||||
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B) {
|
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B) {
|
||||||
|
|
|
@ -899,6 +899,10 @@ LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location) {
|
||||||
return wrap(unwrapDI<DILocation>(Location)->getScope());
|
return wrap(unwrapDI<DILocation>(Location)->getScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location) {
|
||||||
|
return wrap(unwrapDI<DILocation>(Location)->getInlinedAt());
|
||||||
|
}
|
||||||
|
|
||||||
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
|
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
|
||||||
const char *Name, size_t NameLen,
|
const char *Name, size_t NameLen,
|
||||||
int64_t Value,
|
int64_t Value,
|
||||||
|
|
Loading…
Reference in New Issue