Xazax-hun wrote:

I wonder if we want a more general fix here. For example, consider the 
following code:
```
[[noreturn]]
int* terminate();

bool cond;
void f() {
    int* i = cond ? nullptr : terminate();
}
```

Here, we also might not want to have a flow from `terminate` as we do not have 
a runtime execution path that produces a value when we take that branch. The 
`throw` problem is a special case of that.

I believe in both cases of these cases the CFG should correctly reflect the 
lack of flow by not having an edge between the corresponding CFG nodes. 

So I believe the more general solution would have the shape like:
* Get the CFG node corresponding to the value produced by the ternary
* Get the CFG nodes corresponding to the branches.
* If an edge is missing, do not flow the origins.

This approach would also make the fact generator more precise for the cases 
where the CFG reflects compile-time known flows like `int *p = true ? q1 : q2;`.

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

Reply via email to