| Issue |
233598
|
| Summary |
[analyzer] Non-functional logic in MallocChecker inner pointer logic
|
| Labels |
clang:static analyzer
|
| Assignees |
|
| Reporter |
NagyDonat
|
While reading the sources I noticed that `MallocChecker.cpp` contains the code fragment
```c++
} else if (const auto *CallE = dyn_cast<CallExpr>(S)) {
auto &CEMgr = BRC.getStateManager().getCallEventManager();
CallEventRef<> Call =
CEMgr.getSimpleCall(CallE, state, CurrentSF, {nullptr, 0});
if (const auto *D = dyn_cast_or_null<NamedDecl>(Call->getDecl()))
OS << D->getDeclName();
else
OS << "unknown";
}
```
which creates a `CallEvent` with the constructor that passes an `Expr *`, initializing the `Expr *` half of the data member `llvm::PointerUnion<const Expr *, const Decl *> Origin;` of `CallEvent`. After this `Call->getDecl()` tries to query the `Decl *` half of this pointer union, which always yields a nullpointer.
Therefore this code fragment always writes `"unknown"` to the string stream `OS`, which is at least not a crash, but still unfortunate. This logic should be fixed to get the name of the called function when it's available.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs