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);
4735 L->DefaultArgumentInstantiated(Param);
4741 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4753 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4756 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
4761 assert(!Init->getNumObjects() &&
4762 "default argument expression has capturing blocks?");
4775 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
4784 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4785 return VariadicConstructor;
4787 return VariadicBlock;
4789 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4790 if (Method->isInstance())
4791 return VariadicMethod;
4793 return VariadicMethod;
4794 return VariadicFunction;
4796 return VariadicDoesNotApply;
4805 FunctionName(FuncName) {}
4807 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4831 llvm::make_unique<FunctionCallCCC>(S, FuncName.getAsIdentifierInfo(),
4834 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4835 if (Corrected.isOverloaded()) {
4845 ND = Best->FoundDecl;
4846 Corrected.setCorrectionDecl(ND);
4852 ND = ND->getUnderlyingDecl();
4853 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4872 bool IsExecConfig) {
4882 bool Invalid =
false;
4891 if (Args.size() < NumParams) {
4892 if (Args.size() < MinArgs) {
4897 ? diag::err_typecheck_call_too_few_args_suggest
4898 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4899 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4900 << static_cast<unsigned>(Args.size())
4905 ? diag::err_typecheck_call_too_few_args_one
4906 : diag::err_typecheck_call_too_few_args_at_least_one)
4910 ? diag::err_typecheck_call_too_few_args
4911 : diag::err_typecheck_call_too_few_args_at_least)
4912 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4916 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4924 "We should have reserved space for the default arguments before!");
4929 if (Args.size() > NumParams) {
4935 ? diag::err_typecheck_call_too_many_args_suggest
4936 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4937 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4938 << static_cast<unsigned>(Args.size())
4940 }
else if (NumParams == 1 && FDecl &&
4942 Diag(Args[NumParams]->getBeginLoc(),
4943 MinArgs == NumParams
4944 ? diag::err_typecheck_call_too_many_args_one
4945 : diag::err_typecheck_call_too_many_args_at_most_one)
4949 Args.back()->getEndLoc());
4951 Diag(Args[NumParams]->getBeginLoc(),
4952 MinArgs == NumParams
4953 ? diag::err_typecheck_call_too_many_args
4954 : diag::err_typecheck_call_too_many_args_at_most)
4955 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4958 Args.back()->getEndLoc());
4961 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4972 Invalid = GatherArgumentsForCall(Call->
getBeginLoc(), FDecl, Proto, 0, Args,
4976 unsigned TotalNumArgs = AllArgs.size();
4977 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4978 Call->
setArg(i, AllArgs[i]);
4988 bool IsListInitialization) {
4990 bool Invalid =
false;
4993 for (
unsigned i = FirstParam; i < NumParams; i++) {
4998 if (ArgIx < Args.size()) {
4999 Arg = Args[ArgIx++];
5001 if (RequireCompleteType(Arg->
getBeginLoc(), ProtoArgType,
5002 diag::err_call_incomplete_argument, Arg))
5006 bool CFAudited =
false;
5008 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5009 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5010 Arg = stripARCUnbridgedCast(Arg);
5011 else if (getLangOpts().ObjCAutoRefCount &&
5012 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5013 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5018 BE->getBlockDecl()->setDoesNotEscape();
5031 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
5037 assert(Param &&
"can't use default arguments without a known callee");
5040 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
5050 CheckArrayAccess(Arg);
5053 CheckStaticArrayArgument(CallLoc, Param, Arg);
5055 AllArgs.push_back(Arg);
5059 if (CallType != VariadicDoesNotApply) {
5064 for (
Expr *A : Args.slice(ArgIx)) {
5066 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
5068 AllArgs.push_back(arg.
get());
5073 for (
Expr *A : Args.slice(ArgIx)) {
5074 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
5076 AllArgs.push_back(Arg.
get());
5081 for (
Expr *A : Args.slice(ArgIx))
5082 CheckArrayAccess(A);
5090 TL = DTL.getOriginalLoc();
5093 << ATL.getLocalSourceRange();
5107 const Expr *ArgExpr) {
5135 Diag(CallLoc, diag::warn_static_array_too_small)
5137 << (unsigned) ArgCAT->
getSize().getZExtValue()
5138 << (unsigned) CAT->
getSize().getZExtValue();
5152 if (!placeholder)
return false;
5154 switch (placeholder->
getKind()) {
5156 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 5157 case BuiltinType::Id: 5158 #include "clang/Basic/OpenCLImageTypes.def" 5159 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 5160 case BuiltinType::Id: 5161 #include "clang/Basic/OpenCLExtensionTypes.def" 5162 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 5163 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 5164 #include "clang/AST/BuiltinTypes.def" 5169 case BuiltinType::Overload:
5174 case BuiltinType::ARCUnbridgedCast:
5178 case BuiltinType::PseudoObject:
5183 case BuiltinType::UnknownAny:
5187 case BuiltinType::BoundMember:
5188 case BuiltinType::BuiltinFn:
5189 case BuiltinType::OMPArraySection:
5193 llvm_unreachable(
"bad builtin type kind");
5201 bool hasInvalid =
false;
5202 for (
size_t i = 0, e = args.size(); i != e; i++) {
5205 if (result.
isInvalid()) hasInvalid =
true;
5206 else args[i] = result.
get();
5207 }
else if (hasInvalid) {
5236 bool NeedsNewDecl =
false;
5249 if (!ParamType->isPointerType() ||
5250 ParamType.getQualifiers().hasAddressSpace() ||
5253 OverloadParams.push_back(ParamType);
5261 NeedsNewDecl =
true;
5273 OverloadParams, EPI);
5284 FT = cast<FunctionProtoType>(OverloadTy);
5285 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5292 Params.push_back(Parm);
5294 OverloadDecl->setParams(Params);
5295 return OverloadDecl;
5313 isa<CXXMethodDecl>(Callee)
5314 ? diag::err_ovl_no_viable_member_function_in_call
5315 : diag::err_ovl_no_viable_function_in_call)
5318 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5319 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5327 const auto GetFunctionLevelDCIfCXXClass =
5335 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5336 return MD->
getParent()->getCanonicalDecl();
5339 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5340 return RD->getCanonicalDecl();
5347 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5348 if (!CurParentClass)
5355 assert(NamingClass &&
"Must have naming class even for implicit access");
5361 return CurParentClass == NamingClass ||
5410 Expr *ExecConfig,
bool IsExecConfig) {
5412 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5421 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5422 if (!ArgExprs.empty()) {
5427 ArgExprs.back()->getEndLoc()));
5434 ExprResult result = CheckPlaceholderExpr(Fn);
5444 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5449 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5459 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5469 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5485 return BuildOverloadedCallExpr(
5486 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5488 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5502 bool CallingNDeclIndirectly =
false;
5504 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5505 if (UnOp->getOpcode() == UO_AddrOf) {
5506 CallingNDeclIndirectly =
true;
5511 if (isa<DeclRefExpr>(NakedFn)) {
5512 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5527 }
else if (isa<MemberExpr>(NakedFn))
5528 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5530 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5535 if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5541 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5542 ExecConfig, IsExecConfig);
5554 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5558 diag::err_invalid_astype_of_different_size)
5562 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5574 GetTypeFromParser(ParsedDestTy, &TInfo);
5575 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5589 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5590 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5593 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5602 if (
auto *Caller = getCurFunctionDecl())
5603 if (Caller->hasAttr<ARMInterruptAttr>()) {
5605 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5606 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5621 Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
5624 Result = CallExprUnaryConversions(Fn);
5625 ResultTy = Context.
BoolTy;
5627 if (Result.isInvalid())
5642 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5656 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5664 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
5665 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
5669 assert(UsesADL == ADLCallKind::NotADL &&
5670 "CUDAKernelCallExpr should not use ADL");
5673 ResultTy,
VK_RValue, RParenLoc, NumParams);
5676 RParenLoc, NumParams, UsesADL);
5684 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5687 if (!TheCall)
return Result;
5691 Args = llvm::makeArrayRef(TheCall->
getArgs(), Args.size());
5696 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5698 if (getLangOpts().CUDA) {
5701 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5702 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5707 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5711 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5712 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5727 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5731 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5739 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
5740 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5751 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5752 Expr *Arg = Args[i];
5754 if (Proto && i < Proto->getNumParams()) {
5756 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
5759 if (ArgE.isInvalid())
5762 Arg = ArgE.getAs<
Expr>();
5765 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5774 diag::err_call_incomplete_argument, Arg))
5781 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5782 if (!Method->isStatic())
5783 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5788 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5792 if (CheckFunctionCall(FDecl, TheCall, Proto))
5796 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5798 if (CheckPointerCall(NDecl, TheCall, Proto))
5801 if (CheckOtherCall(TheCall, Proto))
5805 return MaybeBindToTemporary(TheCall);
5811 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5812 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5815 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5819 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5829 diag::err_illegal_decl_array_incomplete_type,
5834 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5837 RequireCompleteType(LParenLoc, literalType,
5838 diag::err_typecheck_decl_incomplete_type,
5853 LiteralExpr = Result.
get();
5855 bool isFileScope = !CurContext->isFunctionOrMethod();
5876 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
5881 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
5882 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
5883 Expr *Init = ILE->getInit(i);
5888 VK, LiteralExpr, isFileScope);
5893 if (CheckForConstantInitializer(LiteralExpr, literalType))
5900 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
5905 return MaybeBindToTemporary(E);
5913 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
5914 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
5915 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
5921 InitArgList[I] = result.
get();
5936 assert(E.
get()->getType()->isBlockPointerType());
5937 assert(E.
get()->isRValue());
5940 if (!getLangOpts().ObjCAutoRefCount)
return;
5943 CK_ARCExtendBlockObject, E.
get(),
5945 Cleanup.setExprNeedsCleanups(
true);
5955 maybeExtendBlockObject(E);
5956 return CK_BlockPointerToObjCPointerCast;
5959 return CK_CPointerToObjCPointerCast;
5976 llvm_unreachable(
"member pointer type in C");
5985 if (SrcAS != DestAS)
5986 return CK_AddressSpaceConversion;
5993 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
5998 return CK_CPointerToObjCPointerCast;
5999 maybeExtendBlockObject(Src);
6000 return CK_BlockPointerToObjCPointerCast;
6002 return CK_PointerToBoolean;
6004 return CK_PointerToIntegral;
6010 llvm_unreachable(
"illegal cast from pointer");
6012 llvm_unreachable(
"Should have returned before this");
6017 return CK_FixedPointCast;
6019 return CK_FixedPointToBoolean;
6025 diag::err_unimplemented_conversion_with_fixed_point_type)
6027 return CK_IntegralCast;
6032 llvm_unreachable(
"illegal cast to pointer type");
6034 llvm_unreachable(
"Should have returned before this");
6042 if (Src.
get()->isNullPointerConstant(Context,
6044 return CK_NullToPointer;
6045 return CK_IntegralToPointer;
6047 return CK_IntegralToBoolean;
6049 return CK_IntegralCast;
6051 return CK_IntegralToFloating;
6053 Src = ImpCastExprToType(Src.
get(),
6056 return CK_IntegralRealToComplex;
6058 Src = ImpCastExprToType(Src.
get(),
6060 CK_IntegralToFloating);
6061 return CK_FloatingRealToComplex;
6063 llvm_unreachable(
"member pointer type in C");
6066 diag::err_unimplemented_conversion_with_fixed_point_type)
6068 return CK_IntegralCast;
6070 llvm_unreachable(
"Should have returned before this");
6075 return CK_FloatingCast;
6077 return CK_FloatingToBoolean;
6079 return CK_FloatingToIntegral;
6081 Src = ImpCastExprToType(Src.
get(),
6084 return CK_FloatingRealToComplex;
6086 Src = ImpCastExprToType(Src.
get(),
6088 CK_FloatingToIntegral);
6089 return CK_IntegralRealToComplex;
6093 llvm_unreachable(
"valid float->pointer cast?");
6095 llvm_unreachable(
"member pointer type in C");
6098 diag::err_unimplemented_conversion_with_fixed_point_type)
6100 return CK_IntegralCast;
6102 llvm_unreachable(
"Should have returned before this");
6107 return CK_FloatingComplexCast;
6109 return CK_FloatingComplexToIntegralComplex;
6113 return CK_FloatingComplexToReal;
6114 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
6115 return CK_FloatingCast;
6118 return CK_FloatingComplexToBoolean;
6120 Src = ImpCastExprToType(Src.
get(),
6122 CK_FloatingComplexToReal);
6123 return CK_FloatingToIntegral;
6127 llvm_unreachable(
"valid complex float->pointer cast?");
6129 llvm_unreachable(
"member pointer type in C");
6132 diag::err_unimplemented_conversion_with_fixed_point_type)
6134 return CK_IntegralCast;
6136 llvm_unreachable(
"Should have returned before this");
6141 return CK_IntegralComplexToFloatingComplex;
6143 return CK_IntegralComplexCast;
6147 return CK_IntegralComplexToReal;
6148 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
6149 return CK_IntegralCast;
6152 return CK_IntegralComplexToBoolean;
6154 Src = ImpCastExprToType(Src.
get(),
6156 CK_IntegralComplexToReal);
6157 return CK_IntegralToFloating;
6161 llvm_unreachable(
"valid complex int->pointer cast?");
6163 llvm_unreachable(
"member pointer type in C");
6166 diag::err_unimplemented_conversion_with_fixed_point_type)
6168 return CK_IntegralCast;
6170 llvm_unreachable(
"Should have returned before this");
6173 llvm_unreachable(
"Unhandled scalar cast");
6180 len = vecType->getNumElements();
6181 eltType = vecType->getElementType();
6213 uint64_t srcLen, destLen;
6221 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
6222 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
6224 return (srcLen * srcEltSize == destLen * destEltSize);
6234 return areLaxCompatibleVectorTypes(srcTy, destTy);
6239 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
6242 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
6245 diag::err_invalid_conversion_between_vectors :
6246 diag::err_invalid_conversion_between_vector_and_integer)
6247 << VectorTy << Ty << R;
6250 diag::err_invalid_conversion_between_vector_and_scalar)
6251 << VectorTy << Ty << R;
6260 if (DestElemTy == SplattedExpr->
getType())
6261 return SplattedExpr;
6273 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6274 CK_BooleanToSignedIntegral);
6275 SplattedExpr = CastExprRes.
get();
6276 CK = CK_IntegralToFloating;
6278 CK = CK_BooleanToSignedIntegral;
6282 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6285 SplattedExpr = CastExprRes.
get();
6287 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6300 if (SrcTy->isVectorType()) {
6301 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6302 (getLangOpts().OpenCL &&
6304 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6305 << DestTy << SrcTy << R;
6315 if (SrcTy->isPointerType())
6317 diag::err_invalid_conversion_between_vector_and_scalar)
6318 << DestTy << SrcTy << R;
6320 Kind = CK_VectorSplat;
6321 return prepareVectorSplat(DestTy, CastExpr);
6329 "ActOnCastExpr(): missing type or expr");
6335 if (getLangOpts().CPlusPlus) {
6337 CheckExtraCXXDefaultArguments(D);
6340 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6343 CastExpr = Res.
get();
6346 checkUnusedDeclAttributes(D);
6349 Ty = CreateParsedType(castType, castTInfo);
6351 bool isVectorLiteral =
false;
6357 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6359 if (PLE && PLE->getNumExprs() == 0) {
6360 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6363 if (PE || PLE->getNumExprs() == 1) {
6366 isVectorLiteral =
true;
6369 isVectorLiteral =
true;
6374 if (isVectorLiteral)
6375 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6380 if (isa<ParenListExpr>(CastExpr)) {
6381 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6383 CastExpr = Result.
get();
6387 !getSourceManager().isInSystemMacro(LParenLoc))
6390 CheckTollFreeBridgeCast(castType, CastExpr);
6392 CheckObjCBridgeRelatedCast(castType, CastExpr);
6394 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6396 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6402 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6403 "Expected paren or paren list expression");
6410 LiteralLParenLoc = PE->getLParenLoc();
6411 LiteralRParenLoc = PE->getRParenLoc();
6412 exprs = PE->getExprs();
6413 numExprs = PE->getNumExprs();
6415 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6416 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6417 subExpr = cast<ParenExpr>(E)->getSubExpr();
6437 if (numExprs == 1) {
6439 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6442 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6443 PrepareScalarCast(Literal, ElemTy));
6444 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6446 else if (numExprs < numElems) {
6448 diag::err_incorrect_number_of_vector_initializers);
6452 initExprs.append(exprs, exprs + numExprs);
6457 if (getLangOpts().OpenCL &&
6461 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6464 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6465 PrepareScalarCast(Literal, ElemTy));
6466 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6469 initExprs.append(exprs, exprs + numExprs);
6474 initExprs, LiteralRParenLoc);
6476 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6489 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
6490 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6493 if (Result.isInvalid())
return ExprError();
6509 Expr *NullExpr = LHSExpr;
6510 Expr *NonPointerExpr = RHSExpr;
6517 NonPointerExpr = LHSExpr;
6534 if (!findMacroSpelling(loc,
"NULL"))
6539 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6540 << NonPointerExpr->
getType() << DiagType
6551 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6559 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6586 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6610 bool IsBlockPointer =
false;
6614 IsBlockPointer =
true;
6639 ResultAddrSpace = LAddrSpace;
6641 ResultAddrSpace = RAddrSpace;
6643 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6644 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6645 << RHS.
get()->getSourceRange();
6650 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6665 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6667 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6676 if (CompositeTy.
isNull()) {
6693 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6694 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6695 << RHS.
get()->getSourceRange();
6704 QualType ResultTy = [&, ResultAddrSpace]() {
6710 .withCVRQualifiers(MergedCVRQual);
6739 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6740 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6741 << RHS.
get()->getSourceRange();
6792 bool IsIntFirstExpr) {
6794 !Int.
get()->getType()->isIntegerType())
6797 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6798 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6800 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6804 CK_IntegralToPointer);
6838 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6839 << LHSType << LHS.
get()->getSourceRange();
6844 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6845 << RHSType << RHS.
get()->getSourceRange();
6850 if (LHSType == RHSType)
6859 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6860 (S, LHS, RHS, LHSType, RHSType,
false);
6894 llvm::raw_svector_ostream OS(Str);
6895 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6896 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6897 << CondTy << OS.str();
6918 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6936 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6937 << CondTy << VecResTy;
6942 QualType RVE = RV->getElementType();
6945 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6946 << CondTy << VecResTy;
6970 if (LHS.
get()->getType()->isVectorType() ||
6971 RHS.
get()->getType()->isVectorType()) {
6990 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
6991 QualType Ty = CE->getCallee()->getType();
7017 if (getLangOpts().CPlusPlus)
7018 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
7025 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
7029 Cond = UsualUnaryConversions(Cond.
get());
7036 if (LHS.
get()->getType()->isVectorType() ||
7037 RHS.
get()->getType()->isVectorType())
7038 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
7042 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
7053 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
7054 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7060 if (getLangOpts().OpenCL &&
7068 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
7069 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
7078 if (LHSRT->getDecl() == RHSRT->getDecl())
7097 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
7101 if (!compositeType.
isNull())
7102 return compositeType;
7127 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
7131 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
7132 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7133 << RHS.
get()->getSourceRange();
7149 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7154 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7160 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7165 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7171 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
7176 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
7203 if (!(compositeType =
7221 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
7223 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7225 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
7226 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
7230 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
7231 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
7232 return compositeType;
7236 if (getLangOpts().ObjCAutoRefCount) {
7239 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7240 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7250 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
7252 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
7256 if (getLangOpts().ObjCAutoRefCount) {
7259 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7260 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7270 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7272 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7286 Self.
Diag(Loc, Note)
7291 Self.
Diag(Loc, Note) << ParenRange;
7311 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
7312 E = MTE->GetTemporaryExpr();
7319 *Opcode = OP->getOpcode();
7320 *RHSExprs = OP->getRHS();
7327 if (Call->getNumArgs() != 2)
7333 if (OO < OO_Plus || OO > OO_Arrow ||
7334 OO == OO_PlusPlus || OO == OO_MinusMinus)
7340 *RHSExprs = Call->getArg(1);
7357 return OP->isComparisonOp() || OP->isLogicalOp();
7359 return OP->getOpcode() == UO_LNot;
7388 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7394 Self.
PDiag(diag::note_precedence_silence)
7399 Self.
PDiag(diag::note_precedence_conditional_first),
7410 auto GetNullability = [&Ctx](
QualType Ty) {
7417 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7425 MergedKind = RHSKind;
7432 MergedKind = RHSKind;
7434 MergedKind = LHSKind;
7440 if (GetNullability(ResTy) == MergedKind)
7462 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7463 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7464 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7477 CondExpr = CondResult.
get();
7478 LHSExpr = LHSResult.
get();
7479 RHSExpr = RHSResult.
get();
7485 Expr *commonExpr =
nullptr;
7487 commonExpr = CondExpr;
7492 ExprResult result = CheckPlaceholderExpr(commonExpr);
7494 commonExpr = result.
get();
7505 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7508 commonExpr = commonRes.
get();
7515 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7518 commonExpr = MatExpr.
get();
7526 LHSExpr = CondExpr = opaqueValue;
7532 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7533 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
7534 VK, OK, QuestionLoc);
7548 return new (Context)
7550 RHS.get(), result, VK, OK);
7553 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7564 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7565 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7568 const Type *lhptee, *rhptee;
7570 std::tie(lhptee, lhq) =
7571 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7572 std::tie(rhptee, rhq) =
7573 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7599 && (lhptee->isVoidType() || rhptee->isVoidType()))
7614 if (lhptee->isVoidType()) {
7615 if (rhptee->isIncompleteOrObjectType())
7619 assert(rhptee->isFunctionType());
7623 if (rhptee->isVoidType()) {
7624 if (lhptee->isIncompleteOrObjectType())
7628 assert(lhptee->isFunctionType());
7639 if (lhptee->isCharType())
7641 else if (lhptee->hasSignedIntegerRepresentation())
7644 if (rhptee->isCharType())
7646 else if (rhptee->hasSignedIntegerRepresentation())
7649 if (ltrans == rtrans) {
7663 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7665 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7666 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7667 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7669 if (lhptee == rhptee)
7689 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7690 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7695 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7696 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7705 Qualifiers LQuals = lhptee.getLocalQualifiers();
7706 Qualifiers RQuals = rhptee.getLocalQualifiers();
7711 if (LQuals != RQuals)
7740 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7741 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7782 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7789 return VT->getElementType() == ElementType;
7822 if (LHSType == RHSType) {
7829 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7831 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
7832 if (result != Compatible)
7834 if (Kind != CK_NoOp && ConvertRHS)
7835 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
7836 Kind = CK_NonAtomicToAtomic;
7849 Kind = CK_LValueBitCast;
7852 return Incompatible;
7859 return Incompatible;
7863 RHS = prepareVectorSplat(LHSType, RHS.
get());
7864 Kind = CK_VectorSplat;
7882 if (isLaxVectorConversion(RHSType, LHSType)) {
7884 return IncompatibleVectors;
7895 isLaxVectorConversion(RHSType, LHSType)) {
7897 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
7903 return Incompatible;
7909 return Incompatible;
7915 return Incompatible;
7921 Kind = PrepareScalarCast(RHS, LHSType);
7926 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7928 if (isa<PointerType>(RHSType)) {
7929 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7931 if (AddrSpaceL != AddrSpaceR)
7932 Kind = CK_AddressSpaceConversion;
7942 Kind = CK_IntegralToPointer;
7943 return IntToPointer;
7948 if (isa<ObjCObjectPointerType>(RHSType)) {
7950 if (LHSPointer->getPointeeType()->isVoidType()) {
7964 return IncompatiblePointer;
7969 if (LHSPointer->getPointeeType()->isVoidType()) {
7970 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7975 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7980 return Incompatible;
7984 if (isa<BlockPointerType>(LHSType)) {
7993 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7999 Kind = CK_IntegralToPointer;
8000 return IntToBlockPointer;
8005 Kind = CK_AnyPointerToBlockPointerCast;
8011 if (RHSPT->getPointeeType()->isVoidType()) {
8012 Kind = CK_AnyPointerToBlockPointerCast;
8016 return Incompatible;
8020 if (isa<ObjCObjectPointerType>(LHSType)) {
8026 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8027 result == Compatible &&
8028 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
8029 result = IncompatibleObjCWeakRef;
8035 Kind = CK_IntegralToPointer;
8036 return IntToPointer;
8041 if (isa<PointerType>(RHSType)) {
8042 Kind = CK_CPointerToObjCPointerCast;
8056 return IncompatiblePointer;
8063 maybeExtendBlockObject(RHS);
8064 Kind = CK_BlockPointerToObjCPointerCast;
8068 return Incompatible;
8072 if (isa<PointerType>(RHSType)) {
8074 if (LHSType == Context.
BoolTy) {
8075 Kind = CK_PointerToBoolean;
8081 Kind = CK_PointerToIntegral;
8082 return PointerToInt;
8085 return Incompatible;
8089 if (isa<ObjCObjectPointerType>(RHSType)) {
8091 if (LHSType == Context.
BoolTy) {
8092 Kind = CK_PointerToBoolean;
8098 Kind = CK_PointerToIntegral;
8099 return PointerToInt;
8102 return Incompatible;
8106 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
8114 Kind = CK_IntToOCLSampler;
8118 return Incompatible;
8131 Initializer->
setType(UnionType);
8150 return Incompatible;
8156 for (
auto *it : UD->
fields()) {
8157 if (it->getType()->isPointerType()) {
8163 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
8168 if (RHS.
get()->isNullPointerConstant(Context,
8170 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
8178 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
8180 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
8187 return Incompatible;
8196 bool DiagnoseCFAudited,
8200 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
8206 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
8209 if (
const auto *RHSPtrType = RHS.
get()->getType()->getAs<
PointerType>()) {
8210 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8211 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8213 diag::warn_noderef_to_dereferenceable_pointer)
8214 << RHS.
get()->getSourceRange();
8237 return Incompatible;
8242 return Incompatible;
8244 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8245 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
8246 result = IncompatibleObjCWeakRef;
8258 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
8259 RHS.
get(), LHSType,
false, DAP))
8260 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
8262 return Incompatible;
8269 RHS.
get()->isNullPointerConstant(Context,
8271 if (Diagnose || ConvertRHS) {
8274 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8283 if (LHSType->
isQueueT() && RHS.
get()->isNullPointerConstant(
8285 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
8297 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8299 return Incompatible;
8303 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8311 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8318 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8319 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8320 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8322 return Incompatible;
8324 if (getLangOpts().ObjC &&
8325 (CheckObjCBridgeRelatedConversions(E->
getBeginLoc(), LHSType,
8327 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8329 return Incompatible;
8337 RHS = ImpCastExprToType(E, Ty, Kind);
8347 struct OriginalOperand {
8348 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
8349 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
8350 Op = MTE->GetTemporaryExpr();
8351 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
8352 Op = BTE->getSubExpr();
8353 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
8354 Orig = ICE->getSubExprAsWritten();
8355 Conversion = ICE->getConversionFunction();
8359 QualType getType()
const {
return Orig->getType(); }
8368 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
8370 Diag(Loc, diag::err_typecheck_invalid_operands)
8371 << OrigLHS.getType() << OrigRHS.getType()
8372 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8376 if (OrigLHS.Conversion) {
8377 Diag(OrigLHS.Conversion->getLocation(),
8378 diag::note_typecheck_invalid_operands_converted)
8379 << 0 << LHS.
get()->getType();
8381 if (OrigRHS.Conversion) {
8382 Diag(OrigRHS.Conversion->getLocation(),
8383 diag::note_typecheck_invalid_operands_converted)
8384 << 1 << RHS.
get()->getType();
8395 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8396 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8401 if (!(LHSNatVec && RHSNatVec)) {
8402 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8403 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8404 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8410 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8411 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8412 << RHS.
get()->getSourceRange();
8442 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8447 scalarCast = CK_IntegralCast;
8452 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8455 scalarCast = CK_FloatingCast;
8458 scalarCast = CK_IntegralToFloating;
8467 if (scalarCast != CK_NoOp)
8478 assert(VecTy &&
"Expression E must be a vector");
8480 VecTy->getNumElements(),
8481 VecTy->getVectorKind());
8485 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8486 if (ICE->getSubExpr()->getType() == NewVecTy)
8487 return ICE->getSubExpr();
8489 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
8497 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8503 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8511 llvm::APSInt Result = EVResult.
Val.
getInt();
8512 unsigned NumBits = IntSigned
8513 ? (Result.isNegative() ? Result.getMinSignedBits()
8514 : Result.getActiveBits())
8515 : Result.getActiveBits();
8522 return (IntSigned != OtherIntSigned &&
8535 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8540 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8549 llvm::APSInt Result = EVResult.
Val.
getInt();
8552 llvm::APFloat::rmTowardZero);
8555 bool Ignored =
false;
8556 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8558 if (Result != ConvertBack)
8564 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8566 if (Bits > FloatPrec)
8579 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
8580 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
8583 assert(!isa<ExtVectorType>(VT) &&
8584 "ExtVectorTypes should not be handled here!");
8611 ScalarCast = CK_IntegralCast;
8617 llvm::APFloat Result(0.0);
8618 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
8620 if (!CstScalar && Order < 0)
8626 bool Truncated =
false;
8628 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8633 ScalarCast = CK_FloatingCast;
8638 ScalarCast = CK_IntegralToFloating;
8645 if (ScalarCast != CK_NoOp)
8655 bool AllowBoolConversions) {
8656 if (!IsCompAssign) {
8657 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
8661 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
8667 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
8668 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
8672 assert(LHSVecType || RHSVecType);
8676 if (!AllowBothBool &&
8679 return InvalidOperands(Loc, LHS, RHS);
8686 if (LHSVecType && RHSVecType &&
8688 if (isa<ExtVectorType>(LHSVecType)) {
8689 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8694 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8701 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8704 Context.
getTypeSize(RHSVecType->getElementType()))) {
8708 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8711 if (!IsCompAssign &&
8714 RHSVecType->getElementType()->isIntegerType()) {
8715 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8722 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8724 if (isa<ExtVectorType>(LHSVecType)) {
8735 if (isa<ExtVectorType>(RHSVecType)) {
8737 LHSType, RHSVecType->getElementType(),
8750 QualType VecType = LHSVecType ? LHSType : RHSType;
8751 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8752 QualType OtherType = LHSVecType ? RHSType : LHSType;
8753 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8754 if (isLaxVectorConversion(OtherType, VecType)) {
8758 if (!IsCompAssign) {
8759 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
8769 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
8777 if ((!RHSVecType && !RHSType->
isRealType()) ||
8779 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8780 << LHSType << RHSType
8781 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8789 if (getLangOpts().OpenCL &&
8790 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8791 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8792 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
8801 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
8802 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
8803 QualType Scalar = LHSVecType ? RHSType : LHSType;
8804 QualType Vector = LHSVecType ? LHSType : RHSType;
8805 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
8807 diag::err_typecheck_vector_not_convertable_implict_truncation)
8808 << ScalarOrVector << Scalar << Vector;
8815 << LHSType << RHSType
8816 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8828 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
8829 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
8831 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
8835 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8836 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8842 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8850 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8851 NonNullType->canDecayToPointerType())
8854 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8855 << LHSNull << NonNullType
8856 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8865 if (LUE->getKind() !=
UETT_SizeOf || LUE->isArgumentType() ||
8869 QualType LHSTy = LUE->getArgumentExpr()->IgnoreParens()->getType();
8872 if (RUE->isArgumentType())
8873 RHSTy = RUE->getArgumentType();
8875 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
8890 if (!RHS.
get()->isValueDependent() &&
8891 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) &&
8894 S.
PDiag(diag::warn_remainder_division_by_zero)
8895 << IsDiv << RHS.
get()->getSourceRange());
8900 bool IsCompAssign,
bool IsDiv) {
8903 if (LHS.
get()->getType()->isVectorType() ||
8904 RHS.
get()->getType()->isVectorType())
8905 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8906 getLangOpts().AltiVec,
8909 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8915 return InvalidOperands(Loc, LHS, RHS);
8927 if (LHS.
get()->getType()->isVectorType() ||
8928 RHS.
get()->getType()->isVectorType()) {
8929 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
8930 RHS.
get()->getType()->hasIntegerRepresentation())
8931 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8932 getLangOpts().AltiVec,
8934 return InvalidOperands(Loc, LHS, RHS);
8937 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8942 return InvalidOperands(Loc, LHS, RHS);
8951 ? diag::err_typecheck_pointer_arith_void_type
8952 : diag::ext_gnu_void_ptr)
8961 ? diag::err_typecheck_pointer_arith_void_type
8962 : diag::ext_gnu_void_ptr)
8972 Expr *Pointer,
bool IsGNUIdiom) {
8974 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
8977 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
8987 ? diag::err_typecheck_pointer_arith_function_type
8988 : diag::ext_gnu_ptr_func_arith)
9002 ? diag::err_typecheck_pointer_arith_function_type
9003 : diag::ext_gnu_ptr_func_arith)
9016 ResType = ResAtomicType->getValueType();
9021 diag::err_typecheck_arithmetic_incomplete_type,
9037 ResType = ResAtomicType->getValueType();
9069 if (!isLHSPointer && !isRHSPointer)
return true;
9071 QualType LHSPointeeTy, RHSPointeeTy;
9076 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
9081 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9089 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
9090 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
9091 if (isLHSVoidPtr || isRHSVoidPtr) {
9099 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
9100 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
9101 if (isLHSFuncPtr || isRHSFuncPtr) {
9123 Expr* IndexExpr = RHSExpr;
9126 IndexExpr = LHSExpr;
9129 bool IsStringPlusInt = StrExpr &&
9131 if (!IsStringPlusInt || IndexExpr->isValueDependent())
9135 Self.
Diag(OpLoc, diag::warn_string_plus_int)
9136 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
9139 if (IndexExpr == RHSExpr) {
9141 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9146 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9152 const Expr *StringRefExpr = LHSExpr;
9158 StringRefExpr = RHSExpr;
9161 if (!CharExpr || !StringRefExpr)
9178 if (!CharType->isAnyCharacterType() &&
9179 CharType->isIntegerType() &&
9181 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9182 << DiagRange << Ctx.
CharTy;
9184 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9185 << DiagRange << CharExpr->
getType();
9191 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9196 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9205 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
9216 if (LHS.
get()->getType()->isVectorType() ||
9217 RHS.
get()->getType()->isVectorType()) {
9218 QualType compType = CheckVectorOperands(
9219 LHS, RHS, Loc, CompLHSTy,
9220 getLangOpts().AltiVec,
9221 getLangOpts().ZVector);
9222 if (CompLHSTy) *CompLHSTy = compType;
9226 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9231 if (Opc == BO_Add) {
9238 if (CompLHSTy) *CompLHSTy = compType;
9248 isObjCPointer =
false;
9250 isObjCPointer =
true;
9252 std::swap(PExp, IExp);
9254 isObjCPointer =
false;
9256 isObjCPointer =
true;
9258 return InvalidOperands(Loc, LHS, RHS);
9263 if (!IExp->getType()->isIntegerType())
9264 return InvalidOperands(Loc, LHS, RHS);
9271 if (!getLangOpts().CPlusPlus ||
9272 (!IExp->isValueDependent() &&
9273 (!IExp->EvaluateAsInt(KnownVal, Context) ||
9277 Context, BO_Add, PExp, IExp);
9289 CheckArrayAccess(PExp, IExp);
9294 LHSTy = LHS.
get()->getType();
9310 if (LHS.
get()->getType()->isVectorType() ||
9311 RHS.
get()->getType()->isVectorType()) {
9312 QualType compType = CheckVectorOperands(
9313 LHS, RHS, Loc, CompLHSTy,
9314 getLangOpts().AltiVec,
9315 getLangOpts().ZVector);
9316 if (CompLHSTy) *CompLHSTy = compType;
9320 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9328 if (CompLHSTy) *CompLHSTy = compType;
9333 if (LHS.
get()->getType()->isAnyPointerType()) {
9334 QualType lpointee = LHS.
get()->getType()->getPointeeType();
9337 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9342 if (RHS.
get()->getType()->isIntegerType()) {
9346 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9350 if (!getLangOpts().CPlusPlus ||
9351 (!RHS.
get()->isValueDependent() &&
9352 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) ||
9362 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9365 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9366 return LHS.
get()->getType();
9400 if (ElementSize.
isZero()) {
9401 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9403 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9407 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9412 return InvalidOperands(Loc, LHS, RHS);
9417 return ET->getDecl()->isScoped();
9431 if (RHS.
get()->isValueDependent() ||
9432 !RHS.
get()->EvaluateAsInt(RHSResult, S.
Context))
9434 llvm::APSInt Right = RHSResult.
Val.
getInt();
9436 if (Right.isNegative()) {
9438 S.
PDiag(diag::warn_shift_negative)
9439 << RHS.
get()->getSourceRange());
9442 llvm::APInt LeftBits(Right.getBitWidth(),
9444 if (Right.uge(LeftBits)) {
9446 S.
PDiag(diag::warn_shift_gt_typewidth)
9447 << RHS.
get()->getSourceRange());
9458 if (LHS.
get()->isValueDependent() ||
9460 !LHS.
get()->EvaluateAsInt(LHSResult, S.
Context))
9462 llvm::APSInt Left = LHSResult.
Val.
getInt();
9468 S.
PDiag(diag::warn_shift_lhs_negative)
9469 << LHS.
get()->getSourceRange());
9473 llvm::APInt ResultBits =
9474 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9475 if (LeftBits.uge(ResultBits))
9477 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9478 Result = Result.shl(Right);
9483 Result.toString(HexResult, 16,
false,
true);
9489 if (LeftBits == ResultBits - 1) {
9490 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9491 << HexResult << LHSType
9492 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9496 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
9497 << HexResult.str() << Result.getMinSignedBits() << LHSType
9498 << Left.getBitWidth() << LHS.
get()->getSourceRange()
9499 << RHS.
get()->getSourceRange();
9508 !LHS.
get()->getType()->isVectorType()) {
9509 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
9510 << RHS.
get()->getType() << LHS.
get()->getType()
9511 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9515 if (!IsCompAssign) {
9535 if (!LHSEleType->isIntegerType()) {
9536 S.
Diag(Loc, diag::err_typecheck_expect_int)
9537 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
9541 if (!RHSEleType->isIntegerType()) {
9542 S.
Diag(Loc, diag::err_typecheck_expect_int)
9543 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
9551 if (LHSEleType != RHSEleType) {
9553 LHSEleType = RHSEleType;
9559 }
else if (RHSVecTy) {
9564 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9565 << LHS.
get()->getType() << RHS.
get()->getType()
9566 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9572 if (LHSBT != RHSBT &&
9574 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9575 << LHS.
get()->getType() << RHS.
get()->getType()
9576 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9592 bool IsCompAssign) {
9596 if (LHS.
get()->getType()->isVectorType() ||
9597 RHS.
get()->getType()->isVectorType()) {
9598 if (LangOpts.ZVector) {
9602 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
9604 return InvalidOperands(Loc, LHS, RHS);
9605 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
9607 return InvalidOperands(Loc, LHS, RHS);
9618 LHS = UsualUnaryConversions(LHS.
get());
9622 if (IsCompAssign) LHS = OldLHS;
9625 RHS = UsualUnaryConversions(RHS.
get());
9633 return InvalidOperands(Loc, LHS, RHS);
9639 return InvalidOperands(Loc, LHS, RHS);
9672 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9673 << LHSStrippedType << RHSStrippedType
9681 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9682 : diag::ext_typecheck_comparison_of_distinct_pointers)
9683 << LHS.
get()->getType() << RHS.
get()->getType()
9684 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9724 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9725 : diag::ext_typecheck_comparison_of_fptr_to_void)
9726 << LHS.
get()->getType() << RHS.
get()->getType()
9727 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9731 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
9732 case Stmt::ObjCArrayLiteralClass:
9733 case Stmt::ObjCDictionaryLiteralClass:
9734 case Stmt::ObjCStringLiteralClass:
9735 case Stmt::ObjCBoxedExprClass:
9794 case Stmt::ObjCStringLiteralClass:
9797 case Stmt::ObjCArrayLiteralClass:
9800 case Stmt::ObjCDictionaryLiteralClass:
9802 return LK_Dictionary;
9803 case Stmt::BlockExprClass:
9805 case Stmt::ObjCBoxedExprClass: {
9806 Expr *Inner = cast<ObjCBoxedExpr>(FromE)->getSubExpr()->IgnoreParens();
9808 case Stmt::IntegerLiteralClass:
9809 case Stmt::FloatingLiteralClass:
9810 case Stmt::CharacterLiteralClass:
9811 case Stmt::ObjCBoolLiteralExprClass:
9812 case Stmt::CXXBoolLiteralExprClass:
9815 case Stmt::ImplicitCastExprClass: {
9816 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
9818 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
9837 Literal = LHS.
get();
9840 Literal = RHS.
get();
9856 llvm_unreachable(
"Unknown Objective-C object literal kind");
9860 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
9863 S.
Diag(Loc, diag::warn_objc_literal_comparison)
9873 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
9886 if (!UO || UO->
getOpcode() != UO_LNot)
return;
9889 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
9896 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
9898 << Loc << IsBitwiseOp;
9926 return DR->getDecl();
9928 if (Ivar->isFreeIvar())
9929 return Ivar->getDecl();
9931 if (
MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
9932 if (Mem->isImplicitAccess())
9933 return Mem->getMemberDecl();
9973 case BO_EQ:
case BO_LE:
case BO_GE:
9976 case BO_NE:
case BO_LT:
case BO_GT:
9980 Result =
"'std::strong_ordering::equal'";
9986 S.
PDiag(diag::warn_comparison_always)
9987 << 0 << !Result.empty()
9989 }
else if (DL && DR &&
10006 S.
PDiag(diag::warn_comparison_always)
10008 << !Result.empty() << Result);
10011 if (isa<CastExpr>(LHSStripped))
10013 if (isa<CastExpr>(RHSStripped))
10018 Expr *LiteralString =
nullptr;
10019 Expr *LiteralStringStripped =
nullptr;
10020 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
10023 LiteralString = LHS;
10024 LiteralStringStripped = LHSStripped;
10025 }
else if ((isa<StringLiteral>(RHSStripped) ||
10026 isa<ObjCEncodeExpr>(RHSStripped)) &&
10029 LiteralString = RHS;
10030 LiteralStringStripped = RHSStripped;
10033 if (LiteralString) {
10035 S.
PDiag(diag::warn_stringcompare)
10036 << isa<ObjCEncodeExpr>(LiteralStringStripped)
10048 llvm_unreachable(
"unhandled cast kind");
10050 case CK_UserDefinedConversion:
10052 case CK_LValueToRValue:
10054 case CK_ArrayToPointerDecay:
10056 case CK_FunctionToPointerDecay:
10058 case CK_IntegralCast:
10060 case CK_FloatingCast:
10062 case CK_IntegralToFloating:
10063 case CK_FloatingToIntegral:
10065 case CK_IntegralComplexCast:
10066 case CK_FloatingComplexCast:
10067 case CK_FloatingComplexToIntegralComplex:
10068 case CK_IntegralComplexToFloatingComplex:
10070 case CK_FloatingComplexToReal:
10071 case CK_FloatingRealToComplex:
10072 case CK_IntegralComplexToReal:
10073 case CK_IntegralRealToComplex:
10086 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10105 << PreNarrowingValue.getAsString(S.
Context, PreNarrowingType) << ToType;
10113 << 0 << FromType << ToType;
10118 llvm_unreachable(
"unhandled case in switch");
10134 QualType LHSStrippedType = LHSStripped.
get()->getType();
10135 QualType RHSStrippedType = RHSStripped.
get()->getType();
10146 if (NumEnumArgs == 1) {
10148 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
10154 if (NumEnumArgs == 2) {
10163 LHSStrippedType->
getAs<
EnumType>()->getDecl()->getIntegerType();
10174 LHSType = RHSType = IntType;
10187 S, Type, LHS.
get(), LHSType, LHS.
get()->getBeginLoc());
10189 RHS.
get()->getBeginLoc());
10193 assert(!Type.
isNull() &&
"composite type for <=> has not been set");
10195 auto TypeKind = [&]() {
10197 if (CT->getElementType()->hasFloatingRepresentation())
10205 llvm_unreachable(
"other types are unimplemented");
10244 bool IsThreeWay = Opc == BO_Cmp;
10255 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
10256 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10259 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10263 LHS = DefaultLvalueConversion(LHS.
get());
10266 RHS = DefaultLvalueConversion(RHS.
get());
10274 if (LHS.
get()->getType()->isVectorType() ||
10275 RHS.
get()->getType()->isVectorType())
10276 return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);
10283 if ((LHSType->isArithmeticType() || LHSType->isEnumeralType()) &&
10294 auto computeResultTy = [&]() {
10304 return CheckComparisonCategoryType(
Kind, Loc);
10322 if (LHSIsNull != RHSIsNull)
10328 return InvalidOperands(Loc, LHS, RHS);
10332 if (!IsRelational && LHSIsNull != RHSIsNull) {
10333 bool IsEquality = Opc == BO_EQ;
10335 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
10336 RHS.
get()->getSourceRange());
10338 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
10339 LHS.
get()->getSourceRange());
10342 if ((LHSType->isIntegerType() && !LHSIsNull) ||
10346 }
else if (getLangOpts().CPlusPlus) {
10351 if (!IsRelational &&
10358 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
10360 if (isSFINAEContext())
10363 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10364 return computeResultTy();
10376 if ((
int)LHSType->isPointerType() + (int)RHSType->
isPointerType() >=
10377 (IsRelational ? 2 : 1) &&
10378 (!LangOpts.ObjCAutoRefCount || !(LHSType->isObjCObjectPointerType() ||
10382 return computeResultTy();
10384 }
else if (LHSType->isPointerType() &&
10398 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
10399 << LHSType << RHSType << LHS.
get()->getSourceRange()
10400 << RHS.
get()->getSourceRange();
10402 }
else if (!IsRelational &&
10406 && !LHSIsNull && !RHSIsNull)
10413 if (LCanPointeeTy != RCanPointeeTy) {
10415 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
10419 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10420 << LHSType << RHSType << 0
10421 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10426 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
10428 if (LHSIsNull && !RHSIsNull)
10429 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
10431 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
10433 return computeResultTy();
10440 if (!IsRelational && LHSIsNull && RHSIsNull) {
10441 if (LHSType->isNullPtrType()) {
10442 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10443 return computeResultTy();
10446 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10447 return computeResultTy();
10454 (LHSType->isObjCObjectPointerType() || LHSType->isBlockPointerType())) {
10455 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10456 return computeResultTy();
10458 if (!IsRelational && LHSType->isNullPtrType() &&
10460 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10461 return computeResultTy();
10464 if (IsRelational &&
10473 if (isa<FunctionDecl>(DC))
10475 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
10476 if (CTSD->isInStdNamespace() &&
10477 llvm::StringSwitch<bool>(CTSD->getName())
10478 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
10481 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10483 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10484 return computeResultTy();
10492 if (!IsRelational &&
10497 return computeResultTy();
10502 if (!IsRelational && LHSType->isBlockPointerType() &&
10507 if (!LHSIsNull && !RHSIsNull &&
10509 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10510 << LHSType << RHSType << LHS.
get()->getSourceRange()
10511 << RHS.
get()->getSourceRange();
10513 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10514 return computeResultTy();
10519 && ((LHSType->isBlockPointerType() && RHSType->
isPointerType())
10521 if (!LHSIsNull && !RHSIsNull) {
10524 || (LHSType->isPointerType() && LHSType->castAs<
PointerType>()
10526 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10527 << LHSType << RHSType << LHS.
get()->getSourceRange()
10528 << RHS.
get()->getSourceRange();
10530 if (LHSIsNull && !RHSIsNull)
10531 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10533 : CK_AnyPointerToBlockPointerCast);
10535 RHS = ImpCastExprToType(RHS.get(), LHSType,
10536 LHSType->isPointerType() ? CK_BitCast
10537 : CK_AnyPointerToBlockPointerCast);
10538 return computeResultTy();
10541 if (LHSType->isObjCObjectPointerType() ||
10547 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
10549 if (!LPtrToVoid && !RPtrToVoid &&
10554 if (LHSIsNull && !RHSIsNull) {
10556 if (getLangOpts().ObjCAutoRefCount)
10558 CCK_ImplicitConversion);
10559 LHS = ImpCastExprToType(E, RHSType,
10560 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10564 if (getLangOpts().ObjCAutoRefCount)
10565 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
10568 RHS = ImpCastExprToType(E, LHSType,
10569 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10571 return computeResultTy();
10573 if (LHSType->isObjCObjectPointerType() &&
10581 if (LHSIsNull && !RHSIsNull)
10582 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10584 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
10585 return computeResultTy();
10588 if (!IsRelational && LHSType->isBlockPointerType() &&
10590 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10591 CK_BlockPointerToObjCPointerCast);
10592 return computeResultTy();
10593 }
else if (!IsRelational &&
10594 LHSType->isBlockCompatibleObjCPointerType(Context) &&
10596 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10597 CK_BlockPointerToObjCPointerCast);
10598 return computeResultTy();
10601 if ((LHSType->isAnyPointerType() && RHSType->
isIntegerType()) ||
10603 unsigned DiagID = 0;
10604 bool isError =
false;
10605 if (LangOpts.DebuggerSupport) {
10608 }
else if ((LHSIsNull && LHSType->isIntegerType()) ||
10610 if (IsRelational) {
10611 isError = getLangOpts().CPlusPlus;
10613 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
10614 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
10617 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
10619 }
else if (IsRelational)
10620 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
10622 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
10626 << LHSType << RHSType << LHS.
get()->getSourceRange()
10627 << RHS.
get()->getSourceRange();
10632 if (LHSType->isIntegerType())
10633 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10634 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10636 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10637 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10638 return computeResultTy();
10642 if (!IsRelational && RHSIsNull
10643 && LHSType->isBlockPointerType() && RHSType->
isIntegerType()) {
10644 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10645 return computeResultTy();
10647 if (!IsRelational && LHSIsNull
10649 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10650 return computeResultTy();
10653 if (getLangOpts().OpenCLVersion >= 200) {
10654 if (LHSType->isClkEventT() && RHSType->
isClkEventT()) {
10655 return computeResultTy();
10658 if (LHSType->isQueueT() && RHSType->
isQueueT()) {
10659 return computeResultTy();
10662 if (LHSIsNull && RHSType->
isQueueT()) {
10663 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10664 return computeResultTy();
10667 if (LHSType->isQueueT() && RHSIsNull) {
10668 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10669 return computeResultTy();
10673 return InvalidOperands(Loc, LHS, RHS);
10685 if (isa<ExtVectorType>(VTy)) {
10695 "Unhandled vector element size in vector compare");
10712 "Unhandled vector element size in vector compare");
10726 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10728 getLangOpts().ZVector);
10736 if (getLangOpts().AltiVec &&
10748 assert(RHS.
get()->getType()->hasFloatingRepresentation());
10749 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
10753 return GetSignedVectorType(vType);
10760 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10764 return InvalidOperands(Loc, LHS, RHS);
10765 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
10767 return InvalidOperands(Loc, LHS, RHS);
10771 if (!getLangOpts().CPlusPlus &&
10773 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
10775 return GetSignedVectorType(LHS.
get()->getType());
10783 bool IsCompAssign =
10784 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
10786 if (LHS.
get()->getType()->isVectorType() ||
10787 RHS.
get()->getType()->isVectorType()) {
10788 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
10789 RHS.
get()->getType()->hasIntegerRepresentation())
10790 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
10792 getLangOpts().ZVector);
10793 return InvalidOperands(Loc, LHS, RHS);
10799 ExprResult LHSResult = LHS, RHSResult = RHS;
10800 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
10802 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
10804 LHS = LHSResult.
get();
10805 RHS = RHSResult.
get();
10809 return InvalidOperands(Loc, LHS, RHS);
10817 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
10818 return CheckVectorLogicalOperands(LHS, RHS, Loc);
10823 if (LHS.
get()->getType()->isIntegerType() &&
10824 !LHS.
get()->getType()->isBooleanType() &&
10825 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
10827 !Loc.
isMacroID() && !inTemplateInstantiation()) {
10833 if (RHS.
get()->EvaluateAsInt(EVResult, Context)) {
10834 llvm::APSInt Result = EVResult.
Val.
getInt();
10835 if ((getLangOpts().
Bool && !RHS.
get()->getType()->isBooleanType() &&
10836 !RHS.
get()->getExprLoc().isMacroID()) ||
10837 (Result != 0 && Result != 1)) {
10838 Diag(Loc, diag::warn_logical_instead_of_bitwise)
10839 << RHS.
get()->getSourceRange()
10840 << (Opc == BO_LAnd ?
"&&" :
"||");
10842 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
10843 << (Opc == BO_LAnd ?
"&" :
"|")
10845 Loc, getLocForEndOfToken(Loc)),
10846 Opc == BO_LAnd ?
"&" :
"|");
10847 if (Opc == BO_LAnd)
10849 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
10852 RHS.
get()->getEndLoc()));
10862 if (LHS.
get()->getType()->isFloatingType() ||
10863 RHS.
get()->getType()->isFloatingType())
10864 return InvalidOperands(Loc, LHS, RHS);
10867 LHS = UsualUnaryConversions(LHS.
get());
10871 RHS = UsualUnaryConversions(RHS.
get());
10875 if (!LHS.
get()->getType()->isScalarType() ||
10876 !RHS.
get()->getType()->isScalarType())
10877 return InvalidOperands(Loc, LHS, RHS);
10879 return Context.
IntTy;
10888 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
10890 return InvalidOperands(Loc, LHS, RHS);
10893 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
10895 return InvalidOperands(Loc, LHS, RHS);
10906 if (!ME)
return false;
10910 if (!Base)
return false;
10931 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
10939 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
10982 bool DiagnosticEmitted =
false;
10986 bool IsDereference =
false;
10987 bool NextIsDereference =
false;
10991 IsDereference = NextIsDereference;
10994 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
10995 NextIsDereference = ME->isArrow();
10996 const ValueDecl *VD = ME->getMemberDecl();
10997 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
10999 if (Field->isMutable()) {
11000 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
11005 if (!DiagnosticEmitted) {
11006 S.
Diag(Loc, diag::err_typecheck_assign_const)
11008 << Field->getType();
11009 DiagnosticEmitted =
true;
11012 <<
ConstMember <<
false << Field << Field->getType()
11013 << Field->getSourceRange();
11017 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
11018 if (VDecl->getType().isConstQualified()) {
11019 if (!DiagnosticEmitted) {
11020 S.
Diag(Loc, diag::err_typecheck_assign_const)
11022 << VDecl->getType();
11023 DiagnosticEmitted =
true;
11026 <<
ConstMember <<
true << VDecl << VDecl->getType()
11027 << VDecl->getSourceRange();
11034 dyn_cast<ArraySubscriptExpr>(E)) {
11038 dyn_cast<ExtVectorElementExpr>(E)) {
11045 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
11049 if (!DiagnosticEmitted) {
11050 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11052 DiagnosticEmitted =
true;
11055 diag::note_typecheck_assign_const)
11059 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11061 if (
const ValueDecl *VD = DRE->getDecl()) {
11063 if (!DiagnosticEmitted) {
11064 S.
Diag(Loc, diag::err_typecheck_assign_const)
11066 DiagnosticEmitted =
true;
11068 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
11069 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
11072 }
else if (isa<CXXThisExpr>(E)) {
11074 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
11075 if (MD->isConst()) {
11076 if (!DiagnosticEmitted) {
11077 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11079 DiagnosticEmitted =
true;
11081 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
11088 if (DiagnosticEmitted)
11092 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
11105 bool &DiagnosticEmitted) {
11106 std::vector<const RecordType *> RecordTypeList;
11107 RecordTypeList.push_back(Ty);
11108 unsigned NextToCheckIndex = 0;
11111 while (RecordTypeList.size() > NextToCheckIndex) {
11112 bool IsNested = NextToCheckIndex > 0;
11114 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
11116 QualType FieldTy = Field->getType();
11118 if (!DiagnosticEmitted) {
11119 S.
Diag(Loc, diag::err_typecheck_assign_const)
11121 << IsNested << Field;
11122 DiagnosticEmitted =
true;
11124 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
11126 << FieldTy << Field->getSourceRange();
11132 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
11133 RecordTypeList.push_back(FieldRecTy);
11136 ++NextToCheckIndex;
11145 assert(Ty->
isRecordType() &&
"lvalue was not record?");
11148 bool DiagEmitted =
false;
11150 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
11153 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11178 unsigned DiagID = 0;
11179 bool NeedType =
false;
11186 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
11188 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
11196 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
11209 ? diag::err_typecheck_arc_assign_self_class_method
11210 : diag::err_typecheck_arc_assign_self;
11213 }
else if (var->
hasAttr<ObjCExternallyRetainedAttr>() ||
11214 isa<ParmVarDecl>(var)) {
11215 DiagID = diag::err_typecheck_arc_assign_externally_retained;
11219 DiagID = diag::err_typecheck_arr_assign_enumeration;
11223 if (Loc != OrigLoc)
11249 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
11253 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
11257 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
11260 llvm_unreachable(
"did not take early return for MLV_Valid");
11264 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
11269 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
11271 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
11274 llvm_unreachable(
"readonly properties should be processed differently");
11276 DiagID = diag::err_readonly_message_assignment;
11279 DiagID = diag::err_no_subobject_property_setting;
11284 if (Loc != OrigLoc)
11309 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase())))
11314 cast<ValueDecl>(MR->getMemberDecl()->getCanonicalDecl());
11315 if (LHSDecl != RHSDecl)
11320 if (RefTy->getPointeeType().isVolatileQualified())
11323 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
11329 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
11332 if (RL && RR && RL->
getDecl() == RR->getDecl())
11333 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
11353 if (getLangOpts().OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
11355 Diag(Loc, diag::err_opencl_half_load_store) << 1
11361 if (CompoundType.
isNull()) {
11367 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
11371 if (ConvTy == IncompatiblePointer &&
11376 ConvTy = Compatible;
11378 if (ConvTy == Compatible &&
11380 Diag(Loc, diag::err_objc_object_assignment)
11387 RHSCheck = ICE->getSubExpr();
11388 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
11389 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
11390 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
11396 UO->getSubExpr()->getBeginLoc().
isFileID()) {
11397 Diag(Loc, diag::warn_not_compound_assign)
11398 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
11399 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
11403 if (ConvTy == Compatible) {
11411 checkRetainCycles(LHSExpr, RHS.
get());
11425 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11426 RHS.
get()->getBeginLoc()))
11427 getCurFunction()->markSafeWeakUse(RHS.
get());
11429 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
11430 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
11435 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
11438 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
11439 RHS.
get(), AA_Assigning))
11459 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
11460 if (CE->getCastKind() == CK_ToVoid) {
11466 CE->getSubExpr()->getType()->isDependentType()) {
11483 if (inTemplateInstantiation())
11493 const unsigned ForIncrementFlags =
11494 getLangOpts().C99 || getLangOpts().CPlusPlus
11498 const unsigned ScopeFlags = getCurScope()->getFlags();
11499 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
11500 (ScopeFlags & ForInitFlags) == ForInitFlags)
11505 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
11506 if (BO->getOpcode() != BO_Comma)
11508 LHS = BO->getRHS();
11515 Diag(Loc, diag::warn_comma_operator);
11519 LangOpts.CPlusPlus ?
"static_cast<void>(" 11549 if (!RHS.
get()->getType()->isVoidType())
11551 diag::err_incomplete_type);
11557 return RHS.
get()->getType();
11566 bool IsInc,
bool IsPrefix) {
11575 ResType = ResAtomicType->getValueType();
11577 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
11579 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
11587 : diag::warn_increment_bool)
11589 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
11591 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
11593 }
else if (ResType->isRealType()) {
11595 }
else if (ResType->isPointerType()) {
11599 }
else if (ResType->isObjCObjectPointerType()) {
11605 }
else if (ResType->isAnyComplexType()) {
11607 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
11609 }
else if (ResType->isPlaceholderType()) {
11614 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
11616 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
11617 (ResType->getAs<
VectorType>()->getVectorKind() !=
11620 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
11624 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
11641 return ResType.getUnqualifiedType();
11660 case Stmt::DeclRefExprClass:
11661 return cast<DeclRefExpr>(E)->getDecl();
11662 case Stmt::MemberExprClass:
11666 if (cast<MemberExpr>(E)->isArrow())
11670 case Stmt::ArraySubscriptExprClass: {
11673 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
11675 if (ICE->getSubExpr()->getType()->isArrayType())
11680 case Stmt::UnaryOperatorClass: {
11692 case Stmt::ParenExprClass:
11694 case Stmt::ImplicitCastExprClass:
11706 AO_Vector_Element = 1,
11707 AO_Property_Expansion = 2,
11708 AO_Register_Variable = 3,
11728 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
11729 if (PTy->getKind() == BuiltinType::Overload) {
11730 Expr *E = OrigOp.
get()->IgnoreParens();
11731 if (!isa<OverloadExpr>(E)) {
11732 assert(cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf);
11733 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
11734 << OrigOp.
get()->getSourceRange();
11739 if (isa<UnresolvedMemberExpr>(Ovl))
11740 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
11741 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11742 << OrigOp.
get()->getSourceRange();
11749 if (PTy->getKind() == BuiltinType::UnknownAny)
11752 if (PTy->getKind() == BuiltinType::BoundMember) {
11753 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11754 << OrigOp.
get()->getSourceRange();
11758 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
11762 if (OrigOp.
get()->isTypeDependent())
11765 assert(!OrigOp.
get()->getType()->isPlaceholderType());
11768 Expr *op = OrigOp.
get()->IgnoreParens();
11775 if (LangOpts.OpenCL) {
11777 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
11778 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
11783 if (getLangOpts().
C99) {
11786 if (uOp->getOpcode() == UO_Deref)
11789 return uOp->getSubExpr()->getType();
11796 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
11802 unsigned AddressOfError = AO_No_Error;
11805 bool sfinae = (
bool)isSFINAEContext();
11806 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
11807 : diag::ext_typecheck_addrof_temporary)
11813 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
11814 }
else if (isa<ObjCSelectorExpr>(op)) {
11821 if (!isa<DeclRefExpr>(op)) {
11822 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11823 << OrigOp.
get()->getSourceRange();
11830 if (OrigOp.
get() != DRE) {
11831 Diag(OpLoc, diag::err_parens_pointer_member_function)
11832 << OrigOp.
get()->getSourceRange();
11836 if (MD->getParent()->getName().empty())
11837 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11841 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
11842 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11849 if (isa<CXXDestructorDecl>(MD))
11856 (
void)isCompleteType(OpLoc, MPTy);
11863 if (isa<PseudoObjectExpr>(op)) {
11864 AddressOfError = AO_Property_Expansion;
11866 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
11873 AddressOfError = AO_Bit_Field;
11876 AddressOfError = AO_Vector_Element;
11880 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
11884 !getLangOpts().CPlusPlus) {
11885 AddressOfError = AO_Register_Variable;
11887 }
else if (isa<MSPropertyDecl>(dcl)) {
11888 AddressOfError = AO_Property_Expansion;
11889 }
else if (isa<FunctionTemplateDecl>(dcl)) {
11891 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
11895 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
11900 diag::err_cannot_form_pointer_to_member_of_reference_type)
11905 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
11913 (
void)isCompleteType(OpLoc, MPTy);
11917 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
11918 !isa<BindingDecl>(dcl))
11919 llvm_unreachable(
"Unknown/unexpected decl type");
11922 if (AddressOfError != AO_No_Error) {
11938 CheckAddressOfPackedMember(op);
11954 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
11957 if (!FD->ModifiedNonNullParams.count(Param))
11958 FD->ModifiedNonNullParams.insert(Param);
11968 if (ConvResult.isInvalid())
11970 Op = ConvResult.get();
11974 if (isa<CXXReinterpretCastExpr>(Op)) {
11990 if (PR.
get() != Op)
11995 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
12010 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
12026 default: llvm_unreachable(
"Unknown binop!");
12027 case tok::periodstar: Opc = BO_PtrMemD;
break;
12028 case tok::arrowstar: Opc = BO_PtrMemI;
break;
12029 case tok::star: Opc = BO_Mul;
break;
12030 case tok::slash: Opc = BO_Div;
break;
12031 case tok::percent: Opc = BO_Rem;
break;
12032 case tok::plus: Opc = BO_Add;
break;
12033 case tok::minus: Opc = BO_Sub;
break;
12034 case tok::lessless: Opc = BO_Shl;
break;
12035 case tok::greatergreater: Opc = BO_Shr;
break;
12036 case tok::lessequal: Opc = BO_LE;
break;
12037 case tok::less: Opc = BO_LT;
break;
12038 case tok::greaterequal: Opc = BO_GE;
break;
12039 case tok::greater: Opc = BO_GT;
break;
12040 case tok::exclaimequal: Opc = BO_NE;
break;
12041 case tok::equalequal: Opc = BO_EQ;
break;
12042 case tok::spaceship: Opc = BO_Cmp;
break;
12043 case tok::amp: Opc = BO_And;
break;
12044 case tok::caret: Opc = BO_Xor;
break;
12045 case tok::pipe: Opc = BO_Or;
break;
12046 case tok::ampamp: Opc = BO_LAnd;
break;
12047 case tok::pipepipe: Opc = BO_LOr;
break;
12048 case tok::equal: Opc = BO_Assign;
break;
12049 case tok::starequal: Opc = BO_MulAssign;
break;
12050 case tok::slashequal: Opc = BO_DivAssign;
break;
12051 case tok::percentequal: Opc = BO_RemAssign;
break;
12052 case tok::plusequal: Opc = BO_AddAssign;
break;
12053 case tok::minusequal: Opc = BO_SubAssign;
break;
12054 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
12055 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
12056 case tok::ampequal: Opc = BO_AndAssign;
break;
12057 case tok::caretequal: Opc = BO_XorAssign;
break;
12058 case tok::pipeequal: Opc = BO_OrAssign;
break;
12059 case tok::comma: Opc = BO_Comma;
break;
12068 default: llvm_unreachable(
"Unknown unary op!");
12069 case tok::plusplus: Opc = UO_PreInc;
break;
12070 case tok::minusminus: Opc = UO_PreDec;
break;
12071 case tok::amp: Opc = UO_AddrOf;
break;
12072 case tok::star: Opc = UO_Deref;
break;
12073 case tok::plus: Opc = UO_Plus;
break;
12074 case tok::minus: Opc = UO_Minus;
break;
12075 case tok::tilde: Opc = UO_Not;
break;
12076 case tok::exclaim: Opc = UO_LNot;
break;
12077 case tok::kw___real: Opc = UO_Real;
break;
12078 case tok::kw___imag: Opc = UO_Imag;
break;
12079 case tok::kw___extension__: Opc = UO_Extension;
break;
12098 if (!LHSDeclRef || !RHSDeclRef ||
12100 RHSDeclRef->getLocation().isMacroID())
12105 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
12106 if (LHSDecl != RHSDecl)
12111 if (RefTy->getPointeeType().isVolatileQualified())
12114 S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
12115 : diag::warn_self_assignment_overloaded)
12127 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
12132 ObjCPointerExpr = LHS;
12136 ObjCPointerExpr = RHS;
12144 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
12145 unsigned Diag = diag::warn_objc_pointer_masking;
12154 if (SelArg0.startswith(
"performSelector"))
12155 Diag = diag::warn_objc_pointer_masking_performSelector;
12158 S.
Diag(OpLoc, Diag)
12166 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
12167 return DRE->getDecl();
12168 if (
auto *ME = dyn_cast<MemberExpr>(E))
12169 return ME->getMemberDecl();
12170 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
12171 return IRE->getDecl();
12186 "Result must be a vector of half or short");
12189 "both operands expected to be a half vector");
12201 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
12202 OpLoc, FPFeatures);
12206 VK, OK, OpLoc, FPFeatures);
12210 static std::pair<ExprResult, ExprResult>
12220 if (Opc != BO_Assign)
12227 return std::make_pair(LHS, RHS);
12234 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
12245 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
12257 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
12260 RHSExpr = Init.
get();
12270 bool ConvertHalfVec =
false;
12273 if (!LHS.
isUsable() || !RHS.isUsable())
12276 if (getLangOpts().OpenCL) {
12283 if (BO_Assign == Opc)
12284 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
12286 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12296 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12303 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
12304 if (getLangOpts().CPlusPlus &&
12306 VK = LHS.
get()->getValueKind();
12307 OK = LHS.
get()->getObjectKind();
12309 if (!ResultTy.
isNull()) {
12311 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
12317 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
12318 Opc == BO_PtrMemI);
12322 ConvertHalfVec =
true;
12323 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
12327 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
12330 ConvertHalfVec =
true;
12331 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
12334 ConvertHalfVec =
true;
12335 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
12339 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
12345 ConvertHalfVec =
true;
12346 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12350 ConvertHalfVec =
true;
12351 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12354 ConvertHalfVec =
true;
12355 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12363 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12367 ConvertHalfVec =
true;
12368 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
12372 ConvertHalfVec =
true;
12373 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
12374 Opc == BO_DivAssign);
12375 CompLHSTy = CompResultTy;
12377 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12380 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
12381 CompLHSTy = CompResultTy;
12383 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12386 ConvertHalfVec =
true;
12387 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
12389 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12392 ConvertHalfVec =
true;
12393 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
12395 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12399 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
12400 CompLHSTy = CompResultTy;
12402 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12409 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12410 CompLHSTy = CompResultTy;
12412 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12416 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
12417 VK = RHS.get()->getValueKind();
12418 OK = RHS.get()->getObjectKind();
12431 "both sides are half vectors or neither sides are");
12433 LHS.
get()->getType());
12436 CheckArrayAccess(LHS.
get());
12437 CheckArrayAccess(RHS.get());
12439 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
12440 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
12441 &Context.
Idents.
get(
"object_setClass"),
12443 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
12444 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
12445 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign)
12447 "object_setClass(")
12453 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
12456 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
12460 if (CompResultTy.
isNull()) {
12461 if (ConvertHalfVec)
12463 OpLoc, FPFeatures);
12465 OK, OpLoc, FPFeatures);
12469 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
12472 OK = LHS.
get()->getObjectKind();
12475 if (ConvertHalfVec)
12477 OpLoc, FPFeatures);
12480 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
12481 OpLoc, FPFeatures);
12496 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
12497 if (isLeftComp == isRightComp)
12502 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
12503 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
12504 if (isLeftBitwise || isRightBitwise)
12510 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
12516 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
12519 Self.
PDiag(diag::note_precedence_silence) << OpStr,
12522 Self.
PDiag(diag::note_precedence_bitwise_first)
12537 Self.
PDiag(diag::note_precedence_silence)
12562 if (Bop->getOpcode() == BO_LAnd) {
12569 }
else if (Bop->getOpcode() == BO_LOr) {
12570 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
12573 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
12584 if (Bop->getOpcode() == BO_LAnd) {
12601 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
12602 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
12604 << Bop->getSourceRange() << OpLoc;
12606 S.
PDiag(diag::note_precedence_silence)
12607 << Bop->getOpcodeStr(),
12608 Bop->getSourceRange());
12616 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
12617 StringRef Op = Bop->getOpcodeStr();
12618 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
12619 << Bop->getSourceRange() << OpLoc << Shift << Op;
12621 S.
PDiag(diag::note_precedence_silence) << Op,
12622 Bop->getSourceRange());
12638 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
12641 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
12643 << (Kind == OO_LessLess);
12645 S.
PDiag(diag::note_precedence_silence)
12646 << (Kind == OO_LessLess ?
"<<" :
">>"),
12649 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
12663 if ((Opc == BO_Or || Opc == BO_Xor) &&
12671 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
12677 || Opc == BO_Shr) {
12694 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
12695 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
12700 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
12729 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
12745 LHSExpr = LHS.
get();
12746 RHSExpr = RHS.
get();
12757 if (pty->getKind() == BuiltinType::PseudoObject &&
12759 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
12762 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
12768 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12770 RHSExpr = resolvedRHS.
get();
12783 if (Opc == BO_LT && inTemplateInstantiation() &&
12784 (pty->getKind() == BuiltinType::BoundMember ||
12785 pty->getKind() == BuiltinType::Overload)) {
12787 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
12788 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
12789 return isa<FunctionTemplateDecl>(ND);
12791 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
12792 : OE->getNameLoc(),
12793 diag::err_template_kw_missing)
12794 << OE->getName().getAsString() <<
"";
12799 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
12801 LHSExpr = LHS.
get();
12808 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
12809 if (getLangOpts().CPlusPlus &&
12814 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12818 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
12822 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12824 RHSExpr = resolvedRHS.
get();
12841 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12861 bool CanOverflow =
false;
12863 bool ConvertHalfVec =
false;
12864 if (getLangOpts().OpenCL) {
12872 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12874 << Input.
get()->getSourceRange());
12884 Opc == UO_PreInc ||
12886 Opc == UO_PreInc ||
12891 resultType = CheckAddressOfOperand(Input, OpLoc);
12892 CheckAddressOfNoDeref(InputExpr);
12896 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
12903 CanOverflow = Opc == UO_Minus &&
12905 Input = UsualUnaryConversions(Input.get());
12906 if (Input.isInvalid())
return ExprError();
12915 if (ConvertHalfVec)
12917 resultType = Input.get()->getType();
12918 if (resultType->isDependentType())
12920 if (resultType->isArithmeticType())
12922 else if (resultType->isVectorType() &&
12925 resultType->getAs<
VectorType>()->getVectorKind() !=
12928 else if (getLangOpts().CPlusPlus &&
12930 resultType->isPointerType())
12933 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12934 << resultType << Input.get()->getSourceRange());
12937 Input = UsualUnaryConversions(Input.get());
12938 if (Input.isInvalid())
12940 resultType = Input.
get()->getType();
12942 if (resultType->isDependentType())
12945 if (resultType->isComplexType() || resultType->isComplexIntegerType())
12947 Diag(OpLoc, diag::ext_integer_complement_complex)
12948 << resultType << Input.get()->getSourceRange();
12949 else if (resultType->hasIntegerRepresentation())
12951 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
12956 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12957 << resultType << Input.get()->getSourceRange());
12959 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12960 << resultType << Input.get()->getSourceRange());
12966 Input = DefaultFunctionArrayLvalueConversion(Input.get());
12967 if (Input.isInvalid())
return ExprError();
12968 resultType = Input.
get()->getType();
12971 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
12972 Input = ImpCastExprToType(Input.get(), Context.
FloatTy, CK_FloatingCast).
get();
12973 resultType = Context.
FloatTy;
12976 if (resultType->isDependentType())
12983 Input = ImpCastExprToType(Input.get(), Context.
BoolTy,
12984 ScalarTypeToBooleanCastKind(resultType));
12989 if (!resultType->isIntegerType() && !resultType->isPointerType())
12990 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12991 << resultType << Input.get()->getSourceRange());
12993 }
else if (resultType->isExtVectorType()) {
13000 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13001 << resultType << Input.get()->getSourceRange());
13004 resultType = GetSignedVectorType(resultType);
13009 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13010 << resultType << Input.get()->getSourceRange());
13022 if (Input.isInvalid())
return ExprError();
13023 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
13024 if (Input.get()->getValueKind() !=
VK_RValue &&
13026 VK = Input.
get()->getValueKind();
13029 Input = DefaultLvalueConversion(Input.get());
13033 resultType = Input.get()->getType();
13034 VK = Input.get()->getValueKind();
13035 OK = Input.get()->getObjectKind();
13040 assert(!Input.get()->getType()->isDependentType() &&
13041 "the co_await expression must be non-dependant before " 13042 "building operator co_await");
13052 if (Opc != UO_AddrOf && Opc != UO_Deref)
13053 CheckArrayAccess(Input.
get());
13055 auto *UO =
new (Context)
13058 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
13059 !isa<ArrayType>(UO->getType().getDesugaredType(Context)))
13060 ExprEvalContexts.back().PossibleDerefs.insert(UO);
13063 if (ConvertHalfVec)
13072 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13073 if (!DRE->getQualifier())
13080 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
13083 return Method->isInstance();
13089 if (!ULE->getQualifier())
13094 if (Method->isInstance())
13114 if (pty->getKind() == BuiltinType::PseudoObject &&
13116 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
13119 if (Opc == UO_Extension)
13120 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13124 if (Opc == UO_AddrOf &&
13125 (pty->getKind() == BuiltinType::Overload ||
13126 pty->getKind() == BuiltinType::UnknownAny ||
13127 pty->getKind() == BuiltinType::BoundMember))
13128 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13131 ExprResult Result = CheckPlaceholderExpr(Input);
13133 Input = Result.
get();
13138 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
13146 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
13149 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
13152 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13178 if (!cleanups)
return nullptr;
13181 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
13194 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13201 DiscardCleanupsInEvaluationContext();
13202 PopExpressionEvaluationContext();
13208 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
13211 if (hasAnyUnrecoverableErrorsInThisFunction())
13212 DiscardCleanupsInEvaluationContext();
13213 assert(!Cleanup.exprNeedsCleanups() &&
13214 "cleanups within StmtExpr not correctly bound!");
13215 PopExpressionEvaluationContext();
13224 bool StmtExprMayBindToTemp =
false;
13230 LastLabelStmt =
Label;
13231 LastStmt =
Label->getSubStmt();
13234 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
13237 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
13240 Ty = LastExpr.
get()->getType().getUnqualifiedType();
13249 if (
Expr *rebuiltLastStmt
13251 LastExpr = rebuiltLastStmt;
13253 LastExpr = PerformCopyInitialization(
13260 if (LastExpr.
get() !=
nullptr) {
13261 if (!LastLabelStmt)
13265 StmtExprMayBindToTemp =
true;
13273 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
13274 if (StmtExprMayBindToTemp)
13275 return MaybeBindToTemporary(ResStmtExpr);
13276 return ResStmtExpr;
13291 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
13292 << ArgTy << TypeRange);
13297 && RequireCompleteType(BuiltinLoc, ArgTy,
13298 diag::err_offsetof_incomplete_type, TypeRange))
13301 bool DidWarnAboutNonPOD =
false;
13306 if (OC.isBrackets) {
13311 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
13317 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
13331 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
13332 Exprs.push_back(Idx);
13340 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
13346 if (RequireCompleteType(OC.LocStart, CurrentType,
13347 diag::err_offsetof_incomplete_type))
13353 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
13365 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
13367 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
13368 : diag::ext_offsetof_non_pod_type;
13370 if (!IsSafe && !DidWarnAboutNonPOD &&
13371 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
13373 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
13375 DidWarnAboutNonPOD =
true;
13379 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
13380 LookupQualifiedName(R, RD);
13385 MemberDecl = IndirectMemberDecl->getAnonField();
13390 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
13398 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
13406 if (IndirectMemberDecl)
13407 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
13412 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
13414 if (Paths.getDetectedVirtual()) {
13415 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
13426 if (IndirectMemberDecl) {
13427 for (
auto *FI : IndirectMemberDecl->chain()) {
13428 assert(isa<FieldDecl>(FI));
13430 cast<FieldDecl>(FI), OC.LocEnd));
13433 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
13439 Comps, Exprs, RParenLoc);
13450 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
13457 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
13465 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
13470 bool ValueDependent =
false;
13471 bool CondIsTrue =
false;
13474 ValueDependent =
true;
13477 llvm::APSInt condEval(32);
13479 = VerifyIntegerConstantExpression(CondExpr, &condEval,
13480 diag::err_typecheck_choose_expr_requires_constant,
false);
13483 CondExpr = CondICE.
get();
13484 CondIsTrue = condEval.getZExtValue();
13487 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
13489 resType = ActiveExpr->
getType();
13495 return new (Context)
13496 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
13508 if (LangOpts.CPlusPlus) {
13509 Decl *ManglingContextDecl;
13512 ManglingContextDecl)) {
13513 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
13518 PushBlockScope(CurScope, Block);
13519 CurContext->addDecl(Block);
13521 PushDeclContext(CurScope, Block);
13523 CurContext = Block;
13525 getCurBlock()->HasImplicitReturnType =
true;
13529 PushExpressionEvaluationContext(
13530 ExpressionEvaluationContext::PotentiallyEvaluated);
13536 "block-id should have no identifier!");
13540 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
13545 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
13558 "GetTypeForDeclarator made a non-function block signature");
13563 if ((ExplicitSignature =
13569 if (ExplicitSignature.getLocalRangeBegin() ==
13570 ExplicitSignature.getLocalRangeEnd()) {
13573 TypeLoc Result = ExplicitSignature.getReturnLoc();
13582 CurBlock->TheDecl->setSignatureAsWritten(Sig);
13583 CurBlock->FunctionType = T;
13588 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
13590 CurBlock->TheDecl->setIsVariadic(isVariadic);
13597 CurBlock->ReturnType = RetTy;
13598 CurBlock->TheDecl->setBlockMissingReturnType(
false);
13599 CurBlock->HasImplicitReturnType =
false;
13604 if (ExplicitSignature) {
13605 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
13606 ParmVarDecl *Param = ExplicitSignature.getParam(I);
13610 !getLangOpts().CPlusPlus)
13612 Params.push_back(Param);
13618 for (
const auto &I : Fn->param_types()) {
13621 Params.push_back(Param);
13626 if (!Params.empty()) {
13627 CurBlock->TheDecl->setParams(Params);
13628 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
13633 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
13636 for (
auto AI : CurBlock->TheDecl->parameters()) {
13637 AI->setOwningFunction(CurBlock->TheDecl);
13640 if (AI->getIdentifier()) {
13641 CheckShadow(CurBlock->TheScope, AI);
13643 PushOnScopeChains(AI, CurBlock->TheScope);
13652 DiscardCleanupsInEvaluationContext();
13653 PopExpressionEvaluationContext();
13657 PopFunctionScopeInfo();
13665 if (!LangOpts.Blocks)
13666 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
13669 if (hasAnyUnrecoverableErrorsInThisFunction())
13670 DiscardCleanupsInEvaluationContext();
13671 assert(!Cleanup.exprNeedsCleanups() &&
13672 "cleanups within block not correctly bound!");
13673 PopExpressionEvaluationContext();
13675 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
13679 deduceClosureReturnType(*BSI);
13687 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
13698 Captures.push_back(NewCap);
13707 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
13710 if (isa<FunctionNoProtoType>(FTy)) {
13737 DiagnoseUnusedParameters(BD->parameters());
13741 if (getCurFunction()->NeedsScopeChecking() &&
13742 !PP.isCodeCompletionEnabled())
13743 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
13745 BD->setBody(cast<CompoundStmt>(Body));
13747 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13748 DiagnoseUnguardedAvailabilityViolations(BD);
13754 !BD->isDependentContext())
13755 computeNRVO(Body, BSI);
13759 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
13766 Cleanup.setExprNeedsCleanups(
true);
13771 const VarDecl *var = CI.getVariable();
13773 setFunctionHasBranchProtectedScope();
13779 if (getCurFunction())
13780 getCurFunction()->addBlock(BD);
13788 GetTypeFromParser(Ty, &TInfo);
13789 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
13795 Expr *OrigExpr = E;
13799 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
13800 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
13802 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
13829 ExprResult Result = UsualUnaryConversions(E);
13833 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
13839 if (Init.isInvalid())
13841 E = Init.getAs<
Expr>();
13855 diag::err_first_argument_to_va_arg_not_of_type_va_list)
13860 diag::err_second_parameter_to_va_arg_incomplete,
13866 diag::err_second_parameter_to_va_arg_abstract,
13873 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
13874 : diag::warn_second_parameter_to_va_arg_not_pod)
13891 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
13898 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
13907 Ty = Context.
IntTy;
13913 llvm_unreachable(
"I don't know size of pointer!");
13921 if (!getLangOpts().ObjC)
13940 if (OV->getSourceExpr())
13949 Exp = BuildObjCStringLiteral(SL->
getBeginLoc(), SL).
get();
13955 const Expr *SrcExpr) {
13977 bool *Complained) {
13979 *Complained =
false;
13982 bool CheckInferredResultType =
false;
13984 unsigned DiagKind = 0;
13987 bool MayHaveConvFixit =
false;
13988 bool MayHaveFunctionDiff =
false;
13994 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
13998 DiagKind = diag::ext_typecheck_convert_pointer_int;
14000 MayHaveConvFixit =
true;
14003 DiagKind = diag::ext_typecheck_convert_int_pointer;
14005 MayHaveConvFixit =
true;
14007 case IncompatiblePointer:
14008 if (Action == AA_Passing_CFAudited)
14009 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
14012 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
14014 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
14018 if (Hint.
isNull() && !CheckInferredResultType) {
14021 else if (CheckInferredResultType) {
14025 MayHaveConvFixit =
true;
14027 case IncompatiblePointerSign:
14028 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
14030 case FunctionVoidPointer:
14031 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
14033 case IncompatiblePointerDiscardsQualifiers: {
14040 DiagKind = diag::err_typecheck_incompatible_address_space;
14044 DiagKind = diag::err_typecheck_incompatible_ownership;
14048 llvm_unreachable(
"unknown error case for discarding qualifiers!");
14051 case CompatiblePointerDiscardsQualifiers:
14062 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
14064 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
14066 case IncompatibleNestedPointerQualifiers:
14067 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
14069 case IntToBlockPointer:
14070 DiagKind = diag::err_int_to_block_pointer;
14072 case IncompatibleBlockPointer:
14073 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
14075 case IncompatibleObjCQualifiedId: {
14079 for (
auto *srcProto : srcOPT->
quals()) {
14085 IFace = IFaceT->getDecl();
14090 for (
auto *dstProto : dstOPT->
quals()) {
14096 IFace = IFaceT->getDecl();
14098 DiagKind = diag::warn_incompatible_qualified_id;
14101 case IncompatibleVectors:
14102 DiagKind = diag::warn_incompatible_vectors;
14104 case IncompatibleObjCWeakRef:
14105 DiagKind = diag::err_arc_weak_unavailable_assign;
14110 *Complained =
true;
14114 DiagKind = diag::err_typecheck_convert_incompatible;
14116 MayHaveConvFixit =
true;
14118 MayHaveFunctionDiff =
true;
14125 case AA_Initializing:
14127 FirstType = DstType;
14128 SecondType = SrcType;
14133 case AA_Passing_CFAudited:
14134 case AA_Converting:
14138 FirstType = SrcType;
14139 SecondType = DstType;
14144 if (Action == AA_Passing_CFAudited)
14145 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
14147 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
14151 if (!ConvHints.
isNull()) {
14157 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
14159 if (MayHaveFunctionDiff)
14160 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
14163 if (DiagKind == diag::warn_incompatible_qualified_id &&
14165 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
14172 if (CheckInferredResultType)
14173 EmitRelatedResultTypeNote(SrcExpr);
14175 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
14176 EmitRelatedResultTypeNoteForReturn(DstType);
14179 *Complained =
true;
14184 llvm::APSInt *Result) {
14188 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
14192 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
14196 llvm::APSInt *Result,
14203 IDDiagnoser(
unsigned DiagID)
14207 S.
Diag(Loc, DiagID) << SR;
14209 } Diagnoser(DiagID);
14211 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
14216 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
14234 CXX11ConvertDiagnoser(
bool Silent)
14240 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
14245 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
14250 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
14261 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
14272 llvm_unreachable(
"conversion functions are permitted");
14274 } ConvertDiagnoser(Diagnoser.
Suppress);
14276 Converted = PerformContextualImplicitConversion(DiagLoc, E,
14280 E = Converted.
get();
14290 if (!isa<ConstantExpr>(E))
14303 EvalResult.
Diag = &Notes;
14313 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
14322 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14323 diag::note_invalid_subexpr_in_const_expr) {
14324 DiagLoc = Notes[0].first;
14328 if (!Folded || !AllowFold) {
14332 Diag(Note.first, Note.second);
14340 Diag(Note.first, Note.second);
14350 class TransformToPE :
public TreeTransform<TransformToPE> {
14354 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
14357 bool AlwaysRebuild() {
return true; }
14364 return BaseTransform::TransformLabelStmt(S);
14375 if (isa<FieldDecl>(E->
getDecl()) &&
14378 diag::err_invalid_non_static_member_use)
14381 return BaseTransform::TransformDeclRefExpr(E);
14389 return BaseTransform::TransformUnaryOperator(E);
14400 assert(isUnevaluatedContext() &&
14401 "Should only transform unevaluated expressions");
14402 ExprEvalContexts.back().Context =
14403 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
14404 if (isUnevaluatedContext())
14406 return TransformToPE(*this).TransformExpr(E);
14413 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
14414 LambdaContextDecl, ExprContext);
14416 if (!MaybeODRUseExprs.empty())
14417 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
14424 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
14425 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
14432 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
14433 if (E->getOpcode() == UO_Deref)
14434 return CheckPossibleDeref(S, E->getSubExpr());
14435 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
14436 return CheckPossibleDeref(S, E->getBase());
14437 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
14438 return CheckPossibleDeref(S, E->getBase());
14439 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
14445 Inner = Arr->getElementType();
14449 if (Inner->
hasAttr(attr::NoDeref))
14459 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
14466 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
14486 D = diag::err_lambda_unevaluated_operand;
14492 D = diag::err_lambda_in_constant_expression;
14493 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
14496 D = diag::err_lambda_in_invalid_context;
14498 llvm_unreachable(
"Couldn't infer lambda error message.");
14500 for (
const auto *L : Rec.
Lambdas)
14501 Diag(L->getBeginLoc(), D);
14505 for (
auto *Lambda : Rec.
Lambdas) {
14506 for (
auto *C : Lambda->capture_inits())
14507 MarkDeclarationsReferencedInExpr(C);
14512 WarnOnPendingNoDerefs(Rec);
14520 ExprCleanupObjects.end());
14522 CleanupVarDeclMarking();
14532 ExprEvalContexts.pop_back();
14535 ExprEvalContexts.back().NumTypos += NumTypos;
14539 ExprCleanupObjects.erase(
14540 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
14541 ExprCleanupObjects.end());
14543 MaybeODRUseExprs.clear();
14547 ExprResult Result = CheckPlaceholderExpr(E);
14553 return TransformToPotentiallyEvaluated(E);
14579 llvm_unreachable(
"Invalid context");
14604 llvm_unreachable(
"Invalid context");
14616 bool MightBeOdrUse) {
14617 assert(Func &&
"No function?");
14639 bool NeedDefinition =
14648 if (NeedDefinition &&
14651 checkSpecializationVisibility(Loc, Func);
14664 ResolveExceptionSpec(Loc, FPT);
14668 if ((Func->
isUsed(
false) || !OdrUse) &&
14669 (!NeedDefinition || Func->
getBody()))
14674 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
14675 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
14676 if (Constructor->isDefaultConstructor()) {
14677 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
14679 DefineImplicitDefaultConstructor(Loc, Constructor);
14680 }
else if (Constructor->isCopyConstructor()) {
14681 DefineImplicitCopyConstructor(Loc, Constructor);
14682 }
else if (Constructor->isMoveConstructor()) {
14683 DefineImplicitMoveConstructor(Loc, Constructor);
14685 }
else if (Constructor->getInheritedConstructor()) {
14686 DefineInheritingConstructor(Loc, Constructor);
14689 dyn_cast<CXXDestructorDecl>(Func)) {
14690 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
14691 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
14692 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
14694 DefineImplicitDestructor(Loc, Destructor);
14696 if (Destructor->isVirtual() && getLangOpts().AppleKext)
14697 MarkVTableUsed(Loc, Destructor->getParent());
14698 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
14699 if (MethodDecl->isOverloadedOperator() &&
14700 MethodDecl->getOverloadedOperator() == OO_Equal) {
14701 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
14702 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
14703 if (MethodDecl->isCopyAssignmentOperator())
14704 DefineImplicitCopyAssignment(Loc, MethodDecl);
14705 else if (MethodDecl->isMoveAssignmentOperator())
14706 DefineImplicitMoveAssignment(Loc, MethodDecl);
14708 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
14709 MethodDecl->getParent()->isLambda()) {
14711 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
14713 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
14715 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
14716 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
14717 MarkVTableUsed(Loc, MethodDecl->getParent());
14722 if (CurContext == Func)
return;
14729 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
14730 if (FirstInstantiation) {
14731 PointOfInstantiation = Loc;
14737 PointOfInstantiation = Loc;
14744 CodeSynthesisContexts.size())
14745 PendingLocalImplicitInstantiations.push_back(
14746 std::make_pair(Func, PointOfInstantiation));
14751 InstantiateFunctionDefinition(PointOfInstantiation, Func);
14754 PendingInstantiations.push_back(std::make_pair(Func,
14755 PointOfInstantiation));
14757 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
14762 for (
auto i : Func->
redecls()) {
14763 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
14764 MarkFunctionReferenced(Loc, i, OdrUse);
14768 if (!OdrUse)
return;
14772 if (mightHaveNonExternalLinkage(Func))
14775 !LangOpts.GNUInline &&
14778 else if (isExternalWithNoLinkageType(Func))
14793 if (isa<ParmVarDecl>(var) &&
14794 isa<TranslationUnitDecl>(VarDC))
14807 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
14809 if (isa<CXXMethodDecl>(VarDC) &&
14810 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
14812 }
else if (isa<FunctionDecl>(VarDC)) {
14814 }
else if (isa<BlockDecl>(VarDC)) {
14818 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
14819 << var << ValueKind << ContextKind << VarDC;
14829 bool &SubCapturesAreNested,
14835 SubCapturesAreNested =
true;
14848 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
14849 !(isa<CapturedRegionScopeInfo>(CSI) &&
14850 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
14861 const bool Diagnose,
Sema &S) {
14876 const bool Diagnose,
Sema &S) {
14878 bool IsBlock = isa<BlockScopeInfo>(CSI);
14879 bool IsLambda = isa<LambdaScopeInfo>(CSI);
14887 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
14896 S.
Diag(Loc, diag::err_ref_vm_type);
14905 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
14908 S.
Diag(Loc, diag::err_ref_flexarray_type);
14910 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
14918 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14921 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
14923 S.
Diag(Loc, diag::err_capture_block_variable)
14934 S.
Diag(Loc, diag::err_opencl_block_ref_block);
14944 const bool BuildAndDiagnose,
14949 Expr *CopyExpr =
nullptr;
14950 bool ByRef =
false;
14956 if (BuildAndDiagnose) {
14957 S.
Diag(Loc, diag::err_ref_array_type);
14966 if (BuildAndDiagnose) {
14967 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
14981 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
14983 if (AttrTy->getAttrKind() == attr::ObjCOwnership)
14987 Ty = AttrTy->getModifiedType();
14997 !IsObjCOwnershipAttributedType(PointeeTy)) {
14998 if (BuildAndDiagnose) {
15000 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
15001 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
15006 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
15015 DeclRefType = CaptureType;
15017 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
15024 if (isa<ParmVarDecl>(Var))
15041 CaptureType,
false),
15048 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
15051 CopyExpr = Result.
get();
15058 if (BuildAndDiagnose)
15059 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
15071 const bool BuildAndDiagnose,
15074 const bool RefersToCapturedVariable,
15093 CaptureType = DeclRefType;
15095 Expr *CopyExpr =
nullptr;
15096 if (BuildAndDiagnose) {
15119 if (BuildAndDiagnose)
15120 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
15132 bool RefersToCapturedVariable) {
15164 const bool BuildAndDiagnose,
15167 const bool RefersToCapturedVariable,
15170 const bool IsTopScope,
15174 bool ByRef =
false;
15208 if (!RefType->getPointeeType()->isFunctionType())
15214 if (BuildAndDiagnose) {
15215 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
15223 if (BuildAndDiagnose) {
15226 diag::err_capture_of_incomplete_type,
15231 diag::err_capture_of_abstract_type))
15237 if (BuildAndDiagnose)
15239 RefersToCapturedVariable);
15256 if (BuildAndDiagnose)
15257 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
15258 Loc, EllipsisLoc, CaptureType,
nullptr);
15266 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
15274 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
15275 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
15278 if (FunctionScopeIndexToStopAt) {
15279 unsigned FSIndex = FunctionScopes.size() - 1;
15280 while (FSIndex != MaxFunctionScopesIndex) {
15289 if (VarDC == DC)
return true;
15294 if (IsGlobal && !(LangOpts.OpenMP && isOpenMPCapturedDecl(Var)))
15306 CaptureType = Var->
getType();
15308 bool Nested =
false;
15309 bool Explicit = (Kind != TryCapture_Implicit);
15310 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
15323 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
15344 if (BuildAndDiagnose) {
15367 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
15368 QTy = PVD->getOriginalType();
15372 if (getLangOpts().OpenMP) {
15373 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
15378 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
15379 auto IsTargetCap = !IsOpenMPPrivateDecl &&
15380 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
15385 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
15387 if (IsTargetCap || IsOpenMPPrivateDecl) {
15388 Nested = !IsTargetCap;
15399 if (BuildAndDiagnose) {
15403 if (cast<LambdaScopeInfo>(CSI)->Lambda)
15404 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getBeginLoc(),
15405 diag::note_lambda_decl);
15421 FunctionScopesIndex--;
15424 }
while (!VarDC->
Equals(DC));
15431 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
15437 BuildAndDiagnose, CaptureType,
15438 DeclRefType, Nested, *
this))
15443 BuildAndDiagnose, CaptureType,
15444 DeclRefType, Nested, *
this))
15450 BuildAndDiagnose, CaptureType,
15451 DeclRefType, Nested, Kind, EllipsisLoc,
15452 I == N - 1, *
this))
15464 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
15466 DeclRefType,
nullptr);
15472 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15473 false, CaptureType,
15474 DeclRefType,
nullptr);
15482 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15483 false, CaptureType,
15484 DeclRefType,
nullptr))
15487 return DeclRefType;
15501 const VarDecl *DefVD =
nullptr;
15528 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
15529 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
15530 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
15531 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
15534 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
15539 Res = CorrectDelayedTyposInExpr(Res);
15548 UpdateMarkingForLValueToRValue(Res.
get());
15553 for (
Expr *E : MaybeODRUseExprs) {
15556 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
15557 Var = cast<VarDecl>(DRE->getDecl());
15558 Loc = DRE->getLocation();
15559 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
15560 Var = cast<VarDecl>(ME->getMemberDecl());
15561 Loc = ME->getMemberLoc();
15563 llvm_unreachable(
"Unexpected expression");
15570 MaybeODRUseExprs.clear();
15576 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
15577 "Invalid Expr argument to DoMarkVarDeclReferenced");
15583 bool UsableInConstantExpr =
15585 bool NeedDefinition =
15590 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
15591 "Can't instantiate a partial template specialization.");
15597 !isa<VarTemplateSpecializationDecl>(Var))
15608 bool TryInstantiating =
15612 if (TryInstantiating) {
15614 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
15615 if (FirstInstantiation) {
15616 PointOfInstantiation = Loc;
15620 bool InstantiationDependent =
false;
15621 bool IsNonDependent =
15627 if (IsNonDependent) {
15628 if (UsableInConstantExpr) {
15632 }
else if (FirstInstantiation ||
15633 isa<VarTemplateSpecializationDecl>(Var)) {
15640 .push_back(std::make_pair(Var, PointOfInstantiation));
15654 if (OdrUseContext && E &&
15661 }
else if (OdrUseContext) {
15669 const bool RefersToEnclosingScope =
15672 if (RefersToEnclosingScope) {
15685 assert(E &&
"Capture variable should be used in an expression.");
15702 Decl *D,
Expr *E,
bool MightBeOdrUse) {
15706 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
15722 bool IsVirtualCall = MD->
isVirtual() &&
15724 if (!IsVirtualCall)
15740 bool OdrUse =
true;
15742 if (Method->isVirtual() &&
15743 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
15756 bool MightBeOdrUse =
true;
15759 if (Method->isPure())
15760 MightBeOdrUse =
false;
15772 bool MightBeOdrUse) {
15773 if (MightBeOdrUse) {
15774 if (
auto *VD = dyn_cast<VarDecl>(D)) {
15775 MarkVariableReferenced(Loc, VD);
15779 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
15780 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
15807 bool MarkReferencedDecls::TraverseTemplateArgument(
15821 return Inherited::TraverseTemplateArgument(Arg);
15825 MarkReferencedDecls Marker(*
this, Loc);
15826 Marker.TraverseType(T);
15834 bool SkipLocalVariables;
15839 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
15840 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
15844 if (SkipLocalVariables) {
15846 if (VD->hasLocalStorage())
15855 Inherited::VisitMemberExpr(E);
15870 Inherited::VisitCXXNewExpr(E);
15878 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
15882 Inherited::VisitCXXDeleteExpr(E);
15887 Inherited::VisitCXXConstructExpr(E);
15895 Inherited::VisitImplicitCastExpr(E);
15909 bool SkipLocalVariables) {
15910 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
15931 switch (ExprEvalContexts.back().Context) {
15932 case ExpressionEvaluationContext::Unevaluated:
15933 case ExpressionEvaluationContext::UnevaluatedList:
15934 case ExpressionEvaluationContext::UnevaluatedAbstract:
15935 case ExpressionEvaluationContext::DiscardedStatement:
15939 case ExpressionEvaluationContext::ConstantEvaluated:
15943 case ExpressionEvaluationContext::PotentiallyEvaluated:
15944 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
15945 if (Statement && getCurFunctionOrMethodDecl()) {
15946 FunctionScopes.back()->PossiblyUnreachableDiags.
15956 if (
auto *VD = dyn_cast_or_null<VarDecl>(
15957 ExprEvalContexts.back().ManglingContextDecl)) {
15958 if (VD->isConstexpr() ||
15959 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
15979 if (ExprEvalContexts.back().ExprContext ==
15980 ExpressionEvaluationContextRecord::EK_Decltype) {
15981 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
15985 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
15991 : FD(FD), CE(CE) { }
15995 S.
Diag(Loc, diag::err_call_incomplete_return)
16000 S.
Diag(Loc, diag::err_call_function_incomplete_return)
16005 } Diagnoser(FD, CE);
16007 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
16018 unsigned diagnostic = diag::warn_condition_is_assignment;
16019 bool IsOrAssign =
false;
16022 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
16025 IsOrAssign = Op->getOpcode() == BO_OrAssign;
16029 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
16033 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
16034 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16038 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16041 Loc = Op->getOperatorLoc();
16043 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
16046 IsOrAssign = Op->getOperator() == OO_PipeEqual;
16047 Loc = Op->getOperatorLoc();
16049 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
16059 Diag(Loc, diag::note_condition_assign_silence)
16064 Diag(Loc, diag::note_condition_or_assign_to_comparison)
16067 Diag(Loc, diag::note_condition_assign_to_comparison)
16085 if (opE->getOpcode() == BO_EQ &&
16086 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
16092 Diag(Loc, diag::note_equality_comparison_silence)
16095 Diag(Loc, diag::note_equality_comparison_to_assign)
16101 bool IsConstexpr) {
16102 DiagnoseAssignmentAsCondition(E);
16103 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
16104 DiagnoseEqualityWithExtraParens(parenE);
16106 ExprResult result = CheckPlaceholderExpr(E);
16111 if (getLangOpts().CPlusPlus)
16112 return CheckCXXBooleanCondition(E, IsConstexpr);
16114 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
16121 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
16139 case ConditionKind::Boolean:
16140 Cond = CheckBooleanCondition(Loc, SubExpr);
16143 case ConditionKind::ConstexprIf:
16144 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
16147 case ConditionKind::Switch:
16148 Cond = CheckSwitchCondition(Loc, SubExpr);
16152 return ConditionError();
16156 if (!FullExpr.
get())
16157 return ConditionError();
16160 CK == ConditionKind::ConstexprIf);
16166 struct RebuildUnknownAnyFunction
16167 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
16171 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
16174 llvm_unreachable(
"unexpected statement!");
16178 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
16185 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16186 ExprResult SubResult = Visit(E->getSubExpr());
16189 Expr *SubExpr = SubResult.
get();
16190 E->setSubExpr(SubExpr);
16191 E->setType(SubExpr->
getType());
16198 return rebuildSugarExpr(E);
16202 return rebuildSugarExpr(E);
16209 Expr *SubExpr = SubResult.
get();
16218 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
16223 if (S.getLangOpts().CPlusPlus &&
16224 !(isa<CXXMethodDecl>(VD) &&
16225 cast<CXXMethodDecl>(VD)->isInstance()))
16236 return resolveDecl(E, E->
getDecl());
16244 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
16254 struct RebuildUnknownAnyExpr
16255 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
16263 : S(S), DestType(CastType) {}
16266 llvm_unreachable(
"unexpected statement!");
16270 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
16280 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16281 ExprResult SubResult = Visit(E->getSubExpr());
16283 Expr *SubExpr = SubResult.
get();
16284 E->setSubExpr(SubExpr);
16285 E->setType(SubExpr->
getType());
16292 return rebuildSugarExpr(E);
16296 return rebuildSugarExpr(E);
16334 return resolveDecl(E, E->
getDecl());
16345 FK_FunctionPointer,
16352 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
16353 Kind = FK_MemberFunction;
16357 Kind = FK_FunctionPointer;
16360 Kind = FK_BlockPointer;
16365 if (DestType->isArrayType() || DestType->isFunctionType()) {
16366 unsigned diagID = diag::err_func_returning_array_function;
16367 if (Kind == FK_BlockPointer)
16368 diagID = diag::err_block_returning_array_function;
16371 << DestType->isFunctionType() << DestType;
16404 if (ParamTypes.empty() && Proto->isVariadic()) {
16406 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
16414 ArgTypes.push_back(ArgType);
16416 ParamTypes = ArgTypes;
16419 Proto->getExtProtoInfo());
16427 case FK_MemberFunction:
16431 case FK_FunctionPointer:
16435 case FK_BlockPointer:
16441 ExprResult CalleeResult = Visit(CalleeExpr);
16451 if (DestType->isArrayType() || DestType->isFunctionType()) {
16452 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
16453 << DestType->isFunctionType() << DestType;
16460 Method->setReturnType(DestType);
16464 E->
setType(DestType.getNonReferenceType());
16472 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
16479 DestType = DestType->castAs<
PointerType>()->getPointeeType();
16486 }
else if (E->
getCastKind() == CK_LValueToRValue) {
16490 assert(isa<BlockPointerType>(E->
getType()));
16503 llvm_unreachable(
"Unhandled cast type!");
16536 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
16539 FD->getDeclContext(),
16540 Loc, Loc, FD->getNameInfo().getName(),
16541 DestType, FD->getTypeSourceInfo(),
16543 FD->hasPrototype(),
16546 if (FD->getQualifier())
16550 for (
const auto &AI : FT->param_types()) {
16554 Params.push_back(Param);
16556 NewFD->setParams(Params);
16557 DRE->setDecl(NewFD);
16558 VD = DRE->getDecl();
16563 if (MD->isInstance()) {
16573 }
else if (isa<VarDecl>(VD)) {
16577 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
16605 diag::err_typecheck_cast_to_incomplete))
16609 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
16612 CastExpr = result.
get();
16614 CastKind = CK_NoOp;
16620 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
16629 ExprResult result = DefaultArgumentPromotion(arg);
16631 paramType = result.
get()->getType();
16643 return PerformCopyInitialization(entity, callLoc, arg);
16648 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
16651 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
16652 E = call->getCallee();
16653 diagID = diag::err_uncasted_call_of_unknown_any;
16661 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
16662 loc = ref->getLocation();
16663 d = ref->getDecl();
16664 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
16665 loc = mem->getMemberLoc();
16666 d = mem->getMemberDecl();
16668 diagID = diag::err_uncasted_call_of_unknown_any;
16669 loc = msg->getSelectorStartLoc();
16670 d = msg->getMethodDecl();
16672 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
16673 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
16696 ExprResult Result = CorrectDelayedTyposInExpr(E);
16702 if (!placeholderType)
return E;
16704 switch (placeholderType->
getKind()) {
16707 case BuiltinType::Overload: {
16711 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
16717 if (resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
16721 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
16727 case BuiltinType::BoundMember: {
16732 if (isa<CXXPseudoDestructorExpr>(BME)) {
16733 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
16734 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
16735 if (ME->getMemberNameInfo().getName().getNameKind() ==
16737 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
16739 tryToRecoverWithCall(result, PD,
16745 case BuiltinType::ARCUnbridgedCast: {
16746 Expr *realCast = stripARCUnbridgedCast(E);
16747 diagnoseARCUnbridgedCast(realCast);
16752 case BuiltinType::UnknownAny:
16756 case BuiltinType::PseudoObject:
16757 return checkPseudoObjectRValue(E);
16759 case BuiltinType::BuiltinFn: {
16763 auto *FD = cast<FunctionDecl>(DRE->getDecl());
16764 if (FD->getBuiltinID() == Builtin::BI__noop) {
16766 CK_BuiltinFnToFnPtr)
16778 case BuiltinType::OMPArraySection:
16783 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 16784 case BuiltinType::Id: 16785 #include "clang/Basic/OpenCLImageTypes.def" 16786 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 16787 case BuiltinType::Id: 16788 #include "clang/Basic/OpenCLExtensionTypes.def" 16789 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 16790 #define PLACEHOLDER_TYPE(Id, SingletonId) 16791 #include "clang/AST/BuiltinTypes.def" 16795 llvm_unreachable(
"invalid placeholder type!");
16809 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
16810 "Unknown Objective-C Boolean value!");
16815 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
16823 return new (Context)
16831 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
16833 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
16835 return Spec.getPlatform() == Platform;
16838 VersionTuple Version;
16839 if (Spec != AvailSpecs.end())
16840 Version = Spec->getVersion();
16844 if (getCurFunctionOrMethodDecl())
16845 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
16846 else if (getCurBlock() || getCurLambda())
16847 getCurFunction()->HasPotentialAvailabilityViolations =
true;
16849 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...
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)