clang  3.9.0
Classes | Public Types | Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | List of all members
clang::sema::FunctionScopeInfo Class Reference

Retains information about a function, method, or block that is currently being parsed. More...

#include <ScopeInfo.h>

Inheritance diagram for clang::sema::FunctionScopeInfo:
[legend]
Collaboration diagram for clang::sema::FunctionScopeInfo:
[legend]

Classes

class  WeakObjectProfileTy
 Represents a simple identification of a weak object. More...
 
class  WeakUseTy
 Represents a single use of a weak object. More...
 

Public Types

typedef SmallVector< WeakUseTy, 4 > WeakUseVector
 Used to collect uses of a particular weak object in a function body. More...
 
typedef llvm::SmallDenseMap
< WeakObjectProfileTy,
WeakUseVector,
8, WeakObjectProfileTy::DenseMapInfo
WeakObjectUseMap
 Used to collect all uses of weak objects in a function body. More...
 

Public Member Functions

template<typename ExprT >
void recordUseOfWeak (const ExprT *E, bool IsRead=true)
 Record that a weak object was accessed. More...
 
void recordUseOfWeak (const ObjCMessageExpr *Msg, const ObjCPropertyDecl *Prop)
 
void markSafeWeakUse (const Expr *E)
 Record that a given expression is a "safe" access of a weak object (e.g. More...
 
const WeakObjectUseMapgetWeakObjectUses () const
 
void setHasBranchIntoScope ()
 
void setHasBranchProtectedScope ()
 
void setHasIndirectGoto ()
 
void setHasDroppedStmt ()
 
void setHasOMPDeclareReductionCombiner ()
 
void setHasFallthroughStmt ()
 
void setHasCXXTry (SourceLocation TryLoc)
 
void setHasSEHTry (SourceLocation TryLoc)
 
bool NeedsScopeChecking () const
 
 FunctionScopeInfo (DiagnosticsEngine &Diag)
 
virtual ~FunctionScopeInfo ()
 
void Clear ()
 Clear out the information in this function scope, making it suitable for reuse. More...
 

Public Attributes

ScopeKind Kind: 3
 What kind of scope we are describing. More...
 
bool HasBranchProtectedScope: 1
 Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jumped past. More...
 
bool HasBranchIntoScope: 1
 Whether this function contains any switches or direct gotos. More...
 
bool HasIndirectGoto: 1
 Whether this function contains any indirect gotos. More...
 
bool HasDroppedStmt: 1
 Whether a statement was dropped because it was invalid. More...
 
bool HasOMPDeclareReductionCombiner
 True if current scope is for OpenMP declare reduction combiner. More...
 
bool HasFallthroughStmt: 1
 Whether there is a fallthrough statement in this function. More...
 
bool ObjCShouldCallSuper: 1
 A flag that is set when parsing a method that must call super's implementation, such as -dealloc, -finalize, or any method marked with attribute((objc_requires_super)). More...
 
bool ObjCIsDesignatedInit: 1
 True when this is a method marked as a designated initializer. More...
 
bool ObjCWarnForNoDesignatedInitChain: 1
 This starts true for a method marked as designated initializer and will be set to false if there is an invocation to a designated initializer of the super class. More...
 
bool ObjCIsSecondaryInit: 1
 True when this is an initializer method not marked as a designated initializer within a class that has at least one initializer marked as a designated initializer. More...
 
bool ObjCWarnForNoInitDelegation: 1
 This starts true for a secondary initializer method and will be set to false if there is an invocation of an initializer on 'self'. More...
 
SourceLocation FirstReturnLoc
 First 'return' statement in the current function. More...
 
SourceLocation FirstCXXTryLoc
 First C++ 'try' statement in the current function. More...
 
SourceLocation FirstSEHTryLoc
 First SEH '__try' statement in the current function. More...
 
DiagnosticErrorTrap ErrorTrap
 Used to determine if errors occurred in this function or block. More...
 
SmallVector< SwitchStmt *, 8 > SwitchStack
 SwitchStack - This is the current set of active switch statements in the block. More...
 
SmallVector< ReturnStmt *, 4 > Returns
 The list of return statements that occur within the function or block, if there is any chance of applying the named return value optimization, or if we need to infer a return type. More...
 
VarDeclCoroutinePromise
 The promise object for this coroutine, if any. More...
 
SmallVector< Stmt *, 4 > CoroutineStmts
 The list of coroutine control flow constructs (co_await, co_yield, co_return) that occur within the function or block. More...
 
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
 The stack of currently active compound stamement scopes in the function. More...
 
SmallVector
< PossiblyUnreachableDiag, 4 > 
PossiblyUnreachableDiags
 A list of PartialDiagnostics created but delayed within the current function scope. More...
 
llvm::SmallPtrSet< const
ParmVarDecl *, 8 > 
ModifiedNonNullParams
 A list of parameters which have the nonnull attribute and are modified in the function. More...
 

Protected Types

enum  ScopeKind { SK_Function, SK_Block, SK_Lambda, SK_CapturedRegion }
 

Protected Member Functions

 FunctionScopeInfo (const FunctionScopeInfo &)=default
 

Detailed Description

Retains information about a function, method, or block that is currently being parsed.

Definition at line 81 of file ScopeInfo.h.

Member Typedef Documentation

Used to collect all uses of weak objects in a function body.

Part of the implementation of -Wrepeated-use-of-weak.

Definition at line 305 of file ScopeInfo.h.

Used to collect uses of a particular weak object in a function body.

Part of the implementation of -Wrepeated-use-of-weak.

Definition at line 298 of file ScopeInfo.h.

Member Enumeration Documentation

Enumerator
SK_Function 
SK_Block 
SK_Lambda 
SK_CapturedRegion 

Definition at line 83 of file ScopeInfo.h.

Constructor & Destructor Documentation

clang::sema::FunctionScopeInfo::FunctionScopeInfo ( const FunctionScopeInfo )
protecteddefault
clang::sema::FunctionScopeInfo::FunctionScopeInfo ( DiagnosticsEngine Diag)
inline

Definition at line 376 of file ScopeInfo.h.

FunctionScopeInfo::~FunctionScopeInfo ( )
virtual

Definition at line 241 of file ScopeInfo.cpp.

Member Function Documentation

void FunctionScopeInfo::Clear ( )
const WeakObjectUseMap& clang::sema::FunctionScopeInfo::getWeakObjectUses ( ) const
inline

Definition at line 332 of file ScopeInfo.h.

Referenced by diagnoseRepeatedUseOfWeak().

void FunctionScopeInfo::markSafeWeakUse ( const Expr E)

Record that a given expression is a "safe" access of a weak object (e.g.

assigning it to a strong variable.)

Part of the implementation of -Wrepeated-use-of-weak.

Definition at line 163 of file ScopeInfo.cpp.

References clang::ObjCPropertyDecl::findPropertyDecl(), clang::PseudoObjectExpr::getSyntacticForm(), and clang::Expr::IgnoreParenCasts().

Referenced by clang::Sema::CheckAssignmentOperands().

bool clang::sema::FunctionScopeInfo::NeedsScopeChecking ( ) const
inline
template<typename ExprT >
void clang::sema::FunctionScopeInfo::recordUseOfWeak ( const ExprT *  E,
bool  IsRead = true 
)
inline

Record that a weak object was accessed.

Part of the implementation of -Wrepeated-use-of-weak.

Definition at line 870 of file ScopeInfo.h.

Referenced by clang::Sema::BuildInstanceMessage(), and clang::Sema::recordUseOfEvaluatedWeak().

void FunctionScopeInfo::recordUseOfWeak ( const ObjCMessageExpr Msg,
const ObjCPropertyDecl Prop 
)
void clang::sema::FunctionScopeInfo::setHasBranchIntoScope ( )
inline

Definition at line 336 of file ScopeInfo.h.

References HasBranchIntoScope.

void clang::sema::FunctionScopeInfo::setHasBranchProtectedScope ( )
inline

Definition at line 340 of file ScopeInfo.h.

References HasBranchProtectedScope.

Referenced by clang::Sema::ActOnBlockStmtExpr(), clang::Sema::ActOnOpenMPAtomicDirective(), clang::Sema::ActOnOpenMPCriticalDirective(), clang::Sema::ActOnOpenMPDeclareReductionCombinerStart(), clang::Sema::ActOnOpenMPDeclareReductionInitializerStart(), clang::Sema::ActOnOpenMPDistributeDirective(), clang::Sema::ActOnOpenMPDistributeParallelForDirective(), clang::Sema::ActOnOpenMPDistributeParallelForSimdDirective(), clang::Sema::ActOnOpenMPDistributeSimdDirective(), clang::Sema::ActOnOpenMPForDirective(), clang::Sema::ActOnOpenMPForSimdDirective(), clang::Sema::ActOnOpenMPMasterDirective(), clang::Sema::ActOnOpenMPOrderedDirective(), clang::Sema::ActOnOpenMPParallelDirective(), clang::Sema::ActOnOpenMPParallelForDirective(), clang::Sema::ActOnOpenMPParallelForSimdDirective(), clang::Sema::ActOnOpenMPParallelSectionsDirective(), clang::Sema::ActOnOpenMPSectionDirective(), clang::Sema::ActOnOpenMPSectionsDirective(), clang::Sema::ActOnOpenMPSimdDirective(), clang::Sema::ActOnOpenMPSingleDirective(), clang::Sema::ActOnOpenMPTargetDataDirective(), clang::Sema::ActOnOpenMPTargetDirective(), clang::Sema::ActOnOpenMPTargetParallelDirective(), clang::Sema::ActOnOpenMPTargetParallelForDirective(), clang::Sema::ActOnOpenMPTargetParallelForSimdDirective(), clang::Sema::ActOnOpenMPTaskDirective(), clang::Sema::ActOnOpenMPTaskgroupDirective(), clang::Sema::ActOnOpenMPTaskLoopDirective(), clang::Sema::ActOnOpenMPTaskLoopSimdDirective(), clang::Sema::ActOnOpenMPTeamsDirective(), setHasCXXTry(), and setHasSEHTry().

void clang::sema::FunctionScopeInfo::setHasCXXTry ( SourceLocation  TryLoc)
inline

Definition at line 360 of file ScopeInfo.h.

References FirstCXXTryLoc, and setHasBranchProtectedScope().

Referenced by clang::Sema::ActOnCXXTryBlock().

void clang::sema::FunctionScopeInfo::setHasDroppedStmt ( )
inline

Definition at line 348 of file ScopeInfo.h.

References HasDroppedStmt.

void clang::sema::FunctionScopeInfo::setHasFallthroughStmt ( )
inline

Definition at line 356 of file ScopeInfo.h.

References HasFallthroughStmt.

void clang::sema::FunctionScopeInfo::setHasIndirectGoto ( )
inline

Definition at line 344 of file ScopeInfo.h.

References HasIndirectGoto.

void clang::sema::FunctionScopeInfo::setHasOMPDeclareReductionCombiner ( )
inline
void clang::sema::FunctionScopeInfo::setHasSEHTry ( SourceLocation  TryLoc)
inline

Definition at line 365 of file ScopeInfo.h.

References FirstSEHTryLoc, and setHasBranchProtectedScope().

Referenced by clang::Sema::ActOnSEHTryBlock().

Member Data Documentation

SmallVector<CompoundScopeInfo, 4> clang::sema::FunctionScopeInfo::CompoundScopes

The stack of currently active compound stamement scopes in the function.

Definition at line 165 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnOpenMPDeclareReductionDirectiveStart(), clang::Sema::PopCompoundScope(), and clang::Sema::PushCompoundScope().

VarDecl* clang::sema::FunctionScopeInfo::CoroutinePromise

The promise object for this coroutine, if any.

Definition at line 156 of file ScopeInfo.h.

Referenced by buildPromiseCall(), clang::Sema::CheckCompletedCoroutineBody(), and Clear().

SmallVector<Stmt*, 4> clang::sema::FunctionScopeInfo::CoroutineStmts

The list of coroutine control flow constructs (co_await, co_yield, co_return) that occur within the function or block.

Empty if and only if this function or block is not (yet known to be) a coroutine.

Definition at line 161 of file ScopeInfo.h.

Referenced by clang::Sema::CheckCompletedCoroutineBody(), and Clear().

DiagnosticErrorTrap clang::sema::FunctionScopeInfo::ErrorTrap

Used to determine if errors occurred in this function or block.

Definition at line 144 of file ScopeInfo.h.

Referenced by Clear(), and clang::Sema::hasAnyUnrecoverableErrorsInThisFunction().

SourceLocation clang::sema::FunctionScopeInfo::FirstCXXTryLoc

First C++ 'try' statement in the current function.

Definition at line 138 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnSEHTryBlock(), Clear(), and setHasCXXTry().

SourceLocation clang::sema::FunctionScopeInfo::FirstReturnLoc

First 'return' statement in the current function.

Definition at line 135 of file ScopeInfo.h.

Referenced by clang::Sema::CheckCompletedCoroutineBody(), and Clear().

SourceLocation clang::sema::FunctionScopeInfo::FirstSEHTryLoc

First SEH '__try' statement in the current function.

Definition at line 141 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnCXXTryBlock(), Clear(), and setHasSEHTry().

bool clang::sema::FunctionScopeInfo::HasBranchIntoScope

Whether this function contains any switches or direct gotos.

Definition at line 100 of file ScopeInfo.h.

Referenced by Clear(), NeedsScopeChecking(), and setHasBranchIntoScope().

bool clang::sema::FunctionScopeInfo::HasBranchProtectedScope

Whether this function contains a VLA, @try, try, C++ initializer, or anything else that can't be jumped past.

Definition at line 97 of file ScopeInfo.h.

Referenced by Clear(), NeedsScopeChecking(), and setHasBranchProtectedScope().

bool clang::sema::FunctionScopeInfo::HasDroppedStmt

Whether a statement was dropped because it was invalid.

Definition at line 106 of file ScopeInfo.h.

Referenced by Clear(), NeedsScopeChecking(), and setHasDroppedStmt().

bool clang::sema::FunctionScopeInfo::HasFallthroughStmt

Whether there is a fallthrough statement in this function.

Definition at line 112 of file ScopeInfo.h.

Referenced by clang::sema::AnalysisBasedWarnings::IssueWarnings(), and setHasFallthroughStmt().

bool clang::sema::FunctionScopeInfo::HasIndirectGoto

Whether this function contains any indirect gotos.

Definition at line 103 of file ScopeInfo.h.

Referenced by Clear(), NeedsScopeChecking(), and setHasIndirectGoto().

bool clang::sema::FunctionScopeInfo::HasOMPDeclareReductionCombiner

True if current scope is for OpenMP declare reduction combiner.

Definition at line 109 of file ScopeInfo.h.

Referenced by Clear(), and setHasOMPDeclareReductionCombiner().

ScopeKind clang::sema::FunctionScopeInfo::Kind
llvm::SmallPtrSet<const ParmVarDecl*, 8> clang::sema::FunctionScopeInfo::ModifiedNonNullParams

A list of parameters which have the nonnull attribute and are modified in the function.

Definition at line 174 of file ScopeInfo.h.

Referenced by Clear().

bool clang::sema::FunctionScopeInfo::ObjCIsDesignatedInit

True when this is a method marked as a designated initializer.

Definition at line 120 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), clang::Sema::BuildInstanceMessage(), and Clear().

