Skip to content

Commit 74f7226

Browse files
author
joaosaffran
committed
addressing comments and fix tests
1 parent b771aea commit 74f7226

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,14 @@ struct RootSignatureValidations {
552552

553553
static Expected<uint32_t> validateRootFlag(uint32_t Flags) {
554554
if ((Flags & ~0x80000fff) != 0)
555-
return llvm::make_error<BinaryStreamError>("Invalid flag");
555+
return llvm::make_error<BinaryStreamError>("Invalid Root Signature flag");
556556
return Flags;
557557
}
558558

559559
static Expected<uint32_t> validateVersion(uint32_t Version) {
560560
if (Version < 1 || Version > 2)
561-
return llvm::make_error<BinaryStreamError>("Invalid Version");
561+
return llvm::make_error<BinaryStreamError>(
562+
"Invalid Root Signature Version");
562563
return Version;
563564
}
564565
};

llvm/lib/Object/DXContainer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ Error DirectX::RootSignature::parse(StringRef Data) {
246246
const char *Current = Data.begin();
247247

248248
// Root Signature headers expects 6 integers to be present.
249-
if (Data.size() < 6 * sizeof(uint32_t)) {
250-
return parseFailed("Invalid data. Too small.");
251-
}
249+
if (Data.size() < 6 * sizeof(uint32_t))
250+
return parseFailed(
251+
"Invalid root signature, insufficient space for header.");
252252

253253
uint32_t VValue =
254254
support::endian::read<uint32_t, llvm::endianness::little>(Current);

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,10 @@ TEST(RootSignature, ParseRootFlags) {
855855
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
856856
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
857857
};
858-
EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<64>(Buffer)),
859-
FailedWithMessage("Invalid data. Too small."));
858+
EXPECT_THAT_EXPECTED(
859+
DXContainer::create(getMemoryBuffer<64>(Buffer)),
860+
FailedWithMessage(
861+
"Invalid root signature, insufficient space for header."));
860862
}
861863
{
862864
// Version has been changed to an invalid number.
@@ -868,8 +870,10 @@ TEST(RootSignature, ParseRootFlags) {
868870
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
869871
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
870872
};
871-
EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<68>(Buffer)),
872-
FailedWithMessage("Invalid Version"));
873+
EXPECT_THAT_EXPECTED(
874+
DXContainer::create(getMemoryBuffer<68>(Buffer)),
875+
FailedWithMessage("Stream Error: An unspecified error has occurred. "
876+
"Invalid Root Signature Version"));
873877
}
874878
{
875879
// Flag has been set to an invalid value
@@ -881,7 +885,9 @@ TEST(RootSignature, ParseRootFlags) {
881885
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
882886
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xFF,
883887
};
884-
EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<68>(Buffer)),
885-
FailedWithMessage("Invalid flag"));
888+
EXPECT_THAT_EXPECTED(
889+
DXContainer::create(getMemoryBuffer<68>(Buffer)),
890+
FailedWithMessage("Stream Error: An unspecified error has occurred. "
891+
"Invalid Root Signature flag"));
886892
}
887893
}

0 commit comments

Comments
 (0)