48 #include "llvm/Support/ConvertUTF.h" 49 using namespace clang;
56 if (ParsingInitForAutoVars.count(D))
66 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
72 if (TreatUnavailableAsInvalid &&
73 isUnavailableAlignedAllocationFunction(*FD))
87 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
90 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
91 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
93 if (DC && !DC->
hasAttr<UnusedAttr>())
110 DiagnoseDeletedDefaultedFunction(Decl);
115 if (Ctor && Ctor->isInheritingConstructor())
116 return NoteDeletedInheritingConstructor(Ctor);
126 if (I->getStorageClass() !=
SC_None)
171 if (!DowngradeWarning && UsedFn)
174 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
175 : diag::ext_internal_in_extern_inline)
180 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
190 Diag(DeclBegin, diag::note_convert_inline_to_static)
209 bool ObjCPropertyAccess,
210 bool AvoidPartialAvailabilityChecks,
213 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
217 if (Pos != SuppressedDiagnostics.end()) {
219 Diag(Suppressed.first, Suppressed.second);
230 if (cast<FunctionDecl>(D)->isMain())
231 Diag(Loc, diag::ext_main_used);
233 diagnoseUnavailableAlignedAllocation(*cast<FunctionDecl>(D), Loc);
237 if (ParsingInitForAutoVars.count(D)) {
238 if (isa<BindingDecl>(D)) {
239 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
242 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
243 << D->
getDeclName() << cast<VarDecl>(D)->getType();
250 if (FD->isDeleted()) {
252 if (Ctor && Ctor->isInheritingConstructor())
253 Diag(Loc, diag::err_deleted_inherited_ctor_use)
255 << Ctor->getInheritedConstructor().getConstructor()->getParent();
257 Diag(Loc, diag::err_deleted_function_use);
258 NoteDeletedFunction(FD);
270 if (FD->getTrailingRequiresClause()) {
272 if (CheckFunctionConstraints(FD, Satisfaction, Loc))
278 diag::err_reference_to_function_with_unsatisfied_constraints)
280 DiagnoseUnsatisfiedConstraint(Satisfaction);
287 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
288 DeduceReturnType(FD, Loc))
291 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
295 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
297 if (MD->getParent()->isLambda() &&
298 ((isa<CXXConstructorDecl>(MD) &&
299 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
300 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
301 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
302 << !isa<CXXConstructorDecl>(MD);
306 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
308 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
313 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
315 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
324 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
326 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
327 << getCurFunction()->HasOMPDeclareReductionCombiner;
337 if (LangOpts.OpenMP && DMD && !CurContext->containsDecl(D) &&
339 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
340 << DMD->getVarName().getAsString();
345 DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
346 AvoidPartialAvailabilityChecks, ClassReceiver);
352 if (isa<ParmVarDecl>(D) && isa<RequiresExprBodyDecl>(D->
getDeclContext()) &&
353 !isUnevaluatedContext()) {
357 Diag(Loc, diag::err_requires_expr_parameter_referenced_in_evaluated_context)
372 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
377 unsigned numFormalParams;
381 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
384 numFormalParams = MD->param_size();
385 calleeType = CT_Method;
386 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
387 numFormalParams = FD->param_size();
388 calleeType = CT_Function;
389 }
else if (isa<VarDecl>(D)) {
395 calleeType = CT_Function;
398 calleeType = CT_Block;
404 numFormalParams = proto->getNumParams();
416 unsigned nullPos = attr->getNullPos();
417 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
418 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
421 unsigned numArgsAfterSentinel = attr->getSentinel();
425 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
432 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
433 if (!sentinelExpr)
return;
442 std::string NullValue;
443 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
445 else if (getLangOpts().CPlusPlus11)
446 NullValue =
"nullptr";
447 else if (PP.isMacroDefined(
"NULL"))
450 NullValue =
"(void*) 0";
453 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
455 Diag(MissingNilLoc, diag::warn_missing_sentinel)
479 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
483 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
488 CK_FunctionToPointerDecay).
get();
501 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
503 CK_ArrayToPointerDecay).
get();
515 if (UO && UO->getOpcode() == UO_Deref &&
516 UO->getSubExpr()->getType()->isPointerType()) {
521 UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
523 !UO->getType().isVolatileQualified()) {
525 S.
PDiag(diag::warn_indirection_through_null)
526 << UO->getSubExpr()->getSourceRange());
528 S.
PDiag(diag::note_indirection_through_null));
542 if (!Member || !Member->
isStr(
"isa"))
552 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
560 if (ObjectSetClass) {
604 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
608 if (getLangOpts().CPlusPlus &&
623 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
632 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
639 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
664 ExprResult Res = CheckLValueToRValueConversionOperand(E);
672 Cleanup.setExprNeedsCleanups(
true);
683 T = Atomic->getValueType().getUnqualifiedType();
692 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
695 Res = DefaultLvalueConversion(Res.
get());
710 CK_FunctionToPointerDecay).
get();
714 Res = DefaultLvalueConversion(Res.
get());
727 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
733 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
736 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
737 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
758 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
763 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
776 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
788 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
789 BTy->
getKind() == BuiltinType::Float)) {
790 if (getLangOpts().OpenCL &&
791 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
792 if (BTy->
getKind() == BuiltinType::Half) {
793 E = ImpCastExprToType(E, Context.
FloatTy, CK_FloatingCast).get();
796 E = ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast).get();
857 if (!Record->hasNonTrivialCopyConstructor() &&
858 !Record->hasNonTrivialMoveConstructor() &&
859 !Record->hasNonTrivialDestructor())
860 return VAK_ValidInCXX11;
868 if (getLangOpts().MSVCCompat)
869 return VAK_MSVCUndefined;
873 return VAK_Undefined;
883 case VAK_ValidInCXX11:
886 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
893 PDiag(diag::warn_pass_class_arg_to_vararg)
894 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
899 case VAK_MSVCUndefined:
901 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
902 << getLangOpts().CPlusPlus11 << Ty << CT);
908 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
912 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
916 << isa<InitListExpr>(E) << Ty << CT;
927 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
928 (CT == VariadicMethod ||
929 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
930 E = stripARCUnbridgedCast(E);
941 ExprResult ExprRes = DefaultArgumentPromotion(E);
948 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
955 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc, Name,
975 diag::err_call_incomplete_argument))
992 if (SkipCast)
return false;
994 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
997 CK_FloatingRealToComplex);
1001 CK_IntegralComplexToFloatingComplex);
1011 bool IsCompAssign) {
1034 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
1035 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
1037 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
1039 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1045 if (!IsCompAssign) {
1052 }
else if (Order > 0) {
1067 bool ConvertFloat,
bool ConvertInt) {
1072 CK_IntegralToFloating);
1083 CK_IntegralComplexToFloatingComplex);
1088 CK_FloatingRealToComplex);
1097 QualType RHSType,
bool IsCompAssign) {
1103 if (LHSFloat && RHSFloat) {
1110 assert(order < 0 &&
"illegal float comparison");
1144 "The remaining types must be floating point types.");
1149 QualType LHSElemType = LHSComplex ?
1150 LHSComplex->getElementType() : LHSType;
1151 QualType RHSElemType = RHSComplex ?
1167 return Float128AndLongDouble &&
1169 &llvm::APFloat::PPCDoubleDouble());
1183 CK_IntegralComplexCast);
1189 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1192 QualType RHSType,
bool IsCompAssign) {
1197 if (LHSSigned == RHSSigned) {
1200 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1202 }
else if (!IsCompAssign)
1203 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1205 }
else if (order != (LHSSigned ? 1 : -1)) {
1209 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1211 }
else if (!IsCompAssign)
1212 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1219 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1221 }
else if (!IsCompAssign)
1222 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1231 RHS = (*doRHSCast)(S, RHS.
get(), result);
1233 LHS = (*doLHSCast)(S, LHS.
get(), result);
1243 bool IsCompAssign) {
1247 if (LHSComplexInt && RHSComplexInt) {
1251 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1252 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1254 return S.Context.getComplexType(ScalarType);
1257 if (LHSComplexInt) {
1260 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1261 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1263 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1264 CK_IntegralRealToComplex);
1269 assert(RHSComplexInt);
1273 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1274 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1278 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1279 CK_IntegralRealToComplex);
1288 assert(BTy &&
"Expected a builtin type.");
1290 switch (BTy->getKind()) {
1291 case BuiltinType::ShortFract:
1292 case BuiltinType::UShortFract:
1293 case BuiltinType::SatShortFract:
1294 case BuiltinType::SatUShortFract:
1296 case BuiltinType::Fract:
1297 case BuiltinType::UFract:
1298 case BuiltinType::SatFract:
1299 case BuiltinType::SatUFract:
1301 case BuiltinType::LongFract:
1302 case BuiltinType::ULongFract:
1303 case BuiltinType::SatLongFract:
1304 case BuiltinType::SatULongFract:
1306 case BuiltinType::ShortAccum:
1307 case BuiltinType::UShortAccum:
1308 case BuiltinType::SatShortAccum:
1309 case BuiltinType::SatUShortAccum:
1311 case BuiltinType::Accum:
1312 case BuiltinType::UAccum:
1313 case BuiltinType::SatAccum:
1314 case BuiltinType::SatUAccum:
1316 case BuiltinType::LongAccum:
1317 case BuiltinType::ULongAccum:
1318 case BuiltinType::SatLongAccum:
1319 case BuiltinType::SatULongAccum:
1322 if (BTy->isInteger())
1324 llvm_unreachable(
"Unexpected fixed point or integer type");
1336 "Expected at least one of the operands to be a fixed point type");
1339 "Special fixed point arithmetic operation conversions are only " 1340 "applied to ints or other fixed point types");
1362 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1384 REnum = R->isUnscopedEnumerationType();
1386 if ((!IsCompAssign && LEnum && R->isFloatingType()) ||
1389 ? diag::warn_arith_conv_enum_float_cxx2a
1390 : diag::warn_arith_conv_enum_float)
1392 << (int)ACK << LEnum << L << R;
1393 }
else if (!IsCompAssign && LEnum && REnum &&
1397 !R->castAs<
EnumType>()->getDecl()->hasNameForLinkage()) {
1402 ? diag::warn_arith_conv_mixed_anon_enum_types_cxx2a
1403 : diag::warn_arith_conv_mixed_anon_enum_types;
1408 ? diag::warn_conditional_mixed_enum_types_cxx2a
1409 : diag::warn_conditional_mixed_enum_types;
1414 ? diag::warn_comparison_mixed_enum_types_cxx2a
1415 : diag::warn_comparison_mixed_enum_types;
1418 ? diag::warn_arith_conv_mixed_enum_types_cxx2a
1419 : diag::warn_arith_conv_mixed_enum_types;
1422 << (int)ACK << L << R;
1435 if (ACK != ACK_CompAssign) {
1436 LHS = UsualUnaryConversions(LHS.
get());
1441 RHS = UsualUnaryConversions(RHS.
get());
1454 LHSType = AtomicLHS->getValueType();
1457 if (LHSType == RHSType)
1466 QualType LHSUnpromotedType = LHSType;
1470 if (!LHSBitfieldPromoteTy.
isNull())
1471 LHSType = LHSBitfieldPromoteTy;
1472 if (LHSType != LHSUnpromotedType && ACK != ACK_CompAssign)
1473 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1476 if (LHSType == RHSType)
1489 ACK == ACK_CompAssign);
1494 ACK == ACK_CompAssign);
1499 ACK == ACK_CompAssign);
1505 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1506 (*
this, LHS, RHS, LHSType, RHSType, ACK == ACK_CompAssign);
1518 Expr *ControllingExpr,
1521 unsigned NumAssocs = ArgTypes.size();
1522 assert(NumAssocs == ArgExprs.size());
1525 for (
unsigned i = 0; i < NumAssocs; ++i) {
1527 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1532 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1534 llvm::makeArrayRef(Types, NumAssocs),
1544 Expr *ControllingExpr,
1547 unsigned NumAssocs = Types.size();
1548 assert(NumAssocs == Exprs.size());
1555 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1558 ControllingExpr = R.
get();
1563 if (!inTemplateInstantiation() &&
1566 diag::warn_side_effects_unevaluated_context);
1568 bool TypeErrorFound =
false,
1570 ContainsUnexpandedParameterPack
1573 for (
unsigned i = 0; i < NumAssocs; ++i) {
1574 if (Exprs[i]->containsUnexpandedParameterPack())
1575 ContainsUnexpandedParameterPack =
true;
1578 if (Types[i]->getType()->containsUnexpandedParameterPack())
1579 ContainsUnexpandedParameterPack =
true;
1581 if (Types[i]->getType()->isDependentType()) {
1582 IsResultDependent =
true;
1587 if (Types[i]->getType()->isIncompleteType())
1588 D = diag::err_assoc_type_incomplete;
1589 else if (!Types[i]->getType()->isObjectType())
1590 D = diag::err_assoc_type_nonobject;
1591 else if (Types[i]->getType()->isVariablyModifiedType())
1592 D = diag::err_assoc_type_variably_modified;
1595 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1596 << Types[i]->getTypeLoc().getSourceRange()
1597 << Types[i]->getType();
1598 TypeErrorFound =
true;
1603 for (
unsigned j = i+1; j < NumAssocs; ++j)
1604 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1606 Types[j]->getType())) {
1607 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1608 diag::err_assoc_compatible_types)
1609 << Types[j]->getTypeLoc().getSourceRange()
1610 << Types[j]->getType()
1611 << Types[i]->getType();
1612 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1613 diag::note_compat_assoc)
1614 << Types[i]->getTypeLoc().getSourceRange()
1615 << Types[i]->getType();
1616 TypeErrorFound =
true;
1626 if (IsResultDependent)
1628 Exprs, DefaultLoc, RParenLoc,
1629 ContainsUnexpandedParameterPack);
1632 unsigned DefaultIndex = -1U;
1633 for (
unsigned i = 0; i < NumAssocs; ++i) {
1637 Types[i]->getType()))
1638 CompatIndices.push_back(i);
1644 if (CompatIndices.size() > 1) {
1648 Diag(ControllingExpr->
getBeginLoc(), diag::err_generic_sel_multi_match)
1650 << (unsigned)CompatIndices.size();
1651 for (
unsigned I : CompatIndices) {
1652 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1653 diag::note_compat_assoc)
1654 << Types[I]->getTypeLoc().getSourceRange()
1655 << Types[I]->getType();
1663 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1677 unsigned ResultIndex =
1678 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1681 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1682 ContainsUnexpandedParameterPack, ResultIndex);
1700 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1703 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1704 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1705 if (ArgTy[ArgIdx]->isArrayType())
1732 assert(!StringToks.empty() &&
"Must have at least one string!");
1735 if (Literal.hadError)
1739 for (
const Token &
Tok : StringToks)
1740 StringTokLocs.push_back(
Tok.getLocation());
1744 if (Literal.isWide()) {
1747 }
else if (Literal.isUTF8()) {
1748 if (getLangOpts().Char8)
1751 }
else if (Literal.isUTF16()) {
1754 }
else if (Literal.isUTF32()) {
1757 }
else if (Literal.isPascal()) {
1763 if (getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus2a &&
1765 Diag(StringTokLocs.front(), diag::warn_cxx2a_compat_utf8_string);
1771 auto RemovalDiag = PDiag(diag::note_cxx2a_compat_utf8_string_remove_u8);
1773 for (
const Token &
Tok : StringToks) {
1774 if (
Tok.getKind() == tok::utf8_string_literal) {
1776 RemovalDiagLoc =
Tok.getLocation();
1780 getSourceManager(), getLangOpts())));
1783 Diag(RemovalDiagLoc, RemovalDiag);
1791 Kind, Literal.Pascal, StrTy,
1793 StringTokLocs.size());
1794 if (Literal.getUDSuffix().empty())
1801 Literal.getUDSuffixOffset());
1805 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1820 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1821 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1830 Expr *Args[] = { Lit, LenArg };
1832 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1835 case LOLR_StringTemplate: {
1846 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1852 return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
1857 case LOLR_ErrorNoDiagnostic:
1858 llvm_unreachable(
"unexpected literal operator lookup result");
1862 llvm_unreachable(
"unexpected literal operator lookup result");
1870 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1881 return BuildDeclRefExpr(D, Ty, VK, NameInfo, NNS, FoundD, TemplateKWLoc,
1887 if (isUnevaluatedContext())
1894 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
1895 if (VD->getType()->isReferenceType() &&
1896 !(getLangOpts().OpenMP && isOpenMPCapturedDecl(D)) &&
1897 VD->isUsableInConstantExpressions(Context))
1914 bool RefersToCapturedVariable =
1916 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1919 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
1920 VK, FoundD, TemplateArgs, getNonOdrUseReasonInCurrentContext(D));
1921 MarkDeclRefReferenced(E);
1937 if (
auto *NewFPT = ResolveExceptionSpec(NameInfo.
getLoc(), FPT))
1942 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1944 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getBeginLoc()))
1945 getCurFunction()->recordUseOfWeak(E);
1949 FD = IFD->getAnonField();
1951 UnusedPrivateFields.remove(FD);
1959 if (
auto *BD = dyn_cast<BindingDecl>(D))
1960 if (
auto *BE = BD->getBinding())
1961 E->setObjectKind(BE->getObjectKind());
1986 translateTemplateArguments(TemplateArgsPtr, Buffer);
1991 TemplateArgs = &Buffer;
1993 NameInfo = GetNameFromUnqualifiedId(Id);
1994 TemplateArgs =
nullptr;
2001 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
2008 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
2011 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
2016 bool DroppedSpecifier =
2019 ? diag::note_implicit_param_decl
2020 : diag::note_previous_decl;
2023 SemaRef.
PDiag(NoteID));
2026 << Typo << Ctx << DroppedSpecifier
2028 SemaRef.
PDiag(NoteID));
2040 unsigned diagnostic = diag::err_undeclared_var_use;
2041 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
2045 diagnostic = diag::err_undeclared_use;
2046 diagnostic_suggest = diag::err_undeclared_use_suggest;
2055 if (isa<CXXRecordDecl>(DC)) {
2056 LookupQualifiedName(R, DC);
2065 bool isDefaultArgument =
2066 !CodeSynthesisContexts.empty() &&
2067 CodeSynthesisContexts.back().Kind ==
2068 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
2070 bool isInstance = CurMethod &&
2072 DC == CurMethod->
getParent() && !isDefaultArgument;
2077 if (getLangOpts().MSVCCompat)
2078 diagnostic = diag::ext_found_via_dependent_bases_lookup;
2089 Diag(D->getLocation(), diag::note_dependent_var_use);
2095 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
2096 Diag(R.getNameLoc(), diag::err_member_call_without_object);
2114 assert(!ExplicitTemplateArgs &&
2115 "Diagnosing an empty lookup with explicit template args!");
2116 *Out = CorrectTypoDelayed(
2120 diagnostic, diagnostic_suggest);
2122 nullptr, CTK_ErrorRecovery);
2127 S, &SS, CCC, CTK_ErrorRecovery))) {
2128 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
2129 bool DroppedSpecifier =
2133 bool AcceptableWithRecovery =
false;
2134 bool AcceptableWithoutRecovery =
false;
2143 dyn_cast<FunctionTemplateDecl>(CD))
2144 AddTemplateOverloadCandidate(
2147 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2148 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2152 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
2154 ND = Best->FoundDecl;
2155 Corrected.setCorrectionDecl(ND);
2159 Corrected.setCorrectionDecl(ND);
2171 Record = cast<CXXRecordDecl>(
2177 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
2178 isa<FunctionTemplateDecl>(UnderlyingND);
2184 AcceptableWithoutRecovery = isa<TypeDecl>(UnderlyingND) ||
2186 isa<ObjCInterfaceDecl>(UnderlyingND);
2190 AcceptableWithoutRecovery =
true;
2193 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2195 ? diag::note_implicit_param_decl
2196 : diag::note_previous_decl;
2198 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2199 PDiag(NoteID), AcceptableWithRecovery);
2201 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2202 << Name << computeDeclContext(SS,
false)
2203 << DroppedSpecifier << SS.getRange(),
2204 PDiag(NoteID), AcceptableWithRecovery);
2207 return !AcceptableWithRecovery;
2214 if (!SS.isEmpty()) {
2216 << Name << computeDeclContext(SS,
false)
2243 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2251 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2252 DB << NameInfo.
getName() << RD;
2254 if (!ThisType.
isNull()) {
2257 Context,
nullptr, ThisType,
true,
2259 nullptr, NameInfo, TemplateArgs);
2276 bool HasTrailingLParen,
bool IsAddressOfOperand,
2278 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2279 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2280 "cannot be direct & operand and have a trailing lparen");
2289 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2312 bool DependentID =
false;
2316 }
else if (SS.
isSet()) {
2317 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2318 if (RequireCompleteDeclContext(SS, DC))
2326 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2327 IsAddressOfOperand, TemplateArgs);
2332 ? LookupObjCImplicitSelfParam
2333 : LookupOrdinaryName);
2334 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2340 bool MemberOfUnknownSpecialization;
2342 if (LookupTemplateName(R, S, SS,
QualType(),
false,
2343 MemberOfUnknownSpecialization, TemplateKWLoc,
2347 if (MemberOfUnknownSpecialization ||
2349 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2350 IsAddressOfOperand, TemplateArgs);
2352 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2353 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2358 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2359 IsAddressOfOperand, TemplateArgs);
2363 if (IvarLookupFollowUp) {
2364 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2378 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2379 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2385 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2387 if (R.
empty() && !ADL) {
2388 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2390 TemplateKWLoc, TemplateArgs))
2395 if (IsInlineAsmIdentifier)
2405 "Typo correction callback misconfigured");
2415 if (DiagnoseEmptyLookup(S, SS, R, CCC ? *CCC : DefaultValidator,
nullptr,
2417 if (TE && KeywordReplacement) {
2418 auto &
State = getTypoExprState(TE);
2419 auto BestTC =
State.Consumer->getNextCorrection();
2420 if (BestTC.isKeyword()) {
2421 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2422 if (
State.DiagHandler)
2423 State.DiagHandler(BestTC);
2427 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2430 clearDelayedTypo(TE);
2433 return (
Expr*)
nullptr;
2435 State.Consumer->resetCorrectionStream();
2440 assert(!R.
empty() &&
2441 "DiagnoseEmptyLookup returned false but added no results");
2448 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2458 assert(!R.
empty() || ADL);
2484 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2485 bool MightBeImplicitMember;
2486 if (!IsAddressOfOperand)
2487 MightBeImplicitMember =
true;
2489 MightBeImplicitMember =
false;
2491 MightBeImplicitMember =
false;
2493 MightBeImplicitMember =
true;
2495 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2499 if (MightBeImplicitMember)
2500 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2501 R, TemplateArgs, S);
2504 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2512 "There should only be one declaration found.");
2515 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2518 return BuildDeclarationNameExpr(SS, R, ADL);
2533 if (RequireCompleteDeclContext(SS, DC))
2537 LookupQualifiedName(R, DC);
2556 unsigned DiagID = diag::err_typename_missing;
2557 if (RecoveryTSI && getLangOpts().MSVCCompat)
2558 DiagID = diag::ext_typename_missing;
2560 auto D =
Diag(Loc, DiagID);
2591 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2592 return BuildPossibleImplicitMemberExpr(SS,
2596 return BuildDeclarationNameExpr(SS, R,
false);
2627 LookForIvars =
true;
2628 else if (IsClassMethod)
2629 LookForIvars =
false;
2640 if (IsClassMethod) {
2648 !getLangOpts().DebuggerSupport)
2661 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2669 Diag(Loc, diag::err_ivar_use_in_class_method) << IV->getDeclName();
2682 "should not reference ivar from this context");
2685 assert(IFace &&
"should not reference ivar from this context");
2693 if (DiagnoseUseOfDecl(IV, Loc))
2705 ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc, SelfName,
2711 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2715 MarkAnyDeclReferenced(Loc, IV,
true);
2719 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2727 if (!isUnevaluatedContext() &&
2728 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2729 getCurFunction()->recordUseOfWeak(Result);
2731 if (getLangOpts().ObjCAutoRefCount)
2733 ImplicitlyRetainedSelfLocs.push_back({Loc, BD});
2746 DeclResult Ivar = LookupIvarInObjCMethod(Lookup, S, II);
2750 return BuildIvarRefExpr(S, Lookup.
getNameLoc(),
2751 cast<ObjCIvarDecl>(Ivar.
get()));
2753 if (Lookup.
empty() && II && AllowBuiltinCreation)
2754 LookupBuiltin(Lookup);
2790 bool PointerConversions =
false;
2791 if (isa<FieldDecl>(Member)) {
2795 DestRecordType, FromPtrType
2802 PointerConversions =
true;
2804 DestType = DestRecordType;
2805 FromRecordType = FromType;
2807 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2808 if (Method->isStatic())
2811 DestType = Method->getThisType();
2816 PointerConversions =
true;
2818 FromRecordType = FromType;
2819 DestType = DestRecordType;
2824 if (FromAS != DestAS) {
2829 if (PointerConversions)
2831 From = ImpCastExprToType(From, FromTypeWithDestAS,
2870 if (Qualifier && Qualifier->
getAsType()) {
2872 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2879 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2881 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2882 FromLoc, FromRange, &BasePath))
2885 if (PointerConversions)
2887 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2888 VK, &BasePath).get();
2891 FromRecordType = QRecordType;
2900 bool IgnoreAccess =
false;
2908 assert(isa<UsingShadowDecl>(FoundDecl));
2915 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2917 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2918 FromLoc, FromRange, &BasePath))
2922 if (PointerConversions)
2924 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2925 VK, &BasePath).get();
2927 FromRecordType = URecordType;
2932 IgnoreAccess =
true;
2936 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2937 FromLoc, FromRange, &BasePath,
2941 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2947 bool HasTrailingLParen) {
2949 if (!HasTrailingLParen)
2957 if (!getLangOpts().CPlusPlus)
2967 if (D->isCXXClassMember())
2976 if (isa<UsingShadowDecl>(D))
2977 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2978 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2985 if (isa<FunctionDecl>(D)) {
2991 }
else if (!isa<FunctionTemplateDecl>(D))
3007 if (isa<TypedefNameDecl>(D)) {
3012 if (isa<ObjCInterfaceDecl>(D)) {
3017 if (isa<NamespaceDecl>(D)) {
3031 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
3036 bool AcceptInvalidDecl) {
3076 bool AcceptInvalidDecl) {
3077 assert(D &&
"Cannot refer to a NULL declaration");
3078 assert(!isa<FunctionTemplateDecl>(D) &&
3079 "Cannot refer unambiguously to a function template");
3085 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
3088 diagnoseMissingTemplateArguments(
TemplateName(Template), Loc);
3095 Diag(Loc, diag::err_ref_non_value)
3105 if (DiagnoseUseOfDecl(VD, Loc))
3116 if (!indirectField->isCXXClassMember())
3117 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
3128 #define ABSTRACT_DECL(kind) 3129 #define VALUE(type, base) 3130 #define DECL(type, base) \ 3132 #include "clang/AST/DeclNodes.inc" 3133 llvm_unreachable(
"invalid value decl kind");
3136 case Decl::ObjCAtDefsField:
3137 llvm_unreachable(
"forming non-member reference to ivar?");
3141 case Decl::EnumConstant:
3142 case Decl::UnresolvedUsingValue:
3143 case Decl::OMPDeclareReduction:
3144 case Decl::OMPDeclareMapper:
3153 case Decl::IndirectField:
3154 case Decl::ObjCIvar:
3156 "building reference to field in C?");
3166 case Decl::NonTypeTemplateParm: {
3181 case Decl::VarTemplateSpecialization:
3182 case Decl::VarTemplatePartialSpecialization:
3183 case Decl::Decomposition:
3184 case Decl::OMPCapturedExpr:
3194 case Decl::ImplicitParam:
3195 case Decl::ParmVar: {
3203 if (!isUnevaluatedContext()) {
3204 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
3205 if (!CapturedType.
isNull())
3206 type = CapturedType;
3212 case Decl::Binding: {
3218 auto *BD = cast<BindingDecl>(VD);
3219 if (BD->getDeclContext() != CurContext) {
3220 auto *DD = dyn_cast_or_null<VarDecl>(BD->getDecomposedDecl());
3221 if (DD && DD->hasLocalStorage())
3228 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3247 if (getLangOpts().CPlusPlus) {
3257 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
3258 isa<FunctionProtoType>(fty))
3267 case Decl::CXXDeductionGuide:
3268 llvm_unreachable(
"building reference to deduction guide");
3270 case Decl::MSProperty:
3274 case Decl::CXXMethod:
3279 = dyn_cast<FunctionProtoType>(VD->
getType()))
3287 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3293 case Decl::CXXConversion:
3294 case Decl::CXXDestructor:
3295 case Decl::CXXConstructor:
3300 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3308 Target.resize(CharByteWidth * (Source.size() + 1));
3309 char *ResultPtr = &Target[0];
3310 const llvm::UTF8 *ErrorPtr;
3312 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3315 Target.resize(ResultPtr - &Target[0]);
3321 Decl *currentDecl =
nullptr;
3323 currentDecl = BSI->TheDecl;
3325 currentDecl = LSI->CallOperator;
3327 currentDecl = CSI->TheCapturedDecl;
3329 currentDecl = getCurFunctionOrMethodDecl();
3332 Diag(Loc, diag::ext_predef_outside_function);
3338 if (cast<DeclContext>(currentDecl)->isDependentContext())
3344 unsigned Length = Str.length();
3375 default: llvm_unreachable(
"Unknown simple primary expr!");
3385 return BuildPredefinedExpr(Loc, IK);
3390 bool Invalid =
false;
3391 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3397 if (Literal.hadError())
3401 if (Literal.isWide())
3403 else if (Literal.isUTF8() && getLangOpts().Char8)
3405 else if (Literal.isUTF16())
3407 else if (Literal.isUTF32())
3409 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3415 if (Literal.isWide())
3417 else if (Literal.isUTF16())
3419 else if (Literal.isUTF32())
3421 else if (Literal.isUTF8())
3427 if (Literal.getUDSuffix().empty())
3437 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3448 Context.
IntTy, Loc);
3455 using llvm::APFloat;
3456 APFloat Val(Format);
3462 if ((result & APFloat::opOverflow) ||
3463 ((result & APFloat::opUnderflow) && Val.isZero())) {
3464 unsigned diagnostic;
3466 if (result & APFloat::opOverflow) {
3467 diagnostic = diag::warn_float_overflow;
3468 APFloat::getLargest(Format).toString(buffer);
3470 diagnostic = diag::warn_float_underflow;
3471 APFloat::getSmallest(Format).toString(buffer);
3474 S.
Diag(Loc, diagnostic)
3476 << StringRef(buffer.data(), buffer.size());
3479 bool isExact = (result == APFloat::opOK);
3484 assert(E &&
"Invalid expression");
3491 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3496 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3501 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3502 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3503 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3504 << ValueAPS.toString(10) << ValueIsPositive;
3515 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3516 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3524 SpellingBuffer.resize(Tok.
getLength() + 1);
3527 bool Invalid =
false;
3528 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3533 if (Literal.hadError)
3536 if (Literal.hasUDSuffix()) {
3544 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3547 if (Literal.isFloatingLiteral()) {
3568 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3569 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3572 !Literal.isImaginary)) {
3573 case LOLR_ErrorNoDiagnostic:
3581 if (Literal.isFloatingLiteral()) {
3585 if (Literal.GetIntegerValue(ResultVal))
3591 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3598 unsigned Length = Literal.getUDSuffixOffset();
3604 false, StrTy, &TokLoc, 1);
3605 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3608 case LOLR_Template: {
3615 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3617 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3618 Value = TokSpelling[I];
3623 return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
3626 case LOLR_StringTemplate:
3627 llvm_unreachable(
"unexpected literal operator lookup result");
3633 if (Literal.isFixedPointLiteral()) {
3636 if (Literal.isAccum) {
3637 if (Literal.isHalf) {
3639 }
else if (Literal.isLong) {
3644 }
else if (Literal.isFract) {
3645 if (Literal.isHalf) {
3647 }
else if (Literal.isLong) {
3656 bool isSigned = !Literal.isUnsigned;
3661 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3662 bool ValIsZero = Val.isNullValue() && !Overflowed;
3665 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3671 else if (Val.ugt(MaxVal) || Overflowed)
3676 }
else if (Literal.isFloatingLiteral()) {
3678 if (Literal.isHalf){
3679 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3685 }
else if (Literal.isFloat)
3687 else if (Literal.isLong)
3689 else if (Literal.isFloat16)
3691 else if (Literal.isFloat128)
3699 if (getLangOpts().SinglePrecisionConstants) {
3701 if (BTy->
getKind() != BuiltinType::Float) {
3702 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3704 }
else if (getLangOpts().
OpenCL &&
3705 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3708 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3711 }
else if (!Literal.isIntegerLiteral()) {
3717 if (!getLangOpts().
C99 && Literal.isLongLong) {
3720 getLangOpts().CPlusPlus11 ?
3721 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3723 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
3730 if (Literal.GetIntegerValue(ResultVal)) {
3732 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3735 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
3736 "long long is not intmax_t?");
3743 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3749 if (Literal.MicrosoftInteger) {
3750 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3754 Width = Literal.MicrosoftInteger;
3756 !Literal.isUnsigned);
3760 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3765 if (ResultVal.isIntN(IntSize)) {
3767 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3769 else if (AllowUnsigned)
3776 if (Ty.
isNull() && !Literal.isLongLong) {
3780 if (ResultVal.isIntN(LongSize)) {
3782 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3784 else if (AllowUnsigned)
3788 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3789 const unsigned LongLongSize =
3792 getLangOpts().CPlusPlus
3794 ? diag::warn_old_implicitly_unsigned_long_cxx
3796 ext_old_implicitly_unsigned_long_cxx
3797 : diag::warn_old_implicitly_unsigned_long)
3798 << (LongLongSize > LongSize ? 0
3811 if (ResultVal.isIntN(LongLongSize)) {
3815 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3816 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3818 else if (AllowUnsigned)
3820 Width = LongLongSize;
3827 Diag(
Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3832 if (ResultVal.getBitWidth() != Width)
3833 ResultVal = ResultVal.trunc(Width);
3839 if (Literal.isImaginary) {
3843 Diag(
Tok.getLocation(), diag::ext_imaginary_constant);
3849 assert(E &&
"ActOnParenExpr() missing expr");
3850 return new (Context)
ParenExpr(L, R, E);
3861 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3867 "Scalar types should always be complete");
3884 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3885 << TraitKind << ArgRange;
3892 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3893 : diag::ext_sizeof_alignof_void_type;
3894 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3908 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3927 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3947 bool IsUnevaluatedOperand =
3950 if (IsUnevaluatedOperand) {
3951 ExprResult Result = CheckUnevaluatedOperand(E);
3973 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3977 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3994 if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
3996 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
4004 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
4005 QualType OType = PVD->getOriginalType();
4010 Diag(PVD->getLocation(), diag::note_declared_at);
4075 if (RequireCompleteType(OpLoc, ExprType,
4076 diag::err_sizeof_alignof_incomplete_type,
4077 ExprKind, ExprRange))
4081 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
4082 << ExprKind << ExprRange;
4099 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
4106 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Inner)) {
4108 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(Inner)) {
4109 D = ME->getMemberDecl();
4129 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
4132 if (!FD->getParent()->isCompleteDefinition()) {
4133 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
4142 if (!FD->getType()->isReferenceType())
4156 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
4162 assert(CSI !=
nullptr);
4168 #define TYPE(Class, Base) 4169 #define ABSTRACT_TYPE(Class, Base) 4170 #define NON_CANONICAL_TYPE(Class, Base) 4171 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 4172 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) 4173 #include "clang/AST/TypeNodes.inc" 4180 case Type::ExtVector:
4183 case Type::Elaborated:
4184 case Type::TemplateSpecialization:
4185 case Type::ObjCObject:
4186 case Type::ObjCInterface:
4187 case Type::ObjCObjectPointer:
4188 case Type::ObjCTypeParam:
4190 llvm_unreachable(
"type class is never variably-modified!");
4191 case Type::Adjusted:
4192 T = cast<AdjustedType>(Ty)->getOriginalType();
4195 T = cast<DecayedType>(Ty)->getPointeeType();
4198 T = cast<PointerType>(Ty)->getPointeeType();
4200 case Type::BlockPointer:
4201 T = cast<BlockPointerType>(Ty)->getPointeeType();
4203 case Type::LValueReference:
4204 case Type::RValueReference:
4205 T = cast<ReferenceType>(Ty)->getPointeeType();
4207 case Type::MemberPointer:
4208 T = cast<MemberPointerType>(Ty)->getPointeeType();
4210 case Type::ConstantArray:
4211 case Type::IncompleteArray:
4213 T = cast<ArrayType>(Ty)->getElementType();
4215 case Type::VariableArray: {
4223 (isa<CapturedRegionScopeInfo>(CSI) || isa<LambdaScopeInfo>(CSI)))
4229 case Type::FunctionProto:
4230 case Type::FunctionNoProto:
4231 T = cast<FunctionType>(Ty)->getReturnType();
4235 case Type::UnaryTransform:
4236 case Type::Attributed:
4237 case Type::SubstTemplateTypeParm:
4238 case Type::PackExpansion:
4239 case Type::MacroQualified:
4244 T = cast<TypedefType>(Ty)->desugar();
4246 case Type::Decltype:
4247 T = cast<DecltypeType>(Ty)->desugar();
4250 case Type::DeducedTemplateSpecialization:
4251 T = cast<DeducedType>(Ty)->getDeducedType();
4253 case Type::TypeOfExpr:
4254 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4257 T = cast<AtomicType>(Ty)->getValueType();
4275 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
4280 for (
auto I = FunctionScopes.rbegin(),
4281 E = std::prev(FunctionScopes.rend());
4287 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4288 DC = LSI->CallOperator;
4289 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4290 DC = CRSI->TheCapturedDecl;
4291 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4325 isInvalid = CheckVecStepExpr(E);
4330 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4333 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
4340 PE = TransformToPotentiallyEvaluated(E);
4363 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4367 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4373 if (V.
get()->isTypeDependent())
4385 return CT->getElementType();
4388 if (V.
get()->getType()->isArithmeticType())
4389 return V.
get()->getType();
4394 if (PR.
get() != V.
get()) {
4400 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4401 << (IsReal ?
"__real" :
"__imag");
4412 default: llvm_unreachable(
"Unknown unary op!");
4413 case tok::plusplus: Opc = UO_PostInc;
break;
4414 case tok::minusminus: Opc = UO_PostDec;
break;
4418 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4420 Input = Result.
get();
4422 return BuildUnaryOp(S, OpLoc, Opc, Input);
4433 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4436 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4444 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4446 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4454 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4458 if (isa<ParenListExpr>(base)) {
4459 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4461 base = result.
get();
4466 ((isa<BinaryOperator>(idx) && cast<BinaryOperator>(idx)->isCommaOp()) ||
4467 (isa<CXXOperatorCallExpr>(idx) &&
4468 cast<CXXOperatorCallExpr>(idx)->getOperator() == OO_Comma))) {
4478 bool IsMSPropertySubscript =
false;
4481 if (!IsMSPropertySubscript) {
4482 ExprResult result = CheckPlaceholderExpr(base);
4485 base = result.
get();
4489 ExprResult result = CheckPlaceholderExpr(idx);
4509 if (IsMSPropertySubscript) {
4524 if (getLangOpts().CPlusPlus &&
4528 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4531 ExprResult Res = CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4533 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
4534 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
4539 void Sema::CheckAddressOfNoDeref(
const Expr *E) {
4546 while ((Member = dyn_cast<MemberExpr>(StrippedExpr)) && !Member->
isArrow())
4557 if (isa<ArrayType>(ResultTy))
4560 if (ResultTy->
hasAttr(attr::NoDeref)) {
4569 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
4578 if (
const auto *Ptr = dyn_cast<PointerType>(Base->
getType())) {
4579 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
4590 BuiltinType::OMPArraySection)) {
4591 ExprResult Result = CheckPlaceholderExpr(Base);
4594 Base = Result.
get();
4597 ExprResult Result = CheckPlaceholderExpr(LowerBound);
4600 Result = DefaultLvalueConversion(Result.
get());
4603 LowerBound = Result.
get();
4606 ExprResult Result = CheckPlaceholderExpr(Length);
4609 Result = DefaultLvalueConversion(Result.
get());
4612 Length = Result.
get();
4620 return new (Context)
4639 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4641 if (Res.isInvalid())
4643 diag::err_omp_typecheck_section_not_integer)
4645 LowerBound = Res.get();
4654 PerformOpenMPImplicitIntegerConversion(Length->
getExprLoc(), Length);
4655 if (Res.isInvalid())
4657 diag::err_omp_typecheck_section_not_integer)
4677 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4678 diag::err_omp_section_incomplete_type, Base))
4687 if (LowerBoundValue.isNegative()) {
4688 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4701 if (LengthValue.isNegative()) {
4702 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4703 << LengthValue.toString(10,
true)
4708 }
else if (ColonLoc.
isValid() &&
4714 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4720 BuiltinType::OMPArraySection)) {
4721 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
4724 Base = Result.
get();
4726 return new (Context)
4734 Expr *LHSExp = Base;
4743 for (
auto *Op : {LHSExp, RHSExp}) {
4744 Op = Op->IgnoreImplicit();
4745 if (Op->getType()->isArrayType() && !Op->isLValue())
4752 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
4755 LHSExp = Result.
get();
4757 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
4760 RHSExp = Result.
get();
4768 Expr *BaseExpr, *IndexExpr;
4785 if (!LangOpts.isSubscriptPointerArithmetic())
4786 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4801 if (!LangOpts.isSubscriptPointerArithmetic()) {
4802 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4811 ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
4814 LHSExp = Materialized.
get();
4820 ResultType = VTy->getElementType();
4824 Qualifiers Combined = BaseQuals + MemberQuals;
4825 if (Combined != MemberQuals)
4836 CK_ArrayToPointerDecay).
get();
4842 }
else if (RHSTy->isArrayType()) {
4847 CK_ArrayToPointerDecay).
get();
4854 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4859 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4877 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4879 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4886 RequireCompleteType(LLoc, ResultType,
4887 diag::err_subscript_incomplete_type, BaseExpr))
4890 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4894 FunctionScopes.size() > 1) {
4897 for (
auto I = FunctionScopes.rbegin(),
4898 E = std::prev(FunctionScopes.rend());
4904 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4905 DC = LSI->CallOperator;
4906 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4907 DC = CRSI->TheCapturedDecl;
4908 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4920 return new (Context)
4928 diag::err_use_of_default_argument_to_function_declared_later) <<
4930 Diag(UnparsedDefaultArgLocs[Param],
4931 diag::note_default_argument_declared_here);
4939 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4959 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4963 if (Inst.isInvalid())
4965 if (Inst.isAlreadyInstantiating()) {
4966 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4980 Result = SubstInitializer(UninstExpr, MutiLevelArgList,
4996 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
5009 L->DefaultArgumentInstantiated(Param);
5015 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
5027 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
5030 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
5035 assert(!Init->getNumObjects() &&
5036 "default argument expression has capturing blocks?");
5043 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
5051 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
5060 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
5061 return VariadicConstructor;
5063 return VariadicBlock;
5065 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5066 if (Method->isInstance())
5067 return VariadicMethod;
5069 return VariadicMethod;
5070 return VariadicFunction;
5072 return VariadicDoesNotApply;
5081 FunctionName(FuncName) {}
5083 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
5092 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
5093 return std::make_unique<FunctionCallCCC>(*this);
5108 FunctionCallCCC CCC(S, FuncName.getAsIdentifierInfo(), Args.size(), ME);
5113 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
5114 if (Corrected.isOverloaded()) {
5124 ND = Best->FoundDecl;
5125 Corrected.setCorrectionDecl(ND);
5131 ND = ND->getUnderlyingDecl();
5132 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
5151 bool IsExecConfig) {
5161 bool Invalid =
false;
5170 if (Args.size() < NumParams) {
5171 if (Args.size() < MinArgs) {
5176 ? diag::err_typecheck_call_too_few_args_suggest
5177 : diag::err_typecheck_call_too_few_args_at_least_suggest;
5178 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
5179 << static_cast<unsigned>(Args.size())
5184 ? diag::err_typecheck_call_too_few_args_one
5185 : diag::err_typecheck_call_too_few_args_at_least_one)
5189 ? diag::err_typecheck_call_too_few_args
5190 : diag::err_typecheck_call_too_few_args_at_least)
5191 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
5195 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5203 "We should have reserved space for the default arguments before!");
5208 if (Args.size() > NumParams) {
5214 ? diag::err_typecheck_call_too_many_args_suggest
5215 : diag::err_typecheck_call_too_many_args_at_most_suggest;
5216 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
5217 << static_cast<unsigned>(Args.size())
5219 }
else if (NumParams == 1 && FDecl &&
5221 Diag(Args[NumParams]->getBeginLoc(),
5222 MinArgs == NumParams
5223 ? diag::err_typecheck_call_too_many_args_one
5224 : diag::err_typecheck_call_too_many_args_at_most_one)
5228 Args.back()->getEndLoc());
5230 Diag(Args[NumParams]->getBeginLoc(),
5231 MinArgs == NumParams
5232 ? diag::err_typecheck_call_too_many_args
5233 : diag::err_typecheck_call_too_many_args_at_most)
5234 << FnKind << NumParams << static_cast<unsigned>(Args.size())
5237 Args.back()->getEndLoc());
5240 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5251 Invalid = GatherArgumentsForCall(Call->
getBeginLoc(), FDecl, Proto, 0, Args,
5255 unsigned TotalNumArgs = AllArgs.size();
5256 for (
unsigned i = 0; i < TotalNumArgs; ++i)
5257 Call->
setArg(i, AllArgs[i]);
5267 bool IsListInitialization) {
5269 bool Invalid =
false;
5272 for (
unsigned i = FirstParam; i < NumParams; i++) {
5277 if (ArgIx < Args.size()) {
5278 Arg = Args[ArgIx++];
5280 if (RequireCompleteType(Arg->
getBeginLoc(), ProtoArgType,
5281 diag::err_call_incomplete_argument, Arg))
5285 bool CFAudited =
false;
5287 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5288 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5289 Arg = stripARCUnbridgedCast(Arg);
5290 else if (getLangOpts().ObjCAutoRefCount &&
5291 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5292 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5297 BE->getBlockDecl()->setDoesNotEscape();
5310 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
5316 assert(Param &&
"can't use default arguments without a known callee");
5318 ExprResult ArgExpr = BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
5328 CheckArrayAccess(Arg);
5331 CheckStaticArrayArgument(CallLoc, Param, Arg);
5333 AllArgs.push_back(Arg);
5337 if (CallType != VariadicDoesNotApply) {
5342 for (
Expr *A : Args.slice(ArgIx)) {
5344 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
5346 AllArgs.push_back(arg.
get());
5351 for (
Expr *A : Args.slice(ArgIx)) {
5352 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
5355 if (A->getType()->isBlockPointerType())
5356 maybeExtendBlockObject(Arg);
5357 AllArgs.push_back(Arg.
get());
5362 for (
Expr *A : Args.slice(ArgIx))
5363 CheckArrayAccess(A);
5371 TL = DTL.getOriginalLoc();
5374 << ATL.getLocalSourceRange();
5388 const Expr *ArgExpr) {
5415 if (getASTContext().hasSameUnqualifiedType(CAT->
getElementType(),
5418 Diag(CallLoc, diag::warn_static_array_too_small)
5420 << (unsigned)ArgCAT->
getSize().getZExtValue()
5421 << (unsigned)CAT->
getSize().getZExtValue() << 0;
5428 getASTContext().getTypeSizeInCharsIfKnown(ArgCAT);
5430 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
5431 Diag(CallLoc, diag::warn_static_array_too_small)
5433 << (unsigned)ParmSize->getQuantity() << 1;
5447 if (!placeholder)
return false;
5449 switch (placeholder->
getKind()) {
5451 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 5452 case BuiltinType::Id: 5453 #include "clang/Basic/OpenCLImageTypes.def" 5454 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 5455 case BuiltinType::Id: 5456 #include "clang/Basic/OpenCLExtensionTypes.def" 5459 #define SVE_TYPE(Name, Id, SingletonId) \ 5460 case BuiltinType::Id: 5461 #include "clang/Basic/AArch64SVEACLETypes.def" 5462 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 5463 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 5464 #include "clang/AST/BuiltinTypes.def" 5469 case BuiltinType::Overload:
5474 case BuiltinType::ARCUnbridgedCast:
5478 case BuiltinType::PseudoObject:
5483 case BuiltinType::UnknownAny:
5487 case BuiltinType::BoundMember:
5488 case BuiltinType::BuiltinFn:
5489 case BuiltinType::OMPArraySection:
5493 llvm_unreachable(
"bad builtin type kind");
5501 bool hasInvalid =
false;
5502 for (
size_t i = 0, e = args.size(); i != e; i++) {
5505 if (result.
isInvalid()) hasInvalid =
true;
5506 else args[i] = result.
get();
5507 }
else if (hasInvalid) {
5536 bool NeedsNewDecl =
false;
5549 if (!ParamType->isPointerType() ||
5550 ParamType.hasAddressSpace() ||
5553 OverloadParams.push_back(ParamType);
5561 NeedsNewDecl =
true;
5574 OverloadParams, EPI);
5585 FT = cast<FunctionProtoType>(OverloadTy);
5586 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5593 Params.push_back(Parm);
5595 OverloadDecl->setParams(Params);
5596 return OverloadDecl;
5614 isa<CXXMethodDecl>(Callee)
5615 ? diag::err_ovl_no_viable_member_function_in_call
5616 : diag::err_ovl_no_viable_function_in_call)
5619 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5620 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5628 const auto GetFunctionLevelDCIfCXXClass =
5636 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5637 return MD->
getParent()->getCanonicalDecl();
5640 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5641 return RD->getCanonicalDecl();
5648 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5649 if (!CurParentClass)
5656 assert(NamingClass &&
"Must have naming class even for implicit access");
5662 return CurParentClass == NamingClass ||
5710 BuildCallExpr(Scope, Fn, LParenLoc, ArgExprs, RParenLoc, ExecConfig);
5716 if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn)) {
5717 if (ULE->hasExplicitTemplateArgs() &&
5718 ULE->decls_begin() == ULE->decls_end()) {
5720 ? diag::warn_cxx17_compat_adl_only_template_id
5721 : diag::ext_adl_only_template_id)
5734 Expr *ExecConfig,
bool IsExecConfig) {
5736 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5745 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5746 if (!ArgExprs.empty()) {
5751 ArgExprs.back()->getEndLoc()));
5758 ExprResult result = CheckPlaceholderExpr(Fn);
5768 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5773 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5783 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5793 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5809 return BuildOverloadedCallExpr(
5810 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5812 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5826 bool CallingNDeclIndirectly =
false;
5828 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5829 if (UnOp->getOpcode() == UO_AddrOf) {
5830 CallingNDeclIndirectly =
true;
5835 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
5836 NDecl = DRE->getDecl();
5849 nullptr, DRE->isNonOdrUse());
5852 }
else if (isa<MemberExpr>(NakedFn))
5853 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5855 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5860 if (getLangOpts().
OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5866 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5867 ExecConfig, IsExecConfig);
5879 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5883 diag::err_invalid_astype_of_different_size)
5887 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5899 GetTypeFromParser(ParsedDestTy, &TInfo);
5900 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5914 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5915 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5918 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5927 if (
auto *Caller = getCurFunctionDecl())
5928 if (Caller->hasAttr<ARMInterruptAttr>()) {
5930 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5931 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5946 Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
5949 Result = CallExprUnaryConversions(Fn);
5950 ResultTy = Context.
BoolTy;
5952 if (Result.isInvalid())
5967 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5982 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5990 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
5991 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
5995 assert(UsesADL == ADLCallKind::NotADL &&
5996 "CUDAKernelCallExpr should not use ADL");
5999 ResultTy,
VK_RValue, RParenLoc, NumParams);
6002 RParenLoc, NumParams, UsesADL);
6013 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
6017 bool CorrectedTypos = TheCall != TheOldCall;
6018 if (!TheCall)
return Result;
6025 if (CorrectedTypos && Args.size() < NumParams) {
6028 Context, Fn, cast<CallExpr>(Config), Args, ResultTy,
VK_RValue,
6029 RParenLoc, NumParams);
6032 RParenLoc, NumParams, UsesADL);
6040 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
6042 if (getLangOpts().CUDA) {
6045 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
6046 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
6053 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
6057 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
6058 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
6073 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
6077 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
6085 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
6086 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
6097 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
6098 Expr *Arg = Args[i];
6100 if (Proto && i < Proto->getNumParams()) {
6102 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
6105 if (ArgE.isInvalid())
6108 Arg = ArgE.getAs<
Expr>();
6111 ExprResult ArgE = DefaultArgumentPromotion(Arg);
6120 diag::err_call_incomplete_argument, Arg))
6127 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
6128 if (!Method->isStatic())
6129 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
6134 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
6138 if (CheckFunctionCall(FDecl, TheCall, Proto))
6141 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
6144 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
6146 if (CheckPointerCall(NDecl, TheCall, Proto))
6149 if (CheckOtherCall(TheCall, Proto))
6153 return MaybeBindToTemporary(TheCall);
6159 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
6160 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
6163 QualType literalType = GetTypeFromParser(Ty, &TInfo);
6167 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
6177 diag::err_illegal_decl_array_incomplete_type,
6182 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
6185 RequireCompleteType(LParenLoc, literalType,
6186 diag::err_typecheck_decl_incomplete_type,
6201 LiteralExpr = Result.
get();
6203 bool isFileScope = !CurContext->isFunctionOrMethod();
6224 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
6229 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
6230 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
6231 Expr *Init = ILE->getInit(i);
6236 VK, LiteralExpr, isFileScope);
6241 if (CheckForConstantInitializer(LiteralExpr, literalType))
6248 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
6259 NTCUC_CompoundLiteral, NTCUK_Destruct);
6263 checkNonTrivialCUnionInInitializer(E->getInitializer(),
6266 return MaybeBindToTemporary(E);
6274 bool DiagnosedArrayDesignator =
false;
6275 bool DiagnosedNestedDesignator =
false;
6276 bool DiagnosedMixedDesignator =
false;
6280 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
6281 if (
auto *DIE = dyn_cast<DesignatedInitExpr>(InitArgList[I])) {
6283 FirstDesignator = DIE->getBeginLoc();
6288 if (!DiagnosedNestedDesignator && DIE->size() > 1) {
6289 DiagnosedNestedDesignator =
true;
6290 Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
6291 << DIE->getDesignatorsSourceRange();
6294 for (
auto &Desig : DIE->designators()) {
6295 if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
6296 DiagnosedArrayDesignator =
true;
6297 Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
6298 << Desig.getSourceRange();
6302 if (!DiagnosedMixedDesignator &&
6303 !isa<DesignatedInitExpr>(InitArgList[0])) {
6304 DiagnosedMixedDesignator =
true;
6305 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
6306 << DIE->getSourceRange();
6307 Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
6308 << InitArgList[0]->getSourceRange();
6310 }
else if (getLangOpts().
CPlusPlus && !DiagnosedMixedDesignator &&
6311 isa<DesignatedInitExpr>(InitArgList[0])) {
6312 DiagnosedMixedDesignator =
true;
6313 auto *DIE = cast<DesignatedInitExpr>(InitArgList[0]);
6314 Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
6315 << DIE->getSourceRange();
6316 Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
6317 << InitArgList[I]->getSourceRange();
6321 if (FirstDesignator.
isValid()) {
6324 if (getLangOpts().CPlusPlus && !DiagnosedArrayDesignator &&
6325 !DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
6327 ? diag::warn_cxx17_compat_designated_init
6328 : diag::ext_cxx_designated_init);
6329 }
else if (!getLangOpts().
CPlusPlus && !getLangOpts().
C99) {
6330 Diag(FirstDesignator, diag::ext_designated_init);
6334 return BuildInitList(LBraceLoc, InitArgList, RBraceLoc);
6345 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
6346 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
6347 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
6353 InitArgList[I] = result.
get();
6365 assert(E.
get()->getType()->isBlockPointerType());
6366 assert(E.
get()->isRValue());
6369 if (!getLangOpts().ObjCAutoRefCount)
return;
6372 CK_ARCExtendBlockObject, E.
get(),
6374 Cleanup.setExprNeedsCleanups(
true);
6384 maybeExtendBlockObject(E);
6385 return CK_BlockPointerToObjCPointerCast;
6388 return CK_CPointerToObjCPointerCast;
6405 llvm_unreachable(
"member pointer type in C");
6414 if (SrcAS != DestAS)
6415 return CK_AddressSpaceConversion;
6422 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
6427 return CK_CPointerToObjCPointerCast;
6428 maybeExtendBlockObject(Src);
6429 return CK_BlockPointerToObjCPointerCast;
6431 return CK_PointerToBoolean;
6433 return CK_PointerToIntegral;
6439 llvm_unreachable(
"illegal cast from pointer");
6441 llvm_unreachable(
"Should have returned before this");
6446 return CK_FixedPointCast;
6448 return CK_FixedPointToBoolean;
6450 return CK_FixedPointToIntegral;
6455 diag::err_unimplemented_conversion_with_fixed_point_type)
6457 return CK_IntegralCast;
6462 llvm_unreachable(
"illegal cast to pointer type");
6464 llvm_unreachable(
"Should have returned before this");
6472 if (Src.
get()->isNullPointerConstant(Context,
6474 return CK_NullToPointer;
6475 return CK_IntegralToPointer;
6477 return CK_IntegralToBoolean;
6479 return CK_IntegralCast;
6481 return CK_IntegralToFloating;
6483 Src = ImpCastExprToType(Src.
get(),
6486 return CK_IntegralRealToComplex;
6488 Src = ImpCastExprToType(Src.
get(),
6490 CK_IntegralToFloating);
6491 return CK_FloatingRealToComplex;
6493 llvm_unreachable(
"member pointer type in C");
6495 return CK_IntegralToFixedPoint;
6497 llvm_unreachable(
"Should have returned before this");
6502 return CK_FloatingCast;
6504 return CK_FloatingToBoolean;
6506 return CK_FloatingToIntegral;
6508 Src = ImpCastExprToType(Src.
get(),
6511 return CK_FloatingRealToComplex;
6513 Src = ImpCastExprToType(Src.
get(),
6515 CK_FloatingToIntegral);
6516 return CK_IntegralRealToComplex;
6520 llvm_unreachable(
"valid float->pointer cast?");
6522 llvm_unreachable(
"member pointer type in C");
6525 diag::err_unimplemented_conversion_with_fixed_point_type)
6527 return CK_IntegralCast;
6529 llvm_unreachable(
"Should have returned before this");
6534 return CK_FloatingComplexCast;
6536 return CK_FloatingComplexToIntegralComplex;
6540 return CK_FloatingComplexToReal;
6541 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
6542 return CK_FloatingCast;
6545 return CK_FloatingComplexToBoolean;
6547 Src = ImpCastExprToType(Src.
get(),
6549 CK_FloatingComplexToReal);
6550 return CK_FloatingToIntegral;
6554 llvm_unreachable(
"valid complex float->pointer cast?");
6556 llvm_unreachable(
"member pointer type in C");
6559 diag::err_unimplemented_conversion_with_fixed_point_type)
6561 return CK_IntegralCast;
6563 llvm_unreachable(
"Should have returned before this");
6568 return CK_IntegralComplexToFloatingComplex;
6570 return CK_IntegralComplexCast;
6574 return CK_IntegralComplexToReal;
6575 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
6576 return CK_IntegralCast;
6579 return CK_IntegralComplexToBoolean;
6581 Src = ImpCastExprToType(Src.
get(),
6583 CK_IntegralComplexToReal);
6584 return CK_IntegralToFloating;
6588 llvm_unreachable(
"valid complex int->pointer cast?");
6590 llvm_unreachable(
"member pointer type in C");
6593 diag::err_unimplemented_conversion_with_fixed_point_type)
6595 return CK_IntegralCast;
6597 llvm_unreachable(
"Should have returned before this");
6600 llvm_unreachable(
"Unhandled scalar cast");
6607 len = vecType->getNumElements();
6608 eltType = vecType->getElementType();
6640 uint64_t srcLen, destLen;
6648 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
6649 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
6651 return (srcLen * srcEltSize == destLen * destEltSize);
6659 switch (Context.
getLangOpts().getLaxVectorConversions()) {
6666 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
6671 if (!Vec || !Vec->getElementType()->isIntegralOrEnumerationType())
6681 return areLaxCompatibleVectorTypes(srcTy, destTy);
6686 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
6689 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
6692 diag::err_invalid_conversion_between_vectors :
6693 diag::err_invalid_conversion_between_vector_and_integer)
6694 << VectorTy << Ty << R;
6697 diag::err_invalid_conversion_between_vector_and_scalar)
6698 << VectorTy << Ty << R;
6707 if (DestElemTy == SplattedExpr->
getType())
6708 return SplattedExpr;
6720 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6721 CK_BooleanToSignedIntegral);
6722 SplattedExpr = CastExprRes.
get();
6723 CK = CK_IntegralToFloating;
6725 CK = CK_BooleanToSignedIntegral;
6729 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6732 SplattedExpr = CastExprRes.
get();
6734 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6747 if (SrcTy->isVectorType()) {
6748 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6749 (getLangOpts().OpenCL &&
6751 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6752 << DestTy << SrcTy << R;
6762 if (SrcTy->isPointerType())
6764 diag::err_invalid_conversion_between_vector_and_scalar)
6765 << DestTy << SrcTy << R;
6767 Kind = CK_VectorSplat;
6768 return prepareVectorSplat(DestTy, CastExpr);
6776 "ActOnCastExpr(): missing type or expr");
6782 if (getLangOpts().CPlusPlus) {
6784 CheckExtraCXXDefaultArguments(D);
6787 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6790 CastExpr = Res.
get();
6793 checkUnusedDeclAttributes(D);
6796 Ty = CreateParsedType(castType, castTInfo);
6798 bool isVectorLiteral =
false;
6804 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6806 if (PLE && PLE->getNumExprs() == 0) {
6807 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6810 if (PE || PLE->getNumExprs() == 1) {
6813 isVectorLiteral =
true;
6816 isVectorLiteral =
true;
6821 if (isVectorLiteral)
6822 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6827 if (isa<ParenListExpr>(CastExpr)) {
6828 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6830 CastExpr = Result.
get();
6834 !getSourceManager().isInSystemMacro(LParenLoc))
6837 CheckTollFreeBridgeCast(castType, CastExpr);
6839 CheckObjCBridgeRelatedCast(castType, CastExpr);
6841 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6843 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6849 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6850 "Expected paren or paren list expression");
6857 LiteralLParenLoc = PE->getLParenLoc();
6858 LiteralRParenLoc = PE->getRParenLoc();
6859 exprs = PE->getExprs();
6860 numExprs = PE->getNumExprs();
6862 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6863 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6864 subExpr = cast<ParenExpr>(E)->getSubExpr();
6884 if (numExprs == 1) {
6886 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6889 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6890 PrepareScalarCast(Literal, ElemTy));
6891 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6893 else if (numExprs < numElems) {
6895 diag::err_incorrect_number_of_vector_initializers);
6899 initExprs.append(exprs, exprs + numExprs);
6904 if (getLangOpts().
OpenCL &&
6908 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6911 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6912 PrepareScalarCast(Literal, ElemTy));
6913 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6916 initExprs.append(exprs, exprs + numExprs);
6921 initExprs, LiteralRParenLoc);
6923 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6936 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
6937 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6940 if (Result.isInvalid())
return ExprError();
6956 Expr *NullExpr = LHSExpr;
6957 Expr *NonPointerExpr = RHSExpr;
6964 NonPointerExpr = LHSExpr;
6981 if (!findMacroSpelling(loc,
"NULL"))
6986 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6987 << NonPointerExpr->
getType() << DiagType
6998 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
7006 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
7033 !NullExpr.
get()->isNullPointerConstant(S.
Context,
7057 bool IsBlockPointer =
false;
7061 IsBlockPointer =
true;
7086 ResultAddrSpace = LAddrSpace;
7088 ResultAddrSpace = RAddrSpace;
7090 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
7091 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
7092 << RHS.
get()->getSourceRange();
7097 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
7112 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
7114 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
7123 if (CompositeTy.
isNull()) {
7140 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
7141 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7142 << RHS.
get()->getSourceRange();
7151 QualType ResultTy = [&, ResultAddrSpace]() {
7157 .withCVRQualifiers(MergedCVRQual);
7186 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
7187 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7188 << RHS.
get()->getSourceRange();
7239 bool IsIntFirstExpr) {
7241 !Int.
get()->getType()->isIntegerType())
7244 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
7245 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
7247 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
7251 CK_IntegralToPointer);
7285 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
7286 << LHSType << LHS.
get()->getSourceRange();
7291 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
7292 << RHSType << RHS.
get()->getSourceRange();
7297 if (LHSType == RHSType)
7306 return handleIntegerConversion<doIntegralCast, doIntegralCast>
7307 (S, LHS, RHS, LHSType, RHSType,
false);
7341 llvm::raw_svector_ostream OS(Str);
7342 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
7343 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
7344 << CondTy << OS.str();
7365 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
7383 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
7384 << CondTy << VecResTy;
7389 QualType RVE = RV->getElementType();
7392 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
7393 << CondTy << VecResTy;
7417 if (LHS.
get()->getType()->isVectorType() ||
7418 RHS.
get()->getType()->isVectorType()) {
7437 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
7438 QualType Ty = CE->getCallee()->getType();
7464 if (getLangOpts().CPlusPlus)
7465 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
7472 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
7476 Cond = UsualUnaryConversions(Cond.
get());
7483 if (LHS.
get()->getType()->isVectorType() ||
7484 RHS.
get()->getType()->isVectorType())
7485 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
7490 UsualArithmeticConversions(LHS, RHS, QuestionLoc, ACK_Conditional);
7501 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
7502 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7508 if (getLangOpts().
OpenCL &&
7516 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
7517 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
7526 if (LHSRT->getDecl() == RHSRT->getDecl())
7545 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
7549 if (!compositeType.
isNull())
7550 return compositeType;
7575 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
7579 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
7580 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7581 << RHS.
get()->getSourceRange();
7597 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7602 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7608 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7613 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7619 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
7624 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
7651 if (!(compositeType =
7659 RHSOPT->isObjCQualifiedIdType()) &&
7670 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
7672 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7674 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
7675 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
7679 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
7680 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
7681 return compositeType;
7685 if (getLangOpts().ObjCAutoRefCount) {
7688 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7689 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7699 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
7701 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
7705 if (getLangOpts().ObjCAutoRefCount) {
7708 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7709 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7719 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7721 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7735 Self.
Diag(Loc, Note)
7740 Self.
Diag(Loc, Note) << ParenRange;
7765 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
7766 E = MTE->getSubExpr();
7773 *Opcode = OP->getOpcode();
7774 *RHSExprs = OP->getRHS();
7781 if (Call->getNumArgs() != 2)
7787 if (OO < OO_Plus || OO > OO_Arrow ||
7788 OO == OO_PlusPlus || OO == OO_MinusMinus)
7794 *RHSExprs = Call->getArg(1);
7811 return OP->isComparisonOp() || OP->isLogicalOp();
7813 return OP->getOpcode() == UO_LNot;
7843 ? diag::warn_precedence_bitwise_conditional
7844 : diag::warn_precedence_conditional;
7846 Self.
Diag(OpLoc, DiagID)
7852 Self.
PDiag(diag::note_precedence_silence)
7857 Self.
PDiag(diag::note_precedence_conditional_first),
7868 auto GetNullability = [&Ctx](
QualType Ty) {
7875 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7883 MergedKind = RHSKind;
7890 MergedKind = RHSKind;
7892 MergedKind = LHSKind;
7898 if (GetNullability(ResTy) == MergedKind)
7920 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7921 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7922 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7935 CondExpr = CondResult.
get();
7936 LHSExpr = LHSResult.
get();
7937 RHSExpr = RHSResult.
get();
7943 Expr *commonExpr =
nullptr;
7945 commonExpr = CondExpr;
7950 ExprResult result = CheckPlaceholderExpr(commonExpr);
7952 commonExpr = result.
get();
7963 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7966 commonExpr = commonRes.
get();
7973 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7976 commonExpr = MatExpr.
get();
7984 LHSExpr = CondExpr = opaqueValue;
7990 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7991 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
7992 VK, OK, QuestionLoc);
8006 return new (Context)
8008 RHS.get(), result, VK, OK);
8011 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
8022 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
8023 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
8026 const Type *lhptee, *rhptee;
8028 std::tie(lhptee, lhq) =
8029 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
8030 std::tie(rhptee, rhq) =
8031 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
8057 && (lhptee->isVoidType() || rhptee->isVoidType()))
8072 if (lhptee->isVoidType()) {
8073 if (rhptee->isIncompleteOrObjectType())
8077 assert(rhptee->isFunctionType());
8081 if (rhptee->isVoidType()) {
8082 if (lhptee->isIncompleteOrObjectType())
8086 assert(lhptee->isFunctionType());
8097 if (lhptee->isCharType())
8099 else if (lhptee->hasSignedIntegerRepresentation())
8102 if (rhptee->isCharType())
8104 else if (rhptee->hasSignedIntegerRepresentation())
8107 if (ltrans == rtrans) {
8121 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
8123 std::tie(lhptee, lhq) =
8124 cast<PointerType>(lhptee)->getPointeeType().split().asPair();
8125 std::tie(rhptee, rhq) =
8126 cast<PointerType>(rhptee)->getPointeeType().split().asPair();
8139 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
8141 if (lhptee == rhptee)
8161 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
8162 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
8167 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
8168 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
8177 Qualifiers LQuals = lhptee.getLocalQualifiers();
8178 Qualifiers RQuals = rhptee.getLocalQualifiers();
8183 if (LQuals != RQuals)
8212 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
8213 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
8254 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
8261 return VT->getElementType() == ElementType;
8294 if (LHSType == RHSType) {
8301 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
8303 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
8304 if (result != Compatible)
8306 if (Kind != CK_NoOp && ConvertRHS)
8307 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
8308 Kind = CK_NonAtomicToAtomic;
8321 Kind = CK_LValueBitCast;
8324 return Incompatible;
8331 return Incompatible;
8335 RHS = prepareVectorSplat(LHSType, RHS.
get());
8336 Kind = CK_VectorSplat;
8354 if (isLaxVectorConversion(RHSType, LHSType)) {
8356 return IncompatibleVectors;
8367 isLaxVectorConversion(RHSType, LHSType)) {
8369 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
8375 return Incompatible;
8381 return Incompatible;
8387 return Incompatible;
8393 Kind = PrepareScalarCast(RHS, LHSType);
8398 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
8400 if (isa<PointerType>(RHSType)) {
8401 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
8403 if (AddrSpaceL != AddrSpaceR)
8404 Kind = CK_AddressSpaceConversion;
8414 Kind = CK_IntegralToPointer;
8415 return IntToPointer;
8420 if (isa<ObjCObjectPointerType>(RHSType)) {
8422 if (LHSPointer->getPointeeType()->isVoidType()) {
8436 return IncompatiblePointer;
8441 if (LHSPointer->getPointeeType()->isVoidType()) {
8442 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
8447 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
8452 return Incompatible;
8456 if (isa<BlockPointerType>(LHSType)) {
8465 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
8471 Kind = CK_IntegralToPointer;
8472 return IntToBlockPointer;
8477 Kind = CK_AnyPointerToBlockPointerCast;
8483 if (RHSPT->getPointeeType()->isVoidType()) {
8484 Kind = CK_AnyPointerToBlockPointerCast;
8488 return Incompatible;
8492 if (isa<ObjCObjectPointerType>(LHSType)) {
8498 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8499 result == Compatible &&
8500 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
8501 result = IncompatibleObjCWeakRef;
8507 Kind = CK_IntegralToPointer;
8508 return IntToPointer;
8513 if (isa<PointerType>(RHSType)) {
8514 Kind = CK_CPointerToObjCPointerCast;
8528 return IncompatiblePointer;
8535 maybeExtendBlockObject(RHS);
8536 Kind = CK_BlockPointerToObjCPointerCast;
8540 return Incompatible;
8544 if (isa<PointerType>(RHSType)) {
8546 if (LHSType == Context.
BoolTy) {
8547 Kind = CK_PointerToBoolean;
8553 Kind = CK_PointerToIntegral;
8554 return PointerToInt;
8557 return Incompatible;
8561 if (isa<ObjCObjectPointerType>(RHSType)) {
8563 if (LHSType == Context.
BoolTy) {
8564 Kind = CK_PointerToBoolean;
8570 Kind = CK_PointerToIntegral;
8571 return PointerToInt;
8574 return Incompatible;
8578 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
8586 Kind = CK_IntToOCLSampler;
8590 return Incompatible;
8603 Initializer->
setType(UnionType);
8622 return Incompatible;
8628 for (
auto *it : UD->
fields()) {
8629 if (it->getType()->isPointerType()) {
8635 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
8640 if (RHS.
get()->isNullPointerConstant(Context,
8642 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
8650 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
8652 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
8659 return Incompatible;
8668 bool DiagnoseCFAudited,
8672 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
8678 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
8681 if (
const auto *RHSPtrType = RHS.
get()->getType()->getAs<
PointerType>()) {
8682 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8683 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8685 diag::warn_noderef_to_dereferenceable_pointer)
8686 << RHS.
get()->getSourceRange();
8709 return Incompatible;
8714 return Incompatible;
8716 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8717 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
8718 result = IncompatibleObjCWeakRef;
8730 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
8731 RHS.
get(), LHSType,
false, DAP))
8732 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
8734 return Incompatible;
8741 RHS.
get()->isNullPointerConstant(Context,
8743 if (Diagnose || ConvertRHS) {
8746 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8755 if (LHSType->
isQueueT() && RHS.
get()->isNullPointerConstant(
8757 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
8769 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8771 return Incompatible;
8775 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8783 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8790 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8791 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8792 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8794 return Incompatible;
8796 if (getLangOpts().ObjC &&
8797 (CheckObjCBridgeRelatedConversions(E->
getBeginLoc(), LHSType,
8799 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8801 return Incompatible;
8809 RHS = ImpCastExprToType(E, Ty, Kind);
8819 struct OriginalOperand {
8820 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
8821 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
8822 Op = MTE->getSubExpr();
8823 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
8824 Op = BTE->getSubExpr();
8825 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
8826 Orig = ICE->getSubExprAsWritten();
8827 Conversion = ICE->getConversionFunction();
8831 QualType getType()
const {
return Orig->getType(); }
8840 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
8842 Diag(Loc, diag::err_typecheck_invalid_operands)
8843 << OrigLHS.getType() << OrigRHS.getType()
8844 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8848 if (OrigLHS.Conversion) {
8849 Diag(OrigLHS.Conversion->getLocation(),
8850 diag::note_typecheck_invalid_operands_converted)
8851 << 0 << LHS.
get()->getType();
8853 if (OrigRHS.Conversion) {
8854 Diag(OrigRHS.Conversion->getLocation(),
8855 diag::note_typecheck_invalid_operands_converted)
8856 << 1 << RHS.
get()->getType();
8867 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8868 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8873 if (!(LHSNatVec && RHSNatVec)) {
8874 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8875 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8876 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8882 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8883 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8884 << RHS.
get()->getSourceRange();
8914 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8919 scalarCast = CK_IntegralCast;
8924 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8927 scalarCast = CK_FloatingCast;
8930 scalarCast = CK_IntegralToFloating;
8939 if (scalarCast != CK_NoOp)
8950 assert(VecTy &&
"Expression E must be a vector");
8952 VecTy->getNumElements(),
8953 VecTy->getVectorKind());
8957 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8958 if (ICE->getSubExpr()->getType() == NewVecTy)
8959 return ICE->getSubExpr();
8969 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8975 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8984 unsigned NumBits = IntSigned
8985 ? (Result.isNegative() ? Result.getMinSignedBits()
8986 : Result.getActiveBits())
8987 : Result.getActiveBits();
8994 return (IntSigned != OtherIntSigned &&
9007 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
9012 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
9024 llvm::APFloat::rmTowardZero);
9027 bool Ignored =
false;
9028 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
9030 if (Result != ConvertBack)
9036 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
9038 if (Bits > FloatPrec)
9051 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
9052 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
9055 assert(!isa<ExtVectorType>(VT) &&
9056 "ExtVectorTypes should not be handled here!");
9083 ScalarCast = CK_IntegralCast;
9087 ScalarCast = CK_FloatingToIntegral;
9095 llvm::APFloat Result(0.0);
9096 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
9098 if (!CstScalar && Order < 0)
9104 bool Truncated =
false;
9106 llvm::APFloat::rmNearestTiesToEven, &Truncated);
9111 ScalarCast = CK_FloatingCast;
9116 ScalarCast = CK_IntegralToFloating;
9123 if (ScalarCast != CK_NoOp)
9133 bool AllowBoolConversions) {
9134 if (!IsCompAssign) {
9135 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
9139 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
9145 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
9146 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
9150 assert(LHSVecType || RHSVecType);
9154 if (!AllowBothBool &&
9157 return InvalidOperands(Loc, LHS, RHS);
9164 if (LHSVecType && RHSVecType &&
9166 if (isa<ExtVectorType>(LHSVecType)) {
9167 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
9172 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
9179 if (AllowBoolConversions && LHSVecType && RHSVecType &&
9182 Context.
getTypeSize(RHSVecType->getElementType()))) {
9186 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
9189 if (!IsCompAssign &&
9192 RHSVecType->getElementType()->isIntegerType()) {
9193 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
9200 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
9202 if (isa<ExtVectorType>(LHSVecType)) {
9213 if (isa<ExtVectorType>(RHSVecType)) {
9215 LHSType, RHSVecType->getElementType(),
9228 QualType VecType = LHSVecType ? LHSType : RHSType;
9229 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
9230 QualType OtherType = LHSVecType ? RHSType : LHSType;
9231 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
9232 if (isLaxVectorConversion(OtherType, VecType)) {
9236 if (!IsCompAssign) {
9237 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
9247 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
9255 if ((!RHSVecType && !RHSType->
isRealType()) ||
9257 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
9258 << LHSType << RHSType
9259 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9267 if (getLangOpts().
OpenCL &&
9268 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
9269 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
9270 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
9279 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
9280 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
9281 QualType Scalar = LHSVecType ? RHSType : LHSType;
9282 QualType Vector = LHSVecType ? LHSType : RHSType;
9283 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
9285 diag::err_typecheck_vector_not_convertable_implict_truncation)
9286 << ScalarOrVector << Scalar << Vector;
9293 << LHSType << RHSType
9294 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9306 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
9307 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
9309 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
9313 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
9314 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
9320 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
9328 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
9329 NonNullType->canDecayToPointerType())
9332 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
9333 << LHSNull << NonNullType
9334 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9343 if (LUE->getKind() !=
UETT_SizeOf || LUE->isArgumentType() ||
9351 if (RUE->isArgumentType())
9352 RHSTy = RUE->getArgumentType();
9354 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
9361 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
9362 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
9363 S.
Diag(LHSArgDecl->getLocation(), diag::note_pointer_declared_here)
9367 QualType ArrayElemTy = ArrayTy->getElementType();
9373 S.
Diag(Loc, diag::warn_division_sizeof_array)
9375 if (
const auto *DRE = dyn_cast<DeclRefExpr>(LHSArg)) {
9376 if (
const ValueDecl *LHSArgDecl = DRE->getDecl())
9377 S.
Diag(LHSArgDecl->getLocation(), diag::note_array_declared_here)
9381 S.
Diag(Loc, diag::note_precedence_silence) << RHS;
9390 if (!RHS.
get()->isValueDependent() &&
9391 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) &&
9394 S.
PDiag(diag::warn_remainder_division_by_zero)
9395 << IsDiv << RHS.
get()->getSourceRange());
9400 bool IsCompAssign,
bool IsDiv) {
9403 if (LHS.
get()->getType()->isVectorType() ||
9404 RHS.
get()->getType()->isVectorType())
9405 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
9406 getLangOpts().AltiVec,
9409 QualType compType = UsualArithmeticConversions(
9410 LHS, RHS, Loc, IsCompAssign ? ACK_CompAssign : ACK_Arithmetic);
9416 return InvalidOperands(Loc, LHS, RHS);
9428 if (LHS.
get()->getType()->isVectorType() ||
9429 RHS.
get()->getType()->isVectorType()) {
9430 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
9431 RHS.
get()->getType()->hasIntegerRepresentation())
9432 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
9433 getLangOpts().AltiVec,
9435 return InvalidOperands(Loc, LHS, RHS);
9438 QualType compType = UsualArithmeticConversions(
9439 LHS, RHS, Loc, IsCompAssign ? ACK_CompAssign : ACK_Arithmetic);
9444 return InvalidOperands(Loc, LHS, RHS);
9453 ? diag::err_typecheck_pointer_arith_void_type
9454 : diag::ext_gnu_void_ptr)
9463 ? diag::err_typecheck_pointer_arith_void_type
9464 : diag::ext_gnu_void_ptr)
9474 Expr *Pointer,
bool IsGNUIdiom) {
9476 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
9479 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
9489 ? diag::err_typecheck_pointer_arith_function_type
9490 : diag::ext_gnu_ptr_func_arith)
9504 ? diag::err_typecheck_pointer_arith_function_type
9505 : diag::ext_gnu_ptr_func_arith)
9518 ResType = ResAtomicType->getValueType();
9523 diag::err_typecheck_arithmetic_incomplete_type,
9539 ResType = ResAtomicType->getValueType();
9571 if (!isLHSPointer && !isRHSPointer)
return true;
9573 QualType LHSPointeeTy, RHSPointeeTy;
9578 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
9583 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9591 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
9592 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
9593 if (isLHSVoidPtr || isRHSVoidPtr) {
9601 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
9602 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
9603 if (isLHSFuncPtr || isRHSFuncPtr) {
9625 Expr* IndexExpr = RHSExpr;
9628 IndexExpr = LHSExpr;
9631 bool IsStringPlusInt = StrExpr &&
9633 if (!IsStringPlusInt || IndexExpr->isValueDependent())
9637 Self.
Diag(OpLoc, diag::warn_string_plus_int)
9638 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
9641 if (IndexExpr == RHSExpr) {
9643 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9648 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9654 const Expr *StringRefExpr = LHSExpr;
9660 StringRefExpr = RHSExpr;
9663 if (!CharExpr || !StringRefExpr)
9680 if (!CharType->isAnyCharacterType() &&
9681 CharType->isIntegerType() &&
9683 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9684 << DiagRange << Ctx.
CharTy;
9686 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9687 << DiagRange << CharExpr->
getType();
9693 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9698 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9707 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
9718 if (LHS.
get()->getType()->isVectorType() ||
9719 RHS.
get()->getType()->isVectorType()) {
9720 QualType compType = CheckVectorOperands(
9721 LHS, RHS, Loc, CompLHSTy,
9722 getLangOpts().AltiVec,
9723 getLangOpts().ZVector);
9724 if (CompLHSTy) *CompLHSTy = compType;
9728 QualType compType = UsualArithmeticConversions(
9729 LHS, RHS, Loc, CompLHSTy ? ACK_CompAssign : ACK_Arithmetic);
9734 if (Opc == BO_Add) {
9741 if (CompLHSTy) *CompLHSTy = compType;
9751 isObjCPointer =
false;
9753 isObjCPointer =
true;
9755 std::swap(PExp, IExp);
9757 isObjCPointer =
false;
9759 isObjCPointer =
true;
9761 return InvalidOperands(Loc, LHS, RHS);
9766 if (!IExp->getType()->isIntegerType())
9767 return InvalidOperands(Loc, LHS, RHS);
9774 if (!getLangOpts().CPlusPlus ||
9775 (!IExp->isValueDependent() &&
9776 (!IExp->EvaluateAsInt(KnownVal, Context) ||
9780 Context, BO_Add, PExp, IExp);
9792 CheckArrayAccess(PExp, IExp);
9797 LHSTy = LHS.
get()->getType();
9813 if (LHS.
get()->getType()->isVectorType() ||
9814 RHS.
get()->getType()->isVectorType()) {
9815 QualType compType = CheckVectorOperands(
9816 LHS, RHS, Loc, CompLHSTy,
9817 getLangOpts().AltiVec,
9818 getLangOpts().ZVector);
9819 if (CompLHSTy) *CompLHSTy = compType;
9823 QualType compType = UsualArithmeticConversions(
9824 LHS, RHS, Loc, CompLHSTy ? ACK_CompAssign : ACK_Arithmetic);
9832 if (CompLHSTy) *CompLHSTy = compType;
9837 if (LHS.
get()->getType()->isAnyPointerType()) {
9838 QualType lpointee = LHS.
get()->getType()->getPointeeType();
9841 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9846 if (RHS.
get()->getType()->isIntegerType()) {
9850 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9854 if (!getLangOpts().CPlusPlus ||
9855 (!RHS.
get()->isValueDependent() &&
9856 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) ||
9866 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9869 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9870 return LHS.
get()->getType();
9904 if (ElementSize.
isZero()) {
9905 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9907 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9911 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9916 return InvalidOperands(Loc, LHS, RHS);
9921 return ET->getDecl()->isScoped();
9935 if (RHS.
get()->isValueDependent() ||
9936 !RHS.
get()->EvaluateAsInt(RHSResult, S.
Context))
9940 if (Right.isNegative()) {
9942 S.
PDiag(diag::warn_shift_negative)
9943 << RHS.
get()->getSourceRange());
9948 if (Right.uge(LeftBits)) {
9950 S.
PDiag(diag::warn_shift_gt_typewidth)
9951 << RHS.
get()->getSourceRange());
9964 if (LHS.
get()->isValueDependent() ||
9966 !LHS.
get()->EvaluateAsInt(LHSResult, S.
Context))
9975 S.
PDiag(diag::warn_shift_lhs_negative)
9976 << LHS.
get()->getSourceRange());
9981 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9982 if (LeftBits.uge(ResultBits))
9984 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9985 Result = Result.shl(Right);
9990 Result.toString(HexResult, 16,
false,
true);
9996 if (LeftBits == ResultBits - 1) {
9997 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9998 << HexResult << LHSType
9999 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10003 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
10004 << HexResult.str() << Result.getMinSignedBits() << LHSType
10005 << Left.getBitWidth() << LHS.
get()->getSourceRange()
10006 << RHS.
get()->getSourceRange();
10015 !LHS.
get()->getType()->isVectorType()) {
10016 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
10017 << RHS.
get()->getType() << LHS.
get()->getType()
10018 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10022 if (!IsCompAssign) {
10042 if (!LHSEleType->isIntegerType()) {
10043 S.
Diag(Loc, diag::err_typecheck_expect_int)
10044 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
10048 if (!RHSEleType->isIntegerType()) {
10049 S.
Diag(Loc, diag::err_typecheck_expect_int)
10050 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
10058 if (LHSEleType != RHSEleType) {
10060 LHSEleType = RHSEleType;
10066 }
else if (RHSVecTy) {
10071 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
10072 << LHS.
get()->getType() << RHS.
get()->getType()
10073 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10079 if (LHSBT != RHSBT &&
10081 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
10082 << LHS.
get()->getType() << RHS.
get()->getType()
10083 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10099 bool IsCompAssign) {
10103 if (LHS.
get()->getType()->isVectorType() ||
10104 RHS.
get()->getType()->isVectorType()) {
10105 if (LangOpts.ZVector) {
10109 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
10111 return InvalidOperands(Loc, LHS, RHS);
10112 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
10114 return InvalidOperands(Loc, LHS, RHS);
10125 LHS = UsualUnaryConversions(LHS.
get());
10129 if (IsCompAssign) LHS = OldLHS;
10132 RHS = UsualUnaryConversions(RHS.
get());
10140 return InvalidOperands(Loc, LHS, RHS);
10146 return InvalidOperands(Loc, LHS, RHS);
10159 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
10160 : diag::ext_typecheck_comparison_of_distinct_pointers)
10161 << LHS.
get()->getType() << RHS.
get()->getType()
10162 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10200 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
10201 : diag::ext_typecheck_comparison_of_fptr_to_void)
10202 << LHS.
get()->getType() << RHS.
get()->getType()
10203 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10207 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
10208 case Stmt::ObjCArrayLiteralClass:
10209 case Stmt::ObjCDictionaryLiteralClass:
10210 case Stmt::ObjCStringLiteralClass:
10211 case Stmt::ObjCBoxedExprClass:
10270 case Stmt::ObjCStringLiteralClass:
10273 case Stmt::ObjCArrayLiteralClass:
10276 case Stmt::ObjCDictionaryLiteralClass:
10278 return LK_Dictionary;
10279 case Stmt::BlockExprClass:
10281 case Stmt::ObjCBoxedExprClass: {
10282 Expr *Inner = cast<ObjCBoxedExpr>(FromE)->getSubExpr()->IgnoreParens();
10284 case Stmt::IntegerLiteralClass:
10285 case Stmt::FloatingLiteralClass:
10286 case Stmt::CharacterLiteralClass:
10287 case Stmt::ObjCBoolLiteralExprClass:
10288 case Stmt::CXXBoolLiteralExprClass:
10291 case Stmt::ImplicitCastExprClass: {
10292 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
10294 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
10313 Literal = LHS.
get();
10316 Literal = RHS.
get();
10332 llvm_unreachable(
"Unknown Objective-C object literal kind");
10336 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
10339 S.
Diag(Loc, diag::warn_objc_literal_comparison)
10349 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
10362 if (!UO || UO->
getOpcode() != UO_LNot)
return;
10365 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
10372 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
10374 << Loc << IsBitwiseOp;
10401 if (
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
10403 }
else if (
const MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
10404 if (Mem->isImplicitAccess())
10405 D = Mem->getMemberDecl();
10455 S.
Diag(Loc, diag::warn_depr_array_comparison)
10470 Result = AlwaysTrue;
10475 Result = AlwaysFalse;
10478 Result = AlwaysEqual;
10481 Result = AlwaysConstant;
10485 S.
PDiag(diag::warn_comparison_always)
10493 Result = AlwaysFalse;
10496 Result = AlwaysTrue;
10500 Result = AlwaysConstant;
10504 S.
PDiag(diag::warn_comparison_always)
10510 if (isa<CastExpr>(LHSStripped))
10512 if (isa<CastExpr>(RHSStripped))
10517 Expr *LiteralString =
nullptr;
10518 Expr *LiteralStringStripped =
nullptr;
10519 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
10522 LiteralString = LHS;
10523 LiteralStringStripped = LHSStripped;
10524 }
else if ((isa<StringLiteral>(RHSStripped) ||
10525 isa<ObjCEncodeExpr>(RHSStripped)) &&
10528 LiteralString = RHS;
10529 LiteralStringStripped = RHSStripped;
10532 if (LiteralString) {
10534 S.
PDiag(diag::warn_stringcompare)
10535 << isa<ObjCEncodeExpr>(LiteralStringStripped)
10547 llvm_unreachable(
"unhandled cast kind");
10549 case CK_UserDefinedConversion:
10551 case CK_LValueToRValue:
10553 case CK_ArrayToPointerDecay:
10555 case CK_FunctionToPointerDecay:
10557 case CK_IntegralCast:
10559 case CK_FloatingCast:
10561 case CK_IntegralToFloating:
10562 case CK_FloatingToIntegral:
10564 case CK_IntegralComplexCast:
10565 case CK_FloatingComplexCast:
10566 case CK_FloatingComplexToIntegralComplex:
10567 case CK_IntegralComplexToFloatingComplex:
10569 case CK_FloatingComplexToReal:
10570 case CK_FloatingRealToComplex:
10571 case CK_IntegralComplexToReal:
10572 case CK_IntegralRealToComplex:
10585 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10604 << PreNarrowingValue.getAsString(S.
Context, PreNarrowingType) << ToType;
10612 << 0 << FromType << ToType;
10617 llvm_unreachable(
"unhandled case in switch");
10631 QualType LHSStrippedType = LHSStripped.
get()->getType();
10632 QualType RHSStrippedType = RHSStripped.
get()->getType();
10644 if (NumEnumArgs == 1) {
10646 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
10652 if (NumEnumArgs == 2) {
10661 LHSStrippedType->
castAs<
EnumType>()->getDecl()->getIntegerType();
10672 LHSType = RHSType = IntType;
10690 S, Type, LHS.
get(), LHSType, LHS.
get()->getBeginLoc());
10692 RHS.
get()->getBeginLoc());
10696 assert(!Type.
isNull() &&
"composite type for <=> has not been set");
10730 if (!NullE.
get()->getType()->isAnyPointerType())
10732 int NullValue = PP.isMacroDefined(
"NULL") ? 0 : 1;
10733 if (!E.
get()->getType()->isAnyPointerType() &&
10734 E.
get()->isNullPointerConstant(Context,
10737 if (
const auto *CL = dyn_cast<CharacterLiteral>(E.
get())) {
10738 if (CL->getValue() == 0)
10739 Diag(E.
get()->getExprLoc(), diag::warn_pointer_compare)
10742 NullValue ?
"NULL" :
"(void *)0");
10743 }
else if (
const auto *CE = dyn_cast<CStyleCastExpr>(E.
get())) {
10746 if (T == Context.
CharTy)
10747 Diag(E.
get()->getExprLoc(), diag::warn_pointer_compare)
10750 NullValue ?
"NULL" :
"(void *)0");
10760 bool IsThreeWay = Opc == BO_Cmp;
10761 bool IsOrdered = IsRelational || IsThreeWay;
10772 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
10773 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10776 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10780 LHS = DefaultLvalueConversion(LHS.
get());
10783 RHS = DefaultLvalueConversion(RHS.
get());
10790 CheckPtrComparisonWithNullChar(LHS, RHS);
10791 CheckPtrComparisonWithNullChar(RHS, LHS);
10795 if (LHS.
get()->getType()->isVectorType() ||
10796 RHS.
get()->getType()->isVectorType())
10797 return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);
10804 if ((LHSType->isArithmeticType() || LHSType->isEnumeralType()) &&
10815 auto computeResultTy = [&]() {
10827 return InvalidOperands(Loc, LHS, RHS);
10829 if (CompositeTy->
isPointerType() && LHSIsNull != RHSIsNull) {
10833 Diag(Loc, diag::err_typecheck_three_way_comparison_of_pointer_and_zero)
10834 << (LHSIsNull ? LHS.
get()->getSourceRange()
10835 : RHS.
get()->getSourceRange());
10839 return CheckComparisonCategoryType(
10840 *CCT, Loc, ComparisonCategoryUsage::OperatorInExpression);
10843 if (!IsOrdered && LHSIsNull != RHSIsNull) {
10844 bool IsEquality = Opc == BO_EQ;
10846 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
10847 RHS.
get()->getSourceRange());
10849 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
10850 LHS.
get()->getSourceRange());
10853 if ((LHSType->isIntegerType() && !LHSIsNull) ||
10857 }
else if (getLangOpts().CPlusPlus) {
10869 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
10871 if (isSFINAEContext())
10874 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10875 return computeResultTy();
10890 if ((
int)LHSType->isPointerType() + (int)RHSType->
isPointerType() >=
10891 (IsOrdered ? 2 : 1) &&
10892 (!LangOpts.ObjCAutoRefCount || !(LHSType->isObjCObjectPointerType() ||
10896 return computeResultTy();
10898 }
else if (LHSType->isPointerType() &&
10912 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
10913 << LHSType << RHSType << LHS.
get()->getSourceRange()
10914 << RHS.
get()->getSourceRange();
10916 }
else if (!IsRelational &&
10920 && !LHSIsNull && !RHSIsNull)
10927 if (LCanPointeeTy != RCanPointeeTy) {
10929 if (getLangOpts().
OpenCL && !LHSIsNull && !RHSIsNull) {
10933 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10934 << LHSType << RHSType << 0
10935 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10940 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
10942 if (LHSIsNull && !RHSIsNull)
10943 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
10945 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
10947 return computeResultTy();
10954 if (!IsOrdered && LHSIsNull && RHSIsNull) {
10955 if (LHSType->isNullPtrType()) {
10956 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10957 return computeResultTy();
10960 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10961 return computeResultTy();
10968 (LHSType->isObjCObjectPointerType() || LHSType->isBlockPointerType())) {
10969 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10970 return computeResultTy();
10972 if (!IsOrdered && LHSType->isNullPtrType() &&
10974 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10975 return computeResultTy();
10978 if (IsRelational &&
10987 if (isa<FunctionDecl>(DC))
10989 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
10990 if (CTSD->isInStdNamespace() &&
10991 llvm::StringSwitch<bool>(CTSD->getName())
10992 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
10995 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10997 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10998 return computeResultTy();
11011 return computeResultTy();
11016 if (!IsOrdered && LHSType->isBlockPointerType() &&
11021 if (!LHSIsNull && !RHSIsNull &&
11023 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
11024 << LHSType << RHSType << LHS.
get()->getSourceRange()
11025 << RHS.
get()->getSourceRange();
11027 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
11028 return computeResultTy();
11033 && ((LHSType->isBlockPointerType() && RHSType->
isPointerType())
11035 if (!LHSIsNull && !RHSIsNull) {
11038 || (LHSType->isPointerType() && LHSType->castAs<
PointerType>()
11040 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
11041 << LHSType << RHSType << LHS.
get()->getSourceRange()
11042 << RHS.
get()->getSourceRange();
11044 if (LHSIsNull && !RHSIsNull)
11045 LHS = ImpCastExprToType(LHS.
get(), RHSType,
11047 : CK_AnyPointerToBlockPointerCast);
11049 RHS = ImpCastExprToType(RHS.get(), LHSType,
11050 LHSType->isPointerType() ? CK_BitCast
11051 : CK_AnyPointerToBlockPointerCast);
11052 return computeResultTy();
11055 if (LHSType->isObjCObjectPointerType() ||
11061 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
11063 if (!LPtrToVoid && !RPtrToVoid &&
11071 if (LHSIsNull && !RHSIsNull) {
11073 if (getLangOpts().ObjCAutoRefCount)
11075 CCK_ImplicitConversion);
11076 LHS = ImpCastExprToType(E, RHSType,
11077 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
11081 if (getLangOpts().ObjCAutoRefCount)
11082 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
11085 RHS = ImpCastExprToType(E, LHSType,
11086 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
11088 return computeResultTy();
11090 if (LHSType->isObjCObjectPointerType() &&
11098 if (LHSIsNull && !RHSIsNull)
11099 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
11101 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
11102 return computeResultTy();
11105 if (!IsOrdered && LHSType->isBlockPointerType() &&
11107 LHS = ImpCastExprToType(LHS.
get(), RHSType,
11108 CK_BlockPointerToObjCPointerCast);
11109 return computeResultTy();
11110 }
else if (!IsOrdered &&
11111 LHSType->isBlockCompatibleObjCPointerType(Context) &&
11113 RHS = ImpCastExprToType(RHS.
get(), LHSType,
11114 CK_BlockPointerToObjCPointerCast);
11115 return computeResultTy();
11118 if ((LHSType->isAnyPointerType() && RHSType->
isIntegerType()) ||
11120 unsigned DiagID = 0;
11121 bool isError =
false;
11122 if (LangOpts.DebuggerSupport) {
11125 }
else if ((LHSIsNull && LHSType->isIntegerType()) ||
11128 isError = getLangOpts().CPlusPlus;
11130 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
11131 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
11134 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
11136 }
else if (IsOrdered)
11137 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
11139 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
11143 << LHSType << RHSType << LHS.
get()->getSourceRange()
11144 << RHS.
get()->getSourceRange();
11149 if (LHSType->isIntegerType())
11150 LHS = ImpCastExprToType(LHS.
get(), RHSType,
11151 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
11153 RHS = ImpCastExprToType(RHS.
get(), LHSType,
11154 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
11155 return computeResultTy();
11159 if (!IsOrdered && RHSIsNull
11160 && LHSType->isBlockPointerType() && RHSType->
isIntegerType()) {
11161 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
11162 return computeResultTy();
11164 if (!IsOrdered && LHSIsNull
11166 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
11167 return computeResultTy();
11170 if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
11171 if (LHSType->isClkEventT() && RHSType->
isClkEventT()) {
11172 return computeResultTy();
11175 if (LHSType->isQueueT() && RHSType->
isQueueT()) {
11176 return computeResultTy();
11179 if (LHSIsNull && RHSType->
isQueueT()) {
11180 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
11181 return computeResultTy();
11184 if (LHSType->isQueueT() && RHSIsNull) {
11185 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
11186 return computeResultTy();
11190 return InvalidOperands(Loc, LHS, RHS);
11202 if (isa<ExtVectorType>(VTy)) {
11212 "Unhandled vector element size in vector compare");
11229 "Unhandled vector element size in vector compare");
11241 if (Opc == BO_Cmp) {
11242 Diag(Loc, diag::err_three_way_vector_comparison);
11248 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
11250 getLangOpts().ZVector);
11258 if (getLangOpts().AltiVec &&
11270 assert(RHS.
get()->getType()->hasFloatingRepresentation());
11271 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
11275 return GetSignedVectorType(vType);
11285 bool Negative =
false;
11286 bool ExplicitPlus =
false;
11294 if (
const auto *UO = dyn_cast<UnaryOperator>(XorRHS.
get())) {
11296 if (Opc != UO_Minus && Opc != UO_Plus)
11301 Negative = (Opc == UO_Minus);
11302 ExplicitPlus = !Negative;
11308 const llvm::APInt &LeftSideValue = LHSInt->getValue();
11310 if (LeftSideValue != 2 && LeftSideValue != 10)
11313 if (LeftSideValue.getBitWidth() != RightSideValue.getBitWidth())
11318 llvm::StringRef ExprStr =
11323 llvm::StringRef XorStr =
11326 if (XorStr ==
"xor")
11337 RightSideValue = -RightSideValue;
11338 RHSStr =
"-" + RHSStr;
11339 }
else if (ExplicitPlus) {
11340 RHSStr =
"+" + RHSStr;
11343 StringRef LHSStrRef = LHSStr;
11344 StringRef RHSStrRef = RHSStr;
11347 if (LHSStrRef.startswith(
"0b") || LHSStrRef.startswith(
"0B") ||
11348 RHSStrRef.startswith(
"0b") || RHSStrRef.startswith(
"0B") ||
11349 LHSStrRef.startswith(
"0x") || LHSStrRef.startswith(
"0X") ||
11350 RHSStrRef.startswith(
"0x") || RHSStrRef.startswith(
"0X") ||
11351 (LHSStrRef.size() > 1 && LHSStrRef.startswith(
"0")) ||
11352 (RHSStrRef.size() > 1 && RHSStrRef.startswith(
"0")) ||
11353 LHSStrRef.find(
'\'') != StringRef::npos ||
11354 RHSStrRef.find(
'\'') != StringRef::npos)
11358 const llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
11359 int64_t RightSideIntValue = RightSideValue.getSExtValue();
11360 if (LeftSideValue == 2 && RightSideIntValue >= 0) {
11361 std::string SuggestedExpr =
"1 << " + RHSStr;
11362 bool Overflow =
false;
11364 llvm::APInt PowValue = One.sshl_ov(RightSideValue, Overflow);
11366 if (RightSideIntValue < 64)
11367 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
11368 << ExprStr << XorValue.toString(10,
true) << (
"1LL << " + RHSStr)
11370 else if (RightSideIntValue == 64)
11371 S.
Diag(Loc, diag::warn_xor_used_as_pow) << ExprStr << XorValue.toString(10,
true);
11375 S.
Diag(Loc, diag::warn_xor_used_as_pow_base_extra)
11376 << ExprStr << XorValue.toString(10,
true) << SuggestedExpr
11377 << PowValue.toString(10,
true)
11379 ExprRange, (RightSideIntValue == 0) ?
"1" : SuggestedExpr);
11382 S.
Diag(Loc, diag::note_xor_used_as_pow_silence) << (
"0x2 ^ " + RHSStr) << SuggestXor;
11383 }
else if (LeftSideValue == 10) {
11384 std::string SuggestedValue =
"1e" + std::to_string(RightSideIntValue);
11385 S.
Diag(Loc, diag::warn_xor_used_as_pow_base)
11386 << ExprStr << XorValue.toString(10,
true) << SuggestedValue
11388 S.
Diag(Loc, diag::note_xor_used_as_pow_silence) << (
"0xA ^ " + RHSStr) << SuggestXor;
11396 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
11400 return InvalidOperands(Loc, LHS, RHS);
11401 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
11403 return InvalidOperands(Loc, LHS, RHS);
11407 if (!getLangOpts().CPlusPlus &&
11409 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
11411 return GetSignedVectorType(LHS.
get()->getType());
11419 bool IsCompAssign =
11420 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
11422 if (LHS.
get()->getType()->isVectorType() ||
11423 RHS.
get()->getType()->isVectorType()) {
11424 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
11425 RHS.
get()->getType()->hasIntegerRepresentation())
11426 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
11428 getLangOpts().ZVector);
11429 return InvalidOperands(Loc, LHS, RHS);
11435 if (LHS.
get()->getType()->hasFloatingRepresentation() ||
11436 RHS.
get()->getType()->hasFloatingRepresentation())
11437 return InvalidOperands(Loc, LHS, RHS);
11439 ExprResult LHSResult = LHS, RHSResult = RHS;
11440 QualType compType = UsualArithmeticConversions(
11441 LHSResult, RHSResult, Loc, IsCompAssign ? ACK_CompAssign : ACK_BitwiseOp);
11442 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
11444 LHS = LHSResult.
get();
11445 RHS = RHSResult.
get();
11452 return InvalidOperands(Loc, LHS, RHS);
11460 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
11461 return CheckVectorLogicalOperands(LHS, RHS, Loc);
11463 bool EnumConstantInBoolContext =
false;
11465 if (
const auto *DREHS = dyn_cast<DeclRefExpr>(HS.get())) {
11467 if (ECDHS && ECDHS->getInitVal() != 0 && ECDHS->getInitVal() != 1)
11468 EnumConstantInBoolContext =
true;
11472 if (EnumConstantInBoolContext)
11473 Diag(Loc, diag::warn_enum_constant_in_bool_context);
11478 if (!EnumConstantInBoolContext && LHS.
get()->getType()->isIntegerType() &&
11479 !LHS.
get()->getType()->isBooleanType() &&
11480 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
11482 !Loc.
isMacroID() && !inTemplateInstantiation()) {
11488 if (RHS.
get()->EvaluateAsInt(EVResult, Context)) {
11490 if ((getLangOpts().
Bool && !RHS.
get()->getType()->isBooleanType() &&
11491 !RHS.
get()->getExprLoc().isMacroID()) ||
11492 (Result != 0 && Result != 1)) {
11493 Diag(Loc, diag::warn_logical_instead_of_bitwise)
11494 << RHS.
get()->getSourceRange()
11495 << (Opc == BO_LAnd ?
"&&" :
"||");
11497 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
11498 << (Opc == BO_LAnd ?
"&" :
"|")
11500 Loc, getLocForEndOfToken(Loc)),
11501 Opc == BO_LAnd ?
"&" :
"|");
11502 if (Opc == BO_LAnd)
11504 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
11507 RHS.
get()->getEndLoc()));
11517 if (LHS.
get()->getType()->isFloatingType() ||
11518 RHS.
get()->getType()->isFloatingType())
11519 return InvalidOperands(Loc, LHS, RHS);
11522 LHS = UsualUnaryConversions(LHS.
get());
11526 RHS = UsualUnaryConversions(RHS.
get());
11530 if (!LHS.
get()->getType()->isScalarType() ||
11531 !RHS.
get()->getType()->isScalarType())
11532 return InvalidOperands(Loc, LHS, RHS);
11534 return Context.
IntTy;
11543 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
11545 return InvalidOperands(Loc, LHS, RHS);
11548 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
11550 return InvalidOperands(Loc, LHS, RHS);
11561 if (!ME)
return false;
11565 if (!Base)
return false;
11586 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
11594 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
11637 bool DiagnosticEmitted =
false;
11641 bool IsDereference =
false;
11642 bool NextIsDereference =
false;
11646 IsDereference = NextIsDereference;
11649 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
11650 NextIsDereference = ME->isArrow();
11651 const ValueDecl *VD = ME->getMemberDecl();
11652 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
11654 if (Field->isMutable()) {
11655 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
11660 if (!DiagnosticEmitted) {
11661 S.
Diag(Loc, diag::err_typecheck_assign_const)
11663 << Field->getType();
11664 DiagnosticEmitted =
true;
11667 <<
ConstMember <<
false << Field << Field->getType()
11668 << Field->getSourceRange();
11672 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
11673 if (VDecl->getType().isConstQualified()) {
11674 if (!DiagnosticEmitted) {
11675 S.
Diag(Loc, diag::err_typecheck_assign_const)
11677 << VDecl->getType();
11678 DiagnosticEmitted =
true;
11681 <<
ConstMember <<
true << VDecl << VDecl->getType()
11682 << VDecl->getSourceRange();
11689 dyn_cast<ArraySubscriptExpr>(E)) {
11693 dyn_cast<ExtVectorElementExpr>(E)) {
11700 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
11704 if (!DiagnosticEmitted) {
11705 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11707 DiagnosticEmitted =
true;
11710 diag::note_typecheck_assign_const)
11714 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11716 if (
const ValueDecl *VD = DRE->getDecl()) {
11718 if (!DiagnosticEmitted) {
11719 S.
Diag(Loc, diag::err_typecheck_assign_const)
11721 DiagnosticEmitted =
true;
11723 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
11724 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
11727 }
else if (isa<CXXThisExpr>(E)) {
11729 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
11730 if (MD->isConst()) {
11731 if (!DiagnosticEmitted) {
11732 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11734 DiagnosticEmitted =
true;
11736 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
11743 if (DiagnosticEmitted)
11747 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
11760 bool &DiagnosticEmitted) {
11761 std::vector<const RecordType *> RecordTypeList;
11762 RecordTypeList.push_back(Ty);
11763 unsigned NextToCheckIndex = 0;
11766 while (RecordTypeList.size() > NextToCheckIndex) {
11767 bool IsNested = NextToCheckIndex > 0;
11769 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
11771 QualType FieldTy = Field->getType();
11773 if (!DiagnosticEmitted) {
11774 S.
Diag(Loc, diag::err_typecheck_assign_const)
11776 << IsNested << Field;
11777 DiagnosticEmitted =
true;
11779 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
11781 << FieldTy << Field->getSourceRange();
11787 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
11788 RecordTypeList.push_back(FieldRecTy);
11791 ++NextToCheckIndex;
11800 assert(Ty->
isRecordType() &&
"lvalue was not record?");
11803 bool DiagEmitted =
false;
11805 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
11808 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11833 unsigned DiagID = 0;
11834 bool NeedType =
false;
11841 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
11843 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
11851 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
11864 ? diag::err_typecheck_arc_assign_self_class_method
11865 : diag::err_typecheck_arc_assign_self;
11868 }
else if (var->
hasAttr<ObjCExternallyRetainedAttr>() ||
11869 isa<ParmVarDecl>(var)) {
11870 DiagID = diag::err_typecheck_arc_assign_externally_retained;
11874 DiagID = diag::err_typecheck_arr_assign_enumeration;
11878 if (Loc != OrigLoc)
11904 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
11908 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
11912 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
11915 llvm_unreachable(
"did not take early return for MLV_Valid");
11919 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
11924 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
11926 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
11929 llvm_unreachable(
"readonly properties should be processed differently");
11931 DiagID = diag::err_readonly_message_assignment;
11934 DiagID = diag::err_no_subobject_property_setting;
11939 if (Loc != OrigLoc)
11964 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase())))
11969 cast<ValueDecl>(MR->getMemberDecl()->getCanonicalDecl());
11970 if (LHSDecl != RHSDecl)
11975 if (RefTy->getPointeeType().isVolatileQualified())
11978 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
11984 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
11987 if (RL && RR && RL->
getDecl() == RR->getDecl())
11988 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
12008 if (getLangOpts().
OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
12010 Diag(Loc, diag::err_opencl_half_load_store) << 1
12016 if (CompoundType.
isNull()) {
12022 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
12026 if (ConvTy == IncompatiblePointer &&
12031 ConvTy = Compatible;
12033 if (ConvTy == Compatible &&
12035 Diag(Loc, diag::err_objc_object_assignment)
12042 RHSCheck = ICE->getSubExpr();
12043 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
12044 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
12045 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
12051 UO->getSubExpr()->getBeginLoc().
isFileID()) {
12052 Diag(Loc, diag::warn_not_compound_assign)
12053 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
12054 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
12058 if (ConvTy == Compatible) {
12066 checkRetainCycles(LHSExpr, RHS.
get());
12080 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
12081 RHS.
get()->getBeginLoc()))
12082 getCurFunction()->markSafeWeakUse(RHS.
get());
12084 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
12085 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
12090 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
12093 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
12094 RHS.
get(), AA_Assigning))
12100 if (CompoundType.
isNull()) {
12105 ExprEvalContexts.back().VolatileAssignmentLHSs.push_back(LHSExpr);
12110 Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
12129 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
12130 if (CE->getCastKind() == CK_ToVoid) {
12136 CE->getSubExpr()->getType()->isDependentType()) {
12153 if (inTemplateInstantiation())
12163 const unsigned ForIncrementFlags =
12164 getLangOpts().C99 || getLangOpts().CPlusPlus
12168 const unsigned ScopeFlags = getCurScope()->getFlags();
12169 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
12170 (ScopeFlags & ForInitFlags) == ForInitFlags)
12175 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
12176 if (BO->getOpcode() != BO_Comma)
12178 LHS = BO->getRHS();
12185 Diag(Loc, diag::warn_comma_operator);
12189 LangOpts.CPlusPlus ?
"static_cast<void>(" 12219 if (!RHS.
get()->getType()->isVoidType())
12221 diag::err_incomplete_type);
12227 return RHS.
get()->getType();
12236 bool IsInc,
bool IsPrefix) {
12245 ResType = ResAtomicType->getValueType();
12247 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
12249 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
12257 : diag::warn_increment_bool)
12259 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
12261 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
12263 }
else if (ResType->isRealType()) {
12265 }
else if (ResType->isPointerType()) {
12269 }
else if (ResType->isObjCObjectPointerType()) {
12275 }
else if (ResType->isAnyComplexType()) {
12277 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
12279 }
else if (ResType->isPlaceholderType()) {
12284 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
12286 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
12287 (ResType->castAs<
VectorType>()->getVectorKind() !=
12290 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
12294 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
12302 if (S.
getLangOpts().CPlusPlus2a && ResType.isVolatileQualified()) {
12305 S.
Diag(OpLoc, diag::warn_deprecated_increment_decrement_volatile)
12306 << IsInc << ResType;
12317 return ResType.getUnqualifiedType();
12336 case Stmt::DeclRefExprClass:
12337 return cast<DeclRefExpr>(E)->getDecl();
12338 case Stmt::MemberExprClass:
12342 if (cast<MemberExpr>(E)->isArrow())
12346 case Stmt::ArraySubscriptExprClass: {
12349 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
12351 if (ICE->getSubExpr()->getType()->isArrayType())
12356 case Stmt::UnaryOperatorClass: {
12368 case Stmt::ParenExprClass:
12370 case Stmt::ImplicitCastExprClass:
12382 AO_Vector_Element = 1,
12383 AO_Property_Expansion = 2,
12384 AO_Register_Variable = 3,
12404 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
12405 if (PTy->getKind() == BuiltinType::Overload) {
12406 Expr *E = OrigOp.
get()->IgnoreParens();
12407 if (!isa<OverloadExpr>(E)) {
12408 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
12409 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
12410 << OrigOp.
get()->getSourceRange();
12415 if (isa<UnresolvedMemberExpr>(Ovl))
12416 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
12417 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
12418 << OrigOp.
get()->getSourceRange();
12425 if (PTy->getKind() == BuiltinType::UnknownAny)
12428 if (PTy->getKind() == BuiltinType::BoundMember) {
12429 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
12430 << OrigOp.
get()->getSourceRange();
12434 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
12438 if (OrigOp.
get()->isTypeDependent())
12441 assert(!OrigOp.
get()->getType()->isPlaceholderType());
12444 Expr *op = OrigOp.
get()->IgnoreParens();
12451 if (LangOpts.OpenCL) {
12453 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
12454 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
12459 if (getLangOpts().
C99) {
12462 if (uOp->getOpcode() == UO_Deref)
12465 return uOp->getSubExpr()->getType();
12472 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
12478 unsigned AddressOfError = AO_No_Error;
12481 bool sfinae = (
bool)isSFINAEContext();
12482 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
12483 : diag::ext_typecheck_addrof_temporary)
12489 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
12490 }
else if (isa<ObjCSelectorExpr>(op)) {
12497 if (!isa<DeclRefExpr>(op)) {
12498 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
12499 << OrigOp.
get()->getSourceRange();
12506 if (OrigOp.
get() != DRE) {
12507 Diag(OpLoc, diag::err_parens_pointer_member_function)
12508 << OrigOp.
get()->getSourceRange();
12512 if (MD->getParent()->getName().empty())
12513 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
12517 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
12518 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
12525 if (isa<CXXDestructorDecl>(MD))
12532 (
void)isCompleteType(OpLoc, MPTy);
12539 if (isa<PseudoObjectExpr>(op)) {
12540 AddressOfError = AO_Property_Expansion;
12542 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
12549 AddressOfError = AO_Bit_Field;
12552 AddressOfError = AO_Vector_Element;
12556 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
12560 !getLangOpts().CPlusPlus) {
12561 AddressOfError = AO_Register_Variable;
12563 }
else if (isa<MSPropertyDecl>(dcl)) {
12564 AddressOfError = AO_Property_Expansion;
12565 }
else if (isa<FunctionTemplateDecl>(dcl)) {
12567 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
12571 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
12576 diag::err_cannot_form_pointer_to_member_of_reference_type)
12581 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
12589 (
void)isCompleteType(OpLoc, MPTy);
12593 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
12594 !isa<BindingDecl>(dcl))
12595 llvm_unreachable(
"Unknown/unexpected decl type");
12598 if (AddressOfError != AO_No_Error) {
12614 CheckAddressOfPackedMember(op);
12630 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
12633 if (!FD->ModifiedNonNullParams.count(Param))
12634 FD->ModifiedNonNullParams.insert(Param);
12644 if (ConvResult.isInvalid())
12646 Op = ConvResult.get();
12650 if (isa<CXXReinterpretCastExpr>(Op)) {
12666 if (PR.
get() != Op)
12671 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
12686 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
12702 default: llvm_unreachable(
"Unknown binop!");
12703 case tok::periodstar: Opc = BO_PtrMemD;
break;
12704 case tok::arrowstar: Opc = BO_PtrMemI;
break;
12705 case tok::star: Opc = BO_Mul;
break;
12706 case tok::slash: Opc = BO_Div;
break;
12707 case tok::percent: Opc = BO_Rem;
break;
12708 case tok::plus: Opc = BO_Add;
break;
12709 case tok::minus: Opc = BO_Sub;
break;
12710 case tok::lessless: Opc = BO_Shl;
break;
12711 case tok::greatergreater: Opc = BO_Shr;
break;
12712 case tok::lessequal: Opc = BO_LE;
break;
12713 case tok::less: Opc = BO_LT;
break;
12714 case tok::greaterequal: Opc = BO_GE;
break;
12715 case tok::greater: Opc = BO_GT;
break;
12716 case tok::exclaimequal: Opc = BO_NE;
break;
12717 case tok::equalequal: Opc = BO_EQ;
break;
12718 case tok::spaceship: Opc = BO_Cmp;
break;
12719 case tok::amp: Opc = BO_And;
break;
12720 case tok::caret: Opc = BO_Xor;
break;
12721 case tok::pipe: Opc = BO_Or;
break;
12722 case tok::ampamp: Opc = BO_LAnd;
break;
12723 case tok::pipepipe: Opc = BO_LOr;
break;
12724 case tok::equal: Opc = BO_Assign;
break;
12725 case tok::starequal: Opc = BO_MulAssign;
break;
12726 case tok::slashequal: Opc = BO_DivAssign;
break;
12727 case tok::percentequal: Opc = BO_RemAssign;
break;
12728 case tok::plusequal: Opc = BO_AddAssign;
break;
12729 case tok::minusequal: Opc = BO_SubAssign;
break;
12730 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
12731 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
12732 case tok::ampequal: Opc = BO_AndAssign;
break;
12733 case tok::caretequal: Opc = BO_XorAssign;
break;
12734 case tok::pipeequal: Opc = BO_OrAssign;
break;
12735 case tok::comma: Opc = BO_Comma;
break;
12744 default: llvm_unreachable(
"Unknown unary op!");
12745 case tok::plusplus: Opc = UO_PreInc;
break;
12746 case tok::minusminus: Opc = UO_PreDec;
break;
12747 case tok::amp: Opc = UO_AddrOf;
break;
12748 case tok::star: Opc = UO_Deref;
break;
12749 case tok::plus: Opc = UO_Plus;
break;
12750 case tok::minus: Opc = UO_Minus;
break;
12751 case tok::tilde: Opc = UO_Not;
break;
12752 case tok::exclaim: Opc = UO_LNot;
break;
12753 case tok::kw___real: Opc = UO_Real;
break;
12754 case tok::kw___imag: Opc = UO_Imag;
break;
12755 case tok::kw___extension__: Opc = UO_Extension;
break;
12774 if (!LHSDeclRef || !RHSDeclRef ||
12776 RHSDeclRef->getLocation().isMacroID())
12781 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
12782 if (LHSDecl != RHSDecl)
12787 if (RefTy->getPointeeType().isVolatileQualified())
12790 S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
12791 : diag::warn_self_assignment_overloaded)
12803 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
12808 ObjCPointerExpr = LHS;
12812 ObjCPointerExpr = RHS;
12820 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
12821 unsigned Diag = diag::warn_objc_pointer_masking;
12830 if (SelArg0.startswith(
"performSelector"))
12831 Diag = diag::warn_objc_pointer_masking_performSelector;
12834 S.
Diag(OpLoc, Diag)
12842 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
12843 return DRE->getDecl();
12844 if (
auto *ME = dyn_cast<MemberExpr>(E))
12845 return ME->getMemberDecl();
12846 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
12847 return IRE->getDecl();
12862 "Result must be a vector of half or short");
12865 "both operands expected to be a half vector");
12877 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
12878 OpLoc, FPFeatures);
12882 VK, OK, OpLoc, FPFeatures);
12886 static std::pair<ExprResult, ExprResult>
12896 if (Opc != BO_Assign)
12903 return std::make_pair(LHS, RHS);
12910 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
12921 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
12933 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
12936 RHSExpr = Init.
get();
12946 bool ConvertHalfVec =
false;
12949 if (!LHS.
isUsable() || !RHS.isUsable())
12952 if (getLangOpts().OpenCL) {
12959 if (BO_Assign == Opc)
12960 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
12962 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12972 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12978 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice) {
12979 if (Opc != BO_Assign && Opc != BO_Comma) {
12980 checkOpenMPDeviceExpr(LHSExpr);
12981 checkOpenMPDeviceExpr(RHSExpr);
12987 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
12988 if (getLangOpts().CPlusPlus &&
12990 VK = LHS.
get()->getValueKind();
12991 OK = LHS.
get()->getObjectKind();
12993 if (!ResultTy.
isNull()) {
12995 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
13010 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
13011 if (
auto *DRE = dyn_cast<DeclRefExpr>(LHS.
get()->IgnoreParens()))
13012 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
13013 if (VD->hasLocalStorage() && getCurScope()->isDeclScope(VD))
13014 BE->getBlockDecl()->setCanAvoidCopyToHeap();
13016 if (LHS.
get()->getType().hasNonTrivialToPrimitiveCopyCUnion())
13017 checkNonTrivialCUnion(LHS.
get()->getType(), LHS.
get()->getExprLoc(),
13018 NTCUC_Assignment, NTCUK_Copy);
13024 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
13025 Opc == BO_PtrMemI);
13029 ConvertHalfVec =
true;
13030 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
13034 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
13037 ConvertHalfVec =
true;
13038 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
13041 ConvertHalfVec =
true;
13042 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
13046 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
13052 ConvertHalfVec =
true;
13053 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
13057 ConvertHalfVec =
true;
13058 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
13061 ConvertHalfVec =
true;
13062 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
13070 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
13074 ConvertHalfVec =
true;
13075 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
13079 ConvertHalfVec =
true;
13080 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
13081 Opc == BO_DivAssign);
13082 CompLHSTy = CompResultTy;
13084 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
13087 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
13088 CompLHSTy = CompResultTy;
13090 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
13093 ConvertHalfVec =
true;
13094 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
13096 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
13099 ConvertHalfVec =
true;
13100 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
13102 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
13106 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
13107 CompLHSTy = CompResultTy;
13109 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
13116 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
13117 CompLHSTy = CompResultTy;
13119 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
13123 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
13124 VK = RHS.get()->getValueKind();
13125 OK = RHS.get()->getObjectKind();
13136 if (
FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
13137 F->setUsesFPIntrin(
true);
13146 "both sides are half vectors or neither sides are");
13148 LHS.
get()->getType());
13151 CheckArrayAccess(LHS.
get());
13152 CheckArrayAccess(RHS.get());
13154 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
13155 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
13156 &Context.
Idents.
get(
"object_setClass"),
13158 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
13159 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
13160 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign)
13162 "object_setClass(")
13168 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
13171 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
13175 if (CompResultTy.
isNull()) {
13176 if (ConvertHalfVec)
13178 OpLoc, FPFeatures);
13180 OK, OpLoc, FPFeatures);
13184 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
13187 OK = LHS.
get()->getObjectKind();
13190 if (ConvertHalfVec)
13192 OpLoc, FPFeatures);
13195 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
13196 OpLoc, FPFeatures);
13211 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
13212 if (isLeftComp == isRightComp)
13217 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
13218 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
13219 if (isLeftBitwise || isRightBitwise)
13225 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
13231 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
13234 Self.
PDiag(diag::note_precedence_silence) << OpStr,
13237 Self.
PDiag(diag::note_precedence_bitwise_first)
13252 Self.
PDiag(diag::note_precedence_silence)
13277 if (Bop->getOpcode() == BO_LAnd) {
13284 }
else if (Bop->getOpcode() == BO_LOr) {
13285 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
13288 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
13299 if (Bop->getOpcode() == BO_LAnd) {
13316 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
13317 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
13319 << Bop->getSourceRange() << OpLoc;
13321 S.
PDiag(diag::note_precedence_silence)
13322 << Bop->getOpcodeStr(),
13323 Bop->getSourceRange());
13331 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
13332 StringRef Op = Bop->getOpcodeStr();
13333 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
13334 << Bop->getSourceRange() << OpLoc << Shift << Op;
13336 S.
PDiag(diag::note_precedence_silence) << Op,
13337 Bop->getSourceRange());
13353 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
13356 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
13358 << (Kind == OO_LessLess);
13360 S.
PDiag(diag::note_precedence_silence)
13361 << (Kind == OO_LessLess ?
"<<" :
">>"),
13364 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
13378 if ((Opc == BO_Or || Opc == BO_Xor) &&
13386 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
13392 || Opc == BO_Shr) {
13409 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
13410 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
13415 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
13444 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
13467 LHSExpr = LHS.
get();
13468 RHSExpr = RHS.
get();
13479 if (pty->getKind() == BuiltinType::PseudoObject &&
13481 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
13484 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
13490 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
13492 RHSExpr = resolvedRHS.
get();
13505 if (Opc == BO_LT && inTemplateInstantiation() &&
13506 (pty->getKind() == BuiltinType::BoundMember ||
13507 pty->getKind() == BuiltinType::Overload)) {
13509 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
13510 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
13511 return isa<FunctionTemplateDecl>(ND);
13513 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
13514 : OE->getNameLoc(),
13515 diag::err_template_kw_missing)
13516 << OE->getName().getAsString() <<
"";
13521 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
13523 LHSExpr = LHS.
get();
13530 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
13531 if (getLangOpts().CPlusPlus &&
13536 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
13540 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
13544 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
13546 RHSExpr = resolvedRHS.
get();
13563 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
13583 bool CanOverflow =
false;
13585 bool ConvertHalfVec =
false;
13586 if (getLangOpts().
OpenCL) {
13594 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13596 << Input.
get()->getSourceRange());
13600 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice) {
13603 checkOpenMPDeviceExpr(InputExpr);
13613 Opc == UO_PreInc ||
13615 Opc == UO_PreInc ||
13620 resultType = CheckAddressOfOperand(Input, OpLoc);
13621 CheckAddressOfNoDeref(InputExpr);
13625 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
13632 CanOverflow = Opc == UO_Minus &&
13634 Input = UsualUnaryConversions(Input.get());
13635 if (Input.isInvalid())
return ExprError();
13644 if (ConvertHalfVec)
13646 resultType = Input.get()->getType();
13647 if (resultType->isDependentType())
13649 if (resultType->isArithmeticType())
13651 else if (resultType->isVectorType() &&
13654 resultType->castAs<
VectorType>()->getVectorKind() !=
13657 else if (getLangOpts().CPlusPlus &&
13659 resultType->isPointerType())
13662 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13663 << resultType << Input.get()->getSourceRange());
13666 Input = UsualUnaryConversions(Input.get());
13667 if (Input.isInvalid())
13669 resultType = Input.
get()->getType();
13670 if (resultType->isDependentType())
13673 if (resultType->isComplexType() || resultType->isComplexIntegerType())
13675 Diag(OpLoc, diag::ext_integer_complement_complex)
13676 << resultType << Input.get()->getSourceRange();
13677 else if (resultType->hasIntegerRepresentation())
13679 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
13684 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13685 << resultType << Input.get()->getSourceRange());
13687 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13688 << resultType << Input.get()->getSourceRange());
13694 Input = DefaultFunctionArrayLvalueConversion(Input.get());
13695 if (Input.isInvalid())
return ExprError();
13696 resultType = Input.
get()->getType();
13699 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
13700 Input = ImpCastExprToType(Input.get(), Context.
FloatTy, CK_FloatingCast).
get();
13701 resultType = Context.
FloatTy;
13704 if (resultType->isDependentType())
13711 Input = ImpCastExprToType(Input.get(), Context.
BoolTy,
13712 ScalarTypeToBooleanCastKind(resultType));
13717 if (!resultType->isIntegerType() && !resultType->isPointerType())
13718 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13719 << resultType << Input.get()->getSourceRange());
13721 }
else if (resultType->isExtVectorType()) {
13729 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13730 << resultType << Input.get()->getSourceRange());
13733 resultType = GetSignedVectorType(resultType);
13738 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13739 << resultType << Input.get()->getSourceRange());
13751 if (Input.isInvalid())
return ExprError();
13752 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
13753 if (Input.get()->getValueKind() !=
VK_RValue &&
13755 VK = Input.
get()->getValueKind();
13758 Input = DefaultLvalueConversion(Input.get());
13762 resultType = Input.get()->getType();
13763 VK = Input.get()->getValueKind();
13764 OK = Input.get()->getObjectKind();
13769 assert(!Input.get()->getType()->isDependentType() &&
13770 "the co_await expression must be non-dependant before " 13771 "building operator co_await");
13781 if (Opc != UO_AddrOf && Opc != UO_Deref)
13782 CheckArrayAccess(Input.
get());
13784 auto *UO =
new (Context)
13787 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
13788 !isa<ArrayType>(UO->getType().getDesugaredType(Context)))
13789 ExprEvalContexts.back().PossibleDerefs.insert(UO);
13792 if (ConvertHalfVec)
13801 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13802 if (!DRE->getQualifier())
13809 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
13812 return Method->isInstance();
13818 if (!ULE->getQualifier())
13823 if (Method->isInstance())
13843 if (pty->getKind() == BuiltinType::PseudoObject &&
13845 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
13848 if (Opc == UO_Extension)
13849 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13853 if (Opc == UO_AddrOf &&
13854 (pty->getKind() == BuiltinType::Overload ||
13855 pty->getKind() == BuiltinType::UnknownAny ||
13856 pty->getKind() == BuiltinType::BoundMember))
13857 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13860 ExprResult Result = CheckPlaceholderExpr(Input);
13862 Input = Result.
get();
13867 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
13875 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
13878 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
13881 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13900 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13907 DiscardCleanupsInEvaluationContext();
13908 PopExpressionEvaluationContext();
13914 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
13917 if (hasAnyUnrecoverableErrorsInThisFunction())
13918 DiscardCleanupsInEvaluationContext();
13919 assert(!Cleanup.exprNeedsCleanups() &&
13920 "cleanups within StmtExpr not correctly bound!");
13921 PopExpressionEvaluationContext();
13930 bool StmtExprMayBindToTemp =
false;
13933 if (
const auto *LastStmt =
13936 StmtExprMayBindToTemp =
true;
13937 Ty =
Value->getType();
13944 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
13945 if (StmtExprMayBindToTemp)
13946 return MaybeBindToTemporary(ResStmtExpr);
13947 return ResStmtExpr;
13956 ER = DefaultFunctionArrayConversion(ER.
get());
13971 if (
Cast &&
Cast->getCastKind() == CK_ARCConsumeObject)
13972 return Cast->getSubExpr();
13975 return PerformCopyInitialization(
13993 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
13994 << ArgTy << TypeRange);
13999 && RequireCompleteType(BuiltinLoc, ArgTy,
14000 diag::err_offsetof_incomplete_type, TypeRange))
14003 bool DidWarnAboutNonPOD =
false;
14008 if (OC.isBrackets) {
14013 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
14019 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
14033 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
14034 Exprs.push_back(Idx);
14042 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
14048 if (RequireCompleteType(OC.LocStart, CurrentType,
14049 diag::err_offsetof_incomplete_type))
14055 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
14067 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
14069 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
14070 : diag::ext_offsetof_non_pod_type;
14072 if (!IsSafe && !DidWarnAboutNonPOD &&
14073 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
14075 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
14077 DidWarnAboutNonPOD =
true;
14081 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
14082 LookupQualifiedName(R, RD);
14087 MemberDecl = IndirectMemberDecl->getAnonField();
14092 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
14100 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
14108 if (IndirectMemberDecl)
14109 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
14114 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
14116 if (Paths.getDetectedVirtual()) {
14117 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
14128 if (IndirectMemberDecl) {
14129 for (
auto *FI : IndirectMemberDecl->chain()) {
14130 assert(isa<FieldDecl>(FI));
14132 cast<FieldDecl>(FI), OC.LocEnd));
14135 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
14141 Comps, Exprs, RParenLoc);
14152 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
14159 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
14167 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
14172 bool ValueDependent =
false;
14173 bool CondIsTrue =
false;
14176 ValueDependent =
true;
14181 = VerifyIntegerConstantExpression(CondExpr, &condEval,
14182 diag::err_typecheck_choose_expr_requires_constant,
false);
14185 CondExpr = CondICE.
get();
14186 CondIsTrue = condEval.getZExtValue();
14189 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
14191 resType = ActiveExpr->
getType();
14197 return new (Context)
14198 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
14210 if (LangOpts.CPlusPlus) {
14212 Decl *ManglingContextDecl;
14213 std::tie(MCtx, ManglingContextDecl) =
14221 PushBlockScope(CurScope, Block);
14222 CurContext->addDecl(Block);
14224 PushDeclContext(CurScope, Block);
14226 CurContext = Block;
14228 getCurBlock()->HasImplicitReturnType =
true;
14232 PushExpressionEvaluationContext(
14233 ExpressionEvaluationContext::PotentiallyEvaluated);
14239 "block-id should have no identifier!");
14243 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
14248 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
14261 "GetTypeForDeclarator made a non-function block signature");
14272 if (ExplicitSignature.getLocalRangeBegin() ==
14273 ExplicitSignature.getLocalRangeEnd()) {
14276 TypeLoc Result = ExplicitSignature.getReturnLoc();
14285 CurBlock->TheDecl->setSignatureAsWritten(Sig);
14286 CurBlock->FunctionType = T;
14291 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
14293 CurBlock->TheDecl->setIsVariadic(isVariadic);
14300 CurBlock->ReturnType = RetTy;
14301 CurBlock->TheDecl->setBlockMissingReturnType(
false);
14302 CurBlock->HasImplicitReturnType =
false;
14307 if (ExplicitSignature) {
14308 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
14309 ParmVarDecl *Param = ExplicitSignature.getParam(I);
14313 !getLangOpts().CPlusPlus)
14315 Params.push_back(Param);
14321 for (
const auto &I : Fn->param_types()) {
14324 Params.push_back(Param);
14329 if (!Params.empty()) {
14330 CurBlock->TheDecl->setParams(Params);
14331 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
14336 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
14339 for (
auto AI : CurBlock->TheDecl->parameters()) {
14340 AI->setOwningFunction(CurBlock->TheDecl);
14343 if (AI->getIdentifier()) {
14344 CheckShadow(CurBlock->TheScope, AI);
14346 PushOnScopeChains(AI, CurBlock->TheScope);
14355 DiscardCleanupsInEvaluationContext();
14356 PopExpressionEvaluationContext();
14360 PopFunctionScopeInfo();
14368 if (!LangOpts.Blocks)
14369 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
14372 if (hasAnyUnrecoverableErrorsInThisFunction())
14373 DiscardCleanupsInEvaluationContext();
14374 assert(!Cleanup.exprNeedsCleanups() &&
14375 "cleanups within block not correctly bound!");
14376 PopExpressionEvaluationContext();
14378 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
14382 deduceClosureReturnType(*BSI);
14388 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
14396 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
14399 if (isa<FunctionNoProtoType>(FTy)) {
14426 DiagnoseUnusedParameters(BD->parameters());
14430 if (getCurFunction()->NeedsScopeChecking() &&
14431 !PP.isCodeCompletionEnabled())
14432 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
14434 BD->setBody(cast<CompoundStmt>(Body));
14436 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
14437 DiagnoseUnguardedAvailabilityViolations(BD);
14443 !BD->isDependentContext())
14444 computeNRVO(Body, BSI);
14448 checkNonTrivialCUnion(RetTy, BD->getCaretLocation(), NTCUC_FunctionReturn,
14449 NTCUK_Destruct|NTCUK_Copy);
14464 Expr *CopyExpr =
nullptr;
14473 if (isa<ParmVarDecl>(Var))
14474 FinalizeVarWithDestructor(Var, Record);
14482 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
14486 ExprResult Result = BuildDeclarationNameExpr(
14493 !Result.
get()->getType().isConstQualified()) {
14494 Result = ImpCastExprToType(Result.
get(),
14495 Result.
get()->getType().withConst(),
14500 Result = PerformCopyInitialization(
14503 Loc, Result.
get());
14510 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
14512 Result = MaybeCreateExprWithCleanups(Result);
14513 CopyExpr = Result.
get();
14520 Captures.push_back(NewCap);
14531 Cleanup.setExprNeedsCleanups(
true);
14536 const VarDecl *var = CI.getVariable();
14538 setFunctionHasBranchProtectedScope();
14544 if (getCurFunction())
14545 getCurFunction()->addBlock(BD);
14553 GetTypeFromParser(Ty, &TInfo);
14554 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
14560 Expr *OrigExpr = E;
14564 if (getLangOpts().
CUDA && getLangOpts().CUDAIsDevice) {
14565 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
14567 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
14573 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
14575 targetDiag(E->
getBeginLoc(), diag::err_va_arg_in_device);
14599 ExprResult Result = UsualUnaryConversions(E);
14603 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
14609 if (Init.isInvalid())
14611 E = Init.getAs<
Expr>();
14625 diag::err_first_argument_to_va_arg_not_of_type_va_list)
14630 diag::err_second_parameter_to_va_arg_incomplete,
14636 diag::err_second_parameter_to_va_arg_abstract,
14643 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
14644 : diag::warn_second_parameter_to_va_arg_not_pod)
14661 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
14668 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
14677 Ty = Context.
IntTy;
14683 llvm_unreachable(
"I don't know size of pointer!");
14692 return BuildSourceLocExpr(Kind, BuiltinLoc, RPLoc, CurContext);
14699 return new (Context)
14700 SourceLocExpr(Context, Kind, BuiltinLoc, RPLoc, ParentContext);
14705 if (!getLangOpts().ObjC)
14724 if (OV->getSourceExpr())
14733 Exp = BuildObjCStringLiteral(SL->
getBeginLoc(), SL).
get();
14739 const Expr *SrcExpr) {
14761 bool *Complained) {
14763 *Complained =
false;
14766 bool CheckInferredResultType =
false;
14768 unsigned DiagKind = 0;
14771 bool MayHaveConvFixit =
false;
14772 bool MayHaveFunctionDiff =
false;
14778 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
14782 DiagKind = diag::ext_typecheck_convert_pointer_int;
14784 MayHaveConvFixit =
true;
14787 DiagKind = diag::ext_typecheck_convert_int_pointer;
14789 MayHaveConvFixit =
true;
14791 case IncompatiblePointer:
14792 if (Action == AA_Passing_CFAudited)
14793 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
14796 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
14798 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
14802 if (Hint.
isNull() && !CheckInferredResultType) {
14805 else if (CheckInferredResultType) {
14809 MayHaveConvFixit =
true;
14811 case IncompatiblePointerSign:
14812 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
14814 case FunctionVoidPointer:
14815 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
14817 case IncompatiblePointerDiscardsQualifiers: {
14824 DiagKind = diag::err_typecheck_incompatible_address_space;
14828 DiagKind = diag::err_typecheck_incompatible_ownership;
14832 llvm_unreachable(
"unknown error case for discarding qualifiers!");
14835 case CompatiblePointerDiscardsQualifiers:
14846 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
14848 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
14850 case IncompatibleNestedPointerQualifiers:
14851 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
14853 case IncompatibleNestedPointerAddressSpaceMismatch:
14854 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
14856 case IntToBlockPointer:
14857 DiagKind = diag::err_int_to_block_pointer;
14859 case IncompatibleBlockPointer:
14860 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
14862 case IncompatibleObjCQualifiedId: {
14866 for (
auto *srcProto : srcOPT->
quals()) {
14872 IFace = IFaceT->getDecl();
14877 for (
auto *dstProto : dstOPT->
quals()) {
14883 IFace = IFaceT->getDecl();
14885 DiagKind = diag::warn_incompatible_qualified_id;
14888 case IncompatibleVectors:
14889 DiagKind = diag::warn_incompatible_vectors;
14891 case IncompatibleObjCWeakRef:
14892 DiagKind = diag::err_arc_weak_unavailable_assign;
14897 *Complained =
true;
14901 DiagKind = diag::err_typecheck_convert_incompatible;
14903 MayHaveConvFixit =
true;
14905 MayHaveFunctionDiff =
true;
14912 case AA_Initializing:
14914 FirstType = DstType;
14915 SecondType = SrcType;
14920 case AA_Passing_CFAudited:
14921 case AA_Converting:
14925 FirstType = SrcType;
14926 SecondType = DstType;
14931 if (Action == AA_Passing_CFAudited)
14932 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
14934 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
14938 if (!ConvHints.
isNull()) {
14944 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
14946 if (MayHaveFunctionDiff)
14947 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
14950 if (DiagKind == diag::warn_incompatible_qualified_id &&
14952 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
14959 if (CheckInferredResultType)
14960 EmitRelatedResultTypeNote(SrcExpr);
14962 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
14963 EmitRelatedResultTypeNoteForReturn(DstType);
14966 *Complained =
true;
14975 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
14979 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
14990 IDDiagnoser(
unsigned DiagID)
14994 S.
Diag(Loc, DiagID) << SR;
14996 } Diagnoser(DiagID);
14998 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
15003 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
15021 CXX11ConvertDiagnoser(
bool Silent)
15027 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
15032 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
15037 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
15048 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
15059 llvm_unreachable(
"conversion functions are permitted");
15061 } ConvertDiagnoser(Diagnoser.
Suppress);
15063 Converted = PerformContextualImplicitConversion(DiagLoc, E,
15067 E = Converted.
get();
15082 if (!isa<ConstantExpr>(E))
15089 EvalResult.
Diag = &Notes;
15097 if (!isa<ConstantExpr>(E))
15103 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
15112 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
15113 diag::note_invalid_subexpr_in_const_expr) {
15114 DiagLoc = Notes[0].first;
15118 if (!Folded || !AllowFold) {
15122 Diag(Note.first, Note.second);
15130 Diag(Note.first, Note.second);
15140 class TransformToPE :
public TreeTransform<TransformToPE> {
15144 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
15147 bool AlwaysRebuild() {
return true; }
15148 bool ReplacingOriginal() {
return true; }
15158 if (isa<FieldDecl>(E->
getDecl()) &&
15161 diag::err_invalid_non_static_member_use)
15164 return BaseTransform::TransformDeclRefExpr(E);
15172 return BaseTransform::TransformUnaryOperator(E);
15180 return SkipLambdaBody(E, Body);
15186 assert(isUnevaluatedContext() &&
15187 "Should only transform unevaluated expressions");
15188 ExprEvalContexts.back().Context =
15189 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
15190 if (isUnevaluatedContext())
15192 return TransformToPE(*this).TransformExpr(E);
15199 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
15200 LambdaContextDecl, ExprContext);
15202 if (!MaybeODRUseExprs.empty())
15203 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
15210 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
15211 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
15218 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
15219 if (E->getOpcode() == UO_Deref)
15220 return CheckPossibleDeref(S, E->getSubExpr());
15221 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
15222 return CheckPossibleDeref(S, E->getBase());
15223 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
15224 return CheckPossibleDeref(S, E->getBase());
15225 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
15231 Inner = Arr->getElementType();
15235 if (Inner->
hasAttr(attr::NoDeref))
15245 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
15252 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
15271 if (BO->getOpcode() == BO_Assign) {
15272 auto &LHSs = ExprEvalContexts.back().VolatileAssignmentLHSs;
15273 LHSs.erase(
std::remove(LHSs.begin(), LHSs.end(), BO->getLHS()),
15292 D = diag::err_lambda_unevaluated_operand;
15298 D = diag::err_lambda_in_constant_expression;
15299 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
15302 D = diag::err_lambda_in_invalid_context;
15304 llvm_unreachable(
"Couldn't infer lambda error message.");
15306 for (
const auto *L : Rec.
Lambdas)
15307 Diag(L->getBeginLoc(), D);
15311 WarnOnPendingNoDerefs(Rec);
15317 Diag(BO->getBeginLoc(), diag::warn_deprecated_simple_assign_volatile)
15326 ExprCleanupObjects.end());
15328 CleanupVarDeclMarking();
15338 ExprEvalContexts.pop_back();
15341 ExprEvalContexts.back().NumTypos += NumTypos;
15345 ExprCleanupObjects.erase(
15346 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
15347 ExprCleanupObjects.end());
15349 MaybeODRUseExprs.clear();
15353 ExprResult Result = CheckPlaceholderExpr(E);
15359 return TransformToPotentiallyEvaluated(E);
15388 llvm_unreachable(
"Invalid context");
15397 if (!TT.isOSWindows() || !TT.isX86())
15435 : FD(FD), Param(Param) {}
15442 CCName =
"stdcall";
15445 CCName =
"fastcall";
15448 CCName =
"vectorcall";
15451 llvm_unreachable(
"CC does not need mangling");
15454 S.
Diag(Loc, diag::err_cconv_incomplete_param_type)
15460 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
15496 Result = OdrUseContext::FormallyOdrUsed;
15502 Result = OdrUseContext::FormallyOdrUsed;
15507 return OdrUseContext::Dependent;
15520 bool MightBeOdrUse) {
15521 assert(Func &&
"No function?");
15527 bool IsRecursiveCall = CurContext == Func;
15539 OdrUse = OdrUseContext::FormallyOdrUsed;
15545 if (
auto *Constructor = dyn_cast<CXXConstructorDecl>(Func))
15546 if (Constructor->isDefaultConstructor())
15547 OdrUse = OdrUseContext::FormallyOdrUsed;
15548 if (isa<CXXDestructorDecl>(Func))
15549 OdrUse = OdrUseContext::FormallyOdrUsed;
15556 bool NeededForConstantEvaluation =
15582 NeededForConstantEvaluation);
15589 if (NeedDefinition &&
15592 checkSpecializationVisibility(Loc, Func);
15594 if (getLangOpts().
CUDA)
15595 CheckCUDACall(Loc, Func);
15598 if (NeedDefinition && !Func->
getBody()) {
15601 dyn_cast<CXXConstructorDecl>(Func)) {
15602 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
15603 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
15604 if (Constructor->isDefaultConstructor()) {
15605 if (Constructor->isTrivial() &&
15606 !Constructor->hasAttr<DLLExportAttr>())
15608 DefineImplicitDefaultConstructor(Loc, Constructor);
15609 }
else if (Constructor->isCopyConstructor()) {
15610 DefineImplicitCopyConstructor(Loc, Constructor);
15611 }
else if (Constructor->isMoveConstructor()) {
15612 DefineImplicitMoveConstructor(Loc, Constructor);
15614 }
else if (Constructor->getInheritedConstructor()) {
15615 DefineInheritingConstructor(Loc, Constructor);
15618 dyn_cast<CXXDestructorDecl>(Func)) {
15619 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
15620 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
15621 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
15623 DefineImplicitDestructor(Loc, Destructor);
15625 if (Destructor->isVirtual() && getLangOpts().AppleKext)
15626 MarkVTableUsed(Loc, Destructor->getParent());
15627 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
15628 if (MethodDecl->isOverloadedOperator() &&
15629 MethodDecl->getOverloadedOperator() == OO_Equal) {
15630 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
15631 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
15632 if (MethodDecl->isCopyAssignmentOperator())
15633 DefineImplicitCopyAssignment(Loc, MethodDecl);
15634 else if (MethodDecl->isMoveAssignmentOperator())
15635 DefineImplicitMoveAssignment(Loc, MethodDecl);
15637 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
15638 MethodDecl->getParent()->isLambda()) {
15640 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
15642 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
15644 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
15645 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
15646 MarkVTableUsed(Loc, MethodDecl->getParent());
15652 DefineDefaultedComparison(Loc, Func, DCK);
15661 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
15662 if (FirstInstantiation) {
15663 PointOfInstantiation = Loc;
15669 PointOfInstantiation = Loc;
15676 CodeSynthesisContexts.size())
15677 PendingLocalImplicitInstantiations.push_back(
15678 std::make_pair(Func, PointOfInstantiation));
15683 InstantiateFunctionDefinition(PointOfInstantiation, Func);
15686 PendingInstantiations.push_back(
15687 std::make_pair(Func, PointOfInstantiation));
15689 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
15694 for (
auto i : Func->
redecls()) {
15695 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
15696 MarkFunctionReferenced(Loc, i, MightBeOdrUse);
15713 ResolveExceptionSpec(Loc, FPT);
15719 if (mightHaveNonExternalLinkage(Func))
15722 !LangOpts.GNUInline &&
15725 else if (isExternalWithNoLinkageType(Func))
15738 if (LangOpts.OpenMP) {
15739 markOpenMPDeclareVariantFuncsReferenced(Loc, Func, MightBeOdrUse);
15740 if (LangOpts.OpenMPIsDevice)
15741 checkOpenMPDeviceFunction(Loc, Func);
15743 checkOpenMPHostFunction(Loc, Func);
15756 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
15767 QualType CaptureType, DeclRefType;
15773 CaptureType, DeclRefType,
15774 FunctionScopeIndexToStopAt);
15781 unsigned CapturingScopeIndex) {
15793 if (isa<ParmVarDecl>(var) &&
15794 isa<TranslationUnitDecl>(VarDC))
15807 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
15809 if (isa<CXXMethodDecl>(VarDC) &&
15810 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
15812 }
else if (isa<FunctionDecl>(VarDC)) {
15814 }
else if (isa<BlockDecl>(VarDC)) {
15818 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
15819 << var << ValueKind << ContextKind << VarDC;
15829 bool &SubCapturesAreNested,
15835 SubCapturesAreNested =
true;
15848 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
15849 !(isa<CapturedRegionScopeInfo>(CSI) &&
15850 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
15861 const bool Diagnose,
Sema &S) {
15876 const bool Diagnose,
Sema &S) {
15878 bool IsBlock = isa<BlockScopeInfo>(CSI);
15879 bool IsLambda = isa<LambdaScopeInfo>(CSI);
15887 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
15896 S.
Diag(Loc, diag::err_ref_vm_type);
15905 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
15908 S.
Diag(Loc, diag::err_ref_flexarray_type);
15910 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
15918 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
15921 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
15923 S.
Diag(Loc, diag::err_capture_block_variable)
15934 S.
Diag(Loc, diag::err_opencl_block_ref_block);
15944 const bool BuildAndDiagnose,
15948 Sema &S,
bool Invalid) {
15949 bool ByRef =
false;
15955 if (BuildAndDiagnose) {
15956 S.
Diag(Loc, diag::err_ref_array_type);
15968 if (BuildAndDiagnose) {
15969 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
15986 if (BuildAndDiagnose) {
15988 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
15989 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
15994 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
16003 DeclRefType = CaptureType;
16007 if (BuildAndDiagnose)
16009 CaptureType, Invalid);
16019 const bool BuildAndDiagnose,
16022 const bool RefersToCapturedVariable,
16023 Sema &S,
bool Invalid) {
16042 CaptureType = DeclRefType;
16045 if (BuildAndDiagnose)
16046 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
16056 const bool BuildAndDiagnose,
16059 const bool RefersToCapturedVariable,
16062 const bool IsTopScope,
16063 Sema &S,
bool Invalid) {
16065 bool ByRef =
false;
16099 if (!RefType->getPointeeType()->isFunctionType())
16106 if (BuildAndDiagnose) {
16107 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
16117 if (!Invalid && BuildAndDiagnose) {
16120 diag::err_capture_of_incomplete_type,
16124 diag::err_capture_of_abstract_type))
16144 if (BuildAndDiagnose)
16145 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
16146 Loc, EllipsisLoc, CaptureType, Invalid);
16154 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
16162 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
16163 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
16166 if (FunctionScopeIndexToStopAt) {
16167 unsigned FSIndex = FunctionScopes.size() - 1;
16168 while (FSIndex != MaxFunctionScopesIndex) {
16177 if (VarDC == DC)
return true;
16183 !(LangOpts.OpenMP && isOpenMPCapturedDecl(Var,
true,
16184 MaxFunctionScopesIndex)))
16196 CaptureType = Var->
getType();
16198 bool Nested =
false;
16199 bool Explicit = (Kind != TryCapture_Implicit);
16200 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
16213 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
16234 if (BuildAndDiagnose) {
16252 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
16253 QTy = PVD->getOriginalType();
16257 if (getLangOpts().OpenMP) {
16258 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
16263 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
16270 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
16271 QTy = PVD->getOriginalType();
16272 for (
int I = 1, E = getNumberOfConstructScopes(RSI->OpenMPLevel);
16274 auto *OuterRSI = cast<CapturedRegionScopeInfo>(
16275 FunctionScopes[FunctionScopesIndex - I]);
16276 assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
16277 "Wrong number of captured regions associated with the " 16278 "OpenMP construct.");
16282 bool IsTargetCap = !IsOpenMPPrivateDecl &&
16283 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
16288 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
16290 if (IsTargetCap || IsOpenMPPrivateDecl) {
16291 Nested = !IsTargetCap;
16302 if (BuildAndDiagnose) {
16306 if (cast<LambdaScopeInfo>(CSI)->Lambda)
16307 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getBeginLoc(),
16308 diag::note_lambda_decl);
16324 FunctionScopesIndex--;
16327 }
while (!VarDC->
Equals(DC));
16334 bool Invalid =
false;
16335 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
16348 if (Invalid && !BuildAndDiagnose)
16352 Invalid = !
captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
16353 DeclRefType, Nested, *
this, Invalid);
16357 CaptureType, DeclRefType, Nested,
16364 DeclRefType, Nested, Kind, EllipsisLoc,
16365 I == N - 1, *
this, Invalid);
16369 if (Invalid && !BuildAndDiagnose)
16379 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
16381 DeclRefType,
nullptr);
16387 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
16388 false, CaptureType,
16389 DeclRefType,
nullptr);
16397 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
16398 false, CaptureType,
16399 DeclRefType,
nullptr))
16402 return DeclRefType;
16410 class CopiedTemplateArgs {
16414 template<
typename RefExpr>
16415 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
16417 E->copyTemplateArgumentsInto(TemplateArgStorage);
16420 #ifdef __has_cpp_attribute
16421 #
if __has_cpp_attribute(clang::lifetimebound)
16422 [[clang::lifetimebound]]
16426 return HasArgs ? &TemplateArgStorage :
nullptr;
16452 auto Rebuild = [&](
Expr *
Sub) {
16457 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
16460 auto *VD = dyn_cast<
VarDecl>(D);
16483 llvm_unreachable(
"unexpected non-odr-use-reason");
16487 if (VD->getType()->isReferenceType())
16489 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
16490 if (RD->hasMutableFields())
16492 if (!VD->isUsableInConstantExpressions(S.
Context))
16497 if (VD->getType()->isReferenceType())
16505 auto MarkNotOdrUsed = [&] {
16508 LSI->markVariableExprAsNonODRUsed(E);
16515 case Expr::DeclRefExprClass: {
16516 auto *DRE = cast<DeclRefExpr>(E);
16517 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
16523 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
16524 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
16525 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
16526 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
16529 case Expr::FunctionParmPackExprClass: {
16530 auto *FPPE = cast<FunctionParmPackExpr>(E);
16534 if (IsPotentialResultOdrUsed(D))
16545 case Expr::ArraySubscriptExprClass: {
16546 auto *ASE = cast<ArraySubscriptExpr>(E);
16548 if (!OldBase->getType()->isArrayType())
16553 Expr *LHS = ASE->getBase() == ASE->getLHS() ? Base.
get() : ASE->getLHS();
16554 Expr *RHS = ASE->getBase() == ASE->getRHS() ? Base.
get() : ASE->getRHS();
16557 ASE->getRBracketLoc());
16560 case Expr::MemberExprClass: {
16561 auto *ME = cast<MemberExpr>(E);
16564 if (isa<FieldDecl>(ME->getMemberDecl())) {
16569 S.
Context, Base.
get(), ME->isArrow(), ME->getOperatorLoc(),
16570 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
16571 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
16572 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
16573 ME->getObjectKind(), ME->isNonOdrUse());
16576 if (ME->getMemberDecl()->isCXXInstanceMember())
16581 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
16587 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
16588 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
16589 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
16590 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
16594 case Expr::BinaryOperatorClass: {
16595 auto *BO = cast<BinaryOperator>(E);
16596 Expr *LHS = BO->getLHS();
16597 Expr *RHS = BO->getRHS();
16599 if (BO->getOpcode() == BO_PtrMemD) {
16605 }
else if (BO->getOpcode() == BO_Comma) {
16613 return S.
BuildBinOp(
nullptr, BO->getOperatorLoc(), BO->getOpcode(),
16618 case Expr::ParenExprClass: {
16619 auto *PE = cast<ParenExpr>(E);
16621 if (!Sub.isUsable())
16623 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
16628 case Expr::ConditionalOperatorClass: {
16629 auto *CO = cast<ConditionalOperator>(E);
16631 if (LHS.isInvalid())
16636 if (!LHS.isUsable() && !RHS.
isUsable())
16638 if (!LHS.isUsable())
16639 LHS = CO->getLHS();
16641 RHS = CO->getRHS();
16643 CO->getCond(), LHS.get(), RHS.
get());
16648 case Expr::UnaryOperatorClass: {
16649 auto *UO = cast<UnaryOperator>(E);
16650 if (UO->getOpcode() != UO_Extension)
16655 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
16662 case Expr::GenericSelectionExprClass: {
16663 auto *GSE = cast<GenericSelectionExpr>(E);
16666 bool AnyChanged =
false;
16667 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
16668 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
16672 AssocExprs.push_back(AssocExpr.
get());
16675 AssocExprs.push_back(OrigAssocExpr);
16680 GSE->getGenericLoc(), GSE->getDefaultLoc(),
16681 GSE->getRParenLoc(), GSE->getControllingExpr(),
16682 GSE->getAssocTypeSourceInfos(), AssocExprs)
16690 case Expr::ChooseExprClass: {
16691 auto *CE = cast<ChooseExpr>(E);
16694 if (LHS.isInvalid())
16701 if (!LHS.get() && !RHS.
get())
16703 if (!LHS.isUsable())
16704 LHS = CE->getLHS();
16706 RHS = CE->getRHS();
16708 return S.
ActOnChooseExpr(CE->getBuiltinLoc(), CE->getCond(), LHS.get(),
16709 RHS.
get(), CE->getRParenLoc());
16713 case Expr::ConstantExprClass: {
16714 auto *CE = cast<ConstantExpr>(E);
16716 if (!Sub.isUsable())
16723 case Expr::ImplicitCastExprClass: {
16724 auto *ICE = cast<ImplicitCastExpr>(E);
16728 switch (ICE->getCastKind()) {
16730 case CK_DerivedToBase:
16731 case CK_UncheckedDerivedToBase: {
16737 ICE->getValueKind(), &Path);
16762 NTCUK_Destruct|NTCUK_Copy);
16774 return Result.
get() ? Result : E;
16778 Res = CorrectDelayedTyposInExpr(Res);
16787 return CheckLValueToRValueConversionOperand(Res.
get());
16794 std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
16796 for (
Expr *E : LocalMaybeODRUseExprs) {
16797 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
16799 DRE->getLocation(), *
this);
16800 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
16803 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
16807 llvm_unreachable(
"Unexpected expression");
16811 assert(MaybeODRUseExprs.empty() &&
16812 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
16817 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E) ||
16818 isa<FunctionParmPackExpr>(E)) &&
16819 "Invalid Expr argument to DoMarkVarDeclReferenced");
16830 bool UsableInConstantExpr =
16838 bool NeededForConstantEvaluation =
16841 bool NeedDefinition =
16846 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
16847 "Can't instantiate a partial template specialization.");
16853 !isa<VarTemplateSpecializationDecl>(Var))
16864 bool TryInstantiating =
16868 if (TryInstantiating) {
16871 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
16872 if (FirstInstantiation) {
16873 PointOfInstantiation = Loc;
16875 MSI->setPointOfInstantiation(PointOfInstantiation);
16880 bool InstantiationDependent =
false;
16881 bool IsNonDependent =
16887 if (IsNonDependent) {
16888 if (UsableInConstantExpr) {
16894 }
else if (FirstInstantiation ||
16895 isa<VarTemplateSpecializationDecl>(Var)) {
16902 .push_back(std::make_pair(Var, PointOfInstantiation));
16927 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
16928 if (DRE->isNonOdrUse())
16930 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
16931 if (ME->isNonOdrUse())
16936 assert((!E || isa<FunctionParmPackExpr>(E)) &&
16937 "missing non-odr-use marking for unevaluated decl ref");
16940 case OdrUseContext::FormallyOdrUsed:
16954 case OdrUseContext::Dependent:
16959 const bool RefersToEnclosingScope =
16962 if (RefersToEnclosingScope) {
16977 assert(E &&
"Capture variable should be used in an expression.");
16995 Decl *D,
Expr *E,
bool MightBeOdrUse) {
16999 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
17015 bool IsVirtualCall = MD->
isVirtual() &&
17017 if (!IsVirtualCall)
17033 bool OdrUse =
true;
17035 if (Method->isVirtual() &&
17036 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
17049 bool MightBeOdrUse =
true;
17052 if (Method->isPure())
17053 MightBeOdrUse =
false;
17071 bool MightBeOdrUse) {
17072 if (MightBeOdrUse) {
17073 if (
auto *VD = dyn_cast<VarDecl>(D)) {
17074 MarkVariableReferenced(Loc, VD);
17078 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
17079 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
17106 bool MarkReferencedDecls::TraverseTemplateArgument(
17120 return Inherited::TraverseTemplateArgument(Arg);
17124 MarkReferencedDecls Marker(*
this, Loc);
17125 Marker.TraverseType(T);
17133 bool SkipLocalVariables;
17138 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
17139 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
17143 if (SkipLocalVariables) {
17145 if (VD->hasLocalStorage())
17154 Inherited::VisitMemberExpr(E);
17169 Inherited::VisitCXXNewExpr(E);
17177 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
17181 Inherited::VisitCXXDeleteExpr(E);
17186 Inherited::VisitCXXConstructExpr(E);
17201 bool SkipLocalVariables) {
17202 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
17223 switch (ExprEvalContexts.back().Context) {
17224 case ExpressionEvaluationContext::Unevaluated:
17225 case ExpressionEvaluationContext::UnevaluatedList:
17226 case ExpressionEvaluationContext::UnevaluatedAbstract:
17227 case ExpressionEvaluationContext::DiscardedStatement:
17231 case ExpressionEvaluationContext::ConstantEvaluated:
17235 case ExpressionEvaluationContext::PotentiallyEvaluated:
17236 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
17237 if (!Stmts.empty() && getCurFunctionOrMethodDecl()) {
17238 FunctionScopes.back()->PossiblyUnreachableDiags.
17248 if (
auto *VD = dyn_cast_or_null<VarDecl>(
17249 ExprEvalContexts.back().ManglingContextDecl)) {
17250 if (VD->isConstexpr() ||
17251 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
17266 return DiagRuntimeBehavior(
17267 Loc, Statement ? llvm::makeArrayRef(Statement) :
llvm::None, PD);
17277 if (ExprEvalContexts.back().ExprContext ==
17278 ExpressionEvaluationContextRecord::EK_Decltype) {
17279 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
17283 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
17289 : FD(FD), CE(CE) { }
17293 S.
Diag(Loc, diag::err_call_incomplete_return)
17298 S.
Diag(Loc, diag::err_call_function_incomplete_return)
17303 } Diagnoser(FD, CE);
17305 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
17316 unsigned diagnostic = diag::warn_condition_is_assignment;
17317 bool IsOrAssign =
false;
17320 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
17323 IsOrAssign = Op->getOpcode() == BO_OrAssign;
17327 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
17331 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
17332 diagnostic = diag::warn_condition_is_idiomatic_assignment;
17336 diagnostic = diag::warn_condition_is_idiomatic_assignment;
17339 Loc = Op->getOperatorLoc();
17341 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
17344 IsOrAssign = Op->getOperator() == OO_PipeEqual;
17345 Loc = Op->getOperatorLoc();
17347 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
17357 Diag(Loc, diag::note_condition_assign_silence)
17362 Diag(Loc, diag::note_condition_or_assign_to_comparison)
17365 Diag(Loc, diag::note_condition_assign_to_comparison)
17383 if (opE->getOpcode() == BO_EQ &&
17384 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
17390 Diag(Loc, diag::note_equality_comparison_silence)
17393 Diag(Loc, diag::note_equality_comparison_to_assign)
17399 bool IsConstexpr) {
17400 DiagnoseAssignmentAsCondition(E);
17401 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
17402 DiagnoseEqualityWithExtraParens(parenE);
17404 ExprResult result = CheckPlaceholderExpr(E);
17409 if (getLangOpts().CPlusPlus)
17410 return CheckCXXBooleanCondition(E, IsConstexpr);
17412 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
17419 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
17437 case ConditionKind::Boolean:
17438 Cond = CheckBooleanCondition(Loc, SubExpr);
17441 case ConditionKind::ConstexprIf:
17442 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
17445 case ConditionKind::Switch:
17446 Cond = CheckSwitchCondition(Loc, SubExpr);
17450 return ConditionError();
17454 if (!FullExpr.
get())
17455 return ConditionError();
17458 CK == ConditionKind::ConstexprIf);
17464 struct RebuildUnknownAnyFunction
17465 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
17469 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
17472 llvm_unreachable(
"unexpected statement!");
17476 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
17483 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
17484 ExprResult SubResult = Visit(E->getSubExpr());
17487 Expr *SubExpr = SubResult.
get();
17488 E->setSubExpr(SubExpr);
17489 E->setType(SubExpr->
getType());
17496 return rebuildSugarExpr(E);
17500 return rebuildSugarExpr(E);
17507 Expr *SubExpr = SubResult.
get();
17516 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
17521 if (S.getLangOpts().CPlusPlus &&
17522 !(isa<CXXMethodDecl>(VD) &&
17523 cast<CXXMethodDecl>(VD)->isInstance()))
17534 return resolveDecl(E, E->
getDecl());
17542 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
17552 struct RebuildUnknownAnyExpr
17553 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
17561 : S(S), DestType(CastType) {}
17564 llvm_unreachable(
"unexpected statement!");
17568 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
17578 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
17579 ExprResult SubResult = Visit(E->getSubExpr());
17581 Expr *SubExpr = SubResult.
get();
17582 E->setSubExpr(SubExpr);
17583 E->setType(SubExpr->
getType());
17590 return rebuildSugarExpr(E);
17594 return rebuildSugarExpr(E);
17632 return resolveDecl(E, E->
getDecl());
17643 FK_FunctionPointer,
17650 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
17651 Kind = FK_MemberFunction;
17655 Kind = FK_FunctionPointer;
17658 Kind = FK_BlockPointer;
17663 if (DestType->isArrayType() || DestType->isFunctionType()) {
17664 unsigned diagID = diag::err_func_returning_array_function;
17665 if (Kind == FK_BlockPointer)
17666 diagID = diag::err_block_returning_array_function;
17669 << DestType->isFunctionType() << DestType;
17702 if (ParamTypes.empty() && Proto->isVariadic()) {
17704 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
17712 ArgTypes.push_back(ArgType);
17714 ParamTypes = ArgTypes;
17717 Proto->getExtProtoInfo());
17725 case FK_MemberFunction:
17729 case FK_FunctionPointer:
17733 case FK_BlockPointer:
17739 ExprResult CalleeResult = Visit(CalleeExpr);
17749 if (DestType->isArrayType() || DestType->isFunctionType()) {
17750 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
17751 << DestType->isFunctionType() << DestType;
17758 Method->setReturnType(DestType);
17762 E->
setType(DestType.getNonReferenceType());
17770 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
17777 DestType = DestType->castAs<
PointerType>()->getPointeeType();
17784 }
else if (E->
getCastKind() == CK_LValueToRValue) {
17788 assert(isa<BlockPointerType>(E->
getType()));
17801 llvm_unreachable(
"Unhandled cast type!");
17834 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
17837 S.
Context, FD->getDeclContext(), Loc, Loc,
17838 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
17839 SC_None,
false , FD->hasPrototype(),
17842 if (FD->getQualifier())
17846 for (
const auto &AI : FT->param_types()) {
17850 Params.push_back(Param);
17852 NewFD->setParams(Params);
17853 DRE->setDecl(NewFD);
17854 VD = DRE->getDecl();
17859 if (MD->isInstance()) {
17869 }
else if (isa<VarDecl>(VD)) {
17873 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
17901 diag::err_typecheck_cast_to_incomplete))
17905 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
17908 CastExpr = result.
get();
17910 CastKind = CK_NoOp;
17916 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
17925 ExprResult result = DefaultArgumentPromotion(arg);
17927 paramType = result.
get()->getType();
17939 return PerformCopyInitialization(entity, callLoc, arg);
17944 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
17947 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
17948 E = call->getCallee();
17949 diagID = diag::err_uncasted_call_of_unknown_any;
17957 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
17958 loc = ref->getLocation();
17959 d = ref->getDecl();
17960 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
17961 loc = mem->getMemberLoc();
17962 d = mem->getMemberDecl();
17964 diagID = diag::err_uncasted_call_of_unknown_any;
17965 loc = msg->getSelectorStartLoc();
17966 d = msg->getMethodDecl();
17968 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
17969 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
17992 ExprResult Result = CorrectDelayedTyposInExpr(E);
17998 if (!placeholderType)
return E;
18000 switch (placeholderType->
getKind()) {
18003 case BuiltinType::Overload: {
18007 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
18013 if (resolveAndFixAddressOfSingleOverloadCandidate(Result))
18017 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
18023 case BuiltinType::BoundMember: {
18028 if (isa<CXXPseudoDestructorExpr>(BME)) {
18029 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
18030 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
18031 if (ME->getMemberNameInfo().getName().getNameKind() ==
18033 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
18035 tryToRecoverWithCall(result, PD,
18041 case BuiltinType::ARCUnbridgedCast: {
18042 Expr *realCast = stripARCUnbridgedCast(E);
18043 diagnoseARCUnbridgedCast(realCast);
18048 case BuiltinType::UnknownAny:
18052 case BuiltinType::PseudoObject:
18053 return checkPseudoObjectRValue(E);
18055 case BuiltinType::BuiltinFn: {
18059 auto *FD = cast<FunctionDecl>(DRE->getDecl());
18060 if (FD->getBuiltinID() == Builtin::BI__noop) {
18062 CK_BuiltinFnToFnPtr)
18074 case BuiltinType::OMPArraySection:
18079 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 18080 case BuiltinType::Id: 18081 #include "clang/Basic/OpenCLImageTypes.def" 18082 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 18083 case BuiltinType::Id: 18084 #include "clang/Basic/OpenCLExtensionTypes.def" 18085 #define SVE_TYPE(Name, Id, SingletonId) \ 18086 case BuiltinType::Id: 18087 #include "clang/Basic/AArch64SVEACLETypes.def" 18088 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 18089 #define PLACEHOLDER_TYPE(Id, SingletonId) 18090 #include "clang/AST/BuiltinTypes.def" 18094 llvm_unreachable(
"invalid placeholder type!");
18108 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
18109 "Unknown Objective-C Boolean value!");
18114 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
18122 return new (Context)
18130 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
18136 VersionTuple Version;
18137 if (Spec != AvailSpecs.end())
18142 if (getCurFunctionOrMethodDecl())
18143 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
18144 else if (getCurBlock() || getCurLambda())
18145 getCurFunction()->HasPotentialAvailabilityViolations =
true;
18147 return new (Context)
18153 return isa<UnresolvedLookupExpr>(E);
Abstract class used to diagnose incomplete types.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
void setTypoName(IdentifierInfo *II)
A call to an overloaded operator written using operator syntax.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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...
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const BlockDecl * getBlockDecl() const
bool hasDefinition() const
Determine whether this class has been defined.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
QualType withConst() const
Retrieves a version of this type with const applied.
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
const CXXDestructorDecl * getDestructor() const
bool isClassMethod() const
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
bool mightBeUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
Represents a function declaration or definition.
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
Expr ** getArgs()
Retrieve the call arguments.
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.
bool Cast(InterpState &S, CodePtr OpPC)
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
SourceRange getCorrectionRange() const
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
IncompatibleNestedPointerAddressSpaceMismatch - The assignment changes address spaces in nested point...
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
bool isSignedOverflowDefined() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
void setKind(UnqualifiedIdKind kind)
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
ExprResult CheckLValueToRValueConversionOperand(Expr *E)
A class which contains all the information about a particular captured value.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
A (possibly-)qualified type.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
bool isBlockPointerType() const
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
Simple class containing the result of Sema::CorrectTypo.
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType)
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
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...
SourceRange getExprRange(Expr *E) const
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
unsigned char getFixedPointScale(QualType Ty) const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool hasCaptures() const
True if this block (or its nested blocks) captures anything of local storage from its enclosing scope...
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc, bool IsBuiltin)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
ObjCInterfaceDecl * getClassInterface()
bool isExternC() const
Determines whether this function is a function with external, C linkage.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
llvm::APSInt getValue() const
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
bool isArithmeticType() const
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
NullabilityKind
Describes the nullability of a particular type.
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
bool isRealFloatingType() const
Floating point categories.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
static bool IsReadonlyMessage(Expr *E, Sema &S)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Defines the SourceManager interface.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
static CharSourceRange getTokenRange(SourceRange R)
void addConst()
Add the const type qualifier to this QualType.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Complex conversions (C99 6.3.1.6)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
bool isRecordType() const
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
bool isEmpty() const
No scope specifier.
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Decl - This represents one declaration (or definition), e.g.
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
bool isVariadic() const
Whether this function prototype is variadic.
StringRef getPlatform() const
FunctionDecl * getOperatorNew() const
bool isExtVectorType() const
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
Defines the C++ template declaration subclasses.
This is a while, do, switch, for, etc that can have break statements embedded into it...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
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...
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
Not a narrowing conversion.
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
bool isCopyCapture() const
ParenExpr - This represents a parethesized expression, e.g.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
bool CheckVecStepExpr(Expr *E)
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
CanQualType ARCUnbridgedCastTy
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
QualType getCorrespondingSignedFixedPointType(QualType Ty) const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
QualType getCorrespondingUnsignedType(QualType T) const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
SourceLocation getEndLoc() const LLVM_READONLY
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
bool isZero() const
isZero - Test whether the quantity equals zero.
QualType withConst() const
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
const TargetInfo & getTargetInfo() const
TemplateNameKind Kind
The kind of template that Template refers to.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
A container of type source information.
QualType getCallResultType() const
Determine the type of an expression that calls this function.
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Floating point control options.
constexpr XRayInstrMask Function
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=CSK_unspecified, Expr *TrailingRequiresClause=nullptr)
MS property subscript expression.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
Wrapper for source info for pointers decayed from arrays and functions.
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
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.
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr *> Args)
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, C99 6.9p3)
size_t param_size() const
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
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 ActOnGNUNullExpr(SourceLocation TokenLoc)
This name appears in an unevaluated operand.
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Retains information about a function, method, or block that is currently being parsed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
This file provides some common utility functions for processing Lambda related AST Constructs...
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
void setRAngleLoc(SourceLocation Loc)
SourceLocation getBeginLoc() const LLVM_READONLY
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
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...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
void removeObjCLifetime()
QualType getReturnType() const
CompoundLiteralExpr - [C99 6.5.2.5].
bool isParamConsumed(unsigned I) const
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
unsigned getNumParams() const
bool isEnumeralType() const
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
APFixedPoint getFixedPointMax(QualType Ty) const
const T * getAs() const
Member-template getAs<specific type>'.
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
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...
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
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 ...
DeclClass * getCorrectionDeclAs() const
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Converts an integer to complex float type.
void ActOnStartStmtExpr()
bool isInvalidDecl() const
bool isOverloaded() const
const Expr * getExprStmt() const
static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
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...
std::vector< FixItHint > Hints
The list of Hints generated so far.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
tok::TokenKind getKind() const
bool isAdditiveOp() const
bool isEqualityOp() const
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
The collection of all-type qualifiers we support.
bool isVariableArrayType() const
tok::TokenKind ContextKind
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
Represents a struct/union/class.
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.
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
bool isOrdinaryOrBitFieldObject() const
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
ExprResult BuildSourceLocExpr(SourceLocExpr::IdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
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.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations. ...
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, QualType SrcType)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
void CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE)
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
A vector component is an element or range of elements on a vector.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
ArrayRef< QualType > getParamTypes() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
SourceLocation getExprLoc() const LLVM_READONLY
ObjCMethodFamily
A family of Objective-C methods.
Used for GCC's __alignof.
FullExpr - Represents a "full-expression" node.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
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...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
field_range fields() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
The current expression is potentially evaluated at run time, which means that code may be generated t...
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
Identity conversion (no conversion)
Stmt * getStmtExprResult()
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Floating point conversions (C++ [conv.double].
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
Token - This structure provides full information about a lexed token.
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, unsigned OpenMPCaptureLevel) const
Return true if the provided declaration VD should be captured by reference.
void setKind(tok::TokenKind K)
A conditional (?:) operator.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
LookupResultKind getResultKind() const
SourceLocation getBeginLoc() const LLVM_READONLY
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.
bool isObjCQualifiedClassType() const
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
void PopExpressionEvaluationContext()
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isAssignmentOp() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
ArrayRef< ParmVarDecl * > parameters() const
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
Values of this type can be null.
bool isUnarySelector() const
The controlling scope in a if/switch/while/for statement.
DeclClass * getAsSingle() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
StringRef getOpcodeStr() const
SourceLocation getOpLoc() const
static unsigned GetFixedPointRank(QualType Ty)
Return the rank of a given fixed point or integer type.
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
Describes an C or C++ initializer list.
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter, check that it is non-null, and that if it is formed by array-to-pointer decay, the underlying array is sufficiently large.
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
bool isThisCapture() const
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
Represents a C++ unqualified-id that has been parsed.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
static QualType checkArithmeticOrEnumeralThreeWayCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
bool isBitField() const
Determines whether this field is a bitfield.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
unsigned getLength() const
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
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...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
FunctionDecl * getOperatorDelete() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
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...
static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
QualType getOriginalType() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool HasFormOfMemberPointer
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
CharUnits - This is an opaque type for sizes expressed in character units.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
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.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
SourceLocation getBeginLoc() const LLVM_READONLY
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
This is a while, do, for, which can have continue statements embedded into it.
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS)
Check for comparisons of floating point operands using != and ==.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
Whether values of this type can be null is (explicitly) unspecified.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, 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...
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...
unsigned toTargetAddressSpace(LangAS AS)
static void checkDirectCallValidity(Sema &S, const Expr *Fn, FunctionDecl *Callee, MultiExprArg ArgExprs)
SourceLocation getBeginLoc() const LLVM_READONLY
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
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...
QualType FunctionType
BlockType - The function type of the block, if one was given.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
CanQualType PseudoObjectTy
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...
LangAS getAddressSpace() const
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
void setTypoNNS(NestedNameSpecifier *NNS)
A narrowing conversion, because a constant expression got narrowed.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Values of this type can never be null.
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
Expr * getSizeExpr() const
Scope - A scope is a transient data structure that is used while parsing the program.
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...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
StringKind
StringLiteral is followed by several trailing objects.
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.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
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...
bool isRelationalOp() const
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
Helper class for OffsetOfExpr.
The current expression occurs within a discarded statement.
Represents an Objective-C protocol declaration.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
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'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
bool isScalarType() const
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
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.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An ordinary object is located at an address in memory.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
MaybeODRUseExprSet MaybeODRUseExprs
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
Represents an ObjC class declaration.
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
QualType getReturnType() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
static bool enclosingClassIsRelatedToClassInWhichMembersWereFound(const UnresolvedMemberExpr *const UME, Sema &S)
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
static OdrUseContext isOdrUseContext(Sema &SemaRef)
Are we within a context in which references to resolved functions or to variables result in odr-use...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
QualType getBOOLType() const
type of 'BOOL' type.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
IdentifierInfo * getIdentifier() const
CanQualType UnsignedCharTy
A default argument (C++ [dcl.fct.default]).
const LangOptions & LangOpts
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool isUnsignedFixedPointType() const
Return true if this is a fixed point type that is unsigned according to ISO/IEC JTC1 SC22 WG14 N1169...
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
static void CheckForNullPointerDereference(Sema &S, Expr *E)
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
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)
void ActOnStmtExprError()
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Qualifiers withoutObjCGCAttr() const
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, Expr *LHS, Expr *RHS)
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 ...
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
DiagnosticsEngine & getDiagnostics() const
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas...
static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)
If D cannot be odr-used in the current expression evaluation context, return a reason explaining why...
OverloadFixItKind Kind
The type of fix applied.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
OpenMP 4.0 [2.4, Array Sections].
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK)
ConditionalOperator - The ?: ternary operator.
QualType getCorrespondingSaturatedType(QualType Ty) const
Sema - This implements semantic analysis and AST building for C.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
static bool ExprLooksBoolean(Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
bool Mutable
Whether this is a mutable lambda.
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
static NamedDecl * getDeclFromExpr(Expr *E)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration...
Retains information about a captured region.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
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...
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getLocalSourceRange() const
Get the local source range.
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr *> Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
static QualType checkConditionalVoidType(Sema &S, ExprResult &LHS, ExprResult &RHS)
Handle when one or both operands are void type.
DeclarationNameTable DeclarationNames
Specifies that the expression should never be value-dependent.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
bool isObjCSelType(QualType T) const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprSet
Store a set of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) t...
SourceLocation getLocation() const
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
Represents a call to the builtin function __builtin_va_arg.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
A narrowing conversion by virtue of the source and destination types.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
bool isSaturatedFixedPointType() const
Return true if this is a saturated fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169...
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr *> Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
std::string getAsString(const LangOptions &LO) const
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
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.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
unsigned getValue() const
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition...
SourceLocation getBeginLoc() const
Get the begin source location.
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, ArithConvKind ACK)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind 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...
Retains information about a block that is currently being parsed.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
QualType getElementType() const
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef)
Are we in a context that is potentially constant evaluated per C++20 [expr.const]p12?
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Represents a character-granular source range.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
ivar_iterator ivar_begin() const
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
static bool EvaluatesAsTrue(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'true'.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool isObjCBuiltinType() const
const T * castAs() const
Member-template castAs<specific type>.
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
ExprResult ActOnStmtExprResult(ExprResult E)
This name appears as a potential result of an lvalue-to-rvalue conversion that is a constant expressi...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
CanQualType OMPArraySectionTy
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
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, lastprivate, reduction etc.) in OpenMP constructs.
std::string getAsString() const
Retrieve the human-readable string for this name.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
bool isNullPtrType() const
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
ObjCLifetime getObjCLifetime() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method...
bool isObjCClassType() const
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
SourceLocation getBeginLoc() const
MaybeODRUseExprSet SavedMaybeODRUseExprs
DeclContext * getDeclContext()
SourceLocation getLParenLoc() const
uint32_t getCodeUnit(size_t i) const
Overload resolution succeeded.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
bool isAnyComplexType() const
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
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.
ObjCInterfaceDecl * getSuperClass() const
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)
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...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
static void diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, ValueDecl *var, DeclContext *DC)
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
Floating-integral conversions (C++ [conv.fpint])
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
void DiscardCleanupsInEvaluationContext()
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
static bool checkForArray(const Expr *E)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isFunctionOrMethod() const
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
Permit vector bitcasts between all vectors with the same total bit-width.
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
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...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
clang::ObjCRuntime ObjCRuntime
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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...
void setAddressSpace(LangAS space)
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, IdentKind IK, StringLiteral *SL)
Create a PredefinedExpr.
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 ...
An expression that sends a message to the given Objective-C object or class.
Data structure that captures multiple levels of template argument lists for use in template instantia...
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Preprocessor & getPreprocessor() const
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void CleanupVarDeclMarking()
const BuiltinType * getAsPlaceholderType() const
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
QualType getDestroyedType() const
Retrieve the type being destroyed.
const Expr * getSubExpr() const
const Expr * getSubExpr() const
unsigned short CapRegionKind
The kind of captured region.
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
void setBlockMangling(unsigned Number, Decl *Ctx)
void removeCVRQualifiers(unsigned mask)
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static std::pair< ExprResult, ExprResult > CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
SourceRange getSourceRange() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
ExprResult ActOnSourceLocExpr(SourceLocExpr::IdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
SourceLocation getEndLoc() const LLVM_READONLY
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing...
bool isSignedFixedPointType() const
Return true if this is a fixed point type that is signed according to ISO/IEC JTC1 SC22 WG14 N1169...
bool isUnresolvableResult() const
static CharSourceRange getCharRange(SourceRange R)
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
ExtInfo withNoReturn(bool noReturn) const
Lvalue-to-rvalue conversion (C++ [conv.lval])
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector...
bool isComparisonOp() const
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...
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse)
static bool isBitwiseOp(Opcode Opc)
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
QualType getWideCharType() const
Return the type of wide characters.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
Wrapper for source info for arrays.
static bool captureInLambda(LambdaScopeInfo *LSI, VarDecl *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.
Expr * IgnoreConversionOperator() LLVM_READONLY
Skip conversion operators.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
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...
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
Integral conversions (C++ [conv.integral])
SmallVectorImpl< OverloadCandidate >::iterator iterator
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
QualType getCanonicalType() const
bool CheckCaseExpression(Expr *E)
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
param_type_range param_types() const
A stack object to be created when performing template instantiation.
ExtParameterInfo getExtParameterInfo(unsigned I) const
VarDecl * getVariable() const
ExtProtoInfo getExtProtoInfo() const
ASTContext & getASTContext() const
Permit no implicit vector bitcasts.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result)
GetFloatValue - Convert this numeric literal to a floating value, using the specified APFloat fltSema...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
SourceLocation getOperatorLoc() const
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
LangAS getAddressSpace() const
Return the address space of this type.
This represents '#pragma omp declare reduction ...' directive.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Expression is not a Null pointer constant.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Expr * getSubExpr() const
Interfaces are the core concept in Objective-C for object oriented design.
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.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * Lambda
The class that describes the lambda.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S, bool Invalid)
Capture the given variable in the captured region.
const ComplexType * getAsComplexIntegerType() const
CastKind getCastKind() const
Rounding to nearest, corresponds to "round.tonearest".
static void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt=nullptr)
Directly mark a variable odr-used.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
SourceLocation getBeginLoc() const
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
ArithConvKind
Context in which we're performing a usual arithmetic conversion.
DeclarationName getName() const
getName - Returns the embedded declaration name.
static bool IgnoreCommaOperand(const Expr *E)
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
QualType getElementType() const
void setReferenced(bool R=true)
Represents the declaration of a label.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
bool isOverloadedResult() const
Determines if the results are overloaded.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
bool isExternalWithNoLinkageType(ValueDecl *VD)
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
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...
void setIdentifierInfo(IdentifierInfo *II)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ExprResult TransformToPotentiallyEvaluated(Expr *E)
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
const ParmVarDecl * getParamDecl(unsigned i) const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Expr * getExpr(unsigned Init)
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
const TemplateArgumentListInfo & getTemplateArgsInfo() 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...
A compound assignment expression.
SourceLocation getBeginLoc() const LLVM_READONLY
Qualifiers withoutObjCLifetime() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
void MarkFunctionParmPackReferenced(FunctionParmPackExpr *E)
Perform reference-marking and odr-use handling for a FunctionParmPackExpr.
This declaration is only a declaration.
is AltiVec 'vector bool ...'
SmallVector< Capture, 4 > Captures
Captures - The captures.
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
void MarkCaptureUsedInEnclosingContext(VarDecl *Capture, SourceLocation Loc, unsigned CapturingScopeIndex)
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
void tryCaptureOpenMPLambdas(ValueDecl *V)
Function tries to capture lambda's captured variables in the OpenMP region before the original lambda...
Represents one property declaration in an Objective-C interface.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
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...
bool hasUninstantiatedDefaultArg() const
virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap.
void addPotentialThisCapture(SourceLocation Loc)
bool isFixedPointOrIntegerType() const
Return true if this is a fixed point or integer type.
TypeClass getTypeClass() const
Used for C's _Alignof and C++'s alignof.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isTargetAddressSpace(LangAS AS)
EnumDecl * getDecl() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
Complex-real conversions (C99 6.3.1.7)
Optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
unsigned getFullDataSize() const
Returns the size of the type source info data block.
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void addArgument(const TemplateArgumentLoc &Loc)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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.
FunctionDecl * getOperatorDelete() const
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Defines the fixed point number interface.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptions FPFeatures)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
CompoundAssignOperator - For compound assignments (e.g.
A POD class for pairing a NamedDecl* with an access specifier.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
VersionTuple getVersion() const
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
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 isMacroDefined(StringRef Id)
Represents an element in a path from a derived class to a base class.
AddrLabelExpr - The GNU address of label extension, representing &&label.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Represents a template argument.
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...
static bool isInvalid(LocType Loc, bool *Invalid)
This name appears as a potential result of a discarded value expression.
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
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 ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
Dataflow Directional Tag Classes.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
bool isValid() const
Return true if this is a valid SourceLocation object.
ExtInfo getExtInfo() const
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
Assume that floating-point exceptions are masked.
static bool isScopedEnumerationType(QualType T)
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
EvalResult is a struct with detailed info about an evaluated expression.
const DeclContext * getCurObjCLexicalContext() const
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
ArrayRef< Capture > captures() const
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
QualType GetSignedVectorType(QualType V)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
typedef char* __builtin_va_list;
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128 and long double if there is no support for such conve...
QualType getType() const
Get the type for which this source info wrapper provides information.
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
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...
Represents a field injected from an anonymous union/struct into the parent scope. ...
The '<=>' operator was used in an expression and a builtin operator was selected. ...
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...
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
Diagnose some forms of syntactically-obvious tautological comparison.
const Expr * getInit() const
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
SourceLocation getEndLoc() const LLVM_READONLY
A runtime availability query.
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.
Array-to-pointer conversion (C++ [conv.array])
This template specialization was instantiated from a template due to an explicit instantiation declar...
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured...
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
const char * getCastKindName() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
const Expr * getExpr() const
bool isBooleanType() const
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type...
OverloadExpr * Expression
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
A set of unresolved declarations.
bool isConstantEvaluated() const
virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR)=0
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
bool InitField(InterpState &S, CodePtr OpPC, uint32_t I)
Expression is a C++11 nullptr.
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.
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
unsigned short OpenMPLevel
ExplicitCastExpr - An explicit cast written in the source code.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS, const ExprResult &XorRHS, const SourceLocation Loc)
ExprResult ActOnConstantExpression(ExprResult Res)
unsigned getLength() const
IdentifierInfo * getCorrectionAsIdentifierInfo() const
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
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.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> Types, ArrayRef< Expr *> Exprs)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored, perform any conversions that are required.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
static QualType handleFixedPointConversion(Sema &S, QualType LHSTy, QualType RHSTy)
handleFixedPointConversion - Fixed point operations between fixed point types and integers or other f...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
CanQualType ObjCBuiltinBoolTy
The standard open() call: int open(const char *path, int oflag, ...);.
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
static bool EvaluatesAsFalse(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'false'.
SourceLocation getBeginLoc() const
unsigned getIntWidth(QualType T) const
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
bool isUnscopedEnumerationType() const
Not an overloaded operator.
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...
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
Expr * getUninstantiatedDefaultArg()
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...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
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"...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
CanQualType UnsignedLongTy
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
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...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
SourceLocation getLocation() const
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
const llvm::APInt & getSize() const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
bool isAtomicType() const
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)
static bool checkThreeWayNarrowingConversion(Sema &S, QualType ToType, Expr *E, QualType FromType, SourceLocation Loc)
bool isFunctionType() const
bool isObjCQualifiedIdType() const
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...
TypeSourceInfo * getTypeSourceInfo() const
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
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...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D)
Diagnoses obvious problems with the use of the given declaration as an expression.
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.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
bool isUnevaluated() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
const Expr * getBase() const
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Determine the kind of template specialization this function represents for the purpose of template in...
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
bool isConstantArrayType() const
bool hasAddressSpace() const
Check if this type has any address space qualifier.
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
A bitfield object is a bitfield on a C or C++ record.
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...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
This is a scope that can contain a declaration.
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
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 isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
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...
QualType withCVRQualifiers(unsigned CVR) const
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool IsDependentFunctionNameExpr(Expr *E)
Check whether the given type-dependent expression will be the name of a function or another callable ...
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void CheckUnusedVolatileAssignment(Expr *E)
Check whether E, which is either a discarded-value expression or an unevaluated operand, is a simple-assignment to a volatlie-qualified lvalue, and if so, remove it from the list of volatile-qualified assignments that we are going to warn are deprecated.
bool isArithmeticOp() const
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
Reading or writing from this object requires a barrier call.
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
ArgKind getKind() const
Return the kind of stored template argument.
QualType getParamType(unsigned i) const
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
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...
Expression is a Null pointer constant built from a literal zero.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E)
Function-to-pointer (C++ [conv.array])
TranslationUnitDecl * getTranslationUnitDecl() const
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr *> ArgExprs)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Data structure used to record current or nested expression evaluation contexts.
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
void setDefaultArg(Expr *defarg)
static bool isObjCObjectLiteral(ExprResult &E)
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
void markUsed(bool IsODRUse)
sema::FunctionScopeInfo * getCurFunction() const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
SourceLocation getBeginLoc() const LLVM_READONLY
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
SourceLocation getRParenLoc() const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ObjCIvarDecl - Represents an ObjC instance variable.
bool isMultiplicativeOp() const
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type...
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
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=None, OverloadCandidateParamOrder PO={})
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Builtin::Context & BuiltinInfo
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr *> Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
SourceManager & getSourceManager() const
A template-id, e.g., f<int>.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, DeclContext *UsedContext)
This represents '#pragma omp declare mapper ...' directive.
void setParameterCFAudited()
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
bool isComplexIntegerType() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static ImplicitConversionKind castKindToImplicitConversionKind(CastKind CK)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber...
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
unsigned getNumElements() const
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The name refers to a variable template whose specialization produces a variable.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static void tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(Sema &S, const UnresolvedMemberExpr *const UME, SourceLocation CallLoc)
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
The class facilities generation and storage of conversion FixIts.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
bool isIncrementDecrementOp() const
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e.g.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
DeclaratorContext getContext() const
bool isStaticDataMember() const
Determines whether this is a static data member.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void setLocation(SourceLocation L)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
bool isFloatingType() const
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A trivial tuple used to represent a source range.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
Expressions appearing as the LHS of a volatile assignment in this context.
Represents a C array with a specified size that is not an integer-constant-expression.
unsigned short OpenMPCaptureLevel
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
No keyword precedes the qualified type name.
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
bool isInline() const
Whether this variable is (C++1z) inline.
AccessControl getAccessControl() const
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parenthese and casts which do not change the value (including ptr->int casts of the sam...
SourceLocation getNameLoc() const
Gets the location of the identifier.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
bool isFunctionPointerType() const
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr *> Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
void setToType(unsigned Idx, QualType T)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr *> Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
void removeAddressSpace()
static void CheckCompleteParameterTypesForMangler(Sema &S, FunctionDecl *FD, SourceLocation Loc)
Require that all of the parameter types of function be complete.
static bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
SourceLocation getBegin() const
SourceLocation ColonLoc
Location of ':'.
const LangOptions & getLangOpts() const
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
void WillReplaceSpecifier(bool ForceReplacement)
static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S, bool Invalid)
bool isBlockCapture() const
An implicit 'self' parameter.
The lookup resulted in an error.
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
Represents the canonical version of C arrays with a specified constant size.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
SourceLocation getBeginLoc() const LLVM_READONLY
ActionResult< Decl * > DeclResult
A class which abstracts out some details necessary for making a call.
bool Sub(InterpState &S, CodePtr OpPC)
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
The current expression occurs within a braced-init-list within an unevaluated operand.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
One specifier in an expression.
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
void startToken()
Reset all flags to cleared.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
bool isExternallyVisible() const
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...
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
QualType getType() const
Return the type wrapped by this type source info.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
ArrayRef< ParmVarDecl * > parameters() const
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
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...
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
CanQualType UnsignedIntTy
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)