[clang] [clang][analyzer] fix false positive of BlockInCriticalSectionChecker (PR #126752)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 02:36:12 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);
----------------
Xazax-hun wrote:
Nit: I know the function is not consistent at the moment but the coding convention requires variable names to start with an uppercase letter.
https://github.com/llvm/llvm-project/pull/126752
More information about the cfe-commits
mailing list