[PATCH] D118276: Adding a DIBuilder interface for Fortran's assumed length string
ykhatav via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 12:47:40 PST 2022
ykhatav updated this revision to Diff 405068.
ykhatav added a comment.
Worked on review comments
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118276/new/
https://reviews.llvm.org/D118276
Files:
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/IR/DIBuilder.cpp
llvm/unittests/IR/DebugInfoTest.cpp
Index: llvm/unittests/IR/DebugInfoTest.cpp
===================================================================
--- llvm/unittests/IR/DebugInfoTest.cpp
+++ llvm/unittests/IR/DebugInfoTest.cpp
@@ -258,7 +258,15 @@
StringRef StrName = "string";
DIVariable *StringLen = DIB.createAutoVariable(Scope, StrName, F, 0, nullptr,
false, DINode::FlagZero, 0);
- DIExpression *StringLocationExp = DIB.createExpression();
+ auto getDIExpression = [&DIB](int offset) {
+ SmallVector<uint64_t, 4> ops;
+ ops.push_back(llvm::dwarf::DW_OP_push_object_address);
+ DIExpression::appendOffset(ops, offset);
+ ops.push_back(llvm::dwarf::DW_OP_deref);
+
+ return DIB.createExpression(ops);
+ };
+ DIExpression *StringLocationExp = getDIExpression(1);
DIStringType *StringType =
DIB.createStringType(StrName, StringLen, StringLocationExp);
@@ -266,22 +274,16 @@
EXPECT_EQ(StringType->getName(), StrName);
EXPECT_EQ(StringType->getStringLength(), StringLen);
EXPECT_EQ(StringType->getStringLocationExp(), StringLocationExp);
-}
-TEST(DIBuilder, CreateStringTypeExp) {
- LLVMContext Ctx;
- std::unique_ptr<Module> M(new Module("MyModule", Ctx));
- DIBuilder DIB(*M);
- StringRef StrName = "string";
- DIExpression *StringLocationExp = DIB.createExpression();
- DIExpression *StringLengthExp = DIB.createExpression();
+ StringRef StrNameExp = "stringexp";
+ DIExpression *StringLengthExp = getDIExpression(2);
DIStringType *StringTypeExp =
- DIB.createStringTypeExp(StrName, StringLengthExp, StringLocationExp);
+ DIB.createStringType(StrNameExp, StringLengthExp, StringLocationExp);
EXPECT_TRUE(isa_and_nonnull<DIStringType>(StringTypeExp));
- EXPECT_EQ(StringTypeExp->getName(), StrName);
- EXPECT_EQ(StringTypeExp->getStringLengthExp(), StringLengthExp);
+ EXPECT_EQ(StringTypeExp->getName(), StrNameExp);
EXPECT_EQ(StringTypeExp->getStringLocationExp(), StringLocationExp);
+ EXPECT_EQ(StringTypeExp->getStringLengthExp(), StringLengthExp);
}
TEST(DIBuilder, DIEnumerator) {
Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -303,7 +303,7 @@
StringLength, nullptr, StrLocationExp, 0, 0, 0);
}
-DIStringType *DIBuilder::createStringTypeExp(StringRef Name,
+DIStringType *DIBuilder::createStringType(StringRef Name,
DIExpression *StringLengthExp,
DIExpression *StrLocationExp) {
assert(!Name.empty() && "Unable to create type without name");
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -234,7 +234,7 @@
/// \param Name Type name.
/// \param StringLengthExp String length expressed in DIExpression form.
/// \param StrLocationExp Optional memory location of the string.
- DIStringType *createStringTypeExp(StringRef Name,
+ DIStringType *createStringType(StringRef Name,
DIExpression *StringLengthExp,
DIExpression *StrLocationExp = nullptr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118276.405068.patch
Type: text/x-patch
Size: 3350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220201/38533ab3/attachment.bin>
More information about the llvm-commits
mailing list