MDNode *getNode() { return MDNode::get(Context, None); }
MDNode *getNode(Metadata *MD) { return MDNode::get(Context, MD); }
MDNode *getNode(Metadata *MD1, Metadata *MD2) {
MDNode *getNode() { return MDNode::get(Context, None); }
MDNode *getNode(Metadata *MD) { return MDNode::get(Context, MD); }
MDNode *getNode(Metadata *MD1, Metadata *MD2) {
nullptr, false, false, 0, nullptr, 0, 0, 0,
0);
}
nullptr, false, false, 0, nullptr, 0, 0, 0,
0);
}
+ MDFile *getFile() {
+ return MDFile::getDistinct(Context, "file.c", "/path/to/dir");
+ }
+ MDBasicType *getBasicType(StringRef Name) {
+ return MDBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name);
+ }
+ MDDerivedType *getDerivedType() {
+ return MDDerivedType::getDistinct(Context, dwarf::DW_TAG_pointer_type, "",
+ nullptr, 0, nullptr,
+ getBasicType("basictype"), 1, 2, 0, 0);
+ }
+ ConstantAsMetadata *getConstantAsMetadata() {
+ return ConstantAsMetadata::get(
+ ConstantInt::get(Type::getInt32Ty(Context), Counter++));
+ }
typedef MetadataTest MDGlobalVariableTest;
TEST_F(MDGlobalVariableTest, get) {
typedef MetadataTest MDGlobalVariableTest;
TEST_F(MDGlobalVariableTest, get) {
unsigned Line = 5;
Metadata *Type = MDTuple::getDistinct(Context, None);
bool IsLocalToUnit = false;
bool IsDefinition = true;
unsigned Line = 5;
Metadata *Type = MDTuple::getDistinct(Context, None);
bool IsLocalToUnit = false;
bool IsDefinition = true;
- Metadata *Variable = MDTuple::getDistinct(Context, None);
- Metadata *StaticDataMemberDeclaration = MDTuple::getDistinct(Context, None);
+ ConstantAsMetadata *Variable = getConstantAsMetadata();
+ MDDerivedType *StaticDataMemberDeclaration = getDerivedType();
auto *N = MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, Variable,
auto *N = MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, Variable,
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, File, Name, LinkageName, File,
- Line, Type, IsLocalToUnit, IsDefinition,
- Variable, StaticDataMemberDeclaration));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, getSubprogram(), Name, LinkageName,
+ File, Line, Type, IsLocalToUnit, IsDefinition,
+ Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, "other", LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, "other", File, Line,
Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, "other", LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, "other", File, Line,
Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
- EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, Scope,
- Line, Type, IsLocalToUnit, IsDefinition,
- Variable, StaticDataMemberDeclaration));
+ EXPECT_NE(N,
+ MDGlobalVariable::get(Context, Scope, Name, LinkageName, getFile(),
+ Line, Type, IsLocalToUnit, IsDefinition,
+ Variable, StaticDataMemberDeclaration));
EXPECT_NE(N,
MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line + 1, Type, IsLocalToUnit, IsDefinition,
EXPECT_NE(N,
MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line + 1, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
TempMDGlobalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
TempMDGlobalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
TEST_F(MDLocalVariableTest, get) {
unsigned Tag = dwarf::DW_TAG_arg_variable;
TEST_F(MDLocalVariableTest, get) {
unsigned Tag = dwarf::DW_TAG_arg_variable;
- Metadata *InlinedAtScope = MDTuple::getDistinct(Context, None);
- Metadata *InlinedAt =
- MDLocation::getDistinct(Context, 10, 20, InlinedAtScope);
+ MDLocation *InlinedAt =
+ MDLocation::getDistinct(Context, 10, 20, getSubprogram());
auto *N = MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
Arg, Flags, InlinedAt);
auto *N = MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
Arg, Flags, InlinedAt);
EXPECT_NE(N, MDLocalVariable::get(Context, dwarf::DW_TAG_auto_variable, Scope,
Name, File, Line, Type, Arg, Flags,
InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, dwarf::DW_TAG_auto_variable, Scope,
Name, File, Line, Type, Arg, Flags,
InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(Context, Tag, File, Name, File, Line,
- Type, Arg, Flags, InlinedAt));
+ EXPECT_NE(N, MDLocalVariable::get(Context, Tag, getSubprogram(), Name, File,
+ Line, Type, Arg, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, "other", File, Line,
Type, Arg, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, "other", File, Line,
Type, Arg, Flags, InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, Scope, Line,
+ EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, getFile(), Line,
Type, Arg, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1,
Type, Arg, Flags, InlinedAt));
Type, Arg, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1,
Type, Arg, Flags, InlinedAt));
Arg + 1, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
Arg, ~Flags, InlinedAt));
Arg + 1, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
Arg, ~Flags, InlinedAt));
- EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
- Arg, Flags, Scope));
+ EXPECT_NE(N, MDLocalVariable::get(
+ Context, Tag, Scope, Name, File, Line, Type, Arg, Flags,
+ MDLocation::getDistinct(Context, 10, 20, getSubprogram())));
TempMDLocalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
TempMDLocalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));