[clang] d82538b - Fix -Wunused compiler warning.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue May 12 02:52:50 PDT 2020


This is neat, fixed in 40ef4274600316ed12a26a73265cf34432e1fbf7, thanks for
the suggestion!

On Tue, 12 May 2020 at 05:13, Eric Christopher <echristo at gmail.com> wrote:

> Very much so. Also nice all_of use! I'd have never thought about that :)
>
> -eric
>
> On Mon, May 11, 2020 at 7:03 PM David Blaikie via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>>
>>
>> On Mon, May 11, 2020 at 12:21 AM Haojian Wu via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>>
>>>
>>> Author: Haojian Wu
>>> Date: 2020-05-11T09:20:48+02:00
>>> New Revision: d82538b3f691f3ba1cb7a945a5f8594f71816fdf
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/d82538b3f691f3ba1cb7a945a5f8594f71816fdf
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/d82538b3f691f3ba1cb7a945a5f8594f71816fdf.diff
>>>
>>> LOG: Fix -Wunused compiler warning.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>>     clang/lib/AST/Expr.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> ################################################################################
>>> diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
>>> index 2a0e0425ef1f..8b327300fb2d 100644
>>> --- a/clang/lib/AST/Expr.cpp
>>> +++ b/clang/lib/AST/Expr.cpp
>>> @@ -4686,8 +4686,10 @@ RecoveryExpr::RecoveryExpr(ASTContext &Ctx,
>>> QualType T, SourceLocation BeginLoc,
>>>      : Expr(RecoveryExprClass, T, VK_LValue, OK_Ordinary),
>>> BeginLoc(BeginLoc),
>>>        EndLoc(EndLoc), NumExprs(SubExprs.size()) {
>>>    assert(!T.isNull());
>>> +#ifndef NDEBUG // avoid -Wunused warnings.
>>>    for (auto *E : SubExprs)
>>>      assert(E != nullptr);
>>> +#endif
>>>
>>
>> This might be better written as:
>>
>> assert(llvm::all_of(SubExprs, [](Expr* E) { return E != nullptr; }));
>>
>> & probably include some kind of message (... && "message") about this
>> precondition.
>>
>>
>>>
>>>    llvm::copy(SubExprs, getTrailingObjects<Expr *>());
>>>    setDependence(computeDependence(this));
>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> https://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/20200512/a5528591/attachment.html>


More information about the cfe-commits mailing list