clang API Documentation
Public Member Functions | |
ThreadSafetyReporter (Sema &S, SourceLocation FL, SourceLocation FEL) | |
void | setVerbose (bool b) |
void | emitDiagnostics () |
Emit all buffered diagnostics in order of sourcelocation. We need to output diagnostics produced while iterating through the lockset in deterministic order, so this function orders diagnostics and outputs them. | |
void | handleInvalidLockExp (StringRef Kind, SourceLocation Loc) override |
void | handleUnmatchedUnlock (StringRef Kind, Name LockName, SourceLocation Loc) override |
void | handleIncorrectUnlockKind (StringRef Kind, Name LockName, LockKind Expected, LockKind Received, SourceLocation Loc) override |
void | handleDoubleLock (StringRef Kind, Name LockName, SourceLocation Loc) override |
void | handleMutexHeldEndOfScope (StringRef Kind, Name LockName, SourceLocation LocLocked, SourceLocation LocEndOfScope, LockErrorKind LEK) override |
void | handleExclusiveAndShared (StringRef Kind, Name LockName, SourceLocation Loc1, SourceLocation Loc2) override |
void | handleNoMutexHeld (StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, AccessKind AK, SourceLocation Loc) override |
void | handleMutexNotHeld (StringRef Kind, const NamedDecl *D, ProtectedOperationKind POK, Name LockName, LockKind LK, SourceLocation Loc, Name *PossibleMatch) override |
virtual void | handleNegativeNotHeld (StringRef Kind, Name LockName, Name Neg, SourceLocation Loc) override |
void | handleFunExcludesLock (StringRef Kind, Name FunName, Name LockName, SourceLocation Loc) override |
void | enterFunction (const FunctionDecl *FD) override |
void | leaveFunction (const FunctionDecl *FD) override |
Called by the analysis when finishing analysis of a function. |
Definition at line 1442 of file AnalysisBasedWarnings.cpp.
clang::threadSafety::ThreadSafetyReporter::ThreadSafetyReporter | ( | Sema & | S, |
SourceLocation | FL, | ||
SourceLocation | FEL | ||
) | [inline] |
Definition at line 1497 of file AnalysisBasedWarnings.cpp.
void clang::threadSafety::ThreadSafetyReporter::emitDiagnostics | ( | ) | [inline] |
Emit all buffered diagnostics in order of sourcelocation. We need to output diagnostics produced while iterating through the lockset in deterministic order, so this function orders diagnostics and outputs them.
Definition at line 1507 of file AnalysisBasedWarnings.cpp.
References Diag(), and Warnings.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().
void clang::threadSafety::ThreadSafetyReporter::enterFunction | ( | const FunctionDecl * | FD | ) | [inline, override, virtual] |
Called by the analysis when starting analysis of a function. Used to issue suggestions for changes to annotations.
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1682 of file AnalysisBasedWarnings.cpp.
void clang::threadSafety::ThreadSafetyReporter::handleDoubleLock | ( | StringRef | Kind, |
Name | LockName, | ||
SourceLocation | Loc | ||
) | [inline, override, virtual] |
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. |
Loc | -- The location of the second lock expression. |
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1538 of file AnalysisBasedWarnings.cpp.
void clang::threadSafety::ThreadSafetyReporter::handleExclusiveAndShared | ( | StringRef | Kind, |
Name | LockName, | ||
SourceLocation | Loc1, | ||
SourceLocation | Loc2 | ||
) | [inline, override, 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.
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 from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1575 of file AnalysisBasedWarnings.cpp.
References clang::serialized_diags::Note, clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleFunExcludesLock | ( | StringRef | Kind, |
Name | FunName, | ||
Name | LockName, | ||
SourceLocation | Loc | ||
) | [inline, override, virtual] |
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. |
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1675 of file AnalysisBasedWarnings.cpp.
References clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleIncorrectUnlockKind | ( | StringRef | Kind, |
Name | LockName, | ||
LockKind | Expected, | ||
LockKind | Received, | ||
SourceLocation | Loc | ||
) | [inline, override, 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.
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 from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1527 of file AnalysisBasedWarnings.cpp.
References clang::SourceLocation::isInvalid(), clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleInvalidLockExp | ( | StringRef | Kind, |
SourceLocation | Loc | ||
) | [inline, override, virtual] |
Warn about lock expressions which fail to resolve to lockable objects.
Kind | -- the capability's name parameter (role, mutex, etc). |
Loc | -- the SourceLocation of the unresolved expression. |
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1516 of file AnalysisBasedWarnings.cpp.
References clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleMutexHeldEndOfScope | ( | StringRef | Kind, |
Name | LockName, | ||
SourceLocation | LocLocked, | ||
SourceLocation | LocEndOfScope, | ||
LockErrorKind | LEK | ||
) | [inline, override, 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.
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 from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1542 of file AnalysisBasedWarnings.cpp.
References clang::SourceLocation::isInvalid(), clang::SourceLocation::isValid(), clang::threadSafety::LEK_LockedAtEndOfFunction, clang::threadSafety::LEK_LockedSomeLoopIterations, clang::threadSafety::LEK_LockedSomePredecessors, clang::threadSafety::LEK_NotLockedAtEndOfFunction, clang::serialized_diags::Note, clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleMutexNotHeld | ( | StringRef | Kind, |
const NamedDecl * | D, | ||
ProtectedOperationKind | POK, | ||
Name | LockName, | ||
LockKind | LK, | ||
SourceLocation | Loc, | ||
Name * | PossibleMatch | ||
) | [inline, override, virtual] |
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. |
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1599 of file AnalysisBasedWarnings.cpp.
References clang::Decl::getLocation(), clang::NamedDecl::getNameAsString(), clang::serialized_diags::Note, clang::threadSafety::POK_FunctionCall, clang::threadSafety::POK_PassByRef, clang::threadSafety::POK_PtPassByRef, clang::threadSafety::POK_VarAccess, clang::threadSafety::POK_VarDereference, clang::diag::Warning, and Warnings.
virtual void clang::threadSafety::ThreadSafetyReporter::handleNegativeNotHeld | ( | StringRef | Kind, |
Name | LockName, | ||
Name | Neg, | ||
SourceLocation | Loc | ||
) | [inline, override, virtual] |
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. |
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1666 of file AnalysisBasedWarnings.cpp.
References clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleNoMutexHeld | ( | StringRef | Kind, |
const NamedDecl * | D, | ||
ProtectedOperationKind | POK, | ||
AccessKind | AK, | ||
SourceLocation | Loc | ||
) | [inline, override, virtual] |
Warn when a protected operation occurs while no locks are held.
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 from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1586 of file AnalysisBasedWarnings.cpp.
References clang::threadSafety::getLockKindFromAccessKind(), clang::NamedDecl::getNameAsString(), clang::threadSafety::POK_VarAccess, clang::threadSafety::POK_VarDereference, clang::diag::Warning, and Warnings.
void clang::threadSafety::ThreadSafetyReporter::handleUnmatchedUnlock | ( | StringRef | Kind, |
Name | LockName, | ||
SourceLocation | Loc | ||
) | [inline, override, virtual] |
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 |
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1522 of file AnalysisBasedWarnings.cpp.
void clang::threadSafety::ThreadSafetyReporter::leaveFunction | ( | const FunctionDecl * | FD | ) | [inline, override, virtual] |
Called by the analysis when finishing analysis of a function.
Reimplemented from clang::threadSafety::ThreadSafetyHandler.
Definition at line 1686 of file AnalysisBasedWarnings.cpp.
void clang::threadSafety::ThreadSafetyReporter::setVerbose | ( | bool | b | ) | [inline] |
Definition at line 1501 of file AnalysisBasedWarnings.cpp.
Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings().