clang 20.0.0git
|
Handler class for thread safety warnings. More...
#include "clang/Analysis/Analyses/ThreadSafety.h"
Public Types | |
using | Name = StringRef |
Public Member Functions | |
ThreadSafetyHandler ()=default | |
virtual | ~ThreadSafetyHandler () |
virtual void | handleInvalidLockExp (SourceLocation Loc) |
Warn about lock expressions which fail to resolve to lockable objects. | |
virtual void | handleUnmatchedUnlock (StringRef Kind, Name LockName, SourceLocation Loc, SourceLocation LocPreviousUnlock) |
Warn about unlock function calls that do not have a prior matching lock expression. | |
virtual void | handleIncorrectUnlockKind (StringRef Kind, Name LockName, LockKind Expected, LockKind Received, SourceLocation LocLocked, SourceLocation LocUnlock) |
Warn about an unlock function call that attempts to unlock a lock with the incorrect lock kind. | |
virtual void | handleDoubleLock (StringRef Kind, Name LockName, SourceLocation LocLocked, SourceLocation LocDoubleLock) |
Warn about lock function calls for locks which are already held. | |
virtual void | handleMutexHeldEndOfScope (StringRef Kind, Name LockName, SourceLocation LocLocked, SourceLocation LocEndOfScope, LockErrorKind LEK) |
Warn about situations where a mutex is sometimes held and sometimes not. | |
virtual void | handleExclusiveAndShared (StringRef Kind, Name LockName, SourceLocation Loc1, SourceLocation Loc2) |
Warn when a mutex is held exclusively and shared at the same point. | |
virtual void | handleNoMutexHeld (const NamedDecl *D, ProtectedOperationKind POK, AccessKind AK, SourceLocation Loc) |
Warn when a protected operation occurs while no locks are held. | |
virtual void | handleMutexNotHeld (StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, Name LockName, LockKind LK, SourceLocation Loc, Name *PossibleMatch=nullptr) |
Warn when a protected operation occurs while the specific mutex protecting the operation is not locked. | |
virtual void | handleNegativeNotHeld (StringRef Kind, Name LockName, Name Neg, SourceLocation Loc) |
Warn when acquiring a lock that the negative capability is not held. | |
virtual void | handleNegativeNotHeld (const NamedDecl *D, Name LockName, SourceLocation Loc) |
Warn when calling a function that a negative capability is not held. | |
virtual void | handleFunExcludesLock (StringRef Kind, Name FunName, Name LockName, SourceLocation Loc) |
Warn when a function is called while an excluded mutex is locked. | |
virtual void | handleLockAcquiredBefore (StringRef Kind, Name L1Name, Name L2Name, SourceLocation Loc) |
Warn that L1 cannot be acquired before L2. | |
virtual void | handleBeforeAfterCycle (Name L1Name, SourceLocation Loc) |
Warn that there is a cycle in acquired_before/after dependencies. | |
virtual void | enterFunction (const FunctionDecl *FD) |
Called by the analysis when starting analysis of a function. | |
virtual void | leaveFunction (const FunctionDecl *FD) |
Called by the analysis when finishing analysis of a function. | |
bool | issueBetaWarnings () |
void | setIssueBetaWarnings (bool b) |
Handler class for thread safety warnings.
Definition at line 99 of file ThreadSafety.h.
using clang::threadSafety::ThreadSafetyHandler::Name = StringRef |
Definition at line 101 of file ThreadSafety.h.
|
default |
|
virtualdefault |
|
inlinevirtual |
Called by the analysis when starting analysis of a function.
Used to issue suggestions for changes to annotations.
Definition at line 235 of file ThreadSafety.h.
|
inlinevirtual |
Warn that there is a cycle in acquired_before/after dependencies.
Definition at line 231 of file ThreadSafety.h.
|
inlinevirtual |
Warn about lock function calls for locks which are already held.
Kind | – the capability's name parameter (role, mutex, etc). |
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
LocLocked | – The location of the first lock expression. |
LocDoubleLock | – The location of the second lock expression. |
Definition at line 142 of file ThreadSafety.h.
|
inlinevirtual |
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.
Kind | – the capability's name parameter (role, mutex, etc). |
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
Loc1 | – The location of the first lock expression. |
Loc2 | – The location of the second lock expression. |
Definition at line 172 of file ThreadSafety.h.
|
inlinevirtual |
Warn when a function is called while an excluded mutex is locked.
For example, the mutex may be locked inside the function.
Kind | – the capability's name parameter (role, mutex, etc). |
FunName | – The name of the function |
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
Loc | – The location of the function call. |
Definition at line 223 of file ThreadSafety.h.
|
inlinevirtual |
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.
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
Kind | – the capability's name parameter (role, mutex, etc). |
Expected | – the kind of lock expected. |
Received | – the kind of lock received. |
LocLocked | – The SourceLocation of the Lock. |
LocUnlock | – The SourceLocation of the Unlock. |
Definition at line 131 of file ThreadSafety.h.
|
inlinevirtual |
Warn about lock expressions which fail to resolve to lockable objects.
Loc | – the SourceLocation of the unresolved expression. |
Definition at line 108 of file ThreadSafety.h.
Referenced by warnInvalidLock().
|
inlinevirtual |
Warn that L1 cannot be acquired before L2.
Definition at line 227 of file ThreadSafety.h.
|
inlinevirtual |
Warn about situations where a mutex is sometimes held and sometimes not.
The three situations are:
Kind | – the capability's name parameter (role, mutex, etc). |
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
LocLocked | – The location of the lock expression where the mutex is locked |
LocEndOfScope | – The location of the end of the scope where the mutex is no longer held |
LEK | – which of the three above cases we should warn for |
Definition at line 159 of file ThreadSafety.h.
|
inlinevirtual |
Warn when a protected operation occurs while the specific mutex protecting the operation is not locked.
Kind | – the capability's name parameter (role, mutex, etc). |
D | – The decl for the protected variable or function |
POK | – The kind of protected operation (e.g. variable access) |
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
LK | – The kind of access (i.e. read or write) that occurred |
Loc | – The location of the protected operation. |
Definition at line 193 of file ThreadSafety.h.
|
inlinevirtual |
Warn when calling a function that a negative capability is not held.
D | – The decl for the function requiring the negative capability. |
LockName | – The name for the lock expression, to be printed in the diagnostic. |
Loc | – The location of the protected operation. |
Definition at line 213 of file ThreadSafety.h.
|
inlinevirtual |
Warn when acquiring a lock that the negative capability is not held.
Kind | – the capability's name parameter (role, mutex, etc). |
LockName | – The name for the lock expression, to be printed in the diagnostic. |
Neg | – The name of the negative capability to be printed in the diagnostic. |
Loc | – The location of the protected operation. |
Definition at line 205 of file ThreadSafety.h.
|
inlinevirtual |
Warn when a protected operation occurs while no locks are held.
D | – The decl for the protected variable or function |
POK | – The kind of protected operation (e.g. variable access) |
AK | – The kind of access (i.e. read or write) that occurred |
Loc | – The location of the protected operation. |
Definition at line 181 of file ThreadSafety.h.
|
inlinevirtual |
Warn about unlock function calls that do not have a prior matching lock expression.
Kind | – the capability's name parameter (role, mutex, etc). |
LockName | – A StringRef name for the lock expression, to be printed in the error message. |
Loc | – The SourceLocation of the Unlock |
LocPreviousUnlock | – If valid, the location of a previous Unlock. |
Definition at line 117 of file ThreadSafety.h.
|
inline |
Definition at line 240 of file ThreadSafety.h.
|
inlinevirtual |
Called by the analysis when finishing analysis of a function.
Definition at line 238 of file ThreadSafety.h.
|
inline |
Definition at line 241 of file ThreadSafety.h.
References b.