[clang] [clang][analyzer] fix false positive of BlockInCriticalSectionChecker (PR #126752)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 03:54:53 PST 2025
================
@@ -339,6 +425,36 @@ void BlockInCriticalSectionChecker::reportBlockInCritSection(
os.str(), ErrNode);
R->addRange(Call.getSourceRange());
R->markInteresting(Call.getReturnValue());
+ // for 'read' call, check whether it's file descriptor(first argument) is
+ // created by 'open' API with O_NONBLOCK flag and don't report for this
+ // situation.
+ if (Call.getCalleeIdentifier()->getName() == "read") {
+ do {
+ const auto *arg = Call.getArgExpr(0);
+ if (!arg)
+ break;
+
+ const auto *DRE = dyn_cast<DeclRefExpr>(arg->IgnoreImpCasts());
----------------
flovent wrote:
i am hoping to get the MemRegion of file descriptor here and compare its corresponding SVal between pred node and current node in `VisitNode`, i can't use `getArgSVal` to get SVal as region because `open` call is evaluated to a symbol or int(-1).
is there a way to check binding from SVal to Expr?
https://github.com/llvm/llvm-project/pull/126752
More information about the cfe-commits
mailing list