Skip to content

Commit

Permalink
[ObjectYAML] Use std::size (NFC)
Browse files Browse the repository at this point in the history
std::size, introduced in C++17, allows us to directly obtain the
number of elements of an array.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
  • Loading branch information
kazutakahirata committed Nov 26, 2022
1 parent 453f27b commit a737146
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/ObjectYAML/COFFEmitter.cpp
Expand Up @@ -456,8 +456,7 @@ static bool writeCOFF(COFFParser &CP, raw_ostream &OS) {
++I) {
const Optional<COFF::DataDirectory> *DataDirectories =
CP.Obj.OptionalHeader->DataDirectories;
uint32_t NumDataDir = sizeof(CP.Obj.OptionalHeader->DataDirectories) /
sizeof(Optional<COFF::DataDirectory>);
uint32_t NumDataDir = std::size(CP.Obj.OptionalHeader->DataDirectories);
if (I >= NumDataDir || !DataDirectories[I]) {
OS << zeros(uint32_t(0));
OS << zeros(uint32_t(0));
Expand Down

0 comments on commit a737146

Please sign in to comment.