64#include "llvm/ADT/STLExtras.h"
65#include "llvm/ADT/StringExtras.h"
66#include "llvm/Support/ConvertUTF.h"
67#include "llvm/Support/SaveAndRestore.h"
68#include "llvm/Support/TimeProfiler.h"
69#include "llvm/Support/TypeSize.h"
94 if (TreatUnavailableAsInvalid &&
112 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
115 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
116 A->getSemanticSpelling() != UnusedAttr::C23_maybe_unused) {
118 if (DC && !DC->
hasAttr<UnusedAttr>())
119 S.
Diag(Loc, diag::warn_used_but_marked_unused) << D;
127 if (
Decl->isDefaulted()) {
138 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
139 if (Ctor && Ctor->isInheritingConstructor())
150 if (I->getStorageClass() !=
SC_None)
201 DiagID = diag::warn_c2y_compat_internal_in_extern_inline;
202 else if ((UsedFn && (UsedFn->
isInlined() || UsedFn->
hasAttr<ConstAttr>())) ||
204 DiagID = diag::ext_internal_in_extern_inline_quiet;
206 DiagID = diag::ext_internal_in_extern_inline;
208 S.
Diag(Loc, DiagID) << !UsedFn << D;
220 Diag(DeclBegin, diag::note_convert_inline_to_static)
227 bool ObjCPropertyAccess,
228 bool AvoidPartialAvailabilityChecks,
230 bool SkipTrailingRequiresClause) {
237 for (
const auto &[DiagLoc, PD] : Pos->second) {
251 Diag(Loc, diag::ext_main_used);
259 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
262 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
271 if (FD->isDeleted()) {
272 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
273 if (Ctor && Ctor->isInheritingConstructor())
274 Diag(Loc, diag::err_deleted_inherited_ctor_use)
276 << Ctor->getInheritedConstructor().getConstructor()->getParent();
279 Diag(Loc, diag::err_deleted_function_use)
280 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
294 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
303 diag::err_reference_to_function_with_unsatisfied_constraints)
321 if (
auto *
Concept = dyn_cast<ConceptDecl>(D);
325 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
327 if (MD->getParent()->isLambda() &&
330 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
331 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
336 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
338 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
339 return MD->findPropertyDecl();
353 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(
CurContext);
356 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
369 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
375 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(D)) {
376 Diag(Loc, diag::err_use_of_empty_using_if_exists);
377 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
382 AvoidPartialAvailabilityChecks, ClassReceiver);
388 if (D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
391 PP.getLastFPEvalPragmaLocation().isValid() &&
392 PP.getCurrentFPEvalMethod() !=
getLangOpts().getFPEvalMethod())
394 diag::err_type_available_only_in_default_eval_method)
398 if (
auto *VD = dyn_cast<ValueDecl>(D))
403 if (!
Context.getTargetInfo().isTLSSupported())
404 if (
const auto *VD = dyn_cast<VarDecl>(D))
406 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
417 const SentinelAttr *
Attr = D->
getAttr<SentinelAttr>();
422 unsigned NumFormalParams;
426 enum { CK_Function, CK_Method, CK_Block } CalleeKind;
428 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
429 NumFormalParams = MD->param_size();
430 CalleeKind = CK_Method;
431 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
432 NumFormalParams = FD->param_size();
433 CalleeKind = CK_Function;
434 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
441 CalleeKind = CK_Function;
444 CalleeKind = CK_Block;
449 if (
const auto *proto = dyn_cast<FunctionProtoType>(Fn))
450 NumFormalParams = proto->getNumParams();
461 unsigned NullPos =
Attr->getNullPos();
462 assert((NullPos == 0 || NullPos == 1) &&
"invalid null position on sentinel");
463 NumFormalParams = (NullPos > NumFormalParams ? 0 : NumFormalParams - NullPos);
466 unsigned NumArgsAfterSentinel =
Attr->getSentinel();
470 if (Args.size() < NumFormalParams + NumArgsAfterSentinel + 1) {
477 const Expr *SentinelExpr = Args[Args.size() - NumArgsAfterSentinel - 1];
482 if (
Context.isSentinelNullExpr(SentinelExpr))
490 std::string NullValue;
491 if (CalleeKind == CK_Method &&
PP.isMacroDefined(
"nil"))
494 NullValue =
"nullptr";
495 else if (
PP.isMacroDefined(
"NULL"))
498 NullValue =
"(void*) 0";
501 Diag(Loc, diag::warn_missing_sentinel) <<
int(CalleeKind);
503 Diag(MissingNilLoc, diag::warn_missing_sentinel)
528 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
532 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
537 CK_FunctionToPointerDecay).
get();
552 CK_ArrayToPointerDecay);
568 if (UO && UO->getOpcode() == UO_Deref &&
569 UO->getSubExpr()->getType()->isPointerType()) {
571 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
574 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
576 !UO->getType().isVolatileQualified()) {
578 S.
PDiag(diag::warn_indirection_through_null)
579 << UO->getSubExpr()->getSourceRange());
581 S.
PDiag(diag::note_indirection_through_null));
601 BaseType = BaseType->getPointeeType();
613 if (ObjectSetClass) {
657 assert(!T.isNull() &&
"r-value conversion on typeless expression?");
661 if (T->canDecayToPointerType())
667 if (T ==
Context.OverloadTy || T->isRecordType() ||
668 (T->isDependentType() && !T->isAnyPointerType() &&
669 !T->isMemberPointerType()))
693 &
Context.Idents.get(
"object_getClass"),
699 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
716 if (T.hasQualifiers())
717 T = T.getUnqualifiedType();
720 if (T->isMemberPointerType() &&
721 Context.getTargetInfo().getCXXABI().isMicrosoft())
732 Cleanup.setExprNeedsCleanups(
true);
735 Cleanup.setExprNeedsCleanups(
true);
742 CastKind CK = T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
750 T =
Atomic->getValueType().getUnqualifiedType();
775 CK_FunctionToPointerDecay);
789 assert(!Ty.
isNull() &&
"UsualUnaryFPConversions - missing type");
795 PP.getLastFPEvalPragmaLocation().isValid())) {
796 switch (EvalMethod) {
798 llvm_unreachable(
"Unrecognized float evaluation method");
801 llvm_unreachable(
"Float evaluation method should be set by now");
809 CK_FloatingComplexCast)
818 CK_FloatingComplexCast)
850 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
874 if (
Context.isPromotableIntegerType(Ty)) {
889 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
901 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
902 BTy->
getKind() == BuiltinType::Float)) {
905 if (BTy->
getKind() == BuiltinType::Half) {
916 Context.getTypeSizeInChars(BTy) <
922 assert(8 ==
Context.getTypeSizeInChars(
Context.LongLongTy).getQuantity() &&
923 "Unexpected typesize for LongLongTy");
977 if (
Context.getTargetInfo().getTriple().isWasm() &&
992 if (!
Record->hasNonTrivialCopyConstructor() &&
993 !
Record->hasNonTrivialMoveConstructor() &&
994 !
Record->hasNonTrivialDestructor())
1027 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
1034 PDiag(diag::warn_pass_class_arg_to_vararg)
1042 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1049 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1053 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1066 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1068 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1107 if (
Call.isInvalid())
1112 if (Comma.isInvalid())
1119 diag::err_call_incomplete_argument))
1137 if (SkipCast)
return false;
1144 CK_IntegralComplexToFloatingComplex);
1162 bool PromotePrecision) {
1167 if (PromotePrecision) {
1172 if (LongerIsComplex)
1184 QualType RHSType,
bool IsCompAssign) {
1209 bool ConvertFloat,
bool ConvertInt) {
1214 CK_IntegralToFloating);
1225 CK_IntegralComplexToFloatingComplex);
1230 CK_FloatingRealToComplex);
1239 QualType RHSType,
bool IsCompAssign) {
1249 else if (!IsCompAssign)
1251 return LHSFloat ? LHSType : RHSType;
1256 if (LHSFloat && RHSFloat) {
1263 assert(order < 0 &&
"illegal float comparison");
1297 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1303 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1304 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1305 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1306 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1323 CK_IntegralComplexCast);
1329template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1332 QualType RHSType,
bool IsCompAssign) {
1337 if (LHSSigned == RHSSigned) {
1340 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1342 }
else if (!IsCompAssign)
1343 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1345 }
else if (order != (LHSSigned ? 1 : -1)) {
1349 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1351 }
else if (!IsCompAssign)
1352 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1359 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1361 }
else if (!IsCompAssign)
1362 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1371 RHS = (*doRHSCast)(S, RHS.
get(), result);
1373 LHS = (*doLHSCast)(S, LHS.
get(), result);
1383 bool IsCompAssign) {
1387 if (LHSComplexInt && RHSComplexInt) {
1392 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1397 if (LHSComplexInt) {
1401 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1404 CK_IntegralRealToComplex);
1409 assert(RHSComplexInt);
1414 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1419 CK_IntegralRealToComplex);
1427 bool IsCompAssign) {
1429 const auto *LhsOBT = LHSType->
getAs<OverflowBehaviorType>();
1430 const auto *RhsOBT = RHSType->
getAs<OverflowBehaviorType>();
1433 "Non-integer type conversion not supported for OverflowBehaviorTypes");
1436 LhsOBT && LhsOBT->getBehaviorKind() ==
1437 OverflowBehaviorType::OverflowBehaviorKind::Trap;
1439 RhsOBT && RhsOBT->getBehaviorKind() ==
1440 OverflowBehaviorType::OverflowBehaviorKind::Trap;
1442 LhsOBT && LhsOBT->getBehaviorKind() ==
1443 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1445 RhsOBT && RhsOBT->getBehaviorKind() ==
1446 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1448 QualType LHSUnderlyingType = LhsOBT ? LhsOBT->getUnderlyingType() : LHSType;
1449 QualType RHSUnderlyingType = RhsOBT ? RhsOBT->getUnderlyingType() : RHSType;
1451 std::optional<OverflowBehaviorType::OverflowBehaviorKind> DominantBehavior;
1452 if (LHSHasTrap || RHSHasTrap)
1453 DominantBehavior = OverflowBehaviorType::OverflowBehaviorKind::Trap;
1454 else if (LHSHasWrap || RHSHasWrap)
1455 DominantBehavior = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1457 QualType LHSConvType = LHSUnderlyingType;
1458 QualType RHSConvType = RHSUnderlyingType;
1459 if (DominantBehavior) {
1460 if (!LhsOBT || LhsOBT->getBehaviorKind() != *DominantBehavior)
1464 LHSConvType = LHSType;
1466 if (!RhsOBT || RhsOBT->getBehaviorKind() != *DominantBehavior)
1470 RHSConvType = RHSType;
1474 S, LHS, RHS, LHSConvType, RHSConvType, IsCompAssign);
1482 assert(BTy &&
"Expected a builtin type.");
1484 switch (BTy->getKind()) {
1485 case BuiltinType::ShortFract:
1486 case BuiltinType::UShortFract:
1487 case BuiltinType::SatShortFract:
1488 case BuiltinType::SatUShortFract:
1490 case BuiltinType::Fract:
1491 case BuiltinType::UFract:
1492 case BuiltinType::SatFract:
1493 case BuiltinType::SatUFract:
1495 case BuiltinType::LongFract:
1496 case BuiltinType::ULongFract:
1497 case BuiltinType::SatLongFract:
1498 case BuiltinType::SatULongFract:
1500 case BuiltinType::ShortAccum:
1501 case BuiltinType::UShortAccum:
1502 case BuiltinType::SatShortAccum:
1503 case BuiltinType::SatUShortAccum:
1505 case BuiltinType::Accum:
1506 case BuiltinType::UAccum:
1507 case BuiltinType::SatAccum:
1508 case BuiltinType::SatUAccum:
1510 case BuiltinType::LongAccum:
1511 case BuiltinType::ULongAccum:
1512 case BuiltinType::SatLongAccum:
1513 case BuiltinType::SatULongAccum:
1516 if (BTy->isInteger())
1518 llvm_unreachable(
"Unexpected fixed point or integer type");
1530 "Expected at least one of the operands to be a fixed point type");
1533 "Special fixed point arithmetic operation conversions are only "
1534 "applied to ints or other fixed point types");
1556 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1579 REnum = R->isUnscopedEnumerationType();
1581 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1585 ? diag::warn_arith_conv_enum_float_cxx20
1586 : diag::warn_arith_conv_enum_float)
1589 }
else if (!IsCompAssign && LEnum && REnum &&
1590 !
Context.hasSameUnqualifiedType(L, R)) {
1595 DiagID = diag::warn_conv_mixed_enum_types_cxx26;
1596 else if (!L->
castAsCanonical<EnumType>()->getDecl()->hasNameForLinkage() ||
1597 !R->castAsCanonical<EnumType>()->getDecl()->hasNameForLinkage()) {
1602 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1603 : diag::warn_arith_conv_mixed_anon_enum_types;
1608 ? diag::warn_conditional_mixed_enum_types_cxx20
1609 : diag::warn_conditional_mixed_enum_types;
1614 ? diag::warn_comparison_mixed_enum_types_cxx20
1615 : diag::warn_comparison_mixed_enum_types;
1618 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1619 : diag::warn_arith_conv_mixed_enum_types;
1622 << (int)ACK << L << R;
1640 auto IsSingleCodeUnitCP = [](
const QualType &T,
const llvm::APSInt &
Value) {
1641 if (T->isChar8Type())
1642 return llvm::IsSingleCodeUnitUTF8Codepoint(
Value.getExtValue());
1643 if (T->isChar16Type())
1644 return llvm::IsSingleCodeUnitUTF16Codepoint(
Value.getExtValue());
1645 assert(T->isChar32Type());
1646 return llvm::IsSingleCodeUnitUTF32Codepoint(
Value.getExtValue());
1659 if (LHSSuccess != RHSuccess) {
1661 if (IsSingleCodeUnitCP(LHSType, Res.
Val.
getInt()) &&
1662 IsSingleCodeUnitCP(RHSType, Res.
Val.
getInt()))
1666 if (!LHSSuccess || !RHSuccess) {
1667 SemaRef.
Diag(Loc, diag::warn_comparison_unicode_mixed_types)
1673 llvm::APSInt LHSValue(32);
1675 llvm::APSInt RHSValue(32);
1678 bool LHSSafe = IsSingleCodeUnitCP(LHSType, LHSValue);
1679 bool RHSSafe = IsSingleCodeUnitCP(RHSType, RHSValue);
1680 if (LHSSafe && RHSSafe)
1683 SemaRef.
Diag(Loc, diag::warn_comparison_unicode_mixed_types_constant)
1693 SemaRef.
Diag(Loc, diag::warn_arith_conv_mixed_unicode_types)
1727 LHSType = AtomicLHS->getValueType();
1730 if (
Context.hasSameType(LHSType, RHSType))
1731 return Context.getCommonSugaredType(LHSType, RHSType);
1739 QualType LHSUnpromotedType = LHSType;
1740 if (
Context.isPromotableIntegerType(LHSType))
1741 LHSType =
Context.getPromotedIntegerType(LHSType);
1743 if (!LHSBitfieldPromoteTy.
isNull())
1744 LHSType = LHSBitfieldPromoteTy;
1749 if (
Context.hasSameType(LHSType, RHSType))
1750 return Context.getCommonSugaredType(LHSType, RHSType);
1793 bool PredicateIsExpr,
void *ControllingExprOrType,
1795 unsigned NumAssocs = ArgTypes.size();
1796 assert(NumAssocs == ArgExprs.size());
1799 for (
unsigned i = 0; i < NumAssocs; ++i) {
1808 if (!PredicateIsExpr) {
1812 assert(ControllingType &&
"couldn't get the type out of the parser");
1813 ControllingExprOrType = ControllingType;
1817 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1829 const auto *TOBT = T->getAs<OverflowBehaviorType>();
1830 const auto *UOBT =
U.getCanonicalType()->getAs<OverflowBehaviorType>();
1834 if (TOBT->getBehaviorKind() == UOBT->getBehaviorKind())
1836 UOBT->getUnderlyingType());
1848 bool PredicateIsExpr,
void *ControllingExprOrType,
1850 unsigned NumAssocs = Types.size();
1851 assert(NumAssocs == Exprs.size());
1852 assert(ControllingExprOrType &&
1853 "Must have either a controlling expression or a controlling type");
1855 Expr *ControllingExpr =
nullptr;
1857 if (PredicateIsExpr) {
1864 reinterpret_cast<Expr *
>(ControllingExprOrType));
1867 ControllingExpr = R.get();
1870 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1871 if (!ControllingType)
1875 bool TypeErrorFound =
false,
1876 IsResultDependent = ControllingExpr
1879 ContainsUnexpandedParameterPack =
1889 diag::warn_side_effects_unevaluated_context);
1891 for (
unsigned i = 0; i < NumAssocs; ++i) {
1892 if (Exprs[i]->containsUnexpandedParameterPack())
1893 ContainsUnexpandedParameterPack =
true;
1896 if (Types[i]->
getType()->containsUnexpandedParameterPack())
1897 ContainsUnexpandedParameterPack =
true;
1899 if (Types[i]->
getType()->isDependentType()) {
1900 IsResultDependent =
true;
1917 if (ControllingExpr && Types[i]->
getType()->isIncompleteType())
1918 D =
LangOpts.C2y ? diag::warn_c2y_compat_assoc_type_incomplete
1919 : diag::ext_assoc_type_incomplete;
1920 else if (ControllingExpr && !Types[i]->
getType()->isObjectType())
1921 D = diag::err_assoc_type_nonobject;
1922 else if (Types[i]->
getType()->isVariablyModifiedType())
1923 D = diag::err_assoc_type_variably_modified;
1924 else if (ControllingExpr) {
1943 unsigned Reason = 0;
1952 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1953 diag::warn_unreachable_association)
1954 << QT << (Reason - 1);
1958 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1959 << Types[i]->getTypeLoc().getSourceRange() << Types[i]->getType();
1961 D, Types[i]->getTypeLoc().getBeginLoc()) >=
1963 TypeErrorFound =
true;
1968 for (
unsigned j = i+1; j < NumAssocs; ++j)
1969 if (Types[j] && !Types[j]->
getType()->isDependentType() &&
1972 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1973 diag::err_assoc_compatible_types)
1974 << Types[j]->getTypeLoc().getSourceRange()
1975 << Types[j]->getType()
1976 << Types[i]->getType();
1977 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1978 diag::note_compat_assoc)
1979 << Types[i]->getTypeLoc().getSourceRange()
1980 << Types[i]->getType();
1981 TypeErrorFound =
true;
1991 if (IsResultDependent) {
1992 if (ControllingExpr)
1994 Types, Exprs, DefaultLoc, RParenLoc,
1995 ContainsUnexpandedParameterPack);
1997 Exprs, DefaultLoc, RParenLoc,
1998 ContainsUnexpandedParameterPack);
2002 unsigned DefaultIndex = std::numeric_limits<unsigned>::max();
2006 for (
unsigned i = 0; i < NumAssocs; ++i) {
2014 QualType AssocQT = Types[i]->getType();
2020 CompatIndices.push_back(i);
2024 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
2028 if (ControllingExpr)
2037 return std::make_pair(SR, QT);
2043 if (CompatIndices.size() > 1) {
2044 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
2047 << SR << P.second << (
unsigned)CompatIndices.size();
2048 for (
unsigned I : CompatIndices) {
2049 Diag(Types[I]->getTypeLoc().getBeginLoc(),
2050 diag::note_compat_assoc)
2051 << Types[I]->getTypeLoc().getSourceRange()
2052 << Types[I]->getType();
2060 if (DefaultIndex == std::numeric_limits<unsigned>::max() &&
2061 CompatIndices.size() == 0) {
2062 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
2064 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR << P.second;
2073 unsigned ResultIndex =
2074 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
2076 if (ControllingExpr) {
2078 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
2079 ContainsUnexpandedParameterPack, ResultIndex);
2082 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
2083 ContainsUnexpandedParameterPack, ResultIndex);
2089 llvm_unreachable(
"unexpected TokenKind");
2090 case tok::kw___func__:
2092 case tok::kw___FUNCTION__:
2094 case tok::kw___FUNCDNAME__:
2096 case tok::kw___FUNCSIG__:
2098 case tok::kw_L__FUNCTION__:
2100 case tok::kw_L__FUNCSIG__:
2102 case tok::kw___PRETTY_FUNCTION__:
2113 return cast_or_null<Decl>(DC);
2131 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
2134 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2135 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
2136 if (ArgTy[ArgIdx]->isArrayType())
2157 std::vector<Token> ExpandedToks;
2163 if (Literal.hadError)
2167 for (
const Token &
Tok : StringToks)
2168 StringTokLocs.push_back(
Tok.getLocation());
2172 false, {}, StringTokLocs);
2174 if (!Literal.getUDSuffix().empty()) {
2177 Literal.getUDSuffixOffset());
2178 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2198 CurrentDecl =
Context.getTranslationUnitDecl();
2200 std::vector<Token> ExpandedToks;
2201 ExpandedToks.reserve(Toks.size());
2205 ExpandedToks.emplace_back(
Tok);
2209 Diag(
Tok.getLocation(), diag::ext_predef_outside_function);
2211 Diag(
Tok.getLocation(), diag::ext_string_literal_from_predefined)
2214 llvm::raw_svector_ostream
OS(Str);
2215 Token &Exp = ExpandedToks.emplace_back();
2217 if (
Tok.getKind() == tok::kw_L__FUNCTION__ ||
2218 Tok.getKind() == tok::kw_L__FUNCSIG__) {
2220 Exp.
setKind(tok::wide_string_literal);
2222 Exp.
setKind(tok::string_literal);
2228 PP.CreateString(
OS.str(), Exp,
Tok.getLocation(),
Tok.getEndLoc());
2230 return ExpandedToks;
2235 assert(!StringToks.empty() &&
"Must have at least one string!");
2238 std::vector<Token> ExpandedToks;
2243 if (Literal.hadError)
2247 for (
const Token &
Tok : StringToks)
2248 StringTokLocs.push_back(
Tok.getLocation());
2252 if (Literal.isWide()) {
2253 CharTy =
Context.getWideCharType();
2255 }
else if (Literal.isUTF8()) {
2259 CharTy =
Context.UnsignedCharTy;
2261 }
else if (Literal.isUTF16()) {
2264 }
else if (Literal.isUTF32()) {
2267 }
else if (Literal.isPascal()) {
2268 CharTy =
Context.UnsignedCharTy;
2280 ? diag::warn_cxx20_compat_utf8_string
2281 : diag::warn_c23_compat_utf8_string);
2287 auto RemovalDiag =
PDiag(diag::note_cxx20_c23_compat_utf8_string_remove_u8);
2289 for (
const Token &
Tok : StringToks) {
2290 if (
Tok.getKind() == tok::utf8_string_literal) {
2292 RemovalDiagLoc =
Tok.getLocation();
2299 Diag(RemovalDiagLoc, RemovalDiag);
2303 Context.getStringLiteralArrayType(CharTy, Literal.GetNumStringChars());
2307 Context, Literal.GetString(), Kind, Literal.Pascal, StrTy, StringTokLocs);
2308 if (Literal.getUDSuffix().empty())
2315 Literal.getUDSuffixOffset());
2319 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2326 Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
2331 Context.getArrayDecayedType(StrTy), SizeType
2341 llvm::APInt Len(
Context.getIntWidth(SizeType), Literal.GetNumStringChars());
2344 Expr *Args[] = { Lit, LenArg };
2361 unsigned CharBits =
Context.getIntWidth(CharTy);
2363 llvm::APSInt
Value(CharBits, CharIsUnsigned);
2369 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
2380 llvm_unreachable(
"unexpected literal operator lookup result");
2384 llvm_unreachable(
"unexpected literal operator lookup result");
2416 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2419 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2420 if (!Referee || !Referee->hasGlobalStorage() ||
2421 Referee->hasAttr<CUDADeviceAttr>())
2427 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2428 if (MD && MD->getParent()->isLambda() &&
2429 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2451 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2452 if (VD->getType()->isReferenceType() &&
2455 VD->isUsableInConstantExpressions(
Context))
2474 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
2502 const auto *FD = dyn_cast<FieldDecl>(D);
2503 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D))
2504 FD = IFD->getAnonField();
2508 if (FD->isBitField())
2514 if (
const auto *BD = dyn_cast<BindingDecl>(D))
2515 if (
const auto *BE = BD->getBinding())
2536 NameInfo =
Context.getNameForTemplate(TName, TNameLoc);
2537 TemplateArgs = &Buffer;
2540 TemplateArgs =
nullptr;
2548 bool isDefaultArgument =
2552 const auto *CurMethod = dyn_cast<CXXMethodDecl>(
CurContext);
2553 bool isInstance = CurMethod && CurMethod->isInstance() &&
2554 R.getNamingClass() == CurMethod->getParent() &&
2562 unsigned DiagID = diag::err_found_in_dependent_base;
2563 unsigned NoteID = diag::note_member_declared_at;
2564 if (R.getRepresentativeDecl()->getDeclContext()->Equals(R.getNamingClass())) {
2565 DiagID =
getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2566 : diag::err_found_later_in_class;
2568 DiagID = diag::ext_found_in_dependent_base;
2569 NoteID = diag::note_dependent_member_use;
2574 Diag(R.getNameLoc(), DiagID)
2575 << R.getLookupName()
2581 Diag(R.getNameLoc(), DiagID) << R.getLookupName();
2585 Diag(D->getLocation(), NoteID);
2594 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
2595 Diag(R.getNameLoc(), diag::err_member_call_without_object) << 0;
2608 SourceRange NameRange = R.getLookupNameInfo().getSourceRange();
2610 unsigned diagnostic = diag::err_undeclared_var_use;
2611 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2615 diagnostic = diag::err_undeclared_use;
2616 diagnostic_suggest = diag::err_undeclared_use_suggest;
2627 if (ExplicitTemplateArgs) {
2639 R.suppressDiagnostics();
2650 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2665 if (S && (Corrected =
2666 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS,
2669 bool DroppedSpecifier =
2673 bool AcceptableWithRecovery =
false;
2674 bool AcceptableWithoutRecovery =
false;
2683 dyn_cast<FunctionTemplateDecl>(CD))
2687 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2688 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2694 ND = Best->FoundDecl;
2695 Corrected.setCorrectionDecl(ND);
2699 Corrected.setCorrectionDecl(ND);
2710 R.setNamingClass(
Record);
2727 AcceptableWithoutRecovery =
true;
2730 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2732 ? diag::note_implicit_param_decl
2733 : diag::note_previous_decl;
2736 PDiag(NoteID), AcceptableWithRecovery);
2739 PDiag(diag::err_no_member_suggest)
2741 << DroppedSpecifier << NameRange,
2742 PDiag(NoteID), AcceptableWithRecovery);
2752 return !AcceptableWithRecovery;
2760 Diag(R.getNameLoc(), diag::err_no_member)
2766 Diag(R.getNameLoc(), diagnostic) << Name << NameRange;
2787 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2795 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2796 DB << NameInfo.
getName() << RD;
2798 if (!ThisType.
isNull()) {
2801 Context,
nullptr, ThisType,
true,
2803 nullptr, NameInfo, TemplateArgs);
2819 bool HasTrailingLParen,
bool IsAddressOfOperand,
2821 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2822 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2823 "cannot be direct & operand and have a trailing lparen");
2852 if (
auto *VD = dyn_cast<ValueDecl>(R.getFoundDecl())) {
2866 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2874 false, TemplateKWLoc,
2878 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
2880 IsAddressOfOperand, TemplateArgs);
2884 !IvarLookupFollowUp);
2888 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
2890 IsAddressOfOperand, TemplateArgs);
2894 if (IvarLookupFollowUp) {
2904 if (R.isAmbiguous())
2909 if (R.empty() && HasTrailingLParen && II &&
2912 if (D) R.addDecl(D);
2919 if (R.empty() && !ADL) {
2922 TemplateKWLoc, TemplateArgs))
2927 if (IsInlineAsmIdentifier)
2935 "Typo correction callback misconfigured");
2949 assert(!R.empty() &&
2950 "DiagnoseEmptyLookup returned false but added no results");
2957 ExprResult E(
ObjC().LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2967 assert(!R.empty() || ADL);
2997 if (TemplateArgs || TemplateKWLoc.
isValid()) {
3006 "There should only be one declaration found.");
3021 if (R.isAmbiguous())
3024 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
3034 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
3035 if (CD->isInvalidDecl() || CD->isBeingDefined())
3045 if (
auto *TagD = dyn_cast<TagDecl>(TD)) {
3052 TL.setNameLoc(NameInfo.
getLoc());
3053 }
else if (
auto *TypedefD = dyn_cast<TypedefNameDecl>(TD)) {
3061 ET =
SemaRef.Context.getTypeDeclType(TD);
3069 unsigned DiagID = diag::err_typename_missing;
3071 DiagID = diag::ext_typename_missing;
3073 auto D =
Diag(Loc, DiagID);
3104 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
3112 bool PointerConversions =
false;
3114 DestRecordType =
Context.getCanonicalTagType(RD);
3116 DestRecordType =
Context.getAddrSpaceQualType(
3117 DestRecordType, FromPtrType
3122 DestType =
Context.getPointerType(DestRecordType);
3124 PointerConversions =
true;
3126 DestType = DestRecordType;
3127 FromRecordType = FromType;
3129 }
else if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
Member)) {
3130 if (!
Method->isImplicitObjectMemberFunction())
3133 DestType =
Method->getThisType().getNonReferenceType();
3134 DestRecordType =
Method->getFunctionObjectParameterType();
3138 PointerConversions =
true;
3140 FromRecordType = FromType;
3141 DestType = DestRecordType;
3146 if (FromAS != DestAS) {
3148 Context.removeAddrSpaceQualType(FromRecordType);
3150 Context.getAddrSpaceQualType(FromRecordTypeWithoutAS, DestAS);
3151 if (PointerConversions)
3152 FromTypeWithDestAS =
Context.getPointerType(FromTypeWithDestAS);
3166 if (
Context.hasSameUnqualifiedType(FromRecordType, DestRecordType))
3194 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3204 FromLoc, FromRange, &BasePath))
3207 if (PointerConversions)
3208 QType =
Context.getPointerType(QType);
3210 VK, &BasePath).
get();
3213 FromRecordType = QRecordType;
3217 if (
Context.hasSameUnqualifiedType(FromRecordType, DestRecordType))
3224 FromLoc, FromRange, &BasePath,
3233 DestType =
Context.getQualifiedType(DestType, FromTypeQuals);
3241 bool HasTrailingLParen) {
3243 if (!HasTrailingLParen)
3261 if (D->isCXXClassMember())
3272 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
3279 if (
const auto *FDecl = dyn_cast<FunctionDecl>(D)) {
3281 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3296 bool AcceptInvalid) {
3321 assert(R.isSingleResult() &&
"Expected only a single result");
3322 const auto *FD = dyn_cast<FunctionDecl>(R.getFoundDecl());
3324 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3329 bool AcceptInvalidDecl) {
3332 if (!NeedsADL && R.isSingleResult() &&
3336 R.getRepresentativeDecl(),
nullptr,
3350 R.suppressDiagnostics();
3354 R.getLookupNameInfo(), NeedsADL, R.begin(), R.end(),
3363 bool AcceptInvalidDecl) {
3364 assert(D &&
"Cannot refer to a NULL declaration");
3366 "Cannot refer unambiguously to a function template");
3385 Diag(Loc, diag::err_ref_non_value) << D << SS.
getRange();
3400 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3406 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3407 IndirectField && !IndirectField->isCXXClassMember())
3419 type =
type.getNonPackExpansionType();
3423#define ABSTRACT_DECL(kind)
3424#define VALUE(type, base)
3425#define DECL(type, base) case Decl::type:
3426#include "clang/AST/DeclNodes.inc"
3427 llvm_unreachable(
"invalid value decl kind");
3430 case Decl::ObjCAtDefsField:
3431 llvm_unreachable(
"forming non-member reference to ivar?");
3435 case Decl::EnumConstant:
3436 case Decl::UnresolvedUsingValue:
3437 case Decl::OMPDeclareReduction:
3438 case Decl::OMPDeclareMapper:
3447 case Decl::IndirectField:
3448 case Decl::ObjCIvar:
3450 "building reference to field in C?");
3460 case Decl::NonTypeTemplateParm: {
3462 type = reftype->getPointeeType();
3472 if (
type->isRecordType()) {
3473 type =
type.getUnqualifiedType().withConst();
3486 case Decl::VarTemplateSpecialization:
3487 case Decl::VarTemplatePartialSpecialization:
3488 case Decl::Decomposition:
3490 case Decl::OMPCapturedExpr:
3493 type->isVoidType()) {
3499 case Decl::ImplicitParam:
3500 case Decl::ParmVar: {
3510 if (!CapturedType.
isNull())
3511 type = CapturedType;
3516 case Decl::Function: {
3518 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
3555 case Decl::CXXDeductionGuide:
3556 llvm_unreachable(
"building reference to deduction guide");
3558 case Decl::MSProperty:
3560 case Decl::TemplateParamObject:
3566 case Decl::UnnamedGlobalConstant:
3570 case Decl::CXXMethod:
3575 dyn_cast<FunctionProtoType>(VD->getType()))
3576 if (proto->getReturnType() ==
Context.UnknownAnyTy) {
3589 case Decl::CXXConversion:
3590 case Decl::CXXDestructor:
3591 case Decl::CXXConstructor:
3603 if (VD->isInvalidDecl() && E)
3610 Target.resize(CharByteWidth * (Source.size() + 1));
3611 char *ResultPtr = &
Target[0];
3612 const llvm::UTF8 *ErrorPtr;
3614 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3624 Diag(Loc, diag::ext_predef_outside_function);
3625 currentDecl =
Context.getTranslationUnitDecl();
3635 bool ForceElaboratedPrinting =
3639 unsigned Length = Str.length();
3641 llvm::APInt LengthI(32, Length + 1);
3645 Context.adjustStringLiteralBaseType(
Context.WideCharTy.withConst());
3649 ResTy =
Context.getConstantArrayType(ResTy, LengthI,
nullptr,
3655 ResTy =
Context.adjustStringLiteralBaseType(
Context.CharTy.withConst());
3656 ResTy =
Context.getConstantArrayType(ResTy, LengthI,
nullptr,
3675 StringRef ThisTok =
PP.getSpelling(
Tok, CharBuffer, &
Invalid);
3681 if (Literal.hadError())
3685 if (Literal.isWide())
3691 else if (Literal.isUTF16())
3693 else if (Literal.isUTF32())
3702 if (Literal.isWide())
3704 else if (Literal.isUTF16())
3706 else if (Literal.isUTF32())
3708 else if (Literal.isUTF8())
3714 if (Literal.getUDSuffix().empty())
3724 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3729 Lit,
Tok.getLocation());
3733 unsigned IntSize =
Context.getTargetInfo().getIntWidth();
3735 llvm::APInt(IntSize, Val,
true),
3743 using llvm::APFloat;
3744 APFloat Val(Format);
3747 if (RM == llvm::RoundingMode::Dynamic)
3748 RM = llvm::RoundingMode::NearestTiesToEven;
3749 APFloat::opStatus result = Literal.GetFloatValue(Val, RM);
3753 if ((result & APFloat::opOverflow) ||
3754 ((result & APFloat::opUnderflow) && Val.isZero())) {
3755 unsigned diagnostic;
3757 if (result & APFloat::opOverflow) {
3758 diagnostic = diag::warn_float_overflow;
3759 APFloat::getLargest(Format).toString(buffer);
3761 diagnostic = diag::warn_float_underflow;
3762 APFloat::getSmallest(Format).toString(buffer);
3765 S.
Diag(Loc, diagnostic) << Ty << buffer.str();
3768 bool isExact = (result == APFloat::opOK);
3773 assert(E &&
"Invalid expression");
3780 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3784 llvm::APSInt ValueAPS;
3795 bool ValueIsPositive =
3796 AllowZero ? ValueAPS.isNonNegative() : ValueAPS.isStrictlyPositive();
3797 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3799 <<
toString(ValueAPS, 10) << ValueIsPositive;
3809 if (
Tok.getLength() == 1 ||
Tok.getKind() == tok::binary_data) {
3810 const uint8_t Val =
PP.getSpellingOfSingleCharacterNumericConstant(
Tok);
3819 SpellingBuffer.resize(
Tok.getLength() + 1);
3823 StringRef TokSpelling =
PP.getSpelling(
Tok, SpellingBuffer, &
Invalid);
3828 PP.getSourceManager(),
PP.getLangOpts(),
3829 PP.getTargetInfo(),
PP.getDiagnostics());
3830 if (Literal.hadError)
3833 if (Literal.hasUDSuffix()) {
3841 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3844 if (Literal.isFloatingLiteral()) {
3848 CookedTy =
Context.LongDoubleTy;
3853 CookedTy =
Context.UnsignedLongLongTy;
3857 Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
3869 !Literal.isImaginary)) {
3878 if (Literal.isFloatingLiteral()) {
3881 llvm::APInt ResultVal(
Context.getTargetInfo().getLongLongWidth(), 0);
3882 if (Literal.GetIntegerValue(ResultVal))
3883 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3895 unsigned Length = Literal.getUDSuffixOffset();
3902 false, StrTy, TokLoc);
3913 bool CharIsUnsigned =
Context.CharTy->isUnsignedIntegerType();
3914 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3915 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3916 Value = TokSpelling[I];
3924 llvm_unreachable(
"unexpected literal operator lookup result");
3930 if (Literal.isFixedPointLiteral()) {
3933 if (Literal.isAccum) {
3934 if (Literal.isHalf) {
3936 }
else if (Literal.isLong) {
3941 }
else if (Literal.isFract) {
3942 if (Literal.isHalf) {
3944 }
else if (Literal.isLong) {
3951 if (Literal.isUnsigned) Ty =
Context.getCorrespondingUnsignedType(Ty);
3953 bool isSigned = !Literal.isUnsigned;
3954 unsigned scale =
Context.getFixedPointScale(Ty);
3955 unsigned bit_width =
Context.getTypeInfo(Ty).Width;
3957 llvm::APInt Val(bit_width, 0, isSigned);
3958 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3959 bool ValIsZero = Val.isZero() && !Overflowed;
3961 auto MaxVal =
Context.getFixedPointMax(Ty).getValue();
3962 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3968 else if (Val.ugt(MaxVal) || Overflowed)
3969 Diag(
Tok.getLocation(), diag::err_too_large_for_fixed_point);
3972 Tok.getLocation(), scale);
3973 }
else if (Literal.isFloatingLiteral()) {
3975 if (Literal.isHalf){
3980 Diag(
Tok.getLocation(), diag::err_half_const_requires_fp16);
3983 }
else if (Literal.isFloat)
3985 else if (Literal.isLong)
3987 else if (Literal.isFloat16)
3989 else if (Literal.isFloat128)
4006 Diag(
Tok.getLocation(), diag::warn_double_const_requires_fp64)
4011 }
else if (!Literal.isIntegerLiteral()) {
4017 if (Literal.isSizeT)
4020 ? diag::warn_cxx20_compat_size_t_suffix
4021 : diag::ext_cxx23_size_t_suffix
4022 : diag::err_cxx23_size_t_suffix);
4029 if (Literal.isBitInt)
4030 PP.Diag(
Tok.getLocation(),
4033 : diag::ext_c23_bitint_suffix);
4042 unsigned BitsNeeded =
Context.getTargetInfo().getIntMaxTWidth();
4043 if (Literal.isBitInt)
4044 BitsNeeded = llvm::APInt::getSufficientBitsNeeded(
4045 Literal.getLiteralDigits(), Literal.getRadix());
4046 if (Literal.MicrosoftInteger) {
4047 if (Literal.MicrosoftInteger == 128 &&
4048 !
Context.getTargetInfo().hasInt128Type())
4049 PP.Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4050 << Literal.isUnsigned;
4051 BitsNeeded = Literal.MicrosoftInteger;
4054 llvm::APInt ResultVal(BitsNeeded, 0);
4056 if (Literal.GetIntegerValue(ResultVal)) {
4058 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4060 Ty =
Context.UnsignedLongLongTy;
4061 assert(
Context.getTypeSize(Ty) == ResultVal.getBitWidth() &&
4062 "long long is not intmax_t?");
4069 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
4076 Literal.isLong =
true;
4077 Literal.isLongLong =
false;
4084 if (Literal.MicrosoftInteger) {
4085 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
4089 Width = Literal.MicrosoftInteger;
4090 Ty =
Context.getIntTypeForBitwidth(Width,
4091 !Literal.isUnsigned);
4097 if (Literal.isBitInt) {
4100 Width = std::max(ResultVal.getActiveBits(), 1u) +
4101 (Literal.isUnsigned ? 0u : 1u);
4105 unsigned int MaxBitIntWidth =
4106 Context.getTargetInfo().getMaxBitIntWidth();
4107 if (Width > MaxBitIntWidth) {
4108 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4109 << Literal.isUnsigned;
4110 Width = MaxBitIntWidth;
4117 ResultVal = ResultVal.zextOrTrunc(Width);
4118 Ty =
Context.getBitIntType(Literal.isUnsigned, Width);
4122 if (Literal.isSizeT) {
4123 assert(!Literal.MicrosoftInteger &&
4124 "size_t literals can't be Microsoft literals");
4125 unsigned SizeTSize =
Context.getTargetInfo().getTypeWidth(
4126 Context.getTargetInfo().getSizeType());
4129 if (ResultVal.isIntN(SizeTSize)) {
4131 if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4132 Ty =
Context.getSignedSizeType();
4133 else if (AllowUnsigned)
4139 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong &&
4142 unsigned IntSize =
Context.getTargetInfo().getIntWidth();
4145 if (ResultVal.isIntN(IntSize)) {
4147 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
4149 else if (AllowUnsigned)
4156 if (Ty.
isNull() && !Literal.isLongLong && !Literal.isSizeT) {
4157 unsigned LongSize =
Context.getTargetInfo().getLongWidth();
4160 if (ResultVal.isIntN(LongSize)) {
4162 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4164 else if (AllowUnsigned)
4169 const unsigned LongLongSize =
4170 Context.getTargetInfo().getLongLongWidth();
4174 ? diag::warn_old_implicitly_unsigned_long_cxx
4176 ext_old_implicitly_unsigned_long_cxx
4177 : diag::warn_old_implicitly_unsigned_long)
4178 << (LongLongSize > LongSize ? 0
4187 if (Ty.
isNull() && !Literal.isSizeT) {
4188 unsigned LongLongSize =
Context.getTargetInfo().getLongLongWidth();
4191 if (ResultVal.isIntN(LongLongSize)) {
4195 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4196 (
getLangOpts().MSVCCompat && Literal.isLongLong)))
4198 else if (AllowUnsigned)
4199 Ty =
Context.UnsignedLongLongTy;
4200 Width = LongLongSize;
4206 ? diag::warn_cxx98_compat_longlong
4207 : diag::ext_cxx11_longlong);
4209 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
4217 if (Literal.isSizeT)
4218 Diag(
Tok.getLocation(), diag::err_size_t_literal_too_large)
4219 << Literal.isUnsigned;
4222 diag::ext_integer_literal_too_large_for_signed);
4223 Ty =
Context.UnsignedLongLongTy;
4224 Width =
Context.getTargetInfo().getLongLongWidth();
4227 if (ResultVal.getBitWidth() != Width)
4228 ResultVal = ResultVal.trunc(Width);
4234 if (Literal.isImaginary) {
4241 DiagId = diag::ext_gnu_imaginary_constant;
4243 DiagId = diag::warn_c23_compat_imaginary_constant;
4245 DiagId = diag::ext_c2y_imaginary_constant;
4246 Diag(
Tok.getLocation(), DiagId);
4252 assert(E &&
"ActOnParenExpr() missing expr");
4267 if (!(T->isArithmeticType() || T->isVoidType() || T->isVectorType())) {
4268 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
4273 assert((T->isVoidType() || !T->isIncompleteType()) &&
4274 "Scalar types should always be complete");
4282 if (!T->isVectorType() && !T->isSizelessVectorType())
4283 return S.
Diag(Loc, diag::err_builtin_non_vector_type)
4285 <<
"__builtin_vectorelements" << T << ArgRange;
4287 if (
auto *FD = dyn_cast<FunctionDecl>(S.
CurContext)) {
4288 if (T->isSVESizelessBuiltinType()) {
4289 llvm::StringMap<bool> CallerFeatureMap;
4304 if (!T->isFunctionType() && !T->isFunctionPointerType() &&
4305 !T->isFunctionReferenceType() && !T->isMemberFunctionPointerType()) {
4306 S.
Diag(Loc, diag::err_ptrauth_type_disc_undiscriminated) << T << ArgRange;
4322 if (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4323 TraitKind == UETT_PreferredAlignOf) {
4326 if (T->isFunctionType()) {
4327 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
4334 if (T->isVoidType()) {
4335 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4336 : diag::ext_sizeof_alignof_void_type;
4351 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
4352 << T << (TraitKind == UETT_SizeOf)
4369 const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
4370 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4373 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4375 << ICE->getSubExpr()->getType();
4383 bool IsUnevaluatedOperand =
4384 (ExprKind == UETT_SizeOf || ExprKind == UETT_DataSizeOf ||
4385 ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4386 ExprKind == UETT_VecStep || ExprKind == UETT_CountOf);
4387 if (IsUnevaluatedOperand) {
4403 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4405 if (ExprKind == UETT_VecStep)
4409 if (ExprKind == UETT_VectorElements)
4420 if (
Context.getTargetInfo().getTriple().isWasm() &&
4431 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4434 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4439 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4458 if (ExprKind == UETT_CountOf) {
4463 Diag(E->
getExprLoc(), diag::err_countof_arg_not_array_type) << ExprType;
4473 if (ExprKind == UETT_SizeOf) {
4474 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreParens())) {
4475 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4476 QualType OType = PVD->getOriginalType();
4481 Diag(PVD->getLocation(), diag::note_declared_at);
4489 if (
const auto *BO = dyn_cast<BinaryOperator>(E->
IgnoreParens())) {
4506 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4513 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4515 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4516 D = ME->getMemberDecl();
4536 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4539 if (!FD->getParent()->isCompleteDefinition()) {
4540 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4549 if (!FD->getType()->isReferenceType())
4568 assert(T->isVariablyModifiedType());
4569 assert(CSI !=
nullptr);
4573 const Type *Ty = T.getTypePtr();
4575#define TYPE(Class, Base)
4576#define ABSTRACT_TYPE(Class, Base)
4577#define NON_CANONICAL_TYPE(Class, Base)
4578#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4579#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4580#include "clang/AST/TypeNodes.inc"
4587 case Type::ExtVector:
4588 case Type::ConstantMatrix:
4591 case Type::TemplateSpecialization:
4592 case Type::ObjCObject:
4593 case Type::ObjCInterface:
4594 case Type::ObjCObjectPointer:
4595 case Type::ObjCTypeParam:
4598 case Type::HLSLInlineSpirv:
4599 llvm_unreachable(
"type class is never variably-modified!");
4600 case Type::Adjusted:
4606 case Type::ArrayParameter:
4612 case Type::BlockPointer:
4615 case Type::LValueReference:
4616 case Type::RValueReference:
4619 case Type::MemberPointer:
4622 case Type::ConstantArray:
4623 case Type::IncompleteArray:
4627 case Type::VariableArray: {
4641 case Type::FunctionProto:
4642 case Type::FunctionNoProto:
4647 case Type::UnaryTransform:
4648 case Type::Attributed:
4649 case Type::BTFTagAttributed:
4650 case Type::OverflowBehavior:
4651 case Type::HLSLAttributedResource:
4652 case Type::SubstTemplateTypeParm:
4653 case Type::MacroQualified:
4654 case Type::CountAttributed:
4656 T = T.getSingleStepDesugaredType(Context);
4661 case Type::Decltype:
4664 case Type::PackIndexing:
4671 case Type::DeducedTemplateSpecialization:
4674 case Type::TypeOfExpr:
4680 case Type::PredefinedSugar:
4684 }
while (!T.isNull() && T->isVariablyModifiedType());
4707 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4708 ExprKind == UETT_OpenMPRequiredSimdAlign) {
4714 ? diag::warn_c2y_compat_alignof_incomplete_array
4715 : diag::ext_c2y_alignof_incomplete_array);
4716 ExprType =
Context.getBaseElementType(ExprType);
4719 if (ExprKind == UETT_VecStep)
4722 if (ExprKind == UETT_VectorElements)
4726 if (ExprKind == UETT_PtrAuthTypeDiscriminator)
4736 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4741 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4745 if (ExprKind == UETT_CountOf) {
4749 Diag(OpLoc, diag::err_countof_arg_not_array_type) << ExprType;
4756 if (
Context.getTargetInfo().getTriple().isWasm() &&
4758 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4772 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4776 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4777 DC = LSI->CallOperator;
4778 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4779 DC = CRSI->TheCapturedDecl;
4780 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4803 if (!T->isDependentType() &&
4812 (ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
4822 ExprKind, TInfo,
Context.getSizeType(), OpLoc, R.getEnd());
4838 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4840 }
else if (ExprKind == UETT_VecStep) {
4842 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4846 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4848 }
else if (ExprKind == UETT_VectorElements || ExprKind == UETT_SizeOf ||
4849 ExprKind == UETT_CountOf) {
4856 if ((ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
4891 UETT_AlignOf, KWName);
4904 if (
V.get()->isTypeDependent())
4916 return CT->getElementType();
4919 if (
V.get()->getType()->isArithmeticType())
4920 return V.get()->getType();
4925 if (PR.
get() !=
V.get()) {
4931 S.
Diag(Loc, diag::err_realimag_invalid_type) <<
V.get()->getType()
4932 << (IsReal ?
"__real" :
"__imag");
4943 default: llvm_unreachable(
"Unknown unary op!");
4944 case tok::plusplus: Opc = UO_PostInc;
break;
4945 case tok::minusminus: Opc = UO_PostDec;
break;
4964 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4967 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4974 auto *BaseNoParens =
Base->IgnoreParens();
4975 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4976 return MSProp->getPropertyDecl()->getType()->isArrayType();
4997 if (RTy->isIntegralOrUnscopedEnumerationType()) {
4999 Result = PT->getPointeeType();
5001 Result = AT->getElementType();
5004 Result = PT->getPointeeType();
5006 Result = AT->getElementType();
5009 return Result->isDependentType() ? Result : Ctx.
DependentTy;
5020 if (AS->isOMPArraySection())
5036 base = result.
get();
5043 auto CheckAndReportCommaError = [
this, base, rbLoc](
Expr *E) {
5045 Diag(E->getExprLoc(), diag::err_matrix_subscript_comma)
5056 Diag(base->
getExprLoc(), diag::err_matrix_separate_incomplete_index)
5062 auto *matSubscriptE = dyn_cast<MatrixSubscriptExpr>(base);
5063 if (matSubscriptE) {
5064 assert(ArgExprs.size() == 1);
5065 if (CheckAndReportCommaError(ArgExprs.front()))
5068 assert(matSubscriptE->isIncomplete() &&
5069 "base has to be an incomplete matrix subscript");
5071 matSubscriptE->getRowIdx(),
5072 ArgExprs.front(), rbLoc);
5080 CheckInvalidBuiltinCountedByRef(base,
5088 bool IsMSPropertySubscript =
false;
5091 if (!IsMSPropertySubscript) {
5095 base = result.
get();
5101 assert(ArgExprs.size() == 1);
5102 if (CheckAndReportCommaError(ArgExprs.front()))
5110 Expr *idx = ArgExprs[0];
5119 if (ArgExprs.size() == 1 &&
5120 ArgExprs[0]->getType()->isNonOverloadPlaceholderType()) {
5124 ArgExprs[0] = result.
get();
5136 base, ArgExprs.front(),
5149 if (IsMSPropertySubscript) {
5150 assert(ArgExprs.size() == 1);
5169 ArgExprs[0]->getType()->isRecordType())))) {
5187 return InitSeq.
Perform(*
this, Entity, Kind, E);
5201 RowIdx = RowR.
get();
5211 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5212 bool IsColumnIdx) ->
Expr * {
5220 if (std::optional<llvm::APSInt> Idx =
5222 if ((*Idx < 0 || *Idx >=
Dim)) {
5224 << IsColumnIdx <<
Dim;
5231 "should be able to convert any integer type to size type");
5232 return ConvExpr.
get();
5236 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5241 Context.getExtVectorType(MTy->getElementType(), MTy->getNumColumns());
5257 RowIdx = RowR.
get();
5261 Base, RowIdx, ColumnIdx,
Context.IncompleteMatrixIdxTy, RBLoc);
5272 ColumnIdx = ColumnR.
get();
5277 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5278 bool IsColumnIdx) ->
Expr * {
5286 if (std::optional<llvm::APSInt> Idx =
5288 if ((*Idx < 0 || *Idx >=
Dim)) {
5290 << IsColumnIdx <<
Dim;
5297 "should be able to convert any integer type to size type");
5298 return ConvExpr.
get();
5302 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5303 ColumnIdx = IsIndexValid(ColumnIdx, MTy->getNumColumns(),
true);
5304 if (!RowIdx || !ColumnIdx)
5308 MTy->getElementType(), RBLoc);
5311void Sema::CheckAddressOfNoDeref(
const Expr *E) {
5318 while ((
Member = dyn_cast<MemberExpr>(StrippedExpr)) && !
Member->isArrow())
5319 StrippedExpr =
Member->getBase()->IgnoreParenImpCasts();
5321 LastRecord.PossibleDerefs.erase(StrippedExpr);
5335 if (ResultTy->
hasAttr(attr::NoDeref)) {
5336 LastRecord.PossibleDerefs.insert(E);
5343 QualType BaseTy =
Base->getType();
5348 const MemberExpr *
Member =
nullptr;
5349 while ((
Member = dyn_cast<MemberExpr>(
Base->IgnoreParenCasts())) &&
5353 if (
const auto *Ptr = dyn_cast<PointerType>(
Base->getType())) {
5354 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
5355 LastRecord.PossibleDerefs.insert(E);
5371 for (
auto *Op : {LHSExp, RHSExp}) {
5372 Op = Op->IgnoreImplicit();
5373 if (Op->getType()->isArrayType() && !Op->isLValue())
5396 Expr *BaseExpr, *IndexExpr;
5414 if (!
LangOpts.isSubscriptPointerArithmetic())
5430 if (!
LangOpts.isSubscriptPointerArithmetic()) {
5431 Diag(LLoc, diag::err_subscript_nonfragile_interface)
5455 LHSExp = Materialized.
get();
5462 Qualifiers BaseQuals = BaseType.getQualifiers();
5464 Qualifiers Combined = BaseQuals + MemberQuals;
5465 if (Combined != MemberQuals)
5466 ResultType =
Context.getQualifiedType(ResultType, Combined);
5476 CK_ArrayToPointerDecay).
get();
5482 }
else if (RHSTy->isArrayType()) {
5487 CK_ArrayToPointerDecay).
get();
5494 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
5499 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
5505 std::optional<llvm::APSInt> IntegerContantExpr =
5507 if (!IntegerContantExpr.has_value() ||
5508 IntegerContantExpr.value().isNegative())
5524 Diag(LLoc, diag::ext_gnu_subscript_void_type)
5535 diag::err_subscript_incomplete_or_sizeless_type, BaseExpr))
5548 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
5552 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
5553 DC = LSI->CallOperator;
5554 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
5555 DC = CRSI->TheCapturedDecl;
5556 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
5574 bool SkipImmediateInvocations) {
5575 if (Param->hasUnparsedDefaultArg()) {
5576 assert(!RewrittenInit &&
"Should not have a rewritten init expression yet");
5580 Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD;
5581 Diag(CallLoc, diag::note_recursive_default_argument_used_here);
5582 Param->setInvalidDecl();
5586 Diag(CallLoc, diag::err_use_of_default_argument_to_function_declared_later)
5589 diag::note_default_argument_declared_here);
5593 if (Param->hasUninstantiatedDefaultArg()) {
5594 assert(!RewrittenInit &&
"Should not have a rewitten init expression yet");
5599 Expr *
Init = RewrittenInit ? RewrittenInit : Param->getInit();
5600 assert(
Init &&
"default argument but no initializer?");
5609 if (
auto *InitWithCleanup = dyn_cast<ExprWithCleanups>(
Init)) {
5612 Cleanup.setExprNeedsCleanups(InitWithCleanup->cleanupsHaveSideEffects());
5616 assert(!InitWithCleanup->getNumObjects() &&
5617 "default argument expression has capturing blocks?");
5630 SkipImmediateInvocations;
5718 if (!
SemaRef.CurrentInstantiationScope ||
5730 assert(Param->hasDefaultArg() &&
"can't build nonexistent default arg");
5734 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5735 InitializationContext =
5737 if (!InitializationContext.has_value())
5738 InitializationContext.emplace(CallLoc, Param,
CurContext);
5740 if (!
Init && !Param->hasUnparsedDefaultArg()) {
5755 if (Param->hasUninstantiatedDefaultArg()) {
5764 if (!NestedDefaultChecking)
5765 V.TraverseDecl(Param);
5769 if (
V.HasImmediateCalls ||
5770 (NeedRebuild && isa_and_present<ExprWithCleanups>(Param->getInit()))) {
5771 if (
V.HasImmediateCalls)
5781 Res = Immediate.TransformInitializer(Param->getInit(),
5795 CallLoc, FD, Param,
Init,
5796 NestedDefaultChecking))
5800 Init, InitializationContext->Context);
5810 ClassPattern->
lookup(Field->getDeclName());
5811 auto Rng = llvm::make_filter_range(
5822 assert(Field->hasInClassInitializer());
5828 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5829 InitializationContext =
5831 if (!InitializationContext.has_value())
5832 InitializationContext.emplace(Loc, Field,
CurContext);
5841 if (!Field->getInClassInitializer()) {
5847 assert(Pattern &&
"We must have set the Pattern!");
5851 Field->setInvalidDecl();
5863 if (!NestedDefaultChecking)
5864 V.TraverseDecl(Field);
5873 bool ContainsAnyTemporaries =
5874 isa_and_present<ExprWithCleanups>(Field->getInClassInitializer());
5875 if (Field->getInClassInitializer() &&
5876 !Field->getInClassInitializer()->containsErrors() &&
5877 (
V.HasImmediateCalls || (NeedRebuild && ContainsAnyTemporaries))) {
5881 NestedDefaultChecking;
5889 Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
5895 Field->setInvalidDecl();
5901 if (Field->getInClassInitializer()) {
5902 Expr *E =
Init ?
Init : Field->getInClassInitializer();
5903 if (!NestedDefaultChecking)
5914 Field->setInvalidDecl();
5920 Field, InitializationContext->Context,
5939 Diag(Loc, diag::err_default_member_initializer_not_yet_parsed)
5940 << OutermostClass << Field;
5941 Diag(Field->getEndLoc(),
5942 diag::note_default_member_initializer_not_yet_parsed);
5945 Field->setInvalidDecl();
5953 if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
5955 else if (Fn && Fn->getType()->isBlockPointerType())
5959 if (
Method->isInstance())
5961 }
else if (Fn && Fn->getType() ==
Context.BoundMemberTy)
5974 FunctionName(FuncName) {}
5976 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
5985 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
5986 return std::make_unique<FunctionCallCCC>(*
this);
5990 const IdentifierInfo *
const FunctionName;
6006 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
6007 if (Corrected.isOverloaded()) {
6017 ND = Best->FoundDecl;
6018 Corrected.setCorrectionDecl(ND);
6024 ND = ND->getUnderlyingDecl();
6039 Fn = Fn->IgnoreParens();
6041 auto *UO = dyn_cast<UnaryOperator>(Fn);
6042 if (!UO || UO->getOpcode() != clang::UO_AddrOf)
6044 if (
auto *DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
6045 return DRE->hasQualifier();
6047 if (
auto *OVL = dyn_cast<OverloadExpr>(UO->getSubExpr()->IgnoreParens()))
6048 return bool(OVL->getQualifier());
6058 bool IsExecConfig) {
6062 if (
Context.BuiltinInfo.hasCustomTypechecking(ID))
6069 bool HasExplicitObjectParameter =
6071 unsigned ExplicitObjectParameterOffset = HasExplicitObjectParameter ? 1 : 0;
6075 unsigned FnKind = Fn->getType()->isBlockPointerType()
6082 if (Args.size() < NumParams) {
6083 if (Args.size() < MinArgs) {
6088 ? diag::err_typecheck_call_too_few_args_suggest
6089 : diag::err_typecheck_call_too_few_args_at_least_suggest;
6092 << FnKind << MinArgs - ExplicitObjectParameterOffset
6093 <<
static_cast<unsigned>(Args.size()) -
6094 ExplicitObjectParameterOffset
6096 }
else if (MinArgs - ExplicitObjectParameterOffset == 1 && FDecl &&
6101 ? diag::err_typecheck_call_too_few_args_one
6102 : diag::err_typecheck_call_too_few_args_at_least_one)
6103 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
6104 << HasExplicitObjectParameter << Fn->getSourceRange();
6107 ? diag::err_typecheck_call_too_few_args
6108 : diag::err_typecheck_call_too_few_args_at_least)
6109 << FnKind << MinArgs - ExplicitObjectParameterOffset
6110 <<
static_cast<unsigned>(Args.size()) -
6111 ExplicitObjectParameterOffset
6112 << HasExplicitObjectParameter << Fn->getSourceRange();
6115 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6123 assert((
Call->getNumArgs() == NumParams) &&
6124 "We should have reserved space for the default arguments before!");
6129 if (Args.size() > NumParams) {
6135 ? diag::err_typecheck_call_too_many_args_suggest
6136 : diag::err_typecheck_call_too_many_args_at_most_suggest;
6139 << FnKind << NumParams - ExplicitObjectParameterOffset
6140 <<
static_cast<unsigned>(Args.size()) -
6141 ExplicitObjectParameterOffset
6143 }
else if (NumParams - ExplicitObjectParameterOffset == 1 && FDecl &&
6146 Diag(Args[NumParams]->getBeginLoc(),
6147 MinArgs == NumParams
6148 ? diag::err_typecheck_call_too_many_args_one
6149 : diag::err_typecheck_call_too_many_args_at_most_one)
6150 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
6151 <<
static_cast<unsigned>(Args.size()) -
6152 ExplicitObjectParameterOffset
6153 << HasExplicitObjectParameter << Fn->getSourceRange()
6155 Args.back()->getEndLoc());
6157 Diag(Args[NumParams]->getBeginLoc(),
6158 MinArgs == NumParams
6159 ? diag::err_typecheck_call_too_many_args
6160 : diag::err_typecheck_call_too_many_args_at_most)
6161 << FnKind << NumParams - ExplicitObjectParameterOffset
6162 <<
static_cast<unsigned>(Args.size()) -
6163 ExplicitObjectParameterOffset
6164 << HasExplicitObjectParameter << Fn->getSourceRange()
6166 Args.back()->getEndLoc());
6169 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6174 Call->shrinkNumArgs(NumParams);
6185 unsigned TotalNumArgs = AllArgs.size();
6186 for (
unsigned i = 0; i < TotalNumArgs; ++i)
6187 Call->setArg(i, AllArgs[i]);
6189 Call->computeDependence();
6198 bool IsListInitialization) {
6203 for (
unsigned i = FirstParam; i < NumParams; i++) {
6208 if (ArgIx < Args.size()) {
6209 Arg = Args[ArgIx++];
6212 diag::err_call_incomplete_argument, Arg))
6216 bool CFAudited =
false;
6218 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6219 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6222 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6223 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6229 BE->getBlockDecl()->setDoesNotEscape();
6250 if (
const auto *OBT = Arg->
getType()->
getAs<OverflowBehaviorType>();
6253 OBT->isUnsignedIntegerOrEnumerationType() && OBT->isWrapKind();
6255 isPedantic ? diag::warn_obt_discarded_at_function_boundary_pedantic
6256 : diag::warn_obt_discarded_at_function_boundary)
6257 << Arg->
getType() << ProtoArgType;
6261 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
6267 assert(Param &&
"can't use default arguments without a known callee");
6279 CheckArrayAccess(Arg);
6284 AllArgs.push_back(Arg);
6293 for (
Expr *A : Args.slice(ArgIx)) {
6297 AllArgs.push_back(arg.get());
6302 for (
Expr *A : Args.slice(ArgIx)) {
6305 AllArgs.push_back(Arg.
get());
6310 for (
Expr *A : Args.slice(ArgIx))
6311 CheckArrayAccess(A);
6319 TL = DTL.getOriginalLoc();
6322 << ATL.getLocalSourceRange();
6328 const Expr *ArgExpr) {
6333 QualType OrigTy = Param->getOriginalType();
6358 Diag(CallLoc, diag::warn_static_array_too_small)
6366 std::optional<CharUnits> ArgSize =
6368 std::optional<CharUnits> ParmSize =
6370 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
6371 Diag(CallLoc, diag::warn_static_array_too_small)
6373 << (
unsigned)ParmSize->getQuantity() << 1;
6387 if (!placeholder)
return false;
6389 switch (placeholder->
getKind()) {
6391#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6392 case BuiltinType::Id:
6393#include "clang/Basic/OpenCLImageTypes.def"
6394#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6395 case BuiltinType::Id:
6396#include "clang/Basic/OpenCLExtensionTypes.def"
6399#define SVE_TYPE(Name, Id, SingletonId) \
6400 case BuiltinType::Id:
6401#include "clang/Basic/AArch64ACLETypes.def"
6402#define PPC_VECTOR_TYPE(Name, Id, Size) \
6403 case BuiltinType::Id:
6404#include "clang/Basic/PPCTypes.def"
6405#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6406#include "clang/Basic/RISCVVTypes.def"
6407#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6408#include "clang/Basic/WebAssemblyReferenceTypes.def"
6409#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
6410#include "clang/Basic/AMDGPUTypes.def"
6411#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6412#include "clang/Basic/HLSLIntangibleTypes.def"
6413#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
6414#define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
6415#include "clang/AST/BuiltinTypes.def"
6418 case BuiltinType::UnresolvedTemplate:
6421 case BuiltinType::Overload:
6426 case BuiltinType::ARCUnbridgedCast:
6430 case BuiltinType::PseudoObject:
6435 case BuiltinType::UnknownAny:
6439 case BuiltinType::BoundMember:
6440 case BuiltinType::BuiltinFn:
6441 case BuiltinType::IncompleteMatrixIdx:
6442 case BuiltinType::ArraySection:
6443 case BuiltinType::OMPArrayShaping:
6444 case BuiltinType::OMPIterator:
6448 llvm_unreachable(
"bad builtin type kind");
6454 bool hasInvalid =
false;
6455 for (
size_t i = 0, e = args.size(); i != e; i++) {
6458 if (result.
isInvalid()) hasInvalid =
true;
6459 else args[i] = result.
get();
6483 if (!Context.BuiltinInfo.hasPtrArgsOrResult(FDecl->
getBuiltinID()) || !FT ||
6487 bool NeedsNewDecl =
false;
6507 if (!ParamType->isPointerType() ||
6508 ParamType->getPointeeType().hasAddressSpace() ||
6509 !ArgType->isPointerType() ||
6510 !ArgType->getPointeeType().hasAddressSpace() ||
6512 OverloadParams.push_back(ParamType);
6517 NeedsNewDecl =
true;
6518 LangAS AS = ArgType->getPointeeType().getAddressSpace();
6520 PointeeType = Context.getAddrSpaceQualType(PointeeType, AS);
6521 OverloadParams.push_back(Context.getPointerType(PointeeType));
6531 OverloadParams, EPI);
6541 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
6548 Params.push_back(Parm);
6550 OverloadDecl->setParams(Params);
6554 if (FDecl->
hasAttr<CUDAHostAttr>())
6555 OverloadDecl->
addAttr(CUDAHostAttr::CreateImplicit(Context));
6556 if (FDecl->
hasAttr<CUDADeviceAttr>())
6557 OverloadDecl->
addAttr(CUDADeviceAttr::CreateImplicit(Context));
6560 return OverloadDecl;
6571 !Callee->isVariadic())
6573 if (Callee->getMinRequiredArguments() > ArgExprs.size())
6576 if (
const EnableIfAttr *
Attr =
6577 S.
CheckEnableIf(Callee, Fn->getBeginLoc(), ArgExprs,
true)) {
6578 S.
Diag(Fn->getBeginLoc(),
6580 ? diag::err_ovl_no_viable_member_function_in_call
6581 : diag::err_ovl_no_viable_function_in_call)
6582 << Callee << Callee->getSourceRange();
6583 S.
Diag(Callee->getLocation(),
6584 diag::note_ovl_candidate_disabled_by_function_cond_attr)
6585 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
6593 const auto GetFunctionLevelDCIfCXXClass =
6601 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
6602 return MD->
getParent()->getCanonicalDecl();
6605 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
6606 return RD->getCanonicalDecl();
6613 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
6614 if (!CurParentClass)
6621 assert(NamingClass &&
"Must have naming class even for implicit access");
6627 return CurParentClass == NamingClass ||
6676 if (
Call->getNumArgs() != 1)
6679 const Expr *E =
Call->getCallee()->IgnoreParenImpCasts();
6682 const DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(E);
6695 if (BuiltinID != Builtin::BImove && BuiltinID != Builtin::BIforward)
6698 S.
Diag(DRE->
getLocation(), diag::warn_unqualified_call_to_std_cast_function)
6709 if (
Call.isInvalid())
6714 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn);
6715 ULE && ULE->hasExplicitTemplateArgs() && ULE->decls().empty()) {
6716 DiagCompat(Fn->getExprLoc(), diag_compat::adl_only_template_id)
6724 if (
const auto *CE = dyn_cast<CallExpr>(
Call.get()))
6730 if (
auto *DRE = dyn_cast<DeclRefExpr>(Fn->IgnoreParens());
6731 DRE &&
Call.get()->isValueDependent()) {
6741 if (T->isDependentType())
6744 if (T == Context.BoundMemberTy || T == Context.UnknownAnyTy ||
6745 T == Context.BuiltinFnTy || T == Context.OverloadTy ||
6746 T->isFunctionType() || T->isFunctionReferenceType() ||
6747 T->isMemberFunctionPointerType() || T->isFunctionPointerType() ||
6748 T->isBlockPointerType() || T->isRecordType())
6757 Expr *ExecConfig,
bool IsExecConfig,
6758 bool AllowRecovery) {
6769 for (
const Expr *Arg : ArgExprs)
6770 if (CheckInvalidBuiltinCountedByRef(Arg,
6777 if (!ArgExprs.empty()) {
6779 Diag(Fn->getBeginLoc(), diag::err_pseudo_dtor_call_with_args)
6782 ArgExprs.back()->getEndLoc()));
6788 if (Fn->getType() ==
Context.PseudoObjectTy) {
6805 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->IgnoreParens()),
6813 Diag(LParenLoc, diag::err_typecheck_call_not_function)
6814 << Fn->getType() << Fn->getSourceRange());
6822 if (Fn->getType()->isRecordType())
6826 if (Fn->getType() ==
Context.UnknownAnyTy) {
6832 if (Fn->getType() ==
Context.BoundMemberTy) {
6834 RParenLoc, ExecConfig, IsExecConfig,
6840 if (Fn->getType() ==
Context.OverloadTy) {
6851 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
6854 RParenLoc, ExecConfig, IsExecConfig,
6860 if (Fn->getType() ==
Context.UnknownAnyTy) {
6866 Expr *NakedFn = Fn->IgnoreParens();
6868 bool CallingNDeclIndirectly =
false;
6870 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
6871 if (UnOp->getOpcode() == UO_AddrOf) {
6872 CallingNDeclIndirectly =
true;
6877 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
6878 NDecl = DRE->getDecl();
6891 Fn->getValueKind(), FDecl,
nullptr, DRE->isNonOdrUse());
6894 }
else if (
auto *ME = dyn_cast<MemberExpr>(NakedFn))
6895 NDecl = ME->getMemberDecl();
6897 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
6899 FD,
true, Fn->getBeginLoc()))
6911 for (
unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size();
6914 if (!ArgExprs[Idx] || !Param || !Param->getType()->isPointerType() ||
6915 !ArgExprs[Idx]->getType()->isPointerType())
6919 auto ArgTy = ArgExprs[Idx]->getType();
6920 auto ArgPtTy = ArgTy->getPointeeType();
6921 auto ArgAS = ArgPtTy.getAddressSpace();
6924 bool NeedImplicitASC =
6929 if (!NeedImplicitASC)
6933 if (ArgExprs[Idx]->isGLValue()) {
6937 ArgExprs[Idx] = Res.
get();
6941 Qualifiers ArgPtQuals = ArgPtTy.getQualifiers();
6944 Context.getQualifiedType(ArgPtTy.getUnqualifiedType(), ArgPtQuals);
6947 ArgTy.getQualifiers());
6951 CK_AddressSpaceConversion)
6957 if (
Context.isDependenceAllowed() &&
6960 assert((Fn->containsErrors() ||
6961 llvm::any_of(ArgExprs,
6962 [](
clang::Expr *E) { return E->containsErrors(); })) &&
6963 "should only occur in error-recovery path.");
6968 ExecConfig, IsExecConfig);
6973 std::string Name =
Context.BuiltinInfo.getName(Id);
6979 assert(BuiltInDecl &&
"failed to find builtin declaration");
6983 assert(DeclRef.
isUsable() &&
"Builtin reference cannot fail");
6988 assert(!
Call.isInvalid() &&
"Call to builtin cannot fail!");
7008 Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
7026 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
7027 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
7030 switch (BuiltinID) {
7031 case Builtin::BI__builtin_longjmp:
7032 case Builtin::BI__builtin_setjmp:
7033 case Builtin::BI__sigsetjmp:
7034 case Builtin::BI_longjmp:
7035 case Builtin::BI_setjmp:
7036 case Builtin::BIlongjmp:
7037 case Builtin::BIsetjmp:
7038 case Builtin::BIsiglongjmp:
7039 case Builtin::BIsigsetjmp:
7052 if (DeferParent->
Contains(*CurScope) &&
7054 Diag(Fn->getExprLoc(), diag::err_defer_invalid_sjlj) << FDecl;
7059 if (FDecl->
hasAttr<AnyX86InterruptAttr>()) {
7060 Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
7063 if (FDecl->
hasAttr<ARMInterruptAttr>()) {
7064 Diag(Fn->getExprLoc(), diag::err_arm_interrupt_called);
7073 if (Caller->hasAttr<AnyX86InterruptAttr>() ||
7074 Caller->hasAttr<AnyX86NoCallerSavedRegistersAttr>()) {
7076 bool HasNonGPRRegisters =
7078 if (HasNonGPRRegisters &&
7079 (!FDecl || !FDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>())) {
7080 Diag(Fn->getExprLoc(), diag::warn_anyx86_excessive_regsave)
7081 << (Caller->hasAttr<AnyX86InterruptAttr>() ? 0 : 1);
7100 Fn->getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn)) {
7116 if (!BuiltinID || !
Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
7123 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7124 << Fn->getType() << Fn->getSourceRange());
7130 if (Fn->getType() ==
Context.UnknownAnyTy) {
7138 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7139 << Fn->getType() << Fn->getSourceRange());
7146 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
7147 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
7151 assert(UsesADL == ADLCallKind::NotADL &&
7152 "CUDAKernelCallExpr should not use ADL");
7163 if (BuiltinID &&
Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
7164 ExprResult E = CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7173 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
7174 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
7175 << FDecl << Fn->getSourceRange());
7181 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
7182 << Fn->getType() << Fn->getSourceRange());
7185 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
7186 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
7187 << FDecl << Fn->getSourceRange());
7201 if (
Context.getTargetInfo().getTriple().isWasm()) {
7202 for (
const Expr *Arg : Args) {
7203 if (Arg && Arg->getType()->isWebAssemblyTableType()) {
7205 diag::err_wasm_table_as_function_parameter));
7223 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
7224 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
7225 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
7244 if (!Proto && !Args.empty() &&
7246 !
Diags.isIgnored(diag::warn_strict_uses_without_prototype,
7248 Diag(LParenLoc, diag::warn_strict_uses_without_prototype)
7249 << (FDecl !=
nullptr) << FDecl;
7252 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7253 Expr *Arg = Args[i];
7255 if (Proto && i < Proto->getNumParams()) {
7257 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
7275 diag::err_call_incomplete_argument, Arg))
7284 if (
Method->isImplicitObjectMemberFunction())
7285 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
7286 << Fn->getSourceRange() << 0);
7294 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7295 if (
const auto *RT =
7296 dyn_cast<RecordType>(Args[i]->
getType().getCanonicalType())) {
7297 if (RT->getDecl()->isOrContainsUnion())
7298 Diag(Args[i]->getBeginLoc(), diag::warn_cmse_nonsecure_union)
7309 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
7312 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7314 if (CheckPointerCall(NDecl, TheCall, Proto))
7317 if (CheckOtherCall(TheCall, Proto))
7327 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
7328 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
7333 TInfo =
Context.getTrivialTypeSourceInfo(literalType);
7345 LParenLoc,
Context.getBaseElementType(literalType),
7346 diag::err_array_incomplete_or_sizeless_type,
7369 ? diag::err_variable_object_no_init
7370 : diag::err_compound_literal_with_vla_type;
7377 diag::err_typecheck_decl_incomplete_type,
7392 LiteralExpr =
Result.get();
7399 bool IsFileScope = !
CurContext->isFunctionOrMethod() &&
7430 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
7431 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
7433 if (!
Init->isTypeDependent() && !
Init->isValueDependent() &&
7435 Diag(
Init->getExprLoc(), diag::err_init_element_not_constant)
7436 <<
Init->getSourceBitField();
7444 LiteralExpr, IsFileScope);
7456 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
7474 Cleanup.setExprNeedsCleanups(
true);
7493 bool DiagnosedArrayDesignator =
false;
7494 bool DiagnosedNestedDesignator =
false;
7495 bool DiagnosedMixedDesignator =
false;
7499 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7500 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
7502 FirstDesignator = DIE->getBeginLoc();
7507 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
7508 DiagnosedNestedDesignator =
true;
7509 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
7510 << DIE->getDesignatorsSourceRange();
7513 for (
auto &Desig : DIE->designators()) {
7514 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
7515 DiagnosedArrayDesignator =
true;
7516 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
7517 << Desig.getSourceRange();
7521 if (!DiagnosedMixedDesignator &&
7523 DiagnosedMixedDesignator =
true;
7524 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7525 << DIE->getSourceRange();
7526 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
7527 << InitArgList[0]->getSourceRange();
7531 DiagnosedMixedDesignator =
true;
7533 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7534 << DIE->getSourceRange();
7535 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
7536 << InitArgList[I]->getSourceRange();
7540 if (FirstDesignator.
isValid()) {
7544 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
7546 ? diag::warn_cxx17_compat_designated_init
7547 : diag::ext_cxx_designated_init);
7549 Diag(FirstDesignator, diag::ext_designated_init);
7564 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7565 if (InitArgList[I]->
getType()->isNonOverloadPlaceholderType()) {
7572 InitArgList[I] = result.
get();
7592 Cleanup.setExprNeedsCleanups(
true);
7601 if (
Context.hasSameUnqualifiedType(SrcTy, DestTy))
7606 llvm_unreachable(
"member pointer type in C");
7615 if (SrcAS != DestAS)
7616 return CK_AddressSpaceConversion;
7617 if (
Context.hasCvrSimilarType(SrcTy, DestTy))
7623 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
7628 return CK_CPointerToObjCPointerCast;
7630 return CK_BlockPointerToObjCPointerCast;
7632 return CK_PointerToBoolean;
7634 return CK_PointerToIntegral;
7640 llvm_unreachable(
"illegal cast from pointer");
7642 llvm_unreachable(
"Should have returned before this");
7647 return CK_FixedPointCast;
7649 return CK_FixedPointToBoolean;
7651 return CK_FixedPointToIntegral;
7653 return CK_FixedPointToFloating;
7657 diag::err_unimplemented_conversion_with_fixed_point_type)
7659 return CK_IntegralCast;
7664 llvm_unreachable(
"illegal cast to pointer type");
7666 llvm_unreachable(
"Should have returned before this");
7676 return CK_NullToPointer;
7677 return CK_IntegralToPointer;
7679 return CK_IntegralToBoolean;
7681 return CK_IntegralCast;
7683 return CK_IntegralToFloating;
7688 return CK_IntegralRealToComplex;
7692 CK_IntegralToFloating);
7693 return CK_FloatingRealToComplex;
7695 llvm_unreachable(
"member pointer type in C");
7697 return CK_IntegralToFixedPoint;
7699 llvm_unreachable(
"Should have returned before this");
7704 return CK_FloatingCast;
7706 return CK_FloatingToBoolean;
7708 return CK_FloatingToIntegral;
7713 return CK_FloatingRealToComplex;
7717 CK_FloatingToIntegral);
7718 return CK_IntegralRealToComplex;
7722 llvm_unreachable(
"valid float->pointer cast?");
7724 llvm_unreachable(
"member pointer type in C");
7726 return CK_FloatingToFixedPoint;
7728 llvm_unreachable(
"Should have returned before this");
7733 return CK_FloatingComplexCast;
7735 return CK_FloatingComplexToIntegralComplex;
7738 if (
Context.hasSameType(ET, DestTy))
7739 return CK_FloatingComplexToReal;
7741 return CK_FloatingCast;
7744 return CK_FloatingComplexToBoolean;
7748 CK_FloatingComplexToReal);
7749 return CK_FloatingToIntegral;
7753 llvm_unreachable(
"valid complex float->pointer cast?");
7755 llvm_unreachable(
"member pointer type in C");
7758 diag::err_unimplemented_conversion_with_fixed_point_type)
7760 return CK_IntegralCast;
7762 llvm_unreachable(
"Should have returned before this");
7767 return CK_IntegralComplexToFloatingComplex;
7769 return CK_IntegralComplexCast;
7772 if (
Context.hasSameType(ET, DestTy))
7773 return CK_IntegralComplexToReal;
7775 return CK_IntegralCast;
7778 return CK_IntegralComplexToBoolean;
7782 CK_IntegralComplexToReal);
7783 return CK_IntegralToFloating;
7787 llvm_unreachable(
"valid complex int->pointer cast?");
7789 llvm_unreachable(
"member pointer type in C");
7792 diag::err_unimplemented_conversion_with_fixed_point_type)
7794 return CK_IntegralCast;
7796 llvm_unreachable(
"Should have returned before this");
7799 llvm_unreachable(
"Unhandled scalar cast");
7806 len = vecType->getNumElements();
7807 eltType = vecType->getElementType();
7814 if (!
type->isRealType())
return false;
7824 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
7828 const auto *VecTy = SecondType->getAs<
VectorType>();
7832 return ValidScalableConversion(srcTy, destTy) ||
7833 ValidScalableConversion(destTy, srcTy);
7843 return matSrcType->
getNumRows() == matDestType->getNumRows() &&
7844 matSrcType->
getNumColumns() == matDestType->getNumColumns();
7850 uint64_t SrcLen, DestLen;
7860 uint64_t SrcEltSize =
Context.getTypeSize(SrcEltTy);
7861 uint64_t DestEltSize =
Context.getTypeSize(DestEltTy);
7863 return (SrcLen * SrcEltSize == DestLen * DestEltSize);
7868 "expected at least one type to be a vector here");
7870 bool IsSrcTyAltivec =
7886 return (IsSrcTyAltivec || IsDestTyAltivec);
7906 switch (
Context.getLangOpts().getLaxVectorConversions()) {
7913 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
7918 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
7935 return Diag(R.getBegin(), diag::err_invalid_conversion_between_matrixes)
7936 << DestTy << SrcTy << R;
7939 return Diag(R.getBegin(),
7940 diag::err_invalid_conversion_between_matrix_and_type)
7941 << SrcTy << DestTy << R;
7943 return Diag(R.getBegin(),
7944 diag::err_invalid_conversion_between_matrix_and_type)
7945 << DestTy << SrcTy << R;
7948 Kind = CK_MatrixCast;
7954 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
7958 return Diag(R.getBegin(),
7960 diag::err_invalid_conversion_between_vectors :
7961 diag::err_invalid_conversion_between_vector_and_integer)
7962 << VectorTy << Ty << R;
7964 return Diag(R.getBegin(),
7965 diag::err_invalid_conversion_between_vector_and_scalar)
7966 << VectorTy << Ty << R;
7975 if (DestElemTy == SplattedExpr->
getType())
7976 return SplattedExpr;
7989 CK_BooleanToSignedIntegral);
7990 SplattedExpr = CastExprRes.
get();
7991 CK = CK_IntegralToFloating;
7993 CK = CK_BooleanToSignedIntegral;
8000 SplattedExpr = CastExprRes.
get();
8008 if (DestElemTy == SplattedExpr->
getType())
8009 return SplattedExpr;
8018 SplattedExpr = CastExprRes.
get();
8036 !
Context.hasSameUnqualifiedType(DestTy, SrcTy) &&
8037 !
Context.areCompatibleVectorTypes(DestTy, SrcTy))) {
8038 Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors)
8039 << DestTy << SrcTy << R;
8050 return Diag(R.getBegin(),
8051 diag::err_invalid_conversion_between_vector_and_scalar)
8052 << DestTy << SrcTy << R;
8054 Kind = CK_VectorSplat;
8064 DestType == SourceType)
8072 if (!CE->getCalleeAllocSizeAttr())
8074 std::optional<llvm::APInt> AllocSize =
8075 CE->evaluateBytesReturnedByAllocSizeCall(S.
Context);
8078 if (!AllocSize || AllocSize->isZero())
8088 if (LhsSize && Size < LhsSize)
8090 << Size.getQuantity() << TargetType << LhsSize->getQuantity();
8098 "ActOnCastExpr(): missing type or expr");
8114 bool isVectorLiteral =
false;
8129 isVectorLiteral =
true;
8132 isVectorLiteral =
true;
8137 if (isVectorLiteral)
8167 "Expected paren or paren list expression");
8174 LiteralLParenLoc = PE->getLParenLoc();
8175 LiteralRParenLoc = PE->getRParenLoc();
8176 exprs = PE->getExprs();
8177 numExprs = PE->getNumExprs();
8204 if (numExprs == 1) {
8207 if (Literal.isInvalid())
8213 else if (numExprs < numElems) {
8215 diag::err_incorrect_number_of_vector_initializers);
8219 initExprs.append(exprs, exprs + numExprs);
8228 Diag(exprs[0]->getBeginLoc(), diag::err_typecheck_convert_incompatible)
8235 if (Literal.isInvalid())
8242 initExprs.append(exprs, exprs + numExprs);
8247 initExprs, LiteralRParenLoc);
8276 unsigned NumUserSpecifiedExprs,
8281 InitLoc, LParenLoc, RParenLoc);
8286 const Expr *NullExpr = LHSExpr;
8287 const Expr *NonPointerExpr = RHSExpr;
8294 NonPointerExpr = LHSExpr;
8316 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
8317 << NonPointerExpr->
getType() << DiagType
8329 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8330 << CondTy <<
Cond->getSourceRange();
8337 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
8338 << CondTy <<
Cond->getSourceRange();
8371 bool IsBlockPointer =
false;
8375 IsBlockPointer =
true;
8400 ResultAddrSpace = LAddrSpace;
8402 ResultAddrSpace = RAddrSpace;
8404 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8411 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
8416 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_ptrauth)
8433 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8435 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8443 lhptee, rhptee,
false,
false,
8446 if (CompositeTy.
isNull()) {
8463 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
8474 QualType ResultTy = [&, ResultAddrSpace]() {
8509 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
8562 bool IsIntFirstExpr) {
8564 !Int.get()->getType()->isIntegerType())
8567 Expr *Expr1 = IsIntFirstExpr ? Int.get() : PointerExpr;
8568 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.get();
8570 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
8574 CK_IntegralToPointer);
8608 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8614 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8620 if (LHSType == RHSType)
8630 (S, LHS, RHS, LHSType, RHSType,
false);
8664 llvm::raw_svector_ostream OS(Str);
8665 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
8666 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8667 << CondTy << OS.str();
8688 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8689 <<
Cond->getType() <<
Cond->getSourceRange();
8706 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
8707 << CondTy << VecResTy;
8712 QualType RVE = RV->getElementType();
8717 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8718 << CondTy << VecResTy;
8733 if (
Cond.isInvalid())
8744 bool IsBoolVecLang =
8773 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
8774 QualType Ty = CE->getCallee()->getType();
8806 if (
Context.isDependenceAllowed() &&
8812 "should only occur in error-recovery path.");
8819 Cond.get()->getType()->isExtVectorType())
8824 if (
Cond.isInvalid())
8847 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
8856 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
8875 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
8891 Context.hasSameUnqualifiedType(LHSTy, RHSTy))
8931 if (!compositeType.
isNull())
8932 return compositeType;
8962 if (
Context.hasSameType(LHSTy, RHSTy))
8963 return Context.getCommonSugaredType(LHSTy, RHSTy);
8966 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
8985 Self.Diag(Loc,
Note) << ParenRange;
9005 const Expr **RHSExprs) {
9010 if (
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
9011 E = MTE->getSubExpr();
9016 if (
const auto *OP = dyn_cast<BinaryOperator>(E);
9018 *Opcode = OP->getOpcode();
9019 *RHSExprs = OP->getRHS();
9024 if (
const auto *
Call = dyn_cast<CXXOperatorCallExpr>(E)) {
9025 if (
Call->getNumArgs() != 2)
9031 if (OO < OO_Plus || OO > OO_Arrow ||
9032 OO == OO_PlusPlus || OO == OO_MinusMinus)
9038 *RHSExprs =
Call->getArg(1);
9054 if (
const auto *OP = dyn_cast<BinaryOperator>(E))
9055 return OP->isComparisonOp() || OP->isLogicalOp();
9056 if (
const auto *OP = dyn_cast<UnaryOperator>(E))
9057 return OP->getOpcode() == UO_LNot;
9072 const Expr *RHSExpr) {
9074 const Expr *CondRHS;
9085 ? diag::warn_precedence_bitwise_conditional
9086 : diag::warn_precedence_conditional;
9088 Self.Diag(OpLoc, DiagID)
9094 Self.PDiag(diag::note_precedence_silence)
9099 Self.PDiag(diag::note_precedence_conditional_first),
9110 auto GetNullability = [](
QualType Ty) {
9111 std::optional<NullabilityKind> Kind = Ty->getNullability();
9121 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
9129 MergedKind = RHSKind;
9136 MergedKind = RHSKind;
9138 MergedKind = LHSKind;
9144 if (GetNullability(ResTy) == MergedKind)
9162 Expr *commonExpr =
nullptr;
9164 commonExpr = CondExpr;
9171 commonExpr = result.
get();
9185 commonExpr = commonRes.
get();
9195 commonExpr = MatExpr.
get();
9203 LHSExpr = CondExpr = opaqueValue;
9211 VK, OK, QuestionLoc);
9212 if (result.
isNull() ||
Cond.isInvalid() || LHS.isInvalid() ||
9219 CheckBoolLikeConversion(
Cond.get(), QuestionLoc);
9227 RHS.get(), result,
VK, OK);
9230 commonExpr, opaqueValue,
Cond.get(), LHS.get(), RHS.get(), QuestionLoc,
9231 ColonLoc, result,
VK, OK);
9235 unsigned FromAttributes = 0, ToAttributes = 0;
9236 if (
const auto *FromFn =
9237 dyn_cast<FunctionProtoType>(
Context.getCanonicalType(FromType)))
9240 if (
const auto *ToFn =
9241 dyn_cast<FunctionProtoType>(
Context.getCanonicalType(ToType)))
9245 return FromAttributes != ToAttributes;
9257 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9258 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9261 const Type *lhptee, *rhptee;
9263 std::tie(lhptee, lhq) =
9265 std::tie(rhptee, rhq) =
9336 diag::warn_typecheck_convert_incompatible_function_pointer_strict,
9360 ltrans = LUnderlying;
9361 rtrans = RUnderlying;
9379 if (ltrans == rtrans) {
9395 std::tie(lhptee, lhq) =
9397 std::tie(rhptee, rhq) =
9409 return AssignConvertType::
9410 IncompatibleNestedPointerAddressSpaceMismatch;
9414 if (lhptee == rhptee)
9434 const auto *LFPT = dyn_cast<FunctionProtoType>(LFT);
9435 const auto *RFPT = dyn_cast<FunctionProtoType>(RFT);
9438 LFPT->getParamTypes(),
9439 RFPT->getExtProtoInfo());
9444 LFPT->getParamTypes(), EPI);
9449 EPI.
ExtInfo = LFT->getExtInfo();
9451 RFPT->getParamTypes(), EPI);
9470 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9471 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9492 if (LQuals != RQuals)
9521 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
9522 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
9570 return VT->getElementType().getCanonicalType() == ElementType;
9600 LHSType =
Context.getCanonicalType(LHSType).getUnqualifiedType();
9601 RHSType =
Context.getCanonicalType(RHSType).getUnqualifiedType();
9604 if (LHSType == RHSType) {
9611 if (
const auto *AT = dyn_cast<AutoType>(LHSType)) {
9612 if (AT->isGNUAutoType()) {
9618 auto OBTResult =
Context.checkOBTAssignmentCompatibility(LHSType, RHSType);
9619 switch (OBTResult) {
9624 Kind = LHSType->
isBooleanType() ? CK_IntegralToBoolean : CK_IntegralCast;
9637 !
Context.areCompatibleOverflowBehaviorTypes(LHSPointee, RHSPointee)) {
9645 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
9650 if (Kind != CK_NoOp && ConvertRHS)
9652 Kind = CK_NonAtomicToAtomic;
9664 if (
Context.typesAreCompatible(LHSTypeRef->getPointeeType(), RHSType)) {
9665 Kind = CK_LValueBitCast;
9676 if (LHSExtType->getNumElements() != RHSExtType->getNumElements())
9680 RHSExtType->getElementType()->isIntegerType()) {
9681 Kind = CK_IntegralToBoolean;
9685 if (
Context.getLangOpts().OpenCL &&
9686 Context.areCompatibleVectorTypes(LHSType, RHSType)) {
9696 Kind = CK_VectorSplat;
9706 if (
Context.areCompatibleVectorTypes(LHSType, RHSType)) {
9718 if (
Context.getTargetInfo().getTriple().isPPC() &&
9720 !
Context.areCompatibleVectorTypes(RHSType, LHSType))
9722 << RHSType << LHSType;
9736 if (
Context.getTargetInfo().getTriple().isPPC() &&
9741 << RHSType << LHSType;
9752 if (
ARM().areCompatibleSveTypes(LHSType, RHSType) ||
9753 ARM().areLaxCompatibleSveTypes(LHSType, RHSType)) {
9761 if (
Context.areCompatibleRVVTypes(LHSType, RHSType) ||
9762 Context.areLaxCompatibleRVVTypes(LHSType, RHSType)) {
9791 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
9794 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
9796 if (AddrSpaceL != AddrSpaceR)
9797 Kind = CK_AddressSpaceConversion;
9798 else if (
Context.hasCvrSimilarType(RHSType, LHSType))
9808 Kind = CK_IntegralToPointer;
9816 if (LHSPointer->getPointeeType()->isVoidType()) {
9824 Context.getObjCClassRedefinitionType())) {
9835 if (LHSPointer->getPointeeType()->isVoidType()) {
9836 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
9841 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
9859 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
9865 Kind = CK_IntegralToPointer;
9871 Kind = CK_AnyPointerToBlockPointerCast;
9877 if (RHSPT->getPointeeType()->isVoidType()) {
9878 Kind = CK_AnyPointerToBlockPointerCast;
9892 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9894 !
ObjC().CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
9901 Kind = CK_IntegralToPointer;
9908 Kind = CK_CPointerToObjCPointerCast;
9918 Context.getObjCClassRedefinitionType())) {
9930 Kind = CK_BlockPointerToObjCPointerCast;
9942 Kind = CK_NullToPointer;
9949 if (LHSType ==
Context.BoolTy) {
9950 Kind = CK_PointerToBoolean;
9956 Kind = CK_PointerToIntegral;
9966 if (LHSType ==
Context.BoolTy) {
9967 Kind = CK_PointerToBoolean;
9973 Kind = CK_PointerToIntegral;
9982 if (
Context.typesAreCompatible(LHSType, RHSType)) {
9989 Kind = CK_IntToOCLSampler;
10023 const RecordType *UT =
ArgType->getAsUnionType();
10027 RecordDecl *UD = UT->getDecl()->getDefinitionOrSelf();
10028 if (!UD->
hasAttr<TransparentUnionAttr>())
10034 for (
auto *it : UD->
fields()) {
10035 if (it->getType()->isPointerType()) {
10074 bool DiagnoseCFAudited,
10078 assert((ConvertRHS || !
Diagnose) &&
"can't indicate whether we diagnosed");
10084 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
10088 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
10089 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
10091 diag::warn_noderef_to_dereferenceable_pointer)
10110 AllowedExplicit::None,
10122 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10123 !
ObjC().CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
10145 RHS.
get(), LHSType,
false, DAP))
10268 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10278 ObjC().CheckConversionToObjCLiteral(LHSType, E,
Diagnose))) {
10298struct OriginalOperand {
10299 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
10300 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
10301 Op = MTE->getSubExpr();
10302 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
10303 Op = BTE->getSubExpr();
10304 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
10305 Orig = ICE->getSubExprAsWritten();
10306 Conversion = ICE->getConversionFunction();
10310 QualType
getType()
const {
return Orig->getType(); }
10313 NamedDecl *Conversion;
10319 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
10321 Diag(Loc, diag::err_typecheck_invalid_operands)
10322 << OrigLHS.getType() << OrigRHS.getType()
10327 if (OrigLHS.Conversion) {
10328 Diag(OrigLHS.Conversion->getLocation(),
10329 diag::note_typecheck_invalid_operands_converted)
10332 if (OrigRHS.Conversion) {
10334 diag::note_typecheck_invalid_operands_converted)
10349 if (!(LHSNatVec && RHSNatVec)) {
10351 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
10352 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10354 <<
Vector->getSourceRange();
10358 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10381 unsigned &DiagID) {
10387 scalarCast = CK_IntegralToBoolean;
10392 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10397 scalarCast = CK_IntegralCast;
10402 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10405 scalarCast = CK_FloatingCast;
10408 scalarCast = CK_IntegralToFloating;
10417 if (scalarCast != CK_NoOp)
10428 assert(VecTy &&
"Expression E must be a vector");
10433 VecTy->getVectorKind());
10437 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10438 if (ICE->getSubExpr()->getType() == NewVecTy)
10439 return ICE->getSubExpr();
10441 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
10449 Expr *E = Int->get();
10453 QualType IntTy = Int->get()->getType().getUnqualifiedType();
10459 bool CstInt = Int->get()->EvaluateAsInt(EVResult, S.
Context);
10467 llvm::APSInt Result = EVResult.
Val.
getInt();
10468 unsigned NumBits = IntSigned
10469 ? (Result.isNegative() ? Result.getSignificantBits()
10470 : Result.getActiveBits())
10471 : Result.getActiveBits();
10478 return (IntSigned != OtherIntSigned &&
10484 return (Order < 0);
10491 if (Int->get()->containsErrors())
10494 QualType IntTy = Int->get()->getType().getUnqualifiedType();
10499 bool CstInt = Int->get()->EvaluateAsInt(EVResult, S.
Context);
10508 llvm::APSInt Result = EVResult.
Val.
getInt();
10511 llvm::APFloat::rmTowardZero);
10514 bool Ignored =
false;
10515 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
10517 if (Result != ConvertBack)
10523 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
10525 if (Bits > FloatPrec)
10538 QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
10539 QualType VectorTy =
Vector->get()->getType().getUnqualifiedType();
10544 "ExtVectorTypes should not be handled here!");
10545 VectorEltTy = VT->getElementType();
10550 llvm_unreachable(
"Only Fixed-Length and SVE Vector types are handled here");
10576 ScalarCast = CK_IntegralCast;
10580 ScalarCast = CK_FloatingToIntegral;
10588 llvm::APFloat
Result(0.0);
10594 bool CstScalar = Scalar->get()->isValueDependent() ||
10595 Scalar->get()->EvaluateAsFloat(Result, S.
Context);
10597 if (!CstScalar && Order < 0)
10603 bool Truncated =
false;
10605 llvm::APFloat::rmNearestTiesToEven, &Truncated);
10610 ScalarCast = CK_FloatingCast;
10615 ScalarCast = CK_IntegralToFloating;
10622 if (ScalarCast != CK_NoOp)
10630 bool AllowBothBool,
10631 bool AllowBoolConversions,
10632 bool AllowBoolOperation,
10633 bool ReportInvalid) {
10634 if (!IsCompAssign) {
10650 assert(LHSVecType || RHSVecType);
10658 (RHSVecType && RHSVecType->getElementType()->isMFloat8Type()))
10663 if (!AllowBothBool && LHSVecType &&
10669 if (!AllowBoolOperation &&
10674 if (
Context.hasSameType(LHSType, RHSType))
10675 return Context.getCommonSugaredType(LHSType, RHSType);
10678 if (LHSVecType && RHSVecType &&
10679 Context.areCompatibleVectorTypes(LHSType, RHSType)) {
10693 if (AllowBoolConversions && LHSVecType && RHSVecType &&
10696 Context.getTypeSize(RHSVecType->getElementType()))) {
10703 if (!IsCompAssign &&
10706 RHSVecType->getElementType()->isIntegerType()) {
10715 unsigned &SVEorRVV) {
10736 if (IsSveRVVConversion(LHSType, RHSType, SVEorRVV) ||
10737 IsSveRVVConversion(RHSType, LHSType, SVEorRVV)) {
10738 Diag(Loc, diag::err_typecheck_sve_rvv_ambiguous)
10739 << SVEorRVV << LHSType << RHSType;
10746 unsigned &SVEorRVV) {
10751 if (FirstVecType && SecondVecType) {
10754 SecondVecType->getVectorKind() ==
10759 SecondVecType->getVectorKind() ==
10761 SecondVecType->getVectorKind() ==
10763 SecondVecType->getVectorKind() ==
10772 if (SecondVecType &&
10785 if (IsSveRVVGnuConversion(LHSType, RHSType, SVEorRVV) ||
10786 IsSveRVVGnuConversion(RHSType, LHSType, SVEorRVV)) {
10787 Diag(Loc, diag::err_typecheck_sve_rvv_gnu_ambiguous)
10788 << SVEorRVV << LHSType << RHSType;
10794 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
10809 LHSType, RHSVecType->getElementType(),
10822 QualType VecType = LHSVecType ? LHSType : RHSType;
10823 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
10824 QualType OtherType = LHSVecType ? RHSType : LHSType;
10825 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
10827 if (
Context.getTargetInfo().getTriple().isPPC() &&
10829 !
Context.areCompatibleVectorTypes(RHSType, LHSType))
10830 Diag(Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType;
10834 if (!IsCompAssign) {
10853 if ((!RHSVecType && !RHSType->
isRealType()) ||
10855 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10856 << LHSType << RHSType
10868 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
10879 QualType Scalar = LHSVecType ? RHSType : LHSType;
10881 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
10883 diag::err_typecheck_vector_not_convertable_implict_truncation)
10884 << ScalarOrVector << Scalar <<
Vector;
10891 << LHSType << RHSType
10900 if (!IsCompAssign) {
10915 unsigned DiagID = diag::err_typecheck_invalid_operands;
10917 ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
10918 (RHSBuiltinTy && RHSBuiltinTy->isSVEBool()))) {
10924 if (
Context.hasSameType(LHSType, RHSType))
10939 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10946 Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
10947 Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC) {
10948 Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
10957 bool ScalarOrVector =
10960 Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
10961 << ScalarOrVector << Scalar <<
Vector;
10993 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
11005 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
11006 << LHSNull << NonNullType
11018 QualType ElementType = CT->getElementType().getCanonicalType();
11019 bool IsComplexRangePromoted = S.
getLangOpts().getComplexRange() ==
11026 const llvm::fltSemantics &ElementTypeSemantics =
11028 const llvm::fltSemantics &HigherElementTypeSemantics =
11031 if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
11032 llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
11039 if (
Type == HigherElementType) {
11051 const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
11052 const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
11055 if (LUE->getKind() != UETT_SizeOf || LUE->isArgumentType() ||
11056 RUE->getKind() != UETT_SizeOf)
11063 if (RUE->isArgumentType())
11064 RHSTy = RUE->getArgumentType().getNonReferenceType();
11066 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
11073 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11074 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11075 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
11079 QualType ArrayElemTy = ArrayTy->getElementType();
11085 S.
Diag(Loc, diag::warn_division_sizeof_array)
11087 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11088 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11089 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
11093 S.
Diag(Loc, diag::note_precedence_silence) << RHS;
11106 S.
PDiag(diag::warn_remainder_division_by_zero)
11115 const Expr *LHSExpr = LHS.
get();
11116 const Expr *RHSExpr = RHS.
get();
11121 if (!LHSIsScoped && !RHSIsScoped)
11133 ->getDefinitionOrSelf()
11134 ->getIntegerType();
11135 std::string InsertionString =
"static_cast<" + IntType.getAsString() +
">(";
11136 S.
Diag(BeginLoc, diag::note_no_implicit_conversion_for_scoped_enum)
11141 DiagnosticHelper(LHSExpr, LHSType);
11144 DiagnosticHelper(RHSExpr, RHSType);
11151 bool IsCompAssign = Opc == BO_MulAssign || Opc == BO_DivAssign;
11152 bool IsDiv = Opc == BO_Div || Opc == BO_DivAssign;
11246 if (compType.
isNull() ||
11251 IsCompAssign ? BO_RemAssign : BO_Rem);
11262 ? diag::err_typecheck_pointer_arith_void_type
11263 : diag::ext_gnu_void_ptr)
11272 ? diag::err_typecheck_pointer_arith_void_type
11273 : diag::ext_gnu_void_ptr)
11274 << 0 <<
Pointer->getSourceRange();
11285 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
11286 <<
Pointer->getSourceRange();
11288 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
11305 S.
PDiag(diag::warn_pointer_sub_null_ptr)
11307 <<
Pointer->getSourceRange());
11316 ? diag::err_typecheck_pointer_arith_function_type
11317 : diag::ext_gnu_ptr_func_arith)
11329 assert(
Pointer->getType()->isAnyPointerType());
11331 ? diag::err_typecheck_pointer_arith_function_type
11332 : diag::ext_gnu_ptr_func_arith)
11333 << 0 <<
Pointer->getType()->getPointeeType()
11335 <<
Pointer->getSourceRange();
11343 QualType ResType = Operand->getType();
11345 ResType = ResAtomicType->getValueType();
11351 diag::err_typecheck_arithmetic_incomplete_or_sizeless_type,
11352 Operand->getSourceRange());
11365 QualType ResType = Operand->getType();
11367 ResType = ResAtomicType->getValueType();
11399 if (!isLHSPointer && !isRHSPointer)
return true;
11401 QualType LHSPointeeTy, RHSPointeeTy;
11406 if (isLHSPointer && isRHSPointer) {
11410 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
11418 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
11419 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
11420 if (isLHSVoidPtr || isRHSVoidPtr) {
11428 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
11429 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
11430 if (isLHSFuncPtr || isRHSFuncPtr) {
11452 Expr* IndexExpr = RHSExpr;
11455 IndexExpr = LHSExpr;
11458 bool IsStringPlusInt = StrExpr &&
11464 Self.Diag(OpLoc, diag::warn_string_plus_int)
11468 if (IndexExpr == RHSExpr) {
11470 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11475 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11481 const Expr *StringRefExpr = LHSExpr;
11486 CharExpr = dyn_cast<CharacterLiteral>(LHSExpr->
IgnoreImpCasts());
11487 StringRefExpr = RHSExpr;
11490 if (!CharExpr || !StringRefExpr)
11510 Self.Diag(OpLoc, diag::warn_string_plus_char)
11511 << DiagRange << Ctx.
CharTy;
11513 Self.Diag(OpLoc, diag::warn_string_plus_char)
11514 << DiagRange << CharExpr->
getType();
11520 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11525 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11534 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
11553 if (CompLHSTy) *CompLHSTy = compType;
11562 *CompLHSTy = compType;
11571 *CompLHSTy = compType;
11582 if (Opc == BO_Add) {
11589 if (CompLHSTy) *CompLHSTy = compType;
11603 std::swap(PExp, IExp);
11616 if (!IExp->getType()->isIntegerType())
11625 (!IExp->isValueDependent() &&
11626 (!IExp->EvaluateAsInt(KnownVal,
Context) ||
11630 Context, BO_Add, PExp, IExp);
11644 Diag(Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
11650 CheckArrayAccess(PExp, IExp);
11656 if (
Context.isPromotableIntegerType(LHSTy))
11657 LHSTy =
Context.getPromotedIntegerType(LHSTy);
11659 *CompLHSTy = LHSTy;
11680 if (CompLHSTy) *CompLHSTy = compType;
11689 *CompLHSTy = compType;
11698 *CompLHSTy = compType;
11712 if (CompLHSTy) *CompLHSTy = compType;
11729 Diag(Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
11755 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
11758 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11769 if (!
Context.hasSameUnqualifiedType(lpointee, rpointee)) {
11774 if (!
Context.typesAreCompatible(
11775 Context.getCanonicalType(lpointee).getUnqualifiedType(),
11776 Context.getCanonicalType(rpointee).getUnqualifiedType())) {
11802 if (ElementSize.
isZero()) {
11803 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
11809 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11810 return Context.getPointerDiffType();
11820 if (
const EnumType *ET = T->getAsCanonical<EnumType>())
11821 return ET->getDecl()->isScoped();
11833 if (Opc == BO_Shr &&
11842 llvm::APSInt Right = RHSResult.
Val.
getInt();
11844 if (Right.isNegative()) {
11846 S.
PDiag(diag::warn_shift_negative)
11857 LeftSize = FXSema.getWidth() - (
unsigned)FXSema.hasUnsignedPadding();
11859 if (Right.uge(LeftSize)) {
11861 S.
PDiag(diag::warn_shift_gt_typewidth)
11881 llvm::APSInt Left = LHSResult.
Val.
getInt();
11892 if (Left.isNegative()) {
11894 S.
PDiag(diag::warn_shift_lhs_negative)
11899 llvm::APInt ResultBits =
11900 static_cast<llvm::APInt &
>(Right) + Left.getSignificantBits();
11901 if (ResultBits.ule(LeftSize))
11903 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
11904 Result = Result.shl(Right);
11909 Result.toString(HexResult, 16,
false,
true);
11915 if (ResultBits - 1 == LeftSize) {
11916 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
11917 << HexResult << LHSType
11922 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
11923 << HexResult.str() << Result.getSignificantBits() << LHSType
11935 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
11941 if (!IsCompAssign) {
11963 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
11970 if (!LHSEleType->isIntegerType()) {
11971 S.
Diag(Loc, diag::err_typecheck_expect_int)
11976 if (!RHSEleType->isIntegerType()) {
11977 S.
Diag(Loc, diag::err_typecheck_expect_int)
11986 if (LHSEleType != RHSEleType) {
11988 LHSEleType = RHSEleType;
11994 }
else if (RHSVecTy) {
11999 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12007 if (LHSBT != RHSBT &&
12009 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
12026 bool IsCompAssign) {
12027 if (!IsCompAssign) {
12050 if ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
12051 (RHSBuiltinTy && RHSBuiltinTy->
isSVEBool())) {
12052 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12057 if (!LHSEleType->isIntegerType()) {
12058 S.
Diag(Loc, diag::err_typecheck_expect_int)
12063 if (!RHSEleType->isIntegerType()) {
12064 S.
Diag(Loc, diag::err_typecheck_expect_int)
12072 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12082 if (LHSEleType != RHSEleType) {
12084 LHSEleType = RHSEleType;
12086 const llvm::ElementCount VecSize =
12095 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12101 const llvm::ElementCount VecSize =
12103 if (LHSEleType != RHSEleType) {
12105 RHSEleType = LHSEleType;
12118 bool IsCompAssign) {
12152 if (IsCompAssign) LHS = OldLHS;
12180 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
12181 : diag::ext_typecheck_comparison_of_distinct_pointers)
12221 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
12222 : diag::ext_typecheck_comparison_of_fptr_to_void)
12229 case Stmt::ObjCArrayLiteralClass:
12230 case Stmt::ObjCDictionaryLiteralClass:
12231 case Stmt::ObjCStringLiteralClass:
12232 case Stmt::ObjCBoxedExprClass:
12276 QualType T = Method->parameters()[0]->getType();
12277 if (!T->isObjCObjectPointerType())
12280 QualType R = Method->getReturnType();
12281 if (!R->isScalarType())
12293 Literal = LHS.
get();
12296 Literal = RHS.
get();
12312 llvm_unreachable(
"Unknown Objective-C object literal kind");
12316 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
12317 << Literal->getSourceRange();
12319 S.
Diag(Loc, diag::warn_objc_literal_comparison)
12320 << LiteralKind << Literal->getSourceRange();
12329 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
12342 if (!UO || UO->
getOpcode() != UO_LNot)
return;
12352 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
12354 << Loc << IsBitwiseOp;
12381 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
12383 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
12384 if (Mem->isImplicitAccess())
12385 D = Mem->getMemberDecl();
12400 return std::nullopt;
12408 std::swap(LHS, RHS);
12412 std::swap(LHS, RHS);
12416 return std::nullopt;
12419 auto *BO = dyn_cast<BinaryOperator>(LHS);
12420 if (!BO || BO->getOpcode() != BO_Add)
12421 return std::nullopt;
12425 Other = BO->getRHS();
12427 Other = BO->getLHS();
12429 return std::nullopt;
12431 if (!
Other->getType()->isUnsignedIntegerType())
12432 return std::nullopt;
12434 return Opc == BO_GE;
12488 auto IsDeprArrayComparionIgnored =
12491 ? diag::warn_array_comparison_cxx26
12492 : !S.
getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored
12493 ? diag::warn_array_comparison
12494 : diag::warn_depr_array_comparison;
12509 Result = AlwaysTrue;
12514 Result = AlwaysFalse;
12517 Result = AlwaysEqual;
12520 Result = AlwaysConstant;
12524 S.
PDiag(diag::warn_comparison_always)
12532 Result = AlwaysFalse;
12535 Result = AlwaysTrue;
12539 Result = AlwaysConstant;
12543 S.
PDiag(diag::warn_comparison_always)
12546 }
else if (std::optional<bool> Res =
12549 S.
PDiag(diag::warn_comparison_always)
12551 << (*Res ? AlwaysTrue : AlwaysFalse));
12562 Expr *LiteralString =
nullptr;
12563 Expr *LiteralStringStripped =
nullptr;
12567 LiteralString = LHS;
12568 LiteralStringStripped = LHSStripped;
12573 LiteralString = RHS;
12574 LiteralStringStripped = RHSStripped;
12577 if (LiteralString) {
12579 S.
PDiag(diag::warn_stringcompare)
12592 llvm_unreachable(
"unhandled cast kind");
12594 case CK_UserDefinedConversion:
12596 case CK_LValueToRValue:
12598 case CK_ArrayToPointerDecay:
12600 case CK_FunctionToPointerDecay:
12602 case CK_IntegralCast:
12604 case CK_FloatingCast:
12606 case CK_IntegralToFloating:
12607 case CK_FloatingToIntegral:
12609 case CK_IntegralComplexCast:
12610 case CK_FloatingComplexCast:
12611 case CK_FloatingComplexToIntegralComplex:
12612 case CK_IntegralComplexToFloatingComplex:
12614 case CK_FloatingComplexToReal:
12615 case CK_FloatingRealToComplex:
12616 case CK_IntegralComplexToReal:
12617 case CK_IntegralRealToComplex:
12619 case CK_HLSLArrayRValue:
12632 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
12659 << 0 << FromType << ToType;
12664 llvm_unreachable(
"unhandled case in switch");
12691 if (NumEnumArgs == 1) {
12693 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
12699 if (NumEnumArgs == 2) {
12708 assert(IntType->isArithmeticType());
12718 LHSType = RHSType = IntType;
12727 if (
Type.isNull()) {
12733 std::optional<ComparisonCategoryType> CCT =
12745 assert(!
Type.isNull() &&
"composite type for <=> has not been set");
12763 if (
Type.isNull()) {
12784 int NullValue =
PP.isMacroDefined(
"NULL") ? 0 : 1;
12789 if (
const auto *
CL = dyn_cast<CharacterLiteral>(E.
get())) {
12790 if (
CL->getValue() == 0)
12794 NullValue ?
"NULL" :
"(void *)0");
12795 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(E.
get())) {
12802 NullValue ?
"NULL" :
"(void *)0");
12812 bool IsThreeWay = Opc == BO_Cmp;
12813 bool IsOrdered = IsRelational || IsThreeWay;
12824 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
12877 auto computeResultTy = [&]() {
12886 std::optional<ComparisonCategoryType> CCT =
12891 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
12895 Diag(Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
12896 << (LHSIsNull ? LHS.
get()->getSourceRange()
12905 if (!IsOrdered && LHSIsNull != RHSIsNull) {
12906 bool IsEquality = Opc == BO_EQ;
12918 bool IsError = Opc == BO_Cmp;
12920 IsError ? diag::err_typecheck_ordered_comparison_of_function_pointers
12922 ? diag::warn_typecheck_ordered_comparison_of_function_pointers
12923 : diag::ext_typecheck_ordered_comparison_of_function_pointers;
12952 return computeResultTy();
12968 (IsOrdered ? 2 : 1) &&
12973 return computeResultTy();
12987 if (IsRelational) {
12992 Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
12998 }
else if (!IsRelational &&
13002 && !LHSIsNull && !RHSIsNull)
13009 if (LCanPointeeTy != RCanPointeeTy) {
13015 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
13016 << LHSType << RHSType << 0
13022 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
13028 bool RHSHasCFIUncheckedCallee = RFn && RFn->getCFIUncheckedCalleeAttr();
13029 bool ChangingCFIUncheckedCallee =
13030 LHSHasCFIUncheckedCallee != RHSHasCFIUncheckedCallee;
13032 if (LHSIsNull && !RHSIsNull)
13034 else if (!ChangingCFIUncheckedCallee)
13037 return computeResultTy();
13049 if (!IsOrdered && LHSIsNull && RHSIsNull) {
13052 return computeResultTy();
13056 return computeResultTy();
13067 return computeResultTy();
13071 return computeResultTy();
13080 return computeResultTy();
13085 return computeResultTy();
13089 if (IsRelational &&
13100 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
13101 if (CTSD->isInStdNamespace() &&
13102 llvm::StringSwitch<bool>(CTSD->getName())
13103 .Cases({
"less",
"less_equal",
"greater",
"greater_equal"},
true)
13109 return computeResultTy();
13122 return computeResultTy();
13132 if (!LHSIsNull && !RHSIsNull &&
13133 !
Context.typesAreCompatible(lpointee, rpointee)) {
13134 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13139 return computeResultTy();
13146 if (!LHSIsNull && !RHSIsNull) {
13151 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13155 if (LHSIsNull && !RHSIsNull)
13158 : CK_AnyPointerToBlockPointerCast);
13162 : CK_AnyPointerToBlockPointerCast);
13163 return computeResultTy();
13172 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
13174 if (!LPtrToVoid && !RPtrToVoid &&
13175 !
Context.typesAreCompatible(LHSType, RHSType)) {
13182 if (LHSIsNull && !RHSIsNull) {
13188 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13198 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13200 return computeResultTy();
13204 if (!
Context.areComparableObjCPointerTypes(LHSType, RHSType))
13210 if (LHSIsNull && !RHSIsNull)
13214 return computeResultTy();
13220 CK_BlockPointerToObjCPointerCast);
13221 return computeResultTy();
13222 }
else if (!IsOrdered &&
13226 CK_BlockPointerToObjCPointerCast);
13227 return computeResultTy();
13232 unsigned DiagID = 0;
13233 bool isError =
false;
13242 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
13243 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
13246 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
13248 }
else if (IsOrdered)
13249 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
13251 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
13263 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13266 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13267 return computeResultTy();
13271 if (!IsOrdered && RHSIsNull
13274 return computeResultTy();
13276 if (!IsOrdered && LHSIsNull
13279 return computeResultTy();
13282 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
13284 return computeResultTy();
13288 return computeResultTy();
13291 if (LHSIsNull && RHSType->
isQueueT()) {
13293 return computeResultTy();
13296 if (LHSType->
isQueueT() && RHSIsNull) {
13298 return computeResultTy();
13323 "Unhandled vector element size in vector compare");
13343 "Unhandled vector element size in vector compare");
13353 const auto TypeSize =
Context.getTypeSize(ETy);
13355 const QualType IntTy =
Context.getIntTypeForBitwidth(TypeSize,
true);
13356 const llvm::ElementCount VecSize =
Context.getBuiltinVectorTypeInfo(VTy).EC;
13357 return Context.getScalableVectorType(IntTy, VecSize.getKnownMinValue());
13363 if (Opc == BO_Cmp) {
13364 Diag(Loc, diag::err_three_way_vector_comparison);
13393 return Context.getLogicalOperationType();
13395 Diag(Loc, diag::warn_deprecated_altivec_src_compat);
13401 return Context.getLogicalOperationType();
13425 if (Opc == BO_Cmp) {
13426 Diag(Loc, diag::err_three_way_vector_comparison);
13454 if (LHSBuiltinTy && RHSBuiltinTy && LHSBuiltinTy->
isSVEBool() &&
13455 RHSBuiltinTy->isSVEBool())
13474 bool Negative =
false;
13475 bool ExplicitPlus =
false;
13476 const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.
get());
13477 const auto *RHSInt = dyn_cast<IntegerLiteral>(XorRHS.
get());
13483 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
13485 if (Opc != UO_Minus && Opc != UO_Plus)
13487 RHSInt = dyn_cast<IntegerLiteral>(UO->getSubExpr());
13490 Negative = (Opc == UO_Minus);
13491 ExplicitPlus = !Negative;
13497 const llvm::APInt &LeftSideValue = LHSInt->getValue();
13498 llvm::APInt RightSideValue = RHSInt->getValue();
13499 if (LeftSideValue != 2 && LeftSideValue != 10)
13502 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
13507 llvm::StringRef ExprStr =
13512 llvm::StringRef XorStr =
13515 if (XorStr ==
"xor")
13526 RightSideValue = -RightSideValue;
13527 RHSStr =
"-" + RHSStr;
13528 }
else if (ExplicitPlus) {
13529 RHSStr =
"+" + RHSStr;
13532 StringRef LHSStrRef = LHSStr;
13533 StringRef RHSStrRef = RHSStr;
13536 if (LHSStrRef.starts_with(
"0b") || LHSStrRef.starts_with(
"0B") ||
13537 RHSStrRef.starts_with(
"0b") || RHSStrRef.starts_with(
"0B") ||
13538 LHSStrRef.starts_with(
"0x") || LHSStrRef.starts_with(
"0X") ||
13539 RHSStrRef.starts_with(
"0x") || RHSStrRef.starts_with(
"0X") ||
13540 (LHSStrRef.size() > 1 && LHSStrRef.starts_with(
"0")) ||
13541 (RHSStrRef.size() > 1 && RHSStrRef.starts_with(
"0")) ||
13542 LHSStrRef.contains(
'\'') || RHSStrRef.contains(
'\''))
13547 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
13548 int64_t RightSideIntValue = RightSideValue.getSExtValue();
13549 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
13550 std::string SuggestedExpr =
"1 << " + RHSStr;
13551 bool Overflow =
false;
13552 llvm::APInt One = (LeftSideValue - 1);
13553 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
13555 if (RightSideIntValue < 64)
13556 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13557 << ExprStr <<
toString(XorValue, 10,
true) << (
"1LL << " + RHSStr)
13559 else if (RightSideIntValue == 64)
13560 S.
Diag(Loc, diag::warn_xor_used_as_pow)
13561 << ExprStr <<
toString(XorValue, 10,
true);
13565 S.
Diag(Loc, diag::warn_xor_used_as_pow_base_extra)
13566 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedExpr
13569 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
13572 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13573 << (
"0x2 ^ " + RHSStr) << SuggestXor;
13574 }
else if (LeftSideValue == 10) {
13575 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
13576 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13577 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedValue
13579 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13580 << (
"0xA ^ " + RHSStr) << SuggestXor;
13597 getLangOpts().getOpenCLCompatibleVersion() < 120 &&
13624 assert(
false &&
"Logical operands are not supported in C\\C++");
13640 bool IsCompAssign) {
13641 if (!IsCompAssign) {
13657 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13659 if (
Context.hasSameType(LHSType, RHSType))
13660 return Context.getCommonSugaredType(LHSType, RHSType);
13666 if (LHSMatType && !RHSMatType) {
13674 if (!LHSMatType && RHSMatType) {
13686 bool IsCompAssign) {
13687 if (!IsCompAssign) {
13698 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13700 if (LHSMatType && RHSMatType) {
13701 if (LHSMatType->getNumColumns() != RHSMatType->
getNumRows())
13704 if (
Context.hasSameType(LHSMatType, RHSMatType))
13705 return Context.getCommonSugaredType(
13709 QualType LHSELTy = LHSMatType->getElementType(),
13711 if (!
Context.hasSameType(LHSELTy, RHSELTy))
13714 return Context.getConstantMatrixType(
13715 Context.getCommonSugaredType(LHSELTy, RHSELTy),
13740 bool IsCompAssign =
13741 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
13752 LegalBoolVecOperator,
13782 ExprResult LHSResult = LHS, RHSResult = RHS;
13784 LHSResult, RHSResult, Loc,
13786 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
13788 LHS = LHSResult.
get();
13789 RHS = RHSResult.
get();
13814 bool EnumConstantInBoolContext =
false;
13816 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
13817 const auto *ECDHS = dyn_cast<EnumConstantDecl>(DREHS->getDecl());
13818 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
13819 EnumConstantInBoolContext =
true;
13823 if (EnumConstantInBoolContext)
13824 Diag(Loc, diag::warn_enum_constant_in_bool_context);
13829 const auto *LHSATy = dyn_cast<ArrayType>(LHSTy);
13830 const auto *RHSATy = dyn_cast<ArrayType>(RHSTy);
13831 if ((LHSATy && LHSATy->getElementType().isWebAssemblyReferenceType()) ||
13832 (RHSATy && RHSATy->getElementType().isWebAssemblyReferenceType())) {
13854 Diag(Loc, diag::warn_logical_instead_of_bitwise)
13857 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
13858 << (Opc == BO_LAnd ?
"&" :
"|")
13861 Opc == BO_LAnd ?
"&" :
"|");
13862 if (Opc == BO_LAnd)
13864 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
13872 if (!
Context.getLangOpts().CPlusPlus) {
13875 if (
Context.getLangOpts().OpenCL &&
13876 Context.getLangOpts().OpenCLVersion < 120) {
13926 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
13927 if (!ME)
return false;
13931 if (!
Base)
return false;
13932 return Base->getMethodDecl() !=
nullptr;
13956 assert(S.
getLangOpts().CPlusPlus &&
"BindingDecl outside of C++?");
13967 assert(Var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
13975 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
14017 bool DiagnosticEmitted =
false;
14021 bool IsDereference =
false;
14022 bool NextIsDereference =
false;
14026 IsDereference = NextIsDereference;
14029 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
14030 NextIsDereference = ME->isArrow();
14031 const ValueDecl *VD = ME->getMemberDecl();
14032 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
14034 if (Field->isMutable()) {
14035 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
14040 if (!DiagnosticEmitted) {
14041 S.
Diag(Loc, diag::err_typecheck_assign_const)
14043 << Field->getType();
14044 DiagnosticEmitted =
true;
14047 <<
ConstMember <<
false << Field << Field->getType()
14048 << Field->getSourceRange();
14052 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
14053 if (VDecl->getType().isConstQualified()) {
14054 if (!DiagnosticEmitted) {
14055 S.
Diag(Loc, diag::err_typecheck_assign_const)
14057 << VDecl->getType();
14058 DiagnosticEmitted =
true;
14061 <<
ConstMember <<
true << VDecl << VDecl->getType()
14062 << VDecl->getSourceRange();
14069 dyn_cast<ArraySubscriptExpr>(E)) {
14073 dyn_cast<ExtVectorElementExpr>(E)) {
14080 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
14084 if (!DiagnosticEmitted) {
14085 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
14087 DiagnosticEmitted =
true;
14090 diag::note_typecheck_assign_const)
14094 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
14096 if (
const ValueDecl *VD = DRE->getDecl()) {
14098 if (!DiagnosticEmitted) {
14099 S.
Diag(Loc, diag::err_typecheck_assign_const)
14101 DiagnosticEmitted =
true;
14103 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
14104 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
14109 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
14110 if (MD->isConst()) {
14111 if (!DiagnosticEmitted) {
14112 S.
Diag(Loc, diag::err_typecheck_assign_const_method)
14113 << ExprRange << MD;
14114 DiagnosticEmitted =
true;
14116 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const_method)
14117 << MD << MD->getSourceRange();
14123 if (DiagnosticEmitted)
14127 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
14137 const RecordType *Ty,
14140 bool &DiagnosticEmitted) {
14141 std::vector<const RecordType *> RecordTypeList;
14142 RecordTypeList.push_back(Ty);
14143 unsigned NextToCheckIndex = 0;
14146 while (RecordTypeList.size() > NextToCheckIndex) {
14147 bool IsNested = NextToCheckIndex > 0;
14148 for (
const FieldDecl *Field : RecordTypeList[NextToCheckIndex]
14153 QualType FieldTy = Field->getType();
14155 if (!DiagnosticEmitted) {
14156 S.
Diag(Loc, diag::err_typecheck_assign_const)
14158 << IsNested << Field;
14159 DiagnosticEmitted =
true;
14161 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
14163 << FieldTy << Field->getSourceRange();
14168 if (
const auto *FieldRecTy = FieldTy->
getAsCanonical<RecordType>()) {
14169 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
14170 RecordTypeList.push_back(FieldRecTy);
14173 ++NextToCheckIndex;
14182 assert(Ty->
isRecordType() &&
"lvalue was not record?");
14185 bool DiagEmitted =
false;
14187 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
14190 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
14215 unsigned DiagID = 0;
14216 bool NeedType =
false;
14223 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
14225 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
14238 if (var->isARCPseudoStrong() &&
14239 (!var->getTypeSourceInfo() ||
14240 !var->getTypeSourceInfo()->getType().isConstQualified())) {
14246 ? diag::err_typecheck_arc_assign_self_class_method
14247 : diag::err_typecheck_arc_assign_self;
14250 }
else if (var->hasAttr<ObjCExternallyRetainedAttr>() ||
14252 DiagID = diag::err_typecheck_arc_assign_externally_retained;
14256 DiagID = diag::err_typecheck_arr_assign_enumeration;
14260 if (Loc != OrigLoc)
14286 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
14290 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
14294 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
14297 llvm_unreachable(
"did not take early return for MLV_Valid");
14301 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
14306 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
14308 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
14311 DiagID = diag::err_typecheck_duplicate_matrix_components_not_mlvalue;
14314 llvm_unreachable(
"readonly properties should be processed differently");
14316 DiagID = diag::err_readonly_message_assignment;
14319 DiagID = diag::err_no_subobject_property_setting;
14324 if (Loc != OrigLoc)
14346 MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
14347 MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
14355 if (LHSDecl != RHSDecl)
14360 if (RefTy->getPointeeType().isVolatileQualified())
14363 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
14373 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
14397 bool ShowFullyQualifiedAssigneeName =
false;
14400 Assignee = DR->getDecl();
14401 }
else if (
auto *ME = dyn_cast<MemberExpr>(LHSExpr->
IgnoreParenCasts())) {
14402 Assignee = ME->getMemberDecl();
14403 ShowFullyQualifiedAssigneeName =
true;
14408 ShowFullyQualifiedAssigneeName);
14417 Diag(Loc, diag::err_opencl_half_load_store) << 1
14424 Diag(Loc, diag::err_wasm_table_art) << 0;
14429 if (CompoundType.
isNull()) {
14440 ((
Context.isObjCNSObjectType(LHSType) &&
14442 (
Context.isObjCNSObjectType(RHSType) &&
14447 Diag(Loc, diag::err_objc_object_assignment) << LHSType;
14453 RHSCheck = ICE->getSubExpr();
14454 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
14455 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
14456 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
14462 UO->getSubExpr()->getBeginLoc().
isFileID()) {
14463 Diag(Loc, diag::warn_not_compound_assign)
14464 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
14465 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
14475 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
14491 if (!
Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
14514 if (CompoundType.
isNull()) {
14540 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
14541 if (CE->getCastKind() == CK_ToVoid) {
14547 CE->getSubExpr()->getType()->isDependentType()) {
14552 if (
const auto *CE = dyn_cast<CallExpr>(E))
14553 return CE->getCallReturnType(Context)->isVoidType();
14573 const unsigned ForIncrementFlags =
14579 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
14580 (ScopeFlags & ForInitFlags) == ForInitFlags)
14585 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
14586 if (BO->getOpcode() != BO_Comma)
14588 LHS = BO->getRHS();
14595 Diag(Loc, diag::warn_comma_operator);
14599 LangOpts.CPlusPlus ?
"static_cast<void>("
14631 diag::err_incomplete_type);
14652 ResType = ResAtomicType->getValueType();
14654 assert(!ResType.
isNull() &&
"no type for increment/decrement expression");
14664 : diag::warn_increment_bool)
14668 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
14686 S.
Diag(OpLoc, S.
getLangOpts().C2y ? diag::warn_c2y_compat_increment_complex
14687 : diag::ext_c2y_increment_complex)
14704 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
14715 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
14716 << IsInc << ResType;
14748 case Stmt::DeclRefExprClass:
14750 case Stmt::MemberExprClass:
14758 case Stmt::ArraySubscriptExprClass: {
14763 if (ICE->getSubExpr()->getType()->isArrayType())
14768 case Stmt::UnaryOperatorClass: {
14780 case Stmt::ParenExprClass:
14782 case Stmt::ImplicitCastExprClass:
14786 case Stmt::CXXUuidofExprClass:
14796 AO_Vector_Element = 1,
14797 AO_Property_Expansion = 2,
14798 AO_Register_Variable = 3,
14799 AO_Matrix_Element = 4,
14817 return Diag(OpLoc, diag::err_parens_pointer_member_function)
14822 return Diag(OpLoc, diag::err_typecheck_addrof_dtor)
14823 << DRE->getSourceRange();
14825 if (DRE->getQualifier())
14829 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
14830 << DRE->getSourceRange();
14833 StringRef Qual = (MD->
getParent()->getName() +
"::").toStringRef(Str);
14834 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
14835 << DRE->getSourceRange()
14841 if (PTy->getKind() == BuiltinType::Overload) {
14845 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
14853 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14861 if (PTy->getKind() == BuiltinType::UnknownAny)
14864 if (PTy->getKind() == BuiltinType::BoundMember) {
14865 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14888 auto* VarRef = dyn_cast<DeclRefExpr>(op);
14889 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
14890 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
14898 if (uOp->getOpcode() == UO_Deref)
14901 return uOp->getSubExpr()->getType();
14908 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
14914 unsigned AddressOfError = AO_No_Error;
14918 Diag(OpLoc, IsError ? diag::err_typecheck_addrof_temporary
14919 : diag::ext_typecheck_addrof_temporary)
14934 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14952 auto ReturnOrParamTypeIsIncomplete = [&](
QualType T,
14957 diag::note_ptrauth_virtual_function_pointer_incomplete_arg_ret);
14958 Diag(RetArgTypeLoc,
14959 diag::note_ptrauth_virtual_function_incomplete_arg_ret_type)
14966 bool IsIncomplete =
14968 ReturnOrParamTypeIsIncomplete(
14971 IsIncomplete |= ReturnOrParamTypeIsIncomplete(PVD->getType(), OpLoc,
14972 PVD->getBeginLoc());
14978 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
14987 AddressOfError = AO_Property_Expansion;
14989 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
14993 }
else if (
const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
14994 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(DRE->getDecl()))
15000 AddressOfError = AO_Bit_Field;
15003 AddressOfError = AO_Vector_Element;
15006 AddressOfError = AO_Matrix_Element;
15010 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
15015 AddressOfError = AO_Register_Variable;
15018 AddressOfError = AO_Property_Expansion;
15031 if (
auto *DRE = dyn_cast<DeclRefExpr>(op);
15037 diag::err_cannot_form_pointer_to_member_of_reference_type)
15048 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
15056 llvm_unreachable(
"Unknown/unexpected decl type");
15059 if (AddressOfError != AO_No_Error) {
15076 if (
Context.getTargetInfo().getTriple().isWasm()) {
15079 Diag(OpLoc, diag::err_wasm_ca_reference)
15084 Diag(OpLoc, diag::err_wasm_table_pr)
15090 CheckAddressOfPackedMember(op);
15096 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp);
15102 const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
15105 if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
15106 if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
15109 FD->ModifiedNonNullParams.insert(Param);
15115 bool IsAfterAmp =
false) {
15119 Op = ConvResult.
get();
15131 Result = PT->getPointeeType();
15139 if (PR.
get() != Op)
15143 if (Result.isNull()) {
15144 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
15149 if (Result->isVoidType()) {
15155 S.
Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
15158 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
15166 if (!S.
getLangOpts().CPlusPlus && Result.isCForbiddenLValueType())
15175 default: llvm_unreachable(
"Unknown binop!");
15176 case tok::periodstar: Opc = BO_PtrMemD;
break;
15177 case tok::arrowstar: Opc = BO_PtrMemI;
break;
15178 case tok::star: Opc = BO_Mul;
break;
15179 case tok::slash: Opc = BO_Div;
break;
15180 case tok::percent: Opc = BO_Rem;
break;
15181 case tok::plus: Opc = BO_Add;
break;
15182 case tok::minus: Opc = BO_Sub;
break;
15183 case tok::lessless: Opc = BO_Shl;
break;
15184 case tok::greatergreater: Opc = BO_Shr;
break;
15185 case tok::lessequal: Opc = BO_LE;
break;
15186 case tok::less: Opc = BO_LT;
break;
15187 case tok::greaterequal: Opc = BO_GE;
break;
15188 case tok::greater: Opc = BO_GT;
break;
15189 case tok::exclaimequal: Opc = BO_NE;
break;
15190 case tok::equalequal: Opc = BO_EQ;
break;
15191 case tok::spaceship: Opc = BO_Cmp;
break;
15192 case tok::amp: Opc = BO_And;
break;
15193 case tok::caret: Opc = BO_Xor;
break;
15194 case tok::pipe: Opc = BO_Or;
break;
15195 case tok::ampamp: Opc = BO_LAnd;
break;
15196 case tok::pipepipe: Opc = BO_LOr;
break;
15197 case tok::equal: Opc = BO_Assign;
break;
15198 case tok::starequal: Opc = BO_MulAssign;
break;
15199 case tok::slashequal: Opc = BO_DivAssign;
break;
15200 case tok::percentequal: Opc = BO_RemAssign;
break;
15201 case tok::plusequal: Opc = BO_AddAssign;
break;
15202 case tok::minusequal: Opc = BO_SubAssign;
break;
15203 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
15204 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
15205 case tok::ampequal: Opc = BO_AndAssign;
break;
15206 case tok::caretequal: Opc = BO_XorAssign;
break;
15207 case tok::pipeequal: Opc = BO_OrAssign;
break;
15208 case tok::comma: Opc = BO_Comma;
break;
15217 default: llvm_unreachable(
"Unknown unary op!");
15218 case tok::plusplus: Opc = UO_PreInc;
break;
15219 case tok::minusminus: Opc = UO_PreDec;
break;
15220 case tok::amp: Opc = UO_AddrOf;
break;
15221 case tok::star: Opc = UO_Deref;
break;
15222 case tok::plus: Opc = UO_Plus;
break;
15223 case tok::minus: Opc = UO_Minus;
break;
15224 case tok::tilde: Opc = UO_Not;
break;
15225 case tok::exclaim: Opc = UO_LNot;
break;
15226 case tok::kw___real: Opc = UO_Real;
break;
15227 case tok::kw___imag: Opc = UO_Imag;
break;
15228 case tok::kw___extension__: Opc = UO_Extension;
break;
15260 llvm::find_if(Parent->
fields(),
15262 return F->getDeclName() == Name;
15264 return (Field != Parent->
field_end()) ? *Field :
nullptr;
15279 const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
15280 const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
15281 if (!LHSDeclRef || !RHSDeclRef ||
15289 if (LHSDecl != RHSDecl)
15294 if (RefTy->getPointeeType().isVolatileQualified())
15297 auto Diag = S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
15298 : diag::warn_self_assignment_overloaded)
15303 Diag << 1 << SelfAssignField
15316 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
15318 const Expr *RHS = R.get();
15321 ObjCPointerExpr = LHS;
15325 ObjCPointerExpr = RHS;
15334 unsigned Diag = diag::warn_objc_pointer_masking;
15343 if (SelArg0.starts_with(
"performSelector"))
15344 Diag = diag::warn_objc_pointer_masking_performSelector;
15361 assert((
isVector(ResultTy, Context.HalfTy) ||
15362 isVector(ResultTy, Context.ShortTy)) &&
15363 "Result must be a vector of half or short");
15366 "both operands expected to be a half vector");
15373 if (
isVector(ResultTy, Context.ShortTy))
15378 ResultTy,
VK, OK, OpLoc, FPFeatures,
15379 BinOpResTy, BinOpResTy);
15383 BinOpResTy,
VK, OK, OpLoc, FPFeatures);
15391 if (!OpRequiresConversion || Ctx.
getLangOpts().NativeHalfType ||
15395 auto HasVectorOfHalfType = [&Ctx](
Expr *E) {
15405 return VT->getElementType().getCanonicalType() == Ctx.
HalfTy;
15410 return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
15415 Expr *RHSExpr,
bool ForFoldExpression) {
15429 if (
Init.isInvalid())
15431 RHSExpr =
Init.get();
15441 bool ConvertHalfVec =
false;
15443 if (!LHS.
isUsable() || !RHS.isUsable())
15453 if (BO_Assign == Opc)
15454 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
15482 if (!ResultTy.
isNull()) {
15499 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
15501 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
15502 if (VD->hasLocalStorage() &&
getCurScope()->isDeclScope(VD))
15503 BE->getBlockDecl()->setCanAvoidCopyToHeap();
15514 Opc == BO_PtrMemI);
15518 ConvertHalfVec =
true;
15525 ConvertHalfVec =
true;
15529 ConvertHalfVec =
true;
15540 ConvertHalfVec =
true;
15543 if (
const auto *BI = dyn_cast<BinaryOperator>(LHSExpr);
15544 !ForFoldExpression && BI && BI->isComparisonOp())
15545 Diag(OpLoc, diag::warn_consecutive_comparison)
15551 ConvertHalfVec =
true;
15555 ConvertHalfVec =
true;
15568 ConvertHalfVec =
true;
15573 ConvertHalfVec =
true;
15575 CompLHSTy = CompResultTy;
15582 CompLHSTy = CompResultTy;
15588 ConvertHalfVec =
true;
15595 ConvertHalfVec =
true;
15604 CompLHSTy = CompResultTy;
15615 CompLHSTy = CompResultTy;
15623 VK = RHS.get()->getValueKind();
15624 OK = RHS.get()->getObjectKind();
15636 (Opc == BO_Comma ||
isVector(RHS.get()->getType(),
Context.HalfTy) ==
15638 "both sides are half vectors or neither sides are");
15643 CheckArrayAccess(LHS.
get());
15644 CheckArrayAccess(RHS.get());
15648 &
Context.Idents.get(
"object_setClass"),
15654 "object_setClass(")
15667 if (CompResultTy.
isNull()) {
15668 if (ConvertHalfVec)
15688 if (ConvertHalfVec)
15693 Context, LHS.
get(), RHS.get(), Opc, ResultTy,
VK, OK, OpLoc,
15710 if (isLeftComp == isRightComp)
15715 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
15716 bool isRightBitwise = RHSBO && RHSBO->
isBitwiseOp();
15717 if (isLeftBitwise || isRightBitwise)
15729 Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
15732 Self.PDiag(diag::note_precedence_silence) << OpStr,
15733 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
15735 Self.PDiag(diag::note_precedence_bitwise_first)
15750 Self.PDiag(diag::note_precedence_silence)
15759 if (Bop->getOpcode() == BO_LAnd) {
15764 }
else if (Bop->getOpcode() == BO_LOr) {
15765 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
15768 if (RBop->getOpcode() == BO_LAnd &&
15780 if (Bop->getOpcode() == BO_LAnd) {
15795 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
15796 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
15798 << Bop->getSourceRange() << OpLoc;
15800 S.
PDiag(diag::note_precedence_silence)
15801 << Bop->getOpcodeStr(),
15802 Bop->getSourceRange());
15808 Expr *SubExpr, StringRef Shift) {
15810 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
15811 StringRef Op = Bop->getOpcodeStr();
15812 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
15813 << Bop->getSourceRange() << OpLoc << Shift << Op;
15815 S.
PDiag(diag::note_precedence_silence) << Op,
15816 Bop->getSourceRange());
15832 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
15835 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
15837 << (Kind == OO_LessLess);
15839 S.
PDiag(diag::note_precedence_silence)
15840 << (Kind == OO_LessLess ?
"<<" :
">>"),
15843 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
15857 if ((Opc == BO_Or || Opc == BO_Xor) &&
15865 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
15871 || Opc == BO_Shr) {
15887 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
15888 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
15897 CheckInvalidBuiltinCountedByRef(LHSExpr, K);
15898 CheckInvalidBuiltinCountedByRef(RHSExpr, K);
15900 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
15906 if (OverOp !=
OO_None && OverOp != OO_Equal)
15955 Expr *RHSExpr,
bool ForFoldExpression) {
15956 if (!LHSExpr || !RHSExpr)
15968 if (pty->getKind() == BuiltinType::PseudoObject &&
15981 RHSExpr = resolvedRHS.
get();
15995 (pty->getKind() == BuiltinType::BoundMember ||
15996 pty->getKind() == BuiltinType::Overload)) {
15997 auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
15998 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
15999 llvm::any_of(OE->decls(), [](
NamedDecl *ND) {
16000 return isa<FunctionTemplateDecl>(ND);
16002 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
16003 : OE->getNameLoc(),
16004 diag::err_template_kw_missing)
16005 << OE->getName().getAsIdentifierInfo();
16012 LHSExpr = LHS.
get();
16019 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
16026 ForFoldExpression);
16036 RHSExpr = resolvedRHS.
get();
16041 if (!
HLSL().CheckResourceBinOp(Opc, LHSExpr, RHSExpr, OpLoc))
16058 "Should only occur in error-recovery path.");
16064 Context, LHSExpr, RHSExpr, Opc,
16084 ResultType = RHSExpr->
getType();
16087 ResultType =
Context.DependentTy;
16100 if (T.isNull() || T->isDependentType())
16116 bool CanOverflow =
false;
16118 bool ConvertHalfVec =
false;
16127 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16134 if (Opc == UO_AddrOf)
16135 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0);
16136 if (Opc == UO_Deref)
16137 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1);
16142 resultType =
Context.DependentTy;
16151 Opc == UO_PreInc || Opc == UO_PostInc,
16152 Opc == UO_PreInc || Opc == UO_PreDec);
16157 CheckAddressOfNoDeref(InputExpr);
16170 CanOverflow = Opc == UO_Minus &&
16182 if (ConvertHalfVec)
16189 (!
Context.getLangOpts().ZVector ||
16199 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16210 Diag(OpLoc, diag::ext_integer_complement_complex)
16218 if (!T->isIntegerType())
16219 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16222 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16238 resultType =
Context.FloatTy;
16244 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16250 if (
Context.getLangOpts().CPlusPlus) {
16255 }
else if (
Context.getLangOpts().OpenCL &&
16256 Context.getLangOpts().OpenCLVersion < 120) {
16260 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16273 Input.
get(), resultType,
16278 if (
Context.getLangOpts().OpenCL &&
16279 Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
16283 if (!T->isIntegerType())
16284 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16290 }
else if (
Context.getLangOpts().CPlusPlus &&
16294 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16301 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16307 resultType =
Context.getLogicalOperationType();
16335 "the co_await expression must be non-dependant before "
16336 "building operator co_await");
16347 if (Opc != UO_AddrOf && Opc != UO_Deref)
16348 CheckArrayAccess(Input.
get());
16354 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
16360 if (ConvertHalfVec)
16366 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
16367 if (!DRE->getQualifier())
16377 return Method->isImplicitObjectMemberFunction();
16383 if (!ULE->getQualifier())
16388 if (
Method->isImplicitObjectMemberFunction())
16409 if (pty->getKind() == BuiltinType::PseudoObject &&
16414 if (Opc == UO_Extension)
16419 if (Opc == UO_AddrOf &&
16420 (pty->getKind() == BuiltinType::Overload ||
16421 pty->getKind() == BuiltinType::UnknownAny ||
16422 pty->getKind() == BuiltinType::BoundMember))
16447 Expr *Input,
bool IsAfterAmp) {
16457 OpLoc, LabLoc, TheDecl,
Context.getPointerType(
Context.VoidTy));
16491 assert(!
Cleanup.exprNeedsCleanups() &&
16492 "cleanups within StmtExpr not correctly bound!");
16502 bool StmtExprMayBindToTemp =
false;
16504 if (
const auto *LastStmt = dyn_cast<ValueStmt>(Compound->
body_back())) {
16505 if (
const Expr *
Value = LastStmt->getExprStmt()) {
16506 StmtExprMayBindToTemp =
true;
16514 Expr *ResStmtExpr =
16516 if (StmtExprMayBindToTemp)
16518 return ResStmtExpr;
16541 auto *Cast = dyn_cast<ImplicitCastExpr>(E);
16542 if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)
16543 return Cast->getSubExpr();
16564 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
16565 << ArgTy << TypeRange);
16571 diag::err_offsetof_incomplete_type, TypeRange))
16574 bool DidWarnAboutNonPOD =
false;
16579 if (OC.isBrackets) {
16584 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
16588 CurrentType =
Context.DependentTy;
16604 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
16605 Exprs.push_back(Idx);
16613 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
16614 CurrentType =
Context.DependentTy;
16620 diag::err_offsetof_incomplete_type))
16626 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
16637 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
16639 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
16640 : diag::ext_offsetof_non_pod_type;
16643 Diag(BuiltinLoc, DiagID)
16644 <<
SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
16645 DidWarnAboutNonPOD =
true;
16656 MemberDecl = IndirectMemberDecl->getAnonField();
16663 if (!R.isAmbiguous())
16664 Diag(BuiltinLoc, diag::err_no_member)
16665 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart, OC.LocEnd);
16674 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
16682 if (IndirectMemberDecl)
16689 Context.getCanonicalTagType(Parent), Paths)) {
16691 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
16702 if (IndirectMemberDecl) {
16703 for (
auto *FI : IndirectMemberDecl->chain()) {
16709 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
16715 Comps, Exprs, RParenLoc);
16741 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
16746 bool CondIsTrue =
false;
16748 resType =
Context.DependentTy;
16751 llvm::APSInt condEval(32);
16753 CondExpr, &condEval, diag::err_typecheck_choose_expr_requires_constant);
16756 CondExpr = CondICE.
get();
16757 CondIsTrue = condEval.getZExtValue();
16760 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
16762 resType = ActiveExpr->
getType();
16768 resType,
VK, OK, RPLoc, CondIsTrue);
16780 Decl *ManglingContextDecl;
16781 std::tie(MCtx, ManglingContextDecl) =
16785 Block->setBlockMangling(ManglingNumber, ManglingContextDecl);
16807 "block-id should have no identifier!");
16818 assert(T->isFunctionType() &&
16819 "GetTypeForDeclarator made a non-function block signature");
16835 unsigned Size =
Result.getFullDataSize();
16836 Sig =
Context.CreateTypeSourceInfo(
Result.getType(), Size);
16847 QualType RetTy = Fn->getReturnType();
16857 if (RetTy !=
Context.DependentTy) {
16865 if (ExplicitSignature) {
16866 for (
unsigned I = 0, E = ExplicitSignature.
getNumParams(); I != E; ++I) {
16868 if (Param->getIdentifier() ==
nullptr && !Param->isImplicit() &&
16872 Diag(Param->getLocation(), diag::ext_parameter_name_omitted_c23);
16874 Params.push_back(Param);
16880 for (
const auto &I : Fn->param_types()) {
16883 Params.push_back(Param);
16888 if (!Params.empty()) {
16899 AI->setOwningFunction(CurBlock->
TheDecl);
16902 if (AI->getIdentifier()) {
16908 if (AI->isInvalidDecl())
16927 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
16932 assert(!
Cleanup.exprNeedsCleanups() &&
16933 "cleanups within block not correctly bound!");
16948 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
16956 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
16962 BlockTy =
Context.getFunctionType(RetTy, {}, EPI);
16983 BlockTy =
Context.getFunctionType(RetTy, {}, EPI);
16987 BlockTy =
Context.getBlockPointerType(BlockTy);
16991 !
PP.isCodeCompletionEnabled())
16996 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
17022 Expr *CopyExpr =
nullptr;
17049 if (!
Result.isInvalid() &&
17050 !
Result.get()->getType().isConstQualified()) {
17052 Result.get()->getType().withConst(),
17056 if (!
Result.isInvalid()) {
17066 if (!
Result.isInvalid() &&
17070 CopyExpr =
Result.get();
17077 Captures.push_back(NewCap);
17091 if (
Result->getBlockDecl()->hasCaptures()) {
17094 Cleanup.setExprNeedsCleanups(
true);
17098 for (
const auto &CI :
Result->getBlockDecl()->captures()) {
17099 const VarDecl *var = CI.getVariable();
17114 {Result},
Result->getType());
17128 Expr *OrigExpr = E;
17142 Context.getTargetInfo().getTriple().isNVPTX())
17165 VaListType =
Context.getArrayDecayedType(VaListType);
17177 if (
Init.isInvalid())
17193 diag::err_first_argument_to_va_arg_not_of_type_va_list)
17198 diag::err_second_parameter_to_va_arg_incomplete,
17204 diag::err_second_parameter_to_va_arg_abstract,
17211 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
17212 : diag::warn_second_parameter_to_va_arg_not_pod)
17219 PDiag(diag::warn_second_parameter_to_va_arg_array)
17252 UnderlyingType = ED->getIntegerType();
17253 if (
Context.typesAreCompatible(PromoteType, UnderlyingType,
17266 ?
Context.getCorrespondingSignedType(UnderlyingType)
17267 :
Context.getCorrespondingUnsignedType(UnderlyingType);
17268 if (
Context.typesAreCompatible(PromoteType, UnderlyingType,
17274 PromoteType =
Context.DoubleTy;
17275 if (!PromoteType.
isNull())
17277 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
17292 if (pw ==
Context.getTargetInfo().getIntWidth())
17294 else if (pw ==
Context.getTargetInfo().getLongWidth())
17296 else if (pw ==
Context.getTargetInfo().getLongLongWidth())
17299 llvm_unreachable(
"I don't know size of pointer!");
17316 if ((SLDecl->isCompleteDefinition() || SLDecl->isBeingDefined()) &&
17325 S.
Diag(Loc, diag::err_std_source_location_impl_not_found);
17333 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17337 unsigned Count = 0;
17339 StringRef Name = F->getName();
17341 if (Name ==
"_M_file_name") {
17342 if (F->getType() !=
17346 }
else if (Name ==
"_M_function_name") {
17347 if (F->getType() !=
17351 }
else if (Name ==
"_M_line") {
17352 if (!F->getType()->isIntegerType())
17355 }
else if (Name ==
"_M_column") {
17356 if (!F->getType()->isIntegerType())
17365 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17388 ResultTy =
Context.UnsignedIntTy;
17397 ResultTy =
Context.getPointerType(
17416 Data->BinaryData = BinaryData;
17420 Data->getDataElementCount());
17424 const Expr *SrcExpr) {
17433 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
17446 bool *Complained) {
17448 *Complained =
false;
17451 bool CheckInferredResultType =
false;
17453 unsigned DiagKind = 0;
17455 bool MayHaveConvFixit =
false;
17456 bool MayHaveFunctionDiff =
false;
17467 DiagKind = diag::warn_compatible_implicit_pointer_conv;
17471 DiagKind = diag::err_typecheck_convert_pointer_int;
17474 DiagKind = diag::ext_typecheck_convert_pointer_int;
17477 MayHaveConvFixit =
true;
17481 DiagKind = diag::err_typecheck_convert_int_pointer;
17484 DiagKind = diag::ext_typecheck_convert_int_pointer;
17487 MayHaveConvFixit =
true;
17491 diag::warn_typecheck_convert_incompatible_function_pointer_strict;
17493 MayHaveConvFixit =
true;
17497 DiagKind = diag::err_typecheck_convert_incompatible_function_pointer;
17500 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
17503 MayHaveConvFixit =
true;
17507 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
17509 DiagKind = diag::err_typecheck_convert_incompatible_pointer;
17512 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
17516 if (CheckInferredResultType) {
17522 MayHaveConvFixit =
true;
17526 DiagKind = diag::err_typecheck_convert_incompatible_pointer_sign;
17529 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
17534 DiagKind = diag::err_typecheck_convert_pointer_void_func;
17537 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
17549 DiagKind = diag::err_typecheck_incompatible_address_space;
17552 DiagKind = diag::err_typecheck_incompatible_ownership;
17555 DiagKind = diag::err_typecheck_incompatible_ptrauth;
17559 llvm_unreachable(
"unknown error case for discarding qualifiers!");
17564 SrcType =
Context.getArrayDecayedType(SrcType);
17566 DiagKind = diag::ext_typecheck_convert_discards_overflow_behavior;
17582 DiagKind = diag::err_typecheck_convert_discards_qualifiers;
17585 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
17592 DiagKind = diag::err_nested_pointer_qualifier_mismatch;
17594 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
17598 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
17602 DiagKind = diag::err_int_to_block_pointer;
17606 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
17613 for (
auto *srcProto : srcOPT->
quals()) {
17619 IFace = IFaceT->getDecl();
17624 for (
auto *dstProto : dstOPT->
quals()) {
17630 IFace = IFaceT->getDecl();
17633 DiagKind = diag::err_incompatible_qualified_id;
17636 DiagKind = diag::warn_incompatible_qualified_id;
17642 DiagKind = diag::err_incompatible_vectors;
17645 DiagKind = diag::warn_incompatible_vectors;
17649 DiagKind = diag::err_arc_weak_unavailable_assign;
17655 auto getOBTKindName = [](
QualType Ty) -> StringRef {
17656 if (Ty->isPointerType())
17657 Ty = Ty->getPointeeType();
17658 if (
const auto *OBT = Ty->getAs<OverflowBehaviorType>()) {
17659 return OBT->getBehaviorKind() ==
17660 OverflowBehaviorType::OverflowBehaviorKind::Trap
17664 llvm_unreachable(
"OBT kind unhandled");
17667 Diag(Loc, diag::err_incompatible_obt_kinds_assignment)
17668 << DstType << SrcType << getOBTKindName(DstType)
17669 << getOBTKindName(SrcType);
17676 *Complained =
true;
17680 DiagKind = diag::err_typecheck_convert_incompatible;
17682 MayHaveConvFixit =
true;
17684 MayHaveFunctionDiff =
true;
17693 FirstType = DstType;
17694 SecondType = SrcType;
17704 FirstType = SrcType;
17705 SecondType = DstType;
17714 FDiag << FirstType << SecondType << ActionForDiag
17717 if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign ||
17718 DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {
17728 if (!ConvHints.
isNull()) {
17733 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
17735 if (MayHaveFunctionDiff)
17739 if ((DiagKind == diag::warn_incompatible_qualified_id ||
17740 DiagKind == diag::err_incompatible_qualified_id) &&
17742 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
17745 if (SecondType ==
Context.OverloadTy)
17749 if (CheckInferredResultType)
17757 *Complained =
true;
17768 return S.
Diag(Loc, diag::err_ice_not_integral)
17772 return S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus;
17787 IDDiagnoser(
unsigned DiagID)
17791 return S.
Diag(Loc, DiagID);
17793 } Diagnoser(DiagID);
17806 return S.
Diag(Loc, diag::ext_expr_not_ice) << S.
LangOpts.CPlusPlus;
17828 BaseDiagnoser(BaseDiagnoser) {}
17837 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
17842 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
17853 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
17864 llvm_unreachable(
"conversion functions are permitted");
17866 } ConvertDiagnoser(Diagnoser);
17872 E = Converted.
get();
17893 E = RValueExpr.
get();
17911 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
17912 diag::note_invalid_subexpr_in_const_expr) {
17913 DiagLoc = Notes[0].first;
17935 EvalResult.
Diag = &Notes;
17959 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
17960 diag::note_invalid_subexpr_in_const_expr) {
17961 DiagLoc = Notes[0].first;
17987 class TransformToPE :
public TreeTransform<TransformToPE> {
17991 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
17994 bool AlwaysRebuild() {
return true; }
17995 bool ReplacingOriginal() {
return true; }
18004 ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
18006 !SemaRef.isUnevaluatedContext())
18008 diag::err_invalid_non_static_member_use)
18011 return BaseTransform::TransformDeclRefExpr(E);
18015 ExprResult TransformUnaryOperator(UnaryOperator *E) {
18019 return BaseTransform::TransformUnaryOperator(E);
18027 return SkipLambdaBody(E, Body);
18034 "Should only transform unevaluated expressions");
18039 return TransformToPE(*this).TransformExpr(E);
18044 "Should only transform unevaluated expressions");
18048 return TransformToPE(*this).TransformType(TInfo);
18056 LambdaContextDecl, ExprContext);
18070 Prev.isImmediateFunctionContext() || Prev.isConstantEvaluated();
18073 Prev.InImmediateEscalatingFunctionContext;
18141 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
18142 if (E->getOpcode() == UO_Deref)
18143 return CheckPossibleDeref(S, E->getSubExpr());
18144 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
18145 return CheckPossibleDeref(S, E->getBase());
18146 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
18147 return CheckPossibleDeref(S, E->getBase());
18148 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
18151 if (
const auto *Ptr = Ty->
getAs<PointerType>())
18154 Inner = Arr->getElementType();
18158 if (Inner->
hasAttr(attr::NoDeref))
18168 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
18175 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
18190 if (BO->getOpcode() == BO_Assign) {
18192 llvm::erase(LHSs, BO->getLHS());
18200 "Cannot mark an immediate escalating expression outside of an "
18201 "immediate escalating context");
18204 if (
auto *DeclRef =
18205 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
18206 DeclRef->setIsImmediateEscalating(
true);
18207 }
else if (
auto *Ctr = dyn_cast<CXXConstructExpr>(E->
IgnoreImplicit())) {
18208 Ctr->setIsImmediateEscalating(
true);
18209 }
else if (
auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreImplicit())) {
18210 DeclRef->setIsImmediateEscalating(
true);
18212 assert(
false &&
"expected an immediately escalating expression");
18215 FI->FoundImmediateEscalatingExpression =
true;
18230 if (
auto *DeclRef =
18231 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
18240 auto CheckConstantExpressionAndKeepResult = [&]() {
18243 Eval.
Diag = &Notes;
18245 Eval,
getASTContext(), ConstantExprKind::ImmediateInvocation);
18246 if (Res && Notes.empty()) {
18247 Cached = std::move(Eval.
Val);
18255 !CheckConstantExpressionAndKeepResult()) {
18260 if (
Cleanup.exprNeedsCleanups()) {
18277 Cleanup.cleanupsHaveSideEffects(), {});
18290 ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
18298 Eval.
Diag = &Notes;
18302 if (!Result || !Notes.empty()) {
18305 if (
auto *
FunctionalCast = dyn_cast<CXXFunctionalCastExpr>(InnerExpr))
18308 if (
auto *
Call = dyn_cast<CallExpr>(InnerExpr))
18310 else if (
auto *
Call = dyn_cast<CXXConstructExpr>(InnerExpr))
18311 FD =
Call->getConstructor();
18312 else if (
auto *Cast = dyn_cast<CastExpr>(InnerExpr))
18313 FD = dyn_cast_or_null<FunctionDecl>(Cast->getConversionFunction());
18316 "could not find an immediate function in this expression");
18323 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
18325 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
18329 for (
auto &
Note : Notes)
18341 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18345 ComplexRemove(
Sema &SemaRef, llvm::SmallPtrSetImpl<DeclRefExpr *> &DR,
18349 :
Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
18351 auto It = std::find_if(CurrentII, IISet.rend(),
18353 return Elem.getPointer() == E;
18359 if (It == IISet.rend()) {
18361 CurrentII->setInt(1);
18368 return Base::TransformConstantExpr(E);
18369 RemoveImmediateInvocation(E);
18370 return Base::TransformExpr(E->
getSubExpr());
18376 return Base::TransformCXXOperatorCallExpr(E);
18390 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(
Init))
18391 Init = ICE->getSubExpr();
18392 else if (
auto *ICE = dyn_cast<MaterializeTemporaryExpr>(
Init))
18393 Init = ICE->getSubExpr();
18399 if (
auto *CE = dyn_cast<ConstantExpr>(
Init);
18400 CE && CE->isImmediateInvocation())
18401 RemoveImmediateInvocation(CE);
18402 return Base::TransformInitializer(
Init, NotCopyInit);
18413 bool AlwaysRebuild() {
return false; }
18414 bool ReplacingOriginal() {
return true; }
18415 bool AllowSkippingCXXConstructExpr() {
18416 bool Res = AllowSkippingFirstCXXConstructExpr;
18417 AllowSkippingFirstCXXConstructExpr =
true;
18420 bool AllowSkippingFirstCXXConstructExpr =
true;
18431 Transformer.AllowSkippingFirstCXXConstructExpr =
false;
18433 ExprResult Res = Transformer.TransformExpr(It->getPointer()->getSubExpr());
18439 It->getPointer()->setSubExpr(Res.
get());
18459 if (VD && (VD->isUsableInConstantExpressions(
SemaRef.
Context) ||
18460 VD->hasConstantInitialization())) {
18493 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18494 SimpleRemove(llvm::SmallPtrSetImpl<DeclRefExpr *> &S) : DRSet(S) {}
18497 return DRSet.size();
18500 Visitor.TraverseStmt(
18510 if (DR->isImmediateEscalating())
18514 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND);
18516 ND = MD->getParent();
18523 bool ImmediateEscalating =
false;
18524 bool IsPotentiallyEvaluated =
18534 SemaRef.
Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
18535 << ND << isa<CXXRecordDecl>(ND) << FD->isConsteval();
18536 if (!FD->getBuiltinID())
18540 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
18542 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
18544 if (FD->isImmediateEscalating() && !FD->isConsteval())
18558 (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument ||
18566 D = diag::err_lambda_unevaluated_operand;
18572 D = diag::err_lambda_in_constant_expression;
18573 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
18576 D = diag::err_lambda_in_invalid_context;
18578 llvm_unreachable(
"Couldn't infer lambda error message.");
18580 for (
const auto *L : Rec.
Lambdas)
18581 Diag(L->getBeginLoc(), D);
18601 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
18672 llvm_unreachable(
"Invalid context");
18718 : FD(FD), Param(Param) {}
18725 CCName =
"stdcall";
18728 CCName =
"fastcall";
18731 CCName =
"vectorcall";
18734 llvm_unreachable(
"CC does not need mangling");
18737 S.
Diag(Loc, diag::err_cconv_incomplete_param_type)
18738 << Param->getDeclName() << FD->
getDeclName() << CCName;
18743 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
18749enum class OdrUseContext {
18768 if (Context.isUnevaluated())
18769 return OdrUseContext::None;
18772 return OdrUseContext::Dependent;
18774 if (Context.isDiscardedStatementContext())
18775 return OdrUseContext::FormallyOdrUsed;
18777 else if (Context.Context ==
18779 return OdrUseContext::FormallyOdrUsed;
18781 return OdrUseContext::Used;
18785 if (!
Func->isConstexpr())
18788 if (
Func->isImplicitlyInstantiable() || !
Func->isUserProvided())
18795 auto *CCD = dyn_cast<CXXConstructorDecl>(
Func);
18796 return CCD && CCD->getInheritedConstructor();
18800 bool MightBeOdrUse) {
18801 assert(
Func &&
"No function?");
18803 Func->setReferenced();
18816 OdrUseContext OdrUse =
18818 if (IsRecursiveCall && OdrUse == OdrUseContext::Used)
18819 OdrUse = OdrUseContext::FormallyOdrUsed;
18823 if (
Func->isTrivial() && !
Func->hasAttr<DLLExportAttr>() &&
18824 OdrUse == OdrUseContext::Used) {
18827 OdrUse = OdrUseContext::FormallyOdrUsed;
18829 OdrUse = OdrUseContext::FormallyOdrUsed;
18836 bool NeededForConstantEvaluation =
18861 bool NeedDefinition =
18862 !IsRecursiveCall &&
18863 (OdrUse == OdrUseContext::Used ||
18864 (NeededForConstantEvaluation && !
Func->isPureVirtual()));
18871 if (NeedDefinition &&
18873 Func->getMemberSpecializationInfo()))
18880 if (NeedDefinition && !
Func->getBody()) {
18883 dyn_cast<CXXConstructorDecl>(
Func)) {
18896 }
else if (
Constructor->getInheritedConstructor()) {
18900 dyn_cast<CXXDestructorDecl>(
Func)) {
18910 if (MethodDecl->isOverloadedOperator() &&
18911 MethodDecl->getOverloadedOperator() == OO_Equal) {
18913 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
18914 if (MethodDecl->isCopyAssignmentOperator())
18916 else if (MethodDecl->isMoveAssignmentOperator())
18920 MethodDecl->getParent()->isLambda()) {
18927 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
18931 if (
Func->isDefaulted() && !
Func->isDeleted()) {
18939 if (
Func->isImplicitlyInstantiable()) {
18941 Func->getTemplateSpecializationKindForInstantiation();
18943 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
18944 if (FirstInstantiation) {
18945 PointOfInstantiation = Loc;
18946 if (
auto *MSI =
Func->getMemberSpecializationInfo())
18947 MSI->setPointOfInstantiation(Loc);
18950 Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
18955 PointOfInstantiation = Loc;
18959 Func->isConstexpr()) {
18964 std::make_pair(
Func, PointOfInstantiation));
18965 else if (
Func->isConstexpr())
18971 Func->setInstantiationIsPending(
true);
18973 std::make_pair(
Func, PointOfInstantiation));
18974 if (llvm::isTimeTraceVerbose()) {
18975 llvm::timeTraceAddInstantEvent(
"DeferInstantiation", [&] {
18977 llvm::raw_string_ostream
OS(Name);
18984 Consumer.HandleCXXImplicitFunctionInstantiation(
Func);
18989 for (
auto *i :
Func->redecls()) {
18990 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
19008 if (
Init->isInClassMemberInitializer())
19010 MarkDeclarationsReferencedInExpr(Init->getInit());
19031 if (
LangOpts.OffloadImplicitHostDeviceTemplates &&
LangOpts.CUDAIsDevice &&
19036 if (OdrUse == OdrUseContext::Used && !
Func->isUsed(
false)) {
19038 if (!
Func->isDefined() && !
Func->isInAnotherModuleUnit()) {
19039 if (mightHaveNonExternalLinkage(
Func))
19041 else if (
Func->getMostRecentDecl()->isInlined() &&
19043 !
Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
19061 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
19062 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(
Func)) {
19082 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
19085 VarDecl *Var =
V->getPotentiallyDecomposedVarDecl();
19086 assert(Var &&
"expected a capturable variable");
19096 QualType CaptureType, DeclRefType;
19102 DeclRefType, FunctionScopeIndexToStopAt);
19117 << 2 << 1 << Var << UserTarget;
19120 ? diag::note_cuda_const_var_unpromoted
19121 : diag::note_cuda_host_var);
19130 Var->
hasAttr<CUDADeviceAttr>() &&
19131 !Var->
getAttr<CUDADeviceAttr>()->isImplicit())) &&
19132 !Var->
hasAttr<CUDASharedAttr>() &&
19148 (!FD || (!FD->getDescribedFunctionTemplate() &&
19160 unsigned CapturingScopeIndex) {
19187 unsigned ContextKind = 3;
19197 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
19198 << var << ValueKind << ContextKind << VarDC;
19199 S.
Diag(var->getLocation(), diag::note_entity_declared_at)
19208 bool &SubCapturesAreNested,
19214 SubCapturesAreNested =
true;
19267 "Only variables and structured bindings can be captured");
19278 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
19287 S.
Diag(Loc, diag::err_ref_vm_type);
19298 S.
Diag(Loc, diag::err_ref_flexarray_type);
19300 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type) << Var;
19305 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19310 S.
Diag(Loc, diag::err_capture_block_variable) << Var << !IsLambda;
19319 S.
Diag(Loc, diag::err_opencl_block_ref_block);
19330 ? diag::warn_cxx17_compat_capture_binding
19331 : diag::ext_capture_binding)
19345 bool ByRef =
false;
19351 if (BuildAndDiagnose) {
19352 S.
Diag(Loc, diag::err_ref_array_type);
19363 if (BuildAndDiagnose) {
19364 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
19380 if (BuildAndDiagnose) {
19382 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
19383 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
19388 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19397 DeclRefType = CaptureType;
19401 if (BuildAndDiagnose)
19411 const bool BuildAndDiagnose,
QualType &CaptureType,
QualType &DeclRefType,
19412 const bool RefersToCapturedVariable,
TryCaptureKind Kind,
bool IsTopScope,
19438 CaptureType = DeclRefType;
19441 if (BuildAndDiagnose)
19442 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
19452 const bool RefersToCapturedVariable,
19457 bool ByRef =
false;
19461 ByRef = (LSI->
ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByref);
19466 S.
Diag(Loc, diag::err_wasm_ca_reference) << 0;
19497 if (!RefType->getPointeeType()->isFunctionType())
19504 if (BuildAndDiagnose) {
19505 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
19515 if (!
Invalid && BuildAndDiagnose) {
19519 diag::err_capture_of_incomplete_or_sizeless_type,
19523 diag::err_capture_of_abstract_type))
19549 if (BuildAndDiagnose)
19550 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
19551 Loc, EllipsisLoc, CaptureType,
Invalid);
19562 if (T.isTriviallyCopyableType(Context))
19566 if (!(RD = RD->getDefinition()))
19568 if (RD->hasSimpleCopyConstructor())
19570 if (RD->hasUserDeclaredCopyConstructor())
19572 if (Ctor->isCopyConstructor())
19573 return !Ctor->isDeleted();
19593 if (ShouldOfferCopyFix) {
19597 FixBuffer.assign({Separator, Var->
getName()});
19598 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
19603 FixBuffer.assign({Separator,
"&", Var->
getName()});
19604 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
19616 return !C.isThisCapture() && !C.isInitCapture();
19625 if (ShouldOfferCopyFix) {
19626 bool CanDefaultCopyCapture =
true;
19635 if (CanDefaultCopyCapture && llvm::none_of(LSI->
Captures, [](
Capture &
C) {
19636 return !C.isThisCapture() && !C.isInitCapture() && C.isCopyCapture();
19638 FixBuffer.assign({
"=", Separator});
19639 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
19648 return !C.isInitCapture() && C.isReferenceCapture() &&
19649 !C.isThisCapture();
19651 FixBuffer.assign({
"&", Separator});
19652 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
19661 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
19684 const auto *VD = dyn_cast<VarDecl>(Var);
19686 if (VD->isInitCapture())
19691 assert(VD &&
"Cannot capture a null variable");
19693 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
19697 if (FunctionScopeIndexToStopAt) {
19698 assert(!
FunctionScopes.empty() &&
"No function scopes to stop at?");
19703 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(
FunctionScopes[FSIndex]);
19704 FSIndex && LSI && !LSI->AfterParameterList)
19706 assert(MaxFunctionScopesIndex <= FSIndex &&
19707 "FunctionScopeIndexToStopAt should be no greater than FSIndex into "
19708 "FunctionScopes.");
19709 while (FSIndex != MaxFunctionScopesIndex) {
19717 bool IsGlobal = !VD->hasLocalStorage();
19718 if (IsGlobal && !(
LangOpts.OpenMP &&
19719 OpenMP().isOpenMPCapturedDecl(Var,
true,
19720 MaxFunctionScopesIndex)))
19734 CaptureType = Var->
getType();
19736 bool Nested =
false;
19738 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
19743 LSI = dyn_cast_or_null<LambdaScopeInfo>(
19746 bool IsInScopeDeclarationContext =
19757 if (IsInScopeDeclarationContext &&
19758 FunctionScopesIndex == MaxFunctionScopesIndex && VarDC == DC)
19764 !IsInScopeDeclarationContext
19767 BuildAndDiagnose, *
this);
19773 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
19792 if (
const auto *Parm = dyn_cast<ParmVarDecl>(Var);
19793 Parm && Parm->getDeclContext() == DC)
19801 if (BuildAndDiagnose) {
19804 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
19819 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
19820 QTy = PVD->getOriginalType();
19825 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
19832 if (BuildAndDiagnose) {
19833 Diag(ExprLoc, diag::err_capture_binding_openmp) << Var;
19839 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
19844 if (IsOpenMPPrivateDecl != OMPC_unknown &&
19847 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
19848 QTy = PVD->getOriginalType();
19850 E =
OpenMP().getNumberOfConstructScopes(RSI->OpenMPLevel);
19854 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
19855 "Wrong number of captured regions associated with the "
19856 "OpenMP construct.");
19861 IsOpenMPPrivateDecl != OMPC_private &&
19863 RSI->OpenMPCaptureLevel);
19867 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
19873 OpenMP().adjustOpenMPTargetScopeIndex(FunctionScopesIndex,
19876 if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
19877 (IsGlobal && !IsGlobalCap)) {
19878 Nested = !IsTargetCap;
19884 CaptureType =
Context.getLValueReferenceType(DeclRefType);
19893 if (BuildAndDiagnose) {
19894 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
19916 FunctionScopesIndex--;
19917 if (IsInScopeDeclarationContext)
19919 }
while (!VarDC->
Equals(DC));
19927 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
19940 if (
Invalid && !BuildAndDiagnose)
19945 DeclRefType, Nested, *
this,
Invalid);
19949 RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
19950 Kind, I == N - 1, *
this,
Invalid);
19956 DeclRefType, Nested, Kind, EllipsisLoc,
19961 if (
Invalid && !BuildAndDiagnose)
19973 DeclRefType,
nullptr);
19981 false, CaptureType, DeclRefType,
nullptr);
19985 assert(Var &&
"Null value cannot be captured");
19992 false, CaptureType, DeclRefType,
19996 return DeclRefType;
20004class CopiedTemplateArgs {
20008 template<
typename RefExpr>
20009 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
20011 E->copyTemplateArgumentsInto(TemplateArgStorage);
20014#ifdef __has_cpp_attribute
20015#if __has_cpp_attribute(clang::lifetimebound)
20016 [[clang::lifetimebound]]
20020 return HasArgs ? &TemplateArgStorage :
nullptr;
20046 auto Rebuild = [&](
Expr *Sub) {
20051 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
20054 auto *VD = dyn_cast<VarDecl>(D);
20077 llvm_unreachable(
"unexpected non-odr-use-reason");
20081 if (VD->getType()->isReferenceType())
20083 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
20084 if (RD->hasDefinition() && RD->hasMutableFields())
20086 if (!VD->isUsableInConstantExpressions(S.
Context))
20091 if (VD->getType()->isReferenceType())
20099 auto MaybeCUDAODRUsed = [&]() ->
bool {
20105 auto *DRE = dyn_cast<DeclRefExpr>(E);
20108 auto *VD = dyn_cast<VarDecl>(DRE->getDecl());
20115 auto MarkNotOdrUsed = [&] {
20116 if (!MaybeCUDAODRUsed()) {
20119 LSI->markVariableExprAsNonODRUsed(E);
20127 case Expr::DeclRefExprClass: {
20129 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
20135 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
20136 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
20137 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
20138 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
20141 case Expr::FunctionParmPackExprClass: {
20146 if (IsPotentialResultOdrUsed(D))
20157 case Expr::ArraySubscriptExprClass: {
20163 if (!
Base.isUsable())
20165 Expr *LHS = ASE->getBase() == ASE->getLHS() ?
Base.get() : ASE->getLHS();
20166 Expr *RHS = ASE->getBase() == ASE->getRHS() ?
Base.get() : ASE->getRHS();
20169 ASE->getRBracketLoc());
20172 case Expr::MemberExprClass: {
20178 if (!
Base.isUsable())
20181 S.
Context,
Base.get(), ME->isArrow(), ME->getOperatorLoc(),
20182 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
20183 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
20184 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
20185 ME->getObjectKind(), ME->isNonOdrUse());
20188 if (ME->getMemberDecl()->isCXXInstanceMember())
20193 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
20199 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
20200 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
20201 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
20202 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
20205 case Expr::BinaryOperatorClass: {
20207 Expr *LHS = BO->getLHS();
20208 Expr *RHS = BO->getRHS();
20210 if (BO->getOpcode() == BO_PtrMemD) {
20212 if (!Sub.isUsable())
20214 BO->setLHS(Sub.get());
20216 }
else if (BO->getOpcode() == BO_Comma) {
20218 if (!Sub.isUsable())
20220 BO->setRHS(Sub.get());
20228 case Expr::ParenExprClass: {
20231 if (!Sub.isUsable())
20233 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
20238 case Expr::ConditionalOperatorClass: {
20249 LHS = CO->getLHS();
20251 RHS = CO->getRHS();
20253 CO->getCond(), LHS.
get(), RHS.
get());
20258 case Expr::UnaryOperatorClass: {
20260 if (UO->getOpcode() != UO_Extension)
20263 if (!Sub.isUsable())
20265 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
20272 case Expr::GenericSelectionExprClass: {
20276 bool AnyChanged =
false;
20277 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
20278 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
20282 AssocExprs.push_back(AssocExpr.
get());
20285 AssocExprs.push_back(OrigAssocExpr);
20289 void *ExOrTy =
nullptr;
20290 bool IsExpr = GSE->isExprPredicate();
20292 ExOrTy = GSE->getControllingExpr();
20294 ExOrTy = GSE->getControllingType();
20296 GSE->getGenericLoc(), GSE->getDefaultLoc(),
20297 GSE->getRParenLoc(), IsExpr, ExOrTy,
20298 GSE->getAssocTypeSourceInfos(), AssocExprs)
20306 case Expr::ChooseExprClass: {
20317 if (!LHS.
get() && !RHS.
get())
20320 LHS = CE->getLHS();
20322 RHS = CE->getRHS();
20325 RHS.
get(), CE->getRParenLoc());
20329 case Expr::ConstantExprClass: {
20332 if (!Sub.isUsable())
20339 case Expr::ImplicitCastExprClass: {
20344 switch (ICE->getCastKind()) {
20346 case CK_DerivedToBase:
20347 case CK_UncheckedDerivedToBase: {
20348 ExprResult Sub = Rebuild(ICE->getSubExpr());
20349 if (!Sub.isUsable())
20353 ICE->getValueKind(), &Path);
20410 for (
Expr *E : LocalMaybeODRUseExprs) {
20411 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
20413 DRE->getLocation(), *
this);
20414 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
20417 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
20421 llvm_unreachable(
"Unexpected expression");
20426 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
20435 const bool RefersToEnclosingScope =
20438 if (RefersToEnclosingScope) {
20453 assert(E &&
"Capture variable should be used in an expression.");
20466 "Invalid Expr argument to DoMarkVarDeclReferenced");
20477 bool UsableInConstantExpr =
20489 bool NeededForConstantEvaluation =
20492 bool NeedDefinition =
20493 OdrUse == OdrUseContext::Used || NeededForConstantEvaluation ||
20495 Var->
getType()->isUndeducedType());
20498 "Can't instantiate a partial template specialization.");
20515 bool TryInstantiating =
20519 if (TryInstantiating) {
20522 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
20523 if (FirstInstantiation) {
20524 PointOfInstantiation = Loc;
20526 MSI->setPointOfInstantiation(PointOfInstantiation);
20548 if (
auto *DRE = dyn_cast_or_null<DeclRefExpr>(E))
20549 DRE->setDecl(DRE->getDecl());
20550 else if (
auto *ME = dyn_cast_or_null<MemberExpr>(E))
20551 ME->setMemberDecl(ME->getMemberDecl());
20552 }
else if (FirstInstantiation) {
20554 .push_back(std::make_pair(Var, PointOfInstantiation));
20556 bool Inserted =
false;
20558 auto Iter = llvm::find_if(
20560 return P.first == Var;
20562 if (Iter != I.end()) {
20577 .push_back(std::make_pair(Var, PointOfInstantiation));
20601 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
20602 if (DRE->isNonOdrUse())
20604 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
20605 if (ME->isNonOdrUse())
20609 case OdrUseContext::None:
20614 "missing non-odr-use marking for unevaluated decl ref");
20617 case OdrUseContext::FormallyOdrUsed:
20622 case OdrUseContext::Used:
20631 case OdrUseContext::Dependent:
20649 if (OdrUse == OdrUseContext::Used) {
20650 QualType CaptureType, DeclRefType;
20656 }
else if (OdrUse == OdrUseContext::Dependent) {
20672 auto *ID = dyn_cast<DeclRefExpr>(E);
20673 if (!ID || ID->isTypeDependent() || !ID->refersToEnclosingVariableOrCapture())
20680 auto IsDependent = [&]() {
20682 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
20687 LSI->AfterParameterList)
20690 const auto *MD = LSI->CallOperator;
20691 if (MD->getType().isNull())
20695 if (!Ty || !MD->isExplicitObjectMemberFunction() ||
20699 if (
auto *
C = LSI->CaptureMap.count(D) ? &LSI->getCapture(D) :
nullptr) {
20700 if (
C->isCopyCapture())
20705 if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
20711 ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
20717 bool MightBeOdrUse,
20725 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
20744 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
20751 bool IsVirtualCall = MD->
isVirtual() &&
20753 if (!IsVirtualCall)
20770 bool OdrUse =
true;
20772 if (
Method->isVirtual() &&
20776 if (
auto *FD = dyn_cast<FunctionDecl>(E->
getDecl())) {
20781 !FD->isDependentContext())
20795 bool MightBeOdrUse =
true;
20798 if (
Method->isPureVirtual())
20799 MightBeOdrUse =
false;
20818 bool MightBeOdrUse) {
20819 if (MightBeOdrUse) {
20820 if (
auto *VD = dyn_cast<VarDecl>(D)) {
20825 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
20851bool MarkReferencedDecls::TraverseTemplateArgument(
20852 const TemplateArgument &Arg) {
20855 EnterExpressionEvaluationContext
Evaluated(
20869 MarkReferencedDecls Marker(*
this, Loc);
20870 Marker.TraverseType(T);
20876class EvaluatedExprMarker :
public UsedDeclVisitor<EvaluatedExprMarker> {
20879 bool SkipLocalVariables;
20882 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables,
20884 : Inherited(S), SkipLocalVariables(SkipLocalVariables), StopAt(StopAt) {}
20890 void Visit(Expr *E) {
20891 if (llvm::is_contained(StopAt, E))
20893 Inherited::Visit(E);
20896 void VisitConstantExpr(ConstantExpr *E) {
20901 void VisitDeclRefExpr(DeclRefExpr *E) {
20903 if (SkipLocalVariables) {
20904 if (VarDecl *VD = dyn_cast<VarDecl>(E->
getDecl()))
20905 if (VD->hasLocalStorage())
20915 void VisitMemberExpr(MemberExpr *E) {
20923 bool SkipLocalVariables,
20925 EvaluatedExprMarker(*
this, SkipLocalVariables, StopAt).Visit(E);
20937 (
Decl->isConstexpr() || (
Decl->isStaticDataMember() &&
20941 if (Stmts.empty()) {
20955 if (
Decl &&
Decl->isFileVarDecl()) {
21028 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
21034 : FD(FD), CE(CE) { }
21038 S.
Diag(Loc, diag::err_call_incomplete_return)
21043 S.
Diag(Loc, diag::err_call_function_incomplete_return)
21048 } Diagnoser(FD, CE);
21061 unsigned diagnostic = diag::warn_condition_is_assignment;
21062 bool IsOrAssign =
false;
21065 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
21068 IsOrAssign = Op->getOpcode() == BO_OrAssign;
21076 if (
ObjC().isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
21077 diagnostic = diag::warn_condition_is_idiomatic_assignment;
21081 diagnostic = diag::warn_condition_is_idiomatic_assignment;
21084 Loc = Op->getOperatorLoc();
21086 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
21089 IsOrAssign = Op->getOperator() == OO_PipeEqual;
21090 Loc = Op->getOperatorLoc();
21102 Diag(Loc, diag::note_condition_assign_silence)
21107 Diag(Loc, diag::note_condition_or_assign_to_comparison)
21110 Diag(Loc, diag::note_condition_assign_to_comparison)
21128 if (opE->getOpcode() == BO_EQ &&
21129 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
21135 Diag(Loc, diag::note_equality_comparison_silence)
21138 Diag(Loc, diag::note_equality_comparison_to_assign)
21144 bool IsConstexpr) {
21146 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
21163 if (!T->isScalarType()) {
21164 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
21168 CheckBoolLikeConversion(E, Loc);
21197 if (
Cond.isInvalid()) {
21205 if (!
Cond.isUsable())
21215 struct RebuildUnknownAnyFunction
21216 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
21220 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
21223 llvm_unreachable(
"unexpected statement!");
21234 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
21235 ExprResult SubResult = Visit(E->getSubExpr());
21238 Expr *SubExpr = SubResult.
get();
21239 E->setSubExpr(SubExpr);
21240 E->setType(SubExpr->
getType());
21247 return rebuildSugarExpr(E);
21250 ExprResult VisitUnaryExtension(UnaryOperator *E) {
21251 return rebuildSugarExpr(E);
21254 ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
21258 Expr *SubExpr = SubResult.
get();
21266 ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
21284 ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
21285 return resolveDecl(E, E->
getDecl());
21293 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
21294 if (Result.isInvalid())
return ExprError();
21303 struct RebuildUnknownAnyExpr
21304 : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
21311 RebuildUnknownAnyExpr(Sema &S, QualType
CastType)
21315 llvm_unreachable(
"unexpected statement!");
21325 ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
21329 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
21330 ExprResult SubResult = Visit(E->getSubExpr());
21332 Expr *SubExpr = SubResult.
get();
21333 E->setSubExpr(SubExpr);
21334 E->setType(SubExpr->
getType());
21341 return rebuildSugarExpr(E);
21344 ExprResult VisitUnaryExtension(UnaryOperator *E) {
21345 return rebuildSugarExpr(E);
21348 ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
21349 const PointerType *Ptr = DestType->
getAs<PointerType>();
21374 ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
21376 ExprResult resolveDecl(Expr *E, ValueDecl *VD);
21382 ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
21383 return resolveDecl(E, E->
getDecl());
21389ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
21394 FK_FunctionPointer,
21399 QualType CalleeType = CalleeExpr->
getType();
21402 Kind = FK_MemberFunction;
21404 }
else if (
const PointerType *Ptr = CalleeType->
getAs<PointerType>()) {
21406 Kind = FK_FunctionPointer;
21409 Kind = FK_BlockPointer;
21411 const FunctionType *FnType = CalleeType->
castAs<FunctionType>();
21416 unsigned diagID = diag::err_func_returning_array_function;
21417 if (Kind == FK_BlockPointer)
21418 diagID = diag::err_block_returning_array_function;
21431 const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FnType);
21453 SmallVector<QualType, 8> ArgTypes;
21454 if (ParamTypes.empty() && Proto->
isVariadic()) {
21456 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
21459 ParamTypes = ArgTypes;
21470 case FK_MemberFunction:
21474 case FK_FunctionPointer:
21478 case FK_BlockPointer:
21484 ExprResult CalleeResult = Visit(CalleeExpr);
21492ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
21495 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
21503 Method->setReturnType(DestType);
21513ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
21515 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
21529 }
else if (E->
getCastKind() == CK_LValueToRValue) {
21546 llvm_unreachable(
"Unhandled cast type!");
21550ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
21552 QualType
Type = DestType;
21557 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(VD)) {
21558 if (
const PointerType *Ptr =
Type->getAs<PointerType>()) {
21566 if (!
Type->isFunctionType()) {
21571 if (
const FunctionProtoType *FT =
Type->getAs<FunctionProtoType>()) {
21575 QualType FDT = FD->getType();
21576 const FunctionType *FnType = FDT->
castAs<FunctionType>();
21577 const FunctionProtoType *Proto = dyn_cast_or_null<FunctionProtoType>(FnType);
21578 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
21579 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
21580 SourceLocation Loc = FD->getLocation();
21582 S.
Context, FD->getDeclContext(), Loc, Loc,
21583 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
21585 false , FD->hasPrototype(),
21588 if (FD->getQualifier())
21591 SmallVector<ParmVarDecl*, 16> Params;
21592 for (
const auto &AI : FT->param_types()) {
21593 ParmVarDecl *Param =
21596 Params.push_back(Param);
21598 NewFD->setParams(Params);
21604 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
21605 if (MD->isInstance()) {
21616 if (
const ReferenceType *RefTy =
Type->getAs<ReferenceType>()) {
21617 Type = RefTy->getPointeeType();
21618 }
else if (
Type->isFunctionType()) {
21619 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
21645 diag::err_typecheck_cast_to_incomplete))
21660 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
21667 ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
21676 assert(!arg->hasPlaceholderType());
21688 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
21691 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
21692 E = call->getCallee();
21693 diagID = diag::err_uncasted_call_of_unknown_any;
21701 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
21702 loc = ref->getLocation();
21703 d = ref->getDecl();
21704 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
21705 loc = mem->getMemberLoc();
21706 d = mem->getMemberDecl();
21708 diagID = diag::err_uncasted_call_of_unknown_any;
21709 loc = msg->getSelectorStartLoc();
21710 d = msg->getMethodDecl();
21712 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
21713 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
21731 if (!placeholderType)
return E;
21733 switch (placeholderType->
getKind()) {
21734 case BuiltinType::UnresolvedTemplate: {
21747 if (
auto *TD = dyn_cast<TemplateDecl>(Temp))
21748 TN =
Context.getQualifiedTemplateName(NNS, ULE->hasTemplateKeyword(),
21753 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
21754 << TN << ULE->getSourceRange() << IsTypeAliasTemplateDecl;
21756 << IsTypeAliasTemplateDecl;
21759 bool HasAnyDependentTA =
false;
21761 HasAnyDependentTA |= Arg.getArgument().
isDependent();
21773 TST =
Context.getTemplateSpecializationType(
21782 case BuiltinType::Overload: {
21802 case BuiltinType::BoundMember: {
21808 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
21809 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
21810 if (ME->getMemberNameInfo().getName().getNameKind() ==
21812 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
21820 case BuiltinType::ARCUnbridgedCast: {
21827 case BuiltinType::UnknownAny:
21831 case BuiltinType::PseudoObject:
21834 case BuiltinType::BuiltinFn: {
21839 unsigned BuiltinID = FD->getBuiltinID();
21840 if (BuiltinID == Builtin::BI__noop) {
21842 CK_BuiltinFnToFnPtr)
21849 if (
Context.BuiltinInfo.isInStdNamespace(BuiltinID)) {
21855 ? diag::err_use_of_unaddressable_function
21856 : diag::warn_cxx20_compat_use_of_unaddressable_function);
21857 if (FD->isImplicitlyInstantiable()) {
21884 case BuiltinType::IncompleteMatrixIdx: {
21890 MS->getBase(), MS->getRowIdx(), E->
getExprLoc());
21892 Diag(MS->getRowIdx()->getBeginLoc(), diag::err_matrix_incomplete_index);
21897 case BuiltinType::ArraySection:
21906 case BuiltinType::OMPArrayShaping:
21909 case BuiltinType::OMPIterator:
21913#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
21914 case BuiltinType::Id:
21915#include "clang/Basic/OpenCLImageTypes.def"
21916#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
21917 case BuiltinType::Id:
21918#include "clang/Basic/OpenCLExtensionTypes.def"
21919#define SVE_TYPE(Name, Id, SingletonId) \
21920 case BuiltinType::Id:
21921#include "clang/Basic/AArch64ACLETypes.def"
21922#define PPC_VECTOR_TYPE(Name, Id, Size) \
21923 case BuiltinType::Id:
21924#include "clang/Basic/PPCTypes.def"
21925#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21926#include "clang/Basic/RISCVVTypes.def"
21927#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21928#include "clang/Basic/WebAssemblyReferenceTypes.def"
21929#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
21930#include "clang/Basic/AMDGPUTypes.def"
21931#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
21932#include "clang/Basic/HLSLIntangibleTypes.def"
21933#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
21934#define PLACEHOLDER_TYPE(Id, SingletonId)
21935#include "clang/AST/BuiltinTypes.def"
21939 llvm_unreachable(
"invalid placeholder type!");
21952 if (!
Context.getLangOpts().RecoveryAST)
21958 if (T.isNull() || T->isUndeducedType() ||
21959 !
Context.getLangOpts().RecoveryASTType)
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static bool isObjCPointer(const MemRegion *R)
Defines enum values for all the target-independent builtin functions.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
static DeclT * getDefinitionOrSelf(DeclT *D)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static QualType getUnderlyingType(const SubRegion *R)
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 functions specific to ARM.
This file declares semantic analysis for CUDA constructs.
static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy, SourceLocation OpLoc)
static void HandleImmediateInvocations(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec)
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr * > Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int, QualType FloatTy)
Test if a (constant) integer Int can be casted to floating point type FloatTy without losing precisio...
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing?
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, const Expr *LHSExpr, const Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D, bool AcceptInvalid)
Diagnoses obvious problems with the use of the given declaration as an expression.
static void diagnoseUncapturableValueReferenceOrBinding(Sema &S, SourceLocation loc, ValueDecl *var)
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Return the resulting type for the conditional operator in OpenCL (aka "ternary selection operator",...
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
static AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
static bool isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn)
static bool isCapturingReferenceToHostVarInCUDADeviceLambda(const Sema &S, VarDecl *VD)
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy, unsigned &DiagID)
Try to convert a value of non-vector type to a vector type by converting the type to the element type...
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
static Expr * recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context, DeclarationNameInfo &NameInfo, SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs)
In Microsoft mode, if we are inside a template class whose parent class has dependent base classes,...
static AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(Sema &SemaRef, ValueDecl *D, Expr *E)
static bool isVariableCapturable(CapturingScopeInfo *CSI, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
static Decl * getPredefinedExprDecl(DeclContext *DC)
getPredefinedExprDecl - Returns Decl of a given DeclContext that can be used to determine the value o...
static CXXRecordDecl * LookupStdSourceLocationImpl(Sema &S, SourceLocation Loc)
static bool IgnoreCommaOperand(const Expr *E, const ASTContext &Context)
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc, bool IsAfterAmp=false)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static bool ExprLooksBoolean(const Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef)
Are we in a context that is potentially constant evaluated per C++20 [expr.const]p12?
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc, bool IsBuiltin)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
static bool checkCondition(Sema &S, const Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
static bool checkForArray(const Expr *E)
static void DiagnosedUnqualifiedCallsToStdFunctions(Sema &S, const CallExpr *Call)
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
static bool areTypesCompatibleForGeneric(ASTContext &Ctx, QualType T, QualType U)
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool MayBeFunctionType(const ASTContext &Context, const Expr *E)
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S)
Convert vector E to a vector with the same number of elements but different element type.
static void DoMarkPotentialCapture(Sema &SemaRef, SourceLocation Loc, ValueDecl *Var, Expr *E)
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
static void EvaluateAndDiagnoseImmediateInvocation(Sema &SemaRef, Sema::ImmediateInvocationCandidate Candidate)
static bool checkThreeWayNarrowingConversion(Sema &S, QualType ToType, Expr *E, QualType FromType, SourceLocation Loc)
static bool IsArithmeticBinaryExpr(const Expr *E, BinaryOperatorKind *Opcode, const Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptionsOverride FPFeatures)
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
static void checkDirectCallValidity(Sema &S, const Expr *Fn, FunctionDecl *Callee, MultiExprArg ArgExprs)
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union.
static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType CondTy, SourceLocation QuestionLoc)
Convert scalar operands to a vector that matches the condition in length.
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static void diagnoseSubtractionOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool BothNull)
Diagnose invalid subraction on a null pointer.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
static void RemoveNestedImmediateInvocation(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec, SmallVector< Sema::ImmediateInvocationCandidate, 4 >::reverse_iterator It)
static void CheckUnicodeArithmeticConversions(Sema &SemaRef, Expr *LHS, Expr *RHS, SourceLocation Loc, ArithConvKind ACK)
static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *SubExpr)
Look for bitwise op in the left or right hand of a bitwise op with lower precedence and emit a diagno...
static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix)
CheckIncrementDecrementOperand - unlike most "Check" methods, this routine doesn't need to call Usual...
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
Diagnose some forms of syntactically-obvious tautological comparison.
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, const Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr * > Args)
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the lambda.
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128, __ibm128 and long double if there is no support for ...
static void MarkVarDeclODRUsed(ValueDecl *V, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt=nullptr)
Directly mark a variable odr-used.
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
static bool funcHasParameterSizeMangling(Sema &S, FunctionDecl *FD)
Return true if this function has a calling convention that requires mangling in the size of the param...
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
static AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType, SourceLocation Loc)
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar, ExprResult *Vector)
Attempt to convert and splat Scalar into a vector whose types matches Vector following GCC conversion...
static void diagnoseScopedEnums(Sema &S, const SourceLocation Loc, const ExprResult &LHS, const ExprResult &RHS, BinaryOperatorKind Opc)
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
static OdrUseContext isOdrUseContext(Sema &SemaRef)
Are we within a context in which references to resolved functions or to variables result in odr-use?
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, ValueDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
static void CheckSufficientAllocSize(Sema &S, QualType DestType, const Expr *E)
Check that a call to alloc_size function specifies sufficient space for the destination type.
static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
static QualType checkArithmeticOrEnumeralThreeWayCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
static QualType handleOverflowBehaviorTypeConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
static bool captureInBlock(BlockScopeInfo *BSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S, bool Invalid)
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
static FieldDecl * FindFieldDeclInstantiationPattern(const ASTContext &Ctx, FieldDecl *Field)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
static bool IsReadonlyMessage(Expr *E, Sema &S)
static std::optional< bool > isTautologicalBoundsCheck(Sema &S, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opc)
Detect patterns ptr + size >= ptr and ptr + size < ptr, where ptr is a pointer and size is an unsigne...
static void buildLambdaCaptureFixit(Sema &Sema, LambdaScopeInfo *LSI, ValueDecl *Var)
Create up to 4 fix-its for explicit reference and value capture of Var or default capture.
static void tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(Sema &S, const UnresolvedMemberExpr *const UME, SourceLocation CallLoc)
static bool checkPtrAuthTypeDiscriminatorOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
static bool CheckVectorElementsTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
static QualType getDependentArraySubscriptType(Expr *LHS, Expr *RHS, const ASTContext &Ctx)
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, TryCaptureKind Kind, bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the captured region.
static bool enclosingClassIsRelatedToClassInWhichMembersWereFound(const UnresolvedMemberExpr *const UME, Sema &S)
static unsigned GetFixedPointRank(QualType Ty)
Return the rank of a given fixed point or integer type.
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer,...
static ImplicitConversionKind castKindToImplicitConversionKind(CastKind CK)
static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS, const ExprResult &XorRHS, const SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
static bool handleComplexIntegerToFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Convert complex integers to complex floats and real integers to real floats as required for complex a...
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type.
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
static QualType handleComplexFloatConversion(Sema &S, ExprResult &Shorter, QualType ShorterType, QualType LongerType, bool PromotePrecision)
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static void DoMarkBindingDeclReferenced(Sema &SemaRef, SourceLocation Loc, BindingDecl *BD, Expr *E)
static PredefinedIdentKind getPredefinedExprKind(tok::TokenKind Kind)
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, QualType RHSTy)
handleFixedPointConversion - Fixed point operations between fixed point types and integers or other f...
static QualType handleComplexConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool canCaptureVariableByCopy(ValueDecl *Var, const ASTContext &Context)
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, Expr *E0, Expr *E1=nullptr)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
static bool isObjCObjectLiteral(ExprResult &E)
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
static bool isLegalBoolVectorBinaryOp(BinaryOperatorKind Opc)
static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E, NonOdrUseReason NOUR)
Walk the set of potential results of an expression and mark them all as non-odr-uses if they satisfy ...
static void CheckCompleteParameterTypesForMangler(Sema &S, FunctionDecl *FD, SourceLocation Loc)
Require that all of the parameter types of function be complete.
static bool isScopedEnumerationType(QualType T)
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for expressions involving.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
C Language Family Type Representation.
@ Open
The standard open() call: int open(const char *path, int oflag, ...);.
a trap message and trap category.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BuiltinVectorTypeInfo getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const
Returns the element type, element count and number of vectors (in case of tuple) for a builtin vector...
unsigned getIntWidth(QualType T) const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getScalableVectorType(QualType EltTy, unsigned NumElts, unsigned NumFields=1) const
Return the unique reference to a scalable vector type of the specified element type and scalable numb...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
const LangOptions & getLangOpts() const
CanQualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
const QualType GetHigherPrecisionFPType(QualType ElementType) const
bool typesAreBlockPointerCompatible(QualType, QualType)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
QualType getCorrespondingSaturatedType(QualType Ty) const
CanQualType BoundMemberTy
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedCharTy
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
const TargetInfo & getTargetInfo() const
QualType getOverflowBehaviorType(const OverflowBehaviorAttr *Attr, QualType Wrapped) const
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
QualType getCorrespondingUnsignedType(QualType T) const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
unsigned getTargetAddressSpace(LangAS AS) const
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false) const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
AddrLabelExpr - The GNU address of label extension, representing &&label.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for arrays.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Attr - This represents one attribute.
SourceRange getRange() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static bool isRelationalOp(Opcode Opc)
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool isComparisonOp(Opcode Opc)
StringRef getOpcodeStr() const
bool isRelationalOp() const
SourceLocation getOperatorLoc() const
bool isMultiplicativeOp() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
bool isAdditiveOp() const
static bool isAssignmentOp(Opcode Opc)
static bool isCompoundAssignmentOp(Opcode Opc)
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, const Expr *LHS, const Expr *RHS)
Return true if a binary operator using the specified opcode and operands would match the 'p = (i8*)nu...
bool isAssignmentOp() const
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static bool isEqualityOp(Opcode Opc)
static bool isBitwiseOp(Opcode Opc)
BinaryOperatorKind Opcode
A binding in a decomposition declaration.
A class which contains all the information about a particular captured value.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
void setSignatureAsWritten(TypeSourceInfo *Sig)
void setBlockMissingReturnType(bool val=true)
void setIsVariadic(bool value)
SourceLocation getCaretLocation() const
void setBody(CompoundStmt *B)
ArrayRef< ParmVarDecl * > parameters() const
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
This class is used for builtin types like 'int'.
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
const RecordType * getDetectedVirtual() const
The virtual base discovered on the path (if we are merely detecting virtuals).
Represents a call to a C++ constructor.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
Represents a C++ base or member initializer.
A default argument (C++ [dcl.fct.default]).
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
Expr * getExpr()
Get the initialization expression that will be used.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a C++ destructor within a class.
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.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
A call to an overloaded operator written using operator syntax.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
SourceRange getSourceRange() const
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Represents a C++ struct/union/class.
bool isStandardLayout() const
Determine whether this class is standard-layout per C++ [class]p7.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool isLambda() const
Determine whether this class describes a lambda function object.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
bool hasDefinition() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
static CXXReflectExpr * Create(ASTContext &C, SourceLocation OperatorLoc, TypeSourceInfo *TL)
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.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() 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.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void computeDependence()
Compute and set dependence bits.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
QualType withConst() const
Retrieves a version of this type with const applied.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
const char * getCastKindName() const
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
Represents a byte-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
static CharUnits One()
One - Construct a CharUnits quantity of one.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
unsigned getValue() const
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
ConditionalOperator - The ?
Represents the canonical version of C arrays with a specified constant size.
llvm::APInt getSize() const
Return the constant array size as an APInt.
uint64_t getZExtSize() const
Return the size zero-extended as a uint64_t.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
static ConstantResultStorageKind getStorageKind(const APValue &Value)
void MoveIntoResult(APValue &Value, const ASTContext &Context)
SourceLocation getBeginLoc() const LLVM_READONLY
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
bool isImmediateInvocation() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
void setTypoName(const IdentifierInfo *II)
void setTypoNNS(NestedNameSpecifier NNS)
Wrapper for source info for pointers decayed from arrays and functions.
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.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isRequiresExprBody() const
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.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
NestedNameSpecifier getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setDecl(ValueDecl *NewD)
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
DeclarationNameInfo getNameInfo() const
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
SourceLocation getBeginLoc() const
SourceLocation getLocation() const
Decl - This represents one declaration (or definition), e.g.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setReferenced(bool R=true)
DeclContext * getDeclContext()
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
DeclaratorContext getContext() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isInvalidType() const
const IdentifierInfo * getIdentifier() const
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
A little helper class used to produce diagnostics.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
bool ShouldVisitImplicitCode
virtual bool VisitStmt(MaybeConst< Stmt > *S)
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
virtual bool TraverseTemplateArgument(const TemplateArgument &Arg)
Represents a reference to emded data.
RAII object that enters a new expression evaluation context.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
ExplicitCastExpr - An explicit cast written in the source code.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
@ SE_AllowSideEffects
Allow any unmodeled side effect.
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreConversionOperatorSingleStep() LLVM_READONLY
Skip conversion operators.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
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...
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
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 EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
@ NPCK_ZeroLiteral
Expression is a Null pointer constant built from a literal zero.
@ NPCK_CXX11_nullptr
Expression is a C++11 nullptr.
@ NPCK_NotNull
Expression is not a Null pointer constant.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
QualType getEnumCoercedType(const ASTContext &Ctx) const
If this expression is an enumeration constant, return the enumeration type under which said constant ...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static bool isSameComparisonOperand(const Expr *E1, const Expr *E2)
Checks that the two Expr's will refer to the same value as a comparison operand.
void setObjectKind(ExprObjectKind Cat)
setObjectKind - Set the object kind produced by this expression.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
@ MLV_DuplicateVectorComponents
@ MLV_InvalidMessageExpression
@ MLV_DuplicateMatrixComponents
@ MLV_ConstQualifiedField
@ MLV_SubObjCPropertySetting
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.
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
bool isFPConstrained() const
RoundingMode getRoundingMode() const
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
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.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
const Expr * getSubExpr() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Represents a function declaration or definition.
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
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isImmediateFunction() const
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool hasCXXExplicitFunctionObjectParameter() const
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
bool isExternC() const
Determines whether this function is a function with external, C linkage.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isImmediateEscalating() const
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
size_t param_size() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool isParamConsumed(unsigned I) const
unsigned getNumParams() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
SourceLocation getLocalRangeEnd() const
TypeLoc getReturnLoc() const
SourceLocation getLocalRangeBegin() const
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
bool getCFIUncheckedCalleeAttr() const
Determine whether this is a function prototype that includes the cfi_unchecked_callee attribute.
QualType getReturnType() const
bool getCmseNSCallAttr() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
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...
Represents a field injected from an anonymous union/struct into the parent scope.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
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.
Describes an entity that is being initialized.
void setParameterCFAudited()
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
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'.
Represents the declaration of a label.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_Extended
Use extended type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
@ FEM_Source
Use the declared type for fp arithmetic.
@ CX_Promoted
Implementation of complex division using algebraic formulas at higher precision.
@ None
Permit no implicit vector bitcasts.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
bool isSignedOverflowDefined() const
bool allowArrayReturnTypes() const
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
static std::string Stringify(StringRef Str, bool Charify=false)
Stringify - Convert the specified string into a C string by i) escaping '\' and " characters and ii) ...
Represents the results of name lookup.
DeclClass * getAsSingle() const
MS property subscript expression.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
MatrixSingleSubscriptExpr - Matrix single subscript expression for the MatrixType extension when you ...
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Represents a matrix type, as defined in the Matrix Types clang extensions.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
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.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool isExternallyVisible() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier, or null.
@ Type
A type, stored as a Type*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber,...
Represents an ObjC class declaration.
bool hasDefinition() const
Determine whether this class has been defined.
ivar_iterator ivar_begin() const
ObjCInterfaceDecl * getSuperClass() const
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getLocation() const
SourceLocation getOpLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
const Expr * getBase() const
An expression that sends a message to the given Objective-C object or class.
const ObjCMethodDecl * getMethodDecl() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
bool isClassMethod() const
Represents a pointer to an Objective C object.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Represents one property declaration in an Objective-C interface.
Represents an Objective-C protocol declaration.
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
Helper class for OffsetOfExpr.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *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.
SmallVectorImpl< OverloadCandidate >::iterator iterator
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
ParenExpr - This represents a parenthesized expression, e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getSubExpr() const
bool isProducedByFoldExpansion() const
Expr * getExpr(unsigned Init)
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
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
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, PredefinedIdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
static std::string ComputeName(PredefinedIdentKind IK, const Decl *CurrentDecl, bool ForceElaboratedPrinting=false)
bool isMacroDefined(StringRef Id)
IdentifierTable & getIdentifierTable()
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
bool isAddressSpaceOverlapping(QualType T, const ASTContext &Ctx) const
Returns true if address space qualifiers overlap with T address space qualifiers.
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.
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
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.
QualType withCVRQualifiers(unsigned CVR) const
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C.
bool isConstQualified() const
Determine whether this type is const-qualified.
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
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...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeCVRQualifiers(unsigned mask)
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
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 removeAddressSpace()
void setAddressSpace(LangAS space)
PointerAuthQualifier getPointerAuth() const
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
Qualifiers withoutObjCGCAttr() const
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
field_iterator field_end() const
field_range fields() const
static RecoveryExpr * Create(ASTContext &Ctx, QualType T, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool Contains(const Scope &rhs) const
Returns if rhs has a higher scope depth than this.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isInCFunctionScope() const
isInObjcMethodScope - Return true if this scope is, or is contained, in an C function body.
bool isFunctionPrototypeScope() const
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ DeclScope
This is a scope that can contain a declaration.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isUnarySelector() const
bool checkSVETypeSupport(QualType Ty, SourceLocation Loc, const FunctionDecl *FD, const llvm::StringMap< bool > &FeatureMap)
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.
void RecordImplicitHostDeviceFuncUsedByDevice(const FunctionDecl *FD)
Record FD if it is a CUDA/HIP implicit host device function used on device side in device compilation...
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool CheckCall(SourceLocation Loc, FunctionDecl *Callee)
Check whether we're allowed to call Callee from the current context.
@ CVT_Host
Emitted on device side with a shadow variable on host side.
@ CVT_Both
Emitted on host side only.
ExprResult ActOnOutParamExpr(ParmVarDecl *Param, Expr *Arg)
void emitLogicalOperatorFixIt(Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
QualType handleVectorBinOpConversion(ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
const DeclContext * getCurObjCLexicalContext() const
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
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 ...
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void CheckDeclReference(SourceLocation Loc, Expr *E, Decl *D)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
ExprResult ActOnOpenMPCall(ExprResult Call, Scope *Scope, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig)
Given the potential call expression Call, determine if there is a specialization via the OpenMP decla...
void tryCaptureOpenMPLambdas(ValueDecl *V)
Function tries to capture lambda's captured variables in the OpenMP region before the original lambda...
OpenMPClauseKind isOpenMPPrivateDecl(ValueDecl *D, unsigned Level, unsigned CapLevel) const
Check if the specified variable is used in 'private' clause.
VarDecl * isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo=false, unsigned StopAt=0)
Check if the specified variable is used in one of the private clauses (private, firstprivate,...
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, unsigned OpenMPCaptureLevel) const
Return true if the provided declaration VD should be captured by reference.
bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level, unsigned CaptureLevel) const
Check if the specified variable is captured by 'target' directive.
bool isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level, unsigned CaptureLevel) const
Check if the specified global variable must be captured by outer capture regions.
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
const ValueDecl * getOpenMPDeclareMapperVarName() const
ExprResult checkAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
ExprResult checkIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
ExprResult checkRValue(Expr *E)
void CheckDeviceUseOfDecl(NamedDecl *ND, SourceLocation Loc)
Issues a deferred diagnostic if use of the declaration designated by 'ND' is invalid in a device cont...
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Abstract base class used for diagnosing integer constant expression violations.
virtual SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc)=0
virtual SemaDiagnosticBuilder diagnoseNotICEType(Sema &S, SourceLocation Loc, QualType T)
virtual SemaDiagnosticBuilder diagnoseFold(Sema &S, SourceLocation Loc)
Sema - This implements semantic analysis and AST building for C.
const FieldDecl * getSelfAssignmentClassMemberCandidate(const ValueDecl *SelfAssigned)
Returns a field in a CXXRecordDecl that has the same name as the decl SelfAssigned when inside a CXXM...
bool TryFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy) const
Same as IsFunctionConversion, but if this would return true, it sets ResultTy to ToType.
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
ExprResult ActOnCXXParenListInitExpr(ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
std::optional< ExpressionEvaluationContextRecord::InitializationContext > InnermostDeclarationWithDelayedImmediateInvocations() const
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Scope * getCurScope() const
Retrieve the parser's current scope.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
bool RequireCompleteSizedExprType(Expr *E, unsigned DiagID, const Ts &...Args)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
bool isAlwaysConstantEvaluatedContext() const
bool isExternalWithNoLinkageType(const ValueDecl *VD) const
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
bool isAttrContext() const
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
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....
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
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 CreateBuiltinMatrixSingleSubscriptExpr(Expr *Base, Expr *RowIdx, SourceLocation RBLoc)
ExprResult ActOnConstantExpression(ExprResult Res)
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool areVectorTypesSameSize(QualType srcType, QualType destType)
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
void ActOnStartStmtExpr()
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
void ActOnStmtExprError()
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
bool BoundsSafetyCheckAssignmentToCountAttrPtr(QualType LHSTy, Expr *RHSExpr, AssignmentAction Action, SourceLocation Loc, const ValueDecl *Assignee, bool ShowFullyQualifiedAssigneeName)
Perform Bounds Safety Semantic checks for assigning to a __counted_by or __counted_by_or_null pointer...
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
void CheckFloatComparison(SourceLocation Loc, const Expr *LHS, const Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
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'.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
bool needsRebuildOfDefaultArgOrInit() const
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.
SourceLocation LocationOfExcessPrecisionNotSatisfied
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
Preprocessor & getPreprocessor() const
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
QualType GetSignedSizelessVectorType(QualType V)
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...
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
DefaultedComparisonKind getDefaultedComparisonKind(const FunctionDecl *FD)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
llvm::SmallSetVector< Expr *, 4 > MaybeODRUseExprSet
Store a set of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) t...
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
FPOptionsOverride CurFPFeatureOverrides()
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types?
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
ExpressionEvaluationContextRecord & parentEvaluationContext()
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.
bool CheckConceptUseInDefinition(NamedDecl *Concept, SourceLocation Loc)
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
ExprResult CheckUnevaluatedOperand(Expr *E)
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
bool DiagIfReachable(SourceLocation Loc, ArrayRef< const Stmt * > Stmts, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the statements's reachability analysis.
bool BoundsSafetyCheckUseOfCountAttrPtr(const Expr *E)
Perform Bounds Safety semantic checks for uses of invalid uses counted_by or counted_by_or_null point...
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.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
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...
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool CheckCaseExpression(Expr *E)
QualType CheckMatrixElementwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Type checking for matrix binary operators.
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
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.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
void checkSpecializationReachability(SourceLocation Loc, NamedDecl *Spec)
void CleanupVarDeclMarking()
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
bool isImmediateFunctionContext() const
ASTContext & getASTContext() const
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
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.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, UnresolvedSetImpl &Functions)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
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 DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
bool CheckArgsForPlaceholders(MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
@ None
This is not a defaultable comparison operator.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
SourceRange getExprRange(Expr *E) const
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...
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
std::optional< ExpressionEvaluationContextRecord::InitializationContext > OutermostDeclarationWithDelayedImmediateInvocations() const
void DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused,...
FPOptions & getCurFPFeatures()
RecordDecl * StdSourceLocationImplDecl
The C++ "std::source_location::__impl" struct, defined in <source_location>.
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_Block
Block expression.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
void DiagnoseInvalidJumps(Stmt *Body)
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID)
Attempt to fold a variable-sized type to a constant-sized type, returning true if we were successful.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
void MarkExpressionAsImmediateEscalating(Expr *E)
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
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...
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
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)
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
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
void PushExpressionEvaluationContextForFunction(ExpressionEvaluationContext NewContext, FunctionDecl *FD)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
ExprResult ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ConvertVectorExpr - Handle __builtin_convertvector.
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
void maybeAddDeclWithEffects(FuncOrBlockDecl *D)
Inline checks from the start of maybeAddDeclWithEffects, to minimize performance impact on code not u...
ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr)
Prepare SplattedExpr for a matrix splat operation, adding implicit casts if necessary.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
ExprResult BuildCXXReflectExpr(SourceLocation OperatorLoc, TypeSourceInfo *TSI)
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
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.
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Diagnose cases where a scalar was implicitly converted to a vector and diagnose the underlying types.
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
SmallVector< std::deque< PendingImplicitInstantiation >, 8 > SavedPendingInstantiations
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
void DiagnoseMisalignedMembers()
Diagnoses the current set of gathered accesses.
sema::FunctionScopeInfo * getCurFunction() const
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData, StringRef FileName)
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
ControllingExprOrType is either an opaque pointer coming out of a ParsedType or an Expr *.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
bool IsAssignConvertCompatible(AssignConvertType ConvTy)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
SuppressedDiagnosticsMap SuppressedDiagnostics
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, SourceLocation Loc={}, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
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...
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
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.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
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.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr, bool ForTypeDeduction=false)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
bool CheckVecStepExpr(Expr *E)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType, BinaryOperatorKind Opc)
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks, ObjCInterfaceDecl *ClassReceiver)
CallExpr::ADLCallKind ADLCallKind
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
std::vector< std::pair< QualType, unsigned > > ExcessPrecisionNotSatisfied
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
bool anyAltivecTypes(QualType srcType, QualType destType)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?
ExprResult BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl=DeclAccessPair::make(nullptr, AS_none), Expr *baseObjectExpr=nullptr, SourceLocation opLoc=SourceLocation())
MaybeODRUseExprSet MaybeODRUseExprs
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
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
CheckParmsForFunctionDef - Check that the parameters of the given function are appropriate for the de...
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over....
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....
ExprResult ActOnCXXReflectExpr(SourceLocation OpLoc, TypeSourceInfo *TSI)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Binary Operators. 'Tok' is the token for the operator.
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, Scope *Scope, bool ForNestedNameSpecifier)
void setFunctionHasBranchProtectedScope()
bool isConstantEvaluatedContext() const
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
void FinalizeVarWithDestructor(VarDecl *VD, CXXRecordDecl *DeclInit)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
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 ...
bool CheckForConstantInitializer(Expr *Init, unsigned DiagID=diag::err_init_element_not_constant)
type checking declaration initializers (C99 6.7.8)
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
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.
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
QualType GetSignedVectorType(QualType V)
Return a signed ext_vector_type that is of identical size and number of elements.
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ DiscardedStatement
The current expression occurs within a discarded statement.
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
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.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
QualType getCapturedDeclRefType(ValueDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
void DiscardCleanupsInEvaluationContext()
bool NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
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 CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
QualType getCompletedType(Expr *E)
Get the type of expression E, triggering instantiation to complete the type if necessary – that is,...
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AvailabilityMergeKind::Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
SourceManager & SourceMgr
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
ExprResult UsualUnaryFPConversions(Expr *E)
UsualUnaryFPConversions - Promotes floating-point types according to the current language semantics.
bool isUnavailableAlignedAllocationFunction(const FunctionDecl &FD) const
Determine whether FD is an aligned allocation or deallocation function that is unavailable.
bool DiagnoseDependentMemberLookup(const LookupResult &R)
Diagnose a lookup that found results in an enclosing class during error recovery.
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types?
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
friend class InitializationSequence
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition,...
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter,...
QualType CheckSizelessVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult ConvertMemberDefaultInitExpression(FieldDecl *FD, Expr *InitExpr, SourceLocation InitLoc)
bool IsInvalidSMECallConversion(QualType FromType, QualType ToType)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
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,...
ExprResult ActOnStmtExprResult(ExprResult E)
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
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.
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
QualType CheckMatrixLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
bool IsFunctionConversion(QualType FromType, QualType ToType) const
Determine whether the conversion from FromType to ToType is a valid conversion of ExtInfo/ExtProtoInf...
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
QualType PreferredConditionType(ConditionKind K) const
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
@ LOLR_Error
The lookup resulted in an error.
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void checkEnumArithmeticConversions(Expr *LHS, Expr *RHS, SourceLocation Loc, ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
static ConditionResult ConditionError()
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
SemaPseudoObject & PseudoObject()
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
bool isCheckingDefaultArgumentOrInitializer() const
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
SmallVector< std::pair< Scope *, SourceLocation >, 2 > CurrentDefer
Stack of '_Defer' statements that are currently being parsed, as well as the locations of their '_Def...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
SourceLocation getBeginLoc() const
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getEndLoc() const
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
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....
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
void setToType(unsigned Idx, QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() 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
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
uint32_t getCodeUnit(size_t i) const
StringRef getString() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void setElaboratedKeywordLoc(SourceLocation Loc)
Exposes information about the current target.
virtual bool hasLongDoubleType() const
Determine whether the long double type is supported on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
virtual bool useFP16ConversionIntrinsics() const
Check whether conversions to and from __fp16 should go through an integer bitcast with i16.
bool shouldUseMicrosoftCCforMangling() const
Should the Microsoft mangling scheme be used for C Calling Convention.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
A template parameter object.
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
void startToken()
Reset all flags to cleared.
Represents a declaration of a type.
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
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.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isFixedPointOrIntegerType() const
Return true if this is a fixed point or integer type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool isMFloat8Type() const
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
bool isIncompleteArrayType() 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 isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
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 canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
bool isVoidPointerType() const
const ComplexType * getAsComplexIntegerType() const
bool isFunctionPointerType() const
bool isArithmeticType() const
bool isConstantMatrixType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isEnumeralType() const
bool isScalarType() const
bool isVariableArrayType() const
bool isSizelessBuiltinType() 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.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isExtVectorType() const
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
QualType getSveEltType(const ASTContext &Ctx) const
Returns the representative type for the element of an SVE builtin type.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isBitIntType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAnyComplexType() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
const BuiltinType * getAsPlaceholderType() const
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool isMemberPointerType() const
bool isAtomicType() const
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isObjCIdType() const
bool isMatrixType() const
bool isOverflowBehaviorType() const
EnumDecl * castAsEnumDecl() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isComplexIntegerType() const
bool isUnscopedEnumerationType() const
bool isObjCObjectType() const
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isHLSLResourceRecord() const
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isDoubleType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169.
bool isVectorType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
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 isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
const T * castAsCanonical() const
Return this type's canonical type cast to the specified type.
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool isSubscriptableVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
bool isHLSLResourceRecordArray() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
bool isUnicodeCharacterType() const
bool hasBooleanRepresentation() const
Determine whether this type has a boolean representation – i.e., it is a boolean type,...
Wrapper for source info for typedefs.
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
std::string getAsString(const LangOptions &LO) const
SourceRange getCorrectionRange() const
void WillReplaceSpecifier(bool ForceReplacement)
DeclClass * getCorrectionDeclAs() const
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool isOverloaded() const
NestedNameSpecifier getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expr * getSubExpr() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static bool isIncrementDecrementOp(Opcode Op)
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Represents a C++ unqualified-id that has been parsed.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
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 ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
A set of unresolved declarations.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Represents a call to the builtin function __builtin_va_arg.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
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.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
bool isInline() const
Whether this variable is (C++1z) inline.
const Expr * getInit() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
@ TLS_None
Not a TLS variable.
@ DeclarationOnly
This declaration is only a declaration.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Represents a GCC generic vector type.
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
Retains information about a block that is currently being parsed.
Scope * TheScope
TheScope - This is the scope for the block itself, which contains arguments etc.
QualType FunctionType
BlockType - The function type of the block, if one was given.
ValueDecl * getVariable() const
bool isBlockCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
void markUsed(bool IsODRUse)
bool isThisCapture() const
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
bool isCopyCapture() const
Retains information about a captured region.
unsigned short OpenMPLevel
unsigned short CapRegionKind
The kind of captured region.
unsigned short OpenMPCaptureLevel
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured.
bool HasImplicitReturnType
Capture & getCXXThisCapture()
Retrieve the capture of C++ 'this', if it has been captured.
llvm::DenseMap< ValueDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Capture & getCapture(ValueDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
Retains information about a function, method, or block that is currently being parsed.
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
Record that a weak object was accessed.
void markSafeWeakUse(const Expr *E)
Record that a given expression is a "safe" access of a weak object (e.g.
void addBlock(const BlockDecl *BD)
void setHasBranchProtectedScope()
llvm::SmallVector< AddrLabelExpr *, 4 > AddrLabels
The set of GNU address of label extension "&&label".
bool HasOMPDeclareReductionCombiner
True if current scope is for OpenMP declare reduction combiner.
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
bool lambdaCaptureShouldBeConst() const
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas.
void addPotentialThisCapture(SourceLocation Loc)
llvm::SmallPtrSet< VarDecl *, 4 > CUDAPotentialODRUsedVars
Variables that are potentially ODR-used in CUDA/HIP.
CXXRecordDecl * Lambda
The class that describes the lambda.
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().
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the ent...
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ OR_Success
Overload resolution succeeded.
bool isTargetAddressSpace(LangAS AS)
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
@ BitwiseOp
A bitwise operation.
@ Arithmetic
An arithmetic operation.
@ Conditional
A conditional (?:) operator.
@ CompAssign
A compound assignment expression.
@ Comparison
A comparison.
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
@ OK_VectorComponent
A vector component is an element or range of elements of a vector.
@ 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.
@ OK_MatrixComponent
A matrix component is a single element or range of elements of a matrix.
std::string FormatUTFCodeUnitAsCodepoint(unsigned Value, QualType T)
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
unsigned toTargetAddressSpace(LangAS AS)
MutableArrayRef< Expr * > MultiExprArg
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
@ CompatibleOBTDiscards
CompatibleOBTDiscards - Assignment discards overflow behavior.
@ IncompatibleOBTKinds
IncompatibleOBTKinds - Assigning between incompatible OverflowBehaviorType kinds, e....
@ CompatibleVoidPtrToNonVoidPtr
CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because a void * can implicitly convert...
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
@ IncompatiblePointerDiscardsOverflowBehavior
IncompatiblePointerDiscardsOverflowBehavior - The assignment discards overflow behavior annotations b...
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
@ IncompatibleFunctionPointer
IncompatibleFunctionPointer - The assignment is between two function pointers types that are not comp...
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
bool isFunctionLocalStringLiteralMacro(tok::TokenKind K, const LangOptions &LO)
Return true if the token corresponds to a function local predefined macro, which expands to a string ...
@ Type
The name was classified as a type.
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
bool isLambdaConversionOperator(CXXConversionDecl *C)
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
@ TNK_Var_template
The name refers to a variable template whose specialization produces a variable.
@ TNK_Concept_template
The name refers to a concept.
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_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ AltiVecBool
is AltiVec 'vector bool ...'
@ SveFixedLengthData
is AArch64 SVE fixed-length data vector
@ AltiVecVector
is AltiVec vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ Generic
not a target-specific vector type
@ RVVFixedLengthData
is RISC-V RVV fixed-length data vector
@ RVVFixedLengthMask
is RISC-V RVV fixed-length mask vector
@ SveFixedLengthPredicate
is AArch64 SVE fixed-length predicate vector
U cast(CodeGen::Address addr)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ None
No keyword precedes the qualified type name.
bool isLambdaMethod(const DeclContext *DC)
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
ActionResult< Expr * > ExprResult
@ Other
Other implicit parameter.
@ Implicit
An implicit conversion.
ActionResult< Stmt * > StmtResult
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
@ NOUR_Discarded
This name appears as a potential result of a discarded value expression.
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
@ NOUR_None
This is an odr-use.
@ NOUR_Constant
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
Represents an element in a path from a derived class to a base class.
The class facilities generation and storage of conversion FixIts.
OverloadFixItKind Kind
The type of fix applied.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
Stores data related to a single embed directive.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasUndefinedBehavior
Whether the evaluation hit undefined behavior.
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
FunctionType::ExtInfo ExtInfo
bool IsAddressOfOperandWithParen
bool HasFormOfMemberPointer
OverloadExpr * Expression
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
Data structure used to record current or nested expression evaluation contexts.
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
Decl * ManglingContextDecl
The declaration that provides context for lambda expressions and block literals if the normal declara...
bool InDiscardedStatement
bool InImmediateFunctionContext
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
bool isUnevaluated() const
llvm::SmallPtrSet< DeclRefExpr *, 4 > ReferenceToConsteval
Set of DeclRefExprs referencing a consteval function when used in a context not already known to be i...
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
Set of candidates for starting an immediate invocation.
bool isImmediateFunctionContext() const
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
P2718R0 - Lifetime extension in range-based for loops.
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
MaybeODRUseExprSet SavedMaybeODRUseExprs
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
bool isConstantEvaluated() const
bool isDiscardedStatementContext() const
ExpressionEvaluationContext Context
The expression evaluation context.
bool InImmediateEscalatingFunctionContext
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
Abstract class used to diagnose incomplete types.
Location information for a TemplateArgument.
TemplateNameKind Kind
The kind of template that Template refers to.
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.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Describes an entity that is being assigned.