[clang] [clang][c++20] Fix code coverage mapping crash with generalized NTTPs (PR #85837)

Andrey Ali Khan Bolshakov via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 23:24:34 PDT 2024


================
@@ -2177,7 +2177,8 @@ struct CounterCoverageMappingBuilder
   }
 
   void VisitOpaqueValueExpr(const OpaqueValueExpr* OVE) {
-    Visit(OVE->getSourceExpr());
+    if (const Expr *SE = OVE->getSourceExpr())
----------------
bolshakov-a wrote:

> If I'm following correctly, you end up visiting the condition twice

No, the "true" branch visitation (`propagateCounts`) is performed only when it is the ordinary `ConditionalOperator` (https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CoverageMappingGen.cpp#L2018).

Do you think it should be rewritten first? It's just the first case found by me where a non-unique OVE has a source expression which is visited. There may be more cases.

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


More information about the cfe-commits mailing list