summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/MetadataTest.cpp
diff options
context:
space:
mode:
authorMatthew Voss <matthew.voss@sony.com>2018-10-03 18:44:53 +0000
committerMatthew Voss <matthew.voss@sony.com>2018-10-03 18:44:53 +0000
commitf8ab35a4f464753751c1df2b56b6c2f9c75d56a7 (patch)
treecd817f07400276d4cf0efea2832f29c75c4d7963 /llvm/unittests/IR/MetadataTest.cpp
parentb80d27a916988f45fa851f23dbb0cdb5649916f7 (diff)
downloadbcm5719-llvm-f8ab35a4f464753751c1df2b56b6c2f9c75d56a7.tar.gz
bcm5719-llvm-f8ab35a4f464753751c1df2b56b6c2f9c75d56a7.zip
Emit template type and value parameter DIEs for template variables.
Summary: Ensure the TemplateParam attribute of the DIGlobalVariable node is translated into the proper DIEs. Resolves https://bugs.llvm.org/show_bug.cgi?id=22119 Reviewers: dblaikie, probinson, aprantl, JDevlieghere, clayborg, whitequark, deadalnix Reviewed By: dblaikie Subscribers: llvm-commits Tags: #debug-info Differential Revision: https://reviews.llvm.org/D52057 llvm-svn: 343706
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp76
1 files changed, 45 insertions, 31 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 48c6cfa9ac8..83b166a263c 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -2014,13 +2014,16 @@ TEST_F(DIGlobalVariableTest, get) {
DIType *Type = getDerivedType();
bool IsLocalToUnit = false;
bool IsDefinition = true;
+ MDTuple *templateParams = getTuple();
DIDerivedType *StaticDataMemberDeclaration =
cast<DIDerivedType>(getDerivedType());
+
uint32_t AlignInBits = 8;
- auto *N = DIGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
- Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits);
+ auto *N = DIGlobalVariable::get(
+ Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
+ IsDefinition, StaticDataMemberDeclaration, templateParams, AlignInBits);
+
EXPECT_EQ(dwarf::DW_TAG_variable, N->getTag());
EXPECT_EQ(Scope, N->getScope());
EXPECT_EQ(Name, N->getName());
@@ -2031,47 +2034,57 @@ TEST_F(DIGlobalVariableTest, get) {
EXPECT_EQ(IsLocalToUnit, N->isLocalToUnit());
EXPECT_EQ(IsDefinition, N->isDefinition());
EXPECT_EQ(StaticDataMemberDeclaration, N->getStaticDataMemberDeclaration());
+ EXPECT_EQ(templateParams, N->getTemplateParams());
EXPECT_EQ(AlignInBits, N->getAlignInBits());
EXPECT_EQ(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
+ StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
- EXPECT_NE(N,
- DIGlobalVariable::get(Context, getSubprogram(), Name, LinkageName,
- File, Line, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
+ EXPECT_NE(N, DIGlobalVariable::get(
+ Context, getSubprogram(), Name, LinkageName, File, Line,
+ Type, IsLocalToUnit, IsDefinition,
+ StaticDataMemberDeclaration, templateParams, AlignInBits));
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, "other", LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
+ StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, "other", File, Line,
Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
- EXPECT_NE(N,
- DIGlobalVariable::get(Context, Scope, Name, LinkageName, getFile(),
- Line, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
- EXPECT_NE(N,
- DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
- Line + 1, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
- EXPECT_NE(N,
- DIGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
- getDerivedType(), IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
+ StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
+ EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName,
+ getFile(), Line, Type, IsLocalToUnit,
+ IsDefinition, StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
+ EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
+ Line + 1, Type, IsLocalToUnit,
+ IsDefinition, StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
+ EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
+ Line, getDerivedType(), IsLocalToUnit,
+ IsDefinition, StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, !IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
+ StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, !IsDefinition,
- StaticDataMemberDeclaration, AlignInBits));
+ StaticDataMemberDeclaration,
+ templateParams, AlignInBits));
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
cast<DIDerivedType>(getDerivedType()),
+ templateParams, AlignInBits));
+ EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
+ Line, Type, IsLocalToUnit, IsDefinition,
+ StaticDataMemberDeclaration, nullptr,
AlignInBits));
EXPECT_NE(N, DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
StaticDataMemberDeclaration,
- (AlignInBits << 1)));
+ templateParams, (AlignInBits << 1)));
TempDIGlobalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -2088,18 +2101,19 @@ TEST_F(DIGlobalVariableExpressionTest, get) {
DIType *Type = getDerivedType();
bool IsLocalToUnit = false;
bool IsDefinition = true;
+ MDTuple *templateParams = getTuple();
auto *Expr = DIExpression::get(Context, {1, 2});
auto *Expr2 = DIExpression::get(Context, {1, 2, 3});
DIDerivedType *StaticDataMemberDeclaration =
cast<DIDerivedType>(getDerivedType());
uint32_t AlignInBits = 8;
- auto *Var = DIGlobalVariable::get(Context, Scope, Name, LinkageName, File,
- Line, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits);
- auto *Var2 = DIGlobalVariable::get(Context, Scope, "other", LinkageName, File,
- Line, Type, IsLocalToUnit, IsDefinition,
- StaticDataMemberDeclaration, AlignInBits);
+ auto *Var = DIGlobalVariable::get(
+ Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
+ IsDefinition, StaticDataMemberDeclaration, templateParams, AlignInBits);
+ auto *Var2 = DIGlobalVariable::get(
+ Context, Scope, "other", LinkageName, File, Line, Type, IsLocalToUnit,
+ IsDefinition, StaticDataMemberDeclaration, templateParams, AlignInBits);
auto *N = DIGlobalVariableExpression::get(Context, Var, Expr);
EXPECT_EQ(Var, N->getVariable());
OpenPOWER on IntegriCloud