class ThreadSafetyHandler
Declaration
class ThreadSafetyHandler { /* full declaration omitted */ };
Description
Handler class for thread safety warnings.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:93
Member Variables
- private bool IssueBetaWarnings = false
Method Overview
- public ThreadSafetyHandler()
- public virtual void enterFunction(const clang::FunctionDecl * FD)
- public virtual void handleBeforeAfterCycle(clang::threadSafety::ThreadSafetyHandler::Name L1Name, clang::SourceLocation Loc)
- public virtual void handleDoubleLock(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::SourceLocation LocLocked, clang::SourceLocation LocDoubleLock)
- public virtual void handleExclusiveAndShared(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::SourceLocation Loc1, clang::SourceLocation Loc2)
- public virtual void handleFunExcludesLock(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name FunName, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::SourceLocation Loc)
- public virtual void handleIncorrectUnlockKind(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::threadSafety::LockKind Expected, clang::threadSafety::LockKind Received, clang::SourceLocation LocLocked, clang::SourceLocation LocUnlock)
- public virtual void handleInvalidLockExp(clang::SourceLocation Loc)
- public virtual void handleLockAcquiredBefore(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name L1Name, clang::threadSafety::ThreadSafetyHandler::Name L2Name, clang::SourceLocation Loc)
- public virtual void handleMutexHeldEndOfScope(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::SourceLocation LocLocked, clang::SourceLocation LocEndOfScope, clang::threadSafety::LockErrorKind LEK)
- public virtual void handleMutexNotHeld(llvm::StringRef Kind, const clang::NamedDecl * D, clang::threadSafety::ProtectedOperationKind POK, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::threadSafety::LockKind LK, clang::SourceLocation Loc, clang::threadSafety::ThreadSafetyHandler::Name * PossibleMatch = nullptr)
- public virtual void handleNegativeNotHeld(const clang::NamedDecl * D, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::SourceLocation Loc)
- public virtual void handleNegativeNotHeld(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::threadSafety::ThreadSafetyHandler::Name Neg, clang::SourceLocation Loc)
- public virtual void handleNoMutexHeld(const clang::NamedDecl * D, clang::threadSafety::ProtectedOperationKind POK, clang::threadSafety::AccessKind AK, clang::SourceLocation Loc)
- public virtual void handleUnmatchedUnlock(llvm::StringRef Kind, clang::threadSafety::ThreadSafetyHandler::Name LockName, clang::SourceLocation Loc, clang::SourceLocation LocPreviousUnlock)
- public bool issueBetaWarnings()
- public virtual void leaveFunction(const clang::FunctionDecl * FD)
- public void setIssueBetaWarnings(bool b)
- public virtual ~ThreadSafetyHandler()
Methods
¶ThreadSafetyHandler()
ThreadSafetyHandler()
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:97
¶virtual void enterFunction(
const clang::FunctionDecl* FD)
virtual void enterFunction(
const clang::FunctionDecl* FD)
Description
Called by the analysis when starting analysis of a function. Used to issue suggestions for changes to annotations.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:229
Parameters
- const clang::FunctionDecl* FD
¶virtual void handleBeforeAfterCycle(
clang::threadSafety::ThreadSafetyHandler::Name
L1Name,
clang::SourceLocation Loc)
virtual void handleBeforeAfterCycle(
clang::threadSafety::ThreadSafetyHandler::Name
L1Name,
clang::SourceLocation Loc)
Description
Warn that there is a cycle in acquired_before/after dependencies.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:225
Parameters
¶virtual void handleDoubleLock(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation LocLocked,
clang::SourceLocation LocDoubleLock)
virtual void handleDoubleLock(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation LocLocked,
clang::SourceLocation LocDoubleLock)
Description
Warn about lock function calls for locks which are already held.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:136
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::SourceLocation LocLocked
- -- The location of the first lock expression.
- clang::SourceLocation LocDoubleLock
- -- The location of the second lock expression.
¶virtual void handleExclusiveAndShared(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc1,
clang::SourceLocation Loc2)
virtual void handleExclusiveAndShared(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc1,
clang::SourceLocation Loc2)
Description
Warn when a mutex is held exclusively and shared at the same point. For example, if a mutex is locked exclusively during an if branch and shared during the else branch.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:166
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::SourceLocation Loc1
- -- The location of the first lock expression.
- clang::SourceLocation Loc2
- -- The location of the second lock expression.
¶virtual void handleFunExcludesLock(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
FunName,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc)
virtual void handleFunExcludesLock(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
FunName,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc)
Description
Warn when a function is called while an excluded mutex is locked. For example, the mutex may be locked inside the function.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:217
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name FunName
- -- The name of the function
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::SourceLocation Loc
- -- The location of the function call.
¶virtual void handleIncorrectUnlockKind(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::threadSafety::LockKind Expected,
clang::threadSafety::LockKind Received,
clang::SourceLocation LocLocked,
clang::SourceLocation LocUnlock)
virtual void handleIncorrectUnlockKind(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::threadSafety::LockKind Expected,
clang::threadSafety::LockKind Received,
clang::SourceLocation LocLocked,
clang::SourceLocation LocUnlock)
Description
Warn about an unlock function call that attempts to unlock a lock with the incorrect lock kind. For instance, a shared lock being unlocked exclusively, or vice versa.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:125
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::threadSafety::LockKind Expected
- -- the kind of lock expected.
- clang::threadSafety::LockKind Received
- -- the kind of lock received.
- clang::SourceLocation LocLocked
- -- The SourceLocation of the Lock.
- clang::SourceLocation LocUnlock
- -- The SourceLocation of the Unlock.
¶virtual void handleInvalidLockExp(
clang::SourceLocation Loc)
virtual void handleInvalidLockExp(
clang::SourceLocation Loc)
Description
Warn about lock expressions which fail to resolve to lockable objects.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:102
Parameters
- clang::SourceLocation Loc
- -- the SourceLocation of the unresolved expression.
¶virtual void handleLockAcquiredBefore(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
L1Name,
clang::threadSafety::ThreadSafetyHandler::Name
L2Name,
clang::SourceLocation Loc)
virtual void handleLockAcquiredBefore(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
L1Name,
clang::threadSafety::ThreadSafetyHandler::Name
L2Name,
clang::SourceLocation Loc)
Description
Warn that L1 cannot be acquired before L2.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:221
Parameters
- llvm::StringRef Kind
- clang::threadSafety::ThreadSafetyHandler::Name L1Name
- clang::threadSafety::ThreadSafetyHandler::Name L2Name
- clang::SourceLocation Loc
¶virtual void handleMutexHeldEndOfScope(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation LocLocked,
clang::SourceLocation LocEndOfScope,
clang::threadSafety::LockErrorKind LEK)
virtual void handleMutexHeldEndOfScope(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation LocLocked,
clang::SourceLocation LocEndOfScope,
clang::threadSafety::LockErrorKind LEK)
Description
Warn about situations where a mutex is sometimes held and sometimes not. The three situations are: 1. a mutex is locked on an "if" branch but not the "else" branch, 2, or a mutex is only held at the start of some loop iterations, 3. or when a mutex is locked but not unlocked inside a function.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:153
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::SourceLocation LocLocked
- -- The location of the lock expression where the mutex is locked
- clang::SourceLocation LocEndOfScope
- -- The location of the end of the scope where the mutex is no longer held
- clang::threadSafety::LockErrorKind LEK
- -- which of the three above cases we should warn for
¶virtual void handleMutexNotHeld(
llvm::StringRef Kind,
const clang::NamedDecl* D,
clang::threadSafety::ProtectedOperationKind
POK,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::threadSafety::LockKind LK,
clang::SourceLocation Loc,
clang::threadSafety::ThreadSafetyHandler::
Name* PossibleMatch = nullptr)
virtual void handleMutexNotHeld(
llvm::StringRef Kind,
const clang::NamedDecl* D,
clang::threadSafety::ProtectedOperationKind
POK,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::threadSafety::LockKind LK,
clang::SourceLocation Loc,
clang::threadSafety::ThreadSafetyHandler::
Name* PossibleMatch = nullptr)
Description
Warn when a protected operation occurs while the specific mutex protecting the operation is not locked.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:187
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- const clang::NamedDecl* D
- -- The decl for the protected variable or function
- clang::threadSafety::ProtectedOperationKind POK
- -- The kind of protected operation (e.g. variable access)
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::threadSafety::LockKind LK
- -- The kind of access (i.e. read or write) that occurred
- clang::SourceLocation Loc
- -- The location of the protected operation.
- clang::threadSafety::ThreadSafetyHandler::Name* PossibleMatch = nullptr
¶virtual void handleNegativeNotHeld(
const clang::NamedDecl* D,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc)
virtual void handleNegativeNotHeld(
const clang::NamedDecl* D,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc)
Description
Warn when calling a function that a negative capability is not held.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:207
Parameters
- const clang::NamedDecl* D
- -- The decl for the function requiring the negative capability.
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- The name for the lock expression, to be printed in the diagnostic.
- clang::SourceLocation Loc
- -- The location of the protected operation.
¶virtual void handleNegativeNotHeld(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::threadSafety::ThreadSafetyHandler::Name
Neg,
clang::SourceLocation Loc)
virtual void handleNegativeNotHeld(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::threadSafety::ThreadSafetyHandler::Name
Neg,
clang::SourceLocation Loc)
Description
Warn when acquiring a lock that the negative capability is not held.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:199
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- The name for the lock expression, to be printed in the diagnostic.
- clang::threadSafety::ThreadSafetyHandler::Name Neg
- -- The name of the negative capability to be printed in the diagnostic.
- clang::SourceLocation Loc
- -- The location of the protected operation.
¶virtual void handleNoMutexHeld(
const clang::NamedDecl* D,
clang::threadSafety::ProtectedOperationKind
POK,
clang::threadSafety::AccessKind AK,
clang::SourceLocation Loc)
virtual void handleNoMutexHeld(
const clang::NamedDecl* D,
clang::threadSafety::ProtectedOperationKind
POK,
clang::threadSafety::AccessKind AK,
clang::SourceLocation Loc)
Description
Warn when a protected operation occurs while no locks are held.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:175
Parameters
- const clang::NamedDecl* D
- -- The decl for the protected variable or function
- clang::threadSafety::ProtectedOperationKind POK
- -- The kind of protected operation (e.g. variable access)
- clang::threadSafety::AccessKind AK
- -- The kind of access (i.e. read or write) that occurred
- clang::SourceLocation Loc
- -- The location of the protected operation.
¶virtual void handleUnmatchedUnlock(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc,
clang::SourceLocation LocPreviousUnlock)
virtual void handleUnmatchedUnlock(
llvm::StringRef Kind,
clang::threadSafety::ThreadSafetyHandler::Name
LockName,
clang::SourceLocation Loc,
clang::SourceLocation LocPreviousUnlock)
Description
Warn about unlock function calls that do not have a prior matching lock expression.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:111
Parameters
- llvm::StringRef Kind
- -- the capability's name parameter (role, mutex, etc).
- clang::threadSafety::ThreadSafetyHandler::Name LockName
- -- A StringRef name for the lock expression, to be printed in the error message.
- clang::SourceLocation Loc
- -- The SourceLocation of the Unlock
- clang::SourceLocation LocPreviousUnlock
- -- If valid, the location of a previous Unlock.
¶bool issueBetaWarnings()
bool issueBetaWarnings()
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:234
¶virtual void leaveFunction(
const clang::FunctionDecl* FD)
virtual void leaveFunction(
const clang::FunctionDecl* FD)
Description
Called by the analysis when finishing analysis of a function.
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:232
Parameters
- const clang::FunctionDecl* FD
¶void setIssueBetaWarnings(bool b)
void setIssueBetaWarnings(bool b)
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:235
Parameters
- bool b
¶virtual ~ThreadSafetyHandler()
virtual ~ThreadSafetyHandler()
Declared at: clang/include/clang/Analysis/Analyses/ThreadSafety.h:98