[llvm] 99f990b - Added StringLocationExp to the new apis

YASHASVI KHATAVKAR via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 10 12:25:27 PST 2022


Author: YASHASVI KHATAVKAR
Date: 2022-02-10T15:24:50-05:00
New Revision: 99f990be64804d1880f762609ec9b49added691a

URL: https://github.com/llvm/llvm-project/commit/99f990be64804d1880f762609ec9b49added691a
DIFF: https://github.com/llvm/llvm-project/commit/99f990be64804d1880f762609ec9b49added691a.diff

LOG: Added  StringLocationExp to the new apis

Added: 
    

Modified: 
    llvm/include/llvm/IR/DIBuilder.h
    llvm/lib/IR/DIBuilder.cpp
    llvm/unittests/IR/DebugInfoTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h
index e58c783dd769..2ba3d9817013 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -220,21 +220,23 @@ namespace llvm {
     /// \param Name        Type name.
     /// \param SizeInBits  Size of the type.
     DIStringType *createStringType(StringRef Name, uint64_t SizeInBits);
-    
+
     /// Create debugging information entry for Fortran
     /// assumed length string type.
     /// \param Name            Type name.
-    /// \param StringLength    String length expressed either as Metadata * or DIVariable *.
+    /// \param StringLength    String length expressed as Metadata *.
     /// \param StrLocationExp  Optional memory location of the string.
-    DIStringType *createStringType(StringRef Name,  PointerUnion<Metadata *, DIVariable *>StringLength, Metadata *StrLocationExp=nullptr);
-    
+    DIStringType *createStringType(StringRef Name, Metadata *StringLength,
+                                   Metadata *StrLocationExp = nullptr);
+
     /// Create debugging information entry for Fortran
     /// assumed length string type.
-    /// \param Name          Type name.
+    /// \param Name             Type name.
     /// \param StringLengthExp  String length expressed in DIExpression form.
-    /// \param StrLocationExp  Optional memory location of the string.
+    /// \param StrLocationExp   Optional memory location of the string.
     DIStringType *createStringTypeExp(StringRef Name,
-                                      DIExpression *StringLengthExp, Metadata *StrLocationExp=nullptr);
+                                      DIExpression *StringLengthExp,
+                                      Metadata *StrLocationExp = nullptr);
 
     /// Create debugging information entry for a qualified
     /// type, e.g. 'const int'.

diff  --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 9b66b369ef00..1e8ebd7e24d3 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -294,17 +294,19 @@ DIStringType *DIBuilder::createStringType(StringRef Name, uint64_t SizeInBits) {
 }
 
 DIStringType *DIBuilder::createStringType(StringRef Name,
-                                          PointerUnion<Metadata *, DIVariable *>StringLength, Metadata *StrLocationExp) {
+                                          Metadata *StringLength,
+                                          Metadata *StrLocationExp) {
   assert(!Name.empty() && "Unable to create type without name");
   return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
                            StringLength, nullptr, StrLocationExp, 0, 0, 0);
 }
 
 DIStringType *DIBuilder::createStringTypeExp(StringRef Name,
-                                             DIExpression *StringLengthExp, Metadata *StrLocationExp) {
+                                             DIExpression *StringLengthExp,
+                                             Metadata *StrLocationExp) {
   assert(!Name.empty() && "Unable to create type without name");
   return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name, nullptr,
-                           StringLengthExp,StrLocationExp, 0, 0, 0);
+                           StringLengthExp, StrLocationExp, 0, 0, 0);
 }
 
 DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) {

diff  --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index f8e5e891d542..682211535333 100644
--- a/llvm/unittests/IR/DebugInfoTest.cpp
+++ b/llvm/unittests/IR/DebugInfoTest.cpp
@@ -252,11 +252,11 @@ TEST(DIBuilder, CreateStringType) {
   std::unique_ptr<Module> M(new Module("MyModule", Ctx));
   DIBuilder DIB(*M);
   StringRef StrName = "string";
-  DIStringType *StringType = DIB.createStringType(StrName,nullptr);
+  DIStringType *StringType = DIB.createStringType(StrName, nullptr);
 
   EXPECT_TRUE(isa_and_nonnull<DIStringType>(StringType));
-  EXPECT_EQ(StringType->getName(),"string");
-  EXPECT_EQ(StringType->getStringLength(),nullptr);
+  EXPECT_EQ(StringType->getName(), "string");
+  EXPECT_EQ(StringType->getStringLength(), nullptr);
 }
 
 TEST(DIBuilder, DIEnumerator) {


        


More information about the llvm-commits mailing list