diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Analysis/Analyses/ThreadSafety.h')
-rw-r--r-- | contrib/llvm/tools/clang/include/clang/Analysis/Analyses/ThreadSafety.h | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Analysis/Analyses/ThreadSafety.h b/contrib/llvm/tools/clang/include/clang/Analysis/Analyses/ThreadSafety.h index 5def3dd..b533c1d 100644 --- a/contrib/llvm/tools/clang/include/clang/Analysis/Analyses/ThreadSafety.h +++ b/contrib/llvm/tools/clang/include/clang/Analysis/Analyses/ThreadSafety.h @@ -39,7 +39,8 @@ enum ProtectedOperationKind { /// mutex. enum LockKind { LK_Shared, ///< Shared/reader lock of a mutex. - LK_Exclusive ///< Exclusive/writer lock of a mutex. + LK_Exclusive, ///< Exclusive/writer lock of a mutex. + LK_Generic ///< Can be either Shared or Exclusive }; /// This enum distinguishes between different ways to access (read or write) a @@ -72,27 +73,46 @@ public: virtual ~ThreadSafetyHandler(); /// Warn about lock expressions which fail to resolve to lockable objects. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param Loc -- the SourceLocation of the unresolved expression. - virtual void handleInvalidLockExp(SourceLocation Loc) {} + virtual void handleInvalidLockExp(StringRef Kind, SourceLocation Loc) {} /// Warn about unlock function calls that do not have a prior matching lock /// expression. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param LockName -- A StringRef name for the lock expression, to be printed /// in the error message. /// \param Loc -- The SourceLocation of the Unlock - virtual void handleUnmatchedUnlock(Name LockName, SourceLocation Loc) {} + virtual void handleUnmatchedUnlock(StringRef Kind, Name LockName, + SourceLocation Loc) {} + + /// 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. + /// \param LockName -- A StringRef name for the lock expression, to be printed + /// in the error message. + /// \param Kind -- the capability's name parameter (role, mutex, etc). + /// \param Expected -- the kind of lock expected. + /// \param Received -- the kind of lock received. + /// \param Loc -- The SourceLocation of the Unlock. + virtual void handleIncorrectUnlockKind(StringRef Kind, Name LockName, + LockKind Expected, LockKind Received, + SourceLocation Loc) {} /// Warn about lock function calls for locks which are already held. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param LockName -- A StringRef name for the lock expression, to be printed /// in the error message. /// \param Loc -- The location of the second lock expression. - virtual void handleDoubleLock(Name LockName, SourceLocation Loc) {} + virtual void handleDoubleLock(StringRef Kind, Name LockName, + SourceLocation Loc) {} /// 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. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param LockName -- A StringRef name for the lock expression, to be printed /// in the error message. /// \param LocLocked -- The location of the lock expression where the mutex is @@ -100,50 +120,56 @@ public: /// \param LocEndOfScope -- The location of the end of the scope where the /// mutex is no longer held /// \param LEK -- which of the three above cases we should warn for - virtual void handleMutexHeldEndOfScope(Name LockName, + virtual void handleMutexHeldEndOfScope(StringRef Kind, Name LockName, SourceLocation LocLocked, SourceLocation LocEndOfScope, - LockErrorKind LEK){} + LockErrorKind LEK) {} /// 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. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param LockName -- A StringRef name for the lock expression, to be printed /// in the error message. /// \param Loc1 -- The location of the first lock expression. /// \param Loc2 -- The location of the second lock expression. - virtual void handleExclusiveAndShared(Name LockName, SourceLocation Loc1, + virtual void handleExclusiveAndShared(StringRef Kind, Name LockName, + SourceLocation Loc1, SourceLocation Loc2) {} /// Warn when a protected operation occurs while no locks are held. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param D -- The decl for the protected variable or function /// \param POK -- The kind of protected operation (e.g. variable access) /// \param AK -- The kind of access (i.e. read or write) that occurred /// \param Loc -- The location of the protected operation. - virtual void handleNoMutexHeld(const NamedDecl *D, ProtectedOperationKind POK, - AccessKind AK, SourceLocation Loc) {} + virtual void handleNoMutexHeld(StringRef Kind, const NamedDecl *D, + ProtectedOperationKind POK, AccessKind AK, + SourceLocation Loc) {} /// Warn when a protected operation occurs while the specific mutex protecting /// the operation is not locked. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param D -- The decl for the protected variable or function /// \param POK -- The kind of protected operation (e.g. variable access) /// \param LockName -- A StringRef name for the lock expression, to be printed /// in the error message. /// \param LK -- The kind of access (i.e. read or write) that occurred /// \param Loc -- The location of the protected operation. - virtual void handleMutexNotHeld(const NamedDecl *D, + virtual void handleMutexNotHeld(StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, Name LockName, LockKind LK, SourceLocation Loc, - Name *PossibleMatch=0) {} + Name *PossibleMatch = nullptr) {} /// Warn when a function is called while an excluded mutex is locked. For /// example, the mutex may be locked inside the function. + /// \param Kind -- the capability's name parameter (role, mutex, etc). /// \param FunName -- The name of the function /// \param LockName -- A StringRef name for the lock expression, to be printed /// in the error message. /// \param Loc -- The location of the function call. - virtual void handleFunExcludesLock(Name FunName, Name LockName, - SourceLocation Loc) {} + virtual void handleFunExcludesLock(StringRef Kind, Name FunName, + Name LockName, SourceLocation Loc) {} bool issueBetaWarnings() { return IssueBetaWarnings; } void setIssueBetaWarnings(bool b) { IssueBetaWarnings = b; } |