[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
Thu Mar 28 07:11:07 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:

Not all `OpaqueValueExpr`s having a source expression are marked as "unique". Checking `isUnique()` instead of `getSourceExpr()` breaks at least handling of the GNU extension of the `?:` operator:
```
    1|      1|int main() {
    2|      1|    int i = 1;
    3|      1|    return (i ? 1 : 0)
                                  ^0        <-- disappears if isUnique() is used
  ------------------
  |  Branch (3:12): [True: 1, False: 0]
  |  Branch (3:13): [True: 1, False: 0]     <-- disappears if isUnique() is used
  ------------------
    4|      1|        ?: 10;
                         ^0
    5|      1|}
```

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


More information about the cfe-commits mailing list