[NFC] Add DebugVariable constructor that takes DbgVariableIntrinsic pointer
authorOCHyams <orlando.hyams@sony.com>
Thu, 20 Oct 2022 14:26:40 +0000 (15:26 +0100)
committerOCHyams <orlando.hyams@sony.com>
Thu, 20 Oct 2022 14:28:00 +0000 (15:28 +0100)
Note: The constructor definition cannot be inline without some refactoring as
it introduces a circular dependency between the headers
llvm/IR/DebugInfoMetadata.h (this file) and llvm/IR/IntrinsicInst.h (where
DbgVariableIntrinsic is defined).

Reviewed By: jryans

Differential Revision: https://reviews.llvm.org/D133286

llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/IR/DebugInfoMetadata.cpp

index db1d031..8fc3f54 100644 (file)
@@ -64,6 +64,8 @@ namespace dwarf {
 enum Tag : uint16_t;
 }
 
+class DbgVariableIntrinsic;
+
 extern cl::opt<bool> EnableFSDiscriminator;
 
 class DITypeRefArray {
@@ -3629,6 +3631,8 @@ class DebugVariable {
   static const FragmentInfo DefaultFragment;
 
 public:
+  DebugVariable(const DbgVariableIntrinsic *DII);
+
   DebugVariable(const DILocalVariable *Var, Optional<FragmentInfo> FragmentInfo,
                 const DILocation *InlinedAt)
       : Variable(Var), Fragment(FragmentInfo), InlinedAt(InlinedAt) {}
index e8d8eaf..b29daeb 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
 
@@ -34,6 +35,11 @@ cl::opt<bool> EnableFSDiscriminator(
 const DIExpression::FragmentInfo DebugVariable::DefaultFragment = {
     std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()};
 
+DebugVariable::DebugVariable(const DbgVariableIntrinsic *DII)
+    : Variable(DII->getVariable()),
+      Fragment(DII->getExpression()->getFragmentInfo()),
+      InlinedAt(DII->getDebugLoc().getInlinedAt()) {}
+
 DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
                        unsigned Column, ArrayRef<Metadata *> MDs,
                        bool ImplicitCode)