48 #include "llvm/Support/ConvertUTF.h" 49 using namespace clang;
56 if (ParsingInitForAutoVars.count(D))
66 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
72 if (TreatUnavailableAsInvalid &&
73 isUnavailableAlignedAllocationFunction(*FD))
87 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
90 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
91 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
93 if (DC && !DC->
hasAttr<UnusedAttr>())
105 if (Method && Method->isDeleted() && Method->isDefaulted()) {
107 if (!Method->isImplicit())
113 if (CSM != CXXInvalid)
114 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
120 if (Ctor && Ctor->isInheritingConstructor())
121 return NoteDeletedInheritingConstructor(Ctor);
131 if (I->getStorageClass() !=
SC_None)
176 if (!DowngradeWarning && UsedFn)
179 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
180 : diag::ext_internal_in_extern_inline)
185 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
195 Diag(DeclBegin, diag::note_convert_inline_to_static)
214 bool ObjCPropertyAccess,
215 bool AvoidPartialAvailabilityChecks,
218 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
222 if (Pos != SuppressedDiagnostics.end()) {
224 Diag(Suppressed.first, Suppressed.second);
235 if (cast<FunctionDecl>(D)->isMain())
236 Diag(Loc, diag::ext_main_used);
238 diagnoseUnavailableAlignedAllocation(*cast<FunctionDecl>(D), Loc);
242 if (ParsingInitForAutoVars.count(D)) {
243 if (isa<BindingDecl>(D)) {
244 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
247 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
248 << D->
getDeclName() << cast<VarDecl>(D)->getType();
255 if (FD->isDeleted()) {
257 if (Ctor && Ctor->isInheritingConstructor())
258 Diag(Loc, diag::err_deleted_inherited_ctor_use)
260 << Ctor->getInheritedConstructor().getConstructor()->getParent();
262 Diag(Loc, diag::err_deleted_function_use);
263 NoteDeletedFunction(FD);
269 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
270 DeduceReturnType(FD, Loc))
273 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
277 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
279 if (MD->getParent()->isLambda() &&
280 ((isa<CXXConstructorDecl>(MD) &&
281 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
282 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
283 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
284 << !isa<CXXConstructorDecl>(MD);
288 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
290 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
295 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
297 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
306 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
308 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
309 << getCurFunction()->HasOMPDeclareReductionCombiner;
314 DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
315 AvoidPartialAvailabilityChecks, ClassReceiver);
330 return ": " + Message;
332 return std::string();
341 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
346 unsigned numFormalParams;
350 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
353 numFormalParams = MD->param_size();
354 calleeType = CT_Method;
355 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
356 numFormalParams = FD->param_size();
357 calleeType = CT_Function;
358 }
else if (isa<VarDecl>(D)) {
364 calleeType = CT_Function;
367 calleeType = CT_Block;
373 numFormalParams = proto->getNumParams();
385 unsigned nullPos = attr->getNullPos();
386 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
387 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
390 unsigned numArgsAfterSentinel = attr->getSentinel();
394 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
401 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
402 if (!sentinelExpr)
return;
411 std::string NullValue;
412 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
414 else if (getLangOpts().CPlusPlus11)
415 NullValue =
"nullptr";
416 else if (PP.isMacroDefined(
"NULL"))
419 NullValue =
"(void*) 0";
422 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
424 Diag(MissingNilLoc, diag::warn_missing_sentinel)
448 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
452 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
457 CK_FunctionToPointerDecay).
get();
470 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
472 CK_ArrayToPointerDecay).
get();
484 if (UO->getOpcode() == UO_Deref &&
485 UO->getSubExpr()->IgnoreParenCasts()->
487 !UO->getType().isVolatileQualified()) {
489 S.
PDiag(diag::warn_indirection_through_null)
490 << UO->getSubExpr()->getSourceRange());
492 S.
PDiag(diag::note_indirection_through_null));
505 if (!Member || !Member->
isStr(
"isa"))
515 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
523 if (ObjectSetClass) {
567 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
571 if (getLangOpts().CPlusPlus &&
586 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
595 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
602 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
627 UpdateMarkingForLValueToRValue(E);
632 Cleanup.setExprNeedsCleanups(
true);
641 T = Atomic->getValueType().getUnqualifiedType();
650 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
653 Res = DefaultLvalueConversion(Res.
get());
668 CK_FunctionToPointerDecay).
get();
672 Res = DefaultLvalueConversion(Res.
get());
685 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
691 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
694 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
695 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
716 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
721 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
734 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
746 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
747 BTy->
getKind() == BuiltinType::Float)) {
748 if (getLangOpts().OpenCL &&
749 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
750 if (BTy->
getKind() == BuiltinType::Half) {
751 E = ImpCastExprToType(E, Context.
FloatTy, CK_FloatingCast).get();
754 E = ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast).get();
815 if (!Record->hasNonTrivialCopyConstructor() &&
816 !Record->hasNonTrivialMoveConstructor() &&
817 !Record->hasNonTrivialDestructor())
818 return VAK_ValidInCXX11;
826 if (getLangOpts().MSVCCompat)
827 return VAK_MSVCUndefined;
831 return VAK_Undefined;
841 case VAK_ValidInCXX11:
844 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
851 PDiag(diag::warn_pass_class_arg_to_vararg)
852 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
857 case VAK_MSVCUndefined:
859 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
860 << getLangOpts().CPlusPlus11 << Ty << CT);
866 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
870 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
874 << isa<InitListExpr>(E) << Ty << CT;
885 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
886 (CT == VariadicMethod ||
887 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
888 E = stripARCUnbridgedCast(E);
899 ExprResult ExprRes = DefaultArgumentPromotion(E);
906 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
913 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
932 diag::err_call_incomplete_argument))
949 if (SkipCast)
return false;
951 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
954 CK_FloatingRealToComplex);
958 CK_IntegralComplexToFloatingComplex);
991 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
992 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
994 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
996 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1002 if (!IsCompAssign) {
1009 }
else if (Order > 0) {
1024 bool ConvertFloat,
bool ConvertInt) {
1029 CK_IntegralToFloating);
1040 CK_IntegralComplexToFloatingComplex);
1045 CK_FloatingRealToComplex);
1054 QualType RHSType,
bool IsCompAssign) {
1060 if (LHSFloat && RHSFloat) {
1067 assert(order < 0 &&
"illegal float comparison");
1101 "The remaining types must be floating point types.");
1106 QualType LHSElemType = LHSComplex ?
1107 LHSComplex->getElementType() : LHSType;
1108 QualType RHSElemType = RHSComplex ?
1124 return Float128AndLongDouble &&
1126 &llvm::APFloat::PPCDoubleDouble());
1140 CK_IntegralComplexCast);
1146 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1149 QualType RHSType,
bool IsCompAssign) {
1154 if (LHSSigned == RHSSigned) {
1157 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1159 }
else if (!IsCompAssign)
1160 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1162 }
else if (order != (LHSSigned ? 1 : -1)) {
1166 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1168 }
else if (!IsCompAssign)
1169 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1176 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1178 }
else if (!IsCompAssign)
1179 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1188 RHS = (*doRHSCast)(S, RHS.
get(), result);
1190 LHS = (*doLHSCast)(S, LHS.
get(), result);
1200 bool IsCompAssign) {
1204 if (LHSComplexInt && RHSComplexInt) {
1208 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1209 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1211 return S.Context.getComplexType(ScalarType);
1214 if (LHSComplexInt) {
1217 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1218 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1220 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1221 CK_IntegralRealToComplex);
1226 assert(RHSComplexInt);
1230 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1231 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1235 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1236 CK_IntegralRealToComplex);
1245 bool IsCompAssign) {
1246 if (!IsCompAssign) {
1247 LHS = UsualUnaryConversions(LHS.
get());
1252 RHS = UsualUnaryConversions(RHS.
get());
1265 LHSType = AtomicLHS->getValueType();
1268 if (LHSType == RHSType)
1277 QualType LHSUnpromotedType = LHSType;
1281 if (!LHSBitfieldPromoteTy.
isNull())
1282 LHSType = LHSBitfieldPromoteTy;
1283 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1284 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1287 if (LHSType == RHSType)
1313 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1314 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1327 Expr *ControllingExpr,
1330 unsigned NumAssocs = ArgTypes.size();
1331 assert(NumAssocs == ArgExprs.size());
1334 for (
unsigned i = 0; i < NumAssocs; ++i) {
1336 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1341 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1343 llvm::makeArrayRef(Types, NumAssocs),
1353 Expr *ControllingExpr,
1356 unsigned NumAssocs = Types.size();
1357 assert(NumAssocs == Exprs.size());
1364 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1367 ControllingExpr = R.
get();
1372 if (!inTemplateInstantiation() &&
1375 diag::warn_side_effects_unevaluated_context);
1377 bool TypeErrorFound =
false,
1379 ContainsUnexpandedParameterPack
1382 for (
unsigned i = 0; i < NumAssocs; ++i) {
1383 if (Exprs[i]->containsUnexpandedParameterPack())
1384 ContainsUnexpandedParameterPack =
true;
1387 if (Types[i]->getType()->containsUnexpandedParameterPack())
1388 ContainsUnexpandedParameterPack =
true;
1390 if (Types[i]->getType()->isDependentType()) {
1391 IsResultDependent =
true;
1396 if (Types[i]->getType()->isIncompleteType())
1397 D = diag::err_assoc_type_incomplete;
1398 else if (!Types[i]->getType()->isObjectType())
1399 D = diag::err_assoc_type_nonobject;
1400 else if (Types[i]->getType()->isVariablyModifiedType())
1401 D = diag::err_assoc_type_variably_modified;
1404 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1405 << Types[i]->getTypeLoc().getSourceRange()
1406 << Types[i]->getType();
1407 TypeErrorFound =
true;
1412 for (
unsigned j = i+1; j < NumAssocs; ++j)
1413 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1415 Types[j]->getType())) {
1416 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1417 diag::err_assoc_compatible_types)
1418 << Types[j]->getTypeLoc().getSourceRange()
1419 << Types[j]->getType()
1420 << Types[i]->getType();
1421 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1422 diag::note_compat_assoc)
1423 << Types[i]->getTypeLoc().getSourceRange()
1424 << Types[i]->getType();
1425 TypeErrorFound =
true;
1435 if (IsResultDependent)
1437 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1438 ContainsUnexpandedParameterPack);
1441 unsigned DefaultIndex = -1U;
1442 for (
unsigned i = 0; i < NumAssocs; ++i) {
1446 Types[i]->getType()))
1447 CompatIndices.push_back(i);
1453 if (CompatIndices.size() > 1) {
1457 Diag(ControllingExpr->
getBeginLoc(), diag::err_generic_sel_multi_match)
1459 << (unsigned)CompatIndices.size();
1460 for (
unsigned I : CompatIndices) {
1461 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1462 diag::note_compat_assoc)
1463 << Types[I]->getTypeLoc().getSourceRange()
1464 << Types[I]->getType();
1472 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1486 unsigned ResultIndex =
1487 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1490 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1491 ContainsUnexpandedParameterPack, ResultIndex);
1509 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1512 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1513 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1514 if (ArgTy[ArgIdx]->isArrayType())
1541 assert(!StringToks.empty() &&
"Must have at least one string!");
1544 if (Literal.hadError)
1548 for (
const Token &
Tok : StringToks)
1549 StringTokLocs.push_back(
Tok.getLocation());
1553 if (Literal.isWide()) {
1556 }
else if (Literal.isUTF8()) {
1557 if (getLangOpts().Char8)
1560 }
else if (Literal.isUTF16()) {
1563 }
else if (Literal.isUTF32()) {
1566 }
else if (Literal.isPascal()) {
1572 if (getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus2a &&
1574 Diag(StringTokLocs.front(), diag::warn_cxx2a_compat_utf8_string);
1580 auto RemovalDiag = PDiag(diag::note_cxx2a_compat_utf8_string_remove_u8);
1582 for (
const Token &
Tok : StringToks) {
1583 if (
Tok.getKind() == tok::utf8_string_literal) {
1585 RemovalDiagLoc =
Tok.getLocation();
1589 getSourceManager(), getLangOpts())));
1592 Diag(RemovalDiagLoc, RemovalDiag);
1598 if (getLangOpts().
CPlusPlus || getLangOpts().ConstStrings)
1607 CharTyConst, llvm::APInt(32, Literal.GetNumStringChars() + 1),
1612 Kind, Literal.Pascal, StrTy,
1614 StringTokLocs.size());
1615 if (Literal.getUDSuffix().empty())
1622 Literal.getUDSuffixOffset());
1626 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1641 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1642 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1648 llvm::APInt Len(Context.
getIntWidth(SizeType), Literal.GetNumStringChars());
1651 Expr *Args[] = { Lit, LenArg };
1653 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1656 case LOLR_StringTemplate: {
1661 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1667 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1673 return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
1678 case LOLR_ErrorNoDiagnostic:
1679 llvm_unreachable(
"unexpected literal operator lookup result");
1683 llvm_unreachable(
"unexpected literal operator lookup result");
1691 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1701 bool RefersToCapturedVariable =
1703 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1706 if (isa<VarTemplateSpecializationDecl>(D)) {
1708 cast<VarTemplateSpecializationDecl>(D);
1713 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1714 FoundD, TemplateArgs);
1716 assert(!TemplateArgs &&
"No template arguments for non-variable" 1717 " template specialization references");
1721 NameInfo, Ty, VK, FoundD);
1724 MarkDeclRefReferenced(E);
1726 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1728 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getBeginLoc()))
1729 getCurFunction()->recordUseOfWeak(E);
1733 FD = IFD->getAnonField();
1735 UnusedPrivateFields.remove(FD);
1743 if (
auto *BD = dyn_cast<BindingDecl>(D))
1744 if (
auto *BE = BD->getBinding())
1745 E->setObjectKind(BE->getObjectKind());
1770 translateTemplateArguments(TemplateArgsPtr, Buffer);
1775 TemplateArgs = &Buffer;
1777 NameInfo = GetNameFromUnqualifiedId(Id);
1778 TemplateArgs =
nullptr;
1785 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1792 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1795 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
1800 bool DroppedSpecifier =
1803 ? diag::note_implicit_param_decl
1804 : diag::note_previous_decl;
1807 SemaRef.
PDiag(NoteID));
1810 << Typo << Ctx << DroppedSpecifier
1812 SemaRef.
PDiag(NoteID));
1820 std::unique_ptr<CorrectionCandidateCallback> CCC,
1825 unsigned diagnostic = diag::err_undeclared_var_use;
1826 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1830 diagnostic = diag::err_undeclared_use;
1831 diagnostic_suggest = diag::err_undeclared_use_suggest;
1840 if (isa<CXXRecordDecl>(DC)) {
1841 LookupQualifiedName(R, DC);
1850 bool isDefaultArgument =
1851 !CodeSynthesisContexts.empty() &&
1852 CodeSynthesisContexts.back().Kind ==
1853 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
1855 bool isInstance = CurMethod &&
1857 DC == CurMethod->
getParent() && !isDefaultArgument;
1862 if (getLangOpts().MSVCCompat)
1863 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1874 Diag(D->getLocation(), diag::note_dependent_var_use);
1880 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1881 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1896 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1897 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1908 assert(!ExplicitTemplateArgs &&
1909 "Diagnosing an empty lookup with explicit template args!");
1910 *Out = CorrectTypoDelayed(
1914 diagnostic, diagnostic_suggest);
1916 nullptr, CTK_ErrorRecovery);
1919 }
else if (S && (Corrected =
1921 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1922 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1923 bool DroppedSpecifier =
1927 bool AcceptableWithRecovery =
false;
1928 bool AcceptableWithoutRecovery =
false;
1937 dyn_cast<FunctionTemplateDecl>(CD))
1938 AddTemplateOverloadCandidate(
1941 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1942 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1946 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1948 ND = Best->FoundDecl;
1949 Corrected.setCorrectionDecl(ND);
1953 Corrected.setCorrectionDecl(ND);
1965 Record = cast<CXXRecordDecl>(
1971 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
1972 isa<FunctionTemplateDecl>(UnderlyingND);
1978 AcceptableWithoutRecovery =
1979 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
1983 AcceptableWithoutRecovery =
true;
1986 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
1988 ? diag::note_implicit_param_decl
1989 : diag::note_previous_decl;
1991 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
1992 PDiag(NoteID), AcceptableWithRecovery);
1994 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
1995 << Name << computeDeclContext(SS,
false)
1996 << DroppedSpecifier << SS.getRange(),
1997 PDiag(NoteID), AcceptableWithRecovery);
2000 return !AcceptableWithRecovery;
2007 if (!SS.isEmpty()) {
2009 << Name << computeDeclContext(SS,
false)
2036 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2044 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2045 DB << NameInfo.
getName() << RD;
2047 if (!ThisType.
isNull()) {
2050 Context,
nullptr, ThisType,
true,
2052 nullptr, NameInfo, TemplateArgs);
2069 bool HasTrailingLParen,
bool IsAddressOfOperand,
2070 std::unique_ptr<CorrectionCandidateCallback> CCC,
2071 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2072 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2073 "cannot be direct & operand and have a trailing lparen");
2082 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2105 bool DependentID =
false;
2109 }
else if (SS.
isSet()) {
2110 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2111 if (RequireCompleteDeclContext(SS, DC))
2119 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2120 IsAddressOfOperand, TemplateArgs);
2125 ? LookupObjCImplicitSelfParam
2126 : LookupOrdinaryName);
2127 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2133 bool MemberOfUnknownSpecialization;
2134 if (LookupTemplateName(R, S, SS,
QualType(),
false,
2135 MemberOfUnknownSpecialization, TemplateKWLoc))
2138 if (MemberOfUnknownSpecialization ||
2140 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2141 IsAddressOfOperand, TemplateArgs);
2143 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2144 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2149 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2150 IsAddressOfOperand, TemplateArgs);
2154 if (IvarLookupFollowUp) {
2155 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2169 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2170 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2176 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2178 if (R.
empty() && !ADL) {
2179 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2181 TemplateKWLoc, TemplateArgs))
2186 if (IsInlineAsmIdentifier)
2192 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2194 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2195 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2196 "Typo correction callback misconfigured");
2199 CCC->setTypoName(II);
2206 if (DiagnoseEmptyLookup(S, SS, R,
2207 CCC ? std::move(CCC) : std::move(DefaultValidator),
2208 nullptr, None, &TE)) {
2209 if (TE && KeywordReplacement) {
2210 auto &
State = getTypoExprState(TE);
2211 auto BestTC =
State.Consumer->getNextCorrection();
2212 if (BestTC.isKeyword()) {
2213 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2214 if (
State.DiagHandler)
2215 State.DiagHandler(BestTC);
2217 KeywordReplacement->
setKind(II->getTokenID());
2219 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2222 clearDelayedTypo(TE);
2225 return (
Expr*)
nullptr;
2227 State.Consumer->resetCorrectionStream();
2232 assert(!R.
empty() &&
2233 "DiagnoseEmptyLookup returned false but added no results");
2240 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2250 assert(!R.
empty() || ADL);
2276 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2277 bool MightBeImplicitMember;
2278 if (!IsAddressOfOperand)
2279 MightBeImplicitMember =
true;
2281 MightBeImplicitMember =
false;
2283 MightBeImplicitMember =
false;
2285 MightBeImplicitMember =
true;
2287 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2291 if (MightBeImplicitMember)
2292 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2293 R, TemplateArgs, S);
2296 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2304 "There should only be one declaration found.");
2307 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2310 return BuildDeclarationNameExpr(SS, R, ADL);
2325 if (RequireCompleteDeclContext(SS, DC))
2329 LookupQualifiedName(R, DC);
2348 unsigned DiagID = diag::err_typename_missing;
2349 if (RecoveryTSI && getLangOpts().MSVCCompat)
2350 DiagID = diag::ext_typename_missing;
2352 auto D =
Diag(Loc, DiagID);
2383 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2384 return BuildPossibleImplicitMemberExpr(SS,
2388 return BuildDeclarationNameExpr(SS, R,
false);
2422 LookForIvars =
true;
2423 else if (IsClassMethod)
2424 LookForIvars =
false;
2436 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2445 if (DiagnoseUseOfDecl(IV, Loc))
2451 !getLangOpts().DebuggerSupport)
2462 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2463 SelfName,
false,
false);
2467 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2471 MarkAnyDeclReferenced(Loc, IV,
true);
2475 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2483 if (!isUnevaluatedContext() &&
2484 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2485 getCurFunction()->recordUseOfWeak(Result);
2487 if (getLangOpts().ObjCAutoRefCount) {
2488 if (CurContext->isClosure())
2489 Diag(Loc, diag::warn_implicitly_retains_self)
2502 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2509 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2510 << IV->getDeclName());
2513 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2559 bool PointerConversions =
false;
2560 if (isa<FieldDecl>(Member)) {
2566 PointerConversions =
true;
2568 DestType = DestRecordType;
2569 FromRecordType = FromType;
2571 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2572 if (Method->isStatic())
2575 DestType = Method->getThisType();
2580 PointerConversions =
true;
2582 FromRecordType = FromType;
2583 DestType = DestRecordType;
2620 if (Qualifier && Qualifier->
getAsType()) {
2622 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2629 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2631 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2632 FromLoc, FromRange, &BasePath))
2635 if (PointerConversions)
2637 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2638 VK, &BasePath).get();
2641 FromRecordType = QRecordType;
2650 bool IgnoreAccess =
false;
2658 assert(isa<UsingShadowDecl>(FoundDecl));
2665 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2667 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2668 FromLoc, FromRange, &BasePath))
2672 if (PointerConversions)
2674 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2675 VK, &BasePath).get();
2677 FromRecordType = URecordType;
2682 IgnoreAccess =
true;
2686 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2687 FromLoc, FromRange, &BasePath,
2691 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2697 bool HasTrailingLParen) {
2699 if (!HasTrailingLParen)
2707 if (!getLangOpts().CPlusPlus)
2717 if (D->isCXXClassMember())
2726 if (isa<UsingShadowDecl>(D))
2727 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2728 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2735 if (isa<FunctionDecl>(D)) {
2741 }
else if (!isa<FunctionTemplateDecl>(D))
2757 if (isa<TypedefNameDecl>(D)) {
2762 if (isa<ObjCInterfaceDecl>(D)) {
2767 if (isa<NamespaceDecl>(D)) {
2781 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
2786 bool AcceptInvalidDecl) {
2826 bool AcceptInvalidDecl) {
2827 assert(D &&
"Cannot refer to a NULL declaration");
2828 assert(!isa<FunctionTemplateDecl>(D) &&
2829 "Cannot refer unambiguously to a function template");
2835 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2838 diagnoseMissingTemplateArguments(
TemplateName(Template), Loc);
2845 Diag(Loc, diag::err_ref_non_value)
2855 if (DiagnoseUseOfDecl(VD, Loc))
2866 if (!indirectField->isCXXClassMember())
2867 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2879 ResolveExceptionSpec(Loc, FPT);
2886 #define ABSTRACT_DECL(kind) 2887 #define VALUE(type, base) 2888 #define DECL(type, base) \ 2890 #include "clang/AST/DeclNodes.inc" 2891 llvm_unreachable(
"invalid value decl kind");
2894 case Decl::ObjCAtDefsField:
2895 case Decl::ObjCIvar:
2896 llvm_unreachable(
"forming non-member reference to ivar?");
2900 case Decl::EnumConstant:
2901 case Decl::UnresolvedUsingValue:
2902 case Decl::OMPDeclareReduction:
2911 case Decl::IndirectField:
2913 "building reference to field in C?");
2923 case Decl::NonTypeTemplateParm: {
2938 case Decl::VarTemplateSpecialization:
2939 case Decl::VarTemplatePartialSpecialization:
2940 case Decl::Decomposition:
2941 case Decl::OMPCapturedExpr:
2951 case Decl::ImplicitParam:
2952 case Decl::ParmVar: {
2960 if (!isUnevaluatedContext()) {
2961 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2962 if (!CapturedType.
isNull())
2963 type = CapturedType;
2969 case Decl::Binding: {
2975 auto *BD = cast<BindingDecl>(VD);
2976 if (BD->getDeclContext()->isFunctionOrMethod() &&
2977 BD->getDeclContext() != CurContext)
2983 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3002 if (getLangOpts().CPlusPlus) {
3012 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
3013 isa<FunctionProtoType>(fty))
3022 case Decl::CXXDeductionGuide:
3023 llvm_unreachable(
"building reference to deduction guide");
3025 case Decl::MSProperty:
3029 case Decl::CXXMethod:
3034 = dyn_cast<FunctionProtoType>(VD->
getType()))
3042 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3048 case Decl::CXXConversion:
3049 case Decl::CXXDestructor:
3050 case Decl::CXXConstructor:
3055 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3062 Target.resize(CharByteWidth * (Source.size() + 1));
3063 char *ResultPtr = &Target[0];
3064 const llvm::UTF8 *ErrorPtr;
3066 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3069 Target.resize(ResultPtr - &Target[0]);
3075 Decl *currentDecl =
nullptr;
3077 currentDecl = BSI->TheDecl;
3079 currentDecl = LSI->CallOperator;
3081 currentDecl = CSI->TheCapturedDecl;
3083 currentDecl = getCurFunctionOrMethodDecl();
3086 Diag(Loc, diag::ext_predef_outside_function);
3092 if (cast<DeclContext>(currentDecl)->isDependentContext())
3098 unsigned Length = Str.length();
3100 llvm::APInt LengthI(32, Length + 1);
3127 default: llvm_unreachable(
"Unknown simple primary expr!");
3137 return BuildPredefinedExpr(Loc, IK);
3142 bool Invalid =
false;
3143 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3149 if (Literal.hadError())
3153 if (Literal.isWide())
3155 else if (Literal.isUTF8() && getLangOpts().Char8)
3157 else if (Literal.isUTF16())
3159 else if (Literal.isUTF32())
3161 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3167 if (Literal.isWide())
3169 else if (Literal.isUTF16())
3171 else if (Literal.isUTF32())
3173 else if (Literal.isUTF8())
3179 if (Literal.getUDSuffix().empty())
3189 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3200 Context.
IntTy, Loc);
3207 using llvm::APFloat;
3208 APFloat Val(Format);
3214 if ((result & APFloat::opOverflow) ||
3215 ((result & APFloat::opUnderflow) && Val.isZero())) {
3216 unsigned diagnostic;
3218 if (result & APFloat::opOverflow) {
3219 diagnostic = diag::warn_float_overflow;
3220 APFloat::getLargest(Format).toString(buffer);
3222 diagnostic = diag::warn_float_underflow;
3223 APFloat::getSmallest(Format).toString(buffer);
3226 S.
Diag(Loc, diagnostic)
3228 << StringRef(buffer.data(), buffer.size());
3231 bool isExact = (result == APFloat::opOK);
3236 assert(E &&
"Invalid expression");
3243 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3247 llvm::APSInt ValueAPS;
3248 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3253 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3254 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3255 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3256 << ValueAPS.toString(10) << ValueIsPositive;
3267 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3268 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3276 SpellingBuffer.resize(Tok.
getLength() + 1);
3279 bool Invalid =
false;
3280 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3285 if (Literal.hadError)
3288 if (Literal.hasUDSuffix()) {
3296 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3299 if (Literal.isFloatingLiteral()) {
3320 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3321 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3324 !Literal.isImaginary)) {
3325 case LOLR_ErrorNoDiagnostic:
3333 if (Literal.isFloatingLiteral()) {
3337 if (Literal.GetIntegerValue(ResultVal))
3343 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3350 unsigned Length = Literal.getUDSuffixOffset();
3356 false, StrTy, &TokLoc, 1);
3357 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3360 case LOLR_Template: {
3367 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3368 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3369 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3370 Value = TokSpelling[I];
3375 return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
3378 case LOLR_StringTemplate:
3379 llvm_unreachable(
"unexpected literal operator lookup result");
3385 if (Literal.isFixedPointLiteral()) {
3388 if (Literal.isAccum) {
3389 if (Literal.isHalf) {
3391 }
else if (Literal.isLong) {
3396 }
else if (Literal.isFract) {
3397 if (Literal.isHalf) {
3399 }
else if (Literal.isLong) {
3408 bool isSigned = !Literal.isUnsigned;
3412 llvm::APInt Val(bit_width, 0, isSigned);
3413 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3414 bool ValIsZero = Val.isNullValue() && !Overflowed;
3417 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3423 else if (Val.ugt(MaxVal) || Overflowed)
3428 }
else if (Literal.isFloatingLiteral()) {
3430 if (Literal.isHalf){
3431 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3437 }
else if (Literal.isFloat)
3439 else if (Literal.isLong)
3441 else if (Literal.isFloat16)
3443 else if (Literal.isFloat128)
3451 if (getLangOpts().SinglePrecisionConstants) {
3453 if (BTy->
getKind() != BuiltinType::Float) {
3454 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3456 }
else if (getLangOpts().OpenCL &&
3457 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3460 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3463 }
else if (!Literal.isIntegerLiteral()) {
3469 if (!getLangOpts().
C99 && Literal.isLongLong) {
3472 getLangOpts().CPlusPlus11 ?
3473 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3475 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
3480 llvm::APInt ResultVal(MaxWidth, 0);
3482 if (Literal.GetIntegerValue(ResultVal)) {
3484 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3487 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
3488 "long long is not intmax_t?");
3495 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3501 if (Literal.MicrosoftInteger) {
3502 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3506 Width = Literal.MicrosoftInteger;
3508 !Literal.isUnsigned);
3512 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3517 if (ResultVal.isIntN(IntSize)) {
3519 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3521 else if (AllowUnsigned)
3528 if (Ty.
isNull() && !Literal.isLongLong) {
3532 if (ResultVal.isIntN(LongSize)) {
3534 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3536 else if (AllowUnsigned)
3540 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3541 const unsigned LongLongSize =
3544 getLangOpts().CPlusPlus
3546 ? diag::warn_old_implicitly_unsigned_long_cxx
3548 ext_old_implicitly_unsigned_long_cxx
3549 : diag::warn_old_implicitly_unsigned_long)
3550 << (LongLongSize > LongSize ? 0
3563 if (ResultVal.isIntN(LongLongSize)) {
3567 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3568 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3570 else if (AllowUnsigned)
3572 Width = LongLongSize;
3579 Diag(
Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3584 if (ResultVal.getBitWidth() != Width)
3585 ResultVal = ResultVal.trunc(Width);
3591 if (Literal.isImaginary) {
3595 Diag(
Tok.getLocation(), diag::ext_imaginary_constant);
3601 assert(E &&
"ActOnParenExpr() missing expr");
3602 return new (Context)
ParenExpr(L, R, E);
3613 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3619 "Scalar types should always be complete");
3636 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3637 << TraitKind << ArgRange;
3644 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3645 : diag::ext_sizeof_alignof_void_type;
3646 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3660 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3679 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3715 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3719 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3739 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3747 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3748 QualType OType = PVD->getOriginalType();
3753 Diag(PVD->getLocation(), diag::note_declared_at);
3818 if (RequireCompleteType(OpLoc, ExprType,
3819 diag::err_sizeof_alignof_incomplete_type,
3820 ExprKind, ExprRange))
3824 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3825 << ExprKind << ExprRange;
3844 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3850 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3852 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3853 D = ME->getMemberDecl();
3873 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3876 if (!FD->getParent()->isCompleteDefinition()) {
3877 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3886 if (!FD->getType()->isReferenceType())
3900 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
3906 assert(CSI !=
nullptr);
3912 #define TYPE(Class, Base) 3913 #define ABSTRACT_TYPE(Class, Base) 3914 #define NON_CANONICAL_TYPE(Class, Base) 3915 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 3916 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) 3917 #include "clang/AST/TypeNodes.def" 3924 case Type::ExtVector:
3927 case Type::Elaborated:
3928 case Type::TemplateSpecialization:
3929 case Type::ObjCObject:
3930 case Type::ObjCInterface:
3931 case Type::ObjCObjectPointer:
3932 case Type::ObjCTypeParam:
3934 llvm_unreachable(
"type class is never variably-modified!");
3935 case Type::Adjusted:
3936 T = cast<AdjustedType>(Ty)->getOriginalType();
3939 T = cast<DecayedType>(Ty)->getPointeeType();
3942 T = cast<PointerType>(Ty)->getPointeeType();
3944 case Type::BlockPointer:
3945 T = cast<BlockPointerType>(Ty)->getPointeeType();
3947 case Type::LValueReference:
3948 case Type::RValueReference:
3949 T = cast<ReferenceType>(Ty)->getPointeeType();
3951 case Type::MemberPointer:
3952 T = cast<MemberPointerType>(Ty)->getPointeeType();
3954 case Type::ConstantArray:
3955 case Type::IncompleteArray:
3957 T = cast<ArrayType>(Ty)->getElementType();
3959 case Type::VariableArray: {
3968 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3969 CapRecord = LSI->Lambda;
3970 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3971 CapRecord = CRSI->TheRecordDecl;
3974 auto ExprLoc = Size->getExprLoc();
3979 nullptr, SizeType,
nullptr,
3982 Field->setImplicit(
true);
3984 Field->setCapturedVLAType(VAT);
3994 case Type::FunctionProto:
3995 case Type::FunctionNoProto:
3996 T = cast<FunctionType>(Ty)->getReturnType();
4000 case Type::UnaryTransform:
4001 case Type::Attributed:
4002 case Type::SubstTemplateTypeParm:
4003 case Type::PackExpansion:
4008 T = cast<TypedefType>(Ty)->desugar();
4010 case Type::Decltype:
4011 T = cast<DecltypeType>(Ty)->desugar();
4014 case Type::DeducedTemplateSpecialization:
4015 T = cast<DeducedType>(Ty)->getDeducedType();
4017 case Type::TypeOfExpr:
4018 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4021 T = cast<AtomicType>(Ty)->getValueType();
4039 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
4044 for (
auto I = FunctionScopes.rbegin(),
4045 E = std::prev(FunctionScopes.rend());
4051 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4052 DC = LSI->CallOperator;
4053 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4054 DC = CRSI->TheCapturedDecl;
4055 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4089 isInvalid = CheckVecStepExpr(E);
4094 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4097 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
4104 PE = TransformToPotentiallyEvaluated(E);
4127 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4131 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4137 if (V.
get()->isTypeDependent())
4149 return CT->getElementType();
4152 if (V.
get()->getType()->isArithmeticType())
4153 return V.
get()->getType();
4158 if (PR.
get() != V.
get()) {
4164 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4165 << (IsReal ?
"__real" :
"__imag");
4176 default: llvm_unreachable(
"Unknown unary op!");
4177 case tok::plusplus: Opc = UO_PostInc;
break;
4178 case tok::minusminus: Opc = UO_PostDec;
break;
4182 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4184 Input = Result.
get();
4186 return BuildUnaryOp(S, OpLoc, Opc, Input);
4197 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4200 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4208 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4210 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4218 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4222 if (isa<ParenListExpr>(base)) {
4223 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4225 base = result.
get();
4233 bool IsMSPropertySubscript =
false;
4236 if (!IsMSPropertySubscript) {
4237 ExprResult result = CheckPlaceholderExpr(base);
4240 base = result.
get();
4244 ExprResult result = CheckPlaceholderExpr(idx);
4264 if (IsMSPropertySubscript) {
4279 if (getLangOpts().CPlusPlus &&
4283 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4286 ExprResult Res = CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4288 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
4289 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
4294 void Sema::CheckAddressOfNoDeref(
const Expr *E) {
4301 while ((Member = dyn_cast<MemberExpr>(StrippedExpr)) && !Member->
isArrow())
4312 if (isa<ArrayType>(ResultTy))
4315 if (ResultTy->
hasAttr(attr::NoDeref)) {
4324 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
4333 if (
const auto *Ptr = dyn_cast<PointerType>(Base->
getType())) {
4334 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
4345 BuiltinType::OMPArraySection)) {
4346 ExprResult Result = CheckPlaceholderExpr(Base);
4349 Base = Result.
get();
4352 ExprResult Result = CheckPlaceholderExpr(LowerBound);
4355 Result = DefaultLvalueConversion(Result.
get());
4358 LowerBound = Result.
get();
4361 ExprResult Result = CheckPlaceholderExpr(Length);
4364 Result = DefaultLvalueConversion(Result.
get());
4367 Length = Result.
get();
4375 return new (Context)
4394 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4396 if (Res.isInvalid())
4398 diag::err_omp_typecheck_section_not_integer)
4400 LowerBound = Res.get();
4409 PerformOpenMPImplicitIntegerConversion(Length->
getExprLoc(), Length);
4410 if (Res.isInvalid())
4412 diag::err_omp_typecheck_section_not_integer)
4432 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4433 diag::err_omp_section_incomplete_type, Base))
4441 llvm::APSInt LowerBoundValue = Result.
Val.
getInt();
4442 if (LowerBoundValue.isNegative()) {
4443 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4455 llvm::APSInt LengthValue = Result.
Val.
getInt();
4456 if (LengthValue.isNegative()) {
4457 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4458 << LengthValue.toString(10,
true)
4463 }
else if (ColonLoc.
isValid() &&
4469 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4475 BuiltinType::OMPArraySection)) {
4476 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
4479 Base = Result.
get();
4481 return new (Context)
4489 Expr *LHSExp = Base;
4498 for (
auto *Op : {LHSExp, RHSExp}) {
4499 Op = Op->IgnoreImplicit();
4500 if (Op->getType()->isArrayType() && !Op->isLValue())
4507 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
4510 LHSExp = Result.
get();
4512 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
4515 RHSExp = Result.
get();
4523 Expr *BaseExpr, *IndexExpr;
4540 if (!LangOpts.isSubscriptPointerArithmetic())
4541 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4556 if (!LangOpts.isSubscriptPointerArithmetic()) {
4557 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4566 ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
4569 LHSExp = Materialized.
get();
4575 ResultType = VTy->getElementType();
4579 Qualifiers Combined = BaseQuals + MemberQuals;
4580 if (Combined != MemberQuals)
4591 CK_ArrayToPointerDecay).
get();
4597 }
else if (RHSTy->isArrayType()) {
4602 CK_ArrayToPointerDecay).
get();
4609 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4614 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4632 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4634 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4641 RequireCompleteType(LLoc, ResultType,
4642 diag::err_subscript_incomplete_type, BaseExpr))
4645 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4648 return new (Context)
4656 diag::err_use_of_default_argument_to_function_declared_later) <<
4658 Diag(UnparsedDefaultArgLocs[Param],
4659 diag::note_default_argument_declared_here);
4667 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4687 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4691 if (Inst.isInvalid())
4693 if (Inst.isAlreadyInstantiating()) {
4694 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4707 Result = SubstInitializer(UninstExpr, MutiLevelArgList,
4722 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4726 Result = ActOnFinishFullExpr(Result.
getAs<
Expr>(),
4734 L->DefaultArgumentInstantiated(Param);
4740 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4752 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4755 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
4760 assert(!Init->getNumObjects() &&
4761 "default argument expression has capturing blocks?");
4774 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
4783 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4784 return VariadicConstructor;
4786 return VariadicBlock;
4788 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4789 if (Method->isInstance())
4790 return VariadicMethod;
4792 return VariadicMethod;
4793 return VariadicFunction;
4795 return VariadicDoesNotApply;
4804 FunctionName(FuncName) {}
4806 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4830 llvm::make_unique<FunctionCallCCC>(S, FuncName.getAsIdentifierInfo(),
4833 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4834 if (Corrected.isOverloaded()) {
4844 ND = Best->FoundDecl;
4845 Corrected.setCorrectionDecl(ND);
4851 ND = ND->getUnderlyingDecl();
4852 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4871 bool IsExecConfig) {
4881 bool Invalid =
false;
4890 if (Args.size() < NumParams) {
4891 if (Args.size() < MinArgs) {
4896 ? diag::err_typecheck_call_too_few_args_suggest
4897 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4898 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4899 << static_cast<unsigned>(Args.size())
4904 ? diag::err_typecheck_call_too_few_args_one
4905 : diag::err_typecheck_call_too_few_args_at_least_one)
4909 ? diag::err_typecheck_call_too_few_args
4910 : diag::err_typecheck_call_too_few_args_at_least)
4911 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4915 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4923 "We should have reserved space for the default arguments before!");
4928 if (Args.size() > NumParams) {
4934 ? diag::err_typecheck_call_too_many_args_suggest
4935 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4936 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4937 << static_cast<unsigned>(Args.size())
4939 }
else if (NumParams == 1 && FDecl &&
4941 Diag(Args[NumParams]->getBeginLoc(),
4942 MinArgs == NumParams
4943 ? diag::err_typecheck_call_too_many_args_one
4944 : diag::err_typecheck_call_too_many_args_at_most_one)
4948 Args.back()->getEndLoc());
4950 Diag(Args[NumParams]->getBeginLoc(),
4951 MinArgs == NumParams
4952 ? diag::err_typecheck_call_too_many_args
4953 : diag::err_typecheck_call_too_many_args_at_most)
4954 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4957 Args.back()->getEndLoc());
4960 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4971 Invalid = GatherArgumentsForCall(Call->
getBeginLoc(), FDecl, Proto, 0, Args,
4975 unsigned TotalNumArgs = AllArgs.size();
4976 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4977 Call->
setArg(i, AllArgs[i]);
4987 bool IsListInitialization) {
4989 bool Invalid =
false;
4992 for (
unsigned i = FirstParam; i < NumParams; i++) {
4997 if (ArgIx < Args.size()) {
4998 Arg = Args[ArgIx++];
5000 if (RequireCompleteType(Arg->
getBeginLoc(), ProtoArgType,
5001 diag::err_call_incomplete_argument, Arg))
5005 bool CFAudited =
false;
5007 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5008 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5009 Arg = stripARCUnbridgedCast(Arg);
5010 else if (getLangOpts().ObjCAutoRefCount &&
5011 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5012 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5017 BE->getBlockDecl()->setDoesNotEscape();
5030 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
5036 assert(Param &&
"can't use default arguments without a known callee");
5039 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
5049 CheckArrayAccess(Arg);
5052 CheckStaticArrayArgument(CallLoc, Param, Arg);
5054 AllArgs.push_back(Arg);
5058 if (CallType != VariadicDoesNotApply) {
5063 for (
Expr *A : Args.slice(ArgIx)) {
5065 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
5067 AllArgs.push_back(arg.
get());
5072 for (
Expr *A : Args.slice(ArgIx)) {
5073 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
5075 AllArgs.push_back(Arg.
get());
5080 for (
Expr *A : Args.slice(ArgIx))
5081 CheckArrayAccess(A);
5089 TL = DTL.getOriginalLoc();
5092 << ATL.getLocalSourceRange();
5106 const Expr *ArgExpr) {
5134 Diag(CallLoc, diag::warn_static_array_too_small)
5136 << (unsigned) ArgCAT->
getSize().getZExtValue()
5137 << (unsigned) CAT->
getSize().getZExtValue();
5151 if (!placeholder)
return false;
5153 switch (placeholder->
getKind()) {
5155 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 5156 case BuiltinType::Id: 5157 #include "clang/Basic/OpenCLImageTypes.def" 5158 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 5159 case BuiltinType::Id: 5160 #include "clang/Basic/OpenCLExtensionTypes.def" 5161 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 5162 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 5163 #include "clang/AST/BuiltinTypes.def" 5168 case BuiltinType::Overload:
5173 case BuiltinType::ARCUnbridgedCast:
5177 case BuiltinType::PseudoObject:
5182 case BuiltinType::UnknownAny:
5186 case BuiltinType::BoundMember:
5187 case BuiltinType::BuiltinFn:
5188 case BuiltinType::OMPArraySection:
5192 llvm_unreachable(
"bad builtin type kind");
5200 bool hasInvalid =
false;
5201 for (
size_t i = 0, e = args.size(); i != e; i++) {
5204 if (result.
isInvalid()) hasInvalid =
true;
5205 else args[i] = result.
get();
5206 }
else if (hasInvalid) {
5235 bool NeedsNewDecl =
false;
5248 if (!ParamType->isPointerType() ||
5249 ParamType.getQualifiers().hasAddressSpace() ||
5252 OverloadParams.push_back(ParamType);
5260 NeedsNewDecl =
true;
5272 OverloadParams, EPI);
5283 FT = cast<FunctionProtoType>(OverloadTy);
5284 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5291 Params.push_back(Parm);
5293 OverloadDecl->setParams(Params);
5294 return OverloadDecl;
5312 isa<CXXMethodDecl>(Callee)
5313 ? diag::err_ovl_no_viable_member_function_in_call
5314 : diag::err_ovl_no_viable_function_in_call)
5317 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5318 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5326 const auto GetFunctionLevelDCIfCXXClass =
5334 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5335 return MD->
getParent()->getCanonicalDecl();
5338 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5339 return RD->getCanonicalDecl();
5346 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5347 if (!CurParentClass)
5354 assert(NamingClass &&
"Must have naming class even for implicit access");
5360 return CurParentClass == NamingClass ||
5409 Expr *ExecConfig,
bool IsExecConfig) {
5411 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5420 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5421 if (!ArgExprs.empty()) {
5426 ArgExprs.back()->getEndLoc()));
5433 ExprResult result = CheckPlaceholderExpr(Fn);
5443 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5448 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5458 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5468 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5484 return BuildOverloadedCallExpr(
5485 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5487 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5501 bool CallingNDeclIndirectly =
false;
5503 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5504 if (UnOp->getOpcode() == UO_AddrOf) {
5505 CallingNDeclIndirectly =
true;
5510 if (isa<DeclRefExpr>(NakedFn)) {
5511 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5526 }
else if (isa<MemberExpr>(NakedFn))
5527 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5529 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5534 if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5540 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5541 ExecConfig, IsExecConfig);
5553 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5557 diag::err_invalid_astype_of_different_size)
5561 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5573 GetTypeFromParser(ParsedDestTy, &TInfo);
5574 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5588 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5589 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5592 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5601 if (
auto *Caller = getCurFunctionDecl())
5602 if (Caller->hasAttr<ARMInterruptAttr>()) {
5604 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5605 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5620 Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
5623 Result = CallExprUnaryConversions(Fn);
5624 ResultTy = Context.
BoolTy;
5626 if (Result.isInvalid())
5641 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5655 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5663 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
5664 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
5668 assert(UsesADL == ADLCallKind::NotADL &&
5669 "CUDAKernelCallExpr should not use ADL");
5672 ResultTy,
VK_RValue, RParenLoc, NumParams);
5675 RParenLoc, NumParams, UsesADL);
5686 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5690 bool CorrectedTypos = TheCall != TheOldCall;
5691 if (!TheCall)
return Result;
5698 if (CorrectedTypos && Args.size() < NumParams) {
5701 Context, Fn, cast<CallExpr>(Config), Args, ResultTy,
VK_RValue,
5702 RParenLoc, NumParams);
5705 RParenLoc, NumParams, UsesADL);
5713 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5715 if (getLangOpts().CUDA) {
5718 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5719 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5724 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5728 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5729 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5744 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5748 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5756 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
5757 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5768 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5769 Expr *Arg = Args[i];
5771 if (Proto && i < Proto->getNumParams()) {
5773 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
5776 if (ArgE.isInvalid())
5779 Arg = ArgE.getAs<
Expr>();
5782 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5791 diag::err_call_incomplete_argument, Arg))
5798 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5799 if (!Method->isStatic())
5800 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5805 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5809 if (CheckFunctionCall(FDecl, TheCall, Proto))
5813 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5815 if (CheckPointerCall(NDecl, TheCall, Proto))
5818 if (CheckOtherCall(TheCall, Proto))
5822 return MaybeBindToTemporary(TheCall);
5828 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5829 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5832 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5836 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5846 diag::err_illegal_decl_array_incomplete_type,
5851 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5854 RequireCompleteType(LParenLoc, literalType,
5855 diag::err_typecheck_decl_incomplete_type,
5870 LiteralExpr = Result.
get();
5872 bool isFileScope = !CurContext->isFunctionOrMethod();
5893 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
5898 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
5899 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
5900 Expr *Init = ILE->getInit(i);
5905 VK, LiteralExpr, isFileScope);
5910 if (CheckForConstantInitializer(LiteralExpr, literalType))
5917 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
5922 return MaybeBindToTemporary(E);
5930 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
5931 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
5932 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
5938 InitArgList[I] = result.
get();
5953 assert(E.
get()->getType()->isBlockPointerType());
5954 assert(E.
get()->isRValue());
5957 if (!getLangOpts().ObjCAutoRefCount)
return;
5960 CK_ARCExtendBlockObject, E.
get(),
5962 Cleanup.setExprNeedsCleanups(
true);
5972 maybeExtendBlockObject(E);
5973 return CK_BlockPointerToObjCPointerCast;
5976 return CK_CPointerToObjCPointerCast;
5993 llvm_unreachable(
"member pointer type in C");
6002 if (SrcAS != DestAS)
6003 return CK_AddressSpaceConversion;
6010 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
6015 return CK_CPointerToObjCPointerCast;
6016 maybeExtendBlockObject(Src);
6017 return CK_BlockPointerToObjCPointerCast;
6019 return CK_PointerToBoolean;
6021 return CK_PointerToIntegral;
6027 llvm_unreachable(
"illegal cast from pointer");
6029 llvm_unreachable(
"Should have returned before this");
6034 return CK_FixedPointCast;
6036 return CK_FixedPointToBoolean;
6042 diag::err_unimplemented_conversion_with_fixed_point_type)
6044 return CK_IntegralCast;
6049 llvm_unreachable(
"illegal cast to pointer type");
6051 llvm_unreachable(
"Should have returned before this");
6059 if (Src.
get()->isNullPointerConstant(Context,
6061 return CK_NullToPointer;
6062 return CK_IntegralToPointer;
6064 return CK_IntegralToBoolean;
6066 return CK_IntegralCast;
6068 return CK_IntegralToFloating;
6070 Src = ImpCastExprToType(Src.
get(),
6073 return CK_IntegralRealToComplex;
6075 Src = ImpCastExprToType(Src.
get(),
6077 CK_IntegralToFloating);
6078 return CK_FloatingRealToComplex;
6080 llvm_unreachable(
"member pointer type in C");
6083 diag::err_unimplemented_conversion_with_fixed_point_type)
6085 return CK_IntegralCast;
6087 llvm_unreachable(
"Should have returned before this");
6092 return CK_FloatingCast;
6094 return CK_FloatingToBoolean;
6096 return CK_FloatingToIntegral;
6098 Src = ImpCastExprToType(Src.
get(),
6101 return CK_FloatingRealToComplex;
6103 Src = ImpCastExprToType(Src.
get(),
6105 CK_FloatingToIntegral);
6106 return CK_IntegralRealToComplex;
6110 llvm_unreachable(
"valid float->pointer cast?");
6112 llvm_unreachable(
"member pointer type in C");
6115 diag::err_unimplemented_conversion_with_fixed_point_type)
6117 return CK_IntegralCast;
6119 llvm_unreachable(
"Should have returned before this");
6124 return CK_FloatingComplexCast;
6126 return CK_FloatingComplexToIntegralComplex;
6130 return CK_FloatingComplexToReal;
6131 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
6132 return CK_FloatingCast;
6135 return CK_FloatingComplexToBoolean;
6137 Src = ImpCastExprToType(Src.
get(),
6139 CK_FloatingComplexToReal);
6140 return CK_FloatingToIntegral;
6144 llvm_unreachable(
"valid complex float->pointer cast?");
6146 llvm_unreachable(
"member pointer type in C");
6149 diag::err_unimplemented_conversion_with_fixed_point_type)
6151 return CK_IntegralCast;
6153 llvm_unreachable(
"Should have returned before this");
6158 return CK_IntegralComplexToFloatingComplex;
6160 return CK_IntegralComplexCast;
6164 return CK_IntegralComplexToReal;
6165 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
6166 return CK_IntegralCast;
6169 return CK_IntegralComplexToBoolean;
6171 Src = ImpCastExprToType(Src.
get(),
6173 CK_IntegralComplexToReal);
6174 return CK_IntegralToFloating;
6178 llvm_unreachable(
"valid complex int->pointer cast?");
6180 llvm_unreachable(
"member pointer type in C");
6183 diag::err_unimplemented_conversion_with_fixed_point_type)
6185 return CK_IntegralCast;
6187 llvm_unreachable(
"Should have returned before this");
6190 llvm_unreachable(
"Unhandled scalar cast");
6197 len = vecType->getNumElements();
6198 eltType = vecType->getElementType();
6230 uint64_t srcLen, destLen;
6238 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
6239 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
6241 return (srcLen * srcEltSize == destLen * destEltSize);
6251 return areLaxCompatibleVectorTypes(srcTy, destTy);
6256 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
6259 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
6262 diag::err_invalid_conversion_between_vectors :
6263 diag::err_invalid_conversion_between_vector_and_integer)
6264 << VectorTy << Ty << R;
6267 diag::err_invalid_conversion_between_vector_and_scalar)
6268 << VectorTy << Ty << R;
6277 if (DestElemTy == SplattedExpr->
getType())
6278 return SplattedExpr;
6290 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6291 CK_BooleanToSignedIntegral);
6292 SplattedExpr = CastExprRes.
get();
6293 CK = CK_IntegralToFloating;
6295 CK = CK_BooleanToSignedIntegral;
6299 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6302 SplattedExpr = CastExprRes.
get();
6304 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6317 if (SrcTy->isVectorType()) {
6318 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6319 (getLangOpts().OpenCL &&
6321 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6322 << DestTy << SrcTy << R;
6332 if (SrcTy->isPointerType())
6334 diag::err_invalid_conversion_between_vector_and_scalar)
6335 << DestTy << SrcTy << R;
6337 Kind = CK_VectorSplat;
6338 return prepareVectorSplat(DestTy, CastExpr);
6346 "ActOnCastExpr(): missing type or expr");
6352 if (getLangOpts().CPlusPlus) {
6354 CheckExtraCXXDefaultArguments(D);
6357 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6360 CastExpr = Res.
get();
6363 checkUnusedDeclAttributes(D);
6366 Ty = CreateParsedType(castType, castTInfo);
6368 bool isVectorLiteral =
false;
6374 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6376 if (PLE && PLE->getNumExprs() == 0) {
6377 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6380 if (PE || PLE->getNumExprs() == 1) {
6383 isVectorLiteral =
true;
6386 isVectorLiteral =
true;
6391 if (isVectorLiteral)
6392 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6397 if (isa<ParenListExpr>(CastExpr)) {
6398 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6400 CastExpr = Result.
get();
6404 !getSourceManager().isInSystemMacro(LParenLoc))
6407 CheckTollFreeBridgeCast(castType, CastExpr);
6409 CheckObjCBridgeRelatedCast(castType, CastExpr);
6411 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6413 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6419 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6420 "Expected paren or paren list expression");
6427 LiteralLParenLoc = PE->getLParenLoc();
6428 LiteralRParenLoc = PE->getRParenLoc();
6429 exprs = PE->getExprs();
6430 numExprs = PE->getNumExprs();
6432 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6433 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6434 subExpr = cast<ParenExpr>(E)->getSubExpr();
6454 if (numExprs == 1) {
6456 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6459 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6460 PrepareScalarCast(Literal, ElemTy));
6461 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6463 else if (numExprs < numElems) {
6465 diag::err_incorrect_number_of_vector_initializers);
6469 initExprs.append(exprs, exprs + numExprs);
6474 if (getLangOpts().OpenCL &&
6478 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6481 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6482 PrepareScalarCast(Literal, ElemTy));
6483 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6486 initExprs.append(exprs, exprs + numExprs);
6491 initExprs, LiteralRParenLoc);
6493 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6506 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
6507 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6510 if (Result.isInvalid())
return ExprError();
6526 Expr *NullExpr = LHSExpr;
6527 Expr *NonPointerExpr = RHSExpr;
6534 NonPointerExpr = LHSExpr;
6551 if (!findMacroSpelling(loc,
"NULL"))
6556 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6557 << NonPointerExpr->
getType() << DiagType
6568 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6576 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6603 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6627 bool IsBlockPointer =
false;
6631 IsBlockPointer =
true;
6656 ResultAddrSpace = LAddrSpace;
6658 ResultAddrSpace = RAddrSpace;
6660 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6661 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6662 << RHS.
get()->getSourceRange();
6667 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6682 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6684 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6693 if (CompositeTy.
isNull()) {
6710 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6711 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6712 << RHS.
get()->getSourceRange();
6721 QualType ResultTy = [&, ResultAddrSpace]() {
6727 .withCVRQualifiers(MergedCVRQual);
6756 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6757 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6758 << RHS.
get()->getSourceRange();
6809 bool IsIntFirstExpr) {
6811 !Int.
get()->getType()->isIntegerType())
6814 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6815 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6817 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6821 CK_IntegralToPointer);
6855 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6856 << LHSType << LHS.
get()->getSourceRange();
6861 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6862 << RHSType << RHS.
get()->getSourceRange();
6867 if (LHSType == RHSType)
6876 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6877 (S, LHS, RHS, LHSType, RHSType,
false);
6911 llvm::raw_svector_ostream OS(Str);
6912 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6913 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6914 << CondTy << OS.str();
6935 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6953 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6954 << CondTy << VecResTy;
6959 QualType RVE = RV->getElementType();
6962 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6963 << CondTy << VecResTy;
6987 if (LHS.
get()->getType()->isVectorType() ||
6988 RHS.
get()->getType()->isVectorType()) {
7007 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
7008 QualType Ty = CE->getCallee()->getType();
7034 if (getLangOpts().CPlusPlus)
7035 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
7042 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
7046 Cond = UsualUnaryConversions(Cond.
get());
7053 if (LHS.
get()->getType()->isVectorType() ||
7054 RHS.
get()->getType()->isVectorType())
7055 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
7059 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
7070 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
7071 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7077 if (getLangOpts().OpenCL &&
7085 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
7086 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
7095 if (LHSRT->getDecl() == RHSRT->getDecl())
7114 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
7118 if (!compositeType.
isNull())
7119 return compositeType;
7144 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
7148 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
7149 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7150 << RHS.
get()->getSourceRange();
7166 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7171 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7177 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7182 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7188 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
7193 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
7220 if (!(compositeType =
7238 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
7240 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7242 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
7243 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
7247 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
7248 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
7249 return compositeType;
7253 if (getLangOpts().ObjCAutoRefCount) {
7256 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7257 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7267 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
7269 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
7273 if (getLangOpts().ObjCAutoRefCount) {
7276 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7277 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7287 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7289 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7303 Self.
Diag(Loc, Note)
7308 Self.
Diag(Loc, Note) << ParenRange;
7328 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
7329 E = MTE->GetTemporaryExpr();
7336 *Opcode = OP->getOpcode();
7337 *RHSExprs = OP->getRHS();
7344 if (Call->getNumArgs() != 2)
7350 if (OO < OO_Plus || OO > OO_Arrow ||
7351 OO == OO_PlusPlus || OO == OO_MinusMinus)
7357 *RHSExprs = Call->getArg(1);
7374 return OP->isComparisonOp() || OP->isLogicalOp();
7376 return OP->getOpcode() == UO_LNot;
7405 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7411 Self.
PDiag(diag::note_precedence_silence)
7416 Self.
PDiag(diag::note_precedence_conditional_first),
7427 auto GetNullability = [&Ctx](
QualType Ty) {
7434 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7442 MergedKind = RHSKind;
7449 MergedKind = RHSKind;
7451 MergedKind = LHSKind;
7457 if (GetNullability(ResTy) == MergedKind)
7479 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7480 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7481 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7494 CondExpr = CondResult.
get();
7495 LHSExpr = LHSResult.
get();
7496 RHSExpr = RHSResult.
get();
7502 Expr *commonExpr =
nullptr;
7504 commonExpr = CondExpr;
7509 ExprResult result = CheckPlaceholderExpr(commonExpr);
7511 commonExpr = result.
get();
7522 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7525 commonExpr = commonRes.
get();
7532 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7535 commonExpr = MatExpr.
get();
7543 LHSExpr = CondExpr = opaqueValue;
7549 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7550 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
7551 VK, OK, QuestionLoc);
7565 return new (Context)
7567 RHS.get(), result, VK, OK);
7570 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7581 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7582 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7585 const Type *lhptee, *rhptee;
7587 std::tie(lhptee, lhq) =
7588 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7589 std::tie(rhptee, rhq) =
7590 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7616 && (lhptee->isVoidType() || rhptee->isVoidType()))
7631 if (lhptee->isVoidType()) {
7632 if (rhptee->isIncompleteOrObjectType())
7636 assert(rhptee->isFunctionType());
7640 if (rhptee->isVoidType()) {
7641 if (lhptee->isIncompleteOrObjectType())
7645 assert(lhptee->isFunctionType());
7656 if (lhptee->isCharType())
7658 else if (lhptee->hasSignedIntegerRepresentation())
7661 if (rhptee->isCharType())
7663 else if (rhptee->hasSignedIntegerRepresentation())
7666 if (ltrans == rtrans) {
7680 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7682 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7683 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7684 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7686 if (lhptee == rhptee)
7706 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7707 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7712 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7713 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7722 Qualifiers LQuals = lhptee.getLocalQualifiers();
7723 Qualifiers RQuals = rhptee.getLocalQualifiers();
7728 if (LQuals != RQuals)
7757 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7758 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7799 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7806 return VT->getElementType() == ElementType;
7839 if (LHSType == RHSType) {
7846 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7848 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
7849 if (result != Compatible)
7851 if (Kind != CK_NoOp && ConvertRHS)
7852 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
7853 Kind = CK_NonAtomicToAtomic;
7866 Kind = CK_LValueBitCast;
7869 return Incompatible;
7876 return Incompatible;
7880 RHS = prepareVectorSplat(LHSType, RHS.
get());
7881 Kind = CK_VectorSplat;
7899 if (isLaxVectorConversion(RHSType, LHSType)) {
7901 return IncompatibleVectors;
7912 isLaxVectorConversion(RHSType, LHSType)) {
7914 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
7920 return Incompatible;
7926 return Incompatible;
7932 return Incompatible;
7938 Kind = PrepareScalarCast(RHS, LHSType);
7943 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7945 if (isa<PointerType>(RHSType)) {
7946 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7948 if (AddrSpaceL != AddrSpaceR)
7949 Kind = CK_AddressSpaceConversion;
7959 Kind = CK_IntegralToPointer;
7960 return IntToPointer;
7965 if (isa<ObjCObjectPointerType>(RHSType)) {
7967 if (LHSPointer->getPointeeType()->isVoidType()) {
7981 return IncompatiblePointer;
7986 if (LHSPointer->getPointeeType()->isVoidType()) {
7987 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7992 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7997 return Incompatible;
8001 if (isa<BlockPointerType>(LHSType)) {
8010 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
8016 Kind = CK_IntegralToPointer;
8017 return IntToBlockPointer;
8022 Kind = CK_AnyPointerToBlockPointerCast;
8028 if (RHSPT->getPointeeType()->isVoidType()) {
8029 Kind = CK_AnyPointerToBlockPointerCast;
8033 return Incompatible;
8037 if (isa<ObjCObjectPointerType>(LHSType)) {
8043 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8044 result == Compatible &&
8045 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
8046 result = IncompatibleObjCWeakRef;
8052 Kind = CK_IntegralToPointer;
8053 return IntToPointer;
8058 if (isa<PointerType>(RHSType)) {
8059 Kind = CK_CPointerToObjCPointerCast;
8073 return IncompatiblePointer;
8080 maybeExtendBlockObject(RHS);
8081 Kind = CK_BlockPointerToObjCPointerCast;
8085 return Incompatible;
8089 if (isa<PointerType>(RHSType)) {
8091 if (LHSType == Context.
BoolTy) {
8092 Kind = CK_PointerToBoolean;
8098 Kind = CK_PointerToIntegral;
8099 return PointerToInt;
8102 return Incompatible;
8106 if (isa<ObjCObjectPointerType>(RHSType)) {
8108 if (LHSType == Context.
BoolTy) {
8109 Kind = CK_PointerToBoolean;
8115 Kind = CK_PointerToIntegral;
8116 return PointerToInt;
8119 return Incompatible;
8123 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
8131 Kind = CK_IntToOCLSampler;
8135 return Incompatible;
8148 Initializer->
setType(UnionType);
8167 return Incompatible;
8173 for (
auto *it : UD->
fields()) {
8174 if (it->getType()->isPointerType()) {
8180 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
8185 if (RHS.
get()->isNullPointerConstant(Context,
8187 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
8195 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
8197 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
8204 return Incompatible;
8213 bool DiagnoseCFAudited,
8217 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
8223 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
8226 if (
const auto *RHSPtrType = RHS.
get()->getType()->getAs<
PointerType>()) {
8227 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8228 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8230 diag::warn_noderef_to_dereferenceable_pointer)
8231 << RHS.
get()->getSourceRange();
8254 return Incompatible;
8259 return Incompatible;
8261 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8262 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
8263 result = IncompatibleObjCWeakRef;
8275 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
8276 RHS.
get(), LHSType,
false, DAP))
8277 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
8279 return Incompatible;
8286 RHS.
get()->isNullPointerConstant(Context,
8288 if (Diagnose || ConvertRHS) {
8291 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8300 if (LHSType->
isQueueT() && RHS.
get()->isNullPointerConstant(
8302 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
8314 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8316 return Incompatible;
8320 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8328 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8335 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8336 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8337 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8339 return Incompatible;
8341 if (getLangOpts().ObjC &&
8342 (CheckObjCBridgeRelatedConversions(E->
getBeginLoc(), LHSType,
8344 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8346 return Incompatible;
8354 RHS = ImpCastExprToType(E, Ty, Kind);
8364 struct OriginalOperand {
8365 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
8366 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
8367 Op = MTE->GetTemporaryExpr();
8368 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
8369 Op = BTE->getSubExpr();
8370 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
8371 Orig = ICE->getSubExprAsWritten();
8372 Conversion = ICE->getConversionFunction();
8376 QualType getType()
const {
return Orig->getType(); }
8385 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
8387 Diag(Loc, diag::err_typecheck_invalid_operands)
8388 << OrigLHS.getType() << OrigRHS.getType()
8389 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8393 if (OrigLHS.Conversion) {
8394 Diag(OrigLHS.Conversion->getLocation(),
8395 diag::note_typecheck_invalid_operands_converted)
8396 << 0 << LHS.
get()->getType();
8398 if (OrigRHS.Conversion) {
8399 Diag(OrigRHS.Conversion->getLocation(),
8400 diag::note_typecheck_invalid_operands_converted)
8401 << 1 << RHS.
get()->getType();
8412 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8413 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8418 if (!(LHSNatVec && RHSNatVec)) {
8419 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8420 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8421 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8427 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8428 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8429 << RHS.
get()->getSourceRange();
8459 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8464 scalarCast = CK_IntegralCast;
8469 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8472 scalarCast = CK_FloatingCast;
8475 scalarCast = CK_IntegralToFloating;
8484 if (scalarCast != CK_NoOp)
8495 assert(VecTy &&
"Expression E must be a vector");
8497 VecTy->getNumElements(),
8498 VecTy->getVectorKind());
8502 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8503 if (ICE->getSubExpr()->getType() == NewVecTy)
8504 return ICE->getSubExpr();
8506 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
8514 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8520 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8528 llvm::APSInt Result = EVResult.
Val.
getInt();
8529 unsigned NumBits = IntSigned
8530 ? (Result.isNegative() ? Result.getMinSignedBits()
8531 : Result.getActiveBits())
8532 : Result.getActiveBits();
8539 return (IntSigned != OtherIntSigned &&
8552 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8557 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8566 llvm::APSInt Result = EVResult.
Val.
getInt();
8569 llvm::APFloat::rmTowardZero);
8572 bool Ignored =
false;
8573 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8575 if (Result != ConvertBack)
8581 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8583 if (Bits > FloatPrec)
8596 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
8597 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
8600 assert(!isa<ExtVectorType>(VT) &&
8601 "ExtVectorTypes should not be handled here!");
8628 ScalarCast = CK_IntegralCast;
8634 llvm::APFloat Result(0.0);
8635 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
8637 if (!CstScalar && Order < 0)
8643 bool Truncated =
false;
8645 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8650 ScalarCast = CK_FloatingCast;
8655 ScalarCast = CK_IntegralToFloating;
8662 if (ScalarCast != CK_NoOp)
8672 bool AllowBoolConversions) {
8673 if (!IsCompAssign) {
8674 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
8678 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
8684 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
8685 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
8689 assert(LHSVecType || RHSVecType);
8693 if (!AllowBothBool &&
8696 return InvalidOperands(Loc, LHS, RHS);
8703 if (LHSVecType && RHSVecType &&
8705 if (isa<ExtVectorType>(LHSVecType)) {
8706 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8711 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8718 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8721 Context.
getTypeSize(RHSVecType->getElementType()))) {
8725 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8728 if (!IsCompAssign &&
8731 RHSVecType->getElementType()->isIntegerType()) {
8732 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8739 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8741 if (isa<ExtVectorType>(LHSVecType)) {
8752 if (isa<ExtVectorType>(RHSVecType)) {
8754 LHSType, RHSVecType->getElementType(),
8767 QualType VecType = LHSVecType ? LHSType : RHSType;
8768 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8769 QualType OtherType = LHSVecType ? RHSType : LHSType;
8770 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8771 if (isLaxVectorConversion(OtherType, VecType)) {
8775 if (!IsCompAssign) {
8776 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
8786 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
8794 if ((!RHSVecType && !RHSType->
isRealType()) ||
8796 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8797 << LHSType << RHSType
8798 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8806 if (getLangOpts().OpenCL &&
8807 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8808 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8809 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
8818 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
8819 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
8820 QualType Scalar = LHSVecType ? RHSType : LHSType;
8821 QualType Vector = LHSVecType ? LHSType : RHSType;
8822 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
8824 diag::err_typecheck_vector_not_convertable_implict_truncation)
8825 << ScalarOrVector << Scalar << Vector;
8832 << LHSType << RHSType
8833 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8845 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
8846 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
8848 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
8852 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8853 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8859 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8867 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8868 NonNullType->canDecayToPointerType())
8871 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8872 << LHSNull << NonNullType
8873 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8882 if (LUE->getKind() !=
UETT_SizeOf || LUE->isArgumentType() ||
8886 QualType LHSTy = LUE->getArgumentExpr()->IgnoreParens()->getType();
8889 if (RUE->isArgumentType())
8890 RHSTy = RUE->getArgumentType();
8892 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
8907 if (!RHS.
get()->isValueDependent() &&
8908 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) &&
8911 S.
PDiag(diag::warn_remainder_division_by_zero)
8912 << IsDiv << RHS.
get()->getSourceRange());
8917 bool IsCompAssign,
bool IsDiv) {
8920 if (LHS.
get()->getType()->isVectorType() ||
8921 RHS.
get()->getType()->isVectorType())
8922 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8923 getLangOpts().AltiVec,
8926 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8932 return InvalidOperands(Loc, LHS, RHS);
8944 if (LHS.
get()->getType()->isVectorType() ||
8945 RHS.
get()->getType()->isVectorType()) {
8946 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
8947 RHS.
get()->getType()->hasIntegerRepresentation())
8948 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8949 getLangOpts().AltiVec,
8951 return InvalidOperands(Loc, LHS, RHS);
8954 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8959 return InvalidOperands(Loc, LHS, RHS);
8968 ? diag::err_typecheck_pointer_arith_void_type
8969 : diag::ext_gnu_void_ptr)
8978 ? diag::err_typecheck_pointer_arith_void_type
8979 : diag::ext_gnu_void_ptr)
8989 Expr *Pointer,
bool IsGNUIdiom) {
8991 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
8994 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
9004 ? diag::err_typecheck_pointer_arith_function_type
9005 : diag::ext_gnu_ptr_func_arith)
9019 ? diag::err_typecheck_pointer_arith_function_type
9020 : diag::ext_gnu_ptr_func_arith)
9033 ResType = ResAtomicType->getValueType();
9038 diag::err_typecheck_arithmetic_incomplete_type,
9054 ResType = ResAtomicType->getValueType();
9086 if (!isLHSPointer && !isRHSPointer)
return true;
9088 QualType LHSPointeeTy, RHSPointeeTy;
9093 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
9098 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9106 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
9107 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
9108 if (isLHSVoidPtr || isRHSVoidPtr) {
9116 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
9117 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
9118 if (isLHSFuncPtr || isRHSFuncPtr) {
9140 Expr* IndexExpr = RHSExpr;
9143 IndexExpr = LHSExpr;
9146 bool IsStringPlusInt = StrExpr &&
9148 if (!IsStringPlusInt || IndexExpr->isValueDependent())
9152 Self.
Diag(OpLoc, diag::warn_string_plus_int)
9153 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
9156 if (IndexExpr == RHSExpr) {
9158 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9163 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9169 const Expr *StringRefExpr = LHSExpr;
9175 StringRefExpr = RHSExpr;
9178 if (!CharExpr || !StringRefExpr)
9195 if (!CharType->isAnyCharacterType() &&
9196 CharType->isIntegerType() &&
9198 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9199 << DiagRange << Ctx.
CharTy;
9201 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9202 << DiagRange << CharExpr->
getType();
9208 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9213 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9222 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
9233 if (LHS.
get()->getType()->isVectorType() ||
9234 RHS.
get()->getType()->isVectorType()) {
9235 QualType compType = CheckVectorOperands(
9236 LHS, RHS, Loc, CompLHSTy,
9237 getLangOpts().AltiVec,
9238 getLangOpts().ZVector);
9239 if (CompLHSTy) *CompLHSTy = compType;
9243 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9248 if (Opc == BO_Add) {
9255 if (CompLHSTy) *CompLHSTy = compType;
9265 isObjCPointer =
false;
9267 isObjCPointer =
true;
9269 std::swap(PExp, IExp);
9271 isObjCPointer =
false;
9273 isObjCPointer =
true;
9275 return InvalidOperands(Loc, LHS, RHS);
9280 if (!IExp->getType()->isIntegerType())
9281 return InvalidOperands(Loc, LHS, RHS);
9288 if (!getLangOpts().CPlusPlus ||
9289 (!IExp->isValueDependent() &&
9290 (!IExp->EvaluateAsInt(KnownVal, Context) ||
9294 Context, BO_Add, PExp, IExp);
9306 CheckArrayAccess(PExp, IExp);
9311 LHSTy = LHS.
get()->getType();
9327 if (LHS.
get()->getType()->isVectorType() ||
9328 RHS.
get()->getType()->isVectorType()) {
9329 QualType compType = CheckVectorOperands(
9330 LHS, RHS, Loc, CompLHSTy,
9331 getLangOpts().AltiVec,
9332 getLangOpts().ZVector);
9333 if (CompLHSTy) *CompLHSTy = compType;
9337 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9345 if (CompLHSTy) *CompLHSTy = compType;
9350 if (LHS.
get()->getType()->isAnyPointerType()) {
9351 QualType lpointee = LHS.
get()->getType()->getPointeeType();
9354 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9359 if (RHS.
get()->getType()->isIntegerType()) {
9363 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9367 if (!getLangOpts().CPlusPlus ||
9368 (!RHS.
get()->isValueDependent() &&
9369 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) ||
9379 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9382 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9383 return LHS.
get()->getType();
9417 if (ElementSize.
isZero()) {
9418 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9420 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9424 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9429 return InvalidOperands(Loc, LHS, RHS);
9434 return ET->getDecl()->isScoped();
9448 if (RHS.
get()->isValueDependent() ||
9449 !RHS.
get()->EvaluateAsInt(RHSResult, S.
Context))
9451 llvm::APSInt Right = RHSResult.
Val.
getInt();
9453 if (Right.isNegative()) {
9455 S.
PDiag(diag::warn_shift_negative)
9456 << RHS.
get()->getSourceRange());
9459 llvm::APInt LeftBits(Right.getBitWidth(),
9461 if (Right.uge(LeftBits)) {
9463 S.
PDiag(diag::warn_shift_gt_typewidth)
9464 << RHS.
get()->getSourceRange());
9475 if (LHS.
get()->isValueDependent() ||
9477 !LHS.
get()->EvaluateAsInt(LHSResult, S.
Context))
9479 llvm::APSInt Left = LHSResult.
Val.
getInt();
9485 S.
PDiag(diag::warn_shift_lhs_negative)
9486 << LHS.
get()->getSourceRange());
9490 llvm::APInt ResultBits =
9491 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9492 if (LeftBits.uge(ResultBits))
9494 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9495 Result = Result.shl(Right);
9500 Result.toString(HexResult, 16,
false,
true);
9506 if (LeftBits == ResultBits - 1) {
9507 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9508 << HexResult << LHSType
9509 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9513 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
9514 << HexResult.str() << Result.getMinSignedBits() << LHSType
9515 << Left.getBitWidth() << LHS.
get()->getSourceRange()
9516 << RHS.
get()->getSourceRange();
9525 !LHS.
get()->getType()->isVectorType()) {
9526 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
9527 << RHS.
get()->getType() << LHS.
get()->getType()
9528 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9532 if (!IsCompAssign) {
9552 if (!LHSEleType->isIntegerType()) {
9553 S.
Diag(Loc, diag::err_typecheck_expect_int)
9554 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
9558 if (!RHSEleType->isIntegerType()) {
9559 S.
Diag(Loc, diag::err_typecheck_expect_int)
9560 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
9568 if (LHSEleType != RHSEleType) {
9570 LHSEleType = RHSEleType;
9576 }
else if (RHSVecTy) {
9581 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9582 << LHS.
get()->getType() << RHS.
get()->getType()
9583 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9589 if (LHSBT != RHSBT &&
9591 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9592 << LHS.
get()->getType() << RHS.
get()->getType()
9593 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9609 bool IsCompAssign) {
9613 if (LHS.
get()->getType()->isVectorType() ||
9614 RHS.
get()->getType()->isVectorType()) {
9615 if (LangOpts.ZVector) {
9619 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
9621 return InvalidOperands(Loc, LHS, RHS);
9622 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
9624 return InvalidOperands(Loc, LHS, RHS);
9635 LHS = UsualUnaryConversions(LHS.
get());
9639 if (IsCompAssign) LHS = OldLHS;
9642 RHS = UsualUnaryConversions(RHS.
get());
9650 return InvalidOperands(Loc, LHS, RHS);
9656 return InvalidOperands(Loc, LHS, RHS);
9689 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9690 << LHSStrippedType << RHSStrippedType
9698 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9699 : diag::ext_typecheck_comparison_of_distinct_pointers)
9700 << LHS.
get()->getType() << RHS.
get()->getType()
9701 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9741 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9742 : diag::ext_typecheck_comparison_of_fptr_to_void)
9743 << LHS.
get()->getType() << RHS.
get()->getType()
9744 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9748 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
9749 case Stmt::ObjCArrayLiteralClass:
9750 case Stmt::ObjCDictionaryLiteralClass:
9751 case Stmt::ObjCStringLiteralClass:
9752 case Stmt::ObjCBoxedExprClass:
9811 case Stmt::ObjCStringLiteralClass:
9814 case Stmt::ObjCArrayLiteralClass:
9817 case Stmt::ObjCDictionaryLiteralClass:
9819 return LK_Dictionary;
9820 case Stmt::BlockExprClass:
9822 case Stmt::ObjCBoxedExprClass: {
9823 Expr *Inner = cast<ObjCBoxedExpr>(FromE)->getSubExpr()->IgnoreParens();
9825 case Stmt::IntegerLiteralClass:
9826 case Stmt::FloatingLiteralClass:
9827 case Stmt::CharacterLiteralClass:
9828 case Stmt::ObjCBoolLiteralExprClass:
9829 case Stmt::CXXBoolLiteralExprClass:
9832 case Stmt::ImplicitCastExprClass: {
9833 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
9835 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
9854 Literal = LHS.
get();
9857 Literal = RHS.
get();
9873 llvm_unreachable(
"Unknown Objective-C object literal kind");
9877 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
9880 S.
Diag(Loc, diag::warn_objc_literal_comparison)
9890 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
9903 if (!UO || UO->
getOpcode() != UO_LNot)
return;
9906 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
9913 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
9915 << Loc << IsBitwiseOp;
9943 return DR->getDecl();
9945 if (Ivar->isFreeIvar())
9946 return Ivar->getDecl();
9948 if (
MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
9949 if (Mem->isImplicitAccess())
9950 return Mem->getMemberDecl();
9990 case BO_EQ:
case BO_LE:
case BO_GE:
9993 case BO_NE:
case BO_LT:
case BO_GT:
9997 Result =
"'std::strong_ordering::equal'";
10003 S.
PDiag(diag::warn_comparison_always)
10004 << 0 << !Result.empty()
10006 }
else if (DL && DR &&
10023 S.
PDiag(diag::warn_comparison_always)
10025 << !Result.empty() << Result);
10028 if (isa<CastExpr>(LHSStripped))
10030 if (isa<CastExpr>(RHSStripped))
10035 Expr *LiteralString =
nullptr;
10036 Expr *LiteralStringStripped =
nullptr;
10037 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
10040 LiteralString = LHS;
10041 LiteralStringStripped = LHSStripped;
10042 }
else if ((isa<StringLiteral>(RHSStripped) ||
10043 isa<ObjCEncodeExpr>(RHSStripped)) &&
10046 LiteralString = RHS;
10047 LiteralStringStripped = RHSStripped;
10050 if (LiteralString) {
10052 S.
PDiag(diag::warn_stringcompare)
10053 << isa<ObjCEncodeExpr>(LiteralStringStripped)
10065 llvm_unreachable(
"unhandled cast kind");
10067 case CK_UserDefinedConversion:
10069 case CK_LValueToRValue:
10071 case CK_ArrayToPointerDecay:
10073 case CK_FunctionToPointerDecay:
10075 case CK_IntegralCast:
10077 case CK_FloatingCast:
10079 case CK_IntegralToFloating:
10080 case CK_FloatingToIntegral:
10082 case CK_IntegralComplexCast:
10083 case CK_FloatingComplexCast:
10084 case CK_FloatingComplexToIntegralComplex:
10085 case CK_IntegralComplexToFloatingComplex:
10087 case CK_FloatingComplexToReal:
10088 case CK_FloatingRealToComplex:
10089 case CK_IntegralComplexToReal:
10090 case CK_IntegralRealToComplex:
10103 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10122 << PreNarrowingValue.getAsString(S.
Context, PreNarrowingType) << ToType;
10130 << 0 << FromType << ToType;
10135 llvm_unreachable(
"unhandled case in switch");
10151 QualType LHSStrippedType = LHSStripped.
get()->getType();
10152 QualType RHSStrippedType = RHSStripped.
get()->getType();
10163 if (NumEnumArgs == 1) {
10165 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
10171 if (NumEnumArgs == 2) {
10180 LHSStrippedType->
getAs<
EnumType>()->getDecl()->getIntegerType();
10191 LHSType = RHSType = IntType;
10204 S, Type, LHS.
get(), LHSType, LHS.
get()->getBeginLoc());
10206 RHS.
get()->getBeginLoc());
10210 assert(!Type.
isNull() &&
"composite type for <=> has not been set");
10212 auto TypeKind = [&]() {
10214 if (CT->getElementType()->hasFloatingRepresentation())
10222 llvm_unreachable(
"other types are unimplemented");
10261 bool IsThreeWay = Opc == BO_Cmp;
10272 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
10273 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10276 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10280 LHS = DefaultLvalueConversion(LHS.
get());
10283 RHS = DefaultLvalueConversion(RHS.
get());
10291 if (LHS.
get()->getType()->isVectorType() ||
10292 RHS.
get()->getType()->isVectorType())
10293 return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);
10300 if ((LHSType->isArithmeticType() || LHSType->isEnumeralType()) &&
10311 auto computeResultTy = [&]() {
10321 return CheckComparisonCategoryType(
Kind, Loc);
10339 if (LHSIsNull != RHSIsNull)
10345 return InvalidOperands(Loc, LHS, RHS);
10349 if (!IsRelational && LHSIsNull != RHSIsNull) {
10350 bool IsEquality = Opc == BO_EQ;
10352 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
10353 RHS.
get()->getSourceRange());
10355 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
10356 LHS.
get()->getSourceRange());
10359 if ((LHSType->isIntegerType() && !LHSIsNull) ||
10363 }
else if (getLangOpts().CPlusPlus) {
10368 if (!IsRelational &&
10375 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
10377 if (isSFINAEContext())
10380 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10381 return computeResultTy();
10393 if ((
int)LHSType->isPointerType() + (int)RHSType->
isPointerType() >=
10394 (IsRelational ? 2 : 1) &&
10395 (!LangOpts.ObjCAutoRefCount || !(LHSType->isObjCObjectPointerType() ||
10399 return computeResultTy();
10401 }
else if (LHSType->isPointerType() &&
10415 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
10416 << LHSType << RHSType << LHS.
get()->getSourceRange()
10417 << RHS.
get()->getSourceRange();
10419 }
else if (!IsRelational &&
10423 && !LHSIsNull && !RHSIsNull)
10430 if (LCanPointeeTy != RCanPointeeTy) {
10432 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
10436 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10437 << LHSType << RHSType << 0
10438 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10443 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
10445 if (LHSIsNull && !RHSIsNull)
10446 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
10448 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
10450 return computeResultTy();
10457 if (!IsRelational && LHSIsNull && RHSIsNull) {
10458 if (LHSType->isNullPtrType()) {
10459 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10460 return computeResultTy();
10463 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10464 return computeResultTy();
10471 (LHSType->isObjCObjectPointerType() || LHSType->isBlockPointerType())) {
10472 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10473 return computeResultTy();
10475 if (!IsRelational && LHSType->isNullPtrType() &&
10477 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10478 return computeResultTy();
10481 if (IsRelational &&
10490 if (isa<FunctionDecl>(DC))
10492 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
10493 if (CTSD->isInStdNamespace() &&
10494 llvm::StringSwitch<bool>(CTSD->getName())
10495 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
10498 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10500 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10501 return computeResultTy();
10509 if (!IsRelational &&
10514 return computeResultTy();
10519 if (!IsRelational && LHSType->isBlockPointerType() &&
10524 if (!LHSIsNull && !RHSIsNull &&
10526 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10527 << LHSType << RHSType << LHS.
get()->getSourceRange()
10528 << RHS.
get()->getSourceRange();
10530 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10531 return computeResultTy();
10536 && ((LHSType->isBlockPointerType() && RHSType->
isPointerType())
10538 if (!LHSIsNull && !RHSIsNull) {
10541 || (LHSType->isPointerType() && LHSType->castAs<
PointerType>()
10543 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10544 << LHSType << RHSType << LHS.
get()->getSourceRange()
10545 << RHS.
get()->getSourceRange();
10547 if (LHSIsNull && !RHSIsNull)
10548 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10550 : CK_AnyPointerToBlockPointerCast);
10552 RHS = ImpCastExprToType(RHS.get(), LHSType,
10553 LHSType->isPointerType() ? CK_BitCast
10554 : CK_AnyPointerToBlockPointerCast);
10555 return computeResultTy();
10558 if (LHSType->isObjCObjectPointerType() ||
10564 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
10566 if (!LPtrToVoid && !RPtrToVoid &&
10571 if (LHSIsNull && !RHSIsNull) {
10573 if (getLangOpts().ObjCAutoRefCount)
10575 CCK_ImplicitConversion);
10576 LHS = ImpCastExprToType(E, RHSType,
10577 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10581 if (getLangOpts().ObjCAutoRefCount)
10582 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
10585 RHS = ImpCastExprToType(E, LHSType,
10586 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10588 return computeResultTy();
10590 if (LHSType->isObjCObjectPointerType() &&
10598 if (LHSIsNull && !RHSIsNull)
10599 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10601 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
10602 return computeResultTy();
10605 if (!IsRelational && LHSType->isBlockPointerType() &&
10607 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10608 CK_BlockPointerToObjCPointerCast);
10609 return computeResultTy();
10610 }
else if (!IsRelational &&
10611 LHSType->isBlockCompatibleObjCPointerType(Context) &&
10613 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10614 CK_BlockPointerToObjCPointerCast);
10615 return computeResultTy();
10618 if ((LHSType->isAnyPointerType() && RHSType->
isIntegerType()) ||
10620 unsigned DiagID = 0;
10621 bool isError =
false;
10622 if (LangOpts.DebuggerSupport) {
10625 }
else if ((LHSIsNull && LHSType->isIntegerType()) ||
10627 if (IsRelational) {
10628 isError = getLangOpts().CPlusPlus;
10630 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
10631 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
10634 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
10636 }
else if (IsRelational)
10637 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
10639 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
10643 << LHSType << RHSType << LHS.
get()->getSourceRange()
10644 << RHS.
get()->getSourceRange();
10649 if (LHSType->isIntegerType())
10650 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10651 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10653 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10654 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10655 return computeResultTy();
10659 if (!IsRelational && RHSIsNull
10660 && LHSType->isBlockPointerType() && RHSType->
isIntegerType()) {
10661 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10662 return computeResultTy();
10664 if (!IsRelational && LHSIsNull
10666 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10667 return computeResultTy();
10670 if (getLangOpts().OpenCLVersion >= 200) {
10671 if (LHSType->isClkEventT() && RHSType->
isClkEventT()) {
10672 return computeResultTy();
10675 if (LHSType->isQueueT() && RHSType->
isQueueT()) {
10676 return computeResultTy();
10679 if (LHSIsNull && RHSType->
isQueueT()) {
10680 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10681 return computeResultTy();
10684 if (LHSType->isQueueT() && RHSIsNull) {
10685 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10686 return computeResultTy();
10690 return InvalidOperands(Loc, LHS, RHS);
10702 if (isa<ExtVectorType>(VTy)) {
10712 "Unhandled vector element size in vector compare");
10729 "Unhandled vector element size in vector compare");
10743 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10745 getLangOpts().ZVector);
10753 if (getLangOpts().AltiVec &&
10765 assert(RHS.
get()->getType()->hasFloatingRepresentation());
10766 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
10770 return GetSignedVectorType(vType);
10777 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10781 return InvalidOperands(Loc, LHS, RHS);
10782 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
10784 return InvalidOperands(Loc, LHS, RHS);
10788 if (!getLangOpts().CPlusPlus &&
10790 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
10792 return GetSignedVectorType(LHS.
get()->getType());
10800 bool IsCompAssign =
10801 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
10803 if (LHS.
get()->getType()->isVectorType() ||
10804 RHS.
get()->getType()->isVectorType()) {
10805 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
10806 RHS.
get()->getType()->hasIntegerRepresentation())
10807 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
10809 getLangOpts().ZVector);
10810 return InvalidOperands(Loc, LHS, RHS);
10816 ExprResult LHSResult = LHS, RHSResult = RHS;
10817 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
10819 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
10821 LHS = LHSResult.
get();
10822 RHS = RHSResult.
get();
10826 return InvalidOperands(Loc, LHS, RHS);
10834 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
10835 return CheckVectorLogicalOperands(LHS, RHS, Loc);
10840 if (LHS.
get()->getType()->isIntegerType() &&
10841 !LHS.
get()->getType()->isBooleanType() &&
10842 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
10844 !Loc.
isMacroID() && !inTemplateInstantiation()) {
10850 if (RHS.
get()->EvaluateAsInt(EVResult, Context)) {
10851 llvm::APSInt Result = EVResult.
Val.
getInt();
10852 if ((getLangOpts().
Bool && !RHS.
get()->getType()->isBooleanType() &&
10853 !RHS.
get()->getExprLoc().isMacroID()) ||
10854 (Result != 0 && Result != 1)) {
10855 Diag(Loc, diag::warn_logical_instead_of_bitwise)
10856 << RHS.
get()->getSourceRange()
10857 << (Opc == BO_LAnd ?
"&&" :
"||");
10859 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
10860 << (Opc == BO_LAnd ?
"&" :
"|")
10862 Loc, getLocForEndOfToken(Loc)),
10863 Opc == BO_LAnd ?
"&" :
"|");
10864 if (Opc == BO_LAnd)
10866 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
10869 RHS.
get()->getEndLoc()));
10879 if (LHS.
get()->getType()->isFloatingType() ||
10880 RHS.
get()->getType()->isFloatingType())
10881 return InvalidOperands(Loc, LHS, RHS);
10884 LHS = UsualUnaryConversions(LHS.
get());
10888 RHS = UsualUnaryConversions(RHS.
get());
10892 if (!LHS.
get()->getType()->isScalarType() ||
10893 !RHS.
get()->getType()->isScalarType())
10894 return InvalidOperands(Loc, LHS, RHS);
10896 return Context.
IntTy;
10905 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
10907 return InvalidOperands(Loc, LHS, RHS);
10910 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
10912 return InvalidOperands(Loc, LHS, RHS);
10923 if (!ME)
return false;
10927 if (!Base)
return false;
10948 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
10956 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
10999 bool DiagnosticEmitted =
false;
11003 bool IsDereference =
false;
11004 bool NextIsDereference =
false;
11008 IsDereference = NextIsDereference;
11011 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
11012 NextIsDereference = ME->isArrow();
11013 const ValueDecl *VD = ME->getMemberDecl();
11014 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
11016 if (Field->isMutable()) {
11017 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
11022 if (!DiagnosticEmitted) {
11023 S.
Diag(Loc, diag::err_typecheck_assign_const)
11025 << Field->getType();
11026 DiagnosticEmitted =
true;
11029 <<
ConstMember <<
false << Field << Field->getType()
11030 << Field->getSourceRange();
11034 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
11035 if (VDecl->getType().isConstQualified()) {
11036 if (!DiagnosticEmitted) {
11037 S.
Diag(Loc, diag::err_typecheck_assign_const)
11039 << VDecl->getType();
11040 DiagnosticEmitted =
true;
11043 <<
ConstMember <<
true << VDecl << VDecl->getType()
11044 << VDecl->getSourceRange();
11051 dyn_cast<ArraySubscriptExpr>(E)) {
11055 dyn_cast<ExtVectorElementExpr>(E)) {
11062 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
11066 if (!DiagnosticEmitted) {
11067 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11069 DiagnosticEmitted =
true;
11072 diag::note_typecheck_assign_const)
11076 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11078 if (
const ValueDecl *VD = DRE->getDecl()) {
11080 if (!DiagnosticEmitted) {
11081 S.
Diag(Loc, diag::err_typecheck_assign_const)
11083 DiagnosticEmitted =
true;
11085 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
11086 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
11089 }
else if (isa<CXXThisExpr>(E)) {
11091 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
11092 if (MD->isConst()) {
11093 if (!DiagnosticEmitted) {
11094 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11096 DiagnosticEmitted =
true;
11098 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
11105 if (DiagnosticEmitted)
11109 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
11122 bool &DiagnosticEmitted) {
11123 std::vector<const RecordType *> RecordTypeList;
11124 RecordTypeList.push_back(Ty);
11125 unsigned NextToCheckIndex = 0;
11128 while (RecordTypeList.size() > NextToCheckIndex) {
11129 bool IsNested = NextToCheckIndex > 0;
11131 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
11133 QualType FieldTy = Field->getType();
11135 if (!DiagnosticEmitted) {
11136 S.
Diag(Loc, diag::err_typecheck_assign_const)
11138 << IsNested << Field;
11139 DiagnosticEmitted =
true;
11141 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
11143 << FieldTy << Field->getSourceRange();
11149 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
11150 RecordTypeList.push_back(FieldRecTy);
11153 ++NextToCheckIndex;
11162 assert(Ty->
isRecordType() &&
"lvalue was not record?");
11165 bool DiagEmitted =
false;
11167 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
11170 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11195 unsigned DiagID = 0;
11196 bool NeedType =
false;
11203 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
11205 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
11213 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
11226 ? diag::err_typecheck_arc_assign_self_class_method
11227 : diag::err_typecheck_arc_assign_self;
11230 }
else if (var->
hasAttr<ObjCExternallyRetainedAttr>() ||
11231 isa<ParmVarDecl>(var)) {
11232 DiagID = diag::err_typecheck_arc_assign_externally_retained;
11236 DiagID = diag::err_typecheck_arr_assign_enumeration;
11240 if (Loc != OrigLoc)
11266 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
11270 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
11274 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
11277 llvm_unreachable(
"did not take early return for MLV_Valid");
11281 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
11286 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
11288 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
11291 llvm_unreachable(
"readonly properties should be processed differently");
11293 DiagID = diag::err_readonly_message_assignment;
11296 DiagID = diag::err_no_subobject_property_setting;
11301 if (Loc != OrigLoc)
11326 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase())))
11331 cast<ValueDecl>(MR->getMemberDecl()->getCanonicalDecl());
11332 if (LHSDecl != RHSDecl)
11337 if (RefTy->getPointeeType().isVolatileQualified())
11340 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
11346 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
11349 if (RL && RR && RL->
getDecl() == RR->getDecl())
11350 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
11370 if (getLangOpts().OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
11372 Diag(Loc, diag::err_opencl_half_load_store) << 1
11378 if (CompoundType.
isNull()) {
11384 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
11388 if (ConvTy == IncompatiblePointer &&
11393 ConvTy = Compatible;
11395 if (ConvTy == Compatible &&
11397 Diag(Loc, diag::err_objc_object_assignment)
11404 RHSCheck = ICE->getSubExpr();
11405 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
11406 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
11407 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
11413 UO->getSubExpr()->getBeginLoc().
isFileID()) {
11414 Diag(Loc, diag::warn_not_compound_assign)
11415 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
11416 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
11420 if (ConvTy == Compatible) {
11428 checkRetainCycles(LHSExpr, RHS.
get());
11442 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11443 RHS.
get()->getBeginLoc()))
11444 getCurFunction()->markSafeWeakUse(RHS.
get());
11446 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
11447 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
11452 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
11455 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
11456 RHS.
get(), AA_Assigning))
11476 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
11477 if (CE->getCastKind() == CK_ToVoid) {
11483 CE->getSubExpr()->getType()->isDependentType()) {
11500 if (inTemplateInstantiation())
11510 const unsigned ForIncrementFlags =
11511 getLangOpts().C99 || getLangOpts().CPlusPlus
11515 const unsigned ScopeFlags = getCurScope()->getFlags();
11516 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
11517 (ScopeFlags & ForInitFlags) == ForInitFlags)
11522 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
11523 if (BO->getOpcode() != BO_Comma)
11525 LHS = BO->getRHS();
11532 Diag(Loc, diag::warn_comma_operator);
11536 LangOpts.CPlusPlus ?
"static_cast<void>(" 11566 if (!RHS.
get()->getType()->isVoidType())
11568 diag::err_incomplete_type);
11574 return RHS.
get()->getType();
11583 bool IsInc,
bool IsPrefix) {
11592 ResType = ResAtomicType->getValueType();
11594 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
11596 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
11604 : diag::warn_increment_bool)
11606 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
11608 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
11610 }
else if (ResType->isRealType()) {
11612 }
else if (ResType->isPointerType()) {
11616 }
else if (ResType->isObjCObjectPointerType()) {
11622 }
else if (ResType->isAnyComplexType()) {
11624 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
11626 }
else if (ResType->isPlaceholderType()) {
11631 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
11633 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
11634 (ResType->getAs<
VectorType>()->getVectorKind() !=
11637 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
11641 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
11658 return ResType.getUnqualifiedType();
11677 case Stmt::DeclRefExprClass:
11678 return cast<DeclRefExpr>(E)->getDecl();
11679 case Stmt::MemberExprClass:
11683 if (cast<MemberExpr>(E)->isArrow())
11687 case Stmt::ArraySubscriptExprClass: {
11690 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
11692 if (ICE->getSubExpr()->getType()->isArrayType())
11697 case Stmt::UnaryOperatorClass: {
11709 case Stmt::ParenExprClass:
11711 case Stmt::ImplicitCastExprClass:
11723 AO_Vector_Element = 1,
11724 AO_Property_Expansion = 2,
11725 AO_Register_Variable = 3,
11745 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
11746 if (PTy->getKind() == BuiltinType::Overload) {
11747 Expr *E = OrigOp.
get()->IgnoreParens();
11748 if (!isa<OverloadExpr>(E)) {
11749 assert(cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf);
11750 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
11751 << OrigOp.
get()->getSourceRange();
11756 if (isa<UnresolvedMemberExpr>(Ovl))
11757 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
11758 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11759 << OrigOp.
get()->getSourceRange();
11766 if (PTy->getKind() == BuiltinType::UnknownAny)
11769 if (PTy->getKind() == BuiltinType::BoundMember) {
11770 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11771 << OrigOp.
get()->getSourceRange();
11775 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
11779 if (OrigOp.
get()->isTypeDependent())
11782 assert(!OrigOp.
get()->getType()->isPlaceholderType());
11785 Expr *op = OrigOp.
get()->IgnoreParens();
11792 if (LangOpts.OpenCL) {
11794 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
11795 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
11800 if (getLangOpts().
C99) {
11803 if (uOp->getOpcode() == UO_Deref)
11806 return uOp->getSubExpr()->getType();
11813 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
11819 unsigned AddressOfError = AO_No_Error;
11822 bool sfinae = (
bool)isSFINAEContext();
11823 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
11824 : diag::ext_typecheck_addrof_temporary)
11830 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
11831 }
else if (isa<ObjCSelectorExpr>(op)) {
11838 if (!isa<DeclRefExpr>(op)) {
11839 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11840 << OrigOp.
get()->getSourceRange();
11847 if (OrigOp.
get() != DRE) {
11848 Diag(OpLoc, diag::err_parens_pointer_member_function)
11849 << OrigOp.
get()->getSourceRange();
11853 if (MD->getParent()->getName().empty())
11854 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11858 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
11859 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11866 if (isa<CXXDestructorDecl>(MD))
11873 (
void)isCompleteType(OpLoc, MPTy);
11880 if (isa<PseudoObjectExpr>(op)) {
11881 AddressOfError = AO_Property_Expansion;
11883 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
11890 AddressOfError = AO_Bit_Field;
11893 AddressOfError = AO_Vector_Element;
11897 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
11901 !getLangOpts().CPlusPlus) {
11902 AddressOfError = AO_Register_Variable;
11904 }
else if (isa<MSPropertyDecl>(dcl)) {
11905 AddressOfError = AO_Property_Expansion;
11906 }
else if (isa<FunctionTemplateDecl>(dcl)) {
11908 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
11912 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
11917 diag::err_cannot_form_pointer_to_member_of_reference_type)
11922 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
11930 (
void)isCompleteType(OpLoc, MPTy);
11934 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
11935 !isa<BindingDecl>(dcl))
11936 llvm_unreachable(
"Unknown/unexpected decl type");
11939 if (AddressOfError != AO_No_Error) {
11955 CheckAddressOfPackedMember(op);
11971 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
11974 if (!FD->ModifiedNonNullParams.count(Param))
11975 FD->ModifiedNonNullParams.insert(Param);
11985 if (ConvResult.isInvalid())
11987 Op = ConvResult.get();
11991 if (isa<CXXReinterpretCastExpr>(Op)) {
12007 if (PR.
get() != Op)
12012 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
12027 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
12043 default: llvm_unreachable(
"Unknown binop!");
12044 case tok::periodstar: Opc = BO_PtrMemD;
break;
12045 case tok::arrowstar: Opc = BO_PtrMemI;
break;
12046 case tok::star: Opc = BO_Mul;
break;
12047 case tok::slash: Opc = BO_Div;
break;
12048 case tok::percent: Opc = BO_Rem;
break;
12049 case tok::plus: Opc = BO_Add;
break;
12050 case tok::minus: Opc = BO_Sub;
break;
12051 case tok::lessless: Opc = BO_Shl;
break;
12052 case tok::greatergreater: Opc = BO_Shr;
break;
12053 case tok::lessequal: Opc = BO_LE;
break;
12054 case tok::less: Opc = BO_LT;
break;
12055 case tok::greaterequal: Opc = BO_GE;
break;
12056 case tok::greater: Opc = BO_GT;
break;
12057 case tok::exclaimequal: Opc = BO_NE;
break;
12058 case tok::equalequal: Opc = BO_EQ;
break;
12059 case tok::spaceship: Opc = BO_Cmp;
break;
12060 case tok::amp: Opc = BO_And;
break;
12061 case tok::caret: Opc = BO_Xor;
break;
12062 case tok::pipe: Opc = BO_Or;
break;
12063 case tok::ampamp: Opc = BO_LAnd;
break;
12064 case tok::pipepipe: Opc = BO_LOr;
break;
12065 case tok::equal: Opc = BO_Assign;
break;
12066 case tok::starequal: Opc = BO_MulAssign;
break;
12067 case tok::slashequal: Opc = BO_DivAssign;
break;
12068 case tok::percentequal: Opc = BO_RemAssign;
break;
12069 case tok::plusequal: Opc = BO_AddAssign;
break;
12070 case tok::minusequal: Opc = BO_SubAssign;
break;
12071 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
12072 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
12073 case tok::ampequal: Opc = BO_AndAssign;
break;
12074 case tok::caretequal: Opc = BO_XorAssign;
break;
12075 case tok::pipeequal: Opc = BO_OrAssign;
break;
12076 case tok::comma: Opc = BO_Comma;
break;
12085 default: llvm_unreachable(
"Unknown unary op!");
12086 case tok::plusplus: Opc = UO_PreInc;
break;
12087 case tok::minusminus: Opc = UO_PreDec;
break;
12088 case tok::amp: Opc = UO_AddrOf;
break;
12089 case tok::star: Opc = UO_Deref;
break;
12090 case tok::plus: Opc = UO_Plus;
break;
12091 case tok::minus: Opc = UO_Minus;
break;
12092 case tok::tilde: Opc = UO_Not;
break;
12093 case tok::exclaim: Opc = UO_LNot;
break;
12094 case tok::kw___real: Opc = UO_Real;
break;
12095 case tok::kw___imag: Opc = UO_Imag;
break;
12096 case tok::kw___extension__: Opc = UO_Extension;
break;
12115 if (!LHSDeclRef || !RHSDeclRef ||
12117 RHSDeclRef->getLocation().isMacroID())
12122 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
12123 if (LHSDecl != RHSDecl)
12128 if (RefTy->getPointeeType().isVolatileQualified())
12131 S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
12132 : diag::warn_self_assignment_overloaded)
12144 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
12149 ObjCPointerExpr = LHS;
12153 ObjCPointerExpr = RHS;
12161 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
12162 unsigned Diag = diag::warn_objc_pointer_masking;
12171 if (SelArg0.startswith(
"performSelector"))
12172 Diag = diag::warn_objc_pointer_masking_performSelector;
12175 S.
Diag(OpLoc, Diag)
12183 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
12184 return DRE->getDecl();
12185 if (
auto *ME = dyn_cast<MemberExpr>(E))
12186 return ME->getMemberDecl();
12187 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
12188 return IRE->getDecl();
12203 "Result must be a vector of half or short");
12206 "both operands expected to be a half vector");
12218 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
12219 OpLoc, FPFeatures);
12223 VK, OK, OpLoc, FPFeatures);
12227 static std::pair<ExprResult, ExprResult>
12237 if (Opc != BO_Assign)
12244 return std::make_pair(LHS, RHS);
12251 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
12262 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
12274 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
12277 RHSExpr = Init.
get();
12287 bool ConvertHalfVec =
false;
12290 if (!LHS.
isUsable() || !RHS.isUsable())
12293 if (getLangOpts().OpenCL) {
12300 if (BO_Assign == Opc)
12301 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
12303 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12313 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12320 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
12321 if (getLangOpts().CPlusPlus &&
12323 VK = LHS.
get()->getValueKind();
12324 OK = LHS.
get()->getObjectKind();
12326 if (!ResultTy.
isNull()) {
12328 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
12334 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
12335 Opc == BO_PtrMemI);
12339 ConvertHalfVec =
true;
12340 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
12344 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
12347 ConvertHalfVec =
true;
12348 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
12351 ConvertHalfVec =
true;
12352 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
12356 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
12362 ConvertHalfVec =
true;
12363 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12367 ConvertHalfVec =
true;
12368 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12371 ConvertHalfVec =
true;
12372 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12380 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12384 ConvertHalfVec =
true;
12385 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
12389 ConvertHalfVec =
true;
12390 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
12391 Opc == BO_DivAssign);
12392 CompLHSTy = CompResultTy;
12394 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12397 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
12398 CompLHSTy = CompResultTy;
12400 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12403 ConvertHalfVec =
true;
12404 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
12406 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12409 ConvertHalfVec =
true;
12410 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
12412 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12416 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
12417 CompLHSTy = CompResultTy;
12419 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12426 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12427 CompLHSTy = CompResultTy;
12429 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12433 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
12434 VK = RHS.get()->getValueKind();
12435 OK = RHS.get()->getObjectKind();
12448 "both sides are half vectors or neither sides are");
12450 LHS.
get()->getType());
12453 CheckArrayAccess(LHS.
get());
12454 CheckArrayAccess(RHS.get());
12456 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
12457 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
12458 &Context.
Idents.
get(
"object_setClass"),
12460 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
12461 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
12462 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign)
12464 "object_setClass(")
12470 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
12473 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
12477 if (CompResultTy.
isNull()) {
12478 if (ConvertHalfVec)
12480 OpLoc, FPFeatures);
12482 OK, OpLoc, FPFeatures);
12486 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
12489 OK = LHS.
get()->getObjectKind();
12492 if (ConvertHalfVec)
12494 OpLoc, FPFeatures);
12497 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
12498 OpLoc, FPFeatures);
12513 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
12514 if (isLeftComp == isRightComp)
12519 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
12520 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
12521 if (isLeftBitwise || isRightBitwise)
12527 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
12533 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
12536 Self.
PDiag(diag::note_precedence_silence) << OpStr,
12539 Self.
PDiag(diag::note_precedence_bitwise_first)
12554 Self.
PDiag(diag::note_precedence_silence)
12579 if (Bop->getOpcode() == BO_LAnd) {
12586 }
else if (Bop->getOpcode() == BO_LOr) {
12587 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
12590 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
12601 if (Bop->getOpcode() == BO_LAnd) {
12618 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
12619 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
12621 << Bop->getSourceRange() << OpLoc;
12623 S.
PDiag(diag::note_precedence_silence)
12624 << Bop->getOpcodeStr(),
12625 Bop->getSourceRange());
12633 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
12634 StringRef Op = Bop->getOpcodeStr();
12635 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
12636 << Bop->getSourceRange() << OpLoc << Shift << Op;
12638 S.
PDiag(diag::note_precedence_silence) << Op,
12639 Bop->getSourceRange());
12655 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
12658 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
12660 << (Kind == OO_LessLess);
12662 S.
PDiag(diag::note_precedence_silence)
12663 << (Kind == OO_LessLess ?
"<<" :
">>"),
12666 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
12680 if ((Opc == BO_Or || Opc == BO_Xor) &&
12688 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
12694 || Opc == BO_Shr) {
12711 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
12712 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
12717 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
12746 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
12762 LHSExpr = LHS.
get();
12763 RHSExpr = RHS.
get();
12774 if (pty->getKind() == BuiltinType::PseudoObject &&
12776 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
12779 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
12785 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12787 RHSExpr = resolvedRHS.
get();
12800 if (Opc == BO_LT && inTemplateInstantiation() &&
12801 (pty->getKind() == BuiltinType::BoundMember ||
12802 pty->getKind() == BuiltinType::Overload)) {
12804 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
12805 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
12806 return isa<FunctionTemplateDecl>(ND);
12808 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
12809 : OE->getNameLoc(),
12810 diag::err_template_kw_missing)
12811 << OE->getName().getAsString() <<
"";
12816 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
12818 LHSExpr = LHS.
get();
12825 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
12826 if (getLangOpts().CPlusPlus &&
12831 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12835 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
12839 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12841 RHSExpr = resolvedRHS.
get();
12858 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12878 bool CanOverflow =
false;
12880 bool ConvertHalfVec =
false;
12881 if (getLangOpts().OpenCL) {
12889 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12891 << Input.
get()->getSourceRange());
12901 Opc == UO_PreInc ||
12903 Opc == UO_PreInc ||
12908 resultType = CheckAddressOfOperand(Input, OpLoc);
12909 CheckAddressOfNoDeref(InputExpr);
12913 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
12920 CanOverflow = Opc == UO_Minus &&
12922 Input = UsualUnaryConversions(Input.get());
12923 if (Input.isInvalid())
return ExprError();
12932 if (ConvertHalfVec)
12934 resultType = Input.get()->getType();
12935 if (resultType->isDependentType())
12937 if (resultType->isArithmeticType())
12939 else if (resultType->isVectorType() &&
12942 resultType->getAs<
VectorType>()->getVectorKind() !=
12945 else if (getLangOpts().CPlusPlus &&
12947 resultType->isPointerType())
12950 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12951 << resultType << Input.get()->getSourceRange());
12954 Input = UsualUnaryConversions(Input.get());
12955 if (Input.isInvalid())
12957 resultType = Input.
get()->getType();
12959 if (resultType->isDependentType())
12962 if (resultType->isComplexType() || resultType->isComplexIntegerType())
12964 Diag(OpLoc, diag::ext_integer_complement_complex)
12965 << resultType << Input.get()->getSourceRange();
12966 else if (resultType->hasIntegerRepresentation())
12968 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
12973 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12974 << resultType << Input.get()->getSourceRange());
12976 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12977 << resultType << Input.get()->getSourceRange());
12983 Input = DefaultFunctionArrayLvalueConversion(Input.get());
12984 if (Input.isInvalid())
return ExprError();
12985 resultType = Input.
get()->getType();
12988 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
12989 Input = ImpCastExprToType(Input.get(), Context.
FloatTy, CK_FloatingCast).
get();
12990 resultType = Context.
FloatTy;
12993 if (resultType->isDependentType())
13000 Input = ImpCastExprToType(Input.get(), Context.
BoolTy,
13001 ScalarTypeToBooleanCastKind(resultType));
13006 if (!resultType->isIntegerType() && !resultType->isPointerType())
13007 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13008 << resultType << Input.get()->getSourceRange());
13010 }
else if (resultType->isExtVectorType()) {
13017 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13018 << resultType << Input.get()->getSourceRange());
13021 resultType = GetSignedVectorType(resultType);
13026 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13027 << resultType << Input.get()->getSourceRange());
13039 if (Input.isInvalid())
return ExprError();
13040 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
13041 if (Input.get()->getValueKind() !=
VK_RValue &&
13043 VK = Input.
get()->getValueKind();
13046 Input = DefaultLvalueConversion(Input.get());
13050 resultType = Input.get()->getType();
13051 VK = Input.get()->getValueKind();
13052 OK = Input.get()->getObjectKind();
13057 assert(!Input.get()->getType()->isDependentType() &&
13058 "the co_await expression must be non-dependant before " 13059 "building operator co_await");
13069 if (Opc != UO_AddrOf && Opc != UO_Deref)
13070 CheckArrayAccess(Input.
get());
13072 auto *UO =
new (Context)
13075 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
13076 !isa<ArrayType>(UO->getType().getDesugaredType(Context)))
13077 ExprEvalContexts.back().PossibleDerefs.insert(UO);
13080 if (ConvertHalfVec)
13089 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13090 if (!DRE->getQualifier())
13097 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
13100 return Method->isInstance();
13106 if (!ULE->getQualifier())
13111 if (Method->isInstance())
13131 if (pty->getKind() == BuiltinType::PseudoObject &&
13133 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
13136 if (Opc == UO_Extension)
13137 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13141 if (Opc == UO_AddrOf &&
13142 (pty->getKind() == BuiltinType::Overload ||
13143 pty->getKind() == BuiltinType::UnknownAny ||
13144 pty->getKind() == BuiltinType::BoundMember))
13145 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13148 ExprResult Result = CheckPlaceholderExpr(Input);
13150 Input = Result.
get();
13155 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
13163 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
13166 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
13169 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13195 if (!cleanups)
return nullptr;
13198 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
13211 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13218 DiscardCleanupsInEvaluationContext();
13219 PopExpressionEvaluationContext();
13225 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
13228 if (hasAnyUnrecoverableErrorsInThisFunction())
13229 DiscardCleanupsInEvaluationContext();
13230 assert(!Cleanup.exprNeedsCleanups() &&
13231 "cleanups within StmtExpr not correctly bound!");
13232 PopExpressionEvaluationContext();
13241 bool StmtExprMayBindToTemp =
false;
13247 LastLabelStmt =
Label;
13248 LastStmt =
Label->getSubStmt();
13251 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
13254 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
13257 Ty = LastExpr.
get()->getType().getUnqualifiedType();
13266 if (
Expr *rebuiltLastStmt
13268 LastExpr = rebuiltLastStmt;
13270 LastExpr = PerformCopyInitialization(
13277 if (LastExpr.
get() !=
nullptr) {
13278 if (!LastLabelStmt)
13282 StmtExprMayBindToTemp =
true;
13290 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
13291 if (StmtExprMayBindToTemp)
13292 return MaybeBindToTemporary(ResStmtExpr);
13293 return ResStmtExpr;
13308 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
13309 << ArgTy << TypeRange);
13314 && RequireCompleteType(BuiltinLoc, ArgTy,
13315 diag::err_offsetof_incomplete_type, TypeRange))
13318 bool DidWarnAboutNonPOD =
false;
13323 if (OC.isBrackets) {
13328 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
13334 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
13348 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
13349 Exprs.push_back(Idx);
13357 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
13363 if (RequireCompleteType(OC.LocStart, CurrentType,
13364 diag::err_offsetof_incomplete_type))
13370 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
13382 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
13384 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
13385 : diag::ext_offsetof_non_pod_type;
13387 if (!IsSafe && !DidWarnAboutNonPOD &&
13388 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
13390 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
13392 DidWarnAboutNonPOD =
true;
13396 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
13397 LookupQualifiedName(R, RD);
13402 MemberDecl = IndirectMemberDecl->getAnonField();
13407 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
13415 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
13423 if (IndirectMemberDecl)
13424 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
13429 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
13431 if (Paths.getDetectedVirtual()) {
13432 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
13443 if (IndirectMemberDecl) {
13444 for (
auto *FI : IndirectMemberDecl->chain()) {
13445 assert(isa<FieldDecl>(FI));
13447 cast<FieldDecl>(FI), OC.LocEnd));
13450 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
13456 Comps, Exprs, RParenLoc);
13467 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
13474 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
13482 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
13487 bool ValueDependent =
false;
13488 bool CondIsTrue =
false;
13491 ValueDependent =
true;
13494 llvm::APSInt condEval(32);
13496 = VerifyIntegerConstantExpression(CondExpr, &condEval,
13497 diag::err_typecheck_choose_expr_requires_constant,
false);
13500 CondExpr = CondICE.
get();
13501 CondIsTrue = condEval.getZExtValue();
13504 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
13506 resType = ActiveExpr->
getType();
13512 return new (Context)
13513 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
13525 if (LangOpts.CPlusPlus) {
13526 Decl *ManglingContextDecl;
13529 ManglingContextDecl)) {
13530 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
13535 PushBlockScope(CurScope, Block);
13536 CurContext->addDecl(Block);
13538 PushDeclContext(CurScope, Block);
13540 CurContext = Block;
13542 getCurBlock()->HasImplicitReturnType =
true;
13546 PushExpressionEvaluationContext(
13547 ExpressionEvaluationContext::PotentiallyEvaluated);
13553 "block-id should have no identifier!");
13557 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
13562 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
13575 "GetTypeForDeclarator made a non-function block signature");
13580 if ((ExplicitSignature =
13586 if (ExplicitSignature.getLocalRangeBegin() ==
13587 ExplicitSignature.getLocalRangeEnd()) {
13590 TypeLoc Result = ExplicitSignature.getReturnLoc();
13599 CurBlock->TheDecl->setSignatureAsWritten(Sig);
13600 CurBlock->FunctionType = T;
13605 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
13607 CurBlock->TheDecl->setIsVariadic(isVariadic);
13614 CurBlock->ReturnType = RetTy;
13615 CurBlock->TheDecl->setBlockMissingReturnType(
false);
13616 CurBlock->HasImplicitReturnType =
false;
13621 if (ExplicitSignature) {
13622 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
13623 ParmVarDecl *Param = ExplicitSignature.getParam(I);
13627 !getLangOpts().CPlusPlus)
13629 Params.push_back(Param);
13635 for (
const auto &I : Fn->param_types()) {
13638 Params.push_back(Param);
13643 if (!Params.empty()) {
13644 CurBlock->TheDecl->setParams(Params);
13645 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
13650 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
13653 for (
auto AI : CurBlock->TheDecl->parameters()) {
13654 AI->setOwningFunction(CurBlock->TheDecl);
13657 if (AI->getIdentifier()) {
13658 CheckShadow(CurBlock->TheScope, AI);
13660 PushOnScopeChains(AI, CurBlock->TheScope);
13669 DiscardCleanupsInEvaluationContext();
13670 PopExpressionEvaluationContext();
13674 PopFunctionScopeInfo();
13682 if (!LangOpts.Blocks)
13683 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
13686 if (hasAnyUnrecoverableErrorsInThisFunction())
13687 DiscardCleanupsInEvaluationContext();
13688 assert(!Cleanup.exprNeedsCleanups() &&
13689 "cleanups within block not correctly bound!");
13690 PopExpressionEvaluationContext();
13692 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
13696 deduceClosureReturnType(*BSI);
13704 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
13715 Captures.push_back(NewCap);
13724 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
13727 if (isa<FunctionNoProtoType>(FTy)) {
13754 DiagnoseUnusedParameters(BD->parameters());
13758 if (getCurFunction()->NeedsScopeChecking() &&
13759 !PP.isCodeCompletionEnabled())
13760 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
13762 BD->setBody(cast<CompoundStmt>(Body));
13764 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13765 DiagnoseUnguardedAvailabilityViolations(BD);
13771 !BD->isDependentContext())
13772 computeNRVO(Body, BSI);
13776 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
13783 Cleanup.setExprNeedsCleanups(
true);
13788 const VarDecl *var = CI.getVariable();
13790 setFunctionHasBranchProtectedScope();
13796 if (getCurFunction())
13797 getCurFunction()->addBlock(BD);
13805 GetTypeFromParser(Ty, &TInfo);
13806 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
13812 Expr *OrigExpr = E;
13816 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
13817 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
13819 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
13846 ExprResult Result = UsualUnaryConversions(E);
13850 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
13856 if (Init.isInvalid())
13858 E = Init.getAs<
Expr>();
13872 diag::err_first_argument_to_va_arg_not_of_type_va_list)
13877 diag::err_second_parameter_to_va_arg_incomplete,
13883 diag::err_second_parameter_to_va_arg_abstract,
13890 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
13891 : diag::warn_second_parameter_to_va_arg_not_pod)
13908 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
13915 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
13924 Ty = Context.
IntTy;
13930 llvm_unreachable(
"I don't know size of pointer!");
13938 if (!getLangOpts().ObjC)
13957 if (OV->getSourceExpr())
13966 Exp = BuildObjCStringLiteral(SL->
getBeginLoc(), SL).
get();
13972 const Expr *SrcExpr) {
13994 bool *Complained) {
13996 *Complained =
false;
13999 bool CheckInferredResultType =
false;
14001 unsigned DiagKind = 0;
14004 bool MayHaveConvFixit =
false;
14005 bool MayHaveFunctionDiff =
false;
14011 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
14015 DiagKind = diag::ext_typecheck_convert_pointer_int;
14017 MayHaveConvFixit =
true;
14020 DiagKind = diag::ext_typecheck_convert_int_pointer;
14022 MayHaveConvFixit =
true;
14024 case IncompatiblePointer:
14025 if (Action == AA_Passing_CFAudited)
14026 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
14029 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
14031 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
14035 if (Hint.
isNull() && !CheckInferredResultType) {
14038 else if (CheckInferredResultType) {
14042 MayHaveConvFixit =
true;
14044 case IncompatiblePointerSign:
14045 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
14047 case FunctionVoidPointer:
14048 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
14050 case IncompatiblePointerDiscardsQualifiers: {
14057 DiagKind = diag::err_typecheck_incompatible_address_space;
14061 DiagKind = diag::err_typecheck_incompatible_ownership;
14065 llvm_unreachable(
"unknown error case for discarding qualifiers!");
14068 case CompatiblePointerDiscardsQualifiers:
14079 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
14081 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
14083 case IncompatibleNestedPointerQualifiers:
14084 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
14086 case IntToBlockPointer:
14087 DiagKind = diag::err_int_to_block_pointer;
14089 case IncompatibleBlockPointer:
14090 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
14092 case IncompatibleObjCQualifiedId: {
14096 for (
auto *srcProto : srcOPT->
quals()) {
14102 IFace = IFaceT->getDecl();
14107 for (
auto *dstProto : dstOPT->
quals()) {
14113 IFace = IFaceT->getDecl();
14115 DiagKind = diag::warn_incompatible_qualified_id;
14118 case IncompatibleVectors:
14119 DiagKind = diag::warn_incompatible_vectors;
14121 case IncompatibleObjCWeakRef:
14122 DiagKind = diag::err_arc_weak_unavailable_assign;
14127 *Complained =
true;
14131 DiagKind = diag::err_typecheck_convert_incompatible;
14133 MayHaveConvFixit =
true;
14135 MayHaveFunctionDiff =
true;
14142 case AA_Initializing:
14144 FirstType = DstType;
14145 SecondType = SrcType;
14150 case AA_Passing_CFAudited:
14151 case AA_Converting:
14155 FirstType = SrcType;
14156 SecondType = DstType;
14161 if (Action == AA_Passing_CFAudited)
14162 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
14164 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
14168 if (!ConvHints.
isNull()) {
14174 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
14176 if (MayHaveFunctionDiff)
14177 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
14180 if (DiagKind == diag::warn_incompatible_qualified_id &&
14182 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
14189 if (CheckInferredResultType)
14190 EmitRelatedResultTypeNote(SrcExpr);
14192 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
14193 EmitRelatedResultTypeNoteForReturn(DstType);
14196 *Complained =
true;
14201 llvm::APSInt *Result) {
14205 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
14209 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
14213 llvm::APSInt *Result,
14220 IDDiagnoser(
unsigned DiagID)
14224 S.
Diag(Loc, DiagID) << SR;
14226 } Diagnoser(DiagID);
14228 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
14233 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
14251 CXX11ConvertDiagnoser(
bool Silent)
14257 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
14262 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
14267 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
14278 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
14289 llvm_unreachable(
"conversion functions are permitted");
14291 } ConvertDiagnoser(Diagnoser.
Suppress);
14293 Converted = PerformContextualImplicitConversion(DiagLoc, E,
14297 E = Converted.
get();
14307 if (!isa<ConstantExpr>(E))
14320 EvalResult.
Diag = &Notes;
14330 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
14339 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14340 diag::note_invalid_subexpr_in_const_expr) {
14341 DiagLoc = Notes[0].first;
14345 if (!Folded || !AllowFold) {
14349 Diag(Note.first, Note.second);
14357 Diag(Note.first, Note.second);
14367 class TransformToPE :
public TreeTransform<TransformToPE> {
14371 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
14374 bool AlwaysRebuild() {
return true; }
14381 return BaseTransform::TransformLabelStmt(S);
14392 if (isa<FieldDecl>(E->
getDecl()) &&
14395 diag::err_invalid_non_static_member_use)
14398 return BaseTransform::TransformDeclRefExpr(E);
14406 return BaseTransform::TransformUnaryOperator(E);
14417 assert(isUnevaluatedContext() &&
14418 "Should only transform unevaluated expressions");
14419 ExprEvalContexts.back().Context =
14420 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
14421 if (isUnevaluatedContext())
14423 return TransformToPE(*this).TransformExpr(E);
14430 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
14431 LambdaContextDecl, ExprContext);
14433 if (!MaybeODRUseExprs.empty())
14434 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
14441 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
14442 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
14449 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
14450 if (E->getOpcode() == UO_Deref)
14451 return CheckPossibleDeref(S, E->getSubExpr());
14452 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
14453 return CheckPossibleDeref(S, E->getBase());
14454 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
14455 return CheckPossibleDeref(S, E->getBase());
14456 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
14462 Inner = Arr->getElementType();
14466 if (Inner->
hasAttr(attr::NoDeref))
14476 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
14483 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
14503 D = diag::err_lambda_unevaluated_operand;
14509 D = diag::err_lambda_in_constant_expression;
14510 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
14513 D = diag::err_lambda_in_invalid_context;
14515 llvm_unreachable(
"Couldn't infer lambda error message.");
14517 for (
const auto *L : Rec.
Lambdas)
14518 Diag(L->getBeginLoc(), D);
14522 for (
auto *Lambda : Rec.
Lambdas) {
14523 for (
auto *C : Lambda->capture_inits())
14524 MarkDeclarationsReferencedInExpr(C);
14529 WarnOnPendingNoDerefs(Rec);
14537 ExprCleanupObjects.end());
14539 CleanupVarDeclMarking();
14549 ExprEvalContexts.pop_back();
14552 ExprEvalContexts.back().NumTypos += NumTypos;
14556 ExprCleanupObjects.erase(
14557 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
14558 ExprCleanupObjects.end());
14560 MaybeODRUseExprs.clear();
14564 ExprResult Result = CheckPlaceholderExpr(E);
14570 return TransformToPotentiallyEvaluated(E);
14596 llvm_unreachable(
"Invalid context");
14621 llvm_unreachable(
"Invalid context");
14633 bool MightBeOdrUse) {
14634 assert(Func &&
"No function?");
14656 bool NeedDefinition =
14665 if (NeedDefinition &&
14668 checkSpecializationVisibility(Loc, Func);
14681 ResolveExceptionSpec(Loc, FPT);
14685 if ((Func->
isUsed(
false) || !OdrUse) &&
14686 (!NeedDefinition || Func->
getBody()))
14691 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
14692 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
14693 if (Constructor->isDefaultConstructor()) {
14694 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
14696 DefineImplicitDefaultConstructor(Loc, Constructor);
14697 }
else if (Constructor->isCopyConstructor()) {
14698 DefineImplicitCopyConstructor(Loc, Constructor);
14699 }
else if (Constructor->isMoveConstructor()) {
14700 DefineImplicitMoveConstructor(Loc, Constructor);
14702 }
else if (Constructor->getInheritedConstructor()) {
14703 DefineInheritingConstructor(Loc, Constructor);
14706 dyn_cast<CXXDestructorDecl>(Func)) {
14707 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
14708 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
14709 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
14711 DefineImplicitDestructor(Loc, Destructor);
14713 if (Destructor->isVirtual() && getLangOpts().AppleKext)
14714 MarkVTableUsed(Loc, Destructor->getParent());
14715 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
14716 if (MethodDecl->isOverloadedOperator() &&
14717 MethodDecl->getOverloadedOperator() == OO_Equal) {
14718 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
14719 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
14720 if (MethodDecl->isCopyAssignmentOperator())
14721 DefineImplicitCopyAssignment(Loc, MethodDecl);
14722 else if (MethodDecl->isMoveAssignmentOperator())
14723 DefineImplicitMoveAssignment(Loc, MethodDecl);
14725 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
14726 MethodDecl->getParent()->isLambda()) {
14728 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
14730 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
14732 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
14733 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
14734 MarkVTableUsed(Loc, MethodDecl->getParent());
14739 if (CurContext == Func)
return;
14746 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
14747 if (FirstInstantiation) {
14748 PointOfInstantiation = Loc;
14754 PointOfInstantiation = Loc;
14761 CodeSynthesisContexts.size())
14762 PendingLocalImplicitInstantiations.push_back(
14763 std::make_pair(Func, PointOfInstantiation));
14768 InstantiateFunctionDefinition(PointOfInstantiation, Func);
14771 PendingInstantiations.push_back(std::make_pair(Func,
14772 PointOfInstantiation));
14774 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
14779 for (
auto i : Func->
redecls()) {
14780 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
14781 MarkFunctionReferenced(Loc, i, OdrUse);
14785 if (!OdrUse)
return;
14789 if (mightHaveNonExternalLinkage(Func))
14792 !LangOpts.GNUInline &&
14795 else if (isExternalWithNoLinkageType(Func))
14810 if (isa<ParmVarDecl>(var) &&
14811 isa<TranslationUnitDecl>(VarDC))
14824 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
14826 if (isa<CXXMethodDecl>(VarDC) &&
14827 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
14829 }
else if (isa<FunctionDecl>(VarDC)) {
14831 }
else if (isa<BlockDecl>(VarDC)) {
14835 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
14836 << var << ValueKind << ContextKind << VarDC;
14846 bool &SubCapturesAreNested,
14852 SubCapturesAreNested =
true;
14865 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
14866 !(isa<CapturedRegionScopeInfo>(CSI) &&
14867 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
14878 const bool Diagnose,
Sema &S) {
14893 const bool Diagnose,
Sema &S) {
14895 bool IsBlock = isa<BlockScopeInfo>(CSI);
14896 bool IsLambda = isa<LambdaScopeInfo>(CSI);
14904 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
14913 S.
Diag(Loc, diag::err_ref_vm_type);
14922 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
14925 S.
Diag(Loc, diag::err_ref_flexarray_type);
14927 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
14935 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14938 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
14940 S.
Diag(Loc, diag::err_capture_block_variable)
14951 S.
Diag(Loc, diag::err_opencl_block_ref_block);
14961 const bool BuildAndDiagnose,
14966 Expr *CopyExpr =
nullptr;
14967 bool ByRef =
false;
14973 if (BuildAndDiagnose) {
14974 S.
Diag(Loc, diag::err_ref_array_type);
14983 if (BuildAndDiagnose) {
14984 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
14998 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
15000 if (AttrTy->getAttrKind() == attr::ObjCOwnership)
15004 Ty = AttrTy->getModifiedType();
15014 !IsObjCOwnershipAttributedType(PointeeTy)) {
15015 if (BuildAndDiagnose) {
15017 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
15018 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
15023 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
15032 DeclRefType = CaptureType;
15034 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
15041 if (isa<ParmVarDecl>(Var))
15058 CaptureType,
false),
15065 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
15068 CopyExpr = Result.
get();
15075 if (BuildAndDiagnose)
15076 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
15088 const bool BuildAndDiagnose,
15091 const bool RefersToCapturedVariable,
15110 CaptureType = DeclRefType;
15112 Expr *CopyExpr =
nullptr;
15113 if (BuildAndDiagnose) {
15136 if (BuildAndDiagnose)
15137 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
15149 bool RefersToCapturedVariable) {
15181 const bool BuildAndDiagnose,
15184 const bool RefersToCapturedVariable,
15187 const bool IsTopScope,
15191 bool ByRef =
false;
15225 if (!RefType->getPointeeType()->isFunctionType())
15231 if (BuildAndDiagnose) {
15232 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
15240 if (BuildAndDiagnose) {
15243 diag::err_capture_of_incomplete_type,
15248 diag::err_capture_of_abstract_type))
15254 if (BuildAndDiagnose)
15256 RefersToCapturedVariable);
15273 if (BuildAndDiagnose)
15274 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
15275 Loc, EllipsisLoc, CaptureType,
nullptr);
15283 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
15291 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
15292 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
15295 if (FunctionScopeIndexToStopAt) {
15296 unsigned FSIndex = FunctionScopes.size() - 1;
15297 while (FSIndex != MaxFunctionScopesIndex) {
15306 if (VarDC == DC)
return true;
15311 if (IsGlobal && !(LangOpts.OpenMP && isOpenMPCapturedDecl(Var)))
15323 CaptureType = Var->
getType();
15325 bool Nested =
false;
15326 bool Explicit = (Kind != TryCapture_Implicit);
15327 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
15340 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
15361 if (BuildAndDiagnose) {
15384 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
15385 QTy = PVD->getOriginalType();
15389 if (getLangOpts().OpenMP) {
15390 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
15395 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
15396 auto IsTargetCap = !IsOpenMPPrivateDecl &&
15397 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
15402 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
15404 if (IsTargetCap || IsOpenMPPrivateDecl) {
15405 Nested = !IsTargetCap;
15416 if (BuildAndDiagnose) {
15420 if (cast<LambdaScopeInfo>(CSI)->Lambda)
15421 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getBeginLoc(),
15422 diag::note_lambda_decl);
15438 FunctionScopesIndex--;
15441 }
while (!VarDC->
Equals(DC));
15448 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
15454 BuildAndDiagnose, CaptureType,
15455 DeclRefType, Nested, *
this))
15460 BuildAndDiagnose, CaptureType,
15461 DeclRefType, Nested, *
this))
15467 BuildAndDiagnose, CaptureType,
15468 DeclRefType, Nested, Kind, EllipsisLoc,
15469 I == N - 1, *
this))
15481 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
15483 DeclRefType,
nullptr);
15489 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15490 false, CaptureType,
15491 DeclRefType,
nullptr);
15499 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15500 false, CaptureType,
15501 DeclRefType,
nullptr))
15504 return DeclRefType;
15518 const VarDecl *DefVD =
nullptr;
15545 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
15546 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
15547 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
15548 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
15551 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
15556 Res = CorrectDelayedTyposInExpr(Res);
15565 UpdateMarkingForLValueToRValue(Res.
get());
15570 for (
Expr *E : MaybeODRUseExprs) {
15573 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
15574 Var = cast<VarDecl>(DRE->getDecl());
15575 Loc = DRE->getLocation();
15576 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
15577 Var = cast<VarDecl>(ME->getMemberDecl());
15578 Loc = ME->getMemberLoc();
15580 llvm_unreachable(
"Unexpected expression");
15587 MaybeODRUseExprs.clear();
15593 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
15594 "Invalid Expr argument to DoMarkVarDeclReferenced");
15600 bool UsableInConstantExpr =
15602 bool NeedDefinition =
15607 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
15608 "Can't instantiate a partial template specialization.");
15614 !isa<VarTemplateSpecializationDecl>(Var))
15625 bool TryInstantiating =
15629 if (TryInstantiating) {
15631 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
15632 if (FirstInstantiation) {
15633 PointOfInstantiation = Loc;
15637 bool InstantiationDependent =
false;
15638 bool IsNonDependent =
15644 if (IsNonDependent) {
15645 if (UsableInConstantExpr) {
15649 }
else if (FirstInstantiation ||
15650 isa<VarTemplateSpecializationDecl>(Var)) {
15657 .push_back(std::make_pair(Var, PointOfInstantiation));
15671 if (OdrUseContext && E &&
15678 }
else if (OdrUseContext) {
15686 const bool RefersToEnclosingScope =
15689 if (RefersToEnclosingScope) {
15702 assert(E &&
"Capture variable should be used in an expression.");
15719 Decl *D,
Expr *E,
bool MightBeOdrUse) {
15723 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
15739 bool IsVirtualCall = MD->
isVirtual() &&
15741 if (!IsVirtualCall)
15757 bool OdrUse =
true;
15759 if (Method->isVirtual() &&
15760 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
15773 bool MightBeOdrUse =
true;
15776 if (Method->isPure())
15777 MightBeOdrUse =
false;
15789 bool MightBeOdrUse) {
15790 if (MightBeOdrUse) {
15791 if (
auto *VD = dyn_cast<VarDecl>(D)) {
15792 MarkVariableReferenced(Loc, VD);
15796 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
15797 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
15824 bool MarkReferencedDecls::TraverseTemplateArgument(
15838 return Inherited::TraverseTemplateArgument(Arg);
15842 MarkReferencedDecls Marker(*
this, Loc);
15843 Marker.TraverseType(T);
15851 bool SkipLocalVariables;
15856 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
15857 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
15861 if (SkipLocalVariables) {
15863 if (VD->hasLocalStorage())
15872 Inherited::VisitMemberExpr(E);
15887 Inherited::VisitCXXNewExpr(E);
15895 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
15899 Inherited::VisitCXXDeleteExpr(E);
15904 Inherited::VisitCXXConstructExpr(E);
15912 Inherited::VisitImplicitCastExpr(E);
15926 bool SkipLocalVariables) {
15927 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
15948 switch (ExprEvalContexts.back().Context) {
15949 case ExpressionEvaluationContext::Unevaluated:
15950 case ExpressionEvaluationContext::UnevaluatedList:
15951 case ExpressionEvaluationContext::UnevaluatedAbstract:
15952 case ExpressionEvaluationContext::DiscardedStatement:
15956 case ExpressionEvaluationContext::ConstantEvaluated:
15960 case ExpressionEvaluationContext::PotentiallyEvaluated:
15961 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
15962 if (Statement && getCurFunctionOrMethodDecl()) {
15963 FunctionScopes.back()->PossiblyUnreachableDiags.
15973 if (
auto *VD = dyn_cast_or_null<VarDecl>(
15974 ExprEvalContexts.back().ManglingContextDecl)) {
15975 if (VD->isConstexpr() ||
15976 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
15996 if (ExprEvalContexts.back().ExprContext ==
15997 ExpressionEvaluationContextRecord::EK_Decltype) {
15998 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
16002 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
16008 : FD(FD), CE(CE) { }
16012 S.
Diag(Loc, diag::err_call_incomplete_return)
16017 S.
Diag(Loc, diag::err_call_function_incomplete_return)
16022 } Diagnoser(FD, CE);
16024 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
16035 unsigned diagnostic = diag::warn_condition_is_assignment;
16036 bool IsOrAssign =
false;
16039 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
16042 IsOrAssign = Op->getOpcode() == BO_OrAssign;
16046 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
16050 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
16051 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16055 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16058 Loc = Op->getOperatorLoc();
16060 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
16063 IsOrAssign = Op->getOperator() == OO_PipeEqual;
16064 Loc = Op->getOperatorLoc();
16066 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
16076 Diag(Loc, diag::note_condition_assign_silence)
16081 Diag(Loc, diag::note_condition_or_assign_to_comparison)
16084 Diag(Loc, diag::note_condition_assign_to_comparison)
16102 if (opE->getOpcode() == BO_EQ &&
16103 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
16109 Diag(Loc, diag::note_equality_comparison_silence)
16112 Diag(Loc, diag::note_equality_comparison_to_assign)
16118 bool IsConstexpr) {
16119 DiagnoseAssignmentAsCondition(E);
16120 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
16121 DiagnoseEqualityWithExtraParens(parenE);
16123 ExprResult result = CheckPlaceholderExpr(E);
16128 if (getLangOpts().CPlusPlus)
16129 return CheckCXXBooleanCondition(E, IsConstexpr);
16131 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
16138 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
16156 case ConditionKind::Boolean:
16157 Cond = CheckBooleanCondition(Loc, SubExpr);
16160 case ConditionKind::ConstexprIf:
16161 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
16164 case ConditionKind::Switch:
16165 Cond = CheckSwitchCondition(Loc, SubExpr);
16169 return ConditionError();
16173 if (!FullExpr.
get())
16174 return ConditionError();
16177 CK == ConditionKind::ConstexprIf);
16183 struct RebuildUnknownAnyFunction
16184 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
16188 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
16191 llvm_unreachable(
"unexpected statement!");
16195 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
16202 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16203 ExprResult SubResult = Visit(E->getSubExpr());
16206 Expr *SubExpr = SubResult.
get();
16207 E->setSubExpr(SubExpr);
16208 E->setType(SubExpr->
getType());
16215 return rebuildSugarExpr(E);
16219 return rebuildSugarExpr(E);
16226 Expr *SubExpr = SubResult.
get();
16235 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
16240 if (S.getLangOpts().CPlusPlus &&
16241 !(isa<CXXMethodDecl>(VD) &&
16242 cast<CXXMethodDecl>(VD)->isInstance()))
16253 return resolveDecl(E, E->
getDecl());
16261 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
16271 struct RebuildUnknownAnyExpr
16272 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
16280 : S(S), DestType(CastType) {}
16283 llvm_unreachable(
"unexpected statement!");
16287 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
16297 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16298 ExprResult SubResult = Visit(E->getSubExpr());
16300 Expr *SubExpr = SubResult.
get();
16301 E->setSubExpr(SubExpr);
16302 E->setType(SubExpr->
getType());
16309 return rebuildSugarExpr(E);
16313 return rebuildSugarExpr(E);
16351 return resolveDecl(E, E->
getDecl());
16362 FK_FunctionPointer,
16369 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
16370 Kind = FK_MemberFunction;
16374 Kind = FK_FunctionPointer;
16377 Kind = FK_BlockPointer;
16382 if (DestType->isArrayType() || DestType->isFunctionType()) {
16383 unsigned diagID = diag::err_func_returning_array_function;
16384 if (Kind == FK_BlockPointer)
16385 diagID = diag::err_block_returning_array_function;
16388 << DestType->isFunctionType() << DestType;
16421 if (ParamTypes.empty() && Proto->isVariadic()) {
16423 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
16431 ArgTypes.push_back(ArgType);
16433 ParamTypes = ArgTypes;
16436 Proto->getExtProtoInfo());
16444 case FK_MemberFunction:
16448 case FK_FunctionPointer:
16452 case FK_BlockPointer:
16458 ExprResult CalleeResult = Visit(CalleeExpr);
16468 if (DestType->isArrayType() || DestType->isFunctionType()) {
16469 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
16470 << DestType->isFunctionType() << DestType;
16477 Method->setReturnType(DestType);
16481 E->
setType(DestType.getNonReferenceType());
16489 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
16496 DestType = DestType->castAs<
PointerType>()->getPointeeType();
16503 }
else if (E->
getCastKind() == CK_LValueToRValue) {
16507 assert(isa<BlockPointerType>(E->
getType()));
16520 llvm_unreachable(
"Unhandled cast type!");
16553 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
16556 FD->getDeclContext(),
16557 Loc, Loc, FD->getNameInfo().getName(),
16558 DestType, FD->getTypeSourceInfo(),
16560 FD->hasPrototype(),
16563 if (FD->getQualifier())
16567 for (
const auto &AI : FT->param_types()) {
16571 Params.push_back(Param);
16573 NewFD->setParams(Params);
16574 DRE->setDecl(NewFD);
16575 VD = DRE->getDecl();
16580 if (MD->isInstance()) {
16590 }
else if (isa<VarDecl>(VD)) {
16594 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
16622 diag::err_typecheck_cast_to_incomplete))
16626 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
16629 CastExpr = result.
get();
16631 CastKind = CK_NoOp;
16637 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
16646 ExprResult result = DefaultArgumentPromotion(arg);
16648 paramType = result.
get()->getType();
16660 return PerformCopyInitialization(entity, callLoc, arg);
16665 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
16668 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
16669 E = call->getCallee();
16670 diagID = diag::err_uncasted_call_of_unknown_any;
16678 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
16679 loc = ref->getLocation();
16680 d = ref->getDecl();
16681 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
16682 loc = mem->getMemberLoc();
16683 d = mem->getMemberDecl();
16685 diagID = diag::err_uncasted_call_of_unknown_any;
16686 loc = msg->getSelectorStartLoc();
16687 d = msg->getMethodDecl();
16689 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
16690 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
16713 ExprResult Result = CorrectDelayedTyposInExpr(E);
16719 if (!placeholderType)
return E;
16721 switch (placeholderType->
getKind()) {
16724 case BuiltinType::Overload: {
16728 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
16734 if (resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
16738 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
16744 case BuiltinType::BoundMember: {
16749 if (isa<CXXPseudoDestructorExpr>(BME)) {
16750 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
16751 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
16752 if (ME->getMemberNameInfo().getName().getNameKind() ==
16754 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
16756 tryToRecoverWithCall(result, PD,
16762 case BuiltinType::ARCUnbridgedCast: {
16763 Expr *realCast = stripARCUnbridgedCast(E);
16764 diagnoseARCUnbridgedCast(realCast);
16769 case BuiltinType::UnknownAny:
16773 case BuiltinType::PseudoObject:
16774 return checkPseudoObjectRValue(E);
16776 case BuiltinType::BuiltinFn: {
16780 auto *FD = cast<FunctionDecl>(DRE->getDecl());
16781 if (FD->getBuiltinID() == Builtin::BI__noop) {
16783 CK_BuiltinFnToFnPtr)
16795 case BuiltinType::OMPArraySection:
16800 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 16801 case BuiltinType::Id: 16802 #include "clang/Basic/OpenCLImageTypes.def" 16803 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 16804 case BuiltinType::Id: 16805 #include "clang/Basic/OpenCLExtensionTypes.def" 16806 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 16807 #define PLACEHOLDER_TYPE(Id, SingletonId) 16808 #include "clang/AST/BuiltinTypes.def" 16812 llvm_unreachable(
"invalid placeholder type!");
16826 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
16827 "Unknown Objective-C Boolean value!");
16832 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
16840 return new (Context)
16848 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
16850 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
16852 return Spec.getPlatform() == Platform;
16855 VersionTuple Version;
16856 if (Spec != AvailSpecs.end())
16857 Version = Spec->getVersion();
16861 if (getCurFunctionOrMethodDecl())
16862 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
16863 else if (getCurBlock() || getCurLambda())
16864 getCurFunction()->HasPotentialAvailabilityViolations =
true;
16866 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.
const Expr * getSubExpr() const
A call to an overloaded operator written using operator syntax.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const BlockDecl * getBlockDecl() const
bool hasDefinition() const
Determine whether this class has been defined.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
QualType withConst() const
Retrieves a version of this type with const applied.
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
const CXXDestructorDecl * getDestructor() const
bool isClassMethod() const
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
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)
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
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)
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
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)
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
llvm::APSInt getValue() const
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
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 void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
bool EvaluateAsInt(EvalResult &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 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)
bool isEmpty() const
No scope specifier.
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Decl - This represents one declaration (or definition), e.g.
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
bool isVariadic() const
Whether this function prototype is variadic.
FunctionDecl * getOperatorNew() const
bool isExtVectorType() const
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
Defines the C++ template declaration subclasses.
This is a while, do, switch, for, etc that can have break statements embedded into it...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer...
void setNumArgsUnsafe(unsigned NewNumArgs)
Bluntly set a new number of arguments without doing any checks whatsoever.
Not a narrowing conversion.
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
bool isCopyCapture() const
ParenExpr - This represents a parethesized expression, e.g.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
bool CheckVecStepExpr(Expr *E)
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
CanQualType ARCUnbridgedCastTy
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
QualType getCorrespondingUnsignedType(QualType T) const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
SourceLocation getEndLoc() const LLVM_READONLY
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
bool isZero() const
isZero - Test whether the quantity equals zero.
QualType withConst() const
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
const TargetInfo & getTargetInfo() const
TemplateNameKind Kind
The kind of template that Template refers to.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
A container of type source information.
QualType getCallResultType() const
Determine the type of an expression that calls this function.
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Floating point control options.
constexpr XRayInstrMask Function
MS property subscript expression.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
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.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr *> Args)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
size_t param_size() const
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Retains information about a function, method, or block that is currently being parsed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
This file provides some common utility functions for processing Lambda related AST Constructs...
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
void setRAngleLoc(SourceLocation Loc)
SourceLocation getBeginLoc() const LLVM_READONLY
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
void removeObjCLifetime()
QualType getReturnType() const
CompoundLiteralExpr - [C99 6.5.2.5].
bool isParamConsumed(unsigned I) const
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
unsigned getNumParams() const
bool isEnumeralType() const
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
APFixedPoint getFixedPointMax(QualType Ty) const
const T * getAs() const
Member-template getAs<specific type>'.
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
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 bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
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.
Used for GCC's __alignof.
FullExpr - Represents a "full-expression" node.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
field_range fields() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
The current expression is potentially evaluated at run time, which means that code may be generated t...
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
Identity conversion (no conversion)
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Floating point conversions (C++ [conv.double].
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
Token - This structure provides full information about a lexed token.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
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)
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
LookupResultKind getResultKind() const
SourceLocation getBeginLoc() const LLVM_READONLY
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
bool isObjCQualifiedClassType() const
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
void PopExpressionEvaluationContext()
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
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
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.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
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.
static void DiagnoseDivisionSizeofPointer(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasAddressSpace() const
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)
SourceLocation getBeginLoc() const LLVM_READONLY
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
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.
StringKind
StringLiteral is followed by several trailing objects.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
bool isRelationalOp() const
Represents a C++ nested-name-specifier or a global scope specifier.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
Helper class for OffsetOfExpr.
The current expression occurs within a discarded statement.
Represents an Objective-C protocol declaration.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
bool isScalarType() const
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An ordinary object is located at an address in memory.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
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)
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
QualType getBOOLType() const
type of 'BOOL' type.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
IdentifierInfo * getIdentifier() const
CanQualType UnsignedCharTy
A default argument (C++ [dcl.fct.default]).
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].
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK)
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...
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...
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.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
std::string getAsString(const LangOptions &LO) const
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
unsigned getValue() const
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition...
SourceLocation getBeginLoc() const
Get the begin source location.
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true)
Create a binary operation that may resolve to an overloaded operator.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
QualType getElementType() const
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
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 ...
This represents one expression.
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
Retrieve the human-readable string for this name.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
bool isNullPtrType() const
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
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
static ValueDecl * getCompareDecl(Expr *E)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
static void diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, ValueDecl *var, DeclContext *DC)
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
Floating-integral conversions (C++ [conv.fpint])
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
void DiscardCleanupsInEvaluationContext()
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isFunctionOrMethod() const
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
clang::ObjCRuntime ObjCRuntime
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr *> Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
void setAddressSpace(LangAS space)
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, IdentKind IK, StringLiteral *SL)
Create a PredefinedExpr.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr *> Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
VarDecl * isOpenMPCapturedDecl(ValueDecl *D)
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
An expression that sends a message to the given Objective-C object or class.
Data structure that captures multiple levels of template argument lists for use in template instantia...
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void CleanupVarDeclMarking()
const BuiltinType * getAsPlaceholderType() const
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
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.
SourceLocation getEndLoc() const LLVM_READONLY
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isUnresolvableResult() const
static CharSourceRange getCharRange(SourceRange R)
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
ExtInfo withNoReturn(bool noReturn) const
Lvalue-to-rvalue conversion (C++ [conv.lval])
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector...
bool isComparisonOp() const
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse)
static bool isBitwiseOp(Opcode Opc)
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
QualType getWideCharType() const
Return the type of wide characters.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
Wrapper for source info for arrays.
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.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
Integral conversions (C++ [conv.integral])
SmallVectorImpl< OverloadCandidate >::iterator iterator
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
QualType getCanonicalType() const
bool CheckCaseExpression(Expr *E)
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
LookupInObjCMethod - The parser has read a name in, and Sema has detected that we're currently inside...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
param_type_range param_types() const
A stack object to be created when performing template instantiation.
ExtParameterInfo getExtParameterInfo(unsigned I) const
VarDecl * getVariable() const
ExtProtoInfo getExtProtoInfo() const
ASTContext & getASTContext() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
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.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Expression is not a Null pointer constant.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Expr * getSubExpr() const
Interfaces are the core concept in Objective-C for object oriented design.
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * Lambda
The class that describes the lambda.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
const ComplexType * getAsComplexIntegerType() const
CastKind getCastKind() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
SourceLocation getBeginLoc() const
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
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 ConstantExpr * Create(const ASTContext &Context, Expr *E)
static bool IgnoreCommaOperand(const Expr *E)
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
QualType getElementType() const
void setReferenced(bool R=true)
Represents the declaration of a label.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
bool isOverloadedResult() const
Determines if the results are overloaded.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S)
Convert vector E to a vector with the same number of elements but different element type...
void setIdentifierInfo(IdentifierInfo *II)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ExprResult TransformToPotentiallyEvaluated(Expr *E)
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
const ParmVarDecl * getParamDecl(unsigned i) const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Expr * getExpr(unsigned Init)
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const
Return true if the provided declaration VD should be captured by reference.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
const TemplateArgumentListInfo & getTemplateArgsInfo() const
SourceLocation getBeginLoc() const LLVM_READONLY
Qualifiers withoutObjCLifetime() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
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)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap.
void addPotentialThisCapture(SourceLocation Loc)
TypeClass getTypeClass() const
Used for C's _Alignof and C++'s alignof.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
EnumDecl * getDecl() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
Complex-real conversions (C99 6.3.1.7)
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
unsigned getFullDataSize() const
Returns the size of the type source info data block.
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
FunctionDecl * getOperatorDelete() const
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
Defines the fixed point number interface.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptions FPFeatures)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
CompoundAssignOperator - For compound assignments (e.g.
A POD class for pairing a NamedDecl* with an access specifier.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
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...
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)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
EvalResult is a struct with detailed info about an evaluated expression.
const DeclContext * getCurObjCLexicalContext() const
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
ArrayRef< Capture > captures() const
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
QualType GetSignedVectorType(QualType V)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
typedef char* __builtin_va_list;
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128 and long double if there is no support for such conve...
QualType getType() const
Get the type for which this source info wrapper provides information.
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
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
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
SourceLocation getEndLoc() const LLVM_READONLY
A runtime availability query.
Array-to-pointer conversion (C++ [conv.array])
This template specialization was instantiated from a template due to an explicit instantiation declar...
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured...
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
const char * getCastKindName() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
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)
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
A set of unresolved declarations.
bool isConstantEvaluated() const
virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR)=0
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Expression is a C++11 nullptr.
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
unsigned short OpenMPLevel
ExplicitCastExpr - An explicit cast written in the source code.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
ExprResult ActOnConstantExpression(ExprResult Res)
unsigned getLength() const
IdentifierInfo * getCorrectionAsIdentifierInfo() const
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr *> Args, SmallVectorImpl< Expr *> &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> Types, ArrayRef< Expr *> Exprs)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
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'.
SourceLocation getBeginLoc() const
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.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
bool isAtomicType() const
static 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)
static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix)
CheckIncrementDecrementOperand - unlike most "Check" methods, this routine doesn't need to call Usual...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D)
Diagnoses obvious problems with the use of the given declaration as an expression.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
SourceLocation getRParenLoc() const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ObjCIvarDecl - Represents an ObjC instance variable.
bool isMultiplicativeOp() const
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type...
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
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()
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
bool isComplexIntegerType() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static ImplicitConversionKind castKindToImplicitConversionKind(CastKind CK)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
void UpdateMarkingForLValueToRValue(Expr *E)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber...
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
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)
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
The class facilities generation and storage of conversion FixIts.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
bool isIncrementDecrementOp() const
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)
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.
SourceLocation getBeginLoc() const LLVM_READONLY
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
A class which abstracts out some details necessary for making a call.
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
The current expression occurs within a braced-init-list within an unevaluated operand.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
One specifier in an expression.
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
void startToken()
Reset all flags to cleared.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
bool isExternallyVisible() const
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
QualType getType() const
Return the type wrapped by this type source info.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
ArrayRef< ParmVarDecl * > parameters() const
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
Helper class that creates diagnostics with optional template instantiation stacks.
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)