46 #include "llvm/Support/ConvertUTF.h" 47 using namespace clang;
54 if (ParsingInitForAutoVars.count(D))
64 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
79 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
82 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
83 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
85 if (DC && !DC->
hasAttr<UnusedAttr>())
97 if (Method && Method->isDeleted() && Method->isDefaulted()) {
99 if (!Method->isImplicit())
105 if (CSM != CXXInvalid)
106 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
112 if (Ctor && Ctor->isInheritingConstructor())
113 return NoteDeletedInheritingConstructor(Ctor);
123 if (I->getStorageClass() !=
SC_None)
168 if (!DowngradeWarning && UsedFn)
171 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
172 : diag::ext_internal_in_extern_inline)
177 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
187 Diag(DeclBegin, diag::note_convert_inline_to_static)
206 bool ObjCPropertyAccess,
207 bool AvoidPartialAvailabilityChecks) {
208 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
212 if (Pos != SuppressedDiagnostics.end()) {
214 Diag(Suppressed.first, Suppressed.second);
225 if (cast<FunctionDecl>(D)->isMain())
226 Diag(Loc, diag::ext_main_used);
230 if (ParsingInitForAutoVars.count(D)) {
231 if (isa<BindingDecl>(D)) {
232 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
235 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
236 << D->
getDeclName() << cast<VarDecl>(D)->getType();
243 if (FD->isDeleted()) {
245 if (Ctor && Ctor->isInheritingConstructor())
246 Diag(Loc, diag::err_deleted_inherited_ctor_use)
248 << Ctor->getInheritedConstructor().getConstructor()->getParent();
250 Diag(Loc, diag::err_deleted_function_use);
251 NoteDeletedFunction(FD);
257 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
258 DeduceReturnType(FD, Loc))
261 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
265 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
267 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
272 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
274 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
283 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
285 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
286 << getCurFunction()->HasOMPDeclareReductionCombiner;
291 DiagnoseAvailabilityOfDecl(D, Loc, UnknownObjCClass, ObjCPropertyAccess,
292 AvoidPartialAvailabilityChecks);
307 return ": " + Message;
309 return std::string();
318 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
323 unsigned numFormalParams;
327 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
330 numFormalParams = MD->param_size();
331 calleeType = CT_Method;
332 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
333 numFormalParams = FD->param_size();
334 calleeType = CT_Function;
335 }
else if (isa<VarDecl>(D)) {
341 calleeType = CT_Function;
344 calleeType = CT_Block;
350 numFormalParams = proto->getNumParams();
362 unsigned nullPos = attr->getNullPos();
363 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
364 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
367 unsigned numArgsAfterSentinel = attr->getSentinel();
371 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
378 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
379 if (!sentinelExpr)
return;
388 = getLocForEndOfToken(sentinelExpr->
getLocEnd());
389 std::string NullValue;
390 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
392 else if (getLangOpts().CPlusPlus11)
393 NullValue =
"nullptr";
394 else if (PP.isMacroDefined(
"NULL"))
397 NullValue =
"(void*) 0";
400 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
402 Diag(MissingNilLoc, diag::warn_missing_sentinel)
426 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
430 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
435 CK_FunctionToPointerDecay).
get();
448 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
450 CK_ArrayToPointerDecay).
get();
462 if (UO->getOpcode() == UO_Deref &&
463 UO->getSubExpr()->IgnoreParenCasts()->
465 !UO->getType().isVolatileQualified()) {
467 S.
PDiag(diag::warn_indirection_through_null)
468 << UO->getSubExpr()->getSourceRange());
470 S.
PDiag(diag::note_indirection_through_null));
483 if (!Member || !Member->
isStr(
"isa"))
493 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
501 if (ObjectSetClass) {
544 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
548 if (getLangOpts().CPlusPlus &&
563 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
572 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
579 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
604 UpdateMarkingForLValueToRValue(E);
609 Cleanup.setExprNeedsCleanups(
true);
618 T = Atomic->getValueType().getUnqualifiedType();
627 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
630 Res = DefaultLvalueConversion(Res.
get());
645 CK_FunctionToPointerDecay).
get();
649 Res = DefaultLvalueConversion(Res.
get());
662 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
668 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
671 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
672 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
693 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
698 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
711 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
723 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
724 BTy->
getKind() == BuiltinType::Float)) {
725 if (getLangOpts().OpenCL &&
726 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
727 if (BTy->
getKind() == BuiltinType::Half) {
728 E = ImpCastExprToType(E, Context.
FloatTy, CK_FloatingCast).get();
731 E = ImpCastExprToType(E, Context.
DoubleTy, CK_FloatingCast).get();
789 if (!Record->hasNonTrivialCopyConstructor() &&
790 !Record->hasNonTrivialMoveConstructor() &&
791 !Record->hasNonTrivialDestructor())
792 return VAK_ValidInCXX11;
800 if (getLangOpts().MSVCCompat)
801 return VAK_MSVCUndefined;
805 return VAK_Undefined;
815 case VAK_ValidInCXX11:
818 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
826 PDiag(diag::warn_pass_class_arg_to_vararg)
827 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
832 case VAK_MSVCUndefined:
835 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
836 << getLangOpts().CPlusPlus11 << Ty << CT);
843 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
847 << isa<InitListExpr>(E) << Ty << CT;
858 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
859 (CT == VariadicMethod ||
860 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
861 E = stripARCUnbridgedCast(E);
872 ExprResult ExprRes = DefaultArgumentPromotion(E);
879 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
886 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
906 diag::err_call_incomplete_argument))
923 if (SkipCast)
return false;
925 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
928 CK_FloatingRealToComplex);
932 CK_IntegralComplexToFloatingComplex);
965 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
966 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
968 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
970 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
983 }
else if (Order > 0) {
998 bool ConvertFloat,
bool ConvertInt) {
1003 CK_IntegralToFloating);
1014 CK_IntegralComplexToFloatingComplex);
1019 CK_FloatingRealToComplex);
1028 QualType RHSType,
bool IsCompAssign) {
1034 if (LHSFloat && RHSFloat) {
1041 assert(order < 0 &&
"illegal float comparison");
1075 "The remaining types must be floating point types.");
1080 QualType LHSElemType = LHSComplex ?
1081 LHSComplex->getElementType() : LHSType;
1082 QualType RHSElemType = RHSComplex ?
1099 return Float128AndLongDouble &&
1101 &llvm::APFloat::IEEEdouble());
1115 CK_IntegralComplexCast);
1121 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1124 QualType RHSType,
bool IsCompAssign) {
1129 if (LHSSigned == RHSSigned) {
1132 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1134 }
else if (!IsCompAssign)
1135 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1137 }
else if (order != (LHSSigned ? 1 : -1)) {
1141 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1143 }
else if (!IsCompAssign)
1144 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1151 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1153 }
else if (!IsCompAssign)
1154 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1163 RHS = (*doRHSCast)(S, RHS.
get(), result);
1165 LHS = (*doLHSCast)(S, LHS.
get(), result);
1175 bool IsCompAssign) {
1179 if (LHSComplexInt && RHSComplexInt) {
1183 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1184 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1186 return S.Context.getComplexType(ScalarType);
1189 if (LHSComplexInt) {
1192 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1193 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1195 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1196 CK_IntegralRealToComplex);
1201 assert(RHSComplexInt);
1205 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1206 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1210 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1211 CK_IntegralRealToComplex);
1220 bool IsCompAssign) {
1221 if (!IsCompAssign) {
1222 LHS = UsualUnaryConversions(LHS.
get());
1227 RHS = UsualUnaryConversions(RHS.
get());
1240 LHSType = AtomicLHS->getValueType();
1243 if (LHSType == RHSType)
1252 QualType LHSUnpromotedType = LHSType;
1256 if (!LHSBitfieldPromoteTy.
isNull())
1257 LHSType = LHSBitfieldPromoteTy;
1258 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1259 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1262 if (LHSType == RHSType)
1288 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1289 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1302 Expr *ControllingExpr,
1305 unsigned NumAssocs = ArgTypes.size();
1306 assert(NumAssocs == ArgExprs.size());
1309 for (
unsigned i = 0; i < NumAssocs; ++i) {
1311 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1316 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1318 llvm::makeArrayRef(Types, NumAssocs),
1328 Expr *ControllingExpr,
1331 unsigned NumAssocs = Types.size();
1332 assert(NumAssocs == Exprs.size());
1339 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1342 ControllingExpr = R.
get();
1347 if (!inTemplateInstantiation() &&
1350 diag::warn_side_effects_unevaluated_context);
1352 bool TypeErrorFound =
false,
1354 ContainsUnexpandedParameterPack
1357 for (
unsigned i = 0; i < NumAssocs; ++i) {
1358 if (Exprs[i]->containsUnexpandedParameterPack())
1359 ContainsUnexpandedParameterPack =
true;
1362 if (Types[i]->getType()->containsUnexpandedParameterPack())
1363 ContainsUnexpandedParameterPack =
true;
1365 if (Types[i]->getType()->isDependentType()) {
1366 IsResultDependent =
true;
1371 if (Types[i]->getType()->isIncompleteType())
1372 D = diag::err_assoc_type_incomplete;
1373 else if (!Types[i]->getType()->isObjectType())
1374 D = diag::err_assoc_type_nonobject;
1375 else if (Types[i]->getType()->isVariablyModifiedType())
1376 D = diag::err_assoc_type_variably_modified;
1379 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1380 << Types[i]->getTypeLoc().getSourceRange()
1381 << Types[i]->getType();
1382 TypeErrorFound =
true;
1387 for (
unsigned j = i+1; j < NumAssocs; ++j)
1388 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1390 Types[j]->getType())) {
1391 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1392 diag::err_assoc_compatible_types)
1393 << Types[j]->getTypeLoc().getSourceRange()
1394 << Types[j]->getType()
1395 << Types[i]->getType();
1396 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1397 diag::note_compat_assoc)
1398 << Types[i]->getTypeLoc().getSourceRange()
1399 << Types[i]->getType();
1400 TypeErrorFound =
true;
1410 if (IsResultDependent)
1412 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1413 ContainsUnexpandedParameterPack);
1416 unsigned DefaultIndex = -1U;
1417 for (
unsigned i = 0; i < NumAssocs; ++i) {
1421 Types[i]->getType()))
1422 CompatIndices.push_back(i);
1428 if (CompatIndices.size() > 1) {
1432 Diag(ControllingExpr->
getLocStart(), diag::err_generic_sel_multi_match)
1434 << (unsigned) CompatIndices.size();
1435 for (
unsigned I : CompatIndices) {
1436 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1437 diag::note_compat_assoc)
1438 << Types[I]->getTypeLoc().getSourceRange()
1439 << Types[I]->getType();
1447 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1461 unsigned ResultIndex =
1462 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1465 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1466 ContainsUnexpandedParameterPack, ResultIndex);
1484 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1487 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1488 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1489 if (ArgTy[ArgIdx]->isArrayType())
1516 assert(!StringToks.empty() &&
"Must have at least one string!");
1519 if (Literal.hadError)
1523 for (
const Token &
Tok : StringToks)
1524 StringTokLocs.push_back(
Tok.getLocation());
1528 if (Literal.isWide()) {
1531 }
else if (Literal.isUTF8()) {
1533 }
else if (Literal.isUTF16()) {
1536 }
else if (Literal.isUTF32()) {
1539 }
else if (Literal.isPascal()) {
1545 if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
1552 llvm::APInt(32, Literal.GetNumStringChars()+1),
1556 if (getLangOpts().OpenCL) {
1562 Kind, Literal.Pascal, StrTy,
1564 StringTokLocs.size());
1565 if (Literal.getUDSuffix().empty())
1572 Literal.getUDSuffixOffset());
1576 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1591 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1592 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1598 llvm::APInt Len(Context.
getIntWidth(SizeType), Literal.GetNumStringChars());
1601 Expr *Args[] = { Lit, LenArg };
1603 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1606 case LOLR_StringTemplate: {
1611 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1617 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1623 return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
1628 case LOLR_ErrorNoDiagnostic:
1629 llvm_unreachable(
"unexpected literal operator lookup result");
1633 llvm_unreachable(
"unexpected literal operator lookup result");
1641 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1651 bool RefersToCapturedVariable =
1653 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1656 if (isa<VarTemplateSpecializationDecl>(D)) {
1658 cast<VarTemplateSpecializationDecl>(D);
1663 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1664 FoundD, TemplateArgs);
1666 assert(!TemplateArgs &&
"No template arguments for non-variable" 1667 " template specialization references");
1671 NameInfo, Ty, VK, FoundD);
1674 MarkDeclRefReferenced(E);
1676 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1678 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
1679 recordUseOfEvaluatedWeak(E);
1683 FD = IFD->getAnonField();
1685 UnusedPrivateFields.remove(FD);
1693 if (
auto *BD = dyn_cast<BindingDecl>(D))
1694 if (
auto *BE = BD->getBinding())
1695 E->setObjectKind(BE->getObjectKind());
1720 translateTemplateArguments(TemplateArgsPtr, Buffer);
1725 TemplateArgs = &Buffer;
1727 NameInfo = GetNameFromUnqualifiedId(Id);
1728 TemplateArgs =
nullptr;
1735 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1742 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1745 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
1750 bool DroppedSpecifier =
1753 ? diag::note_implicit_param_decl
1754 : diag::note_previous_decl;
1757 SemaRef.
PDiag(NoteID));
1760 << Typo << Ctx << DroppedSpecifier
1762 SemaRef.
PDiag(NoteID));
1770 std::unique_ptr<CorrectionCandidateCallback> CCC,
1775 unsigned diagnostic = diag::err_undeclared_var_use;
1776 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1780 diagnostic = diag::err_undeclared_use;
1781 diagnostic_suggest = diag::err_undeclared_use_suggest;
1790 if (isa<CXXRecordDecl>(DC)) {
1791 LookupQualifiedName(R, DC);
1800 bool isDefaultArgument =
1801 !CodeSynthesisContexts.empty() &&
1802 CodeSynthesisContexts.back().Kind ==
1803 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
1805 bool isInstance = CurMethod &&
1807 DC == CurMethod->
getParent() && !isDefaultArgument;
1812 if (getLangOpts().MSVCCompat)
1813 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1824 Diag(D->getLocation(), diag::note_dependent_var_use);
1830 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1831 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1846 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1847 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1858 assert(!ExplicitTemplateArgs &&
1859 "Diagnosing an empty lookup with explicit template args!");
1860 *Out = CorrectTypoDelayed(
1864 diagnostic, diagnostic_suggest);
1866 nullptr, CTK_ErrorRecovery);
1869 }
else if (S && (Corrected =
1871 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1872 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1873 bool DroppedSpecifier =
1877 bool AcceptableWithRecovery =
false;
1878 bool AcceptableWithoutRecovery =
false;
1887 dyn_cast<FunctionTemplateDecl>(CD))
1888 AddTemplateOverloadCandidate(
1891 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1892 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1896 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1898 ND = Best->FoundDecl;
1899 Corrected.setCorrectionDecl(ND);
1903 Corrected.setCorrectionDecl(ND);
1915 Record = cast<CXXRecordDecl>(
1921 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
1922 isa<FunctionTemplateDecl>(UnderlyingND);
1928 AcceptableWithoutRecovery =
1929 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
1933 AcceptableWithoutRecovery =
true;
1936 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
1938 ? diag::note_implicit_param_decl
1939 : diag::note_previous_decl;
1941 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
1942 PDiag(NoteID), AcceptableWithRecovery);
1944 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
1945 << Name << computeDeclContext(SS,
false)
1946 << DroppedSpecifier << SS.getRange(),
1947 PDiag(NoteID), AcceptableWithRecovery);
1950 return !AcceptableWithRecovery;
1957 if (!SS.isEmpty()) {
1959 << Name << computeDeclContext(SS,
false)
1986 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
1994 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
1995 DB << NameInfo.
getName() << RD;
1997 if (!ThisType.
isNull()) {
2000 Context,
nullptr, ThisType,
true,
2002 nullptr, NameInfo, TemplateArgs);
2019 bool HasTrailingLParen,
bool IsAddressOfOperand,
2020 std::unique_ptr<CorrectionCandidateCallback> CCC,
2021 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2022 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2023 "cannot be direct & operand and have a trailing lparen");
2032 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2055 bool DependentID =
false;
2059 }
else if (SS.
isSet()) {
2060 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2061 if (RequireCompleteDeclContext(SS, DC))
2069 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2070 IsAddressOfOperand, TemplateArgs);
2075 ? LookupObjCImplicitSelfParam
2076 : LookupOrdinaryName);
2083 bool MemberOfUnknownSpecialization;
2084 LookupTemplateName(R, S, SS,
QualType(),
false,
2085 MemberOfUnknownSpecialization);
2087 if (MemberOfUnknownSpecialization ||
2089 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2090 IsAddressOfOperand, TemplateArgs);
2092 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2093 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2098 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2099 IsAddressOfOperand, TemplateArgs);
2103 if (IvarLookupFollowUp) {
2104 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2118 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2119 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2125 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2127 if (R.
empty() && !ADL) {
2128 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2130 TemplateKWLoc, TemplateArgs))
2135 if (IsInlineAsmIdentifier)
2141 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2143 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2144 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2145 "Typo correction callback misconfigured");
2148 CCC->setTypoName(II);
2152 if (DiagnoseEmptyLookup(S, SS, R,
2153 CCC ? std::move(CCC) : std::move(DefaultValidator),
2154 nullptr, None, &TE)) {
2155 if (TE && KeywordReplacement) {
2156 auto &
State = getTypoExprState(TE);
2157 auto BestTC =
State.Consumer->getNextCorrection();
2158 if (BestTC.isKeyword()) {
2159 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2160 if (
State.DiagHandler)
2161 State.DiagHandler(BestTC);
2163 KeywordReplacement->
setKind(II->getTokenID());
2165 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2168 clearDelayedTypo(TE);
2171 return (
Expr*)
nullptr;
2173 State.Consumer->resetCorrectionStream();
2178 assert(!R.
empty() &&
2179 "DiagnoseEmptyLookup returned false but added no results");
2186 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2196 assert(!R.
empty() || ADL);
2222 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2223 bool MightBeImplicitMember;
2224 if (!IsAddressOfOperand)
2225 MightBeImplicitMember =
true;
2227 MightBeImplicitMember =
false;
2229 MightBeImplicitMember =
false;
2231 MightBeImplicitMember =
true;
2233 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2237 if (MightBeImplicitMember)
2238 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2239 R, TemplateArgs, S);
2242 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2250 "There should only be one declaration found.");
2253 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2256 return BuildDeclarationNameExpr(SS, R, ADL);
2271 if (RequireCompleteDeclContext(SS, DC))
2275 LookupQualifiedName(R, DC);
2294 unsigned DiagID = diag::err_typename_missing;
2295 if (RecoveryTSI && getLangOpts().MSVCCompat)
2296 DiagID = diag::ext_typename_missing;
2298 auto D =
Diag(Loc, DiagID);
2329 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2330 return BuildPossibleImplicitMemberExpr(SS,
2334 return BuildDeclarationNameExpr(SS, R,
false);
2368 LookForIvars =
true;
2369 else if (IsClassMethod)
2370 LookForIvars =
false;
2382 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2391 if (DiagnoseUseOfDecl(IV, Loc))
2397 !getLangOpts().DebuggerSupport)
2408 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2409 SelfName,
false,
false);
2413 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2417 MarkAnyDeclReferenced(Loc, IV,
true);
2421 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2429 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2430 recordUseOfEvaluatedWeak(Result);
2432 if (getLangOpts().ObjCAutoRefCount) {
2433 if (CurContext->isClosure())
2434 Diag(Loc, diag::warn_implicitly_retains_self)
2447 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2454 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2455 << IV->getDeclName());
2458 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2504 bool PointerConversions =
false;
2505 if (isa<FieldDecl>(Member)) {
2511 PointerConversions =
true;
2513 DestType = DestRecordType;
2514 FromRecordType = FromType;
2516 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2517 if (Method->isStatic())
2520 DestType = Method->getThisType(Context);
2525 PointerConversions =
true;
2527 FromRecordType = FromType;
2528 DestType = DestRecordType;
2565 if (Qualifier && Qualifier->
getAsType()) {
2567 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2574 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2576 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2577 FromLoc, FromRange, &BasePath))
2580 if (PointerConversions)
2582 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2583 VK, &BasePath).get();
2586 FromRecordType = QRecordType;
2595 bool IgnoreAccess =
false;
2603 assert(isa<UsingShadowDecl>(FoundDecl));
2610 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2612 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2613 FromLoc, FromRange, &BasePath))
2617 if (PointerConversions)
2619 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2620 VK, &BasePath).get();
2622 FromRecordType = URecordType;
2627 IgnoreAccess =
true;
2631 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2632 FromLoc, FromRange, &BasePath,
2636 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2642 bool HasTrailingLParen) {
2644 if (!HasTrailingLParen)
2652 if (!getLangOpts().CPlusPlus)
2662 if (D->isCXXClassMember())
2671 if (isa<UsingShadowDecl>(D))
2672 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2673 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2680 if (isa<FunctionDecl>(D)) {
2686 }
else if (!isa<FunctionTemplateDecl>(D))
2702 if (isa<TypedefNameDecl>(D)) {
2707 if (isa<ObjCInterfaceDecl>(D)) {
2712 if (isa<NamespaceDecl>(D)) {
2722 bool AcceptInvalidDecl) {
2760 bool AcceptInvalidDecl) {
2761 assert(D &&
"Cannot refer to a NULL declaration");
2762 assert(!isa<FunctionTemplateDecl>(D) &&
2763 "Cannot refer unambiguously to a function template");
2769 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2772 Diag(Loc, diag::err_template_decl_ref) << (isa<VarTemplateDecl>(D) ? 1 : 0)
2774 Diag(Template->getLocation(), diag::note_template_decl_here);
2781 Diag(Loc, diag::err_ref_non_value)
2791 if (DiagnoseUseOfDecl(VD, Loc))
2802 if (!indirectField->isCXXClassMember())
2803 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2815 ResolveExceptionSpec(Loc, FPT);
2822 #define ABSTRACT_DECL(kind) 2823 #define VALUE(type, base) 2824 #define DECL(type, base) \ 2826 #include "clang/AST/DeclNodes.inc" 2827 llvm_unreachable(
"invalid value decl kind");
2830 case Decl::ObjCAtDefsField:
2831 case Decl::ObjCIvar:
2832 llvm_unreachable(
"forming non-member reference to ivar?");
2836 case Decl::EnumConstant:
2837 case Decl::UnresolvedUsingValue:
2838 case Decl::OMPDeclareReduction:
2847 case Decl::IndirectField:
2849 "building reference to field in C?");
2859 case Decl::NonTypeTemplateParm: {
2874 case Decl::VarTemplateSpecialization:
2875 case Decl::VarTemplatePartialSpecialization:
2876 case Decl::Decomposition:
2877 case Decl::OMPCapturedExpr:
2887 case Decl::ImplicitParam:
2888 case Decl::ParmVar: {
2896 if (!isUnevaluatedContext()) {
2897 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2898 if (!CapturedType.
isNull())
2899 type = CapturedType;
2905 case Decl::Binding: {
2911 auto *BD = cast<BindingDecl>(VD);
2912 if (BD->getDeclContext()->isFunctionOrMethod() &&
2913 BD->getDeclContext() != CurContext)
2918 case Decl::Function: {
2919 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
2938 if (getLangOpts().CPlusPlus) {
2948 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
2949 isa<FunctionProtoType>(fty))
2958 case Decl::CXXDeductionGuide:
2959 llvm_unreachable(
"building reference to deduction guide");
2961 case Decl::MSProperty:
2965 case Decl::CXXMethod:
2970 = dyn_cast<FunctionProtoType>(VD->
getType()))
2978 if (cast<CXXMethodDecl>(VD)->isStatic()) {
2984 case Decl::CXXConversion:
2985 case Decl::CXXDestructor:
2986 case Decl::CXXConstructor:
2991 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
2998 Target.resize(CharByteWidth * (Source.size() + 1));
2999 char *ResultPtr = &Target[0];
3000 const llvm::UTF8 *ErrorPtr;
3002 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3005 Target.resize(ResultPtr - &Target[0]);
3011 Decl *currentDecl =
nullptr;
3013 currentDecl = BSI->TheDecl;
3015 currentDecl = LSI->CallOperator;
3017 currentDecl = CSI->TheCapturedDecl;
3019 currentDecl = getCurFunctionOrMethodDecl();
3022 Diag(Loc, diag::ext_predef_outside_function);
3028 if (cast<DeclContext>(currentDecl)->isDependentContext())
3034 unsigned Length = Str.length();
3036 llvm::APInt LengthI(32, Length + 1);
3062 default: llvm_unreachable(
"Unknown simple primary expr!");
3071 return BuildPredefinedExpr(Loc, IT);
3076 bool Invalid =
false;
3077 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3083 if (Literal.hadError())
3087 if (Literal.isWide())
3089 else if (Literal.isUTF16())
3091 else if (Literal.isUTF32())
3093 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3099 if (Literal.isWide())
3101 else if (Literal.isUTF16())
3103 else if (Literal.isUTF32())
3105 else if (Literal.isUTF8())
3111 if (Literal.getUDSuffix().empty())
3121 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3132 Context.
IntTy, Loc);
3139 using llvm::APFloat;
3140 APFloat Val(Format);
3146 if ((result & APFloat::opOverflow) ||
3147 ((result & APFloat::opUnderflow) && Val.isZero())) {
3148 unsigned diagnostic;
3150 if (result & APFloat::opOverflow) {
3151 diagnostic = diag::warn_float_overflow;
3152 APFloat::getLargest(Format).toString(buffer);
3154 diagnostic = diag::warn_float_underflow;
3155 APFloat::getSmallest(Format).toString(buffer);
3158 S.
Diag(Loc, diagnostic)
3160 << StringRef(buffer.data(), buffer.size());
3163 bool isExact = (result == APFloat::opOK);
3168 assert(E &&
"Invalid expression");
3175 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3179 llvm::APSInt ValueAPS;
3180 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3185 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3186 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3187 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3188 << ValueAPS.toString(10) << ValueIsPositive;
3199 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3200 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3208 SpellingBuffer.resize(Tok.
getLength() + 1);
3211 bool Invalid =
false;
3212 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3217 if (Literal.hadError)
3220 if (Literal.hasUDSuffix()) {
3228 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3231 if (Literal.isFloatingLiteral()) {
3252 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3253 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3256 !Literal.isImaginary)) {
3257 case LOLR_ErrorNoDiagnostic:
3265 if (Literal.isFloatingLiteral()) {
3269 if (Literal.GetIntegerValue(ResultVal))
3275 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3282 unsigned Length = Literal.getUDSuffixOffset();
3288 false, StrTy, &TokLoc, 1);
3289 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3292 case LOLR_Template: {
3299 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3300 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3301 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3302 Value = TokSpelling[I];
3307 return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
3310 case LOLR_StringTemplate:
3311 llvm_unreachable(
"unexpected literal operator lookup result");
3317 if (Literal.isFloatingLiteral()) {
3319 if (Literal.isHalf){
3320 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3326 }
else if (Literal.isFloat)
3328 else if (Literal.isLong)
3330 else if (Literal.isFloat16)
3332 else if (Literal.isFloat128)
3340 if (getLangOpts().SinglePrecisionConstants) {
3342 if (BTy->
getKind() != BuiltinType::Float) {
3343 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3345 }
else if (getLangOpts().OpenCL &&
3346 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3349 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3352 }
else if (!Literal.isIntegerLiteral()) {
3358 if (!getLangOpts().
C99 && Literal.isLongLong) {
3361 getLangOpts().CPlusPlus11 ?
3362 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3364 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
3369 llvm::APInt ResultVal(MaxWidth, 0);
3371 if (Literal.GetIntegerValue(ResultVal)) {
3373 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3376 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
3377 "long long is not intmax_t?");
3384 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3390 if (Literal.MicrosoftInteger) {
3391 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3395 Width = Literal.MicrosoftInteger;
3397 !Literal.isUnsigned);
3401 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3406 if (ResultVal.isIntN(IntSize)) {
3408 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3410 else if (AllowUnsigned)
3417 if (Ty.
isNull() && !Literal.isLongLong) {
3421 if (ResultVal.isIntN(LongSize)) {
3423 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3425 else if (AllowUnsigned)
3429 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3430 const unsigned LongLongSize =
3433 getLangOpts().CPlusPlus
3435 ? diag::warn_old_implicitly_unsigned_long_cxx
3437 ext_old_implicitly_unsigned_long_cxx
3438 : diag::warn_old_implicitly_unsigned_long)
3439 << (LongLongSize > LongSize ? 0
3452 if (ResultVal.isIntN(LongLongSize)) {
3456 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3457 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3459 else if (AllowUnsigned)
3461 Width = LongLongSize;
3468 Diag(
Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3473 if (ResultVal.getBitWidth() != Width)
3474 ResultVal = ResultVal.trunc(Width);
3480 if (Literal.isImaginary) {
3484 Diag(
Tok.getLocation(), diag::ext_imaginary_constant);
3490 assert(E &&
"ActOnParenExpr() missing expr");
3491 return new (Context)
ParenExpr(L, R, E);
3502 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3508 "Scalar types should always be complete");
3524 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3525 << TraitKind << ArgRange;
3532 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3533 : diag::ext_sizeof_alignof_void_type;
3534 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3548 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3567 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3603 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3607 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3626 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3634 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3635 QualType OType = PVD->getOriginalType();
3640 Diag(PVD->getLocation(), diag::note_declared_at);
3704 if (RequireCompleteType(OpLoc, ExprType,
3705 diag::err_sizeof_alignof_incomplete_type,
3706 ExprKind, ExprRange))
3710 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3711 << ExprKind << ExprRange;
3730 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3736 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3738 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3739 D = ME->getMemberDecl();
3759 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3762 if (!FD->getParent()->isCompleteDefinition()) {
3763 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3772 if (!FD->getType()->isReferenceType())
3786 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
3792 assert(CSI !=
nullptr);
3798 #define TYPE(Class, Base) 3799 #define ABSTRACT_TYPE(Class, Base) 3800 #define NON_CANONICAL_TYPE(Class, Base) 3801 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 3802 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) 3803 #include "clang/AST/TypeNodes.def" 3810 case Type::ExtVector:
3813 case Type::Elaborated:
3814 case Type::TemplateSpecialization:
3815 case Type::ObjCObject:
3816 case Type::ObjCInterface:
3817 case Type::ObjCObjectPointer:
3818 case Type::ObjCTypeParam:
3820 llvm_unreachable(
"type class is never variably-modified!");
3821 case Type::Adjusted:
3822 T = cast<AdjustedType>(Ty)->getOriginalType();
3825 T = cast<DecayedType>(Ty)->getPointeeType();
3828 T = cast<PointerType>(Ty)->getPointeeType();
3830 case Type::BlockPointer:
3831 T = cast<BlockPointerType>(Ty)->getPointeeType();
3833 case Type::LValueReference:
3834 case Type::RValueReference:
3835 T = cast<ReferenceType>(Ty)->getPointeeType();
3837 case Type::MemberPointer:
3838 T = cast<MemberPointerType>(Ty)->getPointeeType();
3840 case Type::ConstantArray:
3841 case Type::IncompleteArray:
3843 T = cast<ArrayType>(Ty)->getElementType();
3845 case Type::VariableArray: {
3854 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3855 CapRecord = LSI->Lambda;
3856 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3857 CapRecord = CRSI->TheRecordDecl;
3860 auto ExprLoc = Size->getExprLoc();
3865 nullptr, SizeType,
nullptr,
3868 Field->setImplicit(
true);
3870 Field->setCapturedVLAType(VAT);
3880 case Type::FunctionProto:
3881 case Type::FunctionNoProto:
3882 T = cast<FunctionType>(Ty)->getReturnType();
3886 case Type::UnaryTransform:
3887 case Type::Attributed:
3888 case Type::SubstTemplateTypeParm:
3889 case Type::PackExpansion:
3894 T = cast<TypedefType>(Ty)->desugar();
3896 case Type::Decltype:
3897 T = cast<DecltypeType>(Ty)->desugar();
3900 case Type::DeducedTemplateSpecialization:
3901 T = cast<DeducedType>(Ty)->getDeducedType();
3903 case Type::TypeOfExpr:
3904 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
3907 T = cast<AtomicType>(Ty)->getValueType();
3925 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
3930 for (
auto I = FunctionScopes.rbegin(),
3931 E = std::prev(FunctionScopes.rend());
3937 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
3938 DC = LSI->CallOperator;
3939 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
3940 DC = CRSI->TheCapturedDecl;
3941 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
3975 isInvalid = CheckVecStepExpr(E);
3980 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
3983 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
3990 PE = TransformToPotentiallyEvaluated(E);
4013 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4017 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4023 if (V.
get()->isTypeDependent())
4035 return CT->getElementType();
4038 if (V.
get()->getType()->isArithmeticType())
4039 return V.
get()->getType();
4044 if (PR.
get() != V.
get()) {
4050 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4051 << (IsReal ?
"__real" :
"__imag");
4062 default: llvm_unreachable(
"Unknown unary op!");
4063 case tok::plusplus: Opc = UO_PostInc;
break;
4064 case tok::minusminus: Opc = UO_PostDec;
break;
4068 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4070 Input = Result.
get();
4072 return BuildUnaryOp(S, OpLoc, Opc, Input);
4083 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4086 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4094 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4096 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4104 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4108 if (isa<ParenListExpr>(base)) {
4109 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4111 base = result.
get();
4119 bool IsMSPropertySubscript =
false;
4122 if (!IsMSPropertySubscript) {
4123 ExprResult result = CheckPlaceholderExpr(base);
4126 base = result.
get();
4130 ExprResult result = CheckPlaceholderExpr(idx);
4150 if (IsMSPropertySubscript) {
4165 if (getLangOpts().CPlusPlus &&
4169 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4172 return CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4181 BuiltinType::OMPArraySection)) {
4182 ExprResult Result = CheckPlaceholderExpr(Base);
4185 Base = Result.
get();
4188 ExprResult Result = CheckPlaceholderExpr(LowerBound);
4191 Result = DefaultLvalueConversion(Result.
get());
4194 LowerBound = Result.
get();
4197 ExprResult Result = CheckPlaceholderExpr(Length);
4200 Result = DefaultLvalueConversion(Result.
get());
4203 Length = Result.
get();
4211 return new (Context)
4230 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4232 if (Res.isInvalid())
4234 diag::err_omp_typecheck_section_not_integer)
4236 LowerBound = Res.get();
4245 PerformOpenMPImplicitIntegerConversion(Length->
getExprLoc(), Length);
4246 if (Res.isInvalid())
4248 diag::err_omp_typecheck_section_not_integer)
4268 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4269 diag::err_omp_section_incomplete_type, Base))
4273 llvm::APSInt LowerBoundValue;
4277 if (LowerBoundValue.isNegative()) {
4278 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4286 llvm::APSInt LengthValue;
4290 if (LengthValue.isNegative()) {
4291 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4292 << LengthValue.toString(10,
true)
4297 }
else if (ColonLoc.
isValid() &&
4303 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4309 BuiltinType::OMPArraySection)) {
4310 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
4313 Base = Result.
get();
4315 return new (Context)
4323 Expr *LHSExp = Base;
4338 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
4341 LHSExp = Result.
get();
4343 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
4346 RHSExp = Result.
get();
4354 Expr *BaseExpr, *IndexExpr;
4371 if (!LangOpts.isSubscriptPointerArithmetic())
4372 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4387 if (!LangOpts.isSubscriptPointerArithmetic()) {
4388 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4400 ResultType = VTy->getElementType();
4410 CK_ArrayToPointerDecay).
get();
4416 }
else if (RHSTy->isArrayType()) {
4421 CK_ArrayToPointerDecay).
get();
4428 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4433 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4451 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4453 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4460 RequireCompleteType(LLoc, ResultType,
4461 diag::err_subscript_incomplete_type, BaseExpr))
4464 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4467 return new (Context)
4475 diag::err_use_of_default_argument_to_function_declared_later) <<
4477 Diag(UnparsedDefaultArgLocs[Param],
4478 diag::note_default_argument_declared_here);
4486 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4506 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4510 if (Inst.isInvalid())
4512 if (Inst.isAlreadyInstantiating()) {
4513 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4526 Result = SubstInitializer(UninstExpr, MutiLevelArgList,
4541 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4545 Result = ActOnFinishFullExpr(Result.
getAs<
Expr>(),
4553 L->DefaultArgumentInstantiated(Param);
4559 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4571 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4574 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
4579 assert(!Init->getNumObjects() &&
4580 "default argument expression has capturing blocks?");
4593 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
4602 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4603 return VariadicConstructor;
4605 return VariadicBlock;
4607 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4608 if (Method->isInstance())
4609 return VariadicMethod;
4611 return VariadicMethod;
4612 return VariadicFunction;
4614 return VariadicDoesNotApply;
4623 FunctionName(FuncName) {}
4625 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4649 llvm::make_unique<FunctionCallCCC>(S, FuncName.getAsIdentifierInfo(),
4652 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4653 if (Corrected.isOverloaded()) {
4663 ND = Best->FoundDecl;
4664 Corrected.setCorrectionDecl(ND);
4670 ND = ND->getUnderlyingDecl();
4671 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4690 bool IsExecConfig) {
4700 bool Invalid =
false;
4709 if (Args.size() < NumParams) {
4710 if (Args.size() < MinArgs) {
4715 ? diag::err_typecheck_call_too_few_args_suggest
4716 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4717 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4718 << static_cast<unsigned>(Args.size())
4723 ? diag::err_typecheck_call_too_few_args_one
4724 : diag::err_typecheck_call_too_few_args_at_least_one)
4728 ? diag::err_typecheck_call_too_few_args
4729 : diag::err_typecheck_call_too_few_args_at_least)
4730 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4734 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4745 if (Args.size() > NumParams) {
4751 ? diag::err_typecheck_call_too_many_args_suggest
4752 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4753 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4754 << static_cast<unsigned>(Args.size())
4756 }
else if (NumParams == 1 && FDecl &&
4758 Diag(Args[NumParams]->getLocStart(),
4759 MinArgs == NumParams
4760 ? diag::err_typecheck_call_too_many_args_one
4761 : diag::err_typecheck_call_too_many_args_at_most_one)
4765 Args.back()->getLocEnd());
4767 Diag(Args[NumParams]->getLocStart(),
4768 MinArgs == NumParams
4769 ? diag::err_typecheck_call_too_many_args
4770 : diag::err_typecheck_call_too_many_args_at_most)
4771 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4774 Args.back()->getLocEnd());
4777 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4789 Invalid = GatherArgumentsForCall(Call->
getLocStart(), FDecl,
4790 Proto, 0, Args, AllArgs, CallType);
4793 unsigned TotalNumArgs = AllArgs.size();
4794 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4795 Call->
setArg(i, AllArgs[i]);
4805 bool IsListInitialization) {
4807 bool Invalid =
false;
4810 for (
unsigned i = FirstParam; i < NumParams; i++) {
4815 if (ArgIx < Args.size()) {
4816 Arg = Args[ArgIx++];
4820 diag::err_call_incomplete_argument, Arg))
4824 bool CFAudited =
false;
4826 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4827 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4828 Arg = stripARCUnbridgedCast(Arg);
4829 else if (getLangOpts().ObjCAutoRefCount &&
4830 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4831 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4845 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
4851 assert(Param &&
"can't use default arguments without a known callee");
4854 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
4864 CheckArrayAccess(Arg);
4867 CheckStaticArrayArgument(CallLoc, Param, Arg);
4869 AllArgs.push_back(Arg);
4873 if (CallType != VariadicDoesNotApply) {
4878 for (
Expr *A : Args.slice(ArgIx)) {
4880 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
4882 AllArgs.push_back(arg.
get());
4887 for (
Expr *A : Args.slice(ArgIx)) {
4888 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
4890 AllArgs.push_back(Arg.
get());
4895 for (
Expr *A : Args.slice(ArgIx))
4896 CheckArrayAccess(A);
4904 TL = DTL.getOriginalLoc();
4907 << ATL.getLocalSourceRange();
4921 const Expr *ArgExpr) {
4949 Diag(CallLoc, diag::warn_static_array_too_small)
4951 << (unsigned) ArgCAT->
getSize().getZExtValue()
4952 << (unsigned) CAT->
getSize().getZExtValue();
4966 if (!placeholder)
return false;
4968 switch (placeholder->
getKind()) {
4970 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 4971 case BuiltinType::Id: 4972 #include "clang/Basic/OpenCLImageTypes.def" 4973 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 4974 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 4975 #include "clang/AST/BuiltinTypes.def" 4980 case BuiltinType::Overload:
4985 case BuiltinType::ARCUnbridgedCast:
4989 case BuiltinType::PseudoObject:
4994 case BuiltinType::UnknownAny:
4998 case BuiltinType::BoundMember:
4999 case BuiltinType::BuiltinFn:
5000 case BuiltinType::OMPArraySection:
5004 llvm_unreachable(
"bad builtin type kind");
5012 bool hasInvalid =
false;
5013 for (
size_t i = 0, e = args.size(); i != e; i++) {
5016 if (result.
isInvalid()) hasInvalid =
true;
5017 else args[i] = result.
get();
5018 }
else if (hasInvalid) {
5047 bool NeedsNewDecl =
false;
5060 if (!ParamType->isPointerType() ||
5061 ParamType.getQualifiers().hasAddressSpace() ||
5064 OverloadParams.push_back(ParamType);
5068 NeedsNewDecl =
true;
5081 OverloadParams, EPI);
5092 FT = cast<FunctionProtoType>(OverloadTy);
5093 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5100 Params.push_back(Parm);
5102 OverloadDecl->setParams(Params);
5103 return OverloadDecl;
5121 isa<CXXMethodDecl>(Callee)
5122 ? diag::err_ovl_no_viable_member_function_in_call
5123 : diag::err_ovl_no_viable_function_in_call)
5126 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5127 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5135 const auto GetFunctionLevelDCIfCXXClass =
5143 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5144 return MD->
getParent()->getCanonicalDecl();
5147 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5148 return RD->getCanonicalDecl();
5155 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5156 if (!CurParentClass)
5163 assert(NamingClass &&
"Must have naming class even for implicit access");
5169 return CurParentClass == NamingClass ||
5218 Expr *ExecConfig,
bool IsExecConfig) {
5220 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5229 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5230 if (!ArgExprs.empty()) {
5235 ArgExprs.back()->getLocEnd()));
5238 return new (Context)
5242 ExprResult result = CheckPlaceholderExpr(Fn);
5249 bool Dependent =
false;
5258 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5263 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5273 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5283 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5299 return BuildOverloadedCallExpr(
5300 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5302 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5316 bool CallingNDeclIndirectly =
false;
5318 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5319 if (UnOp->getOpcode() == UO_AddrOf) {
5320 CallingNDeclIndirectly =
true;
5325 if (isa<DeclRefExpr>(NakedFn)) {
5326 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5341 }
else if (isa<MemberExpr>(NakedFn))
5342 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5344 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5345 if (CallingNDeclIndirectly &&
5350 if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5356 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5357 ExecConfig, IsExecConfig);
5369 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5373 diag::err_invalid_astype_of_different_size)
5377 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5389 GetTypeFromParser(ParsedDestTy, &TInfo);
5390 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5404 Expr *Config,
bool IsExecConfig) {
5405 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5406 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5409 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5418 if (
auto *Caller = getCurFunctionDecl())
5419 if (Caller->hasAttr<ARMInterruptAttr>()) {
5421 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5422 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5432 CK_BuiltinFnToFnPtr).get();
5434 Result = CallExprUnaryConversions(Fn);
5436 if (Result.isInvalid())
5445 cast<CallExpr>(Config), Args,
5449 TheCall =
new (Context)
CallExpr(Context, Fn, Args, Context.
BoolTy,
5452 if (!getLangOpts().CPlusPlus) {
5457 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5460 if (!TheCall)
return Result;
5466 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5475 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5490 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5494 if (getLangOpts().CUDA) {
5497 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5498 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5503 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5507 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5508 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5524 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5528 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5537 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5548 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5549 Expr *Arg = Args[i];
5551 if (Proto && i < Proto->getNumParams()) {
5556 if (ArgE.isInvalid())
5559 Arg = ArgE.getAs<
Expr>();
5562 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5572 diag::err_call_incomplete_argument, Arg))
5579 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5580 if (!Method->isStatic())
5581 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5586 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5590 if (CheckFunctionCall(FDecl, TheCall, Proto))
5594 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5596 if (CheckPointerCall(NDecl, TheCall, Proto))
5599 if (CheckOtherCall(TheCall, Proto))
5603 return MaybeBindToTemporary(TheCall);
5609 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5610 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5613 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5617 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5627 diag::err_illegal_decl_array_incomplete_type,
5632 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5635 RequireCompleteType(LParenLoc, literalType,
5636 diag::err_typecheck_decl_incomplete_type,
5651 LiteralExpr = Result.
get();
5653 bool isFileScope = !CurContext->isFunctionOrMethod();
5658 if (CheckForConstantInitializer(LiteralExpr, literalType))
5681 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
5685 return MaybeBindToTemporary(
5687 VK, LiteralExpr, isFileScope));
5695 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
5696 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
5697 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
5703 InitArgList[I] = result.
get();
5718 assert(E.
get()->getType()->isBlockPointerType());
5719 assert(E.
get()->isRValue());
5722 if (!getLangOpts().ObjCAutoRefCount)
return;
5725 CK_ARCExtendBlockObject, E.
get(),
5727 Cleanup.setExprNeedsCleanups(
true);
5737 maybeExtendBlockObject(E);
5738 return CK_BlockPointerToObjCPointerCast;
5741 return CK_CPointerToObjCPointerCast;
5758 llvm_unreachable(
"member pointer type in C");
5767 if (SrcAS != DestAS)
5768 return CK_AddressSpaceConversion;
5773 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
5778 return CK_CPointerToObjCPointerCast;
5779 maybeExtendBlockObject(Src);
5780 return CK_BlockPointerToObjCPointerCast;
5782 return CK_PointerToBoolean;
5784 return CK_PointerToIntegral;
5789 llvm_unreachable(
"illegal cast from pointer");
5791 llvm_unreachable(
"Should have returned before this");
5799 if (Src.
get()->isNullPointerConstant(Context,
5801 return CK_NullToPointer;
5802 return CK_IntegralToPointer;
5804 return CK_IntegralToBoolean;
5806 return CK_IntegralCast;
5808 return CK_IntegralToFloating;
5810 Src = ImpCastExprToType(Src.
get(),
5813 return CK_IntegralRealToComplex;
5815 Src = ImpCastExprToType(Src.
get(),
5817 CK_IntegralToFloating);
5818 return CK_FloatingRealToComplex;
5820 llvm_unreachable(
"member pointer type in C");
5822 llvm_unreachable(
"Should have returned before this");
5827 return CK_FloatingCast;
5829 return CK_FloatingToBoolean;
5831 return CK_FloatingToIntegral;
5833 Src = ImpCastExprToType(Src.
get(),
5836 return CK_FloatingRealToComplex;
5838 Src = ImpCastExprToType(Src.
get(),
5840 CK_FloatingToIntegral);
5841 return CK_IntegralRealToComplex;
5845 llvm_unreachable(
"valid float->pointer cast?");
5847 llvm_unreachable(
"member pointer type in C");
5849 llvm_unreachable(
"Should have returned before this");
5854 return CK_FloatingComplexCast;
5856 return CK_FloatingComplexToIntegralComplex;
5860 return CK_FloatingComplexToReal;
5861 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
5862 return CK_FloatingCast;
5865 return CK_FloatingComplexToBoolean;
5867 Src = ImpCastExprToType(Src.
get(),
5869 CK_FloatingComplexToReal);
5870 return CK_FloatingToIntegral;
5874 llvm_unreachable(
"valid complex float->pointer cast?");
5876 llvm_unreachable(
"member pointer type in C");
5878 llvm_unreachable(
"Should have returned before this");
5883 return CK_IntegralComplexToFloatingComplex;
5885 return CK_IntegralComplexCast;
5889 return CK_IntegralComplexToReal;
5890 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
5891 return CK_IntegralCast;
5894 return CK_IntegralComplexToBoolean;
5896 Src = ImpCastExprToType(Src.
get(),
5898 CK_IntegralComplexToReal);
5899 return CK_IntegralToFloating;
5903 llvm_unreachable(
"valid complex int->pointer cast?");
5905 llvm_unreachable(
"member pointer type in C");
5907 llvm_unreachable(
"Should have returned before this");
5910 llvm_unreachable(
"Unhandled scalar cast");
5917 len = vecType->getNumElements();
5918 eltType = vecType->getElementType();
5950 uint64_t srcLen, destLen;
5958 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
5959 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
5961 return (srcLen * srcEltSize == destLen * destEltSize);
5971 return areLaxCompatibleVectorTypes(srcTy, destTy);
5976 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
5979 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
5982 diag::err_invalid_conversion_between_vectors :
5983 diag::err_invalid_conversion_between_vector_and_integer)
5984 << VectorTy << Ty << R;
5987 diag::err_invalid_conversion_between_vector_and_scalar)
5988 << VectorTy << Ty << R;
5997 if (DestElemTy == SplattedExpr->
getType())
5998 return SplattedExpr;
6010 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6011 CK_BooleanToSignedIntegral);
6012 SplattedExpr = CastExprRes.
get();
6013 CK = CK_IntegralToFloating;
6015 CK = CK_BooleanToSignedIntegral;
6019 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6022 SplattedExpr = CastExprRes.
get();
6024 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6037 if (SrcTy->isVectorType()) {
6038 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6039 (getLangOpts().OpenCL &&
6041 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6042 << DestTy << SrcTy << R;
6052 if (SrcTy->isPointerType())
6054 diag::err_invalid_conversion_between_vector_and_scalar)
6055 << DestTy << SrcTy << R;
6057 Kind = CK_VectorSplat;
6058 return prepareVectorSplat(DestTy, CastExpr);
6066 "ActOnCastExpr(): missing type or expr");
6072 if (getLangOpts().CPlusPlus) {
6074 CheckExtraCXXDefaultArguments(D);
6077 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6080 CastExpr = Res.
get();
6086 Ty = CreateParsedType(castType, castTInfo);
6088 bool isVectorLiteral =
false;
6094 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6096 if (PLE && PLE->getNumExprs() == 0) {
6097 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6100 if (PE || PLE->getNumExprs() == 1) {
6103 isVectorLiteral =
true;
6106 isVectorLiteral =
true;
6111 if (isVectorLiteral)
6112 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6117 if (isa<ParenListExpr>(CastExpr)) {
6118 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6120 CastExpr = Result.
get();
6124 !getSourceManager().isInSystemMacro(LParenLoc))
6127 CheckTollFreeBridgeCast(castType, CastExpr);
6129 CheckObjCBridgeRelatedCast(castType, CastExpr);
6131 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6133 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6139 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6140 "Expected paren or paren list expression");
6147 LiteralLParenLoc = PE->getLParenLoc();
6148 LiteralRParenLoc = PE->getRParenLoc();
6149 exprs = PE->getExprs();
6150 numExprs = PE->getNumExprs();
6152 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6153 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6154 subExpr = cast<ParenExpr>(E)->getSubExpr();
6174 if (numExprs == 1) {
6176 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6179 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6180 PrepareScalarCast(Literal, ElemTy));
6181 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6183 else if (numExprs < numElems) {
6185 diag::err_incorrect_number_of_vector_initializers);
6189 initExprs.append(exprs, exprs + numExprs);
6194 if (getLangOpts().OpenCL &&
6198 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6201 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6202 PrepareScalarCast(Literal, ElemTy));
6203 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6206 initExprs.append(exprs, exprs + numExprs);
6211 initExprs, LiteralRParenLoc);
6213 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6226 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
6227 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6230 if (Result.isInvalid())
return ExprError();
6247 Expr *NullExpr = LHSExpr;
6248 Expr *NonPointerExpr = RHSExpr;
6255 NonPointerExpr = LHSExpr;
6272 if (!findMacroSpelling(loc,
"NULL"))
6277 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6278 << NonPointerExpr->
getType() << DiagType
6289 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6297 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6324 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6348 bool IsBlockPointer =
false;
6352 IsBlockPointer =
true;
6377 ResultAddrSpace = LAddrSpace;
6379 ResultAddrSpace = RAddrSpace;
6382 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6383 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6384 << RHS.
get()->getSourceRange();
6390 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6405 LHSCastKind = LAddrSpace == ResultAddrSpace
6407 : CK_AddressSpaceConversion;
6408 RHSCastKind = RAddrSpace == ResultAddrSpace
6410 : CK_AddressSpaceConversion;
6420 if (CompositeTy.
isNull()) {
6436 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6437 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6438 << RHS.
get()->getSourceRange();
6446 QualType ResultTy = [&, ResultAddrSpace]() {
6452 .withCVRQualifiers(MergedCVRQual);
6481 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6482 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6483 << RHS.
get()->getSourceRange();
6534 bool IsIntFirstExpr) {
6536 !Int.
get()->getType()->isIntegerType())
6539 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6540 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6542 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6546 CK_IntegralToPointer);
6580 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6581 << LHSType << LHS.
get()->getSourceRange();
6586 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6587 << RHSType << RHS.
get()->getSourceRange();
6592 if (LHSType == RHSType)
6601 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6602 (S, LHS, RHS, LHSType, RHSType,
false);
6636 llvm::raw_svector_ostream OS(Str);
6637 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6638 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6639 << CondTy << OS.str();
6660 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6678 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6679 << CondTy << VecResTy;
6684 QualType RVE = RV->getElementType();
6687 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6688 << CondTy << VecResTy;
6712 if (LHS.
get()->getType()->isVectorType() ||
6713 RHS.
get()->getType()->isVectorType()) {
6732 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
6733 QualType Ty = CE->getCallee()->getType();
6759 if (getLangOpts().CPlusPlus)
6760 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
6767 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
6771 Cond = UsualUnaryConversions(Cond.
get());
6778 if (LHS.
get()->getType()->isVectorType() ||
6779 RHS.
get()->getType()->isVectorType())
6780 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
6784 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
6795 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
6796 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6802 if (getLangOpts().OpenCL &&
6810 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
6811 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
6820 if (LHSRT->getDecl() == RHSRT->getDecl())
6839 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
6843 if (!compositeType.
isNull())
6844 return compositeType;
6869 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
6873 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6874 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6875 << RHS.
get()->getSourceRange();
6891 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
6896 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
6902 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
6907 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
6913 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
6918 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
6945 if (!(compositeType =
6963 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
6965 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6967 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
6968 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
6972 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
6973 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
6974 return compositeType;
6978 if (getLangOpts().ObjCAutoRefCount) {
6981 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6982 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6992 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
6994 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
6998 if (getLangOpts().ObjCAutoRefCount) {
7001 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7002 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7012 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7014 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7028 Self.
Diag(Loc, Note)
7033 Self.
Diag(Loc, Note) << ParenRange;
7057 *Opcode = OP->getOpcode();
7058 *RHSExprs = OP->getRHS();
7065 if (Call->getNumArgs() != 2)
7071 if (OO < OO_Plus || OO > OO_Arrow ||
7072 OO == OO_PlusPlus || OO == OO_MinusMinus)
7078 *RHSExprs = Call->getArg(1);
7095 return OP->isComparisonOp() || OP->isLogicalOp();
7097 return OP->getOpcode() == UO_LNot;
7124 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7129 Self.
PDiag(diag::note_precedence_silence)
7134 Self.
PDiag(diag::note_precedence_conditional_first),
7145 auto GetNullability = [&Ctx](
QualType Ty) {
7152 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7160 MergedKind = RHSKind;
7167 MergedKind = RHSKind;
7169 MergedKind = LHSKind;
7175 if (GetNullability(ResTy) == MergedKind)
7197 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7198 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7199 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7212 CondExpr = CondResult.
get();
7213 LHSExpr = LHSResult.
get();
7214 RHSExpr = RHSResult.
get();
7220 Expr *commonExpr =
nullptr;
7222 commonExpr = CondExpr;
7227 ExprResult result = CheckPlaceholderExpr(commonExpr);
7229 commonExpr = result.
get();
7240 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7243 commonExpr = commonRes.
get();
7250 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7253 commonExpr = MatExpr.
get();
7261 LHSExpr = CondExpr = opaqueValue;
7267 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7268 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
7269 VK, OK, QuestionLoc);
7283 return new (Context)
7285 RHS.get(), result, VK, OK);
7288 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7299 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7300 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7303 const Type *lhptee, *rhptee;
7305 std::tie(lhptee, lhq) =
7306 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7307 std::tie(rhptee, rhq) =
7308 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7334 && (lhptee->isVoidType() || rhptee->isVoidType()))
7349 if (lhptee->isVoidType()) {
7350 if (rhptee->isIncompleteOrObjectType())
7354 assert(rhptee->isFunctionType());
7358 if (rhptee->isVoidType()) {
7359 if (lhptee->isIncompleteOrObjectType())
7363 assert(lhptee->isFunctionType());
7374 if (lhptee->isCharType())
7376 else if (lhptee->hasSignedIntegerRepresentation())
7379 if (rhptee->isCharType())
7381 else if (rhptee->hasSignedIntegerRepresentation())
7384 if (ltrans == rtrans) {
7398 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7400 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7401 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7402 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7404 if (lhptee == rhptee)
7424 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7425 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7430 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7431 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7440 Qualifiers LQuals = lhptee.getLocalQualifiers();
7441 Qualifiers RQuals = rhptee.getLocalQualifiers();
7446 if (LQuals != RQuals)
7475 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7476 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7517 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7524 return VT->getElementType() == ElementType;
7557 if (LHSType == RHSType) {
7564 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7566 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
7567 if (result != Compatible)
7569 if (Kind != CK_NoOp && ConvertRHS)
7570 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
7571 Kind = CK_NonAtomicToAtomic;
7584 Kind = CK_LValueBitCast;
7587 return Incompatible;
7594 return Incompatible;
7598 RHS = prepareVectorSplat(LHSType, RHS.
get());
7599 Kind = CK_VectorSplat;
7617 if (isLaxVectorConversion(RHSType, LHSType)) {
7619 return IncompatibleVectors;
7630 isLaxVectorConversion(RHSType, LHSType)) {
7632 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
7638 return Incompatible;
7644 return Incompatible;
7650 return Incompatible;
7656 Kind = PrepareScalarCast(RHS, LHSType);
7661 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7663 if (isa<PointerType>(RHSType)) {
7664 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7666 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7672 Kind = CK_IntegralToPointer;
7673 return IntToPointer;
7678 if (isa<ObjCObjectPointerType>(RHSType)) {
7680 if (LHSPointer->getPointeeType()->isVoidType()) {
7694 return IncompatiblePointer;
7699 if (LHSPointer->getPointeeType()->isVoidType()) {
7700 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7705 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7710 return Incompatible;
7714 if (isa<BlockPointerType>(LHSType)) {
7723 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7729 Kind = CK_IntegralToPointer;
7730 return IntToBlockPointer;
7735 Kind = CK_AnyPointerToBlockPointerCast;
7741 if (RHSPT->getPointeeType()->isVoidType()) {
7742 Kind = CK_AnyPointerToBlockPointerCast;
7746 return Incompatible;
7750 if (isa<ObjCObjectPointerType>(LHSType)) {
7756 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
7757 result == Compatible &&
7758 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
7759 result = IncompatibleObjCWeakRef;
7765 Kind = CK_IntegralToPointer;
7766 return IntToPointer;
7771 if (isa<PointerType>(RHSType)) {
7772 Kind = CK_CPointerToObjCPointerCast;
7786 return IncompatiblePointer;
7793 maybeExtendBlockObject(RHS);
7794 Kind = CK_BlockPointerToObjCPointerCast;
7798 return Incompatible;
7802 if (isa<PointerType>(RHSType)) {
7804 if (LHSType == Context.
BoolTy) {
7805 Kind = CK_PointerToBoolean;
7811 Kind = CK_PointerToIntegral;
7812 return PointerToInt;
7815 return Incompatible;
7819 if (isa<ObjCObjectPointerType>(RHSType)) {
7821 if (LHSType == Context.
BoolTy) {
7822 Kind = CK_PointerToBoolean;
7828 Kind = CK_PointerToIntegral;
7829 return PointerToInt;
7832 return Incompatible;
7836 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
7844 Kind = CK_IntToOCLSampler;
7848 return Incompatible;
7861 Initializer->
setType(UnionType);
7880 return Incompatible;
7886 for (
auto *it : UD->
fields()) {
7887 if (it->getType()->isPointerType()) {
7893 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
7898 if (RHS.
get()->isNullPointerConstant(Context,
7900 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
7908 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
7910 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
7917 return Incompatible;
7926 bool DiagnoseCFAudited,
7930 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
7936 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
7956 return Incompatible;
7961 return Incompatible;
7963 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
7964 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
7965 result = IncompatibleObjCWeakRef;
7977 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
7978 RHS.
get(), LHSType,
false, DAP))
7979 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
7981 return Incompatible;
7988 RHS.
get()->isNullPointerConstant(Context,
7990 if (Diagnose || ConvertRHS) {
7993 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8009 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8011 return Incompatible;
8014 Expr *PRE = RHS.
get()->IgnoreParenCasts();
8015 if (Diagnose && isa<ObjCProtocolExpr>(PRE)) {
8025 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8033 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8040 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8041 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8042 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8044 return Incompatible;
8046 if (getLangOpts().ObjC1 &&
8047 (CheckObjCBridgeRelatedConversions(E->
getLocStart(), LHSType,
8049 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8051 return Incompatible;
8059 RHS = ImpCastExprToType(E, Ty, Kind);
8066 Diag(Loc, diag::err_typecheck_invalid_operands)
8067 << LHS.
get()->getType() << RHS.
get()->getType()
8068 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8077 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8078 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8083 if (!(LHSNatVec && RHSNatVec)) {
8084 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8085 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8086 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8092 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8093 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8094 << RHS.
get()->getSourceRange();
8124 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8129 scalarCast = CK_IntegralCast;
8134 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8137 scalarCast = CK_FloatingCast;
8140 scalarCast = CK_IntegralToFloating;
8149 if (scalarCast != CK_NoOp)
8160 assert(VecTy &&
"Expression E must be a vector");
8162 VecTy->getNumElements(),
8163 VecTy->getVectorKind());
8167 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8168 if (ICE->getSubExpr()->getType() == NewVecTy)
8169 return ICE->getSubExpr();
8171 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
8179 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8184 llvm::APSInt Result;
8185 bool CstInt = Int->
get()->EvaluateAsInt(Result, S.
Context);
8193 unsigned NumBits = IntSigned
8194 ? (Result.isNegative() ? Result.getMinSignedBits()
8195 : Result.getActiveBits())
8196 : Result.getActiveBits();
8203 return (IntSigned != OtherIntSigned &&
8216 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8220 llvm::APSInt Result;
8221 bool CstInt = Int->
get()->EvaluateAsInt(Result, S.
Context);
8231 llvm::APFloat::rmTowardZero);
8234 bool Ignored =
false;
8235 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8237 if (Result != ConvertBack)
8243 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8245 if (Bits > FloatPrec)
8258 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
8259 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
8262 assert(!isa<ExtVectorType>(VT) &&
8263 "ExtVectorTypes should not be handled here!");
8290 ScalarCast = CK_IntegralCast;
8296 llvm::APFloat Result(0.0);
8297 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
8299 if (!CstScalar && Order < 0)
8305 bool Truncated =
false;
8307 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8312 ScalarCast = CK_FloatingCast;
8317 ScalarCast = CK_IntegralToFloating;
8324 if (ScalarCast != CK_NoOp)
8334 bool AllowBoolConversions) {
8335 if (!IsCompAssign) {
8336 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
8340 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
8346 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
8347 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
8351 assert(LHSVecType || RHSVecType);
8355 if (!AllowBothBool &&
8358 return InvalidOperands(Loc, LHS, RHS);
8365 if (LHSVecType && RHSVecType &&
8367 if (isa<ExtVectorType>(LHSVecType)) {
8368 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8373 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8380 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8383 Context.
getTypeSize(RHSVecType->getElementType()))) {
8387 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8390 if (!IsCompAssign &&
8393 RHSVecType->getElementType()->isIntegerType()) {
8394 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8401 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8403 if (isa<ExtVectorType>(LHSVecType)) {
8414 if (isa<ExtVectorType>(RHSVecType)) {
8416 LHSType, RHSVecType->getElementType(),
8429 QualType VecType = LHSVecType ? LHSType : RHSType;
8430 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8431 QualType OtherType = LHSVecType ? RHSType : LHSType;
8432 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8433 if (isLaxVectorConversion(OtherType, VecType)) {
8437 if (!IsCompAssign) {
8438 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
8448 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
8456 if ((!RHSVecType && !RHSType->
isRealType()) ||
8458 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8459 << LHSType << RHSType
8460 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8468 if (getLangOpts().OpenCL &&
8469 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8470 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8471 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
8480 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
8481 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
8482 QualType Scalar = LHSVecType ? RHSType : LHSType;
8483 QualType Vector = LHSVecType ? LHSType : RHSType;
8484 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
8486 diag::err_typecheck_vector_not_convertable_implict_truncation)
8487 << ScalarOrVector << Scalar << Vector;
8494 << LHSType << RHSType
8495 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8507 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
8508 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
8510 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
8514 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8515 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8521 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8529 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8530 NonNullType->canDecayToPointerType())
8533 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8534 << LHSNull << NonNullType
8535 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8542 llvm::APSInt RHSValue;
8543 if (!RHS.
get()->isValueDependent() &&
8544 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) && RHSValue == 0)
8546 S.
PDiag(diag::warn_remainder_division_by_zero)
8547 << IsDiv << RHS.
get()->getSourceRange());
8552 bool IsCompAssign,
bool IsDiv) {
8555 if (LHS.
get()->getType()->isVectorType() ||
8556 RHS.
get()->getType()->isVectorType())
8557 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8558 getLangOpts().AltiVec,
8561 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8567 return InvalidOperands(Loc, LHS, RHS);
8577 if (LHS.
get()->getType()->isVectorType() ||
8578 RHS.
get()->getType()->isVectorType()) {
8579 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
8580 RHS.
get()->getType()->hasIntegerRepresentation())
8581 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8582 getLangOpts().AltiVec,
8584 return InvalidOperands(Loc, LHS, RHS);
8587 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8592 return InvalidOperands(Loc, LHS, RHS);
8601 ? diag::err_typecheck_pointer_arith_void_type
8602 : diag::ext_gnu_void_ptr)
8611 ? diag::err_typecheck_pointer_arith_void_type
8612 : diag::ext_gnu_void_ptr)
8622 Expr *Pointer,
bool IsGNUIdiom) {
8624 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
8627 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
8637 ? diag::err_typecheck_pointer_arith_function_type
8638 : diag::ext_gnu_ptr_func_arith)
8652 ? diag::err_typecheck_pointer_arith_function_type
8653 : diag::ext_gnu_ptr_func_arith)
8666 ResType = ResAtomicType->getValueType();
8671 diag::err_typecheck_arithmetic_incomplete_type,
8687 ResType = ResAtomicType->getValueType();
8719 if (!isLHSPointer && !isRHSPointer)
return true;
8721 QualType LHSPointeeTy, RHSPointeeTy;
8726 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
8731 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8739 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
8740 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
8741 if (isLHSVoidPtr || isRHSVoidPtr) {
8749 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
8750 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
8751 if (isLHSFuncPtr || isRHSFuncPtr) {
8773 Expr* IndexExpr = RHSExpr;
8776 IndexExpr = LHSExpr;
8779 bool IsStringPlusInt = StrExpr &&
8781 if (!IsStringPlusInt || IndexExpr->isValueDependent())
8785 if (IndexExpr->EvaluateAsInt(index, Self.
getASTContext())) {
8786 unsigned StrLenWithNull = StrExpr->
getLength() + 1;
8787 if (index.isNonNegative() &&
8788 index <= llvm::APSInt(llvm::APInt(index.getBitWidth(), StrLenWithNull),
8789 index.isUnsigned()))
8794 Self.
Diag(OpLoc, diag::warn_string_plus_int)
8795 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
8798 if (IndexExpr == RHSExpr) {
8800 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8805 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8811 const Expr *StringRefExpr = LHSExpr;
8817 StringRefExpr = RHSExpr;
8820 if (!CharExpr || !StringRefExpr)
8837 if (!CharType->isAnyCharacterType() &&
8838 CharType->isIntegerType() &&
8840 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8841 << DiagRange << Ctx.
CharTy;
8843 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8844 << DiagRange << CharExpr->
getType();
8850 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8855 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8864 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
8875 if (LHS.
get()->getType()->isVectorType() ||
8876 RHS.
get()->getType()->isVectorType()) {
8877 QualType compType = CheckVectorOperands(
8878 LHS, RHS, Loc, CompLHSTy,
8879 getLangOpts().AltiVec,
8880 getLangOpts().ZVector);
8881 if (CompLHSTy) *CompLHSTy = compType;
8885 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
8890 if (Opc == BO_Add) {
8897 if (CompLHSTy) *CompLHSTy = compType;
8907 isObjCPointer =
false;
8909 isObjCPointer =
true;
8911 std::swap(PExp, IExp);
8913 isObjCPointer =
false;
8915 isObjCPointer =
true;
8917 return InvalidOperands(Loc, LHS, RHS);
8922 if (!IExp->getType()->isIntegerType())
8923 return InvalidOperands(Loc, LHS, RHS);
8929 llvm::APSInt KnownVal;
8930 if (!getLangOpts().CPlusPlus ||
8931 (!IExp->isValueDependent() &&
8932 (!IExp->EvaluateAsInt(KnownVal, Context) || KnownVal != 0))) {
8935 Context, BO_Add, PExp, IExp);
8947 CheckArrayAccess(PExp, IExp);
8952 LHSTy = LHS.
get()->getType();
8968 if (LHS.
get()->getType()->isVectorType() ||
8969 RHS.
get()->getType()->isVectorType()) {
8970 QualType compType = CheckVectorOperands(
8971 LHS, RHS, Loc, CompLHSTy,
8972 getLangOpts().AltiVec,
8973 getLangOpts().ZVector);
8974 if (CompLHSTy) *CompLHSTy = compType;
8978 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
8986 if (CompLHSTy) *CompLHSTy = compType;
8991 if (LHS.
get()->getType()->isAnyPointerType()) {
8992 QualType lpointee = LHS.
get()->getType()->getPointeeType();
8995 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9000 if (RHS.
get()->getType()->isIntegerType()) {
9004 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9007 llvm::APSInt KnownVal;
9008 if (!getLangOpts().CPlusPlus ||
9009 (!RHS.
get()->isValueDependent() &&
9010 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) || KnownVal != 0))) {
9019 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9022 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9023 return LHS.
get()->getType();
9057 if (ElementSize.
isZero()) {
9058 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9060 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9064 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9069 return InvalidOperands(Loc, LHS, RHS);
9074 return ET->getDecl()->isScoped();
9088 if (RHS.
get()->isValueDependent() ||
9092 if (Right.isNegative()) {
9094 S.
PDiag(diag::warn_shift_negative)
9095 << RHS.
get()->getSourceRange());
9098 llvm::APInt LeftBits(Right.getBitWidth(),
9100 if (Right.uge(LeftBits)) {
9102 S.
PDiag(diag::warn_shift_gt_typewidth)
9103 << RHS.
get()->getSourceRange());
9114 if (LHS.
get()->isValueDependent() ||
9123 S.
PDiag(diag::warn_shift_lhs_negative)
9124 << LHS.
get()->getSourceRange());
9128 llvm::APInt ResultBits =
9129 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9130 if (LeftBits.uge(ResultBits))
9132 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9133 Result = Result.shl(Right);
9138 Result.toString(HexResult, 16,
false,
true);
9144 if (LeftBits == ResultBits - 1) {
9145 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9146 << HexResult << LHSType
9147 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9151 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
9152 << HexResult.str() << Result.getMinSignedBits() << LHSType
9153 << Left.getBitWidth() << LHS.
get()->getSourceRange()
9154 << RHS.
get()->getSourceRange();
9163 !LHS.
get()->getType()->isVectorType()) {
9164 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
9165 << RHS.
get()->getType() << LHS.
get()->getType()
9166 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9170 if (!IsCompAssign) {
9190 if (!LHSEleType->isIntegerType()) {
9191 S.
Diag(Loc, diag::err_typecheck_expect_int)
9192 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
9196 if (!RHSEleType->isIntegerType()) {
9197 S.
Diag(Loc, diag::err_typecheck_expect_int)
9198 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
9206 if (LHSEleType != RHSEleType) {
9208 LHSEleType = RHSEleType;
9214 }
else if (RHSVecTy) {
9219 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9220 << LHS.
get()->getType() << RHS.
get()->getType()
9221 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9227 if (LHSBT != RHSBT &&
9229 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9230 << LHS.
get()->getType() << RHS.
get()->getType()
9231 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9247 bool IsCompAssign) {
9251 if (LHS.
get()->getType()->isVectorType() ||
9252 RHS.
get()->getType()->isVectorType()) {
9253 if (LangOpts.ZVector) {
9257 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
9259 return InvalidOperands(Loc, LHS, RHS);
9260 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
9262 return InvalidOperands(Loc, LHS, RHS);
9273 LHS = UsualUnaryConversions(LHS.
get());
9277 if (IsCompAssign) LHS = OldLHS;
9280 RHS = UsualUnaryConversions(RHS.
get());
9288 return InvalidOperands(Loc, LHS, RHS);
9294 return InvalidOperands(Loc, LHS, RHS);
9305 if (isa<ClassTemplateSpecializationDecl>(DC))
9308 return FD->isFunctionTemplateSpecialization();
9337 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9338 << LHSStrippedType << RHSStrippedType
9346 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9347 : diag::ext_typecheck_comparison_of_distinct_pointers)
9348 << LHS.
get()->getType() << RHS.
get()->getType()
9349 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9389 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9390 : diag::ext_typecheck_comparison_of_fptr_to_void)
9391 << LHS.
get()->getType() << RHS.
get()->getType()
9392 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9396 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
9397 case Stmt::ObjCArrayLiteralClass:
9398 case Stmt::ObjCDictionaryLiteralClass:
9399 case Stmt::ObjCStringLiteralClass:
9400 case Stmt::ObjCBoxedExprClass:
9459 case Stmt::ObjCStringLiteralClass:
9462 case Stmt::ObjCArrayLiteralClass:
9465 case Stmt::ObjCDictionaryLiteralClass:
9467 return LK_Dictionary;
9468 case Stmt::BlockExprClass:
9470 case Stmt::ObjCBoxedExprClass: {
9473 case Stmt::IntegerLiteralClass:
9474 case Stmt::FloatingLiteralClass:
9475 case Stmt::CharacterLiteralClass:
9476 case Stmt::ObjCBoolLiteralExprClass:
9477 case Stmt::CXXBoolLiteralExprClass:
9480 case Stmt::ImplicitCastExprClass: {
9481 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
9483 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
9502 Literal = LHS.
get();
9505 Literal = RHS.
get();
9521 llvm_unreachable(
"Unknown Objective-C object literal kind");
9525 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
9528 S.
Diag(Loc, diag::warn_objc_literal_comparison)
9538 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
9551 if (!UO || UO->
getOpcode() != UO_LNot)
return;
9554 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
9561 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
9563 << Loc << IsBitwiseOp;
9591 return DR->getDecl();
9593 if (Ivar->isFreeIvar())
9594 return Ivar->getDecl();
9596 if (
MemberExpr* Mem = dyn_cast<MemberExpr>(E)) {
9597 if (Mem->isImplicitAccess())
9598 return Mem->getMemberDecl();
9606 bool IsRelational) {
9610 if (LHS.
get()->getType()->isVectorType() ||
9611 RHS.
get()->getType()->isVectorType())
9612 return CheckVectorCompareOperands(LHS, RHS, Loc, IsRelational);
9617 Expr *LHSStripped = LHS.
get()->IgnoreParenImpCasts();
9618 Expr *RHSStripped = RHS.
get()->IgnoreParenImpCasts();
9625 !LHS.
get()->getLocStart().isMacroID() &&
9626 !RHS.
get()->getLocStart().isMacroID() &&
9627 !inTemplateInstantiation()) {
9641 DiagRuntimeBehavior(Loc,
nullptr, PDiag(diag::warn_comparison_always)
9650 char always_evals_to;
9653 always_evals_to = 0;
9656 always_evals_to = 1;
9660 always_evals_to = 2;
9663 DiagRuntimeBehavior(Loc,
nullptr, PDiag(diag::warn_comparison_always)
9665 << always_evals_to);
9668 if (isa<CastExpr>(LHSStripped))
9670 if (isa<CastExpr>(RHSStripped))
9675 Expr *literalString =
nullptr;
9676 Expr *literalStringStripped =
nullptr;
9677 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
9680 literalString = LHS.
get();
9681 literalStringStripped = LHSStripped;
9682 }
else if ((isa<StringLiteral>(RHSStripped) ||
9683 isa<ObjCEncodeExpr>(RHSStripped)) &&
9686 literalString = RHS.
get();
9687 literalStringStripped = RHSStripped;
9690 if (literalString) {
9691 DiagRuntimeBehavior(Loc,
nullptr,
9692 PDiag(diag::warn_stringcompare)
9693 << isa<ObjCEncodeExpr>(literalStringStripped)
9699 UsualArithmeticConversions(LHS, RHS);
9703 LHSType = LHS.
get()->getType();
9704 RHSType = RHS.
get()->getType();
9715 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
9728 if (!IsRelational && LHSIsNull != RHSIsNull) {
9729 bool IsEquality = Opc == BO_EQ;
9731 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
9732 RHS.
get()->getSourceRange());
9734 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
9735 LHS.
get()->getSourceRange());
9742 }
else if (getLangOpts().CPlusPlus) {
9747 if (!IsRelational &&
9754 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
9756 if (isSFINAEContext())
9759 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
9770 (IsRelational ? 2 : 1) &&
9771 (!LangOpts.ObjCAutoRefCount ||
9793 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
9794 << LHSType << RHSType << LHS.
get()->getSourceRange()
9795 << RHS.
get()->getSourceRange();
9797 }
else if (!IsRelational &&
9801 && !LHSIsNull && !RHSIsNull)
9808 if (LCanPointeeTy != RCanPointeeTy) {
9810 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
9814 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9815 << LHSType << RHSType << 0
9816 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9821 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
9823 if (LHSIsNull && !RHSIsNull)
9824 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
9826 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
9831 if (getLangOpts().CPlusPlus) {
9835 if (!IsRelational && LHSIsNull && RHSIsNull) {
9837 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
9841 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
9850 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
9855 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
9868 if (isa<FunctionDecl>(DC))
9870 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
9871 if (CTSD->isInStdNamespace() &&
9872 llvm::StringSwitch<bool>(CTSD->getName())
9873 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
9876 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
9878 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
9887 if (!IsRelational &&
9897 if (LHS.
get()->getType()->isEnumeralType() &&
9899 RHS.
get()->getType()))
9909 if (!LHSIsNull && !RHSIsNull &&
9911 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9912 << LHSType << RHSType << LHS.
get()->getSourceRange()
9913 << RHS.
get()->getSourceRange();
9915 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
9923 if (!LHSIsNull && !RHSIsNull) {
9928 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9929 << LHSType << RHSType << LHS.
get()->getSourceRange()
9930 << RHS.
get()->getSourceRange();
9932 if (LHSIsNull && !RHSIsNull)
9933 LHS = ImpCastExprToType(LHS.
get(), RHSType,
9935 : CK_AnyPointerToBlockPointerCast);
9937 RHS = ImpCastExprToType(RHS.get(), LHSType,
9939 : CK_AnyPointerToBlockPointerCast);
9949 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
9951 if (!LPtrToVoid && !RPtrToVoid &&
9956 if (LHSIsNull && !RHSIsNull) {
9958 if (getLangOpts().ObjCAutoRefCount)
9960 CCK_ImplicitConversion);
9961 LHS = ImpCastExprToType(E, RHSType,
9962 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
9966 if (getLangOpts().ObjCAutoRefCount)
9967 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
9970 RHS = ImpCastExprToType(E, LHSType,
9971 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
9983 if (LHSIsNull && !RHSIsNull)
9984 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
9986 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
9992 unsigned DiagID = 0;
9993 bool isError =
false;
9994 if (LangOpts.DebuggerSupport) {
10000 isError = getLangOpts().CPlusPlus;
10002 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
10003 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
10006 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
10008 }
else if (IsRelational)
10009 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
10011 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
10015 << LHSType << RHSType << LHS.
get()->getSourceRange()
10016 << RHS.
get()->getSourceRange();
10022 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10023 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10025 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10026 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10031 if (!IsRelational && RHSIsNull
10033 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10036 if (!IsRelational && LHSIsNull
10038 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10042 if (getLangOpts().OpenCLVersion >= 200) {
10043 if (LHSIsNull && RHSType->
isQueueT()) {
10044 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10048 if (LHSType->
isQueueT() && RHSIsNull) {
10049 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10054 return InvalidOperands(Loc, LHS, RHS);
10066 if (isa<ExtVectorType>(VTy)) {
10076 "Unhandled vector element size in vector compare");
10093 "Unhandled vector element size in vector compare");
10104 bool IsRelational) {
10107 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10109 getLangOpts().ZVector);
10117 if (getLangOpts().AltiVec &&
10126 = dyn_cast<DeclRefExpr>(LHS.
get()->IgnoreParenImpCasts()))
10128 = dyn_cast<DeclRefExpr>(RHS.
get()->IgnoreParenImpCasts()))
10129 if (DRL->getDecl() == DRR->getDecl())
10130 DiagRuntimeBehavior(Loc,
nullptr,
10131 PDiag(diag::warn_comparison_always)
10139 assert (RHS.
get()->getType()->hasFloatingRepresentation());
10140 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
10144 return GetSignedVectorType(vType);
10151 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10155 return InvalidOperands(Loc, LHS, RHS);
10156 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
10158 return InvalidOperands(Loc, LHS, RHS);
10162 if (!getLangOpts().CPlusPlus &&
10164 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
10166 return GetSignedVectorType(LHS.
get()->getType());
10174 bool IsCompAssign =
10175 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
10177 if (LHS.
get()->getType()->isVectorType() ||
10178 RHS.
get()->getType()->isVectorType()) {
10179 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
10180 RHS.
get()->getType()->hasIntegerRepresentation())
10181 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
10183 getLangOpts().ZVector);
10184 return InvalidOperands(Loc, LHS, RHS);
10190 ExprResult LHSResult = LHS, RHSResult = RHS;
10191 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
10193 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
10195 LHS = LHSResult.
get();
10196 RHS = RHSResult.
get();
10200 return InvalidOperands(Loc, LHS, RHS);
10208 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
10209 return CheckVectorLogicalOperands(LHS, RHS, Loc);
10214 if (LHS.
get()->getType()->isIntegerType() &&
10215 !LHS.
get()->getType()->isBooleanType() &&
10216 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
10218 !Loc.
isMacroID() && !inTemplateInstantiation()) {
10223 llvm::APSInt Result;
10224 if (RHS.
get()->EvaluateAsInt(Result, Context))
10225 if ((getLangOpts().Bool && !RHS.
get()->getType()->isBooleanType() &&
10226 !RHS.
get()->getExprLoc().isMacroID()) ||
10227 (Result != 0 && Result != 1)) {
10228 Diag(Loc, diag::warn_logical_instead_of_bitwise)
10229 << RHS.
get()->getSourceRange()
10230 << (Opc == BO_LAnd ?
"&&" :
"||");
10232 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
10233 << (Opc == BO_LAnd ?
"&" :
"|")
10235 Loc, getLocForEndOfToken(Loc)),
10236 Opc == BO_LAnd ?
"&" :
"|");
10237 if (Opc == BO_LAnd)
10239 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
10242 RHS.
get()->getLocEnd()));
10251 if (LHS.
get()->getType()->isFloatingType() ||
10252 RHS.
get()->getType()->isFloatingType())
10253 return InvalidOperands(Loc, LHS, RHS);
10256 LHS = UsualUnaryConversions(LHS.
get());
10260 RHS = UsualUnaryConversions(RHS.
get());
10264 if (!LHS.
get()->getType()->isScalarType() ||
10265 !RHS.
get()->getType()->isScalarType())
10266 return InvalidOperands(Loc, LHS, RHS);
10268 return Context.
IntTy;
10277 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
10279 return InvalidOperands(Loc, LHS, RHS);
10282 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
10284 return InvalidOperands(Loc, LHS, RHS);
10295 if (!ME)
return false;
10299 if (!Base)
return false;
10320 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
10328 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
10371 bool DiagnosticEmitted =
false;
10375 bool IsDereference =
false;
10376 bool NextIsDereference =
false;
10380 IsDereference = NextIsDereference;
10383 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
10384 NextIsDereference = ME->isArrow();
10385 const ValueDecl *VD = ME->getMemberDecl();
10386 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
10388 if (Field->isMutable()) {
10389 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
10394 if (!DiagnosticEmitted) {
10395 S.
Diag(Loc, diag::err_typecheck_assign_const)
10397 << Field->getType();
10398 DiagnosticEmitted =
true;
10401 <<
ConstMember <<
false << Field << Field->getType()
10402 << Field->getSourceRange();
10406 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
10407 if (VDecl->getType().isConstQualified()) {
10408 if (!DiagnosticEmitted) {
10409 S.
Diag(Loc, diag::err_typecheck_assign_const)
10411 << VDecl->getType();
10412 DiagnosticEmitted =
true;
10415 <<
ConstMember <<
true << VDecl << VDecl->getType()
10416 << VDecl->getSourceRange();
10426 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
10430 if (!DiagnosticEmitted) {
10431 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
10433 DiagnosticEmitted =
true;
10436 diag::note_typecheck_assign_const)
10440 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
10442 if (
const ValueDecl *VD = DRE->getDecl()) {
10444 if (!DiagnosticEmitted) {
10445 S.
Diag(Loc, diag::err_typecheck_assign_const)
10447 DiagnosticEmitted =
true;
10449 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
10450 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
10453 }
else if (isa<CXXThisExpr>(E)) {
10455 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
10456 if (MD->isConst()) {
10457 if (!DiagnosticEmitted) {
10458 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
10460 DiagnosticEmitted =
true;
10462 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
10469 if (DiagnosticEmitted)
10473 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
10486 bool &DiagnosticEmitted,
10487 bool IsNested =
false) {
10492 if (Field->getType().isConstQualified()) {
10493 if (!DiagnosticEmitted) {
10494 S.
Diag(Loc, diag::err_typecheck_assign_const)
10496 << IsNested << Field;
10497 DiagnosticEmitted =
true;
10499 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
10501 << Field->getType() << Field->getSourceRange();
10509 OEK, DiagnosticEmitted,
true);
10518 assert(Ty->
isRecordType() &&
"lvalue was not record?");
10521 bool DiagEmitted =
false;
10523 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
10526 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
10551 unsigned DiagID = 0;
10552 bool NeedType =
false;
10559 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
10561 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
10569 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
10582 ? diag::err_typecheck_arc_assign_self_class_method
10583 : diag::err_typecheck_arc_assign_self;
10587 DiagID = diag::err_typecheck_arr_assign_enumeration;
10590 if (Loc != OrigLoc)
10616 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
10620 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
10624 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
10627 llvm_unreachable(
"did not take early return for MLV_Valid");
10631 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
10636 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
10638 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
10641 llvm_unreachable(
"readonly properties should be processed differently");
10643 DiagID = diag::err_readonly_message_assignment;
10646 DiagID = diag::err_no_subobject_property_setting;
10651 if (Loc != OrigLoc)
10666 if (ML && MR && ML->
getMemberDecl() == MR->getMemberDecl()) {
10667 if (isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase()))
10668 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
10674 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
10677 if (RL && RR && RL->
getDecl() == RR->getDecl())
10678 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
10698 if (getLangOpts().OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
10700 Diag(Loc, diag::err_opencl_half_load_store) << 1
10706 if (CompoundType.
isNull()) {
10712 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
10716 if (ConvTy == IncompatiblePointer &&
10721 ConvTy = Compatible;
10723 if (ConvTy == Compatible &&
10725 Diag(Loc, diag::err_objc_object_assignment)
10732 RHSCheck = ICE->getSubExpr();
10733 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
10734 if ((UO->getOpcode() == UO_Plus ||
10735 UO->getOpcode() == UO_Minus) &&
10736 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
10742 UO->getSubExpr()->getLocStart().
isFileID()) {
10743 Diag(Loc, diag::warn_not_compound_assign)
10744 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
10745 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
10749 if (ConvTy == Compatible) {
10757 checkRetainCycles(LHSExpr, RHS.
get());
10771 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
10772 RHS.
get()->getLocStart()))
10773 getCurFunction()->markSafeWeakUse(RHS.
get());
10775 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
10776 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
10781 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
10784 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
10785 RHS.
get(), AA_Assigning))
10805 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
10806 if (CE->getCastKind() == CK_ToVoid) {
10823 if (inTemplateInstantiation())
10832 const unsigned ForIncrementFlags =
10835 const unsigned ScopeFlags = getCurScope()->getFlags();
10836 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
10837 (ScopeFlags & ForInitFlags) == ForInitFlags)
10842 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
10843 if (BO->getOpcode() != BO_Comma)
10845 LHS = BO->getRHS();
10852 Diag(Loc, diag::warn_comma_operator);
10856 LangOpts.CPlusPlus ?
"static_cast<void>(" 10886 if (!RHS.
get()->getType()->isVoidType())
10888 diag::err_incomplete_type);
10894 return RHS.
get()->getType();
10903 bool IsInc,
bool IsPrefix) {
10912 ResType = ResAtomicType->getValueType();
10914 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
10916 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
10924 : diag::warn_increment_bool)
10926 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
10928 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
10930 }
else if (ResType->isRealType()) {
10932 }
else if (ResType->isPointerType()) {
10936 }
else if (ResType->isObjCObjectPointerType()) {
10942 }
else if (ResType->isAnyComplexType()) {
10944 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
10946 }
else if (ResType->isPlaceholderType()) {
10951 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
10953 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
10954 (ResType->getAs<
VectorType>()->getVectorKind() !=
10957 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
10961 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
10978 return ResType.getUnqualifiedType();
10997 case Stmt::DeclRefExprClass:
10998 return cast<DeclRefExpr>(E)->getDecl();
10999 case Stmt::MemberExprClass:
11003 if (cast<MemberExpr>(E)->isArrow())
11007 case Stmt::ArraySubscriptExprClass: {
11010 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
11012 if (ICE->getSubExpr()->getType()->isArrayType())
11017 case Stmt::UnaryOperatorClass: {
11029 case Stmt::ParenExprClass:
11031 case Stmt::ImplicitCastExprClass:
11043 AO_Vector_Element = 1,
11044 AO_Property_Expansion = 2,
11045 AO_Register_Variable = 3,
11065 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
11066 if (PTy->getKind() == BuiltinType::Overload) {
11067 Expr *E = OrigOp.
get()->IgnoreParens();
11068 if (!isa<OverloadExpr>(E)) {
11069 assert(cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf);
11070 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
11071 << OrigOp.
get()->getSourceRange();
11076 if (isa<UnresolvedMemberExpr>(Ovl))
11077 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
11078 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11079 << OrigOp.
get()->getSourceRange();
11086 if (PTy->getKind() == BuiltinType::UnknownAny)
11089 if (PTy->getKind() == BuiltinType::BoundMember) {
11090 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11091 << OrigOp.
get()->getSourceRange();
11095 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
11099 if (OrigOp.
get()->isTypeDependent())
11102 assert(!OrigOp.
get()->getType()->isPlaceholderType());
11105 Expr *op = OrigOp.
get()->IgnoreParens();
11112 if (LangOpts.OpenCL) {
11114 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
11115 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
11120 if (getLangOpts().
C99) {
11123 if (uOp->getOpcode() == UO_Deref)
11126 return uOp->getSubExpr()->getType();
11133 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
11139 unsigned AddressOfError = AO_No_Error;
11142 bool sfinae = (
bool)isSFINAEContext();
11143 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
11144 : diag::ext_typecheck_addrof_temporary)
11150 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
11151 }
else if (isa<ObjCSelectorExpr>(op)) {
11158 if (!isa<DeclRefExpr>(op)) {
11159 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11160 << OrigOp.
get()->getSourceRange();
11167 if (OrigOp.
get() != DRE) {
11168 Diag(OpLoc, diag::err_parens_pointer_member_function)
11169 << OrigOp.
get()->getSourceRange();
11173 if (MD->getParent()->getName().empty())
11174 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11178 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
11179 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11186 if (isa<CXXDestructorDecl>(MD))
11193 (
void)isCompleteType(OpLoc, MPTy);
11200 if (isa<PseudoObjectExpr>(op)) {
11201 AddressOfError = AO_Property_Expansion;
11203 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
11210 AddressOfError = AO_Bit_Field;
11213 AddressOfError = AO_Vector_Element;
11217 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
11221 !getLangOpts().CPlusPlus) {
11222 AddressOfError = AO_Register_Variable;
11224 }
else if (isa<MSPropertyDecl>(dcl)) {
11225 AddressOfError = AO_Property_Expansion;
11226 }
else if (isa<FunctionTemplateDecl>(dcl)) {
11228 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
11232 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
11237 diag::err_cannot_form_pointer_to_member_of_reference_type)
11242 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
11250 (
void)isCompleteType(OpLoc, MPTy);
11254 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
11255 !isa<BindingDecl>(dcl))
11256 llvm_unreachable(
"Unknown/unexpected decl type");
11259 if (AddressOfError != AO_No_Error) {
11275 CheckAddressOfPackedMember(op);
11291 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
11294 if (!FD->ModifiedNonNullParams.count(Param))
11295 FD->ModifiedNonNullParams.insert(Param);
11305 if (ConvResult.isInvalid())
11307 Op = ConvResult.get();
11311 if (isa<CXXReinterpretCastExpr>(Op)) {
11327 if (PR.
get() != Op)
11332 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
11347 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
11363 default: llvm_unreachable(
"Unknown binop!");
11364 case tok::periodstar: Opc = BO_PtrMemD;
break;
11365 case tok::arrowstar: Opc = BO_PtrMemI;
break;
11366 case tok::star: Opc = BO_Mul;
break;
11367 case tok::slash: Opc = BO_Div;
break;
11368 case tok::percent: Opc = BO_Rem;
break;
11369 case tok::plus: Opc = BO_Add;
break;
11370 case tok::minus: Opc = BO_Sub;
break;
11371 case tok::lessless: Opc = BO_Shl;
break;
11372 case tok::greatergreater: Opc = BO_Shr;
break;
11373 case tok::lessequal: Opc = BO_LE;
break;
11374 case tok::less: Opc = BO_LT;
break;
11375 case tok::greaterequal: Opc = BO_GE;
break;
11376 case tok::greater: Opc = BO_GT;
break;
11377 case tok::exclaimequal: Opc = BO_NE;
break;
11378 case tok::equalequal: Opc = BO_EQ;
break;
11379 case tok::spaceship: Opc = BO_Cmp;
break;
11380 case tok::amp: Opc = BO_And;
break;
11381 case tok::caret: Opc = BO_Xor;
break;
11382 case tok::pipe: Opc = BO_Or;
break;
11383 case tok::ampamp: Opc = BO_LAnd;
break;
11384 case tok::pipepipe: Opc = BO_LOr;
break;
11385 case tok::equal: Opc = BO_Assign;
break;
11386 case tok::starequal: Opc = BO_MulAssign;
break;
11387 case tok::slashequal: Opc = BO_DivAssign;
break;
11388 case tok::percentequal: Opc = BO_RemAssign;
break;
11389 case tok::plusequal: Opc = BO_AddAssign;
break;
11390 case tok::minusequal: Opc = BO_SubAssign;
break;
11391 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
11392 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
11393 case tok::ampequal: Opc = BO_AndAssign;
break;
11394 case tok::caretequal: Opc = BO_XorAssign;
break;
11395 case tok::pipeequal: Opc = BO_OrAssign;
break;
11396 case tok::comma: Opc = BO_Comma;
break;
11405 default: llvm_unreachable(
"Unknown unary op!");
11406 case tok::plusplus: Opc = UO_PreInc;
break;
11407 case tok::minusminus: Opc = UO_PreDec;
break;
11408 case tok::amp: Opc = UO_AddrOf;
break;
11409 case tok::star: Opc = UO_Deref;
break;
11410 case tok::plus: Opc = UO_Plus;
break;
11411 case tok::minus: Opc = UO_Minus;
break;
11412 case tok::tilde: Opc = UO_Not;
break;
11413 case tok::exclaim: Opc = UO_LNot;
break;
11414 case tok::kw___real: Opc = UO_Real;
break;
11415 case tok::kw___imag: Opc = UO_Imag;
break;
11416 case tok::kw___extension__: Opc = UO_Extension;
break;
11434 if (!LHSDeclRef || !RHSDeclRef ||
11436 RHSDeclRef->getLocation().isMacroID())
11441 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
11442 if (LHSDecl != RHSDecl)
11447 if (RefTy->getPointeeType().isVolatileQualified())
11450 S.
Diag(OpLoc, diag::warn_self_assignment)
11462 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
11467 ObjCPointerExpr = LHS;
11471 ObjCPointerExpr = RHS;
11479 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
11480 unsigned Diag = diag::warn_objc_pointer_masking;
11489 if (SelArg0.startswith(
"performSelector"))
11490 Diag = diag::warn_objc_pointer_masking_performSelector;
11493 S.
Diag(OpLoc, Diag)
11501 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
11502 return DRE->getDecl();
11503 if (
auto *ME = dyn_cast<MemberExpr>(E))
11504 return ME->getMemberDecl();
11505 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
11506 return IRE->getDecl();
11521 "Result must be a vector of half or short");
11524 "both operands expected to be a half vector");
11536 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
11537 OpLoc, FPFeatures);
11541 VK, OK, OpLoc, FPFeatures);
11545 static std::pair<ExprResult, ExprResult>
11555 if (Opc != BO_Assign)
11562 return std::make_pair(LHS, RHS);
11569 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
11580 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
11592 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
11595 RHSExpr = Init.
get();
11605 bool ConvertHalfVec =
false;
11608 if (!LHS.
isUsable() || !RHS.isUsable())
11611 if (getLangOpts().OpenCL) {
11618 if (BO_Assign == Opc)
11619 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
11621 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
11631 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
11638 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
11639 if (getLangOpts().CPlusPlus &&
11641 VK = LHS.
get()->getValueKind();
11642 OK = LHS.
get()->getObjectKind();
11644 if (!ResultTy.
isNull()) {
11646 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
11652 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
11653 Opc == BO_PtrMemI);
11657 ConvertHalfVec =
true;
11658 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
11662 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
11665 ConvertHalfVec =
true;
11666 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
11669 ConvertHalfVec =
true;
11670 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
11674 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
11680 ConvertHalfVec =
true;
11681 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
true);
11685 ConvertHalfVec =
true;
11686 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
false);
11690 ConvertHalfVec =
true;
11691 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
true);
11693 ResultTy = Context.
VoidTy;
11700 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
11704 ConvertHalfVec =
true;
11705 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
11709 ConvertHalfVec =
true;
11710 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
11711 Opc == BO_DivAssign);
11712 CompLHSTy = CompResultTy;
11714 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
11717 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
11718 CompLHSTy = CompResultTy;
11720 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
11723 ConvertHalfVec =
true;
11724 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
11726 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
11729 ConvertHalfVec =
true;
11730 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
11732 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
11736 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
11737 CompLHSTy = CompResultTy;
11739 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
11746 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
11747 CompLHSTy = CompResultTy;
11749 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
11753 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
11754 VK = RHS.get()->getValueKind();
11755 OK = RHS.get()->getObjectKind();
11768 "both sides are half vectors or neither sides are");
11770 LHS.
get()->getType());
11773 CheckArrayAccess(LHS.
get());
11774 CheckArrayAccess(RHS.get());
11776 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
11777 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
11778 &Context.
Idents.
get(
"object_setClass"),
11780 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
11781 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getLocEnd());
11782 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign) <<
11788 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
11791 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
11795 if (CompResultTy.
isNull()) {
11796 if (ConvertHalfVec)
11798 OpLoc, FPFeatures);
11800 OK, OpLoc, FPFeatures);
11804 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
11807 OK = LHS.
get()->getObjectKind();
11810 if (ConvertHalfVec)
11812 OpLoc, FPFeatures);
11815 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
11816 OpLoc, FPFeatures);
11831 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
11832 if (isLeftComp == isRightComp)
11837 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
11838 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
11839 if (isLeftBitwise || isRightBitwise)
11845 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
11850 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
11853 Self.
PDiag(diag::note_precedence_silence) << OpStr,
11856 Self.
PDiag(diag::note_precedence_bitwise_first)
11871 Self.
PDiag(diag::note_precedence_silence)
11896 if (Bop->getOpcode() == BO_LAnd) {
11903 }
else if (Bop->getOpcode() == BO_LOr) {
11904 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
11907 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
11918 if (Bop->getOpcode() == BO_LAnd) {
11935 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
11936 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
11938 << Bop->getSourceRange() << OpLoc;
11940 S.
PDiag(diag::note_precedence_silence)
11941 << Bop->getOpcodeStr(),
11942 Bop->getSourceRange());
11950 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
11951 StringRef Op = Bop->getOpcodeStr();
11952 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
11953 << Bop->getSourceRange() << OpLoc << Shift << Op;
11955 S.
PDiag(diag::note_precedence_silence) << Op,
11956 Bop->getSourceRange());
11972 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
11975 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
11977 << (Kind == OO_LessLess);
11979 S.
PDiag(diag::note_precedence_silence)
11980 << (Kind == OO_LessLess ?
"<<" :
">>"),
11983 S.
PDiag(diag::note_evaluate_comparison_first),
11998 if ((Opc == BO_Or || Opc == BO_Xor) &&
12006 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
12012 || Opc == BO_Shr) {
12029 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
12030 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
12035 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
12049 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
12065 LHSExpr = LHS.
get();
12066 RHSExpr = RHS.
get();
12077 if (pty->getKind() == BuiltinType::PseudoObject &&
12079 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
12082 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
12088 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12090 RHSExpr = resolvedRHS.
get();
12103 if (Opc == BO_LT && inTemplateInstantiation() &&
12104 (pty->getKind() == BuiltinType::BoundMember ||
12105 pty->getKind() == BuiltinType::Overload)) {
12107 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
12108 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
12109 return isa<FunctionTemplateDecl>(ND);
12111 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
12112 : OE->getNameLoc(),
12113 diag::err_template_kw_missing)
12114 << OE->getName().getAsString() <<
"";
12119 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
12121 LHSExpr = LHS.
get();
12128 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
12129 if (getLangOpts().CPlusPlus &&
12134 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12138 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
12142 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12144 RHSExpr = resolvedRHS.
get();
12161 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12171 bool ConvertHalfVec =
false;
12172 if (getLangOpts().OpenCL) {
12180 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12182 << Input.
get()->getSourceRange());
12192 Opc == UO_PreInc ||
12194 Opc == UO_PreInc ||
12198 resultType = CheckAddressOfOperand(Input, OpLoc);
12202 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
12209 Input = UsualUnaryConversions(Input.
get());
12219 if (ConvertHalfVec)
12221 resultType = Input.
get()->getType();
12222 if (resultType->isDependentType())
12224 if (resultType->isArithmeticType())
12226 else if (resultType->isVectorType() &&
12229 resultType->getAs<
VectorType>()->getVectorKind() !=
12232 else if (getLangOpts().CPlusPlus &&
12234 resultType->isPointerType())
12237 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12238 << resultType << Input.
get()->getSourceRange());
12241 Input = UsualUnaryConversions(Input.
get());
12244 resultType = Input.
get()->getType();
12245 if (resultType->isDependentType())
12248 if (resultType->isComplexType() || resultType->isComplexIntegerType())
12250 Diag(OpLoc, diag::ext_integer_complement_complex)
12251 << resultType << Input.
get()->getSourceRange();
12252 else if (resultType->hasIntegerRepresentation())
12254 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
12259 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12260 << resultType << Input.
get()->getSourceRange());
12262 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12263 << resultType << Input.
get()->getSourceRange());
12269 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
12271 resultType = Input.
get()->getType();
12274 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
12275 Input = ImpCastExprToType(Input.
get(), Context.
FloatTy, CK_FloatingCast).
get();
12276 resultType = Context.
FloatTy;
12279 if (resultType->isDependentType())
12286 Input = ImpCastExprToType(Input.
get(), Context.
BoolTy,
12287 ScalarTypeToBooleanCastKind(resultType));
12292 if (!resultType->isIntegerType() && !resultType->isPointerType())
12293 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12294 << resultType << Input.
get()->getSourceRange());
12296 }
else if (resultType->isExtVectorType()) {
12303 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12304 << resultType << Input.
get()->getSourceRange());
12307 resultType = GetSignedVectorType(resultType);
12312 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12313 << resultType << Input.
get()->getSourceRange());
12326 if (Opc == UO_Real || Input.
get()->getType()->isAnyComplexType()) {
12329 VK = Input.
get()->getValueKind();
12332 Input = DefaultLvalueConversion(Input.
get());
12336 resultType = Input.
get()->getType();
12337 VK = Input.
get()->getValueKind();
12338 OK = Input.
get()->getObjectKind();
12343 assert(!Input.
get()->getType()->isDependentType() &&
12344 "the co_await expression must be non-dependant before " 12345 "building operator co_await");
12355 if (Opc != UO_AddrOf && Opc != UO_Deref)
12356 CheckArrayAccess(Input.
get());
12358 auto *UO =
new (Context)
12361 if (ConvertHalfVec)
12370 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
12371 if (!DRE->getQualifier())
12378 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
12381 return Method->isInstance();
12387 if (!ULE->getQualifier())
12392 if (Method->isInstance())
12412 if (pty->getKind() == BuiltinType::PseudoObject &&
12414 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
12417 if (Opc == UO_Extension)
12418 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12422 if (Opc == UO_AddrOf &&
12423 (pty->getKind() == BuiltinType::Overload ||
12424 pty->getKind() == BuiltinType::UnknownAny ||
12425 pty->getKind() == BuiltinType::BoundMember))
12426 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12429 ExprResult Result = CheckPlaceholderExpr(Input);
12431 Input = Result.
get();
12444 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
12447 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
12450 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12476 if (!cleanups)
return nullptr;
12479 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
12492 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
12499 DiscardCleanupsInEvaluationContext();
12500 PopExpressionEvaluationContext();
12506 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
12509 if (hasAnyUnrecoverableErrorsInThisFunction())
12510 DiscardCleanupsInEvaluationContext();
12511 assert(!Cleanup.exprNeedsCleanups() &&
12512 "cleanups within StmtExpr not correctly bound!");
12513 PopExpressionEvaluationContext();
12522 bool StmtExprMayBindToTemp =
false;
12528 LastLabelStmt =
Label;
12529 LastStmt =
Label->getSubStmt();
12532 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
12535 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
12538 Ty = LastExpr.
get()->getType().getUnqualifiedType();
12547 if (
Expr *rebuiltLastStmt
12549 LastExpr = rebuiltLastStmt;
12551 LastExpr = PerformCopyInitialization(
12561 if (LastExpr.
get() !=
nullptr) {
12562 if (!LastLabelStmt)
12566 StmtExprMayBindToTemp =
true;
12574 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
12575 if (StmtExprMayBindToTemp)
12576 return MaybeBindToTemporary(ResStmtExpr);
12577 return ResStmtExpr;
12592 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
12593 << ArgTy << TypeRange);
12598 && RequireCompleteType(BuiltinLoc, ArgTy,
12599 diag::err_offsetof_incomplete_type, TypeRange))
12602 bool DidWarnAboutNonPOD =
false;
12607 if (OC.isBrackets) {
12612 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
12618 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
12628 diag::err_typecheck_subscript_not_integer)
12632 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
12633 Exprs.push_back(Idx);
12641 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
12647 if (RequireCompleteType(OC.LocStart, CurrentType,
12648 diag::err_offsetof_incomplete_type))
12654 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
12666 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
12668 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
12669 : diag::ext_offsetof_non_pod_type;
12671 if (!IsSafe && !DidWarnAboutNonPOD &&
12672 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
12674 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
12676 DidWarnAboutNonPOD =
true;
12680 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
12681 LookupQualifiedName(R, RD);
12686 MemberDecl = IndirectMemberDecl->getAnonField();
12691 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
12699 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
12707 if (IndirectMemberDecl)
12708 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
12713 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
12715 if (Paths.getDetectedVirtual()) {
12716 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
12727 if (IndirectMemberDecl) {
12728 for (
auto *FI : IndirectMemberDecl->chain()) {
12729 assert(isa<FieldDecl>(FI));
12731 cast<FieldDecl>(FI), OC.LocEnd));
12734 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
12740 Comps, Exprs, RParenLoc);
12751 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
12758 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
12766 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
12771 bool ValueDependent =
false;
12772 bool CondIsTrue =
false;
12775 ValueDependent =
true;
12778 llvm::APSInt condEval(32);
12780 = VerifyIntegerConstantExpression(CondExpr, &condEval,
12781 diag::err_typecheck_choose_expr_requires_constant,
false);
12784 CondExpr = CondICE.
get();
12785 CondIsTrue = condEval.getZExtValue();
12788 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
12790 resType = ActiveExpr->
getType();
12796 return new (Context)
12797 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
12809 if (LangOpts.CPlusPlus) {
12810 Decl *ManglingContextDecl;
12813 ManglingContextDecl)) {
12814 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
12819 PushBlockScope(CurScope, Block);
12820 CurContext->addDecl(Block);
12822 PushDeclContext(CurScope, Block);
12824 CurContext = Block;
12826 getCurBlock()->HasImplicitReturnType =
true;
12830 PushExpressionEvaluationContext(
12831 ExpressionEvaluationContext::PotentiallyEvaluated);
12837 "block-id should have no identifier!");
12841 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
12846 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
12859 "GetTypeForDeclarator made a non-function block signature");
12864 if ((ExplicitSignature =
12870 if (ExplicitSignature.getLocalRangeBegin() ==
12871 ExplicitSignature.getLocalRangeEnd()) {
12874 TypeLoc Result = ExplicitSignature.getReturnLoc();
12883 CurBlock->TheDecl->setSignatureAsWritten(Sig);
12884 CurBlock->FunctionType =
T;
12889 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
12891 CurBlock->TheDecl->setIsVariadic(isVariadic);
12898 CurBlock->ReturnType = RetTy;
12899 CurBlock->TheDecl->setBlockMissingReturnType(
false);
12900 CurBlock->HasImplicitReturnType =
false;
12905 if (ExplicitSignature) {
12906 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
12907 ParmVarDecl *Param = ExplicitSignature.getParam(I);
12911 !getLangOpts().CPlusPlus)
12913 Params.push_back(Param);
12919 for (
const auto &I : Fn->param_types()) {
12922 Params.push_back(Param);
12927 if (!Params.empty()) {
12928 CurBlock->TheDecl->setParams(Params);
12929 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
12934 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
12937 for (
auto AI : CurBlock->TheDecl->parameters()) {
12938 AI->setOwningFunction(CurBlock->TheDecl);
12941 if (AI->getIdentifier()) {
12942 CheckShadow(CurBlock->TheScope, AI);
12944 PushOnScopeChains(AI, CurBlock->TheScope);
12953 DiscardCleanupsInEvaluationContext();
12954 PopExpressionEvaluationContext();
12958 PopFunctionScopeInfo();
12966 if (!LangOpts.Blocks)
12967 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
12970 if (hasAnyUnrecoverableErrorsInThisFunction())
12971 DiscardCleanupsInEvaluationContext();
12972 assert(!Cleanup.exprNeedsCleanups() &&
12973 "cleanups within block not correctly bound!");
12974 PopExpressionEvaluationContext();
12976 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
12979 deduceClosureReturnType(*BSI);
12998 Captures.push_back(NewCap);
13007 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
13010 if (isa<FunctionNoProtoType>(FTy)) {
13041 if (getCurFunction()->NeedsScopeChecking() &&
13042 !PP.isCodeCompletionEnabled())
13043 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
13047 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13048 DiagnoseUnguardedAvailabilityViolations(BSI->
TheDecl);
13055 computeNRVO(Body, BSI);
13059 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
13066 Cleanup.setExprNeedsCleanups(
true);
13071 const VarDecl *var = CI.getVariable();
13073 getCurFunction()->setHasBranchProtectedScope();
13085 GetTypeFromParser(Ty, &TInfo);
13086 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
13092 Expr *OrigExpr = E;
13096 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
13097 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
13099 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
13126 ExprResult Result = UsualUnaryConversions(E);
13130 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
13136 if (Init.isInvalid())
13138 E = Init.getAs<
Expr>();
13151 diag::err_first_argument_to_va_arg_not_of_type_va_list)
13156 diag::err_second_parameter_to_va_arg_incomplete,
13162 diag::err_second_parameter_to_va_arg_abstract,
13169 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
13170 : diag::warn_second_parameter_to_va_arg_not_pod)
13187 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
13194 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
13203 Ty = Context.
IntTy;
13209 llvm_unreachable(
"I don't know size of pointer!");
13217 if (!getLangOpts().ObjC1)
13236 if (OV->getSourceExpr())
13245 Exp = BuildObjCStringLiteral(SL->
getLocStart(), SL).
get();
13251 const Expr *SrcExpr) {
13273 bool *Complained) {
13275 *Complained =
false;
13278 bool CheckInferredResultType =
false;
13280 unsigned DiagKind = 0;
13283 bool MayHaveConvFixit =
false;
13284 bool MayHaveFunctionDiff =
false;
13290 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
13294 DiagKind = diag::ext_typecheck_convert_pointer_int;
13296 MayHaveConvFixit =
true;
13299 DiagKind = diag::ext_typecheck_convert_int_pointer;
13301 MayHaveConvFixit =
true;
13303 case IncompatiblePointer:
13304 if (Action == AA_Passing_CFAudited)
13305 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
13308 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
13310 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
13314 if (Hint.
isNull() && !CheckInferredResultType) {
13317 else if (CheckInferredResultType) {
13321 MayHaveConvFixit =
true;
13323 case IncompatiblePointerSign:
13324 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
13326 case FunctionVoidPointer:
13327 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
13329 case IncompatiblePointerDiscardsQualifiers: {
13336 DiagKind = diag::err_typecheck_incompatible_address_space;
13341 DiagKind = diag::err_typecheck_incompatible_ownership;
13345 llvm_unreachable(
"unknown error case for discarding qualifiers!");
13348 case CompatiblePointerDiscardsQualifiers:
13359 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
13361 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
13363 case IncompatibleNestedPointerQualifiers:
13364 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
13366 case IntToBlockPointer:
13367 DiagKind = diag::err_int_to_block_pointer;
13369 case IncompatibleBlockPointer:
13370 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
13372 case IncompatibleObjCQualifiedId: {
13376 for (
auto *srcProto : srcOPT->
quals()) {
13382 IFace = IFaceT->getDecl();
13387 for (
auto *dstProto : dstOPT->
quals()) {
13393 IFace = IFaceT->getDecl();
13395 DiagKind = diag::warn_incompatible_qualified_id;
13398 case IncompatibleVectors:
13399 DiagKind = diag::warn_incompatible_vectors;
13401 case IncompatibleObjCWeakRef:
13402 DiagKind = diag::err_arc_weak_unavailable_assign;
13407 *Complained =
true;
13411 DiagKind = diag::err_typecheck_convert_incompatible;
13413 MayHaveConvFixit =
true;
13415 MayHaveFunctionDiff =
true;
13422 case AA_Initializing:
13424 FirstType = DstType;
13425 SecondType = SrcType;
13430 case AA_Passing_CFAudited:
13431 case AA_Converting:
13435 FirstType = SrcType;
13436 SecondType = DstType;
13441 if (Action == AA_Passing_CFAudited)
13442 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
13444 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
13448 if (!ConvHints.
isNull()) {
13454 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
13456 if (MayHaveFunctionDiff)
13457 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
13460 if (DiagKind == diag::warn_incompatible_qualified_id &&
13462 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
13469 if (CheckInferredResultType)
13470 EmitRelatedResultTypeNote(SrcExpr);
13472 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
13473 EmitRelatedResultTypeNoteForReturn(DstType);
13476 *Complained =
true;
13481 llvm::APSInt *Result) {
13485 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
13489 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
13493 llvm::APSInt *Result,
13500 IDDiagnoser(
unsigned DiagID)
13504 S.
Diag(Loc, DiagID) << SR;
13506 } Diagnoser(DiagID);
13508 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
13513 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
13531 CXX11ConvertDiagnoser(
bool Silent)
13537 return S.
Diag(Loc, diag::err_ice_not_integral) <<
T;
13542 return S.
Diag(Loc, diag::err_ice_incomplete_type) <<
T;
13547 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
13558 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) <<
T;
13569 llvm_unreachable(
"conversion functions are permitted");
13571 } ConvertDiagnoser(Diagnoser.
Suppress);
13573 Converted = PerformContextualImplicitConversion(DiagLoc, E,
13577 E = Converted.
get();
13597 EvalResult.
Diag = &Notes;
13607 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
13616 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
13617 diag::note_invalid_subexpr_in_const_expr) {
13618 DiagLoc = Notes[0].first;
13622 if (!Folded || !AllowFold) {
13626 Diag(Note.first, Note.second);
13634 Diag(Note.first, Note.second);
13644 class TransformToPE :
public TreeTransform<TransformToPE> {
13648 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
13651 bool AlwaysRebuild() {
return true; }
13658 return BaseTransform::TransformLabelStmt(S);
13669 if (isa<FieldDecl>(E->
getDecl()) &&
13672 diag::err_invalid_non_static_member_use)
13675 return BaseTransform::TransformDeclRefExpr(E);
13683 return BaseTransform::TransformUnaryOperator(E);
13694 assert(isUnevaluatedContext() &&
13695 "Should only transform unevaluated expressions");
13696 ExprEvalContexts.back().Context =
13697 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
13698 if (isUnevaluatedContext())
13700 return TransformToPE(*this).TransformExpr(E);
13705 Decl *LambdaContextDecl,
13707 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
13708 LambdaContextDecl, IsDecltype);
13710 if (!MaybeODRUseExprs.empty())
13711 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
13718 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
13719 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, IsDecltype);
13733 D = diag::err_lambda_unevaluated_operand;
13739 D = diag::err_lambda_in_constant_expression;
13749 for (
const auto *L : Rec.
Lambdas)
13750 Diag(L->getLocStart(), D);
13754 for (
auto *Lambda : Rec.
Lambdas) {
13755 for (
auto *C : Lambda->capture_inits())
13756 MarkDeclarationsReferencedInExpr(C);
13767 ExprCleanupObjects.end());
13769 CleanupVarDeclMarking();
13779 ExprEvalContexts.pop_back();
13781 if (!ExprEvalContexts.empty())
13782 ExprEvalContexts.back().NumTypos += NumTypos;
13784 assert(NumTypos == 0 &&
"There are outstanding typos after popping the " 13785 "last ExpressionEvaluationContextRecord");
13789 ExprCleanupObjects.erase(
13790 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
13791 ExprCleanupObjects.end());
13793 MaybeODRUseExprs.clear();
13799 return TransformToPotentiallyEvaluated(E);
13825 llvm_unreachable(
"Invalid context");
13850 llvm_unreachable(
"Invalid context");
13862 bool MightBeOdrUse) {
13863 assert(Func &&
"No function?");
13885 bool NeedDefinition =
13894 if (NeedDefinition &&
13897 checkSpecializationVisibility(Loc, Func);
13910 ResolveExceptionSpec(Loc, FPT);
13914 if ((Func->
isUsed(
false) || !OdrUse) &&
13915 (!NeedDefinition || Func->
getBody()))
13920 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
13921 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
13922 if (Constructor->isDefaultConstructor()) {
13923 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
13925 DefineImplicitDefaultConstructor(Loc, Constructor);
13926 }
else if (Constructor->isCopyConstructor()) {
13927 DefineImplicitCopyConstructor(Loc, Constructor);
13928 }
else if (Constructor->isMoveConstructor()) {
13929 DefineImplicitMoveConstructor(Loc, Constructor);
13931 }
else if (Constructor->getInheritedConstructor()) {
13932 DefineInheritingConstructor(Loc, Constructor);
13935 dyn_cast<CXXDestructorDecl>(Func)) {
13936 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
13937 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
13938 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
13940 DefineImplicitDestructor(Loc, Destructor);
13942 if (Destructor->isVirtual() && getLangOpts().AppleKext)
13943 MarkVTableUsed(Loc, Destructor->getParent());
13944 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
13945 if (MethodDecl->isOverloadedOperator() &&
13946 MethodDecl->getOverloadedOperator() == OO_Equal) {
13947 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
13948 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
13949 if (MethodDecl->isCopyAssignmentOperator())
13950 DefineImplicitCopyAssignment(Loc, MethodDecl);
13951 else if (MethodDecl->isMoveAssignmentOperator())
13952 DefineImplicitMoveAssignment(Loc, MethodDecl);
13954 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
13955 MethodDecl->getParent()->isLambda()) {
13957 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
13959 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
13961 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
13962 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
13963 MarkVTableUsed(Loc, MethodDecl->getParent());
13968 if (CurContext == Func)
return;
13975 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
13976 if (FirstInstantiation) {
13977 PointOfInstantiation = Loc;
13983 PointOfInstantiation = Loc;
13990 CodeSynthesisContexts.size())
13991 PendingLocalImplicitInstantiations.push_back(
13992 std::make_pair(Func, PointOfInstantiation));
13997 InstantiateFunctionDefinition(PointOfInstantiation, Func);
14000 PendingInstantiations.push_back(std::make_pair(Func,
14001 PointOfInstantiation));
14003 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
14008 for (
auto i : Func->
redecls()) {
14009 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
14010 MarkFunctionReferenced(Loc, i, OdrUse);
14014 if (!OdrUse)
return;
14018 if (mightHaveNonExternalLinkage(Func))
14021 !LangOpts.GNUInline &&
14024 else if (isExternalWithNoLinkageType(Func))
14039 if (isa<ParmVarDecl>(var) &&
14040 isa<TranslationUnitDecl>(VarDC))
14053 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
14055 if (isa<CXXMethodDecl>(VarDC) &&
14056 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
14058 }
else if (isa<FunctionDecl>(VarDC)) {
14060 }
else if (isa<BlockDecl>(VarDC)) {
14064 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
14065 << var << ValueKind << ContextKind << VarDC;
14075 bool &SubCapturesAreNested,
14081 SubCapturesAreNested =
true;
14094 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
14095 !(isa<CapturedRegionScopeInfo>(CSI) &&
14096 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
14107 const bool Diagnose,
Sema &S) {
14122 const bool Diagnose,
Sema &S) {
14124 bool IsBlock = isa<BlockScopeInfo>(CSI);
14125 bool IsLambda = isa<LambdaScopeInfo>(CSI);
14133 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
14142 S.
Diag(Loc, diag::err_ref_vm_type);
14151 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
14154 S.
Diag(Loc, diag::err_ref_flexarray_type);
14156 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
14164 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14167 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
14169 S.
Diag(Loc, diag::err_capture_block_variable)
14180 S.
Diag(Loc, diag::err_opencl_block_ref_block);
14190 const bool BuildAndDiagnose,
14195 Expr *CopyExpr =
nullptr;
14196 bool ByRef =
false;
14200 if (BuildAndDiagnose) {
14201 S.
Diag(Loc, diag::err_ref_array_type);
14210 if (BuildAndDiagnose) {
14211 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
14225 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
14231 Ty = AttrTy->getModifiedType();
14241 !IsObjCOwnershipAttributedType(PointeeTy)) {
14242 if (BuildAndDiagnose) {
14244 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
14246 auto AddAutoreleaseNote =
14247 S.
Diag(VarLoc, diag::note_declare_parameter_autoreleasing);
14263 ?
" __autoreleasing " 14264 :
" __autoreleasing");
14269 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
14274 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14283 DeclRefType = CaptureType;
14285 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
14292 if (isa<ParmVarDecl>(Var))
14310 CaptureType,
false),
14317 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
14320 CopyExpr = Result.
get();
14327 if (BuildAndDiagnose)
14328 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
14340 const bool BuildAndDiagnose,
14343 const bool RefersToCapturedVariable,
14362 CaptureType = DeclRefType;
14364 Expr *CopyExpr =
nullptr;
14365 if (BuildAndDiagnose) {
14388 if (BuildAndDiagnose)
14389 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
14401 bool RefersToCapturedVariable) {
14418 const bool BuildAndDiagnose,
14421 const bool RefersToCapturedVariable,
14424 const bool IsTopScope,
14428 bool ByRef =
false;
14462 if (!RefType->getPointeeType()->isFunctionType())
14468 if (BuildAndDiagnose) {
14469 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
14477 if (BuildAndDiagnose) {
14480 diag::err_capture_of_incomplete_type,
14485 diag::err_capture_of_abstract_type))
14491 if (BuildAndDiagnose)
14493 RefersToCapturedVariable);
14510 if (BuildAndDiagnose)
14511 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
14512 Loc, EllipsisLoc, CaptureType,
nullptr);
14520 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
14528 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
14529 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
14532 if (FunctionScopeIndexToStopAt) {
14533 unsigned FSIndex = FunctionScopes.size() - 1;
14534 while (FSIndex != MaxFunctionScopesIndex) {
14543 if (VarDC == DC)
return true;
14548 if (IsGlobal && !(LangOpts.OpenMP && IsOpenMPCapturedDecl(Var)))
14560 CaptureType = Var->
getType();
14562 bool Nested =
false;
14563 bool Explicit = (Kind != TryCapture_Implicit);
14564 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
14577 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
14598 if (BuildAndDiagnose) {
14621 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
14622 QTy = PVD->getOriginalType();
14626 if (getLangOpts().OpenMP) {
14627 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
14632 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
14633 auto IsTargetCap = !IsOpenMPPrivateDecl &&
14634 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
14639 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
14641 if (IsTargetCap || IsOpenMPPrivateDecl) {
14642 Nested = !IsTargetCap;
14653 if (BuildAndDiagnose) {
14657 if (cast<LambdaScopeInfo>(CSI)->Lambda)
14658 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
14659 diag::note_lambda_decl);
14675 FunctionScopesIndex--;
14678 }
while (!VarDC->
Equals(DC));
14685 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
14691 BuildAndDiagnose, CaptureType,
14692 DeclRefType, Nested, *
this))
14697 BuildAndDiagnose, CaptureType,
14698 DeclRefType, Nested, *
this))
14704 BuildAndDiagnose, CaptureType,
14705 DeclRefType, Nested, Kind, EllipsisLoc,
14706 I == N - 1, *
this))
14718 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
14720 DeclRefType,
nullptr);
14726 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
14727 false, CaptureType,
14728 DeclRefType,
nullptr);
14736 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
14737 false, CaptureType,
14738 DeclRefType,
nullptr))
14741 return DeclRefType;
14755 const VarDecl *DefVD =
nullptr;
14782 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
14783 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
14784 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
14785 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
14788 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
14793 Res = CorrectDelayedTyposInExpr(Res);
14802 UpdateMarkingForLValueToRValue(Res.
get());
14807 for (
Expr *E : MaybeODRUseExprs) {
14810 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
14811 Var = cast<VarDecl>(DRE->getDecl());
14812 Loc = DRE->getLocation();
14813 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
14814 Var = cast<VarDecl>(ME->getMemberDecl());
14815 Loc = ME->getMemberLoc();
14817 llvm_unreachable(
"Unexpected expression");
14824 MaybeODRUseExprs.clear();
14830 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
14831 "Invalid Expr argument to DoMarkVarDeclReferenced");
14837 bool UsableInConstantExpr =
14839 bool NeedDefinition =
14844 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
14845 "Can't instantiate a partial template specialization.");
14851 !isa<VarTemplateSpecializationDecl>(Var))
14862 bool TryInstantiating =
14866 if (TryInstantiating) {
14868 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
14869 if (FirstInstantiation) {
14870 PointOfInstantiation = Loc;
14874 bool InstantiationDependent =
false;
14875 bool IsNonDependent =
14881 if (IsNonDependent) {
14882 if (UsableInConstantExpr) {
14886 }
else if (FirstInstantiation ||
14887 isa<VarTemplateSpecializationDecl>(Var)) {
14894 .push_back(std::make_pair(Var, PointOfInstantiation));
14908 if (OdrUseContext && E &&
14915 }
else if (OdrUseContext) {
14923 const bool RefersToEnclosingScope =
14926 if (RefersToEnclosingScope) {
14939 assert(E &&
"Capture variable should be used in an expression.");
14956 Decl *D,
Expr *E,
bool MightBeOdrUse) {
14960 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
14976 bool IsVirtualCall = MD->
isVirtual() &&
14978 if (!IsVirtualCall)
14994 bool OdrUse =
true;
14996 if (Method->isVirtual() &&
14997 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
15010 bool MightBeOdrUse =
true;
15013 if (Method->isPure())
15014 MightBeOdrUse =
false;
15026 bool MightBeOdrUse) {
15027 if (MightBeOdrUse) {
15028 if (
auto *VD = dyn_cast<VarDecl>(D)) {
15029 MarkVariableReferenced(Loc, VD);
15033 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
15034 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
15061 bool MarkReferencedDecls::TraverseTemplateArgument(
15075 return Inherited::TraverseTemplateArgument(Arg);
15079 MarkReferencedDecls Marker(*
this, Loc);
15080 Marker.TraverseType(T);
15088 bool SkipLocalVariables;
15093 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
15094 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
15098 if (SkipLocalVariables) {
15100 if (VD->hasLocalStorage())
15109 Inherited::VisitMemberExpr(E);
15123 Inherited::VisitCXXNewExpr(E);
15131 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
15136 Inherited::VisitCXXDeleteExpr(E);
15141 Inherited::VisitCXXConstructExpr(E);
15149 Inherited::VisitImplicitCastExpr(E);
15163 bool SkipLocalVariables) {
15164 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
15185 switch (ExprEvalContexts.back().Context) {
15186 case ExpressionEvaluationContext::Unevaluated:
15187 case ExpressionEvaluationContext::UnevaluatedList:
15188 case ExpressionEvaluationContext::UnevaluatedAbstract:
15189 case ExpressionEvaluationContext::DiscardedStatement:
15193 case ExpressionEvaluationContext::ConstantEvaluated:
15197 case ExpressionEvaluationContext::PotentiallyEvaluated:
15198 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
15199 if (Statement && getCurFunctionOrMethodDecl()) {
15200 FunctionScopes.back()->PossiblyUnreachableDiags.
15210 if (
auto *VD = dyn_cast_or_null<VarDecl>(
15211 ExprEvalContexts.back().ManglingContextDecl)) {
15212 if (VD->isConstexpr() ||
15213 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
15233 if (ExprEvalContexts.back().IsDecltype) {
15234 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
15238 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
15244 : FD(FD), CE(CE) { }
15248 S.
Diag(Loc, diag::err_call_incomplete_return)
15253 S.
Diag(Loc, diag::err_call_function_incomplete_return)
15258 } Diagnoser(FD, CE);
15260 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
15271 unsigned diagnostic = diag::warn_condition_is_assignment;
15272 bool IsOrAssign =
false;
15275 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
15278 IsOrAssign = Op->getOpcode() == BO_OrAssign;
15282 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
15286 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
15287 diagnostic = diag::warn_condition_is_idiomatic_assignment;
15291 diagnostic = diag::warn_condition_is_idiomatic_assignment;
15294 Loc = Op->getOperatorLoc();
15296 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
15299 IsOrAssign = Op->getOperator() == OO_PipeEqual;
15300 Loc = Op->getOperatorLoc();
15302 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
15312 Diag(Loc, diag::note_condition_assign_silence)
15317 Diag(Loc, diag::note_condition_or_assign_to_comparison)
15320 Diag(Loc, diag::note_condition_assign_to_comparison)
15338 if (opE->getOpcode() == BO_EQ &&
15339 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
15345 Diag(Loc, diag::note_equality_comparison_silence)
15348 Diag(Loc, diag::note_equality_comparison_to_assign)
15354 bool IsConstexpr) {
15355 DiagnoseAssignmentAsCondition(E);
15356 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
15357 DiagnoseEqualityWithExtraParens(parenE);
15359 ExprResult result = CheckPlaceholderExpr(E);
15364 if (getLangOpts().CPlusPlus)
15365 return CheckCXXBooleanCondition(E, IsConstexpr);
15367 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
15374 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
15392 case ConditionKind::Boolean:
15393 Cond = CheckBooleanCondition(Loc, SubExpr);
15396 case ConditionKind::ConstexprIf:
15397 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
15400 case ConditionKind::Switch:
15401 Cond = CheckSwitchCondition(Loc, SubExpr);
15405 return ConditionError();
15409 if (!FullExpr.
get())
15410 return ConditionError();
15413 CK == ConditionKind::ConstexprIf);
15419 struct RebuildUnknownAnyFunction
15420 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
15424 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
15427 llvm_unreachable(
"unexpected statement!");
15431 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
15438 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
15439 ExprResult SubResult = Visit(E->getSubExpr());
15442 Expr *SubExpr = SubResult.
get();
15443 E->setSubExpr(SubExpr);
15444 E->setType(SubExpr->
getType());
15451 return rebuildSugarExpr(E);
15455 return rebuildSugarExpr(E);
15462 Expr *SubExpr = SubResult.
get();
15471 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
15476 if (S.getLangOpts().CPlusPlus &&
15477 !(isa<CXXMethodDecl>(VD) &&
15478 cast<CXXMethodDecl>(VD)->isInstance()))
15489 return resolveDecl(E, E->
getDecl());
15497 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
15507 struct RebuildUnknownAnyExpr
15508 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
15516 : S(S), DestType(CastType) {}
15519 llvm_unreachable(
"unexpected statement!");
15523 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
15533 template <
class T>
ExprResult rebuildSugarExpr(
T *E) {
15534 ExprResult SubResult = Visit(E->getSubExpr());
15536 Expr *SubExpr = SubResult.
get();
15537 E->setSubExpr(SubExpr);
15538 E->setType(SubExpr->
getType());
15545 return rebuildSugarExpr(E);
15549 return rebuildSugarExpr(E);
15587 return resolveDecl(E, E->
getDecl());
15598 FK_FunctionPointer,
15605 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
15606 Kind = FK_MemberFunction;
15610 Kind = FK_FunctionPointer;
15613 Kind = FK_BlockPointer;
15618 if (DestType->isArrayType() || DestType->isFunctionType()) {
15619 unsigned diagID = diag::err_func_returning_array_function;
15620 if (Kind == FK_BlockPointer)
15621 diagID = diag::err_block_returning_array_function;
15624 << DestType->isFunctionType() << DestType;
15657 if (ParamTypes.empty() && Proto->isVariadic()) {
15659 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
15667 ArgTypes.push_back(ArgType);
15669 ParamTypes = ArgTypes;
15672 Proto->getExtProtoInfo());
15680 case FK_MemberFunction:
15684 case FK_FunctionPointer:
15688 case FK_BlockPointer:
15694 ExprResult CalleeResult = Visit(CalleeExpr);
15704 if (DestType->isArrayType() || DestType->isFunctionType()) {
15705 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
15706 << DestType->isFunctionType() << DestType;
15713 Method->setReturnType(DestType);
15717 E->
setType(DestType.getNonReferenceType());
15725 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
15732 DestType = DestType->castAs<
PointerType>()->getPointeeType();
15739 }
else if (E->
getCastKind() == CK_LValueToRValue) {
15743 assert(isa<BlockPointerType>(E->
getType()));
15756 llvm_unreachable(
"Unhandled cast type!");
15789 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
15792 FD->getDeclContext(),
15793 Loc, Loc, FD->getNameInfo().getName(),
15794 DestType, FD->getTypeSourceInfo(),
15796 FD->hasPrototype(),
15799 if (FD->getQualifier())
15803 for (
const auto &AI : FT->param_types()) {
15807 Params.push_back(Param);
15809 NewFD->setParams(Params);
15810 DRE->setDecl(NewFD);
15811 VD = DRE->getDecl();
15816 if (MD->isInstance()) {
15826 }
else if (isa<VarDecl>(VD)) {
15830 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
15858 diag::err_typecheck_cast_to_incomplete))
15862 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
15865 CastExpr = result.
get();
15867 CastKind = CK_NoOp;
15873 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
15882 ExprResult result = DefaultArgumentPromotion(arg);
15884 paramType = result.
get()->getType();
15896 return PerformCopyInitialization(entity, callLoc, arg);
15901 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
15904 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
15905 E = call->getCallee();
15906 diagID = diag::err_uncasted_call_of_unknown_any;
15914 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
15915 loc = ref->getLocation();
15916 d = ref->getDecl();
15917 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
15918 loc = mem->getMemberLoc();
15919 d = mem->getMemberDecl();
15921 diagID = diag::err_uncasted_call_of_unknown_any;
15922 loc = msg->getSelectorStartLoc();
15923 d = msg->getMethodDecl();
15925 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
15926 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
15949 ExprResult Result = CorrectDelayedTyposInExpr(E);
15955 if (!placeholderType)
return E;
15957 switch (placeholderType->
getKind()) {
15960 case BuiltinType::Overload: {
15964 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
15970 if (resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
15974 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
15980 case BuiltinType::BoundMember: {
15985 if (isa<CXXPseudoDestructorExpr>(BME)) {
15986 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
15987 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
15988 if (ME->getMemberNameInfo().getName().getNameKind() ==
15990 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
15992 tryToRecoverWithCall(result, PD,
15998 case BuiltinType::ARCUnbridgedCast: {
15999 Expr *realCast = stripARCUnbridgedCast(E);
16000 diagnoseARCUnbridgedCast(realCast);
16005 case BuiltinType::UnknownAny:
16009 case BuiltinType::PseudoObject:
16010 return checkPseudoObjectRValue(E);
16012 case BuiltinType::BuiltinFn: {
16016 auto *FD = cast<FunctionDecl>(DRE->getDecl());
16017 if (FD->getBuiltinID() == Builtin::BI__noop) {
16019 CK_BuiltinFnToFnPtr).get();
16020 return new (Context)
CallExpr(Context, E, None, Context.
IntTy,
16030 case BuiltinType::OMPArraySection:
16035 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 16036 case BuiltinType::Id: 16037 #include "clang/Basic/OpenCLImageTypes.def" 16038 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 16039 #define PLACEHOLDER_TYPE(Id, SingletonId) 16040 #include "clang/AST/BuiltinTypes.def" 16044 llvm_unreachable(
"invalid placeholder type!");
16058 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
16059 "Unknown Objective-C Boolean value!");
16064 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
16072 return new (Context)
16080 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
16082 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
16084 return Spec.getPlatform() == Platform;
16088 if (Spec != AvailSpecs.end())
16089 Version = Spec->getVersion();
16093 if (getCurFunctionOrMethodDecl())
16094 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
16095 else if (getCurBlock() || getCurLambda())
16096 getCurFunction()->HasPotentialAvailabilityViolations =
true;
16098 return new (Context)
Abstract class used to diagnose incomplete types.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
SourceLocation getLocStart() const LLVM_READONLY
A call to an overloaded operator written using operator syntax.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
CXXRecordDecl * getNamingClass() const
Retrieve the naming class of this lookup.
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const BlockDecl * getBlockDecl() const
bool hasDefinition() const
Determine whether this class has been defined.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
QualType withConst() const
Retrieves a version of this type with const applied.
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
const CXXDestructorDecl * getDestructor() const
bool isClassMethod() const
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)
An instance of this class is created to represent a function declaration or definition.
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
Expr ** getArgs()
Retrieve the call arguments.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
SourceRange getCorrectionRange() const
void markUsed(bool IsODRUse)
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.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
A class which contains all the information about a particular captured value.
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.
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
Represents a version number in the form major[.minor[.subminor[.build]]].
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool hasCaptures() const
hasCaptures - True if this block (or its nested blocks) captures anything of local storage from its e...
ObjCInterfaceDecl * getClassInterface()
bool isExternC() const
Determines whether this function is a function with external, C linkage.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
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)
TypedefDecl - 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.
ActionResult< Expr * > ExprResult
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.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
bool isRecordType() const
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT)
bool isEmpty() const
No scope specifier.
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
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.
bool isBlockCapture() const
SourceLocation getLocStart() const LLVM_READONLY
FunctionDecl * getOperatorNew() const
bool isExtVectorType() const
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
Defines the C++ template declaration subclasses.
This is a while, do, switch, for, etc that can have break statements embedded into it...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer...
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
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
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
QualType getCorrespondingUnsignedType(QualType T) const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
bool isZero() const
isZero - Test whether the quantity equals zero.
QualType withConst() const
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
const TargetInfo & getTargetInfo() const
TemplateNameKind Kind
The kind of template that Template refers to.
A container of type source information.
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Floating point control options.
SourceLocation getLocStart() const LLVM_READONLY
MS property subscript expression.
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function is defined at all, including a deleted definition.
static bool IsWithinTemplateSpecialization(Decl *D)
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
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
Wrapper for source info for pointers decayed from arrays and functions.
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
Represents a C++ constructor within a class.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr *> Args)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
size_t param_size() const
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.
SourceLocation getEndLoc() const
Get the end source location.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Retains information about a function, method, or block that is currently being parsed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
This file provides some common utility functions for processing Lambda related AST Constructs...
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
void setRAngleLoc(SourceLocation Loc)
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
RAII object that enters a new expression evaluation context.
VarDecl - An instance of this class is created to represent 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.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
void removeObjCLifetime()
QualType getReturnType() const
CompoundLiteralExpr - [C99 6.5.2.5].
bool isParamConsumed(unsigned I) const
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
unsigned getNumParams() const
bool isEnumeralType() const
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, const FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
DeclClass * getCorrectionDeclAs() const
static void checkEnumComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
If two different enums are compared, raise a warning.
static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Converts an integer to complex float type.
void ActOnStartStmtExpr()
bool isInvalidDecl() const
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
bool isOverloaded() const
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
std::vector< FixItHint > Hints
The list of Hints generated so far.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
tok::TokenKind getKind() const
bool isAdditiveOp() const
bool isEqualityOp() const
void 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
getIdentifier - 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...
RecordDecl - 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
getDeclName - 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
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, QualType SrcType)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
VarDecl * getVariable() const
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
A vector component is an element or range of elements on a vector.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S)
Capture the given variable in the captured region.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
ArrayRef< QualType > getParamTypes() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
ObjCMethodFamily
A family of Objective-C methods.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
field_range fields() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
bool isObjCIdType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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.
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
static void checkUnusedDeclAttributes(Sema &S, const AttributeList *A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
bool isReferenceType() const
SourceLocation getLocEnd() const LLVM_READONLY
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
Token - This structure provides full information about a lexed token.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
void setKind(tok::TokenKind K)
SourceLocation getLocStart() const LLVM_READONLY
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
LookupResultKind getResultKind() const
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
bool isObjCQualifiedClassType() const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
void PopExpressionEvaluationContext()
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isAssignmentOp() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
Values of this type can be null.
bool isUnarySelector() const
The controlling scope in a if/switch/while/for statement.
DeclClass * getAsSingle() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
StringRef getOpcodeStr() const
SourceLocation getOpLoc() const
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Describes an C or C++ initializer list.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we we can fold and convert to a ...
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...
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
Represents a C++ unqualified-id that has been parsed.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
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.
bool IsOpenMPCapturedByRef(ValueDecl *D, unsigned Level)
Return true if the provided declaration VD should be captured by reference.
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
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t', '\f', '\v', '\n', '\r'.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
QualType getOriginalType() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool HasFormOfMemberPointer
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
bool hasAddressSpace() const
LabelDecl * getDecl() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
This is a while, do, for, which can have continue statements embedded into it.
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 getEndLoc() const
getEndLoc - Retrieve the location of the last token.
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 void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
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...
TypeDecl - 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.
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
Expr * getSizeExpr() const
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
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.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
static bool enclosingClassIsRelatedToClassInWhichMembersWereFound(const UnresolvedMemberExpr *const UME, Sema &S)
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
QualType getBOOLType() const
type of 'BOOL' type.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
IdentifierInfo * getIdentifier() const
CanQualType UnsignedCharTy
A default argument (C++ [dcl.fct.default]).
void setStmt(LabelStmt *T)
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
const LangOptions & LangOpts
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
void ActOnStmtExprError()
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Qualifiers withoutObjCGCAttr() const
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, Expr *LHS, Expr *RHS)
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
DiagnosticsEngine & getDiagnostics() const
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas...
CXXSpecialMember
Kinds of C++ special members.
OverloadFixItKind Kind
The type of fix applied.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
OpenMP 4.0 [2.4, Array Sections].
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
static bool ExprLooksBoolean(Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
bool Mutable
Whether this is a mutable lambda.
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
SourceLocation getLocStart() const LLVM_READONLY
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
static NamedDecl * getDeclFromExpr(Expr *E)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
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 bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
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)
SourceLocation getLocEnd() const LLVM_READONLY
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)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr *> Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool hasDefinition() const
Determine whether this protocol has a definition.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
std::string getAsString(const LangOptions &LO) const
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
unsigned getValue() const
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition...
SourceLocation getBeginLoc() const
Get the begin source location.
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true)
Create a binary operation that may resolve to an overloaded operator.
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
QualType getElementType() const
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.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
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
hasLocalStorage - 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.
const FunctionProtoType * T
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
static bool EvaluatesAsTrue(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'true'.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool isObjCBuiltinType() const
const T * castAs() const
Member-template castAs<specific type>.
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static bool captureInLambda(LambdaScopeInfo *LSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S)
Capture the given variable in the lambda.
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
static Expr * maybeRebuildARCConsumingStmt(Stmt *Statement)
Given the last statement in a statement-expression, check whether the result is a producing expressio...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
CanQualType OMPArraySectionTy
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const Expr * getCallee() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
SmallVectorImpl< OverloadCandidate >::iterator iterator
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
void setOpenMPCaptureKind(FieldDecl *FD, ValueDecl *D, unsigned Level)
Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.) for FD based on DSA for the...
uint32_t getCodeUnit(size_t i) const
Overload resolution succeeded.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
ObjCInterfaceDecl * getSuperClass() const
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
static ValueDecl * getCompareDecl(Expr *E)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
static void diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, ValueDecl *var, DeclContext *DC)
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
void DiscardCleanupsInEvaluationContext()
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
bool isFunctionOrMethod() const
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
clang::ObjCRuntime ObjCRuntime
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr *> Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
void setAddressSpace(LangAS space)
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr *> Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
An expression that sends a message to the given Objective-C object or class.
Data structure that captures multiple levels of template argument lists for use in template instantia...
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void CleanupVarDeclMarking()
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool isRelational)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
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.
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 TypeLock is not of the desire...
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static std::pair< ExprResult, ExprResult > CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
SourceRange getSourceRange() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isUnresolvableResult() const
static CharSourceRange getCharRange(SourceRange R)
ExtInfo withNoReturn(bool noReturn) const
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
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse)
static bool isBitwiseOp(Opcode Opc)
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
QualType getWideCharType() const
Return the type of wide characters.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
Wrapper for source info for arrays.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
QualType getCanonicalType() const
bool CheckCaseExpression(Expr *E)
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted, bool IsNested=false)
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
LookupInObjCMethod - The parser has read a name in, and Sema has detected that we're currently inside...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
param_type_range param_types() const
A stack object to be created when performing template instantiation.
ExtProtoInfo getExtProtoInfo() const
ASTContext & getASTContext() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getNumExprs() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result)
GetFloatValue - Convert this numeric literal to a floating value, using the specified APFloat fltSema...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
SourceLocation getOperatorLoc() const
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
LangAS getAddressSpace() const
Return the address space of this type.
This represents '#pragma omp declare reduction ...' directive.
Expression is not a Null pointer constant.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Expr * getSubExpr() const
Interfaces are the core concept in Objective-C for object oriented design.
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * Lambda
The class that describes the lambda.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
const ComplexType * getAsComplexIntegerType() const
CastKind getCastKind() const
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.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
void setLastStmt(Stmt *S)
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
DeclarationName getName() const
getName - Returns the embedded declaration name.
bool isThisCapture() const
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)
LabelDecl - Represents the declaration of a label.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
bool isOverloadedResult() const
Determines if the results are overloaded.
const Expr * getExpr(unsigned Init) const
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
SourceLocation getLocStart() const LLVM_READONLY
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S)
Convert vector E to a vector with the same number of elements but different element type...
void setIdentifierInfo(IdentifierInfo *II)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ExprResult TransformToPotentiallyEvaluated(Expr *E)
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
const ParmVarDecl * getParamDecl(unsigned i) const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC)
CheckBoolLikeConversion - Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
const TemplateArgumentListInfo & getTemplateArgsInfo() const
Qualifiers withoutObjCLifetime() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
is AltiVec 'vector bool ...'
SmallVector< Capture, 4 > Captures
Captures - The captures.
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 ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
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...
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool isRelational)
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)
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap.
void addPotentialThisCapture(SourceLocation Loc)
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
EnumDecl * getDecl() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
unsigned getFullDataSize() const
Returns the size of the type source info data block.
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
FunctionDecl * getOperatorDelete() const
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptions FPFeatures)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
CompoundAssignOperator - For compound assignments (e.g.
A POD class for pairing a NamedDecl* with an access specifier.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
Represents a C11 generic selection.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Represents an element in a path from a derived class to a base class.
AddrLabelExpr - The GNU address of label extension, representing &&label.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Represents a template argument.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
static bool isInvalid(LocType Loc, bool *Invalid)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union...
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Dataflow Directional Tag Classes.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
void setBody(CompoundStmt *B)
bool isValid() const
Return true if this is a valid SourceLocation object.
ExtInfo getExtInfo() const
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
static bool isScopedEnumerationType(QualType T)
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
const DeclContext * getCurObjCLexicalContext() const
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
ArrayRef< Capture > captures() const
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
QualType GetSignedVectorType(QualType V)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
typedef char* __builtin_va_list;
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128 and long double if there is no support for such conve...
QualType getType() const
Get the type for which this source info wrapper provides information.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
static bool CheckAlignOfExpr(Sema &S, Expr *E)
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
static bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
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)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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)
const Expr * getInit() const
A runtime availability query.
This template specialization was instantiated from a template due to an explicit instantiation declar...
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured...
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setInstantiationIsPending(bool IC)
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
const Expr * getExpr() const
bool isBooleanType() const
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type...
OverloadExpr * Expression
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
U cast(CodeGen::Address addr)
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
A set of unresolved declarations.
bool isConstantEvaluated() const
SourceLocation getLocStart() const LLVM_READONLY
virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR)=0
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Expression is a C++11 nullptr.
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
unsigned short OpenMPLevel
ExplicitCastExpr - An explicit cast written in the source code.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
ExprResult ActOnConstantExpression(ExprResult Res)
unsigned getLength() const
IdentifierInfo * getCorrectionAsIdentifierInfo() const
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr *> Args, SmallVectorImpl< Expr *> &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> Types, ArrayRef< Expr *> Exprs)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored, perform any conversions that are required.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
CanQualType ObjCBuiltinBoolTy
The standard open() call: int open(const char *path, int oflag, ...);.
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
static bool EvaluatesAsFalse(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'false'.
TypeLoc getPointeeLoc() 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"...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, bool IsDecltype=false)
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
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
SourceLocation getLocation() const
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
const llvm::APInt & getSize() const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
bool isAtomicType() const
Represents a call to a CUDA kernel function.
bool isFunctionType() const
bool isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one.
bool isObjCQualifiedIdType() const
SourceLocation getLocStart() const LLVM_READONLY
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...
SourceLocation getLocStart() const LLVM_READONLY
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D)
Diagnoses obvious problems with the use of the given declaration as an expression.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
bool isUnevaluated() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
const Expr * getBase() const
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
bool isConstantArrayType() const
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
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 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)
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...
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.
bool isCopyCapture() const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
SourceLocation getLocStart() const LLVM_READONLY
sema::FunctionScopeInfo * getCurFunction() const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
SourceLocation getRParenLoc() const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ObjCIvarDecl - Represents an ObjC instance variable.
bool isMultiplicativeOp() const
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type...
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
QualType 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]).
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
void UpdateMarkingForLValueToRValue(Expr *E)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g.
StringRef getName() const
getName - 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)
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
ArrayRef< ParmVarDecl * > parameters() const
The class facilities generation and storage of conversion FixIts.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
bool isIncrementDecrementOp() const
static bool isOdrUseContext(Sema &SemaRef, bool SkipDependentUses=true)
Are we within a context in which references to resolved functions or to variables result in odr-use...
void setSubStmt(Stmt *SS)
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e.g.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
DeclaratorContext getContext() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void setLocation(SourceLocation L)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
bool isFloatingType() const
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
Expr * getInitExpr() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
NamedDecl - This represents a decl with 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.
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...
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.
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
void removeAddressSpace()
static bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
Wrapper for source info for pointers.
SourceLocation getBegin() const
SourceLocation ColonLoc
Location of ':'.
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
An implicit 'self' parameter.
The lookup resulted in an error.
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
Represents the canonical version of C arrays with a specified constant size.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
Declaration of a template function.
void clear()
Clears out any current state.
A class which abstracts out some details necessary for making a call.
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
The current expression occurs within a braced-init-list within an unevaluated operand.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
SourceLocation getLocStart() const LLVM_READONLY
One specifier in an expression.
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
void startToken()
Reset all flags to cleared.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
bool isExternallyVisible() const
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
QualType getType() const
Return the type wrapped by this type source info.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
ArrayRef< ParmVarDecl * > parameters() const
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
Helper class that creates diagnostics with optional template instantiation stacks.
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CanQualType UnsignedIntTy
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
Structure used to store a statement, the constant value to which it was evaluated (if any)...
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
SourceLocation getLocStart() const LLVM_READONLY
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)