19 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETY_H 20 #define LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETY_H 23 #include "llvm/ADT/StringRef.h" 27 class AnalysisDeclContext;
31 namespace threadSafety {
188 Name *PossibleMatch =
nullptr) {}
228 bool IssueBetaWarnings =
false;
249 #endif // LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETY_H virtual void handleNoMutexHeld(StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, AccessKind AK, SourceLocation Loc)
Warn when a protected operation occurs while no locks are held.
Represents a function declaration or definition.
Passing a guarded variable by reference.
TypePropertyCache< Private > Cache
virtual void handleUnmatchedUnlock(StringRef Kind, Name LockName, SourceLocation Loc)
Warn about unlock function calls that do not have a prior matching lock expression.
LockKind getLockKindFromAccessKind(AccessKind AK)
Helper function that returns a LockKind required for the given level of access.
Exclusive/writer lock of a mutex.
ProtectedOperationKind
This enum distinguishes between different kinds of operations that may need to be protected by locks...
void threadSafetyCleanup(BeforeSet *Cache)
LockKind
This enum distinguishes between different kinds of lock actions.
AnalysisDeclContext contains the context data for the function or method under analysis.
virtual void enterFunction(const FunctionDecl *FD)
Called by the analysis when starting analysis of a function.
virtual void handleInvalidLockExp(StringRef Kind, SourceLocation Loc)
Warn about lock expressions which fail to resolve to lockable objects.
virtual void handleNegativeNotHeld(StringRef Kind, Name LockName, Name Neg, SourceLocation Loc)
Warn when acquiring a lock that the negative capability is not held.
Shared/reader lock of a mutex.
virtual ~ThreadSafetyHandler()
Passing a pt-guarded variable by reference.
Handler class for thread safety warnings.
Dereferencing a variable (e.g. p in *p = 5;)
ThreadSafetyHandler()=default
virtual void handleLockAcquiredBefore(StringRef Kind, Name L1Name, Name L2Name, SourceLocation Loc)
Warn that L1 cannot be acquired before L2.
virtual void handleIncorrectUnlockKind(StringRef Kind, Name LockName, LockKind Expected, LockKind Received, SourceLocation Loc)
Warn about an unlock function call that attempts to unlock a lock with the incorrect lock kind...
AccessKind
This enum distinguishes between different ways to access (read or write) a variable.
virtual void handleFunExcludesLock(StringRef Kind, Name FunName, Name LockName, SourceLocation Loc)
Warn when a function is called while an excluded mutex is locked.
Making a function call (e.g. fool())
Reading or writing a variable (e.g. x in x = 5;)
Encodes a location in the source.
virtual void handleBeforeAfterCycle(Name L1Name, SourceLocation Loc)
Warn that there is a cycle in acquired_before/after dependencies.
Dataflow Directional Tag Classes.
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 locke...
void runThreadSafetyAnalysis(AnalysisDeclContext &AC, ThreadSafetyHandler &Handler, BeforeSet **Bset)
Check a function's CFG for thread-safety violations.
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 handleDoubleLock(StringRef Kind, Name LockName, SourceLocation Loc)
Warn about lock function calls for locks which are already held.
Defines the clang::SourceLocation class and associated facilities.
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.
void setIssueBetaWarnings(bool b)
virtual void leaveFunction(const FunctionDecl *FD)
Called by the analysis when finishing analysis of a function.
This represents a decl that may have a name.
Can be either Shared or Exclusive.