clang API Documentation

Classes | Typedefs | Enumerations | Functions
clang::thread_safety Namespace Reference

Classes

class  ThreadSafetyHandler
 Handler class for thread safety warnings. More...
struct  SortDiagBySourceLocation

Typedefs

typedef llvm::SmallVector
< PartialDiagnosticAt, 1 > 
OptionalNotes
typedef std::pair
< PartialDiagnosticAt,
OptionalNotes
DelayedDiag
typedef std::list< DelayedDiagDiagList

Enumerations

enum  ProtectedOperationKind { POK_VarDereference, POK_VarAccess, POK_FunctionCall }
enum  LockKind { LK_Shared, LK_Exclusive }
enum  AccessKind { AK_Read, AK_Written }
enum  LockErrorKind { LEK_LockedSomeLoopIterations, LEK_LockedSomePredecessors, LEK_LockedAtEndOfFunction }

Functions

void runThreadSafetyAnalysis (AnalysisDeclContext &AC, ThreadSafetyHandler &Handler)
 Check a function's CFG for thread-safety violations.
LockKind getLockKindFromAccessKind (AccessKind AK)
 Helper function that returns a LockKind required for the given level of access.

Typedef Documentation

Definition at line 806 of file AnalysisBasedWarnings.cpp.

Definition at line 807 of file AnalysisBasedWarnings.cpp.

Definition at line 805 of file AnalysisBasedWarnings.cpp.


Enumeration Type Documentation

This enum distinguishes between different ways to access (read or write) a variable.

Enumerator:
AK_Read 
AK_Written 

Reading a variable.

Writing a variable

Definition at line 47 of file ThreadSafety.h.

Enumerator:
LEK_LockedSomeLoopIterations 
LEK_LockedSomePredecessors 
LEK_LockedAtEndOfFunction 

Definition at line 60 of file ThreadSafety.h.

This enum distinguishes between different kinds of lock actions. For example, it is an error to write a variable protected by shared version of a mutex.

Enumerator:
LK_Shared 
LK_Exclusive 

Shared/reader lock of a mutex.

Exclusive/writer lock of a mutex

Definition at line 40 of file ThreadSafety.h.

This enum distinguishes between different kinds of operations that may need to be protected by locks. We use this enum in error handling.

Enumerator:
POK_VarDereference 
POK_VarAccess 

Dereferencing a variable (e.g. p in *p = 5;)

POK_FunctionCall 

Reading or writing a variable (e.g. x in x = 5;)

Making a function call (e.g. fool())

Definition at line 31 of file ThreadSafety.h.


Function Documentation

LockKind clang::thread_safety::getLockKindFromAccessKind ( AccessKind  AK)

Helper function that returns a LockKind required for the given level of access.

Definition at line 1762 of file ThreadSafety.cpp.

References AK_Read, AK_Written, LK_Exclusive, and LK_Shared.

void clang::thread_safety::runThreadSafetyAnalysis ( AnalysisDeclContext AC,
ThreadSafetyHandler Handler 
)

Check a function's CFG for thread-safety violations.

We traverse the blocks in the CFG, compute the set of mutexes that are held at the end of each block, and issue warnings for thread safety violations. Each block in the CFG is traversed exactly once.

Definition at line 1754 of file ThreadSafety.cpp.

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