[lld] r194551 - Use empty() instead of size() == 0.

Rui Ueyama ruiu at google.com
Tue Nov 12 19:38:36 PST 2013


Sorry for the breakage. I tested it of course, but did it with Release
build by accident, so the expression in assert() was not verified. The
patch has already been rolled back. I'll re-submit this with a fix.


On Tue, Nov 12, 2013 at 7:28 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
>
> On Tue, Nov 12, 2013 at 7:17 PM, Nick Kledzik <kledzik at apple.com> wrote:
>
>>
>> On Nov 12, 2013, at 7:09 PM, Rui Ueyama <ruiu at google.com> wrote:
>>
>> > Author: ruiu
>> > Date: Tue Nov 12 21:09:20 2013
>> > New Revision: 194551
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=194551&view=rev
>> > Log:
>> > Use empty() instead of size() == 0.
>> >
>> > Modified:
>> >    lld/trunk/lib/Core/Resolver.cpp
>> >    lld/trunk/lib/Driver/InputGraph.cpp
>> >    lld/trunk/lib/Driver/WinLinkDriver.cpp
>> >    lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
>> >    lld/trunk/lib/ReaderWriter/MachO/StubsPass.hpp
>> >    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
>> >
>> > Modified: lld/trunk/lib/Core/Resolver.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=194551&r1=194550&r2=194551&view=diff
>> >
>> ==============================================================================
>> > --- lld/trunk/lib/Core/Resolver.cpp (original)
>> > +++ lld/trunk/lib/Core/Resolver.cpp Tue Nov 12 21:09:20 2013
>> > @@ -227,7 +227,7 @@ void Resolver::doDefinedAtom(const Defin
>> >   switch ( atom.sectionPosition() ) {
>> >   case DefinedAtom::sectionPositionStart:
>> >   case DefinedAtom::sectionPositionEnd:
>> > -    assert(atom.size() == 0);
>> > +    assert(atom.empty());
>> >     break;
>> Atoms are not containers.  There is no empty() method, just a size()
>> method.  This breaks the build.
>>
>
> My fault - I just assumed it was an ArrayRef or container, etc. An empty
> function's probably a nice thing to add, though.
>
>
>>
>> -Nick
>>
>>
>>
>> >   case DefinedAtom::sectionPositionEarly:
>> >   case DefinedAtom::sectionPositionAny:
>> >
>> > Modified: lld/trunk/lib/Driver/InputGraph.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/InputGraph.cpp?rev=194551&r1=194550&r2=194551&view=diff
>> >
>> ==============================================================================
>> > --- lld/trunk/lib/Driver/InputGraph.cpp (original)
>> > +++ lld/trunk/lib/Driver/InputGraph.cpp Tue Nov 12 21:09:20 2013
>> > @@ -133,7 +133,7 @@ uint32_t ControlNode::getResolveState()
>> > /// \brief Set the resolve state for the current element
>> > /// thats processed by the resolver.
>> > void ControlNode::setResolveState(uint32_t resolveState) {
>> > -  if (_elements.size() == 0)
>> > +  if (_elements.empty())
>> >     return;
>> >   _elements[_currentElementIndex]->setResolveState(resolveState);
>> > }
>> > @@ -151,7 +151,7 @@ SimpleFileNode::SimpleFileNode(StringRef
>> > /// of the input elements contained in the group.
>> > ErrorOr<File &> Group::getNextFile() {
>> >   // If there are no elements, move on to the next input element
>> > -  if (_elements.size() == 0)
>> > +  if (_elements.empty())
>> >     return make_error_code(InputGraphError::no_more_files);
>> >
>> >   for (;;) {
>> >
>> > Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=194551&r1=194550&r2=194551&view=diff
>> >
>> ==============================================================================
>> > --- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
>> > +++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Nov 12 21:09:20 2013
>> > @@ -911,7 +911,7 @@ WinLinkDriver::parse(int argc, const cha
>> >     }
>> >   }
>> >
>> > -  if (inputElements.size() == 0 && !isReadingDirectiveSection) {
>> > +  if (inputElements.empty() && !isReadingDirectiveSection) {
>> >     diagnostics << "No input files\n";
>> >     return false;
>> >   }
>> >
>> > Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=194551&r1=194550&r2=194551&view=diff
>> >
>> ==============================================================================
>> > --- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
>> > +++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Tue Nov 12 21:09:20
>> 2013
>> > @@ -576,7 +576,7 @@ StringTable<ELFT>::StringTable(const ELF
>> >
>> > template <class ELFT> uint64_t StringTable<ELFT>::addString(StringRef
>> symname) {
>> >
>> > -  if (symname.size() == 0)
>> > +  if (symname.empty())
>> >     return 0;
>> >   StringMapTIter stringIter = _stringMap.find(symname);
>> >   if (stringIter == _stringMap.end()) {
>> >
>> > Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.hpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.hpp?rev=194551&r1=194550&r2=194551&view=diff
>> >
>> ==============================================================================
>> > --- lld/trunk/lib/ReaderWriter/MachO/StubsPass.hpp (original)
>> > +++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.hpp Tue Nov 12 21:09:20
>> 2013
>> > @@ -123,7 +123,7 @@ public:
>> >
>> >   virtual void addStubAtoms(MutableFile &mergedFile) {
>> >     // Exit early if no stubs needed.
>> > -    if ( _targetToStub.size() == 0 )
>> > +    if (_targetToStub.empty())
>> >       return;
>> >     // Add all stubs to master file.
>> >     for (auto it : _targetToStub) {
>> >
>> > Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
>> > URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=194551&r1=194550&r2=194551&view=diff
>> >
>> ==============================================================================
>> > --- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
>> > +++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Tue Nov 12
>> 21:09:20 2013
>> > @@ -666,7 +666,7 @@ private:
>> >       array = array.slice(3);
>> >     }
>> >
>> > -    if (array.size() == 0)
>> > +    if (array.empty())
>> >       return "";
>> >
>> >     size_t len = 0;
>> >
>> >
>> > _______________________________________________
>> > llvm-commits mailing list
>> > llvm-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131112/e376a066/attachment.html>


More information about the llvm-commits mailing list