================
@@ -1306,6 +1306,23 @@ class CFG {
     bool AddVirtualBaseBranches = false;
     bool OmitImplicitValueInitializers = false;
     bool AssumeReachableDefaultInSwitchStatements = false;
+    // Add the construction (including evaluation of any default member
+    // initializers) of a coroutine's promise object to the CFG being built
+    // for the coroutine. `AnalysisDeclContext::getBody()` returns only the
+    // as-written body of a coroutine (i.e. `CoroutineBodyStmt::getBody()`)
+    // so that CFG-based Sema warnings (e.g. -Wunreachable-code) don't have
+    // to reason about compiler-synthesized coroutine machinery. Because of
+    // that, by default, nothing in the CFG models the initialization of the
+    // promise object (`CoroutineBodyStmt::getPromiseDeclStmt()`), even
+    // though the promise is guaranteed to be constructed, with all of its
+    // default member initializers applied, before any of the coroutine's
+    // body -- including the first `co_await` -- executes. Clients that
+    // symbolically execute the CFG (namely the Static Analyzer) need this
+    // modeled or they will treat the promise's data members as
+    // uninitialized. This option is off by default to preserve the CFG
+    // shape relied upon by the existing Sema-level, non-path-sensitive
+    // warnings.
----------------
steakhal wrote:

I didn't read this comment. I'm 100% sure it's excessive. Could you try to get 
to the point in these comments. Same for the next wall of comment.

https://github.com/llvm/llvm-project/pull/208569
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to