Go to the documentation of this file.
23 #include "llvm/ADT/STLExtras.h"
24 using namespace clang;
70 unsigned CurScopeIndex = FunctionScopes.size() - 1;
71 while (CurScopeIndex > 0 && isa<clang::sema::CapturedRegionScopeInfo>(
72 FunctionScopes[CurScopeIndex]))
75 isa<clang::sema::LambdaScopeInfo>(FunctionScopes[CurScopeIndex]) &&
76 "The function on the top of sema's function-info stack must be a lambda");
79 const bool IsCapturingThis = !VarToCapture;
80 const bool IsCapturingVariable = !IsCapturingThis;
84 cast<sema::LambdaScopeInfo>(FunctionScopes[CurScopeIndex])->CallOperator;
88 cast<sema::LambdaScopeInfo>(FunctionScopes[CurScopeIndex]);
96 if (IsCapturingVariable &&
98 return NoLambdaIsCaptureReady;
117 if (IsCapturingVariable && !LSI->
isCaptured(VarToCapture))
118 return NoLambdaIsCaptureReady;
120 return NoLambdaIsCaptureReady;
124 assert(CurScopeIndex);
130 assert(CurScopeIndex < (FunctionScopes.size() - 1));
134 return CurScopeIndex + 1;
135 return NoLambdaIsCaptureReady;
182 if (!OptionalStackIndex)
183 return NoLambdaIsCaptureCapable;
185 const unsigned IndexOfCaptureReadyLambda = OptionalStackIndex.getValue();
186 assert(((IndexOfCaptureReadyLambda != (FunctionScopes.size() - 1)) ||
188 "The capture ready lambda for a potential capture can only be the "
189 "current lambda if it is a generic lambda");
192 cast<sema::LambdaScopeInfo>(FunctionScopes[IndexOfCaptureReadyLambda]);
195 const bool IsCapturingThis = !VarToCapture;
196 const bool IsCapturingVariable = !IsCapturingThis;
198 if (IsCapturingVariable) {
203 const bool CanCaptureVariable =
209 DeclRefType, &IndexOfCaptureReadyLambda);
210 if (!CanCaptureVariable)
211 return NoLambdaIsCaptureCapable;
216 const bool CanCaptureThis =
220 &IndexOfCaptureReadyLambda);
222 return NoLambdaIsCaptureCapable;
224 return IndexOfCaptureReadyLambda;
243 unsigned LambdaDependencyKind,
252 Context, DC, Info, IntroducerRange.
getBegin(), LambdaDependencyKind,
253 IsGenericLambda, CaptureDefault);
263 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(DC))
273 std::tuple<MangleNumberingContext *, Decl *>
277 Decl *ManglingContextDecl = ExprEvalContexts.back().ManglingContextDecl;
291 if (ManglingContextDecl) {
292 if (
ParmVarDecl *Param = dyn_cast<ParmVarDecl>(ManglingContextDecl)) {
295 if (LexicalDC->isRecord())
296 Kind = DefaultArgument;
297 }
else if (
VarDecl *Var = dyn_cast<VarDecl>(ManglingContextDecl)) {
298 if (Var->getDeclContext()->isRecord())
299 Kind = StaticDataMember;
300 else if (Var->getMostRecentDecl()->isInline())
301 Kind = InlineVariable;
302 else if (Var->getDescribedVarTemplate())
303 Kind = VariableTemplate;
304 else if (
auto *VTS = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
305 if (!VTS->isExplicitSpecialization())
306 Kind = VariableTemplate;
308 }
else if (isa<FieldDecl>(ManglingContextDecl)) {
316 bool IsInNonspecializedTemplate =
317 inTemplateInstantiation() || CurContext->isDependentContext();
322 if ((IsInNonspecializedTemplate &&
323 !(ManglingContextDecl && isa<ParmVarDecl>(ManglingContextDecl))) ||
325 while (
auto *CD = dyn_cast<CapturedDecl>(DC))
330 return std::make_tuple(
nullptr,
nullptr);
333 case StaticDataMember:
335 if (!IsInNonspecializedTemplate)
336 return std::make_tuple(
nullptr, ManglingContextDecl);
342 case DefaultArgument:
346 case VariableTemplate:
348 return std::make_tuple(
350 ManglingContextDecl),
351 ManglingContextDecl);
354 llvm_unreachable(
"unexpected context");
363 Expr *TrailingRequiresClause) {
370 if (Class->isDependentContext() || TemplateParams) {
373 if (Result->isUndeducedType()) {
374 Result = SubstAutoTypeDependent(Result);
390 Context, Class, EndLoc,
393 MethodType, MethodTypeInfo,
SC_None, getCurFPFeatures().isFPConstrained(),
394 true, ConstexprKind, EndLoc, TrailingRequiresClause);
397 Class->addDecl(Method);
408 if (TemplateMethod) {
411 Class->addDecl(TemplateMethod);
416 if (!Params.empty()) {
418 CheckParmsForFunctionDef(Params,
422 P->setOwningFunction(Method);
430 Optional<std::tuple<bool, unsigned, unsigned, Decl *>> Mangling) {
432 bool HasKnownInternalLinkage;
433 unsigned ManglingNumber, DeviceManglingNumber;
434 Decl *ManglingContextDecl;
435 std::tie(HasKnownInternalLinkage, ManglingNumber, DeviceManglingNumber,
436 ManglingContextDecl) = Mangling.getValue();
437 Class->setLambdaMangling(ManglingNumber, ManglingContextDecl,
438 HasKnownInternalLinkage);
439 Class->setDeviceLambdaManglingNumber(DeviceManglingNumber);
443 auto getMangleNumberingContext =
447 if (ManglingContextDecl)
451 auto DC = Class->getDeclContext();
452 while (
auto *CD = dyn_cast<CapturedDecl>(DC))
453 DC = CD->getParent();
458 Decl *ManglingContextDecl;
459 std::tie(MCtx, ManglingContextDecl) =
460 getCurrentMangleNumberContext(Class->getDeclContext());
461 bool HasKnownInternalLinkage =
false;
462 if (!MCtx && (getLangOpts().
CUDA || getLangOpts().SYCLIsDevice ||
463 getLangOpts().SYCLIsHost)) {
471 MCtx = getMangleNumberingContext(Class, ManglingContextDecl);
472 assert(MCtx &&
"Retrieving mangle numbering context failed!");
473 HasKnownInternalLinkage =
true;
477 Class->setLambdaMangling(ManglingNumber, ManglingContextDecl,
478 HasKnownInternalLinkage);
489 bool ExplicitResultType,
493 LSI->
Lambda = LambdaClass;
503 if (ExplicitResultType) {
509 diag::err_lambda_incomplete_result)) {
527 assert(LSI &&
"Expected a lambda scope");
529 "Already acted on explicit template parameters");
531 "Explicit template parameters should come "
532 "before invented (auto) ones");
533 assert(!TParams.empty() &&
534 "No template parameters to act on");
545 for (
unsigned p = 0, NumParams = CallOperator->
getNumParams();
546 p < NumParams; ++p) {
554 for (
const auto &
Capture : Captures) {
558 Diag(
Capture.Loc, diag::note_var_explicitly_captured_here)
563 CheckShadow(CurScope, Param);
565 PushOnScopeChains(Param, CurScope);
585 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
586 return cast<EnumDecl>(D->getDeclContext());
594 if (BO->getOpcode() == BO_Comma)
601 if (
StmtExpr *SE = dyn_cast<StmtExpr>(E)) {
602 if (
Expr *last = dyn_cast_or_null<Expr>(SE->getSubStmt()->body_back()))
623 if (ICE->getCastKind() == CK_IntegralCast)
631 return ET->getDecl();
654 if (!ED)
return nullptr;
657 for (++i; i != e; ++i) {
673 i = returns.begin(), e = returns.end(); i != e; ++i) {
701 assert((!isa<LambdaScopeInfo>(CSI) || !getLangOpts().
CPlusPlus14) &&
702 "lambda expressions use auto deduction in C++14 onwards");
739 assert(!CSI.
ReturnType.
isNull() &&
"We should have a tentative return type.");
745 assert(isa<BlockScopeInfo>(CSI));
768 (RetE ? RetE->
getType() : Context.
VoidTy).getUnqualifiedType();
774 if (BlockNullability &&
775 (!RetTyNullability ||
784 diag::err_typecheck_missing_return_type_incompatible)
785 << ReturnType << CSI.
ReturnType << isa<LambdaScopeInfo>(CSI);
801 DeductType = BuildReferenceType(DeductType,
true, Loc,
Id);
802 assert(!DeductType.
isNull() &&
"can't build reference to auto");
806 if (Init->containsUnexpandedParameterPack()) {
808 ? diag::warn_cxx17_compat_init_capture_pack
809 : diag::ext_init_capture_pack);
828 ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init);
837 Loc, Init->getBeginLoc(), Init->getEndLoc())
849 if (Result.isInvalid())
852 Init = Result.getAs<
Expr>();
860 unsigned InitStyle,
Expr *Init) {
865 PETL.setEllipsisLoc(EllipsisLoc);
880 getCurLambda()->LocalPacks.push_back(NewVD);
885 assert(Var->
isInitCapture() &&
"init capture flag should be set");
895 assert(LSI &&
"LambdaScopeInfo should be on stack!");
903 assert(TemplateParamScope &&
904 "Lambda with explicit template param list should establish a "
905 "template param scope");
906 assert(TemplateParamScope->getParent());
907 if (TemplateParamScope->getParent()->getTemplateParamParent() !=
nullptr)
915 bool ExplicitParams =
true;
916 bool ExplicitResultType =
true;
917 bool ContainsUnexpandedParameterPack =
false;
928 LangAS AS = getDefaultCXXMethodAddrSpace();
938 QualType DefaultTypeForNoTrailingReturn =
944 ExplicitParams =
false;
945 ExplicitResultType =
false;
949 "lambda-declarator is a function");
961 MethodTyInfo = GetTypeForDeclarator(ParamInfo, CurScope);
962 assert(MethodTyInfo &&
"no type from lambda-declarator");
969 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i)
970 Params.push_back(cast<ParmVarDecl>(FTI.
Params[i].
Param));
975 DiagnoseUnexpandedParameterPack(Intro.
Range.
getBegin(), MethodTyInfo,
976 UPPC_DeclarationType);
980 Intro.
Range, MethodTyInfo, LambdaDependencyKind, Intro.
Default);
982 startLambdaDefinition(Class, Intro.
Range, MethodTyInfo, EndLoc, Params,
986 CheckCXXDefaultArguments(Method);
990 AddRangeBasedOptnone(Method);
993 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
997 ProcessDeclAttributes(CurScope, Method, ParamInfo);
1000 if (getLangOpts().
CUDA)
1001 CUDASetLambdaAttrs(Method);
1004 if (LangOpts.OpenMP)
1005 ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Method);
1008 handleLambdaNumbering(Class, Method);
1011 PushDeclContext(CurScope, Method);
1015 ExplicitParams, ExplicitResultType, !Method->
isConst());
1028 if (Intro.
Default !=
LCD_None && !Class->getParent()->isFunctionOrMethod() &&
1029 (getCurrentThisType().isNull() ||
1035 llvm::SmallSet<IdentifierInfo*, 8> CaptureNames;
1041 PrevCaptureLoc = C->Loc, ++C) {
1045 ? diag::ext_star_this_lambda_capture_cxx17
1046 : diag::warn_cxx14_compat_star_this_lambda_capture);
1052 Diag(C->Loc, diag::err_capture_more_than_once)
1055 SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
1066 ? diag::ext_equals_this_lambda_capture_cxx20
1067 : diag::warn_cxx17_compat_equals_this_lambda_capture);
1072 QualType ThisCaptureType = getCurrentThisType();
1073 if (ThisCaptureType.
isNull()) {
1074 Diag(C->Loc, diag::err_this_capture) <<
true;
1078 CheckCXXThisCapture(C->Loc,
true,
true,
1086 assert(C->Id &&
"missing identifier for capture");
1088 if (C->Init.isInvalid())
1092 if (C->Init.isUsable()) {
1094 ? diag::warn_cxx11_compat_init_capture
1095 : diag::ext_init_capture);
1102 if (C->InitCaptureType.get().isNull())
1105 if (C->Init.get()->containsUnexpandedParameterPack() &&
1107 DiagnoseUnexpandedParameterPack(C->Init.get(), UPPC_Initializer);
1110 switch (C->InitKind) {
1112 llvm_unreachable(
"not an init-capture?");
1123 Var = createLambdaInitCaptureVarDecl(C->Loc, C->InitCaptureType.get(),
1124 C->EllipsisLoc, C->Id, InitStyle,
1131 PushOnScopeChains(Var, CurScope,
false);
1134 "init capture has valid but null init?");
1142 Diag(C->Loc, diag::err_reference_capture_with_reference_default)
1144 SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
1147 Diag(C->Loc, diag::err_copy_capture_with_copy_default)
1149 SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
1158 LookupName(R, CurScope);
1165 if (DiagnoseEmptyLookup(CurScope, ScopeSpec, R, Validator))
1170 if (Var && DiagnoseUseOfDecl(Var, C->Loc))
1177 if (!CaptureNames.insert(C->Id).second) {
1179 Diag(C->Loc, diag::err_capture_more_than_once)
1182 SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
1186 Diag(C->Loc, diag::err_capture_more_than_once) << C->Id;
1195 Diag(C->Loc, diag::err_capture_does_not_name_variable) << C->Id;
1204 Diag(C->Loc, diag::err_capture_non_automatic_variable) << C->Id;
1212 if (C->EllipsisLoc.isValid()) {
1214 EllipsisLoc = C->EllipsisLoc;
1216 Diag(C->EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
1217 << (C->Init.isUsable() ? C->Init.get()->getSourceRange()
1223 ContainsUnexpandedParameterPack =
true;
1226 if (C->Init.isUsable()) {
1227 addInitCapture(LSI, Var);
1230 TryCapture_ExplicitByVal;
1231 tryCaptureVariable(Var, C->Loc,
Kind, EllipsisLoc);
1236 finishLambdaExplicitCaptures(LSI);
1241 addLambdaParameters(Intro.
Captures, Method, CurScope);
1245 PushExpressionEvaluationContext(
1247 ? ExpressionEvaluationContext::ImmediateFunctionContext
1248 : ExpressionEvaluationContext::PotentiallyEvaluated);
1252 bool IsInstantiation) {
1256 DiscardCleanupsInEvaluationContext();
1257 PopExpressionEvaluationContext();
1260 if (!IsInstantiation)
1265 Class->setInvalidDecl();
1267 ActOnFields(
nullptr, Class->getLocation(), Class, Fields,
SourceLocation(),
1269 CheckCompletedCXXClass(
nullptr, Class);
1271 PopFunctionScopeInfo();
1274 template <
typename Func>
1298 DefaultFree, DefaultMember, CallOpCC};
1300 llvm::iterator_range<CallingConv *> Range(
1301 std::begin(Convs), std::unique(std::begin(Convs), std::end(Convs)));
1311 if (CallOpCC == DefaultMember && DefaultMember != DefaultFree) {
1333 if (CallOpCC == DefaultMember && DefaultMember != DefaultFree)
1346 "Lambda's call operator should not have a reference qualifier");
1359 auto HasPassObjectSizeAttr = [](
const ParmVarDecl *
P) {
1360 return P->hasAttr<PassObjectSizeAttr>();
1362 if (llvm::any_of(CallOperator->
parameters(), HasPassObjectSizeAttr))
1432 for (
unsigned I = 0, N = CallOperator->
getNumParams(); I != N; ++I) {
1442 CallOpConvTL.setParam(I, From);
1443 CallOpConvNameTL.setParam(I, From);
1457 if (Class->isGenericLambda()) {
1464 Loc, ConversionName,
1470 Class->addDecl(ConversionTemplate);
1472 Class->addDecl(Conversion);
1494 for (
unsigned I = 0, N = CallOperator->
getNumParams(); I != N; ++I)
1495 InvokerParams[I]->setOwningFunction(Invoke);
1499 if (Class->isGenericLambda()) {
1503 S.
Context, Class, Loc, InvokerName,
1509 Class->addDecl(StaticInvokerTemplate);
1511 Class->addDecl(Invoke);
1565 Class->addDecl(Conversion);
1570 bool IsOpenMPMapping) {
1600 QualType ThisTy = getCurrentThisType();
1601 Expr *
This = BuildCXXThisExpr(Loc, ThisTy, ImplicitCaptureLoc.
isValid());
1603 Init = CreateBuiltinUnaryOp(Loc, UO_Deref,
This);
1610 Init = BuildDeclarationNameExpr(
1617 if (IsOpenMPMapping)
1620 if (Init.isInvalid())
1623 Expr *InitExpr = Init.get();
1629 return InitSeq.
Perform(*
this, Entity, InitKind, InitExpr);
1636 return BuildLambdaExpr(StartLoc, Body->
getEndLoc(), &LSI);
1650 llvm_unreachable(
"block capture in lambda");
1652 llvm_unreachable(
"Unknown implicit capture style");
1658 if (Init && Init->HasSideEffects(Context))
1666 ? getCurrentThisType()->getPointeeType()
1674 return !RD->isCompleteDefinition() || !RD->hasTrivialCopyConstructor() ||
1675 !RD->hasTrivialDestructor();
1682 if (CaptureHasSideEffects(From))
1688 auto diag =
Diag(From.
getLocation(), diag::warn_unused_lambda_capture);
1708 if (Var->isInitCapture())
1720 nullptr, FieldType, TSI,
nullptr,
1725 if (RequireCompleteSizedType(Loc, FieldType,
1726 diag::err_field_incomplete_or_sizeless)) {
1728 Field->setInvalidDecl();
1734 Field->setInvalidDecl();
1738 Field->setImplicit(
true);
1759 bool ExplicitParams;
1760 bool ExplicitResultType;
1762 bool ContainsUnexpandedParameterPack;
1763 bool IsGenericLambda;
1772 IsGenericLambda = Class->isGenericLambda();
1775 Decl *TemplateOrNonTemplateCallOperatorDecl =
1778 : cast<Decl>(CallOperator);
1784 PopExpressionEvaluationContext();
1787 bool CurHasPreviousCapture = CaptureDefault !=
LCD_None;
1789 CaptureDefaultLoc : IntroducerRange.
getBegin();
1791 for (
unsigned I = 0, N = LSI->
Captures.size(); I != N; ++I) {
1797 assert(!From.
isBlockCapture() &&
"Cannot capture __block variables");
1806 bool IsCaptureUsed =
true;
1807 if (!CurContext->isDependentContext() && !IsImplicit &&
1811 bool NonODRUsedInitCapture =
1813 if (!NonODRUsedInitCapture) {
1817 if (!CurHasPreviousCapture && !IsLast) {
1821 getLocForEndOfToken(CaptureRange.
getEnd()));
1824 FixItRange =
SourceRange(getLocForEndOfToken(PrevCaptureLoc),
1829 IsCaptureUsed = !DiagnoseUnusedLambdaCapture(FixItRange, From);
1834 CurHasPreviousCapture |= IsCaptureUsed;
1835 PrevCaptureLoc = CaptureRange.
getEnd();
1847 Diag(CaptureDefaultLoc, diag::note_deprecated_this_capture)
1849 getLocForEndOfToken(CaptureDefaultLoc),
", this");
1866 ExprResult Init = BuildCaptureInit(From, ImplicitCaptureLoc);
1873 BuildCaptureField(Class, From);
1875 CaptureInits.push_back(Init.get());
1878 CUDACheckLambdaCapture(CallOperator, From);
1881 Class->setCaptures(Context, Captures);
1888 if (Captures.empty() && CaptureDefault ==
LCD_None)
1898 if (getLangOpts().Blocks && getLangOpts().ObjC && !IsGenericLambda)
1903 ActOnFields(
nullptr, Class->getLocation(), Class, Fields,
SourceLocation(),
1905 CheckCompletedCXXClass(
nullptr, Class);
1908 Cleanup.mergeFrom(LambdaCleanup);
1911 CaptureDefault, CaptureDefaultLoc,
1912 ExplicitParams, ExplicitResultType,
1913 CaptureInits, EndLoc,
1914 ContainsUnexpandedParameterPack);
1920 !isa<CoroutineBodyStmt>(CallOperator->
getBody()) &&
1921 !Class->getDeclContext()->isDependentContext()) {
1923 CheckConstexprFunctionDefinition(CallOperator,
1924 CheckConstexprKind::CheckValid)
1930 DiagnoseShadowingLambdaDecls(LSI);
1932 if (!CurContext->isDependentContext()) {
1933 switch (ExprEvalContexts.back().Context) {
1937 case ExpressionEvaluationContext::Unevaluated:
1938 case ExpressionEvaluationContext::UnevaluatedList:
1939 case ExpressionEvaluationContext::UnevaluatedAbstract:
1949 case ExpressionEvaluationContext::ConstantEvaluated:
1950 case ExpressionEvaluationContext::ImmediateFunctionContext:
1954 ExprEvalContexts.back().Lambdas.push_back(Lambda);
1957 case ExpressionEvaluationContext::DiscardedStatement:
1958 case ExpressionEvaluationContext::PotentiallyEvaluated:
1959 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
1964 return MaybeBindToTemporary(Lambda);
1974 = cast<CXXMethodDecl>(
1982 CurrentLocation, Src);
1983 if (!Init.isInvalid())
1984 Init = ActOnFinishFullExpr(Init.get(),
false);
1986 if (Init.isInvalid())
1995 Block->setBlockMissingReturnType(
false);
1999 for (
unsigned I = 0, N = CallOperator->
getNumParams(); I != N; ++I) {
2007 Block->setParams(BlockParams);
2009 Block->setIsConversionFromLambda(
true);
2017 ConvLocation,
nullptr,
2030 ExprCleanupObjects.push_back(
Block);
2031 Cleanup.setExprNeedsCleanups(
true);
void setLexicalDeclContext(DeclContext *DC)
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, SourceLocation EndLoc)
Construct location information for a non-literal C++ operator.
void finishLambdaExplicitCaptures(sema::LambdaScopeInfo *LSI)
Note that we have finished the explicit captures for the given lambda.
Store information needed for an explicit specifier.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
bool isThisCapture() const
SourceRange ExplicitTemplateParamsRange
Source range covering the explicit template parameter list (if it exists).
bool SetTypeQual(TQ T, SourceLocation Loc)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
static void repeatForLambdaConversionFunctionCallingConvs(Sema &S, const FunctionProtoType &CallOpProto, Func F)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
bool isFPConstrained() const
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
QualType getType() const
Return the type wrapped by this type source info.
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...
Represents a complete lambda introducer.
QualType getReturnType() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclarationNameLoc - Additional source/type location info for a declaration name.
A trivial tuple used to represent a source range.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool ExplicitParams
Whether the (empty) parameter list is explicit.
Wrapper for source info for pointers.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Represents a C++ conversion function within a class.
void ActOnLambdaExplicitTemplateParameterList(SourceLocation LAngleLoc, ArrayRef< NamedDecl * > TParams, SourceLocation RAngleLoc, ExprResult RequiresClause)
This is called after parsing the explicit template parameter list on a lambda (if it exists) in C++2a...
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
ASTContext & getASTContext() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a 'mutable' qualifier.
bool isInitCapture() const
Determine whether this capture is an init-capture.
VarDecl * getVariable() const
bool Mutable
Whether this is a mutable lambda.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
Encodes a location in the source.
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
This represents a decl that may have a name.
SourceLocation getBegin() const
SmallVector< LambdaCapture, 4 > Captures
unsigned NumExplicitCaptures
The number of captures in the Captures list that are explicit captures.
DeclarationNameTable DeclarationNames
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
MutableArrayRef< Expr * > MultiExprArg
A (possibly-)qualified type.
const ParmVarDecl * getParamDecl(unsigned i) const
static InitializedEntity InitializeLambdaCapture(IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc)
Create the initialization entity for a lambda capture.
Represents a member of a struct/union/class.
RefQualifierKind RefQualifier
Represents the results of name lookup.
The collection of all-type qualifiers we support.
Represents a parameter to a function.
Exposes information about the current target.
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the TemplateParam...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
CXXRecordDecl * createLambdaClosureType(SourceRange IntroducerRange, TypeSourceInfo *Info, unsigned LambdaDependencyKind, LambdaCaptureDefault CaptureDefault)
Create a new lambda closure type.
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Represents a C++ nested-name-specifier or a global scope specifier.
void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, Scope *CurScope)
ActOnStartOfLambdaDefinition - This is called just before we start parsing the body of a lambda; it a...
FieldDecl * BuildCaptureField(RecordDecl *RD, const sema::Capture &Capture)
Build a FieldDecl suitable to hold the given capture.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Describes the sequence of initializations required to initialize a given object or reference with a s...
QualType getPackExpansionType(QualType Pattern, Optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
ExprResult RequiresClause
The requires-clause immediately following the explicit template parameter list, if any.
void finishedExplicitCaptures()
Note when all explicit captures have been added.
virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *)
Retrieve the mangling number of a new lambda expression with the given call operator within the devic...
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, sema::LambdaScopeInfo *LSI)
Complete a lambda-expression having processed and attached the lambda body.
The name of a declaration.
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
TranslationUnitDecl * getTranslationUnitDecl() const
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool isCopyCapture() const
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
bool isVariadic() const
Whether this function prototype is variadic.
CanQualType getCanonicalFunctionResultType(QualType ResultType) const
Adjust the given function result type.
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
The base class of the type hierarchy.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
void setRetValue(Expr *E)
ConditionalOperator - The ?: ternary operator.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
const LangOptions & getLangOpts() const
static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo)
Construct location information for a constructor, destructor or conversion operator.
CXXRecordDecl * Lambda
The class that describes the lambda.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Declaration of a template function.
bool isReferenceType() const
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void setConstexprKind(ConstexprSpecKind CSK)
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
static CallingConv getLambdaConversionFunctionCallConv(Sema &S, const FunctionProtoType *CallOpProto)
CompoundStmt - This represents a group of statements like { stmt stmt }.
Represents a pack expansion of types.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc, QualType Type)
Scope * getTemplateParamParent()
CXXMethodDecl * startLambdaDefinition(CXXRecordDecl *Class, SourceRange IntroducerRange, TypeSourceInfo *MethodType, SourceLocation EndLoc, ArrayRef< ParmVarDecl * > Params, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause)
Start the definition of a lambda expression.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
A builtin binary operation expression such as "x + y" or "x <= y".
void setAccess(AccessSpecifier AS)
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Scope - A scope is a transient data structure that is used while parsing the program.
const VariableArrayType * getCapturedVLAType() const
SourceLocation PotentialThisCaptureLocation
SourceLocation getEnd() const
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
Represents difference between two FPOptions values.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ActionResult< Expr * > ExprResult
QualType getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType, CallingConv CC)
Get the return type to use for a lambda's conversion function(s) to function pointer type,...
DeclSpec & getOrCreateMethodQualifiers()
bool isNonODRUsed() const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
const T * getAs() const
Member-template getAs<specific type>'.
bool isInvalidDecl() const
CallingConv getCallConv() const
void setInitCapture(bool IC)
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
static TemplateParameterList * getGenericLambdaTemplateParameterList(LambdaScopeInfo *LSI, Sema &SemaRef)
SourceLocation getEndLoc() const LLVM_READONLY
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
bool isTranslationUnit() const
FunctionType::ExtInfo ExtInfo
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Represents a variable declaration or definition.
ArrayRef< QualType > getParamTypes() const
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
LambdaCaptureDefault Default
Stores a list of template parameters for a TemplateDecl and its derived classes.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
@ RQ_None
No ref-qualifier was provided.
FPOptions & getCurFPFeatures()
ExtInfo withCallingConv(CallingConv cc) const
An instance of this object exists for each enum constant that is defined.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Optional< unsigned > getStackIndexOfNearestEnclosingCaptureCapableLambda(ArrayRef< const sema::FunctionScopeInfo * > FunctionScopes, VarDecl *VarToCapture, Sema &S)
Examines the FunctionScopeInfo stack to determine the nearest enclosing lambda (to the current lambda...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
void setImplicit(bool I=true)
ImplicitCaptureStyle ImpCaptureStyle
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
const Expr * getSubExpr() const
LangAS
Defines the address space values used by the address space qualifier of QualType.
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
const T * castAs() const
Member-template castAs<specific type>.
ConstexprSpecKind
Define the kind of constexpr specifier.
void addInitCapture(sema::LambdaScopeInfo *LSI, VarDecl *Var)
Add an init-capture to a lambda scope.
@ ListInit
Direct list-initialization (C++11)
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Represents a C++ struct/union/class.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
LambdaCaptureKind
The different capture forms in a lambda introducer.
SmallVector< Capture, 4 > Captures
Captures - The captures.
bool empty() const
Return true if no decls were found.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
CleanupInfo Cleanup
Whether any of the capture expressions requires cleanups.
@ LCK_ByRef
Capturing by reference.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
SmallVector< NamedDecl *, 4 > TemplateParams
Store the list of the template parameters for a generic lambda or an abbreviated function template.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void addDecl(Decl *D)
Add the declaration D into this context.
static bool isInInlineFunction(const DeclContext *DC)
Determine whether the given context is or is enclosed in an inline function.
Represents a prototype with parameter type info, e.g.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
bool isVLATypeCapture() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ExprResult BuildCaptureInit(const sema::Capture &Capture, SourceLocation ImplicitCaptureLoc, bool IsOpenMPMapping=false)
Initialize the given capture with a suitable expression.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Decl - This represents one declaration (or definition), e.g.
@ LCK_StarThis
Capturing the *this object by copy.
Sema - This implements semantic analysis and AST building for C.
static void addBlockPointerConversion(Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator)
Add a lambda's conversion to block pointer.
void setInitStyle(InitializationStyle Style)
bool hasWeakerNullability(NullabilityKind L, NullabilityKind R)
Return true if L has a weaker nullability annotation than R.
ConstexprSpecKind getConstexprSpecifier() const
bool isFileContext() const
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
bool isCaptured(VarDecl *Var) const
Determine whether the given variable has been captured.
const Expr * getInit() const
One of these records is kept for each identifier that is lexed.
bool DiagnoseUnusedLambdaCapture(SourceRange CaptureRange, const sema::Capture &From)
Diagnose if an explicit lambda capture is unused.
const TargetInfo & getTargetInfo() const
static EnumDecl * findEnumForBlockReturn(Expr *E)
If this expression is an enumerator-like expression of some type T, return the type T; otherwise,...
void addLambdaParameters(ArrayRef< LambdaIntroducer::LambdaCapture > Captures, CXXMethodDecl *CallOperator, Scope *CurScope)
Introduce the lambda parameters into scope.
Describes the kind of initialization being performed, along with location information for tokens rela...
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
ExceptionSpecificationType Type
The kind of exception specification this is.
@ LCK_VLAType
Capturing variable-length array type.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
ExceptionSpecInfo ExceptionSpec
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
static InitializationKind CreateDirectList(SourceLocation InitLoc)
InitializationStyle
Initialization styles.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool ContainsUnexpandedParameterPack
Whether the lambda contains an unexpanded parameter pack.
SourceLocation DefaultLoc
bool This(InterpState &S, CodePtr OpPC)
@ CInit
C-style initialization with assignment.
Extra information about a function prototype.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
VarDecl * createLambdaInitCaptureVarDecl(SourceLocation Loc, QualType InitCaptureType, SourceLocation EllipsisLoc, IdentifierInfo *Id, unsigned InitStyle, Expr *Init)
Create a dummy variable within the declcontext of the lambda's call operator, for name lookup purpose...
llvm::DenseMap< unsigned, SourceRange > ExplicitCaptureRanges
A map of explicit capture indices to their introducer source ranges.
Stmt - This represents one statement.
@ EST_BasicNoexcept
noexcept
void buildLambdaScope(sema::LambdaScopeInfo *LSI, CXXMethodDecl *CallOperator, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, bool Mutable)
Endow the lambda scope info with the relevant properties.
Information about one declarator, including the parsed type information and the identifier.
void handleLambdaNumbering(CXXRecordDecl *Class, CXXMethodDecl *Method, Optional< std::tuple< bool, unsigned, unsigned, Decl * >> Mangling=None)
Number lambda for linkage purposes if necessary.
@ CopyInit
[a = b], [a = {b}]
SourceLocation getBeginLoc() const
bool CaptureHasSideEffects(const sema::Capture &From)
Does copying/destroying the captured variable have side effects?
bool isValid() const
Return true if this is a valid SourceLocation object.
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-l...
Attr - This represents one attribute.
void addAddressSpace(LangAS space)
A container of type source information.
QualType getReturnType() const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool HasImplicitReturnType
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
static void addFunctionPointerConversions(Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator)
Add a lambda's conversion to function pointers, as described in C++11 [expr.prim.lambda]p6.
@ LCK_This
Capturing the *this object by reference.
Describes an entity that is being initialized.
bool isVariadic() const
Whether this function is variadic.
DeclClass * getAsSingle() const
TypeLoc getReturnLoc() const
static LambdaCaptureDefault mapImplicitCaptureStyle(CapturingScopeInfo::ImplicitCaptureStyle ICS)
void setNameLoc(SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool isBlockCapture() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
Capture & getCXXThisCapture()
Retrieve the capture of C++ 'this', if it has been captured.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
unsigned NumExplicitTemplateParams
The number of parameters in the template parameter list that were explicitly specified by the user,...
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
This represents one expression.
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
QualType buildLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions, IdentifierInfo *Id, bool DirectInit, Expr *&Init)
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
bool isVariableCapture() const
A class which contains all the information about a particular captured value.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
bool isFunctionOrMethod() const
ExtProtoInfo getExtProtoInfo() const
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, Scope *CurScope)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed.
static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange, CXXRecordDecl *Class, CXXMethodDecl *CallOperator, QualType InvokerFunctionTy)
Add a lambda's conversion to function pointer, as described in C++11 [expr.prim.lambda]p6.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ArrayRef< ParmVarDecl * > parameters() const
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
SourceLocation getLocation() const
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void setReferenced(bool R=true)
SourceLocation getEllipsisLoc() const
Retrieve the source location of the ellipsis, whose presence indicates that the capture is a pack exp...
static LambdaExpr * Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr * > CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
Construct a new lambda expression.
A reference to a declared variable, function, enum, etc.
Represents a function declaration or definition.
Represents a struct/union/class.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
StringRef getLambdaStaticInvokerName()
static void adjustBlockReturnsToEnum(Sema &S, ArrayRef< ReturnStmt * > returns, QualType returnType)
Adjust the given return statements so that they formally return the given type.
TypeSourceInfo * getTypeSourceInfo() const
@ ICIS_NoInit
No in-class initializer.
tok::TokenKind ContextKind
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
@ CallInit
Call-style initialization (C++98)
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a static or instance method of a struct/union/class.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
DeclContext * getDeclContext()
SourceLocation CaptureDefaultLoc
Source location of the '&' or '=' specifying the default capture type, if any.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.