bool clang::sema::FunctionScopeInfo::ObjCIsSecondaryInit

True when this is an initializer method not marked as a designated initializer within a class that has at least one initializer marked as a designated initializer.

Definition at line 129 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), clang::Sema::BuildInstanceMessage(), and Clear().

bool clang::sema::FunctionScopeInfo::ObjCShouldCallSuper

A flag that is set when parsing a method that must call super's implementation, such as -dealloc, -finalize, or any method marked with attribute((objc_requires_super)).

Definition at line 117 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), clang::Sema::ActOnSuperMessage(), and Clear().

bool clang::sema::FunctionScopeInfo::ObjCWarnForNoDesignatedInitChain

This starts true for a method marked as designated initializer and will be set to false if there is an invocation to a designated initializer of the super class.

Definition at line 124 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), clang::Sema::BuildInstanceMessage(), and Clear().

bool clang::sema::FunctionScopeInfo::ObjCWarnForNoInitDelegation

This starts true for a secondary initializer method and will be set to false if there is an invocation of an initializer on 'self'.

Definition at line 132 of file ScopeInfo.h.

Referenced by clang::Sema::ActOnStartOfObjCMethodDef(), clang::Sema::BuildInstanceMessage(), and Clear().

SmallVector<PossiblyUnreachableDiag, 4> clang::sema::FunctionScopeInfo::PossiblyUnreachableDiags

A list of PartialDiagnostics created but delayed within the current function scope.

These diagnostics are vetted for reachability prior to being emitted.

Definition at line 170 of file ScopeInfo.h.

Referenced by Clear(), flushDiagnostics(), clang::sema::AnalysisBasedWarnings::IssueWarnings(), and clang::Sema::PopFunctionScopeInfo().

SmallVector<ReturnStmt*, 4> clang::sema::FunctionScopeInfo::Returns

The list of return statements that occur within the function or block, if there is any chance of applying the named return value optimization, or if we need to infer a return type.

Definition at line 153 of file ScopeInfo.h.

Referenced by Clear(), clang::Sema::computeNRVO(), and clang::Sema::deduceClosureReturnType().

SmallVector<SwitchStmt*, 8> clang::sema::FunctionScopeInfo::SwitchStack

SwitchStack - This is the current set of active switch statements in the block.

Definition at line 148 of file ScopeInfo.h.

Referenced by AddKeywordsToConsumer(), AddOrdinaryNameResults(), and Clear().


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