llvm.org GIT mirror llvm / 1642cf1
[LLVM-C] Correct The Current Debug Location Accessors Summary: Deprecate the existing accessors for the "current debug location" of an IRBuilder. The setter could not handle being reset to NULL, and the getter would create bogus metadata if the NULL location was returned. Provide direct metadata-based accessors instead. Reviewers: whitequark, deadalnix Reviewed By: whitequark Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60484 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358039 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 4 months ago
2 changed file(s) with 45 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
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);
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