[PATCH] D26350: Keep invalid Switch in the AST

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 27 07:54:05 PDT 2017


aaron.ballman added a comment.

This looks reasonable to me, but you should wait for @rsmith to sign off before committing.



================
Comment at: lib/Sema/SemaStmt.cpp:669
   if (Cond.isInvalid())
-    return StmtError();
+    Cond = ConditionResult(
+        *this, nullptr,
----------------
ogoffart wrote:
> aaron.ballman wrote:
> > This makes the condition result valid when it isn't. Users of this condition result may expect a valid condition result to return nonnull values when calling `get()`, which makes me uncomfortable.
> Get return a non-null value.
> That's why i'm constructing an OpaqueValueExpr placeholder expression.
> 
> The ConditionVar (nullptr in the line bellow) can be null. It is null in valid code most of the time actually, when one does not declare a new variable in in condition.
> 
> But the result is that users of this condition will get a OpaqueValueExpr when calling get and should not be disturbed by that as they will just take that as an expression.
> 
Ah, sorry, I misread the code in my haste.


https://reviews.llvm.org/D26350





More information about the cfe-commits mailing list