================
@@ -326,6 +326,14 @@ loc::MemRegionVal SValBuilder::getCXXThis(const
CXXRecordDecl *D,
std::optional<SVal> SValBuilder::getConstantVal(const Expr *E) {
E = E->IgnoreParens();
+ // A function used as a constant initializer can either decay to a function
+ // pointer or bind directly to a function reference.
+ if (E->getType()->isFunctionPointerType() || E->getType()->isFunctionType())
{
+ if (const auto *FD =
+ dyn_cast_or_null<FunctionDecl>(E->getReferencedDeclOfCallee()))
+ return getFunctionPointer(FD);
+ }
----------------
steakhal wrote:
Does this mean that we would bind a function address to a bool variable in this
example?
```
void my_global_fn();
const bool Truthy = &my_global_fn;
```
I fear that conflating a fn ptr and a fn could have bad consequences. Remember,
in the symbolic engine we can bind any value to any expression, thus nothing
stops us from binding a pointer value to a boolean variable.
https://github.com/llvm/llvm-project/pull/217608
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits