47 #include "llvm/Support/ConvertUTF.h" 48 using namespace clang;
55 if (ParsingInitForAutoVars.count(D))
65 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
71 if (TreatUnavailableAsInvalid &&
72 isUnavailableAlignedAllocationFunction(*FD))
86 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
89 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
90 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
92 if (DC && !DC->
hasAttr<UnusedAttr>())
104 if (Method && Method->isDeleted() && Method->isDefaulted()) {
106 if (!Method->isImplicit())
112 if (CSM != CXXInvalid)
113 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
119 if (Ctor && Ctor->isInheritingConstructor())
120 return NoteDeletedInheritingConstructor(Ctor);
130 if (I->getStorageClass() !=
SC_None)
175 if (!DowngradeWarning && UsedFn)
178 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
179 : diag::ext_internal_in_extern_inline)
184 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
194 Diag(DeclBegin, diag::note_convert_inline_to_static)
213 bool ObjCPropertyAccess,
214 bool AvoidPartialAvailabilityChecks,
217 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
221 if (Pos != SuppressedDiagnostics.end()) {
223 Diag(Suppressed.first, Suppressed.second);
234 if (cast<FunctionDecl>(D)->isMain())
235 Diag(Loc, diag::ext_main_used);
237 diagnoseUnavailableAlignedAllocation(*cast<FunctionDecl>(D), Loc);
241 if (ParsingInitForAutoVars.count(D)) {
242 if (isa<BindingDecl>(D)) {
243 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
246 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
247 << D->
getDeclName() << cast<VarDecl>(D)->getType();
254 if (FD->isDeleted()) {
256 if (Ctor && Ctor->isInheritingConstructor())
257 Diag(Loc, diag::err_deleted_inherited_ctor_use)
259 << Ctor->getInheritedConstructor().getConstructor()->getParent();
261 Diag(Loc, diag::err_deleted_function_use);
262 NoteDeletedFunction(FD);
268 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
269 DeduceReturnType(FD, Loc))
272 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
276 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
278 if (MD->getParent()->isLambda() &&
279 ((isa<CXXConstructorDecl>(MD) &&
280 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
281 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
282 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
283 << !isa<CXXConstructorDecl>(MD);
287 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
289 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
294 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
296 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
305 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
307 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
308 << getCurFunction()->HasOMPDeclareReductionCombiner;
318 if (LangOpts.OpenMP && DMD && !CurContext->containsDecl(D) &&
320 Diag(Loc, diag::err_omp_declare_mapper_wrong_var)
321 << DMD->getVarName().getAsString();
326 DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
327 AvoidPartialAvailabilityChecks, ClassReceiver);
342 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
347 unsigned numFormalParams;
351 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
354 numFormalParams = MD->param_size();
355 calleeType = CT_Method;
356 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
357 numFormalParams = FD->param_size();
358 calleeType = CT_Function;
359 }
else if (isa<VarDecl>(D)) {
365 calleeType = CT_Function;
368 calleeType = CT_Block;
374 numFormalParams = proto->getNumParams();
386 unsigned nullPos = attr->getNullPos();
387 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
388 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
391 unsigned numArgsAfterSentinel = attr->getSentinel();
395 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
402 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
403 if (!sentinelExpr)
return;
412 std::string NullValue;
413 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
415 else if (getLangOpts().CPlusPlus11)
416 NullValue =
"nullptr";
417 else if (PP.isMacroDefined(
"NULL"))
420 NullValue =
"(void*) 0";
423 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
425 Diag(MissingNilLoc, diag::warn_missing_sentinel)
449 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
453 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
458 CK_FunctionToPointerDecay).
get();
471 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
473 CK_ArrayToPointerDecay).
get();
485 if (UO->getOpcode() == UO_Deref &&
486 UO->getSubExpr()->IgnoreParenCasts()->
488 !UO->getType().isVolatileQualified()) {
490 S.
PDiag(diag::warn_indirection_through_null)
491 << UO->getSubExpr()->getSourceRange());
493 S.
PDiag(diag::note_indirection_through_null));
506 if (!Member || !Member->
isStr(
"isa"))
516 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
524 if (ObjectSetClass) {
568 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
572 if (getLangOpts().CPlusPlus &&
587 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
596 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
603 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
628 ExprResult Res = CheckLValueToRValueConversionOperand(E);
636 Cleanup.setExprNeedsCleanups(
true);
647 T = Atomic->getValueType().getUnqualifiedType();
656 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
659 Res = DefaultLvalueConversion(Res.
get());
674 CK_FunctionToPointerDecay).
get();
678 Res = DefaultLvalueConversion(Res.
get());
691 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
697 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
700 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
701 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
722 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
727 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
740 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
752 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
753 BTy->
getKind() == BuiltinType::Float)) {
754 if (getLangOpts().OpenCL &&
755 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
756 if (BTy->
getKind() == BuiltinType::Half) {
757 E = ImpCastExprToType(E, Context.
FloatTy, CK_FloatingCast).get();
760 E = ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast).get();
821 if (!Record->hasNonTrivialCopyConstructor() &&
822 !Record->hasNonTrivialMoveConstructor() &&
823 !Record->hasNonTrivialDestructor())
824 return VAK_ValidInCXX11;
832 if (getLangOpts().MSVCCompat)
833 return VAK_MSVCUndefined;
837 return VAK_Undefined;
847 case VAK_ValidInCXX11:
850 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
857 PDiag(diag::warn_pass_class_arg_to_vararg)
858 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
863 case VAK_MSVCUndefined:
865 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
866 << getLangOpts().CPlusPlus11 << Ty << CT);
872 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
876 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
880 << isa<InitListExpr>(E) << Ty << CT;
891 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
892 (CT == VariadicMethod ||
893 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
894 E = stripARCUnbridgedCast(E);
905 ExprResult ExprRes = DefaultArgumentPromotion(E);
912 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
919 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc, Name,
939 diag::err_call_incomplete_argument))
956 if (SkipCast)
return false;
958 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
961 CK_FloatingRealToComplex);
965 CK_IntegralComplexToFloatingComplex);
998 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
999 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
1001 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
1003 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1009 if (!IsCompAssign) {
1016 }
else if (Order > 0) {
1031 bool ConvertFloat,
bool ConvertInt) {
1036 CK_IntegralToFloating);
1047 CK_IntegralComplexToFloatingComplex);
1052 CK_FloatingRealToComplex);
1061 QualType RHSType,
bool IsCompAssign) {
1067 if (LHSFloat && RHSFloat) {
1074 assert(order < 0 &&
"illegal float comparison");
1108 "The remaining types must be floating point types.");
1113 QualType LHSElemType = LHSComplex ?
1114 LHSComplex->getElementType() : LHSType;
1115 QualType RHSElemType = RHSComplex ?
1131 return Float128AndLongDouble &&
1133 &llvm::APFloat::PPCDoubleDouble());
1147 CK_IntegralComplexCast);
1153 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1156 QualType RHSType,
bool IsCompAssign) {
1161 if (LHSSigned == RHSSigned) {
1164 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1166 }
else if (!IsCompAssign)
1167 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1169 }
else if (order != (LHSSigned ? 1 : -1)) {
1173 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1175 }
else if (!IsCompAssign)
1176 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1183 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1185 }
else if (!IsCompAssign)
1186 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1195 RHS = (*doRHSCast)(S, RHS.
get(),
result);
1197 LHS = (*doLHSCast)(S, LHS.
get(),
result);
1207 bool IsCompAssign) {
1211 if (LHSComplexInt && RHSComplexInt) {
1215 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1216 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1218 return S.Context.getComplexType(ScalarType);
1221 if (LHSComplexInt) {
1224 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1225 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1227 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1228 CK_IntegralRealToComplex);
1233 assert(RHSComplexInt);
1237 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1238 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1242 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1243 CK_IntegralRealToComplex);
1252 assert(BTy &&
"Expected a builtin type.");
1254 switch (BTy->getKind()) {
1255 case BuiltinType::ShortFract:
1256 case BuiltinType::UShortFract:
1257 case BuiltinType::SatShortFract:
1258 case BuiltinType::SatUShortFract:
1260 case BuiltinType::Fract:
1261 case BuiltinType::UFract:
1262 case BuiltinType::SatFract:
1263 case BuiltinType::SatUFract:
1265 case BuiltinType::LongFract:
1266 case BuiltinType::ULongFract:
1267 case BuiltinType::SatLongFract:
1268 case BuiltinType::SatULongFract:
1270 case BuiltinType::ShortAccum:
1271 case BuiltinType::UShortAccum:
1272 case BuiltinType::SatShortAccum:
1273 case BuiltinType::SatUShortAccum:
1275 case BuiltinType::Accum:
1276 case BuiltinType::UAccum:
1277 case BuiltinType::SatAccum:
1278 case BuiltinType::SatUAccum:
1280 case BuiltinType::LongAccum:
1281 case BuiltinType::ULongAccum:
1282 case BuiltinType::SatLongAccum:
1283 case BuiltinType::SatULongAccum:
1286 if (BTy->isInteger())
1288 llvm_unreachable(
"Unexpected fixed point or integer type");
1300 "Expected at least one of the operands to be a fixed point type");
1303 "Special fixed point arithmetic operation conversions are only " 1304 "applied to ints or other fixed point types");
1326 QualType ResultTy = LHSTyRank > RHSTyRank ? LHSTy : RHSTy;
1339 bool IsCompAssign) {
1340 if (!IsCompAssign) {
1341 LHS = UsualUnaryConversions(LHS.
get());
1346 RHS = UsualUnaryConversions(RHS.
get());
1359 LHSType = AtomicLHS->getValueType();
1362 if (LHSType == RHSType)
1371 QualType LHSUnpromotedType = LHSType;
1375 if (!LHSBitfieldPromoteTy.
isNull())
1376 LHSType = LHSBitfieldPromoteTy;
1377 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1378 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1381 if (LHSType == RHSType)
1410 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1411 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1423 Expr *ControllingExpr,
1426 unsigned NumAssocs = ArgTypes.size();
1427 assert(NumAssocs == ArgExprs.size());
1430 for (
unsigned i = 0;
i < NumAssocs; ++
i) {
1432 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1437 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1439 llvm::makeArrayRef(Types, NumAssocs),
1449 Expr *ControllingExpr,
1452 unsigned NumAssocs = Types.size();
1453 assert(NumAssocs == Exprs.size());
1460 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1463 ControllingExpr = R.
get();
1468 if (!inTemplateInstantiation() &&
1471 diag::warn_side_effects_unevaluated_context);
1473 bool TypeErrorFound =
false,
1475 ContainsUnexpandedParameterPack
1478 for (
unsigned i = 0;
i < NumAssocs; ++
i) {
1479 if (Exprs[
i]->containsUnexpandedParameterPack())
1480 ContainsUnexpandedParameterPack =
true;
1483 if (Types[i]->getType()->containsUnexpandedParameterPack())
1484 ContainsUnexpandedParameterPack =
true;
1486 if (Types[i]->getType()->isDependentType()) {
1487 IsResultDependent =
true;
1492 if (Types[i]->getType()->isIncompleteType())
1493 D = diag::err_assoc_type_incomplete;
1494 else if (!Types[i]->getType()->isObjectType())
1495 D = diag::err_assoc_type_nonobject;
1496 else if (Types[i]->getType()->isVariablyModifiedType())
1497 D = diag::err_assoc_type_variably_modified;
1500 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1501 << Types[
i]->getTypeLoc().getSourceRange()
1502 << Types[
i]->getType();
1503 TypeErrorFound =
true;
1508 for (
unsigned j = i+1; j < NumAssocs; ++j)
1509 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1511 Types[j]->getType())) {
1512 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1513 diag::err_assoc_compatible_types)
1514 << Types[j]->getTypeLoc().getSourceRange()
1515 << Types[j]->getType()
1516 << Types[
i]->getType();
1517 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1518 diag::note_compat_assoc)
1519 << Types[
i]->getTypeLoc().getSourceRange()
1520 << Types[
i]->getType();
1521 TypeErrorFound =
true;
1531 if (IsResultDependent)
1533 Exprs, DefaultLoc, RParenLoc,
1534 ContainsUnexpandedParameterPack);
1537 unsigned DefaultIndex = -1U;
1538 for (
unsigned i = 0;
i < NumAssocs; ++
i) {
1542 Types[
i]->getType()))
1543 CompatIndices.push_back(i);
1549 if (CompatIndices.size() > 1) {
1553 Diag(ControllingExpr->
getBeginLoc(), diag::err_generic_sel_multi_match)
1555 << (unsigned)CompatIndices.size();
1556 for (
unsigned I : CompatIndices) {
1557 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1558 diag::note_compat_assoc)
1559 << Types[I]->getTypeLoc().getSourceRange()
1560 << Types[I]->getType();
1568 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1582 unsigned ResultIndex =
1583 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1586 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1587 ContainsUnexpandedParameterPack, ResultIndex);
1605 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1608 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1609 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1610 if (ArgTy[ArgIdx]->isArrayType())
1637 assert(!StringToks.empty() &&
"Must have at least one string!");
1640 if (Literal.hadError)
1644 for (
const Token &
Tok : StringToks)
1645 StringTokLocs.push_back(
Tok.getLocation());
1649 if (Literal.isWide()) {
1652 }
else if (Literal.isUTF8()) {
1653 if (getLangOpts().Char8)
1656 }
else if (Literal.isUTF16()) {
1659 }
else if (Literal.isUTF32()) {
1662 }
else if (Literal.isPascal()) {
1668 if (getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus2a &&
1670 Diag(StringTokLocs.front(), diag::warn_cxx2a_compat_utf8_string);
1676 auto RemovalDiag = PDiag(diag::note_cxx2a_compat_utf8_string_remove_u8);
1678 for (
const Token &
Tok : StringToks) {
1679 if (
Tok.getKind() == tok::utf8_string_literal) {
1681 RemovalDiagLoc =
Tok.getLocation();
1685 getSourceManager(), getLangOpts())));
1688 Diag(RemovalDiagLoc, RemovalDiag);
1696 Kind, Literal.Pascal, StrTy,
1698 StringTokLocs.size());
1699 if (Literal.getUDSuffix().empty())
1706 Literal.getUDSuffixOffset());
1710 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1725 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1726 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1732 llvm::APInt Len(Context.
getIntWidth(SizeType), Literal.GetNumStringChars());
1735 Expr *Args[] = { Lit, LenArg };
1737 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1740 case LOLR_StringTemplate: {
1745 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1751 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1757 return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
1762 case LOLR_ErrorNoDiagnostic:
1763 llvm_unreachable(
"unexpected literal operator lookup result");
1767 llvm_unreachable(
"unexpected literal operator lookup result");
1775 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1786 return BuildDeclRefExpr(D, Ty, VK, NameInfo, NNS, FoundD, TemplateKWLoc,
1792 if (isUnevaluatedContext())
1799 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
1800 if (VD->getType()->isReferenceType() &&
1801 !(getLangOpts().OpenMP && isOpenMPCapturedDecl(D)) &&
1802 VD->isUsableInConstantExpressions(Context))
1819 bool RefersToCapturedVariable =
1821 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1824 Context, NNS, TemplateKWLoc, D, RefersToCapturedVariable, NameInfo, Ty,
1825 VK, FoundD, TemplateArgs, getNonOdrUseReasonInCurrentContext(D));
1826 MarkDeclRefReferenced(E);
1828 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1830 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getBeginLoc()))
1831 getCurFunction()->recordUseOfWeak(E);
1835 FD = IFD->getAnonField();
1837 UnusedPrivateFields.remove(FD);
1845 if (
auto *BD = dyn_cast<BindingDecl>(D))
1846 if (
auto *BE = BD->getBinding())
1847 E->setObjectKind(BE->getObjectKind());
1872 translateTemplateArguments(TemplateArgsPtr, Buffer);
1877 TemplateArgs = &Buffer;
1879 NameInfo = GetNameFromUnqualifiedId(Id);
1880 TemplateArgs =
nullptr;
1887 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1894 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1897 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
1902 bool DroppedSpecifier =
1905 ? diag::note_implicit_param_decl
1906 : diag::note_previous_decl;
1909 SemaRef.
PDiag(NoteID));
1912 << Typo << Ctx << DroppedSpecifier
1914 SemaRef.
PDiag(NoteID));
1926 unsigned diagnostic = diag::err_undeclared_var_use;
1927 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1931 diagnostic = diag::err_undeclared_use;
1932 diagnostic_suggest = diag::err_undeclared_use_suggest;
1941 if (isa<CXXRecordDecl>(DC)) {
1942 LookupQualifiedName(R, DC);
1951 bool isDefaultArgument =
1952 !CodeSynthesisContexts.empty() &&
1953 CodeSynthesisContexts.back().Kind ==
1954 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
1956 bool isInstance = CurMethod &&
1958 DC == CurMethod->
getParent() && !isDefaultArgument;
1963 if (getLangOpts().MSVCCompat)
1964 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1975 Diag(D->getLocation(), diag::note_dependent_var_use);
1981 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1982 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1997 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1998 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
2009 assert(!ExplicitTemplateArgs &&
2010 "Diagnosing an empty lookup with explicit template args!");
2011 *Out = CorrectTypoDelayed(
2015 diagnostic, diagnostic_suggest);
2017 nullptr, CTK_ErrorRecovery);
2022 S, &SS, CCC, CTK_ErrorRecovery))) {
2023 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
2024 bool DroppedSpecifier =
2028 bool AcceptableWithRecovery =
false;
2029 bool AcceptableWithoutRecovery =
false;
2038 dyn_cast<FunctionTemplateDecl>(CD))
2039 AddTemplateOverloadCandidate(
2042 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
2043 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
2047 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
2049 ND = Best->FoundDecl;
2050 Corrected.setCorrectionDecl(ND);
2054 Corrected.setCorrectionDecl(ND);
2066 Record = cast<CXXRecordDecl>(
2072 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
2073 isa<FunctionTemplateDecl>(UnderlyingND);
2079 AcceptableWithoutRecovery = isa<TypeDecl>(UnderlyingND) ||
2081 isa<ObjCInterfaceDecl>(UnderlyingND);
2085 AcceptableWithoutRecovery =
true;
2088 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2090 ? diag::note_implicit_param_decl
2091 : diag::note_previous_decl;
2093 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2094 PDiag(NoteID), AcceptableWithRecovery);
2096 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2097 << Name << computeDeclContext(SS,
false)
2098 << DroppedSpecifier << SS.getRange(),
2099 PDiag(NoteID), AcceptableWithRecovery);
2102 return !AcceptableWithRecovery;
2109 if (!SS.isEmpty()) {
2111 << Name << computeDeclContext(SS,
false)
2138 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2146 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2147 DB << NameInfo.
getName() << RD;
2149 if (!ThisType.
isNull()) {
2152 Context,
nullptr, ThisType,
true,
2154 nullptr, NameInfo, TemplateArgs);
2171 bool HasTrailingLParen,
bool IsAddressOfOperand,
2173 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2174 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2175 "cannot be direct & operand and have a trailing lparen");
2184 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2207 bool DependentID =
false;
2211 }
else if (SS.
isSet()) {
2212 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2213 if (RequireCompleteDeclContext(SS, DC))
2221 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2222 IsAddressOfOperand, TemplateArgs);
2227 ? LookupObjCImplicitSelfParam
2228 : LookupOrdinaryName);
2229 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2235 bool MemberOfUnknownSpecialization;
2237 if (LookupTemplateName(R, S, SS,
QualType(),
false,
2238 MemberOfUnknownSpecialization, TemplateKWLoc,
2242 if (MemberOfUnknownSpecialization ||
2244 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2245 IsAddressOfOperand, TemplateArgs);
2247 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2248 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2253 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2254 IsAddressOfOperand, TemplateArgs);
2258 if (IvarLookupFollowUp) {
2259 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2273 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2274 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2280 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2282 if (R.
empty() && !ADL) {
2283 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2285 TemplateKWLoc, TemplateArgs))
2290 if (IsInlineAsmIdentifier)
2300 "Typo correction callback misconfigured");
2310 if (DiagnoseEmptyLookup(S, SS, R, CCC ? *CCC : DefaultValidator,
nullptr,
2312 if (TE && KeywordReplacement) {
2313 auto &
State = getTypoExprState(TE);
2314 auto BestTC =
State.Consumer->getNextCorrection();
2315 if (BestTC.isKeyword()) {
2316 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2317 if (
State.DiagHandler)
2318 State.DiagHandler(BestTC);
2322 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2325 clearDelayedTypo(TE);
2328 return (
Expr*)
nullptr;
2330 State.Consumer->resetCorrectionStream();
2335 assert(!R.
empty() &&
2336 "DiagnoseEmptyLookup returned false but added no results");
2343 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2353 assert(!R.
empty() || ADL);
2379 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2380 bool MightBeImplicitMember;
2381 if (!IsAddressOfOperand)
2382 MightBeImplicitMember =
true;
2384 MightBeImplicitMember =
false;
2386 MightBeImplicitMember =
false;
2388 MightBeImplicitMember =
true;
2390 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2394 if (MightBeImplicitMember)
2395 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2396 R, TemplateArgs, S);
2399 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2407 "There should only be one declaration found.");
2410 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2413 return BuildDeclarationNameExpr(SS, R, ADL);
2428 if (RequireCompleteDeclContext(SS, DC))
2432 LookupQualifiedName(R, DC);
2451 unsigned DiagID = diag::err_typename_missing;
2452 if (RecoveryTSI && getLangOpts().MSVCCompat)
2453 DiagID = diag::ext_typename_missing;
2455 auto D =
Diag(Loc, DiagID);
2486 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2487 return BuildPossibleImplicitMemberExpr(SS,
2491 return BuildDeclarationNameExpr(SS, R,
false);
2525 LookForIvars =
true;
2526 else if (IsClassMethod)
2527 LookForIvars =
false;
2539 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2548 if (DiagnoseUseOfDecl(IV, Loc))
2554 !getLangOpts().DebuggerSupport)
2566 ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc, SelfName,
2572 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2576 MarkAnyDeclReferenced(Loc, IV,
true);
2580 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2588 if (!isUnevaluatedContext() &&
2589 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2590 getCurFunction()->recordUseOfWeak(Result);
2592 if (getLangOpts().ObjCAutoRefCount)
2594 ImplicitlyRetainedSelfLocs.push_back({Loc, BD});
2605 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2612 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2613 << IV->getDeclName());
2616 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2662 bool PointerConversions =
false;
2663 if (isa<FieldDecl>(Member)) {
2667 DestRecordType, FromPtrType
2674 PointerConversions =
true;
2676 DestType = DestRecordType;
2677 FromRecordType = FromType;
2679 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2680 if (Method->isStatic())
2683 DestType = Method->getThisType();
2688 PointerConversions =
true;
2690 FromRecordType = FromType;
2691 DestType = DestRecordType;
2728 if (Qualifier && Qualifier->
getAsType()) {
2730 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2737 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2739 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2740 FromLoc, FromRange, &BasePath))
2743 if (PointerConversions)
2745 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2746 VK, &BasePath).get();
2749 FromRecordType = QRecordType;
2758 bool IgnoreAccess =
false;
2766 assert(isa<UsingShadowDecl>(FoundDecl));
2773 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2775 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2776 FromLoc, FromRange, &BasePath))
2780 if (PointerConversions)
2782 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2783 VK, &BasePath).get();
2785 FromRecordType = URecordType;
2790 IgnoreAccess =
true;
2794 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2795 FromLoc, FromRange, &BasePath,
2799 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2805 bool HasTrailingLParen) {
2807 if (!HasTrailingLParen)
2815 if (!getLangOpts().CPlusPlus)
2825 if (D->isCXXClassMember())
2834 if (isa<UsingShadowDecl>(D))
2835 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2836 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2843 if (isa<FunctionDecl>(D)) {
2849 }
else if (!isa<FunctionTemplateDecl>(D))
2865 if (isa<TypedefNameDecl>(D)) {
2870 if (isa<ObjCInterfaceDecl>(D)) {
2875 if (isa<NamespaceDecl>(D)) {
2889 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
2894 bool AcceptInvalidDecl) {
2934 bool AcceptInvalidDecl) {
2935 assert(D &&
"Cannot refer to a NULL declaration");
2936 assert(!isa<FunctionTemplateDecl>(D) &&
2937 "Cannot refer unambiguously to a function template");
2943 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2946 diagnoseMissingTemplateArguments(
TemplateName(Template), Loc);
2953 Diag(Loc, diag::err_ref_non_value)
2963 if (DiagnoseUseOfDecl(VD, Loc))
2974 if (!indirectField->isCXXClassMember())
2975 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2987 ResolveExceptionSpec(Loc, FPT);
2994 #define ABSTRACT_DECL(kind) 2995 #define VALUE(type, base) 2996 #define DECL(type, base) \ 2998 #include "clang/AST/DeclNodes.inc" 2999 llvm_unreachable(
"invalid value decl kind");
3002 case Decl::ObjCAtDefsField:
3003 llvm_unreachable(
"forming non-member reference to ivar?");
3007 case Decl::EnumConstant:
3008 case Decl::UnresolvedUsingValue:
3009 case Decl::OMPDeclareReduction:
3010 case Decl::OMPDeclareMapper:
3019 case Decl::IndirectField:
3020 case Decl::ObjCIvar:
3022 "building reference to field in C?");
3032 case Decl::NonTypeTemplateParm: {
3047 case Decl::VarTemplateSpecialization:
3048 case Decl::VarTemplatePartialSpecialization:
3049 case Decl::Decomposition:
3050 case Decl::OMPCapturedExpr:
3060 case Decl::ImplicitParam:
3061 case Decl::ParmVar: {
3069 if (!isUnevaluatedContext()) {
3070 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
3071 if (!CapturedType.
isNull())
3072 type = CapturedType;
3078 case Decl::Binding: {
3084 auto *BD = cast<BindingDecl>(VD);
3085 if (BD->getDeclContext() != CurContext) {
3086 auto *DD = dyn_cast_or_null<VarDecl>(BD->getDecomposedDecl());
3087 if (DD && DD->hasLocalStorage())
3094 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3113 if (getLangOpts().CPlusPlus) {
3123 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
3124 isa<FunctionProtoType>(fty))
3133 case Decl::CXXDeductionGuide:
3134 llvm_unreachable(
"building reference to deduction guide");
3136 case Decl::MSProperty:
3140 case Decl::CXXMethod:
3145 = dyn_cast<FunctionProtoType>(VD->
getType()))
3153 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3159 case Decl::CXXConversion:
3160 case Decl::CXXDestructor:
3161 case Decl::CXXConstructor:
3166 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3174 Target.resize(CharByteWidth * (Source.size() + 1));
3175 char *ResultPtr = &Target[0];
3176 const llvm::UTF8 *ErrorPtr;
3178 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3181 Target.resize(ResultPtr - &Target[0]);
3187 Decl *currentDecl =
nullptr;
3189 currentDecl = BSI->TheDecl;
3191 currentDecl = LSI->CallOperator;
3193 currentDecl = CSI->TheCapturedDecl;
3195 currentDecl = getCurFunctionOrMethodDecl();
3198 Diag(Loc, diag::ext_predef_outside_function);
3204 if (cast<DeclContext>(currentDecl)->isDependentContext())
3210 unsigned Length = Str.length();
3212 llvm::APInt LengthI(32, Length + 1);
3239 default: llvm_unreachable(
"Unknown simple primary expr!");
3249 return BuildPredefinedExpr(Loc, IK);
3254 bool Invalid =
false;
3255 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3261 if (Literal.hadError())
3265 if (Literal.isWide())
3267 else if (Literal.isUTF8() && getLangOpts().Char8)
3269 else if (Literal.isUTF16())
3271 else if (Literal.isUTF32())
3273 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3279 if (Literal.isWide())
3281 else if (Literal.isUTF16())
3283 else if (Literal.isUTF32())
3285 else if (Literal.isUTF8())
3291 if (Literal.getUDSuffix().empty())
3301 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3312 Context.
IntTy, Loc);
3319 using llvm::APFloat;
3320 APFloat Val(Format);
3326 if ((result & APFloat::opOverflow) ||
3327 ((result & APFloat::opUnderflow) && Val.isZero())) {
3328 unsigned diagnostic;
3330 if (result & APFloat::opOverflow) {
3331 diagnostic = diag::warn_float_overflow;
3332 APFloat::getLargest(Format).toString(buffer);
3334 diagnostic = diag::warn_float_underflow;
3335 APFloat::getSmallest(Format).toString(buffer);
3338 S.
Diag(Loc, diagnostic)
3340 << StringRef(buffer.data(), buffer.size());
3343 bool isExact = (result == APFloat::opOK);
3348 assert(E &&
"Invalid expression");
3355 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3359 llvm::APSInt ValueAPS;
3360 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3365 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3366 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3367 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3368 << ValueAPS.toString(10) << ValueIsPositive;
3379 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3380 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3388 SpellingBuffer.resize(Tok.
getLength() + 1);
3391 bool Invalid =
false;
3392 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3397 if (Literal.hadError)
3400 if (Literal.hasUDSuffix()) {
3408 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3411 if (Literal.isFloatingLiteral()) {
3432 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3433 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3436 !Literal.isImaginary)) {
3437 case LOLR_ErrorNoDiagnostic:
3445 if (Literal.isFloatingLiteral()) {
3449 if (Literal.GetIntegerValue(ResultVal))
3455 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3462 unsigned Length = Literal.getUDSuffixOffset();
3468 false, StrTy, &TokLoc, 1);
3469 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3472 case LOLR_Template: {
3479 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3480 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3481 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3482 Value = TokSpelling[I];
3487 return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
3490 case LOLR_StringTemplate:
3491 llvm_unreachable(
"unexpected literal operator lookup result");
3497 if (Literal.isFixedPointLiteral()) {
3500 if (Literal.isAccum) {
3501 if (Literal.isHalf) {
3503 }
else if (Literal.isLong) {
3508 }
else if (Literal.isFract) {
3509 if (Literal.isHalf) {
3511 }
else if (Literal.isLong) {
3520 bool isSigned = !Literal.isUnsigned;
3524 llvm::APInt Val(bit_width, 0, isSigned);
3525 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3526 bool ValIsZero = Val.isNullValue() && !Overflowed;
3529 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3535 else if (Val.ugt(MaxVal) || Overflowed)
3540 }
else if (Literal.isFloatingLiteral()) {
3542 if (Literal.isHalf){
3543 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3549 }
else if (Literal.isFloat)
3551 else if (Literal.isLong)
3553 else if (Literal.isFloat16)
3555 else if (Literal.isFloat128)
3563 if (getLangOpts().SinglePrecisionConstants) {
3565 if (BTy->
getKind() != BuiltinType::Float) {
3566 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3568 }
else if (getLangOpts().OpenCL &&
3569 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3572 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3575 }
else if (!Literal.isIntegerLiteral()) {
3581 if (!getLangOpts().
C99 && Literal.isLongLong) {
3584 getLangOpts().CPlusPlus11 ?
3585 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3587 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
3592 llvm::APInt ResultVal(MaxWidth, 0);
3594 if (Literal.GetIntegerValue(ResultVal)) {
3596 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3599 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
3600 "long long is not intmax_t?");
3607 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3613 if (Literal.MicrosoftInteger) {
3614 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3618 Width = Literal.MicrosoftInteger;
3620 !Literal.isUnsigned);
3624 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3629 if (ResultVal.isIntN(IntSize)) {
3631 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3633 else if (AllowUnsigned)
3640 if (Ty.
isNull() && !Literal.isLongLong) {
3644 if (ResultVal.isIntN(LongSize)) {
3646 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3648 else if (AllowUnsigned)
3652 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3653 const unsigned LongLongSize =
3656 getLangOpts().CPlusPlus
3658 ? diag::warn_old_implicitly_unsigned_long_cxx
3660 ext_old_implicitly_unsigned_long_cxx
3661 : diag::warn_old_implicitly_unsigned_long)
3662 << (LongLongSize > LongSize ? 0
3675 if (ResultVal.isIntN(LongLongSize)) {
3679 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3680 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3682 else if (AllowUnsigned)
3684 Width = LongLongSize;
3691 Diag(
Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3696 if (ResultVal.getBitWidth() != Width)
3697 ResultVal = ResultVal.trunc(Width);
3703 if (Literal.isImaginary) {
3707 Diag(
Tok.getLocation(), diag::ext_imaginary_constant);
3713 assert(E &&
"ActOnParenExpr() missing expr");
3714 return new (Context)
ParenExpr(L, R, E);
3725 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3731 "Scalar types should always be complete");
3748 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3749 << TraitKind << ArgRange;
3756 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3757 : diag::ext_sizeof_alignof_void_type;
3758 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3772 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3791 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3827 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3831 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3851 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3859 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3860 QualType OType = PVD->getOriginalType();
3865 Diag(PVD->getLocation(), diag::note_declared_at);
3930 if (RequireCompleteType(OpLoc, ExprType,
3931 diag::err_sizeof_alignof_incomplete_type,
3932 ExprKind, ExprRange))
3936 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3937 << ExprKind << ExprRange;
3956 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3962 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3964 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3965 D = ME->getMemberDecl();
3985 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3988 if (!FD->getParent()->isCompleteDefinition()) {
3989 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3998 if (!FD->getType()->isReferenceType())
4012 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
4018 assert(CSI !=
nullptr);
4024 #define TYPE(Class, Base) 4025 #define ABSTRACT_TYPE(Class, Base) 4026 #define NON_CANONICAL_TYPE(Class, Base) 4027 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 4028 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) 4029 #include "clang/AST/TypeNodes.def" 4036 case Type::ExtVector:
4039 case Type::Elaborated:
4040 case Type::TemplateSpecialization:
4041 case Type::ObjCObject:
4042 case Type::ObjCInterface:
4043 case Type::ObjCObjectPointer:
4044 case Type::ObjCTypeParam:
4046 llvm_unreachable(
"type class is never variably-modified!");
4047 case Type::Adjusted:
4048 T = cast<AdjustedType>(Ty)->getOriginalType();
4051 T = cast<DecayedType>(Ty)->getPointeeType();
4054 T = cast<PointerType>(Ty)->getPointeeType();
4056 case Type::BlockPointer:
4057 T = cast<BlockPointerType>(Ty)->getPointeeType();
4059 case Type::LValueReference:
4060 case Type::RValueReference:
4061 T = cast<ReferenceType>(Ty)->getPointeeType();
4063 case Type::MemberPointer:
4064 T = cast<MemberPointerType>(Ty)->getPointeeType();
4066 case Type::ConstantArray:
4067 case Type::IncompleteArray:
4069 T = cast<ArrayType>(Ty)->getElementType();
4071 case Type::VariableArray: {
4079 (isa<CapturedRegionScopeInfo>(CSI) || isa<LambdaScopeInfo>(CSI)))
4085 case Type::FunctionProto:
4086 case Type::FunctionNoProto:
4087 T = cast<FunctionType>(Ty)->getReturnType();
4091 case Type::UnaryTransform:
4092 case Type::Attributed:
4093 case Type::SubstTemplateTypeParm:
4094 case Type::PackExpansion:
4095 case Type::MacroQualified:
4100 T = cast<TypedefType>(Ty)->desugar();
4102 case Type::Decltype:
4103 T = cast<DecltypeType>(Ty)->desugar();
4106 case Type::DeducedTemplateSpecialization:
4107 T = cast<DeducedType>(Ty)->getDeducedType();
4109 case Type::TypeOfExpr:
4110 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4113 T = cast<AtomicType>(Ty)->getValueType();
4131 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
4136 for (
auto I = FunctionScopes.rbegin(),
4137 E = std::prev(FunctionScopes.rend());
4143 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4144 DC = LSI->CallOperator;
4145 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4146 DC = CRSI->TheCapturedDecl;
4147 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4181 isInvalid = CheckVecStepExpr(E);
4186 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4189 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
4196 PE = TransformToPotentiallyEvaluated(E);
4219 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4223 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4229 if (V.
get()->isTypeDependent())
4241 return CT->getElementType();
4244 if (V.
get()->getType()->isArithmeticType())
4245 return V.
get()->getType();
4250 if (PR.
get() != V.
get()) {
4256 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4257 << (IsReal ?
"__real" :
"__imag");
4268 default: llvm_unreachable(
"Unknown unary op!");
4269 case tok::plusplus: Opc = UO_PostInc;
break;
4270 case tok::minusminus: Opc = UO_PostDec;
break;
4274 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4276 Input = Result.
get();
4278 return BuildUnaryOp(S, OpLoc, Opc, Input);
4289 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4292 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4300 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4302 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4310 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4314 if (isa<ParenListExpr>(base)) {
4317 base = result.
get();
4325 bool IsMSPropertySubscript =
false;
4328 if (!IsMSPropertySubscript) {
4332 base = result.
get();
4356 if (IsMSPropertySubscript) {
4371 if (getLangOpts().CPlusPlus &&
4375 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4378 ExprResult Res = CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4380 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
4381 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
4386 void Sema::CheckAddressOfNoDeref(
const Expr *E) {
4393 while ((Member = dyn_cast<MemberExpr>(StrippedExpr)) && !Member->
isArrow())
4404 if (isa<ArrayType>(ResultTy))
4407 if (ResultTy->
hasAttr(attr::NoDeref)) {
4416 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
4425 if (
const auto *Ptr = dyn_cast<PointerType>(Base->
getType())) {
4426 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
4437 BuiltinType::OMPArraySection)) {
4438 ExprResult Result = CheckPlaceholderExpr(Base);
4441 Base = Result.
get();
4444 ExprResult Result = CheckPlaceholderExpr(LowerBound);
4447 Result = DefaultLvalueConversion(Result.
get());
4450 LowerBound = Result.
get();
4453 ExprResult Result = CheckPlaceholderExpr(Length);
4456 Result = DefaultLvalueConversion(Result.
get());
4459 Length = Result.
get();
4467 return new (Context)
4486 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4488 if (Res.isInvalid())
4490 diag::err_omp_typecheck_section_not_integer)
4492 LowerBound = Res.get();
4501 PerformOpenMPImplicitIntegerConversion(Length->
getExprLoc(), Length);
4502 if (Res.isInvalid())
4504 diag::err_omp_typecheck_section_not_integer)
4524 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4525 diag::err_omp_section_incomplete_type, Base))
4533 llvm::APSInt LowerBoundValue = Result.
Val.
getInt();
4534 if (LowerBoundValue.isNegative()) {
4535 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4547 llvm::APSInt LengthValue = Result.
Val.
getInt();
4548 if (LengthValue.isNegative()) {
4549 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4550 << LengthValue.toString(10,
true)
4555 }
else if (ColonLoc.
isValid() &&
4561 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4567 BuiltinType::OMPArraySection)) {
4568 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
4571 Base = Result.
get();
4573 return new (Context)
4581 Expr *LHSExp = Base;
4590 for (
auto *Op : {LHSExp, RHSExp}) {
4591 Op = Op->IgnoreImplicit();
4592 if (Op->getType()->isArrayType() && !Op->isLValue())
4599 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
4602 LHSExp = Result.
get();
4604 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
4607 RHSExp = Result.
get();
4615 Expr *BaseExpr, *IndexExpr;
4632 if (!LangOpts.isSubscriptPointerArithmetic())
4633 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4648 if (!LangOpts.isSubscriptPointerArithmetic()) {
4649 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4658 ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
4661 LHSExp = Materialized.
get();
4667 ResultType = VTy->getElementType();
4671 Qualifiers Combined = BaseQuals + MemberQuals;
4672 if (Combined != MemberQuals)
4683 CK_ArrayToPointerDecay).
get();
4689 }
else if (RHSTy->isArrayType()) {
4694 CK_ArrayToPointerDecay).
get();
4701 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4706 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4724 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4726 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4733 RequireCompleteType(LLoc, ResultType,
4734 diag::err_subscript_incomplete_type, BaseExpr))
4737 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4741 FunctionScopes.size() > 1) {
4744 for (
auto I = FunctionScopes.rbegin(),
4745 E = std::prev(FunctionScopes.rend());
4751 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4752 DC = LSI->CallOperator;
4753 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4754 DC = CRSI->TheCapturedDecl;
4755 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4767 return new (Context)
4775 diag::err_use_of_default_argument_to_function_declared_later) <<
4777 Diag(UnparsedDefaultArgLocs[Param],
4778 diag::note_default_argument_declared_here);
4786 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4806 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4810 if (Inst.isInvalid())
4812 if (Inst.isAlreadyInstantiating()) {
4813 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4826 Result = SubstInitializer(UninstExpr, MutiLevelArgList,
4841 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4854 L->DefaultArgumentInstantiated(Param);
4860 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4872 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4875 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
4880 assert(!Init->getNumObjects() &&
4881 "default argument expression has capturing blocks?");
4888 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4896 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
4905 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4906 return VariadicConstructor;
4908 return VariadicBlock;
4910 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4911 if (Method->isInstance())
4912 return VariadicMethod;
4914 return VariadicMethod;
4915 return VariadicFunction;
4917 return VariadicDoesNotApply;
4926 FunctionName(FuncName) {}
4928 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4937 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4938 return llvm::make_unique<FunctionCallCCC>(*this);
4953 FunctionCallCCC CCC(S, FuncName.getAsIdentifierInfo(), Args.size(), ME);
4958 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4959 if (Corrected.isOverloaded()) {
4969 ND = Best->FoundDecl;
4970 Corrected.setCorrectionDecl(ND);
4976 ND = ND->getUnderlyingDecl();
4977 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4996 bool IsExecConfig) {
5006 bool Invalid =
false;
5015 if (Args.size() < NumParams) {
5016 if (Args.size() < MinArgs) {
5021 ? diag::err_typecheck_call_too_few_args_suggest
5022 : diag::err_typecheck_call_too_few_args_at_least_suggest;
5023 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
5024 << static_cast<unsigned>(Args.size())
5029 ? diag::err_typecheck_call_too_few_args_one
5030 : diag::err_typecheck_call_too_few_args_at_least_one)
5034 ? diag::err_typecheck_call_too_few_args
5035 : diag::err_typecheck_call_too_few_args_at_least)
5036 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
5040 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5048 "We should have reserved space for the default arguments before!");
5053 if (Args.size() > NumParams) {
5059 ? diag::err_typecheck_call_too_many_args_suggest
5060 : diag::err_typecheck_call_too_many_args_at_most_suggest;
5061 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
5062 << static_cast<unsigned>(Args.size())
5064 }
else if (NumParams == 1 && FDecl &&
5066 Diag(Args[NumParams]->getBeginLoc(),
5067 MinArgs == NumParams
5068 ? diag::err_typecheck_call_too_many_args_one
5069 : diag::err_typecheck_call_too_many_args_at_most_one)
5073 Args.back()->getEndLoc());
5075 Diag(Args[NumParams]->getBeginLoc(),
5076 MinArgs == NumParams
5077 ? diag::err_typecheck_call_too_many_args
5078 : diag::err_typecheck_call_too_many_args_at_most)
5079 << FnKind << NumParams << static_cast<unsigned>(Args.size())
5082 Args.back()->getEndLoc());
5085 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
5096 Invalid = GatherArgumentsForCall(Call->
getBeginLoc(), FDecl, Proto, 0, Args,
5100 unsigned TotalNumArgs = AllArgs.size();
5101 for (
unsigned i = 0;
i < TotalNumArgs; ++
i)
5112 bool IsListInitialization) {
5114 bool Invalid =
false;
5117 for (
unsigned i = FirstParam;
i < NumParams;
i++) {
5122 if (ArgIx < Args.size()) {
5123 Arg = Args[ArgIx++];
5125 if (RequireCompleteType(Arg->
getBeginLoc(), ProtoArgType,
5126 diag::err_call_incomplete_argument, Arg))
5130 bool CFAudited =
false;
5132 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5133 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5134 Arg = stripARCUnbridgedCast(Arg);
5135 else if (getLangOpts().ObjCAutoRefCount &&
5136 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5137 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5142 BE->getBlockDecl()->setDoesNotEscape();
5155 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
5161 assert(Param &&
"can't use default arguments without a known callee");
5163 ExprResult ArgExpr = BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
5173 CheckArrayAccess(Arg);
5176 CheckStaticArrayArgument(CallLoc, Param, Arg);
5178 AllArgs.push_back(Arg);
5182 if (CallType != VariadicDoesNotApply) {
5187 for (
Expr *A : Args.slice(ArgIx)) {
5189 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
5191 AllArgs.push_back(arg.
get());
5196 for (
Expr *A : Args.slice(ArgIx)) {
5197 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
5199 AllArgs.push_back(Arg.
get());
5204 for (
Expr *A : Args.slice(ArgIx))
5205 CheckArrayAccess(A);
5213 TL = DTL.getOriginalLoc();
5216 << ATL.getLocalSourceRange();
5230 const Expr *ArgExpr) {
5257 if (getASTContext().hasSameUnqualifiedType(CAT->
getElementType(),
5260 Diag(CallLoc, diag::warn_static_array_too_small)
5262 << (unsigned)ArgCAT->
getSize().getZExtValue()
5263 << (unsigned)CAT->
getSize().getZExtValue() << 0;
5270 getASTContext().getTypeSizeInCharsIfKnown(ArgCAT);
5272 if (ArgSize && ParmSize && *ArgSize < *ParmSize) {
5273 Diag(CallLoc, diag::warn_static_array_too_small)
5275 << (unsigned)ParmSize->getQuantity() << 1;
5289 if (!placeholder)
return false;
5291 switch (placeholder->
getKind()) {
5293 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 5294 case BuiltinType::Id: 5295 #include "clang/Basic/OpenCLImageTypes.def" 5296 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 5297 case BuiltinType::Id: 5298 #include "clang/Basic/OpenCLExtensionTypes.def" 5299 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 5300 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 5301 #include "clang/AST/BuiltinTypes.def" 5306 case BuiltinType::Overload:
5311 case BuiltinType::ARCUnbridgedCast:
5315 case BuiltinType::PseudoObject:
5320 case BuiltinType::UnknownAny:
5324 case BuiltinType::BoundMember:
5325 case BuiltinType::BuiltinFn:
5326 case BuiltinType::OMPArraySection:
5330 llvm_unreachable(
"bad builtin type kind");
5338 bool hasInvalid =
false;
5339 for (
size_t i = 0, e = args.size();
i != e;
i++) {
5342 if (result.
isInvalid()) hasInvalid =
true;
5343 else args[
i] = result.
get();
5344 }
else if (hasInvalid) {
5373 bool NeedsNewDecl =
false;
5386 if (!ParamType->isPointerType() ||
5387 ParamType.getQualifiers().hasAddressSpace() ||
5390 OverloadParams.push_back(ParamType);
5398 NeedsNewDecl =
true;
5410 OverloadParams, EPI);
5421 FT = cast<FunctionProtoType>(OverloadTy);
5429 Params.push_back(Parm);
5431 OverloadDecl->setParams(Params);
5432 return OverloadDecl;
5450 isa<CXXMethodDecl>(Callee)
5451 ? diag::err_ovl_no_viable_member_function_in_call
5452 : diag::err_ovl_no_viable_function_in_call)
5455 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5456 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5464 const auto GetFunctionLevelDCIfCXXClass =
5472 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5473 return MD->
getParent()->getCanonicalDecl();
5476 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5477 return RD->getCanonicalDecl();
5484 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5485 if (!CurParentClass)
5492 assert(NamingClass &&
"Must have naming class even for implicit access");
5498 return CurParentClass == NamingClass ||
5546 BuildCallExpr(Scope, Fn, LParenLoc, ArgExprs, RParenLoc, ExecConfig);
5552 if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(Fn)) {
5553 if (ULE->hasExplicitTemplateArgs() &&
5554 ULE->decls_begin() == ULE->decls_end()) {
5556 ? diag::warn_cxx17_compat_adl_only_template_id
5557 : diag::ext_adl_only_template_id)
5570 Expr *ExecConfig,
bool IsExecConfig) {
5572 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5581 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5582 if (!ArgExprs.empty()) {
5587 ArgExprs.back()->getEndLoc()));
5604 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5609 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5619 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5629 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5645 return BuildOverloadedCallExpr(
5646 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5648 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5662 bool CallingNDeclIndirectly =
false;
5664 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5665 if (UnOp->getOpcode() == UO_AddrOf) {
5666 CallingNDeclIndirectly =
true;
5671 if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {
5672 NDecl = DRE->getDecl();
5685 nullptr, DRE->isNonOdrUse());
5688 }
else if (isa<MemberExpr>(NakedFn))
5689 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5691 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5696 if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5702 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5703 ExecConfig, IsExecConfig);
5715 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5719 diag::err_invalid_astype_of_different_size)
5723 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5735 GetTypeFromParser(ParsedDestTy, &TInfo);
5736 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5750 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5751 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5754 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5763 if (
auto *Caller = getCurFunctionDecl())
5764 if (Caller->hasAttr<ARMInterruptAttr>()) {
5766 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5767 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5782 Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
5785 Result = CallExprUnaryConversions(Fn);
5786 ResultTy = Context.
BoolTy;
5788 if (Result.isInvalid())
5803 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5818 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5826 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
5827 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
5831 assert(UsesADL == ADLCallKind::NotADL &&
5832 "CUDAKernelCallExpr should not use ADL");
5835 ResultTy,
VK_RValue, RParenLoc, NumParams);
5838 RParenLoc, NumParams, UsesADL);
5849 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5853 bool CorrectedTypos = TheCall != TheOldCall;
5854 if (!TheCall)
return Result;
5861 if (CorrectedTypos && Args.size() < NumParams) {
5864 Context, Fn, cast<CallExpr>(Config), Args, ResultTy,
VK_RValue,
5865 RParenLoc, NumParams);
5868 RParenLoc, NumParams, UsesADL);
5876 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5878 if (getLangOpts().CUDA) {
5881 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5882 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5887 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5891 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5892 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5907 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5911 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5919 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
5920 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5931 for (
unsigned i = 0, e = Args.size();
i != e;
i++) {
5932 Expr *Arg = Args[
i];
5934 if (Proto && i < Proto->getNumParams()) {
5936 Context, Proto->getParamType(
i), Proto->isParamConsumed(
i));
5939 if (ArgE.isInvalid())
5942 Arg = ArgE.getAs<
Expr>();
5945 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5954 diag::err_call_incomplete_argument, Arg))
5961 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5962 if (!Method->isStatic())
5963 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5968 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5972 if (CheckFunctionCall(FDecl, TheCall, Proto))
5975 checkFortifiedBuiltinMemoryFunction(FDecl, TheCall);
5978 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5980 if (CheckPointerCall(NDecl, TheCall, Proto))
5983 if (CheckOtherCall(TheCall, Proto))
5987 return MaybeBindToTemporary(TheCall);
5993 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5994 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5997 QualType literalType = GetTypeFromParser(Ty, &TInfo);
6001 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
6011 diag::err_illegal_decl_array_incomplete_type,
6016 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
6019 RequireCompleteType(LParenLoc, literalType,
6020 diag::err_typecheck_decl_incomplete_type,
6035 LiteralExpr = Result.
get();
6037 bool isFileScope = !CurContext->isFunctionOrMethod();
6058 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
6063 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
6064 for (
unsigned i = 0, j = ILE->getNumInits();
i != j;
i++) {
6065 Expr *Init = ILE->getInit(
i);
6070 VK, LiteralExpr, isFileScope);
6075 if (CheckForConstantInitializer(LiteralExpr, literalType))
6082 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
6093 NTCUC_CompoundLiteral, NTCUK_Destruct);
6097 checkNonTrivialCUnionInInitializer(E->getInitializer(),
6100 return MaybeBindToTemporary(E);
6108 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
6109 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
6116 InitArgList[I] = result.
get();
6131 assert(E.
get()->getType()->isBlockPointerType());
6132 assert(E.
get()->isRValue());
6135 if (!getLangOpts().ObjCAutoRefCount)
return;
6138 CK_ARCExtendBlockObject, E.
get(),
6140 Cleanup.setExprNeedsCleanups(
true);
6150 maybeExtendBlockObject(E);
6151 return CK_BlockPointerToObjCPointerCast;
6154 return CK_CPointerToObjCPointerCast;
6171 llvm_unreachable(
"member pointer type in C");
6180 if (SrcAS != DestAS)
6181 return CK_AddressSpaceConversion;
6188 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
6193 return CK_CPointerToObjCPointerCast;
6194 maybeExtendBlockObject(Src);
6195 return CK_BlockPointerToObjCPointerCast;
6197 return CK_PointerToBoolean;
6199 return CK_PointerToIntegral;
6205 llvm_unreachable(
"illegal cast from pointer");
6207 llvm_unreachable(
"Should have returned before this");
6212 return CK_FixedPointCast;
6214 return CK_FixedPointToBoolean;
6216 return CK_FixedPointToIntegral;
6221 diag::err_unimplemented_conversion_with_fixed_point_type)
6223 return CK_IntegralCast;
6228 llvm_unreachable(
"illegal cast to pointer type");
6230 llvm_unreachable(
"Should have returned before this");
6238 if (Src.
get()->isNullPointerConstant(Context,
6240 return CK_NullToPointer;
6241 return CK_IntegralToPointer;
6243 return CK_IntegralToBoolean;
6245 return CK_IntegralCast;
6247 return CK_IntegralToFloating;
6249 Src = ImpCastExprToType(Src.
get(),
6252 return CK_IntegralRealToComplex;
6254 Src = ImpCastExprToType(Src.
get(),
6256 CK_IntegralToFloating);
6257 return CK_FloatingRealToComplex;
6259 llvm_unreachable(
"member pointer type in C");
6261 return CK_IntegralToFixedPoint;
6263 llvm_unreachable(
"Should have returned before this");
6268 return CK_FloatingCast;
6270 return CK_FloatingToBoolean;
6272 return CK_FloatingToIntegral;
6274 Src = ImpCastExprToType(Src.
get(),
6277 return CK_FloatingRealToComplex;
6279 Src = ImpCastExprToType(Src.
get(),
6281 CK_FloatingToIntegral);
6282 return CK_IntegralRealToComplex;
6286 llvm_unreachable(
"valid float->pointer cast?");
6288 llvm_unreachable(
"member pointer type in C");
6291 diag::err_unimplemented_conversion_with_fixed_point_type)
6293 return CK_IntegralCast;
6295 llvm_unreachable(
"Should have returned before this");
6300 return CK_FloatingComplexCast;
6302 return CK_FloatingComplexToIntegralComplex;
6306 return CK_FloatingComplexToReal;
6307 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
6308 return CK_FloatingCast;
6311 return CK_FloatingComplexToBoolean;
6313 Src = ImpCastExprToType(Src.
get(),
6315 CK_FloatingComplexToReal);
6316 return CK_FloatingToIntegral;
6320 llvm_unreachable(
"valid complex float->pointer cast?");
6322 llvm_unreachable(
"member pointer type in C");
6325 diag::err_unimplemented_conversion_with_fixed_point_type)
6327 return CK_IntegralCast;
6329 llvm_unreachable(
"Should have returned before this");
6334 return CK_IntegralComplexToFloatingComplex;
6336 return CK_IntegralComplexCast;
6340 return CK_IntegralComplexToReal;
6341 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
6342 return CK_IntegralCast;
6345 return CK_IntegralComplexToBoolean;
6347 Src = ImpCastExprToType(Src.
get(),
6349 CK_IntegralComplexToReal);
6350 return CK_IntegralToFloating;
6354 llvm_unreachable(
"valid complex int->pointer cast?");
6356 llvm_unreachable(
"member pointer type in C");
6359 diag::err_unimplemented_conversion_with_fixed_point_type)
6361 return CK_IntegralCast;
6363 llvm_unreachable(
"Should have returned before this");
6366 llvm_unreachable(
"Unhandled scalar cast");
6373 len = vecType->getNumElements();
6374 eltType = vecType->getElementType();
6406 uint64_t srcLen, destLen;
6414 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
6415 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
6417 return (srcLen * srcEltSize == destLen * destEltSize);
6427 return areLaxCompatibleVectorTypes(srcTy, destTy);
6432 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
6435 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
6438 diag::err_invalid_conversion_between_vectors :
6439 diag::err_invalid_conversion_between_vector_and_integer)
6440 << VectorTy << Ty << R;
6443 diag::err_invalid_conversion_between_vector_and_scalar)
6444 << VectorTy << Ty << R;
6453 if (DestElemTy == SplattedExpr->
getType())
6454 return SplattedExpr;
6466 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6467 CK_BooleanToSignedIntegral);
6468 SplattedExpr = CastExprRes.
get();
6469 CK = CK_IntegralToFloating;
6471 CK = CK_BooleanToSignedIntegral;
6475 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6478 SplattedExpr = CastExprRes.
get();
6480 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6493 if (SrcTy->isVectorType()) {
6494 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6495 (getLangOpts().OpenCL &&
6497 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6498 << DestTy << SrcTy << R;
6508 if (SrcTy->isPointerType())
6510 diag::err_invalid_conversion_between_vector_and_scalar)
6511 << DestTy << SrcTy << R;
6513 Kind = CK_VectorSplat;
6514 return prepareVectorSplat(DestTy, CastExpr);
6522 "ActOnCastExpr(): missing type or expr");
6528 if (getLangOpts().CPlusPlus) {
6530 CheckExtraCXXDefaultArguments(D);
6533 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6536 CastExpr = Res.
get();
6539 checkUnusedDeclAttributes(D);
6542 Ty = CreateParsedType(castType, castTInfo);
6544 bool isVectorLiteral =
false;
6550 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6552 if (PLE && PLE->getNumExprs() == 0) {
6553 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6556 if (PE || PLE->getNumExprs() == 1) {
6559 isVectorLiteral =
true;
6562 isVectorLiteral =
true;
6567 if (isVectorLiteral)
6568 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6573 if (isa<ParenListExpr>(CastExpr)) {
6574 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6576 CastExpr = Result.
get();
6580 !getSourceManager().isInSystemMacro(LParenLoc))
6583 CheckTollFreeBridgeCast(castType, CastExpr);
6585 CheckObjCBridgeRelatedCast(castType, CastExpr);
6587 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6589 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6595 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6596 "Expected paren or paren list expression");
6603 LiteralLParenLoc = PE->getLParenLoc();
6604 LiteralRParenLoc = PE->getRParenLoc();
6605 exprs = PE->getExprs();
6606 numExprs = PE->getNumExprs();
6608 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6609 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6610 subExpr = cast<ParenExpr>(E)->getSubExpr();
6630 if (numExprs == 1) {
6632 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6635 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6636 PrepareScalarCast(Literal, ElemTy));
6637 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6639 else if (numExprs < numElems) {
6641 diag::err_incorrect_number_of_vector_initializers);
6645 initExprs.append(exprs, exprs + numExprs);
6650 if (getLangOpts().OpenCL &&
6654 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6657 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6658 PrepareScalarCast(Literal, ElemTy));
6659 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6662 initExprs.append(exprs, exprs + numExprs);
6667 initExprs, LiteralRParenLoc);
6669 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6682 for (
unsigned i = 1, e = E->
getNumExprs();
i != e && !Result.isInvalid(); ++
i)
6683 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6686 if (Result.isInvalid())
return ExprError();
6702 Expr *NullExpr = LHSExpr;
6703 Expr *NonPointerExpr = RHSExpr;
6710 NonPointerExpr = LHSExpr;
6727 if (!findMacroSpelling(loc,
"NULL"))
6732 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6733 << NonPointerExpr->
getType() << DiagType
6744 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6752 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6779 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6803 bool IsBlockPointer =
false;
6807 IsBlockPointer =
true;
6832 ResultAddrSpace = LAddrSpace;
6834 ResultAddrSpace = RAddrSpace;
6836 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6837 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6838 << RHS.
get()->getSourceRange();
6843 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6858 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6860 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6869 if (CompositeTy.
isNull()) {
6886 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6887 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6888 << RHS.
get()->getSourceRange();
6897 QualType ResultTy = [&, ResultAddrSpace]() {
6903 .withCVRQualifiers(MergedCVRQual);
6932 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6933 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6934 << RHS.
get()->getSourceRange();
6985 bool IsIntFirstExpr) {
6987 !Int.
get()->getType()->isIntegerType())
6990 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6991 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6993 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6997 CK_IntegralToPointer);
7031 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
7032 << LHSType << LHS.
get()->getSourceRange();
7037 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
7038 << RHSType << RHS.
get()->getSourceRange();
7043 if (LHSType == RHSType)
7052 return handleIntegerConversion<doIntegralCast, doIntegralCast>
7053 (S, LHS, RHS, LHSType, RHSType,
false);
7087 llvm::raw_svector_ostream OS(Str);
7088 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
7089 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
7090 << CondTy << OS.str();
7111 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
7129 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
7130 << CondTy << VecResTy;
7135 QualType RVE = RV->getElementType();
7138 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
7139 << CondTy << VecResTy;
7163 if (LHS.
get()->getType()->isVectorType() ||
7164 RHS.
get()->getType()->isVectorType()) {
7183 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
7184 QualType Ty = CE->getCallee()->getType();
7210 if (getLangOpts().CPlusPlus)
7211 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
7218 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
7222 Cond = UsualUnaryConversions(Cond.
get());
7229 if (LHS.
get()->getType()->isVectorType() ||
7230 RHS.
get()->getType()->isVectorType())
7231 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
7235 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
7246 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
7247 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7253 if (getLangOpts().OpenCL &&
7261 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
7262 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
7271 if (LHSRT->getDecl() == RHSRT->getDecl())
7290 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
7294 if (!compositeType.
isNull())
7295 return compositeType;
7320 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
7324 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
7325 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7326 << RHS.
get()->getSourceRange();
7342 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7347 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7353 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7358 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7364 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
7369 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
7396 if (!(compositeType =
7414 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
7416 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7418 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
7419 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
7423 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
7424 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
7425 return compositeType;
7429 if (getLangOpts().ObjCAutoRefCount) {
7432 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7433 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7443 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
7445 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
7449 if (getLangOpts().ObjCAutoRefCount) {
7452 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7453 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7463 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7465 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7479 Self.
Diag(Loc, Note)
7484 Self.
Diag(Loc, Note) << ParenRange;
7504 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
7505 E = MTE->GetTemporaryExpr();
7512 *Opcode = OP->getOpcode();
7513 *RHSExprs = OP->getRHS();
7520 if (Call->getNumArgs() != 2)
7526 if (OO < OO_Plus || OO > OO_Arrow ||
7527 OO == OO_PlusPlus || OO == OO_MinusMinus)
7533 *RHSExprs = Call->getArg(1);
7550 return OP->isComparisonOp() || OP->isLogicalOp();
7552 return OP->getOpcode() == UO_LNot;
7581 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7587 Self.
PDiag(diag::note_precedence_silence)
7592 Self.
PDiag(diag::note_precedence_conditional_first),
7603 auto GetNullability = [&Ctx](
QualType Ty) {
7610 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7618 MergedKind = RHSKind;
7625 MergedKind = RHSKind;
7627 MergedKind = LHSKind;
7633 if (GetNullability(ResTy) == MergedKind)
7655 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7656 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7657 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7670 CondExpr = CondResult.
get();
7671 LHSExpr = LHSResult.
get();
7672 RHSExpr = RHSResult.
get();
7678 Expr *commonExpr =
nullptr;
7680 commonExpr = CondExpr;
7687 commonExpr = result.
get();
7698 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7701 commonExpr = commonRes.
get();
7708 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7711 commonExpr = MatExpr.
get();
7719 LHSExpr = CondExpr = opaqueValue;
7725 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7727 VK, OK, QuestionLoc);
7741 return new (Context)
7743 RHS.get(),
result, VK, OK);
7746 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7757 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7758 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7761 const Type *lhptee, *rhptee;
7763 std::tie(lhptee, lhq) =
7764 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7765 std::tie(rhptee, rhq) =
7766 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7792 && (lhptee->isVoidType() || rhptee->isVoidType()))
7807 if (lhptee->isVoidType()) {
7808 if (rhptee->isIncompleteOrObjectType())
7812 assert(rhptee->isFunctionType());
7816 if (rhptee->isVoidType()) {
7817 if (lhptee->isIncompleteOrObjectType())
7821 assert(lhptee->isFunctionType());
7832 if (lhptee->isCharType())
7834 else if (lhptee->hasSignedIntegerRepresentation())
7837 if (rhptee->isCharType())
7839 else if (rhptee->hasSignedIntegerRepresentation())
7842 if (ltrans == rtrans) {
7856 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7858 std::tie(lhptee, lhq) =
7859 cast<PointerType>(lhptee)->getPointeeType().split().asPair();
7860 std::tie(rhptee, rhq) =
7861 cast<PointerType>(rhptee)->getPointeeType().split().asPair();
7874 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7876 if (lhptee == rhptee)
7896 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7897 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7902 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7903 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7912 Qualifiers LQuals = lhptee.getLocalQualifiers();
7913 Qualifiers RQuals = rhptee.getLocalQualifiers();
7918 if (LQuals != RQuals)
7947 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7948 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7989 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7996 return VT->getElementType() == ElementType;
8029 if (LHSType == RHSType) {
8036 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
8038 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
8039 if (result != Compatible)
8041 if (Kind != CK_NoOp && ConvertRHS)
8042 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
8043 Kind = CK_NonAtomicToAtomic;
8056 Kind = CK_LValueBitCast;
8059 return Incompatible;
8066 return Incompatible;
8070 RHS = prepareVectorSplat(LHSType, RHS.
get());
8071 Kind = CK_VectorSplat;
8089 if (isLaxVectorConversion(RHSType, LHSType)) {
8091 return IncompatibleVectors;
8102 isLaxVectorConversion(RHSType, LHSType)) {
8104 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
8110 return Incompatible;
8116 return Incompatible;
8122 return Incompatible;
8128 Kind = PrepareScalarCast(RHS, LHSType);
8133 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
8135 if (isa<PointerType>(RHSType)) {
8136 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
8138 if (AddrSpaceL != AddrSpaceR)
8139 Kind = CK_AddressSpaceConversion;
8149 Kind = CK_IntegralToPointer;
8150 return IntToPointer;
8155 if (isa<ObjCObjectPointerType>(RHSType)) {
8157 if (LHSPointer->getPointeeType()->isVoidType()) {
8171 return IncompatiblePointer;
8176 if (LHSPointer->getPointeeType()->isVoidType()) {
8177 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
8182 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
8187 return Incompatible;
8191 if (isa<BlockPointerType>(LHSType)) {
8200 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
8206 Kind = CK_IntegralToPointer;
8207 return IntToBlockPointer;
8212 Kind = CK_AnyPointerToBlockPointerCast;
8218 if (RHSPT->getPointeeType()->isVoidType()) {
8219 Kind = CK_AnyPointerToBlockPointerCast;
8223 return Incompatible;
8227 if (isa<ObjCObjectPointerType>(LHSType)) {
8233 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8234 result == Compatible &&
8235 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
8236 result = IncompatibleObjCWeakRef;
8242 Kind = CK_IntegralToPointer;
8243 return IntToPointer;
8248 if (isa<PointerType>(RHSType)) {
8249 Kind = CK_CPointerToObjCPointerCast;
8263 return IncompatiblePointer;
8270 maybeExtendBlockObject(RHS);
8271 Kind = CK_BlockPointerToObjCPointerCast;
8275 return Incompatible;
8279 if (isa<PointerType>(RHSType)) {
8281 if (LHSType == Context.
BoolTy) {
8282 Kind = CK_PointerToBoolean;
8288 Kind = CK_PointerToIntegral;
8289 return PointerToInt;
8292 return Incompatible;
8296 if (isa<ObjCObjectPointerType>(RHSType)) {
8298 if (LHSType == Context.
BoolTy) {
8299 Kind = CK_PointerToBoolean;
8305 Kind = CK_PointerToIntegral;
8306 return PointerToInt;
8309 return Incompatible;
8313 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
8321 Kind = CK_IntToOCLSampler;
8325 return Incompatible;
8338 Initializer->
setType(UnionType);
8357 return Incompatible;
8363 for (
auto *it : UD->
fields()) {
8364 if (it->getType()->isPointerType()) {
8370 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
8375 if (RHS.
get()->isNullPointerConstant(Context,
8377 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
8385 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
8387 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
8394 return Incompatible;
8403 bool DiagnoseCFAudited,
8407 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
8413 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
8416 if (
const auto *RHSPtrType = RHS.
get()->getType()->getAs<
PointerType>()) {
8417 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8418 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8420 diag::warn_noderef_to_dereferenceable_pointer)
8421 << RHS.
get()->getSourceRange();
8444 return Incompatible;
8449 return Incompatible;
8451 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8452 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
8453 result = IncompatibleObjCWeakRef;
8465 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
8466 RHS.
get(), LHSType,
false, DAP))
8467 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
8469 return Incompatible;
8476 RHS.
get()->isNullPointerConstant(Context,
8478 if (Diagnose || ConvertRHS) {
8481 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8490 if (LHSType->
isQueueT() && RHS.
get()->isNullPointerConstant(
8492 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
8504 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8506 return Incompatible;
8510 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8518 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8525 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8526 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8527 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8529 return Incompatible;
8531 if (getLangOpts().ObjC &&
8532 (CheckObjCBridgeRelatedConversions(E->
getBeginLoc(), LHSType,
8534 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8536 return Incompatible;
8544 RHS = ImpCastExprToType(E, Ty, Kind);
8554 struct OriginalOperand {
8555 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
8556 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
8557 Op = MTE->GetTemporaryExpr();
8558 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
8559 Op = BTE->getSubExpr();
8560 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
8561 Orig = ICE->getSubExprAsWritten();
8562 Conversion = ICE->getConversionFunction();
8566 QualType getType()
const {
return Orig->getType(); }
8575 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
8577 Diag(Loc, diag::err_typecheck_invalid_operands)
8578 << OrigLHS.getType() << OrigRHS.getType()
8579 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8583 if (OrigLHS.Conversion) {
8584 Diag(OrigLHS.Conversion->getLocation(),
8585 diag::note_typecheck_invalid_operands_converted)
8586 << 0 << LHS.
get()->getType();
8588 if (OrigRHS.Conversion) {
8589 Diag(OrigRHS.Conversion->getLocation(),
8590 diag::note_typecheck_invalid_operands_converted)
8591 << 1 << RHS.
get()->getType();
8602 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8603 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8608 if (!(LHSNatVec && RHSNatVec)) {
8609 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8610 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8611 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8617 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8618 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8619 << RHS.
get()->getSourceRange();
8649 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8654 scalarCast = CK_IntegralCast;
8659 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8662 scalarCast = CK_FloatingCast;
8665 scalarCast = CK_IntegralToFloating;
8674 if (scalarCast != CK_NoOp)
8685 assert(VecTy &&
"Expression E must be a vector");
8687 VecTy->getNumElements(),
8688 VecTy->getVectorKind());
8692 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8693 if (ICE->getSubExpr()->getType() == NewVecTy)
8694 return ICE->getSubExpr();
8696 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
8704 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8710 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8718 llvm::APSInt Result = EVResult.
Val.
getInt();
8719 unsigned NumBits = IntSigned
8720 ? (Result.isNegative() ? Result.getMinSignedBits()
8721 : Result.getActiveBits())
8722 : Result.getActiveBits();
8729 return (IntSigned != OtherIntSigned &&
8742 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8747 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8756 llvm::APSInt Result = EVResult.
Val.
getInt();
8759 llvm::APFloat::rmTowardZero);
8762 bool Ignored =
false;
8763 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8765 if (Result != ConvertBack)
8771 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8773 if (Bits > FloatPrec)
8786 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
8787 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
8790 assert(!isa<ExtVectorType>(VT) &&
8791 "ExtVectorTypes should not be handled here!");
8818 ScalarCast = CK_IntegralCast;
8824 llvm::APFloat Result(0.0);
8825 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
8827 if (!CstScalar && Order < 0)
8833 bool Truncated =
false;
8835 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8840 ScalarCast = CK_FloatingCast;
8845 ScalarCast = CK_IntegralToFloating;
8852 if (ScalarCast != CK_NoOp)
8862 bool AllowBoolConversions) {
8863 if (!IsCompAssign) {
8864 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
8868 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
8874 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
8875 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
8879 assert(LHSVecType || RHSVecType);
8883 if (!AllowBothBool &&
8886 return InvalidOperands(Loc, LHS, RHS);
8893 if (LHSVecType && RHSVecType &&
8895 if (isa<ExtVectorType>(LHSVecType)) {
8896 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8901 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8908 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8911 Context.
getTypeSize(RHSVecType->getElementType()))) {
8915 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8918 if (!IsCompAssign &&
8921 RHSVecType->getElementType()->isIntegerType()) {
8922 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8929 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8931 if (isa<ExtVectorType>(LHSVecType)) {
8942 if (isa<ExtVectorType>(RHSVecType)) {
8944 LHSType, RHSVecType->getElementType(),
8957 QualType VecType = LHSVecType ? LHSType : RHSType;
8958 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8959 QualType OtherType = LHSVecType ? RHSType : LHSType;
8960 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8961 if (isLaxVectorConversion(OtherType, VecType)) {
8965 if (!IsCompAssign) {
8966 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
8976 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
8984 if ((!RHSVecType && !RHSType->
isRealType()) ||
8986 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8987 << LHSType << RHSType
8988 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8996 if (getLangOpts().OpenCL &&
8997 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8998 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8999 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
9008 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
9009 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
9010 QualType Scalar = LHSVecType ? RHSType : LHSType;
9011 QualType Vector = LHSVecType ? LHSType : RHSType;
9012 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
9014 diag::err_typecheck_vector_not_convertable_implict_truncation)
9015 << ScalarOrVector << Scalar << Vector;
9022 << LHSType << RHSType
9023 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9035 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
9036 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
9038 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
9042 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
9043 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
9049 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
9057 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
9058 NonNullType->canDecayToPointerType())
9061 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
9062 << LHSNull << NonNullType
9063 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9072 if (LUE->getKind() !=
UETT_SizeOf || LUE->isArgumentType() ||
9076 QualType LHSTy = LUE->getArgumentExpr()->IgnoreParens()->getType();
9079 if (RUE->isArgumentType())
9080 RHSTy = RUE->getArgumentType();
9082 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
9097 if (!RHS.
get()->isValueDependent() &&
9098 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) &&
9101 S.
PDiag(diag::warn_remainder_division_by_zero)
9102 << IsDiv << RHS.
get()->getSourceRange());
9107 bool IsCompAssign,
bool IsDiv) {
9110 if (LHS.
get()->getType()->isVectorType() ||
9111 RHS.
get()->getType()->isVectorType())
9112 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
9113 getLangOpts().AltiVec,
9116 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
9122 return InvalidOperands(Loc, LHS, RHS);
9134 if (LHS.
get()->getType()->isVectorType() ||
9135 RHS.
get()->getType()->isVectorType()) {
9136 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
9137 RHS.
get()->getType()->hasIntegerRepresentation())
9138 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
9139 getLangOpts().AltiVec,
9141 return InvalidOperands(Loc, LHS, RHS);
9144 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
9149 return InvalidOperands(Loc, LHS, RHS);
9158 ? diag::err_typecheck_pointer_arith_void_type
9159 : diag::ext_gnu_void_ptr)
9168 ? diag::err_typecheck_pointer_arith_void_type
9169 : diag::ext_gnu_void_ptr)
9179 Expr *Pointer,
bool IsGNUIdiom) {
9181 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
9184 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
9194 ? diag::err_typecheck_pointer_arith_function_type
9195 : diag::ext_gnu_ptr_func_arith)
9209 ? diag::err_typecheck_pointer_arith_function_type
9210 : diag::ext_gnu_ptr_func_arith)
9223 ResType = ResAtomicType->getValueType();
9228 diag::err_typecheck_arithmetic_incomplete_type,
9244 ResType = ResAtomicType->getValueType();
9276 if (!isLHSPointer && !isRHSPointer)
return true;
9278 QualType LHSPointeeTy, RHSPointeeTy;
9283 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
9288 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9296 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
9297 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
9298 if (isLHSVoidPtr || isRHSVoidPtr) {
9306 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
9307 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
9308 if (isLHSFuncPtr || isRHSFuncPtr) {
9330 Expr* IndexExpr = RHSExpr;
9333 IndexExpr = LHSExpr;
9336 bool IsStringPlusInt = StrExpr &&
9338 if (!IsStringPlusInt || IndexExpr->isValueDependent())
9342 Self.
Diag(OpLoc, diag::warn_string_plus_int)
9343 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
9346 if (IndexExpr == RHSExpr) {
9348 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9353 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9359 const Expr *StringRefExpr = LHSExpr;
9365 StringRefExpr = RHSExpr;
9368 if (!CharExpr || !StringRefExpr)
9385 if (!CharType->isAnyCharacterType() &&
9386 CharType->isIntegerType() &&
9388 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9389 << DiagRange << Ctx.
CharTy;
9391 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9392 << DiagRange << CharExpr->
getType();
9398 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9403 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9412 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
9423 if (LHS.
get()->getType()->isVectorType() ||
9424 RHS.
get()->getType()->isVectorType()) {
9425 QualType compType = CheckVectorOperands(
9426 LHS, RHS, Loc, CompLHSTy,
9427 getLangOpts().AltiVec,
9428 getLangOpts().ZVector);
9429 if (CompLHSTy) *CompLHSTy = compType;
9433 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9438 if (Opc == BO_Add) {
9445 if (CompLHSTy) *CompLHSTy = compType;
9455 isObjCPointer =
false;
9457 isObjCPointer =
true;
9459 std::swap(PExp, IExp);
9461 isObjCPointer =
false;
9463 isObjCPointer =
true;
9465 return InvalidOperands(Loc, LHS, RHS);
9470 if (!IExp->getType()->isIntegerType())
9471 return InvalidOperands(Loc, LHS, RHS);
9478 if (!getLangOpts().CPlusPlus ||
9479 (!IExp->isValueDependent() &&
9480 (!IExp->EvaluateAsInt(KnownVal, Context) ||
9484 Context, BO_Add, PExp, IExp);
9496 CheckArrayAccess(PExp, IExp);
9501 LHSTy = LHS.
get()->getType();
9517 if (LHS.
get()->getType()->isVectorType() ||
9518 RHS.
get()->getType()->isVectorType()) {
9519 QualType compType = CheckVectorOperands(
9520 LHS, RHS, Loc, CompLHSTy,
9521 getLangOpts().AltiVec,
9522 getLangOpts().ZVector);
9523 if (CompLHSTy) *CompLHSTy = compType;
9527 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9535 if (CompLHSTy) *CompLHSTy = compType;
9540 if (LHS.
get()->getType()->isAnyPointerType()) {
9541 QualType lpointee = LHS.
get()->getType()->getPointeeType();
9544 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9549 if (RHS.
get()->getType()->isIntegerType()) {
9553 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9557 if (!getLangOpts().CPlusPlus ||
9558 (!RHS.
get()->isValueDependent() &&
9559 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) ||
9569 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9572 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9573 return LHS.
get()->getType();
9607 if (ElementSize.
isZero()) {
9608 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9610 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9614 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9619 return InvalidOperands(Loc, LHS, RHS);
9624 return ET->getDecl()->isScoped();
9638 if (RHS.
get()->isValueDependent() ||
9639 !RHS.
get()->EvaluateAsInt(RHSResult, S.
Context))
9641 llvm::APSInt Right = RHSResult.
Val.
getInt();
9643 if (Right.isNegative()) {
9645 S.
PDiag(diag::warn_shift_negative)
9646 << RHS.
get()->getSourceRange());
9649 llvm::APInt LeftBits(Right.getBitWidth(),
9651 if (Right.uge(LeftBits)) {
9653 S.
PDiag(diag::warn_shift_gt_typewidth)
9654 << RHS.
get()->getSourceRange());
9667 if (LHS.
get()->isValueDependent() ||
9669 !LHS.
get()->EvaluateAsInt(LHSResult, S.
Context))
9671 llvm::APSInt Left = LHSResult.
Val.
getInt();
9678 S.
PDiag(diag::warn_shift_lhs_negative)
9679 << LHS.
get()->getSourceRange());
9683 llvm::APInt ResultBits =
9684 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9685 if (LeftBits.uge(ResultBits))
9687 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9688 Result = Result.shl(Right);
9693 Result.toString(HexResult, 16,
false,
true);
9699 if (LeftBits == ResultBits - 1) {
9700 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9701 << HexResult << LHSType
9702 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9706 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
9707 << HexResult.str() << Result.getMinSignedBits() << LHSType
9708 << Left.getBitWidth() << LHS.
get()->getSourceRange()
9709 << RHS.
get()->getSourceRange();
9718 !LHS.
get()->getType()->isVectorType()) {
9719 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
9720 << RHS.
get()->getType() << LHS.
get()->getType()
9721 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9725 if (!IsCompAssign) {
9745 if (!LHSEleType->isIntegerType()) {
9746 S.
Diag(Loc, diag::err_typecheck_expect_int)
9747 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
9751 if (!RHSEleType->isIntegerType()) {
9752 S.
Diag(Loc, diag::err_typecheck_expect_int)
9753 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
9761 if (LHSEleType != RHSEleType) {
9763 LHSEleType = RHSEleType;
9769 }
else if (RHSVecTy) {
9774 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9775 << LHS.
get()->getType() << RHS.
get()->getType()
9776 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9782 if (LHSBT != RHSBT &&
9784 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9785 << LHS.
get()->getType() << RHS.
get()->getType()
9786 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9802 bool IsCompAssign) {
9806 if (LHS.
get()->getType()->isVectorType() ||
9807 RHS.
get()->getType()->isVectorType()) {
9808 if (LangOpts.ZVector) {
9812 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
9814 return InvalidOperands(Loc, LHS, RHS);
9815 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
9817 return InvalidOperands(Loc, LHS, RHS);
9828 LHS = UsualUnaryConversions(LHS.
get());
9832 if (IsCompAssign) LHS = OldLHS;
9835 RHS = UsualUnaryConversions(RHS.
get());
9843 return InvalidOperands(Loc, LHS, RHS);
9849 return InvalidOperands(Loc, LHS, RHS);
9882 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9883 << LHSStrippedType << RHSStrippedType
9891 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9892 : diag::ext_typecheck_comparison_of_distinct_pointers)
9893 << LHS.
get()->getType() << RHS.
get()->getType()
9894 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9934 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9935 : diag::ext_typecheck_comparison_of_fptr_to_void)
9936 << LHS.
get()->getType() << RHS.
get()->getType()
9937 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9941 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
9942 case Stmt::ObjCArrayLiteralClass:
9943 case Stmt::ObjCDictionaryLiteralClass:
9944 case Stmt::ObjCStringLiteralClass:
9945 case Stmt::ObjCBoxedExprClass:
10004 case Stmt::ObjCStringLiteralClass:
10007 case Stmt::ObjCArrayLiteralClass:
10010 case Stmt::ObjCDictionaryLiteralClass:
10012 return LK_Dictionary;
10013 case Stmt::BlockExprClass:
10015 case Stmt::ObjCBoxedExprClass: {
10016 Expr *Inner = cast<ObjCBoxedExpr>(FromE)->getSubExpr()->IgnoreParens();
10018 case Stmt::IntegerLiteralClass:
10019 case Stmt::FloatingLiteralClass:
10020 case Stmt::CharacterLiteralClass:
10021 case Stmt::ObjCBoolLiteralExprClass:
10022 case Stmt::CXXBoolLiteralExprClass:
10025 case Stmt::ImplicitCastExprClass: {
10026 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
10028 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
10047 Literal = LHS.
get();
10050 Literal = RHS.
get();
10066 llvm_unreachable(
"Unknown Objective-C object literal kind");
10070 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
10073 S.
Diag(Loc, diag::warn_objc_literal_comparison)
10083 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
10096 if (!UO || UO->
getOpcode() != UO_LNot)
return;
10099 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
10106 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
10108 << Loc << IsBitwiseOp;
10136 return DR->getDecl();
10138 if (Ivar->isFreeIvar())
10139 return Ivar->getDecl();
10141 if (
MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
10142 if (Mem->isImplicitAccess())
10143 return Mem->getMemberDecl();
10183 case BO_EQ:
case BO_LE:
case BO_GE:
10186 case BO_NE:
case BO_LT:
case BO_GT:
10190 Result =
"'std::strong_ordering::equal'";
10196 S.
PDiag(diag::warn_comparison_always)
10197 << 0 << !Result.empty()
10199 }
else if (DL && DR &&
10216 S.
PDiag(diag::warn_comparison_always)
10218 << !Result.empty() << Result);
10221 if (isa<CastExpr>(LHSStripped))
10223 if (isa<CastExpr>(RHSStripped))
10228 Expr *LiteralString =
nullptr;
10229 Expr *LiteralStringStripped =
nullptr;
10230 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
10233 LiteralString = LHS;
10234 LiteralStringStripped = LHSStripped;
10235 }
else if ((isa<StringLiteral>(RHSStripped) ||
10236 isa<ObjCEncodeExpr>(RHSStripped)) &&
10239 LiteralString = RHS;
10240 LiteralStringStripped = RHSStripped;
10243 if (LiteralString) {
10245 S.
PDiag(diag::warn_stringcompare)
10246 << isa<ObjCEncodeExpr>(LiteralStringStripped)
10258 llvm_unreachable(
"unhandled cast kind");
10260 case CK_UserDefinedConversion:
10262 case CK_LValueToRValue:
10264 case CK_ArrayToPointerDecay:
10266 case CK_FunctionToPointerDecay:
10268 case CK_IntegralCast:
10270 case CK_FloatingCast:
10272 case CK_IntegralToFloating:
10273 case CK_FloatingToIntegral:
10275 case CK_IntegralComplexCast:
10276 case CK_FloatingComplexCast:
10277 case CK_FloatingComplexToIntegralComplex:
10278 case CK_IntegralComplexToFloatingComplex:
10280 case CK_FloatingComplexToReal:
10281 case CK_FloatingRealToComplex:
10282 case CK_IntegralComplexToReal:
10283 case CK_IntegralRealToComplex:
10296 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10315 << PreNarrowingValue.getAsString(S.
Context, PreNarrowingType) << ToType;
10323 << 0 << FromType << ToType;
10328 llvm_unreachable(
"unhandled case in switch");
10344 QualType LHSStrippedType = LHSStripped.
get()->getType();
10345 QualType RHSStrippedType = RHSStripped.
get()->getType();
10356 if (NumEnumArgs == 1) {
10358 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
10364 if (NumEnumArgs == 2) {
10373 LHSStrippedType->
getAs<
EnumType>()->getDecl()->getIntegerType();
10384 LHSType = RHSType = IntType;
10397 S, Type, LHS.
get(), LHSType, LHS.
get()->getBeginLoc());
10399 RHS.
get()->getBeginLoc());
10403 assert(!Type.
isNull() &&
"composite type for <=> has not been set");
10405 auto TypeKind = [&]() {
10407 if (CT->getElementType()->hasFloatingRepresentation())
10415 llvm_unreachable(
"other types are unimplemented");
10454 bool IsThreeWay = Opc == BO_Cmp;
10465 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
10466 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10469 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10473 LHS = DefaultLvalueConversion(LHS.
get());
10476 RHS = DefaultLvalueConversion(RHS.
get());
10484 if (LHS.
get()->getType()->isVectorType() ||
10485 RHS.
get()->getType()->isVectorType())
10486 return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);
10493 if ((LHSType->isArithmeticType() || LHSType->isEnumeralType()) &&
10504 auto computeResultTy = [&]() {
10514 return CheckComparisonCategoryType(
Kind, Loc);
10532 if (LHSIsNull != RHSIsNull)
10538 return InvalidOperands(Loc, LHS, RHS);
10542 if (!IsRelational && LHSIsNull != RHSIsNull) {
10543 bool IsEquality = Opc == BO_EQ;
10545 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
10546 RHS.
get()->getSourceRange());
10548 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
10549 LHS.
get()->getSourceRange());
10552 if ((LHSType->isIntegerType() && !LHSIsNull) ||
10556 }
else if (getLangOpts().CPlusPlus) {
10561 if (!IsRelational &&
10568 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
10570 if (isSFINAEContext())
10573 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10574 return computeResultTy();
10586 if ((
int)LHSType->isPointerType() + (int)RHSType->
isPointerType() >=
10587 (IsRelational ? 2 : 1) &&
10588 (!LangOpts.ObjCAutoRefCount || !(LHSType->isObjCObjectPointerType() ||
10592 return computeResultTy();
10594 }
else if (LHSType->isPointerType() &&
10608 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
10609 << LHSType << RHSType << LHS.
get()->getSourceRange()
10610 << RHS.
get()->getSourceRange();
10612 }
else if (!IsRelational &&
10616 && !LHSIsNull && !RHSIsNull)
10623 if (LCanPointeeTy != RCanPointeeTy) {
10625 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
10629 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10630 << LHSType << RHSType << 0
10631 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10636 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
10638 if (LHSIsNull && !RHSIsNull)
10639 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
10641 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
10643 return computeResultTy();
10650 if (!IsRelational && LHSIsNull && RHSIsNull) {
10651 if (LHSType->isNullPtrType()) {
10652 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10653 return computeResultTy();
10656 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10657 return computeResultTy();
10664 (LHSType->isObjCObjectPointerType() || LHSType->isBlockPointerType())) {
10665 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10666 return computeResultTy();
10668 if (!IsRelational && LHSType->isNullPtrType() &&
10670 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10671 return computeResultTy();
10674 if (IsRelational &&
10683 if (isa<FunctionDecl>(DC))
10685 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
10686 if (CTSD->isInStdNamespace() &&
10687 llvm::StringSwitch<bool>(CTSD->getName())
10688 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
10691 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10693 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10694 return computeResultTy();
10702 if (!IsRelational &&
10707 return computeResultTy();
10712 if (!IsRelational && LHSType->isBlockPointerType() &&
10717 if (!LHSIsNull && !RHSIsNull &&
10719 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10720 << LHSType << RHSType << LHS.
get()->getSourceRange()
10721 << RHS.
get()->getSourceRange();
10723 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10724 return computeResultTy();
10729 && ((LHSType->isBlockPointerType() && RHSType->
isPointerType())
10731 if (!LHSIsNull && !RHSIsNull) {
10734 || (LHSType->isPointerType() && LHSType->castAs<
PointerType>()
10736 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10737 << LHSType << RHSType << LHS.
get()->getSourceRange()
10738 << RHS.
get()->getSourceRange();
10740 if (LHSIsNull && !RHSIsNull)
10741 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10743 : CK_AnyPointerToBlockPointerCast);
10745 RHS = ImpCastExprToType(RHS.get(), LHSType,
10746 LHSType->isPointerType() ? CK_BitCast
10747 : CK_AnyPointerToBlockPointerCast);
10748 return computeResultTy();
10751 if (LHSType->isObjCObjectPointerType() ||
10757 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
10759 if (!LPtrToVoid && !RPtrToVoid &&
10764 if (LHSIsNull && !RHSIsNull) {
10766 if (getLangOpts().ObjCAutoRefCount)
10768 CCK_ImplicitConversion);
10769 LHS = ImpCastExprToType(E, RHSType,
10770 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10774 if (getLangOpts().ObjCAutoRefCount)
10775 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
10778 RHS = ImpCastExprToType(E, LHSType,
10779 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10781 return computeResultTy();
10783 if (LHSType->isObjCObjectPointerType() &&
10791 if (LHSIsNull && !RHSIsNull)
10792 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10794 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
10795 return computeResultTy();
10798 if (!IsRelational && LHSType->isBlockPointerType() &&
10800 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10801 CK_BlockPointerToObjCPointerCast);
10802 return computeResultTy();
10803 }
else if (!IsRelational &&
10804 LHSType->isBlockCompatibleObjCPointerType(Context) &&
10806 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10807 CK_BlockPointerToObjCPointerCast);
10808 return computeResultTy();
10811 if ((LHSType->isAnyPointerType() && RHSType->
isIntegerType()) ||
10813 unsigned DiagID = 0;
10814 bool isError =
false;
10815 if (LangOpts.DebuggerSupport) {
10818 }
else if ((LHSIsNull && LHSType->isIntegerType()) ||
10820 if (IsRelational) {
10821 isError = getLangOpts().CPlusPlus;
10823 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
10824 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
10827 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
10829 }
else if (IsRelational)
10830 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
10832 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
10836 << LHSType << RHSType << LHS.
get()->getSourceRange()
10837 << RHS.
get()->getSourceRange();
10842 if (LHSType->isIntegerType())
10843 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10844 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10846 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10847 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10848 return computeResultTy();
10852 if (!IsRelational && RHSIsNull
10853 && LHSType->isBlockPointerType() && RHSType->
isIntegerType()) {
10854 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10855 return computeResultTy();
10857 if (!IsRelational && LHSIsNull
10859 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10860 return computeResultTy();
10863 if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
10864 if (LHSType->isClkEventT() && RHSType->
isClkEventT()) {
10865 return computeResultTy();
10868 if (LHSType->isQueueT() && RHSType->
isQueueT()) {
10869 return computeResultTy();
10872 if (LHSIsNull && RHSType->
isQueueT()) {
10873 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10874 return computeResultTy();
10877 if (LHSType->isQueueT() && RHSIsNull) {
10878 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10879 return computeResultTy();
10883 return InvalidOperands(Loc, LHS, RHS);
10895 if (isa<ExtVectorType>(VTy)) {
10905 "Unhandled vector element size in vector compare");
10922 "Unhandled vector element size in vector compare");
10936 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10938 getLangOpts().ZVector);
10946 if (getLangOpts().AltiVec &&
10958 assert(RHS.
get()->getType()->hasFloatingRepresentation());
10959 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
10963 return GetSignedVectorType(vType);
10970 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10974 return InvalidOperands(Loc, LHS, RHS);
10975 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
10977 return InvalidOperands(Loc, LHS, RHS);
10981 if (!getLangOpts().CPlusPlus &&
10983 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
10985 return GetSignedVectorType(LHS.
get()->getType());
10993 bool IsCompAssign =
10994 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
10996 if (LHS.
get()->getType()->isVectorType() ||
10997 RHS.
get()->getType()->isVectorType()) {
10998 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
10999 RHS.
get()->getType()->hasIntegerRepresentation())
11000 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
11002 getLangOpts().ZVector);
11003 return InvalidOperands(Loc, LHS, RHS);
11009 ExprResult LHSResult = LHS, RHSResult = RHS;
11010 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
11012 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
11014 LHS = LHSResult.
get();
11015 RHS = RHSResult.
get();
11019 return InvalidOperands(Loc, LHS, RHS);
11027 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
11028 return CheckVectorLogicalOperands(LHS, RHS, Loc);
11033 if (LHS.
get()->getType()->isIntegerType() &&
11034 !LHS.
get()->getType()->isBooleanType() &&
11035 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
11037 !Loc.
isMacroID() && !inTemplateInstantiation()) {
11043 if (RHS.
get()->EvaluateAsInt(EVResult, Context)) {
11044 llvm::APSInt Result = EVResult.
Val.
getInt();
11045 if ((getLangOpts().
Bool && !RHS.
get()->getType()->isBooleanType() &&
11046 !RHS.
get()->getExprLoc().isMacroID()) ||
11047 (Result != 0 && Result != 1)) {
11048 Diag(Loc, diag::warn_logical_instead_of_bitwise)
11049 << RHS.
get()->getSourceRange()
11050 << (Opc == BO_LAnd ?
"&&" :
"||");
11052 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
11053 << (Opc == BO_LAnd ?
"&" :
"|")
11055 Loc, getLocForEndOfToken(Loc)),
11056 Opc == BO_LAnd ?
"&" :
"|");
11057 if (Opc == BO_LAnd)
11059 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
11062 RHS.
get()->getEndLoc()));
11072 if (LHS.
get()->getType()->isFloatingType() ||
11073 RHS.
get()->getType()->isFloatingType())
11074 return InvalidOperands(Loc, LHS, RHS);
11077 LHS = UsualUnaryConversions(LHS.
get());
11081 RHS = UsualUnaryConversions(RHS.
get());
11085 if (!LHS.
get()->getType()->isScalarType() ||
11086 !RHS.
get()->getType()->isScalarType())
11087 return InvalidOperands(Loc, LHS, RHS);
11089 return Context.
IntTy;
11098 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
11100 return InvalidOperands(Loc, LHS, RHS);
11103 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
11105 return InvalidOperands(Loc, LHS, RHS);
11116 if (!ME)
return false;
11120 if (!Base)
return false;
11141 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
11149 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
11192 bool DiagnosticEmitted =
false;
11196 bool IsDereference =
false;
11197 bool NextIsDereference =
false;
11201 IsDereference = NextIsDereference;
11204 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
11205 NextIsDereference = ME->isArrow();
11206 const ValueDecl *VD = ME->getMemberDecl();
11207 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
11209 if (Field->isMutable()) {
11210 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
11215 if (!DiagnosticEmitted) {
11216 S.
Diag(Loc, diag::err_typecheck_assign_const)
11218 << Field->getType();
11219 DiagnosticEmitted =
true;
11222 <<
ConstMember <<
false << Field << Field->getType()
11223 << Field->getSourceRange();
11227 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
11228 if (VDecl->getType().isConstQualified()) {
11229 if (!DiagnosticEmitted) {
11230 S.
Diag(Loc, diag::err_typecheck_assign_const)
11232 << VDecl->getType();
11233 DiagnosticEmitted =
true;
11236 <<
ConstMember <<
true << VDecl << VDecl->getType()
11237 << VDecl->getSourceRange();
11244 dyn_cast<ArraySubscriptExpr>(E)) {
11248 dyn_cast<ExtVectorElementExpr>(E)) {
11255 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
11259 if (!DiagnosticEmitted) {
11260 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11262 DiagnosticEmitted =
true;
11265 diag::note_typecheck_assign_const)
11269 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11271 if (
const ValueDecl *VD = DRE->getDecl()) {
11273 if (!DiagnosticEmitted) {
11274 S.
Diag(Loc, diag::err_typecheck_assign_const)
11276 DiagnosticEmitted =
true;
11278 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
11279 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
11282 }
else if (isa<CXXThisExpr>(E)) {
11284 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
11285 if (MD->isConst()) {
11286 if (!DiagnosticEmitted) {
11287 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11289 DiagnosticEmitted =
true;
11291 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
11298 if (DiagnosticEmitted)
11302 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
11315 bool &DiagnosticEmitted) {
11316 std::vector<const RecordType *> RecordTypeList;
11317 RecordTypeList.push_back(Ty);
11318 unsigned NextToCheckIndex = 0;
11321 while (RecordTypeList.size() > NextToCheckIndex) {
11322 bool IsNested = NextToCheckIndex > 0;
11324 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
11326 QualType FieldTy = Field->getType();
11328 if (!DiagnosticEmitted) {
11329 S.
Diag(Loc, diag::err_typecheck_assign_const)
11331 << IsNested << Field;
11332 DiagnosticEmitted =
true;
11334 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
11336 << FieldTy << Field->getSourceRange();
11342 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
11343 RecordTypeList.push_back(FieldRecTy);
11346 ++NextToCheckIndex;
11355 assert(Ty->
isRecordType() &&
"lvalue was not record?");
11358 bool DiagEmitted =
false;
11360 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
11363 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11388 unsigned DiagID = 0;
11389 bool NeedType =
false;
11396 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
11398 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
11406 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
11419 ? diag::err_typecheck_arc_assign_self_class_method
11420 : diag::err_typecheck_arc_assign_self;
11423 }
else if (var->
hasAttr<ObjCExternallyRetainedAttr>() ||
11424 isa<ParmVarDecl>(var)) {
11425 DiagID = diag::err_typecheck_arc_assign_externally_retained;
11429 DiagID = diag::err_typecheck_arr_assign_enumeration;
11433 if (Loc != OrigLoc)
11459 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
11463 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
11467 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
11470 llvm_unreachable(
"did not take early return for MLV_Valid");
11474 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
11479 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
11481 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
11484 llvm_unreachable(
"readonly properties should be processed differently");
11486 DiagID = diag::err_readonly_message_assignment;
11489 DiagID = diag::err_no_subobject_property_setting;
11494 if (Loc != OrigLoc)
11519 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase())))
11524 cast<ValueDecl>(MR->getMemberDecl()->getCanonicalDecl());
11525 if (LHSDecl != RHSDecl)
11530 if (RefTy->getPointeeType().isVolatileQualified())
11533 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
11539 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
11542 if (RL && RR && RL->
getDecl() == RR->getDecl())
11543 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
11563 if (getLangOpts().OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
11565 Diag(Loc, diag::err_opencl_half_load_store) << 1
11571 if (CompoundType.
isNull()) {
11577 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
11581 if (ConvTy == IncompatiblePointer &&
11586 ConvTy = Compatible;
11588 if (ConvTy == Compatible &&
11590 Diag(Loc, diag::err_objc_object_assignment)
11597 RHSCheck = ICE->getSubExpr();
11598 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
11599 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
11600 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
11606 UO->getSubExpr()->getBeginLoc().
isFileID()) {
11607 Diag(Loc, diag::warn_not_compound_assign)
11608 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
11609 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
11613 if (ConvTy == Compatible) {
11621 checkRetainCycles(LHSExpr, RHS.
get());
11635 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11636 RHS.
get()->getBeginLoc()))
11637 getCurFunction()->markSafeWeakUse(RHS.
get());
11639 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
11640 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
11645 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
11648 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
11649 RHS.
get(), AA_Assigning))
11669 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
11670 if (CE->getCastKind() == CK_ToVoid) {
11676 CE->getSubExpr()->getType()->isDependentType()) {
11693 if (inTemplateInstantiation())
11703 const unsigned ForIncrementFlags =
11704 getLangOpts().C99 || getLangOpts().CPlusPlus
11708 const unsigned ScopeFlags = getCurScope()->getFlags();
11709 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
11710 (ScopeFlags & ForInitFlags) == ForInitFlags)
11715 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
11716 if (BO->getOpcode() != BO_Comma)
11718 LHS = BO->getRHS();
11725 Diag(Loc, diag::warn_comma_operator);
11729 LangOpts.CPlusPlus ?
"static_cast<void>(" 11759 if (!RHS.
get()->getType()->isVoidType())
11761 diag::err_incomplete_type);
11767 return RHS.
get()->getType();
11776 bool IsInc,
bool IsPrefix) {
11785 ResType = ResAtomicType->getValueType();
11787 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
11789 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
11797 : diag::warn_increment_bool)
11799 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
11801 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
11803 }
else if (ResType->isRealType()) {
11805 }
else if (ResType->isPointerType()) {
11809 }
else if (ResType->isObjCObjectPointerType()) {
11815 }
else if (ResType->isAnyComplexType()) {
11817 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
11819 }
else if (ResType->isPlaceholderType()) {
11824 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
11826 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
11827 (ResType->getAs<
VectorType>()->getVectorKind() !=
11830 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
11834 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
11851 return ResType.getUnqualifiedType();
11870 case Stmt::DeclRefExprClass:
11871 return cast<DeclRefExpr>(E)->getDecl();
11872 case Stmt::MemberExprClass:
11876 if (cast<MemberExpr>(E)->isArrow())
11880 case Stmt::ArraySubscriptExprClass: {
11883 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
11885 if (ICE->getSubExpr()->getType()->isArrayType())
11890 case Stmt::UnaryOperatorClass: {
11902 case Stmt::ParenExprClass:
11904 case Stmt::ImplicitCastExprClass:
11916 AO_Vector_Element = 1,
11917 AO_Property_Expansion = 2,
11918 AO_Register_Variable = 3,
11938 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
11939 if (PTy->getKind() == BuiltinType::Overload) {
11940 Expr *E = OrigOp.
get()->IgnoreParens();
11941 if (!isa<OverloadExpr>(E)) {
11942 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
11943 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
11944 << OrigOp.
get()->getSourceRange();
11949 if (isa<UnresolvedMemberExpr>(Ovl))
11950 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
11951 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11952 << OrigOp.
get()->getSourceRange();
11959 if (PTy->getKind() == BuiltinType::UnknownAny)
11962 if (PTy->getKind() == BuiltinType::BoundMember) {
11963 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11964 << OrigOp.
get()->getSourceRange();
11968 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
11972 if (OrigOp.
get()->isTypeDependent())
11975 assert(!OrigOp.
get()->getType()->isPlaceholderType());
11978 Expr *op = OrigOp.
get()->IgnoreParens();
11985 if (LangOpts.OpenCL) {
11987 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
11988 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
11993 if (getLangOpts().
C99) {
11996 if (uOp->getOpcode() == UO_Deref)
11999 return uOp->getSubExpr()->getType();
12006 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
12012 unsigned AddressOfError = AO_No_Error;
12015 bool sfinae = (
bool)isSFINAEContext();
12016 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
12017 : diag::ext_typecheck_addrof_temporary)
12023 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
12024 }
else if (isa<ObjCSelectorExpr>(op)) {
12031 if (!isa<DeclRefExpr>(op)) {
12032 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
12033 << OrigOp.
get()->getSourceRange();
12040 if (OrigOp.
get() != DRE) {
12041 Diag(OpLoc, diag::err_parens_pointer_member_function)
12042 << OrigOp.
get()->getSourceRange();
12046 if (MD->getParent()->getName().empty())
12047 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
12051 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
12052 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
12059 if (isa<CXXDestructorDecl>(MD))
12066 (
void)isCompleteType(OpLoc, MPTy);
12073 if (isa<PseudoObjectExpr>(op)) {
12074 AddressOfError = AO_Property_Expansion;
12076 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
12083 AddressOfError = AO_Bit_Field;
12086 AddressOfError = AO_Vector_Element;
12090 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
12094 !getLangOpts().CPlusPlus) {
12095 AddressOfError = AO_Register_Variable;
12097 }
else if (isa<MSPropertyDecl>(dcl)) {
12098 AddressOfError = AO_Property_Expansion;
12099 }
else if (isa<FunctionTemplateDecl>(dcl)) {
12101 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
12105 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
12110 diag::err_cannot_form_pointer_to_member_of_reference_type)
12115 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
12123 (
void)isCompleteType(OpLoc, MPTy);
12127 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
12128 !isa<BindingDecl>(dcl))
12129 llvm_unreachable(
"Unknown/unexpected decl type");
12132 if (AddressOfError != AO_No_Error) {
12148 CheckAddressOfPackedMember(op);
12164 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
12167 if (!FD->ModifiedNonNullParams.count(Param))
12168 FD->ModifiedNonNullParams.insert(Param);
12178 if (ConvResult.isInvalid())
12180 Op = ConvResult.get();
12184 if (isa<CXXReinterpretCastExpr>(Op)) {
12200 if (PR.
get() != Op)
12205 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
12220 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
12236 default: llvm_unreachable(
"Unknown binop!");
12237 case tok::periodstar: Opc = BO_PtrMemD;
break;
12238 case tok::arrowstar: Opc = BO_PtrMemI;
break;
12239 case tok::star: Opc = BO_Mul;
break;
12240 case tok::slash: Opc = BO_Div;
break;
12241 case tok::percent: Opc = BO_Rem;
break;
12242 case tok::plus: Opc = BO_Add;
break;
12243 case tok::minus: Opc = BO_Sub;
break;
12244 case tok::lessless: Opc = BO_Shl;
break;
12245 case tok::greatergreater: Opc = BO_Shr;
break;
12246 case tok::lessequal: Opc = BO_LE;
break;
12247 case tok::less: Opc = BO_LT;
break;
12248 case tok::greaterequal: Opc = BO_GE;
break;
12249 case tok::greater: Opc = BO_GT;
break;
12250 case tok::exclaimequal: Opc = BO_NE;
break;
12251 case tok::equalequal: Opc = BO_EQ;
break;
12252 case tok::spaceship: Opc = BO_Cmp;
break;
12253 case tok::amp: Opc = BO_And;
break;
12254 case tok::caret: Opc = BO_Xor;
break;
12255 case tok::pipe: Opc = BO_Or;
break;
12256 case tok::ampamp: Opc = BO_LAnd;
break;
12257 case tok::pipepipe: Opc = BO_LOr;
break;
12258 case tok::equal: Opc = BO_Assign;
break;
12259 case tok::starequal: Opc = BO_MulAssign;
break;
12260 case tok::slashequal: Opc = BO_DivAssign;
break;
12261 case tok::percentequal: Opc = BO_RemAssign;
break;
12262 case tok::plusequal: Opc = BO_AddAssign;
break;
12263 case tok::minusequal: Opc = BO_SubAssign;
break;
12264 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
12265 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
12266 case tok::ampequal: Opc = BO_AndAssign;
break;
12267 case tok::caretequal: Opc = BO_XorAssign;
break;
12268 case tok::pipeequal: Opc = BO_OrAssign;
break;
12269 case tok::comma: Opc = BO_Comma;
break;
12278 default: llvm_unreachable(
"Unknown unary op!");
12279 case tok::plusplus: Opc = UO_PreInc;
break;
12280 case tok::minusminus: Opc = UO_PreDec;
break;
12281 case tok::amp: Opc = UO_AddrOf;
break;
12282 case tok::star: Opc = UO_Deref;
break;
12283 case tok::plus: Opc = UO_Plus;
break;
12284 case tok::minus: Opc = UO_Minus;
break;
12285 case tok::tilde: Opc = UO_Not;
break;
12286 case tok::exclaim: Opc = UO_LNot;
break;
12287 case tok::kw___real: Opc = UO_Real;
break;
12288 case tok::kw___imag: Opc = UO_Imag;
break;
12289 case tok::kw___extension__: Opc = UO_Extension;
break;
12308 if (!LHSDeclRef || !RHSDeclRef ||
12310 RHSDeclRef->getLocation().isMacroID())
12315 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
12316 if (LHSDecl != RHSDecl)
12321 if (RefTy->getPointeeType().isVolatileQualified())
12324 S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
12325 : diag::warn_self_assignment_overloaded)
12337 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
12342 ObjCPointerExpr = LHS;
12346 ObjCPointerExpr = RHS;
12354 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
12355 unsigned Diag = diag::warn_objc_pointer_masking;
12364 if (SelArg0.startswith(
"performSelector"))
12365 Diag = diag::warn_objc_pointer_masking_performSelector;
12368 S.
Diag(OpLoc, Diag)
12376 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
12377 return DRE->getDecl();
12378 if (
auto *ME = dyn_cast<MemberExpr>(E))
12379 return ME->getMemberDecl();
12380 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
12381 return IRE->getDecl();
12396 "Result must be a vector of half or short");
12399 "both operands expected to be a half vector");
12411 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
12412 OpLoc, FPFeatures);
12416 VK, OK, OpLoc, FPFeatures);
12420 static std::pair<ExprResult, ExprResult>
12430 if (Opc != BO_Assign)
12437 return std::make_pair(LHS, RHS);
12444 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
12455 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
12467 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
12470 RHSExpr = Init.
get();
12480 bool ConvertHalfVec =
false;
12483 if (!LHS.
isUsable() || !RHS.isUsable())
12486 if (getLangOpts().OpenCL) {
12493 if (BO_Assign == Opc)
12494 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
12496 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12506 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12512 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice) {
12513 if (Opc != BO_Assign && Opc != BO_Comma) {
12514 checkOpenMPDeviceExpr(LHSExpr);
12515 checkOpenMPDeviceExpr(RHSExpr);
12521 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
12522 if (getLangOpts().CPlusPlus &&
12524 VK = LHS.
get()->getValueKind();
12525 OK = LHS.
get()->getObjectKind();
12527 if (!ResultTy.
isNull()) {
12529 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
12544 if (
auto *BE = dyn_cast<BlockExpr>(RHS.get()->IgnoreParens()))
12545 if (
auto *DRE = dyn_cast<DeclRefExpr>(LHS.
get()->IgnoreParens()))
12546 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
12547 if (VD->hasLocalStorage() && getCurScope()->isDeclScope(VD))
12548 BE->getBlockDecl()->setCanAvoidCopyToHeap();
12550 if (LHS.
get()->getType().hasNonTrivialToPrimitiveCopyCUnion())
12551 checkNonTrivialCUnion(LHS.
get()->getType(), LHS.
get()->getExprLoc(),
12552 NTCUC_Assignment, NTCUK_Copy);
12558 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
12559 Opc == BO_PtrMemI);
12563 ConvertHalfVec =
true;
12564 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
12568 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
12571 ConvertHalfVec =
true;
12572 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
12575 ConvertHalfVec =
true;
12576 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
12580 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
12586 ConvertHalfVec =
true;
12587 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12591 ConvertHalfVec =
true;
12592 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12595 ConvertHalfVec =
true;
12596 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12604 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12608 ConvertHalfVec =
true;
12609 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
12613 ConvertHalfVec =
true;
12614 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
12615 Opc == BO_DivAssign);
12616 CompLHSTy = CompResultTy;
12618 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12621 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
12622 CompLHSTy = CompResultTy;
12624 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12627 ConvertHalfVec =
true;
12628 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
12630 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12633 ConvertHalfVec =
true;
12634 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
12636 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12640 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
12641 CompLHSTy = CompResultTy;
12643 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12650 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12651 CompLHSTy = CompResultTy;
12653 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12657 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
12658 VK = RHS.get()->getValueKind();
12659 OK = RHS.get()->getObjectKind();
12672 "both sides are half vectors or neither sides are");
12674 LHS.
get()->getType());
12677 CheckArrayAccess(LHS.
get());
12678 CheckArrayAccess(RHS.get());
12680 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
12681 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
12682 &Context.
Idents.
get(
"object_setClass"),
12684 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
12685 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
12686 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign)
12688 "object_setClass(")
12694 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
12697 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
12701 if (CompResultTy.
isNull()) {
12702 if (ConvertHalfVec)
12704 OpLoc, FPFeatures);
12706 OK, OpLoc, FPFeatures);
12710 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
12713 OK = LHS.
get()->getObjectKind();
12716 if (ConvertHalfVec)
12718 OpLoc, FPFeatures);
12721 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
12722 OpLoc, FPFeatures);
12737 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
12738 if (isLeftComp == isRightComp)
12743 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
12744 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
12745 if (isLeftBitwise || isRightBitwise)
12751 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
12757 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
12760 Self.
PDiag(diag::note_precedence_silence) << OpStr,
12763 Self.
PDiag(diag::note_precedence_bitwise_first)
12778 Self.
PDiag(diag::note_precedence_silence)
12803 if (Bop->getOpcode() == BO_LAnd) {
12810 }
else if (Bop->getOpcode() == BO_LOr) {
12811 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
12814 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
12825 if (Bop->getOpcode() == BO_LAnd) {
12842 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
12843 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
12845 << Bop->getSourceRange() << OpLoc;
12847 S.
PDiag(diag::note_precedence_silence)
12848 << Bop->getOpcodeStr(),
12849 Bop->getSourceRange());
12857 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
12858 StringRef Op = Bop->getOpcodeStr();
12859 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
12860 << Bop->getSourceRange() << OpLoc << Shift << Op;
12862 S.
PDiag(diag::note_precedence_silence) << Op,
12863 Bop->getSourceRange());
12879 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
12882 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
12884 << (Kind == OO_LessLess);
12886 S.
PDiag(diag::note_precedence_silence)
12887 << (Kind == OO_LessLess ?
"<<" :
">>"),
12890 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
12904 if ((Opc == BO_Or || Opc == BO_Xor) &&
12912 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
12918 || Opc == BO_Shr) {
12935 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
12936 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
12941 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
12970 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
12986 LHSExpr = LHS.
get();
12987 RHSExpr = RHS.
get();
12998 if (pty->getKind() == BuiltinType::PseudoObject &&
13000 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
13003 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
13009 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
13011 RHSExpr = resolvedRHS.
get();
13024 if (Opc == BO_LT && inTemplateInstantiation() &&
13025 (pty->getKind() == BuiltinType::BoundMember ||
13026 pty->getKind() == BuiltinType::Overload)) {
13028 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
13029 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
13030 return isa<FunctionTemplateDecl>(ND);
13032 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
13033 : OE->getNameLoc(),
13034 diag::err_template_kw_missing)
13035 << OE->getName().getAsString() <<
"";
13040 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
13042 LHSExpr = LHS.
get();
13049 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
13050 if (getLangOpts().CPlusPlus &&
13055 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
13059 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
13063 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
13065 RHSExpr = resolvedRHS.
get();
13082 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
13102 bool CanOverflow =
false;
13104 bool ConvertHalfVec =
false;
13105 if (getLangOpts().OpenCL) {
13113 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13115 << Input.
get()->getSourceRange());
13119 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice) {
13122 checkOpenMPDeviceExpr(InputExpr);
13132 Opc == UO_PreInc ||
13134 Opc == UO_PreInc ||
13139 resultType = CheckAddressOfOperand(Input, OpLoc);
13140 CheckAddressOfNoDeref(InputExpr);
13144 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
13151 CanOverflow = Opc == UO_Minus &&
13153 Input = UsualUnaryConversions(Input.get());
13154 if (Input.isInvalid())
return ExprError();
13163 if (ConvertHalfVec)
13165 resultType = Input.get()->getType();
13166 if (resultType->isDependentType())
13168 if (resultType->isArithmeticType())
13170 else if (resultType->isVectorType() &&
13173 resultType->getAs<
VectorType>()->getVectorKind() !=
13176 else if (getLangOpts().CPlusPlus &&
13178 resultType->isPointerType())
13181 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13182 << resultType << Input.get()->getSourceRange());
13185 Input = UsualUnaryConversions(Input.get());
13186 if (Input.isInvalid())
13188 resultType = Input.
get()->getType();
13190 if (resultType->isDependentType())
13193 if (resultType->isComplexType() || resultType->isComplexIntegerType())
13195 Diag(OpLoc, diag::ext_integer_complement_complex)
13196 << resultType << Input.get()->getSourceRange();
13197 else if (resultType->hasIntegerRepresentation())
13199 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
13204 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13205 << resultType << Input.get()->getSourceRange());
13207 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13208 << resultType << Input.get()->getSourceRange());
13214 Input = DefaultFunctionArrayLvalueConversion(Input.get());
13215 if (Input.isInvalid())
return ExprError();
13216 resultType = Input.
get()->getType();
13219 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
13220 Input = ImpCastExprToType(Input.get(), Context.
FloatTy, CK_FloatingCast).
get();
13221 resultType = Context.
FloatTy;
13224 if (resultType->isDependentType())
13231 Input = ImpCastExprToType(Input.get(), Context.
BoolTy,
13232 ScalarTypeToBooleanCastKind(resultType));
13237 if (!resultType->isIntegerType() && !resultType->isPointerType())
13238 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13239 << resultType << Input.get()->getSourceRange());
13241 }
else if (resultType->isExtVectorType()) {
13249 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13250 << resultType << Input.get()->getSourceRange());
13253 resultType = GetSignedVectorType(resultType);
13258 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13259 << resultType << Input.get()->getSourceRange());
13271 if (Input.isInvalid())
return ExprError();
13272 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
13273 if (Input.get()->getValueKind() !=
VK_RValue &&
13275 VK = Input.
get()->getValueKind();
13278 Input = DefaultLvalueConversion(Input.get());
13282 resultType = Input.get()->getType();
13283 VK = Input.get()->getValueKind();
13284 OK = Input.get()->getObjectKind();
13289 assert(!Input.get()->getType()->isDependentType() &&
13290 "the co_await expression must be non-dependant before " 13291 "building operator co_await");
13301 if (Opc != UO_AddrOf && Opc != UO_Deref)
13302 CheckArrayAccess(Input.
get());
13304 auto *UO =
new (Context)
13307 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
13308 !isa<ArrayType>(UO->getType().getDesugaredType(Context)))
13309 ExprEvalContexts.back().PossibleDerefs.insert(UO);
13312 if (ConvertHalfVec)
13321 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13322 if (!DRE->getQualifier())
13329 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
13332 return Method->isInstance();
13338 if (!ULE->getQualifier())
13343 if (Method->isInstance())
13363 if (pty->getKind() == BuiltinType::PseudoObject &&
13365 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
13368 if (Opc == UO_Extension)
13369 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13373 if (Opc == UO_AddrOf &&
13374 (pty->getKind() == BuiltinType::Overload ||
13375 pty->getKind() == BuiltinType::UnknownAny ||
13376 pty->getKind() == BuiltinType::BoundMember))
13377 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13380 ExprResult Result = CheckPlaceholderExpr(Input);
13382 Input = Result.
get();
13387 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
13395 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
13398 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
13401 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13420 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13427 DiscardCleanupsInEvaluationContext();
13428 PopExpressionEvaluationContext();
13434 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
13437 if (hasAnyUnrecoverableErrorsInThisFunction())
13438 DiscardCleanupsInEvaluationContext();
13439 assert(!Cleanup.exprNeedsCleanups() &&
13440 "cleanups within StmtExpr not correctly bound!");
13441 PopExpressionEvaluationContext();
13450 bool StmtExprMayBindToTemp =
false;
13453 if (
const auto *LastStmt =
13456 StmtExprMayBindToTemp =
true;
13457 Ty =
Value->getType();
13464 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
13465 if (StmtExprMayBindToTemp)
13466 return MaybeBindToTemporary(ResStmtExpr);
13467 return ResStmtExpr;
13476 ER = DefaultFunctionArrayConversion(ER.
get());
13491 if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)
13495 return PerformCopyInitialization(
13513 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
13514 << ArgTy << TypeRange);
13519 && RequireCompleteType(BuiltinLoc, ArgTy,
13520 diag::err_offsetof_incomplete_type, TypeRange))
13523 bool DidWarnAboutNonPOD =
false;
13528 if (OC.isBrackets) {
13533 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
13539 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
13553 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
13554 Exprs.push_back(Idx);
13562 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
13568 if (RequireCompleteType(OC.LocStart, CurrentType,
13569 diag::err_offsetof_incomplete_type))
13575 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
13587 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
13589 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
13590 : diag::ext_offsetof_non_pod_type;
13592 if (!IsSafe && !DidWarnAboutNonPOD &&
13593 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
13595 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
13597 DidWarnAboutNonPOD =
true;
13601 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
13602 LookupQualifiedName(R, RD);
13607 MemberDecl = IndirectMemberDecl->getAnonField();
13612 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
13620 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
13628 if (IndirectMemberDecl)
13629 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
13634 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
13636 if (Paths.getDetectedVirtual()) {
13637 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
13648 if (IndirectMemberDecl) {
13649 for (
auto *FI : IndirectMemberDecl->chain()) {
13650 assert(isa<FieldDecl>(FI));
13652 cast<FieldDecl>(FI), OC.LocEnd));
13655 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
13661 Comps, Exprs, RParenLoc);
13672 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
13679 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
13687 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
13692 bool ValueDependent =
false;
13693 bool CondIsTrue =
false;
13696 ValueDependent =
true;
13699 llvm::APSInt condEval(32);
13701 = VerifyIntegerConstantExpression(CondExpr, &condEval,
13702 diag::err_typecheck_choose_expr_requires_constant,
false);
13705 CondExpr = CondICE.
get();
13706 CondIsTrue = condEval.getZExtValue();
13709 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
13711 resType = ActiveExpr->
getType();
13717 return new (Context)
13718 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
13730 if (LangOpts.CPlusPlus) {
13731 Decl *ManglingContextDecl;
13734 ManglingContextDecl)) {
13735 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
13740 PushBlockScope(CurScope, Block);
13741 CurContext->addDecl(Block);
13743 PushDeclContext(CurScope, Block);
13745 CurContext = Block;
13747 getCurBlock()->HasImplicitReturnType =
true;
13751 PushExpressionEvaluationContext(
13752 ExpressionEvaluationContext::PotentiallyEvaluated);
13758 "block-id should have no identifier!");
13762 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
13767 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
13780 "GetTypeForDeclarator made a non-function block signature");
13791 if (ExplicitSignature.getLocalRangeBegin() ==
13792 ExplicitSignature.getLocalRangeEnd()) {
13795 TypeLoc Result = ExplicitSignature.getReturnLoc();
13804 CurBlock->TheDecl->setSignatureAsWritten(Sig);
13805 CurBlock->FunctionType = T;
13810 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
13812 CurBlock->TheDecl->setIsVariadic(isVariadic);
13819 CurBlock->ReturnType = RetTy;
13820 CurBlock->TheDecl->setBlockMissingReturnType(
false);
13821 CurBlock->HasImplicitReturnType =
false;
13826 if (ExplicitSignature) {
13827 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
13828 ParmVarDecl *Param = ExplicitSignature.getParam(I);
13832 !getLangOpts().CPlusPlus)
13834 Params.push_back(Param);
13840 for (
const auto &I : Fn->param_types()) {
13843 Params.push_back(Param);
13848 if (!Params.empty()) {
13849 CurBlock->TheDecl->setParams(Params);
13850 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
13855 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
13858 for (
auto AI : CurBlock->TheDecl->parameters()) {
13859 AI->setOwningFunction(CurBlock->TheDecl);
13862 if (AI->getIdentifier()) {
13863 CheckShadow(CurBlock->TheScope, AI);
13865 PushOnScopeChains(AI, CurBlock->TheScope);
13874 DiscardCleanupsInEvaluationContext();
13875 PopExpressionEvaluationContext();
13879 PopFunctionScopeInfo();
13887 if (!LangOpts.Blocks)
13888 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
13891 if (hasAnyUnrecoverableErrorsInThisFunction())
13892 DiscardCleanupsInEvaluationContext();
13893 assert(!Cleanup.exprNeedsCleanups() &&
13894 "cleanups within block not correctly bound!");
13895 PopExpressionEvaluationContext();
13897 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
13901 deduceClosureReturnType(*BSI);
13907 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
13915 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
13918 if (isa<FunctionNoProtoType>(FTy)) {
13945 DiagnoseUnusedParameters(BD->parameters());
13949 if (getCurFunction()->NeedsScopeChecking() &&
13950 !PP.isCodeCompletionEnabled())
13951 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
13953 BD->setBody(cast<CompoundStmt>(Body));
13955 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13956 DiagnoseUnguardedAvailabilityViolations(BD);
13962 !BD->isDependentContext())
13963 computeNRVO(Body, BSI);
13967 checkNonTrivialCUnion(RetTy, BD->getCaretLocation(), NTCUC_FunctionReturn,
13968 NTCUK_Destruct|NTCUK_Copy);
13983 Expr *CopyExpr =
nullptr;
13992 if (isa<ParmVarDecl>(Var))
13993 FinalizeVarWithDestructor(Var, Record);
14001 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
14005 ExprResult Result = BuildDeclarationNameExpr(
14012 !Result.
get()->getType().isConstQualified()) {
14013 Result = ImpCastExprToType(Result.
get(),
14014 Result.
get()->getType().withConst(),
14019 Result = PerformCopyInitialization(
14022 Loc, Result.
get());
14029 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
14031 Result = MaybeCreateExprWithCleanups(Result);
14032 CopyExpr = Result.
get();
14039 Captures.push_back(NewCap);
14050 Cleanup.setExprNeedsCleanups(
true);
14055 const VarDecl *var = CI.getVariable();
14057 setFunctionHasBranchProtectedScope();
14063 if (getCurFunction())
14064 getCurFunction()->addBlock(BD);
14072 GetTypeFromParser(Ty, &TInfo);
14073 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
14079 Expr *OrigExpr = E;
14083 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
14084 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
14086 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
14092 if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
14094 targetDiag(E->
getBeginLoc(), diag::err_va_arg_in_device);
14118 ExprResult Result = UsualUnaryConversions(E);
14122 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
14128 if (Init.isInvalid())
14130 E = Init.getAs<
Expr>();
14144 diag::err_first_argument_to_va_arg_not_of_type_va_list)
14149 diag::err_second_parameter_to_va_arg_incomplete,
14155 diag::err_second_parameter_to_va_arg_abstract,
14162 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
14163 : diag::warn_second_parameter_to_va_arg_not_pod)
14180 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
14187 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
14196 Ty = Context.
IntTy;
14202 llvm_unreachable(
"I don't know size of pointer!");
14211 return BuildSourceLocExpr(Kind, BuiltinLoc, RPLoc, CurContext);
14218 return new (Context)
14219 SourceLocExpr(Context, Kind, BuiltinLoc, RPLoc, ParentContext);
14224 if (!getLangOpts().ObjC)
14243 if (OV->getSourceExpr())
14252 Exp = BuildObjCStringLiteral(SL->
getBeginLoc(), SL).
get();
14258 const Expr *SrcExpr) {
14280 bool *Complained) {
14282 *Complained =
false;
14285 bool CheckInferredResultType =
false;
14287 unsigned DiagKind = 0;
14290 bool MayHaveConvFixit =
false;
14291 bool MayHaveFunctionDiff =
false;
14297 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
14301 DiagKind = diag::ext_typecheck_convert_pointer_int;
14303 MayHaveConvFixit =
true;
14306 DiagKind = diag::ext_typecheck_convert_int_pointer;
14308 MayHaveConvFixit =
true;
14310 case IncompatiblePointer:
14311 if (Action == AA_Passing_CFAudited)
14312 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
14315 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
14317 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
14321 if (Hint.
isNull() && !CheckInferredResultType) {
14324 else if (CheckInferredResultType) {
14328 MayHaveConvFixit =
true;
14330 case IncompatiblePointerSign:
14331 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
14333 case FunctionVoidPointer:
14334 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
14336 case IncompatiblePointerDiscardsQualifiers: {
14343 DiagKind = diag::err_typecheck_incompatible_address_space;
14347 DiagKind = diag::err_typecheck_incompatible_ownership;
14351 llvm_unreachable(
"unknown error case for discarding qualifiers!");
14354 case CompatiblePointerDiscardsQualifiers:
14365 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
14367 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
14369 case IncompatibleNestedPointerQualifiers:
14370 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
14372 case IncompatibleNestedPointerAddressSpaceMismatch:
14373 DiagKind = diag::err_typecheck_incompatible_nested_address_space;
14375 case IntToBlockPointer:
14376 DiagKind = diag::err_int_to_block_pointer;
14378 case IncompatibleBlockPointer:
14379 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
14381 case IncompatibleObjCQualifiedId: {
14385 for (
auto *srcProto : srcOPT->
quals()) {
14391 IFace = IFaceT->getDecl();
14396 for (
auto *dstProto : dstOPT->
quals()) {
14402 IFace = IFaceT->getDecl();
14404 DiagKind = diag::warn_incompatible_qualified_id;
14407 case IncompatibleVectors:
14408 DiagKind = diag::warn_incompatible_vectors;
14410 case IncompatibleObjCWeakRef:
14411 DiagKind = diag::err_arc_weak_unavailable_assign;
14416 *Complained =
true;
14420 DiagKind = diag::err_typecheck_convert_incompatible;
14422 MayHaveConvFixit =
true;
14424 MayHaveFunctionDiff =
true;
14431 case AA_Initializing:
14433 FirstType = DstType;
14434 SecondType = SrcType;
14439 case AA_Passing_CFAudited:
14440 case AA_Converting:
14444 FirstType = SrcType;
14445 SecondType = DstType;
14450 if (Action == AA_Passing_CFAudited)
14451 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
14453 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
14457 if (!ConvHints.
isNull()) {
14463 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
14465 if (MayHaveFunctionDiff)
14466 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
14469 if (DiagKind == diag::warn_incompatible_qualified_id &&
14471 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
14478 if (CheckInferredResultType)
14479 EmitRelatedResultTypeNote(SrcExpr);
14481 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
14482 EmitRelatedResultTypeNoteForReturn(DstType);
14485 *Complained =
true;
14490 llvm::APSInt *Result) {
14494 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
14498 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
14502 llvm::APSInt *Result,
14509 IDDiagnoser(
unsigned DiagID)
14513 S.
Diag(Loc, DiagID) << SR;
14515 } Diagnoser(DiagID);
14517 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
14522 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
14540 CXX11ConvertDiagnoser(
bool Silent)
14546 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
14551 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
14556 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
14567 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
14578 llvm_unreachable(
"conversion functions are permitted");
14580 } ConvertDiagnoser(Diagnoser.
Suppress);
14582 Converted = PerformContextualImplicitConversion(DiagLoc, E,
14586 E = Converted.
get();
14601 if (!isa<ConstantExpr>(E))
14608 EvalResult.
Diag = &Notes;
14616 if (!isa<ConstantExpr>(E))
14622 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
14631 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14632 diag::note_invalid_subexpr_in_const_expr) {
14633 DiagLoc = Notes[0].first;
14637 if (!Folded || !AllowFold) {
14641 Diag(Note.first, Note.second);
14649 Diag(Note.first, Note.second);
14659 class TransformToPE :
public TreeTransform<TransformToPE> {
14663 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
14666 bool AlwaysRebuild() {
return true; }
14667 bool ReplacingOriginal() {
return true; }
14677 if (isa<FieldDecl>(E->
getDecl()) &&
14680 diag::err_invalid_non_static_member_use)
14683 return BaseTransform::TransformDeclRefExpr(E);
14691 return BaseTransform::TransformUnaryOperator(E);
14699 return SkipLambdaBody(E, Body);
14705 assert(isUnevaluatedContext() &&
14706 "Should only transform unevaluated expressions");
14707 ExprEvalContexts.back().Context =
14708 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
14709 if (isUnevaluatedContext())
14711 return TransformToPE(*this).TransformExpr(E);
14718 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
14719 LambdaContextDecl, ExprContext);
14721 if (!MaybeODRUseExprs.empty())
14722 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
14729 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
14730 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
14737 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
14738 if (E->getOpcode() == UO_Deref)
14739 return CheckPossibleDeref(S, E->getSubExpr());
14740 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
14741 return CheckPossibleDeref(S, E->getBase());
14742 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
14743 return CheckPossibleDeref(S, E->getBase());
14744 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
14750 Inner = Arr->getElementType();
14754 if (Inner->
hasAttr(attr::NoDeref))
14764 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
14771 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
14791 D = diag::err_lambda_unevaluated_operand;
14797 D = diag::err_lambda_in_constant_expression;
14798 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
14801 D = diag::err_lambda_in_invalid_context;
14803 llvm_unreachable(
"Couldn't infer lambda error message.");
14805 for (
const auto *L : Rec.
Lambdas)
14806 Diag(L->getBeginLoc(), D);
14810 WarnOnPendingNoDerefs(Rec);
14818 ExprCleanupObjects.end());
14820 CleanupVarDeclMarking();
14830 ExprEvalContexts.pop_back();
14833 ExprEvalContexts.back().NumTypos += NumTypos;
14837 ExprCleanupObjects.erase(
14838 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
14839 ExprCleanupObjects.end());
14841 MaybeODRUseExprs.clear();
14845 ExprResult Result = CheckPlaceholderExpr(E);
14851 return TransformToPotentiallyEvaluated(E);
14880 llvm_unreachable(
"Invalid context");
14889 if (!TT.isOSWindows() || (TT.getArch() != llvm::Triple::x86 &&
14890 TT.getArch() != llvm::Triple::x86_64))
14928 : FD(FD), Param(Param) {}
14935 CCName =
"stdcall";
14938 CCName =
"fastcall";
14941 CCName =
"vectorcall";
14944 llvm_unreachable(
"CC does not need mangling");
14947 S.
Diag(Loc, diag::err_cconv_incomplete_param_type)
14953 ParamIncompleteTypeDiagnoser Diagnoser(FD, Param);
14989 Result = OdrUseContext::FormallyOdrUsed;
14995 Result = OdrUseContext::FormallyOdrUsed;
15000 return OdrUseContext::Dependent;
15014 bool MightBeOdrUse) {
15015 assert(Func &&
"No function?");
15021 bool IsRecursiveCall = CurContext == Func;
15033 OdrUse = OdrUseContext::FormallyOdrUsed;
15039 bool NeededForConstantEvaluation =
15065 NeededForConstantEvaluation);
15072 if (NeedDefinition &&
15075 checkSpecializationVisibility(Loc, Func);
15088 ResolveExceptionSpec(Loc, FPT);
15090 if (getLangOpts().CUDA)
15091 CheckCUDACall(Loc, Func);
15094 if (NeedDefinition && !Func->
getBody()) {
15096 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
15097 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
15098 if (Constructor->isDefaultConstructor()) {
15099 if (Constructor->isTrivial() &&
15100 !Constructor->hasAttr<DLLExportAttr>())
15102 DefineImplicitDefaultConstructor(Loc, Constructor);
15103 }
else if (Constructor->isCopyConstructor()) {
15104 DefineImplicitCopyConstructor(Loc, Constructor);
15105 }
else if (Constructor->isMoveConstructor()) {
15106 DefineImplicitMoveConstructor(Loc, Constructor);
15108 }
else if (Constructor->getInheritedConstructor()) {
15109 DefineInheritingConstructor(Loc, Constructor);
15112 dyn_cast<CXXDestructorDecl>(Func)) {
15113 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
15114 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
15115 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
15117 DefineImplicitDestructor(Loc, Destructor);
15119 if (Destructor->isVirtual() && getLangOpts().AppleKext)
15120 MarkVTableUsed(Loc, Destructor->getParent());
15121 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
15122 if (MethodDecl->isOverloadedOperator() &&
15123 MethodDecl->getOverloadedOperator() == OO_Equal) {
15124 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
15125 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
15126 if (MethodDecl->isCopyAssignmentOperator())
15127 DefineImplicitCopyAssignment(Loc, MethodDecl);
15128 else if (MethodDecl->isMoveAssignmentOperator())
15129 DefineImplicitMoveAssignment(Loc, MethodDecl);
15131 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
15132 MethodDecl->getParent()->isLambda()) {
15134 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
15136 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
15138 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
15139 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
15140 MarkVTableUsed(Loc, MethodDecl->getParent());
15149 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
15150 if (FirstInstantiation) {
15151 PointOfInstantiation = Loc;
15157 PointOfInstantiation = Loc;
15164 CodeSynthesisContexts.size())
15165 PendingLocalImplicitInstantiations.push_back(
15166 std::make_pair(Func, PointOfInstantiation));
15171 InstantiateFunctionDefinition(PointOfInstantiation, Func);
15174 PendingInstantiations.push_back(
15175 std::make_pair(Func, PointOfInstantiation));
15177 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
15183 if (!
i->isUsed(
false) &&
i->isImplicitlyInstantiable())
15184 MarkFunctionReferenced(Loc,
i, MightBeOdrUse);
15193 if (mightHaveNonExternalLinkage(Func))
15196 !LangOpts.GNUInline &&
15199 else if (isExternalWithNoLinkageType(Func))
15211 if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
15212 checkOpenMPDeviceFunction(Loc, Func);
15225 const unsigned *
const FunctionScopeIndexToStopAt =
nullptr) {
15236 QualType CaptureType, DeclRefType;
15242 CaptureType, DeclRefType,
15243 FunctionScopeIndexToStopAt);
15250 unsigned CapturingScopeIndex) {
15262 if (isa<ParmVarDecl>(var) &&
15263 isa<TranslationUnitDecl>(VarDC))
15276 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
15278 if (isa<CXXMethodDecl>(VarDC) &&
15279 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
15281 }
else if (isa<FunctionDecl>(VarDC)) {
15283 }
else if (isa<BlockDecl>(VarDC)) {
15287 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
15288 << var << ValueKind << ContextKind << VarDC;
15298 bool &SubCapturesAreNested,
15304 SubCapturesAreNested =
true;
15317 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
15318 !(isa<CapturedRegionScopeInfo>(CSI) &&
15319 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
15330 const bool Diagnose,
Sema &S) {
15345 const bool Diagnose,
Sema &S) {
15347 bool IsBlock = isa<BlockScopeInfo>(CSI);
15348 bool IsLambda = isa<LambdaScopeInfo>(CSI);
15356 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
15365 S.
Diag(Loc, diag::err_ref_vm_type);
15374 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
15377 S.
Diag(Loc, diag::err_ref_flexarray_type);
15379 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
15387 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
15390 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
15392 S.
Diag(Loc, diag::err_capture_block_variable)
15403 S.
Diag(Loc, diag::err_opencl_block_ref_block);
15413 const bool BuildAndDiagnose,
15417 Sema &S,
bool Invalid) {
15418 bool ByRef =
false;
15424 if (BuildAndDiagnose) {
15425 S.
Diag(Loc, diag::err_ref_array_type);
15437 if (BuildAndDiagnose) {
15438 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
15454 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
15456 if (AttrTy->getAttrKind() == attr::ObjCOwnership)
15460 Ty = AttrTy->getModifiedType();
15470 !IsObjCOwnershipAttributedType(PointeeTy)) {
15471 if (BuildAndDiagnose) {
15473 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
15474 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
15479 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
15488 DeclRefType = CaptureType;
15492 if (BuildAndDiagnose)
15494 CaptureType, Invalid);
15504 const bool BuildAndDiagnose,
15507 const bool RefersToCapturedVariable,
15508 Sema &S,
bool Invalid) {
15526 CaptureType = DeclRefType;
15529 if (BuildAndDiagnose)
15530 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
15540 const bool BuildAndDiagnose,
15543 const bool RefersToCapturedVariable,
15546 const bool IsTopScope,
15547 Sema &S,
bool Invalid) {
15549 bool ByRef =
false;
15583 if (!RefType->getPointeeType()->isFunctionType())
15590 if (BuildAndDiagnose) {
15591 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
15601 if (!Invalid && BuildAndDiagnose) {
15604 diag::err_capture_of_incomplete_type,
15608 diag::err_capture_of_abstract_type))
15628 if (BuildAndDiagnose)
15629 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
15630 Loc, EllipsisLoc, CaptureType, Invalid);
15638 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
15646 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
15647 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
15650 if (FunctionScopeIndexToStopAt) {
15651 unsigned FSIndex = FunctionScopes.size() - 1;
15652 while (FSIndex != MaxFunctionScopesIndex) {
15661 if (VarDC == DC)
return true;
15667 !(LangOpts.OpenMP && isOpenMPCapturedDecl(Var,
true,
15668 MaxFunctionScopesIndex)))
15680 CaptureType = Var->
getType();
15682 bool Nested =
false;
15683 bool Explicit = (Kind != TryCapture_Implicit);
15684 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
15697 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
15718 if (BuildAndDiagnose) {
15736 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
15737 QTy = PVD->getOriginalType();
15741 if (getLangOpts().OpenMP) {
15742 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
15747 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
15748 auto IsTargetCap = !IsOpenMPPrivateDecl &&
15749 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
15754 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
15756 if (IsTargetCap || IsOpenMPPrivateDecl) {
15757 Nested = !IsTargetCap;
15768 if (BuildAndDiagnose) {
15772 if (cast<LambdaScopeInfo>(CSI)->Lambda)
15773 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getBeginLoc(),
15774 diag::note_lambda_decl);
15790 FunctionScopesIndex--;
15793 }
while (!VarDC->
Equals(DC));
15800 bool Invalid =
false;
15801 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
15814 if (Invalid && !BuildAndDiagnose)
15818 Invalid = !
captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
15819 DeclRefType, Nested, *
this, Invalid);
15823 CaptureType, DeclRefType, Nested,
15830 DeclRefType, Nested, Kind, EllipsisLoc,
15831 I == N - 1, *
this, Invalid);
15835 if (Invalid && !BuildAndDiagnose)
15845 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
15847 DeclRefType,
nullptr);
15853 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15854 false, CaptureType,
15855 DeclRefType,
nullptr);
15863 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15864 false, CaptureType,
15865 DeclRefType,
nullptr))
15868 return DeclRefType;
15876 class CopiedTemplateArgs {
15880 template<
typename RefExpr>
15881 CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
15883 E->copyTemplateArgumentsInto(TemplateArgStorage);
15886 #ifdef __has_cpp_attribute
15887 #
if __has_cpp_attribute(clang::lifetimebound)
15888 [[clang::lifetimebound]]
15892 return HasArgs ? &TemplateArgStorage :
nullptr;
15918 auto Rebuild = [&](
Expr *Sub) {
15923 auto IsPotentialResultOdrUsed = [&](
NamedDecl *D) {
15926 auto *VD = dyn_cast<
VarDecl>(D);
15949 llvm_unreachable(
"unexpected non-odr-use-reason");
15953 if (VD->getType()->isReferenceType())
15955 if (
auto *RD = VD->getType()->getAsCXXRecordDecl())
15956 if (RD->hasMutableFields())
15958 if (!VD->isUsableInConstantExpressions(S.
Context))
15963 if (VD->getType()->isReferenceType())
15971 auto MarkNotOdrUsed = [&] {
15974 LSI->markVariableExprAsNonODRUsed(E);
15981 case Expr::DeclRefExprClass: {
15982 auto *DRE = cast<DeclRefExpr>(E);
15983 if (DRE->isNonOdrUse() || IsPotentialResultOdrUsed(DRE->getDecl()))
15989 S.
Context, DRE->getQualifierLoc(), DRE->getTemplateKeywordLoc(),
15990 DRE->getDecl(), DRE->refersToEnclosingVariableOrCapture(),
15991 DRE->getNameInfo(), DRE->getType(), DRE->getValueKind(),
15992 DRE->getFoundDecl(), CopiedTemplateArgs(DRE), NOUR);
15995 case Expr::FunctionParmPackExprClass: {
15996 auto *FPPE = cast<FunctionParmPackExpr>(E);
16000 if (IsPotentialResultOdrUsed(D))
16011 case Expr::ArraySubscriptExprClass: {
16012 auto *ASE = cast<ArraySubscriptExpr>(E);
16014 if (!OldBase->getType()->isArrayType())
16019 Expr *LHS = ASE->getBase() == ASE->getLHS() ? Base.
get() : ASE->getLHS();
16020 Expr *RHS = ASE->getBase() == ASE->getRHS() ? Base.
get() : ASE->getRHS();
16023 ASE->getRBracketLoc());
16026 case Expr::MemberExprClass: {
16027 auto *ME = cast<MemberExpr>(E);
16030 if (isa<FieldDecl>(ME->getMemberDecl())) {
16035 S.
Context, Base.
get(), ME->isArrow(), ME->getOperatorLoc(),
16036 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(),
16037 ME->getMemberDecl(), ME->getFoundDecl(), ME->getMemberNameInfo(),
16038 CopiedTemplateArgs(ME), ME->getType(), ME->getValueKind(),
16039 ME->getObjectKind(), ME->isNonOdrUse());
16042 if (ME->getMemberDecl()->isCXXInstanceMember())
16047 if (ME->isNonOdrUse() || IsPotentialResultOdrUsed(ME->getMemberDecl()))
16053 S.
Context, ME->getBase(), ME->isArrow(), ME->getOperatorLoc(),
16054 ME->getQualifierLoc(), ME->getTemplateKeywordLoc(), ME->getMemberDecl(),
16055 ME->getFoundDecl(), ME->getMemberNameInfo(), CopiedTemplateArgs(ME),
16056 ME->getType(), ME->getValueKind(), ME->getObjectKind(), NOUR);
16060 case Expr::BinaryOperatorClass: {
16061 auto *BO = cast<BinaryOperator>(E);
16062 Expr *LHS = BO->getLHS();
16063 Expr *RHS = BO->getRHS();
16065 if (BO->getOpcode() == BO_PtrMemD) {
16071 }
else if (BO->getOpcode() == BO_Comma) {
16079 return S.
BuildBinOp(
nullptr, BO->getOperatorLoc(), BO->getOpcode(),
16084 case Expr::ParenExprClass: {
16085 auto *PE = cast<ParenExpr>(E);
16087 if (!Sub.isUsable())
16089 return S.
ActOnParenExpr(PE->getLParen(), PE->getRParen(), Sub.get());
16094 case Expr::ConditionalOperatorClass: {
16095 auto *CO = cast<ConditionalOperator>(E);
16097 if (LHS.isInvalid())
16102 if (!LHS.isUsable() && !RHS.
isUsable())
16104 if (!LHS.isUsable())
16105 LHS = CO->getLHS();
16107 RHS = CO->getRHS();
16109 CO->getCond(), LHS.get(), RHS.
get());
16114 case Expr::UnaryOperatorClass: {
16115 auto *UO = cast<UnaryOperator>(E);
16116 if (UO->getOpcode() != UO_Extension)
16121 return S.
BuildUnaryOp(
nullptr, UO->getOperatorLoc(), UO_Extension,
16128 case Expr::GenericSelectionExprClass: {
16129 auto *GSE = cast<GenericSelectionExpr>(E);
16132 bool AnyChanged =
false;
16133 for (
Expr *OrigAssocExpr : GSE->getAssocExprs()) {
16134 ExprResult AssocExpr = Rebuild(OrigAssocExpr);
16138 AssocExprs.push_back(AssocExpr.
get());
16141 AssocExprs.push_back(OrigAssocExpr);
16146 GSE->getGenericLoc(), GSE->getDefaultLoc(),
16147 GSE->getRParenLoc(), GSE->getControllingExpr(),
16148 GSE->getAssocTypeSourceInfos(), AssocExprs)
16156 case Expr::ChooseExprClass: {
16157 auto *CE = cast<ChooseExpr>(E);
16160 if (LHS.isInvalid())
16167 if (!LHS.get() && !RHS.
get())
16169 if (!LHS.isUsable())
16170 LHS = CE->getLHS();
16172 RHS = CE->getRHS();
16174 return S.
ActOnChooseExpr(CE->getBuiltinLoc(), CE->getCond(), LHS.get(),
16175 RHS.
get(), CE->getRParenLoc());
16179 case Expr::ConstantExprClass: {
16180 auto *CE = cast<ConstantExpr>(E);
16182 if (!Sub.isUsable())
16189 case Expr::ImplicitCastExprClass: {
16190 auto *ICE = cast<ImplicitCastExpr>(E);
16194 switch (ICE->getCastKind()) {
16196 case CK_DerivedToBase:
16197 case CK_UncheckedDerivedToBase: {
16198 ExprResult Sub = Rebuild(ICE->getSubExpr());
16203 ICE->getValueKind(), &Path);
16228 NTCUK_Destruct|NTCUK_Copy);
16240 return Result.
get() ? Result : E;
16244 Res = CorrectDelayedTyposInExpr(Res);
16253 return CheckLValueToRValueConversionOperand(Res.
get());
16260 std::swap(LocalMaybeODRUseExprs, MaybeODRUseExprs);
16262 for (
Expr *E : LocalMaybeODRUseExprs) {
16263 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
16265 DRE->getLocation(), *
this);
16266 }
else if (
auto *ME = dyn_cast<MemberExpr>(E)) {
16269 }
else if (
auto *FP = dyn_cast<FunctionParmPackExpr>(E)) {
16273 llvm_unreachable(
"Unexpected expression");
16277 assert(MaybeODRUseExprs.empty() &&
16278 "MarkVarDeclODRUsed failed to cleanup MaybeODRUseExprs?");
16283 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E) ||
16284 isa<FunctionParmPackExpr>(E)) &&
16285 "Invalid Expr argument to DoMarkVarDeclReferenced");
16296 bool UsableInConstantExpr =
16304 bool NeededForConstantEvaluation =
16307 bool NeedDefinition =
16312 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
16313 "Can't instantiate a partial template specialization.");
16319 !isa<VarTemplateSpecializationDecl>(Var))
16330 bool TryInstantiating =
16334 if (TryInstantiating) {
16337 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
16338 if (FirstInstantiation) {
16339 PointOfInstantiation = Loc;
16341 MSI->setPointOfInstantiation(PointOfInstantiation);
16346 bool InstantiationDependent =
false;
16347 bool IsNonDependent =
16353 if (IsNonDependent) {
16354 if (UsableInConstantExpr) {
16358 }
else if (FirstInstantiation ||
16359 isa<VarTemplateSpecializationDecl>(Var)) {
16366 .push_back(std::make_pair(Var, PointOfInstantiation));
16391 if (
DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(E))
16392 if (DRE->isNonOdrUse())
16394 if (
MemberExpr *ME = dyn_cast_or_null<MemberExpr>(E))
16395 if (ME->isNonOdrUse())
16400 assert((!E || isa<FunctionParmPackExpr>(E)) &&
16401 "missing non-odr-use marking for unevaluated decl ref");
16404 case OdrUseContext::FormallyOdrUsed:
16418 case OdrUseContext::Dependent:
16423 const bool RefersToEnclosingScope =
16426 if (RefersToEnclosingScope) {
16441 assert(E &&
"Capture variable should be used in an expression.");
16459 Decl *D,
Expr *E,
bool MightBeOdrUse) {
16463 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
16479 bool IsVirtualCall = MD->
isVirtual() &&
16481 if (!IsVirtualCall)
16497 bool OdrUse =
true;
16499 if (Method->isVirtual() &&
16500 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
16513 bool MightBeOdrUse =
true;
16516 if (Method->isPure())
16517 MightBeOdrUse =
false;
16535 bool MightBeOdrUse) {
16536 if (MightBeOdrUse) {
16537 if (
auto *VD = dyn_cast<VarDecl>(D)) {
16538 MarkVariableReferenced(Loc, VD);
16542 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
16543 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
16570 bool MarkReferencedDecls::TraverseTemplateArgument(
16584 return Inherited::TraverseTemplateArgument(Arg);
16588 MarkReferencedDecls Marker(*
this, Loc);
16589 Marker.TraverseType(T);
16597 bool SkipLocalVariables;
16602 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
16603 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
16607 if (SkipLocalVariables) {
16609 if (VD->hasLocalStorage())
16618 Inherited::VisitMemberExpr(E);
16633 Inherited::VisitCXXNewExpr(E);
16641 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
16645 Inherited::VisitCXXDeleteExpr(E);
16650 Inherited::VisitCXXConstructExpr(E);
16665 bool SkipLocalVariables) {
16666 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
16687 switch (ExprEvalContexts.back().Context) {
16688 case ExpressionEvaluationContext::Unevaluated:
16689 case ExpressionEvaluationContext::UnevaluatedList:
16690 case ExpressionEvaluationContext::UnevaluatedAbstract:
16691 case ExpressionEvaluationContext::DiscardedStatement:
16695 case ExpressionEvaluationContext::ConstantEvaluated:
16699 case ExpressionEvaluationContext::PotentiallyEvaluated:
16700 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
16701 if (!Stmts.empty() && getCurFunctionOrMethodDecl()) {
16702 FunctionScopes.back()->PossiblyUnreachableDiags.
16712 if (
auto *VD = dyn_cast_or_null<VarDecl>(
16713 ExprEvalContexts.back().ManglingContextDecl)) {
16714 if (VD->isConstexpr() ||
16715 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
16730 return DiagRuntimeBehavior(
16731 Loc, Statement ? llvm::makeArrayRef(Statement) :
llvm::None, PD);
16741 if (ExprEvalContexts.back().ExprContext ==
16742 ExpressionEvaluationContextRecord::EK_Decltype) {
16743 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
16747 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
16753 : FD(FD), CE(CE) { }
16757 S.
Diag(Loc, diag::err_call_incomplete_return)
16762 S.
Diag(Loc, diag::err_call_function_incomplete_return)
16767 } Diagnoser(FD, CE);
16769 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
16780 unsigned diagnostic = diag::warn_condition_is_assignment;
16781 bool IsOrAssign =
false;
16784 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
16787 IsOrAssign = Op->getOpcode() == BO_OrAssign;
16791 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
16795 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
16796 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16800 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16803 Loc = Op->getOperatorLoc();
16805 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
16808 IsOrAssign = Op->getOperator() == OO_PipeEqual;
16809 Loc = Op->getOperatorLoc();
16811 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
16821 Diag(Loc, diag::note_condition_assign_silence)
16826 Diag(Loc, diag::note_condition_or_assign_to_comparison)
16829 Diag(Loc, diag::note_condition_assign_to_comparison)
16847 if (opE->getOpcode() == BO_EQ &&
16848 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
16854 Diag(Loc, diag::note_equality_comparison_silence)
16857 Diag(Loc, diag::note_equality_comparison_to_assign)
16863 bool IsConstexpr) {
16864 DiagnoseAssignmentAsCondition(E);
16865 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
16866 DiagnoseEqualityWithExtraParens(parenE);
16873 if (getLangOpts().CPlusPlus)
16874 return CheckCXXBooleanCondition(E, IsConstexpr);
16876 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
16883 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
16901 case ConditionKind::Boolean:
16902 Cond = CheckBooleanCondition(Loc, SubExpr);
16905 case ConditionKind::ConstexprIf:
16906 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
16909 case ConditionKind::Switch:
16910 Cond = CheckSwitchCondition(Loc, SubExpr);
16914 return ConditionError();
16918 if (!FullExpr.
get())
16919 return ConditionError();
16922 CK == ConditionKind::ConstexprIf);
16928 struct RebuildUnknownAnyFunction
16929 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
16933 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
16936 llvm_unreachable(
"unexpected statement!");
16940 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
16947 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16948 ExprResult SubResult = Visit(E->getSubExpr());
16951 Expr *SubExpr = SubResult.
get();
16952 E->setSubExpr(SubExpr);
16953 E->setType(SubExpr->
getType());
16960 return rebuildSugarExpr(E);
16964 return rebuildSugarExpr(E);
16971 Expr *SubExpr = SubResult.
get();
16980 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
16985 if (S.getLangOpts().CPlusPlus &&
16986 !(isa<CXXMethodDecl>(VD) &&
16987 cast<CXXMethodDecl>(VD)->isInstance()))
16998 return resolveDecl(E, E->
getDecl());
17006 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
17016 struct RebuildUnknownAnyExpr
17017 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
17025 : S(S), DestType(CastType) {}
17028 llvm_unreachable(
"unexpected statement!");
17032 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
17042 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
17043 ExprResult SubResult = Visit(E->getSubExpr());
17045 Expr *SubExpr = SubResult.
get();
17046 E->setSubExpr(SubExpr);
17047 E->setType(SubExpr->
getType());
17054 return rebuildSugarExpr(E);
17058 return rebuildSugarExpr(E);
17096 return resolveDecl(E, E->
getDecl());
17107 FK_FunctionPointer,
17114 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
17115 Kind = FK_MemberFunction;
17119 Kind = FK_FunctionPointer;
17122 Kind = FK_BlockPointer;
17127 if (DestType->isArrayType() || DestType->isFunctionType()) {
17128 unsigned diagID = diag::err_func_returning_array_function;
17129 if (Kind == FK_BlockPointer)
17130 diagID = diag::err_block_returning_array_function;
17133 << DestType->isFunctionType() << DestType;
17166 if (ParamTypes.empty() && Proto->isVariadic()) {
17176 ArgTypes.push_back(ArgType);
17178 ParamTypes = ArgTypes;
17181 Proto->getExtProtoInfo());
17189 case FK_MemberFunction:
17193 case FK_FunctionPointer:
17197 case FK_BlockPointer:
17203 ExprResult CalleeResult = Visit(CalleeExpr);
17213 if (DestType->isArrayType() || DestType->isFunctionType()) {
17214 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
17215 << DestType->isFunctionType() << DestType;
17222 Method->setReturnType(DestType);
17226 E->
setType(DestType.getNonReferenceType());
17234 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
17241 DestType = DestType->castAs<
PointerType>()->getPointeeType();
17248 }
else if (E->
getCastKind() == CK_LValueToRValue) {
17252 assert(isa<BlockPointerType>(E->
getType()));
17265 llvm_unreachable(
"Unhandled cast type!");
17298 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
17301 S.
Context, FD->getDeclContext(), Loc, Loc,
17302 FD->getNameInfo().getName(), DestType, FD->getTypeSourceInfo(),
17303 SC_None,
false , FD->hasPrototype(),
17306 if (FD->getQualifier())
17310 for (
const auto &AI : FT->param_types()) {
17314 Params.push_back(Param);
17316 NewFD->setParams(Params);
17317 DRE->setDecl(NewFD);
17318 VD = DRE->getDecl();
17323 if (MD->isInstance()) {
17333 }
else if (isa<VarDecl>(VD)) {
17337 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
17365 diag::err_typecheck_cast_to_incomplete))
17369 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
17372 CastExpr = result.
get();
17374 CastKind = CK_NoOp;
17380 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
17391 paramType = result.
get()->getType();
17403 return PerformCopyInitialization(entity, callLoc, arg);
17408 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
17411 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
17412 E = call->getCallee();
17413 diagID = diag::err_uncasted_call_of_unknown_any;
17421 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
17422 loc = ref->getLocation();
17423 d = ref->getDecl();
17424 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
17425 loc = mem->getMemberLoc();
17426 d = mem->getMemberDecl();
17428 diagID = diag::err_uncasted_call_of_unknown_any;
17429 loc = msg->getSelectorStartLoc();
17430 d = msg->getMethodDecl();
17432 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
17433 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
17456 ExprResult Result = CorrectDelayedTyposInExpr(E);
17462 if (!placeholderType)
return E;
17464 switch (placeholderType->
getKind()) {
17467 case BuiltinType::Overload: {
17471 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
17477 if (resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
17481 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
17487 case BuiltinType::BoundMember: {
17492 if (isa<CXXPseudoDestructorExpr>(BME)) {
17493 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
17494 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
17495 if (ME->getMemberNameInfo().getName().getNameKind() ==
17497 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
17499 tryToRecoverWithCall(result, PD,
17505 case BuiltinType::ARCUnbridgedCast: {
17506 Expr *realCast = stripARCUnbridgedCast(E);
17507 diagnoseARCUnbridgedCast(realCast);
17512 case BuiltinType::UnknownAny:
17516 case BuiltinType::PseudoObject:
17517 return checkPseudoObjectRValue(E);
17519 case BuiltinType::BuiltinFn: {
17523 auto *FD = cast<FunctionDecl>(DRE->getDecl());
17524 if (FD->getBuiltinID() == Builtin::BI__noop) {
17526 CK_BuiltinFnToFnPtr)
17538 case BuiltinType::OMPArraySection:
17543 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 17544 case BuiltinType::Id: 17545 #include "clang/Basic/OpenCLImageTypes.def" 17546 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 17547 case BuiltinType::Id: 17548 #include "clang/Basic/OpenCLExtensionTypes.def" 17549 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 17550 #define PLACEHOLDER_TYPE(Id, SingletonId) 17551 #include "clang/AST/BuiltinTypes.def" 17555 llvm_unreachable(
"invalid placeholder type!");
17569 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
17570 "Unknown Objective-C Boolean value!");
17575 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
17583 return new (Context)
17591 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
17597 VersionTuple Version;
17598 if (Spec != AvailSpecs.end())
17603 if (getCurFunctionOrMethodDecl())
17604 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
17605 else if (getCurBlock() || getCurLambda())
17606 getCurFunction()->HasPotentialAvailabilityViolations =
true;
17608 return new (Context)
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.
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)
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
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 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...
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.
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.
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...
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
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
static void checkEnumComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
If two different enums are compared, raise a warning.
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.
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
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.
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.
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 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.
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 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...
void setKind(tok::TokenKind K)
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.
static void DiagnoseDivisionSizeofPointer(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
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
bool hasAddressSpace() const
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...
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
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...
CXXSpecialMember
Kinds of C++ special members.
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.
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)
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 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)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true)
Create a binary operation that may resolve to an overloaded operator.
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.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
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.
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.
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...
static ValueDecl * getCompareDecl(Expr *E)
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...
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.
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
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
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.
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 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...
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...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
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...
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)
LookupInObjCMethod - The parser has read a name in, and Sema has detected that we're currently inside...
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
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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
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...
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 isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const
Return true if the provided declaration VD should be captured by reference.
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...
SourceLocation getBeginLoc() const LLVM_READONLY
Qualifiers withoutObjCLifetime() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
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.
EnumDecl * getDecl() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
Complex-real conversions (C99 6.3.1.7)
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.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
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)
Defines the fixed point number interface.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
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...
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)
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.
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.
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...
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)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Represents a field injected from an anonymous union/struct into the parent scope. ...
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...
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.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
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)
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...
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...
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
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...
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 isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
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.
An attributed type is a type to which a type attribute has been applied.
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.
TypedefNameDecl * getTypedefNameForAnonDecl() const
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
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)
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.
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.
Represents a C array with a specified size that is not an integer-constant-expression.
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.
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
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.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
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...
Declaration of a template function.
SourceLocation getBeginLoc() const LLVM_READONLY
A class which abstracts out some details necessary for making a call.
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...
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
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
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)