60#include "llvm/ADT/STLExtras.h"
61#include "llvm/ADT/STLForwardCompat.h"
62#include "llvm/ADT/StringExtras.h"
63#include "llvm/Support/Casting.h"
64#include "llvm/Support/ConvertUTF.h"
65#include "llvm/Support/SaveAndRestore.h"
66#include "llvm/Support/TypeSize.h"
90 if (TreatUnavailableAsInvalid &&
100 if (isa<UnresolvedUsingIfExistsDecl>(
D))
108 if (
const auto *A =
D->
getAttr<UnusedAttr>()) {
111 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
112 A->getSemanticSpelling() != UnusedAttr::C23_maybe_unused) {
114 if (DC && !DC->
hasAttr<UnusedAttr>())
115 S.
Diag(
Loc, diag::warn_used_but_marked_unused) <<
D;
123 if (
Decl->isDefaulted()) {
134 auto *Ctor = dyn_cast<CXXConstructorDecl>(
Decl);
135 if (Ctor && Ctor->isInheritingConstructor())
146 if (I->getStorageClass() !=
SC_None)
173 if (!Current->isInlined())
175 if (!Current->isExternallyVisible())
191 if (!DowngradeWarning && UsedFn)
194 S.
Diag(
Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
195 : diag::ext_internal_in_extern_inline)
210 Diag(DeclBegin, diag::note_convert_inline_to_static)
217 bool ObjCPropertyAccess,
218 bool AvoidPartialAvailabilityChecks,
220 bool SkipTrailingRequiresClause) {
228 Diag(Suppressed.first, Suppressed.second);
239 if (cast<FunctionDecl>(
D)->isMain())
240 Diag(
Loc, diag::ext_main_used);
247 if (isa<BindingDecl>(
D)) {
248 Diag(
Loc, diag::err_binding_cannot_appear_in_own_initializer)
251 Diag(
Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
252 <<
D->getDeclName() << cast<VarDecl>(
D)->getType();
259 if (FD->isDeleted()) {
260 auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
261 if (Ctor && Ctor->isInheritingConstructor())
262 Diag(
Loc, diag::err_deleted_inherited_ctor_use)
264 << Ctor->getInheritedConstructor().getConstructor()->getParent();
267 Diag(
Loc, diag::err_deleted_function_use)
268 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef());
282 if (!SkipTrailingRequiresClause && FD->getTrailingRequiresClause()) {
291 diag::err_reference_to_function_with_unsatisfied_constraints)
309 if (
auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
311 if (MD->getParent()->isLambda() &&
312 ((isa<CXXConstructorDecl>(MD) &&
313 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
314 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
315 Diag(
Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
316 << !isa<CXXConstructorDecl>(MD);
320 auto getReferencedObjCProp = [](
const NamedDecl *
D) ->
322 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D))
337 auto *DRD = dyn_cast<OMPDeclareReductionDecl>(
CurContext);
340 Diag(
Loc, diag::err_omp_wrong_var_in_declare_reduction)
351 if (
LangOpts.OpenMP && isa<VarDecl>(
D) &&
352 !
OpenMP().isOpenMPDeclareMapperVarDeclAllowed(cast<VarDecl>(
D))) {
353 Diag(
Loc, diag::err_omp_declare_mapper_wrong_var)
359 if (
const auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(
D)) {
360 Diag(
Loc, diag::err_use_of_empty_using_if_exists);
361 Diag(EmptyD->getLocation(), diag::note_empty_using_if_exists_here);
366 AvoidPartialAvailabilityChecks, ClassReceiver);
372 if (
D->
hasAttr<AvailableOnlyInDefaultEvalMethodAttr>()) {
378 diag::err_type_available_only_in_default_eval_method)
382 if (
auto *VD = dyn_cast<ValueDecl>(
D))
388 if (
const auto *VD = dyn_cast<VarDecl>(
D))
390 targetDiag(*Locs.begin(), diag::err_thread_unsupported);
393 if (isa<ParmVarDecl>(
D) && isa<RequiresExprBodyDecl>(
D->
getDeclContext()) &&
398 Diag(
Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context)
414 unsigned NumFormalParams;
418 enum { CK_Function, CK_Method, CK_Block } CalleeKind;
420 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D)) {
421 NumFormalParams = MD->param_size();
422 CalleeKind = CK_Method;
423 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
424 NumFormalParams = FD->param_size();
425 CalleeKind = CK_Function;
426 }
else if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
433 CalleeKind = CK_Function;
436 CalleeKind = CK_Block;
441 if (
const auto *proto = dyn_cast<FunctionProtoType>(Fn))
442 NumFormalParams = proto->getNumParams();
453 unsigned NullPos =
Attr->getNullPos();
454 assert((NullPos == 0 || NullPos == 1) &&
"invalid null position on sentinel");
455 NumFormalParams = (NullPos > NumFormalParams ? 0 : NumFormalParams - NullPos);
458 unsigned NumArgsAfterSentinel =
Attr->getSentinel();
462 if (Args.size() < NumFormalParams + NumArgsAfterSentinel + 1) {
463 Diag(
Loc, diag::warn_not_enough_argument) <<
D->getDeclName();
469 const Expr *SentinelExpr = Args[Args.size() - NumArgsAfterSentinel - 1];
482 std::string NullValue;
486 NullValue =
"nullptr";
490 NullValue =
"(void*) 0";
493 Diag(
Loc, diag::warn_missing_sentinel) <<
int(CalleeKind);
495 Diag(MissingNilLoc, diag::warn_missing_sentinel)
520 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
524 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
529 CK_FunctionToPointerDecay).
get();
544 CK_ArrayToPointerDecay);
560 if (UO && UO->getOpcode() == UO_Deref &&
561 UO->getSubExpr()->getType()->isPointerType()) {
563 UO->getSubExpr()->getType()->getPointeeType().getAddressSpace();
566 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
568 !UO->getType().isVolatileQualified()) {
570 S.
PDiag(diag::warn_indirection_through_null)
571 << UO->getSubExpr()->getSourceRange());
573 S.
PDiag(diag::note_indirection_through_null));
605 if (ObjectSetClass) {
649 assert(!
T.isNull() &&
"r-value conversion on typeless expression?");
691 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
708 if (
T.hasQualifiers())
709 T =
T.getUnqualifiedType();
739 T =
Atomic->getValueType().getUnqualifiedType();
764 CK_FunctionToPointerDecay);
787 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
794 switch (EvalMethod) {
796 llvm_unreachable(
"Unrecognized float evaluation method");
799 llvm_unreachable(
"Float evaluation method should be set by now");
807 CK_FloatingComplexCast)
816 CK_FloatingComplexCast)
864 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
876 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
877 BTy->
getKind() == BuiltinType::Float)) {
880 if (BTy->
getKind() == BuiltinType::Half) {
898 "Unexpected typesize for LongLongTy");
960 if (!
Record->hasNonTrivialCopyConstructor() &&
961 !
Record->hasNonTrivialMoveConstructor() &&
962 !
Record->hasNonTrivialDestructor())
989 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
996 PDiag(diag::warn_pass_class_arg_to_vararg)
1004 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
1011 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
1015 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
1019 << isa<InitListExpr>(
E) << Ty << CT;
1028 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
1030 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
1069 if (
Call.isInvalid())
1074 if (Comma.isInvalid())
1081 diag::err_call_incomplete_argument))
1099 if (SkipCast)
return false;
1106 CK_IntegralComplexToFloatingComplex);
1124 bool PromotePrecision) {
1129 if (PromotePrecision) {
1134 if (LongerIsComplex)
1146 QualType RHSType,
bool IsCompAssign) {
1171 bool ConvertFloat,
bool ConvertInt) {
1176 CK_IntegralToFloating);
1187 CK_IntegralComplexToFloatingComplex);
1192 CK_FloatingRealToComplex);
1201 QualType RHSType,
bool IsCompAssign) {
1211 else if (!IsCompAssign)
1213 return LHSFloat ? LHSType : RHSType;
1218 if (LHSFloat && RHSFloat) {
1225 assert(order < 0 &&
"illegal float comparison");
1259 QualType LHSElem = LHSComplex ? LHSComplex->getElementType() : LHSType;
1265 if ((&LHSSem != &llvm::APFloat::PPCDoubleDouble() ||
1266 &RHSSem != &llvm::APFloat::IEEEquad()) &&
1267 (&LHSSem != &llvm::APFloat::IEEEquad() ||
1268 &RHSSem != &llvm::APFloat::PPCDoubleDouble()))
1285 CK_IntegralComplexCast);
1291template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1294 QualType RHSType,
bool IsCompAssign) {
1299 if (LHSSigned == RHSSigned) {
1302 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1304 }
else if (!IsCompAssign)
1305 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1307 }
else if (order != (LHSSigned ? 1 : -1)) {
1311 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1313 }
else if (!IsCompAssign)
1314 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1321 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1323 }
else if (!IsCompAssign)
1324 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1333 RHS = (*doRHSCast)(S, RHS.
get(), result);
1335 LHS = (*doLHSCast)(S, LHS.
get(), result);
1345 bool IsCompAssign) {
1349 if (LHSComplexInt && RHSComplexInt) {
1353 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1354 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1359 if (LHSComplexInt) {
1362 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1363 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1366 CK_IntegralRealToComplex);
1371 assert(RHSComplexInt);
1375 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1376 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1381 CK_IntegralRealToComplex);
1390 assert(BTy &&
"Expected a builtin type.");
1392 switch (BTy->getKind()) {
1393 case BuiltinType::ShortFract:
1394 case BuiltinType::UShortFract:
1395 case BuiltinType::SatShortFract:
1396 case BuiltinType::SatUShortFract:
1398 case BuiltinType::Fract:
1399 case BuiltinType::UFract:
1400 case BuiltinType::SatFract:
1401 case BuiltinType::SatUFract:
1403 case BuiltinType::LongFract:
1404 case BuiltinType::ULongFract:
1405 case BuiltinType::SatLongFract:
1406 case BuiltinType::SatULongFract:
1408 case BuiltinType::ShortAccum:
1409 case BuiltinType::UShortAccum:
1410 case BuiltinType::SatShortAccum:
1411 case BuiltinType::SatUShortAccum:
1413 case BuiltinType::Accum:
1414 case BuiltinType::UAccum:
1415 case BuiltinType::SatAccum:
1416 case BuiltinType::SatUAccum:
1418 case BuiltinType::LongAccum:
1419 case BuiltinType::ULongAccum:
1420 case BuiltinType::SatLongAccum:
1421 case BuiltinType::SatULongAccum:
1424 if (BTy->isInteger())
1426 llvm_unreachable(
"Unexpected fixed point or integer type");
1438 "Expected at least one of the operands to be a fixed point type");
1441 "Special fixed point arithmetic operation conversions are only "
1442 "applied to ints or other fixed point types");
1464 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1487 REnum = R->isUnscopedEnumerationType();
1489 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1492 ? diag::err_arith_conv_enum_float_cxx26
1494 ? diag::warn_arith_conv_enum_float_cxx20
1495 : diag::warn_arith_conv_enum_float)
1498 }
else if (!IsCompAssign && LEnum && REnum &&
1504 DiagID = diag::err_conv_mixed_enum_types_cxx26;
1506 !R->castAs<
EnumType>()->getDecl()->hasNameForLinkage()) {
1511 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx20
1512 : diag::warn_arith_conv_mixed_anon_enum_types;
1517 ? diag::warn_conditional_mixed_enum_types_cxx20
1518 : diag::warn_conditional_mixed_enum_types;
1523 ? diag::warn_comparison_mixed_enum_types_cxx20
1524 : diag::warn_comparison_mixed_enum_types;
1527 ? diag::warn_arith_conv_mixed_enum_types_cxx20
1528 : diag::warn_arith_conv_mixed_enum_types;
1531 << (
int)ACK << L << R;
1561 LHSType = AtomicLHS->getValueType();
1573 QualType LHSUnpromotedType = LHSType;
1577 if (!LHSBitfieldPromoteTy.
isNull())
1578 LHSType = LHSBitfieldPromoteTy;
1612 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1623 bool PredicateIsExpr,
void *ControllingExprOrType,
1625 unsigned NumAssocs = ArgTypes.size();
1626 assert(NumAssocs == ArgExprs.size());
1629 for (
unsigned i = 0; i < NumAssocs; ++i) {
1638 if (!PredicateIsExpr) {
1642 assert(ControllingType &&
"couldn't get the type out of the parser");
1643 ControllingExprOrType = ControllingType;
1647 KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
1655 bool PredicateIsExpr,
void *ControllingExprOrType,
1657 unsigned NumAssocs = Types.size();
1658 assert(NumAssocs == Exprs.size());
1659 assert(ControllingExprOrType &&
1660 "Must have either a controlling expression or a controlling type");
1662 Expr *ControllingExpr =
nullptr;
1664 if (PredicateIsExpr) {
1671 reinterpret_cast<Expr *
>(ControllingExprOrType));
1674 ControllingExpr = R.
get();
1677 ControllingType =
reinterpret_cast<TypeSourceInfo *
>(ControllingExprOrType);
1678 if (!ControllingType)
1682 bool TypeErrorFound =
false,
1683 IsResultDependent = ControllingExpr
1686 ContainsUnexpandedParameterPack =
1696 diag::warn_side_effects_unevaluated_context);
1698 for (
unsigned i = 0; i < NumAssocs; ++i) {
1699 if (Exprs[i]->containsUnexpandedParameterPack())
1700 ContainsUnexpandedParameterPack =
true;
1703 if (Types[i]->getType()->containsUnexpandedParameterPack())
1704 ContainsUnexpandedParameterPack =
true;
1706 if (Types[i]->getType()->isDependentType()) {
1707 IsResultDependent =
true;
1720 if (ControllingExpr && Types[i]->getType()->isIncompleteType())
1721 D = diag::err_assoc_type_incomplete;
1722 else if (ControllingExpr && !Types[i]->getType()->isObjectType())
1723 D = diag::err_assoc_type_nonobject;
1724 else if (Types[i]->getType()->isVariablyModifiedType())
1725 D = diag::err_assoc_type_variably_modified;
1726 else if (ControllingExpr) {
1745 unsigned Reason = 0;
1754 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1755 diag::warn_unreachable_association)
1756 << QT << (Reason - 1);
1760 Diag(Types[i]->getTypeLoc().getBeginLoc(),
D)
1761 << Types[i]->getTypeLoc().getSourceRange()
1762 << Types[i]->getType();
1763 TypeErrorFound =
true;
1768 for (
unsigned j = i+1; j < NumAssocs; ++j)
1769 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1771 Types[j]->getType())) {
1772 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1773 diag::err_assoc_compatible_types)
1774 << Types[j]->getTypeLoc().getSourceRange()
1775 << Types[j]->getType()
1776 << Types[i]->getType();
1777 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1778 diag::note_compat_assoc)
1779 << Types[i]->getTypeLoc().getSourceRange()
1780 << Types[i]->getType();
1781 TypeErrorFound =
true;
1791 if (IsResultDependent) {
1792 if (ControllingExpr)
1794 Types, Exprs, DefaultLoc, RParenLoc,
1795 ContainsUnexpandedParameterPack);
1797 Exprs, DefaultLoc, RParenLoc,
1798 ContainsUnexpandedParameterPack);
1802 unsigned DefaultIndex = -1U;
1806 for (
unsigned i = 0; i < NumAssocs; ++i) {
1809 else if (ControllingExpr &&
1812 Types[i]->getType()))
1813 CompatIndices.push_back(i);
1814 else if (ControllingType &&
1817 Types[i]->getType()))
1818 CompatIndices.push_back(i);
1821 auto GetControllingRangeAndType = [](
Expr *ControllingExpr,
1825 if (ControllingExpr)
1834 return std::make_pair(SR, QT);
1840 if (CompatIndices.size() > 1) {
1841 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1844 << SR <<
P.second << (
unsigned)CompatIndices.size();
1845 for (
unsigned I : CompatIndices) {
1846 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1847 diag::note_compat_assoc)
1848 << Types[I]->getTypeLoc().getSourceRange()
1849 << Types[I]->getType();
1857 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1858 auto P = GetControllingRangeAndType(ControllingExpr, ControllingType);
1860 Diag(SR.
getBegin(), diag::err_generic_sel_no_match) << SR <<
P.second;
1869 unsigned ResultIndex =
1870 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1872 if (ControllingExpr) {
1874 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1875 ContainsUnexpandedParameterPack, ResultIndex);
1878 Context, KeyLoc, ControllingType, Types, Exprs, DefaultLoc, RParenLoc,
1879 ContainsUnexpandedParameterPack, ResultIndex);
1885 llvm_unreachable(
"unexpected TokenKind");
1886 case tok::kw___func__:
1888 case tok::kw___FUNCTION__:
1890 case tok::kw___FUNCDNAME__:
1892 case tok::kw___FUNCSIG__:
1894 case tok::kw_L__FUNCTION__:
1896 case tok::kw_L__FUNCSIG__:
1898 case tok::kw___PRETTY_FUNCTION__:
1907 while (DC && !isa<BlockDecl, CapturedDecl, FunctionDecl, ObjCMethodDecl>(DC))
1909 return cast_or_null<Decl>(DC);
1927 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1930 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1931 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1932 if (ArgTy[ArgIdx]->isArrayType())
1953 std::vector<Token> ExpandedToks;
1959 if (Literal.hadError)
1963 for (
const Token &Tok : StringToks)
1964 StringTokLocs.push_back(Tok.getLocation());
1968 &StringTokLocs[0], StringTokLocs.size());
1970 if (!Literal.getUDSuffix().empty()) {
1973 Literal.getUDSuffixOffset());
1974 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1996 std::vector<Token> ExpandedToks;
1997 ExpandedToks.reserve(Toks.size());
1998 for (
const Token &Tok : Toks) {
2001 ExpandedToks.emplace_back(Tok);
2004 if (isa<TranslationUnitDecl>(CurrentDecl))
2005 Diag(Tok.getLocation(), diag::ext_predef_outside_function);
2007 Diag(Tok.getLocation(), diag::ext_string_literal_from_predefined)
2010 llvm::raw_svector_ostream
OS(Str);
2011 Token &Exp = ExpandedToks.emplace_back();
2013 if (Tok.getKind() == tok::kw_L__FUNCTION__ ||
2014 Tok.getKind() == tok::kw_L__FUNCSIG__) {
2016 Exp.
setKind(tok::wide_string_literal);
2018 Exp.
setKind(tok::string_literal);
2026 return ExpandedToks;
2031 assert(!StringToks.empty() &&
"Must have at least one string!");
2034 std::vector<Token> ExpandedToks;
2039 if (Literal.hadError)
2043 for (
const Token &Tok : StringToks)
2044 StringTokLocs.push_back(Tok.getLocation());
2048 if (Literal.isWide()) {
2051 }
else if (Literal.isUTF8()) {
2057 }
else if (Literal.isUTF16()) {
2060 }
else if (Literal.isUTF32()) {
2063 }
else if (Literal.isPascal()) {
2076 ? diag::warn_cxx20_compat_utf8_string
2077 : diag::warn_c23_compat_utf8_string);
2083 auto RemovalDiag =
PDiag(diag::note_cxx20_c23_compat_utf8_string_remove_u8);
2085 for (
const Token &Tok : StringToks) {
2086 if (Tok.getKind() == tok::utf8_string_literal) {
2088 RemovalDiagLoc = Tok.getLocation();
2095 Diag(RemovalDiagLoc, RemovalDiag);
2103 Kind, Literal.Pascal, StrTy,
2105 StringTokLocs.size());
2106 if (Literal.getUDSuffix().empty())
2113 Literal.getUDSuffixOffset());
2117 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
2142 Expr *Args[] = { Lit, LenArg };
2153 StringTokLocs.back(), &ExplicitArgs);
2161 llvm::APSInt
Value(CharBits, CharIsUnsigned);
2167 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
2174 StringTokLocs.back(), &ExplicitArgs);
2178 llvm_unreachable(
"unexpected literal operator lookup result");
2182 llvm_unreachable(
"unexpected literal operator lookup result");
2214 auto *DRE = dyn_cast<DeclRefExpr>(VD->
getInit());
2217 auto *Referee = dyn_cast<VarDecl>(DRE->getDecl());
2218 if (!Referee || !Referee->hasGlobalStorage() ||
2219 Referee->hasAttr<CUDADeviceAttr>())
2225 auto *MD = dyn_cast_or_null<CXXMethodDecl>(S.
CurContext);
2226 if (MD && MD->getParent()->isLambda() &&
2227 MD->getOverloadedOperator() == OO_Call && MD->hasAttr<CUDADeviceAttr>() &&
2249 if (
VarDecl *VD = dyn_cast<VarDecl>(
D)) {
2250 if (VD->getType()->isReferenceType() &&
2253 VD->isUsableInConstantExpressions(
Context))
2268 bool RefersToCapturedVariable = isa<VarDecl, BindingDecl>(
D) &&
2272 Context, NNS, TemplateKWLoc,
D, RefersToCapturedVariable, NameInfo, Ty,
2300 const auto *FD = dyn_cast<FieldDecl>(
D);
2301 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
D))
2302 FD = IFD->getAnonField();
2306 if (FD->isBitField())
2312 if (
const auto *BD = dyn_cast<BindingDecl>(
D))
2313 if (
const auto *BE = BD->getBinding())
2329 Id.TemplateId->NumArgs);
2335 TemplateArgs = &Buffer;
2338 TemplateArgs =
nullptr;
2345 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
2352 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
2355 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
2360 bool DroppedSpecifier =
2363 ? diag::note_implicit_param_decl
2364 : diag::note_previous_decl;
2367 SemaRef.
PDiag(NoteID));
2370 << Typo << Ctx << DroppedSpecifier
2372 SemaRef.
PDiag(NoteID));
2379 bool isDefaultArgument =
2383 const auto *CurMethod = dyn_cast<CXXMethodDecl>(
CurContext);
2384 bool isInstance = CurMethod && CurMethod->isInstance() &&
2393 unsigned DiagID = diag::err_found_in_dependent_base;
2394 unsigned NoteID = diag::note_member_declared_at;
2396 DiagID =
getLangOpts().MSVCCompat ? diag::ext_found_later_in_class
2397 : diag::err_found_later_in_class;
2399 DiagID = diag::ext_found_in_dependent_base;
2400 NoteID = diag::note_dependent_member_use;
2425 if (isDefaultArgument && ((*R.
begin())->isCXXInstanceMember())) {
2441 unsigned diagnostic = diag::err_undeclared_var_use;
2442 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2446 diagnostic = diag::err_undeclared_use;
2447 diagnostic_suggest = diag::err_undeclared_use_suggest;
2457 if (isa<CXXRecordDecl>(DC)) {
2473 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
2490 assert(!ExplicitTemplateArgs &&
2491 "Diagnosing an empty lookup with explicit template args!");
2495 emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args,
2496 diagnostic, diagnostic_suggest);
2501 }
else if (S && (Corrected =
2505 bool DroppedSpecifier =
2509 bool AcceptableWithRecovery =
false;
2510 bool AcceptableWithoutRecovery =
false;
2519 dyn_cast<FunctionTemplateDecl>(CD))
2523 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2524 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2530 ND = Best->FoundDecl;
2531 Corrected.setCorrectionDecl(ND);
2535 Corrected.setCorrectionDecl(ND);
2547 Record = cast<CXXRecordDecl>(
2553 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
2554 isa<FunctionTemplateDecl>(UnderlyingND);
2560 AcceptableWithoutRecovery = isa<TypeDecl>(UnderlyingND) ||
2562 isa<ObjCInterfaceDecl>(UnderlyingND);
2566 AcceptableWithoutRecovery =
true;
2569 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2571 ? diag::note_implicit_param_decl
2572 : diag::note_previous_decl;
2575 PDiag(NoteID), AcceptableWithRecovery);
2579 << DroppedSpecifier << SS.
getRange(),
2580 PDiag(NoteID), AcceptableWithRecovery);
2583 return !AcceptableWithRecovery;
2619 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2627 auto DB = S.
Diag(
Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2628 DB << NameInfo.
getName() << RD;
2630 if (!ThisType.
isNull()) {
2633 Context,
nullptr, ThisType,
true,
2635 nullptr, NameInfo, TemplateArgs);
2652 bool HasTrailingLParen,
bool IsAddressOfOperand,
2654 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2655 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2656 "cannot be direct & operand and have a trailing lparen");
2685 if (
auto *VD = dyn_cast<ValueDecl>(R.
getFoundDecl())) {
2699 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2707 false, TemplateKWLoc,
2713 IsAddressOfOperand, TemplateArgs);
2717 !IvarLookupFollowUp);
2723 IsAddressOfOperand, TemplateArgs);
2727 if (IvarLookupFollowUp) {
2742 if (R.
empty() && HasTrailingLParen && II &&
2752 if (R.
empty() && !ADL) {
2755 TemplateKWLoc, TemplateArgs))
2760 if (IsInlineAsmIdentifier)
2770 "Typo correction callback misconfigured");
2781 std::nullopt,
nullptr, &TE)) {
2782 if (TE && KeywordReplacement) {
2784 auto BestTC = State.Consumer->getNextCorrection();
2785 if (BestTC.isKeyword()) {
2786 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2787 if (State.DiagHandler)
2788 State.DiagHandler(BestTC);
2792 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2798 return (
Expr*)
nullptr;
2800 State.Consumer->resetCorrectionStream();
2805 assert(!R.
empty() &&
2806 "DiagnoseEmptyLookup returned false but added no results");
2816 if (!
E.isInvalid() && !
E.get())
2823 assert(!R.
empty() || ADL);
2853 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2861 "There should only be one declaration found.");
2889 if (
const auto *CD = dyn_cast<CXXRecordDecl>(DC))
2890 if (CD->isInvalidDecl())
2901 unsigned DiagID = diag::err_typename_missing;
2903 DiagID = diag::ext_typename_missing;
2947 const auto *RD = dyn_cast<CXXRecordDecl>(
Member->getDeclContext());
2955 bool PointerConversions =
false;
2956 if (isa<FieldDecl>(
Member)) {
2960 DestRecordType, FromPtrType
2967 PointerConversions =
true;
2969 DestType = DestRecordType;
2970 FromRecordType = FromType;
2972 }
else if (
const auto *Method = dyn_cast<CXXMethodDecl>(
Member)) {
2973 if (!Method->isImplicitObjectMemberFunction())
2976 DestType = Method->getThisType().getNonReferenceType();
2977 DestRecordType = Method->getFunctionObjectParameterType();
2981 PointerConversions =
true;
2983 FromRecordType = FromType;
2984 DestType = DestRecordType;
2989 if (FromAS != DestAS) {
2994 if (PointerConversions)
3035 if (Qualifier && Qualifier->getAsType()) {
3037 assert(QType->
isRecordType() &&
"lookup done with non-record type");
3047 FromLoc, FromRange, &BasePath))
3050 if (PointerConversions)
3053 VK, &BasePath).
get();
3056 FromRecordType = QRecordType;
3067 FromLoc, FromRange, &BasePath,
3077 bool HasTrailingLParen) {
3079 if (!HasTrailingLParen)
3097 if (
D->isCXXClassMember())
3106 if (isa<UsingShadowDecl>(
D))
3107 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
3115 if (
const auto *FDecl = dyn_cast<FunctionDecl>(
D)) {
3117 if (FDecl->getBuiltinID() && FDecl->isImplicit())
3119 }
else if (!isa<FunctionTemplateDecl>(
D))
3132 bool AcceptInvalid) {
3136 if (isa<TypedefNameDecl>(
D)) {
3137 S.
Diag(
Loc, diag::err_unexpected_typedef) <<
D->getDeclName();
3141 if (isa<ObjCInterfaceDecl>(
D)) {
3142 S.
Diag(
Loc, diag::err_unexpected_interface) <<
D->getDeclName();
3146 if (isa<NamespaceDecl>(
D)) {
3147 S.
Diag(
Loc, diag::err_unexpected_namespace) <<
D->getDeclName();
3158 const auto *FD = dyn_cast<FunctionDecl>(R.
getFoundDecl());
3160 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3165 bool AcceptInvalidDecl) {
3203 bool AcceptInvalidDecl) {
3204 assert(
D &&
"Cannot refer to a NULL declaration");
3205 assert(!isa<FunctionTemplateDecl>(
D) &&
3206 "Cannot refer unambiguously to a function template");
3224 if (!isa<ValueDecl, UnresolvedUsingIfExistsDecl>(
D)) {
3237 auto *VD = cast<ValueDecl>(
D);
3240 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
3246 if (
auto *IndirectField = dyn_cast<IndirectFieldDecl>(VD);
3247 IndirectField && !IndirectField->isCXXClassMember())
3259 type =
type.getNonPackExpansionType();
3263#define ABSTRACT_DECL(kind)
3264#define VALUE(type, base)
3265#define DECL(type, base) case Decl::type:
3266#include "clang/AST/DeclNodes.inc"
3267 llvm_unreachable(
"invalid value decl kind");
3270 case Decl::ObjCAtDefsField:
3271 llvm_unreachable(
"forming non-member reference to ivar?");
3275 case Decl::EnumConstant:
3276 case Decl::UnresolvedUsingValue:
3277 case Decl::OMPDeclareReduction:
3278 case Decl::OMPDeclareMapper:
3287 case Decl::IndirectField:
3288 case Decl::ObjCIvar:
3290 "building reference to field in C?");
3300 case Decl::NonTypeTemplateParm: {
3302 type = reftype->getPointeeType();
3312 if (
type->isRecordType()) {
3313 type =
type.getUnqualifiedType().withConst();
3326 case Decl::VarTemplateSpecialization:
3327 case Decl::VarTemplatePartialSpecialization:
3328 case Decl::Decomposition:
3329 case Decl::OMPCapturedExpr:
3332 type->isVoidType()) {
3338 case Decl::ImplicitParam:
3339 case Decl::ParmVar: {
3349 if (!CapturedType.
isNull())
3350 type = CapturedType;
3362 case Decl::Function: {
3363 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3392 if (!cast<FunctionDecl>(VD)->hasPrototype() && isa<FunctionProtoType>(fty))
3401 case Decl::CXXDeductionGuide:
3402 llvm_unreachable(
"building reference to deduction guide");
3404 case Decl::MSProperty:
3406 case Decl::TemplateParamObject:
3412 case Decl::UnnamedGlobalConstant:
3416 case Decl::CXXMethod:
3421 dyn_cast<FunctionProtoType>(VD->getType()))
3429 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3435 case Decl::CXXConversion:
3436 case Decl::CXXDestructor:
3437 case Decl::CXXConstructor:
3449 if (VD->isInvalidDecl() &&
E)
3456 Target.resize(CharByteWidth * (Source.size() + 1));
3457 char *ResultPtr = &
Target[0];
3458 const llvm::UTF8 *ErrorPtr;
3460 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3470 Diag(
Loc, diag::ext_predef_outside_function);
3476 if (cast<DeclContext>(currentDecl)->isDependentContext())
3481 bool ForceElaboratedPrinting =
3485 unsigned Length = Str.length();
3487 llvm::APInt LengthI(32, Length + 1);
3527 if (Literal.hadError())
3531 if (Literal.isWide())
3537 else if (Literal.isUTF16())
3539 else if (Literal.isUTF32())
3548 if (Literal.isWide())
3550 else if (Literal.isUTF16())
3552 else if (Literal.isUTF32())
3554 else if (Literal.isUTF8())
3560 if (Literal.getUDSuffix().empty())
3570 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3588 using llvm::APFloat;
3589 APFloat Val(Format);
3592 if (RM == llvm::RoundingMode::Dynamic)
3593 RM = llvm::RoundingMode::NearestTiesToEven;
3594 APFloat::opStatus result = Literal.GetFloatValue(Val, RM);
3598 if ((result & APFloat::opOverflow) ||
3599 ((result & APFloat::opUnderflow) && Val.isZero())) {
3600 unsigned diagnostic;
3602 if (result & APFloat::opOverflow) {
3603 diagnostic = diag::warn_float_overflow;
3604 APFloat::getLargest(Format).toString(buffer);
3606 diagnostic = diag::warn_float_underflow;
3607 APFloat::getSmallest(Format).toString(buffer);
3610 S.
Diag(
Loc, diagnostic) << Ty << buffer.str();
3613 bool isExact = (result == APFloat::opOK);
3618 assert(
E &&
"Invalid expression");
3625 Diag(
E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3629 llvm::APSInt ValueAPS;
3640 bool ValueIsPositive =
3641 AllowZero ? ValueAPS.isNonNegative() : ValueAPS.isStrictlyPositive();
3642 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3644 <<
toString(ValueAPS, 10) << ValueIsPositive;
3664 SpellingBuffer.resize(Tok.
getLength() + 1);
3675 if (Literal.hadError)
3678 if (Literal.hasUDSuffix()) {
3686 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3689 if (Literal.isFloatingLiteral()) {
3714 !Literal.isImaginary)) {
3723 if (Literal.isFloatingLiteral()) {
3727 if (Literal.GetIntegerValue(ResultVal))
3740 unsigned Length = Literal.getUDSuffixOffset();
3747 false, StrTy, &TokLoc, 1);
3758 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
3759 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3760 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3761 Value = TokSpelling[I];
3770 llvm_unreachable(
"unexpected literal operator lookup result");
3776 if (Literal.isFixedPointLiteral()) {
3779 if (Literal.isAccum) {
3780 if (Literal.isHalf) {
3782 }
else if (Literal.isLong) {
3787 }
else if (Literal.isFract) {
3788 if (Literal.isHalf) {
3790 }
else if (Literal.isLong) {
3799 bool isSigned = !Literal.isUnsigned;
3803 llvm::APInt Val(bit_width, 0, isSigned);
3804 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3805 bool ValIsZero = Val.isZero() && !Overflowed;
3808 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3814 else if (Val.ugt(MaxVal) || Overflowed)
3819 }
else if (Literal.isFloatingLiteral()) {
3821 if (Literal.isHalf){
3829 }
else if (Literal.isFloat)
3831 else if (Literal.isLong)
3833 else if (Literal.isFloat16)
3835 else if (Literal.isFloat128)
3857 }
else if (!Literal.isIntegerLiteral()) {
3863 if (Literal.isSizeT)
3866 ? diag::warn_cxx20_compat_size_t_suffix
3867 : diag::ext_cxx23_size_t_suffix
3868 : diag::err_cxx23_size_t_suffix);
3875 if (Literal.isBitInt)
3879 : diag::ext_c23_bitint_suffix);
3888 unsigned BitsNeeded =
3889 Literal.isBitInt ? llvm::APInt::getSufficientBitsNeeded(
3890 Literal.getLiteralDigits(), Literal.getRadix())
3892 llvm::APInt ResultVal(BitsNeeded, 0);
3894 if (Literal.GetIntegerValue(ResultVal)) {
3900 "long long is not intmax_t?");
3907 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3914 Literal.isLong =
true;
3915 Literal.isLongLong =
false;
3922 if (Literal.MicrosoftInteger) {
3923 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3927 Width = Literal.MicrosoftInteger;
3929 !Literal.isUnsigned);
3935 if (Literal.isBitInt) {
3938 Width = std::max(ResultVal.getActiveBits(), 1u) +
3939 (Literal.isUnsigned ? 0u : 1u);
3943 unsigned int MaxBitIntWidth =
3945 if (Width > MaxBitIntWidth) {
3947 << Literal.isUnsigned;
3948 Width = MaxBitIntWidth;
3955 ResultVal = ResultVal.zextOrTrunc(Width);
3960 if (Literal.isSizeT) {
3961 assert(!Literal.MicrosoftInteger &&
3962 "size_t literals can't be Microsoft literals");
3967 if (ResultVal.isIntN(SizeTSize)) {
3969 if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
3971 else if (AllowUnsigned)
3977 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong &&
3983 if (ResultVal.isIntN(IntSize)) {
3985 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3987 else if (AllowUnsigned)
3994 if (Ty.
isNull() && !Literal.isLongLong && !Literal.isSizeT) {
3998 if (ResultVal.isIntN(LongSize)) {
4000 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
4002 else if (AllowUnsigned)
4007 const unsigned LongLongSize =
4012 ? diag::warn_old_implicitly_unsigned_long_cxx
4014 ext_old_implicitly_unsigned_long_cxx
4015 : diag::warn_old_implicitly_unsigned_long)
4016 << (LongLongSize > LongSize ? 0
4025 if (Ty.
isNull() && !Literal.isSizeT) {
4029 if (ResultVal.isIntN(LongLongSize)) {
4033 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
4034 (
getLangOpts().MSVCCompat && Literal.isLongLong)))
4036 else if (AllowUnsigned)
4038 Width = LongLongSize;
4044 ? diag::warn_cxx98_compat_longlong
4045 : diag::ext_cxx11_longlong);
4055 if (Literal.isSizeT)
4057 << Literal.isUnsigned;
4060 diag::ext_integer_literal_too_large_for_signed);
4065 if (ResultVal.getBitWidth() != Width)
4066 ResultVal = ResultVal.trunc(Width);
4072 if (Literal.isImaginary) {
4082 assert(
E &&
"ActOnParenExpr() missing expr");
4098 S.
Diag(
Loc, diag::err_vecstep_non_scalar_vector_type)
4104 "Scalar types should always be complete");
4113 return S.
Diag(
Loc, diag::err_builtin_non_vector_type)
4115 <<
"__builtin_vectorelements" <<
T << ArgRange;
4128 S.
Diag(
Loc, diag::err_ptrauth_type_disc_undiscriminated) <<
T << ArgRange;
4145 (TraitKind == UETT_SizeOf || TraitKind == UETT_AlignOf ||
4146 TraitKind == UETT_PreferredAlignOf)) {
4148 S.
Diag(
Loc, diag::ext_sizeof_alignof_function_type)
4156 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
4157 : diag::ext_sizeof_alignof_void_type;
4172 S.
Diag(
Loc, diag::err_sizeof_nonfragile_interface)
4173 <<
T << (TraitKind == UETT_SizeOf)
4190 const auto *ICE = dyn_cast<ImplicitCastExpr>(
E);
4191 if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
4194 S.
Diag(
Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
4196 << ICE->getSubExpr()->getType();
4204 bool IsUnevaluatedOperand =
4205 (ExprKind == UETT_SizeOf || ExprKind == UETT_DataSizeOf ||
4206 ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4207 ExprKind == UETT_VecStep);
4208 if (IsUnevaluatedOperand) {
4226 if (ExprKind == UETT_VecStep)
4230 if (ExprKind == UETT_VectorElements)
4252 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4255 diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4260 E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4279 if (ExprKind == UETT_SizeOf) {
4280 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(
E->
IgnoreParens())) {
4281 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4282 QualType OType = PVD->getOriginalType();
4287 Diag(PVD->getLocation(), diag::note_declared_at);
4295 if (
const auto *BO = dyn_cast<BinaryOperator>(
E->
IgnoreParens())) {
4319 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4321 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4322 D = ME->getMemberDecl();
4342 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(
D)) {
4345 if (!FD->getParent()->isCompleteDefinition()) {
4355 if (!FD->getType()->isReferenceType())
4375 assert(CSI !=
nullptr);
4379 const Type *Ty =
T.getTypePtr();
4381#define TYPE(Class, Base)
4382#define ABSTRACT_TYPE(Class, Base)
4383#define NON_CANONICAL_TYPE(Class, Base)
4384#define DEPENDENT_TYPE(Class, Base) case Type::Class:
4385#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
4386#include "clang/AST/TypeNodes.inc"
4393 case Type::ExtVector:
4394 case Type::ConstantMatrix:
4397 case Type::TemplateSpecialization:
4398 case Type::ObjCObject:
4399 case Type::ObjCInterface:
4400 case Type::ObjCObjectPointer:
4401 case Type::ObjCTypeParam:
4404 llvm_unreachable(
"type class is never variably-modified!");
4405 case Type::Elaborated:
4406 T = cast<ElaboratedType>(Ty)->getNamedType();
4408 case Type::Adjusted:
4409 T = cast<AdjustedType>(Ty)->getOriginalType();
4414 case Type::ArrayParameter:
4415 T = cast<ArrayParameterType>(Ty)->getElementType();
4420 case Type::BlockPointer:
4423 case Type::LValueReference:
4424 case Type::RValueReference:
4427 case Type::MemberPointer:
4430 case Type::ConstantArray:
4431 case Type::IncompleteArray:
4433 T = cast<ArrayType>(Ty)->getElementType();
4435 case Type::VariableArray: {
4443 (isa<CapturedRegionScopeInfo>(CSI) || isa<LambdaScopeInfo>(CSI)))
4449 case Type::FunctionProto:
4450 case Type::FunctionNoProto:
4455 case Type::UnaryTransform:
4456 case Type::Attributed:
4457 case Type::BTFTagAttributed:
4458 case Type::SubstTemplateTypeParm:
4459 case Type::MacroQualified:
4460 case Type::CountAttributed:
4462 T =
T.getSingleStepDesugaredType(Context);
4465 T = cast<TypedefType>(Ty)->
desugar();
4467 case Type::Decltype:
4468 T = cast<DecltypeType>(Ty)->
desugar();
4470 case Type::PackIndexing:
4471 T = cast<PackIndexingType>(Ty)->
desugar();
4474 T = cast<UsingType>(Ty)->
desugar();
4477 case Type::DeducedTemplateSpecialization:
4478 T = cast<DeducedType>(Ty)->getDeducedType();
4480 case Type::TypeOfExpr:
4481 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4484 T = cast<AtomicType>(Ty)->getValueType();
4510 if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
4511 ExprKind == UETT_OpenMPRequiredSimdAlign) {
4517 ? diag::warn_c2y_compat_alignof_incomplete_array
4518 : diag::ext_c2y_alignof_incomplete_array);
4522 if (ExprKind == UETT_VecStep)
4525 if (ExprKind == UETT_VectorElements)
4529 if (ExprKind == UETT_PtrAuthTypeDiscriminator)
4539 OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
4544 Diag(OpLoc, diag::err_sizeof_alignof_function_type) << KWName << ExprRange;
4552 Diag(OpLoc, diag::err_wasm_table_invalid_uett_operand)
4566 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
4570 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4571 DC = LSI->CallOperator;
4572 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4573 DC = CRSI->TheCapturedDecl;
4574 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4626 }
else if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
4628 }
else if (ExprKind == UETT_VecStep) {
4630 }
else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
4636 }
else if (ExprKind == UETT_VectorElements) {
4679 UETT_AlignOf, KWName);
4692 if (
V.get()->isTypeDependent())
4704 return CT->getElementType();
4707 if (
V.get()->getType()->isArithmeticType())
4708 return V.get()->getType();
4713 if (PR.
get() !=
V.get()) {
4719 S.
Diag(
Loc, diag::err_realimag_invalid_type) <<
V.get()->getType()
4720 << (IsReal ?
"__real" :
"__imag");
4731 default: llvm_unreachable(
"Unknown unary op!");
4732 case tok::plusplus: Opc = UO_PostInc;
break;
4733 case tok::minusminus: Opc = UO_PostDec;
break;
4752 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4755 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4762 auto *BaseNoParens =
Base->IgnoreParens();
4763 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4764 return MSProp->getPropertyDecl()->getType()->isArrayType();
4765 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4785 if (RTy->isIntegralOrUnscopedEnumerationType()) {
4787 Result = PT->getPointeeType();
4789 Result = AT->getElementType();
4792 Result = PT->getPointeeType();
4794 Result = AT->getElementType();
4807 auto *AS = cast<ArraySectionExpr>(base);
4808 if (AS->isOMPArraySection())
4820 if (isa<ParenListExpr>(base)) {
4824 base = result.
get();
4831 auto CheckAndReportCommaError = [
this, base, rbLoc](
Expr *
E) {
4832 if (isa<BinaryOperator>(
E) && cast<BinaryOperator>(
E)->isCommaOp()) {
4843 !isa<MatrixSubscriptExpr>(base)) {
4844 Diag(base->
getExprLoc(), diag::err_matrix_separate_incomplete_index)
4850 auto *matSubscriptE = dyn_cast<MatrixSubscriptExpr>(base);
4851 if (matSubscriptE) {
4852 assert(ArgExprs.size() == 1);
4853 if (CheckAndReportCommaError(ArgExprs.front()))
4856 assert(matSubscriptE->isIncomplete() &&
4857 "base has to be an incomplete matrix subscript");
4859 matSubscriptE->getRowIdx(),
4860 ArgExprs.front(), rbLoc);
4873 bool IsMSPropertySubscript =
false;
4876 if (!IsMSPropertySubscript) {
4880 base = result.
get();
4886 assert(ArgExprs.size() == 1);
4887 if (CheckAndReportCommaError(ArgExprs.front()))
4895 Expr *idx = ArgExprs[0];
4896 if ((isa<BinaryOperator>(idx) && cast<BinaryOperator>(idx)->isCommaOp()) ||
4897 (isa<CXXOperatorCallExpr>(idx) &&
4898 cast<CXXOperatorCallExpr>(idx)->getOperator() == OO_Comma)) {
4904 if (ArgExprs.size() == 1 &&
4905 ArgExprs[0]->getType()->isNonOverloadPlaceholderType()) {
4909 ArgExprs[0] = result.
get();
4919 !isa<PackExpansionExpr>(ArgExprs[0])) {
4921 base, ArgExprs.front(),
4934 if (IsMSPropertySubscript) {
4935 assert(ArgExprs.size() == 1);
4953 (ArgExprs.size() != 1 || isa<PackExpansionExpr>(ArgExprs[0]) ||
4954 ArgExprs[0]->getType()->isRecordType())))) {
4961 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
4962 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
4972 return InitSeq.
Perform(*
this, Entity, Kind,
E);
4986 RowIdx = RowR.
get();
5001 ColumnIdx = ColumnR.
get();
5006 auto IsIndexValid = [&](
Expr *IndexExpr,
unsigned Dim,
5007 bool IsColumnIdx) ->
Expr * {
5015 if (std::optional<llvm::APSInt> Idx =
5017 if ((*Idx < 0 || *Idx >= Dim)) {
5019 << IsColumnIdx << Dim;
5027 "should be able to convert any integer type to size type");
5028 return ConvExpr.
get();
5032 RowIdx = IsIndexValid(RowIdx, MTy->getNumRows(),
false);
5033 ColumnIdx = IsIndexValid(ColumnIdx, MTy->getNumColumns(),
true);
5034 if (!RowIdx || !ColumnIdx)
5038 MTy->getElementType(), RBLoc);
5041void Sema::CheckAddressOfNoDeref(
const Expr *
E) {
5048 while ((
Member = dyn_cast<MemberExpr>(StrippedExpr)) && !
Member->isArrow())
5049 StrippedExpr =
Member->getBase()->IgnoreParenImpCasts();
5051 LastRecord.PossibleDerefs.erase(StrippedExpr);
5062 if (isa<ArrayType>(ResultTy))
5065 if (ResultTy->
hasAttr(attr::NoDeref)) {
5066 LastRecord.PossibleDerefs.insert(
E);
5074 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
5079 while ((
Member = dyn_cast<MemberExpr>(
Base->IgnoreParenCasts())) &&
5083 if (
const auto *Ptr = dyn_cast<PointerType>(
Base->getType())) {
5084 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
5085 LastRecord.PossibleDerefs.insert(
E);
5101 for (
auto *Op : {LHSExp, RHSExp}) {
5102 Op = Op->IgnoreImplicit();
5103 if (Op->getType()->isArrayType() && !Op->isLValue())
5126 Expr *BaseExpr, *IndexExpr;
5161 Diag(LLoc, diag::err_subscript_nonfragile_interface)
5185 LHSExp = Materialized.
get();
5194 Qualifiers Combined = BaseQuals + MemberQuals;
5195 if (Combined != MemberQuals)
5206 CK_ArrayToPointerDecay).
get();
5212 }
else if (RHSTy->isArrayType()) {
5217 CK_ArrayToPointerDecay).
get();
5224 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
5229 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
5235 std::optional<llvm::APSInt> IntegerContantExpr =
5237 if (!IntegerContantExpr.has_value() ||
5238 IntegerContantExpr.value().isNegative())
5254 Diag(LLoc, diag::ext_gnu_subscript_void_type)
5265 diag::err_subscript_incomplete_or_sizeless_type, BaseExpr))
5278 auto *CSI = dyn_cast<CapturingScopeInfo>(*I);
5282 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
5283 DC = LSI->CallOperator;
5284 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
5285 DC = CRSI->TheCapturedDecl;
5286 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
5304 bool SkipImmediateInvocations) {
5306 assert(!RewrittenInit &&
"Should not have a rewritten init expression yet");
5310 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
5311 Diag(CallLoc, diag::note_recursive_default_argument_used_here);
5316 Diag(CallLoc, diag::err_use_of_default_argument_to_function_declared_later)
5319 diag::note_default_argument_declared_here);
5324 assert(!RewrittenInit &&
"Should not have a rewitten init expression yet");
5330 assert(
Init &&
"default argument but no initializer?");
5339 if (
auto *InitWithCleanup = dyn_cast<ExprWithCleanups>(
Init)) {
5346 assert(!InitWithCleanup->getNumObjects() &&
5347 "default argument expression has capturing blocks?");
5360 SkipImmediateInvocations;
5371 bool HasImmediateCalls =
false;
5376 HasImmediateCalls |= FD->isImmediateFunction();
5382 HasImmediateCalls |= FD->isImmediateFunction();
5391 HasImmediateCalls =
true;
5402 return VisitCXXMethodDecl(
E->getCallOperator());
5406 return TraverseStmt(
E->getExpr());
5410 return TraverseStmt(
E->getExpr());
5433 if (
E->getParentContext() == SemaRef.CurContext)
5435 return getDerived().RebuildSourceLocExpr(
E->getIdentKind(),
E->
getType(),
5437 SemaRef.CurContext);
5444 assert(Param->
hasDefaultArg() &&
"can't build nonexistent default arg");
5448 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5449 InitializationContext =
5451 if (!InitializationContext.has_value())
5452 InitializationContext.emplace(CallLoc, Param,
CurContext);
5478 if (!NestedDefaultChecking)
5479 V.TraverseDecl(Param);
5483 if (
V.HasImmediateCalls || InLifetimeExtendingContext) {
5484 if (
V.HasImmediateCalls)
5493 Res = Immediate.TransformInitializer(Param->
getInit(),
5507 CallLoc, FD, Param,
Init,
5508 NestedDefaultChecking))
5512 Init, InitializationContext->Context);
5516 assert(Field->hasInClassInitializer());
5519 if (Field->isInvalidDecl())
5524 auto *ParentRD = cast<CXXRecordDecl>(Field->getParent());
5526 std::optional<ExpressionEvaluationContextRecord::InitializationContext>
5527 InitializationContext =
5529 if (!InitializationContext.has_value())
5539 if (!Field->getInClassInitializer()) {
5545 ClassPattern->
lookup(Field->getDeclName());
5548 for (
auto *L : Lookup) {
5549 if ((Pattern = dyn_cast<FieldDecl>(L)))
5552 assert(Pattern &&
"We must have set the Pattern!");
5556 Field->setInvalidDecl();
5568 if (!NestedDefaultChecking)
5569 V.TraverseDecl(Field);
5570 if (
V.HasImmediateCalls) {
5574 NestedDefaultChecking;
5579 Res = Immediate.TransformInitializer(Field->getInClassInitializer(),
5585 Field->setInvalidDecl();
5591 if (Field->getInClassInitializer()) {
5593 if (!NestedDefaultChecking)
5601 if (Res.isInvalid()) {
5602 Field->setInvalidDecl();
5608 Field, InitializationContext->Context,
5627 Diag(
Loc, diag::err_default_member_initializer_not_yet_parsed)
5628 << OutermostClass << Field;
5629 Diag(Field->getEndLoc(),
5630 diag::note_default_member_initializer_not_yet_parsed);
5633 Field->setInvalidDecl();
5641 if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
5643 else if (Fn && Fn->getType()->isBlockPointerType())
5646 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5647 if (Method->isInstance())
5662 FunctionName(FuncName) {}
5664 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
5673 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
5674 return std::make_unique<FunctionCallCCC>(*
this);
5694 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
5695 if (Corrected.isOverloaded()) {
5705 ND = Best->FoundDecl;
5706 Corrected.setCorrectionDecl(ND);
5712 ND = ND->getUnderlyingDecl();
5713 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
5724 if (!isa<ParenExpr>(Fn))
5727 Fn = Fn->IgnoreParens();
5729 auto *UO = dyn_cast<UnaryOperator>(Fn);
5730 if (!UO || UO->getOpcode() != clang::UO_AddrOf)
5732 if (
auto *DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr()->IgnoreParens())) {
5733 return DRE->hasQualifier();
5735 if (
auto *OVL = dyn_cast<OverloadExpr>(UO->getSubExpr()->IgnoreParens()))
5736 return OVL->getQualifier();
5746 bool IsExecConfig) {
5757 bool HasExplicitObjectParameter =
5759 unsigned ExplicitObjectParameterOffset = HasExplicitObjectParameter ? 1 : 0;
5763 unsigned FnKind = Fn->getType()->isBlockPointerType()
5770 if (Args.size() < NumParams) {
5771 if (Args.size() < MinArgs) {
5776 ? diag::err_typecheck_call_too_few_args_suggest
5777 : diag::err_typecheck_call_too_few_args_at_least_suggest;
5780 << FnKind << MinArgs - ExplicitObjectParameterOffset
5781 <<
static_cast<unsigned>(Args.size()) -
5782 ExplicitObjectParameterOffset
5784 }
else if (MinArgs - ExplicitObjectParameterOffset == 1 && FDecl &&
5789 ? diag::err_typecheck_call_too_few_args_one
5790 : diag::err_typecheck_call_too_few_args_at_least_one)
5791 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
5792 << HasExplicitObjectParameter << Fn->getSourceRange();
5795 ? diag::err_typecheck_call_too_few_args
5796 : diag::err_typecheck_call_too_few_args_at_least)
5797 << FnKind << MinArgs - ExplicitObjectParameterOffset
5798 <<
static_cast<unsigned>(Args.size()) -
5799 ExplicitObjectParameterOffset
5800 << HasExplicitObjectParameter << Fn->getSourceRange();
5803 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5811 assert((
Call->getNumArgs() == NumParams) &&
5812 "We should have reserved space for the default arguments before!");
5817 if (Args.size() > NumParams) {
5823 ? diag::err_typecheck_call_too_many_args_suggest
5824 : diag::err_typecheck_call_too_many_args_at_most_suggest;
5827 << FnKind << NumParams - ExplicitObjectParameterOffset
5828 <<
static_cast<unsigned>(Args.size()) -
5829 ExplicitObjectParameterOffset
5831 }
else if (NumParams - ExplicitObjectParameterOffset == 1 && FDecl &&
5834 Diag(Args[NumParams]->getBeginLoc(),
5835 MinArgs == NumParams
5836 ? diag::err_typecheck_call_too_many_args_one
5837 : diag::err_typecheck_call_too_many_args_at_most_one)
5838 << FnKind << FDecl->
getParamDecl(ExplicitObjectParameterOffset)
5839 <<
static_cast<unsigned>(Args.size()) -
5840 ExplicitObjectParameterOffset
5841 << HasExplicitObjectParameter << Fn->getSourceRange()
5843 Args.back()->getEndLoc());
5845 Diag(Args[NumParams]->getBeginLoc(),
5846 MinArgs == NumParams
5847 ? diag::err_typecheck_call_too_many_args
5848 : diag::err_typecheck_call_too_many_args_at_most)
5849 << FnKind << NumParams - ExplicitObjectParameterOffset
5850 <<
static_cast<unsigned>(Args.size()) -
5851 ExplicitObjectParameterOffset
5852 << HasExplicitObjectParameter << Fn->getSourceRange()
5854 Args.back()->getEndLoc());
5857 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5862 Call->shrinkNumArgs(NumParams);
5873 unsigned TotalNumArgs = AllArgs.size();
5874 for (
unsigned i = 0; i < TotalNumArgs; ++i)
5875 Call->setArg(i, AllArgs[i]);
5877 Call->computeDependence();
5886 bool IsListInitialization) {
5891 for (
unsigned i = FirstParam; i < NumParams; i++) {
5896 if (ArgIx < Args.size()) {
5897 Arg = Args[ArgIx++];
5900 diag::err_call_incomplete_argument, Arg))
5904 bool CFAudited =
false;
5906 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5907 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5910 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5911 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5917 BE->getBlockDecl()->setDoesNotEscape();
5930 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
5936 assert(Param &&
"can't use default arguments without a known callee");
5948 CheckArrayAccess(Arg);
5953 AllArgs.push_back(Arg);
5962 for (
Expr *A : Args.slice(ArgIx)) {
5966 AllArgs.push_back(arg.get());
5971 for (
Expr *A : Args.slice(ArgIx)) {
5974 AllArgs.push_back(Arg.
get());
5979 for (
Expr *A : Args.slice(ArgIx))
5980 CheckArrayAccess(A);
5988 TL = DTL.getOriginalLoc();
5991 << ATL.getLocalSourceRange();
5997 const Expr *ArgExpr) {
6027 Diag(CallLoc, diag::warn_static_array_too_small)
6035 std::optional<CharUnits> ArgSize =
6037 std::optional<CharUnits> ParmSize =
6039 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
6040 Diag(CallLoc, diag::warn_static_array_too_small)
6042 << (
unsigned)ParmSize->getQuantity() << 1;
6056 if (!placeholder)
return false;
6058 switch (placeholder->
getKind()) {
6060#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6061 case BuiltinType::Id:
6062#include "clang/Basic/OpenCLImageTypes.def"
6063#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6064 case BuiltinType::Id:
6065#include "clang/Basic/OpenCLExtensionTypes.def"
6068#define SVE_TYPE(Name, Id, SingletonId) \
6069 case BuiltinType::Id:
6070#include "clang/Basic/AArch64SVEACLETypes.def"
6071#define PPC_VECTOR_TYPE(Name, Id, Size) \
6072 case BuiltinType::Id:
6073#include "clang/Basic/PPCTypes.def"
6074#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6075#include "clang/Basic/RISCVVTypes.def"
6076#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6077#include "clang/Basic/WebAssemblyReferenceTypes.def"
6078#define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
6079#include "clang/Basic/AMDGPUTypes.def"
6080#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
6081#define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
6082#include "clang/AST/BuiltinTypes.def"
6085 case BuiltinType::UnresolvedTemplate:
6088 case BuiltinType::Overload:
6093 case BuiltinType::ARCUnbridgedCast:
6097 case BuiltinType::PseudoObject:
6102 case BuiltinType::UnknownAny:
6106 case BuiltinType::BoundMember:
6107 case BuiltinType::BuiltinFn:
6108 case BuiltinType::IncompleteMatrixIdx:
6109 case BuiltinType::ArraySection:
6110 case BuiltinType::OMPArrayShaping:
6111 case BuiltinType::OMPIterator:
6115 llvm_unreachable(
"bad builtin type kind");
6121 bool hasInvalid =
false;
6122 for (
size_t i = 0, e = args.size(); i != e; i++) {
6125 if (result.
isInvalid()) hasInvalid =
true;
6126 else args[i] = result.
get();
6154 bool NeedsNewDecl =
false;
6167 if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
6171 OverloadParams.push_back(ParamType);
6179 NeedsNewDecl =
true;
6192 OverloadParams, EPI);
6201 FT = cast<FunctionProtoType>(OverloadTy);
6202 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
6209 Params.push_back(Parm);
6211 OverloadDecl->setParams(Params);
6213 return OverloadDecl;
6224 !Callee->isVariadic())
6226 if (Callee->getMinRequiredArguments() > ArgExprs.size())
6229 if (
const EnableIfAttr *
Attr =
6230 S.
CheckEnableIf(Callee, Fn->getBeginLoc(), ArgExprs,
true)) {
6231 S.
Diag(Fn->getBeginLoc(),
6232 isa<CXXMethodDecl>(Callee)
6233 ? diag::err_ovl_no_viable_member_function_in_call
6234 : diag::err_ovl_no_viable_function_in_call)
6235 << Callee << Callee->getSourceRange();
6236 S.
Diag(Callee->getLocation(),
6237 diag::note_ovl_candidate_disabled_by_function_cond_attr)
6238 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
6246 const auto GetFunctionLevelDCIfCXXClass =
6254 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
6255 return MD->
getParent()->getCanonicalDecl();
6258 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
6259 return RD->getCanonicalDecl();
6266 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
6267 if (!CurParentClass)
6274 assert(NamingClass &&
"Must have naming class even for implicit access");
6280 return CurParentClass == NamingClass ||
6329 if (
Call->getNumArgs() != 1)
6332 const Expr *
E =
Call->getCallee()->IgnoreParenImpCasts();
6333 if (!
E || isa<UnresolvedLookupExpr>(
E))
6335 const DeclRefExpr *DRE = dyn_cast_if_present<DeclRefExpr>(
E);
6348 if (BuiltinID != Builtin::BImove && BuiltinID != Builtin::BIforward)
6351 S.
Diag(DRE->
getLocation(), diag::warn_unqualified_call_to_std_cast_function)
6362 if (
Call.isInvalid())
6367 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn);
6368 ULE && ULE->hasExplicitTemplateArgs() &&
6369 ULE->decls_begin() == ULE->decls_end()) {
6371 ? diag::warn_cxx17_compat_adl_only_template_id
6372 : diag::ext_adl_only_template_id)
6380 if (
const auto *CE = dyn_cast<CallExpr>(
Call.get()))
6386 if (
auto *DRE = dyn_cast<DeclRefExpr>(Fn->IgnoreParens());
6387 DRE &&
Call.get()->isValueDependent()) {
6396 Expr *ExecConfig,
bool IsExecConfig,
6397 bool AllowRecovery) {
6408 if (isa<CXXPseudoDestructorExpr>(Fn)) {
6409 if (!ArgExprs.empty()) {
6411 Diag(Fn->getBeginLoc(), diag::err_pseudo_dtor_call_with_args)
6414 ArgExprs.back()->getEndLoc()));
6431 cast<CallExpr>(ExecConfig), ArgExprs,
6437 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->IgnoreParens()),
6446 if (Fn->getType()->isRecordType())
6458 RParenLoc, ExecConfig, IsExecConfig,
6475 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
6478 RParenLoc, ExecConfig, IsExecConfig,
6490 Expr *NakedFn = Fn->IgnoreParens();
6492 bool CallingNDeclIndirectly =
false;
6494 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
6495 if (UnOp->getOpcode() == UO_AddrOf) {
6496 CallingNDeclIndirectly =
true;
6501 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
6502 NDecl = DRE->getDecl();
6515 nullptr, DRE->isNonOdrUse());
6518 }
else if (
auto *ME = dyn_cast<MemberExpr>(NakedFn))
6519 NDecl = ME->getMemberDecl();
6521 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
6523 FD,
true, Fn->getBeginLoc()))
6535 FD->getBuiltinID()) {
6536 for (
unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size();
6540 !ArgExprs[Idx]->getType()->isPointerType())
6544 auto ArgTy = ArgExprs[Idx]->getType();
6545 auto ArgPtTy = ArgTy->getPointeeType();
6546 auto ArgAS = ArgPtTy.getAddressSpace();
6549 bool NeedImplicitASC =
6554 if (!NeedImplicitASC)
6558 if (ArgExprs[Idx]->isGLValue()) {
6560 Context, ArgExprs[Idx]->getType(), CK_NoOp, ArgExprs[Idx],
6565 Qualifiers ArgPtQuals = ArgPtTy.getQualifiers();
6575 CK_AddressSpaceConversion)
6584 assert((Fn->containsErrors() ||
6585 llvm::any_of(ArgExprs,
6586 [](
clang::Expr *
E) { return E->containsErrors(); })) &&
6587 "should only occur in error-recovery path.");
6592 ExecConfig, IsExecConfig);
6603 assert(BuiltInDecl &&
"failed to find builtin declaration");
6607 assert(DeclRef.
isUsable() &&
"Builtin reference cannot fail");
6612 assert(!
Call.isInvalid() &&
"Call to builtin cannot fail!");
6632 Diag(BuiltinLoc, diag::err_invalid_astype_of_different_size)
6650 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
6651 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
6655 if (FDecl->
hasAttr<AnyX86InterruptAttr>()) {
6656 Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
6659 if (FDecl->
hasAttr<ARMInterruptAttr>()) {
6660 Diag(Fn->getExprLoc(), diag::err_arm_interrupt_called);
6669 if (Caller->hasAttr<AnyX86InterruptAttr>() ||
6670 Caller->hasAttr<AnyX86NoCallerSavedRegistersAttr>()) {
6672 bool HasNonGPRRegisters =
6674 if (HasNonGPRRegisters &&
6675 (!FDecl || !FDecl->
hasAttr<AnyX86NoCallerSavedRegistersAttr>())) {
6676 Diag(Fn->getExprLoc(), diag::warn_anyx86_excessive_regsave)
6677 << (Caller->hasAttr<AnyX86InterruptAttr>() ? 0 : 1);
6690 Fn->getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn)) {
6717 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
6718 << Fn->getType() << Fn->getSourceRange());
6732 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
6733 << Fn->getType() << Fn->getSourceRange());
6740 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
6741 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
6745 assert(UsesADL == ADLCallKind::NotADL &&
6746 "CUDAKernelCallExpr should not use ADL");
6767 TheCall = dyn_cast<CallExpr>(
Result.get());
6768 bool CorrectedTypos = TheCall != TheOldCall;
6769 if (!TheCall)
return Result;
6776 if (CorrectedTypos && Args.size() < NumParams) {
6792 ExprResult E = CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
6801 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
6802 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
6803 << FDecl << Fn->getSourceRange());
6809 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
6810 << Fn->getType() << Fn->getSourceRange());
6813 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
6814 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
6815 << FDecl << Fn->getSourceRange());
6830 for (
const Expr *Arg : Args) {
6831 if (Arg && Arg->getType()->isWebAssemblyTableType()) {
6833 diag::err_wasm_table_as_function_parameter));
6843 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
6851 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
6852 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
6853 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
6872 if (!Proto && !Args.empty() &&
6876 Diag(LParenLoc, diag::warn_strict_uses_without_prototype)
6877 << (FDecl !=
nullptr) << FDecl;
6880 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
6881 Expr *Arg = Args[i];
6883 if (Proto && i < Proto->getNumParams()) {
6885 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
6903 diag::err_call_incomplete_argument, Arg))
6911 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
6912 if (!isa<RequiresExprBodyDecl>(
CurContext) &&
6913 Method->isImplicitObjectMemberFunction())
6914 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
6915 << Fn->getSourceRange() << 0);
6923 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
6924 if (
const auto *RT =
6925 dyn_cast<RecordType>(Args[i]->getType().getCanonicalType())) {
6926 if (RT->getDecl()->isOrContainsUnion())
6927 Diag(Args[i]->getBeginLoc(), diag::warn_cmse_nonsecure_union)
6938 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
6941 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
6943 if (CheckPointerCall(NDecl, TheCall, Proto))
6946 if (CheckOtherCall(TheCall, Proto))
6956 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
6957 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
6975 diag::err_array_incomplete_or_sizeless_type,
6998 ? diag::err_variable_object_no_init
6999 : diag::err_compound_literal_with_vla_type;
7006 diag::err_typecheck_decl_incomplete_type,
7021 LiteralExpr =
Result.get();
7049 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
7050 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
7056 VK, LiteralExpr, isFileScope);
7068 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
7104 bool DiagnosedArrayDesignator =
false;
7105 bool DiagnosedNestedDesignator =
false;
7106 bool DiagnosedMixedDesignator =
false;
7110 for (
unsigned I = 0,
E = InitArgList.size(); I !=
E; ++I) {
7111 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
7113 FirstDesignator = DIE->getBeginLoc();
7118 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
7119 DiagnosedNestedDesignator =
true;
7120 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
7121 << DIE->getDesignatorsSourceRange();
7124 for (
auto &Desig : DIE->designators()) {
7125 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
7126 DiagnosedArrayDesignator =
true;
7127 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
7128 << Desig.getSourceRange();
7132 if (!DiagnosedMixedDesignator &&
7133 !isa<DesignatedInitExpr>(InitArgList[0])) {
7134 DiagnosedMixedDesignator =
true;
7135 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7136 << DIE->getSourceRange();
7137 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
7138 << InitArgList[0]->getSourceRange();
7141 isa<DesignatedInitExpr>(InitArgList[0])) {
7142 DiagnosedMixedDesignator =
true;
7143 auto *DIE = cast<DesignatedInitExpr>(InitArgList[0]);
7144 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
7145 << DIE->getSourceRange();
7146 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
7147 << InitArgList[I]->getSourceRange();
7151 if (FirstDesignator.
isValid()) {
7155 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
7157 ? diag::warn_cxx17_compat_designated_init
7158 : diag::ext_cxx_designated_init);
7160 Diag(FirstDesignator, diag::ext_designated_init);
7175 for (
unsigned I = 0,
E = InitArgList.size(); I !=
E; ++I) {
7176 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
7183 InitArgList[I] = result.
get();
7217 llvm_unreachable(
"member pointer type in C");
7226 if (SrcAS != DestAS)
7227 return CK_AddressSpaceConversion;
7234 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
7239 return CK_CPointerToObjCPointerCast;
7241 return CK_BlockPointerToObjCPointerCast;
7243 return CK_PointerToBoolean;
7245 return CK_PointerToIntegral;
7251 llvm_unreachable(
"illegal cast from pointer");
7253 llvm_unreachable(
"Should have returned before this");
7258 return CK_FixedPointCast;
7260 return CK_FixedPointToBoolean;
7262 return CK_FixedPointToIntegral;
7264 return CK_FixedPointToFloating;
7268 diag::err_unimplemented_conversion_with_fixed_point_type)
7270 return CK_IntegralCast;
7275 llvm_unreachable(
"illegal cast to pointer type");
7277 llvm_unreachable(
"Should have returned before this");
7287 return CK_NullToPointer;
7288 return CK_IntegralToPointer;
7290 return CK_IntegralToBoolean;
7292 return CK_IntegralCast;
7294 return CK_IntegralToFloating;
7299 return CK_IntegralRealToComplex;
7303 CK_IntegralToFloating);
7304 return CK_FloatingRealToComplex;
7306 llvm_unreachable(
"member pointer type in C");
7308 return CK_IntegralToFixedPoint;
7310 llvm_unreachable(
"Should have returned before this");
7315 return CK_FloatingCast;
7317 return CK_FloatingToBoolean;
7319 return CK_FloatingToIntegral;
7324 return CK_FloatingRealToComplex;
7328 CK_FloatingToIntegral);
7329 return CK_IntegralRealToComplex;
7333 llvm_unreachable(
"valid float->pointer cast?");
7335 llvm_unreachable(
"member pointer type in C");
7337 return CK_FloatingToFixedPoint;
7339 llvm_unreachable(
"Should have returned before this");
7344 return CK_FloatingComplexCast;
7346 return CK_FloatingComplexToIntegralComplex;
7350 return CK_FloatingComplexToReal;
7352 return CK_FloatingCast;
7355 return CK_FloatingComplexToBoolean;
7359 CK_FloatingComplexToReal);
7360 return CK_FloatingToIntegral;
7364 llvm_unreachable(
"valid complex float->pointer cast?");
7366 llvm_unreachable(
"member pointer type in C");
7369 diag::err_unimplemented_conversion_with_fixed_point_type)
7371 return CK_IntegralCast;
7373 llvm_unreachable(
"Should have returned before this");
7378 return CK_IntegralComplexToFloatingComplex;
7380 return CK_IntegralComplexCast;
7384 return CK_IntegralComplexToReal;
7386 return CK_IntegralCast;
7389 return CK_IntegralComplexToBoolean;
7393 CK_IntegralComplexToReal);
7394 return CK_IntegralToFloating;
7398 llvm_unreachable(
"valid complex int->pointer cast?");
7400 llvm_unreachable(
"member pointer type in C");
7403 diag::err_unimplemented_conversion_with_fixed_point_type)
7405 return CK_IntegralCast;
7407 llvm_unreachable(
"Should have returned before this");
7410 llvm_unreachable(
"Unhandled scalar cast");
7417 len = vecType->getNumElements();
7418 eltType = vecType->getElementType();
7425 if (!
type->isRealType())
return false;
7435 auto ValidScalableConversion = [](
QualType FirstType,
QualType SecondType) {
7439 const auto *VecTy = SecondType->getAs<
VectorType>();
7443 return ValidScalableConversion(srcTy, destTy) ||
7444 ValidScalableConversion(destTy, srcTy);
7454 return matSrcType->
getNumRows() == matDestType->getNumRows() &&
7455 matSrcType->
getNumColumns() == matDestType->getNumColumns();
7461 uint64_t SrcLen, DestLen;
7474 return (SrcLen * SrcEltSize == DestLen * DestEltSize);
7479 "expected at least one type to be a vector here");
7481 bool IsSrcTyAltivec =
7497 return (IsSrcTyAltivec || IsDestTyAltivec);
7524 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
7529 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
7546 return Diag(R.
getBegin(), diag::err_invalid_conversion_between_matrixes)
7547 << DestTy << SrcTy << R;
7551 diag::err_invalid_conversion_between_matrix_and_type)
7552 << SrcTy << DestTy << R;
7555 diag::err_invalid_conversion_between_matrix_and_type)
7556 << DestTy << SrcTy << R;
7559 Kind = CK_MatrixCast;
7565 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
7571 diag::err_invalid_conversion_between_vectors :
7572 diag::err_invalid_conversion_between_vector_and_integer)
7573 << VectorTy << Ty << R;
7576 diag::err_invalid_conversion_between_vector_and_scalar)
7577 << VectorTy << Ty << R;
7586 if (DestElemTy == SplattedExpr->
getType())
7587 return SplattedExpr;
7600 CK_BooleanToSignedIntegral);
7601 SplattedExpr = CastExprRes.
get();
7602 CK = CK_IntegralToFloating;
7604 CK = CK_BooleanToSignedIntegral;
7611 SplattedExpr = CastExprRes.
get();
7630 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
7631 << DestTy << SrcTy << R;
7643 diag::err_invalid_conversion_between_vector_and_scalar)
7644 << DestTy << SrcTy << R;
7646 Kind = CK_VectorSplat;
7654 assert(!
D.isInvalidType() && (
CastExpr !=
nullptr) &&
7655 "ActOnCastExpr(): missing type or expr");
7658 if (
D.isInvalidType())
7677 bool isVectorLiteral =
false;
7692 isVectorLiteral =
true;
7695 isVectorLiteral =
true;
7700 if (isVectorLiteral)
7706 if (isa<ParenListExpr>(
CastExpr)) {
7727 assert((isa<ParenListExpr>(
E) || isa<ParenExpr>(
E)) &&
7728 "Expected paren or paren list expression");
7735 LiteralLParenLoc = PE->getLParenLoc();
7736 LiteralRParenLoc = PE->getRParenLoc();
7737 exprs = PE->getExprs();
7738 numExprs = PE->getNumExprs();
7740 LiteralLParenLoc = cast<ParenExpr>(
E)->getLParen();
7741 LiteralRParenLoc = cast<ParenExpr>(
E)->getRParen();
7742 subExpr = cast<ParenExpr>(
E)->getSubExpr();
7765 if (numExprs == 1) {
7768 if (Literal.isInvalid())
7774 else if (numExprs < numElems) {
7776 diag::err_incorrect_number_of_vector_initializers);
7780 initExprs.append(exprs, exprs + numExprs);
7789 if (Literal.isInvalid())
7796 initExprs.append(exprs, exprs + numExprs);
7801 initExprs, LiteralRParenLoc);
7814 for (
unsigned i = 1, e =
E->getNumExprs(); i != e && !
Result.isInvalid(); ++i)
7831 const Expr *NullExpr = LHSExpr;
7832 const Expr *NonPointerExpr = RHSExpr;
7839 NonPointerExpr = LHSExpr;
7861 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
7862 << NonPointerExpr->
getType() << DiagType
7874 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
7882 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
7916 bool IsBlockPointer =
false;
7920 IsBlockPointer =
true;
7945 ResultAddrSpace = LAddrSpace;
7947 ResultAddrSpace = RAddrSpace;
7949 S.
Diag(
Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
7956 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
7971 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
7973 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
7981 lhptee, rhptee,
false,
false,
7984 if (CompositeTy.
isNull()) {
8001 S.
Diag(
Loc, diag::ext_typecheck_cond_incompatible_pointers)
8012 QualType ResultTy = [&, ResultAddrSpace]() {
8018 .withCVRQualifiers(MergedCVRQual);
8047 S.
Diag(
Loc, diag::err_typecheck_cond_incompatible_operands)
8100 bool IsIntFirstExpr) {
8102 !Int.get()->getType()->isIntegerType())
8105 Expr *Expr1 = IsIntFirstExpr ? Int.get() : PointerExpr;
8106 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.get();
8108 S.
Diag(
Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
8112 CK_IntegralToPointer);
8146 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8152 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
8158 if (LHSType == RHSType)
8167 return handleIntegerConversion<doIntegralCast, doIntegralCast>
8168 (S, LHS, RHS, LHSType, RHSType,
false);
8202 llvm::raw_svector_ostream OS(Str);
8203 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
8204 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8205 << CondTy << OS.str();
8226 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
8244 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
8245 << CondTy << VecResTy;
8250 QualType RVE = RV->getElementType();
8253 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
8254 << CondTy << VecResTy;
8280 bool IsBoolVecLang =
8304 if (
const CallExpr *CE = dyn_cast<CallExpr>(
E)) {
8305 QualType Ty = CE->getCallee()->getType();
8343 "should only occur in error-recovery path.");
8378 Diag(QuestionLoc, diag::err_wasm_table_conditional_expression)
8387 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
8406 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
8422 if (LHSRT->getDecl() == RHSRT->getDecl())
8466 if (!compositeType.
isNull())
8467 return compositeType;
8501 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
8540 const Expr **RHSExprs) {
8545 if (
const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(
E)) {
8546 E = MTE->getSubExpr();
8551 if (
const auto *OP = dyn_cast<BinaryOperator>(
E);
8553 *Opcode = OP->getOpcode();
8554 *RHSExprs = OP->getRHS();
8559 if (
const auto *
Call = dyn_cast<CXXOperatorCallExpr>(
E)) {
8560 if (
Call->getNumArgs() != 2)
8566 if (OO < OO_Plus || OO > OO_Arrow ||
8567 OO == OO_PlusPlus || OO == OO_MinusMinus)
8573 *RHSExprs =
Call->getArg(1);
8589 if (
const auto *OP = dyn_cast<BinaryOperator>(
E))
8590 return OP->isComparisonOp() || OP->isLogicalOp();
8591 if (
const auto *OP = dyn_cast<UnaryOperator>(
E))
8592 return OP->getOpcode() == UO_LNot;
8607 const Expr *RHSExpr) {
8609 const Expr *CondRHS;
8620 ? diag::warn_precedence_bitwise_conditional
8621 : diag::warn_precedence_conditional;
8623 Self.Diag(OpLoc, DiagID)
8629 Self.PDiag(diag::note_precedence_silence)
8634 Self.PDiag(diag::note_precedence_conditional_first),
8645 auto GetNullability = [](
QualType Ty) {
8646 std::optional<NullabilityKind> Kind = Ty->getNullability();
8656 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
8664 MergedKind = RHSKind;
8671 MergedKind = RHSKind;
8673 MergedKind = LHSKind;
8679 if (GetNullability(ResTy) == MergedKind)
8714 CondExpr = CondResult.
get();
8715 LHSExpr = LHSResult.
get();
8716 RHSExpr = RHSResult.
get();
8722 Expr *commonExpr =
nullptr;
8724 commonExpr = CondExpr;
8731 commonExpr = result.
get();
8745 commonExpr = commonRes.
get();
8755 commonExpr = MatExpr.
get();
8763 LHSExpr = CondExpr = opaqueValue;
8769 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
8771 VK, OK, QuestionLoc);
8779 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
8787 RHS.get(), result, VK, OK);
8790 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
8791 ColonLoc, result, VK, OK);
8795 unsigned FromAttributes = 0, ToAttributes = 0;
8796 if (
const auto *FromFn =
8800 if (
const auto *ToFn =
8805 return FromAttributes != ToAttributes;
8813 if (
const auto *ToFn =
8815 if (
const auto *FromFn =
8834 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
8835 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
8838 const Type *lhptee, *rhptee;
8840 std::tie(lhptee, lhq) =
8841 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
8842 std::tie(rhptee, rhq) =
8843 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
8903 diag::warn_typecheck_convert_incompatible_function_pointer_strict,
8926 if (ltrans == rtrans) {
8940 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
8942 std::tie(lhptee, lhq) =
8943 cast<PointerType>(lhptee)->getPointeeType().split().asPair();
8944 std::tie(rhptee, rhq) =
8945 cast<PointerType>(rhptee)->getPointeeType().split().asPair();
8958 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
8960 if (lhptee == rhptee)
8986 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
8987 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
9008 if (LQuals != RQuals)
9037 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
9038 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
9086 return VT->getElementType().getCanonicalType() == ElementType;
9119 if (LHSType == RHSType) {
9126 if (
const auto *AT = dyn_cast<AutoType>(LHSType)) {
9127 if (AT->isGNUAutoType()) {
9135 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
9140 if (Kind != CK_NoOp && ConvertRHS)
9142 Kind = CK_NonAtomicToAtomic;
9155 Kind = CK_LValueBitCast;
9170 Kind = CK_VectorSplat;
9196 << RHSType << LHSType;
9215 << RHSType << LHSType;
9265 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
9267 if (isa<PointerType>(RHSType)) {
9268 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
9270 if (AddrSpaceL != AddrSpaceR)
9271 Kind = CK_AddressSpaceConversion;
9282 Kind = CK_IntegralToPointer;
9288 if (isa<ObjCObjectPointerType>(RHSType)) {
9290 if (LHSPointer->getPointeeType()->isVoidType()) {
9309 if (LHSPointer->getPointeeType()->isVoidType()) {
9310 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
9315 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
9324 if (isa<BlockPointerType>(LHSType)) {
9333 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
9339 Kind = CK_IntegralToPointer;
9345 Kind = CK_AnyPointerToBlockPointerCast;
9351 if (RHSPT->getPointeeType()->isVoidType()) {
9352 Kind = CK_AnyPointerToBlockPointerCast;
9360 if (isa<ObjCObjectPointerType>(LHSType)) {
9366 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9368 !
ObjC().CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
9375 Kind = CK_IntegralToPointer;
9381 if (isa<PointerType>(RHSType)) {
9382 Kind = CK_CPointerToObjCPointerCast;
9404 Kind = CK_BlockPointerToObjCPointerCast;
9416 Kind = CK_NullToPointer;
9421 if (isa<PointerType>(RHSType)) {
9424 Kind = CK_PointerToBoolean;
9430 Kind = CK_PointerToIntegral;
9438 if (isa<ObjCObjectPointerType>(RHSType)) {
9441 Kind = CK_PointerToBoolean;
9447 Kind = CK_PointerToIntegral;
9455 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
9463 Kind = CK_IntToOCLSampler;
9505 for (
auto *it : UD->
fields()) {
9506 if (it->getType()->isPointerType()) {
9545 bool DiagnoseCFAudited,
9549 assert((ConvertRHS || !
Diagnose) &&
"can't indicate whether we diagnosed");
9555 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
9559 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
9560 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
9562 diag::warn_noderef_to_dereferenceable_pointer)
9581 AllowedExplicit::None,
9593 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9594 !
ObjC().CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
9608 RHS.
get(), LHSType,
false, DAP))
9699 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
9709 ObjC().CheckConversionToObjCLiteral(LHSType,
E,
Diagnose))) {
9729struct OriginalOperand {
9730 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(nullptr) {
9731 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
9732 Op = MTE->getSubExpr();
9733 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
9734 Op = BTE->getSubExpr();
9735 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
9736 Orig = ICE->getSubExprAsWritten();
9737 Conversion = ICE->getConversionFunction();
9741 QualType getType()
const {
return Orig->getType(); }
9750 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
9752 Diag(
Loc, diag::err_typecheck_invalid_operands)
9753 << OrigLHS.getType() << OrigRHS.getType()
9758 if (OrigLHS.Conversion) {
9759 Diag(OrigLHS.Conversion->getLocation(),
9760 diag::note_typecheck_invalid_operands_converted)
9763 if (OrigRHS.Conversion) {
9764 Diag(OrigRHS.Conversion->getLocation(),
9765 diag::note_typecheck_invalid_operands_converted)
9780 if (!(LHSNatVec && RHSNatVec)) {
9782 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
9783 Diag(
Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
9785 <<
Vector->getSourceRange();
9789 Diag(
Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
9821 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
9826 scalarCast = CK_IntegralCast;
9831 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
9834 scalarCast = CK_FloatingCast;
9837 scalarCast = CK_IntegralToFloating;
9846 if (scalarCast != CK_NoOp)
9857 assert(VecTy &&
"Expression E must be a vector");
9862 VecTy->getVectorKind());
9866 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(
E))
9867 if (ICE->getSubExpr()->getType() == NewVecTy)
9868 return ICE->getSubExpr();
9870 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
9878 QualType IntTy = Int->get()->getType().getUnqualifiedType();
9884 bool CstInt = Int->get()->EvaluateAsInt(EVResult, S.
Context);
9893 unsigned NumBits = IntSigned
9895 :
Result.getActiveBits())
9896 :
Result.getActiveBits();
9903 return (IntSigned != OtherIntSigned &&
9916 QualType IntTy = Int->get()->getType().getUnqualifiedType();
9921 bool CstInt = Int->get()->EvaluateAsInt(EVResult, S.
Context);
9933 llvm::APFloat::rmTowardZero);
9936 bool Ignored =
false;
9937 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
9939 if (
Result != ConvertBack)
9945 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
9947 if (Bits > FloatPrec)
9960 QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
9961 QualType VectorTy =
Vector->get()->getType().getUnqualifiedType();
9965 assert(!isa<ExtVectorType>(VT) &&
9966 "ExtVectorTypes should not be handled here!");
9967 VectorEltTy = VT->getElementType();
9972 llvm_unreachable(
"Only Fixed-Length and SVE Vector types are handled here");
9998 ScalarCast = CK_IntegralCast;
10002 ScalarCast = CK_FloatingToIntegral;
10010 llvm::APFloat
Result(0.0);
10016 bool CstScalar = Scalar->get()->isValueDependent() ||
10019 if (!CstScalar && Order < 0)
10025 bool Truncated =
false;
10027 llvm::APFloat::rmNearestTiesToEven, &Truncated);
10032 ScalarCast = CK_FloatingCast;
10037 ScalarCast = CK_IntegralToFloating;
10044 if (ScalarCast != CK_NoOp)
10052 bool AllowBothBool,
10053 bool AllowBoolConversions,
10054 bool AllowBoolOperation,
10055 bool ReportInvalid) {
10056 if (!IsCompAssign) {
10072 assert(LHSVecType || RHSVecType);
10076 if (!AllowBothBool && LHSVecType &&
10082 if (!AllowBoolOperation &&
10091 if (LHSVecType && RHSVecType &&
10093 if (isa<ExtVectorType>(LHSVecType)) {
10106 if (AllowBoolConversions && LHSVecType && RHSVecType &&
10116 if (!IsCompAssign &&
10119 RHSVecType->getElementType()->isIntegerType()) {
10128 unsigned &SVEorRVV) {
10146 if (IsSveRVVConversion(LHSType, RHSType, SVEorRVV) ||
10147 IsSveRVVConversion(RHSType, LHSType, SVEorRVV)) {
10148 Diag(
Loc, diag::err_typecheck_sve_rvv_ambiguous)
10149 << SVEorRVV << LHSType << RHSType;
10156 unsigned &SVEorRVV) {
10161 if (FirstVecType && SecondVecType) {
10164 SecondVecType->getVectorKind() ==
10176 if (SecondVecType &&
10189 if (IsSveRVVGnuConversion(LHSType, RHSType, SVEorRVV) ||
10190 IsSveRVVGnuConversion(RHSType, LHSType, SVEorRVV)) {
10191 Diag(
Loc, diag::err_typecheck_sve_rvv_gnu_ambiguous)
10192 << SVEorRVV << LHSType << RHSType;
10198 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
10200 if (isa<ExtVectorType>(LHSVecType)) {
10211 if (isa<ExtVectorType>(RHSVecType)) {
10213 LHSType, RHSVecType->getElementType(),
10226 QualType VecType = LHSVecType ? LHSType : RHSType;
10227 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
10228 QualType OtherType = LHSVecType ? RHSType : LHSType;
10229 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
10234 Diag(
Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << LHSType;
10238 if (!IsCompAssign) {
10257 if ((!RHSVecType && !RHSType->
isRealType()) ||
10259 Diag(
Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10260 << LHSType << RHSType
10270 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
10271 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
10272 Diag(
Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
10281 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
10282 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
10283 QualType Scalar = LHSVecType ? RHSType : LHSType;
10285 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
10287 diag::err_typecheck_vector_not_convertable_implict_truncation)
10288 << ScalarOrVector << Scalar <<
Vector;
10295 << LHSType << RHSType
10304 if (!IsCompAssign) {
10319 unsigned DiagID = diag::err_typecheck_invalid_operands;
10321 ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
10322 (RHSBuiltinTy && RHSBuiltinTy->isSVEBool()))) {
10343 Diag(
Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
10352 Diag(
Loc, diag::err_typecheck_vector_lengths_not_equal)
10361 bool ScalarOrVector =
10364 Diag(
Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
10365 << ScalarOrVector << Scalar <<
Vector;
10397 S.
Diag(
Loc, diag::warn_null_in_arithmetic_operation)
10409 S.
Diag(
Loc, diag::warn_null_in_comparison_operation)
10410 << LHSNull << NonNullType
10416 const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
10417 const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
10420 if (LUE->getKind() != UETT_SizeOf || LUE->isArgumentType() ||
10421 RUE->getKind() != UETT_SizeOf)
10428 if (RUE->isArgumentType())
10429 RHSTy = RUE->getArgumentType().getNonReferenceType();
10431 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
10438 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
10439 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
10440 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
10444 QualType ArrayElemTy = ArrayTy->getElementType();
10450 S.
Diag(
Loc, diag::warn_division_sizeof_array)
10452 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
10453 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
10454 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
10458 S.
Diag(
Loc, diag::note_precedence_silence) << RHS;
10471 S.
PDiag(diag::warn_remainder_division_by_zero)
10477 bool IsCompAssign,
bool IsDiv) {
10555 ? diag::err_typecheck_pointer_arith_void_type
10556 : diag::ext_gnu_void_ptr)
10565 ? diag::err_typecheck_pointer_arith_void_type
10566 : diag::ext_gnu_void_ptr)
10567 << 0 <<
Pointer->getSourceRange();
10578 S.
Diag(
Loc, diag::warn_gnu_null_ptr_arith)
10579 <<
Pointer->getSourceRange();
10581 S.
Diag(
Loc, diag::warn_pointer_arith_null_ptr)
10598 S.
PDiag(diag::warn_pointer_sub_null_ptr)
10600 <<
Pointer->getSourceRange());
10609 ? diag::err_typecheck_pointer_arith_function_type
10610 : diag::ext_gnu_ptr_func_arith)
10622 assert(
Pointer->getType()->isAnyPointerType());
10624 ? diag::err_typecheck_pointer_arith_function_type
10625 : diag::ext_gnu_ptr_func_arith)
10626 << 0 <<
Pointer->getType()->getPointeeType()
10628 <<
Pointer->getSourceRange();
10636 QualType ResType = Operand->getType();
10638 ResType = ResAtomicType->getValueType();
10644 diag::err_typecheck_arithmetic_incomplete_or_sizeless_type,
10645 Operand->getSourceRange());
10658 QualType ResType = Operand->getType();
10660 ResType = ResAtomicType->getValueType();
10692 if (!isLHSPointer && !isRHSPointer)
return true;
10694 QualType LHSPointeeTy, RHSPointeeTy;
10699 if (isLHSPointer && isRHSPointer) {
10702 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10710 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
10711 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
10712 if (isLHSVoidPtr || isRHSVoidPtr) {
10720 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
10721 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
10722 if (isLHSFuncPtr || isRHSFuncPtr) {
10744 Expr* IndexExpr = RHSExpr;
10747 IndexExpr = LHSExpr;
10750 bool IsStringPlusInt = StrExpr &&
10756 Self.Diag(OpLoc, diag::warn_string_plus_int)
10760 if (IndexExpr == RHSExpr) {
10762 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
10767 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
10773 const Expr *StringRefExpr = LHSExpr;
10778 CharExpr = dyn_cast<CharacterLiteral>(LHSExpr->
IgnoreImpCasts());
10779 StringRefExpr = RHSExpr;
10782 if (!CharExpr || !StringRefExpr)
10802 Self.Diag(OpLoc, diag::warn_string_plus_char)
10803 << DiagRange << Ctx.
CharTy;
10805 Self.Diag(OpLoc, diag::warn_string_plus_char)
10806 << DiagRange << CharExpr->
getType();
10812 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence)
10817 Self.Diag(OpLoc, diag::note_string_plus_scalar_silence);
10826 S.
Diag(
Loc, diag::err_typecheck_sub_ptr_compatible)
10845 if (CompLHSTy) *CompLHSTy = compType;
10854 *CompLHSTy = compType;
10863 *CompLHSTy = compType;
10873 if (Opc == BO_Add) {
10880 if (CompLHSTy) *CompLHSTy = compType;
10894 std::swap(PExp, IExp);
10905 if (!IExp->getType()->isIntegerType())
10914 (!IExp->isValueDependent() &&
10915 (!IExp->EvaluateAsInt(KnownVal,
Context) ||
10919 Context, BO_Add, PExp, IExp);
10932 if (isa<AddrLabelExpr>(PExp) &&
getLangOpts().PointerAuthIndirectGotos) {
10933 Diag(
Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
10939 CheckArrayAccess(PExp, IExp);
10948 *CompLHSTy = LHSTy;
10968 if (CompLHSTy) *CompLHSTy = compType;
10977 *CompLHSTy = compType;
10986 *CompLHSTy = compType;
10999 if (CompLHSTy) *CompLHSTy = compType;
11014 if (isa<AddrLabelExpr>(LHS.
get()) &&
11016 Diag(
Loc, diag::err_ptrauth_indirect_goto_addrlabel_arithmetic)
11042 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
11045 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11089 if (ElementSize.
isZero()) {
11090 Diag(
Loc,diag::warn_sub_ptr_zero_size_types)
11096 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
11106 return ET->getDecl()->isScoped();
11123 llvm::APSInt Right = RHSResult.
Val.
getInt();
11125 if (Right.isNegative()) {
11127 S.
PDiag(diag::warn_shift_negative)
11138 LeftSize = FXSema.getWidth() - (
unsigned)FXSema.hasUnsignedPadding();
11140 if (Right.uge(LeftSize)) {
11142 S.
PDiag(diag::warn_shift_gt_typewidth)
11162 llvm::APSInt Left = LHSResult.
Val.
getInt();
11173 if (Left.isNegative()) {
11175 S.
PDiag(diag::warn_shift_lhs_negative)
11180 llvm::APInt ResultBits =
11181 static_cast<llvm::APInt &
>(Right) + Left.getSignificantBits();
11182 if (ResultBits.ule(LeftSize))
11184 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
11190 Result.toString(HexResult, 16,
false,
true);
11196 if (ResultBits - 1 == LeftSize) {
11197 S.
Diag(
Loc, diag::warn_shift_result_sets_sign_bit)
11198 << HexResult << LHSType
11203 S.
Diag(
Loc, diag::warn_shift_result_gt_typewidth)
11204 << HexResult.str() <<
Result.getSignificantBits() << LHSType
11216 S.
Diag(
Loc, diag::err_shift_rhs_only_vector)
11222 if (!IsCompAssign) {
11244 S.
Diag(
Loc, diag::err_typecheck_invalid_operands)
11251 if (!LHSEleType->isIntegerType()) {
11252 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11257 if (!RHSEleType->isIntegerType()) {
11258 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11267 if (LHSEleType != RHSEleType) {
11269 LHSEleType = RHSEleType;
11275 }
else if (RHSVecTy) {
11280 S.
Diag(
Loc, diag::err_typecheck_vector_lengths_not_equal)
11288 if (LHSBT != RHSBT &&
11290 S.
Diag(
Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
11307 bool IsCompAssign) {
11308 if (!IsCompAssign) {
11331 if ((LHSBuiltinTy && LHSBuiltinTy->
isSVEBool()) ||
11332 (RHSBuiltinTy && RHSBuiltinTy->
isSVEBool())) {
11333 S.
Diag(
Loc, diag::err_typecheck_invalid_operands)
11338 if (!LHSEleType->isIntegerType()) {
11339 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11344 if (!RHSEleType->isIntegerType()) {
11345 S.
Diag(
Loc, diag::err_typecheck_expect_int)
11353 S.
Diag(
Loc, diag::err_typecheck_invalid_operands)
11363 if (LHSEleType != RHSEleType) {
11365 LHSEleType = RHSEleType;
11367 const llvm::ElementCount VecSize =
11376 S.
Diag(
Loc, diag::err_typecheck_vector_lengths_not_equal)
11382 const llvm::ElementCount VecSize =
11384 if (LHSEleType != RHSEleType) {
11386 RHSEleType = LHSEleType;
11399 bool IsCompAssign) {
11433 if (IsCompAssign) LHS = OldLHS;
11464 S.
Diag(
Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
11465 : diag::ext_typecheck_comparison_of_distinct_pointers)
11505 S.
Diag(
Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
11506 : diag::ext_typecheck_comparison_of_fptr_to_void)
11513 case Stmt::ObjCArrayLiteralClass:
11514 case Stmt::ObjCDictionaryLiteralClass:
11515 case Stmt::ObjCStringLiteralClass:
11516 case Stmt::ObjCBoxedExprClass:
11577 Literal = LHS.
get();
11580 Literal = RHS.
get();
11596 llvm_unreachable(
"Unknown Objective-C object literal kind");
11600 S.
Diag(
Loc, diag::warn_objc_string_literal_comparison)
11601 << Literal->getSourceRange();
11603 S.
Diag(
Loc, diag::warn_objc_literal_comparison)
11604 << LiteralKind << Literal->getSourceRange();
11613 S.
Diag(
Loc, diag::note_objc_literal_comparison_isequal)
11626 if (!UO || UO->
getOpcode() != UO_LNot)
return;
11636 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
11638 <<
Loc << IsBitwiseOp;
11665 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(
E)) {
11667 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(
E)) {
11668 if (Mem->isImplicitAccess())
11669 D = Mem->getMemberDecl();
11673 return D->getType()->isArrayType() && !
D->isWeak();
11724 S.
Diag(
Loc, diag::warn_depr_array_comparison)
11750 Result = AlwaysConstant;
11754 S.
PDiag(diag::warn_comparison_always)
11769 Result = AlwaysConstant;
11773 S.
PDiag(diag::warn_comparison_always)
11779 if (isa<CastExpr>(LHSStripped))
11781 if (isa<CastExpr>(RHSStripped))
11786 Expr *LiteralString =
nullptr;
11787 Expr *LiteralStringStripped =
nullptr;
11788 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
11791 LiteralString = LHS;
11792 LiteralStringStripped = LHSStripped;
11793 }
else if ((isa<StringLiteral>(RHSStripped) ||
11794 isa<ObjCEncodeExpr>(RHSStripped)) &&
11797 LiteralString = RHS;
11798 LiteralStringStripped = RHSStripped;
11801 if (LiteralString) {
11803 S.
PDiag(diag::warn_stringcompare)
11804 << isa<ObjCEncodeExpr>(LiteralStringStripped)
11816 llvm_unreachable(
"unhandled cast kind");
11818 case CK_UserDefinedConversion:
11820 case CK_LValueToRValue:
11822 case CK_ArrayToPointerDecay:
11824 case CK_FunctionToPointerDecay:
11826 case CK_IntegralCast:
11828 case CK_FloatingCast:
11830 case CK_IntegralToFloating:
11831 case CK_FloatingToIntegral:
11833 case CK_IntegralComplexCast:
11834 case CK_FloatingComplexCast:
11835 case CK_FloatingComplexToIntegralComplex:
11836 case CK_IntegralComplexToFloatingComplex:
11838 case CK_FloatingComplexToReal:
11839 case CK_FloatingRealToComplex:
11840 case CK_IntegralComplexToReal:
11841 case CK_IntegralRealToComplex:
11843 case CK_HLSLArrayRValue:
11856 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(
E))
11883 << 0 << FromType << ToType;
11888 llvm_unreachable(
"unhandled case in switch");
11915 if (NumEnumArgs == 1) {
11917 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
11923 if (NumEnumArgs == 2) {
11932 LHSStrippedType->
castAs<
EnumType>()->getDecl()->getIntegerType();
11943 LHSType = RHSType = IntType;
11955 std::optional<ComparisonCategoryType> CCT =
11967 assert(!
Type.isNull() &&
"composite type for <=> has not been set");
12008 if (
const auto *CL = dyn_cast<CharacterLiteral>(
E.get())) {
12009 if (CL->getValue() == 0)
12013 NullValue ?
"NULL" :
"(void *)0");
12014 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(
E.get())) {
12021 NullValue ?
"NULL" :
"(void *)0");
12031 bool IsThreeWay = Opc == BO_Cmp;
12032 bool IsOrdered = IsRelational || IsThreeWay;
12043 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
12096 auto computeResultTy = [&]() {
12105 std::optional<ComparisonCategoryType> CCT =
12110 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
12114 Diag(
Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
12124 if (!IsOrdered && LHSIsNull != RHSIsNull) {
12125 bool IsEquality = Opc == BO_EQ;
12137 bool IsError = Opc == BO_Cmp;
12139 IsError ? diag::err_typecheck_ordered_comparison_of_function_pointers
12141 ? diag::warn_typecheck_ordered_comparison_of_function_pointers
12142 : diag::ext_typecheck_ordered_comparison_of_function_pointers;
12171 return computeResultTy();
12187 (IsOrdered ? 2 : 1) &&
12192 return computeResultTy();
12206 if (IsRelational) {
12211 Diag(
Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
12217 }
else if (!IsRelational &&
12221 && !LHSIsNull && !RHSIsNull)
12228 if (LCanPointeeTy != RCanPointeeTy) {
12233 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
12234 << LHSType << RHSType << 0
12240 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
12242 if (LHSIsNull && !RHSIsNull)
12247 return computeResultTy();
12259 if (!IsOrdered && LHSIsNull && RHSIsNull) {
12262 return computeResultTy();
12266 return computeResultTy();
12277 return computeResultTy();
12281 return computeResultTy();
12290 return computeResultTy();
12295 return computeResultTy();
12299 if (IsRelational &&
12308 if (isa<FunctionDecl>(DC))
12310 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
12311 if (CTSD->isInStdNamespace() &&
12312 llvm::StringSwitch<bool>(CTSD->getName())
12313 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
12319 return computeResultTy();
12332 return computeResultTy();
12342 if (!LHSIsNull && !RHSIsNull &&
12344 Diag(
Loc, diag::err_typecheck_comparison_of_distinct_blocks)
12349 return computeResultTy();
12356 if (!LHSIsNull && !RHSIsNull) {
12361 Diag(
Loc, diag::err_typecheck_comparison_of_distinct_blocks)
12365 if (LHSIsNull && !RHSIsNull)
12368 : CK_AnyPointerToBlockPointerCast);
12372 : CK_AnyPointerToBlockPointerCast);
12373 return computeResultTy();
12382 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
12384 if (!LPtrToVoid && !RPtrToVoid &&
12392 if (LHSIsNull && !RHSIsNull) {
12398 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
12408 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
12410 return computeResultTy();
12420 if (LHSIsNull && !RHSIsNull)
12424 return computeResultTy();
12430 CK_BlockPointerToObjCPointerCast);
12431 return computeResultTy();
12432 }
else if (!IsOrdered &&
12436 CK_BlockPointerToObjCPointerCast);
12437 return computeResultTy();
12442 unsigned DiagID = 0;
12443 bool isError =
false;
12452 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
12453 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
12456 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
12458 }
else if (IsOrdered)
12459 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
12461 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
12473 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
12476 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
12477 return computeResultTy();
12481 if (!IsOrdered && RHSIsNull
12484 return computeResultTy();
12486 if (!IsOrdered && LHSIsNull
12489 return computeResultTy();
12492 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
12494 return computeResultTy();
12498 return computeResultTy();
12501 if (LHSIsNull && RHSType->
isQueueT()) {
12503 return computeResultTy();
12506 if (LHSType->
isQueueT() && RHSIsNull) {
12508 return computeResultTy();
12519 if (isa<ExtVectorType>(VTy)) {
12533 "Unhandled vector element size in vector compare");
12553 "Unhandled vector element size in vector compare");
12573 if (Opc == BO_Cmp) {
12574 Diag(
Loc, diag::err_three_way_vector_comparison);
12605 Diag(
Loc, diag::warn_deprecated_altivec_src_compat);
12635 if (Opc == BO_Cmp) {
12636 Diag(
Loc, diag::err_three_way_vector_comparison);
12664 if (LHSBuiltinTy && RHSBuiltinTy && LHSBuiltinTy->
isSVEBool() &&
12665 RHSBuiltinTy->isSVEBool())
12684 bool Negative =
false;
12685 bool ExplicitPlus =
false;
12686 const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.
get());
12687 const auto *RHSInt = dyn_cast<IntegerLiteral>(XorRHS.
get());
12693 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
12695 if (Opc != UO_Minus && Opc != UO_Plus)
12697 RHSInt = dyn_cast<IntegerLiteral>(UO->getSubExpr());
12700 Negative = (Opc == UO_Minus);
12701 ExplicitPlus = !Negative;
12707 const llvm::APInt &LeftSideValue = LHSInt->getValue();
12708 llvm::APInt RightSideValue = RHSInt->getValue();
12709 if (LeftSideValue != 2 && LeftSideValue != 10)
12712 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
12717 llvm::StringRef ExprStr =
12722 llvm::StringRef XorStr =
12725 if (XorStr ==
"xor")
12736 RightSideValue = -RightSideValue;
12737 RHSStr =
"-" + RHSStr;
12738 }
else if (ExplicitPlus) {
12739 RHSStr =
"+" + RHSStr;
12742 StringRef LHSStrRef = LHSStr;
12743 StringRef RHSStrRef = RHSStr;
12746 if (LHSStrRef.starts_with(
"0b") || LHSStrRef.starts_with(
"0B") ||
12747 RHSStrRef.starts_with(
"0b") || RHSStrRef.starts_with(
"0B") ||
12748 LHSStrRef.starts_with(
"0x") || LHSStrRef.starts_with(
"0X") ||
12749 RHSStrRef.starts_with(
"0x") || RHSStrRef.starts_with(
"0X") ||
12750 (LHSStrRef.size() > 1 && LHSStrRef.starts_with(
"0")) ||
12751 (RHSStrRef.size() > 1 && RHSStrRef.starts_with(
"0")) ||
12752 LHSStrRef.contains(
'\'') || RHSStrRef.contains(
'\''))
12757 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
12758 int64_t RightSideIntValue = RightSideValue.getSExtValue();
12759 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
12760 std::string SuggestedExpr =
"1 << " + RHSStr;
12761 bool Overflow =
false;
12762 llvm::APInt One = (LeftSideValue - 1);
12763 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
12765 if (RightSideIntValue < 64)
12766 S.
Diag(
Loc, diag::warn_xor_used_as_pow_base)
12767 << ExprStr <<
toString(XorValue, 10,
true) << (
"1LL << " + RHSStr)
12769 else if (RightSideIntValue == 64)
12770 S.
Diag(
Loc, diag::warn_xor_used_as_pow)
12771 << ExprStr <<
toString(XorValue, 10,
true);
12775 S.
Diag(
Loc, diag::warn_xor_used_as_pow_base_extra)
12776 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedExpr
12779 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
12782 S.
Diag(
Loc, diag::note_xor_used_as_pow_silence)
12783 << (
"0x2 ^ " + RHSStr) << SuggestXor;
12784 }
else if (LeftSideValue == 10) {
12785 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
12786 S.
Diag(
Loc, diag::warn_xor_used_as_pow_base)
12787 << ExprStr <<
toString(XorValue, 10,
true) << SuggestedValue
12789 S.
Diag(
Loc, diag::note_xor_used_as_pow_silence)
12790 << (
"0xA ^ " + RHSStr) << SuggestXor;
12806 getLangOpts().getOpenCLCompatibleVersion() < 120 &&
12821 bool IsCompAssign) {
12822 if (!IsCompAssign) {
12838 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
12847 if (LHSMatType && !RHSMatType) {
12855 if (!LHSMatType && RHSMatType) {
12867 bool IsCompAssign) {
12868 if (!IsCompAssign) {
12879 assert((LHSMatType || RHSMatType) &&
"At least one operand must be a matrix");
12881 if (LHSMatType && RHSMatType) {
12882 if (LHSMatType->getNumColumns() != RHSMatType->
getNumRows())
12890 QualType LHSELTy = LHSMatType->getElementType(),
12921 bool IsCompAssign =
12922 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
12933 LegalBoolVecOperator,
12963 ExprResult LHSResult = LHS, RHSResult = RHS;
12966 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
12968 LHS = LHSResult.
get();
12969 RHS = RHSResult.
get();
12988 bool EnumConstantInBoolContext =
false;
12990 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
12991 const auto *ECDHS = dyn_cast<EnumConstantDecl>(DREHS->getDecl());
12992 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
12993 EnumConstantInBoolContext =
true;
12997 if (EnumConstantInBoolContext)
12998 Diag(
Loc, diag::warn_enum_constant_in_bool_context);
13003 const auto *LHSATy = dyn_cast<ArrayType>(LHSTy);
13004 const auto *RHSATy = dyn_cast<ArrayType>(RHSTy);
13005 if ((LHSATy && LHSATy->getElementType().isWebAssemblyReferenceType()) ||
13006 (RHSATy && RHSATy->getElementType().isWebAssemblyReferenceType())) {
13028 Diag(
Loc, diag::warn_logical_instead_of_bitwise)
13031 Diag(
Loc, diag::note_logical_instead_of_bitwise_change_operator)
13032 << (Opc == BO_LAnd ?
"&" :
"|")
13035 Opc == BO_LAnd ?
"&" :
"|");
13036 if (Opc == BO_LAnd)
13038 Diag(
Loc, diag::note_logical_instead_of_bitwise_remove_constant)
13095 if (!ME)
return false;
13099 if (!
Base)
return false;
13100 return Base->getMethodDecl() !=
nullptr;
13119 if (var->getType().isConstQualified())
return NCCK_None;
13120 assert(var->hasLocalStorage() &&
"capture added 'const' to non-local?");
13128 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
13129 if (var->isInitCapture() &&
13130 FD->getTemplateInstantiationPattern() == var->getDeclContext())
13132 if (DC == var->getDeclContext())
13138 if (!var->isInitCapture())
13171 bool DiagnosticEmitted =
false;
13175 bool IsDereference =
false;
13176 bool NextIsDereference =
false;
13180 IsDereference = NextIsDereference;
13183 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(
E)) {
13184 NextIsDereference = ME->isArrow();
13185 const ValueDecl *VD = ME->getMemberDecl();
13186 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
13188 if (Field->isMutable()) {
13189 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
13194 if (!DiagnosticEmitted) {
13195 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13197 << Field->getType();
13198 DiagnosticEmitted =
true;
13201 <<
ConstMember <<
false << Field << Field->getType()
13202 << Field->getSourceRange();
13206 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
13207 if (VDecl->getType().isConstQualified()) {
13208 if (!DiagnosticEmitted) {
13209 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13211 << VDecl->getType();
13212 DiagnosticEmitted =
true;
13215 <<
ConstMember <<
true << VDecl << VDecl->getType()
13216 << VDecl->getSourceRange();
13223 dyn_cast<ArraySubscriptExpr>(
E)) {
13227 dyn_cast<ExtVectorElementExpr>(
E)) {
13234 if (
const CallExpr *CE = dyn_cast<CallExpr>(
E)) {
13238 if (!DiagnosticEmitted) {
13239 S.
Diag(
Loc, diag::err_typecheck_assign_const) << ExprRange
13241 DiagnosticEmitted =
true;
13244 diag::note_typecheck_assign_const)
13248 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
E)) {
13250 if (
const ValueDecl *VD = DRE->getDecl()) {
13252 if (!DiagnosticEmitted) {
13253 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13255 DiagnosticEmitted =
true;
13257 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
13258 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
13261 }
else if (isa<CXXThisExpr>(
E)) {
13263 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
13264 if (MD->isConst()) {
13265 if (!DiagnosticEmitted) {
13266 S.
Diag(
Loc, diag::err_typecheck_assign_const) << ExprRange
13268 DiagnosticEmitted =
true;
13270 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
13277 if (DiagnosticEmitted)
13294 bool &DiagnosticEmitted) {
13295 std::vector<const RecordType *> RecordTypeList;
13296 RecordTypeList.push_back(Ty);
13297 unsigned NextToCheckIndex = 0;
13300 while (RecordTypeList.size() > NextToCheckIndex) {
13301 bool IsNested = NextToCheckIndex > 0;
13303 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
13305 QualType FieldTy = Field->getType();
13307 if (!DiagnosticEmitted) {
13308 S.
Diag(
Loc, diag::err_typecheck_assign_const)
13310 << IsNested << Field;
13311 DiagnosticEmitted =
true;
13313 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
13315 << FieldTy << Field->getSourceRange();
13321 if (!llvm::is_contained(RecordTypeList, FieldRecTy))
13322 RecordTypeList.push_back(FieldRecTy);
13325 ++NextToCheckIndex;
13334 assert(Ty->
isRecordType() &&
"lvalue was not record?");
13337 bool DiagEmitted =
false;
13339 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(
E))
13342 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
E))
13367 unsigned DiagID = 0;
13368 bool NeedType =
false;
13375 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
13377 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
13385 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
13390 if (var->isARCPseudoStrong() &&
13391 (!var->getTypeSourceInfo() ||
13392 !var->getTypeSourceInfo()->getType().isConstQualified())) {
13398 ? diag::err_typecheck_arc_assign_self_class_method
13399 : diag::err_typecheck_arc_assign_self;
13402 }
else if (var->hasAttr<ObjCExternallyRetainedAttr>() ||
13403 isa<ParmVarDecl>(var)) {
13404 DiagID = diag::err_typecheck_arc_assign_externally_retained;
13408 DiagID = diag::err_typecheck_arr_assign_enumeration;
13412 if (
Loc != OrigLoc)
13438 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
13442 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
13446 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
13449 llvm_unreachable(
"did not take early return for MLV_Valid");
13453 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
13458 diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
E);
13460 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
13463 llvm_unreachable(
"readonly properties should be processed differently");
13465 DiagID = diag::err_readonly_message_assignment;
13468 DiagID = diag::err_no_subobject_property_setting;
13473 if (
Loc != OrigLoc)
13495 MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
13496 MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
13498 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->
getBase())))
13504 if (LHSDecl != RHSDecl)
13509 if (RefTy->getPointeeType().isVolatileQualified())
13512 Sema.
Diag(
Loc, diag::warn_identity_field_assign) << 0;
13522 Sema.
Diag(
Loc, diag::warn_identity_field_assign) << 1;
13546 Diag(
Loc, diag::err_opencl_half_load_store) << 1
13553 Diag(
Loc, diag::err_wasm_table_art) << 0;
13558 if (CompoundType.
isNull()) {
13577 Diag(
Loc, diag::err_objc_object_assignment)
13584 RHSCheck = ICE->getSubExpr();
13585 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
13586 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
13587 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
13593 UO->getSubExpr()->getBeginLoc().
isFileID()) {
13594 Diag(
Loc, diag::warn_not_compound_assign)
13595 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
13596 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
13606 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
13645 if (CompoundType.
isNull()) {
13671 if (
const CastExpr *CE = dyn_cast<CastExpr>(
E)) {
13672 if (CE->getCastKind() == CK_ToVoid) {
13678 CE->getSubExpr()->getType()->isDependentType()) {
13683 if (
const auto *CE = dyn_cast<CallExpr>(
E))
13684 return CE->getCallReturnType(Context)->isVoidType();
13704 const unsigned ForIncrementFlags =
13710 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
13711 (ScopeFlags & ForInitFlags) == ForInitFlags)
13716 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
13717 if (BO->getOpcode() != BO_Comma)
13719 LHS = BO->getRHS();
13726 Diag(
Loc, diag::warn_comma_operator);
13730 LangOpts.CPlusPlus ?
"static_cast<void>("
13762 diag::err_incomplete_type);
13783 ResType = ResAtomicType->getValueType();
13785 assert(!ResType.
isNull() &&
"no type for increment/decrement expression");
13795 : diag::warn_increment_bool)
13799 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
13815 S.
Diag(OpLoc, S.
getLangOpts().C2y ? diag::warn_c2y_compat_increment_complex
13816 : diag::ext_c2y_increment_complex)
13833 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
13844 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
13845 << IsInc << ResType;
13877 case Stmt::DeclRefExprClass:
13878 return cast<DeclRefExpr>(
E)->getDecl();
13879 case Stmt::MemberExprClass:
13883 if (cast<MemberExpr>(
E)->isArrow())
13887 case Stmt::ArraySubscriptExprClass: {
13890 Expr*
Base = cast<ArraySubscriptExpr>(
E)->getBase();
13892 if (ICE->getSubExpr()->getType()->isArrayType())
13897 case Stmt::UnaryOperatorClass: {
13909 case Stmt::ParenExprClass:
13911 case Stmt::ImplicitCastExprClass:
13915 case Stmt::CXXUuidofExprClass:
13916 return cast<CXXUuidofExpr>(
E)->getGuidDecl();
13925 AO_Vector_Element = 1,
13926 AO_Property_Expansion = 2,
13927 AO_Register_Variable = 3,
13928 AO_Matrix_Element = 4,
13943 const auto *DRE = cast<DeclRefExpr>(Op->
IgnoreParens());
13946 return Diag(OpLoc, diag::err_parens_pointer_member_function)
13950 if (isa<CXXDestructorDecl>(MD))
13951 return Diag(OpLoc, diag::err_typecheck_addrof_dtor)
13952 << DRE->getSourceRange();
13954 if (DRE->getQualifier())
13958 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
13959 << DRE->getSourceRange();
13963 return Diag(OpLoc, diag::err_unqualified_pointer_member_function)
13964 << DRE->getSourceRange()
13970 if (PTy->getKind() == BuiltinType::Overload) {
13972 if (!isa<OverloadExpr>(
E)) {
13973 assert(cast<UnaryOperator>(
E)->getOpcode() == UO_AddrOf);
13974 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
13980 if (isa<UnresolvedMemberExpr>(Ovl))
13982 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
13990 if (PTy->getKind() == BuiltinType::UnknownAny)
13993 if (PTy->getKind() == BuiltinType::BoundMember) {
13994 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14017 auto* VarRef = dyn_cast<DeclRefExpr>(op);
14018 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
14019 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
14027 if (uOp->getOpcode() == UO_Deref)
14030 return uOp->getSubExpr()->getType();
14037 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
14043 unsigned AddressOfError = AO_No_Error;
14048 : diag::ext_typecheck_addrof_temporary)
14055 }
else if (isa<ObjCSelectorExpr>(op)) {
14062 if (!isa<DeclRefExpr>(op)) {
14063 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
14082 auto ReturnOrParamTypeIsIncomplete = [&](
QualType T,
14087 diag::note_ptrauth_virtual_function_pointer_incomplete_arg_ret);
14088 Diag(RetArgTypeLoc,
14089 diag::note_ptrauth_virtual_function_incomplete_arg_ret_type)
14096 bool IsIncomplete =
14098 ReturnOrParamTypeIsIncomplete(
14101 IsIncomplete |= ReturnOrParamTypeIsIncomplete(PVD->getType(), OpLoc,
14102 PVD->getBeginLoc());
14116 if (isa<PseudoObjectExpr>(op)) {
14117 AddressOfError = AO_Property_Expansion;
14119 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
14123 }
else if (
const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
14124 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(DRE->getDecl()))
14130 AddressOfError = AO_Bit_Field;
14133 AddressOfError = AO_Vector_Element;
14136 AddressOfError = AO_Matrix_Element;
14140 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
14145 AddressOfError = AO_Register_Variable;
14147 }
else if (isa<MSPropertyDecl>(dcl)) {
14148 AddressOfError = AO_Property_Expansion;
14149 }
else if (isa<FunctionTemplateDecl>(dcl)) {
14151 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
14161 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier() &&
14162 !isa<ParenExpr>(OrigOp.
get())) {
14167 diag::err_cannot_form_pointer_to_member_of_reference_type)
14172 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
14186 llvm_unreachable(
"Unknown/unexpected decl type");
14189 if (AddressOfError != AO_No_Error) {
14209 Diag(OpLoc, diag::err_wasm_ca_reference)
14214 Diag(OpLoc, diag::err_wasm_table_pr)
14220 CheckAddressOfPackedMember(op);
14226 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp);
14236 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
14239 FD->ModifiedNonNullParams.insert(Param);
14245 bool IsAfterAmp =
false) {
14249 Op = ConvResult.
get();
14253 if (isa<CXXReinterpretCastExpr>(Op)) {
14261 Result = PT->getPointeeType();
14265 Result = OPT->getPointeeType();
14269 if (PR.
get() != Op)
14274 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
14279 if (
Result->isVoidType()) {
14285 S.
Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
14288 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
14305 default: llvm_unreachable(
"Unknown binop!");
14306 case tok::periodstar: Opc = BO_PtrMemD;
break;
14307 case tok::arrowstar: Opc = BO_PtrMemI;
break;
14308 case tok::star: Opc = BO_Mul;
break;
14309 case tok::slash: Opc = BO_Div;
break;
14310 case tok::percent: Opc = BO_Rem;
break;
14311 case tok::plus: Opc = BO_Add;
break;
14312 case tok::minus: Opc = BO_Sub;
break;
14313 case tok::lessless: Opc = BO_Shl;
break;
14314 case tok::greatergreater: Opc = BO_Shr;
break;
14315 case tok::lessequal: Opc = BO_LE;
break;
14316 case tok::less: Opc = BO_LT;
break;
14317 case tok::greaterequal: Opc = BO_GE;
break;
14318 case tok::greater: Opc = BO_GT;
break;
14319 case tok::exclaimequal: Opc = BO_NE;
break;
14320 case tok::equalequal: Opc = BO_EQ;
break;
14321 case tok::spaceship: Opc = BO_Cmp;
break;
14322 case tok::amp: Opc = BO_And;
break;
14323 case tok::caret: Opc = BO_Xor;
break;
14324 case tok::pipe: Opc = BO_Or;
break;
14325 case tok::ampamp: Opc = BO_LAnd;
break;
14326 case tok::pipepipe: Opc = BO_LOr;
break;
14327 case tok::equal: Opc = BO_Assign;
break;
14328 case tok::starequal: Opc = BO_MulAssign;
break;
14329 case tok::slashequal: Opc = BO_DivAssign;
break;
14330 case tok::percentequal: Opc = BO_RemAssign;
break;
14331 case tok::plusequal: Opc = BO_AddAssign;
break;
14332 case tok::minusequal: Opc = BO_SubAssign;
break;
14333 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
14334 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
14335 case tok::ampequal: Opc = BO_AndAssign;
break;
14336 case tok::caretequal: Opc = BO_XorAssign;
break;
14337 case tok::pipeequal: Opc = BO_OrAssign;
break;
14338 case tok::comma: Opc = BO_Comma;
break;
14347 default: llvm_unreachable(
"Unknown unary op!");
14348 case tok::plusplus: Opc = UO_PreInc;
break;
14349 case tok::minusminus: Opc = UO_PreDec;
break;
14350 case tok::amp: Opc = UO_AddrOf;
break;
14351 case tok::star: Opc = UO_Deref;
break;
14352 case tok::plus: Opc = UO_Plus;
break;
14353 case tok::minus: Opc = UO_Minus;
break;
14354 case tok::tilde: Opc = UO_Not;
break;
14355 case tok::exclaim: Opc = UO_LNot;
break;
14356 case tok::kw___real: Opc = UO_Real;
break;
14357 case tok::kw___imag: Opc = UO_Imag;
break;
14358 case tok::kw___extension__: Opc = UO_Extension;
break;
14374 if (!isa<ParmVarDecl>(SelfAssigned))
14376 const auto *Method =
14390 llvm::find_if(
Parent->fields(),
14392 return F->getDeclName() == Name;
14394 return (Field !=
Parent->field_end()) ? *Field :
nullptr;
14409 const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
14410 const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
14411 if (!LHSDeclRef || !RHSDeclRef ||
14419 if (LHSDecl != RHSDecl)
14424 if (RefTy->getPointeeType().isVolatileQualified())
14427 auto Diag = S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
14428 : diag::warn_self_assignment_overloaded)
14433 Diag << 1 << SelfAssignField
14446 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
14451 ObjCPointerExpr = LHS;
14455 ObjCPointerExpr = RHS;
14463 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
14464 unsigned Diag = diag::warn_objc_pointer_masking;
14472 StringRef SelArg0 = S.getNameForSlot(0);
14473 if (SelArg0.starts_with(
"performSelector"))
14474 Diag = diag::warn_objc_pointer_masking_performSelector;
14485 if (
auto *DRE = dyn_cast<DeclRefExpr>(
E))
14486 return DRE->getDecl();
14487 if (
auto *ME = dyn_cast<MemberExpr>(
E))
14488 return ME->getMemberDecl();
14489 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(
E))
14490 return IRE->getDecl();
14505 "Result must be a vector of half or short");
14508 "both operands expected to be a half vector");
14520 ResultTy, VK, OK, OpLoc, FPFeatures,
14521 BinOpResTy, BinOpResTy);
14525 BinOpResTy, VK, OK, OpLoc, FPFeatures);
14529static std::pair<ExprResult, ExprResult>
14539 RHS,
nullptr,
false,
14540 [Opc, LHS](
Expr *
E) {
14541 if (Opc != BO_Assign)
14548 return std::make_pair(LHS, RHS);
14555 if (!OpRequiresConversion || Ctx.
getLangOpts().NativeHalfType ||
14559 auto HasVectorOfHalfType = [&Ctx](
Expr *
E) {
14569 return VT->getElementType().getCanonicalType() == Ctx.
HalfTy;
14574 return HasVectorOfHalfType(E0) && (!E1 || HasVectorOfHalfType(E1));
14593 if (
Init.isInvalid())
14595 RHSExpr =
Init.get();
14605 bool ConvertHalfVec =
false;
14608 if (!LHS.
isUsable() || !RHS.isUsable())
14618 if (BO_Assign == Opc)
14619 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
14647 if (!ResultTy.
isNull()) {
14664 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
14666 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
14667 if (VD->hasLocalStorage() &&
getCurScope()->isDeclScope(VD))
14668 BE->getBlockDecl()->setCanAvoidCopyToHeap();
14679 Opc == BO_PtrMemI);
14683 ConvertHalfVec =
true;
14691 ConvertHalfVec =
true;
14695 ConvertHalfVec =
true;
14706 ConvertHalfVec =
true;
14709 if (
const auto *BI = dyn_cast<BinaryOperator>(LHSExpr);
14710 BI && BI->isComparisonOp())
14711 Diag(OpLoc, diag::warn_consecutive_comparison);
14716 ConvertHalfVec =
true;
14720 ConvertHalfVec =
true;
14733 ConvertHalfVec =
true;
14738 ConvertHalfVec =
true;
14740 Opc == BO_DivAssign);
14741 CompLHSTy = CompResultTy;
14748 CompLHSTy = CompResultTy;
14754 ConvertHalfVec =
true;
14761 ConvertHalfVec =
true;
14770 CompLHSTy = CompResultTy;
14781 CompLHSTy = CompResultTy;
14789 VK = RHS.get()->getValueKind();
14790 OK = RHS.get()->getObjectKind();
14804 "both sides are half vectors or neither sides are");
14809 CheckArrayAccess(LHS.
get());
14810 CheckArrayAccess(RHS.get());
14816 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
14820 "object_setClass(")
14833 if (CompResultTy.
isNull()) {
14834 if (ConvertHalfVec)
14854 if (ConvertHalfVec)
14859 Context, LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, OpLoc,
14876 if (isLeftComp == isRightComp)
14881 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
14882 bool isRightBitwise = RHSBO && RHSBO->
isBitwiseOp();
14883 if (isLeftBitwise || isRightBitwise)
14895 Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
14898 Self.PDiag(diag::note_precedence_silence) << OpStr,
14899 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
14901 Self.PDiag(diag::note_precedence_bitwise_first)
14916 Self.PDiag(diag::note_precedence_silence)
14925 if (Bop->getOpcode() == BO_LAnd) {
14928 if (!isa<StringLiteral>(Bop->getLHS()->IgnoreParenImpCasts()))
14930 }
else if (Bop->getOpcode() == BO_LOr) {
14931 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
14934 if (RBop->getOpcode() == BO_LAnd &&
14935 isa<StringLiteral>(RBop->getRHS()->IgnoreParenImpCasts()))
14946 if (Bop->getOpcode() == BO_LAnd) {
14949 if (!isa<StringLiteral>(Bop->getRHS()->IgnoreParenImpCasts()))
14961 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
14962 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
14964 << Bop->getSourceRange() << OpLoc;
14966 S.
PDiag(diag::note_precedence_silence)
14967 << Bop->getOpcodeStr(),
14968 Bop->getSourceRange());
14974 Expr *SubExpr, StringRef Shift) {
14976 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
14977 StringRef Op = Bop->getOpcodeStr();
14978 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
14979 << Bop->getSourceRange() << OpLoc << Shift << Op;
14981 S.
PDiag(diag::note_precedence_silence) << Op,
14982 Bop->getSourceRange());
14998 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
15001 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
15003 << (Kind == OO_LessLess);
15005 S.
PDiag(diag::note_precedence_silence)
15006 << (Kind == OO_LessLess ?
"<<" :
">>"),
15009 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
15023 if ((Opc == BO_Or || Opc == BO_Xor) &&
15031 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
15037 || Opc == BO_Shr) {
15053 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
15054 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
15059 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
15065 if (OverOp !=
OO_None && OverOp != OO_Equal)
15119 LHSExpr = LHS.
get();
15120 RHSExpr = RHS.
get();
15131 if (pty->getKind() == BuiltinType::PseudoObject &&
15144 RHSExpr = resolvedRHS.
get();
15158 (pty->getKind() == BuiltinType::BoundMember ||
15159 pty->getKind() == BuiltinType::Overload)) {
15160 auto *OE = dyn_cast<OverloadExpr>(LHSExpr);
15161 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
15162 llvm::any_of(OE->decls(), [](
NamedDecl *ND) {
15163 return isa<FunctionTemplateDecl>(ND);
15165 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
15166 : OE->getNameLoc(),
15167 diag::err_template_kw_missing)
15168 << OE->getName().getAsString() <<
"";
15175 LHSExpr = LHS.
get();
15182 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
15198 RHSExpr = resolvedRHS.
get();
15214 "Should only occur in error-recovery path.");
15220 Context, LHSExpr, RHSExpr, Opc,
15240 ResultType = RHSExpr->
getType();
15272 bool CanOverflow =
false;
15274 bool ConvertHalfVec =
false;
15283 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15290 if (Opc == UO_AddrOf)
15291 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 0);
15292 if (Opc == UO_Deref)
15293 return ExprError(
Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 1);
15307 Opc == UO_PreInc || Opc == UO_PostInc,
15308 Opc == UO_PreInc || Opc == UO_PreDec);
15313 CheckAddressOfNoDeref(InputExpr);
15326 CanOverflow = Opc == UO_Minus &&
15338 if (ConvertHalfVec)
15355 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15366 Diag(OpLoc, diag::ext_integer_complement_complex)
15375 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15378 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15400 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15416 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15426 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15436 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15443 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
15477 "the co_await expression must be non-dependant before "
15478 "building operator co_await");
15489 if (Opc != UO_AddrOf && Opc != UO_Deref)
15490 CheckArrayAccess(Input.
get());
15496 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
15497 !isa<ArrayType>(UO->getType().getDesugaredType(
Context)) &&
15502 if (ConvertHalfVec)
15509 if (!DRE->getQualifier())
15516 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
15519 return Method->isImplicitObjectMemberFunction();
15525 if (!ULE->getQualifier())
15530 if (Method->isImplicitObjectMemberFunction())
15551 if (pty->getKind() == BuiltinType::PseudoObject &&
15556 if (Opc == UO_Extension)
15561 if (Opc == UO_AddrOf &&
15562 (pty->getKind() == BuiltinType::Overload ||
15563 pty->getKind() == BuiltinType::UnknownAny ||
15564 pty->getKind() == BuiltinType::BoundMember))
15589 Expr *Input,
bool IsAfterAmp) {
15628 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
15634 "cleanups within StmtExpr not correctly bound!");
15644 bool StmtExprMayBindToTemp =
false;
15647 if (
const auto *LastStmt =
15649 if (
const Expr *
Value = LastStmt->getExprStmt()) {
15650 StmtExprMayBindToTemp =
true;
15658 Expr *ResStmtExpr =
15660 if (StmtExprMayBindToTemp)
15662 return ResStmtExpr;
15685 auto *Cast = dyn_cast<ImplicitCastExpr>(
E);
15686 if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)
15687 return Cast->getSubExpr();
15708 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
15709 << ArgTy << TypeRange);
15715 diag::err_offsetof_incomplete_type, TypeRange))
15718 bool DidWarnAboutNonPOD =
false;
15723 if (OC.isBrackets) {
15728 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
15748 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
15749 Exprs.push_back(Idx);
15757 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
15764 diag::err_offsetof_incomplete_type))
15770 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
15782 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
15784 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
15785 : diag::ext_offsetof_non_pod_type;
15788 Diag(BuiltinLoc, DiagID)
15789 <<
SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
15790 DidWarnAboutNonPOD =
true;
15801 MemberDecl = IndirectMemberDecl->getAnonField();
15809 Diag(BuiltinLoc, diag::err_no_member)
15810 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart, OC.LocEnd);
15819 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
15827 if (IndirectMemberDecl)
15828 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
15835 if (Paths.getDetectedVirtual()) {
15836 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
15847 if (IndirectMemberDecl) {
15848 for (
auto *FI : IndirectMemberDecl->chain()) {
15849 assert(isa<FieldDecl>(FI));
15851 cast<FieldDecl>(FI), OC.LocEnd));
15854 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
15860 Comps, Exprs, RParenLoc);
15886 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
15891 bool CondIsTrue =
false;
15896 llvm::APSInt condEval(32);
15898 CondExpr, &condEval, diag::err_typecheck_choose_expr_requires_constant);
15901 CondExpr = CondICE.
get();
15902 CondIsTrue = condEval.getZExtValue();
15905 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
15907 resType = ActiveExpr->
getType();
15913 resType, VK, OK, RPLoc, CondIsTrue);
15925 Decl *ManglingContextDecl;
15926 std::tie(MCtx, ManglingContextDecl) =
15930 Block->setBlockMangling(ManglingNumber, ManglingContextDecl);
15952 "block-id should have no identifier!");
15974 "GetTypeForDeclarator made a non-function block signature");
15990 unsigned Size =
Result.getFullDataSize();
16002 QualType RetTy = Fn->getReturnType();
16004 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
16020 if (ExplicitSignature) {
16021 for (
unsigned I = 0,
E = ExplicitSignature.
getNumParams(); I !=
E; ++I) {
16029 Params.push_back(Param);
16035 for (
const auto &I : Fn->param_types()) {
16038 Params.push_back(Param);
16043 if (!Params.empty()) {
16054 AI->setOwningFunction(CurBlock->
TheDecl);
16057 if (AI->getIdentifier()) {
16063 if (AI->isInvalidDecl())
16082 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
16088 "cleanups within block not correctly bound!");
16101 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
16109 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
16112 if (isa<FunctionNoProtoType>(FTy)) {
16147 BD->
setBody(cast<CompoundStmt>(Body));
16149 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
16174 Expr *CopyExpr =
nullptr;
16183 if (isa<ParmVarDecl>(Var))
16202 if (!
Result.isInvalid() &&
16203 !
Result.get()->getType().isConstQualified()) {
16205 Result.get()->getType().withConst(),
16209 if (!
Result.isInvalid()) {
16219 if (!
Result.isInvalid() &&
16220 !cast<CXXConstructExpr>(
Result.get())->getConstructor()
16223 CopyExpr =
Result.get();
16230 Captures.push_back(NewCap);
16242 if (
Result->getBlockDecl()->hasCaptures()) {
16249 for (
const auto &CI :
Result->getBlockDecl()->captures()) {
16250 const VarDecl *var = CI.getVariable();
16263 {Result},
Result->getType());
16277 Expr *OrigExpr =
E;
16327 if (
Init.isInvalid())
16343 diag::err_first_argument_to_va_arg_not_of_type_va_list)
16348 diag::err_second_parameter_to_va_arg_incomplete,
16354 diag::err_second_parameter_to_va_arg_abstract,
16361 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
16362 : diag::warn_second_parameter_to_va_arg_not_pod)
16395 UnderlyingType = ET->getDecl()->getIntegerType();
16418 if (!PromoteType.
isNull())
16420 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
16442 llvm_unreachable(
"I don't know size of pointer!");
16459 if ((SLDecl->isCompleteDefinition() || SLDecl->isBeingDefined()) &&
16468 S.
Diag(
Loc, diag::err_std_source_location_impl_not_found);
16476 S.
Diag(
Loc, diag::err_std_source_location_impl_malformed);
16480 unsigned Count = 0;
16482 StringRef Name = F->getName();
16484 if (Name ==
"_M_file_name") {
16485 if (F->getType() !=
16489 }
else if (Name ==
"_M_function_name") {
16490 if (F->getType() !=
16494 }
else if (Name ==
"_M_line") {
16495 if (!F->getType()->isIntegerType())
16498 }
else if (Name ==
"_M_column") {
16499 if (!F->getType()->isIntegerType())
16508 S.
Diag(
Loc, diag::err_std_source_location_impl_malformed);
16559 Data->BinaryData = BinaryData;
16562 Data->getDataElementCount());
16566 const Expr *SrcExpr) {
16575 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
16588 bool *Complained) {
16590 *Complained =
false;
16593 bool CheckInferredResultType =
false;
16595 unsigned DiagKind = 0;
16597 bool MayHaveConvFixit =
false;
16598 bool MayHaveFunctionDiff =
false;
16609 DiagKind = diag::err_typecheck_convert_pointer_int;
16612 DiagKind = diag::ext_typecheck_convert_pointer_int;
16615 MayHaveConvFixit =
true;
16619 DiagKind = diag::err_typecheck_convert_int_pointer;
16622 DiagKind = diag::ext_typecheck_convert_int_pointer;
16625 MayHaveConvFixit =
true;
16629 diag::warn_typecheck_convert_incompatible_function_pointer_strict;
16631 MayHaveConvFixit =
true;
16635 DiagKind = diag::err_typecheck_convert_incompatible_function_pointer;
16638 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
16641 MayHaveConvFixit =
true;
16645 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
16647 DiagKind = diag::err_typecheck_convert_incompatible_pointer;
16650 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
16654 if (CheckInferredResultType) {
16660 MayHaveConvFixit =
true;
16664 DiagKind = diag::err_typecheck_convert_incompatible_pointer_sign;
16667 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
16672 DiagKind = diag::err_typecheck_convert_pointer_void_func;
16675 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
16687 DiagKind = diag::err_typecheck_incompatible_address_space;
16690 DiagKind = diag::err_typecheck_incompatible_ownership;
16694 llvm_unreachable(
"unknown error case for discarding qualifiers!");
16711 DiagKind = diag::err_typecheck_convert_discards_qualifiers;
16714 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
16721 DiagKind = diag::err_nested_pointer_qualifier_mismatch;
16723 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
16727 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
16731 DiagKind = diag::err_int_to_block_pointer;
16735 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
16742 for (
auto *srcProto : srcOPT->
quals()) {
16748 IFace = IFaceT->getDecl();
16753 for (
auto *dstProto : dstOPT->
quals()) {
16759 IFace = IFaceT->getDecl();
16762 DiagKind = diag::err_incompatible_qualified_id;
16765 DiagKind = diag::warn_incompatible_qualified_id;
16771 DiagKind = diag::err_incompatible_vectors;
16774 DiagKind = diag::warn_incompatible_vectors;
16778 DiagKind = diag::err_arc_weak_unavailable_assign;
16784 *Complained =
true;
16788 DiagKind = diag::err_typecheck_convert_incompatible;
16790 MayHaveConvFixit =
true;
16792 MayHaveFunctionDiff =
true;
16801 FirstType = DstType;
16802 SecondType = SrcType;
16812 FirstType = SrcType;
16813 SecondType = DstType;
16822 FDiag << FirstType << SecondType << ActionForDiag
16825 if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign ||
16826 DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {
16836 if (!ConvHints.
isNull()) {
16841 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
16843 if (MayHaveFunctionDiff)
16847 if ((DiagKind == diag::warn_incompatible_qualified_id ||
16848 DiagKind == diag::err_incompatible_qualified_id) &&
16850 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
16857 if (CheckInferredResultType)
16864 *Complained =
true;
16875 return S.
Diag(
Loc, diag::err_ice_not_integral)
16894 IDDiagnoser(
unsigned DiagID)
16900 } Diagnoser(DiagID);
16935 BaseDiagnoser(BaseDiagnoser) {}
16944 return S.
Diag(
Loc, diag::err_ice_incomplete_type) <<
T;
16949 return S.
Diag(
Loc, diag::err_ice_explicit_conversion) <<
T << ConvTy;
16960 return S.
Diag(
Loc, diag::err_ice_ambiguous_conversion) <<
T;
16971 llvm_unreachable(
"conversion functions are permitted");
16973 } ConvertDiagnoser(Diagnoser);
16979 E = Converted.
get();
16984 if (isa<RecoveryExpr>(
E))
17000 E = RValueExpr.
get();
17008 if (!isa<ConstantExpr>(
E))
17018 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
17019 diag::note_invalid_subexpr_in_const_expr) {
17020 DiagLoc = Notes[0].first;
17042 EvalResult.
Diag = &Notes;
17051 if (!isa<ConstantExpr>(
E))
17057 if (Folded &&
getLangOpts().CPlusPlus11 && Notes.empty()) {
17066 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
17067 diag::note_invalid_subexpr_in_const_expr) {
17068 DiagLoc = Notes[0].first;
17072 if (!Folded || !CanFold) {
17094 class TransformToPE :
public TreeTransform<TransformToPE> {
17098 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
17101 bool AlwaysRebuild() {
return true; }
17102 bool ReplacingOriginal() {
return true; }
17112 if (isa<FieldDecl>(
E->getDecl()) &&
17113 !SemaRef.isUnevaluatedContext())
17114 return SemaRef.Diag(
E->getLocation(),
17115 diag::err_invalid_non_static_member_use)
17118 return BaseTransform::TransformDeclRefExpr(
E);
17126 return BaseTransform::TransformUnaryOperator(
E);
17134 return SkipLambdaBody(
E, Body);
17141 "Should only transform unevaluated expressions");
17146 return TransformToPE(*this).TransformExpr(
E);
17151 "Should only transform unevaluated expressions");
17155 return TransformToPE(*this).TransformType(TInfo);
17163 LambdaContextDecl, ExprContext);
17177 Prev.isImmediateFunctionContext() || Prev.isConstantEvaluated();
17180 Prev.InImmediateEscalatingFunctionContext;
17199 if (
const auto *
E = dyn_cast<UnaryOperator>(PossibleDeref)) {
17200 if (
E->getOpcode() == UO_Deref)
17201 return CheckPossibleDeref(S,
E->getSubExpr());
17202 }
else if (
const auto *
E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
17203 return CheckPossibleDeref(S,
E->getBase());
17204 }
else if (
const auto *
E = dyn_cast<MemberExpr>(PossibleDeref)) {
17205 return CheckPossibleDeref(S,
E->getBase());
17206 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
17210 Inner = Ptr->getPointeeType();
17212 Inner = Arr->getElementType();
17216 if (Inner->hasAttr(attr::NoDeref))
17226 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this,
E);
17233 Diag(
E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
17248 if (BO->getOpcode() == BO_Assign) {
17250 llvm::erase(LHSs, BO->getLHS());
17258 "Cannot mark an immediate escalating expression outside of an "
17259 "immediate escalating context");
17262 if (
auto *DeclRef =
17263 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
17264 DeclRef->setIsImmediateEscalating(
true);
17265 }
else if (
auto *Ctr = dyn_cast<CXXConstructExpr>(
E->
IgnoreImplicit())) {
17266 Ctr->setIsImmediateEscalating(
true);
17267 }
else if (
auto *DeclRef = dyn_cast<DeclRefExpr>(
E->
IgnoreImplicit())) {
17268 DeclRef->setIsImmediateEscalating(
true);
17270 assert(
false &&
"expected an immediately escalating expression");
17273 FI->FoundImmediateEscalatingExpression =
true;
17288 if (
auto *DeclRef =
17289 dyn_cast<DeclRefExpr>(
Call->getCallee()->IgnoreImplicit()))
17298 auto CheckConstantExpressionAndKeepResult = [&]() {
17301 Eval.
Diag = &Notes;
17303 Eval,
getASTContext(), ConstantExprKind::ImmediateInvocation);
17304 if (Res && Notes.empty()) {
17305 Cached = std::move(Eval.
Val);
17313 !CheckConstantExpressionAndKeepResult()) {
17348 ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
17356 Eval.
Diag = &Notes;
17360 if (!
Result || !Notes.empty()) {
17363 if (
auto *
FunctionalCast = dyn_cast<CXXFunctionalCastExpr>(InnerExpr))
17366 if (
auto *
Call = dyn_cast<CallExpr>(InnerExpr))
17367 FD = cast<FunctionDecl>(
Call->getCalleeDecl());
17368 else if (
auto *
Call = dyn_cast<CXXConstructExpr>(InnerExpr))
17369 FD =
Call->getConstructor();
17370 else if (
auto *Cast = dyn_cast<CastExpr>(InnerExpr))
17371 FD = dyn_cast_or_null<FunctionDecl>(Cast->getConversionFunction());
17374 "could not find an immediate function in this expression");
17387 for (
auto &
Note : Notes)
17399 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
17403 ComplexRemove(
Sema &SemaRef, llvm::SmallPtrSetImpl<DeclRefExpr *> &DR,
17406 4>::reverse_iterator Current)
17407 :
Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
17409 auto It = std::find_if(CurrentII, IISet.rend(),
17411 return Elem.getPointer() == E;
17417 if (It == IISet.rend()) {
17419 CurrentII->setInt(1);
17425 if (!
E->isImmediateInvocation())
17426 return Base::TransformConstantExpr(
E);
17427 RemoveImmediateInvocation(
E);
17428 return Base::TransformExpr(
E->getSubExpr());
17434 return Base::TransformCXXOperatorCallExpr(
E);
17446 if (
auto *CE = dyn_cast<ConstantExpr>(
Init))
17447 if (CE->isImmediateInvocation())
17448 RemoveImmediateInvocation(CE);
17449 return Base::TransformInitializer(
Init, NotCopyInit);
17460 bool AlwaysRebuild() {
return false; }
17461 bool ReplacingOriginal() {
return true; }
17462 bool AllowSkippingCXXConstructExpr() {
17463 bool Res = AllowSkippingFirstCXXConstructExpr;
17464 AllowSkippingFirstCXXConstructExpr =
true;
17467 bool AllowSkippingFirstCXXConstructExpr =
true;
17477 if (isa<CXXConstructExpr>(It->getPointer()->IgnoreImplicit()))
17478 Transformer.AllowSkippingFirstCXXConstructExpr =
false;
17480 ExprResult Res = Transformer.TransformExpr(It->getPointer()->getSubExpr());
17486 It->getPointer()->setSubExpr(Res.
get());
17521 llvm::SmallPtrSetImpl<DeclRefExpr *> &DRSet;
17522 SimpleRemove(llvm::SmallPtrSetImpl<DeclRefExpr *> &S) : DRSet(S) {}
17525 return DRSet.size();
17528 Visitor.TraverseStmt(
17538 if (DR->isImmediateEscalating())
17540 auto *FD = cast<FunctionDecl>(DR->getDecl());
17542 if (
const auto *MD = dyn_cast<CXXMethodDecl>(ND);
17544 ND = MD->getParent();
17551 bool ImmediateEscalating =
false;
17552 bool IsPotentiallyEvaluated =
17562 SemaRef.
Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
17563 << ND << isa<CXXRecordDecl>(ND) << FD->isConsteval();
17571 if (FD->isImmediateEscalating() && !FD->isConsteval())
17587 (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument ||
17595 D = diag::err_lambda_unevaluated_operand;
17601 D = diag::err_lambda_in_constant_expression;
17602 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
17605 D = diag::err_lambda_in_invalid_context;
17607 llvm_unreachable(
"Couldn't infer lambda error message.");
17609 for (
const auto *L : Rec.
Lambdas)
17610 Diag(L->getBeginLoc(),
D);
17618 PrevRecord.InLifetimeExtendingContext &&
17620 PrevRecord.ForRangeLifetimeExtendTemps.append(
17631 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
17704 llvm_unreachable(
"Invalid context");
17713 if (!TT.isOSWindows() || !TT.isX86())
17751 : FD(FD), Param(Param) {}
17758 CCName =
"stdcall";
17761 CCName =
"fastcall";
17764 CCName =
"vectorcall";
17767 llvm_unreachable(
"CC does not need mangling");
17770 S.
Diag(
Loc, diag::err_cconv_incomplete_param_type)
17776 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
17782enum class OdrUseContext {
17804 return OdrUseContext::None;
17809 Result = OdrUseContext::Used;
17813 Result = OdrUseContext::FormallyOdrUsed;
17819 Result = OdrUseContext::FormallyOdrUsed;
17824 return OdrUseContext::Dependent;
17830 if (!
Func->isConstexpr())
17833 if (
Func->isImplicitlyInstantiable() || !
Func->isUserProvided())
17835 auto *CCD = dyn_cast<CXXConstructorDecl>(
Func);
17836 return CCD && CCD->getInheritedConstructor();
17840 bool MightBeOdrUse) {
17841 assert(
Func &&
"No function?");
17843 Func->setReferenced();
17856 OdrUseContext OdrUse =
17858 if (IsRecursiveCall && OdrUse == OdrUseContext::Used)
17859 OdrUse = OdrUseContext::FormallyOdrUsed;
17863 if (
Func->isTrivial() && !
Func->hasAttr<DLLExportAttr>() &&
17864 OdrUse == OdrUseContext::Used) {
17865 if (
auto *Constructor = dyn_cast<CXXConstructorDecl>(
Func))
17866 if (Constructor->isDefaultConstructor())
17867 OdrUse = OdrUseContext::FormallyOdrUsed;
17868 if (isa<CXXDestructorDecl>(
Func))
17869 OdrUse = OdrUseContext::FormallyOdrUsed;
17876 bool NeededForConstantEvaluation =
17901 bool NeedDefinition =
17902 !IsRecursiveCall &&
17903 (OdrUse == OdrUseContext::Used ||
17904 (NeededForConstantEvaluation && !
Func->isPureVirtual()));
17911 if (NeedDefinition &&
17913 Func->getMemberSpecializationInfo()))
17920 if (NeedDefinition && !
Func->getBody()) {
17923 dyn_cast<CXXConstructorDecl>(
Func)) {
17924 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
17925 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
17926 if (Constructor->isDefaultConstructor()) {
17927 if (Constructor->isTrivial() &&
17928 !Constructor->hasAttr<DLLExportAttr>())
17931 }
else if (Constructor->isCopyConstructor()) {
17933 }
else if (Constructor->isMoveConstructor()) {
17936 }
else if (Constructor->getInheritedConstructor()) {
17940 dyn_cast<CXXDestructorDecl>(
Func)) {
17950 if (MethodDecl->isOverloadedOperator() &&
17951 MethodDecl->getOverloadedOperator() == OO_Equal) {
17952 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
17953 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
17954 if (MethodDecl->isCopyAssignmentOperator())
17956 else if (MethodDecl->isMoveAssignmentOperator())
17959 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
17960 MethodDecl->getParent()->isLambda()) {
17962 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
17967 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
17971 if (
Func->isDefaulted() && !
Func->isDeleted()) {
17979 if (
Func->isImplicitlyInstantiable()) {
17981 Func->getTemplateSpecializationKindForInstantiation();
17983 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
17984 if (FirstInstantiation) {
17985 PointOfInstantiation =
Loc;
17986 if (
auto *MSI =
Func->getMemberSpecializationInfo())
17987 MSI->setPointOfInstantiation(
Loc);
17990 Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
17995 PointOfInstantiation =
Loc;
17999 Func->isConstexpr()) {
18000 if (isa<CXXRecordDecl>(
Func->getDeclContext()) &&
18001 cast<CXXRecordDecl>(
Func->getDeclContext())->isLocalClass() &&
18004 std::make_pair(
Func, PointOfInstantiation));
18005 else if (
Func->isConstexpr())
18011 Func->setInstantiationIsPending(
true);
18013 std::make_pair(
Func, PointOfInstantiation));
18020 for (
auto *i :
Func->redecls()) {
18021 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
18034 Constructor->isImmediateFunction()
18039 if (
Init->isInClassMemberInitializer())
18041 MarkDeclarationsReferencedInExpr(Init->getInit());
18062 if (
LangOpts.OffloadImplicitHostDeviceTemplates &&
LangOpts.CUDAIsDevice &&
18067 if (OdrUse == OdrUseContext::Used && !
Func->isUsed(
false)) {
18069 if (!
Func->isDefined()) {
18070 if (mightHaveNonExternalLinkage(
Func))
18072 else if (
Func->getMostRecentDecl()->isInlined() &&
18074 !
Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
18093 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(
Func)) {
18095 if (
Parent->getNumVBases() > 0 && !Dtor->getBody())
18113 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
18116 VarDecl *Var =
V->getPotentiallyDecomposedVarDecl();
18117 assert(Var &&
"expected a capturable variable");
18127 QualType CaptureType, DeclRefType;
18133 DeclRefType, FunctionScopeIndexToStopAt);
18149 << llvm::to_underlying(UserTarget);
18152 ? diag::note_cuda_const_var_unpromoted
18153 : diag::note_cuda_host_var);
18156 !Var->
hasAttr<CUDASharedAttr>() &&
18172 (!FD || (!FD->getDescribedFunctionTemplate() &&
18184 unsigned CapturingScopeIndex) {
18195 if (isa<ParmVarDecl>(var) &&
18196 isa<TranslationUnitDecl>(VarDC))
18209 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
18210 unsigned ContextKind = 3;
18211 if (isa<CXXMethodDecl>(VarDC) &&
18212 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
18214 }
else if (isa<FunctionDecl>(VarDC)) {
18216 }
else if (isa<BlockDecl>(VarDC)) {
18220 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
18221 << var << ValueKind << ContextKind << VarDC;
18222 S.
Diag(var->getLocation(), diag::note_entity_declared_at)
18231 bool &SubCapturesAreNested,
18237 SubCapturesAreNested =
true;
18250 !(isa<LambdaScopeInfo>(CSI) &&
18251 !cast<LambdaScopeInfo>(CSI)->lambdaCaptureShouldBeConst()) &&
18252 !(isa<CapturedRegionScopeInfo>(CSI) &&
18253 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
18285 assert((isa<VarDecl, BindingDecl>(Var)) &&
18286 "Only variables and structured bindings can be captured");
18288 bool IsBlock = isa<BlockScopeInfo>(CSI);
18289 bool IsLambda = isa<LambdaScopeInfo>(CSI);
18297 S.
Diag(
Loc, diag::err_lambda_capture_anonymous_var);
18306 S.
Diag(
Loc, diag::err_ref_vm_type);
18314 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
18317 S.
Diag(
Loc, diag::err_ref_flexarray_type);
18319 S.
Diag(
Loc, diag::err_lambda_capture_flexarray_type) << Var;
18325 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
18328 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
18330 S.
Diag(
Loc, diag::err_capture_block_variable) << Var << !IsLambda;
18339 S.
Diag(
Loc, diag::err_opencl_block_ref_block);
18343 if (isa<BindingDecl>(Var)) {
18350 ? diag::warn_cxx17_compat_capture_binding
18351 : diag::ext_capture_binding)
18365 bool ByRef =
false;
18371 if (BuildAndDiagnose) {
18372 S.
Diag(
Loc, diag::err_ref_array_type);
18383 if (BuildAndDiagnose) {
18384 S.
Diag(
Loc, diag::err_arc_autoreleasing_capture)
18400 if (BuildAndDiagnose) {
18402 S.
Diag(
Loc, diag::warn_block_capture_autoreleasing);
18403 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
18408 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
18417 DeclRefType = CaptureType;
18421 if (BuildAndDiagnose)
18431 const bool BuildAndDiagnose,
QualType &CaptureType,
QualType &DeclRefType,
18458 CaptureType = DeclRefType;
18461 if (BuildAndDiagnose)
18462 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
18472 const bool RefersToCapturedVariable,
18477 bool ByRef =
false;
18481 ByRef = (LSI->
ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByref);
18486 S.
Diag(
Loc, diag::err_wasm_ca_reference) << 0;
18517 if (!RefType->getPointeeType()->isFunctionType())
18524 if (BuildAndDiagnose) {
18525 S.
Diag(
Loc, diag::err_arc_autoreleasing_capture) << 1;
18535 if (!
Invalid && BuildAndDiagnose) {
18539 diag::err_capture_of_incomplete_or_sizeless_type,
18543 diag::err_capture_of_abstract_type))
18564 if (BuildAndDiagnose)
18565 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
18577 if (
T.isTriviallyCopyableType(
Context))
18581 if (!(RD = RD->getDefinition()))
18583 if (RD->hasSimpleCopyConstructor())
18585 if (RD->hasUserDeclaredCopyConstructor())
18587 if (Ctor->isCopyConstructor())
18588 return !Ctor->isDeleted();
18608 if (ShouldOfferCopyFix) {
18612 FixBuffer.assign({Separator, Var->
getName()});
18613 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
18618 FixBuffer.assign({Separator,
"&", Var->
getName()});
18619 Sema.
Diag(VarInsertLoc, diag::note_lambda_variable_capture_fixit)
18631 return !C.isThisCapture() && !C.isInitCapture();
18640 if (ShouldOfferCopyFix) {
18641 bool CanDefaultCopyCapture =
true;
18650 if (CanDefaultCopyCapture && llvm::none_of(LSI->
Captures, [](
Capture &
C) {
18651 return !C.isThisCapture() && !C.isInitCapture() && C.isCopyCapture();
18653 FixBuffer.assign({
"=", Separator});
18654 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
18663 return !C.isInitCapture() && C.isReferenceCapture() &&
18664 !C.isThisCapture();
18666 FixBuffer.assign({
"&", Separator});
18667 Sema.
Diag(DefaultInsertLoc, diag::note_lambda_default_capture_fixit)
18676 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
18699 const auto *VD = dyn_cast<VarDecl>(Var);
18701 if (VD->isInitCapture())
18706 assert(VD &&
"Cannot capture a null variable");
18708 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
18712 if (FunctionScopeIndexToStopAt) {
18714 while (FSIndex != MaxFunctionScopesIndex) {
18722 bool IsGlobal = !VD->hasLocalStorage();
18723 if (IsGlobal && !(
LangOpts.OpenMP &&
18724 OpenMP().isOpenMPCapturedDecl(Var,
true,
18725 MaxFunctionScopesIndex)))
18728 if (isa<VarDecl>(Var))
18739 CaptureType = Var->
getType();
18741 bool Nested =
false;
18743 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
18748 LSI = dyn_cast_or_null<LambdaScopeInfo>(
18751 bool IsInScopeDeclarationContext =
18762 if (IsInScopeDeclarationContext &&
18763 FunctionScopesIndex == MaxFunctionScopesIndex && VarDC == DC)
18769 !IsInScopeDeclarationContext
18772 BuildAndDiagnose, *
this);
18778 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
18797 if (
const auto *Parm = dyn_cast<ParmVarDecl>(Var);
18798 Parm && Parm->getDeclContext() == DC)
18806 if (BuildAndDiagnose) {
18809 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
18824 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
18825 QTy = PVD->getOriginalType();
18830 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
18836 if (isa<BindingDecl>(Var)) {
18837 if (BuildAndDiagnose) {
18838 Diag(ExprLoc, diag::err_capture_binding_openmp) << Var;
18844 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
18849 if (IsOpenMPPrivateDecl != OMPC_unknown &&
18852 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
18853 QTy = PVD->getOriginalType();
18855 E =
OpenMP().getNumberOfConstructScopes(RSI->OpenMPLevel);
18857 auto *OuterRSI = cast<CapturedRegionScopeInfo>(
18859 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
18860 "Wrong number of captured regions associated with the "
18861 "OpenMP construct.");
18866 IsOpenMPPrivateDecl != OMPC_private &&
18868 RSI->OpenMPCaptureLevel);
18872 Var, RSI->OpenMPLevel, RSI->OpenMPCaptureLevel);
18878 OpenMP().adjustOpenMPTargetScopeIndex(FunctionScopesIndex,
18881 if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
18882 (IsGlobal && !IsGlobalCap)) {
18883 Nested = !IsTargetCap;
18898 if (BuildAndDiagnose) {
18899 Diag(ExprLoc, diag::err_lambda_impcap) << Var;
18901 auto *LSI = cast<LambdaScopeInfo>(CSI);
18921 FunctionScopesIndex--;
18922 if (IsInScopeDeclarationContext)
18924 }
while (!VarDC->
Equals(DC));
18932 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
18945 if (
Invalid && !BuildAndDiagnose)
18950 DeclRefType, Nested, *
this,
Invalid);
18954 RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
18955 Kind, I == N - 1, *
this,
Invalid);
18961 DeclRefType, Nested, Kind, EllipsisLoc,
18966 if (
Invalid && !BuildAndDiagnose)
18978 DeclRefType,
nullptr);
18985 false, CaptureType,
18986 DeclRefType,
nullptr);
18995 false, CaptureType,
18996 DeclRefType,
nullptr))
18999 return DeclRefType;
19007class CopiedTemplateArgs {
19011 template<
typename RefExpr>
19012 CopiedTemplateArgs(RefExpr *
E) : HasArgs(
E->hasExplicitTemplateArgs()) {
19014 E->copyTemplateArgumentsInto(TemplateArgStorage);
19017#ifdef __has_cpp_attribute
19018#
if __has_cpp_attribute(clang::lifetimebound)
19019 [[clang::lifetimebound]]
19023 return HasArgs ? &TemplateArgStorage :
nullptr;
19049 auto Rebuild = [&](
Expr *Sub) {
19054 auto IsPotentialResultOdrUsed = [&](
NamedDecl *
D) {
19057 auto *VD = dyn_cast<VarDecl>(
D);
19080 llvm_unreachable(
"unexpected non-odr-use-reason");
19084 if (VD->getType()->isReferenceType())
19086 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
19087 if (RD->hasMutableFields())
19089 if (!VD->isUsableInConstantExpressions(S.
Context))
19094 if (VD->getType()->isReferenceType())
19102 auto MarkNotOdrUsed = [&] {
19105 LSI->markVariableExprAsNonODRUsed(
E);
19112 case Expr::DeclRefExprClass: {
19113 auto *DRE = cast<DeclRefExpr>(
E);
19114 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
19120 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
19121 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
19122 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
19123 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
19126 case Expr::FunctionParmPackExprClass: {
19127 auto *FPPE = cast<FunctionParmPackExpr>(
E);
19131 if (IsPotentialResultOdrUsed(
D))
19142 case Expr::ArraySubscriptExprClass: {
19143 auto *ASE = cast<ArraySubscriptExpr>(
E);
19148 if (!
Base.isUsable())
19150 Expr *LHS = ASE->getBase() == ASE->getLHS() ?
Base.get() : ASE->getLHS();
19151 Expr *RHS = ASE->getBase() == ASE->getRHS() ?
Base.get() : ASE->getRHS();
19154 ASE->getRBracketLoc());
19157 case Expr::MemberExprClass: {
19158 auto *ME = cast<MemberExpr>(
E);
19161 if (isa<FieldDecl>(ME->getMemberDecl())) {
19163 if (!
Base.isUsable())
19166 S.
Context,
Base.get(), ME->isArrow(), ME->getOperatorLoc(),
19167 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
19168 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
19169 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
19170 ME->getObjectKind(), ME->isNonOdrUse());
19173 if (ME->getMemberDecl()->isCXXInstanceMember())
19178 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
19184 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
19185 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
19186 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
19187 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
19190 case Expr::BinaryOperatorClass: {
19191 auto *BO = cast<BinaryOperator>(
E);
19192 Expr *LHS = BO->getLHS();
19193 Expr *RHS = BO->getRHS();
19195 if (BO->getOpcode() == BO_PtrMemD) {
19197 if (!Sub.isUsable())
19199 BO->setLHS(Sub.get());
19201 }
else if (BO->getOpcode() == BO_Comma) {
19203 if (!Sub.isUsable())
19205 BO->setRHS(Sub.get());
19213 case Expr::ParenExprClass: {
19214 auto *PE = cast<ParenExpr>(
E);
19216 if (!Sub.isUsable())
19218 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
19223 case Expr::ConditionalOperatorClass: {
19224 auto *CO = cast<ConditionalOperator>(
E);
19234 LHS = CO->getLHS();
19236 RHS = CO->getRHS();
19238 CO->getCond(), LHS.
get(), RHS.
get());
19243 case Expr::UnaryOperatorClass: {
19244 auto *UO = cast<UnaryOperator>(
E);
19245 if (UO->getOpcode() != UO_Extension)
19248 if (!Sub.isUsable())
19250 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
19257 case Expr::GenericSelectionExprClass: {
19258 auto *GSE = cast<GenericSelectionExpr>(
E);
19261 bool AnyChanged =
false;
19262 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
19263 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
19267 AssocExprs.push_back(AssocExpr.
get());
19270 AssocExprs.push_back(OrigAssocExpr);
19274 void *ExOrTy =
nullptr;
19275 bool IsExpr = GSE->isExprPredicate();
19277 ExOrTy = GSE->getControllingExpr();
19279 ExOrTy = GSE->getControllingType();
19281 GSE->getGenericLoc(), GSE->getDefaultLoc(),
19282 GSE->getRParenLoc(), IsExpr, ExOrTy,
19283 GSE->getAssocTypeSourceInfos(), AssocExprs)
19291 case Expr::ChooseExprClass: {
19292 auto *CE = cast<ChooseExpr>(
E);
19302 if (!LHS.
get() && !RHS.
get())
19305 LHS = CE->getLHS();
19307 RHS = CE->getRHS();
19310 RHS.
get(), CE->getRParenLoc());
19314 case Expr::ConstantExprClass: {
19315 auto *CE = cast<ConstantExpr>(
E);
19317 if (!Sub.isUsable())
19324 case Expr::ImplicitCastExprClass: {
19325 auto *ICE = cast<ImplicitCastExpr>(
E);
19329 switch (ICE->getCastKind()) {
19331 case CK_DerivedToBase:
19332 case CK_UncheckedDerivedToBase: {
19333 ExprResult Sub = Rebuild(ICE->getSubExpr());
19334 if (!Sub.isUsable())
19338 ICE->getValueKind(), &
Path);
19397 for (
Expr *
E : LocalMaybeODRUseExprs) {
19398 if (
auto *DRE = dyn_cast<DeclRefExpr>(
E)) {
19400 DRE->getLocation(), *
this);
19401 }
else if (
auto *ME = dyn_cast<MemberExpr>(
E)) {
19404 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(
E)) {
19408 llvm_unreachable(
"Unexpected expression");
19413 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
19422 const bool RefersToEnclosingScope =
19425 if (RefersToEnclosingScope) {
19440 assert(
E &&
"Capture variable should be used in an expression.");
19451 assert((!
E || isa<DeclRefExpr>(
E) || isa<MemberExpr>(
E) ||
19452 isa<FunctionParmPackExpr>(
E)) &&
19453 "Invalid Expr argument to DoMarkVarDeclReferenced");
19464 bool UsableInConstantExpr =
19476 bool NeededForConstantEvaluation =
19479 bool NeedDefinition =
19480 OdrUse == OdrUseContext::Used || NeededForConstantEvaluation;
19482 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
19483 "Can't instantiate a partial template specialization.");
19489 !isa<VarTemplateSpecializationDecl>(Var))
19500 bool TryInstantiating =
19504 if (TryInstantiating) {
19507 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
19508 if (FirstInstantiation) {
19509 PointOfInstantiation =
Loc;
19511 MSI->setPointOfInstantiation(PointOfInstantiation);
19517 if (UsableInConstantExpr) {
19526 if (
auto *DRE = dyn_cast_or_null<DeclRefExpr>(
E))
19527 DRE->setDecl(DRE->getDecl());
19528 else if (
auto *ME = dyn_cast_or_null<MemberExpr>(
E))
19529 ME->setMemberDecl(ME->getMemberDecl());
19530 }
else if (FirstInstantiation) {
19532 .push_back(std::make_pair(Var, PointOfInstantiation));
19534 bool Inserted =
false;
19536 auto Iter = llvm::find_if(
19538 return P.first == Var;
19540 if (
Iter != I.end()) {
19553 if (isa<VarTemplateSpecializationDecl>(Var) && !Inserted)
19555 .push_back(std::make_pair(Var, PointOfInstantiation));
19579 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(
E))
19580 if (DRE->isNonOdrUse())
19582 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(
E))
19583 if (ME->isNonOdrUse())
19587 case OdrUseContext::None:
19590 assert((!
E || isa<FunctionParmPackExpr>(
E) ||
19592 "missing non-odr-use marking for unevaluated decl ref");
19595 case OdrUseContext::FormallyOdrUsed:
19600 case OdrUseContext::Used:
19609 case OdrUseContext::Dependent:
19627 if (OdrUse == OdrUseContext::Used) {
19628 QualType CaptureType, DeclRefType;
19634 }
else if (OdrUse == OdrUseContext::Dependent) {
19650 auto *ID = dyn_cast<DeclRefExpr>(
E);
19651 if (!ID || ID->isTypeDependent() || !ID->refersToEnclosingVariableOrCapture())
19658 auto IsDependent = [&]() {
19660 auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope);
19665 LSI->AfterParameterList)
19668 const auto *MD = LSI->CallOperator;
19669 if (MD->getType().isNull())
19673 if (!Ty || !MD->isExplicitObjectMemberFunction() ||
19677 if (
auto *
C = LSI->CaptureMap.count(
D) ? &LSI->getCapture(
D) :
nullptr) {
19678 if (
C->isCopyCapture())
19683 if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
19689 ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
19695 bool MightBeOdrUse,
19700 if (
VarDecl *Var = dyn_cast<VarDecl>(
D)) {
19726 bool IsVirtualCall = MD->
isVirtual() &&
19728 if (!IsVirtualCall)
19743 bool OdrUse =
true;
19744 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(
E->getDecl()))
19745 if (Method->isVirtual() &&
19749 if (
auto *FD = dyn_cast<FunctionDecl>(
E->getDecl())) {
19754 !FD->isDependentContext())
19768 bool MightBeOdrUse =
true;
19770 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(
E->getMemberDecl()))
19771 if (Method->isPureVirtual())
19772 MightBeOdrUse =
false;
19775 E->getMemberLoc().isValid() ?
E->getMemberLoc() :
E->
getBeginLoc();
19791 bool MightBeOdrUse) {
19792 if (MightBeOdrUse) {
19793 if (
auto *VD = dyn_cast<VarDecl>(
D)) {
19798 if (
auto *FD = dyn_cast<FunctionDecl>(
D)) {
19826bool MarkReferencedDecls::TraverseTemplateArgument(
19840 return Inherited::TraverseTemplateArgument(Arg);
19844 MarkReferencedDecls Marker(*
this,
Loc);
19845 Marker.TraverseType(
T);
19851class EvaluatedExprMarker :
public UsedDeclVisitor<EvaluatedExprMarker> {
19854 bool SkipLocalVariables;
19857 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables,
19859 : Inherited(S), SkipLocalVariables(SkipLocalVariables), StopAt(StopAt) {}
19865 void Visit(
Expr *
E) {
19866 if (llvm::is_contained(StopAt,
E))
19868 Inherited::Visit(
E);
19878 if (SkipLocalVariables) {
19879 if (
VarDecl *VD = dyn_cast<VarDecl>(
E->getDecl()))
19880 if (VD->hasLocalStorage())
19892 Visit(
E->getBase());
19898 bool SkipLocalVariables,
19900 EvaluatedExprMarker(*
this, SkipLocalVariables, StopAt).Visit(
E);
19922 if (
auto *VD = dyn_cast_or_null<VarDecl>(
19924 if (VD->isConstexpr() ||
19925 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
19997 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
20003 : FD(FD), CE(CE) { }
20007 S.
Diag(
Loc, diag::err_call_incomplete_return)
20012 S.
Diag(
Loc, diag::err_call_function_incomplete_return)
20017 } Diagnoser(FD, CE);
20030 unsigned diagnostic = diag::warn_condition_is_assignment;
20031 bool IsOrAssign =
false;
20034 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
20037 IsOrAssign = Op->getOpcode() == BO_OrAssign;
20045 if (
ObjC().isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
20046 diagnostic = diag::warn_condition_is_idiomatic_assignment;
20050 diagnostic = diag::warn_condition_is_idiomatic_assignment;
20053 Loc = Op->getOperatorLoc();
20055 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
20058 IsOrAssign = Op->getOperator() == OO_PipeEqual;
20059 Loc = Op->getOperatorLoc();
20071 Diag(
Loc, diag::note_condition_assign_silence)
20076 Diag(
Loc, diag::note_condition_or_assign_to_comparison)
20079 Diag(
Loc, diag::note_condition_assign_to_comparison)
20095 if (opE->getOpcode() == BO_EQ &&
20096 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
20102 Diag(
Loc, diag::note_equality_comparison_silence)
20105 Diag(
Loc, diag::note_equality_comparison_to_assign)
20111 bool IsConstexpr) {
20113 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(
E))
20131 Diag(
Loc, diag::err_typecheck_statement_requires_scalar)
20135 CheckBoolLikeConversion(
E,
Loc);
20181 struct RebuildUnknownAnyFunction
20182 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
20186 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
20189 llvm_unreachable(
"unexpected statement!");
20200 template <
class T>
ExprResult rebuildSugarExpr(
T *
E) {
20204 Expr *SubExpr = SubResult.
get();
20205 E->setSubExpr(SubExpr);
20213 return rebuildSugarExpr(
E);
20217 return rebuildSugarExpr(
E);
20224 Expr *SubExpr = SubResult.
get();
20225 E->setSubExpr(SubExpr);
20233 if (!isa<FunctionDecl>(VD))
return VisitExpr(
E);
20239 !(isa<CXXMethodDecl>(VD) &&
20240 cast<CXXMethodDecl>(VD)->isInstance()))
20247 return resolveDecl(
E,
E->getMemberDecl());
20251 return resolveDecl(
E,
E->getDecl());
20269 struct RebuildUnknownAnyExpr
20270 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
20281 llvm_unreachable(
"unexpected statement!");
20295 template <
class T>
ExprResult rebuildSugarExpr(
T *
E) {
20298 Expr *SubExpr = SubResult.
get();
20299 E->setSubExpr(SubExpr);
20307 return rebuildSugarExpr(
E);
20311 return rebuildSugarExpr(
E);
20317 S.
Diag(
E->getOperatorLoc(), diag::err_unknown_any_addrof)
20322 if (isa<CallExpr>(
E->getSubExpr())) {
20323 S.
Diag(
E->getOperatorLoc(), diag::err_unknown_any_addrof_call)
20336 E->setSubExpr(SubResult.
get());
20345 return resolveDecl(
E,
E->getMemberDecl());
20349 return resolveDecl(
E,
E->getDecl());
20356 Expr *CalleeExpr =
E->getCallee();
20360 FK_FunctionPointer,
20367 assert(isa<CXXMemberCallExpr>(
E) || isa<CXXOperatorCallExpr>(
E));
20368 Kind = FK_MemberFunction;
20372 Kind = FK_FunctionPointer;
20375 Kind = FK_BlockPointer;
20381 unsigned diagID = diag::err_func_returning_array_function;
20382 if (Kind == FK_BlockPointer)
20383 diagID = diag::err_block_returning_array_function;
20419 if (ParamTypes.empty() && Proto->
isVariadic()) {
20420 ArgTypes.reserve(
E->getNumArgs());
20421 for (
unsigned i = 0, e =
E->getNumArgs(); i != e; ++i) {
20424 ParamTypes = ArgTypes;
20435 case FK_MemberFunction:
20439 case FK_FunctionPointer:
20443 case FK_BlockPointer:
20449 ExprResult CalleeResult = Visit(CalleeExpr);
20451 E->setCallee(CalleeResult.
get());
20468 Method->setReturnType(DestType);
20480 if (
E->getCastKind() == CK_FunctionToPointerDecay) {
20494 }
else if (
E->getCastKind() == CK_LValueToRValue) {
20498 assert(isa<BlockPointerType>(
E->
getType()));
20511 llvm_unreachable(
"Unhandled cast type!");
20544 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
20548 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
20550 false , FD->hasPrototype(),
20553 if (FD->getQualifier())
20557 for (
const auto &AI : FT->param_types()) {
20561 Params.push_back(Param);
20563 NewFD->setParams(Params);
20570 if (MD->isInstance()) {
20580 }
else if (isa<VarDecl>(VD)) {
20610 diag::err_typecheck_cast_to_incomplete))
20625 return RebuildUnknownAnyExpr(*
this, ToType).Visit(
E);
20632 ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
20641 assert(!arg->hasPlaceholderType());
20653 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
20656 if (
CallExpr *call = dyn_cast<CallExpr>(
E)) {
20657 E = call->getCallee();
20658 diagID = diag::err_uncasted_call_of_unknown_any;
20667 loc = ref->getLocation();
20668 d = ref->getDecl();
20669 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(
E)) {
20670 loc = mem->getMemberLoc();
20671 d = mem->getMemberDecl();
20673 diagID = diag::err_uncasted_call_of_unknown_any;
20674 loc = msg->getSelectorStartLoc();
20675 d = msg->getMethodDecl();
20677 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
20678 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
20705 if (!placeholderType)
return E;
20707 switch (placeholderType->
getKind()) {
20708 case BuiltinType::UnresolvedTemplate: {
20709 auto *ULE = cast<UnresolvedLookupExpr>(
E);
20714 const bool IsTypeAliasTemplateDecl = isa<TypeAliasTemplateDecl>(Temp);
20717 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
20719 <<
Loc.getSourceRange() << IsTypeAliasTemplateDecl;
20721 Diag(NameInfo.
getLoc(), diag::err_template_kw_refers_to_type_template)
20723 << IsTypeAliasTemplateDecl;
20725 << IsTypeAliasTemplateDecl;
20731 case BuiltinType::Overload: {
20751 case BuiltinType::BoundMember: {
20756 if (isa<CXXPseudoDestructorExpr>(BME)) {
20757 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
20758 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
20759 if (ME->getMemberNameInfo().getName().getNameKind() ==
20761 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
20769 case BuiltinType::ARCUnbridgedCast: {
20776 case BuiltinType::UnknownAny:
20780 case BuiltinType::PseudoObject:
20783 case BuiltinType::BuiltinFn: {
20787 auto *FD = cast<FunctionDecl>(DRE->
getDecl());
20788 unsigned BuiltinID = FD->getBuiltinID();
20789 if (BuiltinID == Builtin::BI__noop) {
20791 CK_BuiltinFnToFnPtr)
20804 ? diag::err_use_of_unaddressable_function
20805 : diag::warn_cxx20_compat_use_of_unaddressable_function);
20806 if (FD->isImplicitlyInstantiable()) {
20833 case BuiltinType::IncompleteMatrixIdx:
20837 diag::err_matrix_incomplete_index);
20841 case BuiltinType::ArraySection:
20843 << cast<ArraySectionExpr>(
E)->isOMPArraySection();
20847 case BuiltinType::OMPArrayShaping:
20850 case BuiltinType::OMPIterator:
20854#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
20855 case BuiltinType::Id:
20856#include "clang/Basic/OpenCLImageTypes.def"
20857#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
20858 case BuiltinType::Id:
20859#include "clang/Basic/OpenCLExtensionTypes.def"
20860#define SVE_TYPE(Name, Id, SingletonId) \
20861 case BuiltinType::Id:
20862#include "clang/Basic/AArch64SVEACLETypes.def"
20863#define PPC_VECTOR_TYPE(Name, Id, Size) \
20864 case BuiltinType::Id:
20865#include "clang/Basic/PPCTypes.def"
20866#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
20867#include "clang/Basic/RISCVVTypes.def"
20868#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
20869#include "clang/Basic/WebAssemblyReferenceTypes.def"
20870#define AMDGPU_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
20871#include "clang/Basic/AMDGPUTypes.def"
20872#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
20873#define PLACEHOLDER_TYPE(Id, SingletonId)
20874#include "clang/AST/BuiltinTypes.def"
20878 llvm_unreachable(
"invalid placeholder type!");
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static bool isObjCPointer(const MemRegion *R)
Defines enum values for all the target-independent builtin functions.
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
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 captureInCapturedRegion(CapturedRegionScopeInfo *RSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema::TryCaptureKind Kind, bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the captured region.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing?
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, const Expr *LHSExpr, const Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D, bool AcceptInvalid)
Diagnoses obvious problems with the use of the given declaration as an expression.
static 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 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 void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(Sema &SemaRef, ValueDecl *D, Expr *E)
static bool isVariableCapturable(CapturingScopeInfo *CSI, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
static Decl * getPredefinedExprDecl(DeclContext *DC)
getPredefinedExprDecl - Returns Decl of a given DeclContext that can be used to determine the value o...
static CXXRecordDecl * LookupStdSourceLocationImpl(Sema &S, SourceLocation Loc)
static bool IgnoreCommaOperand(const Expr *E, const ASTContext &Context)
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc, bool IsAfterAmp=false)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static bool ExprLooksBoolean(const Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef)
Are we in a context that is potentially constant evaluated per C++20 [expr.const]p12?
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc, bool IsBuiltin)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
static bool checkCondition(Sema &S, const Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
static bool checkForArray(const Expr *E)
static void DiagnosedUnqualifiedCallsToStdFunctions(Sema &S, const CallExpr *Call)
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse, llvm::DenseMap< const VarDecl *, int > &RefsMinusAssignments)
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 NamedDecl * getDeclFromExpr(Expr *E)
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
static bool IsInvalidCmseNSCallConversion(Sema &S, QualType FromType, QualType ToType)
static void RemoveNestedImmediateInvocation(Sema &SemaRef, Sema::ExpressionEvaluationContextRecord &Rec, SmallVector< Sema::ImmediateInvocationCandidate, 4 >::reverse_iterator It)
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 void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr * > Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
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 Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
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 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 bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S, bool Invalid)
Capture the given variable in the lambda.
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 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 SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
static bool captureInBlock(BlockScopeInfo *BSI, ValueDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S, bool Invalid)
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
static void diagnoseUncapturableValueReferenceOrBinding(Sema &S, SourceLocation loc, ValueDecl *var)
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 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 Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType, SourceLocation Loc)
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 checkEnumArithmeticConversions(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc, Sema::ArithConvKind ACK)
Check that the usual arithmetic conversions can be performed on this pair of expressions that might b...
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
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 std::pair< ExprResult, ExprResult > CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type.
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
static QualType handleComplexFloatConversion(Sema &S, ExprResult &Shorter, QualType ShorterType, QualType LongerType, bool PromotePrecision)
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static void DoMarkBindingDeclReferenced(Sema &SemaRef, SourceLocation Loc, BindingDecl *BD, Expr *E)
static PredefinedIdentKind getPredefinedExprKind(tok::TokenKind Kind)
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, QualType RHSTy)
handleFixedPointConversion - Fixed point operations between fixed point types and integers or other f...
static QualType handleComplexConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool canCaptureVariableByCopy(ValueDecl *Var, const ASTContext &Context)
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, Expr *E0, Expr *E1=nullptr)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
static bool isObjCObjectLiteral(ExprResult &E)
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, ValueDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
static bool isLegalBoolVectorBinaryOp(BinaryOperatorKind Opc)
static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E, NonOdrUseReason NOUR)
Walk the set of potential results of an expression and mark them all as non-odr-uses if they satisfy ...
static void CheckCompleteParameterTypesForMangler(Sema &S, FunctionDecl *FD, SourceLocation Loc)
Require that all of the parameter types of function be complete.
static bool isScopedEnumerationType(QualType T)
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for expressions involving.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Defines the clang::TypeLoc interface and its subclasses.
Defines enumerations for the type traits support.
C Language Family Type Representation.
@ Open
The standard open() call: int open(const char *path, int oflag, ...);.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D)
Invoked when a function is implicitly instantiated.
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...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
CanQualType ARCUnbridgedCastTy
unsigned getIntWidth(QualType T) const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
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.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
DeclarationNameTable DeclarationNames
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
QualType getRecordType(const RecordDecl *Decl) 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 getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
bool typesAreBlockPointerCompatible(QualType, QualType)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
CanQualType UnsignedLongTy
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length.
QualType getCorrespondingSaturatedType(QualType Ty) const
CanQualType BoundMemberTy
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
llvm::DenseSet< const VarDecl * > CUDADeviceVarODRUsedByHost
Keep track of CUDA/HIP device-side variables ODR-used by host code.
CanQualType PseudoObjectTy
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
llvm::FixedPointSemantics getFixedPointSemantics(QualType Ty) const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
llvm::DenseSet< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
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
CanQualType UnsignedIntTy
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
CanQualType UnsignedLongLongTy
QualType getCommonSugaredType(QualType X, QualType Y, bool Unqualified=false)
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.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
llvm::APFixedPoint getFixedPointMax(QualType Ty) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
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.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
CanQualType IncompleteMatrixIdxTy
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) 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 ...
QualType getCorrespondingSignedType(QualType T) const
unsigned getTargetAddressSpace(LangAS AS) const
QualType getWideCharType() const
Return the type of wide characters.
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
CanQualType getSignedSizeType() const
Return the unique signed counterpart of the integer type corresponding to size_t.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
unsigned char getFixedPointScale(QualType Ty) const
QualType adjustStringLiteralBaseType(QualType StrLTy) const
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
bool isDependenceAllowed() const
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
bool isSentinelNullExpr(const Expr *E)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
QualType getBitIntType(bool Unsigned, unsigned NumBits) const
Return a bit-precise integer type with the specified signedness and bit count.
AddrLabelExpr - The GNU address of label extension, representing &&label.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
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
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
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 OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool isComparisonOp(Opcode Opc)
bool isComparisonOp() const
StringRef getOpcodeStr() const
bool isRelationalOp() const
SourceLocation getOperatorLoc() const
bool isCompoundAssignmentOp() const
bool isMultiplicativeOp() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
bool isEqualityOp() const
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 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 isBitwiseOp(Opcode Opc)
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'.
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool isImmediate(unsigned ID) const
Returns true if this is an immediate (consteval) function.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
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...
Represents a call to a C++ constructor.
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.
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
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.
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.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
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.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
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.
Expr ** getArgs()
Retrieve the call arguments.
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
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...
const char * getCastKindName() const
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
unsigned getValue() const
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
void mergeFrom(CleanupInfo Rhs)
void setExprNeedsCleanups(bool SideEffects)
bool cleanupsHaveSideEffects() const
bool exprNeedsCleanups() const
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 }.
Stmt * getStmtExprResult()
ConditionalOperator - The ?: ternary operator.
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)
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
void setTypoName(const IdentifierInfo *II)
void setTypoNNS(NestedNameSpecifier *NNS)
Wrapper for source info for pointers decayed from arrays and functions.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isRequiresExprBody() const
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 ...
void addDecl(Decl *D)
Add the declaration D into this context.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
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 getLocation() const
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
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 isInvalidDecl() const
SourceLocation getLocation() const
void setReferenced(bool R=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
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
bool isIdentifier() const
Predicate functions for querying what type of name this is.
SourceLocation getBeginLoc() const LLVM_READONLY
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
DeclaratorContext getContext() const
SourceLocation getBeginLoc() const LLVM_READONLY
const IdentifierInfo * getIdentifier() const
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool getSuppressSystemWarnings() const
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Represents a reference to #emded data.
RAII object that enters a new expression evaluation context.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
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,...
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...
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, e.g.
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.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
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.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant 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_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)
FullExpr - Represents a "full-expression" node.
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.
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.
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, Expr *TrailingRequiresClause=nullptr)
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 or init-capture pack that has been substituted bu...
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.
bool getCmseNSCall() const
ExtInfo withNoReturn(bool noReturn) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn 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.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
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.
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
void setParameterCFAudited()
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
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.
@ 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 isSubscriptPointerArithmetic() const
bool isSignedOverflowDefined() const
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
static std::string Stringify(StringRef Str, bool Charify=false)
Stringify - Convert the specified string into a C string by i) escaping '\' and " characters and ii) ...
Represents the results of name lookup.
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
MS property subscript expression.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
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.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
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
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>::".
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
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
Interfaces are the core concept in Objective-C for object oriented design.
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.
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ArrayRef< ParmVarDecl * > parameters() const
QualType getReturnType() 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 a class type in Objective C.
Represents one property declaration in an Objective-C interface.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
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.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
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
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.
Represents a parameter to a function.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
QualType getOriginalType() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
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)
SourceLocation getLastFPEvalPragmaLocation() const
void CreateString(StringRef Str, Token &Tok, SourceLocation ExpansionLocStart=SourceLocation(), SourceLocation ExpansionLocEnd=SourceLocation())
Plop the specified string into a scratch buffer and set the specified token's location and length to ...
LangOptions::FPEvalMethodKind getCurrentFPEvalMethod() const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceManager & getSourceManager() const
bool isMacroDefined(StringRef Id)
const TargetInfo & getTargetInfo() const
char getSpellingOfSingleCharacterNumericConstant(const Token &Tok, bool *Invalid=nullptr) const
Given a Token Tok that is a numeric constant with length 1, return the character.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
IdentifierTable & getIdentifierTable()
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
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
QualType withConst() const
void addConst()
Add the const type qualifier to this QualType.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
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 isAddressSpaceOverlapping(QualType T) const
Returns true if address space qualifiers overlap with T address space qualifiers.
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.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
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).
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()
void removeAddressSpace()
void setAddressSpace(LangAS space)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
Qualifiers withoutObjCGCAttr() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
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.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
static RecoveryExpr * Create(ASTContext &Ctx, QualType T, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs)
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
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.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ DeclScope
This is a scope that can contain a declaration.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isUnarySelector() const
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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.
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
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...
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.
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
ExprResult ActOnOpenMPCall(ExprResult Call, Scope *Scope, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig)
Given the potential call expression Call, determine if there is a specialization via the OpenMP decla...
void tryCaptureOpenMPLambdas(ValueDecl *V)
Function tries to capture lambda's captured variables in the OpenMP region before the original lambda...
OpenMPClauseKind isOpenMPPrivateDecl(ValueDecl *D, unsigned Level, unsigned CapLevel) const
Check if the specified variable is used in 'private' clause.
VarDecl * isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo=false, unsigned StopAt=0)
Check if the specified variable is used in one of the private clauses (private, firstprivate,...
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, unsigned OpenMPCaptureLevel) const
Return true if the provided declaration VD should be captured by reference.
bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level, unsigned CaptureLevel) const
Check if the specified variable is captured by 'target' directive.
bool isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level, unsigned CaptureLevel) const
Check if the specified global variable must be captured by outer capture regions.
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
const ValueDecl * getOpenMPDeclareMapperVarName() const
ExprResult checkAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
ExprResult checkIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
ExprResult checkRValue(Expr *E)
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
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...
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.
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.
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opcode)
Check for comparisons of floating-point values using == and !=.
Scope * getCurScope() const
Retrieve the parser's current scope.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
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 ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
bool isAlwaysConstantEvaluatedContext() const
bool isExternalWithNoLinkageType(const ValueDecl *VD) const
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
bool isAttrContext() const
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &...Args)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ExprResult 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)
@ NTCUC_LValueToRValueVolatile
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.
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()
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6....
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
unsigned CapturingFunctionScopes
Track the number of currently active capturing scopes.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Preprocessor & getPreprocessor() const
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
QualType GetSignedSizelessVectorType(QualType V)
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
llvm::SmallPtrSet< ConstantExpr *, 4 > FailedImmediateInvocations
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
DefaultedComparisonKind getDefaultedComparisonKind(const FunctionDecl *FD)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
void MarkCaptureUsedInEnclosingContext(ValueDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
Expr * BuildBuiltinCallExpr(SourceLocation Loc, Builtin::ID Id, MultiExprArg CallArgs)
BuildBuiltinCallExpr - Create a call to a builtin function specified by Id.
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion, bool AllowBoolOperation, bool ReportInvalid)
type checking for vector binary operators.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
FPOptionsOverride CurFPFeatureOverrides()
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
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.
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt=std::nullopt)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
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.
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.
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6....
bool checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range)
ExprResult CheckUnevaluatedOperand(Expr *E)
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
Look for instances where it is likely the comma operator is confused with another operator.
ExprResult tryConvertExprToType(Expr *E, QualType Ty)
Try to convert an expression E to type Ty.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
std::vector< Token > ExpandFunctionLocalPredefinedMacros(ArrayRef< Token > Toks)
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
QualType 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.
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
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()
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
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".
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
@ None
This is not a defaultable comparison operator.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
QualType CheckMatrixMultiplyOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
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...
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
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>.
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)
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
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...
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
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.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
bool areMatrixTypesOfTheSameDimension(QualType srcTy, QualType destTy)
Are the two types matrix types and do they have the same dimensions i.e.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
bool hasCStrMethod(const Expr *E)
Check to see if a given expression could have '.c_str()' called on it.
const LangOptions & LangOpts
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand,...
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
@ OperatorInExpression
The '<=>' operator was used in an expression and a builtin operator was selected.
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
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
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
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
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)
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...
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
QualType CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, ArithConvKind OperationKind)
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.
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.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
bool isInLifetimeExtendingContext() const
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.
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.
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...
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.
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.
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointerDiscardsQualifiers
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
@ IntToPointer
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension.
@ IncompatibleBlockPointer
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
@ IncompatibleObjCQualifiedId
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
@ IncompatibleVectors
IncompatibleVectors - The assignment is between two vector types that have the same size,...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ IncompatibleObjCWeakRef
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier.
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatibleFunctionPointerStrict
IncompatibleFunctionPointerStrict - The assignment is between two function pointer types that are not...
@ Incompatible
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST.
@ FunctionVoidPointer
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
@ 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 ...
@ IncompatibleNestedPointerQualifiers
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types,...
@ IncompatibleNestedPointerAddressSpaceMismatch
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
@ PointerToInt
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension.
@ IntToBlockPointer
IntToBlockPointer - The assignment converts an int to a block pointer.
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
@ ACK_Arithmetic
An arithmetic operation.
@ ACK_CompAssign
A compound assignment expression.
@ ACK_BitwiseOp
A bitwise operation.
@ ACK_Conditional
A conditional (?:) operator.
@ ACK_Comparison
A comparison.
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
llvm::PointerIntPair< ConstantExpr *, 1 > ImmediateInvocationCandidate
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ExprResult TransformToPotentiallyEvaluated(Expr *E)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
@ TryCapture_ExplicitByRef
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 ?: operation.
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
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...
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
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.
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=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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 keepInLifetimeExtendingContext()
keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext flag from previous context.
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 ?: under C++ semantics.
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 InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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....
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)
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 mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
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)
ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc, StringLiteral *BinaryData)
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)
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 DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr)
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)
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.
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? That is, given that one of them is a vector,...
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
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)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
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 BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
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
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
@ 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.
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...
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
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.
const TypoExprState & getTypoExprState(TypoExpr *TE) const
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
SemaPseudoObject & PseudoObject()
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
FullExprArg MakeFullExpr(Expr *Arg)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
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)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
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...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
void DiagnoseImmediateEscalatingReason(FunctionDecl *FD)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
void setToType(unsigned Idx, QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
StringLiteral - This represents a string literal expression, e.g.
unsigned getLength() const
uint32_t getCodeUnit(size_t i) const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
StringRef getString() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
virtual size_t getMaxBitIntWidth() const
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
IntType getSizeType() const
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isTLSSupported() const
Whether the target supports thread-local storage.
virtual bool supportsExtendIntArgs() const
Whether the option -fextend-arguments={32,64} is supported on the target.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
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.
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.
Token - This structure provides full information about a lexed token.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
unsigned getLength() const
void setKind(tok::TokenKind K)
tok::TokenKind getKind() const
void setLocation(SourceLocation L)
void startToken()
Reset all flags to cleared.
void setIdentifierInfo(IdentifierInfo *II)
Represents a declaration of a type.
const Type * getTypeForDecl() const
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.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isFixedPointOrIntegerType() const
Return true if this is a fixed point or integer type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isFunctionReferenceType() const
bool isObjCBuiltinType() 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.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
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.
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
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 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 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 isMemberFunctionPointerType() const
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.
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...
bool isAnyPointerType() const
TypeClass getTypeClass() const
bool isSubscriptableVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isSizelessVectorType() const
Returns true for all scalable vector types.
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.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isOverloaded() const
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
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 UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
bool isIncrementDecrementOp() const
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
Represents a C++ unqualified-id that has been parsed.
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)
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)
VarDecl * getPotentiallyDecomposedVarDecl()
Represents a variable declaration or definition.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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,...
Declaration of a variable template.
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
Policy getDefaultPolicy()
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.
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)
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.
void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for initializing the ent...
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
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)
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 on 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 of a matrix.
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
llvm::omp::Clause OpenMPClauseKind
OpenMP clauses.
std::optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
unsigned toTargetAddressSpace(LangAS AS)
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
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 ...
ActionResult< Expr * > ExprResult
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
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.
bool isPtrSizeAddressSpace(LangAS AS)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
const FunctionProtoType * T
@ 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.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
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
@ None
No keyword precedes the qualified type name.
@ Other
Other implicit parameter.
@ Implicit
An implicit conversion.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
@ NOUR_Discarded
This name appears as a potential result of a discarded value expression.
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
@ NOUR_None
This is an odr-use.
@ NOUR_Constant
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
Represents an element in a path from a derived class to a base class.
The class facilities generation and storage of conversion FixIts.
OverloadFixItKind Kind
The type of fix applied.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
Stores data related to a single #embed directive.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool HasUndefinedBehavior
Whether the evaluation hit undefined behavior.
bool HasSideEffects
Whether the evaluated expression has side effects.
Extra information about a function prototype.
unsigned HasTrailingReturn
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,...
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.
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
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.
Describes an entity that is being assigned.