[llvm] 0e7341b - worked on review comments
YASHASVI KHATAVKAR via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 12:25:32 PST 2022
Author: YASHASVI KHATAVKAR
Date: 2022-02-10T15:24:51-05:00
New Revision: 0e7341b7b19995693bfe93a7a48415ed8f20dc58
URL: https://github.com/llvm/llvm-project/commit/0e7341b7b19995693bfe93a7a48415ed8f20dc58
DIFF: https://github.com/llvm/llvm-project/commit/0e7341b7b19995693bfe93a7a48415ed8f20dc58.diff
LOG: worked on review comments
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 8876fbc2ac0d..a5e0f550733a 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -234,7 +234,7 @@ namespace llvm {
/// \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);
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index aec200486f78..ea67791448ea 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -301,7 +301,7 @@ DIStringType *DIBuilder::createStringType(StringRef Name,
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");
diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index a6071ab028e3..524752168b09 100644
--- a/llvm/unittests/IR/DebugInfoTest.cpp
+++ b/llvm/unittests/IR/DebugInfoTest.cpp
@@ -258,7 +258,15 @@ TEST(DIBuilder, CreateStringType) {
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 @@ TEST(DIBuilder, CreateStringType) {
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) {
More information about the llvm-commits
mailing list