summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-03 20:26:11 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-03 20:26:11 +0000
commit148779df305667b6942fee7e758fdf81a6498f38 (patch)
tree976d85fb9cb4bc8ed54348b045f742be90e10c57 /unittests
parenta303c417bbdb53703c2c17398b08486bde78f1f6 (diff)
Notes
Diffstat (limited to 'unittests')
-rw-r--r--unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp352
-rw-r--r--unittests/DebugInfo/PDB/ErrorChecking.h12
-rw-r--r--unittests/DebugInfo/PDB/StringTableBuilderTest.cpp25
-rw-r--r--unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp20
-rw-r--r--unittests/IR/AttributesTest.cpp2
-rw-r--r--unittests/Support/BinaryStreamTest.cpp14
6 files changed, 335 insertions, 90 deletions
diff --git a/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 3f0e3dab72bd..a9d0d9ef4e69 100644
--- a/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -10,6 +10,7 @@
#include "DwarfGenerator.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Config/llvm-config.h"
@@ -18,8 +19,8 @@
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/Object/ObjectFile.h"
-#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/ObjectYAML/DWARFEmitter.h"
+#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -1191,10 +1192,7 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {
auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
ASSERT_TRUE((bool)ErrOrSections);
-
- auto &DebugSections = *ErrOrSections;
-
- DWARFContextInMemory DwarfContext(DebugSections, 8);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
// Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits();
@@ -1667,6 +1665,13 @@ TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
EXPECT_EQ(DIEs.find(Val2)->second, AbbrevPtrVal2);
}
+void VerifyError(DWARFContext &DwarfContext, StringRef Error) {
+ SmallString<1024> Str;
+ raw_svector_ostream Strm(Str);
+ EXPECT_FALSE(DwarfContext.verify(Strm, DIDT_All));
+ EXPECT_TRUE(Str.str().contains(Error));
+}
+
TEST(DWARFDebugInfo, TestDwarfVerifyInvalidCURef) {
// Create a single compile unit with a single function that has a DW_AT_type
// that is CU relative. The CU offset is not valid becuase it is larger than
@@ -1711,17 +1716,10 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidCURef) {
)";
auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
ASSERT_TRUE((bool)ErrOrSections);
-
- auto &DebugSections = *ErrOrSections;
-
- DWARFContextInMemory DwarfContext(DebugSections, 8);
-
- std::string str;
- raw_string_ostream strm(str);
- EXPECT_FALSE(DwarfContext.verify(strm, DIDT_All));
- const char *err = "error: DW_FORM_ref4 CU offset 0x00001234 is invalid "
- "(must be less than CU size of 0x0000001a):";
- EXPECT_TRUE(strm.str().find(err) != std::string::npos);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext, "error: DW_FORM_ref4 CU offset 0x00001234 is "
+ "invalid (must be less than CU size of "
+ "0x0000001a):");
}
TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddr) {
@@ -1766,17 +1764,9 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddr) {
)";
auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
ASSERT_TRUE((bool)ErrOrSections);
-
- auto &DebugSections = *ErrOrSections;
-
- DWARFContextInMemory DwarfContext(DebugSections, 8);
-
- std::string str;
- raw_string_ostream strm(str);
- EXPECT_FALSE(DwarfContext.verify(strm, DIDT_All));
- strm.flush();
- const char *err = "error: DW_FORM_ref_addr offset beyond .debug_info bounds:";
- EXPECT_TRUE(strm.str().find(err) != std::string::npos);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext,
+ "error: DW_FORM_ref_addr offset beyond .debug_info bounds:");
}
TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRanges) {
@@ -1810,18 +1800,9 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRanges) {
)";
auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
ASSERT_TRUE((bool)ErrOrSections);
-
- auto &DebugSections = *ErrOrSections;
-
- DWARFContextInMemory DwarfContext(DebugSections, 8);
-
- std::string str;
- raw_string_ostream strm(str);
- EXPECT_FALSE(DwarfContext.verify(strm, DIDT_All));
- strm.flush();
- const char *err = "error: DW_AT_ranges offset is beyond .debug_ranges "
- "bounds:";
- EXPECT_TRUE(strm.str().find(err) != std::string::npos);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext,
+ "error: DW_AT_ranges offset is beyond .debug_ranges bounds:");
}
TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStmtList) {
@@ -1855,18 +1836,10 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStmtList) {
)";
auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
ASSERT_TRUE((bool)ErrOrSections);
-
- auto &DebugSections = *ErrOrSections;
-
- DWARFContextInMemory DwarfContext(DebugSections, 8);
-
- std::string str;
- raw_string_ostream strm(str);
- EXPECT_FALSE(DwarfContext.verify(strm, DIDT_All));
- strm.flush();
- const char *err = "error: DW_AT_stmt_list offset is beyond .debug_line "
- "bounds: 0x00001000";
- EXPECT_TRUE(strm.str().find(err) != std::string::npos);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(
+ DwarfContext,
+ "error: DW_AT_stmt_list offset is beyond .debug_line bounds: 0x00001000");
}
TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStrp) {
@@ -1895,17 +1868,278 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStrp) {
)";
auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
ASSERT_TRUE((bool)ErrOrSections);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext,
+ "error: DW_FORM_strp offset beyond .debug_str bounds:");
+}
+
+TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddrBetween) {
+ // Create a single compile unit with a single function that has a DW_AT_type
+ // with a valid .debug_info offset, but the offset is between two DIEs.
+ const char *yamldata = R"(
+ debug_str:
+ - ''
+ - /tmp/main.c
+ - main
+ debug_abbrev:
+ - Code: 0x00000001
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Code: 0x00000002
+ Tag: DW_TAG_subprogram
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_type
+ Form: DW_FORM_ref_addr
+ debug_info:
+ - Length:
+ TotalLength: 22
+ Version: 4
+ AbbrOffset: 0
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x00000001
+ Values:
+ - Value: 0x0000000000000001
+ - AbbrCode: 0x00000002
+ Values:
+ - Value: 0x000000000000000D
+ - Value: 0x0000000000000011
+ - AbbrCode: 0x00000000
+ Values:
+ )";
+ auto ErrOrSections = DWARFYAML::EmitDebugSections(StringRef(yamldata));
+ ASSERT_TRUE((bool)ErrOrSections);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(
+ DwarfContext,
+ "error: invalid DIE reference 0x00000011. Offset is in between DIEs:");
+}
- auto &DebugSections = *ErrOrSections;
+TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineSequence) {
+ // Create a single compile unit whose line table has a sequence in it where
+ // the address decreases.
+ StringRef yamldata = R"(
+ debug_str:
+ - ''
+ - /tmp/main.c
+ debug_abbrev:
+ - Code: 0x00000001
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_stmt_list
+ Form: DW_FORM_sec_offset
+ debug_info:
+ - Length:
+ TotalLength: 16
+ Version: 4
+ AbbrOffset: 0
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x00000001
+ Values:
+ - Value: 0x0000000000000001
+ - Value: 0x0000000000000000
+ debug_line:
+ - Length:
+ TotalLength: 68
+ Version: 2
+ PrologueLength: 34
+ MinInstLength: 1
+ DefaultIsStmt: 1
+ LineBase: 251
+ LineRange: 14
+ OpcodeBase: 13
+ StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
+ IncludeDirs:
+ - /tmp
+ Files:
+ - Name: main.c
+ DirIdx: 1
+ ModTime: 0
+ Length: 0
+ Opcodes:
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 9
+ SubOpcode: DW_LNE_set_address
+ Data: 4112
+ - Opcode: DW_LNS_advance_line
+ SData: 9
+ Data: 4112
+ - Opcode: DW_LNS_copy
+ Data: 4112
+ - Opcode: DW_LNS_advance_pc
+ Data: 18446744073709551600
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 1
+ SubOpcode: DW_LNE_end_sequence
+ Data: 18446744073709551600
+ )";
+ auto ErrOrSections = DWARFYAML::EmitDebugSections(yamldata);
+ ASSERT_TRUE((bool)ErrOrSections);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext, "error: .debug_line[0x00000000] row[1] decreases "
+ "in address from previous row:");
+}
- DWARFContextInMemory DwarfContext(DebugSections, 8);
+TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineFileIndex) {
+ // Create a single compile unit whose line table has a line table row with
+ // an invalid file index.
+ StringRef yamldata = R"(
+ debug_str:
+ - ''
+ - /tmp/main.c
+ debug_abbrev:
+ - Code: 0x00000001
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_stmt_list
+ Form: DW_FORM_sec_offset
+ debug_info:
+ - Length:
+ TotalLength: 16
+ Version: 4
+ AbbrOffset: 0
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x00000001
+ Values:
+ - Value: 0x0000000000000001
+ - Value: 0x0000000000000000
+ debug_line:
+ - Length:
+ TotalLength: 61
+ Version: 2
+ PrologueLength: 34
+ MinInstLength: 1
+ DefaultIsStmt: 1
+ LineBase: 251
+ LineRange: 14
+ OpcodeBase: 13
+ StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
+ IncludeDirs:
+ - /tmp
+ Files:
+ - Name: main.c
+ DirIdx: 1
+ ModTime: 0
+ Length: 0
+ Opcodes:
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 9
+ SubOpcode: DW_LNE_set_address
+ Data: 4096
+ - Opcode: DW_LNS_advance_line
+ SData: 9
+ Data: 4096
+ - Opcode: DW_LNS_copy
+ Data: 4096
+ - Opcode: DW_LNS_advance_pc
+ Data: 16
+ - Opcode: DW_LNS_set_file
+ Data: 5
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 1
+ SubOpcode: DW_LNE_end_sequence
+ Data: 5
+ )";
+ auto ErrOrSections = DWARFYAML::EmitDebugSections(yamldata);
+ ASSERT_TRUE((bool)ErrOrSections);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext, "error: .debug_line[0x00000000][1] has invalid "
+ "file index 5 (valid values are [1,1]):");
+}
- std::string str;
- raw_string_ostream strm(str);
- EXPECT_FALSE(DwarfContext.verify(strm, DIDT_All));
- strm.flush();
- const char *err = "error: DW_FORM_strp offset beyond .debug_str bounds:";
- EXPECT_TRUE(strm.str().find(err) != std::string::npos);
+TEST(DWARFDebugInfo, TestDwarfVerifyCUDontShareLineTable) {
+ // Create a two compile units where both compile units share the same
+ // DW_AT_stmt_list value and verify we report the error correctly.
+ StringRef yamldata = R"(
+ debug_str:
+ - ''
+ - /tmp/main.c
+ - /tmp/foo.c
+ debug_abbrev:
+ - Code: 0x00000001
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_stmt_list
+ Form: DW_FORM_sec_offset
+ debug_info:
+ - Length:
+ TotalLength: 16
+ Version: 4
+ AbbrOffset: 0
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x00000001
+ Values:
+ - Value: 0x0000000000000001
+ - Value: 0x0000000000000000
+ - Length:
+ TotalLength: 16
+ Version: 4
+ AbbrOffset: 0
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x00000001
+ Values:
+ - Value: 0x000000000000000D
+ - Value: 0x0000000000000000
+ debug_line:
+ - Length:
+ TotalLength: 60
+ Version: 2
+ PrologueLength: 34
+ MinInstLength: 1
+ DefaultIsStmt: 1
+ LineBase: 251
+ LineRange: 14
+ OpcodeBase: 13
+ StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
+ IncludeDirs:
+ - /tmp
+ Files:
+ - Name: main.c
+ DirIdx: 1
+ ModTime: 0
+ Length: 0
+ Opcodes:
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 9
+ SubOpcode: DW_LNE_set_address
+ Data: 4096
+ - Opcode: DW_LNS_advance_line
+ SData: 9
+ Data: 4096
+ - Opcode: DW_LNS_copy
+ Data: 4096
+ - Opcode: DW_LNS_advance_pc
+ Data: 256
+ - Opcode: DW_LNS_extended_op
+ ExtLen: 1
+ SubOpcode: DW_LNE_end_sequence
+ Data: 256
+ )";
+ auto ErrOrSections = DWARFYAML::EmitDebugSections(yamldata);
+ ASSERT_TRUE((bool)ErrOrSections);
+ DWARFContextInMemory DwarfContext(*ErrOrSections, 8);
+ VerifyError(DwarfContext, "error: two compile unit DIEs, 0x0000000b and "
+ "0x0000001f, have the same DW_AT_stmt_list section "
+ "offset:");
}
} // end anonymous namespace
diff --git a/unittests/DebugInfo/PDB/ErrorChecking.h b/unittests/DebugInfo/PDB/ErrorChecking.h
index 6d4a7de7834a..f284bfd8bb7a 100644
--- a/unittests/DebugInfo/PDB/ErrorChecking.h
+++ b/unittests/DebugInfo/PDB/ErrorChecking.h
@@ -36,6 +36,18 @@
} \
}
+#define EXPECT_EXPECTED_EQ(Val, Exp) \
+ { \
+ auto Result = Exp; \
+ auto E = Result.takeError(); \
+ EXPECT_FALSE(static_cast<bool>(E)); \
+ if (E) { \
+ consumeError(std::move(E)); \
+ return; \
+ } \
+ EXPECT_EQ(Val, *Result); \
+ }
+
#define EXPECT_UNEXPECTED(Exp) \
{ \
auto E = Exp.takeError(); \
diff --git a/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp b/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
index 7c4838778e43..249bc4a03b87 100644
--- a/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
+++ b/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
@@ -9,8 +9,8 @@
#include "ErrorChecking.h"
-#include "llvm/DebugInfo/PDB/Native/StringTable.h"
-#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
+#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
@@ -27,13 +27,13 @@ class StringTableBuilderTest : public ::testing::Test {};
TEST_F(StringTableBuilderTest, Simple) {
// Create /names table contents.
- StringTableBuilder Builder;
+ PDBStringTableBuilder Builder;
EXPECT_EQ(1U, Builder.insert("foo"));
EXPECT_EQ(5U, Builder.insert("bar"));
EXPECT_EQ(1U, Builder.insert("foo"));
EXPECT_EQ(9U, Builder.insert("baz"));
- std::vector<uint8_t> Buffer(Builder.finalize());
+ std::vector<uint8_t> Buffer(Builder.calculateSerializedSize());
MutableBinaryByteStream OutStream(Buffer, little);
BinaryStreamWriter Writer(OutStream);
EXPECT_NO_ERROR(Builder.commit(Writer));
@@ -41,15 +41,16 @@ TEST_F(StringTableBuilderTest, Simple) {
// Reads the contents back.
BinaryByteStream InStream(Buffer, little);
BinaryStreamReader Reader(InStream);
- StringTable Table;
- EXPECT_NO_ERROR(Table.load(Reader));
+ PDBStringTable Table;
+ EXPECT_NO_ERROR(Table.reload(Reader));
EXPECT_EQ(3U, Table.getNameCount());
EXPECT_EQ(1U, Table.getHashVersion());
- EXPECT_EQ("foo", Table.getStringForID(1));
- EXPECT_EQ("bar", Table.getStringForID(5));
- EXPECT_EQ("baz", Table.getStringForID(9));
- EXPECT_EQ(1U, Table.getIDForString("foo"));
- EXPECT_EQ(5U, Table.getIDForString("bar"));
- EXPECT_EQ(9U, Table.getIDForString("baz"));
+
+ EXPECT_EXPECTED_EQ("foo", Table.getStringForID(1));
+ EXPECT_EXPECTED_EQ("bar", Table.getStringForID(5));
+ EXPECT_EXPECTED_EQ("baz", Table.getStringForID(9));
+ EXPECT_EXPECTED_EQ(1U, Table.getIDForString("foo"));
+ EXPECT_EXPECTED_EQ(5U, Table.getIDForString("bar"));
+ EXPECT_EXPECTED_EQ(9U, Table.getIDForString("baz"));
}
diff --git a/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp b/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
index 4af3aa707a90..ab43c4af13f1 100644
--- a/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
+++ b/unittests/ExecutionEngine/Orc/IndirectionUtilsTest.cpp
@@ -20,17 +20,15 @@ TEST(IndirectionUtilsTest, MakeStub) {
LLVMContext Context;
ModuleBuilder MB(Context, "x86_64-apple-macosx10.10", "");
Function *F = MB.createFunctionDecl<void(DummyStruct, DummyStruct)>("");
- SmallVector<AttributeList, 4> Attrs;
- Attrs.push_back(
- AttributeList::get(MB.getModule()->getContext(), 1U,
- AttrBuilder().addAttribute(Attribute::StructRet)));
- Attrs.push_back(
- AttributeList::get(MB.getModule()->getContext(), 2U,
- AttrBuilder().addAttribute(Attribute::ByVal)));
- Attrs.push_back(
- AttributeList::get(MB.getModule()->getContext(), ~0U,
- AttrBuilder().addAttribute(Attribute::NoUnwind)));
- F->setAttributes(AttributeList::get(MB.getModule()->getContext(), Attrs));
+ AttributeSet FnAttrs = AttributeSet::get(
+ Context, AttrBuilder().addAttribute(Attribute::NoUnwind));
+ AttributeSet RetAttrs; // None
+ AttributeSet ArgAttrs[2] = {
+ AttributeSet::get(Context,
+ AttrBuilder().addAttribute(Attribute::StructRet)),
+ AttributeSet::get(Context, AttrBuilder().addAttribute(Attribute::ByVal)),
+ };
+ F->setAttributes(AttributeList::get(Context, FnAttrs, RetAttrs, ArgAttrs));
auto ImplPtr = orc::createImplPointer(*F->getType(), *MB.getModule(), "", nullptr);
orc::makeStub(*F, *ImplPtr);
diff --git a/unittests/IR/AttributesTest.cpp b/unittests/IR/AttributesTest.cpp
index 7c3df2e19e8f..0df7a847f8a5 100644
--- a/unittests/IR/AttributesTest.cpp
+++ b/unittests/IR/AttributesTest.cpp
@@ -45,7 +45,7 @@ TEST(Attributes, Ordering) {
AttributeList::get(C, 1, Attribute::SExt)};
AttributeList SetA = AttributeList::get(C, ASs);
- AttributeList SetB = SetA.removeAttributes(C, 1, ASs[1]);
+ AttributeList SetB = SetA.removeAttributes(C, 1, ASs[1].getAttributes(1));
EXPECT_NE(SetA, SetB);
}
diff --git a/unittests/Support/BinaryStreamTest.cpp b/unittests/Support/BinaryStreamTest.cpp
index 74c51e382d99..41567dad6226 100644
--- a/unittests/Support/BinaryStreamTest.cpp
+++ b/unittests/Support/BinaryStreamTest.cpp
@@ -358,14 +358,14 @@ TEST_F(BinaryStreamTest, VarStreamArray) {
struct StringExtractor {
public:
- typedef uint32_t ContextType;
+ typedef uint32_t &ContextType;
static Error extract(BinaryStreamRef Stream, uint32_t &Len, StringRef &Item,
- uint32_t *Index) {
- if (*Index == 0)
+ uint32_t &Index) {
+ if (Index == 0)
Len = strlen("1. Test");
- else if (*Index == 1)
+ else if (Index == 1)
Len = strlen("2. Longer Test");
- else if (*Index == 2)
+ else if (Index == 2)
Len = strlen("3. Really Long Test");
else
Len = strlen("4. Super Extra Longest Test Of All");
@@ -374,14 +374,14 @@ TEST_F(BinaryStreamTest, VarStreamArray) {
return EC;
Item =
StringRef(reinterpret_cast<const char *>(Bytes.data()), Bytes.size());
- ++(*Index);
+ ++Index;
return Error::success();
}
};
for (auto &Stream : Streams) {
uint32_t Context = 0;
- VarStreamArray<StringRef, StringExtractor> Array(*Stream.Input, &Context);
+ VarStreamArray<StringRef, StringExtractor> Array(*Stream.Input, Context);
auto Iter = Array.begin();
ASSERT_EQ("1. Test", *Iter++);
ASSERT_EQ("2. Longer Test", *Iter++);