48#include "llvm/ADT/APInt.h"
49#include "llvm/ADT/STLExtras.h"
50#include "llvm/ADT/StringExtras.h"
51#include "llvm/Support/ErrorHandling.h"
52#include "llvm/Support/TypeSize.h"
62 if ([[maybe_unused]]
const auto *DNT = dyn_cast<DependentNameType>(
Type))
63 assert(DNT->getIdentifier() == &Name &&
"not a constructor name");
76 "not a constructor name");
98 auto *RD = dyn_cast<CXXRecordDecl>(ND);
99 if (RD && RD->isInjectedClassName()) {
100 InjectedClassName = RD;
104 if (!InjectedClassName) {
109 diag::err_incomplete_nested_name_spec) << CurClass << SS.
getRange();
115 InjectedClassName,
false);
122 bool EnteringContext) {
168 auto IsAcceptableResult = [&](
NamedDecl *
D) ->
bool {
169 auto *
Type = dyn_cast<TypeDecl>(
D->getUnderlyingDecl());
180 unsigned NumAcceptableResults = 0;
182 if (IsAcceptableResult(
D))
183 ++NumAcceptableResults;
188 if (
auto *RD = dyn_cast<CXXRecordDecl>(
D))
189 if (RD->isInjectedClassName())
190 D = cast<NamedDecl>(RD->getParent());
192 if (FoundDeclSet.insert(
D).second)
193 FoundDecls.push_back(
D);
201 if (
Found.isAmbiguous() && NumAcceptableResults == 1) {
202 Diag(NameLoc, diag::ext_dtor_name_ambiguous);
206 if (
auto *TD = dyn_cast<TypeDecl>(
D->getUnderlyingDecl()))
213 if (!IsAcceptableResult(
D))
219 if (
Found.isAmbiguous())
223 if (IsAcceptableResult(
Type)) {
235 bool IsDependent =
false;
237 auto LookupInObjectType = [&]() ->
ParsedType {
238 if (Failed || SearchType.
isNull())
248 return CheckLookupResult(
Found);
266 return CheckLookupResult(
Found);
275 return CheckLookupResult(
Found);
318 return TL.getPrefix();
329 PrefixSS.
Adopt(Prefix);
330 if (
ParsedType T = LookupInNestedNameSpec(PrefixSS))
362 unsigned NumNonExtensionDecls = FoundDecls.size();
386 Diag(SS.
getEndLoc(), diag::ext_qualified_dtor_named_in_lexical_scope)
388 Diag(FoundDecls.back()->getLocation(), diag::note_destructor_type_here)
399 FoundDecls.resize(NumNonExtensionDecls);
408 auto MakeFixItHint = [&]{
414 Destroyed = dyn_cast_or_null<CXXRecordDecl>(S->getEntity());
421 if (FoundDecls.empty()) {
423 Diag(NameLoc, diag::err_undeclared_destructor_name)
424 << &II << MakeFixItHint();
425 }
else if (!SearchType.
isNull() && FoundDecls.size() == 1) {
426 if (
auto *TD = dyn_cast<TypeDecl>(FoundDecls[0]->getUnderlyingDecl())) {
427 assert(!SearchType.
isNull() &&
428 "should only reject a type result if we have a search type");
429 Diag(NameLoc, diag::err_destructor_expr_type_mismatch)
432 << SearchType << MakeFixItHint();
434 Diag(NameLoc, diag::err_destructor_expr_nontype)
435 << &II << MakeFixItHint();
438 Diag(NameLoc, SearchType.
isNull() ? diag::err_destructor_name_nontype
439 : diag::err_destructor_expr_mismatch)
440 << &II << SearchType << MakeFixItHint();
444 if (
auto *TD = dyn_cast<TypeDecl>(FoundD->getUnderlyingDecl()))
445 Diag(FoundD->getLocation(), diag::note_destructor_type_here)
449 Diag(FoundD->getLocation(), diag::note_destructor_nontype_here)
467 "unexpected type in getDestructorType");
496 Name.getSourceRange(),
497 (StringRef(
"operator\"\"") + II->
getName()).str());
506 Diag(
Loc, diag::warn_deprecated_literal_operator_id) << II << Hint;
509 Diag(
Loc, diag::warn_reserved_extern_symbol)
510 << II << static_cast<int>(Status) << Hint;
519 Diag(Name.getBeginLoc(), diag::err_literal_operator_id_outside_namespace)
530 llvm_unreachable(
"unknown nested name specifier kind");
551 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid) <<
T);
564 bool WasEvaluated =
false;
584 if (RecordD->isPolymorphic() &&
E->
isGLValue()) {
619 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid)
626 ? diag::warn_side_effects_typeid
627 : diag::warn_side_effects_unevaluated_context);
640 return ExprError(
Diag(OpLoc, diag::err_openclcxx_not_supported)
646 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid));
660 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid));
664 return ExprError(
Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
688 if (
auto *CTE = dyn_cast<CXXTypeidExpr>(
Result.get()))
689 if (CTE->isPotentiallyEvaluated() && !CTE->isMostDerived(
Context))
690 Diag(OpLoc, diag::warn_no_typeid_with_rtti_disabled)
712 if (
const auto *Uuid = TD->getMostRecentDecl()->getAttr<UuidAttr>()) {
713 UuidAttrs.insert(Uuid);
718 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(TD)) {
721 const UuidAttr *UuidForTA =
nullptr;
728 UuidAttrs.insert(UuidForTA);
738 if (!Operand->getType()->isDependentType()) {
741 if (UuidAttrs.empty())
742 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
743 if (UuidAttrs.size() > 1)
744 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
745 Guid = UuidAttrs.back()->getGuidDecl();
762 if (UuidAttrs.empty())
763 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
764 if (UuidAttrs.size() > 1)
765 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
766 Guid = UuidAttrs.back()->getGuidDecl();
801 assert((Kind == tok::kw_true || Kind == tok::kw_false) &&
802 "Unknown C++ Boolean value!");
814 bool IsThrownVarInScope =
false;
827 if (
const auto *DRE = dyn_cast<DeclRefExpr>(Ex->
IgnoreParens()))
828 if (
const auto *Var = dyn_cast<VarDecl>(DRE->getDecl());
829 Var && Var->hasLocalStorage() &&
830 !Var->getType().isVolatileQualified()) {
831 for (; S; S = S->getParent()) {
832 if (S->isDeclScope(Var)) {
833 IsThrownVarInScope =
true;
850 bool IsThrownVarInScope) {
852 const bool IsOpenMPGPUTarget =
853 getLangOpts().OpenMPIsTargetDevice && (
T.isNVPTX() ||
T.isAMDGCN());
858 if (IsOpenMPGPUTarget)
859 targetDiag(OpLoc, diag::warn_throw_not_valid_on_target) <<
T.str();
867 Diag(OpLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"throw";
872 Diag(OpLoc, diag::err_acc_branch_in_out_compute_construct)
916 llvm::DenseMap<CXXRecordDecl *, unsigned> &SubobjectsSeen,
917 llvm::SmallPtrSetImpl<CXXRecordDecl *> &VBases,
918 llvm::SetVector<CXXRecordDecl *> &PublicSubobjectsSeen,
919 bool ParentIsPublic) {
921 CXXRecordDecl *BaseDecl = BS.getType()->getAsCXXRecordDecl();
926 NewSubobject = VBases.insert(BaseDecl).second;
931 ++SubobjectsSeen[BaseDecl];
934 bool PublicPath = ParentIsPublic && BS.getAccessSpecifier() ==
AS_public;
936 PublicSubobjectsSeen.insert(BaseDecl);
946 llvm::DenseMap<CXXRecordDecl *, unsigned> SubobjectsSeen;
948 llvm::SetVector<CXXRecordDecl *> PublicSubobjectsSeen;
949 SubobjectsSeen[RD] = 1;
950 PublicSubobjectsSeen.insert(RD);
954 for (
CXXRecordDecl *PublicSubobject : PublicSubobjectsSeen) {
956 if (SubobjectsSeen[PublicSubobject] > 1)
959 Objects.push_back(PublicSubobject);
968 bool isPointer =
false;
988 isPointer ? diag::err_throw_incomplete_ptr
989 : diag::err_throw_incomplete,
999 diag::err_throw_abstract_type,
E))
1021 PDiag(diag::err_access_dtor_exception) << Ty);
1037 for (
CXXRecordDecl *Subobject : UnambiguousPublicSubobjects) {
1078 if (ExnObjAlign < TypeAlign) {
1079 Diag(ThrowLoc, diag::warn_throw_underaligned_obj);
1080 Diag(ThrowLoc, diag::note_throw_underaligned_obj)
1085 if (!isPointer &&
getLangOpts().AssumeNothrowExceptionDtor) {
1087 auto Ty = Dtor->getType();
1091 Diag(ThrowLoc, diag::err_throw_object_throwing_dtor) << RD;
1143 for (
int I = FunctionScopes.size();
1144 I-- && isa<LambdaScopeInfo>(FunctionScopes[I]) &&
1146 cast<LambdaScopeInfo>(FunctionScopes[I])->CallOperator);
1148 CurLSI = cast<LambdaScopeInfo>(FunctionScopes[I]);
1155 if (
C.isCopyCapture()) {
1167 "While computing 'this' capture-type for a generic lambda, when we "
1168 "run out of enclosing LSI's, yet the enclosing DC is a "
1169 "lambda-call-operator we must be (i.e. Current LSI) in a generic "
1170 "lambda call oeprator");
1173 auto IsThisCaptured =
1178 if (
C.capturesThis()) {
1189 bool IsByCopyCapture =
false;
1190 bool IsConstCapture =
false;
1193 IsThisCaptured(Closure, IsByCopyCapture, IsConstCapture)) {
1194 if (IsByCopyCapture) {
1212 if (method && method->isImplicitObjectMemberFunction())
1213 ThisTy = method->getThisType().getNonReferenceType();
1241 : S(S), OldCXXThisTypeOverride(S.CXXThisTypeOverride), Enabled(
false)
1243 if (!Enabled || !ContextDecl)
1250 Record = cast<CXXRecordDecl>(ContextDecl);
1258 this->Enabled =
true;
1275 Sema.
Diag(DiagLoc, diag::note_lambda_this_capture_fixit)
1281 bool BuildAndDiagnose,
const unsigned *
const FunctionScopeIndexToStopAt,
1282 const bool ByCopy) {
1287 assert((!ByCopy ||
Explicit) &&
"cannot implicitly capture *this by value");
1289 const int MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
1290 ? *FunctionScopeIndexToStopAt
1316 unsigned NumCapturingClosures = 0;
1317 for (
int idx = MaxFunctionScopesIndex; idx >= 0; idx--) {
1320 if (CSI->CXXThisCaptureIndex != 0) {
1322 CSI->Captures[CSI->CXXThisCaptureIndex - 1].markUsed(BuildAndDiagnose);
1328 if (BuildAndDiagnose) {
1330 Diag(
Loc, diag::err_this_capture)
1331 << (
Explicit && idx == MaxFunctionScopesIndex);
1341 (
Explicit && idx == MaxFunctionScopesIndex)) {
1347 NumCapturingClosures++;
1351 if (BuildAndDiagnose) {
1353 Diag(
Loc, diag::err_this_capture)
1354 << (
Explicit && idx == MaxFunctionScopesIndex);
1362 if (!BuildAndDiagnose)
return false;
1375 "Only a lambda can capture the enclosing object (referred to by "
1378 for (
int idx = MaxFunctionScopesIndex; NumCapturingClosures;
1379 --idx, --NumCapturingClosures) {
1386 bool isNested = NumCapturingClosures > 1;
1420 const auto *
Method = dyn_cast<CXXMethodDecl>(DC);
1421 if (
Method &&
Method->isExplicitObjectMemberFunction()) {
1422 Diag(
Loc, diag::err_invalid_this_use) << 1;
1424 Diag(
Loc, diag::err_invalid_this_use) << 1;
1426 Diag(
Loc, diag::err_invalid_this_use) << 0;
1440 if (
This->isTypeDependent())
1445 auto IsDependent = [&]() {
1447 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
1451 if (LSI->Lambda && !LSI->Lambda->Encloses(
CurContext) &&
1452 LSI->AfterParameterList)
1459 if (LSI->isCXXThisCaptured()) {
1460 if (!LSI->getCXXThisCapture().isCopyCapture())
1463 const auto *MD = LSI->CallOperator;
1464 if (MD->getType().isNull())
1468 return Ty && MD->isExplicitObjectMemberFunction() &&
1475 This->setCapturedByCopyInLambdaWithExplicitObjectParameter(IsDependent);
1495 bool ListInitialization) {
1505 RParenOrBraceLoc, ListInitialization);
1508 RParenOrBraceLoc, exprs, Ty);
1517 bool ListInitialization) {
1526 ? ListInitialization
1528 TyBeginLoc, LParenOrBraceLoc, RParenOrBraceLoc)
1542 isa<DeducedTemplateSpecializationType>(Deduced)) {
1548 }
else if (Deduced && !Deduced->
isDeduced()) {
1550 if (ListInitialization) {
1551 auto *ILE = cast<InitListExpr>(Exprs[0]);
1552 Inits =
MultiExprArg(ILE->getInits(), ILE->getNumInits());
1556 return ExprError(
Diag(TyBeginLoc, diag::err_auto_expr_init_no_expression)
1557 << Ty << FullRange);
1558 if (Inits.size() > 1) {
1559 Expr *FirstBad = Inits[1];
1561 diag::err_auto_expr_init_multiple_expressions)
1562 << Ty << FullRange);
1566 Diag(TyBeginLoc, diag::warn_cxx20_compat_auto_expr) << FullRange;
1568 Expr *Deduce = Inits[0];
1569 if (isa<InitListExpr>(Deduce))
1572 << ListInitialization << Ty << FullRange);
1579 return ExprError(
Diag(TyBeginLoc, diag::err_auto_expr_deduction_failure)
1580 << Ty << Deduce->
getType() << FullRange
1594 RParenOrBraceLoc, ListInitialization);
1600 if (Exprs.size() == 1 && !ListInitialization &&
1601 !isa<InitListExpr>(Exprs[0])) {
1602 Expr *Arg = Exprs[0];
1610 if (!ListInitialization)
1611 return ExprError(
Diag(TyBeginLoc, diag::err_value_init_for_array_type)
1621 return ExprError(
Diag(TyBeginLoc, diag::err_init_for_function_type)
1622 << Ty << FullRange);
1631 if (ListInitialization &&
1632 cast<InitListExpr>(Exprs[0])->getNumInits() == 0) {
1636 Exprs[0]->getBeginLoc(), Exprs[0]->getEndLoc());
1639 diag::err_invalid_incomplete_type_use,
1653 Inner = BTE->getSubExpr();
1654 if (
auto *CE = dyn_cast<ConstantExpr>(Inner);
1655 CE && CE->isImmediateInvocation())
1656 Inner = CE->getSubExpr();
1657 if (!isa<CXXTemporaryObjectExpr>(Inner) &&
1658 !isa<CXXScalarValueInitExpr>(Inner)) {
1670 :
SourceRange(LParenOrBraceLoc, RParenOrBraceLoc);
1691 Method->getDeclContext()->lookup(
Method->getDeclName());
1692 for (
const auto *
D : R) {
1693 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
1703 bool Result =
Method->isUsualDeallocationFunction(PreventedBy);
1710 return llvm::none_of(PreventedBy, [&](
const FunctionDecl *FD) {
1712 "Only single-operand functions should be in PreventedBy");
1730 unsigned UsualParams = 1;
1731 if (S.
getLangOpts().SizedDeallocation && UsualParams < FD->getNumParams() &&
1737 if (S.
getLangOpts().AlignedAllocation && UsualParams < FD->getNumParams() &&
1747 struct UsualDeallocFnInfo {
1748 UsualDeallocFnInfo()
1749 :
Found(), FD(nullptr),
1755 IDP({AllocType, TypeAwareAllocationMode::No,
1756 AlignedAllocationMode::No, SizedDeallocationMode::No}),
1761 if (AllocType.isNull())
1763 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Found->getUnderlyingDecl());
1768 if (!InstantiatedDecl)
1770 FD = InstantiatedDecl;
1772 unsigned NumBaseParams = 1;
1773 if (FD->isTypeAwareOperatorNewOrDelete()) {
1779 if (AllocType.isNull()) {
1783 QualType TypeIdentityTag = FD->getParamDecl(0)->getType();
1786 if (ExpectedTypeIdentityTag.
isNull()) {
1794 IDP.PassTypeIdentity = TypeAwareAllocationMode::Yes;
1798 if (FD->isDestroyingOperatorDelete()) {
1803 if (NumBaseParams < FD->getNumParams() &&
1805 FD->getParamDecl(NumBaseParams)->getType(),
1808 IDP.PassSize = SizedDeallocationMode::Yes;
1811 if (NumBaseParams < FD->getNumParams() &&
1812 FD->getParamDecl(NumBaseParams)->getType()->isAlignValT()) {
1814 IDP.PassAlignment = AlignedAllocationMode::Yes;
1823 explicit operator bool()
const {
return FD; }
1833 if (Destroying !=
Other.Destroying)
1834 return Destroying ? 1 : -1;
1846 return IDP.PassAlignment == TargetIDP.
PassAlignment ? 1 : -1;
1848 if (IDP.PassSize != OtherIDP.
PassSize)
1849 return IDP.PassSize == TargetIDP.
PassSize ? 1 : -1;
1856 Other.FD->getPrimaryTemplate();
1857 if ((!PrimaryTemplate) != (!OtherPrimaryTemplate))
1858 return OtherPrimaryTemplate ? 1 : -1;
1860 if (PrimaryTemplate && OtherPrimaryTemplate) {
1861 const auto *DC = dyn_cast<CXXRecordDecl>(
Found->getDeclContext());
1862 const auto *OtherDC =
1863 dyn_cast<CXXRecordDecl>(
Other.Found->getDeclContext());
1864 unsigned ImplicitArgCount = Destroying + IDP.getNumImplicitArgs();
1871 return Best == PrimaryTemplate ? 1 : -1;
1877 if (CUDAPref >
Other.CUDAPref)
1879 if (CUDAPref ==
Other.CUDAPref)
1907 QualType SelectedTypeIdentityParameter =
1910 diag::err_incomplete_type))
1918 S.
Diag(StartLoc, diag::err_deleted_function_use)
1919 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
1936 UsualDeallocFnInfo Best;
1937 for (
auto I = R.
begin(),
E = R.
end(); I !=
E; ++I) {
1938 UsualDeallocFnInfo Info(S, I.getPair(), IDP.
Type,
Loc);
1949 BestFns->push_back(Info);
1952 int ComparisonResult = Best.Compare(S, Info, IDP);
1953 if (ComparisonResult > 0)
1958 if (BestFns && ComparisonResult < 0)
1963 BestFns->push_back(Info);
1976 const auto *record =
1978 if (!record)
return false;
1991 if (ops.
empty())
return false;
2001 allocType, PassType,
2013 std::optional<Expr *> ArraySize;
2015 if (
D.getNumTypeObjects() > 0 &&
2018 if (
D.getDeclSpec().hasAutoTypeSpec())
2029 D.DropFirstTypeObject();
2034 for (
unsigned I = 0, N =
D.getNumTypeObjects(); I < N; ++I) {
2039 if (
Expr *NumElts = Array.NumElts) {
2040 if (!NumElts->isTypeDependent() && !NumElts->isValueDependent()) {
2054 NumElts,
nullptr, diag::err_new_array_nonconst,
2067 if (
D.isInvalidType())
2072 DirectInitRange = List->getSourceRange();
2075 PlacementLParen, PlacementArgs, PlacementRParen,
2076 TypeIdParens, AllocType, TInfo, ArraySize, DirectInitRange,
2085 return IsCPlusPlus20 || PLE->getNumExprs() == 0;
2086 if (isa<ImplicitValueInitExpr>(
Init))
2089 return !CCE->isListInitialization() &&
2090 CCE->getConstructor()->isDefaultConstructor();
2092 assert(isa<InitListExpr>(
Init) &&
2093 "Shouldn't create list CXXConstructExprs for arrays.");
2118 StringRef OSName = AvailabilityAttr::getPlatformNameSourceSpelling(
2123 Diag(
Loc, diag::err_aligned_allocation_unavailable)
2125 << OSVersion.getAsString() << OSVersion.empty();
2126 Diag(
Loc, diag::note_silence_aligned_allocation_unavailable);
2136 std::optional<Expr *> ArraySize,
2142 if (DirectInitRange.
isValid()) {
2143 assert(
Initializer &&
"Have parens but no initializer.");
2145 }
else if (isa_and_nonnull<InitListExpr>(
Initializer))
2150 "Initializer expression that cannot have been implicitly created.");
2157 "paren init for non-call init");
2158 Exprs =
MultiExprArg(List->getExprs(), List->getNumExprs());
2159 }
else if (
auto *List = dyn_cast_or_null<CXXParenListInitExpr>(
Initializer)) {
2161 "paren init for non-call init");
2162 Exprs = List->getInitExprs();
2169 switch (InitStyle) {
2180 DirectInitRange.
getEnd());
2186 llvm_unreachable(
"Unknown initialization kind");
2191 if (Deduced && !Deduced->isDeduced() &&
2192 isa<DeducedTemplateSpecializationType>(Deduced)) {
2195 Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.
getBegin(),
2196 diag::err_deduced_class_template_compound_type)
2198 << (*ArraySize ? (*ArraySize)->getSourceRange() : TypeRange));
2203 AllocTypeInfo, Entity, Kind, Exprs);
2206 }
else if (Deduced && !Deduced->isDeduced()) {
2210 auto *ILE = cast<InitListExpr>(Exprs[0]);
2211 Inits =
MultiExprArg(ILE->getInits(), ILE->getNumInits());
2215 return ExprError(
Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
2216 << AllocType << TypeRange);
2217 if (Inits.size() > 1) {
2218 Expr *FirstBad = Inits[1];
2220 diag::err_auto_new_ctor_multiple_expressions)
2221 << AllocType << TypeRange);
2225 << AllocType << TypeRange;
2226 Expr *Deduce = Inits[0];
2227 if (isa<InitListExpr>(Deduce))
2230 << Braced << AllocType << TypeRange);
2237 return ExprError(
Diag(StartLoc, diag::err_auto_new_deduction_failure)
2238 << AllocType << Deduce->
getType() << TypeRange
2256 AllocType = Array->getElementType();
2276 if (ArraySize && *ArraySize &&
2277 (*ArraySize)->getType()->isNonOverloadPlaceholderType()) {
2280 ArraySize = result.
get();
2289 std::optional<uint64_t> KnownArraySize;
2290 if (ArraySize && *ArraySize && !(*ArraySize)->isTypeDependent()) {
2298 if (!ConvertedSize.
isInvalid() && (*ArraySize)->getType()->isRecordType())
2300 Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
2301 << (*ArraySize)->getType() << 0 <<
"'size_t'";
2308 SizeConvertDiagnoser(
Expr *ArraySize)
2310 ArraySize(ArraySize) {}
2314 return S.
Diag(
Loc, diag::err_array_size_not_integral)
2320 return S.
Diag(
Loc, diag::err_array_size_incomplete_type)
2326 return S.
Diag(
Loc, diag::err_array_size_explicit_conversion) <<
T << ConvTy;
2337 return S.
Diag(
Loc, diag::err_array_size_ambiguous_conversion) <<
T;
2351 ? diag::warn_cxx98_compat_array_size_conversion
2352 : diag::ext_array_size_conversion)
2355 } SizeDiagnoser(*ArraySize);
2363 ArraySize = ConvertedSize.
get();
2364 QualType SizeType = (*ArraySize)->getType();
2382 if (std::optional<llvm::APSInt>
Value =
2383 (*ArraySize)->getIntegerConstantExpr(
Context)) {
2384 if (
Value->isSigned() &&
Value->isNegative()) {
2386 diag::err_typecheck_negative_array_size)
2387 << (*ArraySize)->getSourceRange());
2391 unsigned ActiveSizeBits =
2395 Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large)
2399 KnownArraySize =
Value->getZExtValue();
2400 }
else if (TypeIdParens.
isValid()) {
2402 Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst)
2403 << (*ArraySize)->getSourceRange()
2416 unsigned Alignment =
2422 Alignment > NewAlignment)};
2431 AllocationParameterRange =
SourceRange(PlacementLParen, PlacementRParen);
2435 AllocType, ArraySize.has_value(), IAP,
2436 PlacementArgs, OperatorNew, OperatorDelete))
2441 bool UsualArrayDeleteWantsSize =
false;
2457 unsigned NumImplicitArgs = 1;
2459 assert(OperatorNew->isTypeAwareOperatorNewOrDelete());
2465 Proto, NumImplicitArgs, PlacementArgs,
2466 AllPlaceArgs, CallType))
2469 if (!AllPlaceArgs.empty())
2470 PlacementArgs = AllPlaceArgs;
2480 llvm::APInt SingleEltSize(
2484 std::optional<llvm::APInt> AllocationSize;
2487 AllocationSize = SingleEltSize;
2491 AllocationSize = llvm::APInt(SizeTyWidth, *KnownArraySize)
2492 .umul_ov(SingleEltSize, Overflow);
2496 "Expected that all the overflows would have been handled already.");
2500 Context, AllocationSize.value_or(llvm::APInt::getZero(SizeTyWidth)),
2519 CK_IntegralCast, &AlignmentLiteral,
2524 CallArgs.reserve(NumImplicitArgs + PlacementArgs.size());
2525 CallArgs.emplace_back(AllocationSize
2526 ?
static_cast<Expr *
>(&AllocationSizeLiteral)
2527 : &OpaqueAllocationSize);
2529 CallArgs.emplace_back(&DesiredAlignment);
2530 llvm::append_range(CallArgs, PlacementArgs);
2534 checkCall(OperatorNew, Proto,
nullptr, CallArgs,
2535 false, StartLoc,
Range, CallType);
2540 (OperatorNew->isImplicit() ||
2541 (OperatorNew->getBeginLoc().isValid() &&
2543 if (Alignment > NewAlignment)
2544 Diag(StartLoc, diag::warn_overaligned_type)
2556 SourceRange InitRange(Exprs.front()->getBeginLoc(),
2557 Exprs.back()->getEndLoc());
2558 Diag(StartLoc, diag::err_new_array_init_args) << InitRange;
2578 InitType = AllocType;
2591 dyn_cast_or_null<CXXBindTemporaryExpr>(FullInit.
get()))
2592 FullInit = Binder->getSubExpr();
2599 if (ArraySize && !*ArraySize) {
2607 Diag(TypeRange.
getEnd(), diag::err_new_array_size_unknown_from_init)
2619 if (OperatorDelete) {
2626 IAP, UsualArrayDeleteWantsSize, PlacementArgs,
2628 ResultType, AllocTypeInfo,
Range, DirectInitRange);
2636 return Diag(
Loc, diag::err_bad_new_type)
2637 << AllocType << 0 << R;
2639 return Diag(
Loc, diag::err_bad_new_type)
2640 << AllocType << 1 << R;
2643 Loc, AllocType, diag::err_new_incomplete_or_sizeless_type, R))
2646 diag::err_allocation_of_abstract_type))
2649 return Diag(
Loc, diag::err_variably_modified_new_type)
2653 return Diag(
Loc, diag::err_address_space_qualified_new)
2661 return Diag(
Loc, diag::err_arc_new_array_without_ownership)
2675 unsigned NonTypeArgumentOffset = 0;
2676 if (Mode == ResolveMode::Typed) {
2677 ++NonTypeArgumentOffset;
2683 Alloc != AllocEnd; ++Alloc) {
2686 NamedDecl *
D = (*Alloc)->getUnderlyingDecl();
2688 if (IsTypeAware == (Mode != ResolveMode::Typed))
2725 AlignArg = Args[NonTypeArgumentOffset + 1];
2726 Args.erase(Args.begin() + NonTypeArgumentOffset + 1);
2728 PassAlignment, Operator,
2745 PassAlignment, Operator,
2749 if (Mode == ResolveMode::Typed) {
2760 (Args[1]->getType()->isObjectPointerType() ||
2761 Args[1]->getType()->isArrayType())) {
2762 const QualType Arg1Type = Args[1]->getType();
2767 S.
Diag(Args[1]->getExprLoc(),
2768 diag::err_placement_new_into_const_qualified_storage)
2769 << Arg1Type << Args[1]->getSourceRange();
2772 S.
Diag(R.
getNameLoc(), diag::err_need_header_before_placement_new)
2787 if (AlignedCandidates) {
2789 auto AlignArgOffset = NonTypeArgumentOffset + 1;
2790 return C.Function->getNumParams() > AlignArgOffset &&
2791 C.Function->getParamDecl(AlignArgOffset)
2797 AlignedArgs.reserve(Args.size() + NonTypeArgumentOffset + 1);
2798 for (
unsigned Idx = 0; Idx < NonTypeArgumentOffset + 1; ++Idx)
2799 AlignedArgs.push_back(Args[Idx]);
2800 AlignedArgs.push_back(AlignArg);
2801 AlignedArgs.append(Args.begin() + NonTypeArgumentOffset + 1,
2815 if (AlignedCandidates)
2816 AlignedCandidates->
NoteCandidates(S, AlignedArgs, AlignedCands,
"",
2826 S.
PDiag(diag::err_ovl_ambiguous_call)
2835 Candidates, Best->Function, Args);
2839 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
2849 if (Mode != DeallocLookupMode::OptionallyTyped) {
2851 bool RemoveTypedDecl = Mode == DeallocLookupMode::Untyped;
2853 while (Filter.hasNext()) {
2854 FunctionDecl *FD = Filter.next()->getUnderlyingDecl()->getAsFunction();
2874 UntypedParameters.reserve(Args.size() - 1);
2875 UntypedParameters.push_back(Args[1]);
2880 UntypedParameters.push_back(Args[2]);
2881 UntypedParameters.append(Args.begin() + 3, Args.end());
2887 AlignedCandidates, AlignArg,
Diagnose))
2897 Args = std::move(UntypedParameters);
2902 AlignedCandidates, AlignArg,
Diagnose);
2933 IsArray ? OO_Array_New : OO_New);
2948 if (!SpecializedTypeIdentity.
isNull()) {
2949 TypeIdentity = SpecializedTypeIdentity;
2951 diag::err_incomplete_type))
2960 AllocArgs.push_back(&TypeIdentityParam);
2966 AllocArgs.push_back(&Size);
2971 if (IncludeAlignParam) {
2976 if (IncludeAlignParam)
2977 AllocArgs.push_back(&Align);
2979 llvm::append_range(AllocArgs, PlaceArgs);
3010 if (PlaceArgs.empty()) {
3011 Diag(StartLoc, diag::err_openclcxx_not_supported) <<
"default new";
3013 Diag(StartLoc, diag::err_openclcxx_placement_new);
3018 assert(!R.
empty() &&
"implicitly declared allocation functions not found");
3019 assert(!R.
isAmbiguous() &&
"global allocation functions are ambiguous");
3032 OperatorDelete =
nullptr;
3039 OperatorNew->getDeclName().getCXXOverloadedOperator() == OO_Array_New
3067 while (Filter.hasNext()) {
3068 auto *FD = dyn_cast<FunctionDecl>(Filter.next()->getUnderlyingDecl());
3069 if (FD && FD->isDestroyingOperatorDelete())
3075 auto GetRedeclContext = [](
Decl *
D) {
3079 DeclContext *OperatorNewContext = GetRedeclContext(OperatorNew);
3081 bool FoundGlobalDelete = FoundDelete.
empty();
3082 bool IsClassScopedTypeAwareNew =
3085 auto DiagnoseMissingTypeAwareCleanupOperator = [&](
bool IsPlacementOperator) {
3088 Diag(StartLoc, diag::err_mismatching_type_aware_cleanup_deallocator)
3089 << OperatorNew->getDeclName() << IsPlacementOperator << DeleteName;
3090 Diag(OperatorNew->getLocation(), diag::note_type_aware_operator_declared)
3091 << OperatorNew->isTypeAwareOperatorNewOrDelete()
3092 << OperatorNew->getDeclName() << OperatorNewContext;
3095 if (IsClassScopedTypeAwareNew && FoundDelete.
empty()) {
3096 DiagnoseMissingTypeAwareCleanupOperator(
false);
3099 if (FoundDelete.
empty()) {
3107 ? DeallocLookupMode::OptionallyTyped
3108 : DeallocLookupMode::Untyped;
3131 unsigned NonPlacementNewArgCount = 1;
3133 NonPlacementNewArgCount =
3135 bool isPlacementNew = !PlaceArgs.empty() ||
3136 OperatorNew->param_size() != NonPlacementNewArgCount ||
3137 OperatorNew->isVariadic();
3139 if (isPlacementNew) {
3155 int InitialParamOffset = 0;
3157 ArgTypes.push_back(TypeIdentity);
3158 InitialParamOffset = 1;
3161 for (
unsigned I = ArgTypes.size() - InitialParamOffset,
3162 N = Proto->getNumParams();
3164 ArgTypes.push_back(Proto->getParamType(I));
3168 EPI.
Variadic = Proto->isVariadic();
3170 ExpectedFunctionType
3175 DEnd = FoundDelete.
end();
3179 dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) {
3187 Fn = cast<FunctionDecl>((*D)->getUnderlyingDecl());
3190 ExpectedFunctionType,
3192 ExpectedFunctionType))
3193 Matches.push_back(std::make_pair(
D.getPair(), Fn));
3200 DiagnoseMissingTypeAwareCleanupOperator(isPlacementNew);
3213 AllocElemType, OriginalTypeAwareState,
3218 *
this, FoundDelete, IDP, StartLoc, &BestDeallocFns);
3219 if (Selected && BestDeallocFns.empty())
3220 Matches.push_back(std::make_pair(Selected.Found, Selected.FD));
3224 for (
auto Fn : BestDeallocFns)
3225 Matches.push_back(std::make_pair(Fn.Found, Fn.FD));
3233 if (Matches.size() == 1) {
3234 OperatorDelete = Matches[0].second;
3235 DeclContext *OperatorDeleteContext = GetRedeclContext(OperatorDelete);
3236 bool FoundTypeAwareOperator =
3237 OperatorDelete->isTypeAwareOperatorNewOrDelete() ||
3238 OperatorNew->isTypeAwareOperatorNewOrDelete();
3239 if (
Diagnose && FoundTypeAwareOperator) {
3240 bool MismatchedTypeAwareness =
3241 OperatorDelete->isTypeAwareOperatorNewOrDelete() !=
3242 OperatorNew->isTypeAwareOperatorNewOrDelete();
3243 bool MismatchedContext = OperatorDeleteContext != OperatorNewContext;
3244 if (MismatchedTypeAwareness || MismatchedContext) {
3245 FunctionDecl *Operators[] = {OperatorDelete, OperatorNew};
3246 bool TypeAwareOperatorIndex =
3247 OperatorNew->isTypeAwareOperatorNewOrDelete();
3248 Diag(StartLoc, diag::err_mismatching_type_aware_cleanup_deallocator)
3249 << Operators[TypeAwareOperatorIndex]->
getDeclName()
3251 << Operators[!TypeAwareOperatorIndex]->
getDeclName()
3252 << GetRedeclContext(Operators[TypeAwareOperatorIndex]);
3253 Diag(OperatorNew->getLocation(),
3254 diag::note_type_aware_operator_declared)
3255 << OperatorNew->isTypeAwareOperatorNewOrDelete()
3256 << OperatorNew->getDeclName() << OperatorNewContext;
3257 Diag(OperatorDelete->getLocation(),
3258 diag::note_type_aware_operator_declared)
3259 << OperatorDelete->isTypeAwareOperatorNewOrDelete()
3260 << OperatorDelete->getDeclName() << OperatorDeleteContext;
3272 UsualDeallocFnInfo Info(*
this,
3274 AllocElemType, StartLoc);
3280 if (IsSizedDelete && !FoundGlobalDelete) {
3282 AllocElemType, Info.IDP.PassTypeIdentity, Info.IDP.PassAlignment,
3285 *
this, FoundDelete, SizeTestingIDP, StartLoc);
3286 if (NonSizedDelete &&
3288 NonSizedDelete.IDP.PassAlignment == Info.IDP.PassAlignment)
3289 IsSizedDelete =
false;
3296 PlaceArgs.back()->getEndLoc());
3297 Diag(StartLoc, diag::err_placement_new_non_placement_delete) << R;
3298 if (!OperatorDelete->isImplicit())
3299 Diag(OperatorDelete->getLocation(), diag::note_previous_decl)
3308 }
else if (!Matches.empty()) {
3312 Diag(StartLoc, diag::warn_ambiguous_suitable_delete_function_found)
3313 << DeleteName << AllocElemType;
3315 for (
auto &
Match : Matches)
3317 diag::note_member_declared_here) << DeleteName;
3381 if (TheGlobalModuleFragment) {
3396 if (TheGlobalModuleFragment) {
3397 AlignValT->setModuleOwnershipKind(
3399 AlignValT->setLocalOwningModule(TheGlobalModuleFragment);
3404 AlignValT->setImplicit(
true);
3417 Params.push_back(Param);
3420 bool HasSizedVariant =
getLangOpts().SizedDeallocation &&
3421 (Kind == OO_Delete || Kind == OO_Array_Delete);
3422 bool HasAlignedVariant =
getLangOpts().AlignedAllocation;
3424 int NumSizeVariants = (HasSizedVariant ? 2 : 1);
3425 int NumAlignVariants = (HasAlignedVariant ? 2 : 1);
3426 for (
int Sized = 0; Sized < NumSizeVariants; ++Sized) {
3428 Params.push_back(
SizeT);
3430 for (
int Aligned = 0; Aligned < NumAlignVariants; ++Aligned) {
3443 DeclareGlobalAllocationFunctions(OO_New, VoidPtr,
SizeT);
3444 DeclareGlobalAllocationFunctions(OO_Array_New, VoidPtr,
SizeT);
3445 DeclareGlobalAllocationFunctions(OO_Delete,
Context.
VoidTy, VoidPtr);
3446 DeclareGlobalAllocationFunctions(OO_Array_Delete,
Context.
VoidTy, VoidPtr);
3449 PopGlobalModuleFragment();
3462 Alloc != AllocEnd; ++Alloc) {
3466 if (
Func->getNumParams() == Params.size()) {
3467 if (std::equal(
Func->param_begin(),
Func->param_end(), Params.begin(),
3469 return Context.hasSameUnqualifiedType(D->getType(),
3475 Func->setVisibleDespiteOwningModule();
3486 bool HasBadAllocExceptionSpec = Name.isAnyOperatorNew();
3487 if (HasBadAllocExceptionSpec) {
3490 assert(
StdBadAlloc &&
"Must have std::bad_alloc declared");
3502 auto CreateAllocationFunctionDecl = [&](
Attr *ExtraAttr) {
3509 isa<CUDAHostAttr>(ExtraAttr) &&
3521 Alloc->setImplicit();
3523 Alloc->setVisibleDespiteOwningModule();
3525 if (HasBadAllocExceptionSpec &&
getLangOpts().NewInfallible &&
3528 ReturnsNonNullAttr::CreateImplicit(
Context, Alloc->getLocation()));
3540 if (TheGlobalModuleFragment) {
3541 Alloc->setModuleOwnershipKind(
3543 Alloc->setLocalOwningModule(TheGlobalModuleFragment);
3547 Alloc->addAttr(VisibilityAttr::CreateImplicit(
3549 ? VisibilityAttr::Hidden
3551 ? VisibilityAttr::Protected
3552 : VisibilityAttr::Default));
3559 ParamDecls.back()->setImplicit();
3561 Alloc->setParams(ParamDecls);
3563 Alloc->addAttr(ExtraAttr);
3570 CreateAllocationFunctionDecl(
nullptr);
3574 CreateAllocationFunctionDecl(CUDAHostAttr::CreateImplicit(
Context));
3575 CreateAllocationFunctionDecl(CUDADeviceAttr::CreateImplicit(
Context));
3587 DeallocLookupMode::OptionallyTyped, Name);
3602 assert(
Result.FD &&
"operator delete missing from global scope?");
3621 return OperatorDelete;
3640 if (
Found.isAmbiguous())
3643 Found.suppressDiagnostics();
3656 if (Matches.size() == 1) {
3657 Operator = cast<CXXMethodDecl>(Matches[0].FD);
3659 Found.getNamingClass(), Matches[0].Found,
3666 if (!Matches.empty()) {
3668 Diag(StartLoc, diag::err_ambiguous_suitable_delete_member_function_found)
3670 for (
auto &
Match : Matches)
3671 Diag(
Match.FD->getLocation(), diag::note_member_declared_here) << Name;
3678 if (!
Found.empty()) {
3680 Diag(StartLoc, diag::err_no_suitable_delete_member_function_found)
3685 diag::note_member_declared_here) << Name;
3697class MismatchingNewDeleteDetector {
3699 enum MismatchResult {
3705 MemberInitMismatches,
3714 explicit MismatchingNewDeleteDetector(
bool EndOfTU)
3715 : Field(nullptr), IsArrayForm(
false), EndOfTU(EndOfTU),
3716 HasUndefinedConstructors(
false) {}
3733 MismatchResult analyzeField(
FieldDecl *Field,
bool DeleteWasArrayForm);
3743 bool HasUndefinedConstructors;
3755 MismatchResult analyzeMemberExpr(
const MemberExpr *ME);
3778 MismatchResult analyzeInClassInitializer();
3782MismatchingNewDeleteDetector::MismatchResult
3783MismatchingNewDeleteDetector::analyzeDeleteExpr(
const CXXDeleteExpr *DE) {
3785 assert(DE &&
"Expected delete-expression");
3788 if (
const MemberExpr *ME = dyn_cast<const MemberExpr>(
E)) {
3789 return analyzeMemberExpr(ME);
3790 }
else if (
const DeclRefExpr *
D = dyn_cast<const DeclRefExpr>(
E)) {
3791 if (!hasMatchingVarInit(
D))
3792 return VarInitMismatches;
3798MismatchingNewDeleteDetector::getNewExprFromInitListOrExpr(
const Expr *
E) {
3799 assert(
E !=
nullptr &&
"Expected a valid initializer expression");
3801 if (
const InitListExpr *ILE = dyn_cast<const InitListExpr>(
E)) {
3802 if (ILE->getNumInits() == 1)
3803 E = dyn_cast<const CXXNewExpr>(ILE->getInit(0)->IgnoreParenImpCasts());
3806 return dyn_cast_or_null<const CXXNewExpr>(
E);
3809bool MismatchingNewDeleteDetector::hasMatchingNewInCtorInit(
3813 (NE = getNewExprFromInitListOrExpr(CI->
getInit()))) {
3814 if (
NE->isArray() == IsArrayForm)
3817 NewExprs.push_back(NE);
3822bool MismatchingNewDeleteDetector::hasMatchingNewInCtor(
3828 HasUndefinedConstructors =
true;
3831 for (
const auto *CI : cast<const CXXConstructorDecl>(
Definition)->inits()) {
3832 if (hasMatchingNewInCtorInit(CI))
3838MismatchingNewDeleteDetector::MismatchResult
3839MismatchingNewDeleteDetector::analyzeInClassInitializer() {
3840 assert(Field !=
nullptr &&
"This should be called only for members");
3841 const Expr *InitExpr =
Field->getInClassInitializer();
3843 return EndOfTU ? NoMismatch : AnalyzeLater;
3844 if (
const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
3845 if (
NE->isArray() != IsArrayForm) {
3846 NewExprs.push_back(NE);
3847 return MemberInitMismatches;
3853MismatchingNewDeleteDetector::MismatchResult
3854MismatchingNewDeleteDetector::analyzeField(
FieldDecl *Field,
3855 bool DeleteWasArrayForm) {
3856 assert(Field !=
nullptr &&
"Analysis requires a valid class member.");
3857 this->Field =
Field;
3858 IsArrayForm = DeleteWasArrayForm;
3860 for (
const auto *CD : RD->
ctors()) {
3861 if (hasMatchingNewInCtor(CD))
3864 if (HasUndefinedConstructors)
3865 return EndOfTU ? NoMismatch : AnalyzeLater;
3866 if (!NewExprs.empty())
3867 return MemberInitMismatches;
3868 return Field->hasInClassInitializer() ? analyzeInClassInitializer()
3872MismatchingNewDeleteDetector::MismatchResult
3873MismatchingNewDeleteDetector::analyzeMemberExpr(
const MemberExpr *ME) {
3874 assert(ME !=
nullptr &&
"Expected a member expression");
3876 return analyzeField(F, IsArrayForm);
3880bool MismatchingNewDeleteDetector::hasMatchingVarInit(
const DeclRefExpr *
D) {
3882 if (
const VarDecl *VD = dyn_cast<const VarDecl>(
D->getDecl())) {
3883 if (VD->hasInit() && (NE = getNewExprFromInitListOrExpr(VD->getInit())) &&
3884 NE->isArray() != IsArrayForm) {
3885 NewExprs.push_back(NE);
3888 return NewExprs.empty();
3893 const MismatchingNewDeleteDetector &Detector) {
3896 if (!Detector.IsArrayForm)
3905 SemaRef.
Diag(DeleteLoc, diag::warn_mismatched_delete_new)
3906 << Detector.IsArrayForm << H;
3908 for (
const auto *NE : Detector.NewExprs)
3909 SemaRef.
Diag(NE->getExprLoc(), diag::note_allocated_here)
3910 << Detector.IsArrayForm;
3913void Sema::AnalyzeDeleteExprMismatch(
const CXXDeleteExpr *DE) {
3916 MismatchingNewDeleteDetector Detector(
false);
3917 switch (Detector.analyzeDeleteExpr(DE)) {
3918 case MismatchingNewDeleteDetector::VarInitMismatches:
3919 case MismatchingNewDeleteDetector::MemberInitMismatches: {
3923 case MismatchingNewDeleteDetector::AnalyzeLater: {
3928 case MismatchingNewDeleteDetector::NoMismatch:
3934 bool DeleteWasArrayForm) {
3935 MismatchingNewDeleteDetector Detector(
true);
3936 switch (Detector.analyzeField(Field, DeleteWasArrayForm)) {
3937 case MismatchingNewDeleteDetector::VarInitMismatches:
3938 llvm_unreachable(
"This analysis should have been done for class members.");
3939 case MismatchingNewDeleteDetector::AnalyzeLater:
3940 llvm_unreachable(
"Analysis cannot be postponed any point beyond end of "
3941 "translation unit.");
3942 case MismatchingNewDeleteDetector::MemberInitMismatches:
3945 case MismatchingNewDeleteDetector::NoMismatch:
3952 bool ArrayForm,
Expr *ExE) {
3962 bool ArrayFormAsWritten = ArrayForm;
3963 bool UsualArrayDeleteWantsSize =
false;
3981 if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType())
3988 return S.
Diag(
Loc, diag::err_delete_operand) <<
T;
3993 return S.
Diag(
Loc, diag::err_delete_incomplete_class_type) <<
T;
3999 return S.
Diag(
Loc, diag::err_delete_explicit_conversion) <<
T << ConvTy;
4010 return S.
Diag(
Loc, diag::err_ambiguous_delete_operand) <<
T;
4022 llvm_unreachable(
"conversion functions are permitted");
4030 if (!Converter.match(
Type))
4041 diag::err_address_space_qualified_delete)
4051 Diag(StartLoc,
LangOpts.CPlusPlus26 ? diag::err_delete_incomplete
4052 : diag::ext_delete_void_ptr_operand)
4065 ? diag::err_delete_incomplete
4066 : diag::warn_delete_incomplete,
4073 Diag(StartLoc, diag::warn_delete_array_type)
4080 ArrayForm ? OO_Array_Delete : OO_Delete);
4088 OperatorDelete, IDP))
4102 else if (isa_and_nonnull<CXXMethodDecl>(OperatorDelete)) {
4103 UsualDeallocFnInfo UDFI(
4112 if (Dtor->isCalledByDelete(OperatorDelete)) {
4126 if (!OperatorDelete) {
4128 Diag(StartLoc, diag::err_openclcxx_not_supported) <<
"default delete";
4133 bool CanProvideSize =
4134 IsComplete && (!ArrayForm || UsualArrayDeleteWantsSize ||
4144 if (!OperatorDelete)
4148 if (OperatorDelete->isInvalidDecl())
4155 bool IsVirtualDelete =
false;
4158 if (Dtor->isCalledByDelete(OperatorDelete))
4160 PDiag(diag::err_access_dtor) << PointeeElem);
4161 IsVirtualDelete = Dtor->isVirtual();
4167 unsigned AddressParamIdx = 0;
4168 if (OperatorDelete->isTypeAwareOperatorNewOrDelete()) {
4169 QualType TypeIdentity = OperatorDelete->getParamDecl(0)->getType();
4171 diag::err_incomplete_type))
4173 AddressParamIdx = 1;
4181 OperatorDelete->getParamDecl(AddressParamIdx)->getType();
4201 UsualArrayDeleteWantsSize, OperatorDelete, Ex.
get(), StartLoc);
4202 AnalyzeDeleteExprMismatch(
Result);
4211 IsDelete ? OO_Delete : OO_New);
4215 assert(!R.
empty() &&
"implicitly declared allocation functions not found");
4216 assert(!R.
isAmbiguous() &&
"global allocation functions are ambiguous");
4225 FnOvl != FnOvlEnd; ++FnOvl) {
4228 NamedDecl *
D = (*FnOvl)->getUnderlyingDecl();
4252 "class members should not be considered");
4255 S.
Diag(R.
getNameLoc(), diag::err_builtin_operator_new_delete_not_usual)
4256 << (IsDelete ? 1 : 0) <<
Range;
4257 S.
Diag(FnDecl->
getLocation(), diag::note_non_usual_function_declared_here)
4269 S.
PDiag(diag::err_ovl_no_viable_function_in_call)
4277 S.
PDiag(diag::err_ovl_ambiguous_call)
4284 Candidates, Best->Function, Args);
4287 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
4292 CallExpr *TheCall = cast<CallExpr>(TheCallResult.
get());
4295 << (IsDelete ?
"__builtin_operator_delete" :
"__builtin_operator_new")
4305 OperatorNewOrDelete))
4307 assert(OperatorNewOrDelete &&
"should be found");
4313 for (
unsigned i = 0; i != TheCall->
getNumArgs(); ++i) {
4324 assert(Callee &&
Callee->getCastKind() == CK_BuiltinFnToFnPtr &&
4325 "Callee expected to be implicit cast to a builtin function pointer");
4328 return TheCallResult;
4332 bool IsDelete,
bool CallCanBeVirtual,
4333 bool WarnOnNonAbstractTypes,
4360 Diag(
Loc, diag::warn_delete_abstract_non_virtual_dtor) << (IsDelete ? 0 : 1)
4362 }
else if (WarnOnNonAbstractTypes) {
4365 Diag(
Loc, diag::warn_delete_non_virtual_dtor) << (IsDelete ? 0 : 1)
4369 std::string TypeStr;
4371 Diag(DtorLoc, diag::note_delete_non_virtual)
4400 diag::err_invalid_use_of_function_type)
4404 diag::err_invalid_use_of_array_type)
4422 llvm_unreachable(
"unexpected condition kind");
4454 diag::err_constexpr_if_condition_expression_is_not_constant);
4462 From = Cast->getSubExpr();
4474 if (!ToPtrType->getPointeeType().hasQualifiers()) {
4475 switch (StrLit->getKind()) {
4483 return (ToPointeeType->getKind() == BuiltinType::Char_U ||
4484 ToPointeeType->getKind() == BuiltinType::Char_S);
4489 assert(
false &&
"Unevaluated string literal in expression");
4504 bool HadMultipleCandidates,
4507 default: llvm_unreachable(
"Unhandled cast kind!");
4508 case CK_ConstructorConversion: {
4513 diag::err_allocation_of_abstract_type))
4526 CastLoc, Ty, FoundDecl, cast<CXXConstructorDecl>(
Method),
4527 ConstructorArgs, HadMultipleCandidates,
4528 false,
false,
false,
4536 case CK_UserDefinedConversion: {
4546 HadMultipleCandidates);
4551 CK_UserDefinedConversion,
Result.get(),
4552 nullptr,
Result.get()->getValueKind(),
4585 assert(FD &&
"no conversion function for user-defined conversion seq");
4587 CastKind = CK_UserDefinedConversion;
4595 CastKind = CK_ConstructorConversion;
4622 From = CastArg.
get();
4636 PDiag(diag::err_typecheck_ambiguous_condition)
4642 llvm_unreachable(
"bad conversion");
4652 assert(Diagnosed &&
"failed to diagnose bad conversion"); (void)Diagnosed;
4666 ElType = ToVec->getElementType();
4703 false,
false,
false,
4710 false,
false,
false,
4743 ToAtomicType = ToType;
4744 ToType = ToAtomic->getValueType();
4747 QualType InitialFromType = FromType;
4749 switch (SCS.
First) {
4752 FromType = FromAtomic->getValueType().getUnqualifiedType();
4765 From = FromRes.
get();
4797 llvm_unreachable(
"Improper first standard conversion");
4838 "only enums with fixed underlying type can promote to bool");
4868 CK = CK_FloatingComplexCast;
4870 CK = CK_FloatingComplexToIntegralComplex;
4872 CK = CK_IntegralComplexToFloatingComplex;
4874 CK = CK_IntegralComplexCast;
4900 "Attempting implicit fixed point conversion without a fixed "
4905 nullptr, CCK).
get();
4909 nullptr, CCK).
get();
4913 nullptr, CCK).
get();
4917 nullptr, CCK).
get();
4921 nullptr, CCK).
get();
4925 nullptr, CCK).
get();
4930 nullptr, CCK).
get();
4940 diag::ext_typecheck_convert_incompatible_pointer)
4945 diag::ext_typecheck_convert_incompatible_pointer)
4952 }
else if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
4953 !
ObjC().CheckObjCARCUnavailableWeakConversion(ToType,
4958 Diag(From->
getBeginLoc(), diag::err_arc_convesion_of_weak_unavailable)
4987 if (Kind == CK_BlockPointerToObjCPointerCast) {
5007 assert((Kind != CK_NullToMemberPointer ||
5010 "Expr must be null pointer constant!");
5015 llvm_unreachable(
"unexpected result");
5017 llvm_unreachable(
"Should not have been called if derivation isn't OK.");
5060 &BasePath, CCK).
get();
5089 QualType ElType = ToComplex->getElementType();
5097 isFloatingComplex ? CK_FloatingCast : CK_FloatingToIntegral).
get();
5101 isFloatingComplex ? CK_IntegralToFloating : CK_IntegralCast).
get();
5105 isFloatingComplex ? CK_FloatingRealToComplex
5106 : CK_IntegralRealToComplex).
get();
5111 QualType ElType = FromComplex->getElementType();
5116 isFloatingComplex ? CK_FloatingComplexToReal
5117 : CK_IntegralComplexToReal,
5126 isFloatingComplex ? CK_FloatingCast
5127 : CK_IntegralToFloating,
5133 isFloatingComplex ? CK_FloatingToIntegral
5150 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
5163 From = FromRes.
get();
5165 "Improper transparent union conversion");
5173 CK_ZeroToOCLOpaqueType,
5188 llvm_unreachable(
"Improper second standard conversion");
5197 "Dimension conversion for matrix types is not implemented yet.");
5199 "Dimension conversion output must be vector or scalar type.");
5216 QualType TruncTy = FromVec->getElementType();
5227 llvm_unreachable(
"Improper element standard conversion");
5231 switch (SCS.
Third) {
5254 CK = CK_AddressSpaceConversion;
5259 CK = CK_AddressSpaceConversion;
5265 << InitialFromType << ToType;
5276 ? diag::ext_deprecated_string_literal_conversion
5277 : diag::warn_deprecated_string_literal_conversion)
5285 llvm_unreachable(
"Improper third standard conversion");
5290 if (!ToAtomicType.
isNull()) {
5322 "placeholders should have been weeded out by now");
5337 const char *OpSpelling = isIndirect ?
"->*" :
".*";
5345 Diag(
Loc, diag::err_bad_memptr_rhs)
5367 Diag(
Loc, diag::err_bad_memptr_lhs)
5368 << OpSpelling << 1 << LHSType
5378 OpSpelling, (
int)isIndirect)) {
5383 Diag(
Loc, diag::err_bad_memptr_lhs) << OpSpelling
5392 LHSType, RHSClassType,
Loc,
5410 Diag(
Loc, diag::err_pointer_to_member_type) << isIndirect;
5429 switch (Proto->getRefQualifier()) {
5438 if (Proto->isConst() && !Proto->isVolatile())
5440 ? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
5441 : diag::ext_pointer_to_const_ref_member_on_rvalue);
5443 Diag(
Loc, diag::err_pointer_to_member_oper_value_classify)
5450 Diag(
Loc, diag::err_pointer_to_member_oper_value_classify)
5463 if (
Result->isFunctionType()) {
5466 }
else if (isIndirect) {
5484 bool &HaveConversion,
5486 HaveConversion =
false;
5509 HaveConversion =
true;
5524 bool FDerivedFromT = FRec && TRec && FRec != TRec &&
5525 Self.IsDerivedFrom(QuestionLoc, FTy, TTy);
5526 if (FRec && TRec && (FRec == TRec || FDerivedFromT ||
5527 Self.IsDerivedFrom(QuestionLoc, TTy, FTy))) {
5531 if (FRec == TRec || FDerivedFromT) {
5536 HaveConversion =
true;
5559 HaveConversion = !InitSeq.
Failed();
5577 Self.AddBuiltinOperatorCandidates(OO_Conditional, QuestionLoc, Args,
5585 LHS.
get(), Best->BuiltinParamTypes[0], Best->Conversions[0],
5592 RHS.
get(), Best->BuiltinParamTypes[1], Best->Conversions[1],
5598 Self.MarkFunctionReferenced(QuestionLoc, Best->Function);
5607 if (
Self.DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
5610 Self.Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
5616 Self.Diag(QuestionLoc, diag::err_conditional_ambiguous_ovl)
5624 llvm_unreachable(
"Conditional operator has only built-in overloads");
5635 Expr *Arg =
E.get();
5653 assert(!EltTy->
isEnumeralType() &&
"Vectors cant be enum types");
5663 assert(!EltTy->
isEnumeralType() &&
"Vectors cant be enum types");
5675 QualType CondElementTy = CondVT->getElementType();
5676 unsigned CondElementCount = CondVT->getNumElements();
5685 if (LHSVT && RHSVT) {
5686 if (isa<ExtVectorType>(CondVT) != isa<ExtVectorType>(LHSVT)) {
5687 Diag(QuestionLoc, diag::err_conditional_vector_cond_result_mismatch)
5688 << isa<ExtVectorType>(CondVT);
5694 Diag(QuestionLoc, diag::err_conditional_vector_mismatched)
5695 << LHSType << RHSType;
5699 }
else if (LHSVT || RHSVT) {
5701 LHS, RHS, QuestionLoc,
false,
true,
5705 if (ResultType.isNull())
5718 Diag(QuestionLoc, diag::err_conditional_vector_operand_type)
5733 assert(!ResultType.isNull() && ResultType->isVectorType() &&
5735 "Result should have been a vector type");
5736 auto *ResultVectorTy = ResultType->castAs<
VectorType>();
5737 QualType ResultElementTy = ResultVectorTy->getElementType();
5738 unsigned ResultElementCount = ResultVectorTy->getNumElements();
5740 if (ResultElementCount != CondElementCount) {
5741 Diag(QuestionLoc, diag::err_conditional_vector_size) << CondType
5749 (!CondElementTy->isBooleanType() ||
LangOpts.OpenCL)) {
5750 Diag(QuestionLoc, diag::err_conditional_vector_element_size)
5751 << CondType << ResultType;
5768 llvm::ElementCount CondElementCount =
5780 if (LHSBT && RHSBT) {
5783 Diag(QuestionLoc, diag::err_conditional_vector_mismatched)
5784 << LHSType << RHSType;
5787 ResultType = LHSType;
5788 }
else if (LHSBT || RHSBT) {
5792 if (ResultType.isNull())
5801 ResultElementTy = LHSType;
5807 Diag(QuestionLoc, diag::err_conditional_vector_operand_type)
5813 ResultElementTy, CondElementCount.getKnownMinValue());
5819 assert(!ResultType.isNull() && ResultType->isSveVLSBuiltinType() &&
5820 "Result should have been a vector type");
5821 auto *ResultBuiltinTy = ResultType->castAs<
BuiltinType>();
5823 llvm::ElementCount ResultElementCount =
5826 if (ResultElementCount != CondElementCount) {
5827 Diag(QuestionLoc, diag::err_conditional_vector_size)
5828 << CondType << ResultType;
5834 Diag(QuestionLoc, diag::err_conditional_vector_element_size)
5835 << CondType << ResultType;
5852 bool IsVectorConditional =
5855 bool IsSizelessVectorConditional =
5862 ExprResult CondRes = IsVectorConditional || IsSizelessVectorConditional
5888 if (LVoid || RVoid) {
5897 if (IsVectorConditional) {
5900 bool IsThrow = LVoid ? LThrow : RThrow;
5901 Diag(DiagLoc.
getBegin(), diag::err_conditional_vector_has_void)
5902 << DiagLoc << IsThrow;
5906 if (LThrow != RThrow) {
5907 Expr *NonThrow = LThrow ? RHS.
get() : LHS.
get();
5921 Diag(QuestionLoc, diag::err_conditional_void_nonvoid)
5922 << (LVoid ? RTy : LTy) << (LVoid ? 0 : 1)
5928 if (IsVectorConditional)
5931 if (IsSizelessVectorConditional)
5936 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
5949 bool HaveL2R, HaveR2L;
5956 if (HaveL2R && HaveR2L) {
5957 Diag(QuestionLoc, diag::err_conditional_ambiguous)
5969 }
else if (HaveR2L) {
5993 ReferenceConversions::Qualification |
5994 ReferenceConversions::NestedQualification |
5995 ReferenceConversions::Function;
6000 !(RefConv & ~AllowedConversions) &&
6008 !(RefConv & ~AllowedConversions) &&
6024 if (Same && LVK == RVK && LVK !=
VK_PRValue &&
6098 diag::err_typecheck_cond_incompatible_operands) << LTy << RTy
6136 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6156 bool T2IsPointerLike = T2->isAnyPointerType() || T2->isMemberPointerType() ||
6157 T2->isNullPtrType();
6158 if (!T1IsPointerLike && !T2IsPointerLike)
6166 if (T1IsPointerLike &&
6170 ? CK_NullToMemberPointer
6171 : CK_NullToPointer).
get();
6174 if (T2IsPointerLike &&
6178 ? CK_NullToMemberPointer
6179 : CK_NullToPointer).
get();
6184 if (!T1IsPointerLike || !T2IsPointerLike)
6187 "nullptr_t should be a null pointer constant");
6190 enum Kind {
Pointer, ObjCPointer, MemberPointer, Array } K;
6196 const Type *ClassOrBound;
6198 Step(
Kind K,
const Type *ClassOrBound =
nullptr)
6199 : K(K), ClassOrBound(ClassOrBound) {}
6211 if (
auto *CAT = cast_or_null<ConstantArrayType>(ClassOrBound))
6213 ArraySizeModifier::Normal, 0);
6217 llvm_unreachable(
"unknown step kind");
6239 unsigned NeedConstBefore = 0;
6248 if (!Steps.empty()) {
6258 }
else if (Steps.size() == 1) {
6261 if (MaybeQ1 == MaybeQ2) {
6280 assert(Steps.size() == 1);
6288 assert(Steps.size() == 1);
6297 Steps.back().Quals = Quals;
6298 if (Q1 != Quals || Q2 != Quals)
6299 NeedConstBefore = Steps.size() - 1;
6307 auto *CAT1 = dyn_cast<ConstantArrayType>(Arr1);
6308 auto *CAT2 = dyn_cast<ConstantArrayType>(Arr2);
6309 if (CAT1 && CAT2 && CAT1->getSize() == CAT2->getSize()) {
6312 Steps.emplace_back(Step::Array, CAT1);
6315 bool IAT1 = isa<IncompleteArrayType>(Arr1);
6316 bool IAT2 = isa<IncompleteArrayType>(Arr2);
6317 if ((IAT1 && IAT2) ||
6319 ((
bool)CAT1 != (
bool)CAT2) &&
6320 (Steps.empty() || Steps.back().K != Step::Array))) {
6326 Steps.emplace_back(Step::Array);
6328 NeedConstBefore = Steps.size();
6338 Steps.emplace_back(Step::Pointer);
6347 Steps.emplace_back(Step::ObjCPointer);
6371 else if (Steps.empty())
6378 Steps.emplace_back(Step::MemberPointer,
6391 Steps.emplace_back(Step::Pointer);
6429 if (Steps.size() == 1) {
6441 bool CFIUncheckedCallee =
6453 FPT1->getParamTypes(), EPI1);
6455 FPT2->getParamTypes(), EPI2);
6461 if (Steps.size() == 1 && Steps.front().K == Step::Pointer &&
6467 Composite2 = Composite1;
6469 Composite1 = Composite2;
6478 Composite1 = Composite2;
6480 Composite2 = Composite1;
6490 for (
unsigned I = 0; I != NeedConstBefore; ++I)
6491 Steps[I].Quals.addConst();
6495 for (
auto &S : llvm::reverse(Steps))
6496 Composite = S.rebuild(
Context, Composite);
6517 E1 = E1Result.
get();
6522 E2 = E2Result.
get();
6532 assert(!isa<CXXBindTemporaryExpr>(
E) &&
"Double-bound temporary?");
6543 bool ReturnsRetained;
6548 Expr *Callee =
Call->getCallee()->IgnoreParens();
6554 T = BinOp->getRHS()->getType();
6555 else if (
MemberExpr *Mem = dyn_cast<MemberExpr>(Callee))
6556 T = Mem->getMemberDecl()->getType();
6571 }
else if (isa<StmtExpr>(
E)) {
6572 ReturnsRetained =
true;
6576 }
else if (isa<CastExpr>(
E) &&
6577 isa<BlockExpr>(cast<CastExpr>(
E)->getSubExpr())) {
6586 D = Send->getMethodDecl();
6587 }
else if (
ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(
E)) {
6588 D = BoxedExpr->getBoxingMethod();
6592 if (ArrayLit->getNumElements() == 0 &&
6596 D = ArrayLit->getArrayWithObjectsMethod();
6598 = dyn_cast<ObjCDictionaryLiteral>(
E)) {
6601 if (DictLit->getNumElements() == 0 &&
6605 D = DictLit->getDictWithObjectsMethod();
6608 ReturnsRetained = (
D &&
D->
hasAttr<NSReturnsRetainedAttr>());
6613 if (!ReturnsRetained &&
6624 CastKind ck = (ReturnsRetained ? CK_ARCConsumeObject
6625 : CK_ARCReclaimReturnedObject);
6643 RT = cast<RecordType>(
T);
6645 case Type::ConstantArray:
6646 case Type::IncompleteArray:
6647 case Type::VariableArray:
6648 case Type::DependentSizedArray:
6649 T = cast<ArrayType>(
T)->getElementType().getTypePtr();
6670 PDiag(diag::err_access_dtor_temp)
6701 assert(SubExpr &&
"subexpression can't be null!");
6723 assert(SubStmt &&
"sub-statement can't be null!");
6746 "not in a decltype expression");
6763 if (
ParenExpr *PE = dyn_cast<ParenExpr>(
E)) {
6767 if (SubExpr.
get() == PE->getSubExpr())
6772 if (BO->getOpcode() == BO_Comma) {
6776 if (RHS.
get() == BO->getRHS())
6779 BO->
getType(), BO->getValueKind(),
6780 BO->getObjectKind(), BO->getOperatorLoc(),
6781 BO->getFPFeatures());
6808 for (
unsigned I = 0, N =
ExprEvalContexts.back().DelayedDecltypeCalls.size();
6811 if (
Call == TopCall)
6821 for (
unsigned I = 0, N =
ExprEvalContexts.back().DelayedDecltypeBinds.size();
6825 if (
Bind == TopBind)
6831 Bind->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
6837 PDiag(diag::err_access_dtor_temp)
6838 <<
Bind->getType());
6853 unsigned SkipStart = OperatorArrows.size(), SkipCount = 0;
6856 if (OperatorArrows.size() > Limit) {
6858 SkipStart = (Limit - 1) / 2 + (Limit - 1) % 2;
6859 SkipCount = OperatorArrows.size() - (Limit - 1);
6862 for (
unsigned I = 0; I < OperatorArrows.size(); ) {
6863 if (I == SkipStart) {
6864 S.
Diag(OperatorArrows[I]->getLocation(),
6865 diag::note_operator_arrows_suppressed)
6869 S.
Diag(OperatorArrows[I]->getLocation(), diag::note_operator_arrow_here)
6870 << OperatorArrows[I]->getCallResultType();
6880 bool &MayBePseudoDestructor) {
6891 MayBePseudoDestructor =
false;
6896 if (OpKind == tok::arrow)
6901 MayBePseudoDestructor =
true;
6908 if (OpKind == tok::arrow) {
6910 bool NoArrowOperatorFound =
false;
6911 bool FirstIteration =
true;
6919 if (OperatorArrows.size() >=
getLangOpts().ArrowDepth) {
6920 Diag(OpLoc, diag::err_operator_arrow_depth_exceeded)
6921 << StartingType <<
getLangOpts().ArrowDepth <<
Base->getSourceRange();
6923 Diag(OpLoc, diag::note_operator_arrow_depth)
6936 : &NoArrowOperatorFound);
6937 if (
Result.isInvalid()) {
6938 if (NoArrowOperatorFound) {
6939 if (FirstIteration) {
6940 Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
6941 << BaseType << 1 <<
Base->getSourceRange()
6943 OpKind = tok::period;
6946 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
6947 << BaseType <<
Base->getSourceRange();
6951 diag::note_member_reference_arrow_from_operator_arrow);
6958 OperatorArrows.push_back(OpCall->getDirectCallee());
6959 BaseType =
Base->getType();
6961 if (!CTypes.insert(CBaseType).second) {
6962 Diag(OpLoc, diag::err_operator_arrow_circular) << StartingType;
6966 FirstIteration =
false;
6969 if (OpKind == tok::arrow) {
6973 BaseType = AT->getElementType();
6995 MayBePseudoDestructor =
true;
7007 diag::err_incomplete_member_access)) {
7022 if (
Base->hasPlaceholderType()) {
7027 ObjectType =
Base->getType();
7035 if (OpKind == tok::arrow) {
7045 ObjectType =
Base->getType();
7050 }
else if (!
Base->isTypeDependent()) {
7052 S.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
7053 << ObjectType <<
true
7058 OpKind = tok::period;
7100 Diag(OpLoc, diag::ext_pseudo_dtor_on_void) <<
Base->getSourceRange();
7102 Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
7103 << ObjectType <<
Base->getSourceRange();
7111 if (DestructedTypeInfo) {
7124 Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
7125 << ObjectType << 0 <<
Base->getSourceRange();
7129 *
this, DestructedType))
7134 ObjectType = DestructedType;
7135 OpKind = tok::arrow;
7137 Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
7138 << ObjectType << DestructedType <<
Base->getSourceRange()
7142 DestructedType = ObjectType;
7143 DestructedTypeInfo =
7154 Diag(DestructedTypeStart, diag::err_arc_pseudo_dtor_inconstant_quals)
7155 << ObjectType << DestructedType <<
Base->getSourceRange()
7160 DestructedType = ObjectType;
7162 DestructedTypeStart);
7175 if (ScopeTypeInfo) {
7177 if (!ScopeType->isDependentType() && !ObjectType->
isDependentType() &&
7181 diag::err_pseudo_dtor_type_mismatch)
7182 << ObjectType << ScopeType <<
Base->getSourceRange()
7186 ScopeTypeInfo =
nullptr;
7192 OpKind == tok::arrow, OpLoc,
7212 "Invalid first type name in pseudo-destructor");
7215 "Invalid second type name in pseudo-destructor");
7239 S, &SS,
true,
false, ObjectTypePtrForLookup,
7252 diag::err_pseudo_dtor_destructor_non_type)
7258 DestructedType = ObjectType;
7273 if (
T.isInvalid() || !
T.get()) {
7275 DestructedType = ObjectType;
7282 if (!DestructedType.
isNull()) {
7283 if (!DestructedTypeInfo)
7297 S, &SS,
true,
false, ObjectTypePtrForLookup,
7301 diag::err_pseudo_dtor_destructor_non_type)
7323 if (
T.isInvalid() || !
T.get()) {
7331 if (!ScopeType.isNull() && !ScopeTypeInfo)
7337 ScopeTypeInfo, CCLoc, TildeLoc,
7369 cast<PackIndexingType>(
T.getTypePtr())->getPattern(),
7376 llvm_unreachable(
"Unsupported type in pseudo destructor");
7402 Operand->HasSideEffects(
Context,
false)) {
7405 Diag(Operand->getExprLoc(), diag::warn_side_effects_unevaluated_context);
7421 bool IsCompoundAssign =
false;
7422 bool isIncrementDecrementUnaryOp =
false;
7424 if (BO->getLHS()->getType()->isDependentType() ||
7425 BO->getRHS()->getType()->isDependentType()) {
7426 if (BO->getOpcode() != BO_Assign)
7428 }
else if (!BO->isAssignmentOp())
7431 IsCompoundAssign = BO->isCompoundAssignmentOp();
7432 LHS = dyn_cast<DeclRefExpr>(BO->getLHS());
7434 if (COCE->getOperator() != OO_Equal)
7436 LHS = dyn_cast<DeclRefExpr>(COCE->getArg(0));
7438 if (!UO->isIncrementDecrementOp())
7440 isIncrementDecrementUnaryOp =
true;
7441 LHS = dyn_cast<DeclRefExpr>(UO->getSubExpr());
7451 if ((IsCompoundAssign || isIncrementDecrementUnaryOp) &&
7457 iter->getSecond()--;
7534 diag::err_incomplete_type);
7560 if (isa<ParmVarDecl>(Var))
return true;
7561 const VarDecl *DefVD =
nullptr;
7595 while (isa_and_nonnull<CapturedDecl>(DC))
7599 "The current call operator must be synchronized with Sema's CurContext");
7620 !IsFullExprInstantiationDependent)
7633 const bool IsVarNeverAConstantExpression =
7635 if (!IsFullExprInstantiationDependent || IsVarNeverAConstantExpression) {
7647 DeclRefType,
nullptr)) {
7653 DeclRefType,
nullptr);
7665 const unsigned FunctionScopeIndexOfCapturableLambda = *Index;
7668 &FunctionScopeIndexOfCapturableLambda);
7677 bool DiscardedValue,
bool IsConstexpr,
7678 bool IsTemplateArgument) {
7687 if (DiscardedValue) {
7710 CheckCompletedExpr(
FullExpr.get(), CC, IsConstexpr);
7759 while (isa_and_nonnull<CapturedDecl>(DC))
7762 if (IsInLambdaDeclContext && CurrentLSI &&
7788 RedeclarationKind::NotForRedeclaration);
7806 llvm_unreachable(
"Invalid LookupResult Kind!");
7835 "Exactly one of TypeName and TemplateId must be specified.");
7903 E,
false, NoexceptLoc,
7931 auto *Param = cast<TemplateTypeParmDecl>(TPL->
getParam(0));
7936 assert(TC &&
"Type Constraint cannot be null here");
7938 assert(IDC &&
"ImmediatelyDeclaredConstraint can't be null here.");
7943 [&](llvm::raw_ostream &
OS) {
7944 IDC->printPretty(OS, nullptr,
7945 getPrintingPolicy());
7947 IsSimple, NoexceptLoc, ReturnTypeRequirement);
7949 SubstitutedConstraintExpr =
7950 cast<ConceptSpecializationExpr>(Constraint.
get());
7955 ReturnTypeRequirement, Status,
7956 SubstitutedConstraintExpr);
7965 IsSimple, NoexceptLoc,
7966 ReturnTypeRequirement);
8000 InvalidConstraintEntity,
8016 if (Param->getType()->isVoidType()) {
8017 if (LocalParameters.size() > 1) {
8018 Diag(Param->getBeginLoc(), diag::err_void_only_param);
8020 }
else if (Param->getIdentifier()) {
8021 Diag(Param->getBeginLoc(), diag::err_param_with_void_type);
8023 }
else if (Param->getType().hasQualifiers()) {
8024 Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
8026 }
else if (Param->hasDefaultArg()) {
8030 Diag(Param->getDefaultArgRange().getBegin(),
8031 diag::err_requires_expr_local_parameter_default_argument);
8033 }
else if (Param->isExplicitObjectParameter()) {
8044 Diag(Param->getExplicitObjectParamThisLoc(),
8045 diag::err_requires_expr_explicit_object_parameter);
8049 Param->setDeclContext(Body);
8051 if (Param->getIdentifier()) {
8060 assert(
CurContext &&
"DeclContext imbalance!");
8062 assert(
CurContext &&
"Popped translation unit!");
8071 LocalParameters, RParenLoc, Requirements,
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines a function that returns the minimum OS versions supporting C++17's aligned allocation functio...
static bool CanThrow(Expr *E, ASTContext &Ctx)
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
static const char * getPlatformName(Darwin::DarwinPlatformKind Platform, Darwin::DarwinEnvironmentKind Environment)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static bool doesUsualArrayDeleteWantSize(Sema &S, SourceLocation loc, TypeAwareAllocationMode PassType, QualType allocType)
Determine whether a given type is a class for which 'delete[]' would call a member 'operator delete[]...
static void collectPublicBases(CXXRecordDecl *RD, llvm::DenseMap< CXXRecordDecl *, unsigned > &SubobjectsSeen, llvm::SmallPtrSetImpl< CXXRecordDecl * > &VBases, llvm::SetVector< CXXRecordDecl * > &PublicSubobjectsSeen, bool ParentIsPublic)
static bool ConvertForConditional(Sema &Self, ExprResult &E, QualType T)
Perform an "extended" implicit conversion as returned by TryClassUnification.
static void MaybeDecrementCount(Expr *E, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool CheckDeleteOperator(Sema &S, SourceLocation StartLoc, SourceRange Range, bool Diagnose, CXXRecordDecl *NamingClass, DeclAccessPair Decl, FunctionDecl *Operator)
static void DiagnoseMismatchedNewDelete(Sema &SemaRef, SourceLocation DeleteLoc, const MismatchingNewDeleteDetector &Detector)
static void getUnambiguousPublicSubobjects(CXXRecordDecl *RD, llvm::SmallVectorImpl< CXXRecordDecl * > &Objects)
static bool isLegalArrayNewInitializer(CXXNewInitializationStyle Style, Expr *Init, bool IsCPlusPlus20)
static QualType adjustVectorType(ASTContext &Context, QualType FromTy, QualType ToType, QualType *ElTy=nullptr)
static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(Expr *const FE, LambdaScopeInfo *const CurrentLSI, Sema &S)
Check if the current lambda has any potential captures that must be captured by any of its enclosing ...
static void getUuidAttrOfType(Sema &SemaRef, QualType QT, llvm::SmallSetVector< const UuidAttr *, 1 > &UuidAttrs)
Grabs __declspec(uuid()) off a type, or returns 0 if we cannot resolve to a single GUID.
static QualType adjustCVQualifiersForCXXThisWithinLambda(ArrayRef< FunctionScopeInfo * > FunctionScopes, QualType ThisTy, DeclContext *CurSemaContext, ASTContext &ASTCtx)
static bool resolveAllocationOverloadInterior(Sema &S, LookupResult &R, SourceRange Range, ResolveMode Mode, SmallVectorImpl< Expr * > &Args, AlignedAllocationMode &PassAlignment, FunctionDecl *&Operator, OverloadCandidateSet *AlignedCandidates, Expr *AlignArg, bool Diagnose)
static bool FindConditionalOverload(Sema &Self, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Try to find a common type for two according to C++0x 5.16p5.
static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, SourceLocation QuestionLoc, bool &HaveConversion, QualType &ToType)
Try to convert a type to another according to C++11 5.16p3.
static bool resolveAllocationOverload(Sema &S, LookupResult &R, SourceRange Range, SmallVectorImpl< Expr * > &Args, ImplicitAllocationParameters &IAP, FunctionDecl *&Operator, OverloadCandidateSet *AlignedCandidates, Expr *AlignArg, bool Diagnose)
static UsualDeallocFnInfo resolveDeallocationOverload(Sema &S, LookupResult &R, const ImplicitDeallocationParameters &IDP, SourceLocation Loc, llvm::SmallVectorImpl< UsualDeallocFnInfo > *BestFns=nullptr)
Select the correct "usual" deallocation function to use from a selection of deallocation functions (e...
static bool hasNewExtendedAlignment(Sema &S, QualType AllocType)
Determine whether a type has new-extended alignment.
static ExprResult BuildCXXCastArgument(Sema &S, SourceLocation CastLoc, QualType Ty, CastKind Kind, CXXMethodDecl *Method, DeclAccessPair FoundDecl, bool HadMultipleCandidates, Expr *From)
static bool VariableCanNeverBeAConstantExpression(VarDecl *Var, ASTContext &Context)
static bool canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema &SemaRef, QualType DestructedType)
Check if it's ok to try and recover dot pseudo destructor calls on pointer objects.
static bool CheckArrow(Sema &S, QualType &ObjectType, Expr *&Base, tok::TokenKind &OpKind, SourceLocation OpLoc)
static bool resolveBuiltinNewDeleteOverload(Sema &S, CallExpr *TheCall, bool IsDelete, FunctionDecl *&Operator)
static bool isValidVectorForConditionalCondition(ASTContext &Ctx, QualType CondTy)
static void LookupGlobalDeallocationFunctions(Sema &S, SourceLocation Loc, LookupResult &FoundDelete, DeallocLookupMode Mode, DeclarationName Name)
static void noteOperatorArrows(Sema &S, ArrayRef< FunctionDecl * > OperatorArrows)
Note a set of 'operator->' functions that were used for a member access.
static bool isValidSizelessVectorForConditionalCondition(ASTContext &Ctx, QualType CondTy)
static void buildLambdaThisCaptureFixit(Sema &Sema, LambdaScopeInfo *LSI)
static bool isNonPlacementDeallocationFunction(Sema &S, FunctionDecl *FD)
Determine whether the given function is a non-placement deallocation function.
This file declares semantic analysis for HLSL constructs.
This file provides some common utility functions for processing Lambdas.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis functions specific to PowerPC.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TokenKind enum and support functions.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
a trap message and trap category.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
unsigned getIntWidth(QualType T) const
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
DeclarationNameTable DeclarationNames
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
FunctionProtoType::ExceptionSpecInfo mergeExceptionSpecs(FunctionProtoType::ExceptionSpecInfo ESI1, FunctionProtoType::ExceptionSpecInfo ESI2, SmallVectorImpl< QualType > &ExceptionTypeStorage, bool AcceptDependent) const
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
const TargetInfo * getAuxTargetInfo() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType BoundMemberTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
CharUnits getExnObjectAlignment() const
Return the alignment (in bytes) of the thrown exception object.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
QualType getExceptionObjectType(QualType T) const
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
unsigned getTypeAlignIfKnown(QualType T, bool NeedsPreferredAlignment=false) const
Return the alignment of a type, in bits, or 0 if the type is incomplete and we cannot determine the a...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
CanQualType getMSGuidType() const
Retrieve the implicitly-predeclared 'struct _GUID' type.
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
QualType getWideCharType() const
Return the type of wide characters.
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
A builtin binary operation expression such as "x + y" or "x <= y".
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents binding an expression to a temporary.
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
const Expr * getSubExpr() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
Represents a C++ base or member initializer.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Expr * getInit() const
Get the initializer.
Represents a delete expression for memory deallocation and destructor calls, e.g.
SourceLocation getBeginLoc() const
Represents a C++ destructor within a class.
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, SourceLocation RPLoc)
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getFunctionObjectParameterType() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP, bool UsualArrayDeleteWantsSize, ArrayRef< Expr * > PlacementArgs, SourceRange TypeIdParens, std::optional< Expr * > ArraySize, CXXNewInitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange)
Create a c++ new expression.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
The null pointer literal (C++11 [lex.nullptr])
A call to an overloaded operator written using operator syntax.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
capture_const_range captures() const
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
bool hasDefinition() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
CXXRecordDecl * getDefinitionOrSelf() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
An expression "T()" which creates an rvalue of a non-class type T.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
SourceLocation getEndLoc() const
SourceRange getRange() const
bool isSet() const
Deprecated.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Represents a C++ temporary.
void setDestructor(const CXXDestructorDecl *Dtor)
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Represents the this expression in C++.
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
A C++ throw-expression (C++ [except.throw]).
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
void setExprNeedsCleanups(bool SideEffects)
bool cleanupsHaveSideEffects() const
bool exprNeedsCleanups() const
Complex values, per C99 6.2.5p11.
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
bool isSatisfied() const
Whether or not the concept with the given arguments was satisfied when the expression was created.
Represents the canonical version of C arrays with a specified constant size.
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
A reference to a declared variable, function, enum, etc.
Captures information about "declaration specifiers".
Expr * getPackIndexingExpr() const
TST getTypeSpecType() const
SourceLocation getBeginLoc() const LLVM_READONLY
static const TST TST_typename_pack_indexing
ParsedType getRepAsType() const
SourceLocation getEllipsisLoc() const
Expr * getRepAsExpr() const
static const TST TST_decltype
SourceLocation getTypeSpecTypeLoc() const
static const TST TST_decltype_auto
static const TST TST_error
SourceRange getTypeofParensRange() const
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Kind
Lists the kind of concrete classes of Decl.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
DeclContext * getDeclContext()
@ ReachableWhenImported
This declaration has an owning module, and is visible to lookups that occurs within that module.
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
bool isAnyOperatorDelete() const
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
SourceLocation getBeginLoc() const LLVM_READONLY
Information about one declarator, including the parsed type information and the identifier.
void setRParenLoc(SourceLocation Loc)
void setDecltypeLoc(SourceLocation Loc)
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool isComplete() const
Returns true if this can be considered a complete type.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool isReadIfDiscardedInCPlusPlus11() const
Determine whether an lvalue-to-rvalue conversion should implicitly be applied to this expression if i...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool isOrdinaryOrBitFieldObject() const
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
FullExpr - Represents a "full-expression" node.
Represents a function declaration or definition.
static constexpr unsigned RequiredTypeAwareDeleteParameterCount
Count of mandatory parameters for type aware operator delete.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
const ParmVarDecl * getParamDecl(unsigned i) const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
QualType getReturnType() const
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool isReplaceableGlobalAllocationFunction(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
bool isDeleted() const
Whether this function has been deleted.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
Represents a prototype with parameter type info, e.g.
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
Declaration of a template function.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo withNoReturn(bool noReturn) const
bool getProducesResult() const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
One of these records is kept for each identifier that is lexed.
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine whether this is a name reserved for the implementation (C99 7.1.3, C++ [lib....
ReservedLiteralSuffixIdStatus isReservedLiteralSuffixId() const
Determine whether this is a name reserved for future standardization or the implementation (C++ [usrl...
StringRef getName() const
Return the actual identifier string.
bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)
Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
Describes the sequence of initializations required to initialize a given object or reference with a s...
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.
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
bool Failed() const
Determine whether the initialization sequence is invalid.
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init....
Describes an entity that is being initialized.
static InitializedEntity InitializeException(SourceLocation ThrowLoc, QualType Type)
Create the initialization entity for an exception object.
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
static InitializedEntity InitializeNew(SourceLocation NewLoc, QualType Type)
Create the initialization entity for an object allocated via new.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
clang::ObjCRuntime ObjCRuntime
bool hasGlobalAllocationFunctionVisibility() const
bool allowsNonTrivialObjCLifetimeQualifiers() const
True if any ObjC types may have non-trivial lifetime qualifiers.
bool hasHiddenGlobalAllocationFunctionVisibility() const
bool hasProtectedGlobalAllocationFunctionVisibility() const
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
DeclClass * getAsSingle() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
bool isClassLookup() const
Returns whether these results arose from performing a lookup into a class.
LookupResultKind getResultKind() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
Data structure that captures multiple levels of template argument lists for use in template instantia...
void addOuterRetainedLevels(unsigned Num)
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
TypeLoc getAsTypeLoc() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
const Type * getAsType() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
ObjCBoxedExpr - used for generalized expression boxing.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
bool hasEmptyCollections() const
Are the empty collection symbols available?
static OpaquePtr getFromOpaquePtr(void *P)
static OpaquePtr make(QualType P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
void setEllipsisLoc(SourceLocation Loc)
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool isEquivalent(PointerAuthQualifier Other) const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierTable & getIdentifierTable()
const LangOptions & getLangOpts() const
Stores the type being destroyed by a pseudo-destructor expression.
TypeSourceInfo * getTypeSourceInfo() const
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType withConst() const
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isWebAssemblyReferenceType() const
Returns true if it is a WebAssembly Reference Type.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
The collection of all-type qualifiers we support.
void removeCVRQualifiers(unsigned mask)
@ OCL_None
There is no lifetime qualification on this type.
bool hasCVRQualifiers() const
bool hasUnaligned() const
unsigned getAddressSpaceAttributePrintValue() const
Get the address space attribute value to be printed by diagnostics.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
void setAddressSpace(LangAS space)
unsigned getCVRUQualifiers() const
PointerAuthQualifier getPointerAuth() const
void setObjCGCAttr(GC type)
ObjCLifetime getObjCLifetime() const
static Qualifiers fromCVRUMask(unsigned CVRU)
LangAS getAddressSpace() const
void setPointerAuth(PointerAuthQualifier Q)
void setObjCLifetime(ObjCLifetime type)
Represents a struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getOriginalDecl() const
Represents the body of a requires-expression.
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
Scope - A scope is a transient data structure that is used while parsing the program.
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ ClassScope
The scope of a struct/union/class definition.
@ TryScope
This is the scope of a C++ try statement.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD, bool IsReinterpretCast=false)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
bool CheckPPCMMAType(QualType Type, SourceLocation TypeLoc)
CXXThisScopeRAII(Sema &S, Decl *ContextDecl, Qualifiers CXXThisTypeQuals, bool Enabled=true)
Introduce a new scope where 'this' may be allowed (when enabled), using the given declaration (which ...
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Sema - This implements semantic analysis and AST building for C.
void DeclareGlobalNewDelete()
DeclareGlobalNewDelete - Declare the global forms of operator new and delete.
IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo)
QualType CheckSizelessVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXUuidof - Parse __uuidof( something ).
Scope * getCurScope() const
Retrieve the parser's current scope.
QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
bool checkArrayElementAlignment(QualType EltTy, SourceLocation Loc)
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupDestructorName
Look up a name following ~ in a destructor name.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
@ LookupAnyName
Look up any declaration with any name.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
bool BuildTypeConstraint(const CXXScopeSpec &SS, TemplateIdAnnotation *TypeConstraint, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc, bool AllowUnexpandedPack)
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, ImplicitDeallocationParameters, bool Diagnose=true)
bool CheckCXXThisType(SourceLocation Loc, QualType Type)
Check whether the type of 'this' is valid in the current context.
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
QualType tryBuildStdTypeIdentity(QualType Type, SourceLocation Loc)
Looks for the std::type_identity template and instantiates it with Type, or returns a null type if ty...
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicCallType::DoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
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...
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
FPOptionsOverride CurFPFeatureOverrides()
concepts::Requirement * ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc)
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
concepts::Requirement::SubstitutionDiagnostic * createSubstDiagAt(SourceLocation Location, EntityPrinter Printer)
create a Requirement::SubstitutionDiagnostic with only a SubstitutedEntity and DiagLoc using ASTConte...
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ExprResult CheckUnevaluatedOperand(Expr *E)
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
void DiagnoseExceptionUse(SourceLocation Loc, bool IsTry)
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
bool isStdTypeIdentity(QualType Ty, QualType *TypeArgument, const Decl **MalformedDecl=nullptr)
Tests whether Ty is an instance of std::type_identity and, if it is and TypeArgument is not NULL,...
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
void CleanupVarDeclMarking()
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, ArrayRef< QualType > Params)
DeclareGlobalAllocationFunction - Declares a single implicit global allocation function if it doesn't...
bool DiagnoseUnexpandedParameterPackInRequiresExpr(RequiresExpr *RE)
If the given requirees-expression contains an unexpanded reference to one of its own parameter packs,...
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
bool tryCaptureVariable(ValueDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
void ActOnFinishRequiresExpr()
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
NamedReturnInfo getNamedReturnInfo(Expr *&E, SimplerImplicitMoveMode Mode=SimplerImplicitMoveMode::Normal)
Determine whether the given expression might be move-eligible or copy-elidable in either a (co_)retur...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id, bool IsUDSuffix)
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_IfExists
Microsoft __if_exists.
@ UPPC_IfNotExists
Microsoft __if_not_exists.
const LangOptions & getLangOpts() const
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
StmtResult ActOnFinishFullStmt(Stmt *Stmt)
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
void diagnoseUnavailableAlignedAllocation(const FunctionDecl &FD, SourceLocation Loc)
Produce diagnostics if FD is an aligned allocation or deallocation function that is unavailable.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
const LangOptions & LangOpts
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
ExprResult CheckConditionVariable(VarDecl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
Check the use of the given variable as a C++ condition in an if, while, do-while, or switch statement...
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
CXXRecordDecl * getStdBadAlloc() const
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenOrBraceLoc, MultiExprArg Exprs, SourceLocation RParenOrBraceLoc, bool ListInitialization)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, SourceRange R)
Checks that a type is suitable as the allocated type in a new-expression.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
MemberPointerConversionResult CheckMemberPointerConversion(QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind, CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange, bool IgnoreBaseAccess, MemberPointerConversionDirection Direction)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
void MarkThisReferenced(CXXThisExpr *This)
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
static bool isCast(CheckedConversionKind CCK)
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, ImplicitAllocationParameters &IAP, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
bool DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived, CXXRecordDecl *Base, CXXBasePaths &Paths)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
Stmt * MaybeCreateStmtWithCleanups(Stmt *SubStmt)
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
Parsed a C++ 'new' expression (C++ 5.3.4).
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared.
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD, bool Diagnose=true)
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr *Value, bool SupressSimplerImplicitMoves=false)
Perform the initialization of a potentially-movable value, which is the result of return value.
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
CanThrowResult canThrow(const Stmt *E)
bool isThisOutsideMemberFunctionBody(QualType BaseType)
Determine whether the given type is the type of *this that is used outside of the body of a member fu...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
concepts::ExprRequirement * BuildExprRequirement(Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement)
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?: under C++ semantics.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
FunctionDecl * BuildTypeAwareUsualDelete(FunctionTemplateDecl *FnDecl, QualType AllocType, SourceLocation)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
concepts::Requirement * ActOnTypeRequirement(SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
ExprResult BuildPseudoDestructorExpr(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
RequiresExprBodyDecl * ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, ArrayRef< ParmVarDecl * > LocalParameters, Scope *BodyScope)
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType.
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void DiscardCleanupsInEvaluationContext()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const
Determine whether FD is an aligned allocation or deallocation function that is unavailable.
DiagnosticsEngine & Diags
TypeAwareAllocationMode ShouldUseTypeAwareOperatorNewOrDelete() const
NamespaceDecl * getStdNamespace() const
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
bool CheckQualifiedFunctionForTypeId(QualType T, SourceLocation Loc)
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
TypeResult ActOnTemplateIdType(Scope *S, ElaboratedTypeKeyword ElaboratedKeyword, SourceLocation ElaboratedKeywordLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ParsedType getConstructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E)
CheckCXXThrowOperand - Validate the operand of a throw.
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
concepts::Requirement * ActOnNestedRequirement(Expr *Constraint)
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
static ConditionResult ConditionError()
IdentifierResolver IdResolver
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, ImplicitDeallocationParameters, DeclarationName Name)
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false, bool PartialOverloading=false)
Returns the more specialized function template according to the rules of function template partial or...
ExprResult ActOnCXXThis(SourceLocation Loc)
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, SourceLocation DtorLoc)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef< const Expr * > Args, bool IsMemberFunction, SourceLocation Loc, SourceRange Range, VariadicCallType CallType)
Handles the checks for format strings, non-POD arguments to vararg functions, NULL arguments passed t...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
DeclAccessPair FoundCopyConstructor
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion,...
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
ImplicitConversionKind Dimension
Dimension - Between the second and third conversion a vector or matrix dimension conversion may occur...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool isItaniumFamily() const
Does this ABI generally fall into the Itanium family of ABIs?
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with '::operator new(size_t)' is g...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Represents a template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Type
The template argument is a type.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
Represents a declaration of a type.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
void pushTrivial(ASTContext &Context, QualType T, SourceLocation Loc)
Pushes 'T' with all locations pointing to 'Loc'.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isBlockPointerType() const
bool isBooleanType() const
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isVoidPointerType() const
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isPointerType() const
bool isArrayParameterType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isScalarType() const
bool isSveVLSBuiltinType() const
Determines if this is a sizeless type supported by the 'arm_sve_vector_bits' type attribute,...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isExtVectorType() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isMemberPointerType() const
bool isMatrixType() const
EnumDecl * castAsEnumDecl() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isObjectType() const
Determine whether this type is an object type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isPointerOrReferenceType() const
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isFloatingType() const
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool isNullPtrType() const
bool isRecordType() const
bool isObjCRetainableType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a C++ unqualified-id that has been parsed.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
const IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId,...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
The iterator over UnresolvedSets.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
VarDecl * getPotentiallyDecomposedVarDecl()
Represents a variable declaration or definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
Represents a GCC generic vector type.
bool isTypeConstraint() const
TemplateParameterList * getTypeConstraintTemplateParameterList() const
bool isSubstitutionFailure() const
A requires-expression requirement which queries the validity and properties of an expression ('simple...
@ SS_ConstraintsNotSatisfied
@ SS_TypeRequirementSubstitutionFailure
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
ImplicitCaptureStyle ImpCaptureStyle
Capture & getCXXThisCapture()
Retrieve the capture of C++ 'this', if it has been captured.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, bool ByCopy)
SourceLocation PotentialThisCaptureLocation
bool hasPotentialThisCapture() const
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
bool lambdaCaptureShouldBeConst() const
void clearPotentialCaptures()
bool hasPotentialCaptures() const
bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const
CXXRecordDecl * Lambda
The class that describes the lambda.
void visitPotentialCaptures(llvm::function_ref< void(ValueDecl *, Expr *)> Callback) const
unsigned NumExplicitCaptures
The number of captures in the Captures list that are explicit captures.
bool AfterParameterList
Indicate that we parsed the parameter list at which point the mutability of the lambda is known.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
bool NE(InterpState &S, CodePtr OpPC)
ComparisonCategoryResult Compare(const T &X, const T &Y)
Helper to compare two comparable types.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
bool isLambdaCallWithImplicitObjectParameter(const DeclContext *DC)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
CanThrowResult
Possible results from evaluation of a noexcept expression.
AllocationFunctionScope
The scope in which to find allocation functions.
@ Both
Look for allocation functions in both the global scope and in the scope of the allocated class.
@ Global
Only look for allocation functions in the global scope.
@ Class
Only look for allocation functions in the scope of the allocated class.
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
AlignedAllocationMode alignedAllocationModeFromBool(bool IsAligned)
@ Conditional
A conditional (?:) operator.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
UnsignedOrNone getStackIndexOfNearestEnclosingCaptureCapableLambda(ArrayRef< const sema::FunctionScopeInfo * > FunctionScopes, ValueDecl *VarToCapture, Sema &S)
Examines the FunctionScopeInfo stack to determine the nearest enclosing lambda (to the current lambda...
@ LCK_StarThis
Capturing the *this object by copy.
@ Bind
'bind' clause, allowed on routine constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
bool isLambdaCallWithExplicitObjectParameter(const DeclContext *DC)
bool isAlignedAllocation(AlignedAllocationMode Mode)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Floating_Promotion
Floating point promotions (C++ [conv.fpprom])
@ ICK_Boolean_Conversion
Boolean conversions (C++ [conv.bool])
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Fixed_Point_Conversion
Fixed point type conversions according to N1169.
@ ICK_Vector_Conversion
Vector conversions.
@ ICK_Block_Pointer_Conversion
Block Pointer conversions.
@ ICK_Pointer_Member
Pointer-to-member conversions (C++ [conv.mem])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_SVE_Vector_Conversion
Arm SVE Vector conversions.
@ ICK_HLSL_Vector_Truncation
HLSL vector truncation.
@ ICK_Incompatible_Pointer_Conversion
C-only conversion between pointers with incompatible types.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_RVV_Vector_Conversion
RISC-V RVV Vector conversions.
@ ICK_Complex_Promotion
Complex promotions (Clang extension)
@ ICK_Num_Conversion_Kinds
The number of conversion kinds.
@ ICK_Function_Conversion
Function pointer conversion (C++17 [conv.fctptr])
@ ICK_Vector_Splat
A vector splat from an arithmetic type.
@ ICK_Zero_Queue_Conversion
Zero constant to queue.
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Derived_To_Base
Derived-to-base (C++ [over.best.ics])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Qualification
Qualification conversions (C++ [conv.qual])
@ ICK_Pointer_Conversion
Pointer conversions (C++ [conv.ptr])
@ ICK_TransparentUnionConversion
Transparent Union Conversions.
@ ICK_Integral_Promotion
Integral promotions (C++ [conv.prom])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Compatible_Conversion
Conversions between compatible types in C99.
@ ICK_C_Only_Conversion
Conversions allowed in C, but not C++.
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
@ ICK_Zero_Event_Conversion
Zero constant to event (OpenCL1.2 6.12.10)
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
@ Template
We are parsing a template declaration.
llvm::VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS)
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
@ Compatible
Compatible - the types are compatible according to the standard.
@ NotStartsWithUnderscore
@ Class
The "class" keyword.
bool isTypeAwareAllocation(TypeAwareAllocationMode Mode)
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
SizedDeallocationMode sizedDeallocationModeFromBool(bool IsSized)
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
const FunctionProtoType * T
bool isSizedDeallocation(SizedDeallocationMode Mode)
IfExistsResult
Describes the result of an "if-exists" condition check.
@ Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
@ Exists
The symbol exists.
@ Error
An error occurred.
@ DoesNotExist
The symbol does not exist.
@ TPOC_Call
Partial ordering of function templates for a function call.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ Generic
not a target-specific vector type
@ ArrayBound
Array bound in array declarator or new-expression.
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
@ Other
Other implicit parameter.
CXXNewInitializationStyle
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ None
New-expression has no initializer as written.
@ Braces
New-expression has a C++11 list-initializer.
@ EST_BasicNoexcept
noexcept
@ EST_Dynamic
throw(T1, T2)
CheckedConversionKind
The kind of conversion being performed.
@ CStyleCast
A C-style cast.
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
@ FunctionalCast
A functional-style cast.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
MutableArrayRef< Expr * > MultiExprArg
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
static ASTConstraintSatisfaction * Rebuild(const ASTContext &C, const ASTConstraintSatisfaction &Satisfaction)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
unsigned hasStatic
True if this dimension included the 'static' keyword.
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
One instance of this struct is used for each type in a declarator that is parsed.
SourceLocation Loc
Loc - The place where this type was defined.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
unsigned CFIUncheckedCallee
FunctionType::ExtInfo ExtInfo
AlignedAllocationMode PassAlignment
TypeAwareAllocationMode PassTypeIdentity
unsigned getNumImplicitArgs() const
TypeAwareAllocationMode PassTypeIdentity
SizedDeallocationMode PassSize
AlignedAllocationMode PassAlignment
Parts of a decomposed MSGuidDecl.
NestedNameSpecifierLoc Prefix
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ....
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...