@@ -145,17 +145,16 @@ using MutexDescriptor =
145145 std::variant<FirstArgMutexDescriptor, MemberMutexDescriptor,
146146 RAIIMutexDescriptor>;
147147
148- class NonBlockOpenVisitor : public BugReporterVisitor {
148+ class SuppressNonBlockingStreams : public BugReporterVisitor {
149149private:
150- SymbolRef SR ;
151- int O_NONBLOCKValue ;
152- const CallDescription OpenFunction ;
153- bool Satisfied;
150+ const CallDescription OpenFunction{CDM::CLibrary, { " open " }, 2 } ;
151+ SymbolRef StreamSym ;
152+ const int NonBlockMacroVal ;
153+ bool Satisfied = false ;
154154
155155public:
156- NonBlockOpenVisitor (SymbolRef SR, int O_NONBLOCKValue)
157- : SR(SR), O_NONBLOCKValue(O_NONBLOCKValue),
158- OpenFunction (CDM::CLibrary, {" open" }, 2 ), Satisfied(false ) {}
156+ SuppressNonBlockingStreams (SymbolRef SR, int NonBlockMacroVal)
157+ : StreamSym(SR), NonBlockMacroVal(NonBlockMacroVal) {}
159158
160159 static void *getTag () {
161160 static int Tag = 0 ;
@@ -164,7 +163,6 @@ class NonBlockOpenVisitor : public BugReporterVisitor {
164163
165164 void Profile (llvm::FoldingSetNodeID &ID) const override {
166165 ID.AddPointer (getTag ());
167- ID.AddPointer (SR);
168166 }
169167
170168 PathDiagnosticPieceRef VisitNode (const ExplodedNode *N,
@@ -182,7 +180,7 @@ class NonBlockOpenVisitor : public BugReporterVisitor {
182180 return nullptr ;
183181
184182 SVal SV = N->getSVal (CE);
185- if (SV.getAsSymbol () != SR )
183+ if (SV.getAsSymbol () != StreamSym )
186184 return nullptr ;
187185
188186 Satisfied = true ;
@@ -194,7 +192,7 @@ class NonBlockOpenVisitor : public BugReporterVisitor {
194192 if (!FlagV)
195193 return nullptr ;
196194
197- if ((*FlagV & O_NONBLOCKValue ) != 0 )
195+ if ((*FlagV & NonBlockMacroVal ) != 0 )
198196 BR.markInvalid (getTag (), nullptr );
199197
200198 return nullptr ;
@@ -415,7 +413,7 @@ void BlockInCriticalSectionChecker::reportBlockInCritSection(
415413 O_NONBLOCKValue = tryExpandAsInteger (
416414 " O_NONBLOCK" , C.getBugReporter ().getPreprocessor ());
417415 if (*O_NONBLOCKValue)
418- R->addVisitor <NonBlockOpenVisitor >(SR, **O_NONBLOCKValue);
416+ R->addVisitor <SuppressNonBlockingStreams >(SR, **O_NONBLOCKValue);
419417 }
420418 }
421419 R->addRange (Call.getSourceRange ());
0 commit comments