[PATCH] D102251: Suppress Deferred Diagnostics in discarded statements.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 11 17:18:55 PDT 2021
rsmith added a comment.
(No blocking concerns here.)
================
Comment at: clang/lib/AST/Stmt.cpp:1000-1003
+ if (Optional<Stmt *> Result =
+ const_cast<IfStmt *>(this)->getNondiscardedCase(Ctx))
+ return *Result;
+ return None;
----------------
Can this simply be
```
return const_cast<IfStmt *>(this)->getNondiscardedCase(Ctx));
```
? I would expect that if `T` implicitly converts to `U` then `Optional<T>` implicitly converts to `Optional<U>`.
================
Comment at: clang/lib/Sema/Sema.cpp:1545
class DeferredDiagnosticsEmitter
: public UsedDeclVisitor<DeferredDiagnosticsEmitter> {
public:
----------------
I wonder if there are other `UsedDeclVisitor`s that would want this behavior, largely because of [basic.def.odr]p10: "Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program outside of a discarded statement (8.5.2)". It seems worth checking, and maybe moving this functionality to an optional behavior in the base class, but I don't want to hold up this patch on that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102251/new/
https://reviews.llvm.org/D102251
More information about the cfe-commits
mailing list