47 #include "llvm/Support/ConvertUTF.h" 48 using namespace clang;
55 if (ParsingInitForAutoVars.count(D))
65 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
80 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
83 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
84 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
86 if (DC && !DC->
hasAttr<UnusedAttr>())
98 if (Method && Method->isDeleted() && Method->isDefaulted()) {
100 if (!Method->isImplicit())
106 if (CSM != CXXInvalid)
107 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
113 if (Ctor && Ctor->isInheritingConstructor())
114 return NoteDeletedInheritingConstructor(Ctor);
124 if (I->getStorageClass() !=
SC_None)
169 if (!DowngradeWarning && UsedFn)
172 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
173 : diag::ext_internal_in_extern_inline)
178 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
188 Diag(DeclBegin, diag::note_convert_inline_to_static)
207 bool ObjCPropertyAccess,
208 bool AvoidPartialAvailabilityChecks) {
210 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
214 if (Pos != SuppressedDiagnostics.end()) {
216 Diag(Suppressed.first, Suppressed.second);
227 if (cast<FunctionDecl>(D)->isMain())
228 Diag(Loc, diag::ext_main_used);
232 if (ParsingInitForAutoVars.count(D)) {
233 if (isa<BindingDecl>(D)) {
234 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
237 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
238 << D->
getDeclName() << cast<VarDecl>(D)->getType();
245 if (FD->isDeleted()) {
247 if (Ctor && Ctor->isInheritingConstructor())
248 Diag(Loc, diag::err_deleted_inherited_ctor_use)
250 << Ctor->getInheritedConstructor().getConstructor()->getParent();
252 Diag(Loc, diag::err_deleted_function_use);
253 NoteDeletedFunction(FD);
259 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
260 DeduceReturnType(FD, Loc))
263 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
267 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
269 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
274 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
276 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
285 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
287 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
288 << getCurFunction()->HasOMPDeclareReductionCombiner;
293 DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
294 AvoidPartialAvailabilityChecks);
309 return ": " + Message;
311 return std::string();
320 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
325 unsigned numFormalParams;
329 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
332 numFormalParams = MD->param_size();
333 calleeType = CT_Method;
334 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
335 numFormalParams = FD->param_size();
336 calleeType = CT_Function;
337 }
else if (isa<VarDecl>(D)) {
343 calleeType = CT_Function;
346 calleeType = CT_Block;
352 numFormalParams = proto->getNumParams();
364 unsigned nullPos = attr->getNullPos();
365 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
366 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
369 unsigned numArgsAfterSentinel = attr->getSentinel();
373 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
380 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
381 if (!sentinelExpr)
return;
390 = getLocForEndOfToken(sentinelExpr->
getLocEnd());
391 std::string NullValue;
392 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
394 else if (getLangOpts().CPlusPlus11)
395 NullValue =
"nullptr";
396 else if (PP.isMacroDefined(
"NULL"))
399 NullValue =
"(void*) 0";
402 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
404 Diag(MissingNilLoc, diag::warn_missing_sentinel)
428 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
432 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
437 CK_FunctionToPointerDecay).
get();
450 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
452 CK_ArrayToPointerDecay).
get();
464 if (UO->getOpcode() == UO_Deref &&
465 UO->getSubExpr()->IgnoreParenCasts()->
467 !UO->getType().isVolatileQualified()) {
469 S.
PDiag(diag::warn_indirection_through_null)
470 << UO->getSubExpr()->getSourceRange());
472 S.
PDiag(diag::note_indirection_through_null));
485 if (!Member || !Member->
isStr(
"isa"))
495 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
503 if (ObjectSetClass) {
546 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
550 if (getLangOpts().CPlusPlus &&
565 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
574 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
581 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
606 UpdateMarkingForLValueToRValue(E);
611 Cleanup.setExprNeedsCleanups(
true);
620 T = Atomic->getValueType().getUnqualifiedType();
629 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
632 Res = DefaultLvalueConversion(Res.
get());
647 CK_FunctionToPointerDecay).
get();
651 Res = DefaultLvalueConversion(Res.
get());
664 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
670 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
673 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
674 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
695 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
700 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
713 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
725 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
726 BTy->
getKind() == BuiltinType::Float)) {
727 if (getLangOpts().OpenCL &&
728 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
729 if (BTy->
getKind() == BuiltinType::Half) {
730 E = ImpCastExprToType(E, Context.
FloatTy, CK_FloatingCast).get();
733 E = ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast).get();
794 if (!Record->hasNonTrivialCopyConstructor() &&
795 !Record->hasNonTrivialMoveConstructor() &&
796 !Record->hasNonTrivialDestructor())
797 return VAK_ValidInCXX11;
805 if (getLangOpts().MSVCCompat)
806 return VAK_MSVCUndefined;
810 return VAK_Undefined;
820 case VAK_ValidInCXX11:
823 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
831 PDiag(diag::warn_pass_class_arg_to_vararg)
832 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
837 case VAK_MSVCUndefined:
840 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
841 << getLangOpts().CPlusPlus11 << Ty << CT);
847 diag::err_cannot_pass_non_trivial_c_struct_to_vararg) << Ty << CT;
851 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
855 << isa<InitListExpr>(E) << Ty << CT;
866 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
867 (CT == VariadicMethod ||
868 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
869 E = stripARCUnbridgedCast(E);
880 ExprResult ExprRes = DefaultArgumentPromotion(E);
887 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
894 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
914 diag::err_call_incomplete_argument))
931 if (SkipCast)
return false;
933 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
936 CK_FloatingRealToComplex);
940 CK_IntegralComplexToFloatingComplex);
973 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
974 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
976 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
978 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
991 }
else if (Order > 0) {
1006 bool ConvertFloat,
bool ConvertInt) {
1011 CK_IntegralToFloating);
1022 CK_IntegralComplexToFloatingComplex);
1027 CK_FloatingRealToComplex);
1036 QualType RHSType,
bool IsCompAssign) {
1042 if (LHSFloat && RHSFloat) {
1049 assert(order < 0 &&
"illegal float comparison");
1083 "The remaining types must be floating point types.");
1088 QualType LHSElemType = LHSComplex ?
1089 LHSComplex->getElementType() : LHSType;
1090 QualType RHSElemType = RHSComplex ?
1106 return Float128AndLongDouble &&
1108 &llvm::APFloat::PPCDoubleDouble());
1122 CK_IntegralComplexCast);
1128 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1131 QualType RHSType,
bool IsCompAssign) {
1136 if (LHSSigned == RHSSigned) {
1139 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1141 }
else if (!IsCompAssign)
1142 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1144 }
else if (order != (LHSSigned ? 1 : -1)) {
1148 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1150 }
else if (!IsCompAssign)
1151 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1158 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1160 }
else if (!IsCompAssign)
1161 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1170 RHS = (*doRHSCast)(S, RHS.
get(), result);
1172 LHS = (*doLHSCast)(S, LHS.
get(), result);
1182 bool IsCompAssign) {
1186 if (LHSComplexInt && RHSComplexInt) {
1190 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1191 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1193 return S.Context.getComplexType(ScalarType);
1196 if (LHSComplexInt) {
1199 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1200 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1202 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1203 CK_IntegralRealToComplex);
1208 assert(RHSComplexInt);
1212 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1213 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1217 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1218 CK_IntegralRealToComplex);
1227 bool IsCompAssign) {
1228 if (!IsCompAssign) {
1229 LHS = UsualUnaryConversions(LHS.
get());
1234 RHS = UsualUnaryConversions(RHS.
get());
1247 LHSType = AtomicLHS->getValueType();
1250 if (LHSType == RHSType)
1259 QualType LHSUnpromotedType = LHSType;
1263 if (!LHSBitfieldPromoteTy.
isNull())
1264 LHSType = LHSBitfieldPromoteTy;
1265 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1266 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1269 if (LHSType == RHSType)
1295 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1296 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1309 Expr *ControllingExpr,
1312 unsigned NumAssocs = ArgTypes.size();
1313 assert(NumAssocs == ArgExprs.size());
1316 for (
unsigned i = 0; i < NumAssocs; ++i) {
1318 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1323 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1325 llvm::makeArrayRef(Types, NumAssocs),
1335 Expr *ControllingExpr,
1338 unsigned NumAssocs = Types.size();
1339 assert(NumAssocs == Exprs.size());
1346 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1349 ControllingExpr = R.
get();
1354 if (!inTemplateInstantiation() &&
1357 diag::warn_side_effects_unevaluated_context);
1359 bool TypeErrorFound =
false,
1361 ContainsUnexpandedParameterPack
1364 for (
unsigned i = 0; i < NumAssocs; ++i) {
1365 if (Exprs[i]->containsUnexpandedParameterPack())
1366 ContainsUnexpandedParameterPack =
true;
1369 if (Types[i]->getType()->containsUnexpandedParameterPack())
1370 ContainsUnexpandedParameterPack =
true;
1372 if (Types[i]->getType()->isDependentType()) {
1373 IsResultDependent =
true;
1378 if (Types[i]->getType()->isIncompleteType())
1379 D = diag::err_assoc_type_incomplete;
1380 else if (!Types[i]->getType()->isObjectType())
1381 D = diag::err_assoc_type_nonobject;
1382 else if (Types[i]->getType()->isVariablyModifiedType())
1383 D = diag::err_assoc_type_variably_modified;
1386 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1387 << Types[i]->getTypeLoc().getSourceRange()
1388 << Types[i]->getType();
1389 TypeErrorFound =
true;
1394 for (
unsigned j = i+1; j < NumAssocs; ++j)
1395 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1397 Types[j]->getType())) {
1398 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1399 diag::err_assoc_compatible_types)
1400 << Types[j]->getTypeLoc().getSourceRange()
1401 << Types[j]->getType()
1402 << Types[i]->getType();
1403 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1404 diag::note_compat_assoc)
1405 << Types[i]->getTypeLoc().getSourceRange()
1406 << Types[i]->getType();
1407 TypeErrorFound =
true;
1417 if (IsResultDependent)
1419 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1420 ContainsUnexpandedParameterPack);
1423 unsigned DefaultIndex = -1U;
1424 for (
unsigned i = 0; i < NumAssocs; ++i) {
1428 Types[i]->getType()))
1429 CompatIndices.push_back(i);
1435 if (CompatIndices.size() > 1) {
1439 Diag(ControllingExpr->
getLocStart(), diag::err_generic_sel_multi_match)
1441 << (unsigned) CompatIndices.size();
1442 for (
unsigned I : CompatIndices) {
1443 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1444 diag::note_compat_assoc)
1445 << Types[I]->getTypeLoc().getSourceRange()
1446 << Types[I]->getType();
1454 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1468 unsigned ResultIndex =
1469 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1472 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1473 ContainsUnexpandedParameterPack, ResultIndex);
1491 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1494 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1495 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1496 if (ArgTy[ArgIdx]->isArrayType())
1523 assert(!StringToks.empty() &&
"Must have at least one string!");
1526 if (Literal.hadError)
1530 for (
const Token &
Tok : StringToks)
1531 StringTokLocs.push_back(
Tok.getLocation());
1535 if (Literal.isWide()) {
1538 }
else if (Literal.isUTF8()) {
1539 if (getLangOpts().Char8)
1542 }
else if (Literal.isUTF16()) {
1545 }
else if (Literal.isUTF32()) {
1548 }
else if (Literal.isPascal()) {
1554 if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
1563 CharTyConst, llvm::APInt(32, Literal.GetNumStringChars() + 1),
1568 Kind, Literal.Pascal, StrTy,
1570 StringTokLocs.size());
1571 if (Literal.getUDSuffix().empty())
1578 Literal.getUDSuffixOffset());
1582 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1597 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1598 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1604 llvm::APInt Len(Context.
getIntWidth(SizeType), Literal.GetNumStringChars());
1607 Expr *Args[] = { Lit, LenArg };
1609 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1612 case LOLR_StringTemplate: {
1617 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1623 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1629 return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
1634 case LOLR_ErrorNoDiagnostic:
1635 llvm_unreachable(
"unexpected literal operator lookup result");
1639 llvm_unreachable(
"unexpected literal operator lookup result");
1647 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1657 bool RefersToCapturedVariable =
1659 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1662 if (isa<VarTemplateSpecializationDecl>(D)) {
1664 cast<VarTemplateSpecializationDecl>(D);
1669 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1670 FoundD, TemplateArgs);
1672 assert(!TemplateArgs &&
"No template arguments for non-variable" 1673 " template specialization references");
1677 NameInfo, Ty, VK, FoundD);
1680 MarkDeclRefReferenced(E);
1682 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1684 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
1685 getCurFunction()->recordUseOfWeak(E);
1689 FD = IFD->getAnonField();
1691 UnusedPrivateFields.remove(FD);
1699 if (
auto *BD = dyn_cast<BindingDecl>(D))
1700 if (
auto *BE = BD->getBinding())
1701 E->setObjectKind(BE->getObjectKind());
1726 translateTemplateArguments(TemplateArgsPtr, Buffer);
1731 TemplateArgs = &Buffer;
1733 NameInfo = GetNameFromUnqualifiedId(Id);
1734 TemplateArgs =
nullptr;
1741 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1748 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1751 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
1756 bool DroppedSpecifier =
1759 ? diag::note_implicit_param_decl
1760 : diag::note_previous_decl;
1763 SemaRef.
PDiag(NoteID));
1766 << Typo << Ctx << DroppedSpecifier
1768 SemaRef.
PDiag(NoteID));
1776 std::unique_ptr<CorrectionCandidateCallback> CCC,
1781 unsigned diagnostic = diag::err_undeclared_var_use;
1782 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1786 diagnostic = diag::err_undeclared_use;
1787 diagnostic_suggest = diag::err_undeclared_use_suggest;
1796 if (isa<CXXRecordDecl>(DC)) {
1797 LookupQualifiedName(R, DC);
1806 bool isDefaultArgument =
1807 !CodeSynthesisContexts.empty() &&
1808 CodeSynthesisContexts.back().Kind ==
1809 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
1811 bool isInstance = CurMethod &&
1813 DC == CurMethod->
getParent() && !isDefaultArgument;
1818 if (getLangOpts().MSVCCompat)
1819 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1830 Diag(D->getLocation(), diag::note_dependent_var_use);
1836 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1837 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1852 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1853 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1864 assert(!ExplicitTemplateArgs &&
1865 "Diagnosing an empty lookup with explicit template args!");
1866 *Out = CorrectTypoDelayed(
1870 diagnostic, diagnostic_suggest);
1872 nullptr, CTK_ErrorRecovery);
1875 }
else if (S && (Corrected =
1877 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1878 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1879 bool DroppedSpecifier =
1883 bool AcceptableWithRecovery =
false;
1884 bool AcceptableWithoutRecovery =
false;
1893 dyn_cast<FunctionTemplateDecl>(CD))
1894 AddTemplateOverloadCandidate(
1897 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1898 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1902 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1904 ND = Best->FoundDecl;
1905 Corrected.setCorrectionDecl(ND);
1909 Corrected.setCorrectionDecl(ND);
1921 Record = cast<CXXRecordDecl>(
1927 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
1928 isa<FunctionTemplateDecl>(UnderlyingND);
1934 AcceptableWithoutRecovery =
1935 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
1939 AcceptableWithoutRecovery =
true;
1942 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
1944 ? diag::note_implicit_param_decl
1945 : diag::note_previous_decl;
1947 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
1948 PDiag(NoteID), AcceptableWithRecovery);
1950 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
1951 << Name << computeDeclContext(SS,
false)
1952 << DroppedSpecifier << SS.getRange(),
1953 PDiag(NoteID), AcceptableWithRecovery);
1956 return !AcceptableWithRecovery;
1963 if (!SS.isEmpty()) {
1965 << Name << computeDeclContext(SS,
false)
1992 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2000 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2001 DB << NameInfo.
getName() << RD;
2003 if (!ThisType.
isNull()) {
2006 Context,
nullptr, ThisType,
true,
2008 nullptr, NameInfo, TemplateArgs);
2025 bool HasTrailingLParen,
bool IsAddressOfOperand,
2026 std::unique_ptr<CorrectionCandidateCallback> CCC,
2027 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2028 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2029 "cannot be direct & operand and have a trailing lparen");
2038 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2061 bool DependentID =
false;
2065 }
else if (SS.
isSet()) {
2066 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2067 if (RequireCompleteDeclContext(SS, DC))
2075 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2076 IsAddressOfOperand, TemplateArgs);
2081 ? LookupObjCImplicitSelfParam
2082 : LookupOrdinaryName);
2083 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2089 bool MemberOfUnknownSpecialization;
2090 if (LookupTemplateName(R, S, SS,
QualType(),
false,
2091 MemberOfUnknownSpecialization, TemplateKWLoc))
2094 if (MemberOfUnknownSpecialization ||
2096 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2097 IsAddressOfOperand, TemplateArgs);
2099 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2100 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2105 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2106 IsAddressOfOperand, TemplateArgs);
2110 if (IvarLookupFollowUp) {
2111 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2125 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2126 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2132 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2134 if (R.
empty() && !ADL) {
2135 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2137 TemplateKWLoc, TemplateArgs))
2142 if (IsInlineAsmIdentifier)
2148 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2150 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2151 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2152 "Typo correction callback misconfigured");
2155 CCC->setTypoName(II);
2162 if (DiagnoseEmptyLookup(S, SS, R,
2163 CCC ? std::move(CCC) : std::move(DefaultValidator),
2164 nullptr, None, &TE)) {
2165 if (TE && KeywordReplacement) {
2166 auto &
State = getTypoExprState(TE);
2167 auto BestTC =
State.Consumer->getNextCorrection();
2168 if (BestTC.isKeyword()) {
2169 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2170 if (
State.DiagHandler)
2171 State.DiagHandler(BestTC);
2173 KeywordReplacement->
setKind(II->getTokenID());
2175 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2178 clearDelayedTypo(TE);
2181 return (
Expr*)
nullptr;
2183 State.Consumer->resetCorrectionStream();
2188 assert(!R.
empty() &&
2189 "DiagnoseEmptyLookup returned false but added no results");
2196 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2206 assert(!R.
empty() || ADL);
2232 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2233 bool MightBeImplicitMember;
2234 if (!IsAddressOfOperand)
2235 MightBeImplicitMember =
true;
2237 MightBeImplicitMember =
false;
2239 MightBeImplicitMember =
false;
2241 MightBeImplicitMember =
true;
2243 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2247 if (MightBeImplicitMember)
2248 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2249 R, TemplateArgs, S);
2252 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2260 "There should only be one declaration found.");
2263 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2266 return BuildDeclarationNameExpr(SS, R, ADL);
2281 if (RequireCompleteDeclContext(SS, DC))
2285 LookupQualifiedName(R, DC);
2304 unsigned DiagID = diag::err_typename_missing;
2305 if (RecoveryTSI && getLangOpts().MSVCCompat)
2306 DiagID = diag::ext_typename_missing;
2308 auto D =
Diag(Loc, DiagID);
2339 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2340 return BuildPossibleImplicitMemberExpr(SS,
2344 return BuildDeclarationNameExpr(SS, R,
false);
2378 LookForIvars =
true;
2379 else if (IsClassMethod)
2380 LookForIvars =
false;
2392 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2401 if (DiagnoseUseOfDecl(IV, Loc))
2407 !getLangOpts().DebuggerSupport)
2418 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2419 SelfName,
false,
false);
2423 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2427 MarkAnyDeclReferenced(Loc, IV,
true);
2431 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2439 if (!isUnevaluatedContext() &&
2440 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2441 getCurFunction()->recordUseOfWeak(Result);
2443 if (getLangOpts().ObjCAutoRefCount) {
2444 if (CurContext->isClosure())
2445 Diag(Loc, diag::warn_implicitly_retains_self)
2458 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2465 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2466 << IV->getDeclName());
2469 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2515 bool PointerConversions =
false;
2516 if (isa<FieldDecl>(Member)) {
2522 PointerConversions =
true;
2524 DestType = DestRecordType;
2525 FromRecordType = FromType;
2527 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2528 if (Method->isStatic())
2531 DestType = Method->getThisType(Context);
2536 PointerConversions =
true;
2538 FromRecordType = FromType;
2539 DestType = DestRecordType;
2576 if (Qualifier && Qualifier->
getAsType()) {
2578 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2585 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2587 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2588 FromLoc, FromRange, &BasePath))
2591 if (PointerConversions)
2593 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2594 VK, &BasePath).get();
2597 FromRecordType = QRecordType;
2606 bool IgnoreAccess =
false;
2614 assert(isa<UsingShadowDecl>(FoundDecl));
2621 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2623 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2624 FromLoc, FromRange, &BasePath))
2628 if (PointerConversions)
2630 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2631 VK, &BasePath).get();
2633 FromRecordType = URecordType;
2638 IgnoreAccess =
true;
2642 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2643 FromLoc, FromRange, &BasePath,
2647 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2653 bool HasTrailingLParen) {
2655 if (!HasTrailingLParen)
2663 if (!getLangOpts().CPlusPlus)
2673 if (D->isCXXClassMember())
2682 if (isa<UsingShadowDecl>(D))
2683 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2684 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2691 if (isa<FunctionDecl>(D)) {
2697 }
else if (!isa<FunctionTemplateDecl>(D))
2713 if (isa<TypedefNameDecl>(D)) {
2718 if (isa<ObjCInterfaceDecl>(D)) {
2723 if (isa<NamespaceDecl>(D)) {
2737 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
2742 bool AcceptInvalidDecl) {
2782 bool AcceptInvalidDecl) {
2783 assert(D &&
"Cannot refer to a NULL declaration");
2784 assert(!isa<FunctionTemplateDecl>(D) &&
2785 "Cannot refer unambiguously to a function template");
2791 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2794 diagnoseMissingTemplateArguments(
TemplateName(Template), Loc);
2801 Diag(Loc, diag::err_ref_non_value)
2811 if (DiagnoseUseOfDecl(VD, Loc))
2822 if (!indirectField->isCXXClassMember())
2823 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2835 ResolveExceptionSpec(Loc, FPT);
2842 #define ABSTRACT_DECL(kind) 2843 #define VALUE(type, base) 2844 #define DECL(type, base) \ 2846 #include "clang/AST/DeclNodes.inc" 2847 llvm_unreachable(
"invalid value decl kind");
2850 case Decl::ObjCAtDefsField:
2851 case Decl::ObjCIvar:
2852 llvm_unreachable(
"forming non-member reference to ivar?");
2856 case Decl::EnumConstant:
2857 case Decl::UnresolvedUsingValue:
2858 case Decl::OMPDeclareReduction:
2867 case Decl::IndirectField:
2869 "building reference to field in C?");
2879 case Decl::NonTypeTemplateParm: {
2894 case Decl::VarTemplateSpecialization:
2895 case Decl::VarTemplatePartialSpecialization:
2896 case Decl::Decomposition:
2897 case Decl::OMPCapturedExpr:
2907 case Decl::ImplicitParam:
2908 case Decl::ParmVar: {
2916 if (!isUnevaluatedContext()) {
2917 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2918 if (!CapturedType.
isNull())
2919 type = CapturedType;
2925 case Decl::Binding: {
2931 auto *BD = cast<BindingDecl>(VD);
2932 if (BD->getDeclContext()->isFunctionOrMethod() &&
2933 BD->getDeclContext() != CurContext)
2939 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
2958 if (getLangOpts().CPlusPlus) {
2968 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
2969 isa<FunctionProtoType>(fty))
2978 case Decl::CXXDeductionGuide:
2979 llvm_unreachable(
"building reference to deduction guide");
2981 case Decl::MSProperty:
2985 case Decl::CXXMethod:
2990 = dyn_cast<FunctionProtoType>(VD->
getType()))
2998 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3004 case Decl::CXXConversion:
3005 case Decl::CXXDestructor:
3006 case Decl::CXXConstructor:
3011 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3018 Target.resize(CharByteWidth * (Source.size() + 1));
3019 char *ResultPtr = &Target[0];
3020 const llvm::UTF8 *ErrorPtr;
3022 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3025 Target.resize(ResultPtr - &Target[0]);
3031 Decl *currentDecl =
nullptr;
3033 currentDecl = BSI->TheDecl;
3035 currentDecl = LSI->CallOperator;
3037 currentDecl = CSI->TheCapturedDecl;
3039 currentDecl = getCurFunctionOrMethodDecl();
3042 Diag(Loc, diag::ext_predef_outside_function);
3048 if (cast<DeclContext>(currentDecl)->isDependentContext())
3054 unsigned Length = Str.length();
3056 llvm::APInt LengthI(32, Length + 1);
3083 default: llvm_unreachable(
"Unknown simple primary expr!");
3093 return BuildPredefinedExpr(Loc, IT);
3098 bool Invalid =
false;
3099 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3105 if (Literal.hadError())
3109 if (Literal.isWide())
3111 else if (Literal.isUTF8() && getLangOpts().Char8)
3113 else if (Literal.isUTF16())
3115 else if (Literal.isUTF32())
3117 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3123 if (Literal.isWide())
3125 else if (Literal.isUTF16())
3127 else if (Literal.isUTF32())
3129 else if (Literal.isUTF8())
3135 if (Literal.getUDSuffix().empty())
3145 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3156 Context.
IntTy, Loc);
3163 using llvm::APFloat;
3164 APFloat Val(Format);
3170 if ((result & APFloat::opOverflow) ||
3171 ((result & APFloat::opUnderflow) && Val.isZero())) {
3172 unsigned diagnostic;
3174 if (result & APFloat::opOverflow) {
3175 diagnostic = diag::warn_float_overflow;
3176 APFloat::getLargest(Format).toString(buffer);
3178 diagnostic = diag::warn_float_underflow;
3179 APFloat::getSmallest(Format).toString(buffer);
3182 S.
Diag(Loc, diagnostic)
3184 << StringRef(buffer.data(), buffer.size());
3187 bool isExact = (result == APFloat::opOK);
3192 assert(E &&
"Invalid expression");
3199 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3203 llvm::APSInt ValueAPS;
3204 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3209 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3210 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3211 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3212 << ValueAPS.toString(10) << ValueIsPositive;
3223 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3224 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3232 SpellingBuffer.resize(Tok.
getLength() + 1);
3235 bool Invalid =
false;
3236 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3241 if (Literal.hadError)
3244 if (Literal.hasUDSuffix()) {
3252 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3255 if (Literal.isFloatingLiteral()) {
3276 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3277 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3280 !Literal.isImaginary)) {
3281 case LOLR_ErrorNoDiagnostic:
3289 if (Literal.isFloatingLiteral()) {
3293 if (Literal.GetIntegerValue(ResultVal))
3299 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3306 unsigned Length = Literal.getUDSuffixOffset();
3312 false, StrTy, &TokLoc, 1);
3313 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3316 case LOLR_Template: {
3323 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3324 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3325 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3326 Value = TokSpelling[I];
3331 return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
3334 case LOLR_StringTemplate:
3335 llvm_unreachable(
"unexpected literal operator lookup result");
3341 if (Literal.isFixedPointLiteral()) {
3344 if (Literal.isAccum) {
3345 if (Literal.isHalf) {
3347 }
else if (Literal.isLong) {
3352 }
else if (Literal.isFract) {
3353 if (Literal.isHalf) {
3355 }
else if (Literal.isLong) {
3364 bool isSigned = !Literal.isUnsigned;
3369 llvm::APInt Val(bit_width, 0, isSigned);
3370 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3374 auto MaxVal = llvm::APInt::getMaxValue(ibits + scale).zextOrSelf(bit_width);
3375 if (Literal.isFract && Val == MaxVal + 1)
3381 else if (Val.ugt(MaxVal) || Overflowed)
3386 }
else if (Literal.isFloatingLiteral()) {
3388 if (Literal.isHalf){
3389 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3395 }
else if (Literal.isFloat)
3397 else if (Literal.isLong)
3399 else if (Literal.isFloat16)
3401 else if (Literal.isFloat128)
3409 if (getLangOpts().SinglePrecisionConstants) {
3411 if (BTy->
getKind() != BuiltinType::Float) {
3412 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3414 }
else if (getLangOpts().OpenCL &&
3415 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3418 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3421 }
else if (!Literal.isIntegerLiteral()) {
3427 if (!getLangOpts().
C99 && Literal.isLongLong) {
3430 getLangOpts().CPlusPlus11 ?
3431 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3433 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
3438 llvm::APInt ResultVal(MaxWidth, 0);
3440 if (Literal.GetIntegerValue(ResultVal)) {
3442 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3445 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
3446 "long long is not intmax_t?");
3453 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3459 if (Literal.MicrosoftInteger) {
3460 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3464 Width = Literal.MicrosoftInteger;
3466 !Literal.isUnsigned);
3470 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3475 if (ResultVal.isIntN(IntSize)) {
3477 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3479 else if (AllowUnsigned)
3486 if (Ty.
isNull() && !Literal.isLongLong) {
3490 if (ResultVal.isIntN(LongSize)) {
3492 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3494 else if (AllowUnsigned)
3498 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3499 const unsigned LongLongSize =
3502 getLangOpts().CPlusPlus
3504 ? diag::warn_old_implicitly_unsigned_long_cxx
3506 ext_old_implicitly_unsigned_long_cxx
3507 : diag::warn_old_implicitly_unsigned_long)
3508 << (LongLongSize > LongSize ? 0
3521 if (ResultVal.isIntN(LongLongSize)) {
3525 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3526 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3528 else if (AllowUnsigned)
3530 Width = LongLongSize;
3537 Diag(
Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3542 if (ResultVal.getBitWidth() != Width)
3543 ResultVal = ResultVal.trunc(Width);
3549 if (Literal.isImaginary) {
3553 Diag(
Tok.getLocation(), diag::ext_imaginary_constant);
3559 assert(E &&
"ActOnParenExpr() missing expr");
3560 return new (Context)
ParenExpr(L, R, E);
3571 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3577 "Scalar types should always be complete");
3593 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3594 << TraitKind << ArgRange;
3601 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3602 : diag::ext_sizeof_alignof_void_type;
3603 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3617 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3636 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3672 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3676 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3695 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3703 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3704 QualType OType = PVD->getOriginalType();
3709 Diag(PVD->getLocation(), diag::note_declared_at);
3773 if (RequireCompleteType(OpLoc, ExprType,
3774 diag::err_sizeof_alignof_incomplete_type,
3775 ExprKind, ExprRange))
3779 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3780 << ExprKind << ExprRange;
3799 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3805 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3807 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3808 D = ME->getMemberDecl();
3828 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3831 if (!FD->getParent()->isCompleteDefinition()) {
3832 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3841 if (!FD->getType()->isReferenceType())
3855 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
3861 assert(CSI !=
nullptr);
3867 #define TYPE(Class, Base) 3868 #define ABSTRACT_TYPE(Class, Base) 3869 #define NON_CANONICAL_TYPE(Class, Base) 3870 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 3871 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) 3872 #include "clang/AST/TypeNodes.def" 3879 case Type::ExtVector:
3882 case Type::Elaborated:
3883 case Type::TemplateSpecialization:
3884 case Type::ObjCObject:
3885 case Type::ObjCInterface:
3886 case Type::ObjCObjectPointer:
3887 case Type::ObjCTypeParam:
3889 llvm_unreachable(
"type class is never variably-modified!");
3890 case Type::Adjusted:
3891 T = cast<AdjustedType>(Ty)->getOriginalType();
3894 T = cast<DecayedType>(Ty)->getPointeeType();
3897 T = cast<PointerType>(Ty)->getPointeeType();
3899 case Type::BlockPointer:
3900 T = cast<BlockPointerType>(Ty)->getPointeeType();
3902 case Type::LValueReference:
3903 case Type::RValueReference:
3904 T = cast<ReferenceType>(Ty)->getPointeeType();
3906 case Type::MemberPointer:
3907 T = cast<MemberPointerType>(Ty)->getPointeeType();
3909 case Type::ConstantArray:
3910 case Type::IncompleteArray:
3912 T = cast<ArrayType>(Ty)->getElementType();
3914 case Type::VariableArray: {
3923 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3924 CapRecord = LSI->Lambda;
3925 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3926 CapRecord = CRSI->TheRecordDecl;
3929 auto ExprLoc = Size->getExprLoc();
3934 nullptr, SizeType,
nullptr,
3937 Field->setImplicit(
true);
3939 Field->setCapturedVLAType(VAT);
3949 case Type::FunctionProto:
3950 case Type::FunctionNoProto:
3951 T = cast<FunctionType>(Ty)->getReturnType();
3955 case Type::UnaryTransform:
3956 case Type::Attributed:
3957 case Type::SubstTemplateTypeParm:
3958 case Type::PackExpansion:
3963 T = cast<TypedefType>(Ty)->desugar();
3965 case Type::Decltype:
3966 T = cast<DecltypeType>(Ty)->desugar();
3969 case Type::DeducedTemplateSpecialization:
3970 T = cast<DeducedType>(Ty)->getDeducedType();
3972 case Type::TypeOfExpr:
3973 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
3976 T = cast<AtomicType>(Ty)->getValueType();
3994 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
3999 for (
auto I = FunctionScopes.rbegin(),
4000 E = std::prev(FunctionScopes.rend());
4006 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4007 DC = LSI->CallOperator;
4008 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4009 DC = CRSI->TheCapturedDecl;
4010 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4044 isInvalid = CheckVecStepExpr(E);
4049 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4052 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
4059 PE = TransformToPotentiallyEvaluated(E);
4082 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4086 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4092 if (V.
get()->isTypeDependent())
4104 return CT->getElementType();
4107 if (V.
get()->getType()->isArithmeticType())
4108 return V.
get()->getType();
4113 if (PR.
get() != V.
get()) {
4119 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4120 << (IsReal ?
"__real" :
"__imag");
4131 default: llvm_unreachable(
"Unknown unary op!");
4132 case tok::plusplus: Opc = UO_PostInc;
break;
4133 case tok::minusminus: Opc = UO_PostDec;
break;
4137 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4139 Input = Result.
get();
4141 return BuildUnaryOp(S, OpLoc, Opc, Input);
4152 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4155 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4163 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4165 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4173 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4177 if (isa<ParenListExpr>(base)) {
4178 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4180 base = result.
get();
4188 bool IsMSPropertySubscript =
false;
4191 if (!IsMSPropertySubscript) {
4192 ExprResult result = CheckPlaceholderExpr(base);
4195 base = result.
get();
4199 ExprResult result = CheckPlaceholderExpr(idx);
4219 if (IsMSPropertySubscript) {
4234 if (getLangOpts().CPlusPlus &&
4238 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4241 return CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4250 BuiltinType::OMPArraySection)) {
4251 ExprResult Result = CheckPlaceholderExpr(Base);
4254 Base = Result.
get();
4257 ExprResult Result = CheckPlaceholderExpr(LowerBound);
4260 Result = DefaultLvalueConversion(Result.
get());
4263 LowerBound = Result.
get();
4266 ExprResult Result = CheckPlaceholderExpr(Length);
4269 Result = DefaultLvalueConversion(Result.
get());
4272 Length = Result.
get();
4280 return new (Context)
4299 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4301 if (Res.isInvalid())
4303 diag::err_omp_typecheck_section_not_integer)
4305 LowerBound = Res.get();
4314 PerformOpenMPImplicitIntegerConversion(Length->
getExprLoc(), Length);
4315 if (Res.isInvalid())
4317 diag::err_omp_typecheck_section_not_integer)
4337 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4338 diag::err_omp_section_incomplete_type, Base))
4342 llvm::APSInt LowerBoundValue;
4346 if (LowerBoundValue.isNegative()) {
4347 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4355 llvm::APSInt LengthValue;
4359 if (LengthValue.isNegative()) {
4360 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4361 << LengthValue.toString(10,
true)
4366 }
else if (ColonLoc.
isValid() &&
4372 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4378 BuiltinType::OMPArraySection)) {
4379 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
4382 Base = Result.
get();
4384 return new (Context)
4392 Expr *LHSExp = Base;
4401 for (
auto *Op : {LHSExp, RHSExp}) {
4402 Op = Op->IgnoreImplicit();
4403 if (Op->getType()->isArrayType() && !Op->isLValue())
4410 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
4413 LHSExp = Result.
get();
4415 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
4418 RHSExp = Result.
get();
4426 Expr *BaseExpr, *IndexExpr;
4443 if (!LangOpts.isSubscriptPointerArithmetic())
4444 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4459 if (!LangOpts.isSubscriptPointerArithmetic()) {
4460 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4469 ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
4472 LHSExp = Materialized.
get();
4478 ResultType = VTy->getElementType();
4482 Qualifiers Combined = BaseQuals + MemberQuals;
4483 if (Combined != MemberQuals)
4494 CK_ArrayToPointerDecay).
get();
4500 }
else if (RHSTy->isArrayType()) {
4505 CK_ArrayToPointerDecay).
get();
4512 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4517 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4535 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4537 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4544 RequireCompleteType(LLoc, ResultType,
4545 diag::err_subscript_incomplete_type, BaseExpr))
4548 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4551 return new (Context)
4559 diag::err_use_of_default_argument_to_function_declared_later) <<
4561 Diag(UnparsedDefaultArgLocs[Param],
4562 diag::note_default_argument_declared_here);
4570 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4590 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4594 if (Inst.isInvalid())
4596 if (Inst.isAlreadyInstantiating()) {
4597 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4610 Result = SubstInitializer(UninstExpr, MutiLevelArgList,
4625 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4629 Result = ActOnFinishFullExpr(Result.
getAs<
Expr>(),
4637 L->DefaultArgumentInstantiated(Param);
4643 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4655 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4658 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
4663 assert(!Init->getNumObjects() &&
4664 "default argument expression has capturing blocks?");
4677 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
4686 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4687 return VariadicConstructor;
4689 return VariadicBlock;
4691 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4692 if (Method->isInstance())
4693 return VariadicMethod;
4695 return VariadicMethod;
4696 return VariadicFunction;
4698 return VariadicDoesNotApply;
4707 FunctionName(FuncName) {}
4709 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4733 llvm::make_unique<FunctionCallCCC>(S, FuncName.getAsIdentifierInfo(),
4736 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4737 if (Corrected.isOverloaded()) {
4747 ND = Best->FoundDecl;
4748 Corrected.setCorrectionDecl(ND);
4754 ND = ND->getUnderlyingDecl();
4755 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4774 bool IsExecConfig) {
4784 bool Invalid =
false;
4793 if (Args.size() < NumParams) {
4794 if (Args.size() < MinArgs) {
4799 ? diag::err_typecheck_call_too_few_args_suggest
4800 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4801 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4802 << static_cast<unsigned>(Args.size())
4807 ? diag::err_typecheck_call_too_few_args_one
4808 : diag::err_typecheck_call_too_few_args_at_least_one)
4812 ? diag::err_typecheck_call_too_few_args
4813 : diag::err_typecheck_call_too_few_args_at_least)
4814 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4818 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4829 if (Args.size() > NumParams) {
4835 ? diag::err_typecheck_call_too_many_args_suggest
4836 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4837 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4838 << static_cast<unsigned>(Args.size())
4840 }
else if (NumParams == 1 && FDecl &&
4842 Diag(Args[NumParams]->getLocStart(),
4843 MinArgs == NumParams
4844 ? diag::err_typecheck_call_too_many_args_one
4845 : diag::err_typecheck_call_too_many_args_at_most_one)
4849 Args.back()->getLocEnd());
4851 Diag(Args[NumParams]->getLocStart(),
4852 MinArgs == NumParams
4853 ? diag::err_typecheck_call_too_many_args
4854 : diag::err_typecheck_call_too_many_args_at_most)
4855 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4858 Args.back()->getLocEnd());
4861 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4873 Invalid = GatherArgumentsForCall(Call->
getLocStart(), FDecl,
4874 Proto, 0, Args, AllArgs, CallType);
4877 unsigned TotalNumArgs = AllArgs.size();
4878 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4879 Call->
setArg(i, AllArgs[i]);
4889 bool IsListInitialization) {
4891 bool Invalid =
false;
4894 for (
unsigned i = FirstParam; i < NumParams; i++) {
4899 if (ArgIx < Args.size()) {
4900 Arg = Args[ArgIx++];
4904 diag::err_call_incomplete_argument, Arg))
4908 bool CFAudited =
false;
4910 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4911 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4912 Arg = stripARCUnbridgedCast(Arg);
4913 else if (getLangOpts().ObjCAutoRefCount &&
4914 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4915 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4920 BE->getBlockDecl()->setDoesNotEscape();
4933 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
4939 assert(Param &&
"can't use default arguments without a known callee");
4942 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
4952 CheckArrayAccess(Arg);
4955 CheckStaticArrayArgument(CallLoc, Param, Arg);
4957 AllArgs.push_back(Arg);
4961 if (CallType != VariadicDoesNotApply) {
4966 for (
Expr *A : Args.slice(ArgIx)) {
4968 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
4970 AllArgs.push_back(arg.
get());
4975 for (
Expr *A : Args.slice(ArgIx)) {
4976 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
4978 AllArgs.push_back(Arg.
get());
4983 for (
Expr *A : Args.slice(ArgIx))
4984 CheckArrayAccess(A);
4992 TL = DTL.getOriginalLoc();
4995 << ATL.getLocalSourceRange();
5009 const Expr *ArgExpr) {
5037 Diag(CallLoc, diag::warn_static_array_too_small)
5039 << (unsigned) ArgCAT->
getSize().getZExtValue()
5040 << (unsigned) CAT->
getSize().getZExtValue();
5054 if (!placeholder)
return false;
5056 switch (placeholder->
getKind()) {
5058 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 5059 case BuiltinType::Id: 5060 #include "clang/Basic/OpenCLImageTypes.def" 5061 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 5062 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 5063 #include "clang/AST/BuiltinTypes.def" 5068 case BuiltinType::Overload:
5073 case BuiltinType::ARCUnbridgedCast:
5077 case BuiltinType::PseudoObject:
5082 case BuiltinType::UnknownAny:
5086 case BuiltinType::BoundMember:
5087 case BuiltinType::BuiltinFn:
5088 case BuiltinType::OMPArraySection:
5092 llvm_unreachable(
"bad builtin type kind");
5100 bool hasInvalid =
false;
5101 for (
size_t i = 0, e = args.size(); i != e; i++) {
5104 if (result.
isInvalid()) hasInvalid =
true;
5105 else args[i] = result.
get();
5106 }
else if (hasInvalid) {
5135 bool NeedsNewDecl =
false;
5148 if (!ParamType->isPointerType() ||
5149 ParamType.getQualifiers().hasAddressSpace() ||
5152 OverloadParams.push_back(ParamType);
5156 NeedsNewDecl =
true;
5169 OverloadParams, EPI);
5180 FT = cast<FunctionProtoType>(OverloadTy);
5181 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5188 Params.push_back(Parm);
5190 OverloadDecl->setParams(Params);
5191 return OverloadDecl;
5209 isa<CXXMethodDecl>(Callee)
5210 ? diag::err_ovl_no_viable_member_function_in_call
5211 : diag::err_ovl_no_viable_function_in_call)
5214 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5215 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5223 const auto GetFunctionLevelDCIfCXXClass =
5231 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5232 return MD->
getParent()->getCanonicalDecl();
5235 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5236 return RD->getCanonicalDecl();
5243 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5244 if (!CurParentClass)
5251 assert(NamingClass &&
"Must have naming class even for implicit access");
5257 return CurParentClass == NamingClass ||
5306 Expr *ExecConfig,
bool IsExecConfig) {
5308 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5317 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5318 if (!ArgExprs.empty()) {
5323 ArgExprs.back()->getLocEnd()));
5326 return new (Context)
5330 ExprResult result = CheckPlaceholderExpr(Fn);
5337 bool Dependent =
false;
5346 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5351 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5361 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5371 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5387 return BuildOverloadedCallExpr(
5388 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5390 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5404 bool CallingNDeclIndirectly =
false;
5406 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5407 if (UnOp->getOpcode() == UO_AddrOf) {
5408 CallingNDeclIndirectly =
true;
5413 if (isa<DeclRefExpr>(NakedFn)) {
5414 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5429 }
else if (isa<MemberExpr>(NakedFn))
5430 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5432 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5433 if (CallingNDeclIndirectly &&
5438 if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5444 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5445 ExecConfig, IsExecConfig);
5457 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5461 diag::err_invalid_astype_of_different_size)
5465 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5477 GetTypeFromParser(ParsedDestTy, &TInfo);
5478 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5492 Expr *Config,
bool IsExecConfig) {
5493 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5494 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5497 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5506 if (
auto *Caller = getCurFunctionDecl())
5507 if (Caller->hasAttr<ARMInterruptAttr>()) {
5509 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5510 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5520 CK_BuiltinFnToFnPtr).get();
5522 Result = CallExprUnaryConversions(Fn);
5524 if (Result.isInvalid())
5533 cast<CallExpr>(Config), Args,
5537 TheCall =
new (Context)
CallExpr(Context, Fn, Args, Context.
BoolTy,
5540 if (!getLangOpts().CPlusPlus) {
5545 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5548 if (!TheCall)
return Result;
5554 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5563 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5578 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5582 if (getLangOpts().CUDA) {
5585 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5586 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5591 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5595 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5596 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5612 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5616 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5625 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5636 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5637 Expr *Arg = Args[i];
5639 if (Proto && i < Proto->getNumParams()) {
5644 if (ArgE.isInvalid())
5647 Arg = ArgE.getAs<
Expr>();
5650 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5660 diag::err_call_incomplete_argument, Arg))
5667 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5668 if (!Method->isStatic())
5669 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5674 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5678 if (CheckFunctionCall(FDecl, TheCall, Proto))
5682 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5684 if (CheckPointerCall(NDecl, TheCall, Proto))
5687 if (CheckOtherCall(TheCall, Proto))
5691 return MaybeBindToTemporary(TheCall);
5697 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5698 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5701 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5705 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5715 diag::err_illegal_decl_array_incomplete_type,
5720 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5723 RequireCompleteType(LParenLoc, literalType,
5724 diag::err_typecheck_decl_incomplete_type,
5739 LiteralExpr = Result.
get();
5741 bool isFileScope = !CurContext->isFunctionOrMethod();
5746 if (CheckForConstantInitializer(LiteralExpr, literalType))
5769 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
5773 return MaybeBindToTemporary(
5775 VK, LiteralExpr, isFileScope));
5783 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
5784 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
5785 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
5791 InitArgList[I] = result.
get();
5806 assert(E.
get()->getType()->isBlockPointerType());
5807 assert(E.
get()->isRValue());
5810 if (!getLangOpts().ObjCAutoRefCount)
return;
5813 CK_ARCExtendBlockObject, E.
get(),
5815 Cleanup.setExprNeedsCleanups(
true);
5825 maybeExtendBlockObject(E);
5826 return CK_BlockPointerToObjCPointerCast;
5829 return CK_CPointerToObjCPointerCast;
5846 llvm_unreachable(
"member pointer type in C");
5855 if (SrcAS != DestAS)
5856 return CK_AddressSpaceConversion;
5861 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
5866 return CK_CPointerToObjCPointerCast;
5867 maybeExtendBlockObject(Src);
5868 return CK_BlockPointerToObjCPointerCast;
5870 return CK_PointerToBoolean;
5872 return CK_PointerToIntegral;
5877 llvm_unreachable(
"illegal cast from pointer");
5879 llvm_unreachable(
"Should have returned before this");
5887 if (Src.
get()->isNullPointerConstant(Context,
5889 return CK_NullToPointer;
5890 return CK_IntegralToPointer;
5892 return CK_IntegralToBoolean;
5894 return CK_IntegralCast;
5896 return CK_IntegralToFloating;
5898 Src = ImpCastExprToType(Src.
get(),
5901 return CK_IntegralRealToComplex;
5903 Src = ImpCastExprToType(Src.
get(),
5905 CK_IntegralToFloating);
5906 return CK_FloatingRealToComplex;
5908 llvm_unreachable(
"member pointer type in C");
5910 llvm_unreachable(
"Should have returned before this");
5915 return CK_FloatingCast;
5917 return CK_FloatingToBoolean;
5919 return CK_FloatingToIntegral;
5921 Src = ImpCastExprToType(Src.
get(),
5924 return CK_FloatingRealToComplex;
5926 Src = ImpCastExprToType(Src.
get(),
5928 CK_FloatingToIntegral);
5929 return CK_IntegralRealToComplex;
5933 llvm_unreachable(
"valid float->pointer cast?");
5935 llvm_unreachable(
"member pointer type in C");
5937 llvm_unreachable(
"Should have returned before this");
5942 return CK_FloatingComplexCast;
5944 return CK_FloatingComplexToIntegralComplex;
5948 return CK_FloatingComplexToReal;
5949 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
5950 return CK_FloatingCast;
5953 return CK_FloatingComplexToBoolean;
5955 Src = ImpCastExprToType(Src.
get(),
5957 CK_FloatingComplexToReal);
5958 return CK_FloatingToIntegral;
5962 llvm_unreachable(
"valid complex float->pointer cast?");
5964 llvm_unreachable(
"member pointer type in C");
5966 llvm_unreachable(
"Should have returned before this");
5971 return CK_IntegralComplexToFloatingComplex;
5973 return CK_IntegralComplexCast;
5977 return CK_IntegralComplexToReal;
5978 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
5979 return CK_IntegralCast;
5982 return CK_IntegralComplexToBoolean;
5984 Src = ImpCastExprToType(Src.
get(),
5986 CK_IntegralComplexToReal);
5987 return CK_IntegralToFloating;
5991 llvm_unreachable(
"valid complex int->pointer cast?");
5993 llvm_unreachable(
"member pointer type in C");
5995 llvm_unreachable(
"Should have returned before this");
5998 llvm_unreachable(
"Unhandled scalar cast");
6005 len = vecType->getNumElements();
6006 eltType = vecType->getElementType();
6038 uint64_t srcLen, destLen;
6046 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
6047 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
6049 return (srcLen * srcEltSize == destLen * destEltSize);
6059 return areLaxCompatibleVectorTypes(srcTy, destTy);
6064 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
6067 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
6070 diag::err_invalid_conversion_between_vectors :
6071 diag::err_invalid_conversion_between_vector_and_integer)
6072 << VectorTy << Ty << R;
6075 diag::err_invalid_conversion_between_vector_and_scalar)
6076 << VectorTy << Ty << R;
6085 if (DestElemTy == SplattedExpr->
getType())
6086 return SplattedExpr;
6098 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6099 CK_BooleanToSignedIntegral);
6100 SplattedExpr = CastExprRes.
get();
6101 CK = CK_IntegralToFloating;
6103 CK = CK_BooleanToSignedIntegral;
6107 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6110 SplattedExpr = CastExprRes.
get();
6112 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6125 if (SrcTy->isVectorType()) {
6126 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6127 (getLangOpts().OpenCL &&
6129 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6130 << DestTy << SrcTy << R;
6140 if (SrcTy->isPointerType())
6142 diag::err_invalid_conversion_between_vector_and_scalar)
6143 << DestTy << SrcTy << R;
6145 Kind = CK_VectorSplat;
6146 return prepareVectorSplat(DestTy, CastExpr);
6154 "ActOnCastExpr(): missing type or expr");
6160 if (getLangOpts().CPlusPlus) {
6162 CheckExtraCXXDefaultArguments(D);
6165 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6168 CastExpr = Res.
get();
6174 Ty = CreateParsedType(castType, castTInfo);
6176 bool isVectorLiteral =
false;
6182 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6184 if (PLE && PLE->getNumExprs() == 0) {
6185 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6188 if (PE || PLE->getNumExprs() == 1) {
6191 isVectorLiteral =
true;
6194 isVectorLiteral =
true;
6199 if (isVectorLiteral)
6200 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6205 if (isa<ParenListExpr>(CastExpr)) {
6206 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6208 CastExpr = Result.
get();
6212 !getSourceManager().isInSystemMacro(LParenLoc))
6215 CheckTollFreeBridgeCast(castType, CastExpr);
6217 CheckObjCBridgeRelatedCast(castType, CastExpr);
6219 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6221 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6227 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6228 "Expected paren or paren list expression");
6235 LiteralLParenLoc = PE->getLParenLoc();
6236 LiteralRParenLoc = PE->getRParenLoc();
6237 exprs = PE->getExprs();
6238 numExprs = PE->getNumExprs();
6240 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6241 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6242 subExpr = cast<ParenExpr>(E)->getSubExpr();
6262 if (numExprs == 1) {
6264 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6267 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6268 PrepareScalarCast(Literal, ElemTy));
6269 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6271 else if (numExprs < numElems) {
6273 diag::err_incorrect_number_of_vector_initializers);
6277 initExprs.append(exprs, exprs + numExprs);
6282 if (getLangOpts().OpenCL &&
6286 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6289 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6290 PrepareScalarCast(Literal, ElemTy));
6291 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6294 initExprs.append(exprs, exprs + numExprs);
6299 initExprs, LiteralRParenLoc);
6301 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6314 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
6315 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6318 if (Result.isInvalid())
return ExprError();
6335 Expr *NullExpr = LHSExpr;
6336 Expr *NonPointerExpr = RHSExpr;
6343 NonPointerExpr = LHSExpr;
6360 if (!findMacroSpelling(loc,
"NULL"))
6365 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6366 << NonPointerExpr->
getType() << DiagType
6377 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6385 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6412 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6436 bool IsBlockPointer =
false;
6440 IsBlockPointer =
true;
6465 ResultAddrSpace = LAddrSpace;
6467 ResultAddrSpace = RAddrSpace;
6470 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6471 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6472 << RHS.
get()->getSourceRange();
6478 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6493 LHSCastKind = LAddrSpace == ResultAddrSpace
6495 : CK_AddressSpaceConversion;
6496 RHSCastKind = RAddrSpace == ResultAddrSpace
6498 : CK_AddressSpaceConversion;
6508 if (CompositeTy.
isNull()) {
6524 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6525 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6526 << RHS.
get()->getSourceRange();
6534 QualType ResultTy = [&, ResultAddrSpace]() {
6540 .withCVRQualifiers(MergedCVRQual);
6569 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6570 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6571 << RHS.
get()->getSourceRange();
6622 bool IsIntFirstExpr) {
6624 !Int.
get()->getType()->isIntegerType())
6627 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6628 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6630 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6634 CK_IntegralToPointer);
6668 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6669 << LHSType << LHS.
get()->getSourceRange();
6674 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6675 << RHSType << RHS.
get()->getSourceRange();
6680 if (LHSType == RHSType)
6689 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6690 (S, LHS, RHS, LHSType, RHSType,
false);
6724 llvm::raw_svector_ostream OS(Str);
6725 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6726 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6727 << CondTy << OS.str();
6748 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6766 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6767 << CondTy << VecResTy;
6772 QualType RVE = RV->getElementType();
6775 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6776 << CondTy << VecResTy;
6800 if (LHS.
get()->getType()->isVectorType() ||
6801 RHS.
get()->getType()->isVectorType()) {
6820 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
6821 QualType Ty = CE->getCallee()->getType();
6847 if (getLangOpts().CPlusPlus)
6848 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
6855 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
6859 Cond = UsualUnaryConversions(Cond.
get());
6866 if (LHS.
get()->getType()->isVectorType() ||
6867 RHS.
get()->getType()->isVectorType())
6868 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
6872 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
6883 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
6884 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6890 if (getLangOpts().OpenCL &&
6898 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
6899 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
6908 if (LHSRT->getDecl() == RHSRT->getDecl())
6927 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
6931 if (!compositeType.
isNull())
6932 return compositeType;
6957 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
6961 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6962 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6963 << RHS.
get()->getSourceRange();
6979 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
6984 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
6990 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
6995 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7001 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
7006 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
7033 if (!(compositeType =
7051 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
7053 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7055 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
7056 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
7060 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
7061 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
7062 return compositeType;
7066 if (getLangOpts().ObjCAutoRefCount) {
7069 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7070 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7080 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
7082 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
7086 if (getLangOpts().ObjCAutoRefCount) {
7089 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7090 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7100 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7102 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7116 Self.
Diag(Loc, Note)
7121 Self.
Diag(Loc, Note) << ParenRange;
7141 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
7142 E = MTE->GetTemporaryExpr();
7149 *Opcode = OP->getOpcode();
7150 *RHSExprs = OP->getRHS();
7157 if (Call->getNumArgs() != 2)
7163 if (OO < OO_Plus || OO > OO_Arrow ||
7164 OO == OO_PlusPlus || OO == OO_MinusMinus)
7170 *RHSExprs = Call->getArg(1);
7187 return OP->isComparisonOp() || OP->isLogicalOp();
7189 return OP->getOpcode() == UO_LNot;
7218 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7223 Self.
PDiag(diag::note_precedence_silence)
7228 Self.
PDiag(diag::note_precedence_conditional_first),
7239 auto GetNullability = [&Ctx](
QualType Ty) {
7246 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7254 MergedKind = RHSKind;
7261 MergedKind = RHSKind;
7263 MergedKind = LHSKind;
7269 if (GetNullability(ResTy) == MergedKind)
7291 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7292 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7293 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7306 CondExpr = CondResult.
get();
7307 LHSExpr = LHSResult.
get();
7308 RHSExpr = RHSResult.
get();
7314 Expr *commonExpr =
nullptr;
7316 commonExpr = CondExpr;
7321 ExprResult result = CheckPlaceholderExpr(commonExpr);
7323 commonExpr = result.
get();
7334 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7337 commonExpr = commonRes.
get();
7344 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7347 commonExpr = MatExpr.
get();
7355 LHSExpr = CondExpr = opaqueValue;
7361 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7362 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
7363 VK, OK, QuestionLoc);
7377 return new (Context)
7379 RHS.get(), result, VK, OK);
7382 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7393 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7394 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7397 const Type *lhptee, *rhptee;
7399 std::tie(lhptee, lhq) =
7400 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7401 std::tie(rhptee, rhq) =
7402 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7428 && (lhptee->isVoidType() || rhptee->isVoidType()))
7443 if (lhptee->isVoidType()) {
7444 if (rhptee->isIncompleteOrObjectType())
7448 assert(rhptee->isFunctionType());
7452 if (rhptee->isVoidType()) {
7453 if (lhptee->isIncompleteOrObjectType())
7457 assert(lhptee->isFunctionType());
7468 if (lhptee->isCharType())
7470 else if (lhptee->hasSignedIntegerRepresentation())
7473 if (rhptee->isCharType())
7475 else if (rhptee->hasSignedIntegerRepresentation())
7478 if (ltrans == rtrans) {
7492 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7494 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7495 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7496 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7498 if (lhptee == rhptee)
7518 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7519 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7524 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7525 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7534 Qualifiers LQuals = lhptee.getLocalQualifiers();
7535 Qualifiers RQuals = rhptee.getLocalQualifiers();
7540 if (LQuals != RQuals)
7569 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7570 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7611 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7618 return VT->getElementType() == ElementType;
7651 if (LHSType == RHSType) {
7658 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7660 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
7661 if (result != Compatible)
7663 if (Kind != CK_NoOp && ConvertRHS)
7664 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
7665 Kind = CK_NonAtomicToAtomic;
7678 Kind = CK_LValueBitCast;
7681 return Incompatible;
7688 return Incompatible;
7692 RHS = prepareVectorSplat(LHSType, RHS.
get());
7693 Kind = CK_VectorSplat;
7711 if (isLaxVectorConversion(RHSType, LHSType)) {
7713 return IncompatibleVectors;
7724 isLaxVectorConversion(RHSType, LHSType)) {
7726 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
7732 return Incompatible;
7738 return Incompatible;
7744 return Incompatible;
7750 Kind = PrepareScalarCast(RHS, LHSType);
7755 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7757 if (isa<PointerType>(RHSType)) {
7758 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7760 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7766 Kind = CK_IntegralToPointer;
7767 return IntToPointer;
7772 if (isa<ObjCObjectPointerType>(RHSType)) {
7774 if (LHSPointer->getPointeeType()->isVoidType()) {
7788 return IncompatiblePointer;
7793 if (LHSPointer->getPointeeType()->isVoidType()) {
7794 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7799 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7804 return Incompatible;
7808 if (isa<BlockPointerType>(LHSType)) {
7817 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7823 Kind = CK_IntegralToPointer;
7824 return IntToBlockPointer;
7829 Kind = CK_AnyPointerToBlockPointerCast;
7835 if (RHSPT->getPointeeType()->isVoidType()) {
7836 Kind = CK_AnyPointerToBlockPointerCast;
7840 return Incompatible;
7844 if (isa<ObjCObjectPointerType>(LHSType)) {
7850 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
7851 result == Compatible &&
7852 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
7853 result = IncompatibleObjCWeakRef;
7859 Kind = CK_IntegralToPointer;
7860 return IntToPointer;
7865 if (isa<PointerType>(RHSType)) {
7866 Kind = CK_CPointerToObjCPointerCast;
7880 return IncompatiblePointer;
7887 maybeExtendBlockObject(RHS);
7888 Kind = CK_BlockPointerToObjCPointerCast;
7892 return Incompatible;
7896 if (isa<PointerType>(RHSType)) {
7898 if (LHSType == Context.
BoolTy) {
7899 Kind = CK_PointerToBoolean;
7905 Kind = CK_PointerToIntegral;
7906 return PointerToInt;
7909 return Incompatible;
7913 if (isa<ObjCObjectPointerType>(RHSType)) {
7915 if (LHSType == Context.
BoolTy) {
7916 Kind = CK_PointerToBoolean;
7922 Kind = CK_PointerToIntegral;
7923 return PointerToInt;
7926 return Incompatible;
7930 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
7938 Kind = CK_IntToOCLSampler;
7942 return Incompatible;
7955 Initializer->
setType(UnionType);
7974 return Incompatible;
7980 for (
auto *it : UD->
fields()) {
7981 if (it->getType()->isPointerType()) {
7987 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
7992 if (RHS.
get()->isNullPointerConstant(Context,
7994 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
8002 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
8004 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
8011 return Incompatible;
8020 bool DiagnoseCFAudited,
8024 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
8030 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
8050 return Incompatible;
8055 return Incompatible;
8057 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8058 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
8059 result = IncompatibleObjCWeakRef;
8071 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
8072 RHS.
get(), LHSType,
false, DAP))
8073 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
8075 return Incompatible;
8082 RHS.
get()->isNullPointerConstant(Context,
8084 if (Diagnose || ConvertRHS) {
8087 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8103 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8105 return Incompatible;
8108 Expr *PRE = RHS.
get()->IgnoreParenCasts();
8109 if (Diagnose && isa<ObjCProtocolExpr>(PRE)) {
8112 Diag(PRE->
getExprLoc(), diag::warn_atprotocol_protocol) << PDecl;
8119 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8127 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8134 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8135 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8136 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8138 return Incompatible;
8140 if (getLangOpts().ObjC1 &&
8141 (CheckObjCBridgeRelatedConversions(E->
getLocStart(), LHSType,
8143 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8145 return Incompatible;
8153 RHS = ImpCastExprToType(E, Ty, Kind);
8162 struct OriginalOperand {
8163 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
8164 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
8165 Op = MTE->GetTemporaryExpr();
8166 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
8167 Op = BTE->getSubExpr();
8168 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
8169 Orig = ICE->getSubExprAsWritten();
8170 Conversion = ICE->getConversionFunction();
8174 QualType getType()
const {
return Orig->getType(); }
8183 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
8185 Diag(Loc, diag::err_typecheck_invalid_operands)
8186 << OrigLHS.getType() << OrigRHS.getType()
8187 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8191 if (OrigLHS.Conversion) {
8192 Diag(OrigLHS.Conversion->getLocation(),
8193 diag::note_typecheck_invalid_operands_converted)
8194 << 0 << LHS.
get()->getType();
8196 if (OrigRHS.Conversion) {
8197 Diag(OrigRHS.Conversion->getLocation(),
8198 diag::note_typecheck_invalid_operands_converted)
8199 << 1 << RHS.
get()->getType();
8210 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8211 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8216 if (!(LHSNatVec && RHSNatVec)) {
8217 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8218 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8219 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8225 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8226 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8227 << RHS.
get()->getSourceRange();
8257 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8262 scalarCast = CK_IntegralCast;
8267 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8270 scalarCast = CK_FloatingCast;
8273 scalarCast = CK_IntegralToFloating;
8282 if (scalarCast != CK_NoOp)
8293 assert(VecTy &&
"Expression E must be a vector");
8295 VecTy->getNumElements(),
8296 VecTy->getVectorKind());
8300 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8301 if (ICE->getSubExpr()->getType() == NewVecTy)
8302 return ICE->getSubExpr();
8304 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
8312 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8317 llvm::APSInt Result;
8318 bool CstInt = Int->
get()->EvaluateAsInt(Result, S.
Context);
8326 unsigned NumBits = IntSigned
8327 ? (Result.isNegative() ? Result.getMinSignedBits()
8328 : Result.getActiveBits())
8329 : Result.getActiveBits();
8336 return (IntSigned != OtherIntSigned &&
8349 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8353 llvm::APSInt Result;
8354 bool CstInt = Int->
get()->EvaluateAsInt(Result, S.
Context);
8364 llvm::APFloat::rmTowardZero);
8367 bool Ignored =
false;
8368 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8370 if (Result != ConvertBack)
8376 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8378 if (Bits > FloatPrec)
8391 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
8392 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
8395 assert(!isa<ExtVectorType>(VT) &&
8396 "ExtVectorTypes should not be handled here!");
8423 ScalarCast = CK_IntegralCast;
8429 llvm::APFloat Result(0.0);
8430 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
8432 if (!CstScalar && Order < 0)
8438 bool Truncated =
false;
8440 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8445 ScalarCast = CK_FloatingCast;
8450 ScalarCast = CK_IntegralToFloating;
8457 if (ScalarCast != CK_NoOp)
8467 bool AllowBoolConversions) {
8468 if (!IsCompAssign) {
8469 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
8473 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
8479 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
8480 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
8484 assert(LHSVecType || RHSVecType);
8488 if (!AllowBothBool &&
8491 return InvalidOperands(Loc, LHS, RHS);
8498 if (LHSVecType && RHSVecType &&
8500 if (isa<ExtVectorType>(LHSVecType)) {
8501 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8506 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8513 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8516 Context.
getTypeSize(RHSVecType->getElementType()))) {
8520 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8523 if (!IsCompAssign &&
8526 RHSVecType->getElementType()->isIntegerType()) {
8527 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8534 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8536 if (isa<ExtVectorType>(LHSVecType)) {
8547 if (isa<ExtVectorType>(RHSVecType)) {
8549 LHSType, RHSVecType->getElementType(),
8562 QualType VecType = LHSVecType ? LHSType : RHSType;
8563 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8564 QualType OtherType = LHSVecType ? RHSType : LHSType;
8565 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8566 if (isLaxVectorConversion(OtherType, VecType)) {
8570 if (!IsCompAssign) {
8571 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
8581 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
8589 if ((!RHSVecType && !RHSType->
isRealType()) ||
8591 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8592 << LHSType << RHSType
8593 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8601 if (getLangOpts().OpenCL &&
8602 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8603 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8604 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
8613 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
8614 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
8615 QualType Scalar = LHSVecType ? RHSType : LHSType;
8616 QualType Vector = LHSVecType ? LHSType : RHSType;
8617 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
8619 diag::err_typecheck_vector_not_convertable_implict_truncation)
8620 << ScalarOrVector << Scalar << Vector;
8627 << LHSType << RHSType
8628 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8640 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
8641 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
8643 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
8647 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8648 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8654 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8662 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8663 NonNullType->canDecayToPointerType())
8666 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8667 << LHSNull << NonNullType
8668 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8675 llvm::APSInt RHSValue;
8676 if (!RHS.
get()->isValueDependent() &&
8677 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) && RHSValue == 0)
8679 S.
PDiag(diag::warn_remainder_division_by_zero)
8680 << IsDiv << RHS.
get()->getSourceRange());
8685 bool IsCompAssign,
bool IsDiv) {
8688 if (LHS.
get()->getType()->isVectorType() ||
8689 RHS.
get()->getType()->isVectorType())
8690 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8691 getLangOpts().AltiVec,
8694 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8700 return InvalidOperands(Loc, LHS, RHS);
8710 if (LHS.
get()->getType()->isVectorType() ||
8711 RHS.
get()->getType()->isVectorType()) {
8712 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
8713 RHS.
get()->getType()->hasIntegerRepresentation())
8714 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8715 getLangOpts().AltiVec,
8717 return InvalidOperands(Loc, LHS, RHS);
8720 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8725 return InvalidOperands(Loc, LHS, RHS);
8734 ? diag::err_typecheck_pointer_arith_void_type
8735 : diag::ext_gnu_void_ptr)
8744 ? diag::err_typecheck_pointer_arith_void_type
8745 : diag::ext_gnu_void_ptr)
8755 Expr *Pointer,
bool IsGNUIdiom) {
8757 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
8760 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
8770 ? diag::err_typecheck_pointer_arith_function_type
8771 : diag::ext_gnu_ptr_func_arith)
8785 ? diag::err_typecheck_pointer_arith_function_type
8786 : diag::ext_gnu_ptr_func_arith)
8799 ResType = ResAtomicType->getValueType();
8804 diag::err_typecheck_arithmetic_incomplete_type,
8820 ResType = ResAtomicType->getValueType();
8852 if (!isLHSPointer && !isRHSPointer)
return true;
8854 QualType LHSPointeeTy, RHSPointeeTy;
8859 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
8864 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8872 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
8873 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
8874 if (isLHSVoidPtr || isRHSVoidPtr) {
8882 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
8883 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
8884 if (isLHSFuncPtr || isRHSFuncPtr) {
8906 Expr* IndexExpr = RHSExpr;
8909 IndexExpr = LHSExpr;
8912 bool IsStringPlusInt = StrExpr &&
8914 if (!IsStringPlusInt || IndexExpr->isValueDependent())
8918 if (IndexExpr->EvaluateAsInt(index, Self.
getASTContext())) {
8919 unsigned StrLenWithNull = StrExpr->
getLength() + 1;
8920 if (index.isNonNegative() &&
8921 index <= llvm::APSInt(llvm::APInt(index.getBitWidth(), StrLenWithNull),
8922 index.isUnsigned()))
8927 Self.
Diag(OpLoc, diag::warn_string_plus_int)
8928 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
8931 if (IndexExpr == RHSExpr) {
8933 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8938 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8944 const Expr *StringRefExpr = LHSExpr;
8950 StringRefExpr = RHSExpr;
8953 if (!CharExpr || !StringRefExpr)
8970 if (!CharType->isAnyCharacterType() &&
8971 CharType->isIntegerType() &&
8973 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8974 << DiagRange << Ctx.
CharTy;
8976 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8977 << DiagRange << CharExpr->
getType();
8983 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8988 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8997 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
9008 if (LHS.
get()->getType()->isVectorType() ||
9009 RHS.
get()->getType()->isVectorType()) {
9010 QualType compType = CheckVectorOperands(
9011 LHS, RHS, Loc, CompLHSTy,
9012 getLangOpts().AltiVec,
9013 getLangOpts().ZVector);
9014 if (CompLHSTy) *CompLHSTy = compType;
9018 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9023 if (Opc == BO_Add) {
9030 if (CompLHSTy) *CompLHSTy = compType;
9040 isObjCPointer =
false;
9042 isObjCPointer =
true;
9044 std::swap(PExp, IExp);
9046 isObjCPointer =
false;
9048 isObjCPointer =
true;
9050 return InvalidOperands(Loc, LHS, RHS);
9055 if (!IExp->getType()->isIntegerType())
9056 return InvalidOperands(Loc, LHS, RHS);
9062 llvm::APSInt KnownVal;
9063 if (!getLangOpts().CPlusPlus ||
9064 (!IExp->isValueDependent() &&
9065 (!IExp->EvaluateAsInt(KnownVal, Context) || KnownVal != 0))) {
9068 Context, BO_Add, PExp, IExp);
9080 CheckArrayAccess(PExp, IExp);
9085 LHSTy = LHS.
get()->getType();
9101 if (LHS.
get()->getType()->isVectorType() ||
9102 RHS.
get()->getType()->isVectorType()) {
9103 QualType compType = CheckVectorOperands(
9104 LHS, RHS, Loc, CompLHSTy,
9105 getLangOpts().AltiVec,
9106 getLangOpts().ZVector);
9107 if (CompLHSTy) *CompLHSTy = compType;
9111 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9119 if (CompLHSTy) *CompLHSTy = compType;
9124 if (LHS.
get()->getType()->isAnyPointerType()) {
9125 QualType lpointee = LHS.
get()->getType()->getPointeeType();
9128 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9133 if (RHS.
get()->getType()->isIntegerType()) {
9137 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9140 llvm::APSInt KnownVal;
9141 if (!getLangOpts().CPlusPlus ||
9142 (!RHS.
get()->isValueDependent() &&
9143 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) || KnownVal != 0))) {
9152 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9155 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9156 return LHS.
get()->getType();
9190 if (ElementSize.
isZero()) {
9191 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9193 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9197 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9202 return InvalidOperands(Loc, LHS, RHS);
9207 return ET->getDecl()->isScoped();
9221 if (RHS.
get()->isValueDependent() ||
9225 if (Right.isNegative()) {
9227 S.
PDiag(diag::warn_shift_negative)
9228 << RHS.
get()->getSourceRange());
9231 llvm::APInt LeftBits(Right.getBitWidth(),
9233 if (Right.uge(LeftBits)) {
9235 S.
PDiag(diag::warn_shift_gt_typewidth)
9236 << RHS.
get()->getSourceRange());
9247 if (LHS.
get()->isValueDependent() ||
9256 S.
PDiag(diag::warn_shift_lhs_negative)
9257 << LHS.
get()->getSourceRange());
9261 llvm::APInt ResultBits =
9262 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9263 if (LeftBits.uge(ResultBits))
9265 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9266 Result = Result.shl(Right);
9271 Result.toString(HexResult, 16,
false,
true);
9277 if (LeftBits == ResultBits - 1) {
9278 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9279 << HexResult << LHSType
9280 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9284 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
9285 << HexResult.str() << Result.getMinSignedBits() << LHSType
9286 << Left.getBitWidth() << LHS.
get()->getSourceRange()
9287 << RHS.
get()->getSourceRange();
9296 !LHS.
get()->getType()->isVectorType()) {
9297 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
9298 << RHS.
get()->getType() << LHS.
get()->getType()
9299 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9303 if (!IsCompAssign) {
9323 if (!LHSEleType->isIntegerType()) {
9324 S.
Diag(Loc, diag::err_typecheck_expect_int)
9325 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
9329 if (!RHSEleType->isIntegerType()) {
9330 S.
Diag(Loc, diag::err_typecheck_expect_int)
9331 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
9339 if (LHSEleType != RHSEleType) {
9341 LHSEleType = RHSEleType;
9347 }
else if (RHSVecTy) {
9352 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9353 << LHS.
get()->getType() << RHS.
get()->getType()
9354 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9360 if (LHSBT != RHSBT &&
9362 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9363 << LHS.
get()->getType() << RHS.
get()->getType()
9364 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9380 bool IsCompAssign) {
9384 if (LHS.
get()->getType()->isVectorType() ||
9385 RHS.
get()->getType()->isVectorType()) {
9386 if (LangOpts.ZVector) {
9390 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
9392 return InvalidOperands(Loc, LHS, RHS);
9393 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
9395 return InvalidOperands(Loc, LHS, RHS);
9406 LHS = UsualUnaryConversions(LHS.
get());
9410 if (IsCompAssign) LHS = OldLHS;
9413 RHS = UsualUnaryConversions(RHS.
get());
9421 return InvalidOperands(Loc, LHS, RHS);
9427 return InvalidOperands(Loc, LHS, RHS);
9460 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9461 << LHSStrippedType << RHSStrippedType
9469 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9470 : diag::ext_typecheck_comparison_of_distinct_pointers)
9471 << LHS.
get()->getType() << RHS.
get()->getType()
9472 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9512 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9513 : diag::ext_typecheck_comparison_of_fptr_to_void)
9514 << LHS.
get()->getType() << RHS.
get()->getType()
9515 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9519 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
9520 case Stmt::ObjCArrayLiteralClass:
9521 case Stmt::ObjCDictionaryLiteralClass:
9522 case Stmt::ObjCStringLiteralClass:
9523 case Stmt::ObjCBoxedExprClass:
9582 case Stmt::ObjCStringLiteralClass:
9585 case Stmt::ObjCArrayLiteralClass:
9588 case Stmt::ObjCDictionaryLiteralClass:
9590 return LK_Dictionary;
9591 case Stmt::BlockExprClass:
9593 case Stmt::ObjCBoxedExprClass: {
9594 Expr *Inner = cast<ObjCBoxedExpr>(FromE)->getSubExpr()->IgnoreParens();
9596 case Stmt::IntegerLiteralClass:
9597 case Stmt::FloatingLiteralClass:
9598 case Stmt::CharacterLiteralClass:
9599 case Stmt::ObjCBoolLiteralExprClass:
9600 case Stmt::CXXBoolLiteralExprClass:
9603 case Stmt::ImplicitCastExprClass: {
9604 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
9606 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
9625 Literal = LHS.
get();
9628 Literal = RHS.
get();
9644 llvm_unreachable(
"Unknown Objective-C object literal kind");
9648 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
9651 S.
Diag(Loc, diag::warn_objc_literal_comparison)
9661 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
9674 if (!UO || UO->
getOpcode() != UO_LNot)
return;
9677 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
9684 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
9686 << Loc << IsBitwiseOp;
9714 return DR->getDecl();
9716 if (Ivar->isFreeIvar())
9717 return Ivar->getDecl();
9719 if (
MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
9720 if (Mem->isImplicitAccess())
9721 return Mem->getMemberDecl();
9761 case BO_EQ:
case BO_LE:
case BO_GE:
9764 case BO_NE:
case BO_LT:
case BO_GT:
9768 Result =
"'std::strong_ordering::equal'";
9774 S.
PDiag(diag::warn_comparison_always)
9775 << 0 << !Result.empty()
9777 }
else if (DL && DR &&
9794 S.
PDiag(diag::warn_comparison_always)
9796 << !Result.empty() << Result);
9799 if (isa<CastExpr>(LHSStripped))
9801 if (isa<CastExpr>(RHSStripped))
9806 Expr *LiteralString =
nullptr;
9807 Expr *LiteralStringStripped =
nullptr;
9808 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
9811 LiteralString = LHS;
9812 LiteralStringStripped = LHSStripped;
9813 }
else if ((isa<StringLiteral>(RHSStripped) ||
9814 isa<ObjCEncodeExpr>(RHSStripped)) &&
9817 LiteralString = RHS;
9818 LiteralStringStripped = RHSStripped;
9821 if (LiteralString) {
9823 S.
PDiag(diag::warn_stringcompare)
9824 << isa<ObjCEncodeExpr>(LiteralStringStripped)
9836 llvm_unreachable(
"unhandled cast kind");
9838 case CK_UserDefinedConversion:
9840 case CK_LValueToRValue:
9842 case CK_ArrayToPointerDecay:
9844 case CK_FunctionToPointerDecay:
9846 case CK_IntegralCast:
9848 case CK_FloatingCast:
9850 case CK_IntegralToFloating:
9851 case CK_FloatingToIntegral:
9853 case CK_IntegralComplexCast:
9854 case CK_FloatingComplexCast:
9855 case CK_FloatingComplexToIntegralComplex:
9856 case CK_IntegralComplexToFloatingComplex:
9858 case CK_FloatingComplexToReal:
9859 case CK_FloatingRealToComplex:
9860 case CK_IntegralComplexToReal:
9861 case CK_IntegralRealToComplex:
9874 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
9893 << PreNarrowingValue.getAsString(S.
Context, PreNarrowingType) << ToType;
9901 << 0 << FromType << ToType;
9906 llvm_unreachable(
"unhandled case in switch");
9922 QualType LHSStrippedType = LHSStripped.
get()->getType();
9923 QualType RHSStrippedType = RHSStripped.
get()->getType();
9934 if (NumEnumArgs == 1) {
9936 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
9942 if (NumEnumArgs == 2) {
9951 LHSStrippedType->
getAs<
EnumType>()->getDecl()->getIntegerType();
9962 LHSType = RHSType = IntType;
9975 S, Type, LHS.
get(), LHSType, LHS.
get()->getLocStart());
9977 S, Type, RHS.
get(), RHSType, RHS.
get()->getLocStart());
9981 assert(!Type.
isNull() &&
"composite type for <=> has not been set");
9983 auto TypeKind = [&]() {
9985 if (CT->getElementType()->hasFloatingRepresentation())
9993 llvm_unreachable(
"other types are unimplemented");
10032 bool IsThreeWay = Opc == BO_Cmp;
10043 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
10044 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10047 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10051 LHS = DefaultLvalueConversion(LHS.
get());
10054 RHS = DefaultLvalueConversion(RHS.
get());
10062 if (LHS.
get()->getType()->isVectorType() ||
10063 RHS.
get()->getType()->isVectorType())
10064 return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);
10071 if ((LHSType->isArithmeticType() || LHSType->isEnumeralType()) &&
10082 auto computeResultTy = [&]() {
10092 return CheckComparisonCategoryType(
Kind, Loc);
10110 if (LHSIsNull != RHSIsNull)
10116 return InvalidOperands(Loc, LHS, RHS);
10120 if (!IsRelational && LHSIsNull != RHSIsNull) {
10121 bool IsEquality = Opc == BO_EQ;
10123 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
10124 RHS.
get()->getSourceRange());
10126 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
10127 LHS.
get()->getSourceRange());
10130 if ((LHSType->isIntegerType() && !LHSIsNull) ||
10134 }
else if (getLangOpts().CPlusPlus) {
10139 if (!IsRelational &&
10146 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
10148 if (isSFINAEContext())
10151 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10152 return computeResultTy();
10164 if ((
int)LHSType->isPointerType() + (int)RHSType->
isPointerType() >=
10165 (IsRelational ? 2 : 1) &&
10166 (!LangOpts.ObjCAutoRefCount || !(LHSType->isObjCObjectPointerType() ||
10170 return computeResultTy();
10172 }
else if (LHSType->isPointerType() &&
10186 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
10187 << LHSType << RHSType << LHS.
get()->getSourceRange()
10188 << RHS.
get()->getSourceRange();
10190 }
else if (!IsRelational &&
10194 && !LHSIsNull && !RHSIsNull)
10201 if (LCanPointeeTy != RCanPointeeTy) {
10203 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
10207 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10208 << LHSType << RHSType << 0
10209 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10214 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
10216 if (LHSIsNull && !RHSIsNull)
10217 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
10219 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
10221 return computeResultTy();
10228 if (!IsRelational && LHSIsNull && RHSIsNull) {
10229 if (LHSType->isNullPtrType()) {
10230 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10231 return computeResultTy();
10234 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10235 return computeResultTy();
10242 (LHSType->isObjCObjectPointerType() || LHSType->isBlockPointerType())) {
10243 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10244 return computeResultTy();
10246 if (!IsRelational && LHSType->isNullPtrType() &&
10248 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10249 return computeResultTy();
10252 if (IsRelational &&
10261 if (isa<FunctionDecl>(DC))
10263 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
10264 if (CTSD->isInStdNamespace() &&
10265 llvm::StringSwitch<bool>(CTSD->getName())
10266 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
10269 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10271 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10272 return computeResultTy();
10280 if (!IsRelational &&
10285 return computeResultTy();
10290 if (!IsRelational && LHSType->isBlockPointerType() &&
10295 if (!LHSIsNull && !RHSIsNull &&
10297 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10298 << LHSType << RHSType << LHS.
get()->getSourceRange()
10299 << RHS.
get()->getSourceRange();
10301 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10302 return computeResultTy();
10307 && ((LHSType->isBlockPointerType() && RHSType->
isPointerType())
10309 if (!LHSIsNull && !RHSIsNull) {
10312 || (LHSType->isPointerType() && LHSType->castAs<
PointerType>()
10314 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10315 << LHSType << RHSType << LHS.
get()->getSourceRange()
10316 << RHS.
get()->getSourceRange();
10318 if (LHSIsNull && !RHSIsNull)
10319 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10321 : CK_AnyPointerToBlockPointerCast);
10323 RHS = ImpCastExprToType(RHS.get(), LHSType,
10324 LHSType->isPointerType() ? CK_BitCast
10325 : CK_AnyPointerToBlockPointerCast);
10326 return computeResultTy();
10329 if (LHSType->isObjCObjectPointerType() ||
10335 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
10337 if (!LPtrToVoid && !RPtrToVoid &&
10342 if (LHSIsNull && !RHSIsNull) {
10344 if (getLangOpts().ObjCAutoRefCount)
10346 CCK_ImplicitConversion);
10347 LHS = ImpCastExprToType(E, RHSType,
10348 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10352 if (getLangOpts().ObjCAutoRefCount)
10353 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
10356 RHS = ImpCastExprToType(E, LHSType,
10357 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10359 return computeResultTy();
10361 if (LHSType->isObjCObjectPointerType() &&
10369 if (LHSIsNull && !RHSIsNull)
10370 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10372 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
10373 return computeResultTy();
10376 if (!IsRelational && LHSType->isBlockPointerType() &&
10378 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10379 CK_BlockPointerToObjCPointerCast);
10380 return computeResultTy();
10381 }
else if (!IsRelational &&
10382 LHSType->isBlockCompatibleObjCPointerType(Context) &&
10384 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10385 CK_BlockPointerToObjCPointerCast);
10386 return computeResultTy();
10389 if ((LHSType->isAnyPointerType() && RHSType->
isIntegerType()) ||
10391 unsigned DiagID = 0;
10392 bool isError =
false;
10393 if (LangOpts.DebuggerSupport) {
10396 }
else if ((LHSIsNull && LHSType->isIntegerType()) ||
10398 if (IsRelational) {
10399 isError = getLangOpts().CPlusPlus;
10401 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
10402 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
10405 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
10407 }
else if (IsRelational)
10408 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
10410 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
10414 << LHSType << RHSType << LHS.
get()->getSourceRange()
10415 << RHS.
get()->getSourceRange();
10420 if (LHSType->isIntegerType())
10421 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10422 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10424 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10425 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10426 return computeResultTy();
10430 if (!IsRelational && RHSIsNull
10431 && LHSType->isBlockPointerType() && RHSType->
isIntegerType()) {
10432 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10433 return computeResultTy();
10435 if (!IsRelational && LHSIsNull
10437 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10438 return computeResultTy();
10441 if (getLangOpts().OpenCLVersion >= 200) {
10442 if (LHSIsNull && RHSType->
isQueueT()) {
10443 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10444 return computeResultTy();
10447 if (LHSType->isQueueT() && RHSIsNull) {
10448 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10449 return computeResultTy();
10453 return InvalidOperands(Loc, LHS, RHS);
10465 if (isa<ExtVectorType>(VTy)) {
10475 "Unhandled vector element size in vector compare");
10492 "Unhandled vector element size in vector compare");
10506 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10508 getLangOpts().ZVector);
10516 if (getLangOpts().AltiVec &&
10528 assert(RHS.
get()->getType()->hasFloatingRepresentation());
10529 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
10533 return GetSignedVectorType(vType);
10540 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10544 return InvalidOperands(Loc, LHS, RHS);
10545 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
10547 return InvalidOperands(Loc, LHS, RHS);
10551 if (!getLangOpts().CPlusPlus &&
10553 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
10555 return GetSignedVectorType(LHS.
get()->getType());
10563 bool IsCompAssign =
10564 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
10566 if (LHS.
get()->getType()->isVectorType() ||
10567 RHS.
get()->getType()->isVectorType()) {
10568 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
10569 RHS.
get()->getType()->hasIntegerRepresentation())
10570 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
10572 getLangOpts().ZVector);
10573 return InvalidOperands(Loc, LHS, RHS);
10579 ExprResult LHSResult = LHS, RHSResult = RHS;
10580 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
10582 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
10584 LHS = LHSResult.
get();
10585 RHS = RHSResult.
get();
10589 return InvalidOperands(Loc, LHS, RHS);
10597 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
10598 return CheckVectorLogicalOperands(LHS, RHS, Loc);
10603 if (LHS.
get()->getType()->isIntegerType() &&
10604 !LHS.
get()->getType()->isBooleanType() &&
10605 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
10607 !Loc.
isMacroID() && !inTemplateInstantiation()) {
10612 llvm::APSInt Result;
10613 if (RHS.
get()->EvaluateAsInt(Result, Context))
10614 if ((getLangOpts().
Bool && !RHS.
get()->getType()->isBooleanType() &&
10615 !RHS.
get()->getExprLoc().isMacroID()) ||
10616 (Result != 0 && Result != 1)) {
10617 Diag(Loc, diag::warn_logical_instead_of_bitwise)
10618 << RHS.
get()->getSourceRange()
10619 << (Opc == BO_LAnd ?
"&&" :
"||");
10621 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
10622 << (Opc == BO_LAnd ?
"&" :
"|")
10624 Loc, getLocForEndOfToken(Loc)),
10625 Opc == BO_LAnd ?
"&" :
"|");
10626 if (Opc == BO_LAnd)
10628 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
10631 RHS.
get()->getLocEnd()));
10640 if (LHS.
get()->getType()->isFloatingType() ||
10641 RHS.
get()->getType()->isFloatingType())
10642 return InvalidOperands(Loc, LHS, RHS);
10645 LHS = UsualUnaryConversions(LHS.
get());
10649 RHS = UsualUnaryConversions(RHS.
get());
10653 if (!LHS.
get()->getType()->isScalarType() ||
10654 !RHS.
get()->getType()->isScalarType())
10655 return InvalidOperands(Loc, LHS, RHS);
10657 return Context.
IntTy;
10666 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
10668 return InvalidOperands(Loc, LHS, RHS);
10671 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
10673 return InvalidOperands(Loc, LHS, RHS);
10684 if (!ME)
return false;
10688 if (!Base)
return false;
10709 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
10717 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
10760 bool DiagnosticEmitted =
false;
10764 bool IsDereference =
false;
10765 bool NextIsDereference =
false;
10769 IsDereference = NextIsDereference;
10772 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
10773 NextIsDereference = ME->isArrow();
10774 const ValueDecl *VD = ME->getMemberDecl();
10775 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
10777 if (Field->isMutable()) {
10778 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
10783 if (!DiagnosticEmitted) {
10784 S.
Diag(Loc, diag::err_typecheck_assign_const)
10786 << Field->getType();
10787 DiagnosticEmitted =
true;
10790 <<
ConstMember <<
false << Field << Field->getType()
10791 << Field->getSourceRange();
10795 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
10796 if (VDecl->getType().isConstQualified()) {
10797 if (!DiagnosticEmitted) {
10798 S.
Diag(Loc, diag::err_typecheck_assign_const)
10800 << VDecl->getType();
10801 DiagnosticEmitted =
true;
10804 <<
ConstMember <<
true << VDecl << VDecl->getType()
10805 << VDecl->getSourceRange();
10812 dyn_cast<ArraySubscriptExpr>(E)) {
10816 dyn_cast<ExtVectorElementExpr>(E)) {
10823 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
10827 if (!DiagnosticEmitted) {
10828 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
10830 DiagnosticEmitted =
true;
10833 diag::note_typecheck_assign_const)
10837 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
10839 if (
const ValueDecl *VD = DRE->getDecl()) {
10841 if (!DiagnosticEmitted) {
10842 S.
Diag(Loc, diag::err_typecheck_assign_const)
10844 DiagnosticEmitted =
true;
10846 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
10847 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
10850 }
else if (isa<CXXThisExpr>(E)) {
10852 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
10853 if (MD->isConst()) {
10854 if (!DiagnosticEmitted) {
10855 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
10857 DiagnosticEmitted =
true;
10859 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
10866 if (DiagnosticEmitted)
10870 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
10883 bool &DiagnosticEmitted,
10884 bool IsNested =
false) {
10889 if (Field->getType().isConstQualified()) {
10890 if (!DiagnosticEmitted) {
10891 S.
Diag(Loc, diag::err_typecheck_assign_const)
10893 << IsNested << Field;
10894 DiagnosticEmitted =
true;
10896 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
10898 << Field->getType() << Field->getSourceRange();
10906 OEK, DiagnosticEmitted,
true);
10915 assert(Ty->
isRecordType() &&
"lvalue was not record?");
10918 bool DiagEmitted =
false;
10920 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
10923 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
10948 unsigned DiagID = 0;
10949 bool NeedType =
false;
10956 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
10958 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
10966 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
10979 ? diag::err_typecheck_arc_assign_self_class_method
10980 : diag::err_typecheck_arc_assign_self;
10984 DiagID = diag::err_typecheck_arr_assign_enumeration;
10987 if (Loc != OrigLoc)
11013 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
11017 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
11021 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
11024 llvm_unreachable(
"did not take early return for MLV_Valid");
11028 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
11033 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
11035 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
11038 llvm_unreachable(
"readonly properties should be processed differently");
11040 DiagID = diag::err_readonly_message_assignment;
11043 DiagID = diag::err_no_subobject_property_setting;
11048 if (Loc != OrigLoc)
11073 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase())))
11078 cast<ValueDecl>(MR->getMemberDecl()->getCanonicalDecl());
11079 if (LHSDecl != RHSDecl)
11084 if (RefTy->getPointeeType().isVolatileQualified())
11087 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
11093 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
11096 if (RL && RR && RL->
getDecl() == RR->getDecl())
11097 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
11117 if (getLangOpts().OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
11119 Diag(Loc, diag::err_opencl_half_load_store) << 1
11125 if (CompoundType.
isNull()) {
11131 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
11135 if (ConvTy == IncompatiblePointer &&
11140 ConvTy = Compatible;
11142 if (ConvTy == Compatible &&
11144 Diag(Loc, diag::err_objc_object_assignment)
11151 RHSCheck = ICE->getSubExpr();
11152 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
11153 if ((UO->getOpcode() == UO_Plus ||
11154 UO->getOpcode() == UO_Minus) &&
11155 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
11161 UO->getSubExpr()->getLocStart().
isFileID()) {
11162 Diag(Loc, diag::warn_not_compound_assign)
11163 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
11164 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
11168 if (ConvTy == Compatible) {
11176 checkRetainCycles(LHSExpr, RHS.
get());
11190 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11191 RHS.
get()->getLocStart()))
11192 getCurFunction()->markSafeWeakUse(RHS.
get());
11194 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
11195 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
11200 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
11203 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
11204 RHS.
get(), AA_Assigning))
11224 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
11225 if (CE->getCastKind() == CK_ToVoid) {
11242 if (inTemplateInstantiation())
11251 const unsigned ForIncrementFlags =
11254 const unsigned ScopeFlags = getCurScope()->getFlags();
11255 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
11256 (ScopeFlags & ForInitFlags) == ForInitFlags)
11261 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
11262 if (BO->getOpcode() != BO_Comma)
11264 LHS = BO->getRHS();
11271 Diag(Loc, diag::warn_comma_operator);
11275 LangOpts.CPlusPlus ?
"static_cast<void>(" 11305 if (!RHS.
get()->getType()->isVoidType())
11307 diag::err_incomplete_type);
11313 return RHS.
get()->getType();
11322 bool IsInc,
bool IsPrefix) {
11331 ResType = ResAtomicType->getValueType();
11333 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
11335 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
11343 : diag::warn_increment_bool)
11345 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
11347 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
11349 }
else if (ResType->isRealType()) {
11351 }
else if (ResType->isPointerType()) {
11355 }
else if (ResType->isObjCObjectPointerType()) {
11361 }
else if (ResType->isAnyComplexType()) {
11363 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
11365 }
else if (ResType->isPlaceholderType()) {
11370 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
11372 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
11373 (ResType->getAs<
VectorType>()->getVectorKind() !=
11376 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
11380 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
11397 return ResType.getUnqualifiedType();
11416 case Stmt::DeclRefExprClass:
11417 return cast<DeclRefExpr>(E)->getDecl();
11418 case Stmt::MemberExprClass:
11422 if (cast<MemberExpr>(E)->isArrow())
11426 case Stmt::ArraySubscriptExprClass: {
11429 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
11431 if (ICE->getSubExpr()->getType()->isArrayType())
11436 case Stmt::UnaryOperatorClass: {
11448 case Stmt::ParenExprClass:
11450 case Stmt::ImplicitCastExprClass:
11462 AO_Vector_Element = 1,
11463 AO_Property_Expansion = 2,
11464 AO_Register_Variable = 3,
11484 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
11485 if (PTy->getKind() == BuiltinType::Overload) {
11486 Expr *E = OrigOp.
get()->IgnoreParens();
11487 if (!isa<OverloadExpr>(E)) {
11488 assert(cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf);
11489 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
11490 << OrigOp.
get()->getSourceRange();
11495 if (isa<UnresolvedMemberExpr>(Ovl))
11496 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
11497 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11498 << OrigOp.
get()->getSourceRange();
11505 if (PTy->getKind() == BuiltinType::UnknownAny)
11508 if (PTy->getKind() == BuiltinType::BoundMember) {
11509 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11510 << OrigOp.
get()->getSourceRange();
11514 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
11518 if (OrigOp.
get()->isTypeDependent())
11521 assert(!OrigOp.
get()->getType()->isPlaceholderType());
11524 Expr *op = OrigOp.
get()->IgnoreParens();
11531 if (LangOpts.OpenCL) {
11533 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
11534 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
11539 if (getLangOpts().
C99) {
11542 if (uOp->getOpcode() == UO_Deref)
11545 return uOp->getSubExpr()->getType();
11552 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
11558 unsigned AddressOfError = AO_No_Error;
11561 bool sfinae = (
bool)isSFINAEContext();
11562 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
11563 : diag::ext_typecheck_addrof_temporary)
11569 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
11570 }
else if (isa<ObjCSelectorExpr>(op)) {
11577 if (!isa<DeclRefExpr>(op)) {
11578 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11579 << OrigOp.
get()->getSourceRange();
11586 if (OrigOp.
get() != DRE) {
11587 Diag(OpLoc, diag::err_parens_pointer_member_function)
11588 << OrigOp.
get()->getSourceRange();
11592 if (MD->getParent()->getName().empty())
11593 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11597 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
11598 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11605 if (isa<CXXDestructorDecl>(MD))
11612 (
void)isCompleteType(OpLoc, MPTy);
11619 if (isa<PseudoObjectExpr>(op)) {
11620 AddressOfError = AO_Property_Expansion;
11622 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
11629 AddressOfError = AO_Bit_Field;
11632 AddressOfError = AO_Vector_Element;
11636 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
11640 !getLangOpts().CPlusPlus) {
11641 AddressOfError = AO_Register_Variable;
11643 }
else if (isa<MSPropertyDecl>(dcl)) {
11644 AddressOfError = AO_Property_Expansion;
11645 }
else if (isa<FunctionTemplateDecl>(dcl)) {
11647 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
11651 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
11656 diag::err_cannot_form_pointer_to_member_of_reference_type)
11661 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
11669 (
void)isCompleteType(OpLoc, MPTy);
11673 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
11674 !isa<BindingDecl>(dcl))
11675 llvm_unreachable(
"Unknown/unexpected decl type");
11678 if (AddressOfError != AO_No_Error) {
11694 CheckAddressOfPackedMember(op);
11710 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
11713 if (!FD->ModifiedNonNullParams.count(Param))
11714 FD->ModifiedNonNullParams.insert(Param);
11724 if (ConvResult.isInvalid())
11726 Op = ConvResult.get();
11730 if (isa<CXXReinterpretCastExpr>(Op)) {
11746 if (PR.
get() != Op)
11751 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
11766 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
11782 default: llvm_unreachable(
"Unknown binop!");
11783 case tok::periodstar: Opc = BO_PtrMemD;
break;
11784 case tok::arrowstar: Opc = BO_PtrMemI;
break;
11785 case tok::star: Opc = BO_Mul;
break;
11786 case tok::slash: Opc = BO_Div;
break;
11787 case tok::percent: Opc = BO_Rem;
break;
11788 case tok::plus: Opc = BO_Add;
break;
11789 case tok::minus: Opc = BO_Sub;
break;
11790 case tok::lessless: Opc = BO_Shl;
break;
11791 case tok::greatergreater: Opc = BO_Shr;
break;
11792 case tok::lessequal: Opc = BO_LE;
break;
11793 case tok::less: Opc = BO_LT;
break;
11794 case tok::greaterequal: Opc = BO_GE;
break;
11795 case tok::greater: Opc = BO_GT;
break;
11796 case tok::exclaimequal: Opc = BO_NE;
break;
11797 case tok::equalequal: Opc = BO_EQ;
break;
11798 case tok::spaceship: Opc = BO_Cmp;
break;
11799 case tok::amp: Opc = BO_And;
break;
11800 case tok::caret: Opc = BO_Xor;
break;
11801 case tok::pipe: Opc = BO_Or;
break;
11802 case tok::ampamp: Opc = BO_LAnd;
break;
11803 case tok::pipepipe: Opc = BO_LOr;
break;
11804 case tok::equal: Opc = BO_Assign;
break;
11805 case tok::starequal: Opc = BO_MulAssign;
break;
11806 case tok::slashequal: Opc = BO_DivAssign;
break;
11807 case tok::percentequal: Opc = BO_RemAssign;
break;
11808 case tok::plusequal: Opc = BO_AddAssign;
break;
11809 case tok::minusequal: Opc = BO_SubAssign;
break;
11810 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
11811 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
11812 case tok::ampequal: Opc = BO_AndAssign;
break;
11813 case tok::caretequal: Opc = BO_XorAssign;
break;
11814 case tok::pipeequal: Opc = BO_OrAssign;
break;
11815 case tok::comma: Opc = BO_Comma;
break;
11824 default: llvm_unreachable(
"Unknown unary op!");
11825 case tok::plusplus: Opc = UO_PreInc;
break;
11826 case tok::minusminus: Opc = UO_PreDec;
break;
11827 case tok::amp: Opc = UO_AddrOf;
break;
11828 case tok::star: Opc = UO_Deref;
break;
11829 case tok::plus: Opc = UO_Plus;
break;
11830 case tok::minus: Opc = UO_Minus;
break;
11831 case tok::tilde: Opc = UO_Not;
break;
11832 case tok::exclaim: Opc = UO_LNot;
break;
11833 case tok::kw___real: Opc = UO_Real;
break;
11834 case tok::kw___imag: Opc = UO_Imag;
break;
11835 case tok::kw___extension__: Opc = UO_Extension;
break;
11854 if (!LHSDeclRef || !RHSDeclRef ||
11856 RHSDeclRef->getLocation().isMacroID())
11861 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
11862 if (LHSDecl != RHSDecl)
11867 if (RefTy->getPointeeType().isVolatileQualified())
11870 S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
11871 : diag::warn_self_assignment_overloaded)
11883 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
11888 ObjCPointerExpr = LHS;
11892 ObjCPointerExpr = RHS;
11900 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
11901 unsigned Diag = diag::warn_objc_pointer_masking;
11910 if (SelArg0.startswith(
"performSelector"))
11911 Diag = diag::warn_objc_pointer_masking_performSelector;
11914 S.
Diag(OpLoc, Diag)
11922 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
11923 return DRE->getDecl();
11924 if (
auto *ME = dyn_cast<MemberExpr>(E))
11925 return ME->getMemberDecl();
11926 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
11927 return IRE->getDecl();
11942 "Result must be a vector of half or short");
11945 "both operands expected to be a half vector");
11957 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
11958 OpLoc, FPFeatures);
11962 VK, OK, OpLoc, FPFeatures);
11966 static std::pair<ExprResult, ExprResult>
11976 if (Opc != BO_Assign)
11983 return std::make_pair(LHS, RHS);
11990 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
12001 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
12013 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
12016 RHSExpr = Init.
get();
12026 bool ConvertHalfVec =
false;
12029 if (!LHS.
isUsable() || !RHS.isUsable())
12032 if (getLangOpts().OpenCL) {
12039 if (BO_Assign == Opc)
12040 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
12042 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12052 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12059 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
12060 if (getLangOpts().CPlusPlus &&
12062 VK = LHS.
get()->getValueKind();
12063 OK = LHS.
get()->getObjectKind();
12065 if (!ResultTy.
isNull()) {
12067 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
12073 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
12074 Opc == BO_PtrMemI);
12078 ConvertHalfVec =
true;
12079 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
12083 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
12086 ConvertHalfVec =
true;
12087 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
12090 ConvertHalfVec =
true;
12091 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
12095 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
12101 ConvertHalfVec =
true;
12102 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12106 ConvertHalfVec =
true;
12107 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12110 ConvertHalfVec =
true;
12111 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12119 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12123 ConvertHalfVec =
true;
12124 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
12128 ConvertHalfVec =
true;
12129 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
12130 Opc == BO_DivAssign);
12131 CompLHSTy = CompResultTy;
12133 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12136 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
12137 CompLHSTy = CompResultTy;
12139 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12142 ConvertHalfVec =
true;
12143 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
12145 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12148 ConvertHalfVec =
true;
12149 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
12151 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12155 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
12156 CompLHSTy = CompResultTy;
12158 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12165 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12166 CompLHSTy = CompResultTy;
12168 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12172 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
12173 VK = RHS.get()->getValueKind();
12174 OK = RHS.get()->getObjectKind();
12187 "both sides are half vectors or neither sides are");
12189 LHS.
get()->getType());
12192 CheckArrayAccess(LHS.
get());
12193 CheckArrayAccess(RHS.get());
12195 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
12196 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
12197 &Context.
Idents.
get(
"object_setClass"),
12199 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
12200 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getLocEnd());
12201 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign) <<
12207 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
12210 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
12214 if (CompResultTy.
isNull()) {
12215 if (ConvertHalfVec)
12217 OpLoc, FPFeatures);
12219 OK, OpLoc, FPFeatures);
12223 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
12226 OK = LHS.
get()->getObjectKind();
12229 if (ConvertHalfVec)
12231 OpLoc, FPFeatures);
12234 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
12235 OpLoc, FPFeatures);
12250 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
12251 if (isLeftComp == isRightComp)
12256 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
12257 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
12258 if (isLeftBitwise || isRightBitwise)
12264 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
12269 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
12272 Self.
PDiag(diag::note_precedence_silence) << OpStr,
12275 Self.
PDiag(diag::note_precedence_bitwise_first)
12290 Self.
PDiag(diag::note_precedence_silence)
12315 if (Bop->getOpcode() == BO_LAnd) {
12322 }
else if (Bop->getOpcode() == BO_LOr) {
12323 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
12326 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
12337 if (Bop->getOpcode() == BO_LAnd) {
12354 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
12355 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
12357 << Bop->getSourceRange() << OpLoc;
12359 S.
PDiag(diag::note_precedence_silence)
12360 << Bop->getOpcodeStr(),
12361 Bop->getSourceRange());
12369 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
12370 StringRef Op = Bop->getOpcodeStr();
12371 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
12372 << Bop->getSourceRange() << OpLoc << Shift << Op;
12374 S.
PDiag(diag::note_precedence_silence) << Op,
12375 Bop->getSourceRange());
12391 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
12394 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
12396 << (Kind == OO_LessLess);
12398 S.
PDiag(diag::note_precedence_silence)
12399 << (Kind == OO_LessLess ?
"<<" :
">>"),
12402 S.
PDiag(diag::note_evaluate_comparison_first),
12417 if ((Opc == BO_Or || Opc == BO_Xor) &&
12425 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
12431 || Opc == BO_Shr) {
12448 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
12449 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
12454 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
12483 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
12499 LHSExpr = LHS.
get();
12500 RHSExpr = RHS.
get();
12511 if (pty->getKind() == BuiltinType::PseudoObject &&
12513 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
12516 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
12522 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12524 RHSExpr = resolvedRHS.
get();
12537 if (Opc == BO_LT && inTemplateInstantiation() &&
12538 (pty->getKind() == BuiltinType::BoundMember ||
12539 pty->getKind() == BuiltinType::Overload)) {
12541 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
12542 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
12543 return isa<FunctionTemplateDecl>(ND);
12545 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
12546 : OE->getNameLoc(),
12547 diag::err_template_kw_missing)
12548 << OE->getName().getAsString() <<
"";
12553 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
12555 LHSExpr = LHS.
get();
12562 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
12563 if (getLangOpts().CPlusPlus &&
12568 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12572 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
12576 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12578 RHSExpr = resolvedRHS.
get();
12595 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12615 bool CanOverflow =
false;
12617 bool ConvertHalfVec =
false;
12618 if (getLangOpts().OpenCL) {
12626 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12628 << Input.
get()->getSourceRange());
12638 Opc == UO_PreInc ||
12640 Opc == UO_PreInc ||
12645 resultType = CheckAddressOfOperand(Input, OpLoc);
12649 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
12656 CanOverflow = Opc == UO_Minus &&
12658 Input = UsualUnaryConversions(Input.get());
12659 if (Input.isInvalid())
return ExprError();
12668 if (ConvertHalfVec)
12670 resultType = Input.get()->getType();
12671 if (resultType->isDependentType())
12673 if (resultType->isArithmeticType())
12675 else if (resultType->isVectorType() &&
12678 resultType->getAs<
VectorType>()->getVectorKind() !=
12681 else if (getLangOpts().CPlusPlus &&
12683 resultType->isPointerType())
12686 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12687 << resultType << Input.get()->getSourceRange());
12690 Input = UsualUnaryConversions(Input.get());
12691 if (Input.isInvalid())
12693 resultType = Input.
get()->getType();
12695 if (resultType->isDependentType())
12698 if (resultType->isComplexType() || resultType->isComplexIntegerType())
12700 Diag(OpLoc, diag::ext_integer_complement_complex)
12701 << resultType << Input.get()->getSourceRange();
12702 else if (resultType->hasIntegerRepresentation())
12704 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
12709 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12710 << resultType << Input.get()->getSourceRange());
12712 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12713 << resultType << Input.get()->getSourceRange());
12719 Input = DefaultFunctionArrayLvalueConversion(Input.get());
12720 if (Input.isInvalid())
return ExprError();
12721 resultType = Input.
get()->getType();
12724 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
12725 Input = ImpCastExprToType(Input.get(), Context.
FloatTy, CK_FloatingCast).
get();
12726 resultType = Context.
FloatTy;
12729 if (resultType->isDependentType())
12736 Input = ImpCastExprToType(Input.get(), Context.
BoolTy,
12737 ScalarTypeToBooleanCastKind(resultType));
12742 if (!resultType->isIntegerType() && !resultType->isPointerType())
12743 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12744 << resultType << Input.get()->getSourceRange());
12746 }
else if (resultType->isExtVectorType()) {
12753 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12754 << resultType << Input.get()->getSourceRange());
12757 resultType = GetSignedVectorType(resultType);
12762 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12763 << resultType << Input.get()->getSourceRange());
12775 if (Input.isInvalid())
return ExprError();
12776 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
12777 if (Input.get()->getValueKind() !=
VK_RValue &&
12779 VK = Input.
get()->getValueKind();
12782 Input = DefaultLvalueConversion(Input.get());
12786 resultType = Input.get()->getType();
12787 VK = Input.get()->getValueKind();
12788 OK = Input.get()->getObjectKind();
12793 assert(!Input.get()->getType()->isDependentType() &&
12794 "the co_await expression must be non-dependant before " 12795 "building operator co_await");
12805 if (Opc != UO_AddrOf && Opc != UO_Deref)
12806 CheckArrayAccess(Input.
get());
12808 auto *UO =
new (Context)
12811 if (ConvertHalfVec)
12820 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
12821 if (!DRE->getQualifier())
12828 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
12831 return Method->isInstance();
12837 if (!ULE->getQualifier())
12842 if (Method->isInstance())
12862 if (pty->getKind() == BuiltinType::PseudoObject &&
12864 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
12867 if (Opc == UO_Extension)
12868 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12872 if (Opc == UO_AddrOf &&
12873 (pty->getKind() == BuiltinType::Overload ||
12874 pty->getKind() == BuiltinType::UnknownAny ||
12875 pty->getKind() == BuiltinType::BoundMember))
12876 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12879 ExprResult Result = CheckPlaceholderExpr(Input);
12881 Input = Result.
get();
12886 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
12894 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
12897 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
12900 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12926 if (!cleanups)
return nullptr;
12929 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
12942 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
12949 DiscardCleanupsInEvaluationContext();
12950 PopExpressionEvaluationContext();
12956 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
12959 if (hasAnyUnrecoverableErrorsInThisFunction())
12960 DiscardCleanupsInEvaluationContext();
12961 assert(!Cleanup.exprNeedsCleanups() &&
12962 "cleanups within StmtExpr not correctly bound!");
12963 PopExpressionEvaluationContext();
12972 bool StmtExprMayBindToTemp =
false;
12978 LastLabelStmt =
Label;
12979 LastStmt =
Label->getSubStmt();
12982 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
12985 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
12988 Ty = LastExpr.
get()->getType().getUnqualifiedType();
12997 if (
Expr *rebuiltLastStmt
12999 LastExpr = rebuiltLastStmt;
13001 LastExpr = PerformCopyInitialization(
13008 if (LastExpr.
get() !=
nullptr) {
13009 if (!LastLabelStmt)
13013 StmtExprMayBindToTemp =
true;
13021 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
13022 if (StmtExprMayBindToTemp)
13023 return MaybeBindToTemporary(ResStmtExpr);
13024 return ResStmtExpr;
13039 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
13040 << ArgTy << TypeRange);
13045 && RequireCompleteType(BuiltinLoc, ArgTy,
13046 diag::err_offsetof_incomplete_type, TypeRange))
13049 bool DidWarnAboutNonPOD =
false;
13054 if (OC.isBrackets) {
13059 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
13065 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
13075 diag::err_typecheck_subscript_not_integer)
13079 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
13080 Exprs.push_back(Idx);
13088 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
13094 if (RequireCompleteType(OC.LocStart, CurrentType,
13095 diag::err_offsetof_incomplete_type))
13101 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
13113 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
13115 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
13116 : diag::ext_offsetof_non_pod_type;
13118 if (!IsSafe && !DidWarnAboutNonPOD &&
13119 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
13121 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
13123 DidWarnAboutNonPOD =
true;
13127 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
13128 LookupQualifiedName(R, RD);
13133 MemberDecl = IndirectMemberDecl->getAnonField();
13138 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
13146 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
13154 if (IndirectMemberDecl)
13155 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
13160 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
13162 if (Paths.getDetectedVirtual()) {
13163 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
13174 if (IndirectMemberDecl) {
13175 for (
auto *FI : IndirectMemberDecl->chain()) {
13176 assert(isa<FieldDecl>(FI));
13178 cast<FieldDecl>(FI), OC.LocEnd));
13181 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
13187 Comps, Exprs, RParenLoc);
13198 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
13205 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
13213 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
13218 bool ValueDependent =
false;
13219 bool CondIsTrue =
false;
13222 ValueDependent =
true;
13225 llvm::APSInt condEval(32);
13227 = VerifyIntegerConstantExpression(CondExpr, &condEval,
13228 diag::err_typecheck_choose_expr_requires_constant,
false);
13231 CondExpr = CondICE.
get();
13232 CondIsTrue = condEval.getZExtValue();
13235 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
13237 resType = ActiveExpr->
getType();
13243 return new (Context)
13244 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
13256 if (LangOpts.CPlusPlus) {
13257 Decl *ManglingContextDecl;
13260 ManglingContextDecl)) {
13261 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
13266 PushBlockScope(CurScope, Block);
13267 CurContext->addDecl(Block);
13269 PushDeclContext(CurScope, Block);
13271 CurContext = Block;
13273 getCurBlock()->HasImplicitReturnType =
true;
13277 PushExpressionEvaluationContext(
13278 ExpressionEvaluationContext::PotentiallyEvaluated);
13284 "block-id should have no identifier!");
13288 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
13293 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
13306 "GetTypeForDeclarator made a non-function block signature");
13311 if ((ExplicitSignature =
13317 if (ExplicitSignature.getLocalRangeBegin() ==
13318 ExplicitSignature.getLocalRangeEnd()) {
13321 TypeLoc Result = ExplicitSignature.getReturnLoc();
13330 CurBlock->TheDecl->setSignatureAsWritten(Sig);
13331 CurBlock->FunctionType = T;
13336 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
13338 CurBlock->TheDecl->setIsVariadic(isVariadic);
13345 CurBlock->ReturnType = RetTy;
13346 CurBlock->TheDecl->setBlockMissingReturnType(
false);
13347 CurBlock->HasImplicitReturnType =
false;
13352 if (ExplicitSignature) {
13353 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
13354 ParmVarDecl *Param = ExplicitSignature.getParam(I);
13358 !getLangOpts().CPlusPlus)
13360 Params.push_back(Param);
13366 for (
const auto &I : Fn->param_types()) {
13369 Params.push_back(Param);
13374 if (!Params.empty()) {
13375 CurBlock->TheDecl->setParams(Params);
13376 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
13381 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
13384 for (
auto AI : CurBlock->TheDecl->parameters()) {
13385 AI->setOwningFunction(CurBlock->TheDecl);
13388 if (AI->getIdentifier()) {
13389 CheckShadow(CurBlock->TheScope, AI);
13391 PushOnScopeChains(AI, CurBlock->TheScope);
13400 DiscardCleanupsInEvaluationContext();
13401 PopExpressionEvaluationContext();
13405 PopFunctionScopeInfo();
13413 if (!LangOpts.Blocks)
13414 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
13417 if (hasAnyUnrecoverableErrorsInThisFunction())
13418 DiscardCleanupsInEvaluationContext();
13419 assert(!Cleanup.exprNeedsCleanups() &&
13420 "cleanups within block not correctly bound!");
13421 PopExpressionEvaluationContext();
13423 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
13426 deduceClosureReturnType(*BSI);
13445 Captures.push_back(NewCap);
13454 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
13457 if (isa<FunctionNoProtoType>(FTy)) {
13488 if (getCurFunction()->NeedsScopeChecking() &&
13489 !PP.isCodeCompletionEnabled())
13490 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
13494 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13495 DiagnoseUnguardedAvailabilityViolations(BSI->
TheDecl);
13502 computeNRVO(Body, BSI);
13506 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
13513 Cleanup.setExprNeedsCleanups(
true);
13518 const VarDecl *var = CI.getVariable();
13520 setFunctionHasBranchProtectedScope();
13532 GetTypeFromParser(Ty, &TInfo);
13533 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
13539 Expr *OrigExpr = E;
13543 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
13544 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
13546 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
13573 ExprResult Result = UsualUnaryConversions(E);
13577 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
13583 if (Init.isInvalid())
13585 E = Init.getAs<
Expr>();
13598 diag::err_first_argument_to_va_arg_not_of_type_va_list)
13603 diag::err_second_parameter_to_va_arg_incomplete,
13609 diag::err_second_parameter_to_va_arg_abstract,
13616 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
13617 : diag::warn_second_parameter_to_va_arg_not_pod)
13634 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
13641 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
13650 Ty = Context.
IntTy;
13656 llvm_unreachable(
"I don't know size of pointer!");
13664 if (!getLangOpts().ObjC1)
13683 if (OV->getSourceExpr())
13692 Exp = BuildObjCStringLiteral(SL->
getLocStart(), SL).
get();
13698 const Expr *SrcExpr) {
13720 bool *Complained) {
13722 *Complained =
false;
13725 bool CheckInferredResultType =
false;
13727 unsigned DiagKind = 0;
13730 bool MayHaveConvFixit =
false;
13731 bool MayHaveFunctionDiff =
false;
13737 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
13741 DiagKind = diag::ext_typecheck_convert_pointer_int;
13743 MayHaveConvFixit =
true;
13746 DiagKind = diag::ext_typecheck_convert_int_pointer;
13748 MayHaveConvFixit =
true;
13750 case IncompatiblePointer:
13751 if (Action == AA_Passing_CFAudited)
13752 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
13755 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
13757 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
13761 if (Hint.
isNull() && !CheckInferredResultType) {
13764 else if (CheckInferredResultType) {
13768 MayHaveConvFixit =
true;
13770 case IncompatiblePointerSign:
13771 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
13773 case FunctionVoidPointer:
13774 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
13776 case IncompatiblePointerDiscardsQualifiers: {
13783 DiagKind = diag::err_typecheck_incompatible_address_space;
13787 DiagKind = diag::err_typecheck_incompatible_ownership;
13791 llvm_unreachable(
"unknown error case for discarding qualifiers!");
13794 case CompatiblePointerDiscardsQualifiers:
13805 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
13807 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
13809 case IncompatibleNestedPointerQualifiers:
13810 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
13812 case IntToBlockPointer:
13813 DiagKind = diag::err_int_to_block_pointer;
13815 case IncompatibleBlockPointer:
13816 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
13818 case IncompatibleObjCQualifiedId: {
13822 for (
auto *srcProto : srcOPT->
quals()) {
13828 IFace = IFaceT->getDecl();
13833 for (
auto *dstProto : dstOPT->
quals()) {
13839 IFace = IFaceT->getDecl();
13841 DiagKind = diag::warn_incompatible_qualified_id;
13844 case IncompatibleVectors:
13845 DiagKind = diag::warn_incompatible_vectors;
13847 case IncompatibleObjCWeakRef:
13848 DiagKind = diag::err_arc_weak_unavailable_assign;
13853 *Complained =
true;
13857 DiagKind = diag::err_typecheck_convert_incompatible;
13859 MayHaveConvFixit =
true;
13861 MayHaveFunctionDiff =
true;
13868 case AA_Initializing:
13870 FirstType = DstType;
13871 SecondType = SrcType;
13876 case AA_Passing_CFAudited:
13877 case AA_Converting:
13881 FirstType = SrcType;
13882 SecondType = DstType;
13887 if (Action == AA_Passing_CFAudited)
13888 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
13890 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
13894 if (!ConvHints.
isNull()) {
13900 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
13902 if (MayHaveFunctionDiff)
13903 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
13906 if (DiagKind == diag::warn_incompatible_qualified_id &&
13908 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
13915 if (CheckInferredResultType)
13916 EmitRelatedResultTypeNote(SrcExpr);
13918 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
13919 EmitRelatedResultTypeNoteForReturn(DstType);
13922 *Complained =
true;
13927 llvm::APSInt *Result) {
13931 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
13935 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
13939 llvm::APSInt *Result,
13946 IDDiagnoser(
unsigned DiagID)
13950 S.
Diag(Loc, DiagID) << SR;
13952 } Diagnoser(DiagID);
13954 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
13959 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
13977 CXX11ConvertDiagnoser(
bool Silent)
13983 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
13988 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
13993 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
14004 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
14015 llvm_unreachable(
"conversion functions are permitted");
14017 } ConvertDiagnoser(Diagnoser.
Suppress);
14019 Converted = PerformContextualImplicitConversion(DiagLoc, E,
14023 E = Converted.
get();
14043 EvalResult.
Diag = &Notes;
14053 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
14062 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14063 diag::note_invalid_subexpr_in_const_expr) {
14064 DiagLoc = Notes[0].first;
14068 if (!Folded || !AllowFold) {
14072 Diag(Note.first, Note.second);
14080 Diag(Note.first, Note.second);
14090 class TransformToPE :
public TreeTransform<TransformToPE> {
14094 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
14097 bool AlwaysRebuild() {
return true; }
14104 return BaseTransform::TransformLabelStmt(S);
14115 if (isa<FieldDecl>(E->
getDecl()) &&
14118 diag::err_invalid_non_static_member_use)
14121 return BaseTransform::TransformDeclRefExpr(E);
14129 return BaseTransform::TransformUnaryOperator(E);
14140 assert(isUnevaluatedContext() &&
14141 "Should only transform unevaluated expressions");
14142 ExprEvalContexts.back().Context =
14143 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
14144 if (isUnevaluatedContext())
14146 return TransformToPE(*this).TransformExpr(E);
14153 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
14154 LambdaContextDecl, ExprContext);
14156 if (!MaybeODRUseExprs.empty())
14157 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
14164 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
14165 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
14181 D = diag::err_lambda_unevaluated_operand;
14187 D = diag::err_lambda_in_constant_expression;
14188 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
14191 D = diag::err_lambda_in_invalid_context;
14193 llvm_unreachable(
"Couldn't infer lambda error message.");
14195 for (
const auto *L : Rec.
Lambdas)
14196 Diag(L->getLocStart(), D);
14200 for (
auto *Lambda : Rec.
Lambdas) {
14201 for (
auto *C : Lambda->capture_inits())
14202 MarkDeclarationsReferencedInExpr(C);
14213 ExprCleanupObjects.end());
14215 CleanupVarDeclMarking();
14225 ExprEvalContexts.pop_back();
14227 if (!ExprEvalContexts.empty())
14228 ExprEvalContexts.back().NumTypos += NumTypos;
14230 assert(NumTypos == 0 &&
"There are outstanding typos after popping the " 14231 "last ExpressionEvaluationContextRecord");
14235 ExprCleanupObjects.erase(
14236 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
14237 ExprCleanupObjects.end());
14239 MaybeODRUseExprs.clear();
14245 return TransformToPotentiallyEvaluated(E);
14271 llvm_unreachable(
"Invalid context");
14296 llvm_unreachable(
"Invalid context");
14308 bool MightBeOdrUse) {
14309 assert(Func &&
"No function?");
14331 bool NeedDefinition =
14340 if (NeedDefinition &&
14343 checkSpecializationVisibility(Loc, Func);
14356 ResolveExceptionSpec(Loc, FPT);
14360 if ((Func->
isUsed(
false) || !OdrUse) &&
14361 (!NeedDefinition || Func->
getBody()))
14366 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
14367 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
14368 if (Constructor->isDefaultConstructor()) {
14369 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
14371 DefineImplicitDefaultConstructor(Loc, Constructor);
14372 }
else if (Constructor->isCopyConstructor()) {
14373 DefineImplicitCopyConstructor(Loc, Constructor);
14374 }
else if (Constructor->isMoveConstructor()) {
14375 DefineImplicitMoveConstructor(Loc, Constructor);
14377 }
else if (Constructor->getInheritedConstructor()) {
14378 DefineInheritingConstructor(Loc, Constructor);
14381 dyn_cast<CXXDestructorDecl>(Func)) {
14382 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
14383 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
14384 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
14386 DefineImplicitDestructor(Loc, Destructor);
14388 if (Destructor->isVirtual() && getLangOpts().AppleKext)
14389 MarkVTableUsed(Loc, Destructor->getParent());
14390 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
14391 if (MethodDecl->isOverloadedOperator() &&
14392 MethodDecl->getOverloadedOperator() == OO_Equal) {
14393 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
14394 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
14395 if (MethodDecl->isCopyAssignmentOperator())
14396 DefineImplicitCopyAssignment(Loc, MethodDecl);
14397 else if (MethodDecl->isMoveAssignmentOperator())
14398 DefineImplicitMoveAssignment(Loc, MethodDecl);
14400 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
14401 MethodDecl->getParent()->isLambda()) {
14403 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
14405 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
14407 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
14408 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
14409 MarkVTableUsed(Loc, MethodDecl->getParent());
14414 if (CurContext == Func)
return;
14421 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
14422 if (FirstInstantiation) {
14423 PointOfInstantiation = Loc;
14429 PointOfInstantiation = Loc;
14436 CodeSynthesisContexts.size())
14437 PendingLocalImplicitInstantiations.push_back(
14438 std::make_pair(Func, PointOfInstantiation));
14443 InstantiateFunctionDefinition(PointOfInstantiation, Func);
14446 PendingInstantiations.push_back(std::make_pair(Func,
14447 PointOfInstantiation));
14449 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
14454 for (
auto i : Func->
redecls()) {
14455 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
14456 MarkFunctionReferenced(Loc, i, OdrUse);
14460 if (!OdrUse)
return;
14464 if (mightHaveNonExternalLinkage(Func))
14467 !LangOpts.GNUInline &&
14470 else if (isExternalWithNoLinkageType(Func))
14485 if (isa<ParmVarDecl>(var) &&
14486 isa<TranslationUnitDecl>(VarDC))
14499 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
14501 if (isa<CXXMethodDecl>(VarDC) &&
14502 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
14504 }
else if (isa<FunctionDecl>(VarDC)) {
14506 }
else if (isa<BlockDecl>(VarDC)) {
14510 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
14511 << var << ValueKind << ContextKind << VarDC;
14521 bool &SubCapturesAreNested,
14527 SubCapturesAreNested =
true;
14540 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
14541 !(isa<CapturedRegionScopeInfo>(CSI) &&
14542 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
14553 const bool Diagnose,
Sema &S) {
14568 const bool Diagnose,
Sema &S) {
14570 bool IsBlock = isa<BlockScopeInfo>(CSI);
14571 bool IsLambda = isa<LambdaScopeInfo>(CSI);
14579 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
14588 S.
Diag(Loc, diag::err_ref_vm_type);
14597 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
14600 S.
Diag(Loc, diag::err_ref_flexarray_type);
14602 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
14610 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14613 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
14615 S.
Diag(Loc, diag::err_capture_block_variable)
14626 S.
Diag(Loc, diag::err_opencl_block_ref_block);
14636 const bool BuildAndDiagnose,
14641 Expr *CopyExpr =
nullptr;
14642 bool ByRef =
false;
14646 if (BuildAndDiagnose) {
14647 S.
Diag(Loc, diag::err_ref_array_type);
14656 if (BuildAndDiagnose) {
14657 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
14671 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
14677 Ty = AttrTy->getModifiedType();
14687 !IsObjCOwnershipAttributedType(PointeeTy)) {
14688 if (BuildAndDiagnose) {
14690 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
14691 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
14696 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14705 DeclRefType = CaptureType;
14707 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
14714 if (isa<ParmVarDecl>(Var))
14732 CaptureType,
false),
14739 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
14742 CopyExpr = Result.
get();
14749 if (BuildAndDiagnose)
14750 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
14762 const bool BuildAndDiagnose,
14765 const bool RefersToCapturedVariable,
14784 CaptureType = DeclRefType;
14786 Expr *CopyExpr =
nullptr;
14787 if (BuildAndDiagnose) {
14810 if (BuildAndDiagnose)
14811 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
14823 bool RefersToCapturedVariable) {
14840 const bool BuildAndDiagnose,
14843 const bool RefersToCapturedVariable,
14846 const bool IsTopScope,
14850 bool ByRef =
false;
14884 if (!RefType->getPointeeType()->isFunctionType())
14890 if (BuildAndDiagnose) {
14891 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
14899 if (BuildAndDiagnose) {
14902 diag::err_capture_of_incomplete_type,
14907 diag::err_capture_of_abstract_type))
14913 if (BuildAndDiagnose)
14915 RefersToCapturedVariable);
14932 if (BuildAndDiagnose)
14933 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
14934 Loc, EllipsisLoc, CaptureType,
nullptr);
14942 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
14950 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
14951 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
14954 if (FunctionScopeIndexToStopAt) {
14955 unsigned FSIndex = FunctionScopes.size() - 1;
14956 while (FSIndex != MaxFunctionScopesIndex) {
14965 if (VarDC == DC)
return true;
14970 if (IsGlobal && !(LangOpts.OpenMP && isOpenMPCapturedDecl(Var)))
14982 CaptureType = Var->
getType();
14984 bool Nested =
false;
14985 bool Explicit = (Kind != TryCapture_Implicit);
14986 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
14999 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
15020 if (BuildAndDiagnose) {
15043 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
15044 QTy = PVD->getOriginalType();
15048 if (getLangOpts().OpenMP) {
15049 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
15054 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
15055 auto IsTargetCap = !IsOpenMPPrivateDecl &&
15056 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
15061 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
15063 if (IsTargetCap || IsOpenMPPrivateDecl) {
15064 Nested = !IsTargetCap;
15075 if (BuildAndDiagnose) {
15079 if (cast<LambdaScopeInfo>(CSI)->Lambda)
15080 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
15081 diag::note_lambda_decl);
15097 FunctionScopesIndex--;
15100 }
while (!VarDC->
Equals(DC));
15107 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
15113 BuildAndDiagnose, CaptureType,
15114 DeclRefType, Nested, *
this))
15119 BuildAndDiagnose, CaptureType,
15120 DeclRefType, Nested, *
this))
15126 BuildAndDiagnose, CaptureType,
15127 DeclRefType, Nested, Kind, EllipsisLoc,
15128 I == N - 1, *
this))
15140 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
15142 DeclRefType,
nullptr);
15148 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15149 false, CaptureType,
15150 DeclRefType,
nullptr);
15158 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15159 false, CaptureType,
15160 DeclRefType,
nullptr))
15163 return DeclRefType;
15177 const VarDecl *DefVD =
nullptr;
15204 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
15205 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
15206 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
15207 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
15210 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
15215 Res = CorrectDelayedTyposInExpr(Res);
15224 UpdateMarkingForLValueToRValue(Res.
get());
15229 for (
Expr *E : MaybeODRUseExprs) {
15232 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
15233 Var = cast<VarDecl>(DRE->getDecl());
15234 Loc = DRE->getLocation();
15235 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
15236 Var = cast<VarDecl>(ME->getMemberDecl());
15237 Loc = ME->getMemberLoc();
15239 llvm_unreachable(
"Unexpected expression");
15246 MaybeODRUseExprs.clear();
15252 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
15253 "Invalid Expr argument to DoMarkVarDeclReferenced");
15259 bool UsableInConstantExpr =
15261 bool NeedDefinition =
15266 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
15267 "Can't instantiate a partial template specialization.");
15273 !isa<VarTemplateSpecializationDecl>(Var))
15284 bool TryInstantiating =
15288 if (TryInstantiating) {
15290 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
15291 if (FirstInstantiation) {
15292 PointOfInstantiation = Loc;
15296 bool InstantiationDependent =
false;
15297 bool IsNonDependent =
15303 if (IsNonDependent) {
15304 if (UsableInConstantExpr) {
15308 }
else if (FirstInstantiation ||
15309 isa<VarTemplateSpecializationDecl>(Var)) {
15316 .push_back(std::make_pair(Var, PointOfInstantiation));
15330 if (OdrUseContext && E &&
15337 }
else if (OdrUseContext) {
15345 const bool RefersToEnclosingScope =
15348 if (RefersToEnclosingScope) {
15361 assert(E &&
"Capture variable should be used in an expression.");
15378 Decl *D,
Expr *E,
bool MightBeOdrUse) {
15382 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
15398 bool IsVirtualCall = MD->
isVirtual() &&
15400 if (!IsVirtualCall)
15416 bool OdrUse =
true;
15418 if (Method->isVirtual() &&
15419 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
15432 bool MightBeOdrUse =
true;
15435 if (Method->isPure())
15436 MightBeOdrUse =
false;
15448 bool MightBeOdrUse) {
15449 if (MightBeOdrUse) {
15450 if (
auto *VD = dyn_cast<VarDecl>(D)) {
15451 MarkVariableReferenced(Loc, VD);
15455 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
15456 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
15483 bool MarkReferencedDecls::TraverseTemplateArgument(
15497 return Inherited::TraverseTemplateArgument(Arg);
15501 MarkReferencedDecls Marker(*
this, Loc);
15502 Marker.TraverseType(T);
15510 bool SkipLocalVariables;
15515 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
15516 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
15520 if (SkipLocalVariables) {
15522 if (VD->hasLocalStorage())
15531 Inherited::VisitMemberExpr(E);
15545 Inherited::VisitCXXNewExpr(E);
15553 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
15558 Inherited::VisitCXXDeleteExpr(E);
15563 Inherited::VisitCXXConstructExpr(E);
15571 Inherited::VisitImplicitCastExpr(E);
15585 bool SkipLocalVariables) {
15586 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
15607 switch (ExprEvalContexts.back().Context) {
15608 case ExpressionEvaluationContext::Unevaluated:
15609 case ExpressionEvaluationContext::UnevaluatedList:
15610 case ExpressionEvaluationContext::UnevaluatedAbstract:
15611 case ExpressionEvaluationContext::DiscardedStatement:
15615 case ExpressionEvaluationContext::ConstantEvaluated:
15619 case ExpressionEvaluationContext::PotentiallyEvaluated:
15620 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
15621 if (Statement && getCurFunctionOrMethodDecl()) {
15622 FunctionScopes.back()->PossiblyUnreachableDiags.
15632 if (
auto *VD = dyn_cast_or_null<VarDecl>(
15633 ExprEvalContexts.back().ManglingContextDecl)) {
15634 if (VD->isConstexpr() ||
15635 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
15655 if (ExprEvalContexts.back().ExprContext ==
15656 ExpressionEvaluationContextRecord::EK_Decltype) {
15657 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
15661 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
15667 : FD(FD), CE(CE) { }
15671 S.
Diag(Loc, diag::err_call_incomplete_return)
15676 S.
Diag(Loc, diag::err_call_function_incomplete_return)
15681 } Diagnoser(FD, CE);
15683 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
15694 unsigned diagnostic = diag::warn_condition_is_assignment;
15695 bool IsOrAssign =
false;
15698 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
15701 IsOrAssign = Op->getOpcode() == BO_OrAssign;
15705 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
15709 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
15710 diagnostic = diag::warn_condition_is_idiomatic_assignment;
15714 diagnostic = diag::warn_condition_is_idiomatic_assignment;
15717 Loc = Op->getOperatorLoc();
15719 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
15722 IsOrAssign = Op->getOperator() == OO_PipeEqual;
15723 Loc = Op->getOperatorLoc();
15725 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
15735 Diag(Loc, diag::note_condition_assign_silence)
15740 Diag(Loc, diag::note_condition_or_assign_to_comparison)
15743 Diag(Loc, diag::note_condition_assign_to_comparison)
15761 if (opE->getOpcode() == BO_EQ &&
15762 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
15768 Diag(Loc, diag::note_equality_comparison_silence)
15771 Diag(Loc, diag::note_equality_comparison_to_assign)
15777 bool IsConstexpr) {
15778 DiagnoseAssignmentAsCondition(E);
15779 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
15780 DiagnoseEqualityWithExtraParens(parenE);
15782 ExprResult result = CheckPlaceholderExpr(E);
15787 if (getLangOpts().CPlusPlus)
15788 return CheckCXXBooleanCondition(E, IsConstexpr);
15790 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
15797 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
15815 case ConditionKind::Boolean:
15816 Cond = CheckBooleanCondition(Loc, SubExpr);
15819 case ConditionKind::ConstexprIf:
15820 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
15823 case ConditionKind::Switch:
15824 Cond = CheckSwitchCondition(Loc, SubExpr);
15828 return ConditionError();
15832 if (!FullExpr.
get())
15833 return ConditionError();
15836 CK == ConditionKind::ConstexprIf);
15842 struct RebuildUnknownAnyFunction
15843 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
15847 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
15850 llvm_unreachable(
"unexpected statement!");
15854 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
15861 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
15862 ExprResult SubResult = Visit(E->getSubExpr());
15865 Expr *SubExpr = SubResult.
get();
15866 E->setSubExpr(SubExpr);
15867 E->setType(SubExpr->
getType());
15874 return rebuildSugarExpr(E);
15878 return rebuildSugarExpr(E);
15885 Expr *SubExpr = SubResult.
get();
15894 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
15899 if (S.getLangOpts().CPlusPlus &&
15900 !(isa<CXXMethodDecl>(VD) &&
15901 cast<CXXMethodDecl>(VD)->isInstance()))
15912 return resolveDecl(E, E->
getDecl());
15920 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
15930 struct RebuildUnknownAnyExpr
15931 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
15939 : S(S), DestType(CastType) {}
15942 llvm_unreachable(
"unexpected statement!");
15946 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
15956 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
15957 ExprResult SubResult = Visit(E->getSubExpr());
15959 Expr *SubExpr = SubResult.
get();
15960 E->setSubExpr(SubExpr);
15961 E->setType(SubExpr->
getType());
15968 return rebuildSugarExpr(E);
15972 return rebuildSugarExpr(E);
16010 return resolveDecl(E, E->
getDecl());
16021 FK_FunctionPointer,
16028 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
16029 Kind = FK_MemberFunction;
16033 Kind = FK_FunctionPointer;
16036 Kind = FK_BlockPointer;
16041 if (DestType->isArrayType() || DestType->isFunctionType()) {
16042 unsigned diagID = diag::err_func_returning_array_function;
16043 if (Kind == FK_BlockPointer)
16044 diagID = diag::err_block_returning_array_function;
16047 << DestType->isFunctionType() << DestType;
16080 if (ParamTypes.empty() && Proto->isVariadic()) {
16082 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
16090 ArgTypes.push_back(ArgType);
16092 ParamTypes = ArgTypes;
16095 Proto->getExtProtoInfo());
16103 case FK_MemberFunction:
16107 case FK_FunctionPointer:
16111 case FK_BlockPointer:
16117 ExprResult CalleeResult = Visit(CalleeExpr);
16127 if (DestType->isArrayType() || DestType->isFunctionType()) {
16128 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
16129 << DestType->isFunctionType() << DestType;
16136 Method->setReturnType(DestType);
16140 E->
setType(DestType.getNonReferenceType());
16148 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
16155 DestType = DestType->castAs<
PointerType>()->getPointeeType();
16162 }
else if (E->
getCastKind() == CK_LValueToRValue) {
16166 assert(isa<BlockPointerType>(E->
getType()));
16179 llvm_unreachable(
"Unhandled cast type!");
16212 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
16215 FD->getDeclContext(),
16216 Loc, Loc, FD->getNameInfo().getName(),
16217 DestType, FD->getTypeSourceInfo(),
16219 FD->hasPrototype(),
16222 if (FD->getQualifier())
16226 for (
const auto &AI : FT->param_types()) {
16230 Params.push_back(Param);
16232 NewFD->setParams(Params);
16233 DRE->setDecl(NewFD);
16234 VD = DRE->getDecl();
16239 if (MD->isInstance()) {
16249 }
else if (isa<VarDecl>(VD)) {
16253 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
16281 diag::err_typecheck_cast_to_incomplete))
16285 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
16288 CastExpr = result.
get();
16290 CastKind = CK_NoOp;
16296 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
16305 ExprResult result = DefaultArgumentPromotion(arg);
16307 paramType = result.
get()->getType();
16319 return PerformCopyInitialization(entity, callLoc, arg);
16324 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
16327 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
16328 E = call->getCallee();
16329 diagID = diag::err_uncasted_call_of_unknown_any;
16337 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
16338 loc = ref->getLocation();
16339 d = ref->getDecl();
16340 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
16341 loc = mem->getMemberLoc();
16342 d = mem->getMemberDecl();
16344 diagID = diag::err_uncasted_call_of_unknown_any;
16345 loc = msg->getSelectorStartLoc();
16346 d = msg->getMethodDecl();
16348 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
16349 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
16372 ExprResult Result = CorrectDelayedTyposInExpr(E);
16378 if (!placeholderType)
return E;
16380 switch (placeholderType->
getKind()) {
16383 case BuiltinType::Overload: {
16387 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
16393 if (resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
16397 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
16403 case BuiltinType::BoundMember: {
16408 if (isa<CXXPseudoDestructorExpr>(BME)) {
16409 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
16410 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
16411 if (ME->getMemberNameInfo().getName().getNameKind() ==
16413 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
16415 tryToRecoverWithCall(result, PD,
16421 case BuiltinType::ARCUnbridgedCast: {
16422 Expr *realCast = stripARCUnbridgedCast(E);
16423 diagnoseARCUnbridgedCast(realCast);
16428 case BuiltinType::UnknownAny:
16432 case BuiltinType::PseudoObject:
16433 return checkPseudoObjectRValue(E);
16435 case BuiltinType::BuiltinFn: {
16439 auto *FD = cast<FunctionDecl>(DRE->getDecl());
16440 if (FD->getBuiltinID() == Builtin::BI__noop) {
16442 CK_BuiltinFnToFnPtr).get();
16443 return new (Context)
CallExpr(Context, E, None, Context.
IntTy,
16453 case BuiltinType::OMPArraySection:
16458 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 16459 case BuiltinType::Id: 16460 #include "clang/Basic/OpenCLImageTypes.def" 16461 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 16462 #define PLACEHOLDER_TYPE(Id, SingletonId) 16463 #include "clang/AST/BuiltinTypes.def" 16467 llvm_unreachable(
"invalid placeholder type!");
16481 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
16482 "Unknown Objective-C Boolean value!");
16487 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
16495 return new (Context)
16503 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
16505 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
16507 return Spec.getPlatform() == Platform;
16510 VersionTuple Version;
16511 if (Spec != AvailSpecs.end())
16512 Version = Spec->getVersion();
16516 if (getCurFunctionOrMethodDecl())
16517 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
16518 else if (getCurBlock() || getCurLambda())
16519 getCurFunction()->HasPotentialAvailabilityViolations =
true;
16521 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.
SourceLocation getLocStart() const LLVM_READONLY
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...
CXXRecordDecl * getNamingClass() const
Retrieve the naming class of this lookup.
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.
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
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)
void setImplicit(bool I=true)
void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt)
Represents a function declaration or definition.
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
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.
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.
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)
unsigned char getFixedPointIBits(QualType Ty) const
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
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).
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)
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
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.
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
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 UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
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...
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)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT)
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.
SourceLocation getLocStart() const LLVM_READONLY
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...
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)
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.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
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.
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
SourceLocation getLocStart() const LLVM_READONLY
MS property subscript expression.
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
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.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to...
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.
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)
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 EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
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)
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.
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...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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.
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, const FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static bool 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.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
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
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.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
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.
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 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.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
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.
LabelStmt - Represents a label, which has a substatement.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
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)
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...
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...
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S)
Capture the given variable in the captured region.
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.
ObjCMethodFamily
A family of Objective-C methods.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
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.
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)
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
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
SourceLocation getLocEnd() const LLVM_READONLY
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)
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...
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)
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)
SourceLocation getLocStart() const LLVM_READONLY
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
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()
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
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)
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 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.
Describes an C or C++ initializer list.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
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)
Expr * getInitExpr() const
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
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
bool hasAddressSpace() const
LabelDecl * getDecl() 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 ==.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
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)
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.
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
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.
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
IgnoreParenCasts - Ignore parentheses and casts.
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.
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...
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)
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.
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)
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...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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]).
void setStmt(LabelStmt *T)
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, bool isConstexprSpecified=false)
const LangOptions & LangOpts
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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.
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)
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.
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].
ConditionalOperator - The ?: ternary operator.
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...
SourceLocation getLocStart() const LLVM_READONLY
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...
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
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...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr *> Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
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.
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.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
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.
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.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool hasDefinition() const
Determine whether this protocol has a definition.
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.
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
VarDecl * isOpenMPCapturedDecl(ValueDecl *D) const
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
QualType getElementType() const
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
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.
Pepresents 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 ...
Expr - This represents one expression.
SourceLocation getLocStart() const LLVM_READONLY
Represents a character-granular source range.
static bool isEvaluatableContext(Sema &SemaRef)
Are we within a context in which some evaluation could be performed (be it constant evaluation or run...
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?
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)
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)
Capture the given variable in the lambda.
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
static Expr * maybeRebuildARCConsumingStmt(Stmt *Statement)
Given the last statement in a statement-expression, check whether the result is a producing expressio...
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.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const Expr * getCallee() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
bool isNullPtrType() const
bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context)
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
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
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
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.
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 DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
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
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
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
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)
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...
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.
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.
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.
void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level)
Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.) for FD based on DSA for the...
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.
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.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
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...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isUnresolvableResult() const
static CharSourceRange getCharRange(SourceRange R)
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.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
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...
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted, bool IsNested=false)
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
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(...)
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
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
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
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.
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)
const ComplexType * getAsComplexIntegerType() const
CastKind getCastKind() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
void setLastStmt(Stmt *S)
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...
SourceLocation getLocStart() const LLVM_READONLY
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.
const Expr * getExpr(unsigned Init) const
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
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)
SourceLocation getLocStart() const LLVM_READONLY
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...
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)
CheckBoolLikeConversion - Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
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
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
is AltiVec 'vector bool ...'
SmallVector< Capture, 4 > Captures
Captures - The captures.
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
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.
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)
SourceLocation getLocEnd() const LLVM_READONLY
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)
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
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.
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)
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...
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
Represents a C11 generic selection.
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 template argument.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
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)
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...
void setBody(CompoundStmt *B)
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)
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
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.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
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.
static bool CheckAlignOfExpr(Sema &S, Expr *E)
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...
static bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context)
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.
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
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
A runtime availability query.
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.
DeclarationName - 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)
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
Returns 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...
U cast(CodeGen::Address addr)
SourceLocation getLocStart() const LLVM_READONLY
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
SourceLocation getLocStart() const LLVM_READONLY
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
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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.
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'.
unsigned getIntWidth(QualType T) const
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
Not an overloaded operator.
RecordDecl * TheRecordDecl
The captured record type.
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()
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.
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
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
Represents a call to a CUDA kernel function.
static bool checkThreeWayNarrowingConversion(Sema &S, QualType ToType, Expr *E, QualType FromType, SourceLocation Loc)
bool isFunctionType() const
bool isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one.
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)
SourceLocation getLocStart() const LLVM_READONLY
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...
SourceLocation getLocStart() const LLVM_READONLY
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.
void addDecl(Decl *D)
Add the declaration D into this context.
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.
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...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
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.
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...
Expression is a Null pointer constant built from a literal zero.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
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)
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.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
void markUsed(bool IsODRUse)
sema::FunctionScopeInfo * getCurFunction() const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
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.
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)...
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'.
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
SourceManager & getSourceManager() const
A template-id, e.g., f<int>.
void setParameterCFAudited()
static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
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?
void UpdateMarkingForLValueToRValue(Expr *E)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
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.
static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S)
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)
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.
ArrayRef< ParmVarDecl * > parameters() const
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
static bool isOdrUseContext(Sema &SemaRef, bool SkipDependentUses=true)
Are we within a context in which references to resolved functions or to variables result in odr-use...
void setSubStmt(Stmt *SS)
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 addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
DeclaratorContext getContext() const
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)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< 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...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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.
void setAccess(AccessSpecifier AS)
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)
AccessControl getAccessControl() const
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
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
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 bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
SourceLocation getBegin() const
SourceLocation ColonLoc
Location of ':'.
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
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.
void clear()
Clears out any current state.
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()...
SourceLocation getLocStart() const LLVM_READONLY
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.
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
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)
Structure used to store a statement, the constant value to which it was evaluated (if any)...
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)