66#include "llvm/ADT/STLExtras.h"
67#include "llvm/ADT/StringExtras.h"
68#include "llvm/IR/DerivedTypes.h"
69#include "llvm/Support/ConvertUTF.h"
70#include "llvm/Support/SaveAndRestore.h"
71#include "llvm/Support/TimeProfiler.h"
72#include "llvm/Support/TypeSize.h"
97 if (TreatUnavailableAsInvalid &&
115 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
118 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
119 A->getSemanticSpelling() != UnusedAttr::C23_maybe_unused) {
121 if (DC && !DC->
hasAttr<UnusedAttr>())
122 S.
Diag(Loc, diag::warn_used_but_marked_unused) << D;
130 if (
Decl->isDefaulted()) {
141 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
142 if (Ctor && Ctor->isInheritingConstructor())
153 if (I->getStorageClass() !=
SC_None)
204 DiagID = diag::warn_c2y_compat_internal_in_extern_inline;
205 else if ((UsedFn && (UsedFn->
isInlined() || UsedFn->
hasAttr<ConstAttr>())) ||
207 DiagID = diag::ext_internal_in_extern_inline_quiet;
209 DiagID = diag::ext_internal_in_extern_inline;
211 S.
Diag(Loc, DiagID) << !UsedFn << D;
223 Diag(DeclBegin, diag::note_convert_inline_to_static)
230 bool ObjCPropertyAccess,
231 bool AvoidPartialAvailabilityChecks,
233 bool SkipTrailingRequiresClause) {
240 for (
const auto &[DiagLoc, PD] : Pos->second) {
254 Diag(Loc, diag::ext_main_used);
262 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
265 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
274 if (FD->isDeleted()) {
275 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
276 if (Ctor && Ctor->isInheritingConstructor())
277 Diag(Loc, diag::err_deleted_inherited_ctor_use)
279 << Ctor->getInheritedConstructor().getConstructor()->getParent();
282 Diag(Loc, diag::err_deleted_function_use)
283 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
297 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
306 diag::err_reference_to_function_with_unsatisfied_constraints)
324 if (
auto *
Concept = dyn_cast<ConceptDecl>(D);
328 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
330 if (MD->getParent()->isLambda() &&
333 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
334 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
339 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
341 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
342 return MD->findPropertyDecl();
356 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(
CurContext);
359 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
372 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
378 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(D)) {
379 Diag(Loc, diag::err_use_of_empty_using_if_exists);
380 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
385 AvoidPartialAvailabilityChecks, ClassReceiver);
391 if (D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
394 PP.getLastFPEvalPragmaLocation().isValid() &&
395 PP.getCurrentFPEvalMethod() !=
getLangOpts().getFPEvalMethod())
397 diag::err_type_available_only_in_default_eval_method)
401 if (
auto *VD = dyn_cast<ValueDecl>(D))
406 if (!
Context.getTargetInfo().isTLSSupported())
407 if (
const auto *VD = dyn_cast<VarDecl>(D))
409 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
420 const SentinelAttr *
Attr = D->
getAttr<SentinelAttr>();
425 unsigned NumFormalParams;
429 enum { CK_Function, CK_Method, CK_Block } CalleeKind;
431 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
432 NumFormalParams = MD->param_size();
433 CalleeKind = CK_Method;
434 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
435 NumFormalParams = FD->param_size();
436 CalleeKind = CK_Function;
437 if (FD->hasCXXExplicitFunctionObjectParameter())
439 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
446 CalleeKind = CK_Function;
449 CalleeKind = CK_Block;
454 if (
const auto *proto = dyn_cast<FunctionProtoType>(Fn))
455 NumFormalParams = proto->getNumParams();
466 unsigned NullPos =
Attr->getNullPos();
467 assert((NullPos == 0 || NullPos == 1) &&
"invalid null position on sentinel");
468 NumFormalParams = (NullPos > NumFormalParams ? 0 : NumFormalParams - NullPos);
471 unsigned NumArgsAfterSentinel =
Attr->getSentinel();
475 if (Args.size() < NumFormalParams + NumArgsAfterSentinel + 1) {
482 const Expr *SentinelExpr = Args[Args.size() - NumArgsAfterSentinel - 1];
487 if (
Context.isSentinelNullExpr(SentinelExpr))
495 std::string NullValue;
496 if (CalleeKind == CK_Method &&
PP.isMacroDefined(
"nil"))
499 NullValue =
"nullptr";
500 else if (
PP.isMacroDefined(
"NULL"))
503 NullValue =
"(void*) 0";
506 Diag(Loc, diag::warn_missing_sentinel) <<
int(CalleeKind);
508 Diag(MissingNilLoc, diag::warn_missing_sentinel)
533 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
537 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
542 CK_FunctionToPointerDecay).
get();
557 CK_ArrayToPointerDecay);
573 if (UO && UO->getOpcode() == UO_Deref &&
574 UO->getSubExpr()->getType()->isPointerType()) {
576 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
579 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
581 !UO->getType().isVolatileQualified()) {
583 S.
PDiag(diag::warn_indirection_through_null)
584 << UO->getSubExpr()->getSourceRange());
586 S.
PDiag(diag::note_indirection_through_null));
606 BaseType = BaseType->getPointeeType();
618 if (ObjectSetClass) {
662 assert(!
T.isNull() &&
"r-value conversion on typeless expression?");
666 if (
T->canDecayToPointerType())
674 (
T->isDependentType() && !
T->isAnyPointerType() &&
675 !
T->isMemberPointerType()))
699 &
Context.Idents.get(
"object_getClass"),
705 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
722 if (
T.hasQualifiers())
723 T =
T.getUnqualifiedType();
730 if (
T->isMemberPointerType() &&
731 Context.getTargetInfo().getCXXABI().isMicrosoft())
742 Cleanup.setExprNeedsCleanups(
true);
745 Cleanup.setExprNeedsCleanups(
true);
752 CastKind CK =
T->isNullPtrType() ? CK_NullToPointer : CK_LValueToRValue;
760 T =
Atomic->getValueType().getUnqualifiedType();
785 CK_FunctionToPointerDecay);
799 assert(!Ty.
isNull() &&
"UsualUnaryFPConversions - missing type");
805 PP.getLastFPEvalPragmaLocation().isValid())) {
806 switch (EvalMethod) {
808 llvm_unreachable(
"Unrecognized float evaluation method");
811 llvm_unreachable(
"Float evaluation method should be set by now");
819 CK_FloatingComplexCast)
828 CK_FloatingComplexCast)
860 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
884 if (
Context.isPromotableIntegerType(Ty)) {
899 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
911 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
912 BTy->
getKind() == BuiltinType::Float)) {
915 if (BTy->
getKind() == BuiltinType::Half) {
926 Context.getTypeSizeInChars(BTy) <
932 assert(8 ==
Context.getTypeSizeInChars(
Context.LongLongTy).getQuantity() &&
933 "Unexpected typesize for LongLongTy");
987 if (
Context.getTargetInfo().getTriple().isWasm() &&
1002 if (!
Record->hasNonTrivialCopyConstructor() &&
1003 !
Record->hasNonTrivialMoveConstructor() &&
1004 !
Record->hasNonTrivialDestructor())
1037 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
1044 PDiag(diag::warn_pass_class_arg_to_vararg)
1052 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1059 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1063 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1076 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1078 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1117 if (
Call.isInvalid())
1122 if (Comma.isInvalid())
1129 diag::err_call_incomplete_argument))
1147 if (SkipCast)
return false;
1154 CK_IntegralComplexToFloatingComplex);
1172 bool PromotePrecision) {
1177 if (PromotePrecision) {
1182 if (LongerIsComplex)
1194 QualType RHSType,
bool IsCompAssign) {
1219 bool ConvertFloat,
bool ConvertInt) {
1224 CK_IntegralToFloating);
1235 CK_IntegralComplexToFloatingComplex);
1240 CK_FloatingRealToComplex);
1249 QualType RHSType,
bool IsCompAssign) {
1259 else if (!IsCompAssign)
1261 return LHSFloat ? LHSType : RHSType;
1266 if (LHSFloat && RHSFloat) {
1273 assert(order < 0 &&
"illegal float comparison");
1307 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1313 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1314 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1315 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1316 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1333 CK_IntegralComplexCast);
1339template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1342 QualType RHSType,
bool IsCompAssign) {
1347 if (LHSSigned == RHSSigned) {
1350 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1352 }
else if (!IsCompAssign)
1353 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1355 }
else if (order != (LHSSigned ? 1 : -1)) {
1359 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1361 }
else if (!IsCompAssign)
1362 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1369 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1371 }
else if (!IsCompAssign)
1372 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1381 RHS = (*doRHSCast)(S, RHS.
get(), result);
1383 LHS = (*doLHSCast)(S, LHS.
get(), result);
1393 bool IsCompAssign) {
1397 if (LHSComplexInt && RHSComplexInt) {
1402 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1407 if (LHSComplexInt) {
1411 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1414 CK_IntegralRealToComplex);
1419 assert(RHSComplexInt);
1424 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1429 CK_IntegralRealToComplex);
1437 bool IsCompAssign) {
1439 const auto *LhsOBT = LHSType->
getAs<OverflowBehaviorType>();
1440 const auto *RhsOBT = RHSType->
getAs<OverflowBehaviorType>();
1443 "Non-integer type conversion not supported for OverflowBehaviorTypes");
1446 LhsOBT && LhsOBT->getBehaviorKind() ==
1447 OverflowBehaviorType::OverflowBehaviorKind::Trap;
1449 RhsOBT && RhsOBT->getBehaviorKind() ==
1450 OverflowBehaviorType::OverflowBehaviorKind::Trap;
1452 LhsOBT && LhsOBT->getBehaviorKind() ==
1453 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1455 RhsOBT && RhsOBT->getBehaviorKind() ==
1456 OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1458 QualType LHSUnderlyingType = LhsOBT ? LhsOBT->getUnderlyingType() : LHSType;
1459 QualType RHSUnderlyingType = RhsOBT ? RhsOBT->getUnderlyingType() : RHSType;
1461 std::optional<OverflowBehaviorType::OverflowBehaviorKind> DominantBehavior;
1462 if (LHSHasTrap || RHSHasTrap)
1463 DominantBehavior = OverflowBehaviorType::OverflowBehaviorKind::Trap;
1464 else if (LHSHasWrap || RHSHasWrap)
1465 DominantBehavior = OverflowBehaviorType::OverflowBehaviorKind::Wrap;
1467 QualType LHSConvType = LHSUnderlyingType;
1468 QualType RHSConvType = RHSUnderlyingType;
1469 if (DominantBehavior) {
1470 if (!LhsOBT || LhsOBT->getBehaviorKind() != *DominantBehavior)
1474 LHSConvType = LHSType;
1476 if (!RhsOBT || RhsOBT->getBehaviorKind() != *DominantBehavior)
1480 RHSConvType = RHSType;
1484 S, LHS, RHS, LHSConvType, RHSConvType, IsCompAssign);
1492 assert(BTy &&
"Expected a builtin type.");
1494 switch (BTy->getKind()) {
1495 case BuiltinType::ShortFract:
1496 case BuiltinType::UShortFract:
1497 case BuiltinType::SatShortFract:
1498 case BuiltinType::SatUShortFract:
1500 case BuiltinType::Fract:
1501 case BuiltinType::UFract:
1502 case BuiltinType::SatFract:
1503 case BuiltinType::SatUFract:
1505 case BuiltinType::LongFract:
1506 case BuiltinType::ULongFract:
1507 case BuiltinType::SatLongFract:
1508 case BuiltinType::SatULongFract:
1510 case BuiltinType::ShortAccum:
1511 case BuiltinType::UShortAccum:
1512 case BuiltinType::SatShortAccum:
1513 case BuiltinType::SatUShortAccum:
1515 case BuiltinType::Accum:
1516 case BuiltinType::UAccum:
1517 case BuiltinType::SatAccum:
1518 case BuiltinType::SatUAccum:
1520 case BuiltinType::LongAccum:
1521 case BuiltinType::ULongAccum:
1522 case BuiltinType::SatLongAccum:
1523 case BuiltinType::SatULongAccum:
1526 if (BTy->isInteger())
1528 llvm_unreachable(
"Unexpected fixed point or integer type");
1540 "Expected at least one of the operands to be a fixed point type");
1543 "Special fixed point arithmetic operation conversions are only "
1544 "applied to ints or other fixed point types");
1566 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1589 REnum = R->isUnscopedEnumerationType();
1591 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1595 ? diag::warn_arith_conv_enum_float_cxx20
1596 : diag::warn_arith_conv_enum_float)
1599 }
else if (!IsCompAssign && LEnum && REnum &&
1600 !
Context.hasSameUnqualifiedType(L, R)) {
1605 DiagID = diag::warn_conv_mixed_enum_types_cxx26;
1606 else if (!L->
castAsCanonical<EnumType>()->getDecl()->hasNameForLinkage() ||
1607 !R->castAsCanonical<EnumType>()->getDecl()->hasNameForLinkage()) {
1612 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1613 : diag::warn_arith_conv_mixed_anon_enum_types;
1618 ? diag::warn_conditional_mixed_enum_types_cxx20
1619 : diag::warn_conditional_mixed_enum_types;
1624 ? diag::warn_comparison_mixed_enum_types_cxx20
1625 : diag::warn_comparison_mixed_enum_types;
1628 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1629 : diag::warn_arith_conv_mixed_enum_types;
1632 << (int)ACK << L << R;
1650 auto IsSingleCodeUnitCP = [](
const QualType &
T,
const llvm::APSInt &
Value) {
1651 if (
T->isChar8Type())
1652 return llvm::IsSingleCodeUnitUTF8Codepoint(
Value.getExtValue());
1653 if (
T->isChar16Type())
1654 return llvm::IsSingleCodeUnitUTF16Codepoint(
Value.getExtValue());
1655 assert(
T->isChar32Type());
1656 return llvm::IsSingleCodeUnitUTF32Codepoint(
Value.getExtValue());
1669 if (LHSSuccess != RHSuccess) {
1671 if (IsSingleCodeUnitCP(LHSType, Res.
Val.
getInt()) &&
1672 IsSingleCodeUnitCP(RHSType, Res.
Val.
getInt()))
1676 if (!LHSSuccess || !RHSuccess) {
1677 SemaRef.
Diag(Loc, diag::warn_comparison_unicode_mixed_types)
1683 llvm::APSInt LHSValue(32);
1685 llvm::APSInt RHSValue(32);
1688 bool LHSSafe = IsSingleCodeUnitCP(LHSType, LHSValue);
1689 bool RHSSafe = IsSingleCodeUnitCP(RHSType, RHSValue);
1690 if (LHSSafe && RHSSafe)
1693 SemaRef.
Diag(Loc, diag::warn_comparison_unicode_mixed_types_constant)
1703 SemaRef.
Diag(Loc, diag::warn_arith_conv_mixed_unicode_types)
1737 LHSType = AtomicLHS->getValueType();
1740 if (
Context.hasSameType(LHSType, RHSType))
1741 return Context.getCommonSugaredType(LHSType, RHSType);
1749 QualType LHSUnpromotedType = LHSType;
1750 if (
Context.isPromotableIntegerType(LHSType))
1751 LHSType =
Context.getPromotedIntegerType(LHSType);
1753 if (!LHSBitfieldPromoteTy.
isNull())
1754 LHSType = LHSBitfieldPromoteTy;
1759 if (
Context.hasSameType(LHSType, RHSType))
1760 return Context.getCommonSugaredType(LHSType, RHSType);
1807 bool PredicateIsExpr,
void *ControllingExprOrType,
1809 unsigned NumAssocs = ArgTypes.size();
1810 assert(NumAssocs == ArgExprs.size());
1813 for (
unsigned i = 0; i < NumAssocs; ++i) {
1822 if (!PredicateIsExpr) {
1826 assert(ControllingType &&
"couldn't get the type out of the parser");
1827 ControllingExprOrType = ControllingType;
1831 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1843 const auto *TOBT =
T->getAs<OverflowBehaviorType>();
1844 const auto *UOBT =
U.getCanonicalType()->getAs<OverflowBehaviorType>();
1848 if (TOBT->getBehaviorKind() == UOBT->getBehaviorKind())
1850 UOBT->getUnderlyingType());
1862 bool PredicateIsExpr,
void *ControllingExprOrType,
1864 unsigned NumAssocs = Types.size();
1865 assert(NumAssocs == Exprs.size());
1866 assert(ControllingExprOrType &&
1867 "Must have either a controlling expression or a controlling type");
1869 Expr *ControllingExpr =
nullptr;
1871 if (PredicateIsExpr) {
1878 reinterpret_cast<Expr *
>(ControllingExprOrType));
1881 ControllingExpr = R.get();
1884 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1885 if (!ControllingType)
1889 bool TypeErrorFound =
false,
1890 IsResultDependent = ControllingExpr
1893 ContainsUnexpandedParameterPack =
1903 diag::warn_side_effects_unevaluated_context);
1905 for (
unsigned i = 0; i < NumAssocs; ++i) {
1906 if (Exprs[i]->containsUnexpandedParameterPack())
1907 ContainsUnexpandedParameterPack =
true;
1910 if (Types[i]->
getType()->containsUnexpandedParameterPack())
1911 ContainsUnexpandedParameterPack =
true;
1913 if (Types[i]->
getType()->isDependentType()) {
1914 IsResultDependent =
true;
1931 if (ControllingExpr && Types[i]->
getType()->isIncompleteType())
1932 D =
LangOpts.C2y ? diag::compat_c2y_assoc_type_incomplete
1933 : diag::compat_pre_c2y_assoc_type_incomplete;
1934 else if (ControllingExpr && !Types[i]->
getType()->isObjectType())
1935 D = diag::err_assoc_type_nonobject;
1936 else if (Types[i]->
getType()->isVariablyModifiedType())
1937 D = diag::err_assoc_type_variably_modified;
1938 else if (ControllingExpr) {
1957 unsigned Reason = 0;
1966 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1967 diag::warn_unreachable_association)
1968 << QT << (Reason - 1);
1972 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1973 << Types[i]->getTypeLoc().getSourceRange() << Types[i]->getType();
1975 D, Types[i]->getTypeLoc().getBeginLoc()) >=
1977 TypeErrorFound =
true;
1982 for (
unsigned j = i+1; j < NumAssocs; ++j)
1983 if (Types[j] && !Types[j]->
getType()->isDependentType() &&
1986 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1987 diag::err_assoc_compatible_types)
1988 << Types[j]->getTypeLoc().getSourceRange()
1989 << Types[j]->getType()
1990 << Types[i]->getType();
1991 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1992 diag::note_compat_assoc)
1993 << Types[i]->getTypeLoc().getSourceRange()
1994 << Types[i]->getType();
1995 TypeErrorFound =
true;
2005 if (IsResultDependent) {
2006 if (ControllingExpr)
2008 Types, Exprs, DefaultLoc, RParenLoc,
2009 ContainsUnexpandedParameterPack);
2011 Exprs, DefaultLoc, RParenLoc,
2012 ContainsUnexpandedParameterPack);
2016 unsigned DefaultIndex = std::numeric_limits<unsigned>::max();
2020 for (
unsigned i = 0; i < NumAssocs; ++i) {
2028 QualType AssocQT = Types[i]->getType();
2034 CompatIndices.push_back(i);
2038 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
2042 if (ControllingExpr)
2051 return std::make_pair(SR, QT);
2057 if (CompatIndices.size() > 1) {
2058 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
2061 << SR << P.second << (
unsigned)CompatIndices.size();
2062 for (
unsigned I : CompatIndices) {
2063 Diag(Types[I]->getTypeLoc().getBeginLoc(),
2064 diag::note_compat_assoc)
2065 << Types[I]->getTypeLoc().getSourceRange()
2066 << Types[I]->getType();
2074 if (DefaultIndex == std::numeric_limits<unsigned>::max() &&
2075 CompatIndices.size() == 0) {
2076 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
2078 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR << P.second;
2087 unsigned ResultIndex =
2088 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
2090 if (ControllingExpr) {
2092 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
2093 ContainsUnexpandedParameterPack, ResultIndex);
2096 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
2097 ContainsUnexpandedParameterPack, ResultIndex);
2103 llvm_unreachable(
"unexpected TokenKind");
2104 case tok::kw___func__:
2106 case tok::kw___FUNCTION__:
2108 case tok::kw___FUNCDNAME__:
2110 case tok::kw___FUNCSIG__:
2112 case tok::kw_L__FUNCTION__:
2114 case tok::kw_L__FUNCSIG__:
2116 case tok::kw___PRETTY_FUNCTION__:
2127 auto tryAdjustLambdaContext = [&S, &LSI](
DeclContext *&DC) {
2132 assert(LSI != E &&
"Should be in a lambda scope info");
2133 if (dyn_cast<LambdaScopeInfo>(*LSI)->BeforeCompoundStatement)
2139 tryAdjustLambdaContext(DC);
2143 tryAdjustLambdaContext(DC);
2146 return cast_or_null<Decl>(DC);
2164 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
2167 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2168 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
2169 if (ArgTy[ArgIdx]->isArrayType())
2190 std::vector<Token> ExpandedToks;
2196 if (Literal.hadError)
2200 for (
const Token &
Tok : StringToks)
2201 StringTokLocs.push_back(
Tok.getLocation());
2205 false, {}, StringTokLocs);
2207 if (!Literal.getUDSuffix().empty()) {
2210 Literal.getUDSuffixOffset());
2211 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2231 CurrentDecl =
Context.getTranslationUnitDecl();
2233 std::vector<Token> ExpandedToks;
2234 ExpandedToks.reserve(Toks.size());
2238 ExpandedToks.emplace_back(
Tok);
2242 Diag(
Tok.getLocation(), diag::ext_predef_outside_function);
2244 Diag(
Tok.getLocation(), diag::ext_string_literal_from_predefined)
2247 llvm::raw_svector_ostream
OS(Str);
2248 Token &Exp = ExpandedToks.emplace_back();
2250 if (
Tok.getKind() == tok::kw_L__FUNCTION__ ||
2251 Tok.getKind() == tok::kw_L__FUNCSIG__) {
2253 Exp.
setKind(tok::wide_string_literal);
2255 Exp.
setKind(tok::string_literal);
2261 PP.CreateString(
OS.str(), Exp,
Tok.getLocation(),
Tok.getEndLoc());
2263 return ExpandedToks;
2268 assert(!StringToks.empty() &&
"Must have at least one string!");
2271 std::vector<Token> ExpandedToks;
2277 if (Literal.hadError)
2281 for (
const Token &
Tok : StringToks)
2282 StringTokLocs.push_back(
Tok.getLocation());
2286 if (Literal.isWide()) {
2287 CharTy =
Context.getWideCharType();
2289 }
else if (Literal.isUTF8()) {
2293 CharTy =
Context.UnsignedCharTy;
2295 }
else if (Literal.isUTF16()) {
2298 }
else if (Literal.isUTF32()) {
2301 }
else if (Literal.isPascal()) {
2302 CharTy =
Context.UnsignedCharTy;
2314 ? diag::warn_cxx20_compat_utf8_string
2315 : diag::warn_c23_compat_utf8_string);
2321 auto RemovalDiag =
PDiag(diag::note_cxx20_c23_compat_utf8_string_remove_u8);
2323 for (
const Token &
Tok : StringToks) {
2324 if (
Tok.getKind() == tok::utf8_string_literal) {
2326 RemovalDiagLoc =
Tok.getLocation();
2333 Diag(RemovalDiagLoc, RemovalDiag);
2337 Context.getStringLiteralArrayType(CharTy, Literal.GetNumStringChars());
2341 Context, Literal.GetString(), Kind, Literal.Pascal, StrTy, StringTokLocs);
2342 if (Literal.getUDSuffix().empty())
2349 Literal.getUDSuffixOffset());
2353 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2360 Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
2365 Context.getArrayDecayedType(StrTy), SizeType
2375 llvm::APInt Len(
Context.getIntWidth(SizeType), Literal.GetNumStringChars());
2378 Expr *Args[] = { Lit, LenArg };
2395 unsigned CharBits =
Context.getIntWidth(CharTy);
2397 llvm::APSInt
Value(CharBits, CharIsUnsigned);
2404 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
2414 llvm_unreachable(
"unexpected literal operator lookup result");
2418 llvm_unreachable(
"unexpected literal operator lookup result");
2450 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2453 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2454 if (!Referee || !Referee->hasGlobalStorage() ||
2455 Referee->hasAttr<CUDADeviceAttr>())
2461 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2462 if (MD && MD->getParent()->isLambda() &&
2463 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2485 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2486 if (VD->getType()->isReferenceType() &&
2489 VD->isUsableInConstantExpressions(
Context))
2508 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
2536 const auto *FD = dyn_cast<FieldDecl>(D);
2537 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D))
2538 FD = IFD->getAnonField();
2542 if (FD->isBitField())
2548 if (
const auto *BD = dyn_cast<BindingDecl>(D))
2549 if (
const auto *BE = BD->getBinding())
2561 if (II->hasMacroDefinition()) {
2571 std::optional<Token> NextTok =
2573 if (NextTok && NextTok->is(tok::l_paren))
2575 SemaRef.
Diag(TypoLoc,
2576 diag::err_undeclared_var_use_suggest_func_like_macro)
2579 diag::note_function_like_macro_requires_parens)
2603 NameInfo =
Context.getNameForTemplate(TName, TNameLoc);
2604 TemplateArgs = &Buffer;
2607 TemplateArgs =
nullptr;
2615 bool isDefaultArgument =
2619 const auto *CurMethod = dyn_cast<CXXMethodDecl>(
CurContext);
2620 bool isInstance = CurMethod && CurMethod->isInstance() &&
2621 R.getNamingClass() == CurMethod->getParent() &&
2629 unsigned DiagID = diag::err_found_in_dependent_base;
2630 unsigned NoteID = diag::note_member_declared_at;
2631 if (R.getRepresentativeDecl()->getDeclContext()->Equals(R.getNamingClass())) {
2632 DiagID =
getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2633 : diag::err_found_later_in_class;
2635 DiagID = diag::ext_found_in_dependent_base;
2636 NoteID = diag::note_dependent_member_use;
2641 Diag(R.getNameLoc(), DiagID)
2642 << R.getLookupName()
2648 Diag(R.getNameLoc(), DiagID) << R.getLookupName();
2652 Diag(D->getLocation(), NoteID);
2661 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
2662 Diag(R.getNameLoc(), diag::err_member_call_without_object) << 0;
2675 SourceRange NameRange = R.getLookupNameInfo().getSourceRange();
2677 unsigned diagnostic = diag::err_undeclared_var_use;
2678 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2682 diagnostic = diag::err_undeclared_use;
2683 diagnostic_suggest = diag::err_undeclared_use_suggest;
2694 if (ExplicitTemplateArgs) {
2706 R.suppressDiagnostics();
2717 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2732 if (S && (Corrected =
2733 CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS,
2736 bool DroppedSpecifier =
2740 bool AcceptableWithRecovery =
false;
2741 bool AcceptableWithoutRecovery =
false;
2750 dyn_cast<FunctionTemplateDecl>(CD))
2754 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2755 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2761 ND = Best->FoundDecl;
2762 Corrected.setCorrectionDecl(ND);
2766 Corrected.setCorrectionDecl(ND);
2777 R.setNamingClass(
Record);
2794 AcceptableWithoutRecovery =
true;
2797 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2799 ? diag::note_implicit_param_decl
2800 : diag::note_previous_decl;
2803 PDiag(NoteID), AcceptableWithRecovery);
2806 PDiag(diag::err_no_member_suggest)
2808 << DroppedSpecifier << NameRange,
2809 PDiag(NoteID), AcceptableWithRecovery);
2819 return !AcceptableWithRecovery;
2830 Diag(R.getNameLoc(), diag::err_no_member)
2836 Diag(R.getNameLoc(), diagnostic) << Name << NameRange;
2857 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2865 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2866 DB << NameInfo.
getName() << RD;
2868 if (!ThisType.
isNull()) {
2871 Context,
nullptr, ThisType,
true,
2873 nullptr, NameInfo, TemplateArgs);
2889 bool IsAddressOfOperand,
2891 bool IsInlineAsmIdentifier) {
2892 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2893 "cannot be direct & operand and have a trailing lparen");
2928 if (
auto *VD = dyn_cast<ValueDecl>(R.getFoundDecl())) {
2942 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2950 false, TemplateKWLoc,
2954 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
2956 IsAddressOfOperand, TemplateArgs);
2960 !IvarLookupFollowUp);
2964 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
2966 IsAddressOfOperand, TemplateArgs);
2970 if (IvarLookupFollowUp) {
2980 if (R.isAmbiguous())
2985 if (R.empty() && HasTrailingLParen && II &&
2988 if (D) R.addDecl(D);
2995 if (R.empty() && !ADL) {
2998 TemplateKWLoc, TemplateArgs))
3003 if (IsInlineAsmIdentifier)
3011 "Typo correction callback misconfigured");
3025 assert(!R.empty() &&
3026 "DiagnoseEmptyLookup returned false but added no results");
3033 ExprResult E(
ObjC().LookupInObjCMethod(R, S, Ivar->getIdentifier()));
3043 assert(!R.empty() || ADL);
3073 if (TemplateArgs || TemplateKWLoc.
isValid()) {
3082 "There should only be one declaration found.");
3097 if (R.isAmbiguous())
3100 if (R.wasNotFoundInCurrentInstantiation() || SS.
isInvalid())
3110 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
3111 if (CD->isInvalidDecl() || CD->isBeingDefined())
3121 if (
auto *TagD = dyn_cast<TagDecl>(TD)) {
3128 TL.setNameLoc(NameInfo.
getLoc());
3129 }
else if (
auto *TypedefD = dyn_cast<TypedefNameDecl>(TD)) {
3137 ET =
SemaRef.Context.getTypeDeclType(TD);
3145 unsigned DiagID = diag::err_typename_missing;
3147 DiagID = diag::ext_typename_missing;
3149 auto D =
Diag(Loc, DiagID);
3180 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
3188 bool PointerConversions =
false;
3190 DestRecordType =
Context.getCanonicalTagType(RD);
3192 DestRecordType =
Context.getAddrSpaceQualType(
3193 DestRecordType, FromPtrType
3198 DestType =
Context.getPointerType(DestRecordType);
3200 PointerConversions =
true;
3202 DestType = DestRecordType;
3203 FromRecordType = FromType;
3205 }
else if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
Member)) {
3206 if (!
Method->isImplicitObjectMemberFunction())
3209 DestType =
Method->getThisType().getNonReferenceType();
3210 DestRecordType =
Method->getFunctionObjectParameterType();
3214 PointerConversions =
true;
3216 FromRecordType = FromType;
3217 DestType = DestRecordType;
3222 if (FromAS != DestAS) {
3224 Context.removeAddrSpaceQualType(FromRecordType);
3226 Context.getAddrSpaceQualType(FromRecordTypeWithoutAS, DestAS);
3227 if (PointerConversions)
3228 FromTypeWithDestAS =
Context.getPointerType(FromTypeWithDestAS);
3242 if (
Context.hasSameUnqualifiedType(FromRecordType, DestRecordType))
3270 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3280 FromLoc, FromRange, &BasePath))
3283 if (PointerConversions)
3284 QType =
Context.getPointerType(QType);
3286 VK, &BasePath).
get();
3289 FromRecordType = QRecordType;
3293 if (
Context.hasSameUnqualifiedType(FromRecordType, DestRecordType))
3300 FromLoc, FromRange, &BasePath,
3309 DestType =
Context.getQualifiedType(DestType, FromTypeQuals);
3317 bool HasTrailingLParen) {
3319 if (!HasTrailingLParen)
3337 if (D->isCXXClassMember())
3348 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
3355 if (
const auto *FDecl = dyn_cast<FunctionDecl>(D)) {
3357 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3372 bool AcceptInvalid) {
3397 assert(R.isSingleResult() &&
"Expected only a single result");
3398 const auto *FD = dyn_cast<FunctionDecl>(R.getFoundDecl());
3400 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3405 bool AcceptInvalidDecl) {
3408 if (!NeedsADL && R.isSingleResult() &&
3412 R.getRepresentativeDecl(),
nullptr,
3426 R.suppressDiagnostics();
3430 R.getLookupNameInfo(), NeedsADL, R.begin(), R.end(),
3439 bool AcceptInvalidDecl) {
3440 assert(D &&
"Cannot refer to a NULL declaration");
3442 "Cannot refer unambiguously to a function template");
3461 Diag(Loc, diag::err_ref_non_value) << D << SS.
getRange();
3476 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3482 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3483 IndirectField && !IndirectField->isCXXClassMember())
3495 type =
type.getNonPackExpansionType();
3499#define ABSTRACT_DECL(kind)
3500#define VALUE(type, base)
3501#define DECL(type, base) case Decl::type:
3502#include "clang/AST/DeclNodes.inc"
3503 llvm_unreachable(
"invalid value decl kind");
3506 case Decl::ObjCAtDefsField:
3507 llvm_unreachable(
"forming non-member reference to ivar?");
3511 case Decl::EnumConstant:
3512 case Decl::UnresolvedUsingValue:
3513 case Decl::OMPDeclareReduction:
3514 case Decl::OMPDeclareMapper:
3523 case Decl::IndirectField:
3524 case Decl::ObjCIvar:
3526 "building reference to field in C?");
3536 case Decl::NonTypeTemplateParm: {
3538 type = reftype->getPointeeType();
3548 if (
type->isRecordType()) {
3549 type =
type.getUnqualifiedType().withConst();
3562 case Decl::VarTemplateSpecialization:
3563 case Decl::VarTemplatePartialSpecialization:
3564 case Decl::Decomposition:
3566 case Decl::OMPCapturedExpr:
3569 type->isVoidType()) {
3575 case Decl::ImplicitParam:
3576 case Decl::ParmVar: {
3586 if (!CapturedType.
isNull())
3587 type = CapturedType;
3592 case Decl::Function: {
3594 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
3631 case Decl::CXXDeductionGuide:
3632 llvm_unreachable(
"building reference to deduction guide");
3634 case Decl::MSProperty:
3636 case Decl::TemplateParamObject:
3642 case Decl::UnnamedGlobalConstant:
3646 case Decl::CXXMethod:
3651 dyn_cast<FunctionProtoType>(VD->getType()))
3652 if (proto->getReturnType() ==
Context.UnknownAnyTy) {
3665 case Decl::CXXConversion:
3666 case Decl::CXXDestructor:
3667 case Decl::CXXConstructor:
3679 if (VD->isInvalidDecl() && E)
3686 Target.resize(CharByteWidth * (Source.size() + 1));
3687 char *ResultPtr = &
Target[0];
3688 const llvm::UTF8 *ErrorPtr;
3690 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3700 Diag(Loc, diag::ext_predef_outside_function);
3701 currentDecl =
Context.getTranslationUnitDecl();
3711 bool ForceElaboratedPrinting =
3715 unsigned Length = Str.length();
3717 llvm::APInt LengthI(32, Length + 1);
3721 Context.adjustStringLiteralBaseType(
Context.WideCharTy.withConst());
3725 ResTy =
Context.getConstantArrayType(ResTy, LengthI,
nullptr,
3731 ResTy =
Context.adjustStringLiteralBaseType(
Context.CharTy.withConst());
3732 ResTy =
Context.getConstantArrayType(ResTy, LengthI,
nullptr,
3751 StringRef ThisTok =
PP.getSpelling(
Tok, CharBuffer, &
Invalid);
3757 if (Literal.hadError())
3761 if (Literal.isWide())
3767 else if (Literal.isUTF16())
3769 else if (Literal.isUTF32())
3778 if (Literal.isWide())
3780 else if (Literal.isUTF16())
3782 else if (Literal.isUTF32())
3784 else if (Literal.isUTF8())
3790 if (Literal.getUDSuffix().empty())
3800 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3805 Lit,
Tok.getLocation());
3809 unsigned IntSize =
Context.getTargetInfo().getIntWidth();
3811 llvm::APInt(IntSize, Val,
true),
3833 using llvm::APFloat;
3834 APFloat Val(Format);
3837 if (RM == llvm::RoundingMode::Dynamic)
3838 RM = llvm::RoundingMode::NearestTiesToEven;
3839 APFloat::opStatus result = Literal.GetFloatValue(Val, RM);
3843 if ((result & APFloat::opOverflow) ||
3844 ((result & APFloat::opUnderflow) && Val.isZero())) {
3845 unsigned diagnostic;
3847 if (result & APFloat::opOverflow) {
3848 diagnostic = diag::warn_float_overflow;
3849 APFloat::getLargest(Format).toString(buffer);
3851 diagnostic = diag::warn_float_underflow;
3852 APFloat::getSmallest(Format).toString(buffer);
3855 S.
Diag(Loc, diagnostic) << Ty << buffer.str();
3858 bool isExact = (result == APFloat::opOK);
3863 assert(E &&
"Invalid expression");
3870 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3874 llvm::APSInt ValueAPS;
3885 bool ValueIsPositive =
3886 AllowZero ? ValueAPS.isNonNegative() : ValueAPS.isStrictlyPositive();
3887 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3889 <<
toString(ValueAPS, 10) << ValueIsPositive;
3899 if (
Tok.getLength() == 1 ||
Tok.getKind() == tok::binary_data) {
3900 const uint8_t Val =
PP.getSpellingOfSingleCharacterNumericConstant(
Tok);
3909 SpellingBuffer.resize(
Tok.getLength() + 1);
3913 StringRef TokSpelling =
PP.getSpelling(
Tok, SpellingBuffer, &
Invalid);
3918 PP.getSourceManager(),
PP.getLangOpts(),
3919 PP.getTargetInfo(),
PP.getDiagnostics());
3920 if (Literal.hadError)
3923 if (Literal.hasUDSuffix()) {
3931 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3934 if (Literal.isFloatingLiteral()) {
3938 CookedTy =
Context.LongDoubleTy;
3943 CookedTy =
Context.UnsignedLongLongTy;
3947 Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
3959 !Literal.isImaginary)) {
3968 if (Literal.isFloatingLiteral()) {
3971 llvm::APInt ResultVal(
Context.getTargetInfo().getLongLongWidth(), 0);
3972 if (Literal.GetIntegerValue(ResultVal))
3973 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3985 unsigned Length = Literal.getUDSuffixOffset();
3992 false, StrTy, TokLoc);
4003 bool CharIsUnsigned =
Context.CharTy->isUnsignedIntegerType();
4004 llvm::APSInt
Value(CharBits, CharIsUnsigned);
4005 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
4006 Value = TokSpelling[I];
4014 llvm_unreachable(
"unexpected literal operator lookup result");
4020 if (Literal.isFixedPointLiteral()) {
4023 if (Literal.isAccum) {
4024 if (Literal.isHalf) {
4026 }
else if (Literal.isLong) {
4031 }
else if (Literal.isFract) {
4032 if (Literal.isHalf) {
4034 }
else if (Literal.isLong) {
4041 if (Literal.isUnsigned) Ty =
Context.getCorrespondingUnsignedType(Ty);
4043 bool isSigned = !Literal.isUnsigned;
4044 unsigned scale =
Context.getFixedPointScale(Ty);
4045 unsigned bit_width =
Context.getTypeInfo(Ty).Width;
4047 llvm::APInt Val(bit_width, 0, isSigned);
4048 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
4049 bool ValIsZero = Val.isZero() && !Overflowed;
4051 auto MaxVal =
Context.getFixedPointMax(Ty).getValue();
4052 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
4058 else if (Val.ugt(MaxVal) || Overflowed)
4059 Diag(
Tok.getLocation(), diag::err_too_large_for_fixed_point);
4062 Tok.getLocation(), scale);
4063 }
else if (Literal.isFloatingLiteral()) {
4065 if (Literal.isHalf){
4070 Diag(
Tok.getLocation(), diag::err_half_const_requires_fp16);
4073 }
else if (Literal.isFloat)
4075 else if (Literal.isLong)
4077 else if (Literal.isFloat16)
4079 else if (Literal.isFloat128)
4096 Diag(
Tok.getLocation(), diag::warn_double_const_requires_fp64)
4101 }
else if (!Literal.isIntegerLiteral()) {
4107 if (Literal.isSizeT) {
4111 Diag(
Tok.getLocation(), diag::err_cxx23_size_t_suffix);
4119 if (Literal.isBitInt)
4120 PP.Diag(
Tok.getLocation(),
4123 : diag::ext_c23_bitint_suffix);
4132 unsigned BitsNeeded =
Context.getTargetInfo().getIntMaxTWidth();
4133 if (Literal.isBitInt)
4134 BitsNeeded = llvm::APInt::getSufficientBitsNeeded(
4135 Literal.getLiteralDigits(), Literal.getRadix());
4136 if (Literal.MicrosoftInteger) {
4137 if (Literal.MicrosoftInteger == 128 &&
4138 !
Context.getTargetInfo().hasInt128Type())
4139 PP.Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4140 << Literal.isUnsigned;
4141 BitsNeeded = std::max<unsigned>(BitsNeeded, Literal.MicrosoftInteger);
4144 llvm::APInt ResultVal(BitsNeeded, 0);
4146 if (Literal.GetIntegerValue(ResultVal)) {
4148 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4150 Ty =
Context.UnsignedLongLongTy;
4151 assert(
Context.getTypeSize(Ty) == ResultVal.getBitWidth() &&
4152 "long long is not intmax_t?");
4159 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
4166 Literal.isLong =
true;
4167 Literal.isLongLong =
false;
4174 if (Literal.MicrosoftInteger) {
4175 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
4179 Width = Literal.MicrosoftInteger;
4180 Ty =
Context.getIntTypeForBitwidth(Width,
4181 !Literal.isUnsigned);
4185 ResultVal = ResultVal.zextOrTrunc(Width);
4190 if (Literal.isBitInt) {
4193 Width = std::max(ResultVal.getActiveBits(), 1u) +
4194 (Literal.isUnsigned ? 0u : 1u);
4198 unsigned int MaxBitIntWidth =
4199 Context.getTargetInfo().getMaxBitIntWidth();
4200 if (Width > MaxBitIntWidth) {
4201 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
4202 << Literal.isUnsigned;
4203 Width = MaxBitIntWidth;
4210 ResultVal = ResultVal.zextOrTrunc(Width);
4211 Ty =
Context.getBitIntType(Literal.isUnsigned, Width);
4215 if (Literal.isSizeT) {
4216 assert(!Literal.MicrosoftInteger &&
4217 "size_t literals can't be Microsoft literals");
4218 unsigned SizeTSize =
Context.getTargetInfo().getTypeWidth(
4219 Context.getTargetInfo().getSizeType());
4222 if (ResultVal.isIntN(SizeTSize)) {
4224 if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4225 Ty =
Context.getSignedSizeType();
4226 else if (AllowUnsigned)
4232 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong &&
4235 unsigned IntSize =
Context.getTargetInfo().getIntWidth();
4238 if (ResultVal.isIntN(IntSize)) {
4240 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
4242 else if (AllowUnsigned)
4249 if (Ty.
isNull() && !Literal.isLongLong && !Literal.isSizeT) {
4250 unsigned LongSize =
Context.getTargetInfo().getLongWidth();
4253 if (ResultVal.isIntN(LongSize)) {
4255 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4257 else if (AllowUnsigned)
4262 const unsigned LongLongSize =
4263 Context.getTargetInfo().getLongLongWidth();
4267 ? diag::warn_old_implicitly_unsigned_long_cxx
4269 ext_old_implicitly_unsigned_long_cxx
4270 : diag::warn_old_implicitly_unsigned_long)
4271 << (LongLongSize > LongSize ? 0
4280 if (Ty.
isNull() && !Literal.isSizeT) {
4281 unsigned LongLongSize =
Context.getTargetInfo().getLongLongWidth();
4284 if (ResultVal.isIntN(LongLongSize)) {
4288 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4289 (
getLangOpts().MSVCCompat && Literal.isLongLong)))
4291 else if (AllowUnsigned)
4292 Ty =
Context.UnsignedLongLongTy;
4293 Width = LongLongSize;
4299 ? diag::warn_cxx98_compat_longlong
4300 : diag::ext_cxx11_longlong);
4302 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
4310 if (Literal.isSizeT)
4311 Diag(
Tok.getLocation(), diag::err_size_t_literal_too_large)
4312 << Literal.isUnsigned;
4315 diag::ext_integer_literal_too_large_for_signed);
4316 Ty =
Context.UnsignedLongLongTy;
4317 Width =
Context.getTargetInfo().getLongLongWidth();
4320 if (ResultVal.getBitWidth() != Width)
4321 ResultVal = ResultVal.trunc(Width);
4327 if (Literal.isImaginary) {
4333 Diag(
Tok.getLocation(), diag::ext_gnu_imaginary_constant);
4335 DiagCompat(
Tok.getLocation(), diag_compat::imaginary_constant);
4341 assert(E &&
"ActOnParenExpr() missing expr");
4344 !E->
isLValue() && ExprTy->hasFloatingRepresentation())
4356 if (!(
T->isArithmeticType() ||
T->isVoidType() ||
T->isVectorType())) {
4357 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
4362 assert((
T->isVoidType() || !
T->isIncompleteType()) &&
4363 "Scalar types should always be complete");
4371 if (!
T->isVectorType() && !
T->isSizelessVectorType())
4372 return S.
Diag(Loc, diag::err_builtin_non_vector_type)
4374 <<
"__builtin_vectorelements" <<
T << ArgRange;
4376 if (
auto *FD = dyn_cast<FunctionDecl>(S.
CurContext)) {
4377 if (
T->isSVESizelessBuiltinType()) {
4378 llvm::StringMap<bool> CallerFeatureMap;
4393 if (!
T->isFunctionType() && !
T->isFunctionPointerType() &&
4394 !
T->isFunctionReferenceType() && !
T->isMemberFunctionPointerType()) {
4395 S.
Diag(Loc, diag::err_ptrauth_type_disc_undiscriminated) <<
T << ArgRange;
4405 UnaryExprOrTypeTrait TraitKind) {
4411 if (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4412 TraitKind == UETT_PreferredAlignOf) {
4415 if (
T->isFunctionType()) {
4416 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
4423 if (
T->isVoidType()) {
4424 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4425 : diag::ext_sizeof_alignof_void_type;
4436 UnaryExprOrTypeTrait TraitKind) {
4440 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
4441 <<
T << (TraitKind == UETT_SizeOf)
4458 const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
4459 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4462 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4464 << ICE->getSubExpr()->getType();
4468 UnaryExprOrTypeTrait ExprKind) {
4470 assert(!ExprTy->isReferenceType());
4472 bool IsUnevaluatedOperand =
4473 (ExprKind == UETT_SizeOf || ExprKind == UETT_DataSizeOf ||
4474 ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4475 ExprKind == UETT_VecStep || ExprKind == UETT_CountOf);
4476 if (IsUnevaluatedOperand) {
4492 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4494 if (ExprKind == UETT_VecStep)
4498 if (ExprKind == UETT_VectorElements)
4509 if (
Context.getTargetInfo().getTriple().isWasm() &&
4520 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4523 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4528 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4535 assert(!ExprTy->isReferenceType());
4537 if (ExprTy->isFunctionType()) {
4547 if (ExprKind == UETT_CountOf) {
4552 Diag(E->
getExprLoc(), diag::err_countof_arg_not_array_type) << ExprType;
4562 if (ExprKind == UETT_SizeOf) {
4563 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreParens())) {
4564 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4565 QualType OType = PVD->getOriginalType();
4570 Diag(PVD->getLocation(), diag::note_declared_at);
4578 if (
const auto *BO = dyn_cast<BinaryOperator>(E->
IgnoreParens())) {
4595 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4602 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4604 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4605 D = ME->getMemberDecl();
4625 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4628 if (!FD->getParent()->isCompleteDefinition()) {
4629 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4638 if (!FD->getType()->isReferenceType())
4657 assert(
T->isVariablyModifiedType());
4658 assert(CSI !=
nullptr);
4662 const Type *Ty =
T.getTypePtr();
4664#define TYPE(Class, Base)
4665#define ABSTRACT_TYPE(Class, Base)
4666#define NON_CANONICAL_TYPE(Class, Base)
4667#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4668#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4669#include "clang/AST/TypeNodes.inc"
4676 case Type::ExtVector:
4677 case Type::ConstantMatrix:
4680 case Type::TemplateSpecialization:
4681 case Type::ObjCObject:
4682 case Type::ObjCInterface:
4683 case Type::ObjCObjectPointer:
4684 case Type::ObjCTypeParam:
4687 case Type::HLSLInlineSpirv:
4688 llvm_unreachable(
"type class is never variably-modified!");
4689 case Type::Adjusted:
4695 case Type::ArrayParameter:
4701 case Type::BlockPointer:
4704 case Type::LValueReference:
4705 case Type::RValueReference:
4708 case Type::MemberPointer:
4711 case Type::ConstantArray:
4712 case Type::IncompleteArray:
4716 case Type::VariableArray: {
4730 case Type::FunctionProto:
4731 case Type::FunctionNoProto:
4736 case Type::UnaryTransform:
4737 case Type::Attributed:
4738 case Type::BTFTagAttributed:
4739 case Type::OverflowBehavior:
4740 case Type::HLSLAttributedResource:
4741 case Type::SubstTemplateTypeParm:
4742 case Type::MacroQualified:
4743 case Type::CountAttributed:
4744 case Type::LateParsedAttr:
4746 T =
T.getSingleStepDesugaredType(Context);
4751 case Type::Decltype:
4754 case Type::PackIndexing:
4761 case Type::DeducedTemplateSpecialization:
4764 case Type::TypeOfExpr:
4770 case Type::PredefinedSugar:
4774 }
while (!
T.isNull() &&
T->isVariablyModifiedType());
4780 UnaryExprOrTypeTrait ExprKind,
4787 if (ExprKind == UETT_VectorElements)
4790 if (ExprKind == UETT_VecStep)
4792 if (ExprKind == UETT_PtrAuthTypeDiscriminator)
4808 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4809 ExprKind == UETT_OpenMPRequiredSimdAlign) {
4814 DiagCompat(OpLoc, diag_compat::alignof_incomplete_array);
4815 ExprType =
Context.getBaseElementType(ExprType);
4824 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4829 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4833 if (ExprKind == UETT_CountOf) {
4837 Diag(OpLoc, diag::err_countof_arg_not_array_type) << ExprType;
4844 if (
Context.getTargetInfo().getTriple().isWasm() &&
4846 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4860 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4864 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4865 DC = LSI->CallOperator;
4866 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4867 DC = CRSI->TheCapturedDecl;
4868 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4884 UnaryExprOrTypeTrait ExprKind,
4891 if (!
T->isDependentType() &&
4900 (ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
4910 ExprKind, TInfo,
Context.getSizeType(), OpLoc, R.getEnd());
4915 UnaryExprOrTypeTrait ExprKind) {
4926 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4928 }
else if (ExprKind == UETT_VecStep) {
4930 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4934 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4936 }
else if (ExprKind == UETT_VectorElements || ExprKind == UETT_SizeOf ||
4937 ExprKind == UETT_CountOf) {
4944 if ((ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
4958 UnaryExprOrTypeTrait ExprKind,
bool IsType,
4979 UETT_AlignOf, KWName);
4992 if (
V.get()->isTypeDependent())
5004 return CT->getElementType();
5007 if (
V.get()->getType()->isArithmeticType())
5008 return V.get()->getType();
5013 if (PR.
get() !=
V.get()) {
5019 S.
Diag(Loc, diag::err_realimag_invalid_type) <<
V.get()->getType()
5020 << (IsReal ?
"__real" :
"__imag");
5031 default: llvm_unreachable(
"Unknown unary op!");
5032 case tok::plusplus: Opc = UO_PostInc;
break;
5033 case tok::minusminus: Opc = UO_PostDec;
break;
5052 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
5055 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
5062 auto *BaseNoParens =
Base->IgnoreParens();
5063 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
5064 return MSProp->getPropertyDecl()->getType()->isArrayType();
5085 if (RTy->isIntegralOrUnscopedEnumerationType()) {
5087 Result = PT->getPointeeType();
5089 Result = AT->getElementType();
5092 Result = PT->getPointeeType();
5094 Result = AT->getElementType();
5108 if (AS->isOMPArraySection())
5124 base = result.
get();
5133 auto CheckAndReportCommaError = [&](
Expr *E) {
5134 if (ArgExprs.size() > 1 ||
5136 Diag(E->getExprLoc(), diag::err_matrix_subscript_comma)
5147 Diag(base->
getExprLoc(), diag::err_matrix_separate_incomplete_index)
5153 auto *matSubscriptE = dyn_cast<MatrixSubscriptExpr>(base);
5154 if (matSubscriptE && matSubscriptE->isIncomplete()) {
5155 if (CheckAndReportCommaError(ArgExprs.front()))
5159 matSubscriptE->getRowIdx(),
5160 ArgExprs.front(), rbLoc);
5168 CheckInvalidBuiltinCountedByRef(base,
5176 bool IsMSPropertySubscript =
false;
5179 if (!IsMSPropertySubscript) {
5183 base = result.
get();
5189 if (CheckAndReportCommaError(ArgExprs.front()))
5197 Expr *idx = ArgExprs[0];
5206 if (ArgExprs.size() == 1 &&
5207 ArgExprs[0]->getType()->isNonOverloadPlaceholderType()) {
5211 ArgExprs[0] = result.
get();
5223 base, ArgExprs.front(),
5236 if (IsMSPropertySubscript) {
5237 if (ArgExprs.size() > 1) {
5239 diag::err_ms_property_subscript_expects_single_arg);
5265 Diag(base->
getExprLoc(), diag::err_ovl_builtin_subscript_expects_single_arg)
5273 ArgExprs[0]->getType()->isRecordType())))) {
5291 return InitSeq.
Perform(*
this, Entity, Kind, E);
5305 RowIdx = RowR.
get();
5315 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5316 bool IsColumnIdx) ->
Expr * {
5324 if (std::optional<llvm::APSInt> Idx =
5326 if ((*Idx < 0 || *Idx >=
Dim)) {
5328 << IsColumnIdx <<
Dim;
5335 "should be able to convert any integer type to size type");
5336 return ConvExpr.
get();
5340 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5345 Context.getExtVectorType(MTy->getElementType(), MTy->getNumColumns());
5361 RowIdx = RowR.
get();
5365 Base, RowIdx, ColumnIdx,
Context.IncompleteMatrixIdxTy, RBLoc);
5376 ColumnIdx = ColumnR.
get();
5381 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5382 bool IsColumnIdx) ->
Expr * {
5390 if (std::optional<llvm::APSInt> Idx =
5392 if ((*Idx < 0 || *Idx >=
Dim)) {
5394 << IsColumnIdx <<
Dim;
5401 "should be able to convert any integer type to size type");
5402 return ConvExpr.
get();
5406 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5407 ColumnIdx = IsIndexValid(ColumnIdx, MTy->getNumColumns(),
true);
5408 if (!RowIdx || !ColumnIdx)
5412 MTy->getElementType(), RBLoc);
5415void Sema::CheckAddressOfNoDeref(
const Expr *E) {
5422 while ((
Member = dyn_cast<MemberExpr>(StrippedExpr)) && !
Member->isArrow())
5423 StrippedExpr =
Member->getBase()->IgnoreParenImpCasts();
5425 LastRecord.PossibleDerefs.erase(StrippedExpr);
5439 if (ResultTy->
hasAttr(attr::NoDeref)) {
5440 LastRecord.PossibleDerefs.insert(E);
5447 QualType BaseTy =
Base->getType();
5452 const MemberExpr *
Member =
nullptr;
5453 while ((
Member = dyn_cast<MemberExpr>(
Base->IgnoreParenCasts())) &&
5457 if (
const auto *Ptr = dyn_cast<PointerType>(
Base->getType())) {
5458 if (
Ptr->getPointeeType()->hasAttr(attr::NoDeref))
5459 LastRecord.PossibleDerefs.insert(E);
5475 for (
auto *Op : {LHSExp, RHSExp}) {
5476 Op = Op->IgnoreImplicit();
5477 if (Op->getType()->isArrayType() && !Op->isLValue())
5500 Expr *BaseExpr, *IndexExpr;
5518 if (!
LangOpts.isSubscriptPointerArithmetic())
5534 if (!
LangOpts.isSubscriptPointerArithmetic()) {
5535 Diag(LLoc, diag::err_subscript_nonfragile_interface)
5559 LHSExp = Materialized.
get();
5566 Qualifiers BaseQuals = BaseType.getQualifiers();
5568 Qualifiers Combined = BaseQuals + MemberQuals;
5569 if (Combined != MemberQuals)
5570 ResultType =
Context.getQualifiedType(ResultType, Combined);
5580 CK_ArrayToPointerDecay).
get();
5586 }
else if (RHSTy->isArrayType()) {
5591 CK_ArrayToPointerDecay).
get();
5598 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
5603 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
5609 std::optional<llvm::APSInt> IntegerContantExpr =
5611 if (!IntegerContantExpr.has_value() ||
5612 IntegerContantExpr.value().isNegative())
5628 Diag(LLoc, diag::ext_gnu_subscript_void_type)
5639 diag::err_subscript_incomplete_or_sizeless_type, BaseExpr))
5652 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
5656 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
5657 DC = LSI->CallOperator;
5658 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
5659 DC = CRSI->TheCapturedDecl;
5660 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
5678 bool SkipImmediateInvocations) {
5679 if (Param->hasUnparsedDefaultArg()) {
5680 assert(!RewrittenInit &&
"Should not have a rewritten init expression yet");
5684 Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD;
5685 Diag(CallLoc, diag::note_recursive_default_argument_used_here);
5686 Param->setInvalidDecl();
5690 Diag(CallLoc, diag::err_use_of_default_argument_to_function_declared_later)
5693 diag::note_default_argument_declared_here);
5697 if (Param->hasUninstantiatedDefaultArg()) {
5698 assert(!RewrittenInit &&
"Should not have a rewitten init expression yet");
5703 Expr *
Init = RewrittenInit ? RewrittenInit : Param->getInit();
5704 assert(
Init &&
"default argument but no initializer?");
5713 if (
auto *InitWithCleanup = dyn_cast<ExprWithCleanups>(
Init)) {
5716 Cleanup.setExprNeedsCleanups(InitWithCleanup->cleanupsHaveSideEffects());
5720 assert(!InitWithCleanup->getNumObjects() &&
5721 "default argument expression has capturing blocks?");
5734 SkipImmediateInvocations;
5822 if (!
SemaRef.CurrentInstantiationScope ||
5834 assert(Param->hasDefaultArg() &&
"can't build nonexistent default arg");
5838 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5839 InitializationContext =
5841 if (!InitializationContext.has_value())
5842 InitializationContext.emplace(CallLoc, Param,
CurContext);
5844 if (!
Init && !Param->hasUnparsedDefaultArg()) {
5859 if (Param->hasUninstantiatedDefaultArg()) {
5868 if (!NestedDefaultChecking)
5869 V.TraverseDecl(Param);
5873 if (
V.HasImmediateCalls ||
5874 (NeedRebuild && isa_and_present<ExprWithCleanups>(Param->getInit()))) {
5875 if (
V.HasImmediateCalls)
5885 Res = Immediate.TransformInitializer(Param->getInit(),
5899 CallLoc, FD, Param,
Init,
5900 NestedDefaultChecking))
5904 Init, InitializationContext->Context);
5914 ClassPattern->
lookup(Field->getDeclName());
5915 auto Rng = llvm::make_filter_range(
5928 bool NestedDefaultChecking,
5932 if (!
Field->getInClassInitializer() &&
5936 FieldDecl *Pattern =
5938 assert(Pattern &&
"We must have set the Pattern!");
5945 Expr *InClassInit =
Field->getInClassInitializer();
5961 RecordDecl *OutermostClass = ParentRD->getOuterLexicalRecordContext();
5962 Diag(Loc, diag::err_default_member_initializer_not_yet_parsed)
5963 << OutermostClass <<
Field;
5965 diag::note_default_member_initializer_not_yet_parsed);
5968 Field->setInvalidDecl();
5978 if (!NestedDefaultChecking)
5979 V.TraverseDecl(Field);
5989 Expr *
Init = InClassInit;
5991 (
V.HasImmediateCalls || (NeedRebuild && ContainsAnyTemporaries))) {
5995 NestedDefaultChecking;
6001 EnsureImmediateInvocationInDefaultArgs
Immediate(*
this);
6004 Res =
Immediate.TransformInitializer(InClassInit,
6010 Field->setInvalidDecl();
6016 if (!NestedDefaultChecking)
6025 assert(Field->hasInClassInitializer());
6053 NestedDefaultChecking,
false);
6054 if (
Init.isInvalid())
6058 if (
Init.isInvalid()) {
6059 Field->setInvalidDecl();
6064 Context, InitContext->Loc, Field, InitContext->Context,
6065 Init.get() == Field->getInClassInitializer() ?
nullptr :
Init.get());
6071 assert(Field->hasInClassInitializer());
6103 Loc, Field, MemberEntity, NestedDefaultChecking,
true);
6104 if (
Init.isInvalid())
6114 Context, InitContext->Loc, Field, InitContext->Context,
6115 Init.get() == Field->getInClassInitializer() ?
nullptr :
Init.get());
6122 if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
6124 else if (Fn && Fn->getType()->isBlockPointerType())
6128 if (
Method->isInstance())
6130 }
else if (Fn && Fn->getType() ==
Context.BoundMemberTy)
6143 FunctionName(FuncName) {}
6145 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
6154 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
6155 return std::make_unique<FunctionCallCCC>(*
this);
6159 const IdentifierInfo *
const FunctionName;
6175 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
6176 if (Corrected.isOverloaded()) {
6186 ND = Best->FoundDecl;
6187 Corrected.setCorrectionDecl(ND);
6193 ND = ND->getUnderlyingDecl();
6208 Fn = Fn->IgnoreParens();
6210 auto *UO = dyn_cast<UnaryOperator>(Fn);
6211 if (!UO || UO->getOpcode() != clang::UO_AddrOf)
6213 if (
auto *DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
6214 return DRE->hasQualifier();
6216 if (
auto *OVL = dyn_cast<OverloadExpr>(UO->getSubExpr()->IgnoreParens()))
6217 return bool(OVL->getQualifier());
6227 bool IsExecConfig) {
6235 if (
Context.BuiltinInfo.hasCustomTypechecking(ID) &&
6236 !(
Context.getLangOpts().HLSL && FDecl->
hasAttr<BuiltinAliasAttr>()))
6243 bool HasExplicitObjectParameter =
6245 unsigned ExplicitObjectParameterOffset = HasExplicitObjectParameter ? 1 : 0;
6249 unsigned FnKind = Fn->getType()->isBlockPointerType()
6256 if (Args.size() < NumParams) {
6257 if (Args.size() < MinArgs) {
6262 ? diag::err_typecheck_call_too_few_args_suggest
6263 : diag::err_typecheck_call_too_few_args_at_least_suggest;
6266 << FnKind << MinArgs - ExplicitObjectParameterOffset
6267 <<
static_cast<unsigned>(Args.size()) -
6268 ExplicitObjectParameterOffset
6270 }
else if (MinArgs - ExplicitObjectParameterOffset == 1 && FDecl &&
6275 ? diag::err_typecheck_call_too_few_args_one
6276 : diag::err_typecheck_call_too_few_args_at_least_one)
6277 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
6278 << HasExplicitObjectParameter << Fn->getSourceRange();
6281 ? diag::err_typecheck_call_too_few_args
6282 : diag::err_typecheck_call_too_few_args_at_least)
6283 << FnKind << MinArgs - ExplicitObjectParameterOffset
6284 <<
static_cast<unsigned>(Args.size()) -
6285 ExplicitObjectParameterOffset
6286 << HasExplicitObjectParameter << Fn->getSourceRange();
6289 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6297 assert((
Call->getNumArgs() == NumParams) &&
6298 "We should have reserved space for the default arguments before!");
6303 if (Args.size() > NumParams) {
6309 ? diag::err_typecheck_call_too_many_args_suggest
6310 : diag::err_typecheck_call_too_many_args_at_most_suggest;
6313 << FnKind << NumParams - ExplicitObjectParameterOffset
6314 <<
static_cast<unsigned>(Args.size()) -
6315 ExplicitObjectParameterOffset
6317 }
else if (NumParams - ExplicitObjectParameterOffset == 1 && FDecl &&
6320 Diag(Args[NumParams]->getBeginLoc(),
6321 MinArgs == NumParams
6322 ? diag::err_typecheck_call_too_many_args_one
6323 : diag::err_typecheck_call_too_many_args_at_most_one)
6324 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
6325 <<
static_cast<unsigned>(Args.size()) -
6326 ExplicitObjectParameterOffset
6327 << HasExplicitObjectParameter << Fn->getSourceRange()
6329 Args.back()->getEndLoc());
6331 Diag(Args[NumParams]->getBeginLoc(),
6332 MinArgs == NumParams
6333 ? diag::err_typecheck_call_too_many_args
6334 : diag::err_typecheck_call_too_many_args_at_most)
6335 << FnKind << NumParams - ExplicitObjectParameterOffset
6336 <<
static_cast<unsigned>(Args.size()) -
6337 ExplicitObjectParameterOffset
6338 << HasExplicitObjectParameter << Fn->getSourceRange()
6340 Args.back()->getEndLoc());
6343 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
6348 Call->shrinkNumArgs(NumParams);
6359 unsigned TotalNumArgs = AllArgs.size();
6360 for (
unsigned i = 0; i < TotalNumArgs; ++i)
6361 Call->setArg(i, AllArgs[i]);
6363 Call->computeDependence();
6372 bool IsListInitialization) {
6377 for (
unsigned i = FirstParam; i < NumParams; i++) {
6382 if (ArgIx < Args.size()) {
6383 Arg = Args[ArgIx++];
6386 diag::err_call_incomplete_argument, Arg))
6390 bool CFAudited =
false;
6392 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6393 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6396 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
6397 (!Param || !Param->hasAttr<CFConsumedAttr>()))
6403 BE->getBlockDecl()->setDoesNotEscape();
6424 if (
const auto *OBT = Arg->
getType()->
getAs<OverflowBehaviorType>();
6427 OBT->isUnsignedIntegerOrEnumerationType() && OBT->isWrapKind();
6429 isPedantic ? diag::warn_obt_discarded_at_function_boundary_pedantic
6430 : diag::warn_obt_discarded_at_function_boundary)
6431 << Arg->
getType() << ProtoArgType;
6435 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
6441 assert(Param &&
"can't use default arguments without a known callee");
6453 CheckArrayAccess(Arg);
6458 AllArgs.push_back(Arg);
6467 for (
Expr *A : Args.slice(ArgIx)) {
6471 AllArgs.push_back(arg.get());
6476 for (
Expr *A : Args.slice(ArgIx)) {
6479 AllArgs.push_back(Arg.
get());
6484 for (
Expr *A : Args.slice(ArgIx))
6485 CheckArrayAccess(A);
6493 TL = DTL.getOriginalLoc();
6496 << ATL.getLocalSourceRange();
6502 const Expr *ArgExpr) {
6507 QualType OrigTy = Param->getOriginalType();
6532 Diag(CallLoc, diag::warn_static_array_too_small)
6540 std::optional<CharUnits> ArgSize =
6542 std::optional<CharUnits> ParmSize =
6544 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
6545 Diag(CallLoc, diag::warn_static_array_too_small)
6547 << (
unsigned)ParmSize->getQuantity() << 1;
6561 if (!placeholder)
return false;
6563 switch (placeholder->
getKind()) {
6565#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6566 case BuiltinType::Id:
6567#include "clang/Basic/OpenCLImageTypes.def"
6568#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6569 case BuiltinType::Id:
6570#include "clang/Basic/OpenCLExtensionTypes.def"
6573#define SVE_TYPE(Name, Id, SingletonId) \
6574 case BuiltinType::Id:
6575#include "clang/Basic/AArch64ACLETypes.def"
6576#define PPC_VECTOR_TYPE(Name, Id, Size) \
6577 case BuiltinType::Id:
6578#include "clang/Basic/PPCTypes.def"
6579#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6580#include "clang/Basic/RISCVVTypes.def"
6581#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6582#include "clang/Basic/WebAssemblyReferenceTypes.def"
6583#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
6584#include "clang/Basic/AMDGPUTypes.def"
6585#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6586#include "clang/Basic/HLSLIntangibleTypes.def"
6587#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6588#include "clang/Basic/HLSLPackedTypes.def"
6589#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6590#include "clang/Basic/SPIRVTypes.def"
6591#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
6592#define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
6593#include "clang/AST/BuiltinTypes.def"
6596 case BuiltinType::UnresolvedTemplate:
6599 case BuiltinType::Overload:
6604 case BuiltinType::ARCUnbridgedCast:
6608 case BuiltinType::PseudoObject:
6613 case BuiltinType::UnknownAny:
6617 case BuiltinType::BoundMember:
6618 case BuiltinType::BuiltinFn:
6619 case BuiltinType::IncompleteMatrixIdx:
6620 case BuiltinType::ArraySection:
6621 case BuiltinType::OMPArrayShaping:
6622 case BuiltinType::OMPIterator:
6626 llvm_unreachable(
"bad builtin type kind");
6632 bool hasInvalid =
false;
6633 for (
size_t i = 0, e = args.size(); i != e; i++) {
6636 if (result.
isInvalid()) hasInvalid =
true;
6637 else args[i] = result.
get();
6661 if (!Context.BuiltinInfo.hasPtrArgsOrResult(FDecl->
getBuiltinID()) || !FT ||
6665 bool NeedsNewDecl =
false;
6685 if (!ParamType->isPointerType() ||
6686 ParamType->getPointeeType().hasAddressSpace() ||
6687 !ArgType->isPointerType() ||
6688 !ArgType->getPointeeType().hasAddressSpace() ||
6690 OverloadParams.push_back(ParamType);
6695 NeedsNewDecl =
true;
6696 LangAS AS = ArgType->getPointeeType().getAddressSpace();
6698 PointeeType = Context.getAddrSpaceQualType(PointeeType, AS);
6699 OverloadParams.push_back(Context.getPointerType(PointeeType));
6709 OverloadParams, EPI);
6719 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
6726 Params.push_back(Parm);
6728 OverloadDecl->setParams(Params);
6732 if (FDecl->
hasAttr<CUDAHostAttr>())
6733 OverloadDecl->
addAttr(CUDAHostAttr::CreateImplicit(Context));
6734 if (FDecl->
hasAttr<CUDADeviceAttr>())
6735 OverloadDecl->
addAttr(CUDADeviceAttr::CreateImplicit(Context));
6738 return OverloadDecl;
6749 !Callee->isVariadic())
6751 if (Callee->getMinRequiredArguments() > ArgExprs.size())
6754 if (
const EnableIfAttr *
Attr =
6755 S.
CheckEnableIf(Callee, Fn->getBeginLoc(), ArgExprs,
true)) {
6756 S.
Diag(Fn->getBeginLoc(),
6758 ? diag::err_ovl_no_viable_member_function_in_call
6759 : diag::err_ovl_no_viable_function_in_call)
6760 << Callee << Callee->getSourceRange();
6761 S.
Diag(Callee->getLocation(),
6762 diag::note_ovl_candidate_disabled_by_function_cond_attr)
6763 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
6771 const auto GetFunctionLevelDCIfCXXClass =
6779 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
6780 return MD->
getParent()->getCanonicalDecl();
6783 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
6784 return RD->getCanonicalDecl();
6791 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
6792 if (!CurParentClass)
6799 assert(NamingClass &&
"Must have naming class even for implicit access");
6805 return CurParentClass == NamingClass ||
6854 if (
Call->getNumArgs() != 1)
6857 const Expr *E =
Call->getCallee()->IgnoreParenImpCasts();
6860 const DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(E);
6873 if (BuiltinID != Builtin::BImove && BuiltinID != Builtin::BIforward)
6876 S.
Diag(DRE->
getLocation(), diag::warn_unqualified_call_to_std_cast_function)
6887 if (
Call.isInvalid())
6892 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn);
6893 ULE && ULE->hasExplicitTemplateArgs() && ULE->decls().empty()) {
6894 DiagCompat(Fn->getExprLoc(), diag_compat::adl_only_template_id)
6902 if (
const auto *CE = dyn_cast<CallExpr>(
Call.get()))
6908 if (
auto *DRE = dyn_cast<DeclRefExpr>(Fn->IgnoreParens());
6909 DRE &&
Call.get()->isValueDependent()) {
6919 if (
T->isDependentType())
6922 if (
T == Context.BoundMemberTy ||
T == Context.UnknownAnyTy ||
6923 T == Context.BuiltinFnTy ||
T == Context.OverloadTy ||
6924 T->isFunctionType() ||
T->isFunctionReferenceType() ||
6925 T->isMemberFunctionPointerType() ||
T->isFunctionPointerType() ||
6926 T->isBlockPointerType() ||
T->isRecordType() ||
T->isUndeducedType())
6935 Expr *ExecConfig,
bool IsExecConfig,
6936 bool AllowRecovery) {
6945 if (Fn->getType() ==
Context.BuiltinFnTy && ArgExprs.size() == 1 &&
6946 ArgExprs[0]->getType() ==
Context.BuiltinFnTy) {
6949 if (FD->getName() ==
"__builtin_amdgcn_is_invocable") {
6963 for (
const Expr *Arg : ArgExprs)
6964 if (CheckInvalidBuiltinCountedByRef(Arg,
6971 if (!ArgExprs.empty()) {
6973 Diag(Fn->getBeginLoc(), diag::err_pseudo_dtor_call_with_args)
6976 ArgExprs.back()->getEndLoc()));
6982 if (Fn->getType() ==
Context.PseudoObjectTy) {
6999 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->IgnoreParens()),
7007 Diag(LParenLoc, diag::err_typecheck_call_not_function)
7008 << Fn->getType() << Fn->getSourceRange());
7016 if (Fn->getType()->isRecordType())
7020 if (Fn->getType() ==
Context.UnknownAnyTy) {
7026 if (Fn->getType() ==
Context.BoundMemberTy) {
7028 RParenLoc, ExecConfig, IsExecConfig,
7034 if (Fn->getType() ==
Context.OverloadTy) {
7045 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
7048 RParenLoc, ExecConfig, IsExecConfig,
7054 if (Fn->getType() ==
Context.UnknownAnyTy) {
7060 Expr *NakedFn = Fn->IgnoreParens();
7062 bool CallingNDeclIndirectly =
false;
7064 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
7065 if (UnOp->getOpcode() == UO_AddrOf) {
7066 CallingNDeclIndirectly =
true;
7071 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
7072 NDecl = DRE->getDecl();
7076 const llvm::Triple &Triple =
Context.getTargetInfo().getTriple();
7077 if (Triple.isSPIRV() && Triple.getVendor() == llvm::Triple::AMD) {
7094 Fn->getValueKind(), FDecl,
nullptr, DRE->isNonOdrUse());
7097 }
else if (
auto *ME = dyn_cast<MemberExpr>(NakedFn))
7098 NDecl = ME->getMemberDecl();
7100 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
7102 FD,
true, Fn->getBeginLoc()))
7114 for (
unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size();
7117 if (!ArgExprs[Idx] || !Param || !Param->getType()->isPointerType() ||
7118 !ArgExprs[Idx]->getType()->isPointerType())
7122 auto ArgTy = ArgExprs[Idx]->getType();
7123 auto ArgPtTy = ArgTy->getPointeeType();
7124 auto ArgAS = ArgPtTy.getAddressSpace();
7127 bool NeedImplicitASC =
7132 if (!NeedImplicitASC)
7136 if (ArgExprs[Idx]->isGLValue()) {
7140 ArgExprs[Idx] = Res.
get();
7144 Qualifiers ArgPtQuals = ArgPtTy.getQualifiers();
7147 Context.getQualifiedType(ArgPtTy.getUnqualifiedType(), ArgPtQuals);
7150 ArgTy.getQualifiers());
7154 CK_AddressSpaceConversion)
7160 if (
Context.isDependenceAllowed() &&
7163 assert((Fn->containsErrors() ||
7164 llvm::any_of(ArgExprs,
7165 [](
clang::Expr *E) { return E->containsErrors(); })) &&
7166 "should only occur in error-recovery path.");
7171 ExecConfig, IsExecConfig);
7176 std::string Name =
Context.BuiltinInfo.getName(Id);
7182 assert(BuiltInDecl &&
"failed to find builtin declaration");
7186 assert(DeclRef.
isUsable() &&
"Builtin reference cannot fail");
7191 assert(!
Call.isInvalid() &&
"Call to builtin cannot fail!");
7211 Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
7229 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
7230 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
7233 switch (BuiltinID) {
7234 case Builtin::BI__builtin_longjmp:
7235 case Builtin::BI__builtin_setjmp:
7236 case Builtin::BI__sigsetjmp:
7237 case Builtin::BI_longjmp:
7238 case Builtin::BI_setjmp:
7239 case Builtin::BIlongjmp:
7240 case Builtin::BIsetjmp:
7241 case Builtin::BIsiglongjmp:
7242 case Builtin::BIsigsetjmp:
7255 if (DeferParent->
Contains(*CurScope) &&
7257 Diag(Fn->getExprLoc(), diag::err_defer_invalid_sjlj) << FDecl;
7262 if (FDecl->
hasAttr<AnyX86InterruptAttr>()) {
7263 Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
7266 if (FDecl->
hasAttr<ARMInterruptAttr>()) {
7267 Diag(Fn->getExprLoc(), diag::err_arm_interrupt_called);
7276 if (Caller->hasAttr<AnyX86InterruptAttr>() ||
7277 Caller->hasAttr<AnyX86NoCallerSavedRegistersAttr>()) {
7279 bool HasNonGPRRegisters =
7281 if (HasNonGPRRegisters &&
7282 (!FDecl || !FDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>())) {
7283 Diag(Fn->getExprLoc(), diag::warn_anyx86_excessive_regsave)
7284 << (Caller->hasAttr<AnyX86InterruptAttr>() ? 0 : 1);
7303 Fn->getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn)) {
7319 if (!BuiltinID || !
Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
7326 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7327 << Fn->getType() << Fn->getSourceRange());
7333 if (Fn->getType() ==
Context.UnknownAnyTy) {
7341 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
7342 << Fn->getType() << Fn->getSourceRange());
7349 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
7350 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
7354 assert(UsesADL == ADLCallKind::NotADL &&
7355 "CUDAKernelCallExpr should not use ADL");
7366 if (BuiltinID &&
Context.BuiltinInfo.hasCustomTypechecking(BuiltinID)) {
7379 ExprResult E = CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7388 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
7389 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
7390 << FDecl << Fn->getSourceRange());
7396 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
7397 << Fn->getType() << Fn->getSourceRange());
7400 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
7401 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
7402 << FDecl << Fn->getSourceRange());
7416 if (
Context.getTargetInfo().getTriple().isWasm()) {
7417 for (
const Expr *Arg : Args) {
7418 if (Arg && Arg->getType()->isWebAssemblyTableType()) {
7420 diag::err_wasm_table_as_function_parameter));
7444 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
7445 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
7446 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
7465 if (!Proto && !Args.empty() &&
7467 !
Diags.isIgnored(diag::warn_strict_uses_without_prototype,
7469 Diag(LParenLoc, diag::warn_strict_uses_without_prototype)
7470 << (FDecl !=
nullptr) << FDecl;
7473 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7474 Expr *Arg = Args[i];
7476 if (Proto && i < Proto->getNumParams()) {
7478 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
7496 diag::err_call_incomplete_argument, Arg))
7505 if (
Method->isImplicitObjectMemberFunction())
7506 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
7507 << Fn->getSourceRange() << 0);
7515 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
7516 if (
const auto *RT =
7517 dyn_cast<RecordType>(Args[i]->
getType().getCanonicalType())) {
7518 if (RT->getDecl()->isOrContainsUnion())
7519 Diag(Args[i]->getBeginLoc(), diag::warn_cmse_nonsecure_union)
7530 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
7531 checkFortifiedLibcArgument(FDecl, TheCall);
7534 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
7536 if (CheckPointerCall(NDecl, TheCall, Proto))
7539 if (CheckOtherCall(TheCall, Proto))
7549 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
7550 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
7555 TInfo =
Context.getTrivialTypeSourceInfo(literalType);
7567 LParenLoc,
Context.getBaseElementType(literalType),
7568 diag::err_array_incomplete_or_sizeless_type,
7591 ? diag::err_variable_object_no_init
7592 : diag::err_compound_literal_with_vla_type;
7599 diag::err_typecheck_decl_incomplete_type,
7614 LiteralExpr =
Result.get();
7621 bool IsFileScope = !
CurContext->isFunctionOrMethod() &&
7652 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
7653 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
7655 if (!
Init->isTypeDependent() && !
Init->isValueDependent() &&
7657 Diag(
Init->getExprLoc(), diag::err_init_element_not_constant)
7658 <<
Init->getSourceBitField();
7666 LiteralExpr, IsFileScope);
7678 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
7695 Cleanup.setExprNeedsCleanups(
true);
7715 bool DiagnosedArrayDesignator =
false;
7716 bool DiagnosedNestedDesignator =
false;
7717 bool DiagnosedMixedDesignator =
false;
7721 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7722 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
7724 FirstDesignator = DIE->getBeginLoc();
7729 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
7730 DiagnosedNestedDesignator =
true;
7731 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
7732 << DIE->getDesignatorsSourceRange();
7735 for (
auto &Desig : DIE->designators()) {
7736 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
7737 DiagnosedArrayDesignator =
true;
7738 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
7739 << Desig.getSourceRange();
7743 if (!DiagnosedMixedDesignator &&
7745 DiagnosedMixedDesignator =
true;
7746 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7747 << DIE->getSourceRange();
7748 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
7749 << InitArgList[0]->getSourceRange();
7753 DiagnosedMixedDesignator =
true;
7755 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7756 << DIE->getSourceRange();
7757 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
7758 << InitArgList[I]->getSourceRange();
7762 if (FirstDesignator.
isValid()) {
7766 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
7768 ? diag::warn_cxx17_compat_designated_init
7769 : diag::ext_cxx_designated_init);
7771 Diag(FirstDesignator, diag::ext_designated_init);
7775 return BuildInitList(LBraceLoc, InitArgList, RBraceLoc,
true);
7786 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
7787 if (InitArgList[I]->
getType()->isNonOverloadPlaceholderType()) {
7794 InitArgList[I] = result.
get();
7814 Cleanup.setExprNeedsCleanups(
true);
7823 if (
Context.hasSameUnqualifiedType(SrcTy, DestTy))
7828 llvm_unreachable(
"member pointer type in C");
7837 if (SrcAS != DestAS)
7838 return CK_AddressSpaceConversion;
7839 if (
Context.hasCvrSimilarType(SrcTy, DestTy))
7845 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
7850 return CK_CPointerToObjCPointerCast;
7852 return CK_BlockPointerToObjCPointerCast;
7854 return CK_PointerToBoolean;
7856 return CK_PointerToIntegral;
7862 llvm_unreachable(
"illegal cast from pointer");
7864 llvm_unreachable(
"Should have returned before this");
7869 return CK_FixedPointCast;
7871 return CK_FixedPointToBoolean;
7873 return CK_FixedPointToIntegral;
7875 return CK_FixedPointToFloating;
7879 diag::err_unimplemented_conversion_with_fixed_point_type)
7881 return CK_IntegralCast;
7886 llvm_unreachable(
"illegal cast to pointer type");
7888 llvm_unreachable(
"Should have returned before this");
7898 return CK_NullToPointer;
7899 return CK_IntegralToPointer;
7901 return CK_IntegralToBoolean;
7903 return CK_IntegralCast;
7905 return CK_IntegralToFloating;
7910 return CK_IntegralRealToComplex;
7914 CK_IntegralToFloating);
7915 return CK_FloatingRealToComplex;
7917 llvm_unreachable(
"member pointer type in C");
7919 return CK_IntegralToFixedPoint;
7921 llvm_unreachable(
"Should have returned before this");
7926 return CK_FloatingCast;
7928 return CK_FloatingToBoolean;
7930 return CK_FloatingToIntegral;
7935 return CK_FloatingRealToComplex;
7939 CK_FloatingToIntegral);
7940 return CK_IntegralRealToComplex;
7944 llvm_unreachable(
"valid float->pointer cast?");
7946 llvm_unreachable(
"member pointer type in C");
7948 return CK_FloatingToFixedPoint;
7950 llvm_unreachable(
"Should have returned before this");
7955 return CK_FloatingComplexCast;
7957 return CK_FloatingComplexToIntegralComplex;
7960 if (
Context.hasSameType(ET, DestTy))
7961 return CK_FloatingComplexToReal;
7963 return CK_FloatingCast;
7966 return CK_FloatingComplexToBoolean;
7970 CK_FloatingComplexToReal);
7971 return CK_FloatingToIntegral;
7975 llvm_unreachable(
"valid complex float->pointer cast?");
7977 llvm_unreachable(
"member pointer type in C");
7980 diag::err_unimplemented_conversion_with_fixed_point_type)
7982 return CK_IntegralCast;
7984 llvm_unreachable(
"Should have returned before this");
7989 return CK_IntegralComplexToFloatingComplex;
7991 return CK_IntegralComplexCast;
7994 if (
Context.hasSameType(ET, DestTy))
7995 return CK_IntegralComplexToReal;
7997 return CK_IntegralCast;
8000 return CK_IntegralComplexToBoolean;
8004 CK_IntegralComplexToReal);
8005 return CK_IntegralToFloating;
8009 llvm_unreachable(
"valid complex int->pointer cast?");
8011 llvm_unreachable(
"member pointer type in C");
8014 diag::err_unimplemented_conversion_with_fixed_point_type)
8016 return CK_IntegralCast;
8018 llvm_unreachable(
"Should have returned before this");
8021 llvm_unreachable(
"Unhandled scalar cast");
8028 len = vecType->getNumElements();
8029 eltType = vecType->getElementType();
8036 if (!
type->isRealType())
return false;
8046 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
8050 const auto *VecTy = SecondType->getAs<
VectorType>();
8054 return ValidScalableConversion(srcTy, destTy) ||
8055 ValidScalableConversion(destTy, srcTy);
8065 return matSrcType->
getNumRows() == matDestType->getNumRows() &&
8066 matSrcType->
getNumColumns() == matDestType->getNumColumns();
8072 uint64_t SrcLen, DestLen;
8082 uint64_t SrcEltSize =
Context.getTypeSize(SrcEltTy);
8083 uint64_t DestEltSize =
Context.getTypeSize(DestEltTy);
8085 return (SrcLen * SrcEltSize == DestLen * DestEltSize);
8090 "expected at least one type to be a vector here");
8092 bool IsSrcTyAltivec =
8108 return (IsSrcTyAltivec || IsDestTyAltivec);
8128 switch (
Context.getLangOpts().getLaxVectorConversions()) {
8135 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
8140 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
8157 return Diag(R.getBegin(), diag::err_invalid_conversion_between_matrixes)
8158 << DestTy << SrcTy << R;
8161 return Diag(R.getBegin(),
8162 diag::err_invalid_conversion_between_matrix_and_type)
8163 << SrcTy << DestTy << R;
8165 return Diag(R.getBegin(),
8166 diag::err_invalid_conversion_between_matrix_and_type)
8167 << DestTy << SrcTy << R;
8170 Kind = CK_MatrixCast;
8176 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
8180 return Diag(R.getBegin(),
8182 diag::err_invalid_conversion_between_vectors :
8183 diag::err_invalid_conversion_between_vector_and_integer)
8184 << VectorTy << Ty << R;
8186 return Diag(R.getBegin(),
8187 diag::err_invalid_conversion_between_vector_and_scalar)
8188 << VectorTy << Ty << R;
8197 if (DestElemTy == SplattedExpr->
getType())
8198 return SplattedExpr;
8211 CK_BooleanToSignedIntegral);
8212 SplattedExpr = CastExprRes.
get();
8213 CK = CK_IntegralToFloating;
8215 CK = CK_BooleanToSignedIntegral;
8222 SplattedExpr = CastExprRes.
get();
8230 if (DestElemTy == SplattedExpr->
getType())
8231 return SplattedExpr;
8240 SplattedExpr = CastExprRes.
get();
8258 !
Context.hasSameUnqualifiedType(DestTy, SrcTy) &&
8259 !
Context.areCompatibleVectorTypes(DestTy, SrcTy))) {
8260 Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors)
8261 << DestTy << SrcTy << R;
8272 return Diag(R.getBegin(),
8273 diag::err_invalid_conversion_between_vector_and_scalar)
8274 << DestTy << SrcTy << R;
8276 Kind = CK_VectorSplat;
8286 DestType == SourceType)
8294 if (!CE->getCalleeAllocSizeAttr())
8296 std::optional<llvm::APInt> AllocSize =
8297 CE->evaluateBytesReturnedByAllocSizeCall(S.
Context);
8300 if (!AllocSize || AllocSize->isZero())
8310 if (LhsSize && Size < LhsSize)
8312 << Size.getQuantity() << TargetType << LhsSize->getQuantity();
8320 "ActOnCastExpr(): missing type or expr");
8336 bool isVectorLiteral =
false;
8351 isVectorLiteral =
true;
8354 isVectorLiteral =
true;
8359 if (isVectorLiteral)
8389 "Expected paren or paren list expression");
8396 LiteralLParenLoc = PE->getLParenLoc();
8397 LiteralRParenLoc = PE->getRParenLoc();
8398 exprs = PE->getExprs();
8399 numExprs = PE->getNumExprs();
8426 if (numExprs == 1) {
8429 if (Literal.isInvalid())
8435 else if (numExprs < numElems) {
8437 diag::err_incorrect_number_of_vector_initializers);
8441 initExprs.append(exprs, exprs + numExprs);
8450 Diag(exprs[0]->getBeginLoc(), diag::err_typecheck_convert_incompatible)
8457 if (Literal.isInvalid())
8464 initExprs.append(exprs, exprs + numExprs);
8470 LiteralRParenLoc,
false);
8499 unsigned NumUserSpecifiedExprs,
8504 InitLoc, LParenLoc, RParenLoc);
8509 const Expr *NullExpr = LHSExpr;
8510 const Expr *NonPointerExpr = RHSExpr;
8517 NonPointerExpr = LHSExpr;
8539 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
8540 << NonPointerExpr->
getType() << DiagType
8552 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8560 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
8594 bool IsBlockPointer =
false;
8598 IsBlockPointer =
true;
8623 ResultAddrSpace = LAddrSpace;
8625 ResultAddrSpace = RAddrSpace;
8627 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8634 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
8639 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_ptrauth)
8656 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8658 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
8666 lhptee, rhptee,
false,
false,
8669 if (CompositeTy.
isNull()) {
8686 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
8697 QualType ResultTy = [&, ResultAddrSpace]() {
8732 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
8785 bool IsIntFirstExpr) {
8787 !
Int.get()->getType()->isIntegerType())
8790 Expr *Expr1 = IsIntFirstExpr ?
Int.get() : PointerExpr;
8791 Expr *Expr2 = IsIntFirstExpr ? PointerExpr :
Int.get();
8793 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
8797 CK_IntegralToPointer);
8831 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8837 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8843 if (LHSType == RHSType)
8853 (S, LHS, RHS, LHSType, RHSType,
false);
8887 llvm::raw_svector_ostream OS(Str);
8888 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
8889 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8890 << CondTy << OS.str();
8911 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8929 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
8930 << CondTy << VecResTy;
8935 QualType RVE = RV->getElementType();
8940 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8941 << CondTy << VecResTy;
8967 bool IsBoolVecLang =
8995 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
8996 QualType Ty = CE->getCallee()->getType();
9028 if (
Context.isDependenceAllowed() &&
9034 "should only occur in error-recovery path.");
9068 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
9077 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
9096 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
9112 Context.hasSameUnqualifiedType(LHSTy, RHSTy))
9152 if (!compositeType.
isNull())
9153 return compositeType;
9183 if (
Context.hasSameType(LHSTy, RHSTy))
9184 return Context.getCommonSugaredType(LHSTy, RHSTy);
9187 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
9206 Self.Diag(Loc,
Note) << ParenRange;
9226 const Expr **RHSExprs) {
9231 if (
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
9232 E = MTE->getSubExpr();
9237 if (
const auto *OP = dyn_cast<BinaryOperator>(E);
9239 *Opcode = OP->getOpcode();
9240 *RHSExprs = OP->getRHS();
9245 if (
const auto *
Call = dyn_cast<CXXOperatorCallExpr>(E)) {
9246 if (
Call->getNumArgs() != 2)
9252 if (OO < OO_Plus || OO > OO_Arrow ||
9253 OO == OO_PlusPlus || OO == OO_MinusMinus)
9259 *RHSExprs =
Call->getArg(1);
9275 if (
const auto *OP = dyn_cast<BinaryOperator>(E))
9276 return OP->isComparisonOp() || OP->isLogicalOp();
9277 if (
const auto *OP = dyn_cast<UnaryOperator>(E))
9278 return OP->getOpcode() == UO_LNot;
9293 const Expr *RHSExpr) {
9295 const Expr *CondRHS;
9306 ? diag::warn_precedence_bitwise_conditional
9307 : diag::warn_precedence_conditional;
9309 Self.Diag(OpLoc, DiagID)
9315 Self.PDiag(diag::note_precedence_silence)
9320 Self.PDiag(diag::note_precedence_conditional_first),
9331 auto GetNullability = [](
QualType Ty) {
9342 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
9350 MergedKind = RHSKind;
9357 MergedKind = RHSKind;
9359 MergedKind = LHSKind;
9365 if (GetNullability(ResTy) == MergedKind)
9383 Expr *commonExpr =
nullptr;
9385 commonExpr = CondExpr;
9392 commonExpr = result.
get();
9406 commonExpr = commonRes.
get();
9416 commonExpr = MatExpr.
get();
9424 LHSExpr = CondExpr = opaqueValue;
9430 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
9432 VK, OK, QuestionLoc);
9440 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
9448 RHS.get(), result,
VK, OK);
9451 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
9452 ColonLoc, result,
VK, OK);
9456 unsigned FromAttributes = 0, ToAttributes = 0;
9457 if (
const auto *FromFn =
9458 dyn_cast<FunctionProtoType>(
Context.getCanonicalType(FromType)))
9461 if (
const auto *ToFn =
9462 dyn_cast<FunctionProtoType>(
Context.getCanonicalType(ToType)))
9466 return FromAttributes != ToAttributes;
9478 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9479 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9482 const Type *lhptee, *rhptee;
9484 std::tie(lhptee, lhq) =
9486 std::tie(rhptee, rhq) =
9557 diag::warn_typecheck_convert_incompatible_function_pointer_strict,
9581 ltrans = LUnderlying;
9582 rtrans = RUnderlying;
9600 if (ltrans == rtrans) {
9616 std::tie(lhptee, lhq) =
9618 std::tie(rhptee, rhq) =
9630 return AssignConvertType::
9631 IncompatibleNestedPointerAddressSpaceMismatch;
9635 if (lhptee == rhptee)
9655 const auto *LFPT = dyn_cast<FunctionProtoType>(LFT);
9656 const auto *RFPT = dyn_cast<FunctionProtoType>(RFT);
9659 LFPT->getParamTypes(),
9660 RFPT->getExtProtoInfo());
9665 LFPT->getParamTypes(), EPI);
9670 EPI.
ExtInfo = LFT->getExtInfo();
9672 RFPT->getParamTypes(), EPI);
9691 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
9692 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9713 if (LQuals != RQuals)
9742 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
9743 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
9791 return VT->getElementType().getCanonicalType() == ElementType;
9821 LHSType =
Context.getCanonicalType(LHSType).getUnqualifiedType();
9822 RHSType =
Context.getCanonicalType(RHSType).getUnqualifiedType();
9825 if (LHSType == RHSType) {
9832 if (
const auto *AT = dyn_cast<AutoType>(LHSType)) {
9833 if (AT->isGNUAutoType()) {
9839 auto OBTResult =
Context.checkOBTAssignmentCompatibility(LHSType, RHSType);
9840 switch (OBTResult) {
9845 Kind = LHSType->
isBooleanType() ? CK_IntegralToBoolean : CK_IntegralCast;
9858 !
Context.areCompatibleOverflowBehaviorTypes(LHSPointee, RHSPointee)) {
9866 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
9871 if (Kind != CK_NoOp && ConvertRHS)
9873 Kind = CK_NonAtomicToAtomic;
9885 if (
Context.typesAreCompatible(LHSTypeRef->getPointeeType(), RHSType)) {
9886 Kind = CK_LValueBitCast;
9897 if (LHSExtType->getNumElements() != RHSExtType->getNumElements())
9901 RHSExtType->getElementType()->isIntegerType()) {
9902 Kind = CK_IntegralToBoolean;
9906 if (
Context.getLangOpts().OpenCL &&
9907 Context.areCompatibleVectorTypes(LHSType, RHSType)) {
9917 Kind = CK_VectorSplat;
9927 if (
Context.areCompatibleVectorTypes(LHSType, RHSType)) {
9939 if (
Context.getTargetInfo().getTriple().isPPC() &&
9941 !
Context.areCompatibleVectorTypes(RHSType, LHSType))
9943 << RHSType << LHSType;
9957 if (
Context.getTargetInfo().getTriple().isPPC() &&
9962 << RHSType << LHSType;
9973 if (
ARM().areCompatibleSveTypes(LHSType, RHSType) ||
9974 ARM().areLaxCompatibleSveTypes(LHSType, RHSType)) {
9982 if (
Context.areCompatibleRVVTypes(LHSType, RHSType) ||
9983 Context.areLaxCompatibleRVVTypes(LHSType, RHSType)) {
10012 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
10015 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
10017 if (AddrSpaceL != AddrSpaceR)
10018 Kind = CK_AddressSpaceConversion;
10019 else if (
Context.hasCvrSimilarType(RHSType, LHSType))
10029 Kind = CK_IntegralToPointer;
10037 if (LHSPointer->getPointeeType()->isVoidType()) {
10045 Context.getObjCClassRedefinitionType())) {
10056 if (LHSPointer->getPointeeType()->isVoidType()) {
10057 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
10062 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
10080 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
10086 Kind = CK_IntegralToPointer;
10092 Kind = CK_AnyPointerToBlockPointerCast;
10098 if (RHSPT->getPointeeType()->isVoidType()) {
10099 Kind = CK_AnyPointerToBlockPointerCast;
10113 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10115 !
ObjC().CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
10122 Kind = CK_IntegralToPointer;
10129 Kind = CK_CPointerToObjCPointerCast;
10139 Context.getObjCClassRedefinitionType())) {
10151 Kind = CK_BlockPointerToObjCPointerCast;
10163 Kind = CK_NullToPointer;
10170 if (LHSType ==
Context.BoolTy) {
10171 Kind = CK_PointerToBoolean;
10177 Kind = CK_PointerToIntegral;
10187 if (LHSType ==
Context.BoolTy) {
10188 Kind = CK_PointerToBoolean;
10194 Kind = CK_PointerToIntegral;
10203 if (
Context.typesAreCompatible(LHSType, RHSType)) {
10210 Kind = CK_IntToOCLSampler;
10244 const RecordType *UT =
ArgType->getAsUnionType();
10249 if (!UD->
hasAttr<TransparentUnionAttr>())
10255 for (
auto *it : UD->
fields()) {
10256 if (it->getType()->isPointerType()) {
10295 bool DiagnoseCFAudited,
10299 assert((ConvertRHS || !
Diagnose) &&
"can't indicate whether we diagnosed");
10305 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
10309 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
10310 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
10312 diag::warn_noderef_to_dereferenceable_pointer)
10331 AllowedExplicit::None,
10343 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10344 !
ObjC().CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
10366 RHS.
get(), LHSType,
false, DAP))
10375 if (!
Context.hasSameUnqualifiedType(RHSType, LHSType)) {
10503 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
10513 ObjC().CheckConversionToObjCLiteral(LHSType, E,
Diagnose))) {
10533struct OriginalOperand {
10534 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
10535 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
10536 Op = MTE->getSubExpr();
10537 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
10538 Op = BTE->getSubExpr();
10539 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
10540 Orig = ICE->getSubExprAsWritten();
10541 Conversion = ICE->getConversionFunction();
10545 QualType
getType()
const {
return Orig->getType(); }
10548 NamedDecl *Conversion;
10554 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
10556 Diag(Loc, diag::err_typecheck_invalid_operands)
10557 << OrigLHS.getType() << OrigRHS.getType()
10562 if (OrigLHS.Conversion) {
10563 Diag(OrigLHS.Conversion->getLocation(),
10564 diag::note_typecheck_invalid_operands_converted)
10567 if (OrigRHS.Conversion) {
10569 diag::note_typecheck_invalid_operands_converted)
10584 if (!(LHSNatVec && RHSNatVec)) {
10586 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
10587 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10589 <<
Vector->getSourceRange();
10593 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
10616 unsigned &DiagID) {
10622 scalarCast = CK_IntegralToBoolean;
10627 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10632 scalarCast = CK_IntegralCast;
10637 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
10640 scalarCast = CK_FloatingCast;
10643 scalarCast = CK_IntegralToFloating;
10652 if (scalarCast != CK_NoOp)
10663 assert(VecTy &&
"Expression E must be a vector");
10668 VecTy->getVectorKind());
10672 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10673 if (ICE->getSubExpr()->getType() == NewVecTy)
10674 return ICE->getSubExpr();
10676 auto Cast = ElementType->isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
10688 QualType IntTy =
Int->get()->getType().getUnqualifiedType();
10694 bool CstInt =
Int->get()->EvaluateAsInt(EVResult, S.
Context);
10703 unsigned NumBits = IntSigned
10705 :
Result.getActiveBits())
10706 :
Result.getActiveBits();
10713 return (IntSigned != OtherIntSigned &&
10719 return (Order < 0);
10726 if (
Int->get()->containsErrors())
10729 QualType IntTy =
Int->get()->getType().getUnqualifiedType();
10734 bool CstInt =
Int->get()->EvaluateAsInt(EVResult, S.
Context);
10746 llvm::APFloat::rmTowardZero);
10749 bool Ignored =
false;
10750 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
10752 if (
Result != ConvertBack)
10758 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
10760 if (Bits > FloatPrec)
10773 QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
10774 QualType VectorTy =
Vector->get()->getType().getUnqualifiedType();
10779 "ExtVectorTypes should not be handled here!");
10780 VectorEltTy = VT->getElementType();
10785 llvm_unreachable(
"Only Fixed-Length and SVE Vector types are handled here");
10811 ScalarCast = CK_IntegralCast;
10815 ScalarCast = CK_FloatingToIntegral;
10823 llvm::APFloat
Result(0.0);
10829 bool CstScalar = Scalar->get()->isValueDependent() ||
10832 if (!CstScalar && Order < 0)
10838 bool Truncated =
false;
10840 llvm::APFloat::rmNearestTiesToEven, &Truncated);
10845 ScalarCast = CK_FloatingCast;
10850 ScalarCast = CK_IntegralToFloating;
10857 if (ScalarCast != CK_NoOp)
10865 bool AllowBothBool,
10866 bool AllowBoolConversions,
10867 bool AllowBoolOperation) {
10868 if (!IsCompAssign) {
10884 assert(LHSVecType || RHSVecType);
10892 (RHSVecType && RHSVecType->getElementType()->isMFloat8Type()))
10897 if (!AllowBothBool && LHSVecType &&
10903 if (!AllowBoolOperation &&
10908 if (
Context.hasSameType(LHSType, RHSType))
10909 return Context.getCommonSugaredType(LHSType, RHSType);
10912 if (LHSVecType && RHSVecType &&
10913 Context.areCompatibleVectorTypes(LHSType, RHSType)) {
10927 if (AllowBoolConversions && LHSVecType && RHSVecType &&
10930 Context.getTypeSize(RHSVecType->getElementType()))) {
10937 if (!IsCompAssign &&
10940 RHSVecType->getElementType()->isIntegerType()) {
10949 unsigned &SVEorRVV) {
10970 if (IsSveRVVConversion(LHSType, RHSType, SVEorRVV) ||
10971 IsSveRVVConversion(RHSType, LHSType, SVEorRVV)) {
10972 Diag(Loc, diag::err_typecheck_sve_rvv_ambiguous)
10973 << SVEorRVV << LHSType << RHSType;
10980 unsigned &SVEorRVV) {
10985 if (FirstVecType && SecondVecType) {
10988 SecondVecType->getVectorKind() ==
10993 SecondVecType->getVectorKind() ==
10995 SecondVecType->getVectorKind() ==
10997 SecondVecType->getVectorKind() ==
11006 if (SecondVecType &&
11019 if (IsSveRVVGnuConversion(LHSType, RHSType, SVEorRVV) ||
11020 IsSveRVVGnuConversion(RHSType, LHSType, SVEorRVV)) {
11021 Diag(Loc, diag::err_typecheck_sve_rvv_gnu_ambiguous)
11022 << SVEorRVV << LHSType << RHSType;
11028 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
11043 LHSType, RHSVecType->getElementType(),
11056 QualType VecType = LHSVecType ? LHSType : RHSType;
11057 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
11058 QualType OtherType = LHSVecType ? RHSType : LHSType;
11059 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
11061 if (
Context.getTargetInfo().getTriple().isPPC() &&
11063 !
Context.areCompatibleVectorTypes(RHSType, LHSType))
11064 Diag(Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType;
11068 if (!IsCompAssign) {
11087 if ((!RHSVecType && !RHSType->
isRealType()) ||
11089 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
11090 << LHSType << RHSType
11102 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
11113 QualType Scalar = LHSVecType ? RHSType : LHSType;
11115 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
11117 diag::err_typecheck_vector_not_convertable_implict_truncation)
11118 << ScalarOrVector << Scalar <<
Vector;
11125 << LHSType << RHSType
11134 if (!IsCompAssign) {
11149 unsigned DiagID = diag::err_typecheck_invalid_operands;
11151 ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
11152 (RHSBuiltinTy && RHSBuiltinTy->isSVEBool()))) {
11158 if (
Context.hasSameType(LHSType, RHSType))
11173 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
11180 Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
11181 Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC) {
11182 Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
11191 bool ScalarOrVector =
11194 Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
11195 << ScalarOrVector << Scalar <<
Vector;
11227 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
11239 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
11240 << LHSNull << NonNullType
11252 QualType ElementType = CT->getElementType().getCanonicalType();
11253 bool IsComplexRangePromoted = S.
getLangOpts().getComplexRange() ==
11255 if (!ElementType->isFloatingType() || !IsComplexRangePromoted)
11260 const llvm::fltSemantics &ElementTypeSemantics =
11262 const llvm::fltSemantics &HigherElementTypeSemantics =
11265 if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
11266 llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
11273 if (
Type == HigherElementType) {
11285 const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
11286 const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
11289 if (LUE->getKind() != UETT_SizeOf || LUE->isArgumentType() ||
11290 RUE->getKind() != UETT_SizeOf)
11297 if (RUE->isArgumentType())
11298 RHSTy = RUE->getArgumentType().getNonReferenceType();
11300 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
11307 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11308 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11309 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
11313 QualType ArrayElemTy = ArrayTy->getElementType();
11319 S.
Diag(Loc, diag::warn_division_sizeof_array)
11321 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
11322 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
11323 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
11327 S.
Diag(Loc, diag::note_precedence_silence) << RHS;
11340 S.
PDiag(diag::warn_remainder_division_by_zero)
11349 const Expr *LHSExpr = LHS.
get();
11350 const Expr *RHSExpr = RHS.
get();
11355 if (!LHSIsScoped && !RHSIsScoped)
11367 ->getDefinitionOrSelf()
11368 ->getIntegerType();
11369 std::string InsertionString =
"static_cast<" + IntType.getAsString() +
">(";
11370 S.
Diag(BeginLoc, diag::note_no_implicit_conversion_for_scoped_enum)
11375 DiagnosticHelper(LHSExpr, LHSType);
11378 DiagnosticHelper(RHSExpr, RHSType);
11385 bool IsCompAssign = Opc == BO_MulAssign || Opc == BO_DivAssign;
11386 bool IsDiv = Opc == BO_Div || Opc == BO_DivAssign;
11478 if (compType.
isNull() ||
11483 IsCompAssign ? BO_RemAssign : BO_Rem);
11494 ? diag::err_typecheck_pointer_arith_void_type
11495 : diag::ext_gnu_void_ptr)
11504 ? diag::err_typecheck_pointer_arith_void_type
11505 : diag::ext_gnu_void_ptr)
11506 << 0 <<
Pointer->getSourceRange();
11517 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
11518 <<
Pointer->getSourceRange();
11520 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
11537 S.
PDiag(diag::warn_pointer_sub_null_ptr)
11539 <<
Pointer->getSourceRange());
11548 ? diag::err_typecheck_pointer_arith_function_type
11549 : diag::ext_gnu_ptr_func_arith)
11561 assert(
Pointer->getType()->isAnyPointerType());
11563 ? diag::err_typecheck_pointer_arith_function_type
11564 : diag::ext_gnu_ptr_func_arith)
11565 << 0 <<
Pointer->getType()->getPointeeType()
11567 <<
Pointer->getSourceRange();
11575 QualType ResType = Operand->getType();
11577 ResType = ResAtomicType->getValueType();
11583 diag::err_typecheck_arithmetic_incomplete_or_sizeless_type,
11584 Operand->getSourceRange());
11597 QualType ResType = Operand->getType();
11599 ResType = ResAtomicType->getValueType();
11631 if (!isLHSPointer && !isRHSPointer)
return true;
11633 QualType LHSPointeeTy, RHSPointeeTy;
11638 if (isLHSPointer && isRHSPointer) {
11642 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
11650 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
11651 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
11652 if (isLHSVoidPtr || isRHSVoidPtr) {
11660 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
11661 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
11662 if (isLHSFuncPtr || isRHSFuncPtr) {
11684 Expr* IndexExpr = RHSExpr;
11687 IndexExpr = LHSExpr;
11690 bool IsStringPlusInt = StrExpr &&
11696 Self.Diag(OpLoc, diag::warn_string_plus_int)
11700 if (IndexExpr == RHSExpr) {
11702 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11707 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11713 const Expr *StringRefExpr = LHSExpr;
11718 CharExpr = dyn_cast<CharacterLiteral>(LHSExpr->
IgnoreImpCasts());
11719 StringRefExpr = RHSExpr;
11722 if (!CharExpr || !StringRefExpr)
11742 Self.Diag(OpLoc, diag::warn_string_plus_char)
11743 << DiagRange << Ctx.
CharTy;
11745 Self.Diag(OpLoc, diag::warn_string_plus_char)
11746 << DiagRange << CharExpr->
getType();
11752 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
11757 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
11766 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
11784 if (CompLHSTy) *CompLHSTy = compType;
11793 *CompLHSTy = compType;
11802 *CompLHSTy = compType;
11813 if (Opc == BO_Add) {
11820 if (CompLHSTy) *CompLHSTy = compType;
11834 std::swap(PExp, IExp);
11847 if (!IExp->getType()->isIntegerType())
11856 (!IExp->isValueDependent() &&
11857 (!IExp->EvaluateAsInt(KnownVal,
Context) ||
11861 Context, BO_Add, PExp, IExp);
11875 Diag(Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
11881 CheckArrayAccess(PExp, IExp);
11887 if (
Context.isPromotableIntegerType(LHSTy))
11888 LHSTy =
Context.getPromotedIntegerType(LHSTy);
11890 *CompLHSTy = LHSTy;
11901 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
11902 if (CAT->isZeroSize())
11904 }
else if (
const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
11905 if (
const Expr *Bound = VAT->getSizeExpr())
11906 if (std::optional<llvm::APSInt> Size =
11907 Bound->getIntegerConstantExpr(Ctx))
11911 T = AT->getElementType();
11930 if (CompLHSTy) *CompLHSTy = compType;
11939 *CompLHSTy = compType;
11948 *CompLHSTy = compType;
11962 if (CompLHSTy) *CompLHSTy = compType;
11979 Diag(Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
12005 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
12008 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
12019 if (!
Context.hasSameUnqualifiedType(lpointee, rpointee)) {
12024 if (!
Context.typesAreCompatible(
12025 Context.getCanonicalType(lpointee).getUnqualifiedType(),
12026 Context.getCanonicalType(rpointee).getUnqualifiedType())) {
12042 if (LAddrSpace != RAddrSpace) {
12049 if (LAddrSpace != ResultAddrSpace) {
12056 if (RAddrSpace != ResultAddrSpace) {
12082 Diag(Loc, diag::warn_sub_ptr_zero_size_types)
12086 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
12087 return Context.getPointerDiffType();
12097 if (
const EnumType *ET =
T->getAsCanonical<EnumType>())
12098 return ET->getDecl()->isScoped();
12110 if (Opc == BO_Shr &&
12119 llvm::APSInt Right = RHSResult.
Val.
getInt();
12121 if (Right.isNegative()) {
12123 S.
PDiag(diag::warn_shift_negative)
12134 LeftSize = FXSema.getWidth() - (
unsigned)FXSema.hasUnsignedPadding();
12136 if (Right.uge(LeftSize)) {
12138 S.
PDiag(diag::warn_shift_gt_typewidth)
12158 llvm::APSInt Left = LHSResult.
Val.
getInt();
12169 if (Left.isNegative()) {
12171 S.
PDiag(diag::warn_shift_lhs_negative)
12176 llvm::APInt ResultBits =
12177 static_cast<llvm::APInt &
>(Right) + Left.getSignificantBits();
12178 if (ResultBits.ule(LeftSize))
12180 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
12186 Result.toString(HexResult, 16,
false,
true);
12192 if (ResultBits - 1 == LeftSize) {
12193 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
12194 << HexResult << LHSType
12199 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
12200 << HexResult.str() <<
Result.getSignificantBits() << LHSType
12212 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
12218 if (!IsCompAssign) {
12240 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12247 if (!LHSEleType->isIntegerType()) {
12248 S.
Diag(Loc, diag::err_typecheck_expect_int)
12253 if (!RHSEleType->isIntegerType()) {
12254 S.
Diag(Loc, diag::err_typecheck_expect_int)
12263 if (LHSEleType != RHSEleType) {
12265 LHSEleType = RHSEleType;
12271 }
else if (RHSVecTy) {
12276 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12284 if (LHSBT != RHSBT &&
12286 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
12303 bool IsCompAssign) {
12304 if (!IsCompAssign) {
12327 if ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
12328 (RHSBuiltinTy && RHSBuiltinTy->
isSVEBool())) {
12329 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12334 if (!LHSEleType->isIntegerType()) {
12335 S.
Diag(Loc, diag::err_typecheck_expect_int)
12340 if (!RHSEleType->isIntegerType()) {
12341 S.
Diag(Loc, diag::err_typecheck_expect_int)
12349 S.
Diag(Loc, diag::err_typecheck_invalid_operands)
12359 if (LHSEleType != RHSEleType) {
12361 LHSEleType = RHSEleType;
12363 const llvm::ElementCount VecSize =
12372 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
12378 const llvm::ElementCount VecSize =
12380 if (LHSEleType != RHSEleType) {
12382 RHSEleType = LHSEleType;
12395 bool IsCompAssign) {
12429 if (IsCompAssign) LHS = OldLHS;
12457 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
12458 : diag::ext_typecheck_comparison_of_distinct_pointers)
12498 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
12499 : diag::ext_typecheck_comparison_of_fptr_to_void)
12506 case Stmt::ObjCArrayLiteralClass:
12507 case Stmt::ObjCDictionaryLiteralClass:
12508 case Stmt::ObjCStringLiteralClass:
12509 case Stmt::ObjCBoxedExprClass:
12553 QualType T = Method->parameters()[0]->getType();
12554 if (!
T->isObjCObjectPointerType())
12557 QualType R = Method->getReturnType();
12558 if (!R->isScalarType())
12570 Literal = LHS.
get();
12573 Literal = RHS.
get();
12589 llvm_unreachable(
"Unknown Objective-C object literal kind");
12593 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
12594 << Literal->getSourceRange();
12596 S.
Diag(Loc, diag::warn_objc_literal_comparison)
12597 << LiteralKind << Literal->getSourceRange();
12606 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
12619 if (!UO || UO->
getOpcode() != UO_LNot)
return;
12629 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
12631 << Loc << IsBitwiseOp;
12658 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
12660 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
12661 if (Mem->isImplicitAccess())
12662 D = Mem->getMemberDecl();
12677 return std::nullopt;
12685 std::swap(LHS, RHS);
12689 std::swap(LHS, RHS);
12693 return std::nullopt;
12696 auto *BO = dyn_cast<BinaryOperator>(LHS);
12697 if (!BO || BO->getOpcode() != BO_Add)
12698 return std::nullopt;
12702 Other = BO->getRHS();
12704 Other = BO->getLHS();
12706 return std::nullopt;
12708 if (!
Other->getType()->isUnsignedIntegerType())
12709 return std::nullopt;
12711 return Opc == BO_GE;
12765 auto IsDeprArrayComparionIgnored =
12768 ? diag::warn_array_comparison_cxx26
12769 : !S.
getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored
12770 ? diag::warn_array_comparison
12771 : diag::warn_depr_array_comparison;
12797 Result = AlwaysConstant;
12801 S.
PDiag(diag::warn_comparison_always)
12816 Result = AlwaysConstant;
12820 S.
PDiag(diag::warn_comparison_always)
12823 }
else if (std::optional<bool> Res =
12826 S.
PDiag(diag::warn_comparison_always)
12828 << (*Res ? AlwaysTrue : AlwaysFalse));
12839 Expr *LiteralString =
nullptr;
12840 Expr *LiteralStringStripped =
nullptr;
12844 LiteralString = LHS;
12845 LiteralStringStripped = LHSStripped;
12850 LiteralString = RHS;
12851 LiteralStringStripped = RHSStripped;
12854 if (LiteralString) {
12856 S.
PDiag(diag::warn_stringcompare)
12869 llvm_unreachable(
"unhandled cast kind");
12871 case CK_UserDefinedConversion:
12873 case CK_LValueToRValue:
12875 case CK_ArrayToPointerDecay:
12877 case CK_FunctionToPointerDecay:
12879 case CK_IntegralCast:
12881 case CK_FloatingCast:
12883 case CK_IntegralToFloating:
12884 case CK_FloatingToIntegral:
12886 case CK_IntegralComplexCast:
12887 case CK_FloatingComplexCast:
12888 case CK_FloatingComplexToIntegralComplex:
12889 case CK_IntegralComplexToFloatingComplex:
12891 case CK_FloatingComplexToReal:
12892 case CK_FloatingRealToComplex:
12893 case CK_IntegralComplexToReal:
12894 case CK_IntegralRealToComplex:
12896 case CK_HLSLArrayRValue:
12909 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
12936 << 0 << FromType << ToType;
12941 llvm_unreachable(
"unhandled case in switch");
12968 if (NumEnumArgs == 1) {
12970 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
12976 if (NumEnumArgs == 2) {
12985 assert(IntType->isArithmeticType());
12995 LHSType = RHSType = IntType;
13004 if (
Type.isNull()) {
13010 std::optional<ComparisonCategoryType> CCT =
13022 assert(!
Type.isNull() &&
"composite type for <=> has not been set");
13040 if (
Type.isNull()) {
13061 int NullValue =
PP.isMacroDefined(
"NULL") ? 0 : 1;
13066 if (
const auto *
CL = dyn_cast<CharacterLiteral>(E.
get())) {
13067 if (
CL->getValue() == 0)
13071 NullValue ?
"NULL" :
"(void *)0");
13072 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(E.
get())) {
13079 NullValue ?
"NULL" :
"(void *)0");
13089 bool IsThreeWay = Opc == BO_Cmp;
13090 bool IsOrdered = IsRelational || IsThreeWay;
13101 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
13158 auto computeResultTy = [&]() {
13167 std::optional<ComparisonCategoryType> CCT =
13172 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
13176 Diag(Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
13177 << (LHSIsNull ? LHS.
get()->getSourceRange()
13190 return computeResultTy();
13193 if (!IsOrdered && LHSIsNull != RHSIsNull) {
13194 bool IsEquality = Opc == BO_EQ;
13206 bool IsError = Opc == BO_Cmp;
13208 IsError ? diag::err_typecheck_ordered_comparison_of_function_pointers
13210 ? diag::warn_typecheck_ordered_comparison_of_function_pointers
13211 : diag::ext_typecheck_ordered_comparison_of_function_pointers;
13240 return computeResultTy();
13256 (IsOrdered ? 2 : 1) &&
13261 return computeResultTy();
13275 if (IsRelational) {
13280 Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
13286 }
else if (!IsRelational &&
13290 && !LHSIsNull && !RHSIsNull)
13297 if (LCanPointeeTy != RCanPointeeTy) {
13303 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
13304 << LHSType << RHSType << 0
13310 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
13316 bool RHSHasCFIUncheckedCallee = RFn && RFn->getCFIUncheckedCalleeAttr();
13317 bool ChangingCFIUncheckedCallee =
13318 LHSHasCFIUncheckedCallee != RHSHasCFIUncheckedCallee;
13320 if (LHSIsNull && !RHSIsNull)
13322 else if (!ChangingCFIUncheckedCallee)
13325 return computeResultTy();
13337 if (!IsOrdered && LHSIsNull && RHSIsNull) {
13340 return computeResultTy();
13344 return computeResultTy();
13355 return computeResultTy();
13359 return computeResultTy();
13368 return computeResultTy();
13373 return computeResultTy();
13377 if (IsRelational &&
13388 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
13389 if (CTSD->isInStdNamespace() &&
13390 llvm::StringSwitch<bool>(CTSD->getName())
13391 .Cases({
"less",
"less_equal",
"greater",
"greater_equal"},
true)
13397 return computeResultTy();
13410 return computeResultTy();
13420 if (!LHSIsNull && !RHSIsNull &&
13421 !
Context.typesAreCompatible(lpointee, rpointee)) {
13422 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13427 return computeResultTy();
13434 if (!LHSIsNull && !RHSIsNull) {
13439 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
13443 if (LHSIsNull && !RHSIsNull)
13446 : CK_AnyPointerToBlockPointerCast);
13450 : CK_AnyPointerToBlockPointerCast);
13451 return computeResultTy();
13460 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
13462 if (!LPtrToVoid && !RPtrToVoid &&
13463 !
Context.typesAreCompatible(LHSType, RHSType)) {
13470 if (LHSIsNull && !RHSIsNull) {
13476 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13486 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
13488 return computeResultTy();
13492 if (!
Context.areComparableObjCPointerTypes(LHSType, RHSType))
13498 if (LHSIsNull && !RHSIsNull)
13502 return computeResultTy();
13508 CK_BlockPointerToObjCPointerCast);
13509 return computeResultTy();
13510 }
else if (!IsOrdered &&
13514 CK_BlockPointerToObjCPointerCast);
13515 return computeResultTy();
13520 unsigned DiagID = 0;
13521 bool isError =
false;
13530 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
13531 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
13534 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
13536 }
else if (IsOrdered)
13537 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
13539 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
13551 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13554 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
13555 return computeResultTy();
13559 if (!IsOrdered && RHSIsNull
13562 return computeResultTy();
13564 if (!IsOrdered && LHSIsNull
13567 return computeResultTy();
13570 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
13572 return computeResultTy();
13576 return computeResultTy();
13579 if (LHSIsNull && RHSType->
isQueueT()) {
13581 return computeResultTy();
13584 if (LHSType->
isQueueT() && RHSIsNull) {
13586 return computeResultTy();
13611 "Unhandled vector element size in vector compare");
13631 "Unhandled vector element size in vector compare");
13641 const auto TypeSize =
Context.getTypeSize(ETy);
13643 const QualType IntTy =
Context.getIntTypeForBitwidth(TypeSize,
true);
13644 const llvm::ElementCount VecSize =
Context.getBuiltinVectorTypeInfo(VTy).EC;
13645 return Context.getScalableVectorType(IntTy, VecSize.getKnownMinValue());
13651 if (Opc == BO_Cmp) {
13652 Diag(Loc, diag::err_three_way_vector_comparison);
13680 return Context.getLogicalOperationType();
13682 Diag(Loc, diag::warn_deprecated_altivec_src_compat);
13688 return Context.getLogicalOperationType();
13711 assert(
getLangOpts().
HLSL &&
"matrix comparisons are only supported in HLSL");
13712 assert(Opc != BO_Cmp &&
"three-way comparisons are not supported in HLSL");
13733 return Context.getConstantMatrixType(
Context.BoolTy, MT->getNumRows(),
13734 MT->getNumColumns());
13741 if (Opc == BO_Cmp) {
13742 Diag(Loc, diag::err_three_way_vector_comparison);
13770 if (LHSBuiltinTy && RHSBuiltinTy && LHSBuiltinTy->
isSVEBool() &&
13771 RHSBuiltinTy->isSVEBool())
13790 bool Negative =
false;
13791 bool ExplicitPlus =
false;
13792 const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.
get());
13793 const auto *RHSInt = dyn_cast<IntegerLiteral>(XorRHS.
get());
13799 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
13801 if (Opc != UO_Minus && Opc != UO_Plus)
13803 RHSInt = dyn_cast<IntegerLiteral>(UO->getSubExpr());
13806 Negative = (Opc == UO_Minus);
13807 ExplicitPlus = !Negative;
13813 const llvm::APInt &LeftSideValue = LHSInt->getValue();
13814 llvm::APInt RightSideValue = RHSInt->getValue();
13815 if (LeftSideValue != 2 && LeftSideValue != 10)
13818 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
13823 llvm::StringRef ExprStr =
13828 llvm::StringRef XorStr =
13831 if (XorStr ==
"xor")
13842 RightSideValue = -RightSideValue;
13843 RHSStr =
"-" + RHSStr;
13844 }
else if (ExplicitPlus) {
13845 RHSStr =
"+" + RHSStr;
13848 StringRef LHSStrRef = LHSStr;
13849 StringRef RHSStrRef = RHSStr;
13852 if (LHSStrRef.starts_with(
"0b") || LHSStrRef.starts_with(
"0B") ||
13853 RHSStrRef.starts_with(
"0b") || RHSStrRef.starts_with(
"0B") ||
13854 LHSStrRef.starts_with(
"0x") || LHSStrRef.starts_with(
"0X") ||
13855 RHSStrRef.starts_with(
"0x") || RHSStrRef.starts_with(
"0X") ||
13856 (LHSStrRef.size() > 1 && LHSStrRef.starts_with(
"0")) ||
13857 (RHSStrRef.size() > 1 && RHSStrRef.starts_with(
"0")) ||
13858 LHSStrRef.contains(
'\'') || RHSStrRef.contains(
'\''))
13863 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
13864 int64_t RightSideIntValue = RightSideValue.getSExtValue();
13865 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
13866 std::string SuggestedExpr =
"1 << " + RHSStr;
13867 bool Overflow =
false;
13868 llvm::APInt One = (LeftSideValue - 1);
13869 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
13871 if (RightSideIntValue < 64)
13872 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13873 << ExprStr <<
toString(XorValue, 10,
true) << (
"1LL << " + RHSStr)
13875 else if (RightSideIntValue == 64)
13876 S.
Diag(Loc, diag::warn_xor_used_as_pow)
13877 << ExprStr <<
toString(XorValue, 10,
true);
13881 S.
Diag(Loc, diag::warn_xor_used_as_pow_base_extra)
13882 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedExpr
13885 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
13888 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13889 << (
"0x2 ^ " + RHSStr) << SuggestXor;
13890 }
else if (LeftSideValue == 10) {
13891 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
13892 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
13893 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedValue
13895 S.
Diag(Loc, diag::note_xor_used_as_pow_silence)
13896 << (
"0xA ^ " + RHSStr) << SuggestXor;
13912 getLangOpts().getOpenCLCompatibleVersion() < 120 &&
13939 SemaRef.Diag(Loc, diag::err_matrix_logical_operations_supported_for_hlsl);
13955 bool IsCompAssign) {
13956 if (!IsCompAssign) {
13972 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
13974 if (
Context.hasSameType(LHSType, RHSType))
13975 return Context.getCommonSugaredType(LHSType, RHSType);
13981 if (LHSMatType && !RHSMatType) {
13989 if (!LHSMatType && RHSMatType) {
14001 bool IsCompAssign) {
14002 if (!IsCompAssign) {
14013 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
14015 if (LHSMatType && RHSMatType) {
14016 if (LHSMatType->getNumColumns() != RHSMatType->
getNumRows())
14019 if (
Context.hasSameType(LHSMatType, RHSMatType))
14020 return Context.getCommonSugaredType(
14024 QualType LHSELTy = LHSMatType->getElementType(),
14026 if (!
Context.hasSameType(LHSELTy, RHSELTy))
14029 return Context.getConstantMatrixType(
14030 Context.getCommonSugaredType(LHSELTy, RHSELTy),
14055 bool IsCompAssign =
14056 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
14065 LHS, RHS, Loc, IsCompAssign,
14068 LegalBoolVecOperator);
14097 ExprResult LHSResult = LHS, RHSResult = RHS;
14099 LHSResult, RHSResult, Loc,
14101 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
14103 LHS = LHSResult.
get();
14104 RHS = RHSResult.
get();
14129 bool EnumConstantInBoolContext =
false;
14131 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
14132 const auto *ECDHS = dyn_cast<EnumConstantDecl>(DREHS->getDecl());
14133 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
14134 EnumConstantInBoolContext =
true;
14138 if (EnumConstantInBoolContext)
14139 Diag(Loc, diag::warn_enum_constant_in_bool_context);
14144 const auto *LHSATy = dyn_cast<ArrayType>(LHSTy);
14145 const auto *RHSATy = dyn_cast<ArrayType>(RHSTy);
14146 if ((LHSATy && LHSATy->getElementType().isWebAssemblyReferenceType()) ||
14147 (RHSATy && RHSATy->getElementType().isWebAssemblyReferenceType())) {
14169 Diag(Loc, diag::warn_logical_instead_of_bitwise)
14172 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
14173 << (Opc == BO_LAnd ?
"&" :
"|")
14176 Opc == BO_LAnd ?
"&" :
"|");
14177 if (Opc == BO_LAnd)
14179 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
14187 if (!
Context.getLangOpts().CPlusPlus) {
14190 if (
Context.getLangOpts().OpenCL &&
14191 Context.getLangOpts().OpenCLVersion < 120) {
14246 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
14247 if (!ME)
return false;
14251 if (!
Base)
return false;
14252 return Base->getMethodDecl() !=
nullptr;
14276 assert(S.
getLangOpts().CPlusPlus &&
"BindingDecl outside of C++?");
14287 assert(Var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
14295 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
14337 bool DiagnosticEmitted =
false;
14341 bool IsDereference =
false;
14342 bool NextIsDereference =
false;
14346 IsDereference = NextIsDereference;
14349 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
14350 NextIsDereference = ME->isArrow();
14351 const ValueDecl *VD = ME->getMemberDecl();
14352 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
14354 if (Field->isMutable()) {
14355 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
14360 if (!DiagnosticEmitted) {
14361 S.
Diag(Loc, diag::err_typecheck_assign_const)
14363 << Field->getType();
14364 DiagnosticEmitted =
true;
14367 <<
ConstMember <<
false << Field << Field->getType()
14368 << Field->getSourceRange();
14372 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
14373 if (VDecl->getType().isConstQualified()) {
14374 if (!DiagnosticEmitted) {
14375 S.
Diag(Loc, diag::err_typecheck_assign_const)
14377 << VDecl->getType();
14378 DiagnosticEmitted =
true;
14381 <<
ConstMember <<
true << VDecl << VDecl->getType()
14382 << VDecl->getSourceRange();
14389 dyn_cast<ArraySubscriptExpr>(E)) {
14393 dyn_cast<ExtVectorElementExpr>(E)) {
14400 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
14404 if (!DiagnosticEmitted) {
14405 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
14407 DiagnosticEmitted =
true;
14410 diag::note_typecheck_assign_const)
14414 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
14416 if (
const ValueDecl *VD = DRE->getDecl()) {
14418 if (!DiagnosticEmitted) {
14419 S.
Diag(Loc, diag::err_typecheck_assign_const)
14421 DiagnosticEmitted =
true;
14423 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
14424 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
14429 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
14430 if (MD->isConst()) {
14431 if (!DiagnosticEmitted) {
14432 S.
Diag(Loc, diag::err_typecheck_assign_const_method)
14433 << ExprRange << MD;
14434 DiagnosticEmitted =
true;
14436 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const_method)
14437 << MD << MD->getSourceRange();
14443 if (DiagnosticEmitted)
14447 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
14457 const RecordType *Ty,
14460 bool &DiagnosticEmitted) {
14461 std::vector<const RecordType *> RecordTypeList;
14462 RecordTypeList.push_back(Ty);
14463 unsigned NextToCheckIndex = 0;
14466 while (RecordTypeList.size() > NextToCheckIndex) {
14467 bool IsNested = NextToCheckIndex > 0;
14468 for (
const FieldDecl *Field : RecordTypeList[NextToCheckIndex]
14470 ->getDefinitionOrSelf()
14473 QualType FieldTy = Field->getType();
14475 if (!DiagnosticEmitted) {
14476 S.
Diag(Loc, diag::err_typecheck_assign_const)
14478 << IsNested << Field;
14479 DiagnosticEmitted =
true;
14481 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
14483 << FieldTy << Field->getSourceRange();
14488 if (
const auto *FieldRecTy = FieldTy->
getAsCanonical<RecordType>()) {
14489 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
14490 RecordTypeList.push_back(FieldRecTy);
14493 ++NextToCheckIndex;
14502 assert(Ty->
isRecordType() &&
"lvalue was not record?");
14505 bool DiagEmitted =
false;
14507 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
14510 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
14535 unsigned DiagID = 0;
14536 bool NeedType =
false;
14543 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
14545 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
14558 if (var->isARCPseudoStrong() &&
14559 (!var->getTypeSourceInfo() ||
14560 !var->getTypeSourceInfo()->getType().isConstQualified())) {
14566 ? diag::err_typecheck_arc_assign_self_class_method
14567 : diag::err_typecheck_arc_assign_self;
14570 }
else if (var->hasAttr<ObjCExternallyRetainedAttr>() ||
14572 DiagID = diag::err_typecheck_arc_assign_externally_retained;
14576 DiagID = diag::err_typecheck_arr_assign_enumeration;
14580 if (Loc != OrigLoc)
14606 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
14610 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
14614 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
14617 llvm_unreachable(
"did not take early return for MLV_Valid");
14621 if (
const auto *UnaryOp = dyn_cast<UnaryOperator>(E)) {
14623 if (UnaryOp->getOpcode() == UO_Imag &&
14625 DiagID = diag::err_typecheck_lvalue_imag_not_modifiable_lvalue;
14631 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
14637 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
14639 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
14642 DiagID = diag::err_typecheck_duplicate_matrix_components_not_mlvalue;
14645 llvm_unreachable(
"readonly properties should be processed differently");
14647 DiagID = diag::err_readonly_message_assignment;
14650 DiagID = diag::err_no_subobject_property_setting;
14655 if (Loc != OrigLoc)
14677 MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
14678 MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
14686 if (LHSDecl != RHSDecl)
14691 if (RefTy->getPointeeType().isVolatileQualified())
14694 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
14704 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
14728 bool ShowFullyQualifiedAssigneeName =
false;
14731 Assignee = DR->getDecl();
14732 }
else if (
auto *ME = dyn_cast<MemberExpr>(LHSExpr->
IgnoreParenCasts())) {
14733 Assignee = ME->getMemberDecl();
14734 ShowFullyQualifiedAssigneeName =
true;
14739 ShowFullyQualifiedAssigneeName);
14748 Diag(Loc, diag::err_opencl_half_load_store) << 1
14755 Diag(Loc, diag::err_wasm_table_art) << 0;
14760 if (CompoundType.
isNull()) {
14771 ((
Context.isObjCNSObjectType(LHSType) &&
14773 (
Context.isObjCNSObjectType(RHSType) &&
14778 Diag(Loc, diag::err_objc_object_assignment) << LHSType;
14784 RHSCheck = ICE->getSubExpr();
14785 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
14786 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
14787 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
14793 UO->getSubExpr()->getBeginLoc().
isFileID()) {
14794 Diag(Loc, diag::warn_not_compound_assign)
14795 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
14796 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
14806 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
14822 if (!
Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
14845 if (CompoundType.
isNull()) {
14871 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
14872 if (CE->getCastKind() == CK_ToVoid) {
14878 CE->getSubExpr()->getType()->isDependentType()) {
14883 if (
const auto *CE = dyn_cast<CallExpr>(E))
14884 return CE->getCallReturnType(Context)->isVoidType();
14908 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
14909 if (BO->getOpcode() != BO_Comma)
14911 LHS = BO->getRHS();
14918 Diag(Loc, diag::warn_comma_operator);
14922 LangOpts.CPlusPlus ?
"static_cast<void>("
14954 diag::err_incomplete_type);
14975 ResType = ResAtomicType->getValueType();
14977 assert(!ResType.
isNull() &&
"no type for increment/decrement expression");
14987 : diag::warn_increment_bool)
14991 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
15009 S.
DiagCompat(OpLoc, diag_compat::increment_complex)
15026 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
15037 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
15038 << IsInc << ResType;
15070 case Stmt::DeclRefExprClass:
15072 case Stmt::MemberExprClass:
15080 case Stmt::ArraySubscriptExprClass: {
15085 if (ICE->getSubExpr()->getType()->isArrayType())
15090 case Stmt::UnaryOperatorClass: {
15102 case Stmt::ParenExprClass:
15104 case Stmt::ImplicitCastExprClass:
15108 case Stmt::CXXUuidofExprClass:
15118 AO_Vector_Element = 1,
15119 AO_Property_Expansion = 2,
15120 AO_Register_Variable = 3,
15121 AO_Matrix_Element = 4,
15139 return Diag(OpLoc, diag::err_parens_pointer_member_function)
15144 return Diag(OpLoc, diag::err_typecheck_addrof_dtor)
15145 << DRE->getSourceRange();
15147 if (DRE->getQualifier())
15151 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
15152 << DRE->getSourceRange();
15155 StringRef Qual = (MD->
getParent()->getName() +
"::").toStringRef(Str);
15156 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
15157 << DRE->getSourceRange()
15163 if (PTy->getKind() == BuiltinType::Overload) {
15167 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
15175 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
15183 if (PTy->getKind() == BuiltinType::UnknownAny)
15186 if (PTy->getKind() == BuiltinType::BoundMember) {
15187 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
15210 auto* VarRef = dyn_cast<DeclRefExpr>(op);
15211 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
15212 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
15220 if (uOp->getOpcode() == UO_Deref)
15223 return uOp->getSubExpr()->getType();
15230 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
15236 unsigned AddressOfError = AO_No_Error;
15240 Diag(OpLoc, IsError ? diag::err_typecheck_addrof_temporary
15241 : diag::ext_typecheck_addrof_temporary)
15256 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
15274 auto ReturnOrParamTypeIsIncomplete = [&](
QualType T,
15279 diag::note_ptrauth_virtual_function_pointer_incomplete_arg_ret);
15280 Diag(RetArgTypeLoc,
15281 diag::note_ptrauth_virtual_function_incomplete_arg_ret_type)
15288 bool IsIncomplete =
15290 ReturnOrParamTypeIsIncomplete(
15293 IsIncomplete |= ReturnOrParamTypeIsIncomplete(PVD->getType(), OpLoc,
15294 PVD->getBeginLoc());
15300 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
15309 AddressOfError = AO_Property_Expansion;
15311 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
15315 }
else if (
const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
15316 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(DRE->getDecl()))
15322 AddressOfError = AO_Bit_Field;
15325 AddressOfError = AO_Vector_Element;
15328 AddressOfError = AO_Matrix_Element;
15332 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
15337 AddressOfError = AO_Register_Variable;
15340 AddressOfError = AO_Property_Expansion;
15353 if (
auto *DRE = dyn_cast<DeclRefExpr>(op);
15359 diag::err_cannot_form_pointer_to_member_of_reference_type)
15370 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
15378 llvm_unreachable(
"Unknown/unexpected decl type");
15381 if (AddressOfError != AO_No_Error) {
15398 if (
Context.getTargetInfo().getTriple().isWasm()) {
15401 Diag(OpLoc, diag::err_wasm_ca_reference)
15406 Diag(OpLoc, diag::err_wasm_table_pr)
15412 CheckAddressOfPackedMember(op);
15418 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp);
15424 const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
15427 if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
15428 if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
15431 FD->ModifiedNonNullParams.insert(Param);
15437 bool IsAfterAmp =
false) {
15441 Op = ConvResult.
get();
15453 Result = PT->getPointeeType();
15457 Result = OPT->getPointeeType();
15461 if (PR.
get() != Op)
15466 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
15471 if (
Result->isVoidType()) {
15477 S.
Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
15480 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
15497 default: llvm_unreachable(
"Unknown binop!");
15498 case tok::periodstar: Opc = BO_PtrMemD;
break;
15499 case tok::arrowstar: Opc = BO_PtrMemI;
break;
15500 case tok::star: Opc = BO_Mul;
break;
15501 case tok::slash: Opc = BO_Div;
break;
15502 case tok::percent: Opc = BO_Rem;
break;
15503 case tok::plus: Opc = BO_Add;
break;
15504 case tok::minus: Opc = BO_Sub;
break;
15505 case tok::lessless: Opc = BO_Shl;
break;
15506 case tok::greatergreater: Opc = BO_Shr;
break;
15507 case tok::lessequal: Opc = BO_LE;
break;
15508 case tok::less: Opc = BO_LT;
break;
15509 case tok::greaterequal: Opc = BO_GE;
break;
15510 case tok::greater: Opc = BO_GT;
break;
15511 case tok::exclaimequal: Opc = BO_NE;
break;
15512 case tok::equalequal: Opc = BO_EQ;
break;
15513 case tok::spaceship: Opc = BO_Cmp;
break;
15514 case tok::amp: Opc = BO_And;
break;
15515 case tok::caret: Opc = BO_Xor;
break;
15516 case tok::pipe: Opc = BO_Or;
break;
15517 case tok::ampamp: Opc = BO_LAnd;
break;
15518 case tok::pipepipe: Opc = BO_LOr;
break;
15519 case tok::equal: Opc = BO_Assign;
break;
15520 case tok::starequal: Opc = BO_MulAssign;
break;
15521 case tok::slashequal: Opc = BO_DivAssign;
break;
15522 case tok::percentequal: Opc = BO_RemAssign;
break;
15523 case tok::plusequal: Opc = BO_AddAssign;
break;
15524 case tok::minusequal: Opc = BO_SubAssign;
break;
15525 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
15526 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
15527 case tok::ampequal: Opc = BO_AndAssign;
break;
15528 case tok::caretequal: Opc = BO_XorAssign;
break;
15529 case tok::pipeequal: Opc = BO_OrAssign;
break;
15530 case tok::comma: Opc = BO_Comma;
break;
15539 default: llvm_unreachable(
"Unknown unary op!");
15540 case tok::plusplus: Opc = UO_PreInc;
break;
15541 case tok::minusminus: Opc = UO_PreDec;
break;
15542 case tok::amp: Opc = UO_AddrOf;
break;
15543 case tok::star: Opc = UO_Deref;
break;
15544 case tok::plus: Opc = UO_Plus;
break;
15545 case tok::minus: Opc = UO_Minus;
break;
15546 case tok::tilde: Opc = UO_Not;
break;
15547 case tok::exclaim: Opc = UO_LNot;
break;
15548 case tok::kw___real: Opc = UO_Real;
break;
15549 case tok::kw___imag: Opc = UO_Imag;
break;
15550 case tok::kw___extension__: Opc = UO_Extension;
break;
15582 llvm::find_if(Parent->
fields(),
15584 return F->getDeclName() == Name;
15586 return (Field != Parent->
field_end()) ? *Field :
nullptr;
15601 const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
15602 const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
15603 if (!LHSDeclRef || !RHSDeclRef ||
15611 if (LHSDecl != RHSDecl)
15616 if (RefTy->getPointeeType().isVolatileQualified())
15619 auto Diag = S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
15620 : diag::warn_self_assignment_overloaded)
15625 Diag << 1 << SelfAssignField
15638 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
15640 const Expr *RHS = R.get();
15643 ObjCPointerExpr = LHS;
15647 ObjCPointerExpr = RHS;
15656 unsigned Diag = diag::warn_objc_pointer_masking;
15665 if (SelArg0.starts_with(
"performSelector"))
15666 Diag = diag::warn_objc_pointer_masking_performSelector;
15683 assert((
isVector(ResultTy, Context.HalfTy) ||
15684 isVector(ResultTy, Context.ShortTy)) &&
15685 "Result must be a vector of half or short");
15688 "both operands expected to be a half vector");
15695 if (
isVector(ResultTy, Context.ShortTy))
15700 ResultTy,
VK, OK, OpLoc, FPFeatures,
15701 BinOpResTy, BinOpResTy);
15705 BinOpResTy,
VK, OK, OpLoc, FPFeatures);
15713 Expr *E1 =
nullptr) {
15714 if (!OpRequiresConversion || Ctx.
getLangOpts().NativeHalfType)
15723 auto HasVectorOfHalfType = [&Ctx](
Expr *E) {
15733 return VT->getElementType().getCanonicalType() == Ctx.
HalfTy;
15738 return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
15743 Expr *RHSExpr,
bool ForFoldExpression) {
15757 if (
Init.isInvalid())
15759 RHSExpr =
Init.get();
15769 bool ConvertHalfVec =
false;
15771 if (!LHS.
isUsable() || !RHS.isUsable())
15781 if (BO_Assign == Opc)
15782 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
15810 if (!ResultTy.
isNull()) {
15827 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
15829 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
15830 if (VD->hasLocalStorage() &&
getCurScope()->isDeclScope(VD))
15831 BE->getBlockDecl()->setCanAvoidCopyToHeap();
15842 Opc == BO_PtrMemI);
15846 ConvertHalfVec =
true;
15853 ConvertHalfVec =
true;
15857 ConvertHalfVec =
true;
15868 ConvertHalfVec =
true;
15871 if (
const auto *BI = dyn_cast<BinaryOperator>(LHSExpr);
15872 !ForFoldExpression && BI && BI->isComparisonOp())
15873 Diag(OpLoc, diag::warn_consecutive_comparison)
15879 ConvertHalfVec =
true;
15883 ConvertHalfVec =
true;
15896 ConvertHalfVec =
true;
15901 ConvertHalfVec =
true;
15903 CompLHSTy = CompResultTy;
15910 CompLHSTy = CompResultTy;
15916 ConvertHalfVec =
true;
15923 ConvertHalfVec =
true;
15932 CompLHSTy = CompResultTy;
15943 CompLHSTy = CompResultTy;
15951 VK = RHS.get()->getValueKind();
15952 OK = RHS.get()->getObjectKind();
15964 (Opc == BO_Comma ||
isVector(RHS.get()->getType(),
Context.HalfTy) ==
15966 "both sides are half vectors or neither sides are");
15968 LHS.
get(), RHS.get());
15971 CheckArrayAccess(LHS.
get());
15972 CheckArrayAccess(RHS.get());
15976 &
Context.Idents.get(
"object_setClass"),
15982 "object_setClass(")
15995 if (CompResultTy.
isNull()) {
15996 if (ConvertHalfVec)
16016 if (ConvertHalfVec)
16021 Context, LHS.
get(), RHS.get(), Opc, ResultTy,
VK, OK, OpLoc,
16038 if (isLeftComp == isRightComp)
16043 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
16044 bool isRightBitwise = RHSBO && RHSBO->
isBitwiseOp();
16045 if (isLeftBitwise || isRightBitwise)
16057 Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
16060 Self.PDiag(diag::note_precedence_silence) << OpStr,
16061 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
16063 Self.PDiag(diag::note_precedence_bitwise_first)
16078 Self.PDiag(diag::note_precedence_silence)
16087 if (Bop->getOpcode() == BO_LAnd) {
16092 }
else if (Bop->getOpcode() == BO_LOr) {
16093 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
16096 if (RBop->getOpcode() == BO_LAnd &&
16108 if (Bop->getOpcode() == BO_LAnd) {
16123 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
16124 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
16126 << Bop->getSourceRange() << OpLoc;
16128 S.
PDiag(diag::note_precedence_silence)
16129 << Bop->getOpcodeStr(),
16130 Bop->getSourceRange());
16136 Expr *SubExpr, StringRef Shift) {
16138 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
16139 StringRef Op = Bop->getOpcodeStr();
16140 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
16141 << Bop->getSourceRange() << OpLoc << Shift << Op;
16143 S.
PDiag(diag::note_precedence_silence) << Op,
16144 Bop->getSourceRange());
16160 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
16163 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
16165 << (Kind == OO_LessLess);
16167 S.
PDiag(diag::note_precedence_silence)
16168 << (Kind == OO_LessLess ?
"<<" :
">>"),
16171 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
16185 if ((Opc == BO_Or || Opc == BO_Xor) &&
16193 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
16199 || Opc == BO_Shr) {
16215 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
16216 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
16225 CheckInvalidBuiltinCountedByRef(LHSExpr, K);
16226 CheckInvalidBuiltinCountedByRef(RHSExpr, K);
16228 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
16234 if (OverOp !=
OO_None && OverOp != OO_Equal)
16283 Expr *RHSExpr,
bool ForFoldExpression) {
16284 if (!LHSExpr || !RHSExpr)
16296 if (pty->getKind() == BuiltinType::PseudoObject &&
16309 RHSExpr = resolvedRHS.
get();
16323 (pty->getKind() == BuiltinType::BoundMember ||
16324 pty->getKind() == BuiltinType::Overload)) {
16325 auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
16326 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
16327 llvm::any_of(OE->decls(), [](
NamedDecl *ND) {
16328 return isa<FunctionTemplateDecl>(ND);
16330 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
16331 : OE->getNameLoc(),
16332 diag::err_template_kw_missing)
16333 << OE->getName().getAsIdentifierInfo();
16340 LHSExpr = LHS.
get();
16347 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
16354 ForFoldExpression);
16364 RHSExpr = resolvedRHS.
get();
16370 if (!
HLSL().CheckResourceBinOp(Opc, LHSExpr, RHSExpr, OpLoc))
16373 std::optional<ExprResult> ConvRHS =
16375 if (ConvRHS &&
Context.hasSameUnqualifiedType(
16376 LHSExpr->
getType(), ConvRHS->get()->getType())) {
16377 assert(!ConvRHS->isInvalid());
16378 RHSExpr = ConvRHS->get();
16384 bool CanOverloadBinOp =
16388 bool TypeDependent =
16392 if (CanOverloadBinOp && (TypeDependent || Overloadable))
16400 "Should only occur in error-recovery path.");
16406 Context, LHSExpr, RHSExpr, Opc,
16426 ResultType = RHSExpr->
getType();
16429 ResultType =
Context.DependentTy;
16442 if (
T.isNull() ||
T->isDependentType())
16458 bool CanOverflow =
false;
16460 bool ConvertHalfVec =
false;
16469 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16476 if (Opc == UO_AddrOf)
16477 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0);
16478 if (Opc == UO_Deref)
16479 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1);
16484 resultType =
Context.DependentTy;
16493 Opc == UO_PreInc || Opc == UO_PostInc,
16494 Opc == UO_PreInc || Opc == UO_PreDec);
16499 CheckAddressOfNoDeref(InputExpr);
16512 CanOverflow = Opc == UO_Minus &&
16525 if (ConvertHalfVec)
16532 (!
Context.getLangOpts().ZVector ||
16542 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16553 Diag(OpLoc, diag::ext_integer_complement_complex)
16561 if (!
T->isIntegerType())
16562 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16565 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16581 resultType =
Context.FloatTy;
16587 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16597 if (
Context.getLangOpts().CPlusPlus) {
16602 }
else if (
Context.getLangOpts().OpenCL &&
16603 Context.getLangOpts().OpenCLVersion < 120) {
16607 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16620 Input.
get(), resultType,
16625 if (
Context.getLangOpts().OpenCL &&
16626 Context.getLangOpts().getOpenCLCompatibleVersion() < 120) {
16630 if (!
T->isIntegerType())
16631 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16637 }
else if (
Context.getLangOpts().CPlusPlus &&
16641 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16647 }
else if (resultType ==
Context.AMDGPUFeaturePredicateTy) {
16648 resultType =
Context.getLogicalOperationType();
16652 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
16658 resultType =
Context.getLogicalOperationType();
16686 "the co_await expression must be non-dependant before "
16687 "building operator co_await");
16698 if (Opc != UO_AddrOf && Opc != UO_Deref)
16699 CheckArrayAccess(Input.
get());
16705 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
16711 if (ConvertHalfVec)
16717 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
16718 if (!DRE->getQualifier())
16728 return Method->isImplicitObjectMemberFunction();
16734 if (!ULE->getQualifier())
16739 if (
Method->isImplicitObjectMemberFunction())
16760 if (pty->getKind() == BuiltinType::PseudoObject &&
16765 if (Opc == UO_Extension)
16770 if (Opc == UO_AddrOf &&
16771 (pty->getKind() == BuiltinType::Overload ||
16772 pty->getKind() == BuiltinType::UnknownAny ||
16773 pty->getKind() == BuiltinType::BoundMember))
16798 Expr *Input,
bool IsAfterAmp) {
16808 OpLoc, LabLoc, TheDecl,
Context.getPointerType(
Context.VoidTy));
16842 assert(!
Cleanup.exprNeedsCleanups() &&
16843 "cleanups within StmtExpr not correctly bound!");
16853 bool StmtExprMayBindToTemp =
false;
16855 if (
const auto *LastStmt = dyn_cast<ValueStmt>(Compound->
body_back())) {
16856 if (
const Expr *
Value = LastStmt->getExprStmt()) {
16857 StmtExprMayBindToTemp =
true;
16865 Expr *ResStmtExpr =
16867 if (StmtExprMayBindToTemp)
16869 return ResStmtExpr;
16892 auto *Cast = dyn_cast<ImplicitCastExpr>(E);
16893 if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)
16894 return Cast->getSubExpr();
16915 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
16916 << ArgTy << TypeRange);
16922 diag::err_offsetof_incomplete_type, TypeRange))
16925 bool DidWarnAboutNonPOD =
false;
16941 CurrentType =
Context.DependentTy;
16959 Exprs.push_back(Idx);
16971 CurrentType =
Context.DependentTy;
16977 diag::err_offsetof_incomplete_type))
16994 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
16996 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
16997 : diag::ext_offsetof_non_pod_type;
17000 Diag(BuiltinLoc, DiagID)
17003 DidWarnAboutNonPOD =
true;
17014 MemberDecl = IndirectMemberDecl->getAnonField();
17021 if (!R.isAmbiguous())
17022 Diag(BuiltinLoc, diag::err_no_member)
17039 if (IndirectMemberDecl)
17046 Context.getCanonicalTagType(Parent), Paths)) {
17048 Diag(D.
getEndLoc(), diag::err_offsetof_field_of_virtual_base)
17058 if (IndirectMemberDecl) {
17059 for (
auto *FI : IndirectMemberDecl->chain()) {
17071 Comps, Exprs, RParenLoc);
17095 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
17100 bool CondIsTrue =
false;
17102 resType =
Context.DependentTy;
17105 llvm::APSInt condEval(32);
17107 CondExpr, &condEval, diag::err_typecheck_choose_expr_requires_constant);
17110 CondExpr = CondICE.
get();
17111 CondIsTrue = condEval.getZExtValue();
17114 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
17116 resType = ActiveExpr->
getType();
17122 resType,
VK, OK, RPLoc, CondIsTrue);
17134 Decl *ManglingContextDecl;
17135 std::tie(MCtx, ManglingContextDecl) =
17139 Block->setBlockMangling(ManglingNumber, ManglingContextDecl);
17161 "block-id should have no identifier!");
17172 assert(
T->isFunctionType() &&
17173 "GetTypeForDeclarator made a non-function block signature");
17189 unsigned Size =
Result.getFullDataSize();
17190 Sig =
Context.CreateTypeSourceInfo(
Result.getType(), Size);
17201 QualType RetTy = Fn->getReturnType();
17211 if (RetTy !=
Context.DependentTy) {
17219 if (ExplicitSignature) {
17220 for (
unsigned I = 0, E = ExplicitSignature.
getNumParams(); I != E; ++I) {
17222 if (Param->getIdentifier() ==
nullptr && !Param->isImplicit() &&
17226 Diag(Param->getLocation(), diag::ext_parameter_name_omitted_c23);
17228 Params.push_back(Param);
17234 for (
const auto &I : Fn->param_types()) {
17237 Params.push_back(Param);
17242 if (!Params.empty()) {
17253 AI->setOwningFunction(CurBlock->
TheDecl);
17256 if (AI->getIdentifier()) {
17262 if (AI->isInvalidDecl())
17281 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
17286 assert(!
Cleanup.exprNeedsCleanups() &&
17287 "cleanups within block not correctly bound!");
17302 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
17310 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
17316 BlockTy =
Context.getFunctionType(RetTy, {}, EPI);
17337 BlockTy =
Context.getFunctionType(RetTy, {}, EPI);
17341 BlockTy =
Context.getBlockPointerType(BlockTy);
17345 !
PP.isCodeCompletionEnabled())
17350 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
17376 Expr *CopyExpr =
nullptr;
17403 if (!
Result.isInvalid() &&
17404 !
Result.get()->getType().isConstQualified()) {
17406 Result.get()->getType().withConst(),
17410 if (!
Result.isInvalid()) {
17420 if (!
Result.isInvalid() &&
17424 CopyExpr =
Result.get();
17431 Captures.push_back(NewCap);
17445 if (
Result->getBlockDecl()->hasCaptures()) {
17448 Cleanup.setExprNeedsCleanups(
true);
17452 for (
const auto &CI :
Result->getBlockDecl()->captures()) {
17453 const VarDecl *var = CI.getVariable();
17468 {Result},
Result->getType());
17482 Expr *OrigExpr = E;
17496 Context.getTargetInfo().getTriple().isNVPTX())
17523 "__builtin_zos_va_list must be an array type");
17528 VaListType = ZOSVaListType;
17537 VaListType =
Context.getArrayDecayedType(VaListType);
17549 if (
Init.isInvalid())
17565 diag::err_first_argument_to_va_arg_not_of_type_va_list)
17570 diag::err_second_parameter_to_va_arg_incomplete,
17576 diag::err_second_parameter_to_va_arg_abstract,
17583 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
17584 : diag::warn_second_parameter_to_va_arg_not_pod)
17591 PDiag(diag::warn_second_parameter_to_va_arg_array)
17624 UnderlyingType = ED->getIntegerType();
17625 if (
Context.typesAreCompatible(PromoteType, UnderlyingType,
17638 ?
Context.getCorrespondingSignedType(UnderlyingType)
17639 :
Context.getCorrespondingUnsignedType(UnderlyingType);
17640 if (
Context.typesAreCompatible(PromoteType, UnderlyingType,
17646 PromoteType =
Context.DoubleTy;
17647 if (!PromoteType.
isNull())
17649 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
17664 if (pw ==
Context.getTargetInfo().getIntWidth())
17666 else if (pw ==
Context.getTargetInfo().getLongWidth())
17668 else if (pw ==
Context.getTargetInfo().getLongLongWidth())
17671 llvm_unreachable(
"I don't know size of pointer!");
17688 if ((SLDecl->isCompleteDefinition() || SLDecl->isBeingDefined()) &&
17697 S.
Diag(Loc, diag::err_std_source_location_impl_not_found);
17705 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17709 unsigned Count = 0;
17711 StringRef Name = F->getName();
17713 if (Name ==
"_M_file_name") {
17714 if (F->getType() !=
17718 }
else if (Name ==
"_M_function_name") {
17719 if (F->getType() !=
17723 }
else if (Name ==
"_M_line") {
17724 if (!F->getType()->isIntegerType())
17727 }
else if (Name ==
"_M_column") {
17728 if (!F->getType()->isIntegerType())
17737 S.
Diag(Loc, diag::err_std_source_location_impl_malformed);
17760 ResultTy =
Context.UnsignedIntTy;
17769 ResultTy =
Context.getPointerType(
17788 Data->BinaryData = BinaryData;
17792 Data->getDataElementCount());
17796 const Expr *SrcExpr) {
17805 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
17818 bool *Complained) {
17820 *Complained =
false;
17823 bool CheckInferredResultType =
false;
17825 unsigned DiagKind = 0;
17827 bool MayHaveConvFixit =
false;
17828 bool MayHaveFunctionDiff =
false;
17839 DiagKind = diag::warn_compatible_implicit_pointer_conv;
17843 DiagKind = diag::err_typecheck_convert_pointer_int;
17846 DiagKind = diag::ext_typecheck_convert_pointer_int;
17849 MayHaveConvFixit =
true;
17853 DiagKind = diag::err_typecheck_convert_int_pointer;
17856 DiagKind = diag::ext_typecheck_convert_int_pointer;
17859 MayHaveConvFixit =
true;
17863 diag::warn_typecheck_convert_incompatible_function_pointer_strict;
17865 MayHaveConvFixit =
true;
17869 DiagKind = diag::err_typecheck_convert_incompatible_function_pointer;
17872 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
17875 MayHaveConvFixit =
true;
17879 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
17881 DiagKind = diag::err_typecheck_convert_incompatible_pointer;
17884 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
17888 if (CheckInferredResultType) {
17894 MayHaveConvFixit =
true;
17898 DiagKind = diag::err_typecheck_convert_incompatible_pointer_sign;
17901 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
17906 DiagKind = diag::err_typecheck_convert_pointer_void_func;
17909 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
17915 SrcType =
Context.getDecayedType(SrcType);
17922 DiagKind = diag::err_typecheck_incompatible_address_space;
17925 DiagKind = diag::err_typecheck_incompatible_ownership;
17928 DiagKind = diag::err_typecheck_incompatible_ptrauth;
17932 llvm_unreachable(
"unknown error case for discarding qualifiers!");
17937 SrcType =
Context.getArrayDecayedType(SrcType);
17939 DiagKind = diag::ext_typecheck_convert_discards_overflow_behavior;
17955 DiagKind = diag::err_typecheck_convert_discards_qualifiers;
17958 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
17965 DiagKind = diag::err_nested_pointer_qualifier_mismatch;
17967 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
17971 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
17975 DiagKind = diag::err_int_to_block_pointer;
17979 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
17986 for (
auto *srcProto : srcOPT->
quals()) {
17992 IFace = IFaceT->getDecl();
17997 for (
auto *dstProto : dstOPT->
quals()) {
18003 IFace = IFaceT->getDecl();
18006 DiagKind = diag::err_incompatible_qualified_id;
18009 DiagKind = diag::warn_incompatible_qualified_id;
18015 DiagKind = diag::err_incompatible_vectors;
18018 DiagKind = diag::warn_incompatible_vectors;
18022 DiagKind = diag::err_arc_weak_unavailable_assign;
18029 "Unexpected function type found in IncompatibleOBTKinds assignment");
18031 SrcType =
Context.getDecayedType(SrcType);
18033 auto getOBTKindName = [](
QualType Ty) -> StringRef {
18034 if (Ty->isPointerType())
18035 Ty = Ty->getPointeeType();
18036 if (
const auto *OBT = Ty->getAs<OverflowBehaviorType>()) {
18037 return OBT->getBehaviorKind() ==
18038 OverflowBehaviorType::OverflowBehaviorKind::Trap
18042 llvm_unreachable(
"OBT kind unhandled");
18045 Diag(Loc, diag::err_incompatible_obt_kinds_assignment)
18046 << DstType << SrcType << getOBTKindName(DstType)
18047 << getOBTKindName(SrcType);
18054 *Complained =
true;
18058 DiagKind = diag::err_typecheck_convert_incompatible;
18060 MayHaveConvFixit =
true;
18062 MayHaveFunctionDiff =
true;
18071 FirstType = DstType;
18072 SecondType = SrcType;
18082 FirstType = SrcType;
18083 SecondType = DstType;
18092 FDiag << FirstType << SecondType << ActionForDiag
18095 if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign ||
18096 DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {
18106 if (!ConvHints.
isNull()) {
18111 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
18113 if (MayHaveFunctionDiff)
18117 if ((DiagKind == diag::warn_incompatible_qualified_id ||
18118 DiagKind == diag::err_incompatible_qualified_id) &&
18120 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
18123 if (SecondType ==
Context.OverloadTy)
18127 if (CheckInferredResultType)
18135 *Complained =
true;
18146 return S.
Diag(Loc, diag::err_ice_not_integral)
18150 return S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus;
18165 IDDiagnoser(
unsigned DiagID)
18169 return S.
Diag(Loc, DiagID);
18171 } Diagnoser(DiagID);
18184 return S.
Diag(Loc, diag::ext_expr_not_ice) << S.
LangOpts.CPlusPlus;
18206 BaseDiagnoser(BaseDiagnoser) {}
18215 return S.
Diag(Loc, diag::err_ice_incomplete_type) <<
T;
18220 return S.
Diag(Loc, diag::err_ice_explicit_conversion) <<
T << ConvTy;
18231 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) <<
T;
18242 llvm_unreachable(
"conversion functions are permitted");
18244 } ConvertDiagnoser(Diagnoser);
18250 E = Converted.
get();
18271 E = RValueExpr.
get();
18289 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
18290 diag::note_invalid_subexpr_in_const_expr) {
18291 DiagLoc = Notes[0].first;
18314 EvalResult.
Diag = &Notes;
18329 if (!MSWarning.empty()) {
18333 for (
auto &Info : MSWarning)
18334 Diag(Info.first, Info.second);
18350 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
18351 diag::note_invalid_subexpr_in_const_expr) {
18352 DiagLoc = Notes[0].first;
18378 class TransformToPE :
public TreeTransform<TransformToPE> {
18382 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
18385 bool AlwaysRebuild() {
return true; }
18386 bool ReplacingOriginal() {
return true; }
18395 ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
18397 !SemaRef.isUnevaluatedContext())
18399 diag::err_invalid_non_static_member_use)
18402 return BaseTransform::TransformDeclRefExpr(E);
18406 ExprResult TransformUnaryOperator(UnaryOperator *E) {
18410 return BaseTransform::TransformUnaryOperator(E);
18418 return SkipLambdaBody(E, Body);
18425 "Should only transform unevaluated expressions");
18430 return TransformToPE(*this).TransformExpr(E);
18435 "Should only transform unevaluated expressions");
18439 return TransformToPE(*this).TransformType(TInfo);
18447 LambdaContextDecl, ExprContext);
18461 Prev.isImmediateFunctionContext() || Prev.isConstantEvaluated();
18464 Prev.InImmediateEscalatingFunctionContext;
18532 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
18533 if (E->getOpcode() == UO_Deref)
18534 return CheckPossibleDeref(S, E->getSubExpr());
18535 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
18536 return CheckPossibleDeref(S, E->getBase());
18537 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
18538 return CheckPossibleDeref(S, E->getBase());
18539 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
18542 if (
const auto *Ptr = Ty->
getAs<PointerType>())
18543 Inner =
Ptr->getPointeeType();
18545 Inner = Arr->getElementType();
18549 if (Inner->
hasAttr(attr::NoDeref))
18559 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
18566 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
18581 if (BO->getOpcode() == BO_Assign) {
18583 llvm::erase(LHSs, BO->getLHS());
18591 "Cannot mark an immediate escalating expression outside of an "
18592 "immediate escalating context");
18595 if (
auto *DeclRef =
18596 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
18597 DeclRef->setIsImmediateEscalating(
true);
18598 }
else if (
auto *Ctr = dyn_cast<CXXConstructExpr>(E->
IgnoreImplicit())) {
18599 Ctr->setIsImmediateEscalating(
true);
18600 }
else if (
auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreImplicit())) {
18601 DeclRef->setIsImmediateEscalating(
true);
18603 assert(
false &&
"expected an immediately escalating expression");
18606 FI->FoundImmediateEscalatingExpression =
true;
18621 if (
auto *DeclRef =
18622 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
18631 auto CheckConstantExpressionAndKeepResult = [&]() {
18634 Eval,
getASTContext(), ConstantExprKind::ImmediateInvocation);
18636 Cached = std::move(Eval.
Val);
18644 !CheckConstantExpressionAndKeepResult()) {
18649 if (
Cleanup.exprNeedsCleanups()) {
18666 Cleanup.cleanupsHaveSideEffects(), {});
18679 ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
18687 Eval.
Diag = &Notes;
18691 if (!
Result || !Notes.empty()) {
18694 if (
auto *
FunctionalCast = dyn_cast<CXXFunctionalCastExpr>(InnerExpr))
18697 if (
auto *
Call = dyn_cast<CallExpr>(InnerExpr))
18699 else if (
auto *
Call = dyn_cast<CXXConstructExpr>(InnerExpr))
18700 FD =
Call->getConstructor();
18701 else if (
auto *Cast = dyn_cast<CastExpr>(InnerExpr))
18702 FD = dyn_cast_or_null<FunctionDecl>(Cast->getConversionFunction());
18705 "could not find an immediate function in this expression");
18712 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
18714 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
18718 for (
auto &
Note : Notes)
18730 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18734 ComplexRemove(
Sema &SemaRef, llvm::SmallPtrSetImpl<DeclRefExpr *> &DR,
18738 :
Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
18740 auto It = std::find_if(CurrentII, IISet.rend(),
18742 return Elem.getPointer() == E;
18748 if (It == IISet.rend()) {
18750 CurrentII->setInt(1);
18757 return Base::TransformConstantExpr(E);
18758 RemoveImmediateInvocation(E);
18759 return Base::TransformExpr(E->
getSubExpr());
18765 return Base::TransformCXXOperatorCallExpr(E);
18779 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(
Init))
18780 Init = ICE->getSubExpr();
18781 else if (
auto *ICE = dyn_cast<MaterializeTemporaryExpr>(
Init))
18782 Init = ICE->getSubExpr();
18788 if (
auto *CE = dyn_cast<ConstantExpr>(
Init);
18789 CE && CE->isImmediateInvocation())
18790 RemoveImmediateInvocation(CE);
18791 return Base::TransformInitializer(
Init, NotCopyInit);
18807 bool AlwaysRebuild() {
return false; }
18808 bool ReplacingOriginal() {
return true; }
18809 bool AllowSkippingCXXConstructExpr() {
18810 bool Res = AllowSkippingFirstCXXConstructExpr;
18811 AllowSkippingFirstCXXConstructExpr =
true;
18814 bool AllowSkippingFirstCXXConstructExpr =
true;
18825 Transformer.AllowSkippingFirstCXXConstructExpr =
false;
18827 ExprResult Res = Transformer.TransformExpr(It->getPointer()->getSubExpr());
18833 It->getPointer()->setSubExpr(Res.
get());
18853 if (VD && (VD->isUsableInConstantExpressions(
SemaRef.
Context) ||
18854 VD->hasConstantInitialization())) {
18887 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
18888 SimpleRemove(llvm::SmallPtrSetImpl<DeclRefExpr *> &S) : DRSet(S) {}
18891 return DRSet.size();
18894 Visitor.TraverseStmt(
18904 if (DR->isImmediateEscalating())
18908 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND);
18910 ND = MD->getParent();
18917 bool ImmediateEscalating =
false;
18918 bool IsPotentiallyEvaluated =
18928 SemaRef.
Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
18929 << ND << isa<CXXRecordDecl>(ND) << FD->isConsteval();
18930 if (!FD->getBuiltinID())
18934 SemaRef.
Diag(Context->Loc, diag::note_invalid_consteval_initializer)
18936 SemaRef.
Diag(Context->Decl->getBeginLoc(), diag::note_declared_at);
18938 if (FD->isImmediateEscalating() && !FD->isConsteval())
18952 (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument ||
18960 D = diag::err_lambda_unevaluated_operand;
18966 D = diag::err_lambda_in_constant_expression;
18967 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
18970 D = diag::err_lambda_in_invalid_context;
18972 llvm_unreachable(
"Couldn't infer lambda error message.");
18974 for (
const auto *L : Rec.
Lambdas)
18975 Diag(L->getBeginLoc(), D);
18995 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
19066 llvm_unreachable(
"Invalid context");
19112 : FD(FD), Param(Param) {}
19119 CCName =
"stdcall";
19122 CCName =
"fastcall";
19125 CCName =
"vectorcall";
19128 llvm_unreachable(
"CC does not need mangling");
19131 S.
Diag(Loc, diag::err_cconv_incomplete_param_type)
19132 << Param->getDeclName() << FD->
getDeclName() << CCName;
19137 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
19143enum class OdrUseContext {
19162 if (Context.isUnevaluated())
19163 return OdrUseContext::None;
19166 return OdrUseContext::Dependent;
19168 if (Context.isDiscardedStatementContext())
19169 return OdrUseContext::FormallyOdrUsed;
19171 else if (Context.Context ==
19173 return OdrUseContext::FormallyOdrUsed;
19175 return OdrUseContext::Used;
19179 if (!
Func->isConstexpr())
19182 if (
Func->isImplicitlyInstantiable() || !
Func->isUserProvided())
19189 auto *CCD = dyn_cast<CXXConstructorDecl>(
Func);
19190 return CCD && CCD->getInheritedConstructor();
19194 bool MightBeOdrUse) {
19195 assert(
Func &&
"No function?");
19197 Func->setReferenced();
19210 OdrUseContext OdrUse =
19212 if (IsRecursiveCall && OdrUse == OdrUseContext::Used)
19213 OdrUse = OdrUseContext::FormallyOdrUsed;
19217 if (
Func->isTrivial() && !
Func->hasAttr<DLLExportAttr>() &&
19218 OdrUse == OdrUseContext::Used) {
19221 OdrUse = OdrUseContext::FormallyOdrUsed;
19223 OdrUse = OdrUseContext::FormallyOdrUsed;
19230 bool NeededForConstantEvaluation =
19255 bool NeedDefinition =
19256 !IsRecursiveCall &&
19257 (OdrUse == OdrUseContext::Used ||
19258 (NeededForConstantEvaluation && !
Func->isPureVirtual()));
19265 if (NeedDefinition &&
19267 Func->getMemberSpecializationInfo()))
19274 if (NeedDefinition && !
Func->getBody()) {
19277 dyn_cast<CXXConstructorDecl>(
Func)) {
19290 }
else if (
Constructor->getInheritedConstructor()) {
19294 dyn_cast<CXXDestructorDecl>(
Func)) {
19304 if (MethodDecl->isOverloadedOperator() &&
19305 MethodDecl->getOverloadedOperator() == OO_Equal) {
19307 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
19308 if (MethodDecl->isCopyAssignmentOperator())
19310 else if (MethodDecl->isMoveAssignmentOperator())
19314 MethodDecl->getParent()->isLambda()) {
19321 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
19325 if (
Func->isDefaulted() && !
Func->isDeleted()) {
19333 if (
Func->isImplicitlyInstantiable()) {
19335 Func->getTemplateSpecializationKindForInstantiation();
19337 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
19338 if (FirstInstantiation) {
19339 PointOfInstantiation = Loc;
19340 if (
auto *MSI =
Func->getMemberSpecializationInfo())
19341 MSI->setPointOfInstantiation(Loc);
19344 Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
19349 PointOfInstantiation = Loc;
19353 Func->isConstexpr()) {
19358 std::make_pair(
Func, PointOfInstantiation));
19359 else if (
Func->isConstexpr())
19365 Func->setInstantiationIsPending(
true);
19367 std::make_pair(
Func, PointOfInstantiation));
19368 if (llvm::isTimeTraceVerbose()) {
19369 llvm::timeTraceAddInstantEvent(
"DeferInstantiation", [&] {
19371 llvm::raw_string_ostream
OS(Name);
19378 Consumer.HandleCXXImplicitFunctionInstantiation(
Func);
19383 for (
auto *i :
Func->redecls()) {
19384 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
19402 if (
Init->isInClassMemberInitializer())
19404 MarkDeclarationsReferencedInExpr(Init->getInit());
19425 if (
LangOpts.OffloadImplicitHostDeviceTemplates &&
LangOpts.CUDAIsDevice &&
19430 if (OdrUse == OdrUseContext::Used && !
Func->isUsed(
false)) {
19432 if (!
Func->isDefined() && !
Func->isInAnotherModuleUnit()) {
19433 if (mightHaveNonExternalLinkage(
Func))
19435 else if (
Func->getMostRecentDecl()->isInlined() &&
19437 !
Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
19455 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
19456 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(
Func)) {
19476 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
19479 VarDecl *Var =
V->getPotentiallyDecomposedVarDecl();
19480 assert(Var &&
"expected a capturable variable");
19490 QualType CaptureType, DeclRefType;
19496 DeclRefType, FunctionScopeIndexToStopAt);
19511 << 2 << 1 << Var << UserTarget;
19514 ? diag::note_cuda_const_var_unpromoted
19515 : diag::note_cuda_host_var);
19524 Var->
hasAttr<CUDADeviceAttr>() &&
19525 !Var->
getAttr<CUDADeviceAttr>()->isImplicit())) &&
19526 !Var->
hasAttr<CUDASharedAttr>() &&
19542 (!FD || (!FD->getDescribedFunctionTemplate() &&
19554 unsigned CapturingScopeIndex) {
19562 var->getDeclContext()->getEnclosingNonExpansionStatementContext();
19582 unsigned ContextKind = 3;
19592 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
19593 << var << ValueKind << ContextKind << VarDC;
19594 S.
Diag(var->getLocation(), diag::note_entity_declared_at)
19603 bool &SubCapturesAreNested,
19609 SubCapturesAreNested =
true;
19662 "Only variables and structured bindings can be captured");
19669 if ((IsLambda || IsBlock) && S.
getLangOpts().OpenMP &&
19672 S.
Diag(Loc, diag::err_omp_unsupported_on_binding) << 3;
19682 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
19691 S.
Diag(Loc, diag::err_ref_vm_type);
19702 S.
Diag(Loc, diag::err_ref_flexarray_type);
19704 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type) << Var;
19709 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19714 S.
Diag(Loc, diag::err_capture_block_variable) << Var << !IsLambda;
19723 S.
Diag(Loc, diag::err_opencl_block_ref_block);
19727 if (
auto *BD = dyn_cast<BindingDecl>(Var)) {
19728 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
19730 if (BD->getHoldingVar()) {
19732 S.
Diag(Loc, diag::err_capture_tuple_binding_openmp) << Var;
19738 S.
DiagCompat(Loc, diag_compat::capture_binding) << Var;
19749 S.
DiagCompat(Loc, diag_compat::capture_binding) << Var;
19762 bool ByRef =
false;
19768 if (BuildAndDiagnose) {
19769 S.
Diag(Loc, diag::err_ref_array_type);
19780 if (BuildAndDiagnose) {
19781 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
19797 if (BuildAndDiagnose) {
19799 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
19800 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
19805 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
19814 DeclRefType = CaptureType;
19818 if (BuildAndDiagnose)
19828 const bool BuildAndDiagnose,
QualType &CaptureType,
QualType &DeclRefType,
19829 const bool RefersToCapturedVariable,
TryCaptureKind Kind,
bool IsTopScope,
19857 if (IsBindingDecl ? PrivateKind == OMPC_private
19858 : PrivateKind != OMPC_unknown)
19864 if (BuildAndDiagnose && IsBindingDecl) {
19866 if (Idx != 0 && RSI->
Captures[Idx - 1].isReferenceCapture() != ByRef) {
19868 diag::err_omp_decomposition_bindings_different_capture_kinds)
19878 CaptureType = DeclRefType;
19881 if (BuildAndDiagnose)
19882 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
19885 if (BuildAndDiagnose && IsBindingDecl)
19897 const bool RefersToCapturedVariable,
19902 bool ByRef =
false;
19906 ByRef = (LSI->
ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByref);
19911 S.
Diag(Loc, diag::err_wasm_ca_reference) << 0;
19942 if (!RefType->getPointeeType()->isFunctionType())
19949 if (BuildAndDiagnose) {
19950 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
19960 if (!
Invalid && BuildAndDiagnose) {
19964 diag::err_capture_of_incomplete_or_sizeless_type,
19968 diag::err_capture_of_abstract_type))
19994 if (BuildAndDiagnose)
19995 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
19996 Loc, EllipsisLoc, CaptureType,
Invalid);
20007 if (
T.isTriviallyCopyableType(Context))
20011 if (!(RD = RD->getDefinition()))
20013 if (RD->hasSimpleCopyConstructor())
20015 if (RD->hasUserDeclaredCopyConstructor())
20017 if (Ctor->isCopyConstructor())
20018 return !Ctor->isDeleted();
20038 if (ShouldOfferCopyFix) {
20042 FixBuffer.assign({Separator, Var->
getName()});
20043 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
20048 FixBuffer.assign({Separator,
"&", Var->
getName()});
20049 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
20061 return !C.isThisCapture() && !C.isInitCapture();
20070 if (ShouldOfferCopyFix) {
20071 bool CanDefaultCopyCapture =
true;
20080 if (CanDefaultCopyCapture && llvm::none_of(LSI->
Captures, [](
Capture &
C) {
20081 return !C.isThisCapture() && !C.isInitCapture() && C.isCopyCapture();
20083 FixBuffer.assign({
"=", Separator});
20084 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
20093 return !C.isInitCapture() && C.isReferenceCapture() &&
20094 !C.isThisCapture();
20096 FixBuffer.assign({
"&", Separator});
20097 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
20106 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
20130 const auto *VD = dyn_cast<VarDecl>(Var);
20132 if (VD->isInitCapture())
20137 assert(VD &&
"Cannot capture a null variable");
20139 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
20143 if (FunctionScopeIndexToStopAt) {
20144 assert(!
FunctionScopes.empty() &&
"No function scopes to stop at?");
20149 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(
FunctionScopes[FSIndex]);
20150 FSIndex && LSI && !LSI->AfterParameterList)
20152 assert(MaxFunctionScopesIndex <= FSIndex &&
20153 "FunctionScopeIndexToStopAt should be no greater than FSIndex into "
20154 "FunctionScopes.");
20155 while (FSIndex != MaxFunctionScopesIndex) {
20163 bool IsGlobal = !VD->hasLocalStorage();
20164 if (IsGlobal && !(
LangOpts.OpenMP &&
20165 OpenMP().isOpenMPCapturedDecl(Var,
true,
20166 MaxFunctionScopesIndex)))
20180 CaptureType = Var->
getType();
20182 bool Nested =
false;
20184 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
20189 LSI = dyn_cast_or_null<LambdaScopeInfo>(
20192 bool IsInScopeDeclarationContext =
20203 if (IsInScopeDeclarationContext &&
20204 FunctionScopesIndex == MaxFunctionScopesIndex && VarDC == DC)
20210 !IsInScopeDeclarationContext
20213 BuildAndDiagnose, *
this);
20219 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
20238 if (
const auto *Parm = dyn_cast<ParmVarDecl>(Var);
20239 Parm && Parm->getDeclContext() == DC)
20247 if (BuildAndDiagnose) {
20250 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
20265 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
20266 QTy = PVD->getOriginalType();
20271 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
20277 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
20282 if (IsOpenMPPrivateDecl != OMPC_unknown &&
20285 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
20286 QTy = PVD->getOriginalType();
20288 E =
OpenMP().getNumberOfConstructScopes(RSI->OpenMPLevel);
20292 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
20293 "Wrong number of captured regions associated with the "
20294 "OpenMP construct.");
20299 IsOpenMPPrivateDecl != OMPC_private &&
20301 RSI->OpenMPCaptureLevel);
20305 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
20311 OpenMP().adjustOpenMPTargetScopeIndex(FunctionScopesIndex,
20314 if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
20315 (IsGlobal && !IsGlobalCap)) {
20316 Nested = !IsTargetCap;
20322 CaptureType =
Context.getLValueReferenceType(DeclRefType);
20331 if (BuildAndDiagnose) {
20332 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
20354 FunctionScopesIndex--;
20355 if (IsInScopeDeclarationContext)
20357 }
while (!VarDC->
Equals(DC));
20365 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
20378 if (
Invalid && !BuildAndDiagnose)
20383 DeclRefType, Nested, *
this,
Invalid);
20387 RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
20388 Kind, I == N - 1, *
this,
Invalid);
20394 DeclRefType, Nested, Kind, EllipsisLoc,
20399 if (
Invalid && !BuildAndDiagnose)
20411 DeclRefType,
nullptr);
20419 false, CaptureType, DeclRefType,
nullptr);
20423 assert(Var &&
"Null value cannot be captured");
20430 false, CaptureType, DeclRefType,
20434 return DeclRefType;
20442class CopiedTemplateArgs {
20446 template<
typename RefExpr>
20447 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
20449 E->copyTemplateArgumentsInto(TemplateArgStorage);
20452#ifdef __has_cpp_attribute
20453#if __has_cpp_attribute(clang::lifetimebound)
20454 [[clang::lifetimebound]]
20458 return HasArgs ? &TemplateArgStorage :
nullptr;
20484 auto Rebuild = [&](
Expr *Sub) {
20489 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
20492 auto *VD = dyn_cast<VarDecl>(D);
20515 llvm_unreachable(
"unexpected non-odr-use-reason");
20519 if (VD->getType()->isReferenceType())
20521 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
20522 if (RD->hasDefinition() && RD->hasMutableFields())
20524 if (!VD->isUsableInConstantExpressions(S.
Context))
20529 if (VD->getType()->isReferenceType())
20537 auto MaybeCUDAODRUsed = [&]() ->
bool {
20543 auto *DRE = dyn_cast<DeclRefExpr>(E);
20546 auto *VD = dyn_cast<VarDecl>(DRE->getDecl());
20553 auto MarkNotOdrUsed = [&] {
20554 if (!MaybeCUDAODRUsed()) {
20557 LSI->markVariableExprAsNonODRUsed(E);
20565 case Expr::DeclRefExprClass: {
20567 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
20573 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
20574 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
20575 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
20576 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
20579 case Expr::FunctionParmPackExprClass: {
20584 if (IsPotentialResultOdrUsed(D))
20595 case Expr::ArraySubscriptExprClass: {
20601 if (!
Base.isUsable())
20603 Expr *LHS = ASE->getBase() == ASE->getLHS() ?
Base.get() : ASE->getLHS();
20604 Expr *RHS = ASE->getBase() == ASE->getRHS() ?
Base.get() : ASE->getRHS();
20607 ASE->getRBracketLoc());
20610 case Expr::MemberExprClass: {
20616 if (!
Base.isUsable())
20619 S.
Context,
Base.get(), ME->isArrow(), ME->getOperatorLoc(),
20620 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
20621 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
20622 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
20623 ME->getObjectKind(), ME->isNonOdrUse());
20626 if (ME->getMemberDecl()->isCXXInstanceMember())
20631 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
20637 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
20638 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
20639 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
20640 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
20643 case Expr::BinaryOperatorClass: {
20645 Expr *LHS = BO->getLHS();
20646 Expr *RHS = BO->getRHS();
20648 if (BO->getOpcode() == BO_PtrMemD) {
20650 if (!Sub.isUsable())
20652 BO->setLHS(Sub.get());
20654 }
else if (BO->getOpcode() == BO_Comma) {
20656 if (!Sub.isUsable())
20658 BO->setRHS(Sub.get());
20666 case Expr::ParenExprClass: {
20669 if (!Sub.isUsable())
20671 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
20676 case Expr::ConditionalOperatorClass: {
20687 LHS = CO->getLHS();
20689 RHS = CO->getRHS();
20691 CO->getCond(), LHS.
get(), RHS.
get());
20696 case Expr::UnaryOperatorClass: {
20698 if (UO->getOpcode() != UO_Extension)
20701 if (!Sub.isUsable())
20703 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
20710 case Expr::GenericSelectionExprClass: {
20714 bool AnyChanged =
false;
20715 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
20716 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
20720 AssocExprs.push_back(AssocExpr.
get());
20723 AssocExprs.push_back(OrigAssocExpr);
20727 void *ExOrTy =
nullptr;
20728 bool IsExpr = GSE->isExprPredicate();
20730 ExOrTy = GSE->getControllingExpr();
20732 ExOrTy = GSE->getControllingType();
20734 GSE->getGenericLoc(), GSE->getDefaultLoc(),
20735 GSE->getRParenLoc(), IsExpr, ExOrTy,
20736 GSE->getAssocTypeSourceInfos(), AssocExprs)
20744 case Expr::ChooseExprClass: {
20755 if (!LHS.
get() && !RHS.
get())
20758 LHS = CE->getLHS();
20760 RHS = CE->getRHS();
20763 RHS.
get(), CE->getRParenLoc());
20767 case Expr::ConstantExprClass: {
20770 if (!Sub.isUsable())
20777 case Expr::ImplicitCastExprClass: {
20782 switch (ICE->getCastKind()) {
20784 case CK_DerivedToBase:
20785 case CK_UncheckedDerivedToBase: {
20786 ExprResult Sub = Rebuild(ICE->getSubExpr());
20787 if (!Sub.isUsable())
20791 ICE->getValueKind(), &Path);
20848 for (
Expr *E : LocalMaybeODRUseExprs) {
20849 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
20851 DRE->getLocation(), *
this);
20852 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
20855 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
20859 llvm_unreachable(
"Unexpected expression");
20864 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
20873 const bool RefersToEnclosingScope =
20876 if (RefersToEnclosingScope) {
20891 assert(E &&
"Capture variable should be used in an expression.");
20904 "Invalid Expr argument to DoMarkVarDeclReferenced");
20915 bool UsableInConstantExpr =
20934 bool NeededForConstantEvaluation =
20937 bool NeedDefinition =
20938 OdrUse == OdrUseContext::Used || NeededForConstantEvaluation ||
20940 Var->
getType()->isUndeducedType());
20943 "Can't instantiate a partial template specialization.");
20960 bool TryInstantiating =
20964 if (TryInstantiating) {
20967 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
20968 if (FirstInstantiation) {
20969 PointOfInstantiation = Loc;
20971 MSI->setPointOfInstantiation(PointOfInstantiation);
20993 if (
auto *DRE = dyn_cast_or_null<DeclRefExpr>(E))
20994 DRE->setDecl(DRE->getDecl());
20995 else if (
auto *ME = dyn_cast_or_null<MemberExpr>(E))
20996 ME->setMemberDecl(ME->getMemberDecl());
20997 }
else if (FirstInstantiation) {
20999 .push_back(std::make_pair(Var, PointOfInstantiation));
21001 bool Inserted =
false;
21003 auto Iter = llvm::find_if(
21005 return P.first == Var;
21007 if (Iter != I.end()) {
21022 .push_back(std::make_pair(Var, PointOfInstantiation));
21046 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
21047 if (DRE->isNonOdrUse())
21049 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
21050 if (ME->isNonOdrUse())
21054 case OdrUseContext::None:
21059 "missing non-odr-use marking for unevaluated decl ref");
21062 case OdrUseContext::FormallyOdrUsed:
21067 case OdrUseContext::Used:
21076 case OdrUseContext::Dependent:
21094 if (OdrUse == OdrUseContext::Used) {
21095 QualType CaptureType, DeclRefType;
21101 }
else if (OdrUse == OdrUseContext::Dependent) {
21117 auto *ID = dyn_cast<DeclRefExpr>(E);
21118 if (!ID || ID->isTypeDependent() || !ID->refersToEnclosingVariableOrCapture())
21125 auto IsDependent = [&]() {
21127 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
21132 LSI->AfterParameterList)
21135 const auto *MD = LSI->CallOperator;
21136 if (MD->getType().isNull())
21140 if (!Ty || !MD->isExplicitObjectMemberFunction() ||
21144 if (
auto *
C = LSI->CaptureMap.count(D) ? &LSI->getCapture(D) :
nullptr) {
21145 if (
C->isCopyCapture())
21150 if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
21156 ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
21162 bool MightBeOdrUse,
21170 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
21189 const MemberExpr *ME = dyn_cast<MemberExpr>(E);
21196 bool IsVirtualCall = MD->
isVirtual() &&
21198 if (!IsVirtualCall)
21215 bool OdrUse =
true;
21217 if (
Method->isVirtual() &&
21221 if (
auto *FD = dyn_cast<FunctionDecl>(E->
getDecl())) {
21226 !FD->isDependentContext())
21240 bool MightBeOdrUse =
true;
21243 if (
Method->isPureVirtual())
21244 MightBeOdrUse =
false;
21263 bool MightBeOdrUse) {
21264 if (MightBeOdrUse) {
21265 if (
auto *VD = dyn_cast<VarDecl>(D)) {
21270 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
21296bool MarkReferencedDecls::TraverseTemplateArgument(
21297 const TemplateArgument &Arg) {
21300 EnterExpressionEvaluationContext
Evaluated(
21314 MarkReferencedDecls Marker(*
this, Loc);
21315 Marker.TraverseType(
T);
21321class EvaluatedExprMarker :
public UsedDeclVisitor<EvaluatedExprMarker> {
21324 bool SkipLocalVariables;
21327 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables,
21329 : Inherited(S), SkipLocalVariables(SkipLocalVariables), StopAt(StopAt) {}
21335 void Visit(Expr *E) {
21336 if (llvm::is_contained(StopAt, E))
21338 Inherited::Visit(E);
21341 void VisitConstantExpr(ConstantExpr *E) {
21346 void VisitDeclRefExpr(DeclRefExpr *E) {
21348 if (SkipLocalVariables) {
21349 if (VarDecl *VD = dyn_cast<VarDecl>(E->
getDecl()))
21350 if (VD->hasLocalStorage())
21360 void VisitMemberExpr(MemberExpr *E) {
21368 bool SkipLocalVariables,
21370 EvaluatedExprMarker(*
this, SkipLocalVariables, StopAt).Visit(E);
21382 (
Decl->isConstexpr() || (
Decl->isStaticDataMember() &&
21386 if (Stmts.empty()) {
21397 if (
Diags.getIgnoreAllWarnings() &&
21408 if (
Decl &&
Decl->isFileVarDecl()) {
21481 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
21487 : FD(FD), CE(CE) { }
21491 S.
Diag(Loc, diag::err_call_incomplete_return)
21496 S.
Diag(Loc, diag::err_call_function_incomplete_return)
21501 } Diagnoser(FD, CE);
21514 unsigned diagnostic = diag::warn_condition_is_assignment;
21515 bool IsOrAssign =
false;
21518 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
21521 IsOrAssign = Op->getOpcode() == BO_OrAssign;
21529 if (
ObjC().isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
21530 diagnostic = diag::warn_condition_is_idiomatic_assignment;
21534 diagnostic = diag::warn_condition_is_idiomatic_assignment;
21537 Loc = Op->getOperatorLoc();
21539 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
21542 IsOrAssign = Op->getOperator() == OO_PipeEqual;
21543 Loc = Op->getOperatorLoc();
21555 Diag(Loc, diag::note_condition_assign_silence)
21560 Diag(Loc, diag::note_condition_or_assign_to_comparison)
21563 Diag(Loc, diag::note_condition_assign_to_comparison)
21581 if (opE->getOpcode() == BO_EQ &&
21582 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
21588 Diag(Loc, diag::note_equality_comparison_silence)
21591 Diag(Loc, diag::note_equality_comparison_to_assign)
21597 bool IsConstexpr) {
21599 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
21619 if (!
T->isScalarType()) {
21620 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
21624 CheckBoolLikeConversion(E, Loc);
21671 struct RebuildUnknownAnyFunction
21672 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
21676 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
21679 llvm_unreachable(
"unexpected statement!");
21690 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
21691 ExprResult SubResult = Visit(E->getSubExpr());
21694 Expr *SubExpr = SubResult.
get();
21695 E->setSubExpr(SubExpr);
21696 E->setType(SubExpr->
getType());
21703 return rebuildSugarExpr(E);
21706 ExprResult VisitUnaryExtension(UnaryOperator *E) {
21707 return rebuildSugarExpr(E);
21710 ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
21714 Expr *SubExpr = SubResult.
get();
21722 ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
21740 ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
21741 return resolveDecl(E, E->
getDecl());
21759 struct RebuildUnknownAnyExpr
21760 : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
21767 RebuildUnknownAnyExpr(Sema &S, QualType
CastType)
21771 llvm_unreachable(
"unexpected statement!");
21781 ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
21785 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
21786 ExprResult SubResult = Visit(E->getSubExpr());
21788 Expr *SubExpr = SubResult.
get();
21789 E->setSubExpr(SubExpr);
21790 E->setType(SubExpr->
getType());
21797 return rebuildSugarExpr(E);
21800 ExprResult VisitUnaryExtension(UnaryOperator *E) {
21801 return rebuildSugarExpr(E);
21804 ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
21805 const PointerType *
Ptr = DestType->
getAs<PointerType>();
21823 DestType =
Ptr->getPointeeType();
21830 ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
21832 ExprResult resolveDecl(Expr *E, ValueDecl *VD);
21838 ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
21839 return resolveDecl(E, E->
getDecl());
21845ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
21850 FK_FunctionPointer,
21855 QualType CalleeType = CalleeExpr->
getType();
21858 Kind = FK_MemberFunction;
21860 }
else if (
const PointerType *Ptr = CalleeType->
getAs<PointerType>()) {
21861 CalleeType =
Ptr->getPointeeType();
21862 Kind = FK_FunctionPointer;
21865 Kind = FK_BlockPointer;
21867 const FunctionType *FnType = CalleeType->
castAs<FunctionType>();
21872 unsigned diagID = diag::err_func_returning_array_function;
21873 if (Kind == FK_BlockPointer)
21874 diagID = diag::err_block_returning_array_function;
21887 const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FnType);
21909 SmallVector<QualType, 8> ArgTypes;
21910 if (ParamTypes.empty() && Proto->
isVariadic()) {
21912 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
21915 ParamTypes = ArgTypes;
21926 case FK_MemberFunction:
21930 case FK_FunctionPointer:
21934 case FK_BlockPointer:
21940 ExprResult CalleeResult = Visit(CalleeExpr);
21948ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
21951 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
21959 Method->setReturnType(DestType);
21969ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
21971 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
21985 }
else if (E->
getCastKind() == CK_LValueToRValue) {
22002 llvm_unreachable(
"Unhandled cast type!");
22006ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
22008 QualType
Type = DestType;
22013 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(VD)) {
22014 if (
const PointerType *Ptr =
Type->getAs<PointerType>()) {
22015 DestType =
Ptr->getPointeeType();
22022 if (!
Type->isFunctionType()) {
22027 if (
const FunctionProtoType *FT =
Type->getAs<FunctionProtoType>()) {
22031 QualType FDT = FD->getType();
22032 const FunctionType *FnType = FDT->
castAs<FunctionType>();
22033 const FunctionProtoType *Proto = dyn_cast_or_null<FunctionProtoType>(FnType);
22034 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
22035 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
22036 SourceLocation Loc = FD->getLocation();
22038 S.
Context, FD->getDeclContext(), Loc, Loc,
22039 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
22041 false , FD->hasPrototype(),
22044 if (FD->getQualifier())
22047 SmallVector<ParmVarDecl*, 16> Params;
22048 for (
const auto &AI : FT->param_types()) {
22049 ParmVarDecl *Param =
22052 Params.push_back(Param);
22054 NewFD->setParams(Params);
22060 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
22061 if (MD->isInstance()) {
22072 if (
const ReferenceType *RefTy =
Type->getAs<ReferenceType>()) {
22073 Type = RefTy->getPointeeType();
22074 }
else if (
Type->isFunctionType()) {
22075 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
22101 diag::err_typecheck_cast_to_incomplete))
22116 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
22123 ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
22132 assert(!arg->hasPlaceholderType());
22144 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
22147 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
22148 E = call->getCallee();
22149 diagID = diag::err_uncasted_call_of_unknown_any;
22157 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
22158 loc = ref->getLocation();
22159 d = ref->getDecl();
22160 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
22161 loc = mem->getMemberLoc();
22162 d = mem->getMemberDecl();
22164 diagID = diag::err_uncasted_call_of_unknown_any;
22165 loc = msg->getSelectorStartLoc();
22166 d = msg->getMethodDecl();
22168 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
22169 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
22187 if (!placeholderType)
return E;
22189 switch (placeholderType->
getKind()) {
22190 case BuiltinType::UnresolvedTemplate: {
22203 if (
auto *TD = dyn_cast<TemplateDecl>(Temp))
22204 TN =
Context.getQualifiedTemplateName(NNS, ULE->hasTemplateKeyword(),
22209 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
22210 << TN << ULE->getSourceRange() << IsTypeAliasTemplateDecl;
22212 << IsTypeAliasTemplateDecl;
22215 bool HasAnyDependentTA =
false;
22217 HasAnyDependentTA |= Arg.getArgument().
isDependent();
22229 TST =
Context.getTemplateSpecializationType(
22238 case BuiltinType::Overload: {
22258 case BuiltinType::BoundMember: {
22264 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
22265 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
22266 if (ME->getMemberNameInfo().getName().getNameKind() ==
22268 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
22276 case BuiltinType::ARCUnbridgedCast: {
22283 case BuiltinType::UnknownAny:
22287 case BuiltinType::PseudoObject:
22290 case BuiltinType::BuiltinFn: {
22295 unsigned BuiltinID = FD->getBuiltinID();
22296 if (BuiltinID == Builtin::BI__noop) {
22298 CK_BuiltinFnToFnPtr)
22305 if (
Context.BuiltinInfo.isInStdNamespace(BuiltinID)) {
22311 ? diag::err_use_of_unaddressable_function
22312 : diag::warn_cxx20_compat_use_of_unaddressable_function);
22313 if (FD->isImplicitlyInstantiable()) {
22340 case BuiltinType::IncompleteMatrixIdx: {
22346 MS->getBase(), MS->getRowIdx(), E->
getExprLoc());
22348 Diag(MS->getRowIdx()->getBeginLoc(), diag::err_matrix_incomplete_index);
22353 case BuiltinType::ArraySection:
22362 case BuiltinType::OMPArrayShaping:
22365 case BuiltinType::OMPIterator:
22369#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
22370 case BuiltinType::Id:
22371#include "clang/Basic/OpenCLImageTypes.def"
22372#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
22373 case BuiltinType::Id:
22374#include "clang/Basic/OpenCLExtensionTypes.def"
22375#define SVE_TYPE(Name, Id, SingletonId) \
22376 case BuiltinType::Id:
22377#include "clang/Basic/AArch64ACLETypes.def"
22378#define PPC_VECTOR_TYPE(Name, Id, Size) \
22379 case BuiltinType::Id:
22380#include "clang/Basic/PPCTypes.def"
22381#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22382#include "clang/Basic/RISCVVTypes.def"
22383#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22384#include "clang/Basic/WebAssemblyReferenceTypes.def"
22385#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) case BuiltinType::Id:
22386#include "clang/Basic/AMDGPUTypes.def"
22387#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22388#include "clang/Basic/HLSLIntangibleTypes.def"
22389#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22390#include "clang/Basic/HLSLPackedTypes.def"
22391#define SPIRV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22392#include "clang/Basic/SPIRVTypes.def"
22393#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
22394#define PLACEHOLDER_TYPE(Id, SingletonId)
22395#include "clang/AST/BuiltinTypes.def"
22399 llvm_unreachable(
"invalid placeholder type!");
22412 if (!
Context.getLangOpts().RecoveryAST)
22418 if (
T.isNull() ||
T->isUndeducedType() ||
22419 !
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 enumerations for traits support.
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.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
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 AMDGPU.
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 Decl * getPredefinedExprDecl(Sema &S, DeclContext *DC)
getPredefinedExprDecl - Returns Decl of a given DeclContext that can be used to determine the value o...
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 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 diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name, SourceLocation TypoLoc)
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 bool isProvablyZeroSize(const ASTContext &Ctx, QualType T)
Determine whether the size of T is provably zero: some array dimension is provably zero or the base e...
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, QualType ResultTy, 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 routines for OpenCL.
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.
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 VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
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
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.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
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, const TypeSourceInfo *TSI)
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)
bool isZero() const
Test whether the quantity equals zero.
static CharUnits One()
Construct a CharUnits quantity of one.
static CharUnits fromQuantity(QuantityType Quantity)
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.
std::optional< LayoutKind > getLayout() const
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.
Represents a pointer type decayed from an array or function type.
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.
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
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.
DeclContext * getEnclosingNonExpansionStatementContext()
Retrieve the innermost enclosing context that doesn't belong to an expansion statement.
bool isExpansionStmt() const
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)
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
Designator - A designator in a C99 designated initializer.
bool isArrayDesignator() const
SourceLocation getEndLoc() const
Returns the end location of this designator.
bool isArrayRangeDesignator() const
bool isFieldDesignator() const
const IdentifierInfo * getFieldDecl() const
SourceLocation getBeginLoc() const
Returns the start location of this designator.
Expr * getArrayIndex() const
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.
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.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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 InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
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::optional< Token > findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeComments=false)
Finds the token that comes right after the given location.
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.
Encapsulates the data about a macro definition (e.g.
bool isFunctionLike() const
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
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)
unsigned getDiagID() const
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)
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
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
RecordDecl * getDefinitionOrSelf() 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.
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.
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
Expr * ExpandAMDGPUPredicateBuiltIn(Expr *CE)
Expand a valid use of the feature identification builtins into its corresponding sequence of instruct...
void AddPotentiallyUnguardedBuiltinUser(FunctionDecl *FD)
Diagnose unguarded usages of AMDGPU builtins and recommend guarding with __builtin_amdgcn_is_invocabl...
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)
bool canHaveOverloadedBinOp(QualType Ty, BinaryOperatorKind Opc)
std::optional< ExprResult > tryPerformConstantBufferConversion(Expr *BaseExpr)
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.
void checkBuiltinReadImage(FunctionDecl *FDecl, CallExpr *Call)
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)
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
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 BuildBoolLiteral(SourceLocation Loc, bool Value)
Build a boolean-typed literal expression.
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'.
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)
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.
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 ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, const Designation &Desig, SourceLocation RParenLoc)
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)
QualType CheckMatrixCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
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)
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, const Designation &Desig, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
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.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false)
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.
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
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)
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)
ExprResult BuildCXXAggregateDefaultInitExpr(SourceLocation Loc, FieldDecl *Field, const InitializedEntity &MemberEntity)
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...
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation)
type checking for vector binary operators.
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)
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)
ExprResult CheckVarOrConceptTemplateTemplateId(const DeclarationNameInfo &NameInfo, TemplateName Template, const TemplateArgumentListInfo *TemplateArgs)
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.
ExprResult BuildCXXCtorDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
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 BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc, bool IsExplicit)
ExprResult ActOnIntegerConstant(SourceLocation Loc, int64_t Val)
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)
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 ...
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.
This class handles loading and caching of source files into memory.
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.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false, bool AllowRelaxedEval=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
void setToType(unsigned Idx, QualType T)
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
uint32_t getCodeUnit(size_t I) const
Return the code unit at the given position.
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...
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;
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.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
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 isMetaInfoType() 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
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
NullabilityKindOrNone getNullability() const
Determine the nullability of the given 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 isInternalLinkageFileVar() const
Returns true if this is a file-scope variable with internal linkage.
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.
Top level wrappers for InstallAPI frontend operations.
const char * getTraitSpelling(TypeTrait T) LLVM_READONLY
Return the spelling of the trait T. Never null.
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...
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.
const FunctionProtoType * T
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 ...
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
@ None
This is not a defaultable comparison operator.
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.
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.
OptionalUnsigned< NullabilityKind > NullabilityKindOrNone
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 DiagEmitted
Whether any diagnostic has been emitted.
bool HasUndefinedBehavior
Whether the evaluation hit undefined behavior.
bool HasSideEffects
Whether the evaluated expression has side effects.
SmallVectorImpl< PartialDiagnosticAt > * ExtendedDiag
Location where we spot ptr to int cast or null subobject while evaluating constant expression in MS c...
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.