clang  6.0.0svn
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 "clang/Sema/ScopeInfo.h"

Inheritance diagram for clang::sema::FunctionScopeInfo:
Inheritance graph
[legend]
Collaboration diagram for clang::sema::FunctionScopeInfo:
Collaboration graph
[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::DenseMapInfoWeakObjectUseMap
 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
 
bool isCoroutine () const
 
void setFirstCoroutineStmt (SourceLocation Loc, StringRef Keyword)
 
StringRef getFirstCoroutineStmtKeyword () const
 
void setNeedsCoroutineSuspends (bool value=true)
 
bool hasInvalidCoroutineSuspends () const
 
void setCoroutineSuspends (Stmt *Initial, Stmt *Final)
 
 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: 1
 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 HasPotentialAvailabilityViolations: 1
 Whether we make reference to a declaration that could be unavailable. 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...
 
bool NeedsCoroutineSuspends: 1
 True only when this function has not already built, or attempted to build, the initial and final coroutine suspend points. More...
 
unsigned char FirstCoroutineStmtKind: 2
 An enumeration represeting the kind of the first coroutine statement in the function. More...
 
SourceLocation FirstCoroutineStmtLoc
 First coroutine statement in the current function. 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 = nullptr
 The promise object for this coroutine, if any. More...
 
std::pair< Stmt *, Stmt * > CoroutineSuspends
 The initial and final coroutine suspend points. 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 82 of file ScopeInfo.h.

Member Typedef Documentation

◆ WeakObjectUseMap

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

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

Definition at line 320 of file ScopeInfo.h.

◆ WeakUseVector

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 313 of file ScopeInfo.h.

Member Enumeration Documentation

◆ ScopeKind

Enumerator
SK_Function 
SK_Block 
SK_Lambda 
SK_CapturedRegion 

Definition at line 84 of file ScopeInfo.h.

Constructor & Destructor Documentation

◆ FunctionScopeInfo() [1/2]

clang::sema::FunctionScopeInfo::FunctionScopeInfo ( const FunctionScopeInfo )
protecteddefault

◆ FunctionScopeInfo() [2/2]

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

Definition at line 433 of file ScopeInfo.h.

◆ ~FunctionScopeInfo()

FunctionScopeInfo::~FunctionScopeInfo ( )
virtual

Definition at line 248 of file ScopeInfo.cpp.

Member Function Documentation

◆ Clear()

void FunctionScopeInfo::Clear ( )

◆ getFirstCoroutineStmtKeyword()

StringRef clang::sema::FunctionScopeInfo::getFirstCoroutineStmtKeyword ( ) const
inline

Definition at line 403 of file ScopeInfo.h.

References clang::SourceLocation::isValid().

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

◆ getWeakObjectUses()

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

Definition at line 347 of file ScopeInfo.h.

Referenced by diagnoseRepeatedUseOfWeak().

◆ hasInvalidCoroutineSuspends()

bool clang::sema::FunctionScopeInfo::hasInvalidCoroutineSuspends ( ) const
inline

Definition at line 421 of file ScopeInfo.h.

Referenced by clang::CoroutineStmtBuilder::buildParameterMoves().

◆ isCoroutine()

bool clang::sema::FunctionScopeInfo::isCoroutine ( ) const
inline

◆ markSafeWeakUse()

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 170 of file ScopeInfo.cpp.

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

Referenced by LookupMethodInReceiverType().

◆ NeedsScopeChecking()

bool clang::sema::FunctionScopeInfo::NeedsScopeChecking ( ) const
inline

Definition at line 385 of file ScopeInfo.h.

◆ recordUseOfWeak() [1/2]

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 958 of file ScopeInfo.h.

◆ recordUseOfWeak() [2/2]

void FunctionScopeInfo::recordUseOfWeak ( const ObjCMessageExpr Msg,
const ObjCPropertyDecl Prop 
)

◆ setCoroutineSuspends()

void clang::sema::FunctionScopeInfo::setCoroutineSuspends ( Stmt Initial,
Stmt Final 
)
inline

Definition at line 425 of file ScopeInfo.h.

◆ setFirstCoroutineStmt()

void clang::sema::FunctionScopeInfo::setFirstCoroutineStmt ( SourceLocation  Loc,
StringRef  Keyword 
)
inline

Definition at line 393 of file ScopeInfo.h.

References clang::SourceLocation::isInvalid().

◆ setHasBranchIntoScope()

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

Definition at line 351 of file ScopeInfo.h.

◆ setHasBranchProtectedScope()

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

Definition at line 355 of file ScopeInfo.h.

◆ setHasCXXTry()

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

Definition at line 375 of file ScopeInfo.h.

◆ setHasDroppedStmt()

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

Definition at line 363 of file ScopeInfo.h.

◆ setHasFallthroughStmt()

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

Definition at line 371 of file ScopeInfo.h.

◆ setHasIndirectGoto()

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

Definition at line 359 of file ScopeInfo.h.

◆ setHasOMPDeclareReductionCombiner()

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

Definition at line 367 of file ScopeInfo.h.

◆ setHasSEHTry()

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

Definition at line 380 of file ScopeInfo.h.

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

◆ setNeedsCoroutineSuspends()

void clang::sema::FunctionScopeInfo::setNeedsCoroutineSuspends ( bool  value = true)
inline

Definition at line 415 of file ScopeInfo.h.

Member Data Documentation

◆ CompoundScopes

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

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

Definition at line 180 of file ScopeInfo.h.

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

◆ CoroutinePromise

VarDecl* clang::sema::FunctionScopeInfo::CoroutinePromise = nullptr

The promise object for this coroutine, if any.

Definition at line 173 of file ScopeInfo.h.

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

◆ CoroutineSuspends

std::pair<Stmt *, Stmt *> clang::sema::FunctionScopeInfo::CoroutineSuspends

The initial and final coroutine suspend points.

Definition at line 176 of file ScopeInfo.h.

Referenced by clang::CoroutineStmtBuilder::buildParameterMoves(), and Clear().

◆ ErrorTrap

DiagnosticErrorTrap clang::sema::FunctionScopeInfo::ErrorTrap

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

Definition at line 161 of file ScopeInfo.h.

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

◆ FirstCoroutineStmtKind

unsigned char clang::sema::FunctionScopeInfo::FirstCoroutineStmtKind

An enumeration represeting the kind of the first coroutine statement in the function.

One of co_return, co_await, or co_yield.

Definition at line 145 of file ScopeInfo.h.

◆ FirstCoroutineStmtLoc

SourceLocation clang::sema::FunctionScopeInfo::FirstCoroutineStmtLoc

First coroutine statement in the current function.

(ex co_return, co_await, co_yield)

Definition at line 149 of file ScopeInfo.h.

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

◆ FirstCXXTryLoc

SourceLocation clang::sema::FunctionScopeInfo::FirstCXXTryLoc

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

Definition at line 155 of file ScopeInfo.h.

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

◆ FirstReturnLoc

SourceLocation clang::sema::FunctionScopeInfo::FirstReturnLoc

First 'return' statement in the current function.

Definition at line 152 of file ScopeInfo.h.

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

◆ FirstSEHTryLoc

SourceLocation clang::sema::FunctionScopeInfo::FirstSEHTryLoc

First SEH '__try' statement in the current function.

Definition at line 158 of file ScopeInfo.h.

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

◆ HasBranchIntoScope

bool clang::sema::FunctionScopeInfo::HasBranchIntoScope

Whether this function contains any switches or direct gotos.

Definition at line 101 of file ScopeInfo.h.

Referenced by Clear().

◆ HasBranchProtectedScope

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 98 of file ScopeInfo.h.

Referenced by Clear().

◆ HasDroppedStmt

bool clang::sema::FunctionScopeInfo::HasDroppedStmt

Whether a statement was dropped because it was invalid.

Definition at line 107 of file ScopeInfo.h.

Referenced by Clear().

◆ HasFallthroughStmt

bool clang::sema::FunctionScopeInfo::HasFallthroughStmt

Whether there is a fallthrough statement in this function.

Definition at line 113 of file ScopeInfo.h.

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

◆ HasIndirectGoto

bool clang::sema::FunctionScopeInfo::HasIndirectGoto

Whether this function contains any indirect gotos.

Definition at line 104 of file ScopeInfo.h.

Referenced by Clear().

◆ HasOMPDeclareReductionCombiner

bool clang::sema::FunctionScopeInfo::HasOMPDeclareReductionCombiner

True if current scope is for OpenMP declare reduction combiner.

Definition at line 110 of file ScopeInfo.h.

Referenced by Clear().

◆ HasPotentialAvailabilityViolations

bool clang::sema::FunctionScopeInfo::HasPotentialAvailabilityViolations

Whether we make reference to a declaration that could be unavailable.

Definition at line 117 of file ScopeInfo.h.

Referenced by Clear().

◆ Kind

ScopeKind clang::sema::FunctionScopeInfo::Kind

◆ ModifiedNonNullParams

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 189 of file ScopeInfo.h.

Referenced by Clear().

◆ NeedsCoroutineSuspends

bool clang::sema::FunctionScopeInfo::NeedsCoroutineSuspends

True only when this function has not already built, or attempted to build, the initial and final coroutine suspend points.

Definition at line 141 of file ScopeInfo.h.

Referenced by Clear().

◆ ObjCIsDesignatedInit

bool clang::sema::FunctionScopeInfo::ObjCIsDesignatedInit

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

Definition at line 125 of file ScopeInfo.h.

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

◆ ObjCIsSecondaryInit

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 134 of file ScopeInfo.h.

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

◆ ObjCShouldCallSuper

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 122 of file ScopeInfo.h.

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

◆ ObjCWarnForNoDesignatedInitChain

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 129 of file ScopeInfo.h.

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

◆ ObjCWarnForNoInitDelegation

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 137 of file ScopeInfo.h.

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

◆ PossiblyUnreachableDiags

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 185 of file ScopeInfo.h.

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

◆ Returns

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 170 of file ScopeInfo.h.

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

◆ SwitchStack

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

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

Definition at line 165 of file ScopeInfo.h.

Referenced by Clear().


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