[PATCH] D102251: Suppress Deferred Diagnostics in discarded statements.
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 11 09:58:14 PDT 2021
erichkeane added inline comments.
================
Comment at: clang/include/clang/AST/Stmt.h:2082-2083
/// Otherwise, or if the condition is value-dependent, returns None.
Optional<const Stmt*> getNondiscardedCase(const ASTContext &Ctx) const;
+ Optional<Stmt *> getNondiscardedCase(const ASTContext &Ctx);
----------------
ABataev wrote:
> Do you really need `Optional` here? Just nullptr is not enough?
Yes for 2 reasons:
1- This is the existing interface, I didn't see reason to change it.
2- Optional::None and nullptr are two different 'cases'. None is returned here when this is not a constexpr-if. Nullptr is returned in cases where it _IS_ a constexpr-if, but the nondiscarded case is not present. For example:
if (foo) {} // Returns None.
if constexpr (false) {} // Returns nullptr.
if constexpr (false) else {} // Returns the 'else' compound statement.
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