48 #include "llvm/Support/ConvertUTF.h" 49 using namespace clang;
56 if (ParsingInitForAutoVars.count(D))
66 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
72 if (TreatUnavailableAsInvalid &&
73 isUnavailableAlignedAllocationFunction(*FD))
87 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
90 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused &&
91 A->getSemanticSpelling() != UnusedAttr::C2x_maybe_unused) {
93 if (DC && !DC->
hasAttr<UnusedAttr>())
105 if (Method && Method->isDeleted() && Method->isDefaulted()) {
107 if (!Method->isImplicit())
113 if (CSM != CXXInvalid)
114 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
120 if (Ctor && Ctor->isInheritingConstructor())
121 return NoteDeletedInheritingConstructor(Ctor);
131 if (I->getStorageClass() !=
SC_None)
176 if (!DowngradeWarning && UsedFn)
179 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
180 : diag::ext_internal_in_extern_inline)
185 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
195 Diag(DeclBegin, diag::note_convert_inline_to_static)
214 bool ObjCPropertyAccess,
215 bool AvoidPartialAvailabilityChecks,
218 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
222 if (Pos != SuppressedDiagnostics.end()) {
224 Diag(Suppressed.first, Suppressed.second);
235 if (cast<FunctionDecl>(D)->isMain())
236 Diag(Loc, diag::ext_main_used);
238 diagnoseUnavailableAlignedAllocation(*cast<FunctionDecl>(D), Loc);
242 if (ParsingInitForAutoVars.count(D)) {
243 if (isa<BindingDecl>(D)) {
244 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
247 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
248 << D->
getDeclName() << cast<VarDecl>(D)->getType();
255 if (FD->isDeleted()) {
257 if (Ctor && Ctor->isInheritingConstructor())
258 Diag(Loc, diag::err_deleted_inherited_ctor_use)
260 << Ctor->getInheritedConstructor().getConstructor()->getParent();
262 Diag(Loc, diag::err_deleted_function_use);
263 NoteDeletedFunction(FD);
269 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
270 DeduceReturnType(FD, Loc))
273 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
277 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
279 if (MD->getParent()->isLambda() &&
280 ((isa<CXXConstructorDecl>(MD) &&
281 cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
282 MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
283 Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
284 << !isa<CXXConstructorDecl>(MD);
288 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
290 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
295 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
297 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
306 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
308 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
309 << getCurFunction()->HasOMPDeclareReductionCombiner;
314 DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
315 AvoidPartialAvailabilityChecks, ClassReceiver);
330 return ": " + Message;
332 return std::string();
341 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
346 unsigned numFormalParams;
350 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
353 numFormalParams = MD->param_size();
354 calleeType = CT_Method;
355 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
356 numFormalParams = FD->param_size();
357 calleeType = CT_Function;
358 }
else if (isa<VarDecl>(D)) {
364 calleeType = CT_Function;
367 calleeType = CT_Block;
373 numFormalParams = proto->getNumParams();
385 unsigned nullPos = attr->getNullPos();
386 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
387 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
390 unsigned numArgsAfterSentinel = attr->getSentinel();
394 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
401 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
402 if (!sentinelExpr)
return;
411 std::string NullValue;
412 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
414 else if (getLangOpts().CPlusPlus11)
415 NullValue =
"nullptr";
416 else if (PP.isMacroDefined(
"NULL"))
419 NullValue =
"(void*) 0";
422 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
424 Diag(MissingNilLoc, diag::warn_missing_sentinel)
448 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
452 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
457 CK_FunctionToPointerDecay).
get();
470 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
472 CK_ArrayToPointerDecay).
get();
484 if (UO->getOpcode() == UO_Deref &&
485 UO->getSubExpr()->IgnoreParenCasts()->
487 !UO->getType().isVolatileQualified()) {
489 S.
PDiag(diag::warn_indirection_through_null)
490 << UO->getSubExpr()->getSourceRange());
492 S.
PDiag(diag::note_indirection_through_null));
505 if (!Member || !Member->
isStr(
"isa"))
515 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
523 if (ObjectSetClass) {
567 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
571 if (getLangOpts().CPlusPlus &&
586 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
595 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
602 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
627 UpdateMarkingForLValueToRValue(E);
632 Cleanup.setExprNeedsCleanups(
true);
641 T = Atomic->getValueType().getUnqualifiedType();
650 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
653 Res = DefaultLvalueConversion(Res.
get());
668 CK_FunctionToPointerDecay).
get();
672 Res = DefaultLvalueConversion(Res.
get());
685 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
691 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
694 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
695 return ImpCastExprToType(Res.
get(), Context.
FloatTy, CK_FloatingCast);
716 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
721 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
734 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
742 unsigned NumElts = 0;
744 NumElts = VecTy->getNumElements();
745 ScalarTy = VecTy->getElementType();
753 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
754 BTy->
getKind() == BuiltinType::Float)) {
755 if (getLangOpts().OpenCL &&
756 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
757 if (BTy->
getKind() == BuiltinType::Half) {
761 E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
767 E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
828 if (!Record->hasNonTrivialCopyConstructor() &&
829 !Record->hasNonTrivialMoveConstructor() &&
830 !Record->hasNonTrivialDestructor())
831 return VAK_ValidInCXX11;
839 if (getLangOpts().MSVCCompat)
840 return VAK_MSVCUndefined;
844 return VAK_Undefined;
854 case VAK_ValidInCXX11:
857 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg) << Ty << CT);
864 PDiag(diag::warn_pass_class_arg_to_vararg)
865 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
870 case VAK_MSVCUndefined:
872 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
873 << getLangOpts().CPlusPlus11 << Ty << CT);
879 diag::err_cannot_pass_non_trivial_c_struct_to_vararg)
883 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
887 << isa<InitListExpr>(E) << Ty << CT;
898 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
899 (CT == VariadicMethod ||
900 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
901 E = stripARCUnbridgedCast(E);
912 ExprResult ExprRes = DefaultArgumentPromotion(E);
919 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
926 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
945 diag::err_call_incomplete_argument))
962 if (SkipCast)
return false;
964 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
967 CK_FloatingRealToComplex);
971 CK_IntegralComplexToFloatingComplex);
1004 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
1005 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
1007 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
1009 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1015 if (!IsCompAssign) {
1022 }
else if (Order > 0) {
1037 bool ConvertFloat,
bool ConvertInt) {
1042 CK_IntegralToFloating);
1053 CK_IntegralComplexToFloatingComplex);
1058 CK_FloatingRealToComplex);
1067 QualType RHSType,
bool IsCompAssign) {
1073 if (LHSFloat && RHSFloat) {
1080 assert(order < 0 &&
"illegal float comparison");
1114 "The remaining types must be floating point types.");
1119 QualType LHSElemType = LHSComplex ?
1120 LHSComplex->getElementType() : LHSType;
1121 QualType RHSElemType = RHSComplex ?
1137 return Float128AndLongDouble &&
1139 &llvm::APFloat::PPCDoubleDouble());
1153 CK_IntegralComplexCast);
1159 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1162 QualType RHSType,
bool IsCompAssign) {
1167 if (LHSSigned == RHSSigned) {
1170 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1172 }
else if (!IsCompAssign)
1173 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1175 }
else if (order != (LHSSigned ? 1 : -1)) {
1179 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1181 }
else if (!IsCompAssign)
1182 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1189 RHS = (*doRHSCast)(S, RHS.
get(), LHSType);
1191 }
else if (!IsCompAssign)
1192 LHS = (*doLHSCast)(S, LHS.
get(), RHSType);
1201 RHS = (*doRHSCast)(S, RHS.
get(), result);
1203 LHS = (*doLHSCast)(S, LHS.
get(), result);
1213 bool IsCompAssign) {
1217 if (LHSComplexInt && RHSComplexInt) {
1221 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1222 (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1224 return S.Context.getComplexType(ScalarType);
1227 if (LHSComplexInt) {
1230 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1231 (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1233 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1234 CK_IntegralRealToComplex);
1239 assert(RHSComplexInt);
1243 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1244 (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1248 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1249 CK_IntegralRealToComplex);
1258 bool IsCompAssign) {
1259 if (!IsCompAssign) {
1260 LHS = UsualUnaryConversions(LHS.
get());
1265 RHS = UsualUnaryConversions(RHS.
get());
1278 LHSType = AtomicLHS->getValueType();
1281 if (LHSType == RHSType)
1290 QualType LHSUnpromotedType = LHSType;
1294 if (!LHSBitfieldPromoteTy.
isNull())
1295 LHSType = LHSBitfieldPromoteTy;
1296 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1297 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1300 if (LHSType == RHSType)
1326 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1327 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1340 Expr *ControllingExpr,
1343 unsigned NumAssocs = ArgTypes.size();
1344 assert(NumAssocs == ArgExprs.size());
1347 for (
unsigned i = 0; i < NumAssocs; ++i) {
1349 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1354 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1356 llvm::makeArrayRef(Types, NumAssocs),
1366 Expr *ControllingExpr,
1369 unsigned NumAssocs = Types.size();
1370 assert(NumAssocs == Exprs.size());
1377 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1380 ControllingExpr = R.
get();
1385 if (!inTemplateInstantiation() &&
1388 diag::warn_side_effects_unevaluated_context);
1390 bool TypeErrorFound =
false,
1392 ContainsUnexpandedParameterPack
1395 for (
unsigned i = 0; i < NumAssocs; ++i) {
1396 if (Exprs[i]->containsUnexpandedParameterPack())
1397 ContainsUnexpandedParameterPack =
true;
1400 if (Types[i]->getType()->containsUnexpandedParameterPack())
1401 ContainsUnexpandedParameterPack =
true;
1403 if (Types[i]->getType()->isDependentType()) {
1404 IsResultDependent =
true;
1409 if (Types[i]->getType()->isIncompleteType())
1410 D = diag::err_assoc_type_incomplete;
1411 else if (!Types[i]->getType()->isObjectType())
1412 D = diag::err_assoc_type_nonobject;
1413 else if (Types[i]->getType()->isVariablyModifiedType())
1414 D = diag::err_assoc_type_variably_modified;
1417 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1418 << Types[i]->getTypeLoc().getSourceRange()
1419 << Types[i]->getType();
1420 TypeErrorFound =
true;
1425 for (
unsigned j = i+1; j < NumAssocs; ++j)
1426 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1428 Types[j]->getType())) {
1429 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1430 diag::err_assoc_compatible_types)
1431 << Types[j]->getTypeLoc().getSourceRange()
1432 << Types[j]->getType()
1433 << Types[i]->getType();
1434 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1435 diag::note_compat_assoc)
1436 << Types[i]->getTypeLoc().getSourceRange()
1437 << Types[i]->getType();
1438 TypeErrorFound =
true;
1448 if (IsResultDependent)
1450 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1451 ContainsUnexpandedParameterPack);
1454 unsigned DefaultIndex = -1U;
1455 for (
unsigned i = 0; i < NumAssocs; ++i) {
1459 Types[i]->getType()))
1460 CompatIndices.push_back(i);
1466 if (CompatIndices.size() > 1) {
1470 Diag(ControllingExpr->
getBeginLoc(), diag::err_generic_sel_multi_match)
1472 << (unsigned)CompatIndices.size();
1473 for (
unsigned I : CompatIndices) {
1474 Diag(Types[I]->getTypeLoc().getBeginLoc(),
1475 diag::note_compat_assoc)
1476 << Types[I]->getTypeLoc().getSourceRange()
1477 << Types[I]->getType();
1485 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1499 unsigned ResultIndex =
1500 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1503 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1504 ContainsUnexpandedParameterPack, ResultIndex);
1522 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1525 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1526 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1527 if (ArgTy[ArgIdx]->isArrayType())
1554 assert(!StringToks.empty() &&
"Must have at least one string!");
1557 if (Literal.hadError)
1561 for (
const Token &
Tok : StringToks)
1562 StringTokLocs.push_back(
Tok.getLocation());
1566 if (Literal.isWide()) {
1569 }
else if (Literal.isUTF8()) {
1570 if (getLangOpts().Char8)
1573 }
else if (Literal.isUTF16()) {
1576 }
else if (Literal.isUTF32()) {
1579 }
else if (Literal.isPascal()) {
1585 if (getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus2a &&
1587 Diag(StringTokLocs.front(), diag::warn_cxx2a_compat_utf8_string);
1593 auto RemovalDiag = PDiag(diag::note_cxx2a_compat_utf8_string_remove_u8);
1595 for (
const Token &
Tok : StringToks) {
1596 if (
Tok.getKind() == tok::utf8_string_literal) {
1598 RemovalDiagLoc =
Tok.getLocation();
1602 getSourceManager(), getLangOpts())));
1605 Diag(RemovalDiagLoc, RemovalDiag);
1611 if (getLangOpts().
CPlusPlus || getLangOpts().ConstStrings)
1620 CharTyConst, llvm::APInt(32, Literal.GetNumStringChars() + 1),
1625 Kind, Literal.Pascal, StrTy,
1627 StringTokLocs.size());
1628 if (Literal.getUDSuffix().empty())
1635 Literal.getUDSuffixOffset());
1639 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1654 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1655 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1661 llvm::APInt Len(Context.
getIntWidth(SizeType), Literal.GetNumStringChars());
1664 Expr *Args[] = { Lit, LenArg };
1666 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1669 case LOLR_StringTemplate: {
1674 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1680 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1686 return BuildLiteralOperatorCall(R, OpNameInfo, None, StringTokLocs.back(),
1691 case LOLR_ErrorNoDiagnostic:
1692 llvm_unreachable(
"unexpected literal operator lookup result");
1696 llvm_unreachable(
"unexpected literal operator lookup result");
1704 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1714 bool RefersToCapturedVariable =
1716 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1719 if (isa<VarTemplateSpecializationDecl>(D)) {
1721 cast<VarTemplateSpecializationDecl>(D);
1726 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1727 FoundD, TemplateArgs);
1729 assert(!TemplateArgs &&
"No template arguments for non-variable" 1730 " template specialization references");
1734 NameInfo, Ty, VK, FoundD);
1737 MarkDeclRefReferenced(E);
1739 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1741 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getBeginLoc()))
1742 getCurFunction()->recordUseOfWeak(E);
1746 FD = IFD->getAnonField();
1748 UnusedPrivateFields.remove(FD);
1756 if (
auto *BD = dyn_cast<BindingDecl>(D))
1757 if (
auto *BE = BD->getBinding())
1758 E->setObjectKind(BE->getObjectKind());
1783 translateTemplateArguments(TemplateArgsPtr, Buffer);
1788 TemplateArgs = &Buffer;
1790 NameInfo = GetNameFromUnqualifiedId(Id);
1791 TemplateArgs =
nullptr;
1798 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1805 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1808 SemaRef.
Diag(TypoLoc, DiagnosticID) << Typo;
1813 bool DroppedSpecifier =
1816 ? diag::note_implicit_param_decl
1817 : diag::note_previous_decl;
1820 SemaRef.
PDiag(NoteID));
1823 << Typo << Ctx << DroppedSpecifier
1825 SemaRef.
PDiag(NoteID));
1833 std::unique_ptr<CorrectionCandidateCallback> CCC,
1838 unsigned diagnostic = diag::err_undeclared_var_use;
1839 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1843 diagnostic = diag::err_undeclared_use;
1844 diagnostic_suggest = diag::err_undeclared_use_suggest;
1853 if (isa<CXXRecordDecl>(DC)) {
1854 LookupQualifiedName(R, DC);
1863 bool isDefaultArgument =
1864 !CodeSynthesisContexts.empty() &&
1865 CodeSynthesisContexts.back().Kind ==
1866 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
1868 bool isInstance = CurMethod &&
1870 DC == CurMethod->
getParent() && !isDefaultArgument;
1875 if (getLangOpts().MSVCCompat)
1876 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1887 Diag(D->getLocation(), diag::note_dependent_var_use);
1893 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1894 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1909 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1910 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1921 assert(!ExplicitTemplateArgs &&
1922 "Diagnosing an empty lookup with explicit template args!");
1923 *Out = CorrectTypoDelayed(
1927 diagnostic, diagnostic_suggest);
1929 nullptr, CTK_ErrorRecovery);
1932 }
else if (S && (Corrected =
1934 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1935 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1936 bool DroppedSpecifier =
1940 bool AcceptableWithRecovery =
false;
1941 bool AcceptableWithoutRecovery =
false;
1950 dyn_cast<FunctionTemplateDecl>(CD))
1951 AddTemplateOverloadCandidate(
1954 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1955 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1959 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1961 ND = Best->FoundDecl;
1962 Corrected.setCorrectionDecl(ND);
1966 Corrected.setCorrectionDecl(ND);
1978 Record = cast<CXXRecordDecl>(
1984 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
1985 isa<FunctionTemplateDecl>(UnderlyingND);
1991 AcceptableWithoutRecovery =
1992 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
1996 AcceptableWithoutRecovery =
true;
1999 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2001 ? diag::note_implicit_param_decl
2002 : diag::note_previous_decl;
2004 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
2005 PDiag(NoteID), AcceptableWithRecovery);
2007 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2008 << Name << computeDeclContext(SS,
false)
2009 << DroppedSpecifier << SS.getRange(),
2010 PDiag(NoteID), AcceptableWithRecovery);
2013 return !AcceptableWithRecovery;
2020 if (!SS.isEmpty()) {
2022 << Name << computeDeclContext(SS,
false)
2049 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2057 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2058 DB << NameInfo.
getName() << RD;
2060 if (!ThisType.
isNull()) {
2063 Context,
nullptr, ThisType,
true,
2065 nullptr, NameInfo, TemplateArgs);
2082 bool HasTrailingLParen,
bool IsAddressOfOperand,
2083 std::unique_ptr<CorrectionCandidateCallback> CCC,
2084 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2085 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2086 "cannot be direct & operand and have a trailing lparen");
2095 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2118 bool DependentID =
false;
2122 }
else if (SS.
isSet()) {
2123 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2124 if (RequireCompleteDeclContext(SS, DC))
2132 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2133 IsAddressOfOperand, TemplateArgs);
2138 ? LookupObjCImplicitSelfParam
2139 : LookupOrdinaryName);
2140 if (TemplateKWLoc.
isValid() || TemplateArgs) {
2146 bool MemberOfUnknownSpecialization;
2147 if (LookupTemplateName(R, S, SS,
QualType(),
false,
2148 MemberOfUnknownSpecialization, TemplateKWLoc))
2151 if (MemberOfUnknownSpecialization ||
2153 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2154 IsAddressOfOperand, TemplateArgs);
2156 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2157 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2162 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2163 IsAddressOfOperand, TemplateArgs);
2167 if (IvarLookupFollowUp) {
2168 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2182 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2183 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2189 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2191 if (R.
empty() && !ADL) {
2192 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2194 TemplateKWLoc, TemplateArgs))
2199 if (IsInlineAsmIdentifier)
2205 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2207 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2208 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2209 "Typo correction callback misconfigured");
2212 CCC->setTypoName(II);
2219 if (DiagnoseEmptyLookup(S, SS, R,
2220 CCC ? std::move(CCC) : std::move(DefaultValidator),
2221 nullptr, None, &TE)) {
2222 if (TE && KeywordReplacement) {
2223 auto &
State = getTypoExprState(TE);
2224 auto BestTC =
State.Consumer->getNextCorrection();
2225 if (BestTC.isKeyword()) {
2226 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2227 if (
State.DiagHandler)
2228 State.DiagHandler(BestTC);
2230 KeywordReplacement->
setKind(II->getTokenID());
2232 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2235 clearDelayedTypo(TE);
2238 return (
Expr*)
nullptr;
2240 State.Consumer->resetCorrectionStream();
2245 assert(!R.
empty() &&
2246 "DiagnoseEmptyLookup returned false but added no results");
2253 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2263 assert(!R.
empty() || ADL);
2289 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2290 bool MightBeImplicitMember;
2291 if (!IsAddressOfOperand)
2292 MightBeImplicitMember =
true;
2294 MightBeImplicitMember =
false;
2296 MightBeImplicitMember =
false;
2298 MightBeImplicitMember =
true;
2300 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2304 if (MightBeImplicitMember)
2305 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2306 R, TemplateArgs, S);
2309 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2317 "There should only be one declaration found.");
2320 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2323 return BuildDeclarationNameExpr(SS, R, ADL);
2338 if (RequireCompleteDeclContext(SS, DC))
2342 LookupQualifiedName(R, DC);
2361 unsigned DiagID = diag::err_typename_missing;
2362 if (RecoveryTSI && getLangOpts().MSVCCompat)
2363 DiagID = diag::ext_typename_missing;
2365 auto D =
Diag(Loc, DiagID);
2396 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2397 return BuildPossibleImplicitMemberExpr(SS,
2401 return BuildDeclarationNameExpr(SS, R,
false);
2435 LookForIvars =
true;
2436 else if (IsClassMethod)
2437 LookForIvars =
false;
2449 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2458 if (DiagnoseUseOfDecl(IV, Loc))
2464 !getLangOpts().DebuggerSupport)
2475 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2476 SelfName,
false,
false);
2480 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2484 MarkAnyDeclReferenced(Loc, IV,
true);
2488 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2496 if (!isUnevaluatedContext() &&
2497 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2498 getCurFunction()->recordUseOfWeak(Result);
2500 if (getLangOpts().ObjCAutoRefCount) {
2501 if (CurContext->isClosure())
2502 Diag(Loc, diag::warn_implicitly_retains_self)
2515 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2522 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2523 << IV->getDeclName());
2526 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2572 bool PointerConversions =
false;
2573 if (isa<FieldDecl>(Member)) {
2579 PointerConversions =
true;
2581 DestType = DestRecordType;
2582 FromRecordType = FromType;
2584 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2585 if (Method->isStatic())
2588 DestType = Method->getThisType();
2593 PointerConversions =
true;
2595 FromRecordType = FromType;
2596 DestType = DestRecordType;
2633 if (Qualifier && Qualifier->
getAsType()) {
2635 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2642 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2644 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2645 FromLoc, FromRange, &BasePath))
2648 if (PointerConversions)
2650 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2651 VK, &BasePath).get();
2654 FromRecordType = QRecordType;
2663 bool IgnoreAccess =
false;
2671 assert(isa<UsingShadowDecl>(FoundDecl));
2678 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2680 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2681 FromLoc, FromRange, &BasePath))
2685 if (PointerConversions)
2687 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2688 VK, &BasePath).get();
2690 FromRecordType = URecordType;
2695 IgnoreAccess =
true;
2699 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2700 FromLoc, FromRange, &BasePath,
2704 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2710 bool HasTrailingLParen) {
2712 if (!HasTrailingLParen)
2720 if (!getLangOpts().CPlusPlus)
2730 if (D->isCXXClassMember())
2739 if (isa<UsingShadowDecl>(D))
2740 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2741 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2748 if (isa<FunctionDecl>(D)) {
2754 }
else if (!isa<FunctionTemplateDecl>(D))
2770 if (isa<TypedefNameDecl>(D)) {
2775 if (isa<ObjCInterfaceDecl>(D)) {
2780 if (isa<NamespaceDecl>(D)) {
2794 (FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion());
2799 bool AcceptInvalidDecl) {
2839 bool AcceptInvalidDecl) {
2840 assert(D &&
"Cannot refer to a NULL declaration");
2841 assert(!isa<FunctionTemplateDecl>(D) &&
2842 "Cannot refer unambiguously to a function template");
2848 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2851 diagnoseMissingTemplateArguments(
TemplateName(Template), Loc);
2858 Diag(Loc, diag::err_ref_non_value)
2868 if (DiagnoseUseOfDecl(VD, Loc))
2879 if (!indirectField->isCXXClassMember())
2880 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2892 ResolveExceptionSpec(Loc, FPT);
2899 #define ABSTRACT_DECL(kind) 2900 #define VALUE(type, base) 2901 #define DECL(type, base) \ 2903 #include "clang/AST/DeclNodes.inc" 2904 llvm_unreachable(
"invalid value decl kind");
2907 case Decl::ObjCAtDefsField:
2908 case Decl::ObjCIvar:
2909 llvm_unreachable(
"forming non-member reference to ivar?");
2913 case Decl::EnumConstant:
2914 case Decl::UnresolvedUsingValue:
2915 case Decl::OMPDeclareReduction:
2924 case Decl::IndirectField:
2926 "building reference to field in C?");
2936 case Decl::NonTypeTemplateParm: {
2951 case Decl::VarTemplateSpecialization:
2952 case Decl::VarTemplatePartialSpecialization:
2953 case Decl::Decomposition:
2954 case Decl::OMPCapturedExpr:
2964 case Decl::ImplicitParam:
2965 case Decl::ParmVar: {
2973 if (!isUnevaluatedContext()) {
2974 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2975 if (!CapturedType.
isNull())
2976 type = CapturedType;
2982 case Decl::Binding: {
2988 auto *BD = cast<BindingDecl>(VD);
2989 if (BD->getDeclContext()->isFunctionOrMethod() &&
2990 BD->getDeclContext() != CurContext)
2996 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
3015 if (getLangOpts().CPlusPlus) {
3025 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
3026 isa<FunctionProtoType>(fty))
3035 case Decl::CXXDeductionGuide:
3036 llvm_unreachable(
"building reference to deduction guide");
3038 case Decl::MSProperty:
3042 case Decl::CXXMethod:
3047 = dyn_cast<FunctionProtoType>(VD->
getType()))
3055 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3061 case Decl::CXXConversion:
3062 case Decl::CXXDestructor:
3063 case Decl::CXXConstructor:
3068 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3075 Target.resize(CharByteWidth * (Source.size() + 1));
3076 char *ResultPtr = &Target[0];
3077 const llvm::UTF8 *ErrorPtr;
3079 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3082 Target.resize(ResultPtr - &Target[0]);
3088 Decl *currentDecl =
nullptr;
3090 currentDecl = BSI->TheDecl;
3092 currentDecl = LSI->CallOperator;
3094 currentDecl = CSI->TheCapturedDecl;
3096 currentDecl = getCurFunctionOrMethodDecl();
3099 Diag(Loc, diag::ext_predef_outside_function);
3105 if (cast<DeclContext>(currentDecl)->isDependentContext())
3111 unsigned Length = Str.length();
3113 llvm::APInt LengthI(32, Length + 1);
3140 default: llvm_unreachable(
"Unknown simple primary expr!");
3150 return BuildPredefinedExpr(Loc, IK);
3155 bool Invalid =
false;
3156 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3162 if (Literal.hadError())
3166 if (Literal.isWide())
3168 else if (Literal.isUTF8() && getLangOpts().Char8)
3170 else if (Literal.isUTF16())
3172 else if (Literal.isUTF32())
3174 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3180 if (Literal.isWide())
3182 else if (Literal.isUTF16())
3184 else if (Literal.isUTF32())
3186 else if (Literal.isUTF8())
3192 if (Literal.getUDSuffix().empty())
3202 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3213 Context.
IntTy, Loc);
3220 using llvm::APFloat;
3221 APFloat Val(Format);
3227 if ((result & APFloat::opOverflow) ||
3228 ((result & APFloat::opUnderflow) && Val.isZero())) {
3229 unsigned diagnostic;
3231 if (result & APFloat::opOverflow) {
3232 diagnostic = diag::warn_float_overflow;
3233 APFloat::getLargest(Format).toString(buffer);
3235 diagnostic = diag::warn_float_underflow;
3236 APFloat::getSmallest(Format).toString(buffer);
3239 S.
Diag(Loc, diagnostic)
3241 << StringRef(buffer.data(), buffer.size());
3244 bool isExact = (result == APFloat::opOK);
3249 assert(E &&
"Invalid expression");
3256 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3260 llvm::APSInt ValueAPS;
3261 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3266 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3267 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3268 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3269 << ValueAPS.toString(10) << ValueIsPositive;
3280 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3281 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3289 SpellingBuffer.resize(Tok.
getLength() + 1);
3292 bool Invalid =
false;
3293 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3298 if (Literal.hadError)
3301 if (Literal.hasUDSuffix()) {
3309 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3312 if (Literal.isFloatingLiteral()) {
3333 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3334 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3337 !Literal.isImaginary)) {
3338 case LOLR_ErrorNoDiagnostic:
3346 if (Literal.isFloatingLiteral()) {
3350 if (Literal.GetIntegerValue(ResultVal))
3356 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3363 unsigned Length = Literal.getUDSuffixOffset();
3369 false, StrTy, &TokLoc, 1);
3370 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3373 case LOLR_Template: {
3380 bool CharIsUnsigned = Context.
CharTy->isUnsignedIntegerType();
3381 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3382 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3383 Value = TokSpelling[I];
3388 return BuildLiteralOperatorCall(R, OpNameInfo, None, TokLoc,
3391 case LOLR_StringTemplate:
3392 llvm_unreachable(
"unexpected literal operator lookup result");
3398 if (Literal.isFixedPointLiteral()) {
3401 if (Literal.isAccum) {
3402 if (Literal.isHalf) {
3404 }
else if (Literal.isLong) {
3409 }
else if (Literal.isFract) {
3410 if (Literal.isHalf) {
3412 }
else if (Literal.isLong) {
3421 bool isSigned = !Literal.isUnsigned;
3425 llvm::APInt Val(bit_width, 0, isSigned);
3426 bool Overflowed = Literal.GetFixedPointValue(Val, scale);
3427 bool ValIsZero = Val.isNullValue() && !Overflowed;
3430 if (Literal.isFract && Val == MaxVal + 1 && !ValIsZero)
3436 else if (Val.ugt(MaxVal) || Overflowed)
3441 }
else if (Literal.isFloatingLiteral()) {
3443 if (Literal.isHalf){
3444 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3450 }
else if (Literal.isFloat)
3452 else if (Literal.isLong)
3454 else if (Literal.isFloat16)
3456 else if (Literal.isFloat128)
3464 if (getLangOpts().SinglePrecisionConstants) {
3466 if (BTy->
getKind() != BuiltinType::Float) {
3467 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3469 }
else if (getLangOpts().OpenCL &&
3470 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3473 Res = ImpCastExprToType(Res, Context.
FloatTy, CK_FloatingCast).get();
3476 }
else if (!Literal.isIntegerLiteral()) {
3482 if (!getLangOpts().
C99 && Literal.isLongLong) {
3485 getLangOpts().CPlusPlus11 ?
3486 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3488 Diag(
Tok.getLocation(), diag::ext_c99_longlong);
3493 llvm::APInt ResultVal(MaxWidth, 0);
3495 if (Literal.GetIntegerValue(ResultVal)) {
3497 Diag(
Tok.getLocation(), diag::err_integer_literal_too_large)
3500 assert(Context.
getTypeSize(Ty) == ResultVal.getBitWidth() &&
3501 "long long is not intmax_t?");
3508 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3514 if (Literal.MicrosoftInteger) {
3515 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3519 Width = Literal.MicrosoftInteger;
3521 !Literal.isUnsigned);
3525 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3530 if (ResultVal.isIntN(IntSize)) {
3532 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3534 else if (AllowUnsigned)
3541 if (Ty.
isNull() && !Literal.isLongLong) {
3545 if (ResultVal.isIntN(LongSize)) {
3547 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3549 else if (AllowUnsigned)
3553 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3554 const unsigned LongLongSize =
3557 getLangOpts().CPlusPlus
3559 ? diag::warn_old_implicitly_unsigned_long_cxx
3561 ext_old_implicitly_unsigned_long_cxx
3562 : diag::warn_old_implicitly_unsigned_long)
3563 << (LongLongSize > LongSize ? 0
3576 if (ResultVal.isIntN(LongLongSize)) {
3580 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3581 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3583 else if (AllowUnsigned)
3585 Width = LongLongSize;
3592 Diag(
Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3597 if (ResultVal.getBitWidth() != Width)
3598 ResultVal = ResultVal.trunc(Width);
3604 if (Literal.isImaginary) {
3608 Diag(
Tok.getLocation(), diag::ext_imaginary_constant);
3614 assert(E &&
"ActOnParenExpr() missing expr");
3615 return new (Context)
ParenExpr(L, R, E);
3626 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3632 "Scalar types should always be complete");
3649 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3650 << TraitKind << ArgRange;
3657 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3658 : diag::ext_sizeof_alignof_void_type;
3659 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3673 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3692 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3728 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3732 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3752 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3760 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3761 QualType OType = PVD->getOriginalType();
3766 Diag(PVD->getLocation(), diag::note_declared_at);
3831 if (RequireCompleteType(OpLoc, ExprType,
3832 diag::err_sizeof_alignof_incomplete_type,
3833 ExprKind, ExprRange))
3837 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3838 << ExprKind << ExprRange;
3857 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3863 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3865 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3866 D = ME->getMemberDecl();
3886 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3889 if (!FD->getParent()->isCompleteDefinition()) {
3890 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3899 if (!FD->getType()->isReferenceType())
3913 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
3919 assert(CSI !=
nullptr);
3925 #define TYPE(Class, Base) 3926 #define ABSTRACT_TYPE(Class, Base) 3927 #define NON_CANONICAL_TYPE(Class, Base) 3928 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 3929 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) 3930 #include "clang/AST/TypeNodes.def" 3937 case Type::ExtVector:
3940 case Type::Elaborated:
3941 case Type::TemplateSpecialization:
3942 case Type::ObjCObject:
3943 case Type::ObjCInterface:
3944 case Type::ObjCObjectPointer:
3945 case Type::ObjCTypeParam:
3947 llvm_unreachable(
"type class is never variably-modified!");
3948 case Type::Adjusted:
3949 T = cast<AdjustedType>(Ty)->getOriginalType();
3952 T = cast<DecayedType>(Ty)->getPointeeType();
3955 T = cast<PointerType>(Ty)->getPointeeType();
3957 case Type::BlockPointer:
3958 T = cast<BlockPointerType>(Ty)->getPointeeType();
3960 case Type::LValueReference:
3961 case Type::RValueReference:
3962 T = cast<ReferenceType>(Ty)->getPointeeType();
3964 case Type::MemberPointer:
3965 T = cast<MemberPointerType>(Ty)->getPointeeType();
3967 case Type::ConstantArray:
3968 case Type::IncompleteArray:
3970 T = cast<ArrayType>(Ty)->getElementType();
3972 case Type::VariableArray: {
3981 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3982 CapRecord = LSI->Lambda;
3983 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3984 CapRecord = CRSI->TheRecordDecl;
3987 auto ExprLoc = Size->getExprLoc();
3992 nullptr, SizeType,
nullptr,
3995 Field->setImplicit(
true);
3997 Field->setCapturedVLAType(VAT);
4007 case Type::FunctionProto:
4008 case Type::FunctionNoProto:
4009 T = cast<FunctionType>(Ty)->getReturnType();
4013 case Type::UnaryTransform:
4014 case Type::Attributed:
4015 case Type::SubstTemplateTypeParm:
4016 case Type::PackExpansion:
4021 T = cast<TypedefType>(Ty)->desugar();
4023 case Type::Decltype:
4024 T = cast<DecltypeType>(Ty)->desugar();
4027 case Type::DeducedTemplateSpecialization:
4028 T = cast<DeducedType>(Ty)->getDeducedType();
4030 case Type::TypeOfExpr:
4031 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
4034 T = cast<AtomicType>(Ty)->getValueType();
4052 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
4057 for (
auto I = FunctionScopes.rbegin(),
4058 E = std::prev(FunctionScopes.rend());
4064 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
4065 DC = LSI->CallOperator;
4066 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
4067 DC = CRSI->TheCapturedDecl;
4068 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4102 isInvalid = CheckVecStepExpr(E);
4107 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4110 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
4117 PE = TransformToPotentiallyEvaluated(E);
4140 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
4144 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
4150 if (V.
get()->isTypeDependent())
4162 return CT->getElementType();
4165 if (V.
get()->getType()->isArithmeticType())
4166 return V.
get()->getType();
4171 if (PR.
get() != V.
get()) {
4177 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4178 << (IsReal ?
"__real" :
"__imag");
4189 default: llvm_unreachable(
"Unknown unary op!");
4190 case tok::plusplus: Opc = UO_PostInc;
break;
4191 case tok::minusminus: Opc = UO_PostDec;
break;
4195 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
4197 Input = Result.
get();
4199 return BuildUnaryOp(S, OpLoc, Opc, Input);
4210 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4213 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4221 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4223 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4231 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4235 if (isa<ParenListExpr>(base)) {
4236 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4238 base = result.
get();
4246 bool IsMSPropertySubscript =
false;
4249 if (!IsMSPropertySubscript) {
4250 ExprResult result = CheckPlaceholderExpr(base);
4253 base = result.
get();
4257 ExprResult result = CheckPlaceholderExpr(idx);
4277 if (IsMSPropertySubscript) {
4292 if (getLangOpts().CPlusPlus &&
4296 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4299 ExprResult Res = CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4301 if (!Res.
isInvalid() && isa<ArraySubscriptExpr>(Res.
get()))
4302 CheckSubscriptAccessOfNoDeref(cast<ArraySubscriptExpr>(Res.
get()));
4307 void Sema::CheckAddressOfNoDeref(
const Expr *E) {
4314 while ((Member = dyn_cast<MemberExpr>(StrippedExpr)) && !Member->
isArrow())
4325 if (isa<ArrayType>(ResultTy))
4328 if (ResultTy->
hasAttr(attr::NoDeref)) {
4337 if (!(isa<ArrayType>(BaseTy) || isa<PointerType>(BaseTy)))
4346 if (
const auto *Ptr = dyn_cast<PointerType>(Base->
getType())) {
4347 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
4358 BuiltinType::OMPArraySection)) {
4359 ExprResult Result = CheckPlaceholderExpr(Base);
4362 Base = Result.
get();
4365 ExprResult Result = CheckPlaceholderExpr(LowerBound);
4368 Result = DefaultLvalueConversion(Result.
get());
4371 LowerBound = Result.
get();
4374 ExprResult Result = CheckPlaceholderExpr(Length);
4377 Result = DefaultLvalueConversion(Result.
get());
4380 Length = Result.
get();
4388 return new (Context)
4407 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4409 if (Res.isInvalid())
4411 diag::err_omp_typecheck_section_not_integer)
4413 LowerBound = Res.get();
4422 PerformOpenMPImplicitIntegerConversion(Length->
getExprLoc(), Length);
4423 if (Res.isInvalid())
4425 diag::err_omp_typecheck_section_not_integer)
4445 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4446 diag::err_omp_section_incomplete_type, Base))
4454 llvm::APSInt LowerBoundValue = Result.
Val.
getInt();
4455 if (LowerBoundValue.isNegative()) {
4456 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4468 llvm::APSInt LengthValue = Result.
Val.
getInt();
4469 if (LengthValue.isNegative()) {
4470 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4471 << LengthValue.toString(10,
true)
4476 }
else if (ColonLoc.
isValid() &&
4482 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4488 BuiltinType::OMPArraySection)) {
4489 ExprResult Result = DefaultFunctionArrayLvalueConversion(Base);
4492 Base = Result.
get();
4494 return new (Context)
4502 Expr *LHSExp = Base;
4511 for (
auto *Op : {LHSExp, RHSExp}) {
4512 Op = Op->IgnoreImplicit();
4513 if (Op->getType()->isArrayType() && !Op->isLValue())
4520 ExprResult Result = DefaultFunctionArrayLvalueConversion(LHSExp);
4523 LHSExp = Result.
get();
4525 ExprResult Result = DefaultFunctionArrayLvalueConversion(RHSExp);
4528 RHSExp = Result.
get();
4536 Expr *BaseExpr, *IndexExpr;
4553 if (!LangOpts.isSubscriptPointerArithmetic())
4554 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4569 if (!LangOpts.isSubscriptPointerArithmetic()) {
4570 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4579 ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
4582 LHSExp = Materialized.
get();
4588 ResultType = VTy->getElementType();
4592 Qualifiers Combined = BaseQuals + MemberQuals;
4593 if (Combined != MemberQuals)
4604 CK_ArrayToPointerDecay).
get();
4610 }
else if (RHSTy->isArrayType()) {
4615 CK_ArrayToPointerDecay).
get();
4622 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4627 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4645 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4647 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4654 RequireCompleteType(LLoc, ResultType,
4655 diag::err_subscript_incomplete_type, BaseExpr))
4658 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4661 return new (Context)
4669 diag::err_use_of_default_argument_to_function_declared_later) <<
4671 Diag(UnparsedDefaultArgLocs[Param],
4672 diag::note_default_argument_declared_here);
4680 *
this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
4700 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4704 if (Inst.isInvalid())
4706 if (Inst.isAlreadyInstantiating()) {
4707 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4720 Result = SubstInitializer(UninstExpr, MutiLevelArgList,
4735 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4748 L->DefaultArgumentInstantiated(Param);
4754 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
4766 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4769 Cleanup.setExprNeedsCleanups(Init->cleanupsHaveSideEffects());
4774 assert(!Init->getNumObjects() &&
4775 "default argument expression has capturing blocks?");
4788 if (CheckCXXDefaultArgExpr(CallLoc, FD, Param))
4797 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4798 return VariadicConstructor;
4800 return VariadicBlock;
4802 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4803 if (Method->isInstance())
4804 return VariadicMethod;
4806 return VariadicMethod;
4807 return VariadicFunction;
4809 return VariadicDoesNotApply;
4818 FunctionName(FuncName) {}
4820 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4844 llvm::make_unique<FunctionCallCCC>(S, FuncName.getAsIdentifierInfo(),
4847 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4848 if (Corrected.isOverloaded()) {
4858 ND = Best->FoundDecl;
4859 Corrected.setCorrectionDecl(ND);
4865 ND = ND->getUnderlyingDecl();
4866 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4885 bool IsExecConfig) {
4895 bool Invalid =
false;
4904 if (Args.size() < NumParams) {
4905 if (Args.size() < MinArgs) {
4910 ? diag::err_typecheck_call_too_few_args_suggest
4911 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4912 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4913 << static_cast<unsigned>(Args.size())
4918 ? diag::err_typecheck_call_too_few_args_one
4919 : diag::err_typecheck_call_too_few_args_at_least_one)
4923 ? diag::err_typecheck_call_too_few_args
4924 : diag::err_typecheck_call_too_few_args_at_least)
4925 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4929 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4937 "We should have reserved space for the default arguments before!");
4942 if (Args.size() > NumParams) {
4948 ? diag::err_typecheck_call_too_many_args_suggest
4949 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4950 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4951 << static_cast<unsigned>(Args.size())
4953 }
else if (NumParams == 1 && FDecl &&
4955 Diag(Args[NumParams]->getBeginLoc(),
4956 MinArgs == NumParams
4957 ? diag::err_typecheck_call_too_many_args_one
4958 : diag::err_typecheck_call_too_many_args_at_most_one)
4962 Args.back()->getEndLoc());
4964 Diag(Args[NumParams]->getBeginLoc(),
4965 MinArgs == NumParams
4966 ? diag::err_typecheck_call_too_many_args
4967 : diag::err_typecheck_call_too_many_args_at_most)
4968 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4971 Args.back()->getEndLoc());
4974 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4985 Invalid = GatherArgumentsForCall(Call->
getBeginLoc(), FDecl, Proto, 0, Args,
4989 unsigned TotalNumArgs = AllArgs.size();
4990 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4991 Call->
setArg(i, AllArgs[i]);
5001 bool IsListInitialization) {
5003 bool Invalid =
false;
5006 for (
unsigned i = FirstParam; i < NumParams; i++) {
5011 if (ArgIx < Args.size()) {
5012 Arg = Args[ArgIx++];
5014 if (RequireCompleteType(Arg->
getBeginLoc(), ProtoArgType,
5015 diag::err_call_incomplete_argument, Arg))
5019 bool CFAudited =
false;
5021 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5022 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5023 Arg = stripARCUnbridgedCast(Arg);
5024 else if (getLangOpts().ObjCAutoRefCount &&
5025 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
5026 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
5031 BE->getBlockDecl()->setDoesNotEscape();
5044 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
5050 assert(Param &&
"can't use default arguments without a known callee");
5053 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
5063 CheckArrayAccess(Arg);
5066 CheckStaticArrayArgument(CallLoc, Param, Arg);
5068 AllArgs.push_back(Arg);
5072 if (CallType != VariadicDoesNotApply) {
5077 for (
Expr *A : Args.slice(ArgIx)) {
5079 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
5081 AllArgs.push_back(arg.
get());
5086 for (
Expr *A : Args.slice(ArgIx)) {
5087 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
5089 AllArgs.push_back(Arg.
get());
5094 for (
Expr *A : Args.slice(ArgIx))
5095 CheckArrayAccess(A);
5103 TL = DTL.getOriginalLoc();
5106 << ATL.getLocalSourceRange();
5120 const Expr *ArgExpr) {
5148 Diag(CallLoc, diag::warn_static_array_too_small)
5150 << (unsigned) ArgCAT->
getSize().getZExtValue()
5151 << (unsigned) CAT->
getSize().getZExtValue();
5165 if (!placeholder)
return false;
5167 switch (placeholder->
getKind()) {
5169 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 5170 case BuiltinType::Id: 5171 #include "clang/Basic/OpenCLImageTypes.def" 5172 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 5173 case BuiltinType::Id: 5174 #include "clang/Basic/OpenCLExtensionTypes.def" 5175 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID) 5176 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: 5177 #include "clang/AST/BuiltinTypes.def" 5182 case BuiltinType::Overload:
5187 case BuiltinType::ARCUnbridgedCast:
5191 case BuiltinType::PseudoObject:
5196 case BuiltinType::UnknownAny:
5200 case BuiltinType::BoundMember:
5201 case BuiltinType::BuiltinFn:
5202 case BuiltinType::OMPArraySection:
5206 llvm_unreachable(
"bad builtin type kind");
5214 bool hasInvalid =
false;
5215 for (
size_t i = 0, e = args.size(); i != e; i++) {
5218 if (result.
isInvalid()) hasInvalid =
true;
5219 else args[i] = result.
get();
5220 }
else if (hasInvalid) {
5249 bool NeedsNewDecl =
false;
5262 if (!ParamType->isPointerType() ||
5263 ParamType.getQualifiers().hasAddressSpace() ||
5266 OverloadParams.push_back(ParamType);
5274 NeedsNewDecl =
true;
5286 OverloadParams, EPI);
5297 FT = cast<FunctionProtoType>(OverloadTy);
5298 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5305 Params.push_back(Parm);
5307 OverloadDecl->setParams(Params);
5308 return OverloadDecl;
5326 isa<CXXMethodDecl>(Callee)
5327 ? diag::err_ovl_no_viable_member_function_in_call
5328 : diag::err_ovl_no_viable_function_in_call)
5331 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5332 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5340 const auto GetFunctionLevelDCIfCXXClass =
5348 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
5349 return MD->
getParent()->getCanonicalDecl();
5352 if (
const auto *RD = dyn_cast<CXXRecordDecl>(DC))
5353 return RD->getCanonicalDecl();
5360 const CXXRecordDecl *
const CurParentClass = GetFunctionLevelDCIfCXXClass(S);
5361 if (!CurParentClass)
5368 assert(NamingClass &&
"Must have naming class even for implicit access");
5374 return CurParentClass == NamingClass ||
5423 Expr *ExecConfig,
bool IsExecConfig) {
5425 ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
5434 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5435 if (!ArgExprs.empty()) {
5440 ArgExprs.back()->getEndLoc()));
5447 ExprResult result = CheckPlaceholderExpr(Fn);
5457 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5462 *
this, dyn_cast<UnresolvedMemberExpr>(Fn->
IgnoreParens()),
5472 return BuildCallToObjectOfClassType(Scope, Fn, LParenLoc, ArgExprs,
5482 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5498 return BuildOverloadedCallExpr(
5499 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5501 return BuildCallToMemberFunction(Scope, Fn, LParenLoc, ArgExprs,
5515 bool CallingNDeclIndirectly =
false;
5517 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5518 if (UnOp->getOpcode() == UO_AddrOf) {
5519 CallingNDeclIndirectly =
true;
5524 if (isa<DeclRefExpr>(NakedFn)) {
5525 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5540 }
else if (isa<MemberExpr>(NakedFn))
5541 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5543 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5548 if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn))
5554 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5555 ExecConfig, IsExecConfig);
5567 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5571 diag::err_invalid_astype_of_different_size)
5575 return new (Context)
AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc);
5587 GetTypeFromParser(ParsedDestTy, &TInfo);
5588 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5602 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5603 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5606 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5615 if (
auto *Caller = getCurFunctionDecl())
5616 if (Caller->hasAttr<ARMInterruptAttr>()) {
5618 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5619 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5634 Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
5637 Result = CallExprUnaryConversions(Fn);
5638 ResultTy = Context.
BoolTy;
5640 if (Result.isInvalid())
5655 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5669 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5677 const auto *Proto = dyn_cast_or_null<FunctionProtoType>(FuncT);
5678 unsigned NumParams = Proto ? Proto->getNumParams() : 0;
5682 assert(UsesADL == ADLCallKind::NotADL &&
5683 "CUDAKernelCallExpr should not use ADL");
5686 ResultTy,
VK_RValue, RParenLoc, NumParams);
5689 RParenLoc, NumParams, UsesADL);
5697 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5700 if (!TheCall)
return Result;
5704 Args = llvm::makeArrayRef(TheCall->
getArgs(), Args.size());
5709 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5711 if (getLangOpts().CUDA) {
5714 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5715 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5720 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5724 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5725 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5740 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5744 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5752 if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->
param_size()))
5753 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5764 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5765 Expr *Arg = Args[i];
5767 if (Proto && i < Proto->getNumParams()) {
5769 Context, Proto->getParamType(i), Proto->isParamConsumed(i));
5772 if (ArgE.isInvalid())
5775 Arg = ArgE.getAs<
Expr>();
5778 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5787 diag::err_call_incomplete_argument, Arg))
5794 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5795 if (!Method->isStatic())
5796 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5801 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5805 if (CheckFunctionCall(FDecl, TheCall, Proto))
5809 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5811 if (CheckPointerCall(NDecl, TheCall, Proto))
5814 if (CheckOtherCall(TheCall, Proto))
5818 return MaybeBindToTemporary(TheCall);
5824 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5825 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5828 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5832 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5842 diag::err_illegal_decl_array_incomplete_type,
5847 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5850 RequireCompleteType(LParenLoc, literalType,
5851 diag::err_typecheck_decl_incomplete_type,
5866 LiteralExpr = Result.
get();
5868 bool isFileScope = !CurContext->isFunctionOrMethod();
5889 (getLangOpts().CPlusPlus && !(isFileScope && literalType->
isArrayType()))
5894 if (
auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
5895 for (
unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
5896 Expr *Init = ILE->getInit(i);
5901 VK, LiteralExpr, isFileScope);
5906 if (CheckForConstantInitializer(LiteralExpr, literalType))
5913 Diag(LParenLoc, diag::err_compound_literal_with_address_space)
5918 return MaybeBindToTemporary(E);
5926 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
5927 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
5928 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
5934 InitArgList[I] = result.
get();
5949 assert(E.
get()->getType()->isBlockPointerType());
5950 assert(E.
get()->isRValue());
5953 if (!getLangOpts().ObjCAutoRefCount)
return;
5956 CK_ARCExtendBlockObject, E.
get(),
5958 Cleanup.setExprNeedsCleanups(
true);
5968 maybeExtendBlockObject(E);
5969 return CK_BlockPointerToObjCPointerCast;
5972 return CK_CPointerToObjCPointerCast;
5989 llvm_unreachable(
"member pointer type in C");
5998 if (SrcAS != DestAS)
5999 return CK_AddressSpaceConversion;
6006 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
6011 return CK_CPointerToObjCPointerCast;
6012 maybeExtendBlockObject(Src);
6013 return CK_BlockPointerToObjCPointerCast;
6015 return CK_PointerToBoolean;
6017 return CK_PointerToIntegral;
6023 llvm_unreachable(
"illegal cast from pointer");
6025 llvm_unreachable(
"Should have returned before this");
6030 return CK_FixedPointCast;
6032 return CK_FixedPointToBoolean;
6038 diag::err_unimplemented_conversion_with_fixed_point_type)
6040 return CK_IntegralCast;
6045 llvm_unreachable(
"illegal cast to pointer type");
6047 llvm_unreachable(
"Should have returned before this");
6055 if (Src.
get()->isNullPointerConstant(Context,
6057 return CK_NullToPointer;
6058 return CK_IntegralToPointer;
6060 return CK_IntegralToBoolean;
6062 return CK_IntegralCast;
6064 return CK_IntegralToFloating;
6066 Src = ImpCastExprToType(Src.
get(),
6069 return CK_IntegralRealToComplex;
6071 Src = ImpCastExprToType(Src.
get(),
6073 CK_IntegralToFloating);
6074 return CK_FloatingRealToComplex;
6076 llvm_unreachable(
"member pointer type in C");
6079 diag::err_unimplemented_conversion_with_fixed_point_type)
6081 return CK_IntegralCast;
6083 llvm_unreachable(
"Should have returned before this");
6088 return CK_FloatingCast;
6090 return CK_FloatingToBoolean;
6092 return CK_FloatingToIntegral;
6094 Src = ImpCastExprToType(Src.
get(),
6097 return CK_FloatingRealToComplex;
6099 Src = ImpCastExprToType(Src.
get(),
6101 CK_FloatingToIntegral);
6102 return CK_IntegralRealToComplex;
6106 llvm_unreachable(
"valid float->pointer cast?");
6108 llvm_unreachable(
"member pointer type in C");
6111 diag::err_unimplemented_conversion_with_fixed_point_type)
6113 return CK_IntegralCast;
6115 llvm_unreachable(
"Should have returned before this");
6120 return CK_FloatingComplexCast;
6122 return CK_FloatingComplexToIntegralComplex;
6126 return CK_FloatingComplexToReal;
6127 Src = ImpCastExprToType(Src.
get(), ET, CK_FloatingComplexToReal);
6128 return CK_FloatingCast;
6131 return CK_FloatingComplexToBoolean;
6133 Src = ImpCastExprToType(Src.
get(),
6135 CK_FloatingComplexToReal);
6136 return CK_FloatingToIntegral;
6140 llvm_unreachable(
"valid complex float->pointer cast?");
6142 llvm_unreachable(
"member pointer type in C");
6145 diag::err_unimplemented_conversion_with_fixed_point_type)
6147 return CK_IntegralCast;
6149 llvm_unreachable(
"Should have returned before this");
6154 return CK_IntegralComplexToFloatingComplex;
6156 return CK_IntegralComplexCast;
6160 return CK_IntegralComplexToReal;
6161 Src = ImpCastExprToType(Src.
get(), ET, CK_IntegralComplexToReal);
6162 return CK_IntegralCast;
6165 return CK_IntegralComplexToBoolean;
6167 Src = ImpCastExprToType(Src.
get(),
6169 CK_IntegralComplexToReal);
6170 return CK_IntegralToFloating;
6174 llvm_unreachable(
"valid complex int->pointer cast?");
6176 llvm_unreachable(
"member pointer type in C");
6179 diag::err_unimplemented_conversion_with_fixed_point_type)
6181 return CK_IntegralCast;
6183 llvm_unreachable(
"Should have returned before this");
6186 llvm_unreachable(
"Unhandled scalar cast");
6193 len = vecType->getNumElements();
6194 eltType = vecType->getElementType();
6226 uint64_t srcLen, destLen;
6234 uint64_t srcEltSize = Context.
getTypeSize(srcEltTy);
6235 uint64_t destEltSize = Context.
getTypeSize(destEltTy);
6237 return (srcLen * srcEltSize == destLen * destEltSize);
6247 return areLaxCompatibleVectorTypes(srcTy, destTy);
6252 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
6255 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
6258 diag::err_invalid_conversion_between_vectors :
6259 diag::err_invalid_conversion_between_vector_and_integer)
6260 << VectorTy << Ty << R;
6263 diag::err_invalid_conversion_between_vector_and_scalar)
6264 << VectorTy << Ty << R;
6273 if (DestElemTy == SplattedExpr->
getType())
6274 return SplattedExpr;
6286 ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.
IntTy,
6287 CK_BooleanToSignedIntegral);
6288 SplattedExpr = CastExprRes.
get();
6289 CK = CK_IntegralToFloating;
6291 CK = CK_BooleanToSignedIntegral;
6295 CK = PrepareScalarCast(CastExprRes, DestElemTy);
6298 SplattedExpr = CastExprRes.
get();
6300 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
6313 if (SrcTy->isVectorType()) {
6314 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy) ||
6315 (getLangOpts().OpenCL &&
6317 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
6318 << DestTy << SrcTy << R;
6328 if (SrcTy->isPointerType())
6330 diag::err_invalid_conversion_between_vector_and_scalar)
6331 << DestTy << SrcTy << R;
6333 Kind = CK_VectorSplat;
6334 return prepareVectorSplat(DestTy, CastExpr);
6342 "ActOnCastExpr(): missing type or expr");
6348 if (getLangOpts().CPlusPlus) {
6350 CheckExtraCXXDefaultArguments(D);
6353 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
6356 CastExpr = Res.
get();
6359 checkUnusedDeclAttributes(D);
6362 Ty = CreateParsedType(castType, castTInfo);
6364 bool isVectorLiteral =
false;
6370 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
6372 if (PLE && PLE->getNumExprs() == 0) {
6373 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
6376 if (PE || PLE->getNumExprs() == 1) {
6379 isVectorLiteral =
true;
6382 isVectorLiteral =
true;
6387 if (isVectorLiteral)
6388 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
6393 if (isa<ParenListExpr>(CastExpr)) {
6394 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
6396 CastExpr = Result.
get();
6400 !getSourceManager().isInSystemMacro(LParenLoc))
6403 CheckTollFreeBridgeCast(castType, CastExpr);
6405 CheckObjCBridgeRelatedCast(castType, CastExpr);
6407 DiscardMisalignedMemberAddress(castType.
getTypePtr(), CastExpr);
6409 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
6415 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6416 "Expected paren or paren list expression");
6423 LiteralLParenLoc = PE->getLParenLoc();
6424 LiteralRParenLoc = PE->getRParenLoc();
6425 exprs = PE->getExprs();
6426 numExprs = PE->getNumExprs();
6428 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
6429 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
6430 subExpr = cast<ParenExpr>(E)->getSubExpr();
6450 if (numExprs == 1) {
6452 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6455 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6456 PrepareScalarCast(Literal, ElemTy));
6457 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6459 else if (numExprs < numElems) {
6461 diag::err_incorrect_number_of_vector_initializers);
6465 initExprs.append(exprs, exprs + numExprs);
6470 if (getLangOpts().OpenCL &&
6474 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
6477 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
6478 PrepareScalarCast(Literal, ElemTy));
6479 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
6482 initExprs.append(exprs, exprs + numExprs);
6487 initExprs, LiteralRParenLoc);
6489 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
6502 for (
unsigned i = 1, e = E->
getNumExprs(); i != e && !Result.isInvalid(); ++i)
6503 Result = ActOnBinOp(S, E->
getExprLoc(), tok::comma, Result.get(),
6506 if (Result.isInvalid())
return ExprError();
6522 Expr *NullExpr = LHSExpr;
6523 Expr *NonPointerExpr = RHSExpr;
6530 NonPointerExpr = LHSExpr;
6547 if (!findMacroSpelling(loc,
"NULL"))
6552 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6553 << NonPointerExpr->
getType() << DiagType
6564 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6572 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6599 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6623 bool IsBlockPointer =
false;
6627 IsBlockPointer =
true;
6652 ResultAddrSpace = LAddrSpace;
6654 ResultAddrSpace = RAddrSpace;
6656 S.
Diag(Loc, diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6657 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6658 << RHS.
get()->getSourceRange();
6663 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6678 LAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6680 RAddrSpace == ResultAddrSpace ? CK_BitCast : CK_AddressSpaceConversion;
6689 if (CompositeTy.
isNull()) {
6706 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6707 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6708 << RHS.
get()->getSourceRange();
6717 QualType ResultTy = [&, ResultAddrSpace]() {
6723 .withCVRQualifiers(MergedCVRQual);
6752 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6753 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6754 << RHS.
get()->getSourceRange();
6805 bool IsIntFirstExpr) {
6807 !Int.
get()->getType()->isIntegerType())
6810 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6811 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6813 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6817 CK_IntegralToPointer);
6851 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6852 << LHSType << LHS.
get()->getSourceRange();
6857 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6858 << RHSType << RHS.
get()->getSourceRange();
6863 if (LHSType == RHSType)
6872 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6873 (S, LHS, RHS, LHSType, RHSType,
false);
6907 llvm::raw_svector_ostream OS(Str);
6908 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6909 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6910 << CondTy << OS.str();
6931 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6949 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6950 << CondTy << VecResTy;
6955 QualType RVE = RV->getElementType();
6958 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6959 << CondTy << VecResTy;
6983 if (LHS.
get()->getType()->isVectorType() ||
6984 RHS.
get()->getType()->isVectorType()) {
7003 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
7004 QualType Ty = CE->getCallee()->getType();
7030 if (getLangOpts().CPlusPlus)
7031 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
7038 if (getLangOpts().OpenCL && Cond.
get()->getType()->isVectorType())
7042 Cond = UsualUnaryConversions(Cond.
get());
7049 if (LHS.
get()->getType()->isVectorType() ||
7050 RHS.
get()->getType()->isVectorType())
7051 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
7055 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
7066 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
7067 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7073 if (getLangOpts().OpenCL &&
7081 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
7082 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
7091 if (LHSRT->getDecl() == RHSRT->getDecl())
7110 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
7114 if (!compositeType.
isNull())
7115 return compositeType;
7140 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
7144 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
7145 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
7146 << RHS.
get()->getSourceRange();
7162 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7167 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7173 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_CPointerToObjCPointerCast);
7178 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_CPointerToObjCPointerCast);
7184 RHS = ImpCastExprToType(RHS.
get(), LHSTy, CK_BitCast);
7189 LHS = ImpCastExprToType(LHS.
get(), RHSTy, CK_BitCast);
7216 if (!(compositeType =
7234 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
7236 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7238 LHS = ImpCastExprToType(LHS.
get(), incompatTy, CK_BitCast);
7239 RHS = ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
7243 LHS = ImpCastExprToType(LHS.
get(), compositeType, CK_BitCast);
7244 RHS = ImpCastExprToType(RHS.get(), compositeType, CK_BitCast);
7245 return compositeType;
7249 if (getLangOpts().ObjCAutoRefCount) {
7252 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7253 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7263 LHS = ImpCastExprToType(LHS.
get(), destType, CK_NoOp);
7265 RHS = ImpCastExprToType(RHS.get(), destType, CK_BitCast);
7269 if (getLangOpts().ObjCAutoRefCount) {
7272 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
7273 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7283 RHS = ImpCastExprToType(RHS.
get(), destType, CK_NoOp);
7285 LHS = ImpCastExprToType(LHS.get(), destType, CK_BitCast);
7299 Self.
Diag(Loc, Note)
7304 Self.
Diag(Loc, Note) << ParenRange;
7324 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
7325 E = MTE->GetTemporaryExpr();
7332 *Opcode = OP->getOpcode();
7333 *RHSExprs = OP->getRHS();
7340 if (Call->getNumArgs() != 2)
7346 if (OO < OO_Plus || OO > OO_Arrow ||
7347 OO == OO_PlusPlus || OO == OO_MinusMinus)
7353 *RHSExprs = Call->getArg(1);
7370 return OP->isComparisonOp() || OP->isLogicalOp();
7372 return OP->getOpcode() == UO_LNot;
7401 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7407 Self.
PDiag(diag::note_precedence_silence)
7412 Self.
PDiag(diag::note_precedence_conditional_first),
7423 auto GetNullability = [&Ctx](
QualType Ty) {
7430 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7438 MergedKind = RHSKind;
7445 MergedKind = RHSKind;
7447 MergedKind = LHSKind;
7453 if (GetNullability(ResTy) == MergedKind)
7475 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
7476 ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
7477 ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
7490 CondExpr = CondResult.
get();
7491 LHSExpr = LHSResult.
get();
7492 RHSExpr = RHSResult.
get();
7498 Expr *commonExpr =
nullptr;
7500 commonExpr = CondExpr;
7505 ExprResult result = CheckPlaceholderExpr(commonExpr);
7507 commonExpr = result.
get();
7518 ExprResult commonRes = UsualUnaryConversions(commonExpr);
7521 commonExpr = commonRes.
get();
7528 ExprResult MatExpr = TemporaryMaterializationConversion(commonExpr);
7531 commonExpr = MatExpr.
get();
7539 LHSExpr = CondExpr = opaqueValue;
7545 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7546 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
7547 VK, OK, QuestionLoc);
7561 return new (Context)
7563 RHS.get(), result, VK, OK);
7566 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7577 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7578 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7581 const Type *lhptee, *rhptee;
7583 std::tie(lhptee, lhq) =
7584 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7585 std::tie(rhptee, rhq) =
7586 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7612 && (lhptee->isVoidType() || rhptee->isVoidType()))
7627 if (lhptee->isVoidType()) {
7628 if (rhptee->isIncompleteOrObjectType())
7632 assert(rhptee->isFunctionType());
7636 if (rhptee->isVoidType()) {
7637 if (lhptee->isIncompleteOrObjectType())
7641 assert(lhptee->isFunctionType());
7652 if (lhptee->isCharType())
7654 else if (lhptee->hasSignedIntegerRepresentation())
7657 if (rhptee->isCharType())
7659 else if (rhptee->hasSignedIntegerRepresentation())
7662 if (ltrans == rtrans) {
7676 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7678 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7679 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7680 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7682 if (lhptee == rhptee)
7702 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7703 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7708 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7709 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7718 Qualifiers LQuals = lhptee.getLocalQualifiers();
7719 Qualifiers RQuals = rhptee.getLocalQualifiers();
7724 if (LQuals != RQuals)
7753 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7754 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7795 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7802 return VT->getElementType() == ElementType;
7835 if (LHSType == RHSType) {
7842 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7844 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
7845 if (result != Compatible)
7847 if (Kind != CK_NoOp && ConvertRHS)
7848 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
7849 Kind = CK_NonAtomicToAtomic;
7862 Kind = CK_LValueBitCast;
7865 return Incompatible;
7872 return Incompatible;
7876 RHS = prepareVectorSplat(LHSType, RHS.
get());
7877 Kind = CK_VectorSplat;
7895 if (isLaxVectorConversion(RHSType, LHSType)) {
7897 return IncompatibleVectors;
7908 isLaxVectorConversion(RHSType, LHSType)) {
7910 *VecExpr = ImpCastExprToType(VecExpr->
get(), LHSType, CK_BitCast);
7916 return Incompatible;
7922 return Incompatible;
7928 return Incompatible;
7934 Kind = PrepareScalarCast(RHS, LHSType);
7939 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7941 if (isa<PointerType>(RHSType)) {
7942 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7944 if (AddrSpaceL != AddrSpaceR)
7945 Kind = CK_AddressSpaceConversion;
7955 Kind = CK_IntegralToPointer;
7956 return IntToPointer;
7961 if (isa<ObjCObjectPointerType>(RHSType)) {
7963 if (LHSPointer->getPointeeType()->isVoidType()) {
7977 return IncompatiblePointer;
7982 if (LHSPointer->getPointeeType()->isVoidType()) {
7983 LangAS AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7988 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7993 return Incompatible;
7997 if (isa<BlockPointerType>(LHSType)) {
8006 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
8012 Kind = CK_IntegralToPointer;
8013 return IntToBlockPointer;
8018 Kind = CK_AnyPointerToBlockPointerCast;
8024 if (RHSPT->getPointeeType()->isVoidType()) {
8025 Kind = CK_AnyPointerToBlockPointerCast;
8029 return Incompatible;
8033 if (isa<ObjCObjectPointerType>(LHSType)) {
8039 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8040 result == Compatible &&
8041 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
8042 result = IncompatibleObjCWeakRef;
8048 Kind = CK_IntegralToPointer;
8049 return IntToPointer;
8054 if (isa<PointerType>(RHSType)) {
8055 Kind = CK_CPointerToObjCPointerCast;
8069 return IncompatiblePointer;
8076 maybeExtendBlockObject(RHS);
8077 Kind = CK_BlockPointerToObjCPointerCast;
8081 return Incompatible;
8085 if (isa<PointerType>(RHSType)) {
8087 if (LHSType == Context.
BoolTy) {
8088 Kind = CK_PointerToBoolean;
8094 Kind = CK_PointerToIntegral;
8095 return PointerToInt;
8098 return Incompatible;
8102 if (isa<ObjCObjectPointerType>(RHSType)) {
8104 if (LHSType == Context.
BoolTy) {
8105 Kind = CK_PointerToBoolean;
8111 Kind = CK_PointerToIntegral;
8112 return PointerToInt;
8115 return Incompatible;
8119 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
8127 Kind = CK_IntToOCLSampler;
8131 return Incompatible;
8144 Initializer->
setType(UnionType);
8163 return Incompatible;
8169 for (
auto *it : UD->
fields()) {
8170 if (it->getType()->isPointerType()) {
8176 RHS = ImpCastExprToType(RHS.
get(), it->getType(), CK_BitCast);
8181 if (RHS.
get()->isNullPointerConstant(Context,
8183 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
8191 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
8193 RHS = ImpCastExprToType(RHS.
get(), it->getType(),
Kind);
8200 return Incompatible;
8209 bool DiagnoseCFAudited,
8213 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
8219 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
8222 if (
const auto *RHSPtrType = RHS.
get()->getType()->getAs<
PointerType>()) {
8223 if (RHSPtrType->getPointeeType()->hasAttr(attr::NoDeref) &&
8224 !LHSPtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
8226 diag::warn_noderef_to_dereferenceable_pointer)
8227 << RHS.
get()->getSourceRange();
8250 return Incompatible;
8255 return Incompatible;
8257 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8258 !CheckObjCARCUnavailableWeakConversion(LHSType, RHSType))
8259 result = IncompatibleObjCWeakRef;
8271 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
8272 RHS.
get(), LHSType,
false, DAP))
8273 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
8275 return Incompatible;
8282 RHS.
get()->isNullPointerConstant(Context,
8284 if (Diagnose || ConvertRHS) {
8287 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
8296 if (LHSType->
isQueueT() && RHS.
get()->isNullPointerConstant(
8298 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
8310 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
8312 return Incompatible;
8316 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
8324 if (result != Incompatible && RHS.
get()->getType() != LHSType) {
8331 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
8332 CheckObjCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
8333 Diagnose, DiagnoseCFAudited) != ACR_okay) {
8335 return Incompatible;
8337 if (getLangOpts().ObjC &&
8338 (CheckObjCBridgeRelatedConversions(E->
getBeginLoc(), LHSType,
8340 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
8342 return Incompatible;
8350 RHS = ImpCastExprToType(E, Ty, Kind);
8360 struct OriginalOperand {
8361 explicit OriginalOperand(
Expr *Op) : Orig(Op), Conversion(
nullptr) {
8362 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Op))
8363 Op = MTE->GetTemporaryExpr();
8364 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Op))
8365 Op = BTE->getSubExpr();
8366 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(Op)) {
8367 Orig = ICE->getSubExprAsWritten();
8368 Conversion = ICE->getConversionFunction();
8372 QualType getType()
const {
return Orig->getType(); }
8381 OriginalOperand OrigLHS(LHS.
get()), OrigRHS(RHS.
get());
8383 Diag(Loc, diag::err_typecheck_invalid_operands)
8384 << OrigLHS.getType() << OrigRHS.getType()
8385 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8389 if (OrigLHS.Conversion) {
8390 Diag(OrigLHS.Conversion->getLocation(),
8391 diag::note_typecheck_invalid_operands_converted)
8392 << 0 << LHS.
get()->getType();
8394 if (OrigRHS.Conversion) {
8395 Diag(OrigRHS.Conversion->getLocation(),
8396 diag::note_typecheck_invalid_operands_converted)
8397 << 1 << RHS.
get()->getType();
8408 QualType LHSType = LHS.
get()->IgnoreImpCasts()->getType();
8409 QualType RHSType = RHS.
get()->IgnoreImpCasts()->getType();
8414 if (!(LHSNatVec && RHSNatVec)) {
8415 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
8416 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
8417 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8423 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
8424 << 1 << LHSType << RHSType << LHS.
get()->getSourceRange()
8425 << RHS.
get()->getSourceRange();
8455 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8460 scalarCast = CK_IntegralCast;
8465 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8468 scalarCast = CK_FloatingCast;
8471 scalarCast = CK_IntegralToFloating;
8480 if (scalarCast != CK_NoOp)
8491 assert(VecTy &&
"Expression E must be a vector");
8493 VecTy->getNumElements(),
8494 VecTy->getVectorKind());
8498 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
8499 if (ICE->getSubExpr()->getType() == NewVecTy)
8500 return ICE->getSubExpr();
8502 auto Cast = ElementType->
isIntegerType() ? CK_IntegralCast : CK_FloatingCast;
8510 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8516 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8524 llvm::APSInt Result = EVResult.
Val.
getInt();
8525 unsigned NumBits = IntSigned
8526 ? (Result.isNegative() ? Result.getMinSignedBits()
8527 : Result.getActiveBits())
8528 : Result.getActiveBits();
8535 return (IntSigned != OtherIntSigned &&
8548 QualType IntTy = Int->
get()->getType().getUnqualifiedType();
8553 bool CstInt = Int->
get()->EvaluateAsInt(EVResult, S.
Context);
8562 llvm::APSInt Result = EVResult.
Val.
getInt();
8565 llvm::APFloat::rmTowardZero);
8568 bool Ignored =
false;
8569 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8571 if (Result != ConvertBack)
8577 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8579 if (Bits > FloatPrec)
8592 QualType ScalarTy = Scalar->
get()->getType().getUnqualifiedType();
8593 QualType VectorTy = Vector->
get()->getType().getUnqualifiedType();
8596 assert(!isa<ExtVectorType>(VT) &&
8597 "ExtVectorTypes should not be handled here!");
8624 ScalarCast = CK_IntegralCast;
8630 llvm::APFloat Result(0.0);
8631 bool CstScalar = Scalar->
get()->EvaluateAsFloat(Result, S.
Context);
8633 if (!CstScalar && Order < 0)
8639 bool Truncated =
false;
8641 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8646 ScalarCast = CK_FloatingCast;
8651 ScalarCast = CK_IntegralToFloating;
8658 if (ScalarCast != CK_NoOp)
8668 bool AllowBoolConversions) {
8669 if (!IsCompAssign) {
8670 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
8674 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
8680 QualType LHSType = LHS.
get()->getType().getUnqualifiedType();
8681 QualType RHSType = RHS.
get()->getType().getUnqualifiedType();
8685 assert(LHSVecType || RHSVecType);
8689 if (!AllowBothBool &&
8692 return InvalidOperands(Loc, LHS, RHS);
8699 if (LHSVecType && RHSVecType &&
8701 if (isa<ExtVectorType>(LHSVecType)) {
8702 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8707 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8714 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8717 Context.
getTypeSize(RHSVecType->getElementType()))) {
8721 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
8724 if (!IsCompAssign &&
8727 RHSVecType->getElementType()->isIntegerType()) {
8728 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
8735 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8737 if (isa<ExtVectorType>(LHSVecType)) {
8748 if (isa<ExtVectorType>(RHSVecType)) {
8750 LHSType, RHSVecType->getElementType(),
8763 QualType VecType = LHSVecType ? LHSType : RHSType;
8764 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8765 QualType OtherType = LHSVecType ? RHSType : LHSType;
8766 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8767 if (isLaxVectorConversion(OtherType, VecType)) {
8771 if (!IsCompAssign) {
8772 *OtherExpr = ImpCastExprToType(OtherExpr->
get(), VecType, CK_BitCast);
8782 *RHSExpr = ImpCastExprToType(RHSExpr->
get(), LHSType, CK_BitCast);
8790 if ((!RHSVecType && !RHSType->
isRealType()) ||
8792 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8793 << LHSType << RHSType
8794 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8802 if (getLangOpts().OpenCL &&
8803 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8804 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8805 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
8814 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
8815 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
8816 QualType Scalar = LHSVecType ? RHSType : LHSType;
8817 QualType Vector = LHSVecType ? LHSType : RHSType;
8818 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
8820 diag::err_typecheck_vector_not_convertable_implict_truncation)
8821 << ScalarOrVector << Scalar << Vector;
8828 << LHSType << RHSType
8829 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8841 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
8842 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
8844 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
8848 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8849 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8855 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8863 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8864 NonNullType->canDecayToPointerType())
8867 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8868 << LHSNull << NonNullType
8869 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8878 if (LUE->getKind() !=
UETT_SizeOf || LUE->isArgumentType() ||
8882 QualType LHSTy = LUE->getArgumentExpr()->IgnoreParens()->getType();
8885 if (RUE->isArgumentType())
8886 RHSTy = RUE->getArgumentType();
8888 RHSTy = RUE->getArgumentExpr()->IgnoreParens()->getType();
8903 if (!RHS.
get()->isValueDependent() &&
8904 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) &&
8907 S.
PDiag(diag::warn_remainder_division_by_zero)
8908 << IsDiv << RHS.
get()->getSourceRange());
8913 bool IsCompAssign,
bool IsDiv) {
8916 if (LHS.
get()->getType()->isVectorType() ||
8917 RHS.
get()->getType()->isVectorType())
8918 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8919 getLangOpts().AltiVec,
8922 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8928 return InvalidOperands(Loc, LHS, RHS);
8940 if (LHS.
get()->getType()->isVectorType() ||
8941 RHS.
get()->getType()->isVectorType()) {
8942 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
8943 RHS.
get()->getType()->hasIntegerRepresentation())
8944 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8945 getLangOpts().AltiVec,
8947 return InvalidOperands(Loc, LHS, RHS);
8950 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
8955 return InvalidOperands(Loc, LHS, RHS);
8964 ? diag::err_typecheck_pointer_arith_void_type
8965 : diag::ext_gnu_void_ptr)
8974 ? diag::err_typecheck_pointer_arith_void_type
8975 : diag::ext_gnu_void_ptr)
8985 Expr *Pointer,
bool IsGNUIdiom) {
8987 S.
Diag(Loc, diag::warn_gnu_null_ptr_arith)
8990 S.
Diag(Loc, diag::warn_pointer_arith_null_ptr)
9000 ? diag::err_typecheck_pointer_arith_function_type
9001 : diag::ext_gnu_ptr_func_arith)
9015 ? diag::err_typecheck_pointer_arith_function_type
9016 : diag::ext_gnu_ptr_func_arith)
9029 ResType = ResAtomicType->getValueType();
9034 diag::err_typecheck_arithmetic_incomplete_type,
9050 ResType = ResAtomicType->getValueType();
9082 if (!isLHSPointer && !isRHSPointer)
return true;
9084 QualType LHSPointeeTy, RHSPointeeTy;
9089 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
9094 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9102 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
9103 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
9104 if (isLHSVoidPtr || isRHSVoidPtr) {
9112 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
9113 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
9114 if (isLHSFuncPtr || isRHSFuncPtr) {
9136 Expr* IndexExpr = RHSExpr;
9139 IndexExpr = LHSExpr;
9142 bool IsStringPlusInt = StrExpr &&
9144 if (!IsStringPlusInt || IndexExpr->isValueDependent())
9148 Self.
Diag(OpLoc, diag::warn_string_plus_int)
9149 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
9152 if (IndexExpr == RHSExpr) {
9154 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9159 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9165 const Expr *StringRefExpr = LHSExpr;
9171 StringRefExpr = RHSExpr;
9174 if (!CharExpr || !StringRefExpr)
9191 if (!CharType->isAnyCharacterType() &&
9192 CharType->isIntegerType() &&
9194 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9195 << DiagRange << Ctx.
CharTy;
9197 Self.
Diag(OpLoc, diag::warn_string_plus_char)
9198 << DiagRange << CharExpr->
getType();
9204 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
9209 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
9218 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
9229 if (LHS.
get()->getType()->isVectorType() ||
9230 RHS.
get()->getType()->isVectorType()) {
9231 QualType compType = CheckVectorOperands(
9232 LHS, RHS, Loc, CompLHSTy,
9233 getLangOpts().AltiVec,
9234 getLangOpts().ZVector);
9235 if (CompLHSTy) *CompLHSTy = compType;
9239 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9244 if (Opc == BO_Add) {
9251 if (CompLHSTy) *CompLHSTy = compType;
9261 isObjCPointer =
false;
9263 isObjCPointer =
true;
9265 std::swap(PExp, IExp);
9267 isObjCPointer =
false;
9269 isObjCPointer =
true;
9271 return InvalidOperands(Loc, LHS, RHS);
9276 if (!IExp->getType()->isIntegerType())
9277 return InvalidOperands(Loc, LHS, RHS);
9284 if (!getLangOpts().CPlusPlus ||
9285 (!IExp->isValueDependent() &&
9286 (!IExp->EvaluateAsInt(KnownVal, Context) ||
9290 Context, BO_Add, PExp, IExp);
9302 CheckArrayAccess(PExp, IExp);
9307 LHSTy = LHS.
get()->getType();
9323 if (LHS.
get()->getType()->isVectorType() ||
9324 RHS.
get()->getType()->isVectorType()) {
9325 QualType compType = CheckVectorOperands(
9326 LHS, RHS, Loc, CompLHSTy,
9327 getLangOpts().AltiVec,
9328 getLangOpts().ZVector);
9329 if (CompLHSTy) *CompLHSTy = compType;
9333 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
9341 if (CompLHSTy) *CompLHSTy = compType;
9346 if (LHS.
get()->getType()->isAnyPointerType()) {
9347 QualType lpointee = LHS.
get()->getType()->getPointeeType();
9350 if (LHS.
get()->getType()->isObjCObjectPointerType() &&
9355 if (RHS.
get()->getType()->isIntegerType()) {
9359 if (LHS.
get()->IgnoreParenCasts()->isNullPointerConstant(Context,
9363 if (!getLangOpts().CPlusPlus ||
9364 (!RHS.
get()->isValueDependent() &&
9365 (!RHS.
get()->EvaluateAsInt(KnownVal, Context) ||
9375 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
9378 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9379 return LHS.
get()->getType();
9413 if (ElementSize.
isZero()) {
9414 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
9416 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9420 if (CompLHSTy) *CompLHSTy = LHS.
get()->getType();
9425 return InvalidOperands(Loc, LHS, RHS);
9430 return ET->getDecl()->isScoped();
9444 if (RHS.
get()->isValueDependent() ||
9445 !RHS.
get()->EvaluateAsInt(RHSResult, S.
Context))
9447 llvm::APSInt Right = RHSResult.
Val.
getInt();
9449 if (Right.isNegative()) {
9451 S.
PDiag(diag::warn_shift_negative)
9452 << RHS.
get()->getSourceRange());
9455 llvm::APInt LeftBits(Right.getBitWidth(),
9457 if (Right.uge(LeftBits)) {
9459 S.
PDiag(diag::warn_shift_gt_typewidth)
9460 << RHS.
get()->getSourceRange());
9471 if (LHS.
get()->isValueDependent() ||
9473 !LHS.
get()->EvaluateAsInt(LHSResult, S.
Context))
9475 llvm::APSInt Left = LHSResult.
Val.
getInt();
9481 S.
PDiag(diag::warn_shift_lhs_negative)
9482 << LHS.
get()->getSourceRange());
9486 llvm::APInt ResultBits =
9487 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
9488 if (LeftBits.uge(ResultBits))
9490 llvm::APSInt Result = Left.extend(ResultBits.getLimitedValue());
9491 Result = Result.shl(Right);
9496 Result.toString(HexResult, 16,
false,
true);
9502 if (LeftBits == ResultBits - 1) {
9503 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
9504 << HexResult << LHSType
9505 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9509 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
9510 << HexResult.str() << Result.getMinSignedBits() << LHSType
9511 << Left.getBitWidth() << LHS.
get()->getSourceRange()
9512 << RHS.
get()->getSourceRange();
9521 !LHS.
get()->getType()->isVectorType()) {
9522 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
9523 << RHS.
get()->getType() << LHS.
get()->getType()
9524 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9528 if (!IsCompAssign) {
9548 if (!LHSEleType->isIntegerType()) {
9549 S.
Diag(Loc, diag::err_typecheck_expect_int)
9550 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
9554 if (!RHSEleType->isIntegerType()) {
9555 S.
Diag(Loc, diag::err_typecheck_expect_int)
9556 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
9564 if (LHSEleType != RHSEleType) {
9566 LHSEleType = RHSEleType;
9572 }
else if (RHSVecTy) {
9577 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9578 << LHS.
get()->getType() << RHS.
get()->getType()
9579 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9585 if (LHSBT != RHSBT &&
9587 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9588 << LHS.
get()->getType() << RHS.
get()->getType()
9589 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9605 bool IsCompAssign) {
9609 if (LHS.
get()->getType()->isVectorType() ||
9610 RHS.
get()->getType()->isVectorType()) {
9611 if (LangOpts.ZVector) {
9615 if (
auto LHSVecType = LHS.
get()->getType()->getAs<
VectorType>())
9617 return InvalidOperands(Loc, LHS, RHS);
9618 if (
auto RHSVecType = RHS.
get()->getType()->getAs<
VectorType>())
9620 return InvalidOperands(Loc, LHS, RHS);
9631 LHS = UsualUnaryConversions(LHS.
get());
9635 if (IsCompAssign) LHS = OldLHS;
9638 RHS = UsualUnaryConversions(RHS.
get());
9646 return InvalidOperands(Loc, LHS, RHS);
9652 return InvalidOperands(Loc, LHS, RHS);
9685 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9686 << LHSStrippedType << RHSStrippedType
9694 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9695 : diag::ext_typecheck_comparison_of_distinct_pointers)
9696 << LHS.
get()->getType() << RHS.
get()->getType()
9697 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9737 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9738 : diag::ext_typecheck_comparison_of_fptr_to_void)
9739 << LHS.
get()->getType() << RHS.
get()->getType()
9740 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9744 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
9745 case Stmt::ObjCArrayLiteralClass:
9746 case Stmt::ObjCDictionaryLiteralClass:
9747 case Stmt::ObjCStringLiteralClass:
9748 case Stmt::ObjCBoxedExprClass:
9807 case Stmt::ObjCStringLiteralClass:
9810 case Stmt::ObjCArrayLiteralClass:
9813 case Stmt::ObjCDictionaryLiteralClass:
9815 return LK_Dictionary;
9816 case Stmt::BlockExprClass:
9818 case Stmt::ObjCBoxedExprClass: {
9819 Expr *Inner = cast<ObjCBoxedExpr>(FromE)->getSubExpr()->IgnoreParens();
9821 case Stmt::IntegerLiteralClass:
9822 case Stmt::FloatingLiteralClass:
9823 case Stmt::CharacterLiteralClass:
9824 case Stmt::ObjCBoolLiteralExprClass:
9825 case Stmt::CXXBoolLiteralExprClass:
9828 case Stmt::ImplicitCastExprClass: {
9829 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
9831 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
9850 Literal = LHS.
get();
9853 Literal = RHS.
get();
9869 llvm_unreachable(
"Unknown Objective-C object literal kind");
9873 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
9876 S.
Diag(Loc, diag::warn_objc_literal_comparison)
9886 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
9899 if (!UO || UO->
getOpcode() != UO_LNot)
return;
9902 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
9909 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
9911 << Loc << IsBitwiseOp;
9939 return DR->getDecl();
9941 if (Ivar->isFreeIvar())
9942 return Ivar->getDecl();
9944 if (
MemberExpr *Mem = dyn_cast<MemberExpr>(E)) {
9945 if (Mem->isImplicitAccess())
9946 return Mem->getMemberDecl();
9986 case BO_EQ:
case BO_LE:
case BO_GE:
9989 case BO_NE:
case BO_LT:
case BO_GT:
9993 Result =
"'std::strong_ordering::equal'";
9999 S.
PDiag(diag::warn_comparison_always)
10000 << 0 << !Result.empty()
10002 }
else if (DL && DR &&
10019 S.
PDiag(diag::warn_comparison_always)
10021 << !Result.empty() << Result);
10024 if (isa<CastExpr>(LHSStripped))
10026 if (isa<CastExpr>(RHSStripped))
10031 Expr *LiteralString =
nullptr;
10032 Expr *LiteralStringStripped =
nullptr;
10033 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
10036 LiteralString = LHS;
10037 LiteralStringStripped = LHSStripped;
10038 }
else if ((isa<StringLiteral>(RHSStripped) ||
10039 isa<ObjCEncodeExpr>(RHSStripped)) &&
10042 LiteralString = RHS;
10043 LiteralStringStripped = RHSStripped;
10046 if (LiteralString) {
10048 S.
PDiag(diag::warn_stringcompare)
10049 << isa<ObjCEncodeExpr>(LiteralStringStripped)
10061 llvm_unreachable(
"unhandled cast kind");
10063 case CK_UserDefinedConversion:
10065 case CK_LValueToRValue:
10067 case CK_ArrayToPointerDecay:
10069 case CK_FunctionToPointerDecay:
10071 case CK_IntegralCast:
10073 case CK_FloatingCast:
10075 case CK_IntegralToFloating:
10076 case CK_FloatingToIntegral:
10078 case CK_IntegralComplexCast:
10079 case CK_FloatingComplexCast:
10080 case CK_FloatingComplexToIntegralComplex:
10081 case CK_IntegralComplexToFloatingComplex:
10083 case CK_FloatingComplexToReal:
10084 case CK_FloatingRealToComplex:
10085 case CK_IntegralComplexToReal:
10086 case CK_IntegralRealToComplex:
10099 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E))
10118 << PreNarrowingValue.getAsString(S.
Context, PreNarrowingType) << ToType;
10126 << 0 << FromType << ToType;
10131 llvm_unreachable(
"unhandled case in switch");
10147 QualType LHSStrippedType = LHSStripped.
get()->getType();
10148 QualType RHSStrippedType = RHSStripped.
get()->getType();
10159 if (NumEnumArgs == 1) {
10161 QualType OtherTy = LHSIsEnum ? RHSStrippedType : LHSStrippedType;
10167 if (NumEnumArgs == 2) {
10176 LHSStrippedType->
getAs<
EnumType>()->getDecl()->getIntegerType();
10187 LHSType = RHSType = IntType;
10200 S, Type, LHS.
get(), LHSType, LHS.
get()->getBeginLoc());
10202 RHS.
get()->getBeginLoc());
10206 assert(!Type.
isNull() &&
"composite type for <=> has not been set");
10208 auto TypeKind = [&]() {
10210 if (CT->getElementType()->hasFloatingRepresentation())
10218 llvm_unreachable(
"other types are unimplemented");
10257 bool IsThreeWay = Opc == BO_Cmp;
10268 if (!IsThreeWay || IsAnyPointerType(LHS) || IsAnyPointerType(RHS)) {
10269 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
10272 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
10276 LHS = DefaultLvalueConversion(LHS.
get());
10279 RHS = DefaultLvalueConversion(RHS.
get());
10287 if (LHS.
get()->getType()->isVectorType() ||
10288 RHS.
get()->getType()->isVectorType())
10289 return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);
10296 if ((LHSType->isArithmeticType() || LHSType->isEnumeralType()) &&
10307 auto computeResultTy = [&]() {
10317 return CheckComparisonCategoryType(
Kind, Loc);
10335 if (LHSIsNull != RHSIsNull)
10341 return InvalidOperands(Loc, LHS, RHS);
10345 if (!IsRelational && LHSIsNull != RHSIsNull) {
10346 bool IsEquality = Opc == BO_EQ;
10348 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
10349 RHS.
get()->getSourceRange());
10351 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
10352 LHS.
get()->getSourceRange());
10355 if ((LHSType->isIntegerType() && !LHSIsNull) ||
10359 }
else if (getLangOpts().CPlusPlus) {
10364 if (!IsRelational &&
10371 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
10373 if (isSFINAEContext())
10376 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10377 return computeResultTy();
10389 if ((
int)LHSType->isPointerType() + (int)RHSType->
isPointerType() >=
10390 (IsRelational ? 2 : 1) &&
10391 (!LangOpts.ObjCAutoRefCount || !(LHSType->isObjCObjectPointerType() ||
10395 return computeResultTy();
10397 }
else if (LHSType->isPointerType() &&
10411 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
10412 << LHSType << RHSType << LHS.
get()->getSourceRange()
10413 << RHS.
get()->getSourceRange();
10415 }
else if (!IsRelational &&
10419 && !LHSIsNull && !RHSIsNull)
10426 if (LCanPointeeTy != RCanPointeeTy) {
10428 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
10432 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
10433 << LHSType << RHSType << 0
10434 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
10439 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
10441 if (LHSIsNull && !RHSIsNull)
10442 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
10444 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
10446 return computeResultTy();
10453 if (!IsRelational && LHSIsNull && RHSIsNull) {
10454 if (LHSType->isNullPtrType()) {
10455 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10456 return computeResultTy();
10459 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10460 return computeResultTy();
10467 (LHSType->isObjCObjectPointerType() || LHSType->isBlockPointerType())) {
10468 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10469 return computeResultTy();
10471 if (!IsRelational && LHSType->isNullPtrType() &&
10473 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10474 return computeResultTy();
10477 if (IsRelational &&
10486 if (isa<FunctionDecl>(DC))
10488 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
10489 if (CTSD->isInStdNamespace() &&
10490 llvm::StringSwitch<bool>(CTSD->getName())
10491 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
10494 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10496 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10497 return computeResultTy();
10505 if (!IsRelational &&
10510 return computeResultTy();
10515 if (!IsRelational && LHSType->isBlockPointerType() &&
10520 if (!LHSIsNull && !RHSIsNull &&
10522 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10523 << LHSType << RHSType << LHS.
get()->getSourceRange()
10524 << RHS.
get()->getSourceRange();
10526 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_BitCast);
10527 return computeResultTy();
10532 && ((LHSType->isBlockPointerType() && RHSType->
isPointerType())
10534 if (!LHSIsNull && !RHSIsNull) {
10537 || (LHSType->isPointerType() && LHSType->castAs<
PointerType>()
10539 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
10540 << LHSType << RHSType << LHS.
get()->getSourceRange()
10541 << RHS.
get()->getSourceRange();
10543 if (LHSIsNull && !RHSIsNull)
10544 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10546 : CK_AnyPointerToBlockPointerCast);
10548 RHS = ImpCastExprToType(RHS.get(), LHSType,
10549 LHSType->isPointerType() ? CK_BitCast
10550 : CK_AnyPointerToBlockPointerCast);
10551 return computeResultTy();
10554 if (LHSType->isObjCObjectPointerType() ||
10560 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
10562 if (!LPtrToVoid && !RPtrToVoid &&
10567 if (LHSIsNull && !RHSIsNull) {
10569 if (getLangOpts().ObjCAutoRefCount)
10571 CCK_ImplicitConversion);
10572 LHS = ImpCastExprToType(E, RHSType,
10573 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10577 if (getLangOpts().ObjCAutoRefCount)
10578 CheckObjCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
10581 RHS = ImpCastExprToType(E, LHSType,
10582 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
10584 return computeResultTy();
10586 if (LHSType->isObjCObjectPointerType() &&
10594 if (LHSIsNull && !RHSIsNull)
10595 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_BitCast);
10597 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
10598 return computeResultTy();
10601 if (!IsRelational && LHSType->isBlockPointerType() &&
10603 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10604 CK_BlockPointerToObjCPointerCast);
10605 return computeResultTy();
10606 }
else if (!IsRelational &&
10607 LHSType->isBlockCompatibleObjCPointerType(Context) &&
10609 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10610 CK_BlockPointerToObjCPointerCast);
10611 return computeResultTy();
10614 if ((LHSType->isAnyPointerType() && RHSType->
isIntegerType()) ||
10616 unsigned DiagID = 0;
10617 bool isError =
false;
10618 if (LangOpts.DebuggerSupport) {
10621 }
else if ((LHSIsNull && LHSType->isIntegerType()) ||
10623 if (IsRelational) {
10624 isError = getLangOpts().CPlusPlus;
10626 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
10627 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
10630 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
10632 }
else if (IsRelational)
10633 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
10635 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
10639 << LHSType << RHSType << LHS.
get()->getSourceRange()
10640 << RHS.
get()->getSourceRange();
10645 if (LHSType->isIntegerType())
10646 LHS = ImpCastExprToType(LHS.
get(), RHSType,
10647 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10649 RHS = ImpCastExprToType(RHS.
get(), LHSType,
10650 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
10651 return computeResultTy();
10655 if (!IsRelational && RHSIsNull
10656 && LHSType->isBlockPointerType() && RHSType->
isIntegerType()) {
10657 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10658 return computeResultTy();
10660 if (!IsRelational && LHSIsNull
10662 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10663 return computeResultTy();
10666 if (getLangOpts().OpenCLVersion >= 200) {
10667 if (LHSType->isClkEventT() && RHSType->
isClkEventT()) {
10668 return computeResultTy();
10671 if (LHSType->isQueueT() && RHSType->
isQueueT()) {
10672 return computeResultTy();
10675 if (LHSIsNull && RHSType->
isQueueT()) {
10676 LHS = ImpCastExprToType(LHS.
get(), RHSType, CK_NullToPointer);
10677 return computeResultTy();
10680 if (LHSType->isQueueT() && RHSIsNull) {
10681 RHS = ImpCastExprToType(RHS.
get(), LHSType, CK_NullToPointer);
10682 return computeResultTy();
10686 return InvalidOperands(Loc, LHS, RHS);
10698 if (isa<ExtVectorType>(VTy)) {
10708 "Unhandled vector element size in vector compare");
10725 "Unhandled vector element size in vector compare");
10739 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10741 getLangOpts().ZVector);
10749 if (getLangOpts().AltiVec &&
10761 assert(RHS.
get()->getType()->hasFloatingRepresentation());
10762 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
10766 return GetSignedVectorType(vType);
10773 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
10777 return InvalidOperands(Loc, LHS, RHS);
10778 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
10780 return InvalidOperands(Loc, LHS, RHS);
10784 if (!getLangOpts().CPlusPlus &&
10786 return InvalidLogicalVectorOperands(Loc, LHS, RHS);
10788 return GetSignedVectorType(LHS.
get()->getType());
10796 bool IsCompAssign =
10797 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
10799 if (LHS.
get()->getType()->isVectorType() ||
10800 RHS.
get()->getType()->isVectorType()) {
10801 if (LHS.
get()->getType()->hasIntegerRepresentation() &&
10802 RHS.
get()->getType()->hasIntegerRepresentation())
10803 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
10805 getLangOpts().ZVector);
10806 return InvalidOperands(Loc, LHS, RHS);
10812 ExprResult LHSResult = LHS, RHSResult = RHS;
10813 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
10815 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
10817 LHS = LHSResult.
get();
10818 RHS = RHSResult.
get();
10822 return InvalidOperands(Loc, LHS, RHS);
10830 if (LHS.
get()->getType()->isVectorType() || RHS.
get()->getType()->isVectorType())
10831 return CheckVectorLogicalOperands(LHS, RHS, Loc);
10836 if (LHS.
get()->getType()->isIntegerType() &&
10837 !LHS.
get()->getType()->isBooleanType() &&
10838 RHS.
get()->getType()->isIntegerType() && !RHS.
get()->isValueDependent() &&
10840 !Loc.
isMacroID() && !inTemplateInstantiation()) {
10846 if (RHS.
get()->EvaluateAsInt(EVResult, Context)) {
10847 llvm::APSInt Result = EVResult.
Val.
getInt();
10848 if ((getLangOpts().
Bool && !RHS.
get()->getType()->isBooleanType() &&
10849 !RHS.
get()->getExprLoc().isMacroID()) ||
10850 (Result != 0 && Result != 1)) {
10851 Diag(Loc, diag::warn_logical_instead_of_bitwise)
10852 << RHS.
get()->getSourceRange()
10853 << (Opc == BO_LAnd ?
"&&" :
"||");
10855 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
10856 << (Opc == BO_LAnd ?
"&" :
"|")
10858 Loc, getLocForEndOfToken(Loc)),
10859 Opc == BO_LAnd ?
"&" :
"|");
10860 if (Opc == BO_LAnd)
10862 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
10865 RHS.
get()->getEndLoc()));
10875 if (LHS.
get()->getType()->isFloatingType() ||
10876 RHS.
get()->getType()->isFloatingType())
10877 return InvalidOperands(Loc, LHS, RHS);
10880 LHS = UsualUnaryConversions(LHS.
get());
10884 RHS = UsualUnaryConversions(RHS.
get());
10888 if (!LHS.
get()->getType()->isScalarType() ||
10889 !RHS.
get()->getType()->isScalarType())
10890 return InvalidOperands(Loc, LHS, RHS);
10892 return Context.
IntTy;
10901 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
10903 return InvalidOperands(Loc, LHS, RHS);
10906 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
10908 return InvalidOperands(Loc, LHS, RHS);
10919 if (!ME)
return false;
10923 if (!Base)
return false;
10944 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
10952 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
10995 bool DiagnosticEmitted =
false;
10999 bool IsDereference =
false;
11000 bool NextIsDereference =
false;
11004 IsDereference = NextIsDereference;
11007 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
11008 NextIsDereference = ME->isArrow();
11009 const ValueDecl *VD = ME->getMemberDecl();
11010 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
11012 if (Field->isMutable()) {
11013 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
11018 if (!DiagnosticEmitted) {
11019 S.
Diag(Loc, diag::err_typecheck_assign_const)
11021 << Field->getType();
11022 DiagnosticEmitted =
true;
11025 <<
ConstMember <<
false << Field << Field->getType()
11026 << Field->getSourceRange();
11030 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
11031 if (VDecl->getType().isConstQualified()) {
11032 if (!DiagnosticEmitted) {
11033 S.
Diag(Loc, diag::err_typecheck_assign_const)
11035 << VDecl->getType();
11036 DiagnosticEmitted =
true;
11039 <<
ConstMember <<
true << VDecl << VDecl->getType()
11040 << VDecl->getSourceRange();
11047 dyn_cast<ArraySubscriptExpr>(E)) {
11051 dyn_cast<ExtVectorElementExpr>(E)) {
11058 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
11062 if (!DiagnosticEmitted) {
11063 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11065 DiagnosticEmitted =
true;
11068 diag::note_typecheck_assign_const)
11072 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11074 if (
const ValueDecl *VD = DRE->getDecl()) {
11076 if (!DiagnosticEmitted) {
11077 S.
Diag(Loc, diag::err_typecheck_assign_const)
11079 DiagnosticEmitted =
true;
11081 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
11082 <<
ConstVariable << VD << VD->getType() << VD->getSourceRange();
11085 }
else if (isa<CXXThisExpr>(E)) {
11087 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
11088 if (MD->isConst()) {
11089 if (!DiagnosticEmitted) {
11090 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
11092 DiagnosticEmitted =
true;
11094 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
11101 if (DiagnosticEmitted)
11105 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange <<
ConstUnknown;
11118 bool &DiagnosticEmitted) {
11119 std::vector<const RecordType *> RecordTypeList;
11120 RecordTypeList.push_back(Ty);
11121 unsigned NextToCheckIndex = 0;
11124 while (RecordTypeList.size() > NextToCheckIndex) {
11125 bool IsNested = NextToCheckIndex > 0;
11127 RecordTypeList[NextToCheckIndex]->getDecl()->fields()) {
11129 QualType FieldTy = Field->getType();
11131 if (!DiagnosticEmitted) {
11132 S.
Diag(Loc, diag::err_typecheck_assign_const)
11134 << IsNested << Field;
11135 DiagnosticEmitted =
true;
11137 S.
Diag(Field->getLocation(), diag::note_typecheck_assign_const)
11139 << FieldTy << Field->getSourceRange();
11145 if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
11146 RecordTypeList.push_back(FieldRecTy);
11149 ++NextToCheckIndex;
11158 assert(Ty->
isRecordType() &&
"lvalue was not record?");
11161 bool DiagEmitted =
false;
11163 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E))
11166 else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
11191 unsigned DiagID = 0;
11192 bool NeedType =
false;
11199 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
11201 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
11209 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
11222 ? diag::err_typecheck_arc_assign_self_class_method
11223 : diag::err_typecheck_arc_assign_self;
11226 }
else if (var->
hasAttr<ObjCExternallyRetainedAttr>() ||
11227 isa<ParmVarDecl>(var)) {
11228 DiagID = diag::err_typecheck_arc_assign_externally_retained;
11232 DiagID = diag::err_typecheck_arr_assign_enumeration;
11236 if (Loc != OrigLoc)
11262 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
11266 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
11270 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
11273 llvm_unreachable(
"did not take early return for MLV_Valid");
11277 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
11282 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
11284 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
11287 llvm_unreachable(
"readonly properties should be processed differently");
11289 DiagID = diag::err_readonly_message_assignment;
11292 DiagID = diag::err_no_subobject_property_setting;
11297 if (Loc != OrigLoc)
11322 if (!(isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase())))
11327 cast<ValueDecl>(MR->getMemberDecl()->getCanonicalDecl());
11328 if (LHSDecl != RHSDecl)
11333 if (RefTy->getPointeeType().isVolatileQualified())
11336 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
11342 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
11345 if (RL && RR && RL->
getDecl() == RR->getDecl())
11346 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
11366 if (getLangOpts().OpenCL && !getOpenCLOptions().
isEnabled(
"cl_khr_fp16") &&
11368 Diag(Loc, diag::err_opencl_half_load_store) << 1
11374 if (CompoundType.
isNull()) {
11380 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
11384 if (ConvTy == IncompatiblePointer &&
11389 ConvTy = Compatible;
11391 if (ConvTy == Compatible &&
11393 Diag(Loc, diag::err_objc_object_assignment)
11400 RHSCheck = ICE->getSubExpr();
11401 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
11402 if ((UO->getOpcode() == UO_Plus || UO->getOpcode() == UO_Minus) &&
11403 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
11409 UO->getSubExpr()->getBeginLoc().
isFileID()) {
11410 Diag(Loc, diag::warn_not_compound_assign)
11411 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
11412 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
11416 if (ConvTy == Compatible) {
11424 checkRetainCycles(LHSExpr, RHS.
get());
11438 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
11439 RHS.
get()->getBeginLoc()))
11440 getCurFunction()->markSafeWeakUse(RHS.
get());
11442 }
else if (getLangOpts().ObjCAutoRefCount || getLangOpts().ObjCWeak) {
11443 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
11448 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
11451 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
11452 RHS.
get(), AA_Assigning))
11472 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
11473 if (CE->getCastKind() == CK_ToVoid) {
11479 CE->getSubExpr()->getType()->isDependentType()) {
11496 if (inTemplateInstantiation())
11506 const unsigned ForIncrementFlags =
11507 getLangOpts().C99 || getLangOpts().CPlusPlus
11511 const unsigned ScopeFlags = getCurScope()->getFlags();
11512 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
11513 (ScopeFlags & ForInitFlags) == ForInitFlags)
11518 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
11519 if (BO->getOpcode() != BO_Comma)
11521 LHS = BO->getRHS();
11528 Diag(Loc, diag::warn_comma_operator);
11532 LangOpts.CPlusPlus ?
"static_cast<void>(" 11562 if (!RHS.
get()->getType()->isVoidType())
11564 diag::err_incomplete_type);
11570 return RHS.
get()->getType();
11579 bool IsInc,
bool IsPrefix) {
11588 ResType = ResAtomicType->getValueType();
11590 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
11592 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
11600 : diag::warn_increment_bool)
11602 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
11604 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
11606 }
else if (ResType->isRealType()) {
11608 }
else if (ResType->isPointerType()) {
11612 }
else if (ResType->isObjCObjectPointerType()) {
11618 }
else if (ResType->isAnyComplexType()) {
11620 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
11622 }
else if (ResType->isPlaceholderType()) {
11627 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
11629 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
11630 (ResType->getAs<
VectorType>()->getVectorKind() !=
11633 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
11637 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
11654 return ResType.getUnqualifiedType();
11673 case Stmt::DeclRefExprClass:
11674 return cast<DeclRefExpr>(E)->getDecl();
11675 case Stmt::MemberExprClass:
11679 if (cast<MemberExpr>(E)->isArrow())
11683 case Stmt::ArraySubscriptExprClass: {
11686 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
11688 if (ICE->getSubExpr()->getType()->isArrayType())
11693 case Stmt::UnaryOperatorClass: {
11705 case Stmt::ParenExprClass:
11707 case Stmt::ImplicitCastExprClass:
11719 AO_Vector_Element = 1,
11720 AO_Property_Expansion = 2,
11721 AO_Register_Variable = 3,
11741 if (
const BuiltinType *PTy = OrigOp.
get()->getType()->getAsPlaceholderType()){
11742 if (PTy->getKind() == BuiltinType::Overload) {
11743 Expr *E = OrigOp.
get()->IgnoreParens();
11744 if (!isa<OverloadExpr>(E)) {
11745 assert(cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf);
11746 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
11747 << OrigOp.
get()->getSourceRange();
11752 if (isa<UnresolvedMemberExpr>(Ovl))
11753 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
11754 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11755 << OrigOp.
get()->getSourceRange();
11762 if (PTy->getKind() == BuiltinType::UnknownAny)
11765 if (PTy->getKind() == BuiltinType::BoundMember) {
11766 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11767 << OrigOp.
get()->getSourceRange();
11771 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
11775 if (OrigOp.
get()->isTypeDependent())
11778 assert(!OrigOp.
get()->getType()->isPlaceholderType());
11781 Expr *op = OrigOp.
get()->IgnoreParens();
11788 if (LangOpts.OpenCL) {
11790 if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
11791 Diag(op->
getExprLoc(), diag::err_opencl_taking_address_capture);
11796 if (getLangOpts().
C99) {
11799 if (uOp->getOpcode() == UO_Deref)
11802 return uOp->getSubExpr()->getType();
11809 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
11815 unsigned AddressOfError = AO_No_Error;
11818 bool sfinae = (
bool)isSFINAEContext();
11819 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
11820 : diag::ext_typecheck_addrof_temporary)
11826 CreateMaterializeTemporaryExpr(op->
getType(), OrigOp.
get(),
true);
11827 }
else if (isa<ObjCSelectorExpr>(op)) {
11834 if (!isa<DeclRefExpr>(op)) {
11835 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
11836 << OrigOp.
get()->getSourceRange();
11843 if (OrigOp.
get() != DRE) {
11844 Diag(OpLoc, diag::err_parens_pointer_member_function)
11845 << OrigOp.
get()->getSourceRange();
11849 if (MD->getParent()->getName().empty())
11850 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11854 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
11855 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
11862 if (isa<CXXDestructorDecl>(MD))
11869 (
void)isCompleteType(OpLoc, MPTy);
11876 if (isa<PseudoObjectExpr>(op)) {
11877 AddressOfError = AO_Property_Expansion;
11879 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
11886 AddressOfError = AO_Bit_Field;
11889 AddressOfError = AO_Vector_Element;
11893 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
11897 !getLangOpts().CPlusPlus) {
11898 AddressOfError = AO_Register_Variable;
11900 }
else if (isa<MSPropertyDecl>(dcl)) {
11901 AddressOfError = AO_Property_Expansion;
11902 }
else if (isa<FunctionTemplateDecl>(dcl)) {
11904 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
11908 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
11913 diag::err_cannot_form_pointer_to_member_of_reference_type)
11918 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
11926 (
void)isCompleteType(OpLoc, MPTy);
11930 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
11931 !isa<BindingDecl>(dcl))
11932 llvm_unreachable(
"Unknown/unexpected decl type");
11935 if (AddressOfError != AO_No_Error) {
11951 CheckAddressOfPackedMember(op);
11967 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
11970 if (!FD->ModifiedNonNullParams.count(Param))
11971 FD->ModifiedNonNullParams.insert(Param);
11981 if (ConvResult.isInvalid())
11983 Op = ConvResult.get();
11987 if (isa<CXXReinterpretCastExpr>(Op)) {
12003 if (PR.
get() != Op)
12008 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
12023 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
12039 default: llvm_unreachable(
"Unknown binop!");
12040 case tok::periodstar: Opc = BO_PtrMemD;
break;
12041 case tok::arrowstar: Opc = BO_PtrMemI;
break;
12042 case tok::star: Opc = BO_Mul;
break;
12043 case tok::slash: Opc = BO_Div;
break;
12044 case tok::percent: Opc = BO_Rem;
break;
12045 case tok::plus: Opc = BO_Add;
break;
12046 case tok::minus: Opc = BO_Sub;
break;
12047 case tok::lessless: Opc = BO_Shl;
break;
12048 case tok::greatergreater: Opc = BO_Shr;
break;
12049 case tok::lessequal: Opc = BO_LE;
break;
12050 case tok::less: Opc = BO_LT;
break;
12051 case tok::greaterequal: Opc = BO_GE;
break;
12052 case tok::greater: Opc = BO_GT;
break;
12053 case tok::exclaimequal: Opc = BO_NE;
break;
12054 case tok::equalequal: Opc = BO_EQ;
break;
12055 case tok::spaceship: Opc = BO_Cmp;
break;
12056 case tok::amp: Opc = BO_And;
break;
12057 case tok::caret: Opc = BO_Xor;
break;
12058 case tok::pipe: Opc = BO_Or;
break;
12059 case tok::ampamp: Opc = BO_LAnd;
break;
12060 case tok::pipepipe: Opc = BO_LOr;
break;
12061 case tok::equal: Opc = BO_Assign;
break;
12062 case tok::starequal: Opc = BO_MulAssign;
break;
12063 case tok::slashequal: Opc = BO_DivAssign;
break;
12064 case tok::percentequal: Opc = BO_RemAssign;
break;
12065 case tok::plusequal: Opc = BO_AddAssign;
break;
12066 case tok::minusequal: Opc = BO_SubAssign;
break;
12067 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
12068 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
12069 case tok::ampequal: Opc = BO_AndAssign;
break;
12070 case tok::caretequal: Opc = BO_XorAssign;
break;
12071 case tok::pipeequal: Opc = BO_OrAssign;
break;
12072 case tok::comma: Opc = BO_Comma;
break;
12081 default: llvm_unreachable(
"Unknown unary op!");
12082 case tok::plusplus: Opc = UO_PreInc;
break;
12083 case tok::minusminus: Opc = UO_PreDec;
break;
12084 case tok::amp: Opc = UO_AddrOf;
break;
12085 case tok::star: Opc = UO_Deref;
break;
12086 case tok::plus: Opc = UO_Plus;
break;
12087 case tok::minus: Opc = UO_Minus;
break;
12088 case tok::tilde: Opc = UO_Not;
break;
12089 case tok::exclaim: Opc = UO_LNot;
break;
12090 case tok::kw___real: Opc = UO_Real;
break;
12091 case tok::kw___imag: Opc = UO_Imag;
break;
12092 case tok::kw___extension__: Opc = UO_Extension;
break;
12111 if (!LHSDeclRef || !RHSDeclRef ||
12113 RHSDeclRef->getLocation().isMacroID())
12118 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
12119 if (LHSDecl != RHSDecl)
12124 if (RefTy->getPointeeType().isVolatileQualified())
12127 S.
Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin
12128 : diag::warn_self_assignment_overloaded)
12140 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
12145 ObjCPointerExpr = LHS;
12149 ObjCPointerExpr = RHS;
12157 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
12158 unsigned Diag = diag::warn_objc_pointer_masking;
12167 if (SelArg0.startswith(
"performSelector"))
12168 Diag = diag::warn_objc_pointer_masking_performSelector;
12171 S.
Diag(OpLoc, Diag)
12179 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
12180 return DRE->getDecl();
12181 if (
auto *ME = dyn_cast<MemberExpr>(E))
12182 return ME->getMemberDecl();
12183 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
12184 return IRE->getDecl();
12199 "Result must be a vector of half or short");
12202 "both operands expected to be a half vector");
12214 LHS.
get(), RHS.
get(), Opc, ResultTy, VK, OK, BinOpResTy, BinOpResTy,
12215 OpLoc, FPFeatures);
12219 VK, OK, OpLoc, FPFeatures);
12223 static std::pair<ExprResult, ExprResult>
12233 if (Opc != BO_Assign)
12240 return std::make_pair(LHS, RHS);
12247 return OpRequiresConversion && !Ctx.
getLangOpts().NativeHalfType &&
12258 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
12270 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
12273 RHSExpr = Init.
get();
12283 bool ConvertHalfVec =
false;
12286 if (!LHS.
isUsable() || !RHS.isUsable())
12289 if (getLangOpts().OpenCL) {
12296 if (BO_Assign == Opc)
12297 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
12299 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12309 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
12316 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
12317 if (getLangOpts().CPlusPlus &&
12319 VK = LHS.
get()->getValueKind();
12320 OK = LHS.
get()->getObjectKind();
12322 if (!ResultTy.
isNull()) {
12324 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
12330 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
12331 Opc == BO_PtrMemI);
12335 ConvertHalfVec =
true;
12336 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
12340 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
12343 ConvertHalfVec =
true;
12344 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
12347 ConvertHalfVec =
true;
12348 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
12352 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
12358 ConvertHalfVec =
true;
12359 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12363 ConvertHalfVec =
true;
12364 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12367 ConvertHalfVec =
true;
12368 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc);
12376 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12380 ConvertHalfVec =
true;
12381 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
12385 ConvertHalfVec =
true;
12386 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
12387 Opc == BO_DivAssign);
12388 CompLHSTy = CompResultTy;
12390 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12393 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
12394 CompLHSTy = CompResultTy;
12396 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12399 ConvertHalfVec =
true;
12400 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
12402 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12405 ConvertHalfVec =
true;
12406 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
12408 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12412 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
12413 CompLHSTy = CompResultTy;
12415 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12422 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc);
12423 CompLHSTy = CompResultTy;
12425 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
12429 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
12430 VK = RHS.get()->getValueKind();
12431 OK = RHS.get()->getObjectKind();
12444 "both sides are half vectors or neither sides are");
12446 LHS.
get()->getType());
12449 CheckArrayAccess(LHS.
get());
12450 CheckArrayAccess(RHS.get());
12452 if (
const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.
get()->IgnoreParenCasts())) {
12453 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
12454 &Context.
Idents.
get(
"object_setClass"),
12456 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
12457 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
12458 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign)
12460 "object_setClass(")
12466 Diag(LHS.
get()->getExprLoc(), diag::warn_objc_isa_assign);
12469 dyn_cast<ObjCIvarRefExpr>(LHS.
get()->IgnoreParenCasts()))
12473 if (CompResultTy.
isNull()) {
12474 if (ConvertHalfVec)
12476 OpLoc, FPFeatures);
12478 OK, OpLoc, FPFeatures);
12482 if (getLangOpts().CPlusPlus && LHS.
get()->getObjectKind() !=
12485 OK = LHS.
get()->getObjectKind();
12488 if (ConvertHalfVec)
12490 OpLoc, FPFeatures);
12493 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
12494 OpLoc, FPFeatures);
12509 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
12510 if (isLeftComp == isRightComp)
12515 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
12516 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
12517 if (isLeftBitwise || isRightBitwise)
12523 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
12529 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
12532 Self.
PDiag(diag::note_precedence_silence) << OpStr,
12535 Self.
PDiag(diag::note_precedence_bitwise_first)
12550 Self.
PDiag(diag::note_precedence_silence)
12575 if (Bop->getOpcode() == BO_LAnd) {
12582 }
else if (Bop->getOpcode() == BO_LOr) {
12583 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
12586 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
12597 if (Bop->getOpcode() == BO_LAnd) {
12614 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
12615 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
12617 << Bop->getSourceRange() << OpLoc;
12619 S.
PDiag(diag::note_precedence_silence)
12620 << Bop->getOpcodeStr(),
12621 Bop->getSourceRange());
12629 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
12630 StringRef Op = Bop->getOpcodeStr();
12631 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
12632 << Bop->getSourceRange() << OpLoc << Shift << Op;
12634 S.
PDiag(diag::note_precedence_silence) << Op,
12635 Bop->getSourceRange());
12651 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
12654 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
12656 << (Kind == OO_LessLess);
12658 S.
PDiag(diag::note_precedence_silence)
12659 << (Kind == OO_LessLess ?
"<<" :
">>"),
12662 S, OpLoc, S.
PDiag(diag::note_evaluate_comparison_first),
12676 if ((Opc == BO_Or || Opc == BO_Xor) &&
12684 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
12690 || Opc == BO_Shr) {
12707 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
12708 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
12713 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
12742 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
12758 LHSExpr = LHS.
get();
12759 RHSExpr = RHS.
get();
12770 if (pty->getKind() == BuiltinType::PseudoObject &&
12772 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
12775 if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
12781 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12783 RHSExpr = resolvedRHS.
get();
12796 if (Opc == BO_LT && inTemplateInstantiation() &&
12797 (pty->getKind() == BuiltinType::BoundMember ||
12798 pty->getKind() == BuiltinType::Overload)) {
12800 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
12801 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
12802 return isa<FunctionTemplateDecl>(ND);
12804 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
12805 : OE->getNameLoc(),
12806 diag::err_template_kw_missing)
12807 << OE->getName().getAsString() <<
"";
12812 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
12814 LHSExpr = LHS.
get();
12821 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
12822 if (getLangOpts().CPlusPlus &&
12827 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12831 if (getLangOpts().
CPlusPlus && pty->getKind() == BuiltinType::Overload &&
12835 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
12837 RHSExpr = resolvedRHS.
get();
12854 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
12874 bool CanOverflow =
false;
12876 bool ConvertHalfVec =
false;
12877 if (getLangOpts().OpenCL) {
12885 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12887 << Input.
get()->getSourceRange());
12897 Opc == UO_PreInc ||
12899 Opc == UO_PreInc ||
12904 resultType = CheckAddressOfOperand(Input, OpLoc);
12905 CheckAddressOfNoDeref(InputExpr);
12909 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
12916 CanOverflow = Opc == UO_Minus &&
12918 Input = UsualUnaryConversions(Input.get());
12919 if (Input.isInvalid())
return ExprError();
12928 if (ConvertHalfVec)
12930 resultType = Input.get()->getType();
12931 if (resultType->isDependentType())
12933 if (resultType->isArithmeticType())
12935 else if (resultType->isVectorType() &&
12938 resultType->getAs<
VectorType>()->getVectorKind() !=
12941 else if (getLangOpts().CPlusPlus &&
12943 resultType->isPointerType())
12946 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12947 << resultType << Input.get()->getSourceRange());
12950 Input = UsualUnaryConversions(Input.get());
12951 if (Input.isInvalid())
12953 resultType = Input.
get()->getType();
12955 if (resultType->isDependentType())
12958 if (resultType->isComplexType() || resultType->isComplexIntegerType())
12960 Diag(OpLoc, diag::ext_integer_complement_complex)
12961 << resultType << Input.get()->getSourceRange();
12962 else if (resultType->hasIntegerRepresentation())
12964 else if (resultType->isExtVectorType() && Context.
getLangOpts().OpenCL) {
12969 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12970 << resultType << Input.get()->getSourceRange());
12972 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
12973 << resultType << Input.get()->getSourceRange());
12979 Input = DefaultFunctionArrayLvalueConversion(Input.get());
12980 if (Input.isInvalid())
return ExprError();
12981 resultType = Input.
get()->getType();
12984 if (resultType->isHalfType() && !Context.
getLangOpts().NativeHalfType) {
12985 Input = ImpCastExprToType(Input.get(), Context.
FloatTy, CK_FloatingCast).
get();
12986 resultType = Context.
FloatTy;
12989 if (resultType->isDependentType())
12996 Input = ImpCastExprToType(Input.get(), Context.
BoolTy,
12997 ScalarTypeToBooleanCastKind(resultType));
13002 if (!resultType->isIntegerType() && !resultType->isPointerType())
13003 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13004 << resultType << Input.get()->getSourceRange());
13006 }
else if (resultType->isExtVectorType()) {
13013 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13014 << resultType << Input.get()->getSourceRange());
13017 resultType = GetSignedVectorType(resultType);
13022 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
13023 << resultType << Input.get()->getSourceRange());
13035 if (Input.isInvalid())
return ExprError();
13036 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
13037 if (Input.get()->getValueKind() !=
VK_RValue &&
13039 VK = Input.
get()->getValueKind();
13042 Input = DefaultLvalueConversion(Input.get());
13046 resultType = Input.get()->getType();
13047 VK = Input.get()->getValueKind();
13048 OK = Input.get()->getObjectKind();
13053 assert(!Input.get()->getType()->isDependentType() &&
13054 "the co_await expression must be non-dependant before " 13055 "building operator co_await");
13065 if (Opc != UO_AddrOf && Opc != UO_Deref)
13066 CheckArrayAccess(Input.
get());
13068 auto *UO =
new (Context)
13071 if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
13072 !isa<ArrayType>(UO->getType().getDesugaredType(Context)))
13073 ExprEvalContexts.back().PossibleDerefs.insert(UO);
13076 if (ConvertHalfVec)
13085 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13086 if (!DRE->getQualifier())
13093 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
13096 return Method->isInstance();
13102 if (!ULE->getQualifier())
13107 if (Method->isInstance())
13127 if (pty->getKind() == BuiltinType::PseudoObject &&
13129 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
13132 if (Opc == UO_Extension)
13133 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13137 if (Opc == UO_AddrOf &&
13138 (pty->getKind() == BuiltinType::Overload ||
13139 pty->getKind() == BuiltinType::UnknownAny ||
13140 pty->getKind() == BuiltinType::BoundMember))
13141 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13144 ExprResult Result = CheckPlaceholderExpr(Input);
13146 Input = Result.
get();
13151 !(Opc == UO_AddrOf && isQualifiedMemberAccess(Input))) {
13159 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
13162 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
13165 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13191 if (!cleanups)
return nullptr;
13194 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
13207 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
13214 DiscardCleanupsInEvaluationContext();
13215 PopExpressionEvaluationContext();
13221 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
13224 if (hasAnyUnrecoverableErrorsInThisFunction())
13225 DiscardCleanupsInEvaluationContext();
13226 assert(!Cleanup.exprNeedsCleanups() &&
13227 "cleanups within StmtExpr not correctly bound!");
13228 PopExpressionEvaluationContext();
13237 bool StmtExprMayBindToTemp =
false;
13243 LastLabelStmt =
Label;
13244 LastStmt =
Label->getSubStmt();
13247 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
13250 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
13253 Ty = LastExpr.
get()->getType().getUnqualifiedType();
13262 if (
Expr *rebuiltLastStmt
13264 LastExpr = rebuiltLastStmt;
13266 LastExpr = PerformCopyInitialization(
13273 if (LastExpr.
get() !=
nullptr) {
13274 if (!LastLabelStmt)
13278 StmtExprMayBindToTemp =
true;
13286 Expr *ResStmtExpr =
new (Context)
StmtExpr(Compound, Ty, LPLoc, RPLoc);
13287 if (StmtExprMayBindToTemp)
13288 return MaybeBindToTemporary(ResStmtExpr);
13289 return ResStmtExpr;
13304 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
13305 << ArgTy << TypeRange);
13310 && RequireCompleteType(BuiltinLoc, ArgTy,
13311 diag::err_offsetof_incomplete_type, TypeRange))
13314 bool DidWarnAboutNonPOD =
false;
13319 if (OC.isBrackets) {
13324 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
13330 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
13344 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
13345 Exprs.push_back(Idx);
13353 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
13359 if (RequireCompleteType(OC.LocStart, CurrentType,
13360 diag::err_offsetof_incomplete_type))
13366 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
13378 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
13380 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
13381 : diag::ext_offsetof_non_pod_type;
13383 if (!IsSafe && !DidWarnAboutNonPOD &&
13384 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
13386 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
13388 DidWarnAboutNonPOD =
true;
13392 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
13393 LookupQualifiedName(R, RD);
13398 MemberDecl = IndirectMemberDecl->getAnonField();
13403 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
13411 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
13419 if (IndirectMemberDecl)
13420 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
13425 if (IsDerivedFrom(OC.LocStart, CurrentType, Context.
getTypeDeclType(Parent),
13427 if (Paths.getDetectedVirtual()) {
13428 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
13439 if (IndirectMemberDecl) {
13440 for (
auto *FI : IndirectMemberDecl->chain()) {
13441 assert(isa<FieldDecl>(FI));
13443 cast<FieldDecl>(FI), OC.LocEnd));
13446 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
13452 Comps, Exprs, RParenLoc);
13463 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
13470 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
13478 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
13483 bool ValueDependent =
false;
13484 bool CondIsTrue =
false;
13487 ValueDependent =
true;
13490 llvm::APSInt condEval(32);
13492 = VerifyIntegerConstantExpression(CondExpr, &condEval,
13493 diag::err_typecheck_choose_expr_requires_constant,
false);
13496 CondExpr = CondICE.
get();
13497 CondIsTrue = condEval.getZExtValue();
13500 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
13502 resType = ActiveExpr->
getType();
13508 return new (Context)
13509 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
13521 if (LangOpts.CPlusPlus) {
13522 Decl *ManglingContextDecl;
13525 ManglingContextDecl)) {
13526 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
13531 PushBlockScope(CurScope, Block);
13532 CurContext->addDecl(Block);
13534 PushDeclContext(CurScope, Block);
13536 CurContext = Block;
13538 getCurBlock()->HasImplicitReturnType =
true;
13542 PushExpressionEvaluationContext(
13543 ExpressionEvaluationContext::PotentiallyEvaluated);
13549 "block-id should have no identifier!");
13553 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
13558 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
13571 "GetTypeForDeclarator made a non-function block signature");
13576 if ((ExplicitSignature =
13582 if (ExplicitSignature.getLocalRangeBegin() ==
13583 ExplicitSignature.getLocalRangeEnd()) {
13586 TypeLoc Result = ExplicitSignature.getReturnLoc();
13595 CurBlock->TheDecl->setSignatureAsWritten(Sig);
13596 CurBlock->FunctionType = T;
13601 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
13603 CurBlock->TheDecl->setIsVariadic(isVariadic);
13610 CurBlock->ReturnType = RetTy;
13611 CurBlock->TheDecl->setBlockMissingReturnType(
false);
13612 CurBlock->HasImplicitReturnType =
false;
13617 if (ExplicitSignature) {
13618 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
13619 ParmVarDecl *Param = ExplicitSignature.getParam(I);
13623 !getLangOpts().CPlusPlus)
13625 Params.push_back(Param);
13631 for (
const auto &I : Fn->param_types()) {
13634 Params.push_back(Param);
13639 if (!Params.empty()) {
13640 CurBlock->TheDecl->setParams(Params);
13641 CheckParmsForFunctionDef(CurBlock->TheDecl->parameters(),
13646 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
13649 for (
auto AI : CurBlock->TheDecl->parameters()) {
13650 AI->setOwningFunction(CurBlock->TheDecl);
13653 if (AI->getIdentifier()) {
13654 CheckShadow(CurBlock->TheScope, AI);
13656 PushOnScopeChains(AI, CurBlock->TheScope);
13665 DiscardCleanupsInEvaluationContext();
13666 PopExpressionEvaluationContext();
13670 PopFunctionScopeInfo();
13678 if (!LangOpts.Blocks)
13679 Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
13682 if (hasAnyUnrecoverableErrorsInThisFunction())
13683 DiscardCleanupsInEvaluationContext();
13684 assert(!Cleanup.exprNeedsCleanups() &&
13685 "cleanups within block not correctly bound!");
13686 PopExpressionEvaluationContext();
13688 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
13692 deduceClosureReturnType(*BSI);
13700 bool NoReturn = BD->
hasAttr<NoReturnAttr>();
13711 Captures.push_back(NewCap);
13720 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
13723 if (isa<FunctionNoProtoType>(FTy)) {
13750 DiagnoseUnusedParameters(BD->parameters());
13754 if (getCurFunction()->NeedsScopeChecking() &&
13755 !PP.isCodeCompletionEnabled())
13756 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
13758 BD->setBody(cast<CompoundStmt>(Body));
13760 if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
13761 DiagnoseUnguardedAvailabilityViolations(BD);
13767 !BD->isDependentContext())
13768 computeNRVO(Body, BSI);
13772 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
13779 Cleanup.setExprNeedsCleanups(
true);
13784 const VarDecl *var = CI.getVariable();
13786 setFunctionHasBranchProtectedScope();
13792 if (getCurFunction())
13793 getCurFunction()->addBlock(BD);
13801 GetTypeFromParser(Ty, &TInfo);
13802 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
13808 Expr *OrigExpr = E;
13812 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
13813 if (
const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
13815 if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
13842 ExprResult Result = UsualUnaryConversions(E);
13846 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
13852 if (Init.isInvalid())
13854 E = Init.getAs<
Expr>();
13868 diag::err_first_argument_to_va_arg_not_of_type_va_list)
13873 diag::err_second_parameter_to_va_arg_incomplete,
13879 diag::err_second_parameter_to_va_arg_abstract,
13886 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
13887 : diag::warn_second_parameter_to_va_arg_not_pod)
13904 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
13911 return new (Context)
VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T, IsMS);
13920 Ty = Context.
IntTy;
13926 llvm_unreachable(
"I don't know size of pointer!");
13934 if (!getLangOpts().ObjC)
13953 if (OV->getSourceExpr())
13962 Exp = BuildObjCStringLiteral(SL->
getBeginLoc(), SL).
get();
13968 const Expr *SrcExpr) {
13990 bool *Complained) {
13992 *Complained =
false;
13995 bool CheckInferredResultType =
false;
13997 unsigned DiagKind = 0;
14000 bool MayHaveConvFixit =
false;
14001 bool MayHaveFunctionDiff =
false;
14007 DiagnoseAssignmentEnum(DstType, SrcType, SrcExpr);
14011 DiagKind = diag::ext_typecheck_convert_pointer_int;
14013 MayHaveConvFixit =
true;
14016 DiagKind = diag::ext_typecheck_convert_int_pointer;
14018 MayHaveConvFixit =
true;
14020 case IncompatiblePointer:
14021 if (Action == AA_Passing_CFAudited)
14022 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
14025 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
14027 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
14031 if (Hint.
isNull() && !CheckInferredResultType) {
14034 else if (CheckInferredResultType) {
14038 MayHaveConvFixit =
true;
14040 case IncompatiblePointerSign:
14041 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
14043 case FunctionVoidPointer:
14044 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
14046 case IncompatiblePointerDiscardsQualifiers: {
14053 DiagKind = diag::err_typecheck_incompatible_address_space;
14057 DiagKind = diag::err_typecheck_incompatible_ownership;
14061 llvm_unreachable(
"unknown error case for discarding qualifiers!");
14064 case CompatiblePointerDiscardsQualifiers:
14075 IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
14077 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
14079 case IncompatibleNestedPointerQualifiers:
14080 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
14082 case IntToBlockPointer:
14083 DiagKind = diag::err_int_to_block_pointer;
14085 case IncompatibleBlockPointer:
14086 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
14088 case IncompatibleObjCQualifiedId: {
14092 for (
auto *srcProto : srcOPT->
quals()) {
14098 IFace = IFaceT->getDecl();
14103 for (
auto *dstProto : dstOPT->
quals()) {
14109 IFace = IFaceT->getDecl();
14111 DiagKind = diag::warn_incompatible_qualified_id;
14114 case IncompatibleVectors:
14115 DiagKind = diag::warn_incompatible_vectors;
14117 case IncompatibleObjCWeakRef:
14118 DiagKind = diag::err_arc_weak_unavailable_assign;
14123 *Complained =
true;
14127 DiagKind = diag::err_typecheck_convert_incompatible;
14129 MayHaveConvFixit =
true;
14131 MayHaveFunctionDiff =
true;
14138 case AA_Initializing:
14140 FirstType = DstType;
14141 SecondType = SrcType;
14146 case AA_Passing_CFAudited:
14147 case AA_Converting:
14151 FirstType = SrcType;
14152 SecondType = DstType;
14157 if (Action == AA_Passing_CFAudited)
14158 FDiag << FirstType << SecondType << AA_Passing << SrcExpr->
getSourceRange();
14160 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
14164 if (!ConvHints.
isNull()) {
14170 if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.
Kind); }
14172 if (MayHaveFunctionDiff)
14173 HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
14176 if (DiagKind == diag::warn_incompatible_qualified_id &&
14178 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
14185 if (CheckInferredResultType)
14186 EmitRelatedResultTypeNote(SrcExpr);
14188 if (Action == AA_Returning && ConvTy == IncompatiblePointer)
14189 EmitRelatedResultTypeNoteForReturn(DstType);
14192 *Complained =
true;
14197 llvm::APSInt *Result) {
14201 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
14205 return VerifyIntegerConstantExpression(E, Result, Diagnoser);
14209 llvm::APSInt *Result,
14216 IDDiagnoser(
unsigned DiagID)
14220 S.
Diag(Loc, DiagID) << SR;
14222 } Diagnoser(DiagID);
14224 return VerifyIntegerConstantExpression(E, Result, Diagnoser, AllowFold);
14229 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
14247 CXX11ConvertDiagnoser(
bool Silent)
14253 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
14258 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
14263 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
14274 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
14285 llvm_unreachable(
"conversion functions are permitted");
14287 } ConvertDiagnoser(Diagnoser.
Suppress);
14289 Converted = PerformContextualImplicitConversion(DiagLoc, E,
14293 E = Converted.
get();
14303 if (!isa<ConstantExpr>(E))
14316 EvalResult.
Diag = &Notes;
14326 if (Folded && getLangOpts().
CPlusPlus11 && Notes.empty()) {
14335 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14336 diag::note_invalid_subexpr_in_const_expr) {
14337 DiagLoc = Notes[0].first;
14341 if (!Folded || !AllowFold) {
14345 Diag(Note.first, Note.second);
14353 Diag(Note.first, Note.second);
14363 class TransformToPE :
public TreeTransform<TransformToPE> {
14367 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
14370 bool AlwaysRebuild() {
return true; }
14377 return BaseTransform::TransformLabelStmt(S);
14388 if (isa<FieldDecl>(E->
getDecl()) &&
14391 diag::err_invalid_non_static_member_use)
14394 return BaseTransform::TransformDeclRefExpr(E);
14402 return BaseTransform::TransformUnaryOperator(E);
14413 assert(isUnevaluatedContext() &&
14414 "Should only transform unevaluated expressions");
14415 ExprEvalContexts.back().Context =
14416 ExprEvalContexts[ExprEvalContexts.size()-2].Context;
14417 if (isUnevaluatedContext())
14419 return TransformToPE(*this).TransformExpr(E);
14426 ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
14427 LambdaContextDecl, ExprContext);
14429 if (!MaybeODRUseExprs.empty())
14430 std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
14437 Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
14438 PushExpressionEvaluationContext(NewContext, ClosureContextDecl, ExprContext);
14445 if (
const auto *E = dyn_cast<UnaryOperator>(PossibleDeref)) {
14446 if (E->getOpcode() == UO_Deref)
14447 return CheckPossibleDeref(S, E->getSubExpr());
14448 }
else if (
const auto *E = dyn_cast<ArraySubscriptExpr>(PossibleDeref)) {
14449 return CheckPossibleDeref(S, E->getBase());
14450 }
else if (
const auto *E = dyn_cast<MemberExpr>(PossibleDeref)) {
14451 return CheckPossibleDeref(S, E->getBase());
14452 }
else if (
const auto E = dyn_cast<DeclRefExpr>(PossibleDeref)) {
14458 Inner = Arr->getElementType();
14462 if (Inner->
hasAttr(attr::NoDeref))
14472 const DeclRefExpr *DeclRef = CheckPossibleDeref(*
this, E);
14479 Diag(E->
getExprLoc(), diag::warn_dereference_of_noderef_type_no_decl)
14499 D = diag::err_lambda_unevaluated_operand;
14505 D = diag::err_lambda_in_constant_expression;
14506 }
else if (Rec.
ExprContext == ExpressionKind::EK_TemplateArgument) {
14509 D = diag::err_lambda_in_invalid_context;
14511 llvm_unreachable(
"Couldn't infer lambda error message.");
14513 for (
const auto *L : Rec.
Lambdas)
14514 Diag(L->getBeginLoc(), D);
14518 for (
auto *Lambda : Rec.
Lambdas) {
14519 for (
auto *C : Lambda->capture_inits())
14520 MarkDeclarationsReferencedInExpr(C);
14525 WarnOnPendingNoDerefs(Rec);
14533 ExprCleanupObjects.end());
14535 CleanupVarDeclMarking();
14545 ExprEvalContexts.pop_back();
14548 ExprEvalContexts.back().NumTypos += NumTypos;
14552 ExprCleanupObjects.erase(
14553 ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
14554 ExprCleanupObjects.end());
14556 MaybeODRUseExprs.clear();
14560 ExprResult Result = CheckPlaceholderExpr(E);
14566 return TransformToPotentiallyEvaluated(E);
14592 llvm_unreachable(
"Invalid context");
14617 llvm_unreachable(
"Invalid context");
14629 bool MightBeOdrUse) {
14630 assert(Func &&
"No function?");
14652 bool NeedDefinition =
14661 if (NeedDefinition &&
14664 checkSpecializationVisibility(Loc, Func);
14677 ResolveExceptionSpec(Loc, FPT);
14681 if ((Func->
isUsed(
false) || !OdrUse) &&
14682 (!NeedDefinition || Func->
getBody()))
14687 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
14688 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
14689 if (Constructor->isDefaultConstructor()) {
14690 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
14692 DefineImplicitDefaultConstructor(Loc, Constructor);
14693 }
else if (Constructor->isCopyConstructor()) {
14694 DefineImplicitCopyConstructor(Loc, Constructor);
14695 }
else if (Constructor->isMoveConstructor()) {
14696 DefineImplicitMoveConstructor(Loc, Constructor);
14698 }
else if (Constructor->getInheritedConstructor()) {
14699 DefineInheritingConstructor(Loc, Constructor);
14702 dyn_cast<CXXDestructorDecl>(Func)) {
14703 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
14704 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
14705 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
14707 DefineImplicitDestructor(Loc, Destructor);
14709 if (Destructor->isVirtual() && getLangOpts().AppleKext)
14710 MarkVTableUsed(Loc, Destructor->getParent());
14711 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
14712 if (MethodDecl->isOverloadedOperator() &&
14713 MethodDecl->getOverloadedOperator() == OO_Equal) {
14714 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
14715 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
14716 if (MethodDecl->isCopyAssignmentOperator())
14717 DefineImplicitCopyAssignment(Loc, MethodDecl);
14718 else if (MethodDecl->isMoveAssignmentOperator())
14719 DefineImplicitMoveAssignment(Loc, MethodDecl);
14721 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
14722 MethodDecl->getParent()->isLambda()) {
14724 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
14726 DefineImplicitLambdaToBlockPointerConversion(Loc, Conversion);
14728 DefineImplicitLambdaToFunctionPointerConversion(Loc, Conversion);
14729 }
else if (MethodDecl->isVirtual() && getLangOpts().AppleKext)
14730 MarkVTableUsed(Loc, MethodDecl->getParent());
14735 if (CurContext == Func)
return;
14742 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
14743 if (FirstInstantiation) {
14744 PointOfInstantiation = Loc;
14750 PointOfInstantiation = Loc;
14757 CodeSynthesisContexts.size())
14758 PendingLocalImplicitInstantiations.push_back(
14759 std::make_pair(Func, PointOfInstantiation));
14764 InstantiateFunctionDefinition(PointOfInstantiation, Func);
14767 PendingInstantiations.push_back(std::make_pair(Func,
14768 PointOfInstantiation));
14770 Consumer.HandleCXXImplicitFunctionInstantiation(Func);
14775 for (
auto i : Func->
redecls()) {
14776 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
14777 MarkFunctionReferenced(Loc, i, OdrUse);
14781 if (!OdrUse)
return;
14785 if (mightHaveNonExternalLinkage(Func))
14788 !LangOpts.GNUInline &&
14791 else if (isExternalWithNoLinkageType(Func))
14806 if (isa<ParmVarDecl>(var) &&
14807 isa<TranslationUnitDecl>(VarDC))
14820 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
14822 if (isa<CXXMethodDecl>(VarDC) &&
14823 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
14825 }
else if (isa<FunctionDecl>(VarDC)) {
14827 }
else if (isa<BlockDecl>(VarDC)) {
14831 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
14832 << var << ValueKind << ContextKind << VarDC;
14842 bool &SubCapturesAreNested,
14848 SubCapturesAreNested =
true;
14861 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
14862 !(isa<CapturedRegionScopeInfo>(CSI) &&
14863 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
14874 const bool Diagnose,
Sema &S) {
14889 const bool Diagnose,
Sema &S) {
14891 bool IsBlock = isa<BlockScopeInfo>(CSI);
14892 bool IsLambda = isa<LambdaScopeInfo>(CSI);
14900 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
14909 S.
Diag(Loc, diag::err_ref_vm_type);
14918 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
14921 S.
Diag(Loc, diag::err_ref_flexarray_type);
14923 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
14931 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
14934 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
14936 S.
Diag(Loc, diag::err_capture_block_variable)
14947 S.
Diag(Loc, diag::err_opencl_block_ref_block);
14957 const bool BuildAndDiagnose,
14962 Expr *CopyExpr =
nullptr;
14963 bool ByRef =
false;
14969 if (BuildAndDiagnose) {
14970 S.
Diag(Loc, diag::err_ref_array_type);
14979 if (BuildAndDiagnose) {
14980 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
14994 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
14996 if (AttrTy->getAttrKind() == attr::ObjCOwnership)
15000 Ty = AttrTy->getModifiedType();
15010 !IsObjCOwnershipAttributedType(PointeeTy)) {
15011 if (BuildAndDiagnose) {
15013 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
15014 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
15019 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
15028 DeclRefType = CaptureType;
15030 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
15037 if (isa<ParmVarDecl>(Var))
15054 CaptureType,
false),
15061 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
15064 CopyExpr = Result.
get();
15071 if (BuildAndDiagnose)
15072 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
15084 const bool BuildAndDiagnose,
15087 const bool RefersToCapturedVariable,
15106 CaptureType = DeclRefType;
15108 Expr *CopyExpr =
nullptr;
15109 if (BuildAndDiagnose) {
15132 if (BuildAndDiagnose)
15133 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
15145 bool RefersToCapturedVariable) {
15177 const bool BuildAndDiagnose,
15180 const bool RefersToCapturedVariable,
15183 const bool IsTopScope,
15187 bool ByRef =
false;
15221 if (!RefType->getPointeeType()->isFunctionType())
15227 if (BuildAndDiagnose) {
15228 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
15236 if (BuildAndDiagnose) {
15239 diag::err_capture_of_incomplete_type,
15244 diag::err_capture_of_abstract_type))
15250 if (BuildAndDiagnose)
15252 RefersToCapturedVariable);
15269 if (BuildAndDiagnose)
15270 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
15271 Loc, EllipsisLoc, CaptureType,
nullptr);
15279 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
15287 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
15288 ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
15291 if (FunctionScopeIndexToStopAt) {
15292 unsigned FSIndex = FunctionScopes.size() - 1;
15293 while (FSIndex != MaxFunctionScopesIndex) {
15302 if (VarDC == DC)
return true;
15307 if (IsGlobal && !(LangOpts.OpenMP && isOpenMPCapturedDecl(Var)))
15319 CaptureType = Var->
getType();
15321 bool Nested =
false;
15322 bool Explicit = (Kind != TryCapture_Implicit);
15323 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
15336 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
15357 if (BuildAndDiagnose) {
15380 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
15381 QTy = PVD->getOriginalType();
15385 if (getLangOpts().OpenMP) {
15386 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
15391 bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, RSI->OpenMPLevel);
15392 auto IsTargetCap = !IsOpenMPPrivateDecl &&
15393 isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
15398 adjustOpenMPTargetScopeIndex(FunctionScopesIndex, RSI->OpenMPLevel);
15400 if (IsTargetCap || IsOpenMPPrivateDecl) {
15401 Nested = !IsTargetCap;
15412 if (BuildAndDiagnose) {
15416 if (cast<LambdaScopeInfo>(CSI)->Lambda)
15417 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getBeginLoc(),
15418 diag::note_lambda_decl);
15434 FunctionScopesIndex--;
15437 }
while (!VarDC->
Equals(DC));
15444 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
15450 BuildAndDiagnose, CaptureType,
15451 DeclRefType, Nested, *
this))
15456 BuildAndDiagnose, CaptureType,
15457 DeclRefType, Nested, *
this))
15463 BuildAndDiagnose, CaptureType,
15464 DeclRefType, Nested, Kind, EllipsisLoc,
15465 I == N - 1, *
this))
15477 return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
15479 DeclRefType,
nullptr);
15485 return !tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15486 false, CaptureType,
15487 DeclRefType,
nullptr);
15495 if (tryCaptureVariable(Var, Loc, TryCapture_Implicit,
SourceLocation(),
15496 false, CaptureType,
15497 DeclRefType,
nullptr))
15500 return DeclRefType;
15514 const VarDecl *DefVD =
nullptr;
15541 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
15542 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
15543 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
15544 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
15547 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
15552 Res = CorrectDelayedTyposInExpr(Res);
15561 UpdateMarkingForLValueToRValue(Res.
get());
15566 for (
Expr *E : MaybeODRUseExprs) {
15569 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
15570 Var = cast<VarDecl>(DRE->getDecl());
15571 Loc = DRE->getLocation();
15572 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
15573 Var = cast<VarDecl>(ME->getMemberDecl());
15574 Loc = ME->getMemberLoc();
15576 llvm_unreachable(
"Unexpected expression");
15583 MaybeODRUseExprs.clear();
15589 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
15590 "Invalid Expr argument to DoMarkVarDeclReferenced");
15596 bool UsableInConstantExpr =
15598 bool NeedDefinition =
15603 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
15604 "Can't instantiate a partial template specialization.");
15610 !isa<VarTemplateSpecializationDecl>(Var))
15621 bool TryInstantiating =
15625 if (TryInstantiating) {
15627 bool FirstInstantiation = PointOfInstantiation.
isInvalid();
15628 if (FirstInstantiation) {
15629 PointOfInstantiation = Loc;
15633 bool InstantiationDependent =
false;
15634 bool IsNonDependent =
15640 if (IsNonDependent) {
15641 if (UsableInConstantExpr) {
15645 }
else if (FirstInstantiation ||
15646 isa<VarTemplateSpecializationDecl>(Var)) {
15653 .push_back(std::make_pair(Var, PointOfInstantiation));
15667 if (OdrUseContext && E &&
15674 }
else if (OdrUseContext) {
15682 const bool RefersToEnclosingScope =
15685 if (RefersToEnclosingScope) {
15698 assert(E &&
"Capture variable should be used in an expression.");
15715 Decl *D,
Expr *E,
bool MightBeOdrUse) {
15719 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
15735 bool IsVirtualCall = MD->
isVirtual() &&
15737 if (!IsVirtualCall)
15753 bool OdrUse =
true;
15755 if (Method->isVirtual() &&
15756 !Method->getDevirtualizedMethod(Base, getLangOpts().AppleKext))
15769 bool MightBeOdrUse =
true;
15772 if (Method->isPure())
15773 MightBeOdrUse =
false;
15785 bool MightBeOdrUse) {
15786 if (MightBeOdrUse) {
15787 if (
auto *VD = dyn_cast<VarDecl>(D)) {
15788 MarkVariableReferenced(Loc, VD);
15792 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
15793 MarkFunctionReferenced(Loc, FD, MightBeOdrUse);
15820 bool MarkReferencedDecls::TraverseTemplateArgument(
15834 return Inherited::TraverseTemplateArgument(Arg);
15838 MarkReferencedDecls Marker(*
this, Loc);
15839 Marker.TraverseType(T);
15847 bool SkipLocalVariables;
15852 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
15853 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
15857 if (SkipLocalVariables) {
15859 if (VD->hasLocalStorage())
15868 Inherited::VisitMemberExpr(E);
15883 Inherited::VisitCXXNewExpr(E);
15891 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
15895 Inherited::VisitCXXDeleteExpr(E);
15900 Inherited::VisitCXXConstructExpr(E);
15908 Inherited::VisitImplicitCastExpr(E);
15922 bool SkipLocalVariables) {
15923 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
15944 switch (ExprEvalContexts.back().Context) {
15945 case ExpressionEvaluationContext::Unevaluated:
15946 case ExpressionEvaluationContext::UnevaluatedList:
15947 case ExpressionEvaluationContext::UnevaluatedAbstract:
15948 case ExpressionEvaluationContext::DiscardedStatement:
15952 case ExpressionEvaluationContext::ConstantEvaluated:
15956 case ExpressionEvaluationContext::PotentiallyEvaluated:
15957 case ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
15958 if (Statement && getCurFunctionOrMethodDecl()) {
15959 FunctionScopes.back()->PossiblyUnreachableDiags.
15969 if (
auto *VD = dyn_cast_or_null<VarDecl>(
15970 ExprEvalContexts.back().ManglingContextDecl)) {
15971 if (VD->isConstexpr() ||
15972 (VD->isStaticDataMember() && VD->isFirstDecl() && !VD->isInline()))
15992 if (ExprEvalContexts.back().ExprContext ==
15993 ExpressionEvaluationContextRecord::EK_Decltype) {
15994 ExprEvalContexts.back().DelayedDecltypeCalls.push_back(CE);
15998 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
16004 : FD(FD), CE(CE) { }
16008 S.
Diag(Loc, diag::err_call_incomplete_return)
16013 S.
Diag(Loc, diag::err_call_function_incomplete_return)
16018 } Diagnoser(FD, CE);
16020 if (RequireCompleteType(Loc, ReturnType, Diagnoser))
16031 unsigned diagnostic = diag::warn_condition_is_assignment;
16032 bool IsOrAssign =
false;
16035 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
16038 IsOrAssign = Op->getOpcode() == BO_OrAssign;
16042 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
16046 if (isSelfExpr(Op->getLHS()) && ME->getMethodFamily() ==
OMF_init)
16047 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16051 diagnostic = diag::warn_condition_is_idiomatic_assignment;
16054 Loc = Op->getOperatorLoc();
16056 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
16059 IsOrAssign = Op->getOperator() == OO_PipeEqual;
16060 Loc = Op->getOperatorLoc();
16062 return DiagnoseAssignmentAsCondition(POE->getSyntacticForm());
16072 Diag(Loc, diag::note_condition_assign_silence)
16077 Diag(Loc, diag::note_condition_or_assign_to_comparison)
16080 Diag(Loc, diag::note_condition_assign_to_comparison)
16098 if (opE->getOpcode() == BO_EQ &&
16099 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
16105 Diag(Loc, diag::note_equality_comparison_silence)
16108 Diag(Loc, diag::note_equality_comparison_to_assign)
16114 bool IsConstexpr) {
16115 DiagnoseAssignmentAsCondition(E);
16116 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
16117 DiagnoseEqualityWithExtraParens(parenE);
16119 ExprResult result = CheckPlaceholderExpr(E);
16124 if (getLangOpts().CPlusPlus)
16125 return CheckCXXBooleanCondition(E, IsConstexpr);
16127 ExprResult ERes = DefaultFunctionArrayLvalueConversion(E);
16134 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
16152 case ConditionKind::Boolean:
16153 Cond = CheckBooleanCondition(Loc, SubExpr);
16156 case ConditionKind::ConstexprIf:
16157 Cond = CheckBooleanCondition(Loc, SubExpr,
true);
16160 case ConditionKind::Switch:
16161 Cond = CheckSwitchCondition(Loc, SubExpr);
16165 return ConditionError();
16169 if (!FullExpr.
get())
16170 return ConditionError();
16173 CK == ConditionKind::ConstexprIf);
16179 struct RebuildUnknownAnyFunction
16180 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
16184 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
16187 llvm_unreachable(
"unexpected statement!");
16191 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
16198 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16199 ExprResult SubResult = Visit(E->getSubExpr());
16202 Expr *SubExpr = SubResult.
get();
16203 E->setSubExpr(SubExpr);
16204 E->setType(SubExpr->
getType());
16211 return rebuildSugarExpr(E);
16215 return rebuildSugarExpr(E);
16222 Expr *SubExpr = SubResult.
get();
16231 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
16236 if (S.getLangOpts().CPlusPlus &&
16237 !(isa<CXXMethodDecl>(VD) &&
16238 cast<CXXMethodDecl>(VD)->isInstance()))
16249 return resolveDecl(E, E->
getDecl());
16257 ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
16267 struct RebuildUnknownAnyExpr
16268 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
16276 : S(S), DestType(CastType) {}
16279 llvm_unreachable(
"unexpected statement!");
16283 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
16293 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
16294 ExprResult SubResult = Visit(E->getSubExpr());
16296 Expr *SubExpr = SubResult.
get();
16297 E->setSubExpr(SubExpr);
16298 E->setType(SubExpr->
getType());
16305 return rebuildSugarExpr(E);
16309 return rebuildSugarExpr(E);
16347 return resolveDecl(E, E->
getDecl());
16358 FK_FunctionPointer,
16365 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
16366 Kind = FK_MemberFunction;
16370 Kind = FK_FunctionPointer;
16373 Kind = FK_BlockPointer;
16378 if (DestType->isArrayType() || DestType->isFunctionType()) {
16379 unsigned diagID = diag::err_func_returning_array_function;
16380 if (Kind == FK_BlockPointer)
16381 diagID = diag::err_block_returning_array_function;
16384 << DestType->isFunctionType() << DestType;
16417 if (ParamTypes.empty() && Proto->isVariadic()) {
16419 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
16427 ArgTypes.push_back(ArgType);
16429 ParamTypes = ArgTypes;
16432 Proto->getExtProtoInfo());
16440 case FK_MemberFunction:
16444 case FK_FunctionPointer:
16448 case FK_BlockPointer:
16454 ExprResult CalleeResult = Visit(CalleeExpr);
16464 if (DestType->isArrayType() || DestType->isFunctionType()) {
16465 S.
Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
16466 << DestType->isFunctionType() << DestType;
16473 Method->setReturnType(DestType);
16477 E->
setType(DestType.getNonReferenceType());
16485 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
16492 DestType = DestType->castAs<
PointerType>()->getPointeeType();
16499 }
else if (E->
getCastKind() == CK_LValueToRValue) {
16503 assert(isa<BlockPointerType>(E->
getType()));
16516 llvm_unreachable(
"Unhandled cast type!");
16549 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
16552 FD->getDeclContext(),
16553 Loc, Loc, FD->getNameInfo().getName(),
16554 DestType, FD->getTypeSourceInfo(),
16556 FD->hasPrototype(),
16559 if (FD->getQualifier())
16563 for (
const auto &AI : FT->param_types()) {
16567 Params.push_back(Param);
16569 NewFD->setParams(Params);
16570 DRE->setDecl(NewFD);
16571 VD = DRE->getDecl();
16576 if (MD->isInstance()) {
16586 }
else if (isa<VarDecl>(VD)) {
16590 S.
Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
16618 diag::err_typecheck_cast_to_incomplete))
16622 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
16625 CastExpr = result.
get();
16627 CastKind = CK_NoOp;
16633 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
16642 ExprResult result = DefaultArgumentPromotion(arg);
16644 paramType = result.
get()->getType();
16656 return PerformCopyInitialization(entity, callLoc, arg);
16661 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
16664 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
16665 E = call->getCallee();
16666 diagID = diag::err_uncasted_call_of_unknown_any;
16674 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
16675 loc = ref->getLocation();
16676 d = ref->getDecl();
16677 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
16678 loc = mem->getMemberLoc();
16679 d = mem->getMemberDecl();
16681 diagID = diag::err_uncasted_call_of_unknown_any;
16682 loc = msg->getSelectorStartLoc();
16683 d = msg->getMethodDecl();
16685 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
16686 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
16709 ExprResult Result = CorrectDelayedTyposInExpr(E);
16715 if (!placeholderType)
return E;
16717 switch (placeholderType->
getKind()) {
16720 case BuiltinType::Overload: {
16724 if (ResolveAndFixSingleFunctionTemplateSpecialization(Result,
false))
16730 if (resolveAndFixAddressOfOnlyViableOverloadCandidate(Result))
16734 tryToRecoverWithCall(Result, PDiag(diag::err_ovl_unresolvable),
16740 case BuiltinType::BoundMember: {
16745 if (isa<CXXPseudoDestructorExpr>(BME)) {
16746 PD = PDiag(diag::err_dtor_expr_without_call) << 1;
16747 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
16748 if (ME->getMemberNameInfo().getName().getNameKind() ==
16750 PD = PDiag(diag::err_dtor_expr_without_call) << 0;
16752 tryToRecoverWithCall(result, PD,
16758 case BuiltinType::ARCUnbridgedCast: {
16759 Expr *realCast = stripARCUnbridgedCast(E);
16760 diagnoseARCUnbridgedCast(realCast);
16765 case BuiltinType::UnknownAny:
16769 case BuiltinType::PseudoObject:
16770 return checkPseudoObjectRValue(E);
16772 case BuiltinType::BuiltinFn: {
16776 auto *FD = cast<FunctionDecl>(DRE->getDecl());
16777 if (FD->getBuiltinID() == Builtin::BI__noop) {
16779 CK_BuiltinFnToFnPtr)
16791 case BuiltinType::OMPArraySection:
16796 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 16797 case BuiltinType::Id: 16798 #include "clang/Basic/OpenCLImageTypes.def" 16799 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 16800 case BuiltinType::Id: 16801 #include "clang/Basic/OpenCLExtensionTypes.def" 16802 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id: 16803 #define PLACEHOLDER_TYPE(Id, SingletonId) 16804 #include "clang/AST/BuiltinTypes.def" 16808 llvm_unreachable(
"invalid placeholder type!");
16822 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
16823 "Unknown Objective-C Boolean value!");
16828 if (LookupName(Result, getCurScope()) && Result.isSingleResult()) {
16836 return new (Context)
16844 StringRef Platform = getASTContext().getTargetInfo().getPlatformName();
16846 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
16848 return Spec.getPlatform() == Platform;
16851 VersionTuple Version;
16852 if (Spec != AvailSpecs.end())
16853 Version = Spec->getVersion();
16857 if (getCurFunctionOrMethodDecl())
16858 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
16859 else if (getCurBlock() || getCurLambda())
16860 getCurFunction()->HasPotentialAvailabilityViolations =
true;
16862 return new (Context)
Abstract class used to diagnose incomplete types.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
const Expr * getSubExpr() const
A call to an overloaded operator written using operator syntax.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
const BlockDecl * getBlockDecl() const
bool hasDefinition() const
Determine whether this class has been defined.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
QualType withConst() const
Retrieves a version of this type with const applied.
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
const CXXDestructorDecl * getDestructor() const
bool isClassMethod() const
static bool isOverflowingIntegerType(ASTContext &Ctx, QualType T)
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt)
Represents a function declaration or definition.
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
Expr ** getArgs()
Retrieve the call arguments.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
SourceRange getCorrectionRange() const
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
bool isSignedOverflowDefined() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
void setKind(UnqualifiedIdKind kind)
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
A class which contains all the information about a particular captured value.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType getPointeeType() const
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
A (possibly-)qualified type.
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
bool isBlockPointerType() const
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
Simple class containing the result of Sema::CorrectTypo.
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType)
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
SourceRange getExprRange(Expr *E) const
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
unsigned char getFixedPointScale(QualType Ty) const
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool hasCaptures() const
True if this block (or its nested blocks) captures anything of local storage from its enclosing scope...
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc, bool IsBuiltin)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
ObjCInterfaceDecl * getClassInterface()
bool isExternC() const
Determines whether this function is a function with external, C linkage.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
llvm::APSInt EvaluateKnownConstIntCheckOverflow(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Handle arithmetic conversion from integer to float.
llvm::APSInt getValue() const
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
bool isArithmeticType() const
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
NullabilityKind
Describes the nullability of a particular type.
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isRealFloatingType() const
Floating point categories.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
static bool IsReadonlyMessage(Expr *E, Sema &S)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Defines the SourceManager interface.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
void addConst()
Add the const type qualifier to this QualType.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Complex conversions (C99 6.3.1.6)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
bool isRecordType() const
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
bool isEmpty() const
No scope specifier.
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Decl - This represents one declaration (or definition), e.g.
static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD, const RecordType *Ty, SourceLocation Loc, SourceRange Range, OriginalExprKind OEK, bool &DiagnosticEmitted)
bool isVariadic() const
Whether this function prototype is variadic.
FunctionDecl * getOperatorNew() const
bool isExtVectorType() const
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
Defines the C++ template declaration subclasses.
This is a while, do, switch, for, etc that can have break statements embedded into it...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer...
Not a narrowing conversion.
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
bool isCopyCapture() const
ParenExpr - This represents a parethesized expression, e.g.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
bool CheckVecStepExpr(Expr *E)
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
CanQualType ARCUnbridgedCastTy
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
QualType getCorrespondingUnsignedType(QualType T) const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
SourceLocation getEndLoc() const LLVM_READONLY
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
bool isZero() const
isZero - Test whether the quantity equals zero.
QualType withConst() const
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
const TargetInfo & getTargetInfo() const
TemplateNameKind Kind
The kind of template that Template refers to.
QualType adjustStringLiteralBaseType(QualType StrLTy) const
A container of type source information.
QualType getCallResultType() const
Determine the type of an expression that calls this function.
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
Floating point control options.
constexpr XRayInstrMask Function
MS property subscript expression.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to...
Wrapper for source info for pointers decayed from arrays and functions.
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr *> Args)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
size_t param_size() const
bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Retains information about a function, method, or block that is currently being parsed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
This file provides some common utility functions for processing Lambda related AST Constructs...
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
void setRAngleLoc(SourceLocation Loc)
SourceLocation getBeginLoc() const LLVM_READONLY
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
DeclarationName getLookupName() const
Gets the name to look up.
Information about one declarator, including the parsed type information and the identifier.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
void removeObjCLifetime()
QualType getReturnType() const
CompoundLiteralExpr - [C99 6.5.2.5].
bool isParamConsumed(unsigned I) const
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
unsigned getNumParams() const
bool isEnumeralType() const
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
APFixedPoint getFixedPointMax(QualType Ty) const
const T * getAs() const
Member-template getAs<specific type>'.
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, const FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
DeclClass * getCorrectionDeclAs() const
static void checkEnumComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
If two different enums are compared, raise a warning.
static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Converts an integer to complex float type.
void ActOnStartStmtExpr()
bool isInvalidDecl() const
bool isOverloaded() const
static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind)
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
std::vector< FixItHint > Hints
The list of Hints generated so far.
Represents a parameter to a function.
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
Defines the clang::Expr interface and subclasses for C++ expressions.
tok::TokenKind getKind() const
bool isAdditiveOp() const
bool isEqualityOp() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
The collection of all-type qualifiers we support.
bool isVariableArrayType() const
tok::TokenKind ContextKind
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
LabelStmt - Represents a label, which has a substatement.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
Represents a struct/union/class.
static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType CondTy, SourceLocation QuestionLoc)
Convert scalar operands to a vector that matches the condition in length.
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
bool isOrdinaryOrBitFieldObject() const
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations. ...
static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx, QualType SrcType)
Returns true if conversion between vectors of halfs and vectors of floats is needed.
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
A vector component is an element or range of elements on a vector.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S)
Capture the given variable in the captured region.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
ArrayRef< QualType > getParamTypes() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
ObjCMethodFamily
A family of Objective-C methods.
Used for GCC's __alignof.
FullExpr - Represents a "full-expression" node.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
field_range fields() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
Represents a member of a struct/union/class.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
The current expression is potentially evaluated at run time, which means that code may be generated t...
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
Identity conversion (no conversion)
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Floating point conversions (C++ [conv.double].
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
void shrinkNumArgs(unsigned NewNumArgs)
Reduce the number of arguments in this call expression.
Token - This structure provides full information about a lexed token.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
void setKind(tok::TokenKind K)
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
LookupResultKind getResultKind() const
SourceLocation getBeginLoc() const LLVM_READONLY
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
bool isObjCQualifiedClassType() const
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
void PopExpressionEvaluationContext()
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isAssignmentOp() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool isInvalidType() const
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
Values of this type can be null.
bool isUnarySelector() const
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
The controlling scope in a if/switch/while/for statement.
DeclClass * getAsSingle() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
StringRef getOpcodeStr() const
SourceLocation getOpLoc() const
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
Describes an C or C++ initializer list.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter, check that it is non-null, and that if it is formed by array-to-pointer decay, the underlying array is sufficiently large.
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
bool isThisCapture() const
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
Expr * getInitExpr() const
Represents a C++ unqualified-id that has been parsed.
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
static QualType checkArithmeticOrEnumeralThreeWayCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
bool isBitField() const
Determines whether this field is a bitfield.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
unsigned getLength() const
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int, QualType FloatTy)
Test if a (constant) integer Int can be casted to floating point type FloatTy without losing precisio...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
FunctionDecl * getOperatorDelete() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
QualType getOriginalType() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool HasFormOfMemberPointer
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
static void DiagnoseDivisionSizeofPointer(Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc)
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasAddressSpace() const
LabelDecl * getDecl() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
This is a while, do, for, which can have continue statements embedded into it.
void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS)
Check for comparisons of floating point operands using != and ==.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
Whether values of this type can be null is (explicitly) unspecified.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
static void checkDirectCallValidity(Sema &S, const Expr *Fn, FunctionDecl *Callee, MultiExprArg ArgExprs)
SourceLocation getBeginLoc() const LLVM_READONLY
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static Expr * recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context, DeclarationNameInfo &NameInfo, SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs)
In Microsoft mode, if we are inside a template class whose parent class has dependent base classes...
QualType FunctionType
BlockType - The function type of the block, if one was given.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
CanQualType PseudoObjectTy
LangAS getAddressSpace() const
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
A narrowing conversion, because a constant expression got narrowed.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
Expr * getSizeExpr() const
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
StringKind
StringLiteral is followed by several trailing objects.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec)
Emit a warning for all pending noderef expressions that we recorded.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
bool isRelationalOp() const
Represents a C++ nested-name-specifier or a global scope specifier.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
Helper class for OffsetOfExpr.
The current expression occurs within a discarded statement.
Represents an Objective-C protocol declaration.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
bool isScalarType() const
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An ordinary object is located at an address in memory.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
Represents an ObjC class declaration.
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
QualType getReturnType() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
static bool enclosingClassIsRelatedToClassInWhichMembersWereFound(const UnresolvedMemberExpr *const UME, Sema &S)
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
QualType getBOOLType() const
type of 'BOOL' type.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
IdentifierInfo * getIdentifier() const
CanQualType UnsignedCharTy
A default argument (C++ [dcl.fct.default]).
void setStmt(LabelStmt *T)
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
const LangOptions & LangOpts
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
static void CheckForNullPointerDereference(Sema &S, Expr *E)
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
void ActOnStmtExprError()
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Qualifiers withoutObjCGCAttr() const
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, Expr *LHS, Expr *RHS)
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
DiagnosticsEngine & getDiagnostics() const
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas...
CXXSpecialMember
Kinds of C++ special members.
OverloadFixItKind Kind
The type of fix applied.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
OpenMP 4.0 [2.4, Array Sections].
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentKind IK)
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
static bool ExprLooksBoolean(Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
bool Mutable
Whether this is a mutable lambda.
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
static NamedDecl * getDeclFromExpr(Expr *E)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration...
Retains information about a captured region.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *SubExpr)
Look for bitwise op in the left or right hand of a bitwise op with lower precedence and emit a diagno...
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getLocalSourceRange() const
Get the local source range.
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr *> Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
static QualType checkConditionalVoidType(Sema &S, ExprResult &LHS, ExprResult &RHS)
Handle when one or both operands are void type.
DeclarationNameTable DeclarationNames
Specifies that the expression should never be value-dependent.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr *> Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
bool isObjCSelType(QualType T) const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
SourceLocation getLocation() const
SourceRange getRange() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
Represents a call to the builtin function __builtin_va_arg.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
A narrowing conversion by virtue of the source and destination types.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr *> Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
std::string getAsString(const LangOptions &LO) const
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
unsigned getValue() const
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition...
SourceLocation getBeginLoc() const
Get the begin source location.
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true)
Create a binary operation that may resolve to an overloaded operator.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
QualType getElementType() const
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Represents a character-granular source range.
static bool isEvaluatableContext(Sema &SemaRef)
Are we within a context in which some evaluation could be performed (be it constant evaluation or run...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
bool isVariadic() const
Whether this function is variadic.
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
ivar_iterator ivar_begin() const
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
static bool EvaluatesAsTrue(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'true'.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool isObjCBuiltinType() const
const T * castAs() const
Member-template castAs<specific type>.
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static bool captureInLambda(LambdaScopeInfo *LSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S)
Capture the given variable in the lambda.
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
static Expr * maybeRebuildARCConsumingStmt(Stmt *Statement)
Given the last statement in a statement-expression, check whether the result is a producing expressio...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Represents a C++ destructor within a class.
CanQualType OMPArraySectionTy
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
std::string getAsString() const
Retrieve the human-readable string for this name.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Defines the clang::Preprocessor interface.
bool isNullPtrType() const
bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
ObjCLifetime getObjCLifetime() const
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isObjCClassType() const
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
SourceLocation getBeginLoc() const
DeclContext * getDeclContext()
SourceLocation getLParenLoc() const
uint32_t getCodeUnit(size_t i) const
Overload resolution succeeded.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
bool isAnyComplexType() const
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
ObjCInterfaceDecl * getSuperClass() const
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
static ValueDecl * getCompareDecl(Expr *E)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
static void diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, ValueDecl *var, DeclContext *DC)
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
Floating-integral conversions (C++ [conv.fpint])
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
void DiscardCleanupsInEvaluationContext()
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isFunctionOrMethod() const
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
clang::ObjCRuntime ObjCRuntime
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr *> Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
void setAddressSpace(LangAS space)
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, IdentKind IK, StringLiteral *SL)
Create a PredefinedExpr.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr *> Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
VarDecl * isOpenMPCapturedDecl(ValueDecl *D)
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
An expression that sends a message to the given Objective-C object or class.
Data structure that captures multiple levels of template argument lists for use in template instantia...
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
Represents a GCC generic vector type.
ArraySizeModifier getSizeModifier() const
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
void CleanupVarDeclMarking()
const BuiltinType * getAsPlaceholderType() const
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
QualType getDestroyedType() const
Retrieve the type being destroyed.
const Expr * getSubExpr() const
const Expr * getSubExpr() const
unsigned short CapRegionKind
The kind of captured region.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
void setBlockMangling(unsigned Number, Decl *Ctx)
void removeCVRQualifiers(unsigned mask)
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level)
Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.) for FD based on DSA for the...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static std::pair< ExprResult, ExprResult > CorrectDelayedTyposInBinOp(Sema &S, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
SourceRange getSourceRange() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
SourceLocation getEndLoc() const LLVM_READONLY
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isUnresolvableResult() const
static CharSourceRange getCharRange(SourceRange R)
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
ExtInfo withNoReturn(bool noReturn) const
Lvalue-to-rvalue conversion (C++ [conv.lval])
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isVoidPointerType() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector...
bool isComparisonOp() const
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse)
static bool isBitwiseOp(Opcode Opc)
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
QualType getWideCharType() const
Return the type of wide characters.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
Wrapper for source info for arrays.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
Integral conversions (C++ [conv.integral])
SmallVectorImpl< OverloadCandidate >::iterator iterator
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
QualType getCanonicalType() const
bool CheckCaseExpression(Expr *E)
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
LookupInObjCMethod - The parser has read a name in, and Sema has detected that we're currently inside...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
param_type_range param_types() const
A stack object to be created when performing template instantiation.
ExtParameterInfo getExtParameterInfo(unsigned I) const
VarDecl * getVariable() const
ExtProtoInfo getExtProtoInfo() const
ASTContext & getASTContext() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result)
GetFloatValue - Convert this numeric literal to a floating value, using the specified APFloat fltSema...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
SourceLocation getOperatorLoc() const
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
LangAS getAddressSpace() const
Return the address space of this type.
This represents '#pragma omp declare reduction ...' directive.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Expression is not a Null pointer constant.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Expr * getSubExpr() const
Interfaces are the core concept in Objective-C for object oriented design.
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
CXXRecordDecl * Lambda
The class that describes the lambda.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
const ComplexType * getAsComplexIntegerType() const
CastKind getCastKind() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
SourceLocation getBeginLoc() const
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
void setLastStmt(Stmt *S)
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
DeclarationName getName() const
getName - Returns the embedded declaration name.
static ConstantExpr * Create(const ASTContext &Context, Expr *E)
static bool IgnoreCommaOperand(const Expr *E)
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
QualType getElementType() const
void setReferenced(bool R=true)
Represents the declaration of a label.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
bool isOverloadedResult() const
Determines if the results are overloaded.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static ExprResult convertVector(Expr *E, QualType ElementType, Sema &S)
Convert vector E to a vector with the same number of elements but different element type...
void setIdentifierInfo(IdentifierInfo *II)
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ExprResult TransformToPotentiallyEvaluated(Expr *E)
static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl)
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)
Check conversion of given expression to boolean.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Expr * getExpr(unsigned Init)
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
Describes the kind of initialization being performed, along with location information for tokens rela...
bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const
Return true if the provided declaration VD should be captured by reference.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
const TemplateArgumentListInfo & getTemplateArgsInfo() const
SourceLocation getBeginLoc() const LLVM_READONLY
Qualifiers withoutObjCLifetime() const
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
is AltiVec 'vector bool ...'
SmallVector< Capture, 4 > Captures
Captures - The captures.
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Represents one property declaration in an Objective-C interface.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
bool hasUninstantiatedDefaultArg() const
virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap.
void addPotentialThisCapture(SourceLocation Loc)
TypeClass getTypeClass() const
Used for C's _Alignof and C++'s alignof.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
EnumDecl * getDecl() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
Complex-real conversions (C99 6.3.1.7)
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
unsigned getFullDataSize() const
Returns the size of the type source info data block.
CXXRecordDecl * getNamingClass()
Retrieve the naming class of this lookup.
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
void setLAngleLoc(SourceLocation Loc)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addArgument(const TemplateArgumentLoc &Loc)
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
FunctionDecl * getOperatorDelete() const
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
Defines the fixed point number interface.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
static ExprResult convertHalfVecBinOp(Sema &S, ExprResult LHS, ExprResult RHS, BinaryOperatorKind Opc, QualType ResultTy, ExprValueKind VK, ExprObjectKind OK, bool IsCompAssign, SourceLocation OpLoc, FPOptions FPFeatures)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
CompoundAssignOperator - For compound assignments (e.g.
A POD class for pairing a NamedDecl* with an access specifier.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
Represents a C11 generic selection.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Represents an element in a path from a derived class to a base class.
AddrLabelExpr - The GNU address of label extension, representing &&label.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Represents a template argument.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
static bool isInvalid(LocType Loc, bool *Invalid)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union...
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Dataflow Directional Tag Classes.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
bool isValid() const
Return true if this is a valid SourceLocation object.
ExtInfo getExtInfo() const
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
static bool isScopedEnumerationType(QualType T)
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
EvalResult is a struct with detailed info about an evaluated expression.
const DeclContext * getCurObjCLexicalContext() const
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
ArrayRef< Capture > captures() const
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
QualType GetSignedVectorType(QualType V)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
typedef char* __builtin_va_list;
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128 and long double if there is no support for such conve...
QualType getType() const
Get the type for which this source info wrapper provides information.
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
static bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context)
Represents a field injected from an anonymous union/struct into the parent scope. ...
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy, unsigned &DiagID)
Try to convert a value of non-vector type to a vector type by converting the type to the element type...
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS, BinaryOperatorKind Opc)
Diagnose some forms of syntactically-obvious tautological comparison.
const Expr * getInit() const
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
SourceLocation getEndLoc() const LLVM_READONLY
A runtime availability query.
Array-to-pointer conversion (C++ [conv.array])
This template specialization was instantiated from a template due to an explicit instantiation declar...
static bool ShouldLookupResultBeMultiVersionOverload(const LookupResult &R)
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured...
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
The name of a declaration.
StmtClass getStmtClass() const
VectorKind getVectorKind() const
const char * getCastKindName() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
const Expr * getExpr() const
bool isBooleanType() const
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type...
OverloadExpr * Expression
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
U cast(CodeGen::Address addr)
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
A set of unresolved declarations.
bool isConstantEvaluated() const
virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR)=0
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Expression is a C++11 nullptr.
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
unsigned short OpenMPLevel
ExplicitCastExpr - An explicit cast written in the source code.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
ExprResult ActOnConstantExpression(ExprResult Res)
unsigned getLength() const
IdentifierInfo * getCorrectionAsIdentifierInfo() const
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr *> Args, SmallVectorImpl< Expr *> &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> Types, ArrayRef< Expr *> Exprs)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored, perform any conversions that are required.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
CanQualType ObjCBuiltinBoolTy
The standard open() call: int open(const char *path, int oflag, ...);.
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
static bool EvaluatesAsFalse(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'false'.
SourceLocation getBeginLoc() const
unsigned getIntWidth(QualType T) const
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
Not an overloaded operator.
RecordDecl * TheRecordDecl
The captured record type.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
Expr * getUninstantiatedDefaultArg()
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Return the resulting type for the conditional operator in OpenCL (aka "ternary selection operator"...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
CanQualType UnsignedLongTy
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
SourceLocation getLocation() const
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
const llvm::APInt & getSize() const
uint64_t getCharWidth() const
Return the size of the character type, in bits.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
bool isAtomicType() const
static bool checkThreeWayNarrowingConversion(Sema &S, QualType ToType, Expr *E, QualType FromType, SourceLocation Loc)
bool isFunctionType() const
bool isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one.
bool isObjCQualifiedIdType() const
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
TypeSourceInfo * getTypeSourceInfo() const
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix)
CheckIncrementDecrementOperand - unlike most "Check" methods, this routine doesn't need to call Usual...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D)
Diagnoses obvious problems with the use of the given declaration as an expression.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
bool isUnevaluated() const
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
const Expr * getBase() const
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
bool isConstantArrayType() const
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
A bitfield object is a bitfield on a C or C++ record.
static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar, ExprResult *Vector)
Attempt to convert and splat Scalar into a vector whose types matches Vector following GCC conversion...
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
This is a scope that can contain a declaration.
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
QualType withCVRQualifiers(unsigned CVR) const
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
Reading or writing from this object requires a barrier call.
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
ArgKind getKind() const
Return the kind of stored template argument.
An attributed type is a type to which a type attribute has been applied.
QualType getParamType(unsigned i) const
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
Expression is a Null pointer constant built from a literal zero.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E)
Function-to-pointer (C++ [conv.array])
TranslationUnitDecl * getTranslationUnitDecl() const
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr *> ArgExprs)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Data structure used to record current or nested expression evaluation contexts.
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
TypedefNameDecl * getTypedefNameForAnonDecl() const
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
void setDefaultArg(Expr *defarg)
static bool isObjCObjectLiteral(ExprResult &E)
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
void markUsed(bool IsODRUse)
sema::FunctionScopeInfo * getCurFunction() const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
SourceLocation getBeginLoc() const LLVM_READONLY
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
SourceLocation getRParenLoc() const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ObjCIvarDecl - Represents an ObjC instance variable.
bool isMultiplicativeOp() const
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type...
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
Builtin::Context & BuiltinInfo
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool isCXXThisCaptured() const
Determine whether the C++ 'this' is captured.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
SourceManager & getSourceManager() const
A template-id, e.g., f<int>.
void setParameterCFAudited()
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
bool isComplexIntegerType() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static ImplicitConversionKind castKindToImplicitConversionKind(CastKind CK)
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static CUDAKernelCallExpr * Create(const ASTContext &Ctx, Expr *Fn, CallExpr *Config, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
void UpdateMarkingForLValueToRValue(Expr *E)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber...
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S)
unsigned getNumElements() const
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The name refers to a variable template whose specialization produces a variable.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static void tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(Sema &S, const UnresolvedMemberExpr *const UME, SourceLocation CallLoc)
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
The class facilities generation and storage of conversion FixIts.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
bool isDeleted() const
Whether this function has been deleted.
bool isPointerType() const
bool isIncrementDecrementOp() const
static bool isOdrUseContext(Sema &SemaRef, bool SkipDependentUses=true)
Are we within a context in which references to resolved functions or to variables result in odr-use...
void setSubStmt(Stmt *SS)
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e.g.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
DeclaratorContext getContext() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void setLocation(SourceLocation L)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
bool isFloatingType() const
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
void setAccess(AccessSpecifier AS)
Represents a C array with a specified size that is not an integer-constant-expression.
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
No keyword precedes the qualified type name.
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
AccessControl getAccessControl() const
SourceLocation getNameLoc() const
Gets the location of the identifier.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
bool isFunctionPointerType() const
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
unsigned NumArgs
NumArgs - The number of template arguments.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr *> Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
void setToType(unsigned Idx, QualType T)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr *> Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
void removeAddressSpace()
static bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
SourceLocation getBegin() const
SourceLocation ColonLoc
Location of ':'.
const LangOptions & getLangOpts() const
void WillReplaceSpecifier(bool ForceReplacement)
bool isBlockCapture() const
An implicit 'self' parameter.
The lookup resulted in an error.
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
Represents the canonical version of C arrays with a specified constant size.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
Declaration of a template function.
SourceLocation getBeginLoc() const LLVM_READONLY
A class which abstracts out some details necessary for making a call.
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
The current expression occurs within a braced-init-list within an unevaluated operand.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
One specifier in an expression.
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
void startToken()
Reset all flags to cleared.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
bool isExternallyVisible() const
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
QualType getType() const
Return the type wrapped by this type source info.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
ArrayRef< ParmVarDecl * > parameters() const
static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc, Expr *Pointer, bool IsGNUIdiom)
Diagnose invalid arithmetic on a null pointer.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
Helper class that creates diagnostics with optional template instantiation stacks.
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CanQualType UnsignedIntTy
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
Structure used to store a statement, the constant value to which it was evaluated (if any)...
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)