Lines Matching defs:SemaRef
1677 static bool CheckLiteralType(Sema &SemaRef, Sema::CheckConstexprKind Kind,
1685 return SemaRef.RequireLiteralType(Loc, T, DiagID,
1689 return !T->isLiteralType(SemaRef.Context);
1696 static bool CheckConstexprDestructorSubobjects(Sema &SemaRef,
1699 assert(!SemaRef.getLangOpts().CPlusPlus23 &&
1708 SemaRef.Diag(DD->getLocation(), diag::err_constexpr_dtor_subobject)
1711 SemaRef.Diag(Loc, diag::note_constexpr_dtor_subobject)
1729 static bool CheckConstexprParameterTypes(Sema &SemaRef,
1732 assert(!SemaRef.getLangOpts().CPlusPlus23 &&
1742 if (CheckLiteralType(SemaRef, Kind, ParamLoc, *i,
1753 static bool CheckConstexprReturnType(Sema &SemaRef, const FunctionDecl *FD,
1755 assert(!SemaRef.getLangOpts().CPlusPlus23 &&
1757 if (CheckLiteralType(SemaRef, Kind, FD->getLocation(), FD->getReturnType(),
1781 static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl,
1784 static bool CheckConstexprMissingReturn(Sema &SemaRef, const FunctionDecl *Dcl);
1876 static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl,
1906 SemaRef.Diag(TL.getBeginLoc(), diag::err_constexpr_vla)
1920 SemaRef.Diag(DS->getBeginLoc(),
1921 SemaRef.getLangOpts().CPlusPlus14
1925 } else if (!SemaRef.getLangOpts().CPlusPlus14) {
1948 SemaRef.Diag(VD->getLocation(),
1949 SemaRef.getLangOpts().CPlusPlus23
1954 } else if (!SemaRef.getLangOpts().CPlusPlus23) {
1958 if (SemaRef.LangOpts.CPlusPlus23) {
1959 CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
1964 SemaRef, Kind, VD->getLocation(), VD->getType(),
1972 SemaRef.Diag(
1974 SemaRef.getLangOpts().CPlusPlus20
1978 } else if (!SemaRef.getLangOpts().CPlusPlus20) {
1985 SemaRef.Diag(VD->getLocation(),
1986 SemaRef.getLangOpts().CPlusPlus14
1990 } else if (!SemaRef.getLangOpts().CPlusPlus14) {
2006 SemaRef.Diag(DS->getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2029 static bool CheckConstexprCtorInitializer(Sema &SemaRef,
2037 SemaRef.getLangOpts().CPlusPlus20)
2058 SemaRef.Diag(Dcl->getLocation(),
2059 SemaRef.getLangOpts().CPlusPlus20
2064 SemaRef.Diag(Field->getLocation(),
2066 } else if (!SemaRef.getLangOpts().CPlusPlus20) {
2075 if (!CheckConstexprCtorInitializer(SemaRef, Dcl, I, Inits, Diagnosed,
2085 CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S,
2102 if (!CheckConstexprDeclStmt(SemaRef, Dcl, cast<DeclStmt>(S), Cxx1yLoc, Kind))
2122 SemaRef, Dcl, cast<AttributedStmt>(S)->getSubStmt(), ReturnStmts,
2132 if (!CheckConstexprFunctionStmt(SemaRef, Dcl, BodyIt, ReturnStmts,
2145 if (!CheckConstexprFunctionStmt(SemaRef, Dcl, If->getThen(), ReturnStmts,
2149 !CheckConstexprFunctionStmt(SemaRef, Dcl, If->getElse(), ReturnStmts,
2162 if (!SemaRef.getLangOpts().CPlusPlus14)
2168 !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
2184 !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
2196 !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
2210 !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
2220 SemaRef, Dcl, cast<CXXCatchStmt>(S)->getHandlerBlock(), ReturnStmts,
2236 SemaRef.Diag(S->getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2247 static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl,
2267 if (!SemaRef.getLangOpts().CPlusPlus20)
2272 SemaRef.Diag(Body->getBeginLoc(),
2273 !SemaRef.getLangOpts().CPlusPlus20
2289 !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
2297 if ((Cxx2bLoc.isValid() && !SemaRef.getLangOpts().CPlusPlus23) ||
2298 (Cxx2aLoc.isValid() && !SemaRef.getLangOpts().CPlusPlus20) ||
2299 (Cxx1yLoc.isValid() && !SemaRef.getLangOpts().CPlusPlus17))
2302 SemaRef.Diag(Cxx2bLoc,
2303 SemaRef.getLangOpts().CPlusPlus23
2308 SemaRef.Diag(Cxx2aLoc,
2309 SemaRef.getLangOpts().CPlusPlus20
2314 SemaRef.Diag(Cxx1yLoc,
2315 SemaRef.getLangOpts().CPlusPlus14
2334 SemaRef.Diag(
2336 SemaRef.getLangOpts().CPlusPlus20
2339 } else if (!SemaRef.getLangOpts().CPlusPlus20) {
2377 if (!CheckConstexprCtorInitializer(SemaRef, Dcl, I, Inits, Diagnosed,
2386 if (!CheckConstexprMissingReturn(SemaRef, Dcl))
2394 if (!SemaRef.getLangOpts().CPlusPlus14)
2401 SemaRef.Diag(
2403 SemaRef.getLangOpts().CPlusPlus14
2407 SemaRef.Diag(ReturnStmts[I],
2412 if (!SemaRef.getLangOpts().CPlusPlus14)
2436 !SemaRef.getLangOpts().CheckConstexprFunctionBodies ||
2437 SemaRef.getSourceManager().isInSystemHeader(Dcl->getLocation()) ||
2438 SemaRef.getDiagnostics().isIgnored(
2443 SemaRef.Diag(Dcl->getLocation(),
2448 SemaRef.Diag(Diags[I].first, Diags[I].second);
2456 static bool CheckConstexprMissingReturn(Sema &SemaRef,
2463 if (SemaRef.getLangOpts().CPlusPlus23 && !IsVoidOrDependentType)
2470 bool OK = SemaRef.getLangOpts().CPlusPlus14 && IsVoidOrDependentType;
2471 SemaRef.Diag(Dcl->getLocation(),
2506 Sema &SemaRef;
2513 ImmediateEscalatingExpressionsVisitor(Sema &SemaRef, FunctionDecl *FD)
2514 : SemaRef(SemaRef), ImmediateFn(FD),
2531 SemaRef.Diag(Loc, diag::note_immediate_function_reason)
3963 Sema &SemaRef, const CXXConstructorDecl *Constructor) {
3965 if (SemaRef.getDiagnostics().isIgnored(diag::warn_field_is_uninit,
3997 UninitializedFieldVisitor UninitializedChecker(SemaRef,
4126 static bool FindBaseInitializer(Sema &SemaRef,
4134 if (SemaRef.Context.hasSameUnqualifiedType(BaseType, Base.getType())) {
4151 if (SemaRef.IsDerivedFrom(ClassDecl->getLocation(),
4152 SemaRef.Context.getTypeDeclType(ClassDecl),
4760 static Expr *CastForMoving(Sema &SemaRef, Expr *E) {
4762 SemaRef.BuildReferenceType(E->getType(), /*SpelledAsLValue*/ false,
4765 TypeSourceInfo *TargetLoc = SemaRef.Context.getTrivialTypeSourceInfo(
4768 return SemaRef.BuildCXXNamedCast(ExprLoc, tok::kw_static_cast, TargetLoc, E,
4783 BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
4789 = InitializedEntity::InitializeBase(SemaRef.Context, BaseSpec,
4799 InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, std::nullopt);
4800 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, std::nullopt);
4811 DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(),
4816 SemaRef.MarkDeclRefReferenced(cast<DeclRefExpr>(CopyCtorArg));
4820 SemaRef.Context.getQualifiedType(BaseSpec->getType().getUnqualifiedType(),
4824 CopyCtorArg = CastForMoving(SemaRef, CopyCtorArg);
4829 CopyCtorArg = SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy,
4837 InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, CopyCtorArg);
4838 BaseInit = InitSeq.Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4843 BaseInit = SemaRef.MaybeCreateExprWithCleanups(BaseInit);
4848 new (SemaRef.Context) CXXCtorInitializer(SemaRef.Context,
4849 SemaRef.Context.getTrivialTypeSourceInfo(BaseSpec->getType(),
4866 BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
4881 if (Field->isZeroLengthBitField(SemaRef.Context))
4885 DeclRefExpr::Create(SemaRef.Context, NestedNameSpecifierLoc(),
4889 SemaRef.MarkDeclRefReferenced(cast<DeclRefExpr>(MemberExprBase));
4892 MemberExprBase = CastForMoving(SemaRef, MemberExprBase);
4897 LookupResult MemberLookup(SemaRef, Field->getDeclName(), Loc,
4903 = SemaRef.BuildMemberReferenceExpr(MemberExprBase,
4919 CtorArg = CastForMoving(SemaRef, CtorArg.get());
4933 InitializationSequence InitSeq(SemaRef, Entity, InitKind, CtorArgE);
4935 InitSeq.Perform(SemaRef, Entity, InitKind, MultiExprArg(&CtorArgE, 1));
4936 MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit);
4941 CXXMemberInit = new (SemaRef.Context) CXXCtorInitializer(
4942 SemaRef.Context, Indirect, Loc, Loc, MemberInit.getAs<Expr>(), Loc);
4944 CXXMemberInit = new (SemaRef.Context) CXXCtorInitializer(
4945 SemaRef.Context, Field, Loc, Loc, MemberInit.getAs<Expr>(), Loc);
4953 SemaRef.Context.getBaseElementType(Field->getType());
4964 InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, std::nullopt);
4966 InitSeq.Perform(SemaRef, InitEntity, InitKind, std::nullopt);
4968 MemberInit = SemaRef.MaybeCreateExprWithCleanups(MemberInit);
4973 CXXMemberInit = new (SemaRef.Context) CXXCtorInitializer(SemaRef.Context,
4979 CXXMemberInit = new (SemaRef.Context) CXXCtorInitializer(SemaRef.Context,
4988 SemaRef.Diag(Constructor->getLocation(),
4991 << SemaRef.Context.getTagDeclType(Constructor->getParent())
4993 SemaRef.Diag(Field->getLocation(), diag::note_declared_at);
4998 SemaRef.Diag(Constructor->getLocation(),
5001 << SemaRef.Context.getTagDeclType(Constructor->getParent())
5003 SemaRef.Diag(Field->getLocation(), diag::note_declared_at);
5012 = new (SemaRef.Context) CXXCtorInitializer(SemaRef.Context, Field,
5014 new (SemaRef.Context) ImplicitValueInitExpr(Field->getType()),
5130 static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info,
5158 SemaRef.BuildCXXDefaultInitExpr(Info.Ctor->getLocation(), Field);
5163 SemaRef.checkInitializerLifetime(Entity, DIE.get());
5167 Init = new (SemaRef.Context)
5168 CXXCtorInitializer(SemaRef.Context, Indirect, SourceLocation(),
5171 Init = new (SemaRef.Context)
5172 CXXCtorInitializer(SemaRef.Context, Field, SourceLocation(),
5178 if (isIncompleteOrZeroLengthArrayType(SemaRef.Context, Field->getType()))
5435 Sema &SemaRef, const CXXConstructorDecl *Constructor,
5445 if (!SemaRef.Diags.isIgnored(diag::warn_initializer_out_of_order,
5463 IdealInitKeys.push_back(GetKeyForBase(SemaRef.Context, VBase.getType()));
5469 IdealInitKeys.push_back(GetKeyForBase(SemaRef.Context, Base.getType()));
5491 const void *InitKey = GetKeyForMember(SemaRef.Context, Inits[InitIndex]);
5525 Sema::SemaDiagnosticBuilder D = SemaRef.Diag(
5541 SemaRef.getSourceManager(), SemaRef.getLangOpts()));
5556 auto D = SemaRef.Diag(PrevInit->getSourceLocation(),
16104 CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef,
16108 return SemaRef.Diag(FnDecl->getLocation(),
16115 return SemaRef.Diag(FnDecl->getLocation(),
16123 static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef,
16125 auto &Ctx = SemaRef.Context;
16133 CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
16141 if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
16145 ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
16148 ExpectedResultType = RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
16152 if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType) {
16155 return SemaRef.Diag(
16165 return SemaRef.Diag(FnDecl->getLocation(),
16171 return SemaRef.Diag(FnDecl->getLocation(),
16176 if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
16181 FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
16185 RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
16189 if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() !=
16194 return SemaRef.Diag(FnDecl->getLocation(), FirstParamType->isDependentType()
16204 CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl) {
16209 if (CheckOperatorNewDeleteDeclarationScope(SemaRef, FnDecl))
16213 SemaRef.Context.getCanonicalType(SemaRef.Context.getSizeType());
16218 if (CheckOperatorNewDeleteTypes(SemaRef, FnDecl, SemaRef.Context.VoidPtrTy,
16227 return SemaRef.Diag(FnDecl->getLocation(),
16235 CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl) {
16240 if (CheckOperatorNewDeleteDeclarationScope(SemaRef, FnDecl))
16251 ? SemaRef.Context.getCanonicalType(SemaRef.Context.getPointerType(
16252 SemaRef.Context.getRecordType(MD->getParent())))
16253 : SemaRef.Context.VoidPtrTy;
16258 SemaRef, FnDecl, SemaRef.Context.VoidTy, ExpectedFirstParamType,
16267 !SemaRef.isUsualDeallocationFunction(MD)) {
16268 SemaRef.Diag(MD->getLocation(),
16446 checkLiteralOperatorTemplateParameterList(Sema &SemaRef,
16457 SemaRef.Context.hasSameType(PmDecl->getType(), SemaRef.Context.CharTy))
16467 if (SemaRef.getLangOpts().CPlusPlus20 && PmDecl &&
16486 if (!SemaRef.inTemplateInstantiation())
16487 SemaRef.Diag(TpDecl->getLocation(),
16494 SemaRef.Diag(TpDecl->getTemplateParameters()->getSourceRange().getBegin(),