]> granicus.if.org Git - llvm/commitdiff
[LLVM-C] Correct The Current Debug Location Accessors (Again)
authorRobert Widmann <devteam.codafi@gmail.com>
Wed, 10 Apr 2019 14:19:05 +0000 (14:19 +0000)
committerRobert Widmann <devteam.codafi@gmail.com>
Wed, 10 Apr 2019 14:19:05 +0000 (14:19 +0000)
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

bindings/go/llvm/IRBindings.cpp
bindings/go/llvm/IRBindings.h
bindings/go/llvm/ir.go
include/llvm-c/Core.h
include/llvm-c/DebugInfo.h
lib/IR/Core.cpp
lib/IR/DebugInfo.cpp

index 102b79b8c9c669053227264afd16f5f542f16ac3..5b84f482b16b761e58f8a0469ed4e954a0d067ba 100644 (file)
@@ -50,7 +50,7 @@ void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD) {
   unwrap<Instruction>(Inst)->setMetadata(KindID, N);
 }
 
-void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
+void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
                                   unsigned Col, LLVMMetadataRef Scope,
                                   LLVMMetadataRef InlinedAt) {
   unwrap(Bref)->SetCurrentDebugLocation(
@@ -58,7 +58,7 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
                     InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr));
 }
 
-LLVMDebugLocMetadata LLVMGetCurrentDebugLocation2(LLVMBuilderRef Bref) {
+LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref) {
   const auto& Loc = unwrap(Bref)->getCurrentDebugLocation();
   const auto* InlinedAt = Loc.getInlinedAt();
   const LLVMDebugLocMetadata md{
index 04cecdafccd80ec2f9e9df6666dbcd3583fa348c..778b0d21bb260cbff448d1ea49e46c08000e8726 100644 (file)
@@ -43,11 +43,11 @@ void LLVMAddNamedMetadataOperand2(LLVMModuleRef M, const char *name,
                                   LLVMMetadataRef Val);
 void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD);
 
-void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
+void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
                                   unsigned Col, LLVMMetadataRef Scope,
                                   LLVMMetadataRef InlinedAt);
 
-struct LLVMDebugLocMetadata LLVMGetCurrentDebugLocation2(LLVMBuilderRef Bref);
+struct LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref);
 
 #ifdef __cplusplus
 }
index 4682cf35ddbfc9446b62268fec144742d81ce2db..555055f5997e05712d27d07fa1fd1a5ba440965a 100644 (file)
@@ -1301,11 +1301,11 @@ type DebugLoc struct {
        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()
 func (b Builder) GetCurrentDebugLocation() (loc DebugLoc) {
-       md := C.LLVMGetCurrentDebugLocation2(b.C)
+       md := C.LLVMGoGetCurrentDebugLocation(b.C)
        loc.Line = uint(md.Line)
        loc.Col = uint(md.Col)
        loc.Scope = Metadata{C: md.Scope}
index 6adb4d80011cfb8270f5902e9903f69140a43b18..3d153d50aa904a49147e465f4ef386bb5ab37281 100644 (file)
@@ -3510,9 +3510,42 @@ void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
 void LLVMDisposeBuilder(LLVMBuilderRef Builder);
 
 /* Metadata */
+
+/**
+ * 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);
+  
+/**
+ * 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);
-void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
 
 /* Terminators */
 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
index 655b80d2796ee0adb5c64aed53f64258033c33d6..d613a26e95ecbacccfdc36922e21c1e3a14fd79e 100644 (file)
@@ -451,6 +451,15 @@ unsigned LLVMDILocationGetColumn(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.
  * \param Builder        The DIBuilder.
index 997f5330dec76f031f0bf709c0a2a6a782157d70..44291a1784daceec5b4f25588efb1a3fdad45685 100644 (file)
@@ -3006,6 +3006,17 @@ void LLVMDisposeBuilder(LLVMBuilderRef Builder) {
 
 /*--.. 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) {
   MDNode *Loc =
       L ? cast<MDNode>(unwrap<MetadataAsValue>(L)->getMetadata()) : nullptr;
@@ -3022,7 +3033,6 @@ void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) {
   unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
 }
 
-
 /*--.. Instruction builders ................................................--*/
 
 LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef B) {
index ef21b6a555f4ba7304c6ace2438e100a79c0606d..773d547a13690ab9eef72cc0bead4e24a3d9ef38 100644 (file)
@@ -899,6 +899,10 @@ LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location) {
   return wrap(unwrapDI<DILocation>(Location)->getScope());
 }
 
+LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location) {
+  return wrap(unwrapDI<DILocation>(Location)->getInlinedAt());
+}
+
 LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
                                               const char *Name, size_t NameLen,
                                               int64_t Value,