49#include "llvm/ADT/APInt.h"
50#include "llvm/ADT/STLExtras.h"
51#include "llvm/ADT/StringExtras.h"
52#include "llvm/Support/ErrorHandling.h"
53#include "llvm/Support/TypeSize.h"
63 if ([[maybe_unused]]
const auto *DNT = dyn_cast<DependentNameType>(
Type))
64 assert(DNT->getIdentifier() == &Name &&
"not a constructor name");
77 "not a constructor name");
99 auto *RD = dyn_cast<CXXRecordDecl>(ND);
100 if (RD && RD->isInjectedClassName()) {
101 InjectedClassName = RD;
105 if (!InjectedClassName) {
110 diag::err_incomplete_nested_name_spec) << CurClass << SS.
getRange();
116 InjectedClassName,
false);
123 bool EnteringContext) {
169 auto IsAcceptableResult = [&](
NamedDecl *D) ->
bool {
170 auto *
Type = dyn_cast<TypeDecl>(D->getUnderlyingDecl());
178 return Context.hasSameUnqualifiedType(
T, SearchType);
181 unsigned NumAcceptableResults = 0;
183 if (IsAcceptableResult(D))
184 ++NumAcceptableResults;
189 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
190 if (RD->isInjectedClassName())
193 if (FoundDeclSet.insert(D).second)
194 FoundDecls.push_back(D);
202 if (
Found.isAmbiguous() && NumAcceptableResults == 1) {
203 Diag(NameLoc, diag::ext_dtor_name_ambiguous);
214 if (!IsAcceptableResult(D))
220 if (
Found.isAmbiguous())
224 if (IsAcceptableResult(
Type)) {
229 Context.getTrivialTypeSourceInfo(
T, NameLoc));
236 bool IsDependent =
false;
238 auto LookupInObjectType = [&]() ->
ParsedType {
239 if (Failed || SearchType.
isNull())
249 return CheckLookupResult(
Found);
267 return CheckLookupResult(
Found);
276 return CheckLookupResult(
Found);
319 return TL.getPrefix();
330 PrefixSS.
Adopt(Prefix);
331 if (
ParsedType T = LookupInNestedNameSpec(PrefixSS))
365 unsigned NumNonExtensionDecls = FoundDecls.size();
389 Diag(SS.
getEndLoc(), diag::ext_qualified_dtor_named_in_lexical_scope)
391 Diag(FoundDecls.back()->getLocation(), diag::note_destructor_type_here)
402 FoundDecls.resize(NumNonExtensionDecls);
411 auto MakeFixItHint = [&]{
417 Destroyed = dyn_cast_or_null<CXXRecordDecl>(S->
getEntity());
420 Destroyed->getNameAsString());
424 if (FoundDecls.empty()) {
426 Diag(NameLoc, diag::err_undeclared_destructor_name)
427 << &II << MakeFixItHint();
428 }
else if (!SearchType.
isNull() && FoundDecls.size() == 1) {
429 if (
auto *TD = dyn_cast<TypeDecl>(FoundDecls[0]->getUnderlyingDecl())) {
430 assert(!SearchType.
isNull() &&
431 "should only reject a type result if we have a search type");
432 Diag(NameLoc, diag::err_destructor_expr_type_mismatch)
435 << SearchType << MakeFixItHint();
437 Diag(NameLoc, diag::err_destructor_expr_nontype)
438 << &II << MakeFixItHint();
441 Diag(NameLoc, SearchType.
isNull() ? diag::err_destructor_name_nontype
442 : diag::err_destructor_expr_mismatch)
443 << &II << SearchType << MakeFixItHint();
447 if (
auto *TD = dyn_cast<TypeDecl>(FoundD->getUnderlyingDecl()))
448 Diag(FoundD->getLocation(), diag::note_destructor_type_here)
452 Diag(FoundD->getLocation(), diag::note_destructor_nontype_here)
470 "unexpected type in getDestructorType");
477 !
Context.hasSameUnqualifiedType(
T, SearchType)) {
504 (StringRef(
"operator\"\"") + II->
getName()).str());
513 Diag(Loc, diag::warn_deprecated_literal_operator_id) << II << Hint;
516 Diag(Loc, diag::warn_reserved_extern_symbol)
517 << II << static_cast<int>(Status) << Hint;
526 Diag(Name.
getBeginLoc(), diag::err_literal_operator_id_outside_namespace)
537 llvm_unreachable(
"unknown nested name specifier kind");
551 =
Context.getUnqualifiedArrayType(Operand->getType().getNonReferenceType(),
553 if (
T->isRecordType() &&
557 if (
T->isVariablyModifiedType())
558 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid) <<
T);
571 bool WasEvaluated =
false;
580 if (
auto *RecordD =
T->getAsCXXRecordDecl()) {
591 if (RecordD->isPolymorphic() && E->
isGLValue()) {
619 if (!
Context.hasSameType(
T, UnqualT)) {
626 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid)
633 ? diag::warn_side_effects_typeid
634 : diag::warn_side_effects_unevaluated_context);
647 return ExprError(
Diag(OpLoc, diag::err_openclcxx_not_supported)
653 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid)
669 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid)
674 return ExprError(
Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
688 TInfo =
Context.getTrivialTypeSourceInfo(
T, OpLoc);
698 if (
auto *CTE = dyn_cast<CXXTypeidExpr>(
Result.get()))
699 if (CTE->isPotentiallyEvaluated() && !CTE->isMostDerived(
Context))
700 Diag(OpLoc, diag::warn_no_typeid_with_rtti_disabled)
722 if (
const auto *Uuid = TD->getMostRecentDecl()->getAttr<UuidAttr>()) {
723 UuidAttrs.insert(Uuid);
728 if (
const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(TD)) {
731 const UuidAttr *UuidForTA =
nullptr;
738 UuidAttrs.insert(UuidForTA);
748 if (!Operand->getType()->isDependentType()) {
751 if (UuidAttrs.empty())
752 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
753 if (UuidAttrs.size() > 1)
754 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
755 Guid = UuidAttrs.back()->getGuidDecl();
772 if (UuidAttrs.empty())
773 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
774 if (UuidAttrs.size() > 1)
775 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
776 Guid = UuidAttrs.back()->getGuidDecl();
800 TInfo =
Context.getTrivialTypeSourceInfo(
T, OpLoc);
811 assert((Kind == tok::kw_true || Kind == tok::kw_false) &&
812 "Unknown C++ Boolean value!");
824 bool IsThrownVarInScope =
false;
837 if (
const auto *DRE = dyn_cast<DeclRefExpr>(Ex->
IgnoreParens()))
838 if (
const auto *Var = dyn_cast<VarDecl>(DRE->getDecl());
839 Var && Var->hasLocalStorage() &&
840 !Var->getType().isVolatileQualified()) {
843 IsThrownVarInScope =
true;
860 bool IsThrownVarInScope) {
861 const llvm::Triple &
T =
Context.getTargetInfo().getTriple();
862 const bool IsOpenMPGPUTarget =
868 if (IsOpenMPGPUTarget)
869 targetDiag(OpLoc, diag::warn_throw_not_valid_on_target) <<
T.str();
877 Diag(OpLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"throw";
882 Diag(OpLoc, diag::err_acc_branch_in_out_compute_construct)
917 if (Ex &&
Context.getTargetInfo().getTriple().isPPC64())
926 llvm::DenseMap<CXXRecordDecl *, unsigned> &SubobjectsSeen,
927 llvm::SmallPtrSetImpl<CXXRecordDecl *> &VBases,
928 llvm::SetVector<CXXRecordDecl *> &PublicSubobjectsSeen,
929 bool ParentIsPublic) {
931 CXXRecordDecl *BaseDecl = BS.getType()->getAsCXXRecordDecl();
936 NewSubobject = VBases.insert(BaseDecl).second;
941 ++SubobjectsSeen[BaseDecl];
944 bool PublicPath = ParentIsPublic && BS.getAccessSpecifier() ==
AS_public;
946 PublicSubobjectsSeen.insert(BaseDecl);
956 llvm::DenseMap<CXXRecordDecl *, unsigned> SubobjectsSeen;
958 llvm::SetVector<CXXRecordDecl *> PublicSubobjectsSeen;
959 SubobjectsSeen[RD] = 1;
960 PublicSubobjectsSeen.insert(RD);
964 for (
CXXRecordDecl *PublicSubobject : PublicSubobjectsSeen) {
966 if (SubobjectsSeen[PublicSubobject] > 1)
969 Objects.push_back(PublicSubobject);
978 bool isPointer =
false;
980 Ty = Ptr->getPointeeType();
998 isPointer ? diag::err_throw_incomplete_ptr
999 : diag::err_throw_incomplete,
1009 diag::err_throw_abstract_type, E))
1031 PDiag(diag::err_access_dtor_exception) << Ty);
1040 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
1047 for (
CXXRecordDecl *Subobject : UnambiguousPublicSubobjects) {
1070 Context.addCopyConstructorForExceptionObject(Subobject, CD);
1083 if (
Context.getTargetInfo().getCXXABI().isItaniumFamily()) {
1086 if (ExnObjAlign < TypeAlign) {
1087 Diag(ThrowLoc, diag::warn_throw_underaligned_obj);
1088 Diag(ThrowLoc, diag::note_throw_underaligned_obj)
1093 if (!isPointer &&
getLangOpts().AssumeNothrowExceptionDtor) {
1095 auto Ty = Dtor->getType();
1099 Diag(ThrowLoc, diag::err_throw_object_throwing_dtor) << RD;
1151 for (
int I = FunctionScopes.size();
1163 if (
C.isCopyCapture()) {
1175 "While computing 'this' capture-type for a generic lambda, when we "
1176 "run out of enclosing LSI's, yet the enclosing DC is a "
1177 "lambda-call-operator we must be (i.e. Current LSI) in a generic "
1178 "lambda call oeprator");
1181 auto IsThisCaptured =
1186 if (
C.capturesThis()) {
1197 bool IsByCopyCapture =
false;
1198 bool IsConstCapture =
false;
1201 IsThisCaptured(Closure, IsByCopyCapture, IsConstCapture)) {
1202 if (IsByCopyCapture) {
1220 if (method && method->isImplicitObjectMemberFunction())
1221 ThisTy = method->getThisType().getNonReferenceType();
1233 ThisTy =
Context.getPointerType(ClassTy);
1251 if (!Enabled || !ContextDecl)
1265 T = S.getASTContext().getQualifiedType(
T, CXXThisTypeQuals);
1267 S.CXXThisTypeOverride =
1268 S.Context.getLangOpts().HLSL ?
T : S.Context.getPointerType(
T);
1270 this->Enabled =
true;
1276 S.CXXThisTypeOverride = OldCXXThisTypeOverride;
1287 Sema.
Diag(DiagLoc, diag::note_lambda_this_capture_fixit)
1293 bool BuildAndDiagnose,
const unsigned *
const FunctionScopeIndexToStopAt,
1294 const bool ByCopy) {
1299 assert((!ByCopy ||
Explicit) &&
"cannot implicitly capture *this by value");
1301 const int MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
1302 ? *FunctionScopeIndexToStopAt
1328 unsigned NumCapturingClosures = 0;
1329 for (
int idx = MaxFunctionScopesIndex; idx >= 0; idx--) {
1332 if (CSI->CXXThisCaptureIndex != 0) {
1334 CSI->Captures[CSI->CXXThisCaptureIndex - 1].markUsed(BuildAndDiagnose);
1340 if (BuildAndDiagnose) {
1342 Diag(Loc, diag::err_this_capture)
1343 << (
Explicit && idx == MaxFunctionScopesIndex);
1353 (
Explicit && idx == MaxFunctionScopesIndex)) {
1359 NumCapturingClosures++;
1363 if (BuildAndDiagnose) {
1365 Diag(Loc, diag::err_this_capture)
1366 << (
Explicit && idx == MaxFunctionScopesIndex);
1374 if (!BuildAndDiagnose)
return false;
1387 "Only a lambda can capture the enclosing object (referred to by "
1390 for (
int idx = MaxFunctionScopesIndex; NumCapturingClosures;
1391 --idx, --NumCapturingClosures) {
1398 bool isNested = NumCapturingClosures > 1;
1432 const auto *
Method = dyn_cast<CXXMethodDecl>(DC);
1433 if (
Method &&
Method->isExplicitObjectMemberFunction()) {
1434 Diag(Loc, diag::err_invalid_this_use) << 1;
1436 Diag(Loc, diag::err_invalid_this_use) << 1;
1438 Diag(Loc, diag::err_invalid_this_use) << 0;
1452 if (
This->isTypeDependent())
1457 auto IsDependent = [&]() {
1459 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
1463 if (LSI->Lambda && !LSI->Lambda->Encloses(
CurContext) &&
1464 LSI->AfterParameterList)
1471 if (LSI->isCXXThisCaptured()) {
1472 if (!LSI->getCXXThisCapture().isCopyCapture())
1475 const auto *MD = LSI->CallOperator;
1476 if (MD->getType().isNull())
1480 return Ty && MD->isExplicitObjectMemberFunction() &&
1487 This->setCapturedByCopyInLambdaWithExplicitObjectParameter(IsDependent);
1510 bool ListInitialization) {
1520 RParenOrBraceLoc, ListInitialization);
1523 RParenOrBraceLoc, exprs, Ty);
1532 bool ListInitialization) {
1541 ? ListInitialization
1543 TyBeginLoc, LParenOrBraceLoc, RParenOrBraceLoc)
1565 if (ListInitialization) {
1570 if (Ty->
getAs<AutoType>())
1571 DiagCompat(TyBeginLoc, diag_compat::auto_expr) << FullRange;
1574 return ExprError(
Diag(TyBeginLoc, diag::err_auto_expr_init_no_expression)
1575 << Ty << FullRange);
1576 if (
Inits.size() > 1) {
1579 diag::err_auto_expr_init_multiple_expressions)
1580 << Ty << FullRange);
1586 << ListInitialization << Ty << FullRange);
1593 return ExprError(
Diag(TyBeginLoc, diag::err_auto_expr_deduction_failure)
1594 << Ty << Deduce->
getType() << FullRange
1596 if (DeducedType.
isNull()) {
1608 RParenOrBraceLoc, ListInitialization);
1614 if (Exprs.size() == 1 && !ListInitialization &&
1616 Expr *Arg = Exprs[0];
1624 if (!ListInitialization)
1625 return ExprError(
Diag(TyBeginLoc, diag::err_value_init_for_array_type)
1627 ElemTy =
Context.getBaseElementType(Ty);
1635 return ExprError(
Diag(TyBeginLoc, diag::err_init_for_function_type)
1636 << Ty << FullRange);
1645 if (ListInitialization &&
1650 Exprs[0]->getBeginLoc(), Exprs[0]->getEndLoc());
1653 diag::err_invalid_incomplete_type_use,
1667 Inner = BTE->getSubExpr();
1668 if (
auto *CE = dyn_cast<ConstantExpr>(Inner);
1669 CE && CE->isImmediateInvocation())
1670 Inner = CE->getSubExpr();
1688 bool IsListInit = ListInitialization ||
1692 :
SourceRange(LParenOrBraceLoc, RParenOrBraceLoc);
1713 Method->getDeclContext()->lookup(
Method->getDeclName());
1714 for (
const auto *D : R) {
1715 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1725 bool Result =
Method->isUsualDeallocationFunction(PreventedBy);
1732 return llvm::none_of(PreventedBy, [&](
const FunctionDecl *FD) {
1734 "Only single-operand functions should be in PreventedBy");
1752 unsigned UsualParams = 1;
1753 if (S.
getLangOpts().SizedDeallocation && UsualParams < FD->getNumParams() &&
1759 if (S.
getLangOpts().AlignedAllocation && UsualParams < FD->getNumParams() &&
1769 struct UsualDeallocFnInfo {
1770 UsualDeallocFnInfo()
1773 UsualDeallocFnInfo(Sema &S, DeclAccessPair
Found, QualType AllocType,
1775 :
Found(
Found), FD(dyn_cast<FunctionDecl>(
Found->getUnderlyingDecl())),
1777 IDP({AllocType, TypeAwareAllocationMode::No,
1778 AlignedAllocationMode::No, SizedDeallocationMode::No}),
1783 if (AllocType.isNull())
1785 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Found->getUnderlyingDecl());
1788 FunctionDecl *InstantiatedDecl =
1789 S.BuildTypeAwareUsualDelete(FTD, AllocType, Loc);
1790 if (!InstantiatedDecl)
1792 FD = InstantiatedDecl;
1794 unsigned NumBaseParams = 1;
1795 if (FD->isTypeAwareOperatorNewOrDelete()) {
1801 if (AllocType.isNull()) {
1805 QualType TypeIdentityTag = FD->getParamDecl(0)->getType();
1806 QualType ExpectedTypeIdentityTag =
1807 S.tryBuildStdTypeIdentity(AllocType, Loc);
1808 if (ExpectedTypeIdentityTag.
isNull()) {
1812 if (!S.Context.hasSameType(TypeIdentityTag, ExpectedTypeIdentityTag)) {
1816 IDP.PassTypeIdentity = TypeAwareAllocationMode::Yes;
1820 if (FD->isDestroyingOperatorDelete()) {
1825 if (NumBaseParams < FD->getNumParams() &&
1826 S.Context.hasSameUnqualifiedType(
1827 FD->getParamDecl(NumBaseParams)->getType(),
1828 S.Context.getSizeType())) {
1830 IDP.PassSize = SizedDeallocationMode::Yes;
1833 if (NumBaseParams < FD->getNumParams() &&
1834 FD->getParamDecl(NumBaseParams)->getType()->isAlignValT()) {
1836 IDP.PassAlignment = AlignedAllocationMode::Yes;
1840 if (S.getLangOpts().CUDA)
1841 CUDAPref = S.CUDA().IdentifyPreference(
1842 S.getCurFunctionDecl(
true), FD);
1845 explicit operator bool()
const {
return FD; }
1848 ImplicitDeallocationParameters TargetIDP)
const {
1855 if (Destroying !=
Other.Destroying)
1856 return Destroying ? 1 : -1;
1858 const ImplicitDeallocationParameters &OtherIDP =
Other.IDP;
1868 return IDP.PassAlignment == TargetIDP.
PassAlignment ? 1 : -1;
1870 if (IDP.PassSize != OtherIDP.
PassSize)
1871 return IDP.PassSize == TargetIDP.
PassSize ? 1 : -1;
1876 FunctionTemplateDecl *PrimaryTemplate = FD->getPrimaryTemplate();
1877 FunctionTemplateDecl *OtherPrimaryTemplate =
1878 Other.FD->getPrimaryTemplate();
1879 if ((!PrimaryTemplate) != (!OtherPrimaryTemplate))
1880 return OtherPrimaryTemplate ? 1 : -1;
1882 if (PrimaryTemplate && OtherPrimaryTemplate) {
1883 const auto *DC = dyn_cast<CXXRecordDecl>(
Found->getDeclContext());
1884 const auto *OtherDC =
1885 dyn_cast<CXXRecordDecl>(
Other.Found->getDeclContext());
1886 unsigned ImplicitArgCount = Destroying + IDP.getNumImplicitArgs();
1888 PrimaryTemplate, OtherPrimaryTemplate, SourceLocation(),
1893 return Best == PrimaryTemplate ? 1 : -1;
1899 if (CUDAPref >
Other.CUDAPref)
1901 if (CUDAPref ==
Other.CUDAPref)
1906 DeclAccessPair
Found;
1909 ImplicitDeallocationParameters IDP;
1929 QualType SelectedTypeIdentityParameter =
1932 diag::err_incomplete_type))
1940 S.
Diag(StartLoc, diag::err_deleted_function_use)
1941 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
1958 UsualDeallocFnInfo Best;
1959 for (
auto I = R.begin(), E = R.end(); I != E; ++I) {
1960 UsualDeallocFnInfo Info(S, I.getPair(), IDP.
Type, Loc);
1971 BestFns->push_back(Info);
1974 int ComparisonResult = Best.Compare(S, Info, IDP);
1975 if (ComparisonResult > 0)
1980 if (BestFns && ComparisonResult < 0)
1985 BestFns->push_back(Info);
1998 const auto *record =
2000 if (!record)
return false;
2013 if (ops.
empty())
return false;
2023 allocType, PassType,
2035 std::optional<Expr *> ArraySize;
2061 if (
Expr *NumElts = Array.NumElts) {
2062 if (!NumElts->isTypeDependent() && !NumElts->isValueDependent()) {
2076 NumElts,
nullptr, diag::err_new_array_nonconst,
2094 DirectInitRange = List->getSourceRange();
2097 PlacementLParen, PlacementArgs, PlacementRParen,
2098 TypeIdParens, AllocType, TInfo, ArraySize, DirectInitRange,
2107 return IsCPlusPlus20 || PLE->getNumExprs() == 0;
2111 return !CCE->isListInitialization() &&
2112 CCE->getConstructor()->isDefaultConstructor();
2115 "Shouldn't create list CXXConstructExprs for arrays.");
2140 StringRef OSName = AvailabilityAttr::getPlatformNameSourceSpelling(
2145 Diag(Loc, diag::err_aligned_allocation_unavailable)
2147 << OSVersion.getAsString() << OSVersion.empty();
2148 Diag(Loc, diag::note_silence_aligned_allocation_unavailable);
2158 std::optional<Expr *> ArraySize,
2164 if (DirectInitRange.
isValid()) {
2165 assert(
Initializer &&
"Have parens but no initializer.");
2167 }
else if (isa_and_nonnull<InitListExpr>(
Initializer))
2172 "Initializer expression that cannot have been implicitly created.");
2179 "paren init for non-call init");
2180 Exprs =
MultiExprArg(List->getExprs(), List->getNumExprs());
2181 }
else if (
auto *List = dyn_cast_or_null<CXXParenListInitExpr>(
Initializer)) {
2183 "paren init for non-call init");
2184 Exprs = List->getInitExprs();
2191 switch (InitStyle) {
2202 DirectInitRange.
getEnd());
2208 llvm_unreachable(
"Unknown initialization kind");
2217 Diag(*ArraySize ? (*ArraySize)->getExprLoc() : TypeRange.
getBegin(),
2218 diag::err_deduced_class_template_compound_type)
2220 << (*ArraySize ? (*ArraySize)->getSourceRange() : TypeRange));
2225 AllocTypeInfo, Entity, Kind, Exprs);
2237 return ExprError(
Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
2238 << AllocType << TypeRange);
2239 if (
Inits.size() > 1) {
2242 diag::err_auto_new_ctor_multiple_expressions)
2243 << AllocType << TypeRange);
2247 << AllocType << TypeRange;
2252 << Braced << AllocType << TypeRange);
2259 return ExprError(
Diag(StartLoc, diag::err_auto_new_deduction_failure)
2260 << AllocType << Deduce->
getType() << TypeRange
2262 if (DeducedType.
isNull()) {
2266 AllocType = DeducedType;
2274 =
Context.getAsConstantArrayType(AllocType)) {
2278 AllocType = Array->getElementType();
2292 AllocType =
Context.getLifetimeQualifiedType(AllocType,
2298 if (ArraySize && *ArraySize &&
2299 (*ArraySize)->getType()->isNonOverloadPlaceholderType()) {
2302 ArraySize = result.
get();
2311 std::optional<uint64_t> KnownArraySize;
2312 if (ArraySize && *ArraySize && !(*ArraySize)->isTypeDependent()) {
2315 assert(
Context.getTargetInfo().getIntWidth() &&
"Builtin type of size 0?");
2320 if (!ConvertedSize.
isInvalid() && (*ArraySize)->getType()->isRecordType())
2322 Diag(StartLoc, diag::compat_cxx11_array_size_conversion)
2323 << (*ArraySize)->getType() << 0 <<
"'size_t'";
2330 SizeConvertDiagnoser(
Expr *ArraySize)
2332 ArraySize(ArraySize) {}
2336 return S.
Diag(Loc, diag::err_array_size_not_integral)
2342 return S.
Diag(Loc, diag::err_array_size_incomplete_type)
2348 return S.
Diag(Loc, diag::err_array_size_explicit_conversion) <<
T << ConvTy;
2359 return S.
Diag(Loc, diag::err_array_size_ambiguous_conversion) <<
T;
2371 return S.
DiagCompat(Loc, diag_compat::array_size_conversion)
2374 } SizeDiagnoser(*ArraySize);
2382 ArraySize = ConvertedSize.
get();
2383 QualType SizeType = (*ArraySize)->getType();
2401 if (std::optional<llvm::APSInt>
Value =
2402 (*ArraySize)->getIntegerConstantExpr(
Context)) {
2403 if (
Value->isSigned() &&
Value->isNegative()) {
2405 diag::err_typecheck_negative_array_size)
2406 << (*ArraySize)->getSourceRange());
2410 unsigned ActiveSizeBits =
2414 Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large)
2418 << (*ArraySize)->getSourceRange());
2421 KnownArraySize =
Value->getZExtValue();
2422 }
else if (TypeIdParens.
isValid()) {
2424 Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst)
2425 << (*ArraySize)->getSourceRange()
2439 unsigned Alignment =
2441 unsigned NewAlignment =
Context.getTargetInfo().getNewAlign();
2445 Alignment > NewAlignment)};
2454 AllocationParameterRange =
SourceRange(PlacementLParen, PlacementRParen);
2459 StartLoc, AllocationParameterRange,
Scope,
Scope, AllocType,
2460 ArraySize.has_value(), IAP, PlacementArgs);
2461 if (!FoundAllocation)
2463 IAP = FoundAllocation->IAP;
2464 OperatorNew = FoundAllocation->OperatorNew;
2465 OperatorDelete = FoundAllocation->OperatorDelete;
2466 SelectedAllocationArgs = std::move(FoundAllocation->Arguments);
2470 bool UsualArrayDeleteWantsSize =
false;
2486 unsigned NumImplicitArgs =
2487 SelectedAllocationArgs.size() - PlacementArgs.size();
2489 Proto, NumImplicitArgs, PlacementArgs,
2490 AllPlaceArgs, CallType))
2493 if (!AllPlaceArgs.empty())
2494 PlacementArgs = AllPlaceArgs;
2502 unsigned SizeTyWidth =
Context.getTypeSize(SizeTy);
2504 llvm::APInt SingleEltSize(
2505 SizeTyWidth,
Context.getTypeSizeInChars(AllocType).getQuantity());
2508 std::optional<llvm::APInt> AllocationSize;
2511 AllocationSize = SingleEltSize;
2515 AllocationSize = llvm::APInt(SizeTyWidth, *KnownArraySize)
2516 .umul_ov(SingleEltSize, Overflow);
2520 "Expected that all the overflows would have been handled already.");
2524 Context, AllocationSize.value_or(llvm::APInt::getZero(SizeTyWidth)),
2539 llvm::APInt(
Context.getTypeSize(SizeTy),
2540 Alignment /
Context.getCharWidth()),
2543 CK_IntegralCast, &AlignmentLiteral,
2548 CallArgs.reserve(NumImplicitArgs + PlacementArgs.size());
2549 CallArgs.emplace_back(AllocationSize
2550 ?
static_cast<Expr *
>(&AllocationSizeLiteral)
2551 : &OpaqueAllocationSize);
2553 CallArgs.emplace_back(&DesiredAlignment);
2554 llvm::append_range(CallArgs, PlacementArgs);
2558 checkCall(OperatorNew, Proto,
nullptr, CallArgs,
2559 false, StartLoc, Range, CallType);
2564 (OperatorNew->isImplicit() ||
2565 (OperatorNew->getBeginLoc().isValid() &&
2567 if (Alignment > NewAlignment)
2568 Diag(StartLoc, diag::warn_overaligned_type)
2580 SourceRange InitRange(Exprs.front()->getBeginLoc(),
2581 Exprs.back()->getEndLoc());
2582 Diag(StartLoc, diag::err_new_array_init_args) << InitRange;
2593 InitType =
Context.getConstantArrayType(
2599 InitType =
Context.getIncompleteArrayType(AllocType,
2602 InitType = AllocType;
2604 bool VariableLengthArrayNew = ArraySize && *ArraySize && !KnownArraySize;
2618 dyn_cast_or_null<CXXBindTemporaryExpr>(FullInit.
get()))
2619 FullInit = Binder->getSubExpr();
2626 if (ArraySize && !*ArraySize) {
2634 Diag(TypeRange.
getEnd(), diag::err_new_array_size_unknown_from_init)
2646 if (OperatorDelete) {
2654 if (
Context.getTargetInfo().emitVectorDeletingDtors(
Context.getLangOpts())) {
2661 if (!
Context.classMaybeNeedsVectorDeletingDestructor(ClassDecl)) {
2663 if (Dtor && Dtor->isVirtual() && !Dtor->isDeleted()) {
2664 Context.setClassMaybeNeedsVectorDeletingDestructor(ClassDecl);
2665 if (!Dtor->isDefined() && !Dtor->isInvalidDecl()) {
2680 IAP, UsualArrayDeleteWantsSize, PlacementArgs,
2682 ResultType, AllocTypeInfo, Range, DirectInitRange);
2690 return Diag(Loc, diag::err_bad_new_type)
2691 << AllocType << 0 << R;
2693 return Diag(Loc, diag::err_bad_new_type)
2694 << AllocType << 1 << R;
2697 Loc, AllocType, diag::err_new_incomplete_or_sizeless_type, R))
2700 diag::err_allocation_of_abstract_type))
2703 return Diag(Loc, diag::err_variably_modified_new_type)
2707 return Diag(Loc, diag::err_address_space_qualified_new)
2716 return Diag(Loc, diag::err_arc_new_array_without_ownership)
2727 Expr *AlignArg,
bool IncludedMSVCFallback,
bool AlignedBeforeUnaligned) {
2731 if (!R.isClassLookup() && Args.size() == 2 &&
2732 (Args[1]->getType()->isObjectPointerType() ||
2733 Args[1]->getType()->isArrayType())) {
2734 const QualType Arg1Type = Args[1]->getType();
2739 S.
Diag(Args[1]->getExprLoc(),
2740 diag::err_placement_new_into_const_qualified_storage)
2741 << Arg1Type << Args[1]->getSourceRange();
2744 S.
Diag(R.getNameLoc(), diag::err_need_header_before_placement_new)
2745 << R.getLookupName() << Range;
2759 if (AlignedCandidates) {
2761 const unsigned AlignArgOffset = 1;
2762 return C.Function->getNumParams() > AlignArgOffset &&
2763 C.Function->getParamDecl(AlignArgOffset)->getType()->isAlignValT();
2767 AlignedArgs.reserve(Args.size() + 1);
2768 AlignedArgs.push_back(Args[0]);
2769 AlignedArgs.push_back(AlignArg);
2770 AlignedArgs.append(Args.begin() + 1, Args.end());
2775 R.getNameLoc(), IsUnaligned);
2781 S.
Diag(R.getNameLoc(), diag::err_ovl_no_viable_function_in_call)
2782 << R.getLookupName() << Range;
2783 if (AlignedCandidates && AlignedBeforeUnaligned)
2784 AlignedCandidates->
NoteCandidates(S, AlignedArgs, AlignedCands,
"",
2787 if (AlignedCandidates && !AlignedBeforeUnaligned)
2788 AlignedCandidates->
NoteCandidates(S, AlignedArgs, AlignedCands,
"",
2790 if (IncludedMSVCFallback)
2791 S.
Diag(R.getNameLoc(), diag::note_ovl_ms_allocation_fallback_failed)
2800 std::optional<LookupResult> MSVCFallback;
2805 bool ArgumentListIsTypeAware =
2809 AllocEnd = LocalLookup.
end();
2810 Alloc != AllocEnd; ++Alloc) {
2814 bool CandidateIsTypeAware =
2816 if (CandidateIsTypeAware != ArgumentListIsTypeAware)
2822 TrialArguments, Candidates,
2853 S.
PDiag(diag::err_ovl_ambiguous_call)
2863 Best->Function, TrialArguments);
2867 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
2881 while (Filter.hasNext()) {
2882 FunctionDecl *FD = Filter.next()->getUnderlyingDecl()->getAsFunction();
2897 bool IncludedMSVCFallback =
false;
2898 bool AlignedBeforeUnaligned =
true;
2900 if (AllocationArguments.IsMSVCCompatibilityFallback) {
2901 IncludedMSVCFallback =
true;
2907 AlignedArgumentList = &AllocationArguments;
2908 AlignedBeforeUnaligned = !UnalignedArgumentList;
2910 UnalignedArgumentList = &AllocationArguments;
2913 if (!UnalignedArgumentList)
2924 llvm::append_range(Args, PlacementArguments);
2929 std::optional<OverloadCandidateSet> AlignedCandidates;
2930 Expr *AlignArg =
nullptr;
2931 if (AlignedArgumentList) {
2934 Rerun(*AlignedArgumentList, *AlignedCandidates, AlignedArgs);
2940 Rerun(*UnalignedArgumentList, UnalignedCandidates, UnalignedArgs);
2942 SemaRef, R, Range, UnalignedArgs, UnalignedCandidates,
2943 AlignedCandidates ? &*AlignedCandidates :
nullptr, AlignArg,
2944 IncludedMSVCFallback, AlignedBeforeUnaligned);
2947Expr *Sema::tryGetTypeIdentityArgument(QualType
Type, SourceLocation Loc) {
2948 if (
auto Found = AllocationTypeIdentityArguments.find(
Type);
2949 Found != AllocationTypeIdentityArguments.end())
2950 return Found->second;
2953 if (TypeIdentity.
isNull() ||
2957 Expr *TypeIdentityArgument =
2958 new (
Context) CXXScalarValueInitExpr(TypeIdentity,
nullptr, Loc);
2959 AllocationTypeIdentityArguments.insert({
Type, TypeIdentityArgument});
2960 return TypeIdentityArgument;
2963ImplicitAllocationArguments::ImplicitAllocationArguments(
2964 Sema &
SemaRef, Expr *TypeIdentityArg, Expr *SizeArg, Expr *AlignArg,
2965 bool IsMSVCCompatibilityFallback)
2968 IsMSVCCompatibilityFallback(IsMSVCCompatibilityFallback),
2970 if (TypeIdentityArg) {
2972 ImplicitArguments[ArgumentCount++] = TypeIdentityArg;
2977 ImplicitArguments[ArgumentCount++] = SizeArg;
2980 ImplicitArguments[ArgumentCount++] = AlignArg;
2987 std::optional<LookupResult> &Buffer)
const {
3003std::optional<AllocationArgumentSet>
3011 if (!AllocationSizeExpr) {
3013 QualType SizeTy = Context.getSizeType();
3014 unsigned SizeTyWidth = Context.getTypeSize(SizeTy);
3016 Context, llvm::APInt::getZero(SizeTyWidth), SizeTy,
SourceLocation());
3018 if (!AllocationAlignmentExpr) {
3022 AllocationAlignmentExpr =
new (Context)
3029 Expr *TypeIdentityArgument =
3030 tryGetTypeIdentityArgument(IAP.
Type,
R.getNameLoc());
3031 if (!TypeIdentityArgument)
3032 return std::nullopt;
3034 Expr *AlignmentExpr = AllocationAlignmentExpr;
3035 if (!PlacementArguments.empty() &&
3036 PlacementArguments.front()->getType()->isAlignValT())
3037 AlignmentExpr =
nullptr;
3038 FoundArguments.push_back(ImplicitAllocationArguments(
3039 *
this, TypeIdentityArgument, AllocationSizeExpr, AlignmentExpr,
3043 ImplicitAllocationArguments UnalignedArguments(
3044 *
this,
nullptr, AllocationSizeExpr,
3046 ImplicitAllocationArguments AlignedArguments(
3047 *
this,
nullptr, AllocationSizeExpr,
3048 AllocationAlignmentExpr,
false);
3059 FoundArguments.push_back(AlignedArguments);
3060 FoundArguments.push_back(UnalignedArguments);
3062 AllocationAlignmentExpr &&
getLangOpts().AlignedAllocation)
3063 FoundArguments.push_back(AlignedArguments);
3067 R.getLookupName().getCXXOverloadedOperator() == OO_Array_New)
3068 FoundArguments.push_back(ImplicitAllocationArguments(
3069 *
this,
nullptr, AllocationSizeExpr,
3071 return FoundArguments;
3074std::optional<ResolvedAllocation>
3100 IsArray ? OO_Array_New : OO_New);
3124 if (R.isAmbiguous())
3125 return std::nullopt;
3132 return std::nullopt;
3138 if (PlaceArgs.empty()) {
3139 Diag(StartLoc, diag::err_openclcxx_not_supported) <<
"default new";
3141 Diag(StartLoc, diag::err_openclcxx_placement_new);
3143 return std::nullopt;
3146 assert(!R.empty() &&
"implicitly declared allocation functions not found");
3147 assert(!R.isAmbiguous() &&
"global allocation functions are ambiguous");
3150 R.suppressDiagnostics();
3152 std::optional<AllocationArgumentSet> ArgumentListCandidates =
3153 resolveAllocationArguments(R, RequestedIAP, PlaceArgs);
3154 if (!ArgumentListCandidates)
3155 return std::nullopt;
3159 ArgumentList.getImplicitArguments());
3160 llvm::append_range(TrialArguments, PlaceArgs);
3165 TrialArguments, Operator,
3168 return std::nullopt;
3172 Result.OperatorNew = Operator;
3173 Result.IAP.PassTypeIdentity = ArgumentList.PassTypeIdentity;
3174 Result.IAP.PassAlignment = ArgumentList.PassAlignment;
3175 Result.Arguments = std::move(TrialArguments);
3176 goto foundCandidate;
3182 return std::nullopt;
3194 OperatorNew->getDeclName().getCXXOverloadedOperator() == OO_Array_New
3214 return std::nullopt;
3222 while (Filter.hasNext()) {
3223 auto *FD = dyn_cast<FunctionDecl>(Filter.next()->getUnderlyingDecl());
3224 if (FD && FD->isDestroyingOperatorDelete())
3230 auto GetRedeclContext = [](
Decl *D) {
3231 return D->getDeclContext()->getRedeclContext();
3234 DeclContext *OperatorNewContext = GetRedeclContext(OperatorNew);
3236 bool FoundGlobalDelete = FoundDelete.
empty();
3237 bool IsClassScopedTypeAwareNew =
3240 auto DiagnoseMissingTypeAwareCleanupOperator = [&](
bool IsPlacementOperator) {
3243 Diag(StartLoc, diag::err_mismatching_type_aware_cleanup_deallocator)
3244 << OperatorNew->getDeclName() << IsPlacementOperator << DeleteName;
3245 Diag(OperatorNew->getLocation(), diag::note_type_aware_operator_declared)
3246 << OperatorNew->isTypeAwareOperatorNewOrDelete()
3247 << OperatorNew->getDeclName() << OperatorNewContext;
3250 if (IsClassScopedTypeAwareNew && FoundDelete.
empty()) {
3251 DiagnoseMissingTypeAwareCleanupOperator(
false);
3252 return std::nullopt;
3254 if (FoundDelete.
empty()) {
3258 return std::nullopt;
3287 unsigned NonPlacementNewArgCount = 1;
3289 NonPlacementNewArgCount =
3291 bool isPlacementNew = !PlaceArgs.empty() ||
3292 OperatorNew->param_size() != NonPlacementNewArgCount ||
3293 OperatorNew->isVariadic();
3295 if (isPlacementNew) {
3311 int InitialParamOffset = 0;
3313 ArgTypes.push_back(
Result.Arguments.front()->getType());
3314 InitialParamOffset = 1;
3316 ArgTypes.push_back(
Context.VoidPtrTy);
3317 for (
unsigned I = ArgTypes.size() - InitialParamOffset,
3318 N = Proto->getNumParams();
3320 ArgTypes.push_back(Proto->getParamType(I));
3324 EPI.
Variadic = Proto->isVariadic();
3326 ExpectedFunctionType
3331 DEnd = FoundDelete.
end();
3335 dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) {
3346 ExpectedFunctionType,
3348 ExpectedFunctionType))
3349 Matches.push_back(std::make_pair(D.getPair(), Fn));
3356 DiagnoseMissingTypeAwareCleanupOperator(isPlacementNew);
3357 return std::nullopt;
3374 *
this, FoundDelete, IDP, StartLoc, &BestDeallocFns);
3375 if (Selected && BestDeallocFns.empty())
3376 Matches.push_back(std::make_pair(Selected.Found, Selected.FD));
3380 for (
auto Fn : BestDeallocFns)
3381 Matches.push_back(std::make_pair(Fn.Found, Fn.FD));
3389 if (Matches.size() == 1) {
3390 Result.OperatorDelete = Matches[0].second;
3392 DeclContext *OperatorDeleteContext = GetRedeclContext(OperatorDelete);
3393 bool FoundTypeAwareOperator =
3394 OperatorDelete->isTypeAwareOperatorNewOrDelete() ||
3395 OperatorNew->isTypeAwareOperatorNewOrDelete();
3396 if (
Diagnose && FoundTypeAwareOperator) {
3397 bool MismatchedTypeAwareness =
3398 OperatorDelete->isTypeAwareOperatorNewOrDelete() !=
3399 OperatorNew->isTypeAwareOperatorNewOrDelete();
3400 bool MismatchedContext = OperatorDeleteContext != OperatorNewContext;
3401 if (MismatchedTypeAwareness || MismatchedContext) {
3402 FunctionDecl *Operators[] = {OperatorDelete, OperatorNew};
3403 bool TypeAwareOperatorIndex =
3405 Diag(StartLoc, diag::err_mismatching_type_aware_cleanup_deallocator)
3406 << Operators[TypeAwareOperatorIndex]->
getDeclName()
3408 << Operators[!TypeAwareOperatorIndex]->
getDeclName()
3409 << GetRedeclContext(Operators[TypeAwareOperatorIndex]);
3410 Diag(OperatorNew->getLocation(),
3411 diag::note_type_aware_operator_declared)
3412 << OperatorNew->isTypeAwareOperatorNewOrDelete()
3413 << OperatorNew->getDeclName() << OperatorNewContext;
3414 Diag(OperatorDelete->getLocation(),
3415 diag::note_type_aware_operator_declared)
3416 << OperatorDelete->isTypeAwareOperatorNewOrDelete()
3417 << OperatorDelete->getDeclName() << OperatorDeleteContext;
3429 UsualDeallocFnInfo Info(*
this,
3431 AllocElemType, StartLoc);
3437 if (IsSizedDelete && !FoundGlobalDelete) {
3442 *
this, FoundDelete, SizeTestingIDP, StartLoc);
3443 if (NonSizedDelete &&
3446 IsSizedDelete =
false;
3449 if (IsSizedDelete &&
3454 PlaceArgs.back()->getEndLoc());
3455 Diag(StartLoc, diag::err_placement_new_non_placement_delete) << R;
3456 if (!OperatorDelete->isImplicit())
3457 Diag(OperatorDelete->getLocation(), diag::note_previous_decl)
3464 return std::nullopt;
3466 }
else if (!Matches.empty()) {
3470 Diag(StartLoc, diag::warn_ambiguous_suitable_delete_function_found)
3471 << DeleteName << AllocElemType;
3473 for (
auto &
Match : Matches)
3475 diag::note_member_declared_here) << DeleteName;
3534 &
PP.getIdentifierTable().get(
"bad_alloc"),
nullptr);
3539 if (TheGlobalModuleFragment) {
3550 &
PP.getIdentifierTable().get(
"align_val_t"),
nullptr,
true,
true,
true);
3554 if (TheGlobalModuleFragment) {
3555 AlignValT->setModuleOwnershipKind(
3557 AlignValT->setLocalOwningModule(TheGlobalModuleFragment);
3560 AlignValT->setIntegerType(
Context.getSizeType());
3561 AlignValT->setPromotionType(
Context.getSizeType());
3562 AlignValT->setImplicit(
true);
3582 Params.push_back(Param);
3585 bool HasSizedVariant =
getLangOpts().SizedDeallocation &&
3586 (Kind == OO_Delete || Kind == OO_Array_Delete);
3587 bool HasAlignedVariant =
getLangOpts().AlignedAllocation;
3589 int NumSizeVariants = (HasSizedVariant ? 2 : 1);
3590 int NumAlignVariants = (HasAlignedVariant ? 2 : 1);
3591 for (
int Sized = 0; Sized < NumSizeVariants; ++Sized) {
3593 Params.push_back(
SizeT);
3595 for (
int Aligned = 0; Aligned < NumAlignVariants; ++Aligned) {
3600 Context.DeclarationNames.getCXXOperatorName(Kind), Return, Params);
3608 DeclareGlobalAllocationFunctions(OO_New, VoidPtr,
SizeT);
3609 DeclareGlobalAllocationFunctions(OO_Array_New, VoidPtr,
SizeT);
3610 DeclareGlobalAllocationFunctions(OO_Delete,
Context.VoidTy, VoidPtr);
3611 DeclareGlobalAllocationFunctions(OO_Array_Delete,
Context.VoidTy, VoidPtr);
3614 PopGlobalModuleFragment();
3627 Alloc != AllocEnd; ++Alloc) {
3631 if (
Func->getNumParams() == Params.size()) {
3632 if (std::equal(
Func->param_begin(),
Func->param_end(), Params.begin(),
3634 return Context.hasSameUnqualifiedType(D->getType(),
3640 Func->setVisibleDespiteOwningModule();
3648 Context.getTargetInfo().getDefaultCallingConv());
3652 if (HasBadAllocExceptionSpec) {
3655 assert(
StdBadAlloc &&
"Must have std::bad_alloc declared");
3667 auto CreateAllocationFunctionDecl = [&](
Attr *ExtraAttr) {
3675 Context.getTargetInfo().getTriple().isSPIRV()) {
3676 if (
auto *ATI =
Context.getAuxTargetInfo())
3686 Alloc->setImplicit();
3688 Alloc->setVisibleDespiteOwningModule();
3690 if (HasBadAllocExceptionSpec &&
getLangOpts().NewInfallible &&
3693 ReturnsNonNullAttr::CreateImplicit(
Context, Alloc->getLocation()));
3705 if (TheGlobalModuleFragment) {
3706 Alloc->setModuleOwnershipKind(
3708 Alloc->setLocalOwningModule(TheGlobalModuleFragment);
3711 if (
LangOpts.hasGlobalAllocationFunctionVisibility())
3712 Alloc->addAttr(VisibilityAttr::CreateImplicit(
3714 ? VisibilityAttr::Hidden
3715 :
LangOpts.hasProtectedGlobalAllocationFunctionVisibility()
3716 ? VisibilityAttr::Protected
3717 : VisibilityAttr::Default));
3724 ParamDecls.back()->setImplicit();
3726 Alloc->setParams(ParamDecls);
3728 Alloc->addAttr(ExtraAttr);
3730 Context.getTranslationUnitDecl()->addDecl(Alloc);
3735 CreateAllocationFunctionDecl(
nullptr);
3739 CreateAllocationFunctionDecl(CUDAHostAttr::CreateImplicit(
Context));
3740 CreateAllocationFunctionDecl(CUDADeviceAttr::CreateImplicit(
Context));
3767 assert(
Result.FD &&
"operator delete missing from global scope?");
3781 if (!LookForGlobal) {
3786 return OperatorDelete;
3806 if (
Found.isAmbiguous()) {
3808 Found.suppressDiagnostics();
3812 Found.suppressDiagnostics();
3825 if (Matches.size() == 1) {
3828 Found.getNamingClass(), Matches[0].Found,
3835 if (!Matches.empty()) {
3837 Diag(StartLoc, diag::err_ambiguous_suitable_delete_member_function_found)
3839 for (
auto &
Match : Matches)
3840 Diag(
Match.FD->getLocation(), diag::note_member_declared_here) << Name;
3847 if (!
Found.empty()) {
3849 Diag(StartLoc, diag::err_no_suitable_delete_member_function_found)
3853 Diag(D->getUnderlyingDecl()->getLocation(),
3854 diag::note_member_declared_here) << Name;
3866class MismatchingNewDeleteDetector {
3868 enum MismatchResult {
3874 MemberInitMismatches,
3883 explicit MismatchingNewDeleteDetector(
bool EndOfTU)
3884 : Field(
nullptr), IsArrayForm(
false), EndOfTU(EndOfTU),
3885 HasUndefinedConstructors(
false) {}
3897 MismatchResult analyzeDeleteExpr(
const CXXDeleteExpr *DE);
3902 MismatchResult analyzeField(FieldDecl *Field,
bool DeleteWasArrayForm);
3905 llvm::SmallVector<const CXXNewExpr *, 4> NewExprs;
3912 bool HasUndefinedConstructors;
3916 const CXXNewExpr *getNewExprFromInitListOrExpr(
const Expr *E);
3924 MismatchResult analyzeMemberExpr(
const MemberExpr *ME);
3932 bool hasMatchingVarInit(
const DeclRefExpr *D);
3941 bool hasMatchingNewInCtor(
const CXXConstructorDecl *CD);
3944 bool hasMatchingNewInCtorInit(
const CXXCtorInitializer *CI);
3947 MismatchResult analyzeInClassInitializer();
3951MismatchingNewDeleteDetector::MismatchResult
3952MismatchingNewDeleteDetector::analyzeDeleteExpr(
const CXXDeleteExpr *DE) {
3954 assert(DE &&
"Expected delete-expression");
3957 if (
const MemberExpr *ME = dyn_cast<const MemberExpr>(E)) {
3958 return analyzeMemberExpr(ME);
3959 }
else if (
const DeclRefExpr *D = dyn_cast<const DeclRefExpr>(E)) {
3960 if (!hasMatchingVarInit(D))
3961 return VarInitMismatches;
3967MismatchingNewDeleteDetector::getNewExprFromInitListOrExpr(
const Expr *E) {
3968 assert(E !=
nullptr &&
"Expected a valid initializer expression");
3970 if (
const InitListExpr *ILE = dyn_cast<const InitListExpr>(E)) {
3971 if (ILE->getNumInits() == 1)
3972 E = dyn_cast<const CXXNewExpr>(ILE->getInit(0)->IgnoreParenImpCasts());
3975 return dyn_cast_or_null<const CXXNewExpr>(E);
3978bool MismatchingNewDeleteDetector::hasMatchingNewInCtorInit(
3982 (NE = getNewExprFromInitListOrExpr(CI->
getInit()))) {
3983 if (
NE->isArray() == IsArrayForm)
3986 NewExprs.push_back(NE);
3991bool MismatchingNewDeleteDetector::hasMatchingNewInCtor(
3997 HasUndefinedConstructors =
true;
4001 if (hasMatchingNewInCtorInit(CI))
4007MismatchingNewDeleteDetector::MismatchResult
4008MismatchingNewDeleteDetector::analyzeInClassInitializer() {
4009 assert(Field !=
nullptr &&
"This should be called only for members");
4010 const Expr *InitExpr =
Field->getInClassInitializer();
4012 return EndOfTU ? NoMismatch : AnalyzeLater;
4013 if (
const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
4014 if (
NE->isArray() != IsArrayForm) {
4015 NewExprs.push_back(NE);
4016 return MemberInitMismatches;
4022MismatchingNewDeleteDetector::MismatchResult
4023MismatchingNewDeleteDetector::analyzeField(
FieldDecl *Field,
4024 bool DeleteWasArrayForm) {
4025 assert(Field !=
nullptr &&
"Analysis requires a valid class member.");
4027 IsArrayForm = DeleteWasArrayForm;
4029 for (
const auto *CD : RD->
ctors()) {
4030 if (hasMatchingNewInCtor(CD))
4033 if (HasUndefinedConstructors)
4034 return EndOfTU ? NoMismatch : AnalyzeLater;
4035 if (!NewExprs.empty())
4036 return MemberInitMismatches;
4037 return Field->hasInClassInitializer() ? analyzeInClassInitializer()
4041MismatchingNewDeleteDetector::MismatchResult
4042MismatchingNewDeleteDetector::analyzeMemberExpr(
const MemberExpr *ME) {
4043 assert(ME !=
nullptr &&
"Expected a member expression");
4045 return analyzeField(F, IsArrayForm);
4049bool MismatchingNewDeleteDetector::hasMatchingVarInit(
const DeclRefExpr *D) {
4052 if (VD->hasInit() && (NE = getNewExprFromInitListOrExpr(VD->getInit())) &&
4053 NE->isArray() != IsArrayForm) {
4054 NewExprs.push_back(NE);
4057 return NewExprs.empty();
4062 const MismatchingNewDeleteDetector &Detector) {
4065 if (!Detector.IsArrayForm)
4074 SemaRef.
Diag(DeleteLoc, diag::warn_mismatched_delete_new)
4075 << Detector.IsArrayForm << H;
4077 for (
const auto *NE : Detector.NewExprs)
4078 SemaRef.
Diag(NE->getExprLoc(), diag::note_allocated_here)
4079 << Detector.IsArrayForm;
4082void Sema::AnalyzeDeleteExprMismatch(
const CXXDeleteExpr *DE) {
4083 if (
Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation()))
4085 MismatchingNewDeleteDetector Detector(
false);
4086 switch (Detector.analyzeDeleteExpr(DE)) {
4087 case MismatchingNewDeleteDetector::VarInitMismatches:
4088 case MismatchingNewDeleteDetector::MemberInitMismatches: {
4092 case MismatchingNewDeleteDetector::AnalyzeLater: {
4097 case MismatchingNewDeleteDetector::NoMismatch:
4103 bool DeleteWasArrayForm) {
4104 MismatchingNewDeleteDetector Detector(
true);
4105 switch (Detector.analyzeField(Field, DeleteWasArrayForm)) {
4106 case MismatchingNewDeleteDetector::VarInitMismatches:
4107 llvm_unreachable(
"This analysis should have been done for class members.");
4108 case MismatchingNewDeleteDetector::AnalyzeLater:
4109 llvm_unreachable(
"Analysis cannot be postponed any point beyond end of "
4110 "translation unit.");
4111 case MismatchingNewDeleteDetector::MemberInitMismatches:
4114 case MismatchingNewDeleteDetector::NoMismatch:
4121 bool ArrayForm,
Expr *ExE) {
4131 bool ArrayFormAsWritten = ArrayForm;
4132 bool UsualArrayDeleteWantsSize =
false;
4150 if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType())
4157 return S.
Diag(Loc, diag::err_delete_operand) <<
T;
4162 return S.
Diag(Loc, diag::err_delete_incomplete_class_type) <<
T;
4168 return S.
Diag(Loc, diag::err_delete_explicit_conversion) <<
T << ConvTy;
4179 return S.
Diag(Loc, diag::err_ambiguous_delete_operand) <<
T;
4191 llvm_unreachable(
"conversion functions are permitted");
4199 if (!Converter.match(
Type))
4210 diag::err_address_space_qualified_delete)
4220 Diag(StartLoc,
LangOpts.CPlusPlus26 ? diag::err_delete_incomplete
4221 : diag::ext_delete_void_ptr_operand)
4234 ? diag::err_delete_incomplete
4235 : diag::warn_delete_incomplete,
4242 Diag(StartLoc, diag::warn_delete_array_type)
4249 ArrayForm ? OO_Array_Delete : OO_Delete);
4257 OperatorDelete, IDP))
4271 else if (isa_and_nonnull<CXXMethodDecl>(OperatorDelete)) {
4272 UsualDeallocFnInfo UDFI(
4281 if (Dtor->isCalledByDelete(OperatorDelete)) {
4294 if (!OperatorDelete || !OperatorDelete->isDestroyingOperatorDelete())
4301 if (!OperatorDelete) {
4303 Diag(StartLoc, diag::err_openclcxx_not_supported) <<
"default delete";
4308 bool CanProvideSize =
4309 IsComplete && (!ArrayForm || UsualArrayDeleteWantsSize ||
4319 if (!OperatorDelete)
4323 if (OperatorDelete->isInvalidDecl())
4330 bool IsVirtualDelete =
false;
4333 if (Dtor->isCalledByDelete(OperatorDelete))
4335 PDiag(diag::err_access_dtor) << PointeeElem);
4336 IsVirtualDelete = Dtor->isVirtual();
4342 unsigned AddressParamIdx = 0;
4343 if (OperatorDelete->isTypeAwareOperatorNewOrDelete()) {
4344 QualType TypeIdentity = OperatorDelete->getParamDecl(0)->getType();
4346 diag::err_incomplete_type))
4348 AddressParamIdx = 1;
4356 OperatorDelete->getParamDecl(AddressParamIdx)->getType();
4375 Context.VoidTy, UseGlobal, ArrayForm, ArrayFormAsWritten,
4376 UsualArrayDeleteWantsSize, OperatorDelete, Ex.
get(), StartLoc);
4377 AnalyzeDeleteExprMismatch(
Result);
4386 IsDelete ? OO_Delete : OO_New);
4390 assert(!R.empty() &&
"implicitly declared allocation functions not found");
4391 assert(!R.isAmbiguous() &&
"global allocation functions are ambiguous");
4394 R.suppressDiagnostics();
4400 FnOvl != FnOvlEnd; ++FnOvl) {
4403 NamedDecl *D = (*FnOvl)->getUnderlyingDecl();
4426 assert(R.getNamingClass() ==
nullptr &&
4427 "class members should not be considered");
4430 S.
Diag(R.getNameLoc(), diag::err_builtin_operator_new_delete_not_usual)
4431 << (IsDelete ? 1 : 0) << Range;
4432 S.
Diag(FnDecl->
getLocation(), diag::note_non_usual_function_declared_here)
4444 S.
PDiag(diag::err_ovl_no_viable_function_in_call)
4445 << R.getLookupName() << Range),
4452 S.
PDiag(diag::err_ovl_ambiguous_call)
4453 << R.getLookupName() << Range),
4459 Candidates, Best->Function, Args);
4462 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
4470 << (IsDelete ?
"__builtin_operator_delete" :
"__builtin_operator_new")
4478 FunctionDecl *OperatorNewOrDelete =
nullptr;
4480 OperatorNewOrDelete))
4482 assert(OperatorNewOrDelete &&
"should be found");
4488 for (
unsigned i = 0; i != TheCall->
getNumArgs(); ++i) {
4490 InitializedEntity Entity =
4499 assert(Callee &&
Callee->getCastKind() == CK_BuiltinFnToFnPtr &&
4500 "Callee expected to be implicit cast to a builtin function pointer");
4503 return TheCallResult;
4507 bool IsDelete,
bool CallCanBeVirtual,
4508 bool WarnOnNonAbstractTypes,
4535 Diag(Loc, diag::warn_delete_abstract_non_virtual_dtor) << (IsDelete ? 0 : 1)
4537 }
else if (WarnOnNonAbstractTypes) {
4540 Diag(Loc, diag::warn_delete_non_virtual_dtor) << (IsDelete ? 0 : 1)
4544 std::string TypeStr;
4546 Diag(DtorLoc, diag::note_delete_non_virtual)
4573 if (
T->isFunctionType())
4575 diag::err_invalid_use_of_function_type)
4577 else if (
T->isArrayType())
4579 diag::err_invalid_use_of_array_type)
4597 llvm_unreachable(
"unexpected condition kind");
4629 diag::err_constexpr_if_condition_expression_is_not_constant);
4637 From = Cast->getSubExpr();
4649 if (!ToPtrType->getPointeeType().hasQualifiers()) {
4650 switch (StrLit->getKind()) {
4658 return (ToPointeeType->getKind() == BuiltinType::Char_U ||
4659 ToPointeeType->getKind() == BuiltinType::Char_S);
4664 assert(
false &&
"Unevaluated string literal in expression");
4679 bool HadMultipleCandidates,
4682 default: llvm_unreachable(
"Unhandled cast kind!");
4683 case CK_ConstructorConversion: {
4688 diag::err_allocation_of_abstract_type))
4702 ConstructorArgs, HadMultipleCandidates,
4703 false,
false,
false,
4711 case CK_UserDefinedConversion: {
4721 HadMultipleCandidates);
4726 CK_UserDefinedConversion,
Result.get(),
4727 nullptr,
Result.get()->getValueKind(),
4760 assert(FD &&
"no conversion function for user-defined conversion seq");
4762 CastKind = CK_UserDefinedConversion;
4767 BeforeToType =
Context.getCanonicalTagType(Conv->getParent());
4770 CastKind = CK_ConstructorConversion;
4797 From = CastArg.
get();
4811 PDiag(diag::err_typecheck_ambiguous_condition)
4817 llvm_unreachable(
"bad conversion");
4827 assert(Diagnosed &&
"failed to diagnose bad conversion"); (void)Diagnosed;
4844 ElType = ToVec->getElementType();
4846 ElType = ToMat->getElementType();
4852 return Context.getExtVectorType(ElType, FromVec->getNumElements());
4856 return Context.getConstantMatrixType(ElType, FromMat->getNumRows(),
4857 FromMat->getNumColumns());
4866 const auto *FromOBT = FromType->
getAs<OverflowBehaviorType>();
4867 const auto *ToOBT = ToType->
getAs<OverflowBehaviorType>();
4869 if (FromOBT && ToOBT &&
4870 FromOBT->getBehaviorKind() != ToOBT->getBehaviorKind()) {
4871 S.
Diag(From->
getExprLoc(), diag::err_incompatible_obt_kinds_assignment)
4872 << ToType << FromType
4873 << (ToOBT->getBehaviorKind() ==
4874 OverflowBehaviorType::OverflowBehaviorKind::Trap
4877 << (FromOBT->getBehaviorKind() ==
4878 OverflowBehaviorType::OverflowBehaviorKind::Trap
4913 false,
false,
false,
4920 false,
false,
false,
4953 ToAtomicType = ToType;
4954 ToType = ToAtomic->getValueType();
4957 QualType InitialFromType = FromType;
4959 switch (SCS.
First) {
4962 FromType = FromAtomic->getValueType().getUnqualifiedType();
4975 From = FromRes.
get();
4981 FromType =
Context.getArrayDecayedType(FromType);
4989 FromType =
Context.getArrayParameterType(FromType);
5000 FromType =
Context.getPointerType(FromType);
5007 llvm_unreachable(
"Improper first standard conversion");
5055 "only enums with fixed underlying type can promote to bool");
5086 CK = CK_FloatingComplexCast;
5088 CK = CK_FloatingComplexToIntegralComplex;
5090 CK = CK_IntegralComplexToFloatingComplex;
5092 CK = CK_IntegralComplexCast;
5120 "Attempting implicit fixed point conversion without a fixed "
5125 nullptr, CCK).
get();
5129 nullptr, CCK).
get();
5133 nullptr, CCK).
get();
5137 nullptr, CCK).
get();
5141 nullptr, CCK).
get();
5145 nullptr, CCK).
get();
5150 nullptr, CCK).
get();
5160 diag::ext_typecheck_convert_incompatible_pointer)
5165 diag::ext_typecheck_convert_incompatible_pointer)
5172 }
else if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
5173 !
ObjC().CheckObjCARCUnavailableWeakConversion(ToType,
5178 Diag(From->
getBeginLoc(), diag::err_arc_convesion_of_weak_unavailable)
5189 NewToType =
Context.removeAddrSpaceQualType(ToPteeType);
5190 NewToType =
Context.getAddrSpaceQualType(NewToType,
5193 NewToType =
Context.getObjCObjectPointerType(NewToType);
5195 NewToType =
Context.getBlockPointerType(NewToType);
5197 NewToType =
Context.getPointerType(NewToType);
5207 if (Kind == CK_BlockPointerToObjCPointerCast) {
5212 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
5227 assert((Kind != CK_NullToMemberPointer ||
5230 "Expr must be null pointer constant!");
5235 llvm_unreachable(
"unexpected result");
5237 llvm_unreachable(
"Should not have been called if derivation isn't OK.");
5284 &BasePath, CCK).
get();
5313 QualType ElType = ToComplex->getElementType();
5321 isFloatingComplex ? CK_FloatingCast : CK_FloatingToIntegral).
get();
5325 isFloatingComplex ? CK_IntegralToFloating : CK_IntegralCast).
get();
5329 isFloatingComplex ? CK_FloatingRealToComplex
5330 : CK_IntegralRealToComplex).
get();
5335 QualType ElType = FromComplex->getElementType();
5340 isFloatingComplex ? CK_FloatingComplexToReal
5341 : CK_IntegralComplexToReal,
5346 if (
Context.hasSameUnqualifiedType(ElType, ToType)) {
5350 isFloatingComplex ? CK_FloatingCast
5351 : CK_IntegralToFloating,
5357 isFloatingComplex ? CK_FloatingToIntegral
5374 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
5387 From = FromRes.
get();
5389 "Improper transparent union conversion");
5397 CK_ZeroToOCLOpaqueType,
5414 llvm_unreachable(
"Improper second standard conversion");
5423 "Dimension conversion output must be vector, matrix, or scalar type.");
5449 QualType TruncTy = FromVec->getElementType();
5451 TruncTy =
Context.getExtVectorType(TruncTy, ToVec->getNumElements());
5460 QualType TruncTy = FromMat->getElementType();
5473 llvm_unreachable(
"Improper element standard conversion");
5477 switch (SCS.
Third) {
5500 CK = CK_AddressSpaceConversion;
5505 CK = CK_AddressSpaceConversion;
5511 << InitialFromType << ToType;
5522 ? diag::ext_deprecated_string_literal_conversion
5523 : diag::warn_deprecated_string_literal_conversion)
5531 llvm_unreachable(
"Improper third standard conversion");
5536 if (!ToAtomicType.
isNull()) {
5568 "placeholders should have been weeded out by now");
5583 const char *OpSpelling = isIndirect ?
"->*" :
".*";
5591 Diag(Loc, diag::err_bad_memptr_rhs)
5611 LHSType = Ptr->getPointeeType();
5613 Diag(Loc, diag::err_bad_memptr_lhs)
5614 << OpSpelling << 1 << LHSType
5624 OpSpelling, (
int)isIndirect)) {
5629 Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
5638 LHSType, RHSClassType, Loc,
5647 UseType =
Context.getPointerType(UseType);
5656 Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
5675 switch (Proto->getRefQualifier()) {
5684 if (Proto->isConst() && !Proto->isVolatile())
5686 ? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
5687 : diag::ext_pointer_to_const_ref_member_on_rvalue);
5689 Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
5696 Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
5709 if (
Result->isFunctionType()) {
5712 }
else if (isIndirect) {
5730 bool &HaveConversion,
5732 HaveConversion =
false;
5755 HaveConversion =
true;
5770 bool FDerivedFromT = FRec && TRec && FRec != TRec &&
5771 Self.IsDerivedFrom(QuestionLoc, FTy, TTy);
5772 if (FRec && TRec && (FRec == TRec || FDerivedFromT ||
5773 Self.IsDerivedFrom(QuestionLoc, TTy, FTy))) {
5777 if (FRec == TRec || FDerivedFromT) {
5782 HaveConversion =
true;
5805 HaveConversion = !InitSeq.
Failed();
5823 Self.AddBuiltinOperatorCandidates(OO_Conditional, QuestionLoc, Args,
5831 LHS.
get(), Best->BuiltinParamTypes[0], Best->Conversions[0],
5838 RHS.
get(), Best->BuiltinParamTypes[1], Best->Conversions[1],
5844 Self.MarkFunctionReferenced(QuestionLoc, Best->Function);
5853 if (
Self.DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
5856 Self.Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
5862 Self.Diag(QuestionLoc, diag::err_conditional_ambiguous_ovl)
5870 llvm_unreachable(
"Conditional operator has only built-in overloads");
5902 assert(!EltTy->
isEnumeralType() &&
"Vectors cant be enum types");
5918 bool LHSIsVector = LHSType->
isVectorType() || LHSSizelessVector;
5919 bool RHSIsVector = RHSType->
isVectorType() || RHSSizelessVector;
5921 auto GetVectorInfo =
5922 [&](
QualType Type) -> std::pair<QualType, llvm::ElementCount> {
5924 return std::make_pair(VT->getElementType(),
5925 llvm::ElementCount::getFixed(VT->getNumElements()));
5928 return std::make_pair(VectorInfo.
ElementType, VectorInfo.
EC);
5931 auto [CondElementTy, CondElementCount] = GetVectorInfo(CondType);
5934 if (LHSIsVector && RHSIsVector) {
5936 Diag(QuestionLoc, diag::err_conditional_vector_cond_result_mismatch)
5942 if (!
Context.hasSameType(LHSType, RHSType)) {
5943 Diag(QuestionLoc, diag::err_conditional_vector_mismatched)
5944 << LHSType << RHSType;
5947 ResultType =
Context.getCommonSugaredType(LHSType, RHSType);
5948 }
else if (LHSIsVector || RHSIsVector) {
5949 bool ResultSizeless = LHSSizelessVector || RHSSizelessVector;
5951 Diag(QuestionLoc, diag::err_conditional_vector_cond_result_mismatch)
5961 LHS, RHS, QuestionLoc,
false,
true,
5972 Context.hasSameType(LHSType, RHSType)
5973 ?
Context.getCommonSugaredType(LHSType, RHSType)
5978 Diag(QuestionLoc, diag::err_conditional_vector_operand_type)
5983 ResultType =
Context.getExtVectorType(ResultElementTy,
5984 CondElementCount.getFixedValue());
5986 ResultType =
Context.getScalableVectorType(
5987 ResultElementTy, CondElementCount.getKnownMinValue());
5989 if (ResultType.
isNull()) {
5990 Diag(QuestionLoc, diag::err_conditional_vector_scalar_type_unsupported)
5991 << ResultElementTy << CondType;
5995 ResultType =
Context.getVectorType(ResultElementTy,
5996 CondElementCount.getFixedValue(),
6003 assert(!ResultType.
isNull() &&
6006 "Result should have been a vector type");
6008 auto [ResultElementTy, ResultElementCount] = GetVectorInfo(ResultType);
6009 if (ResultElementCount != CondElementCount) {
6010 Diag(QuestionLoc, diag::err_conditional_vector_size) << CondType
6016 if (
Context.getTypeSize(ResultElementTy) !=
6017 Context.getTypeSize(CondElementTy) &&
6018 (!CondElementTy->isBooleanType() ||
LangOpts.OpenCL)) {
6019 Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6020 << CondType << ResultType;
6037 bool IsVectorConditional =
6069 if (LVoid || RVoid) {
6078 if (IsVectorConditional) {
6081 bool IsThrow = LVoid ? LThrow : RThrow;
6082 Diag(DiagLoc.
getBegin(), diag::err_conditional_vector_has_void)
6083 << DiagLoc << IsThrow;
6087 if (LThrow != RThrow) {
6088 Expr *NonThrow = LThrow ? RHS.
get() : LHS.
get();
6099 return Context.getCommonSugaredType(LTy, RTy);
6102 Diag(QuestionLoc, diag::err_conditional_void_nonvoid)
6103 << (LVoid ? RTy : LTy) << (LVoid ? 0 : 1)
6109 if (IsVectorConditional)
6114 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
6123 if (!
Context.hasSameType(LTy, RTy) &&
6127 bool HaveL2R, HaveR2L;
6134 if (HaveL2R && HaveR2L) {
6135 Diag(QuestionLoc, diag::err_conditional_ambiguous)
6147 }
else if (HaveR2L) {
6171 ReferenceConversions::Qualification |
6172 ReferenceConversions::NestedQualification |
6173 ReferenceConversions::Function;
6178 !(RefConv & ~AllowedConversions) &&
6186 !(RefConv & ~AllowedConversions) &&
6201 bool Same =
Context.hasSameType(LTy, RTy);
6202 if (Same && LVK == RVK && LVK !=
VK_PRValue &&
6209 return Context.getCommonSugaredType(LTy, RTy);
6239 if (
Context.hasSameType(LTy, RTy)) {
6255 return Context.getCommonSugaredType(LTy, RTy);
6276 diag::err_typecheck_cond_incompatible_operands) << LTy << RTy
6314 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6334 bool T2IsPointerLike = T2->isAnyPointerType() || T2->isMemberPointerType() ||
6335 T2->isNullPtrType();
6336 if (!T1IsPointerLike && !T2IsPointerLike)
6344 if (T1IsPointerLike &&
6348 ? CK_NullToMemberPointer
6349 : CK_NullToPointer).
get();
6352 if (T2IsPointerLike &&
6356 ? CK_NullToMemberPointer
6357 : CK_NullToPointer).
get();
6362 if (!T1IsPointerLike || !T2IsPointerLike)
6365 "nullptr_t should be a null pointer constant");
6368 enum Kind {
Pointer, ObjCPointer, MemberPointer, Array } K;
6374 const Type *ClassOrBound;
6376 Step(Kind K,
const Type *ClassOrBound =
nullptr)
6377 : K(K), ClassOrBound(ClassOrBound) {}
6389 if (
auto *CAT = cast_or_null<ConstantArrayType>(ClassOrBound))
6395 llvm_unreachable(
"unknown step kind");
6417 unsigned NeedConstBefore = 0;
6422 Composite1 =
Context.getUnqualifiedArrayType(Composite1, Q1);
6423 Composite2 =
Context.getUnqualifiedArrayType(Composite2, Q2);
6426 if (!Steps.empty()) {
6436 }
else if (Steps.size() == 1) {
6439 if (MaybeQ1 == MaybeQ2) {
6458 assert(Steps.size() == 1);
6466 assert(Steps.size() == 1);
6475 Steps.back().Quals = Quals;
6476 if (Q1 != Quals || Q2 != Quals)
6477 NeedConstBefore = Steps.size() - 1;
6483 if ((Arr1 =
Context.getAsArrayType(Composite1)) &&
6484 (Arr2 =
Context.getAsArrayType(Composite2))) {
6485 auto *CAT1 = dyn_cast<ConstantArrayType>(Arr1);
6486 auto *CAT2 = dyn_cast<ConstantArrayType>(Arr2);
6487 if (CAT1 && CAT2 && CAT1->getSize() == CAT2->getSize()) {
6490 Steps.emplace_back(Step::Array, CAT1);
6495 if ((IAT1 && IAT2) ||
6497 ((
bool)CAT1 != (
bool)CAT2) &&
6498 (Steps.empty() || Steps.back().K != Step::Array))) {
6504 Steps.emplace_back(Step::Array);
6506 NeedConstBefore = Steps.size();
6516 Steps.emplace_back(Step::Pointer);
6525 Steps.emplace_back(Step::ObjCPointer);
6549 else if (Steps.empty())
6556 Steps.emplace_back(Step::MemberPointer,
6557 Context.getCanonicalTagType(Cls).getTypePtr());
6569 Steps.emplace_back(Step::Pointer);
6607 if (Steps.size() == 1) {
6619 bool CFIUncheckedCallee =
6630 Composite1 =
Context.getFunctionType(FPT1->getReturnType(),
6631 FPT1->getParamTypes(), EPI1);
6632 Composite2 =
Context.getFunctionType(FPT2->getReturnType(),
6633 FPT2->getParamTypes(), EPI2);
6639 if (Steps.size() == 1 && Steps.front().K == Step::Pointer &&
6640 !
Context.hasSameType(Composite1, Composite2)) {
6645 Composite2 = Composite1;
6647 Composite1 = Composite2;
6656 Composite1 = Composite2;
6658 Composite2 = Composite1;
6663 if (!
Context.hasSameType(Composite1, Composite2))
6668 for (
unsigned I = 0; I != NeedConstBefore; ++I)
6669 Steps[I].Quals.addConst();
6672 QualType Composite =
Context.getCommonSugaredType(Composite1, Composite2);
6673 for (
auto &S : llvm::reverse(Steps))
6674 Composite = S.rebuild(
Context, Composite);
6695 E1 = E1Result.
get();
6700 E2 = E2Result.
get();
6721 bool ReturnsRetained;
6726 Expr *Callee =
Call->getCallee()->IgnoreParens();
6732 T = BinOp->getRHS()->getType();
6733 else if (
MemberExpr *Mem = dyn_cast<MemberExpr>(Callee))
6734 T = Mem->getMemberDecl()->getType();
6738 T = Ptr->getPointeeType();
6740 T = Ptr->getPointeeType();
6742 T = MemPtr->getPointeeType();
6745 ReturnsRetained = FTy->getExtInfo().getProducesResult();
6750 ReturnsRetained =
true;
6764 D = Send->getMethodDecl();
6765 }
else if (
auto *OL = dyn_cast<ObjCObjectLiteral>(E);
6766 OL && OL->isGlobalAllocation()) {
6768 }
else if (
ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(E)) {
6769 D = BoxedExpr->getBoxingMethod();
6773 if (ArrayLit->getNumElements() == 0 &&
6774 Context.getLangOpts().ObjCRuntime.hasEmptyCollections())
6777 D = ArrayLit->getArrayWithObjectsMethod();
6779 dyn_cast<ObjCDictionaryLiteral>(E)) {
6782 if (DictLit->getNumElements() == 0 &&
6783 Context.getLangOpts().ObjCRuntime.hasEmptyCollections())
6786 D = DictLit->getDictWithObjectsMethod();
6789 ReturnsRetained = (D && D->
hasAttr<NSReturnsRetainedAttr>());
6794 if (!ReturnsRetained &&
6803 Cleanup.setExprNeedsCleanups(
true);
6805 CastKind ck = (ReturnsRetained ? CK_ARCConsumeObject
6806 : CK_ARCReclaimReturnedObject);
6812 Cleanup.setExprNeedsCleanups(
true);
6820 const RecordType *RT =
nullptr;
6822 switch (
T->getTypeClass()) {
6826 case Type::ConstantArray:
6827 case Type::IncompleteArray:
6828 case Type::VariableArray:
6829 case Type::DependentSizedArray:
6850 PDiag(diag::err_access_dtor_temp)
6860 Cleanup.setExprNeedsCleanups(
true);
6881 assert(SubExpr &&
"subexpression can't be null!");
6887 assert(
Cleanup.exprNeedsCleanups() ||
6889 if (!
Cleanup.exprNeedsCleanups())
6903 assert(SubStmt &&
"sub-statement can't be null!");
6907 if (!
Cleanup.exprNeedsCleanups())
6926 "not in a decltype expression");
6943 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
6947 if (SubExpr.
get() == PE->getSubExpr())
6952 if (BO->getOpcode() == BO_Comma) {
6956 if (RHS.
get() == BO->getRHS())
6959 BO->
getType(), BO->getValueKind(),
6960 BO->getObjectKind(), BO->getOperatorLoc(),
6961 BO->getFPFeatures());
6988 for (
unsigned I = 0, N =
ExprEvalContexts.back().DelayedDecltypeCalls.size();
6991 if (
Call == TopCall)
7001 for (
unsigned I = 0, N =
ExprEvalContexts.back().DelayedDecltypeBinds.size();
7005 if (
Bind == TopBind)
7011 Bind->getType()->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
7017 PDiag(diag::err_access_dtor_temp)
7018 <<
Bind->getType());
7023 Cleanup.setExprNeedsCleanups(
true);
7033 unsigned SkipStart = OperatorArrows.size(), SkipCount = 0;
7036 if (OperatorArrows.size() > Limit) {
7038 SkipStart = (Limit - 1) / 2 + (Limit - 1) % 2;
7039 SkipCount = OperatorArrows.size() - (Limit - 1);
7042 for (
unsigned I = 0; I < OperatorArrows.size(); ) {
7043 if (I == SkipStart) {
7044 S.
Diag(OperatorArrows[I]->getLocation(),
7045 diag::note_operator_arrows_suppressed)
7049 S.
Diag(OperatorArrows[I]->getLocation(), diag::note_operator_arrow_here)
7050 << OperatorArrows[I]->getCallResultType();
7060 bool &MayBePseudoDestructor) {
7071 MayBePseudoDestructor =
false;
7072 if (BaseType->isDependentType()) {
7076 if (OpKind == tok::arrow)
7078 BaseType = Ptr->getPointeeType();
7081 MayBePseudoDestructor =
true;
7088 if (OpKind == tok::arrow) {
7090 bool NoArrowOperatorFound =
false;
7091 bool FirstIteration =
true;
7096 CTypes.insert(
Context.getCanonicalType(BaseType));
7098 while (BaseType->isRecordType()) {
7099 if (OperatorArrows.size() >=
getLangOpts().ArrowDepth) {
7100 Diag(OpLoc, diag::err_operator_arrow_depth_exceeded)
7101 << StartingType <<
getLangOpts().ArrowDepth <<
Base->getSourceRange();
7103 Diag(OpLoc, diag::note_operator_arrow_depth)
7116 : &NoArrowOperatorFound);
7117 if (
Result.isInvalid()) {
7118 if (NoArrowOperatorFound) {
7119 if (FirstIteration) {
7120 Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
7121 << BaseType << 1 <<
Base->getSourceRange()
7123 OpKind = tok::period;
7126 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
7127 << BaseType <<
Base->getSourceRange();
7131 diag::note_member_reference_arrow_from_operator_arrow);
7138 OperatorArrows.push_back(OpCall->getDirectCallee());
7139 BaseType =
Base->getType();
7141 if (!CTypes.insert(CBaseType).second) {
7142 Diag(OpLoc, diag::err_operator_arrow_circular) << StartingType;
7146 FirstIteration =
false;
7149 if (OpKind == tok::arrow) {
7150 if (BaseType->isPointerType())
7151 BaseType = BaseType->getPointeeType();
7152 else if (
auto *AT =
Context.getAsArrayType(BaseType))
7153 BaseType = AT->getElementType();
7159 if (BaseType->isObjCObjectPointerType())
7160 BaseType = BaseType->getPointeeType();
7173 if (!BaseType->isRecordType()) {
7175 MayBePseudoDestructor =
true;
7184 if (!BaseType->isDependentType() &&
7187 diag::err_incomplete_member_access)) {
7202 if (
Base->hasPlaceholderType()) {
7207 ObjectType =
Base->getType();
7215 if (OpKind == tok::arrow) {
7225 ObjectType =
Base->getType();
7229 ObjectType = Ptr->getPointeeType();
7230 }
else if (!
Base->isTypeDependent()) {
7232 S.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
7233 << ObjectType <<
true
7238 OpKind = tok::period;
7280 Diag(OpLoc, diag::ext_pseudo_dtor_on_void) <<
Base->getSourceRange();
7282 Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
7283 << ObjectType <<
Base->getSourceRange();
7291 if (DestructedTypeInfo) {
7296 if (!
Context.hasSameUnqualifiedType(DestructedType, ObjectType)) {
7301 Context.hasSameUnqualifiedType(DestructedType,
7304 Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
7305 << ObjectType << 0 <<
Base->getSourceRange();
7309 *
this, DestructedType))
7314 ObjectType = DestructedType;
7315 OpKind = tok::arrow;
7317 Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
7318 << ObjectType << DestructedType <<
Base->getSourceRange()
7322 DestructedType = ObjectType;
7323 DestructedTypeInfo =
7324 Context.getTrivialTypeSourceInfo(ObjectType, DestructedTypeStart);
7334 Diag(DestructedTypeStart, diag::err_arc_pseudo_dtor_inconstant_quals)
7335 << ObjectType << DestructedType <<
Base->getSourceRange()
7340 DestructedType = ObjectType;
7341 DestructedTypeInfo =
Context.getTrivialTypeSourceInfo(ObjectType,
7342 DestructedTypeStart);
7355 if (ScopeTypeInfo) {
7357 if (!ScopeType->isDependentType() && !ObjectType->
isDependentType() &&
7358 !
Context.hasSameUnqualifiedType(ScopeType, ObjectType)) {
7361 diag::err_pseudo_dtor_type_mismatch)
7362 << ObjectType << ScopeType <<
Base->getSourceRange()
7366 ScopeTypeInfo =
nullptr;
7372 OpKind == tok::arrow, OpLoc,
7392 "Invalid first type name in pseudo-destructor");
7395 "Invalid second type name in pseudo-destructor");
7419 S, &SS,
true,
false, ObjectTypePtrForLookup,
7432 diag::err_pseudo_dtor_destructor_non_type)
7438 DestructedType = ObjectType;
7453 if (
T.isInvalid() || !
T.get()) {
7455 DestructedType = ObjectType;
7462 if (!DestructedType.
isNull()) {
7463 if (!DestructedTypeInfo)
7464 DestructedTypeInfo =
Context.getTrivialTypeSourceInfo(DestructedType,
7477 S, &SS,
true,
false, ObjectTypePtrForLookup,
7481 diag::err_pseudo_dtor_destructor_non_type)
7503 if (
T.isInvalid() || !
T.get()) {
7511 if (!ScopeType.isNull() && !ScopeTypeInfo)
7512 ScopeTypeInfo =
Context.getTrivialTypeSourceInfo(ScopeType,
7517 ScopeTypeInfo, CCLoc, TildeLoc,
7556 llvm_unreachable(
"Unsupported type in pseudo destructor");
7582 Operand->HasSideEffects(
Context,
false)) {
7585 Diag(Operand->getExprLoc(), diag::warn_side_effects_unevaluated_context);
7599 Expr *E, llvm::DenseMap<const VarDecl *, int> &RefsMinusAssignments) {
7601 bool IsCompoundAssign =
false;
7602 bool isIncrementDecrementUnaryOp =
false;
7604 if (BO->getLHS()->getType()->isDependentType() ||
7605 BO->getRHS()->getType()->isDependentType()) {
7606 if (BO->getOpcode() != BO_Assign)
7608 }
else if (!BO->isAssignmentOp())
7611 IsCompoundAssign = BO->isCompoundAssignmentOp();
7612 LHS = dyn_cast<DeclRefExpr>(BO->getLHS());
7614 if (COCE->getOperator() != OO_Equal)
7616 LHS = dyn_cast<DeclRefExpr>(COCE->getArg(0));
7617 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) {
7618 if (!UO->isIncrementDecrementOp())
7620 isIncrementDecrementUnaryOp =
true;
7621 LHS = dyn_cast<DeclRefExpr>(UO->getSubExpr());
7631 if ((IsCompoundAssign || isIncrementDecrementUnaryOp) &&
7635 if (iter == RefsMinusAssignments.end())
7637 iter->getSecond()--;
7714 diag::err_incomplete_type);
7741 const VarDecl *DefVD =
nullptr;
7774 while (isa_and_nonnull<CapturedDecl>(DC))
7778 "The current call operator must be synchronized with Sema's CurContext");
7799 !IsFullExprInstantiationDependent)
7812 const bool IsVarNeverAConstantExpression =
7814 if (!IsFullExprInstantiationDependent || IsVarNeverAConstantExpression) {
7826 DeclRefType,
nullptr)) {
7832 DeclRefType,
nullptr);
7844 const unsigned FunctionScopeIndexOfCapturableLambda = *Index;
7847 &FunctionScopeIndexOfCapturableLambda);
7856 bool DiscardedValue,
bool IsConstexpr,
7857 bool IsTemplateArgument) {
7866 if (DiscardedValue) {
7889 CheckCompletedExpr(
FullExpr.get(), CC, IsConstexpr);
7938 while (isa_and_nonnull<CapturedDecl>(DC))
7941 if (IsInLambdaDeclContext && CurrentLSI &&
7969 R.suppressDiagnostics();
7971 switch (R.getResultKind()) {
7985 llvm_unreachable(
"Invalid LookupResult Kind!");
8014 "Exactly one of TypeName and TemplateId must be specified.");
8061 auto &II =
Context.Idents.get(
"expr-type");
8082 E,
false, NoexceptLoc,
8114 assert(TC &&
"Type Constraint cannot be null here");
8116 assert(IDC &&
"ImmediatelyDeclaredConstraint can't be null here.");
8122 SubstitutedConstraintExpr =
8132 [&](llvm::raw_ostream &
OS) {
8133 IDC->printPretty(OS, nullptr,
8134 getPrintingPolicy());
8136 IsSimple, NoexceptLoc, ReturnTypeRequirement);
8142 ReturnTypeRequirement, Status,
8143 SubstitutedConstraintExpr);
8152 IsSimple, NoexceptLoc,
8153 ReturnTypeRequirement);
8184 llvm::raw_svector_ostream
OS(Entity);
8198 InvalidConstraintEntity,
8214 if (Param->getType()->isVoidType()) {
8215 if (LocalParameters.size() > 1) {
8216 Diag(Param->getBeginLoc(), diag::err_void_only_param);
8217 Param->setType(
Context.IntTy);
8218 }
else if (Param->getIdentifier()) {
8219 Diag(Param->getBeginLoc(), diag::err_param_with_void_type);
8220 Param->setType(
Context.IntTy);
8221 }
else if (Param->getType().hasQualifiers()) {
8222 Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
8224 }
else if (Param->hasDefaultArg()) {
8228 Diag(Param->getDefaultArgRange().getBegin(),
8229 diag::err_requires_expr_local_parameter_default_argument);
8231 }
else if (Param->isExplicitObjectParameter()) {
8242 Diag(Param->getExplicitObjectParamThisLoc(),
8243 diag::err_requires_expr_explicit_object_parameter);
8247 Param->setDeclContext(Body);
8249 if (Param->getIdentifier()) {
8258 assert(
CurContext &&
"DeclContext imbalance!");
8260 assert(
CurContext &&
"Popped translation unit!");
8269 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)
static const char * getPlatformName(Darwin::DarwinPlatformKind Platform, Darwin::DarwinEnvironmentKind Environment)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Result
Implement __builtin_bit_cast and related operations.
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
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 void DiagnoseAllocationLookupFailure(Sema &SemaRef, const LookupResult &R, SourceRange Range, AllocationArgumentSet &ArgumentCandidates, ArrayRef< Expr * > PlacementArguments)
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 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 adjustVectorOrConstantMatrixType(ASTContext &Context, QualType FromTy, QualType ToType, QualType *ElTy=nullptr)
static QualType adjustCVQualifiersForCXXThisWithinLambda(ArrayRef< FunctionScopeInfo * > FunctionScopes, QualType ThisTy, DeclContext *CurSemaContext, ASTContext &ASTCtx)
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 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 diagnoseNoViableFunctionForAllocationOverloadResolution(Sema &S, const LookupResult &R, SourceRange Range, ArrayRef< Expr * > Args, OverloadCandidateSet &Candidates, OverloadCandidateSet *AlignedCandidates, Expr *AlignArg, bool IncludedMSVCFallback, bool AlignedBeforeUnaligned)
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 void buildLambdaThisCaptureFixit(Sema &Sema, LambdaScopeInfo *LSI)
static bool checkIncompatibleOBTConversion(Sema &S, QualType FromType, QualType ToType, Expr *From)
Check if an integral conversion involves incompatible overflow behavior types.
static AllocatorResolveResult resolveAllocationOverload(Sema &S, const LookupResult &BaseLookup, SourceRange Range, ImplicitAllocationArguments &AllocationArgs, MultiExprArg TrialArguments, FunctionDecl *&Operator, OverloadCandidateSet &Candidates, bool Diagnose)
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 ...
TranslationUnitDecl * getTranslationUnitDecl() const
DeclarationNameTable DeclarationNames
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
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 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 ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const TargetInfo & getTargetInfo() const
CanQualType getCanonicalTagType(const TagDecl *TD) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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.
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.
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.
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.
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.
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.
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
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...
Represents a concrete matrix type with constant number of rows and columns.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
bool HasSubstitutionFailure()
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
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.
lookup_result::iterator lookup_iterator
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
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".
bool hasAutoTypeSpec() const
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.
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.
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.
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
bool isAnyOperatorNew() const
SourceLocation getBeginLoc() const LLVM_READONLY
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
SourceLocation getEndLoc() const LLVM_READONLY
void DropFirstTypeObject()
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void setRParenLoc(SourceLocation Loc)
void setDecltypeLoc(SourceLocation Loc)
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
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:
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
Declaration of a template function.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo withNoReturn(bool noReturn) const
FunctionType - C99 6.7.5.3 - Function Declarators.
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.
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, NewArrayKind IsVariableLengthArrayNew)
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'.
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 stack-allocated class that identifies which local variable declaration instantiations are present i...
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.
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.
UnresolvedSetImpl::iterator iterator
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.
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.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Represents a pointer to an Objective C object.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
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
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
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)
static std::string getAddrSpaceAsString(LangAS AS)
void setObjCLifetime(ObjCLifetime type)
Represents a struct/union/class.
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.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ 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.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
Emit a compatibility diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a 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...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
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)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, ImplicitDeallocationParameters, DeclarationName Name, bool Diagnose=true)
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),...
FunctionDecl * FindDeallocationFunctionForDestructor(SourceLocation StartLoc, CXXRecordDecl *RD, bool Diagnose, bool LookForGlobal, DeclarationName Name)
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.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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)
bool CheckConstraintSatisfaction(ConstrainedDeclOrNestedRequirement Entity, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction, const ConceptReference *TopLevelConceptId=nullptr, Expr **ConvertedExpr=nullptr)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
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()
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
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
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)
bool BuildCtorClosureDefaultArgs(SourceLocation Loc, CXXConstructorDecl *Ctor, bool IsCopy=false)
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)
ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr)
Prepare SplattedExpr for a matrix splat operation, adding implicit casts if necessary.
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 ...
ReferenceConversionsScope::ReferenceConversions ReferenceConversions
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.
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.
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
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.
bool inConstraintSubstitution() const
Determine whether we are currently performing constraint substitution.
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 ?
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 ...
bool isSFINAEContext() const
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 CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
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)
friend class InitializationSequence
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.
std::optional< ResolvedAllocation > FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, AllocationFunctionScope NewScope, AllocationFunctionScope DeleteScope, QualType AllocType, bool IsArray, const ImplicitAllocationParameters &IAP, MultiExprArg PlaceArgs, bool Diagnose=true)
Finds the overloads of operator new and delete that are appropriate for the allocation.
@ 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
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.
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
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
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
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with 'operator new(size_t)' is gua...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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, int D, int 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 isConstantMatrixType() 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...
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
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
bool isSizelessVectorType() const
Returns true for all scalable vector types.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a C++ unqualified-id that has been parsed.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
SourceLocation getEndLoc() const LLVM_READONLY
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 ...
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.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
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.
bool isa(CodeGen::Address addr)
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 (&&).
@ Success
Annotation was successful.
@ 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.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isLambdaCallWithExplicitObjectParameter(const DeclContext *DC)
bool isAlignedAllocation(AlignedAllocationMode Mode)
MutableArrayRef< Expr * > MultiExprArg
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
SmallVector< ImplicitAllocationArguments, 3 > AllocationArgumentSet
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
@ 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_HLSL_Matrix_Splat
HLSL matrix splat from scalar or boolean type.
@ 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_HLSL_Matrix_Truncation
HLSL Matrix truncation.
@ 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.
ActionResult< CXXBaseSpecifier * > BaseResult
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.
@ Type
The name was classified as a type.
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.
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
SizedDeallocationMode sizedDeallocationModeFromBool(bool IsSized)
@ Deduced
The normal deduced case.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
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.
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
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.
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
TypeAwareAllocationMode typeAwareAllocationModeFromBool(bool IsTypeAwareAllocation)
@ Generic
not a target-specific vector type
U cast(CodeGen::Address addr)
@ ArrayBound
Array bound in array declarator or new-expression.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ 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.
ActionResult< Expr * > ExprResult
@ 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.
ActionResult< Stmt * > StmtResult
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
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.
enum clang::DeclaratorChunk::@340323374315200305336204205154073066142310370142 Kind
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
TypeAwareAllocationMode PassTypeIdentity
bool IsMSVCCompatibilityFallback
ArrayRef< Expr * > getImplicitArguments() const
const LookupResult & updateLookupForMSVCCompatibility(Sema &, const LookupResult &, std::optional< LookupResult > &) const
Expr * getAlignmentArgument() const
AlignedAllocationMode PassAlignment
TypeAwareAllocationMode PassTypeIdentity
TypeAwareAllocationMode PassTypeIdentity
SizedDeallocationMode PassSize
AlignedAllocationMode PassAlignment
NestedNameSpecifierLoc Prefix
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
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...