|
clang
5.0.0
|
#include "clang/Sema/DeclSpec.h"#include "TypeLocBuilder.h"#include "clang/AST/ASTLambda.h"#include "clang/AST/ExprCXX.h"#include "clang/Basic/TargetInfo.h"#include "clang/Sema/Initialization.h"#include "clang/Sema/Lookup.h"#include "clang/Sema/Scope.h"#include "clang/Sema/ScopeInfo.h"#include "clang/Sema/SemaInternal.h"#include "clang/Sema/SemaLambda.h"Go to the source code of this file.
Functions | |
| static Optional< unsigned > | getStackIndexOfNearestEnclosingCaptureReadyLambda (ArrayRef< const clang::sema::FunctionScopeInfo * > FunctionScopes, VarDecl *VarToCapture) |
| Examines the FunctionScopeInfo stack to determine the nearest enclosing lambda (to the current lambda) that is 'capture-ready' for the variable referenced in the current lambda (i.e. More... | |
| static TemplateParameterList * | getGenericLambdaTemplateParameterList (LambdaScopeInfo *LSI, Sema &SemaRef) |
| static bool | isInInlineFunction (const DeclContext *DC) |
| Determine whether the given context is or is enclosed in an inline function. More... | |
| static EnumDecl * | findEnumForBlockReturn (Expr *E) |
| If this expression is an enumerator-like expression of some type T, return the type T; otherwise, return null. More... | |
| static EnumDecl * | findEnumForBlockReturn (ReturnStmt *ret) |
| Attempt to find a type T for which the returned expression of the given statement is an enumerator-like expression of that type. More... | |
| static EnumDecl * | findCommonEnumForBlockReturns (ArrayRef< ReturnStmt * > returns) |
| Attempt to find a common type T for which all of the returned expressions in a block are enumerator-like expressions of that type. More... | |
| static void | adjustBlockReturnsToEnum (Sema &S, ArrayRef< ReturnStmt * > returns, QualType returnType) |
| Adjust the given return statements so that they formally return the given type. More... | |
| static void | addFunctionPointerConversion (Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator) |
| Add a lambda's conversion to function pointer, as described in C++11 [expr.prim.lambda]p6. More... | |
| static void | addBlockPointerConversion (Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator) |
| Add a lambda's conversion to block pointer. More... | |
| static ExprResult | performLambdaVarCaptureInitialization (Sema &S, const LambdaScopeInfo::Capture &Capture, FieldDecl *Field) |
| static LambdaCaptureDefault | mapImplicitCaptureStyle (CapturingScopeInfo::ImplicitCaptureStyle ICS) |
|
static |
Add a lambda's conversion to block pointer.
Definition at line 1344 of file SemaLambda.cpp.
References clang::DeclContext::addDecl(), clang::AS_public, clang::Qualifiers::Const, clang::Sema::Context, clang::CXXConversionDecl::Create(), clang::ASTContext::DeclarationNames, clang::FunctionProtoType::ExtProtoInfo::ExtInfo, clang::Type::getAs(), clang::SourceRange::getBegin(), clang::ASTContext::getBlockPointerType(), clang::FunctionDecl::getBody(), clang::ASTContext::getCanonicalType(), clang::DeclarationNameTable::getCXXConversionFunctionName(), clang::ASTContext::getDefaultCallingConvention(), clang::FunctionProtoType::getExtProtoInfo(), clang::ASTContext::getFunctionType(), clang::Stmt::getLocEnd(), clang::FunctionProtoType::getParamTypes(), clang::FunctionType::getReturnType(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::ValueDecl::getType(), clang::FunctionProtoType::isVariadic(), Name, clang::DeclarationNameLoc::NamedType, clang::None, clang::Decl::setAccess(), clang::Decl::setImplicit(), clang::DeclarationNameLoc::NT::TInfo, and clang::FunctionProtoType::ExtProtoInfo::TypeQuals.
Referenced by clang::Sema::BuildLambdaExpr().
|
static |
Add a lambda's conversion to function pointer, as described in C++11 [expr.prim.lambda]p6.
Definition at line 1160 of file SemaLambda.cpp.
References clang::DeclContext::addDecl(), clang::AS_private, clang::AS_public, clang::Qualifiers::Const, clang::Sema::Context, clang::FunctionTemplateDecl::Create(), clang::ParmVarDecl::Create(), clang::CXXMethodDecl::Create(), clang::CXXConversionDecl::Create(), clang::ASTContext::DeclarationNames, clang::FunctionProtoType::ExtProtoInfo::ExtInfo, clang::IdentifierTable::get(), clang::TypeLoc::getAs(), clang::Type::getAs(), clang::SourceRange::getBegin(), clang::FunctionDecl::getBody(), clang::ASTContext::getCanonicalType(), clang::DeclarationNameTable::getCXXConversionFunctionName(), clang::ASTContext::getDefaultCallingConvention(), clang::FunctionDecl::getDescribedFunctionTemplate(), clang::FunctionProtoType::getExtProtoInfo(), clang::ASTContext::getFunctionType(), clang::NamedDecl::getIdentifier(), clang::getLambdaStaticInvokerName(), clang::Sema::getLangOpts(), clang::Decl::getLocation(), clang::Stmt::getLocEnd(), clang::DeclaratorDecl::getLocStart(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::FunctionProtoType::getParamTypes(), clang::ASTContext::getPointerType(), clang::FunctionTypeLoc::getReturnLoc(), clang::FunctionType::getReturnType(), clang::VarDecl::getStorageClass(), clang::TemplateDecl::getTemplateParameters(), clang::ASTContext::getTranslationUnitDecl(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::ValueDecl::getType(), clang::TypeSourceInfo::getTypeLoc(), clang::DeclaratorDecl::getTypeSourceInfo(), I, clang::ASTContext::Idents, clang::CXXRecordDecl::isGenericLambda(), clang::FunctionProtoType::isVariadic(), clang::DeclarationNameLoc::NamedType, clang::None, P, clang::FunctionDecl::parameters(), clang::FunctionProtoType::ExtProtoInfo::RefQualifier, clang::RQ_None, clang::SC_Static, clang::Decl::setAccess(), clang::FunctionDecl::setDescribedFunctionTemplate(), clang::Decl::setImplicit(), clang::FunctionDecl::setParams(), clang::DeclarationNameLoc::NT::TInfo, clang::FunctionProtoType::ExtProtoInfo::TypeQuals, and clang::FunctionType::ExtInfo::withCallingConv().
Referenced by clang::Sema::BuildLambdaExpr().
|
static |
Adjust the given return statements so that they formally return the given type.
It should require, at most, an IntegralCast.
Definition at line 597 of file SemaLambda.cpp.
References clang::Sema::Context, clang::ImplicitCastExpr::Create(), E, clang::ReturnStmt::getRetValue(), clang::Expr::getType(), clang::ASTContext::hasSameType(), clang::Type::isIntegralOrUnscopedEnumerationType(), clang::ReturnStmt::setRetValue(), and clang::VK_RValue.
Referenced by clang::Sema::deduceClosureReturnType().
|
static |
Attempt to find a common type T for which all of the returned expressions in a block are enumerator-like expressions of that type.
Definition at line 576 of file SemaLambda.cpp.
References findEnumForBlockReturn(), and clang::TagDecl::hasNameForLinkage().
Referenced by clang::Sema::deduceClosureReturnType().
If this expression is an enumerator-like expression of some type T, return the type T; otherwise, return null.
Pointer comparisons on the result here should always work because it's derived from either the parent of an EnumConstantDecl (i.e. the definition) or the declaration returned by EnumType::getDecl() (i.e. the definition).
Definition at line 504 of file SemaLambda.cpp.
References clang::Type::getAs(), clang::Expr::getType(), and clang::Expr::IgnoreParens().
Referenced by findCommonEnumForBlockReturns(), and findEnumForBlockReturn().
|
static |
Attempt to find a type T for which the returned expression of the given statement is an enumerator-like expression of that type.
Definition at line 567 of file SemaLambda.cpp.
References findEnumForBlockReturn(), and clang::ReturnStmt::getRetValue().
|
inlinestatic |
Definition at line 228 of file SemaLambda.cpp.
References clang::sema::LambdaScopeInfo::AutoTemplateParams, clang::Sema::Context, clang::TemplateParameterList::Create(), clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), clang::sema::LambdaScopeInfo::GLTemplateParameterList, and clang::sema::LambdaScopeInfo::IntroducerRange.
Referenced by clang::Sema::createLambdaClosureType(), and clang::Sema::startLambdaDefinition().
|
inlinestatic |
Examines the FunctionScopeInfo stack to determine the nearest enclosing lambda (to the current lambda) that is 'capture-ready' for the variable referenced in the current lambda (i.e.
VarToCapture). If successful, returns the index into Sema's FunctionScopeInfo stack of the capture-ready lambda's LambdaScopeInfo.
Climbs down the stack of lambdas (deepest nested lambda - i.e. current lambda - is on top) to determine the index of the nearest enclosing/outer lambda that is ready to capture the VarToCapture being referenced in the current lambda. As we climb down the stack, we want the index of the first such lambda - that is the lambda with the highest index that is 'capture-ready'.
A lambda 'L' is capture-ready for 'V' (var or this) if:
VarToCapture is 'null' then we are trying to capture 'this'.Note that a lambda that is deemed 'capture-ready' still needs to be checked for whether it is 'capture-capable' (see getStackIndexOfNearestEnclosingCaptureCapableLambda), before it can truly capture.
| FunctionScopes | - Sema's stack of nested FunctionScopeInfo's (which a LambdaScopeInfo inherits from). The current/deepest/innermost lambda is at the top of the stack and has the highest index. |
| VarToCapture | - the variable to capture. If NULL, capture 'this'. |
VarToCapture. Definition at line 63 of file SemaLambda.cpp.
References clang::DeclContext::Equals(), clang::Decl::getDeclContext(), clang::getLambdaAwareParentOfDeclContext(), clang::sema::CapturingScopeInfo::ImpCap_None, clang::sema::CapturingScopeInfo::ImpCaptureStyle, clang::sema::CapturingScopeInfo::isCaptured(), clang::sema::CapturingScopeInfo::isCXXThisCaptured(), clang::DeclContext::isDependentContext(), clang::isLambdaCallOperator(), and clang::DeclContext::isTranslationUnit().
Referenced by clang::getStackIndexOfNearestEnclosingCaptureCapableLambda().
|
static |
Determine whether the given context is or is enclosed in an inline function.
Definition at line 268 of file SemaLambda.cpp.
References clang::DeclContext::getLexicalParent(), and clang::DeclContext::isFileContext().
Referenced by clang::Sema::getCurrentMangleNumberContext().
|
static |
Definition at line 1428 of file SemaLambda.cpp.
References clang::sema::CapturingScopeInfo::ImpCap_Block, clang::sema::CapturingScopeInfo::ImpCap_CapturedRegion, clang::sema::CapturingScopeInfo::ImpCap_LambdaByref, clang::sema::CapturingScopeInfo::ImpCap_LambdaByval, clang::sema::CapturingScopeInfo::ImpCap_None, clang::LCD_ByCopy, clang::LCD_ByRef, and clang::LCD_None.
Referenced by clang::Sema::BuildLambdaExpr().
|
static |
Definition at line 1388 of file SemaLambda.cpp.
References clang::Sema::BuildDeclarationNameExpr(), clang::InitializationKind::CreateDirect(), clang::ExprError(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::ValueDecl::getType(), clang::InitializedEntity::InitializeLambdaCapture(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), and clang::InitializationSequence::Perform().
Referenced by clang::Sema::BuildLambdaExpr().
1.8.6