[clang] d82538b - Fix -Wunused compiler warning.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon May 11 19:03:29 PDT 2020


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200511/d93c0ff5/attachment.html>


More information about the cfe-commits mailing list