55#include "llvm/ADT/STLExtras.h"
56#include "llvm/ADT/StringExtras.h"
57#include "llvm/Support/Casting.h"
58#include "llvm/Support/ConvertUTF.h"
59#include "llvm/Support/SaveAndRestore.h"
60#include "llvm/Support/TypeSize.h"
86 if (TreatUnavailableAsInvalid &&
96 if (isa<UnresolvedUsingIfExistsDecl>(D))
104 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
107 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
108 A->getSemanticSpelling() != UnusedAttr::C23_maybe_unused) {
110 if (DC && !DC->
hasAttr<UnusedAttr>())
111 S.
Diag(Loc, diag::warn_used_but_marked_unused) << D;
120 if (
Decl->isDefaulted()) {
131 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
132 if (Ctor && Ctor->isInheritingConstructor())
143 if (I->getStorageClass() !=
SC_None)
170 if (!Current->isInlined())
172 if (!Current->isExternallyVisible())
188 if (!DowngradeWarning && UsedFn)
191 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
192 : diag::ext_internal_in_extern_inline)
207 Diag(DeclBegin, diag::note_convert_inline_to_static)
226 bool ObjCPropertyAccess,
227 bool AvoidPartialAvailabilityChecks,
229 bool SkipTrailingRequiresClause) {
237 Diag(Suppressed.first, Suppressed.second);
248 if (cast<FunctionDecl>(D)->isMain())
249 Diag(Loc, diag::ext_main_used);
256 if (isa<BindingDecl>(D)) {
257 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
260 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
261 << D->
getDeclName() << cast<VarDecl>(D)->getType();
268 if (FD->isDeleted()) {
269 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
270 if (Ctor && Ctor->isInheritingConstructor())
271 Diag(Loc, diag::err_deleted_inherited_ctor_use)
273 << Ctor->getInheritedConstructor().getConstructor()->getParent();
275 Diag(Loc, diag::err_deleted_function_use);
288 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
297 diag::err_reference_to_function_with_unsatisfied_constraints)
315 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
317 if (MD->getParent()->isLambda() &&
318 ((isa<CXXConstructorDecl>(MD) &&
319 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
320 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
321 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
322 << !isa<CXXConstructorDecl>(MD);
326 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
328 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
343 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(
CurContext);
346 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
357 if (
LangOpts.OpenMP && isa<VarDecl>(D) &&
359 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
365 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(D)) {
366 Diag(Loc, diag::err_use_of_empty_using_if_exists);
367 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
372 AvoidPartialAvailabilityChecks, ClassReceiver);
378 if (D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
384 diag::err_type_available_only_in_default_eval_method)
388 if (
auto *VD = dyn_cast<ValueDecl>(D))
394 if (
const auto *VD = dyn_cast<VarDecl>(D))
396 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
399 if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->
getDeclContext()) &&
404 Diag(Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context)
419 const SentinelAttr *
Attr = D->
getAttr<SentinelAttr>();
424 unsigned NumFormalParams;
428 enum { CK_Function, CK_Method, CK_Block } CalleeKind;
430 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
431 NumFormalParams = MD->param_size();
432 CalleeKind = CK_Method;
433 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
434 NumFormalParams = FD->param_size();
435 CalleeKind = CK_Function;
436 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
443 CalleeKind = CK_Function;
446 CalleeKind = CK_Block;
451 if (
const auto *proto = dyn_cast<FunctionProtoType>(Fn))
452 NumFormalParams = proto->getNumParams();
463 unsigned NullPos =
Attr->getNullPos();
464 assert((NullPos == 0 || NullPos == 1) &&
"invalid null position on sentinel");
465 NumFormalParams = (NullPos > NumFormalParams ? 0 : NumFormalParams - NullPos);
468 unsigned NumArgsAfterSentinel =
Attr->getSentinel();
472 if (Args.size() < NumFormalParams + NumArgsAfterSentinel + 1) {
479 const Expr *SentinelExpr = Args[Args.size() - NumArgsAfterSentinel - 1];
492 std::string NullValue;
496 NullValue =
"nullptr";
500 NullValue =
"(void*) 0";
503 Diag(Loc, diag::warn_missing_sentinel) <<
int(CalleeKind);
505 Diag(MissingNilLoc, diag::warn_missing_sentinel)
530 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
534 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
539 CK_FunctionToPointerDecay).
get();
554 CK_ArrayToPointerDecay);
570 if (UO && UO->getOpcode() == UO_Deref &&
571 UO->getSubExpr()->getType()->isPointerType()) {
573 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
576 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
578 !UO->getType().isVolatileQualified()) {
580 S.
PDiag(diag::warn_indirection_through_null)
581 << UO->getSubExpr()->getSourceRange());
583 S.
PDiag(diag::note_indirection_through_null));
615 if (ObjectSetClass) {
659 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
699 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
747 T =
Atomic->getValueType().getUnqualifiedType();
774 CK_FunctionToPointerDecay);
797 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
804 switch (EvalMethod) {
806 llvm_unreachable(
"Unrecognized float evaluation method");
809 llvm_unreachable(
"Float evaluation method should be set by now");
817 CK_FloatingComplexCast)
826 CK_FloatingComplexCast)
874 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
886 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
887 BTy->
getKind() == BuiltinType::Float)) {
890 if (BTy->
getKind() == BuiltinType::Half) {
908 "Unexpected typesize for LongLongTy");
973 if (!Record->hasNonTrivialCopyConstructor() &&
974 !Record->hasNonTrivialMoveConstructor() &&
975 !Record->hasNonTrivialDestructor())
1002 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
1009 PDiag(diag::warn_pass_class_arg_to_vararg)
1017 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1024 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1028 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1032 << isa<InitListExpr>(E) << Ty << CT;
1043 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1045 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1084 if (
Call.isInvalid())
1089 if (Comma.isInvalid())
1096 diag::err_call_incomplete_argument))
1113 if (SkipCast)
return false;
1118 CK_FloatingRealToComplex);
1122 CK_IntegralComplexToFloatingComplex);
1140 bool PromotePrecision) {
1145 if (PromotePrecision) {
1150 if (LongerIsComplex)
1162 QualType RHSType,
bool IsCompAssign) {
1187 bool ConvertFloat,
bool ConvertInt) {
1192 CK_IntegralToFloating);
1203 CK_IntegralComplexToFloatingComplex);
1208 CK_FloatingRealToComplex);
1217 QualType RHSType,
bool IsCompAssign) {
1227 else if (!IsCompAssign)
1229 return LHSFloat ? LHSType : RHSType;
1234 if (LHSFloat && RHSFloat) {
1241 assert(order < 0 &&
"illegal float comparison");
1275 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1281 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1282 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1283 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1284 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1301 CK_IntegralComplexCast);
1307template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1310 QualType RHSType,
bool IsCompAssign) {
1315 if (LHSSigned == RHSSigned) {
1318 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1320 }
else if (!IsCompAssign)
1321 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1323 }
else if (order != (LHSSigned ? 1 : -1)) {
1327 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1329 }
else if (!IsCompAssign)
1330 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1337 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1339 }
else if (!IsCompAssign)
1340 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1349 RHS = (*doRHSCast)(S, RHS.
get(), result);
1351 LHS = (*doLHSCast)(S, LHS.
get(), result);
1361 bool IsCompAssign) {
1365 if (LHSComplexInt && RHSComplexInt) {
1369 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1370 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1375 if (LHSComplexInt) {
1378 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1379 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1382 CK_IntegralRealToComplex);
1387 assert(RHSComplexInt);
1391 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1392 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1397 CK_IntegralRealToComplex);
1406 assert(BTy &&
"Expected a builtin type.");
1408 switch (BTy->getKind()) {
1409 case BuiltinType::ShortFract:
1410 case BuiltinType::UShortFract:
1411 case BuiltinType::SatShortFract:
1412 case BuiltinType::SatUShortFract:
1414 case BuiltinType::Fract:
1415 case BuiltinType::UFract:
1416 case BuiltinType::SatFract:
1417 case BuiltinType::SatUFract:
1419 case BuiltinType::LongFract:
1420 case BuiltinType::ULongFract:
1421 case BuiltinType::SatLongFract:
1422 case BuiltinType::SatULongFract:
1424 case BuiltinType::ShortAccum:
1425 case BuiltinType::UShortAccum:
1426 case BuiltinType::SatShortAccum:
1427 case BuiltinType::SatUShortAccum:
1429 case BuiltinType::Accum:
1430 case BuiltinType::UAccum:
1431 case BuiltinType::SatAccum:
1432 case BuiltinType::SatUAccum:
1434 case BuiltinType::LongAccum:
1435 case BuiltinType::ULongAccum:
1436 case BuiltinType::SatLongAccum:
1437 case BuiltinType::SatULongAccum:
1440 if (BTy->isInteger())
1442 llvm_unreachable(
"Unexpected fixed point or integer type");
1454 "Expected at least one of the operands to be a fixed point type");
1457 "Special fixed point arithmetic operation conversions are only "
1458 "applied to ints or other fixed point types");
1480 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1502 REnum = R->isUnscopedEnumerationType();
1504 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1507 ? diag::err_arith_conv_enum_float_cxx26
1509 ? diag::warn_arith_conv_enum_float_cxx20
1510 : diag::warn_arith_conv_enum_float)
1513 }
else if (!IsCompAssign && LEnum && REnum &&
1519 DiagID = diag::err_conv_mixed_enum_types_cxx26;
1521 !R->castAs<
EnumType>()->getDecl()->hasNameForLinkage()) {
1526 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1527 : diag::warn_arith_conv_mixed_anon_enum_types;
1532 ? diag::warn_conditional_mixed_enum_types_cxx20
1533 : diag::warn_conditional_mixed_enum_types;
1538 ? diag::warn_comparison_mixed_enum_types_cxx20
1539 : diag::warn_comparison_mixed_enum_types;
1542 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1543 : diag::warn_arith_conv_mixed_enum_types;
1546 << (
int)ACK << L << R;
1576 LHSType = AtomicLHS->getValueType();
1588 QualType LHSUnpromotedType = LHSType;
1592 if (!LHSBitfieldPromoteTy.
isNull())
1593 LHSType = LHSBitfieldPromoteTy;
1627 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1638 bool PredicateIsExpr,
void *ControllingExprOrType,
1640 unsigned NumAssocs = ArgTypes.size();
1641 assert(NumAssocs == ArgExprs.size());
1644 for (
unsigned i = 0; i < NumAssocs; ++i) {
1653 if (!PredicateIsExpr) {
1657 assert(ControllingType &&
"couldn't get the type out of the parser");
1658 ControllingExprOrType = ControllingType;
1662 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1670 bool PredicateIsExpr,
void *ControllingExprOrType,
1672 unsigned NumAssocs = Types.size();
1673 assert(NumAssocs == Exprs.size());
1674 assert(ControllingExprOrType &&
1675 "Must have either a controlling expression or a controlling type");
1677 Expr *ControllingExpr =
nullptr;
1679 if (PredicateIsExpr) {
1686 reinterpret_cast<Expr *
>(ControllingExprOrType));
1689 ControllingExpr = R.
get();
1692 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1693 if (!ControllingType)
1697 bool TypeErrorFound =
false,
1698 IsResultDependent = ControllingExpr
1701 ContainsUnexpandedParameterPack =
1711 diag::warn_side_effects_unevaluated_context);
1713 for (
unsigned i = 0; i < NumAssocs; ++i) {
1714 if (Exprs[i]->containsUnexpandedParameterPack())
1715 ContainsUnexpandedParameterPack =
true;
1718 if (Types[i]->getType()->containsUnexpandedParameterPack())
1719 ContainsUnexpandedParameterPack =
true;
1721 if (Types[i]->getType()->isDependentType()) {
1722 IsResultDependent =
true;
1735 if (ControllingExpr && Types[i]->getType()->isIncompleteType())
1736 D = diag::err_assoc_type_incomplete;
1737 else if (ControllingExpr && !Types[i]->getType()->isObjectType())
1738 D = diag::err_assoc_type_nonobject;
1739 else if (Types[i]->getType()->isVariablyModifiedType())
1740 D = diag::err_assoc_type_variably_modified;
1741 else if (ControllingExpr) {
1760 unsigned Reason = 0;
1769 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1770 diag::warn_unreachable_association)
1771 << QT << (Reason - 1);
1775 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1776 << Types[i]->getTypeLoc().getSourceRange()
1777 << Types[i]->getType();
1778 TypeErrorFound =
true;
1783 for (
unsigned j = i+1; j < NumAssocs; ++j)
1784 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1786 Types[j]->getType())) {
1787 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1788 diag::err_assoc_compatible_types)
1789 << Types[j]->getTypeLoc().getSourceRange()
1790 << Types[j]->getType()
1791 << Types[i]->getType();
1792 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1793 diag::note_compat_assoc)
1794 << Types[i]->getTypeLoc().getSourceRange()
1795 << Types[i]->getType();
1796 TypeErrorFound =
true;
1806 if (IsResultDependent) {
1807 if (ControllingExpr)
1809 Types, Exprs, DefaultLoc, RParenLoc,
1810 ContainsUnexpandedParameterPack);
1812 Exprs, DefaultLoc, RParenLoc,
1813 ContainsUnexpandedParameterPack);
1817 unsigned DefaultIndex = -1U;
1821 for (
unsigned i = 0; i < NumAssocs; ++i) {
1824 else if (ControllingExpr &&
1827 Types[i]->getType()))
1828 CompatIndices.push_back(i);
1829 else if (ControllingType &&
1832 Types[i]->getType()))
1833 CompatIndices.push_back(i);
1836 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
1840 if (ControllingExpr)
1849 return std::make_pair(SR, QT);
1855 if (CompatIndices.size() > 1) {
1856 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1859 << SR <<
P.second << (
unsigned)CompatIndices.size();
1860 for (
unsigned I : CompatIndices) {
1861 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1862 diag::note_compat_assoc)
1863 << Types[I]->getTypeLoc().getSourceRange()
1864 << Types[I]->getType();
1872 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1873 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1875 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR <<
P.second;
1884 unsigned ResultIndex =
1885 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1887 if (ControllingExpr) {
1889 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1890 ContainsUnexpandedParameterPack, ResultIndex);
1893 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
1894 ContainsUnexpandedParameterPack, ResultIndex);
1900 llvm_unreachable(
"unexpected TokenKind");
1901 case tok::kw___func__:
1903 case tok::kw___FUNCTION__:
1905 case tok::kw___FUNCDNAME__:
1907 case tok::kw___FUNCSIG__:
1909 case tok::kw_L__FUNCTION__:
1911 case tok::kw_L__FUNCSIG__:
1913 case tok::kw___PRETTY_FUNCTION__:
1922 while (DC && !isa<BlockDecl, CapturedDecl, FunctionDecl, ObjCMethodDecl>(DC))
1924 return cast_or_null<Decl>(DC);
1942 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1945 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1946 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1947 if (ArgTy[ArgIdx]->isArrayType())
1968 std::vector<Token> ExpandedToks;
1974 if (Literal.hadError)
1978 for (
const Token &Tok : StringToks)
1979 StringTokLocs.push_back(Tok.getLocation());
1983 &StringTokLocs[0], StringTokLocs.size());
1985 if (!Literal.getUDSuffix().empty()) {
1988 Literal.getUDSuffixOffset());
1989 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2011 std::vector<Token> ExpandedToks;
2012 ExpandedToks.reserve(Toks.size());
2013 for (
const Token &Tok : Toks) {
2016 ExpandedToks.emplace_back(Tok);
2019 if (isa<TranslationUnitDecl>(CurrentDecl))
2020 Diag(Tok.getLocation(), diag::ext_predef_outside_function);
2022 Diag(Tok.getLocation(), diag::ext_string_literal_from_predefined)
2025 llvm::raw_svector_ostream
OS(Str);
2026 Token &Exp = ExpandedToks.emplace_back();
2028 if (Tok.getKind() == tok::kw_L__FUNCTION__ ||
2029 Tok.getKind() == tok::kw_L__FUNCSIG__) {
2031 Exp.
setKind(tok::wide_string_literal);
2033 Exp.
setKind(tok::string_literal);
2041 return ExpandedToks;
2052 assert(!StringToks.empty() &&
"Must have at least one string!");
2055 std::vector<Token> ExpandedToks;
2060 if (Literal.hadError)
2064 for (
const Token &Tok : StringToks)
2065 StringTokLocs.push_back(Tok.getLocation());
2069 if (Literal.isWide()) {
2072 }
else if (Literal.isUTF8()) {
2076 }
else if (Literal.isUTF16()) {
2079 }
else if (Literal.isUTF32()) {
2082 }
else if (Literal.isPascal()) {
2090 Diag(StringTokLocs.front(), diag::warn_cxx20_compat_utf8_string);
2096 auto RemovalDiag =
PDiag(diag::note_cxx20_compat_utf8_string_remove_u8);
2098 for (
const Token &Tok : StringToks) {
2099 if (Tok.getKind() == tok::utf8_string_literal) {
2101 RemovalDiagLoc = Tok.getLocation();
2108 Diag(RemovalDiagLoc, RemovalDiag);
2116 Kind, Literal.Pascal, StrTy,
2118 StringTokLocs.size());
2119 if (Literal.getUDSuffix().empty())
2126 Literal.getUDSuffixOffset());
2130 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2155 Expr *Args[] = { Lit, LenArg };
2166 StringTokLocs.back(), &ExplicitArgs);
2174 llvm::APSInt
Value(CharBits, CharIsUnsigned);
2180 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
2187 StringTokLocs.back(), &ExplicitArgs);
2191 llvm_unreachable(
"unexpected literal operator lookup result");
2195 llvm_unreachable(
"unexpected literal operator lookup result");
2227 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2230 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2231 if (!Referee || !Referee->hasGlobalStorage() ||
2232 Referee->hasAttr<CUDADeviceAttr>())
2238 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2239 if (MD && MD->getParent()->isLambda() &&
2240 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2262 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2263 if (VD->getType()->isReferenceType() &&
2266 VD->isUsableInConstantExpressions(
Context))
2283 bool RefersToCapturedVariable = isa<VarDecl, BindingDecl>(D) &&
2287 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
2315 const auto *FD = dyn_cast<FieldDecl>(D);
2316 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D))
2317 FD = IFD->getAnonField();
2321 if (FD->isBitField())
2327 if (
const auto *BD = dyn_cast<BindingDecl>(D))
2328 if (
const auto *BE = BD->getBinding())
2353 Id.TemplateId->NumArgs);
2359 TemplateArgs = &Buffer;
2362 TemplateArgs =
nullptr;
2369 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
2376 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
2379 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
2384 bool DroppedSpecifier =
2387 ? diag::note_implicit_param_decl
2388 : diag::note_previous_decl;
2391 SemaRef.
PDiag(NoteID));
2394 << Typo << Ctx << DroppedSpecifier
2396 SemaRef.
PDiag(NoteID));
2411 bool isDefaultArgument =
2415 const auto *CurMethod = dyn_cast<CXXMethodDecl>(
CurContext);
2416 bool isInstance = CurMethod && CurMethod->isInstance() &&
2425 unsigned DiagID = diag::err_found_in_dependent_base;
2426 unsigned NoteID = diag::note_member_declared_at;
2428 DiagID =
getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2429 : diag::err_found_later_in_class;
2431 DiagID = diag::ext_found_in_dependent_base;
2432 NoteID = diag::note_dependent_member_use;
2448 Diag(D->getLocation(), NoteID);
2457 if (isDefaultArgument && ((*R.
begin())->isCXXInstanceMember())) {
2476 unsigned diagnostic = diag::err_undeclared_var_use;
2477 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2481 diagnostic = diag::err_undeclared_use;
2482 diagnostic_suggest = diag::err_undeclared_use_suggest;
2492 if (isa<CXXRecordDecl>(DC)) {
2508 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2525 assert(!ExplicitTemplateArgs &&
2526 "Diagnosing an empty lookup with explicit template args!");
2530 emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args,
2531 diagnostic, diagnostic_suggest);
2536 }
else if (S && (Corrected =
2540 bool DroppedSpecifier =
2544 bool AcceptableWithRecovery =
false;
2545 bool AcceptableWithoutRecovery =
false;
2554 dyn_cast<FunctionTemplateDecl>(CD))
2558 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2559 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2565 ND = Best->FoundDecl;
2566 Corrected.setCorrectionDecl(ND);
2570 Corrected.setCorrectionDecl(ND);
2582 Record = cast<CXXRecordDecl>(
2588 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
2589 isa<FunctionTemplateDecl>(UnderlyingND);
2595 AcceptableWithoutRecovery = isa<TypeDecl>(UnderlyingND) ||
2597 isa<ObjCInterfaceDecl>(UnderlyingND);
2601 AcceptableWithoutRecovery =
true;
2604 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2606 ? diag::note_implicit_param_decl
2607 : diag::note_previous_decl;
2610 PDiag(NoteID), AcceptableWithRecovery);
2614 << DroppedSpecifier << SS.
getRange(),
2615 PDiag(NoteID), AcceptableWithRecovery);
2618 return !AcceptableWithRecovery;
2654 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2662 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2663 DB << NameInfo.
getName() << RD;
2665 if (!ThisType.
isNull()) {
2668 Context,
nullptr, ThisType,
true,
2670 nullptr, NameInfo, TemplateArgs);
2687 bool HasTrailingLParen,
bool IsAddressOfOperand,
2689 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2690 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2691 "cannot be direct & operand and have a trailing lparen");
2723 bool DependentID =
false;
2725 Name.getCXXNameType()->isDependentType()) {
2727 }
else if (SS.
isSet()) {
2738 IsAddressOfOperand, TemplateArgs);
2745 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2751 bool MemberOfUnknownSpecialization;
2754 MemberOfUnknownSpecialization, TemplateKWLoc,
2758 if (MemberOfUnknownSpecialization ||
2761 IsAddressOfOperand, TemplateArgs);
2770 IsAddressOfOperand, TemplateArgs);
2774 if (IvarLookupFollowUp) {
2789 if (R.
empty() && HasTrailingLParen && II &&
2799 if (R.
empty() && !ADL) {
2802 TemplateKWLoc, TemplateArgs))
2807 if (IsInlineAsmIdentifier)
2817 "Typo correction callback misconfigured");
2828 std::nullopt,
nullptr, &TE)) {
2829 if (TE && KeywordReplacement) {
2831 auto BestTC = State.Consumer->getNextCorrection();
2832 if (BestTC.isKeyword()) {
2833 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2834 if (State.DiagHandler)
2835 State.DiagHandler(BestTC);
2839 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2845 return (
Expr*)
nullptr;
2847 State.Consumer->resetCorrectionStream();
2852 assert(!R.
empty() &&
2853 "DiagnoseEmptyLookup returned false but added no results");
2870 assert(!R.
empty() || ADL);
2896 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2897 bool MightBeImplicitMember;
2898 if (!IsAddressOfOperand)
2899 MightBeImplicitMember =
true;
2901 MightBeImplicitMember =
false;
2903 MightBeImplicitMember =
false;
2905 MightBeImplicitMember =
true;
2907 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2911 if (MightBeImplicitMember)
2913 R, TemplateArgs, S);
2916 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2924 "There should only be one declaration found.");
2967 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
2968 if (CD->isInvalidDecl())
2979 unsigned DiagID = diag::err_typename_missing;
2981 DiagID = diag::ext_typename_missing;
2983 auto D =
Diag(Loc, DiagID);
3014 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
3050 LookForIvars =
true;
3051 else if (IsClassMethod)
3052 LookForIvars =
false;
3063 if (IsClassMethod) {
3084 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
3092 Diag(Loc, diag::err_ivar_use_in_class_method) << IV->getDeclName();
3105 "should not reference ivar from this context");
3108 assert(IFace &&
"should not reference ivar from this context");
3173 cast<ObjCIvarDecl>(Ivar.
get()));
3175 if (Lookup.
empty() && II && AllowBuiltinCreation)
3207 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
3215 bool PointerConversions =
false;
3216 if (isa<FieldDecl>(
Member)) {
3220 DestRecordType, FromPtrType
3227 PointerConversions =
true;
3229 DestType = DestRecordType;
3230 FromRecordType = FromType;
3232 }
else if (
const auto *Method = dyn_cast<CXXMethodDecl>(
Member)) {
3233 if (!Method->isImplicitObjectMemberFunction())
3236 DestType = Method->getThisType().getNonReferenceType();
3237 DestRecordType = Method->getFunctionObjectParameterType();
3241 PointerConversions =
true;
3243 FromRecordType = FromType;
3244 DestType = DestRecordType;
3249 if (FromAS != DestAS) {
3254 if (PointerConversions)
3295 if (Qualifier && Qualifier->getAsType()) {
3297 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3307 FromLoc, FromRange, &BasePath))
3310 if (PointerConversions)
3313 VK, &BasePath).
get();
3316 FromRecordType = QRecordType;
3327 FromLoc, FromRange, &BasePath,
3337 bool HasTrailingLParen) {
3339 if (!HasTrailingLParen)
3357 if (D->isCXXClassMember())
3366 if (isa<UsingShadowDecl>(D))
3367 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3368 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
3375 if (
const auto *FDecl = dyn_cast<FunctionDecl>(D)) {
3377 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3379 }
else if (!isa<FunctionTemplateDecl>(D))
3392 bool AcceptInvalid) {
3396 if (isa<TypedefNameDecl>(D)) {
3401 if (isa<ObjCInterfaceDecl>(D)) {
3406 if (isa<NamespaceDecl>(D)) {
3418 const auto *FD = dyn_cast<FunctionDecl>(R.
getFoundDecl());
3420 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3425 bool AcceptInvalidDecl) {
3466 bool AcceptInvalidDecl) {
3467 assert(D &&
"Cannot refer to a NULL declaration");
3468 assert(!isa<FunctionTemplateDecl>(D) &&
3469 "Cannot refer unambiguously to a function template");
3479 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
3487 if (!isa<ValueDecl, UnresolvedUsingIfExistsDecl>(D)) {
3488 Diag(Loc, diag::err_ref_non_value) << D << SS.
getRange();
3500 auto *VD = cast<ValueDecl>(D);
3503 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3509 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3510 IndirectField && !IndirectField->isCXXClassMember())
3522 type =
type.getNonPackExpansionType();
3526#define ABSTRACT_DECL(kind)
3527#define VALUE(type, base)
3528#define DECL(type, base) case Decl::type:
3529#include "clang/AST/DeclNodes.inc"
3530 llvm_unreachable(
"invalid value decl kind");
3533 case Decl::ObjCAtDefsField:
3534 llvm_unreachable(
"forming non-member reference to ivar?");
3538 case Decl::EnumConstant:
3539 case Decl::UnresolvedUsingValue:
3540 case Decl::OMPDeclareReduction:
3541 case Decl::OMPDeclareMapper:
3550 case Decl::IndirectField:
3551 case Decl::ObjCIvar:
3562 case Decl::NonTypeTemplateParm: {
3564 type = reftype->getPointeeType();
3574 if (
type->isRecordType()) {
3575 type =
type.getUnqualifiedType().withConst();
3588 case Decl::VarTemplateSpecialization:
3589 case Decl::VarTemplatePartialSpecialization:
3590 case Decl::Decomposition:
3591 case Decl::OMPCapturedExpr:
3594 type->isVoidType()) {
3600 case Decl::ImplicitParam:
3601 case Decl::ParmVar: {
3611 if (!CapturedType.
isNull())
3612 type = CapturedType;
3624 case Decl::Function: {
3625 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3654 if (!cast<FunctionDecl>(VD)->hasPrototype() && isa<FunctionProtoType>(fty))
3663 case Decl::CXXDeductionGuide:
3664 llvm_unreachable(
"building reference to deduction guide");
3666 case Decl::MSProperty:
3668 case Decl::TemplateParamObject:
3674 case Decl::UnnamedGlobalConstant:
3678 case Decl::CXXMethod:
3683 dyn_cast<FunctionProtoType>(VD->getType()))
3691 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3697 case Decl::CXXConversion:
3698 case Decl::CXXDestructor:
3699 case Decl::CXXConstructor:
3711 if (VD->isInvalidDecl() && E)
3718 Target.resize(CharByteWidth * (Source.size() + 1));
3719 char *ResultPtr = &
Target[0];
3720 const llvm::UTF8 *ErrorPtr;
3722 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3732 Diag(Loc, diag::ext_predef_outside_function);
3738 if (cast<DeclContext>(currentDecl)->isDependentContext())
3744 unsigned Length = Str.length();
3746 llvm::APInt LengthI(32, Length + 1);
3808 if (Literal.hadError())
3812 if (Literal.isWide())
3818 else if (Literal.isUTF16())
3820 else if (Literal.isUTF32())
3829 if (Literal.isWide())
3831 else if (Literal.isUTF16())
3833 else if (Literal.isUTF32())
3835 else if (Literal.isUTF8())
3841 if (Literal.getUDSuffix().empty())
3851 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3869 using llvm::APFloat;
3870 APFloat Val(Format);
3872 APFloat::opStatus result = Literal.GetFloatValue(Val);
3876 if ((result & APFloat::opOverflow) ||
3877 ((result & APFloat::opUnderflow) && Val.isZero())) {
3878 unsigned diagnostic;
3880 if (result & APFloat::opOverflow) {
3881 diagnostic = diag::warn_float_overflow;
3882 APFloat::getLargest(Format).toString(buffer);
3884 diagnostic = diag::warn_float_underflow;
3885 APFloat::getSmallest(Format).toString(buffer);
3888 S.
Diag(Loc, diagnostic)
3890 << StringRef(buffer.data(), buffer.size());
3893 bool isExact = (result == APFloat::opOK);
3898 assert(E &&
"Invalid expression");
3905 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3909 llvm::APSInt ValueAPS;
3915 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3916 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3917 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3918 <<
toString(ValueAPS, 10) << ValueIsPositive;
3938 SpellingBuffer.resize(Tok.
getLength() + 1);
3949 if (Literal.hadError)
3952 if (Literal.hasUDSuffix()) {
3960 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3963 if (Literal.isFloatingLiteral()) {
3988 !Literal.isImaginary)) {
3997 if (Literal.isFloatingLiteral()) {
4001 if (Literal.GetIntegerValue(ResultVal))
4014 unsigned Length = Literal.getUDSuffixOffset();
4021 false, StrTy, &TokLoc, 1);
4032 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
4033 llvm::APSInt
Value(CharBits, CharIsUnsigned);
4034 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
4035 Value = TokSpelling[I];
4044 llvm_unreachable(
"unexpected literal operator lookup result");
4050 if (Literal.isFixedPointLiteral()) {
4053 if (Literal.isAccum) {
4054 if (Literal.isHalf) {
4056 }
else if (Literal.isLong) {
4061 }
else if (Literal.isFract) {
4062 if (Literal.isHalf) {
4064 }
else if (Literal.isLong) {
4073 bool isSigned = !Literal.isUnsigned;
4077 llvm::APInt Val(bit_width, 0, isSigned);
4078 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
4079 bool ValIsZero = Val.isZero() && !Overflowed;
4082 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
4088 else if (Val.ugt(MaxVal) || Overflowed)
4093 }
else if (Literal.isFloatingLiteral()) {
4095 if (Literal.isHalf){
4102 }
else if (Literal.isFloat)
4104 else if (Literal.isLong)
4106 else if (Literal.isFloat16)
4108 else if (Literal.isFloat128)
4128 }
else if (!Literal.isIntegerLiteral()) {
4134 if (Literal.isSizeT)
4137 ? diag::warn_cxx20_compat_size_t_suffix
4138 : diag::ext_cxx23_size_t_suffix
4139 : diag::err_cxx23_size_t_suffix);
4147 ? diag::warn_c23_compat_bitint_suffix
4148 : diag::ext_c23_bitint_suffix);
4157 unsigned BitsNeeded =
4158 Literal.isBitInt ? llvm::APInt::getSufficientBitsNeeded(
4159 Literal.getLiteralDigits(), Literal.getRadix())
4161 llvm::APInt ResultVal(BitsNeeded, 0);
4163 if (Literal.GetIntegerValue(ResultVal)) {
4169 "long long is not intmax_t?");
4176 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
4182 if (Literal.MicrosoftInteger) {
4183 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
4187 Width = Literal.MicrosoftInteger;
4189 !Literal.isUnsigned);
4195 if (Literal.isBitInt) {
4198 Width = std::max(ResultVal.getActiveBits(), 1u) +
4199 (Literal.isUnsigned ? 0u : 1u);
4203 unsigned int MaxBitIntWidth =
4205 if (Width > MaxBitIntWidth) {
4207 << Literal.isUnsigned;
4208 Width = MaxBitIntWidth;
4215 ResultVal = ResultVal.zextOrTrunc(Width);
4220 if (Literal.isSizeT) {
4221 assert(!Literal.MicrosoftInteger &&
4222 "size_t literals can't be Microsoft literals");
4227 if (ResultVal.isIntN(SizeTSize)) {
4229 if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4231 else if (AllowUnsigned)
4237 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong &&
4243 if (ResultVal.isIntN(IntSize)) {
4245 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
4247 else if (AllowUnsigned)
4254 if (Ty.
isNull() && !Literal.isLongLong && !Literal.isSizeT) {
4258 if (ResultVal.isIntN(LongSize)) {
4260 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4262 else if (AllowUnsigned)
4267 const unsigned LongLongSize =
4272 ? diag::warn_old_implicitly_unsigned_long_cxx
4274 ext_old_implicitly_unsigned_long_cxx
4275 : diag::warn_old_implicitly_unsigned_long)
4276 << (LongLongSize > LongSize ? 0
4285 if (Ty.
isNull() && !Literal.isSizeT) {
4289 if (ResultVal.isIntN(LongLongSize)) {
4293 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4294 (
getLangOpts().MSVCCompat && Literal.isLongLong)))
4296 else if (AllowUnsigned)
4298 Width = LongLongSize;
4304 ? diag::warn_cxx98_compat_longlong
4305 : diag::ext_cxx11_longlong);
4315 if (Literal.isSizeT)
4317 << Literal.isUnsigned;
4320 diag::ext_integer_literal_too_large_for_signed);
4325 if (ResultVal.getBitWidth() != Width)
4326 ResultVal = ResultVal.trunc(Width);
4332 if (Literal.isImaginary) {
4342 assert(E &&
"ActOnParenExpr() missing expr");
4358 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
4364 "Scalar types should always be complete");
4373 return S.
Diag(Loc, diag::err_builtin_non_vector_type)
4375 <<
"__builtin_vectorelements" << T << ArgRange;
4390 (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4391 TraitKind == UETT_PreferredAlignOf)) {
4393 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
4401 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4402 : diag::ext_sizeof_alignof_void_type;
4417 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
4418 << T << (TraitKind == UETT_SizeOf)
4435 const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
4436 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4439 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4441 << ICE->getSubExpr()->getType();
4456 bool IsUnevaluatedOperand =
4457 (ExprKind == UETT_SizeOf || ExprKind == UETT_DataSizeOf ||
4458 ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4459 ExprKind == UETT_VecStep);
4460 if (IsUnevaluatedOperand) {
4476 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4478 if (ExprKind == UETT_VecStep)
4482 if (ExprKind == UETT_VectorElements)
4504 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4507 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4512 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4531 if (ExprKind == UETT_SizeOf) {
4532 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(E->
IgnoreParens())) {
4533 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4534 QualType OType = PVD->getOriginalType();
4539 Diag(PVD->getLocation(), diag::note_declared_at);
4547 if (
const auto *BO = dyn_cast<BinaryOperator>(E->
IgnoreParens())) {
4564 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4571 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4573 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4574 D = ME->getMemberDecl();
4594 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4597 if (!FD->getParent()->isCompleteDefinition()) {
4598 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4607 if (!FD->getType()->isReferenceType())
4627 assert(CSI !=
nullptr);
4633#define TYPE(Class, Base)
4634#define ABSTRACT_TYPE(Class, Base)
4635#define NON_CANONICAL_TYPE(Class, Base)
4636#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4637#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4638#include "clang/AST/TypeNodes.inc"
4645 case Type::ExtVector:
4646 case Type::ConstantMatrix:
4649 case Type::TemplateSpecialization:
4650 case Type::ObjCObject:
4651 case Type::ObjCInterface:
4652 case Type::ObjCObjectPointer:
4653 case Type::ObjCTypeParam:
4656 llvm_unreachable(
"type class is never variably-modified!");
4657 case Type::Elaborated:
4658 T = cast<ElaboratedType>(Ty)->getNamedType();
4660 case Type::Adjusted:
4661 T = cast<AdjustedType>(Ty)->getOriginalType();
4669 case Type::BlockPointer:
4672 case Type::LValueReference:
4673 case Type::RValueReference:
4676 case Type::MemberPointer:
4679 case Type::ConstantArray:
4680 case Type::IncompleteArray:
4682 T = cast<ArrayType>(Ty)->getElementType();
4684 case Type::VariableArray: {
4692 (isa<CapturedRegionScopeInfo>(CSI) || isa<LambdaScopeInfo>(CSI)))
4698 case Type::FunctionProto:
4699 case Type::FunctionNoProto:
4700 T = cast<FunctionType>(Ty)->getReturnType();
4704 case Type::UnaryTransform:
4705 case Type::Attributed:
4706 case Type::BTFTagAttributed:
4707 case Type::SubstTemplateTypeParm:
4708 case Type::MacroQualified:
4713 T = cast<TypedefType>(Ty)->desugar();
4715 case Type::Decltype:
4716 T = cast<DecltypeType>(Ty)->desugar();
4719 T = cast<UsingType>(Ty)->desugar();
4722 case Type::DeducedTemplateSpecialization:
4723 T = cast<DeducedType>(Ty)->getDeducedType();
4725 case Type::TypeOfExpr:
4726 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4729 T = cast<AtomicType>(Ty)->getValueType();
4770 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4771 ExprKind == UETT_OpenMPRequiredSimdAlign)
4774 if (ExprKind == UETT_VecStep)
4777 if (ExprKind == UETT_VectorElements)
4787 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4792 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4800 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4814 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4818 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4819 DC = LSI->CallOperator;
4820 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4821 DC = CRSI->TheCapturedDecl;
4822 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4877 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4879 }
else if (ExprKind == UETT_VecStep) {
4881 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4885 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4887 }
else if (ExprKind == UETT_VectorElements) {
4933 UETT_AlignOf, KWName);