clang API Documentation

Public Types | Public Member Functions
clang::threadSafety::ThreadSafetyHandler Class Reference

Handler class for thread safety warnings. More...

#include <ThreadSafety.h>

Inheritance diagram for clang::threadSafety::ThreadSafetyHandler:
Inheritance graph
[legend]

List of all members.

Public Types

typedef StringRef Name

Public Member Functions

 ThreadSafetyHandler ()
virtual ~ThreadSafetyHandler ()
virtual void handleInvalidLockExp (StringRef Kind, SourceLocation Loc)
virtual void handleUnmatchedUnlock (StringRef Kind, Name LockName, SourceLocation Loc)
virtual void handleIncorrectUnlockKind (StringRef Kind, Name LockName, LockKind Expected, LockKind Received, SourceLocation Loc)
virtual void handleDoubleLock (StringRef Kind, Name LockName, SourceLocation Loc)
virtual void handleMutexHeldEndOfScope (StringRef Kind, Name LockName, SourceLocation LocLocked, SourceLocation LocEndOfScope, LockErrorKind LEK)
virtual void handleExclusiveAndShared (StringRef Kind, Name LockName, SourceLocation Loc1, SourceLocation Loc2)
virtual void handleNoMutexHeld (StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, AccessKind AK, SourceLocation Loc)
virtual void handleMutexNotHeld (StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, Name LockName, LockKind LK, SourceLocation Loc, Name *PossibleMatch=nullptr)
virtual void handleNegativeNotHeld (StringRef Kind, Name LockName, Name Neg, SourceLocation Loc)
virtual void handleFunExcludesLock (StringRef Kind, Name FunName, Name LockName, SourceLocation Loc)
virtual void enterFunction (const FunctionDecl *FD)
virtual void leaveFunction (const FunctionDecl *FD)
 Called by the analysis when finishing analysis of a function.
bool issueBetaWarnings ()
void setIssueBetaWarnings (bool b)

Detailed Description

Handler class for thread safety warnings.

Definition at line 71 of file ThreadSafety.h.


Member Typedef Documentation

Definition at line 73 of file ThreadSafety.h.


Constructor & Destructor Documentation

Definition at line 74 of file ThreadSafety.h.

Definition at line 53 of file ThreadSafety.cpp.


Member Function Documentation

virtual void clang::threadSafety::ThreadSafetyHandler::enterFunction ( const FunctionDecl FD) [inline, virtual]

Called by the analysis when starting analysis of a function. Used to issue suggestions for changes to annotations.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 188 of file ThreadSafety.h.

Referenced by clang::threadSafety::ThreadSafetyAnalyzer::runAnalysis().

virtual void clang::threadSafety::ThreadSafetyHandler::handleDoubleLock ( StringRef  Kind,
Name  LockName,
SourceLocation  Loc 
) [inline, virtual]

Warn about lock function calls for locks which are already held.

Parameters:
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 location of the second lock expression.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 109 of file ThreadSafety.h.

Referenced by clang::threadSafety::ThreadSafetyAnalyzer::addLock().

virtual void clang::threadSafety::ThreadSafetyHandler::handleExclusiveAndShared ( StringRef  Kind,
Name  LockName,
SourceLocation  Loc1,
SourceLocation  Loc2 
) [inline, virtual]

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.

Parameters:
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.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 138 of file ThreadSafety.h.

Referenced by clang::threadSafety::ThreadSafetyAnalyzer::intersectAndWarn().

virtual void clang::threadSafety::ThreadSafetyHandler::handleFunExcludesLock ( StringRef  Kind,
Name  FunName,
Name  LockName,
SourceLocation  Loc 
) [inline, virtual]

Warn when a function is called while an excluded mutex is locked. For example, the mutex may be locked inside the function.

Parameters:
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.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 183 of file ThreadSafety.h.

virtual void clang::threadSafety::ThreadSafetyHandler::handleIncorrectUnlockKind ( StringRef  Kind,
Name  LockName,
LockKind  Expected,
LockKind  Received,
SourceLocation  Loc 
) [inline, virtual]

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.

Parameters:
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.
Loc-- The SourceLocation of the Unlock.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 100 of file ThreadSafety.h.

Referenced by clang::threadSafety::ThreadSafetyAnalyzer::removeLock().

virtual void clang::threadSafety::ThreadSafetyHandler::handleInvalidLockExp ( StringRef  Kind,
SourceLocation  Loc 
) [inline, virtual]

Warn about lock expressions which fail to resolve to lockable objects.

Parameters:
Kind-- the capability's name parameter (role, mutex, etc).
Loc-- the SourceLocation of the unresolved expression.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 80 of file ThreadSafety.h.

Referenced by clang::threadSafety::warnInvalidLock().

virtual void clang::threadSafety::ThreadSafetyHandler::handleMutexHeldEndOfScope ( StringRef  Kind,
Name  LockName,
SourceLocation  LocLocked,
SourceLocation  LocEndOfScope,
LockErrorKind  LEK 
) [inline, virtual]

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.

Parameters:
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

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 125 of file ThreadSafety.h.

Referenced by clang::threadSafety::LockableFactEntry::handleRemovalFromIntersection(), and clang::threadSafety::ScopedLockableFactEntry::handleRemovalFromIntersection().

virtual void clang::threadSafety::ThreadSafetyHandler::handleMutexNotHeld ( StringRef  Kind,
const NamedDecl D,
ProtectedOperationKind  POK,
Name  LockName,
LockKind  LK,
SourceLocation  Loc,
Name PossibleMatch = nullptr 
) [inline, virtual]

Warn when a protected operation occurs while the specific mutex protecting the operation is not locked.

Parameters:
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.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 161 of file ThreadSafety.h.

virtual void clang::threadSafety::ThreadSafetyHandler::handleNegativeNotHeld ( StringRef  Kind,
Name  LockName,
Name  Neg,
SourceLocation  Loc 
) [inline, virtual]

Warn when acquiring a lock that the negative capability is not held.

Parameters:
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.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 173 of file ThreadSafety.h.

Referenced by clang::threadSafety::ThreadSafetyAnalyzer::addLock().

virtual void clang::threadSafety::ThreadSafetyHandler::handleNoMutexHeld ( StringRef  Kind,
const NamedDecl D,
ProtectedOperationKind  POK,
AccessKind  AK,
SourceLocation  Loc 
) [inline, virtual]

Warn when a protected operation occurs while no locks are held.

Parameters:
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)
AK-- The kind of access (i.e. read or write) that occurred
Loc-- The location of the protected operation.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 148 of file ThreadSafety.h.

virtual void clang::threadSafety::ThreadSafetyHandler::handleUnmatchedUnlock ( StringRef  Kind,
Name  LockName,
SourceLocation  Loc 
) [inline, virtual]

Warn about unlock function calls that do not have a prior matching lock expression.

Parameters:
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

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 88 of file ThreadSafety.h.

Referenced by clang::threadSafety::ScopedLockableFactEntry::handleUnlock(), and clang::threadSafety::ThreadSafetyAnalyzer::removeLock().

Definition at line 193 of file ThreadSafety.h.

virtual void clang::threadSafety::ThreadSafetyHandler::leaveFunction ( const FunctionDecl FD) [inline, virtual]

Called by the analysis when finishing analysis of a function.

Reimplemented in clang::threadSafety::ThreadSafetyReporter.

Definition at line 191 of file ThreadSafety.h.

Referenced by clang::threadSafety::ThreadSafetyAnalyzer::runAnalysis().

Definition at line 194 of file ThreadSafety.h.

Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().


The documentation for this class was generated from the following files: