r261626 - Fix a -Wunused-variable diagnostic.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 23 09:16:44 PST 2016


On Tue, Feb 23, 2016 at 5:51 PM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Tue, Feb 23, 2016 at 2:29 AM, Alexander Kornienko via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Tue Feb 23 04:29:04 2016
>> New Revision: 261626
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261626&view=rev
>> Log:
>> Fix a -Wunused-variable diagnostic.
>>
>> Modified:
>>     cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
>>
>> Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=261626&r1=261625&r2=261626&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
>> +++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Tue Feb 23 04:29:04
>> 2016
>> @@ -307,8 +307,10 @@ HasNameMatcher::HasNameMatcher(std::vect
>>            N.begin(), N.end(),
>>            [](StringRef Name) { return Name.find("::") == Name.npos; })),
>>        Names(std::move(N)) {
>> +#ifndef NDEBUG
>>    for (StringRef Name : Names)
>>      assert(!Name.empty());
>>
>
> Alternatively, you could fold the loop into the assert:
>
> assert(llvm::all_of(Names, [](StringRef Name) { return !Name.empty(); }));
>
> (not sure if we have rangified llvm::all_of, but we have some of the other
> _of in llvm rangified versions and it would be easy to add this one too)
>

Good to know we have rangified algorithms. However, I'll leave improvement
of the code to the original author.


>
>
>> +#endif
>>  }
>>
>>  namespace {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160223/d1a411c5/attachment.html>


More information about the cfe-commits mailing list