#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include <iterator>
#include <utility>
#include <variant>
usingnamespaceclang;
usingnamespaceento;
namespace {
struct CritSectionMarker { … };
class CallDescriptionBasedMatcher { … };
class FirstArgMutexDescriptor : public CallDescriptionBasedMatcher { … };
class MemberMutexDescriptor : public CallDescriptionBasedMatcher { … };
class RAIIMutexDescriptor { … };
MutexDescriptor;
class BlockInCriticalSectionChecker : public Checker<check::PostCall> { … };
}
REGISTER_LIST_WITH_PROGRAMSTATE(…)
template <>
struct std::iterator_traits<
typename llvm::ImmutableList<CritSectionMarker>::iterator> { … };
std::optional<MutexDescriptor>
BlockInCriticalSectionChecker::checkDescriptorMatch(const CallEvent &Call,
CheckerContext &C,
bool IsLock) const { … }
static const MemRegion *skipStdBaseClassRegion(const MemRegion *Reg) { … }
static const MemRegion *getRegion(const CallEvent &Call,
const MutexDescriptor &Descriptor,
bool IsLock) { … }
void BlockInCriticalSectionChecker::handleLock(
const MutexDescriptor &LockDescriptor, const CallEvent &Call,
CheckerContext &C) const { … }
void BlockInCriticalSectionChecker::handleUnlock(
const MutexDescriptor &UnlockDescriptor, const CallEvent &Call,
CheckerContext &C) const { … }
bool BlockInCriticalSectionChecker::isBlockingInCritSection(
const CallEvent &Call, CheckerContext &C) const { … }
void BlockInCriticalSectionChecker::checkPostCall(const CallEvent &Call,
CheckerContext &C) const { … }
void BlockInCriticalSectionChecker::reportBlockInCritSection(
const CallEvent &Call, CheckerContext &C) const { … }
const NoteTag *
BlockInCriticalSectionChecker::createCritSectionNote(CritSectionMarker M,
CheckerContext &C) const { … }
void ento::registerBlockInCriticalSectionChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterBlockInCriticalSectionChecker(
const CheckerManager &mgr) { … }