Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
23587321
Commit
23587321
authored
15 years ago
by
Owen Anderson
Browse files
Options
Downloads
Patches
Plain Diff
Fix unit tests.
llvm-svn: 77734
parent
0087fe6e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/unittests/VMCore/MetadataTest.cpp
+16
-14
16 additions, 14 deletions
llvm/unittests/VMCore/MetadataTest.cpp
with
16 additions
and
14 deletions
llvm/unittests/VMCore/MetadataTest.cpp
+
16
−
14
View file @
23587321
...
@@ -20,13 +20,15 @@ using namespace llvm;
...
@@ -20,13 +20,15 @@ using namespace llvm;
namespace
{
namespace
{
LLVMContext
&
Context
=
getGlobalContext
();
// Test that construction of MDString with different value produces different
// Test that construction of MDString with different value produces different
// MDString objects, even with the same string pointer and nulls in the string.
// MDString objects, even with the same string pointer and nulls in the string.
TEST
(
MDStringTest
,
CreateDifferent
)
{
TEST
(
MDStringTest
,
CreateDifferent
)
{
char
x
[
3
]
=
{
'f'
,
0
,
'A'
};
char
x
[
3
]
=
{
'f'
,
0
,
'A'
};
MDString
*
s1
=
getGlobalContext
().
getMDString
(
StringRef
(
&
x
[
0
],
3
));
MDString
*
s1
=
MDString
::
get
(
Context
,
StringRef
(
&
x
[
0
],
3
));
x
[
2
]
=
'B'
;
x
[
2
]
=
'B'
;
MDString
*
s2
=
getGlobalContext
().
getMDString
(
StringRef
(
&
x
[
0
],
3
));
MDString
*
s2
=
MDString
::
get
(
Context
,
StringRef
(
&
x
[
0
],
3
));
EXPECT_NE
(
s1
,
s2
);
EXPECT_NE
(
s1
,
s2
);
}
}
...
@@ -36,8 +38,8 @@ TEST(MDStringTest, CreateSame) {
...
@@ -36,8 +38,8 @@ TEST(MDStringTest, CreateSame) {
char
x
[
4
]
=
{
'a'
,
'b'
,
'c'
,
'X'
};
char
x
[
4
]
=
{
'a'
,
'b'
,
'c'
,
'X'
};
char
y
[
4
]
=
{
'a'
,
'b'
,
'c'
,
'Y'
};
char
y
[
4
]
=
{
'a'
,
'b'
,
'c'
,
'Y'
};
MDString
*
s1
=
getGlobalContext
().
getMDString
(
StringRef
(
&
x
[
0
],
3
));
MDString
*
s1
=
MDString
::
get
(
Context
,
StringRef
(
&
x
[
0
],
3
));
MDString
*
s2
=
getGlobalContext
().
getMDString
(
StringRef
(
&
y
[
0
],
3
));
MDString
*
s2
=
MDString
::
get
(
Context
,
StringRef
(
&
y
[
0
],
3
));
EXPECT_EQ
(
s1
,
s2
);
EXPECT_EQ
(
s1
,
s2
);
}
}
...
@@ -45,7 +47,7 @@ TEST(MDStringTest, CreateSame) {
...
@@ -45,7 +47,7 @@ TEST(MDStringTest, CreateSame) {
TEST
(
MDStringTest
,
PrintingSimple
)
{
TEST
(
MDStringTest
,
PrintingSimple
)
{
char
*
str
=
new
char
[
13
];
char
*
str
=
new
char
[
13
];
strncpy
(
str
,
"testing 1 2 3"
,
13
);
strncpy
(
str
,
"testing 1 2 3"
,
13
);
MDString
*
s
=
getGlobalContext
().
getMDString
(
StringRef
(
str
,
13
));
MDString
*
s
=
MDString
::
get
(
Context
,
StringRef
(
str
,
13
));
strncpy
(
str
,
"aaaaaaaaaaaaa"
,
13
);
strncpy
(
str
,
"aaaaaaaaaaaaa"
,
13
);
delete
[]
str
;
delete
[]
str
;
...
@@ -57,7 +59,7 @@ TEST(MDStringTest, PrintingSimple) {
...
@@ -57,7 +59,7 @@ TEST(MDStringTest, PrintingSimple) {
// Test printing of MDString with non-printable characters.
// Test printing of MDString with non-printable characters.
TEST
(
MDStringTest
,
PrintingComplex
)
{
TEST
(
MDStringTest
,
PrintingComplex
)
{
char
str
[
5
]
=
{
0
,
'\n'
,
'"'
,
'\\'
,
-
1
};
char
str
[
5
]
=
{
0
,
'\n'
,
'"'
,
'\\'
,
-
1
};
MDString
*
s
=
getGlobalContext
().
getMDString
(
StringRef
(
str
+
0
,
5
));
MDString
*
s
=
MDString
::
get
(
Context
,
StringRef
(
str
+
0
,
5
));
std
::
ostringstream
oss
;
std
::
ostringstream
oss
;
s
->
print
(
oss
);
s
->
print
(
oss
);
EXPECT_STREQ
(
"metadata !
\"\\
00
\\
0A
\\
22
\\
5C
\\
FF
\"
"
,
oss
.
str
().
c_str
());
EXPECT_STREQ
(
"metadata !
\"\\
00
\\
0A
\\
22
\\
5C
\\
FF
\"
"
,
oss
.
str
().
c_str
());
...
@@ -68,8 +70,8 @@ TEST(MDNodeTest, Simple) {
...
@@ -68,8 +70,8 @@ TEST(MDNodeTest, Simple) {
char
x
[
3
]
=
{
'a'
,
'b'
,
'c'
};
char
x
[
3
]
=
{
'a'
,
'b'
,
'c'
};
char
y
[
3
]
=
{
'1'
,
'2'
,
'3'
};
char
y
[
3
]
=
{
'1'
,
'2'
,
'3'
};
MDString
*
s1
=
getGlobalContext
().
getMDString
(
StringRef
(
&
x
[
0
],
3
));
MDString
*
s1
=
MDString
::
get
(
Context
,
StringRef
(
&
x
[
0
],
3
));
MDString
*
s2
=
getGlobalContext
().
getMDString
(
StringRef
(
&
y
[
0
],
3
));
MDString
*
s2
=
MDString
::
get
(
Context
,
StringRef
(
&
y
[
0
],
3
));
ConstantInt
*
CI
=
ConstantInt
::
get
(
getGlobalContext
(),
APInt
(
8
,
0
));
ConstantInt
*
CI
=
ConstantInt
::
get
(
getGlobalContext
(),
APInt
(
8
,
0
));
std
::
vector
<
Value
*>
V
;
std
::
vector
<
Value
*>
V
;
...
@@ -77,10 +79,10 @@ TEST(MDNodeTest, Simple) {
...
@@ -77,10 +79,10 @@ TEST(MDNodeTest, Simple) {
V
.
push_back
(
CI
);
V
.
push_back
(
CI
);
V
.
push_back
(
s2
);
V
.
push_back
(
s2
);
MDNode
*
n1
=
getGlobalContext
().
getMDNode
(
&
V
[
0
],
3
);
MDNode
*
n1
=
MDNode
::
get
(
Context
,
&
V
[
0
],
3
);
Value
*
const
c1
=
n1
;
Value
*
const
c1
=
n1
;
MDNode
*
n2
=
getGlobalContext
().
getMDNode
(
&
c1
,
1
);
MDNode
*
n2
=
MDNode
::
get
(
Context
,
&
c1
,
1
);
MDNode
*
n3
=
getGlobalContext
().
getMDNode
(
&
V
[
0
],
3
);
MDNode
*
n3
=
MDNode
::
get
(
Context
,
&
V
[
0
],
3
);
EXPECT_NE
(
n1
,
n2
);
EXPECT_NE
(
n1
,
n2
);
EXPECT_EQ
(
n1
,
n3
);
EXPECT_EQ
(
n1
,
n3
);
...
@@ -107,7 +109,7 @@ TEST(MDNodeTest, Delete) {
...
@@ -107,7 +109,7 @@ TEST(MDNodeTest, Delete) {
Instruction
*
I
=
new
BitCastInst
(
C
,
Type
::
Int32Ty
);
Instruction
*
I
=
new
BitCastInst
(
C
,
Type
::
Int32Ty
);
Value
*
const
V
=
I
;
Value
*
const
V
=
I
;
MDNode
*
n
=
getGlobalContext
().
getMDNode
(
&
V
,
1
);
MDNode
*
n
=
MDNode
::
get
(
Context
,
&
V
,
1
);
WeakVH
wvh
=
n
;
WeakVH
wvh
=
n
;
EXPECT_EQ
(
n
,
wvh
);
EXPECT_EQ
(
n
,
wvh
);
...
@@ -125,8 +127,8 @@ TEST(NamedMDNodeTest, Search) {
...
@@ -125,8 +127,8 @@ TEST(NamedMDNodeTest, Search) {
Value
*
const
V
=
C
;
Value
*
const
V
=
C
;
Value
*
const
V2
=
C2
;
Value
*
const
V2
=
C2
;
MDNode
*
n
=
getGlobalContext
().
getMDNode
(
&
V
,
1
);
MDNode
*
n
=
MDNode
::
get
(
Context
,
&
V
,
1
);
MDNode
*
n2
=
getGlobalContext
().
getMDNode
(
&
V2
,
1
);
MDNode
*
n2
=
MDNode
::
get
(
Context
,
&
V2
,
1
);
MetadataBase
*
Nodes
[
2
]
=
{
n
,
n2
};
MetadataBase
*
Nodes
[
2
]
=
{
n
,
n2
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment