[PATCH] D118276: Adding a DIBuilder interface for Fortran's assumed length string
ykhatav via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 31 08:50:35 PST 2022
ykhatav updated this revision to Diff 404556.
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
@@ -251,12 +251,33 @@
LLVMContext Ctx;
std::unique_ptr<Module> M(new Module("MyModule", Ctx));
DIBuilder DIB(*M);
+ DIScope *Scope = DISubprogram::getDistinct(
+ Ctx, nullptr, "", "", nullptr, 0, nullptr, 0, nullptr, 0, 0,
+ DINode::FlagZero, DISubprogram::SPFlagZero, nullptr);
+ DIFile *F = DIB.createFile("main.c", "/");
StringRef StrName = "string";
- DIStringType *StringType = DIB.createStringType(StrName, nullptr);
+ DIVariable *StringLen = DIB.createAutoVariable(Scope, StrName, F, 0, nullptr,
+ false, DINode::FlagZero, 0);
+ DIExpression *StringLocationExp = DIB.createExpression();
+ DIExpression *StringLengthExp = DIB.createExpression();
+ DIStringType *StringType =
+ DIB.createStringType(StrName, StringLen, StringLocationExp);
EXPECT_TRUE(isa_and_nonnull<DIStringType>(StringType));
EXPECT_EQ(StringType->getName(), "string");
- EXPECT_EQ(StringType->getStringLength(), nullptr);
+ EXPECT_EQ(StringType,
+ DIStringType::get(Ctx, dwarf::DW_TAG_string_type, StrName,
+ StringLen, StringLocationExp, nullptr, 0, 0, 0));
+
+ DIStringType *StringTypeExp =
+ DIB.createStringTypeExp(StrName, StringLengthExp, StringLocationExp);
+
+ EXPECT_TRUE(isa_and_nonnull<DIStringType>(StringTypeExp));
+ EXPECT_EQ(StringTypeExp->getName(), "string");
+ EXPECT_EQ(StringTypeExp,
+ DIStringType::get(Ctx, dwarf::DW_TAG_string_type, StrName,
+ StringLengthExp, StringLocationExp, nullptr, 0, 0,
+ 0));
}
TEST(DIBuilder, DIEnumerator) {
Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -296,8 +296,8 @@
}
DIStringType *DIBuilder::createStringType(StringRef Name,
- Metadata *StringLength,
- Metadata *StrLocationExp) {
+ DIVariable *StringLength,
+ DIExpression *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);
@@ -305,7 +305,7 @@
DIStringType *DIBuilder::createStringTypeExp(StringRef Name,
DIExpression *StringLengthExp,
- Metadata *StrLocationExp) {
+ DIExpression *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);
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -224,10 +224,10 @@
/// Create debugging information entry for Fortran
/// assumed length string type.
/// \param Name Type name.
- /// \param StringLength String length expressed as Metadata *.
+ /// \param StringLength String length expressed as DIVariable *.
/// \param StrLocationExp Optional memory location of the string.
- DIStringType *createStringType(StringRef Name, Metadata *StringLength,
- Metadata *StrLocationExp = nullptr);
+ DIStringType *createStringType(StringRef Name, DIVariable *StringLength,
+ DIExpression *StrLocationExp = nullptr);
/// Create debugging information entry for Fortran
/// assumed length string type.
@@ -236,7 +236,7 @@
/// \param StrLocationExp Optional memory location of the string.
DIStringType *createStringTypeExp(StringRef Name,
DIExpression *StringLengthExp,
- Metadata *StrLocationExp = nullptr);
+ DIExpression *StrLocationExp = nullptr);
/// Create debugging information entry for a qualified
/// type, e.g. 'const int'.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118276.404556.patch
Type: text/x-patch
Size: 4536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220131/8b5b8c80/attachment.bin>
More information about the llvm-commits
mailing list