llvm.org GIT mirror llvm / e9dc514
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358086 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 5 months ago
7 changed file(s) with 64 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4949 unwrap(Inst)->setMetadata(KindID, N);
5050 }
5151
52 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
52 void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
5353 unsigned Col, LLVMMetadataRef Scope,
5454 LLVMMetadataRef InlinedAt) {
5555 unwrap(Bref)->SetCurrentDebugLocation(
5757 InlinedAt ? unwrap(InlinedAt) : nullptr));
5858 }
5959
60 LLVMDebugLocMetadata LLVMGetCurrentDebugLocation2(LLVMBuilderRef Bref) {
60 LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref) {
6161 const auto& Loc = unwrap(Bref)->getCurrentDebugLocation();
6262 const auto* InlinedAt = Loc.getInlinedAt();
6363 const LLVMDebugLocMetadata md{
4242 LLVMMetadataRef Val);
4343 void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD);
4444
45 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
45 void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
4646 unsigned Col, LLVMMetadataRef Scope,
4747 LLVMMetadataRef InlinedAt);
4848
49 struct LLVMDebugLocMetadata LLVMGetCurrentDebugLocation2(LLVMBuilderRef Bref);
49 struct LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref);
5050
5151 #ifdef __cplusplus
5252 }
13001300 InlinedAt Metadata
13011301 }
13021302 func (b Builder) SetCurrentDebugLocation(line, col uint, scope, inlinedAt Metadata) {
1303 C.LLVMSetCurrentDebugLocation2(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
1303 C.LLVMGoSetCurrentDebugLocation(b.C, C.unsigned(line), C.unsigned(col), scope.C, inlinedAt.C)
13041304 }
13051305 // Get current debug location. Please do not call this function until setting debug location with SetCurrentDebugLocation()
13061306 func (b Builder) GetCurrentDebugLocation() (loc DebugLoc) {
1307 md := C.LLVMGetCurrentDebugLocation2(b.C)
1307 md := C.LLVMGoGetCurrentDebugLocation(b.C)
13081308 loc.Line = uint(md.Line)
13091309 loc.Col = uint(md.Col)
13101310 loc.Scope = Metadata{C: md.Scope}
35093509 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
35103510
35113511 /* Metadata */
3512
3513 /**
3514 * Get location information used by debugging information.
3515 *
3516 * @see llvm::IRBuilder::getCurrentDebugLocation()
3517 */
3518 LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
3519
3520 /**
3521 * Set location information used by debugging information.
3522 *
3523 * To clear the location metadata of the given instruction, pass NULL to \p Loc.
3524 *
3525 * @see llvm::IRBuilder::SetCurrentDebugLocation()
3526 */
3527 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
3528
3529 /**
3530 * Attempts to set the debug location for the given instruction using the
3531 * current debug location for the given builder. If the builder has no current
3532 * debug location, this function is a no-op.
3533 *
3534 * @see llvm::IRBuilder::SetInstDebugLocation()
3535 */
3536 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
3537
3538 /**
3539 * Deprecated: Passing the NULL location will crash.
3540 * Use LLVMGetCurrentDebugLocation2 instead.
3541 */
35123542 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
3543 /**
3544 * Deprecated: Returning the NULL location will crash.
3545 * Use LLVMGetCurrentDebugLocation2 instead.
3546 */
35133547 LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
3514 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
35153548
35163549 /* Terminators */
35173550 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
451451 LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location);
452452
453453 /**
454 * Get the "inline at" location associated with this debug location.
455 * \param Location The debug location.
456 *
457 * @see DILocation::getInlinedAt()
458 */
459 LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location);
460
461
462 /**
454463 * Create a type array.
455464 * \param Builder The DIBuilder.
456465 * \param Data The type elements.
30053005
30063006 /*--.. Metadata builders ...................................................--*/
30073007
3008 LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder) {
3009 return wrap(unwrap(Builder)->getCurrentDebugLocation().getAsMDNode());
3010 }
3011
3012 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc) {
3013 if (Loc)
3014 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc(unwrap(Loc)));
3015 else
3016 unwrap(Builder)->SetCurrentDebugLocation(DebugLoc());
3017 }
3018
30083019 void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L) {
30093020 MDNode *Loc =
30103021 L ? cast(unwrap(L)->getMetadata()) : nullptr;
30203031 void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) {
30213032 unwrap(Builder)->SetInstDebugLocation(unwrap(Inst));
30223033 }
3023
30243034
30253035 /*--.. Instruction builders ................................................--*/
30263036
898898 return wrap(unwrapDI(Location)->getScope());
899899 }
900900
901 LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location) {
902 return wrap(unwrapDI(Location)->getInlinedAt());
903 }
904
901905 LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
902906 const char *Name, size_t NameLen,
903907 int64_t Value,