[clang] [clang][dataflow] Fix crash when analyzing a coroutine (PR #85957)

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 20 09:33:04 PDT 2024


================
@@ -4628,6 +4662,21 @@ TEST(TransferTest, DoesNotCrashOnUnionThisExpr) {
       LangStandard::lang_cxx17, /*ApplyBuiltinTransfer=*/true, "operator=");
 }
 
+TEST(TransferTest, DoesNotCrashOnNullChildren) {
+  std::string Code = (CoroutineLibrary + R"cc(
+    task foo() noexcept {
+      co_return;
+    }
+  )cc").str();
+  // This is a crash regression test when calling `AdornedCFG::build` on a
+  // statement (in this case, the `CoroutineBodyStmt`) with null children.
+  runDataflow(
+      Code,
+      [](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &,
+         ASTContext &) {},
+      LangStandard::lang_cxx20, /*ApplyBuiltinTransfer=*/true, "foo");
----------------
sam-mccall wrote:

(nit: just call the function "target" and skip naming it here)

https://github.com/llvm/llvm-project/pull/85957


More information about the cfe-commits mailing list