[clang] [analyzer] Modernize, improve and promote chroot checker (PR #117791)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 01:29:46 PST 2024
================
@@ -24,21 +26,30 @@
using namespace clang;
using namespace ento;
-namespace {
-
// enum value that represent the jail state
-enum Kind { NO_CHROOT, ROOT_CHANGED, JAIL_ENTERED };
+enum ChrootKind { NO_CHROOT, ROOT_CHANGED, ROOT_CHANGE_FAILED, JAIL_ENTERED };
-bool isRootChanged(intptr_t k) { return k == ROOT_CHANGED; }
-//bool isJailEntered(intptr_t k) { return k == JAIL_ENTERED; }
+// Track chroot state changes for success, failure, state change
+// and "jail"
+REGISTER_TRAIT_WITH_PROGRAMSTATE(ChrootState, ChrootKind)
+
+// Track the call expression to chroot for accurate
+// warning messages
+REGISTER_TRAIT_WITH_PROGRAMSTATE(ChrootCall, const Expr *)
----------------
steakhal wrote:
Why do we need this metadata?
I thought we can already infer this from the State by looking at the exploded node where we changed `ChrootState`, grab the ProgramPoint as a `StmtPoint` and get the Stmt of it. That will be a CallExpr you were looking for.
This should hold because the checker only "acts on" the `eval::Call` and `check::PreCall` events, so transitions can only happen in a `Stmt` ProgramPoint location.
https://github.com/llvm/llvm-project/pull/117791
More information about the cfe-commits
mailing list