46 #include "llvm/Support/ConvertUTF.h"
47 using namespace clang;
54 if (ParsingInitForAutoVars.count(D))
64 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
81 if (DC && !DC->
hasAttr<UnusedAttr>())
96 Cat->getMethod(OMD->getSelector(), OMD->isInstanceMethod()))
97 if (!CatMeth->hasAttr<AvailabilityAttr>())
105 bool ObjCPropertyAccess) {
125 if (IDecl->getDefinition()) {
126 D = IDecl->getDefinition();
134 if (
const EnumDecl *TheEnumDecl = dyn_cast<EnumDecl>(DC))
135 Result = TheEnumDecl->getAvailability(&Message);
144 if (PDeclResult == Result)
157 D, Message, Loc, UnknownObjCClass, ObjCPDecl,
163 if (isa<EnumConstantDecl>(D) || isa<EnumDecl>(D))
166 bool Warn = !D->
getAttr<AvailabilityAttr>()->isInherited();
175 if (Warn && isa<ObjCInterfaceDecl>(D))
178 if (!Redecl->hasAttr<AvailabilityAttr>() ||
179 Redecl->getAttr<AvailabilityAttr>()->isInherited())
184 UnknownObjCClass, ObjCPDecl,
192 D, Message, Loc, UnknownObjCClass, ObjCPDecl,
206 if (Method && Method->isDeleted() && Method->isDefaulted()) {
208 if (!Method->isImplicit())
214 if (CSM != CXXInvalid)
215 ShouldDeleteSpecialMember(Method, CSM,
true);
222 const_cast<CXXConstructorDecl*>(CD->getInheritedConstructor())) {
224 if (BaseCD->isDeleted()) {
225 NoteDeletedFunction(BaseCD);
229 Diag(BaseCD->getLocation(), diag::note_cannot_inherit);
243 if (
I->getStorageClass() !=
SC_None)
288 if (!DowngradeWarning && UsedFn)
291 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
292 : diag::ext_internal_in_extern_inline)
297 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
307 Diag(DeclBegin, diag::note_convert_inline_to_static)
326 bool ObjCPropertyAccess) {
327 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
331 if (Pos != SuppressedDiagnostics.end()) {
333 Diag(Suppressed.first, Suppressed.second);
344 if (cast<FunctionDecl>(D)->isMain())
345 Diag(Loc, diag::ext_main_used);
349 if (ParsingInitForAutoVars.count(D)) {
352 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
359 if (FD->isDeleted()) {
360 Diag(Loc, diag::err_deleted_function_use);
361 NoteDeletedFunction(FD);
367 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
368 DeduceReturnType(FD, Loc))
387 return ": " + Message;
389 return std::string();
398 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
403 unsigned numFormalParams;
407 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
410 numFormalParams = MD->param_size();
411 calleeType = CT_Method;
412 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
413 numFormalParams = FD->param_size();
414 calleeType = CT_Function;
415 }
else if (isa<VarDecl>(D)) {
421 calleeType = CT_Function;
424 calleeType = CT_Block;
430 numFormalParams = proto->getNumParams();
442 unsigned nullPos = attr->getNullPos();
443 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
444 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
447 unsigned numArgsAfterSentinel = attr->getSentinel();
451 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
458 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
459 if (!sentinelExpr)
return;
468 = getLocForEndOfToken(sentinelExpr->getLocEnd());
469 std::string NullValue;
470 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
472 else if (getLangOpts().CPlusPlus11)
473 NullValue =
"nullptr";
474 else if (PP.isMacroDefined(
"NULL"))
477 NullValue =
"(void*) 0";
480 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
482 Diag(MissingNilLoc, diag::warn_missing_sentinel)
506 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
511 if (getLangOpts().OpenCL) {
518 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
536 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
551 UO->getSubExpr()->IgnoreParenCasts()->
553 !UO->getType().isVolatileQualified()) {
555 S.
PDiag(diag::warn_indirection_through_null)
556 << UO->getSubExpr()->getSourceRange());
558 S.
PDiag(diag::note_indirection_through_null));
571 if (!Member || !Member->
isStr(
"isa"))
581 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
589 if (ObjectSetClass) {
632 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
636 if (getLangOpts().CPlusPlus &&
651 if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16 &&
660 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
667 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
692 UpdateMarkingForLValueToRValue(E);
696 if (getLangOpts().ObjCAutoRefCount &&
698 ExprNeedsCleanups =
true;
707 T = Atomic->getValueType().getUnqualifiedType();
716 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
719 Res = DefaultLvalueConversion(Res.
get());
738 Res = DefaultLvalueConversion(Res.
get());
751 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
757 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
760 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
800 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
810 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
811 BTy->
getKind() == BuiltinType::Float))
868 if (!Record->hasNonTrivialCopyConstructor() &&
869 !Record->hasNonTrivialMoveConstructor() &&
870 !Record->hasNonTrivialDestructor())
871 return VAK_ValidInCXX11;
879 if (getLangOpts().MSVCCompat)
880 return VAK_MSVCUndefined;
884 return VAK_Undefined;
894 case VAK_ValidInCXX11:
896 E->getLocStart(),
nullptr,
897 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
904 DiagRuntimeBehavior(E->getLocStart(),
nullptr,
905 PDiag(diag::warn_pass_class_arg_to_vararg)
906 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
911 case VAK_MSVCUndefined:
913 E->getLocStart(),
nullptr,
914 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
915 << getLangOpts().CPlusPlus11 << Ty << CT);
921 E->getLocStart(),
nullptr,
922 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
925 Diag(E->getLocStart(), diag::err_cannot_pass_to_vararg)
926 << isa<InitListExpr>(E) << Ty << CT;
937 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
938 (CT == VariadicMethod ||
939 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
940 E = stripARCUnbridgedCast(E);
951 ExprResult ExprRes = DefaultArgumentPromotion(E);
958 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
965 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
971 E->getLocStart(),
None,
985 diag::err_call_incomplete_argument))
1002 if (SkipCast)
return false;
1021 bool IsCompAssign) {
1044 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
1045 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
1047 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
1049 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1055 if (!IsCompAssign) {
1062 }
else if (Order > 0) {
1077 bool ConvertFloat,
bool ConvertInt) {
1107 QualType RHSType,
bool IsCompAssign) {
1113 if (LHSFloat && RHSFloat) {
1120 assert(order < 0 &&
"illegal float comparison");
1158 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1161 QualType RHSType,
bool IsCompAssign) {
1166 if (LHSSigned == RHSSigned) {
1169 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1171 }
else if (!IsCompAssign)
1172 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1174 }
else if (order != (LHSSigned ? 1 : -1)) {
1178 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1180 }
else if (!IsCompAssign)
1181 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1188 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1190 }
else if (!IsCompAssign)
1191 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1200 RHS = (*doRHSCast)(
S, RHS.
get(), result);
1202 LHS = (*doLHSCast)(
S, LHS.
get(), result);
1212 bool IsCompAssign) {
1216 if (LHSComplexInt && RHSComplexInt) {
1220 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1221 (
S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1223 return S.Context.getComplexType(ScalarType);
1226 if (LHSComplexInt) {
1229 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1230 (
S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1232 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1238 assert(RHSComplexInt);
1242 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1243 (
S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1247 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1257 bool IsCompAssign) {
1258 if (!IsCompAssign) {
1259 LHS = UsualUnaryConversions(LHS.
get());
1264 RHS = UsualUnaryConversions(RHS.
get());
1277 LHSType = AtomicLHS->getValueType();
1280 if (LHSType == RHSType)
1289 QualType LHSUnpromotedType = LHSType;
1293 if (!LHSBitfieldPromoteTy.
isNull())
1294 LHSType = LHSBitfieldPromoteTy;
1295 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1299 if (LHSType == RHSType)
1320 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1321 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1334 Expr *ControllingExpr,
1337 unsigned NumAssocs = ArgTypes.size();
1338 assert(NumAssocs == ArgExprs.size());
1341 for (
unsigned i = 0; i < NumAssocs; ++i) {
1343 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1348 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1350 llvm::makeArrayRef(Types, NumAssocs),
1360 Expr *ControllingExpr,
1363 unsigned NumAssocs = Types.size();
1364 assert(NumAssocs == Exprs.size());
1370 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1373 ControllingExpr = R.
get();
1378 if (ActiveTemplateInstantiations.empty() &&
1381 diag::warn_side_effects_unevaluated_context);
1383 bool TypeErrorFound =
false,
1385 ContainsUnexpandedParameterPack
1388 for (
unsigned i = 0; i < NumAssocs; ++i) {
1389 if (Exprs[i]->containsUnexpandedParameterPack())
1390 ContainsUnexpandedParameterPack =
true;
1393 if (Types[i]->getType()->containsUnexpandedParameterPack())
1394 ContainsUnexpandedParameterPack =
true;
1396 if (Types[i]->getType()->isDependentType()) {
1397 IsResultDependent =
true;
1402 if (Types[i]->getType()->isIncompleteType())
1403 D = diag::err_assoc_type_incomplete;
1404 else if (!Types[i]->getType()->isObjectType())
1405 D = diag::err_assoc_type_nonobject;
1406 else if (Types[i]->getType()->isVariablyModifiedType())
1407 D = diag::err_assoc_type_variably_modified;
1410 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1411 << Types[i]->getTypeLoc().getSourceRange()
1412 << Types[i]->getType();
1413 TypeErrorFound =
true;
1418 for (
unsigned j = i+1; j < NumAssocs; ++j)
1419 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1421 Types[j]->getType())) {
1422 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1423 diag::err_assoc_compatible_types)
1424 << Types[j]->getTypeLoc().getSourceRange()
1425 << Types[j]->getType()
1426 << Types[i]->getType();
1427 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1428 diag::note_compat_assoc)
1429 << Types[i]->getTypeLoc().getSourceRange()
1430 << Types[i]->getType();
1431 TypeErrorFound =
true;
1441 if (IsResultDependent)
1443 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1444 ContainsUnexpandedParameterPack);
1447 unsigned DefaultIndex = -1U;
1448 for (
unsigned i = 0; i < NumAssocs; ++i) {
1452 Types[i]->getType()))
1453 CompatIndices.push_back(i);
1459 if (CompatIndices.size() > 1) {
1463 Diag(ControllingExpr->getLocStart(), diag::err_generic_sel_multi_match)
1464 << ControllingExpr->getSourceRange() << ControllingExpr->
getType()
1465 << (
unsigned) CompatIndices.size();
1466 for (
unsigned I : CompatIndices) {
1467 Diag(Types[
I]->getTypeLoc().getBeginLoc(),
1468 diag::note_compat_assoc)
1469 << Types[
I]->getTypeLoc().getSourceRange()
1470 << Types[
I]->getType();
1478 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1482 Diag(ControllingExpr->getLocStart(), diag::err_generic_sel_no_match)
1483 << ControllingExpr->getSourceRange() << ControllingExpr->
getType();
1492 unsigned ResultIndex =
1493 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1496 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1497 ContainsUnexpandedParameterPack, ResultIndex);
1515 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1518 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1519 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1520 if (ArgTy[ArgIdx]->isArrayType())
1546 assert(!StringToks.empty() &&
"Must have at least one string!");
1549 if (Literal.hadError)
1553 for (
const Token &Tok : StringToks)
1554 StringTokLocs.push_back(Tok.getLocation());
1558 if (Literal.isWide()) {
1561 }
else if (Literal.isUTF8()) {
1563 }
else if (Literal.isUTF16()) {
1566 }
else if (Literal.isUTF32()) {
1569 }
else if (Literal.isPascal()) {
1575 if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
1582 llvm::APInt(32, Literal.GetNumStringChars()+1),
1586 if (getLangOpts().OpenCL) {
1592 Kind, Literal.Pascal, StrTy,
1594 StringTokLocs.size());
1595 if (Literal.getUDSuffix().empty())
1602 Literal.getUDSuffixOffset());
1606 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1621 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1622 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1630 Expr *Args[] = { Lit, LenArg };
1632 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1635 case LOLR_StringTemplate: {
1640 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1646 for (
unsigned I = 0, N = Lit->
getLength();
I != N; ++
I) {
1652 return BuildLiteralOperatorCall(R, OpNameInfo,
None, StringTokLocs.back(),
1657 llvm_unreachable(
"unexpected literal operator lookup result");
1661 llvm_unreachable(
"unexpected literal operator lookup result");
1669 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1679 if (getLangOpts().CUDA)
1680 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
1681 if (
const FunctionDecl *Callee = dyn_cast<FunctionDecl>(D)) {
1682 if (CheckCUDATarget(Caller, Callee)) {
1683 Diag(NameInfo.
getLoc(), diag::err_ref_bad_target)
1685 << IdentifyCUDATarget(Caller);
1692 bool RefersToCapturedVariable =
1694 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1697 if (isa<VarTemplateSpecializationDecl>(D)) {
1699 cast<VarTemplateSpecializationDecl>(D);
1704 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1705 FoundD, TemplateArgs);
1707 assert(!TemplateArgs &&
"No template arguments for non-variable"
1708 " template specialization references");
1712 NameInfo, Ty, VK, FoundD);
1715 MarkDeclRefReferenced(E);
1717 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1719 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
1720 recordUseOfEvaluatedWeak(E);
1750 translateTemplateArguments(TemplateArgsPtr, Buffer);
1757 NameInfo = GetNameFromUnqualifiedId(Id);
1758 TemplateArgs =
nullptr;
1765 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1772 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1775 SemaRef.
Diag(TypoLoc, DiagnosticID) <<
Typo;
1780 bool DroppedSpecifier =
1783 ? diag::note_implicit_param_decl
1784 : diag::note_previous_decl;
1787 SemaRef.
PDiag(NoteID));
1790 << Typo << Ctx << DroppedSpecifier
1792 SemaRef.
PDiag(NoteID));
1800 std::unique_ptr<CorrectionCandidateCallback> CCC,
1805 unsigned diagnostic = diag::err_undeclared_var_use;
1806 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1810 diagnostic = diag::err_undeclared_use;
1811 diagnostic_suggest = diag::err_undeclared_use_suggest;
1820 if (isa<CXXRecordDecl>(DC)) {
1821 LookupQualifiedName(R, DC);
1830 bool isDefaultArgument = !ActiveTemplateInstantiations.empty() &&
1831 ActiveTemplateInstantiations.back().Kind ==
1832 ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation;
1834 bool isInstance = CurMethod &&
1836 DC == CurMethod->
getParent() && !isDefaultArgument;
1841 if (getLangOpts().MSVCCompat)
1842 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1853 Diag(D->getLocation(), diag::note_dependent_var_use);
1859 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1860 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1875 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1876 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1887 assert(!ExplicitTemplateArgs &&
1888 "Diagnosing an empty lookup with explicit template args!");
1889 *Out = CorrectTypoDelayed(
1893 diagnostic, diagnostic_suggest);
1895 nullptr, CTK_ErrorRecovery);
1898 }
else if (S && (Corrected =
1900 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1901 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1902 bool DroppedSpecifier =
1906 bool AcceptableWithRecovery =
false;
1907 bool AcceptableWithoutRecovery =
false;
1916 dyn_cast<FunctionTemplateDecl>(CD))
1917 AddTemplateOverloadCandidate(
1920 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1921 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1925 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1927 ND = Best->FoundDecl;
1928 Corrected.setCorrectionDecl(ND);
1932 Corrected.setCorrectionDecl(ND);
1944 Record = cast<CXXRecordDecl>(
1950 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
1951 isa<FunctionTemplateDecl>(UnderlyingND);
1957 AcceptableWithoutRecovery =
1958 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
1962 AcceptableWithoutRecovery =
true;
1965 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
1967 ? diag::note_implicit_param_decl
1968 : diag::note_previous_decl;
1970 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) <<
Name,
1971 PDiag(NoteID), AcceptableWithRecovery);
1973 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
1974 << Name << computeDeclContext(SS,
false)
1975 << DroppedSpecifier << SS.getRange(),
1976 PDiag(NoteID), AcceptableWithRecovery);
1979 return !AcceptableWithRecovery;
1986 if (!SS.isEmpty()) {
1988 << Name << computeDeclContext(SS,
false)
2015 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2023 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2024 DB << NameInfo.
getName() << RD;
2026 if (!ThisType.
isNull()) {
2029 Context,
nullptr, ThisType,
true,
2031 nullptr, NameInfo, TemplateArgs);
2048 bool HasTrailingLParen,
bool IsAddressOfOperand,
2049 std::unique_ptr<CorrectionCandidateCallback> CCC,
2050 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2051 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2052 "cannot be direct & operand and have a trailing lparen");
2061 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2078 bool DependentID =
false;
2082 }
else if (SS.
isSet()) {
2083 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2084 if (RequireCompleteDeclContext(SS, DC))
2092 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2093 IsAddressOfOperand, TemplateArgs);
2098 ? LookupObjCImplicitSelfParam : LookupOrdinaryName);
2105 bool MemberOfUnknownSpecialization;
2106 LookupTemplateName(R, S, SS,
QualType(),
false,
2107 MemberOfUnknownSpecialization);
2109 if (MemberOfUnknownSpecialization ||
2111 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2112 IsAddressOfOperand, TemplateArgs);
2114 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2115 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2120 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2121 IsAddressOfOperand, TemplateArgs);
2125 if (IvarLookupFollowUp) {
2140 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2141 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2147 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2149 if (R.
empty() && !ADL) {
2150 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2152 TemplateKWLoc, TemplateArgs))
2157 if (IsInlineAsmIdentifier)
2163 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2165 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2166 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2167 "Typo correction callback misconfigured");
2170 CCC->setTypoName(II);
2174 if (DiagnoseEmptyLookup(S, SS, R,
2175 CCC ? std::move(CCC) : std::move(DefaultValidator),
2176 nullptr,
None, &TE)) {
2177 if (TE && KeywordReplacement) {
2178 auto &
State = getTypoExprState(TE);
2179 auto BestTC =
State.Consumer->getNextCorrection();
2180 if (BestTC.isKeyword()) {
2181 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2182 if (
State.DiagHandler)
2183 State.DiagHandler(BestTC);
2185 KeywordReplacement->
setKind(II->getTokenID());
2187 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2190 clearDelayedTypo(TE);
2193 return (
Expr*)
nullptr;
2195 State.Consumer->resetCorrectionStream();
2200 assert(!R.
empty() &&
2201 "DiagnoseEmptyLookup returned false but added no results");
2208 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2218 assert(!R.
empty() || ADL);
2244 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2245 bool MightBeImplicitMember;
2246 if (!IsAddressOfOperand)
2247 MightBeImplicitMember =
true;
2249 MightBeImplicitMember =
false;
2251 MightBeImplicitMember =
false;
2253 MightBeImplicitMember =
true;
2255 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2259 if (MightBeImplicitMember)
2260 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2261 R, TemplateArgs, S);
2264 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2272 "There should only be one declaration found.");
2275 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2278 return BuildDeclarationNameExpr(SS, R, ADL);
2293 if (RequireCompleteDeclContext(SS, DC))
2297 LookupQualifiedName(R, DC);
2316 unsigned DiagID = diag::err_typename_missing;
2317 if (RecoveryTSI && getLangOpts().MSVCCompat)
2318 DiagID = diag::ext_typename_missing;
2320 auto D =
Diag(Loc, DiagID);
2351 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2352 return BuildPossibleImplicitMemberExpr(SS,
2356 return BuildDeclarationNameExpr(SS, R,
false);
2390 LookForIvars =
true;
2391 else if (IsClassMethod)
2392 LookForIvars =
false;
2404 return ExprError(
Diag(Loc, diag::error_ivar_use_in_class_method)
2413 if (DiagnoseUseOfDecl(IV, Loc))
2419 !getLangOpts().DebuggerSupport)
2430 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2431 SelfName,
false,
false);
2435 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2439 MarkAnyDeclReferenced(Loc, IV,
true);
2443 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2450 if (getLangOpts().ObjCAutoRefCount) {
2452 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2453 recordUseOfEvaluatedWeak(Result);
2455 if (CurContext->isClosure())
2456 Diag(Loc, diag::warn_implicitly_retains_self)
2469 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2476 return ExprError(
Diag(Loc, diag::error_ivar_use_in_class_method)
2477 << IV->getDeclName());
2480 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2526 bool PointerConversions =
false;
2527 if (isa<FieldDecl>(Member)) {
2533 PointerConversions =
true;
2535 DestType = DestRecordType;
2536 FromRecordType = FromType;
2538 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2539 if (Method->isStatic())
2542 DestType = Method->getThisType(
Context);
2547 PointerConversions =
true;
2549 FromRecordType = FromType;
2550 DestType = DestRecordType;
2587 if (Qualifier && Qualifier->
getAsType()) {
2589 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2596 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2598 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2599 FromLoc, FromRange, &BasePath))
2602 if (PointerConversions)
2605 VK, &BasePath).get();
2608 FromRecordType = QRecordType;
2617 bool IgnoreAccess =
false;
2625 assert(isa<UsingShadowDecl>(FoundDecl));
2632 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2634 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2635 FromLoc, FromRange, &BasePath))
2639 if (PointerConversions)
2642 VK, &BasePath).get();
2644 FromRecordType = URecordType;
2649 IgnoreAccess =
true;
2653 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2654 FromLoc, FromRange, &BasePath,
2664 bool HasTrailingLParen) {
2666 if (!HasTrailingLParen)
2674 if (!getLangOpts().CPlusPlus)
2684 if (D->isCXXClassMember())
2693 if (isa<UsingShadowDecl>(D))
2694 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2695 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2702 if (isa<FunctionDecl>(D)) {
2708 }
else if (!isa<FunctionTemplateDecl>(D))
2721 if (isa<TypedefNameDecl>(D)) {
2726 if (isa<ObjCInterfaceDecl>(D)) {
2731 if (isa<NamespaceDecl>(D)) {
2741 bool AcceptInvalidDecl) {
2775 bool AcceptInvalidDecl) {
2776 assert(D &&
"Cannot refer to a NULL declaration");
2777 assert(!isa<FunctionTemplateDecl>(D) &&
2778 "Cannot refer unambiguously to a function template");
2784 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2787 Diag(Loc, diag::err_template_decl_ref) << (isa<VarTemplateDecl>(D) ? 1 : 0)
2789 Diag(Template->getLocation(), diag::note_template_decl_here);
2796 Diag(Loc, diag::err_ref_non_value)
2806 if (DiagnoseUseOfDecl(VD, Loc))
2817 if (!indirectField->isCXXClassMember())
2818 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2827 #define ABSTRACT_DECL(kind)
2828 #define VALUE(type, base)
2829 #define DECL(type, base) \
2831 #include "clang/AST/DeclNodes.inc"
2832 llvm_unreachable(
"invalid value decl kind");
2835 case Decl::ObjCAtDefsField:
2836 case Decl::ObjCIvar:
2837 llvm_unreachable(
"forming non-member reference to ivar?");
2841 case Decl::EnumConstant:
2842 case Decl::UnresolvedUsingValue:
2851 case Decl::IndirectField:
2853 "building reference to field in C?");
2863 case Decl::NonTypeTemplateParm: {
2878 case Decl::VarTemplateSpecialization:
2879 case Decl::VarTemplatePartialSpecialization:
2889 case Decl::ImplicitParam:
2890 case Decl::ParmVar: {
2898 if (!isUnevaluatedContext()) {
2899 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2900 if (!CapturedType.
isNull())
2901 type = CapturedType;
2907 case Decl::Function: {
2908 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
2927 if (getLangOpts().CPlusPlus) {
2937 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
2938 isa<FunctionProtoType>(fty))
2947 case Decl::MSProperty:
2951 case Decl::CXXMethod:
2956 = dyn_cast<FunctionProtoType>(VD->
getType()))
2964 if (cast<CXXMethodDecl>(VD)->isStatic()) {
2970 case Decl::CXXConversion:
2971 case Decl::CXXDestructor:
2972 case Decl::CXXConstructor:
2977 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
2984 Target.resize(CharByteWidth * (Source.size() + 1));
2985 char *ResultPtr = &Target[0];
2986 const UTF8 *ErrorPtr;
2987 bool success = ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
2990 Target.resize(ResultPtr - &Target[0]);
2996 Decl *currentDecl =
nullptr;
2998 currentDecl = BSI->TheDecl;
3000 currentDecl = LSI->CallOperator;
3002 currentDecl = CSI->TheCapturedDecl;
3004 currentDecl = getCurFunctionOrMethodDecl();
3007 Diag(Loc, diag::ext_predef_outside_function);
3013 if (cast<DeclContext>(currentDecl)->isDependentContext())
3019 unsigned Length = Str.length();
3021 llvm::APInt LengthI(32, Length + 1);
3047 default: llvm_unreachable(
"Unknown simple primary expr!");
3056 return BuildPredefinedExpr(Loc, IT);
3061 bool Invalid =
false;
3062 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3068 if (Literal.hadError())
3072 if (Literal.isWide())
3074 else if (Literal.isUTF16())
3076 else if (Literal.isUTF32())
3078 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3084 if (Literal.isWide())
3086 else if (Literal.isUTF16())
3088 else if (Literal.isUTF32())
3090 else if (Literal.isUTF8())
3096 if (Literal.getUDSuffix().empty())
3106 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3124 using llvm::APFloat;
3125 APFloat Val(Format);
3131 if ((result & APFloat::opOverflow) ||
3132 ((result & APFloat::opUnderflow) && Val.isZero())) {
3133 unsigned diagnostic;
3135 if (result & APFloat::opOverflow) {
3136 diagnostic = diag::warn_float_overflow;
3137 APFloat::getLargest(Format).toString(buffer);
3139 diagnostic = diag::warn_float_underflow;
3140 APFloat::getSmallest(Format).toString(buffer);
3143 S.
Diag(Loc, diagnostic)
3145 << StringRef(buffer.data(), buffer.size());
3148 bool isExact = (result == APFloat::opOK);
3153 assert(E &&
"Invalid expression");
3160 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3164 llvm::APSInt ValueAPS;
3165 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3170 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3171 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3172 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3173 << ValueAPS.toString(10) << ValueIsPositive;
3184 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3185 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3193 SpellingBuffer.resize(Tok.
getLength() + 1);
3196 bool Invalid =
false;
3197 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3202 if (Literal.hadError)
3205 if (Literal.hasUDSuffix()) {
3213 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3216 if (Literal.isFloatingLiteral()) {
3237 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3238 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3246 if (Literal.isFloatingLiteral()) {
3250 if (Literal.GetIntegerValue(ResultVal))
3256 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3263 unsigned Length = Literal.getUDSuffixOffset();
3269 false, StrTy, &TokLoc, 1);
3270 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3273 case LOLR_Template: {
3280 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
3281 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3282 for (
unsigned I = 0, N = Literal.getUDSuffixOffset();
I != N; ++
I) {
3283 Value = TokSpelling[
I];
3288 return BuildLiteralOperatorCall(R, OpNameInfo,
None, TokLoc,
3291 case LOLR_StringTemplate:
3292 llvm_unreachable(
"unexpected literal operator lookup result");
3298 if (Literal.isFloatingLiteral()) {
3300 if (Literal.isFloat)
3302 else if (!Literal.isLong)
3310 if (getLangOpts().SinglePrecisionConstants) {
3312 }
else if (getLangOpts().OpenCL &&
3313 !((getLangOpts().OpenCLVersion >= 120) ||
3314 getOpenCLOptions().cl_khr_fp64)) {
3319 }
else if (!Literal.isIntegerLiteral()) {
3325 if (!getLangOpts().
C99 && Literal.isLongLong) {
3328 getLangOpts().CPlusPlus11 ?
3329 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3336 llvm::APInt ResultVal(MaxWidth, 0);
3338 if (Literal.GetIntegerValue(ResultVal)) {
3344 "long long is not intmax_t?");
3351 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3357 if (Literal.MicrosoftInteger) {
3358 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3362 Width = Literal.MicrosoftInteger;
3364 !Literal.isUnsigned);
3368 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3373 if (ResultVal.isIntN(IntSize)) {
3375 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3377 else if (AllowUnsigned)
3384 if (Ty.
isNull() && !Literal.isLongLong) {
3388 if (ResultVal.isIntN(LongSize)) {
3390 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3392 else if (AllowUnsigned)
3396 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3397 const unsigned LongLongSize =
3400 getLangOpts().CPlusPlus
3402 ? diag::warn_old_implicitly_unsigned_long_cxx
3404 ext_old_implicitly_unsigned_long_cxx
3405 : diag::warn_old_implicitly_unsigned_long)
3406 << (LongLongSize > LongSize ? 0
3419 if (ResultVal.isIntN(LongLongSize)) {
3423 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3424 (getLangOpts().MicrosoftExt && Literal.isLongLong)))
3426 else if (AllowUnsigned)
3428 Width = LongLongSize;
3435 Diag(Tok.
getLocation(), diag::ext_integer_literal_too_large_for_signed);
3440 if (ResultVal.getBitWidth() != Width)
3441 ResultVal = ResultVal.trunc(Width);
3447 if (Literal.isImaginary)
3455 assert(E &&
"ActOnParenExpr() missing expr");
3467 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3473 "Scalar types should always be complete");
3489 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3490 << TraitKind << ArgRange;
3497 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3498 : diag::ext_sizeof_alignof_void_type;
3499 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3513 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3535 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
3554 E->getSourceRange());
3558 E->getSourceRange(), ExprKind))
3568 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3569 E->getSourceRange()))
3572 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3573 ExprKind, E->getSourceRange()))
3583 << ExprKind << E->getSourceRange();
3591 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3594 E->getSourceRange(), ExprKind))
3599 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3600 QualType OType = PVD->getOriginalType();
3605 Diag(PVD->getLocation(), diag::note_declared_at);
3669 if (RequireCompleteType(OpLoc, ExprType,
3670 diag::err_sizeof_alignof_incomplete_type,
3671 ExprKind, ExprRange))
3675 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3676 << ExprKind << ExprRange;
3695 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3696 << 1 << E->getSourceRange();
3701 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3703 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3704 D = ME->getMemberDecl();
3724 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3727 if (!FD->getParent()->isCompleteDefinition()) {
3728 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3729 << E->getSourceRange();
3737 if (!FD->getType()->isReferenceType())
3751 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
3757 assert(CSI !=
nullptr);
3763 #define TYPE(Class, Base)
3764 #define ABSTRACT_TYPE(Class, Base)
3765 #define NON_CANONICAL_TYPE(Class, Base)
3766 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
3767 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
3768 #include "clang/AST/TypeNodes.def"
3775 case Type::ExtVector:
3778 case Type::Elaborated:
3779 case Type::TemplateSpecialization:
3780 case Type::ObjCObject:
3781 case Type::ObjCInterface:
3782 case Type::ObjCObjectPointer:
3784 llvm_unreachable(
"type class is never variably-modified!");
3785 case Type::Adjusted:
3786 T = cast<AdjustedType>(Ty)->getOriginalType();
3789 T = cast<DecayedType>(Ty)->getPointeeType();
3792 T = cast<PointerType>(Ty)->getPointeeType();
3794 case Type::BlockPointer:
3795 T = cast<BlockPointerType>(Ty)->getPointeeType();
3797 case Type::LValueReference:
3798 case Type::RValueReference:
3799 T = cast<ReferenceType>(Ty)->getPointeeType();
3801 case Type::MemberPointer:
3802 T = cast<MemberPointerType>(Ty)->getPointeeType();
3804 case Type::ConstantArray:
3805 case Type::IncompleteArray:
3809 case Type::VariableArray: {
3818 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3819 CapRecord = LSI->Lambda;
3820 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3821 CapRecord = CRSI->TheRecordDecl;
3824 auto ExprLoc = Size->getExprLoc();
3829 nullptr, SizeType,
nullptr,
3832 Field->setImplicit(
true);
3834 Field->setCapturedVLAType(VAT);
3844 case Type::FunctionProto:
3845 case Type::FunctionNoProto:
3846 T = cast<FunctionType>(Ty)->getReturnType();
3850 case Type::UnaryTransform:
3851 case Type::Attributed:
3852 case Type::SubstTemplateTypeParm:
3853 case Type::PackExpansion:
3858 T = cast<TypedefType>(Ty)->
desugar();
3860 case Type::Decltype:
3861 T = cast<DecltypeType>(Ty)->
desugar();
3864 T = cast<AutoType>(Ty)->getDeducedType();
3866 case Type::TypeOfExpr:
3867 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
3870 T = cast<AtomicType>(Ty)->getValueType();
3888 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
3893 if (
auto *CSI = dyn_cast<CapturingScopeInfo>(FunctionScopes.back())) {
3895 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI))
3896 DC = LSI->CallOperator;
3897 else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
3898 DC = CRSI->TheCapturedDecl;
3899 if (DC && TT->getDecl()->getDeclContext() != DC)
3928 isInvalid = CheckVecStepExpr(E);
3933 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
3936 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
3943 PE = TransformToPotentiallyEvaluated(E);
3966 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
3970 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
3976 if (V.
get()->isTypeDependent())
3988 return CT->getElementType();
3991 if (V.
get()->getType()->isArithmeticType())
3992 return V.
get()->getType();
3997 if (PR.
get() != V.
get()) {
4003 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4004 << (IsReal ?
"__real" :
"__imag");
4015 default: llvm_unreachable(
"Unknown unary op!");
4017 case tok::minusminus: Opc =
UO_PostDec;
break;
4023 Input = Result.
get();
4025 return BuildUnaryOp(S, OpLoc, Opc, Input);
4036 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4039 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4041 << op->getSourceRange();
4047 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4049 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4057 return ActOnOMPArraySectionExpr(base, lbLoc, idx,
SourceLocation(),
4061 if (isa<ParenListExpr>(base)) {
4062 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
4064 base = result.
get();
4072 bool IsMSPropertySubscript =
false;
4075 if (!IsMSPropertySubscript) {
4076 ExprResult result = CheckPlaceholderExpr(base);
4079 base = result.
get();
4083 ExprResult result = CheckPlaceholderExpr(idx);
4103 if (IsMSPropertySubscript) {
4118 if (getLangOpts().CPlusPlus &&
4122 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
4125 return CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
4134 BuiltinType::OMPArraySection)) {
4138 Base = Result.
get();
4144 LowerBound = Result.
get();
4150 Length = Result.
get();
4173 << Base->getSourceRange());
4177 auto Res = PerformOpenMPImplicitIntegerConversion(LowerBound->
getExprLoc(),
4179 if (Res.isInvalid())
4181 diag::err_omp_typecheck_section_not_integer)
4182 << 0 << LowerBound->getSourceRange());
4183 LowerBound = Res.get();
4188 << 0 << LowerBound->getSourceRange();
4193 if (Res.isInvalid())
4195 diag::err_omp_typecheck_section_not_integer)
4196 << 1 << Length->getSourceRange());
4202 << 1 << Length->getSourceRange();
4211 << ResultTy << Base->getSourceRange();
4215 if (RequireCompleteType(Base->
getExprLoc(), ResultTy,
4216 diag::err_omp_section_incomplete_type, Base))
4220 llvm::APSInt LowerBoundValue;
4224 if (LowerBoundValue.isNegative()) {
4226 << 0 << LowerBoundValue.toString(10,
true)
4227 << LowerBound->getSourceRange();
4234 llvm::APSInt LengthValue;
4238 if (LengthValue.isNegative()) {
4240 << 1 << LengthValue.toString(10,
true)
4241 << Length->getSourceRange();
4245 }
else if (ColonLoc.
isValid() &&
4251 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4264 Expr *LHSExp = Base;
4272 LHSExp = Result.
get();
4277 RHSExp = Result.
get();
4287 Expr *BaseExpr, *IndexExpr;
4304 if (!LangOpts.isSubscriptPointerArithmetic())
4305 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4320 if (!LangOpts.isSubscriptPointerArithmetic()) {
4321 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4322 << ResultType << BaseExpr->getSourceRange();
4333 ResultType = VTy->getElementType();
4340 Diag(LHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
4341 LHSExp->getSourceRange();
4349 }
else if (RHSTy->isArrayType()) {
4351 Diag(RHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
4352 RHSExp->getSourceRange();
4361 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4362 << LHSExp->getSourceRange() << RHSExp->getSourceRange());
4366 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4367 << IndexExpr->getSourceRange());
4372 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
4379 Diag(BaseExpr->getLocStart(), diag::err_subscript_function_type)
4380 << ResultType << BaseExpr->getSourceRange();
4384 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4386 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4387 << BaseExpr->getSourceRange();
4393 RequireCompleteType(LLoc, ResultType,
4394 diag::err_subscript_incomplete_type, BaseExpr))
4397 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4409 diag::err_use_of_default_argument_to_function_declared_later) <<
4411 Diag(UnparsedDefaultArgLocs[Param],
4412 diag::note_default_argument_declared_here);
4424 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4428 if (Inst.isInvalid())
4439 Result = SubstExpr(UninstExpr, MutiLevelArgList);
4449 UninstExpr->getLocStart());
4453 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4457 Result = ActOnFinishFullExpr(Result.
getAs<
Expr>(),
4465 L->DefaultArgumentInstantiated(Param);
4476 if (isa<ExprWithCleanups>(Param->
getInit())) {
4479 ExprNeedsCleanups =
true;
4484 assert(!cast<ExprWithCleanups>(Param->
getInit())->getNumObjects() &&
4485 "default argument expression has capturing blocks?");
4501 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4502 return VariadicConstructor;
4504 return VariadicBlock;
4506 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4507 if (Method->isInstance())
4508 return VariadicMethod;
4510 return VariadicMethod;
4511 return VariadicFunction;
4513 return VariadicDoesNotApply;
4522 FunctionName(FuncName) {}
4524 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4548 llvm::make_unique<FunctionCallCCC>(
S, FuncName.getAsIdentifierInfo(),
4551 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4552 if (Corrected.isOverloaded()) {
4562 ND = Best->FoundDecl;
4563 Corrected.setCorrectionDecl(ND);
4569 ND = ND->getUnderlyingDecl();
4570 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4589 bool IsExecConfig) {
4599 bool Invalid =
false;
4608 if (Args.size() < NumParams) {
4609 if (Args.size() < MinArgs) {
4614 ? diag::err_typecheck_call_too_few_args_suggest
4615 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4616 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4617 << static_cast<unsigned>(Args.size())
4622 ? diag::err_typecheck_call_too_few_args_one
4623 : diag::err_typecheck_call_too_few_args_at_least_one)
4624 << FnKind << FDecl->
getParamDecl(0) << Fn->getSourceRange();
4627 ? diag::err_typecheck_call_too_few_args
4628 : diag::err_typecheck_call_too_few_args_at_least)
4629 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4630 << Fn->getSourceRange();
4633 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4644 if (Args.size() > NumParams) {
4650 ? diag::err_typecheck_call_too_many_args_suggest
4651 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4652 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4653 << static_cast<unsigned>(Args.size())
4655 }
else if (NumParams == 1 && FDecl &&
4657 Diag(Args[NumParams]->getLocStart(),
4658 MinArgs == NumParams
4659 ? diag::err_typecheck_call_too_many_args_one
4660 : diag::err_typecheck_call_too_many_args_at_most_one)
4662 <<
static_cast<unsigned>(Args.size()) << Fn->getSourceRange()
4664 Args.back()->getLocEnd());
4666 Diag(Args[NumParams]->getLocStart(),
4667 MinArgs == NumParams
4668 ? diag::err_typecheck_call_too_many_args
4669 : diag::err_typecheck_call_too_many_args_at_most)
4670 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4671 << Fn->getSourceRange()
4673 Args.back()->getLocEnd());
4676 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4688 Invalid = GatherArgumentsForCall(Call->
getLocStart(), FDecl,
4689 Proto, 0, Args, AllArgs, CallType);
4692 unsigned TotalNumArgs = AllArgs.size();
4693 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4694 Call->
setArg(i, AllArgs[i]);
4704 bool IsListInitialization) {
4706 bool Invalid =
false;
4709 for (
unsigned i = FirstParam; i < NumParams; i++) {
4714 if (ArgIx < Args.size()) {
4715 Arg = Args[ArgIx++];
4717 if (RequireCompleteType(Arg->getLocStart(),
4719 diag::err_call_incomplete_argument, Arg))
4723 bool CFAudited =
false;
4725 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4726 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4727 Arg = stripARCUnbridgedCast(Arg);
4728 else if (getLangOpts().ObjCAutoRefCount &&
4729 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4730 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4744 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
4750 assert(Param &&
"can't use default arguments without a known callee");
4753 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
4763 CheckArrayAccess(Arg);
4766 CheckStaticArrayArgument(CallLoc, Param, Arg);
4768 AllArgs.push_back(Arg);
4772 if (CallType != VariadicDoesNotApply) {
4777 for (
Expr *A : Args.slice(ArgIx)) {
4779 ExprResult arg = checkUnknownAnyArg(CallLoc, A, paramType);
4781 AllArgs.push_back(arg.
get());
4786 for (
Expr *A : Args.slice(ArgIx)) {
4787 ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
4789 AllArgs.push_back(Arg.
get());
4794 for (
Expr *A : Args.slice(ArgIx))
4795 CheckArrayAccess(A);
4803 TL = DTL.getOriginalLoc();
4806 << ATL.getLocalSourceRange();
4820 const Expr *ArgExpr) {
4833 Diag(CallLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
4848 Diag(CallLoc, diag::warn_static_array_too_small)
4849 << ArgExpr->getSourceRange()
4865 if (!placeholder)
return false;
4867 switch (placeholder->
getKind()) {
4869 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
4870 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
4871 #include "clang/AST/BuiltinTypes.def"
4876 case BuiltinType::Overload:
4881 case BuiltinType::ARCUnbridgedCast:
4885 case BuiltinType::PseudoObject:
4890 case BuiltinType::UnknownAny:
4894 case BuiltinType::BoundMember:
4895 case BuiltinType::BuiltinFn:
4896 case BuiltinType::OMPArraySection:
4900 llvm_unreachable(
"bad builtin type kind");
4908 bool hasInvalid =
false;
4909 for (
size_t i = 0, e = args.size(); i != e; i++) {
4912 if (result.
isInvalid()) hasInvalid =
true;
4913 else args[i] = result.
get();
4914 }
else if (hasInvalid) {
4943 bool NeedsNewDecl =
false;
4952 if (!ParamType->isPointerType() ||
4953 ParamType.getQualifiers().hasAddressSpace() ||
4956 OverloadParams.push_back(ParamType);
4960 NeedsNewDecl =
true;
4973 OverloadParams, EPI);
4984 FT = cast<FunctionProtoType>(OverloadTy);
4985 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
4992 Params.push_back(Parm);
4994 OverloadDecl->setParams(Params);
4995 return OverloadDecl;
5004 Expr *ExecConfig,
bool IsExecConfig) {
5015 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5016 if (!ArgExprs.empty()) {
5018 Diag(Fn->getLocStart(), diag::err_pseudo_dtor_call_with_args)
5021 ArgExprs.back()->getLocEnd()));
5028 ExprResult result = CheckPlaceholderExpr(Fn);
5037 bool Dependent =
false;
5046 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5056 return BuildCallToObjectOfClassType(S, Fn, LParenLoc, ArgExprs,
5066 return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, RParenLoc);
5078 return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs,
5079 RParenLoc, ExecConfig,
5082 return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, RParenLoc);
5095 bool CallingNDeclIndirectly =
false;
5097 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5099 CallingNDeclIndirectly =
true;
5104 if (isa<DeclRefExpr>(NakedFn)) {
5105 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5120 }
else if (isa<MemberExpr>(NakedFn))
5121 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5123 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5124 if (CallingNDeclIndirectly &&
5129 if (FD->hasAttr<EnableIfAttr>()) {
5130 if (
const EnableIfAttr *
Attr = CheckEnableIf(FD, ArgExprs,
true)) {
5131 Diag(Fn->getLocStart(),
5132 isa<CXXMethodDecl>(FD) ?
5133 diag::err_ovl_no_viable_member_function_in_call :
5134 diag::err_ovl_no_viable_function_in_call)
5135 << FD << FD->getSourceRange();
5136 Diag(FD->getLocation(),
5137 diag::note_ovl_candidate_disabled_by_enable_if_attr)
5138 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5143 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
5144 ExecConfig, IsExecConfig);
5156 QualType DstTy = GetTypeFromParser(ParsedDestTy);
5160 diag::err_invalid_astype_of_different_size)
5163 << E->getSourceRange());
5176 GetTypeFromParser(ParsedDestTy, &TInfo);
5177 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
5191 Expr *Config,
bool IsExecConfig) {
5192 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5193 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5204 Result = CallExprUnaryConversions(Fn);
5215 cast<CallExpr>(Config), Args,
5222 if (!getLangOpts().CPlusPlus) {
5227 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
5230 if (!TheCall)
return Result;
5236 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5245 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5246 << Fn->
getType() << Fn->getSourceRange());
5260 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5261 << Fn->
getType() << Fn->getSourceRange());
5264 if (getLangOpts().CUDA) {
5267 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5268 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5269 << FDecl->
getName() << Fn->getSourceRange());
5273 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5274 << Fn->
getType() << Fn->getSourceRange());
5277 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5278 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5279 << FDecl->
getName() << Fn->getSourceRange());
5284 if (CheckCallReturnType(FuncT->
getReturnType(), Fn->getLocStart(), TheCall,
5294 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5298 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5307 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5308 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
5318 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5319 Expr *Arg = Args[i];
5321 if (Proto && i < Proto->getNumParams()) {
5326 if (ArgE.isInvalid())
5329 Arg = ArgE.getAs<
Expr>();
5332 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5340 if (RequireCompleteType(Arg->getLocStart(),
5342 diag::err_call_incomplete_argument, Arg))
5349 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5350 if (!Method->isStatic())
5351 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5352 << Fn->getSourceRange());
5356 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5360 if (CheckFunctionCall(FDecl, TheCall, Proto))
5364 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5366 if (CheckPointerCall(NDecl, TheCall, Proto))
5369 if (CheckOtherCall(TheCall, Proto))
5373 return MaybeBindToTemporary(TheCall);
5379 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5380 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5383 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5387 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5397 diag::err_illegal_decl_array_incomplete_type,
5399 LiteralExpr->getSourceRange().getEnd())))
5402 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5403 <<
SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd()));
5405 RequireCompleteType(LParenLoc, literalType,
5406 diag::err_typecheck_decl_incomplete_type,
5407 SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())))
5421 LiteralExpr = Result.
get();
5423 bool isFileScope = getCurFunctionOrMethodDecl() ==
nullptr;
5428 if (CheckForConstantInitializer(LiteralExpr, literalType))
5435 return MaybeBindToTemporary(
5437 VK, LiteralExpr, isFileScope));
5445 for (
unsigned I = 0,
E = InitArgList.size();
I !=
E; ++
I) {
5446 if (InitArgList[
I]->getType()->isNonOverloadPlaceholderType()) {
5447 ExprResult result = CheckPlaceholderExpr(InitArgList[
I]);
5453 InitArgList[
I] = result.
get();
5472 if (!getLangOpts().ObjCAutoRefCount)
return;
5477 ExprNeedsCleanups =
true;
5487 maybeExtendBlockObject(E);
5508 llvm_unreachable(
"member pointer type in C");
5517 if (SrcAS != DestAS)
5529 maybeExtendBlockObject(Src);
5539 llvm_unreachable(
"illegal cast from pointer");
5541 llvm_unreachable(
"Should have returned before this");
5560 Src = ImpCastExprToType(Src.
get(),
5565 Src = ImpCastExprToType(Src.
get(),
5570 llvm_unreachable(
"member pointer type in C");
5572 llvm_unreachable(
"Should have returned before this");
5583 Src = ImpCastExprToType(Src.
get(),
5588 Src = ImpCastExprToType(Src.
get(),
5595 llvm_unreachable(
"valid float->pointer cast?");
5597 llvm_unreachable(
"member pointer type in C");
5599 llvm_unreachable(
"Should have returned before this");
5617 Src = ImpCastExprToType(Src.
get(),
5624 llvm_unreachable(
"valid complex float->pointer cast?");
5626 llvm_unreachable(
"member pointer type in C");
5628 llvm_unreachable(
"Should have returned before this");
5646 Src = ImpCastExprToType(Src.
get(),
5653 llvm_unreachable(
"valid complex int->pointer cast?");
5655 llvm_unreachable(
"member pointer type in C");
5657 llvm_unreachable(
"Should have returned before this");
5660 llvm_unreachable(
"Unhandled scalar cast");
5667 len = vecType->getNumElements();
5668 eltType = vecType->getElementType();
5700 uint64_t srcLen, destLen;
5711 return (srcLen * srcEltSize == destLen * destEltSize);
5721 return areLaxCompatibleVectorTypes(srcTy, destTy);
5726 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
5729 if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
5732 diag::err_invalid_conversion_between_vectors :
5733 diag::err_invalid_conversion_between_vector_and_integer)
5734 << VectorTy << Ty << R;
5737 diag::err_invalid_conversion_between_vector_and_scalar)
5738 << VectorTy << Ty << R;
5747 if (DestElemTy == SplattedExpr->
getType())
5748 return SplattedExpr;
5762 SplattedExpr = CastExprRes.
get();
5769 CK = PrepareScalarCast(CastExprRes, DestElemTy);
5772 SplattedExpr = CastExprRes.
get();
5774 return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
5787 if (SrcTy->isVectorType()) {
5788 if (!areLaxCompatibleVectorTypes(SrcTy, DestTy)
5789 || (getLangOpts().OpenCL &&
5791 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
5792 << DestTy << SrcTy << R;
5802 if (SrcTy->isPointerType())
5804 diag::err_invalid_conversion_between_vector_and_scalar)
5805 << DestTy << SrcTy << R;
5808 return prepareVectorSplat(DestTy, CastExpr);
5816 "ActOnCastExpr(): missing type or expr");
5822 if (getLangOpts().CPlusPlus) {
5824 CheckExtraCXXDefaultArguments(D);
5827 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
5830 CastExpr = Res.
get();
5836 Ty = CreateParsedType(castType, castTInfo);
5838 bool isVectorLiteral =
false;
5844 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
5846 if (PLE && PLE->getNumExprs() == 0) {
5847 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
5850 if (PE || PLE->getNumExprs() == 1) {
5853 isVectorLiteral =
true;
5856 isVectorLiteral =
true;
5861 if (isVectorLiteral)
5862 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
5867 if (isa<ParenListExpr>(CastExpr)) {
5870 CastExpr = Result.
get();
5874 !getSourceManager().isInSystemMacro(LParenLoc))
5875 Diag(LParenLoc, diag::warn_old_style_cast) << CastExpr->getSourceRange();
5877 CheckTollFreeBridgeCast(castType, CastExpr);
5879 CheckObjCBridgeRelatedCast(castType, CastExpr);
5881 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
5887 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
5888 "Expected paren or paren list expression");
5895 LiteralLParenLoc = PE->getLParenLoc();
5896 LiteralRParenLoc = PE->getRParenLoc();
5897 exprs = PE->getExprs();
5898 numExprs = PE->getNumExprs();
5900 LiteralLParenLoc = cast<ParenExpr>(
E)->getLParen();
5901 LiteralRParenLoc = cast<ParenExpr>(
E)->getRParen();
5902 subExpr = cast<ParenExpr>(
E)->getSubExpr();
5922 if (numExprs == 1) {
5924 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
5927 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
5928 PrepareScalarCast(Literal, ElemTy));
5929 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
5931 else if (numExprs < numElems) {
5933 diag::err_incorrect_number_of_vector_initializers);
5937 initExprs.append(exprs, exprs + numExprs);
5942 if (getLangOpts().OpenCL &&
5946 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
5949 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
5950 PrepareScalarCast(Literal, ElemTy));
5951 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
5954 initExprs.append(exprs, exprs + numExprs);
5959 initExprs, LiteralRParenLoc);
5961 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
5995 Expr *NullExpr = LHSExpr;
5996 Expr *NonPointerExpr = RHSExpr;
6003 NonPointerExpr = LHSExpr;
6020 if (!findMacroSpelling(loc,
"NULL"))
6025 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6026 << NonPointerExpr->
getType() << DiagType
6027 << NonPointerExpr->getSourceRange();
6037 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6038 << CondTy << Cond->getSourceRange();
6045 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6046 << CondTy << Cond->getSourceRange();
6057 S.
Diag(RHSExpr->getLocStart(), diag::ext_typecheck_cond_one_void)
6058 << RHSExpr->getSourceRange();
6060 S.
Diag(LHSExpr->getLocStart(), diag::ext_typecheck_cond_one_void)
6061 << LHSExpr->getSourceRange();
6072 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6096 bool IsBlockPointer =
false;
6100 IsBlockPointer =
true;
6127 if (CompositeTy.
isNull()) {
6128 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6129 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6130 << RHS.
get()->getSourceRange();
6167 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6168 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6169 << RHS.
get()->getSourceRange();
6220 bool IsIntFirstExpr) {
6222 !Int.
get()->getType()->isIntegerType())
6225 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6226 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6228 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6230 << Expr1->getSourceRange() << Expr2->getSourceRange();
6266 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6267 << LHSType << LHS.
get()->getSourceRange();
6272 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6273 << RHSType << RHS.
get()->getSourceRange();
6278 if (LHSType == RHSType)
6287 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6288 (
S, LHS, RHS, LHSType, RHSType,
false);
6322 llvm::raw_svector_ostream OS(Str);
6323 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6324 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6325 << CondTy << OS.str();
6346 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6347 << Cond->
getType() << Cond->getSourceRange();
6364 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6365 << CondTy << VecResTy;
6370 QualType RVE = RV->getElementType();
6373 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6374 << CondTy << VecResTy;
6398 if (LHS.
get()->getType()->isVectorType() ||
6399 RHS.
get()->getType()->isVectorType()) {
6433 if (getLangOpts().CPlusPlus)
6434 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
6445 Cond = UsualUnaryConversions(Cond.
get());
6454 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
6458 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
6468 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
6469 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
6478 if (LHSRT->getDecl() == RHSRT->getDecl())
6497 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
6501 if (!compositeType.
isNull())
6502 return compositeType;
6527 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
6531 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6532 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6533 << RHS.
get()->getSourceRange();
6603 if (!(compositeType =
6621 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
6623 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6626 RHS = ImpCastExprToType(RHS.get(), incompatTy,
CK_BitCast);
6630 LHS = ImpCastExprToType(LHS.
get(), compositeType,
CK_BitCast);
6631 RHS = ImpCastExprToType(RHS.get(), compositeType,
CK_BitCast);
6632 return compositeType;
6636 if (getLangOpts().ObjCAutoRefCount) {
6639 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6640 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6650 LHS = ImpCastExprToType(LHS.
get(), destType,
CK_NoOp);
6652 RHS = ImpCastExprToType(RHS.get(), destType,
CK_BitCast);
6656 if (getLangOpts().ObjCAutoRefCount) {
6659 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6660 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6670 RHS = ImpCastExprToType(RHS.
get(), destType,
CK_NoOp);
6672 LHS = ImpCastExprToType(LHS.get(), destType,
CK_BitCast);
6686 Self.
Diag(Loc, Note)
6691 Self.
Diag(Loc, Note) << ParenRange;
6715 *Opcode = OP->getOpcode();
6716 *RHSExprs = OP->getRHS();
6723 if (Call->getNumArgs() != 2)
6729 if (OO < OO_Plus || OO > OO_Arrow ||
6730 OO == OO_PlusPlus || OO == OO_MinusMinus)
6736 *RHSExprs = Call->getArg(1);
6753 return OP->isComparisonOp() || OP->isLogicalOp();
6755 return OP->getOpcode() ==
UO_LNot;
6782 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
6783 << Condition->getSourceRange()
6787 Self.
PDiag(diag::note_precedence_silence)
6789 SourceRange(Condition->getLocStart(), Condition->getLocEnd()));
6792 Self.
PDiag(diag::note_precedence_conditional_first),
6793 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
6806 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
6808 CondExpr = CondResult.
get();
6814 Expr *commonExpr =
nullptr;
6816 commonExpr = CondExpr;
6821 ExprResult result = CheckPlaceholderExpr(commonExpr);
6823 commonExpr = result.
get();
6834 ExprResult commonRes = UsualUnaryConversions(commonExpr);
6837 commonExpr = commonRes.
get();
6845 LHSExpr = CondExpr = opaqueValue;
6850 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
6851 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
6852 VK, OK, QuestionLoc);
6860 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
6865 RHS.get(), result, VK, OK);
6868 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
6879 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
6880 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
6883 const Type *lhptee, *rhptee;
6885 std::tie(lhptee, lhq) =
6886 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
6887 std::tie(rhptee, rhq) =
6888 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
6914 && (lhptee->isVoidType() || rhptee->isVoidType()))
6929 if (lhptee->isVoidType()) {
6930 if (rhptee->isIncompleteOrObjectType())
6934 assert(rhptee->isFunctionType());
6938 if (rhptee->isVoidType()) {
6939 if (lhptee->isIncompleteOrObjectType())
6943 assert(lhptee->isFunctionType());
6954 if (lhptee->isCharType())
6956 else if (lhptee->hasSignedIntegerRepresentation())
6959 if (rhptee->isCharType())
6961 else if (rhptee->hasSignedIntegerRepresentation())
6964 if (ltrans == rtrans) {
6978 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
6980 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
6981 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
6982 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
6984 if (lhptee == rhptee)
7004 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7005 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7010 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7011 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7020 if (lhptee.getLocalQualifiers() != rhptee.getLocalQualifiers())
7034 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7035 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7076 return CheckAssignmentConstraints(LHSType, RHSPtr, K,
false);
7108 if (LHSType == RHSType) {
7115 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7117 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
7118 if (result != Compatible)
7120 if (Kind !=
CK_NoOp && ConvertRHS)
7121 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
7138 return Incompatible;
7145 return Incompatible;
7149 RHS = prepareVectorSplat(LHSType, RHS.
get());
7168 if (isLaxVectorConversion(RHSType, LHSType)) {
7170 return IncompatibleVectors;
7173 return Incompatible;
7180 Kind = PrepareScalarCast(RHS, LHSType);
7185 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7187 if (isa<PointerType>(RHSType)) {
7188 unsigned AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7197 return IntToPointer;
7202 if (isa<ObjCObjectPointerType>(RHSType)) {
7204 if (LHSPointer->getPointeeType()->isVoidType()) {
7218 return IncompatiblePointer;
7223 if (LHSPointer->getPointeeType()->isVoidType()) {
7229 return Incompatible;
7233 if (isa<BlockPointerType>(LHSType)) {
7243 return IntToBlockPointer;
7254 if (RHSPT->getPointeeType()->isVoidType()) {
7259 return Incompatible;
7263 if (isa<ObjCObjectPointerType>(LHSType)) {
7269 if (getLangOpts().ObjCAutoRefCount &&
7270 result == Compatible &&
7271 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
7272 result = IncompatibleObjCWeakRef;
7279 return IntToPointer;
7284 if (isa<PointerType>(RHSType)) {
7299 return IncompatiblePointer;
7306 maybeExtendBlockObject(RHS);
7311 return Incompatible;
7315 if (isa<PointerType>(RHSType)) {
7325 return PointerToInt;
7328 return Incompatible;
7332 if (isa<ObjCObjectPointerType>(RHSType)) {
7342 return PointerToInt;
7345 return Incompatible;
7349 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
7356 return Incompatible;
7369 Initializer->
setType(UnionType);
7388 return Incompatible;
7394 for (
auto *it : UD->
fields()) {
7395 if (it->getType()->isPointerType()) {
7408 RHS = ImpCastExprToType(RHS.
get(), it->
getType(),
7416 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
7425 return Incompatible;
7434 bool DiagnoseCFAudited,
7440 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
7460 return Incompatible;
7465 return Incompatible;
7467 if (getLangOpts().ObjCAutoRefCount &&
7468 !CheckObjCARCUnavailableWeakConversion(LHSType,
7470 result = IncompatibleObjCWeakRef;
7483 if (
FunctionDecl *FD = ResolveAddressOfOverloadedFunction(
7484 RHS.
get(), LHSType,
false, DAP))
7485 RHS = FixOverloadedFunctionReference(RHS.
get(), DAP, FD);
7487 return Incompatible;
7496 if (Diagnose || ConvertRHS) {
7499 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
7515 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get(), Diagnose);
7517 return Incompatible;
7521 if (Diagnose && isa<ObjCProtocolExpr>(PRE)) {
7531 CheckAssignmentConstraints(LHSType, RHS, Kind, ConvertRHS);
7539 if (result != Incompatible && RHS.
get()->
getType() != LHSType) {
7542 if (getLangOpts().ObjCAutoRefCount)
7543 CheckObjCARCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
7544 Diagnose, DiagnoseCFAudited);
7545 if (getLangOpts().ObjC1 &&
7546 (CheckObjCBridgeRelatedConversions(E->getLocStart(), LHSType,
7548 ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {
7554 RHS = ImpCastExprToType(E, Ty, Kind);
7561 Diag(Loc, diag::err_typecheck_invalid_operands)
7563 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7617 bool AllowBoolConversions) {
7618 if (!IsCompAssign) {
7619 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
7623 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
7634 assert(LHSVecType || RHSVecType);
7638 if (!AllowBothBool &&
7641 return InvalidOperands(Loc, LHS, RHS);
7648 if (LHSVecType && RHSVecType &&
7650 if (isa<ExtVectorType>(LHSVecType)) {
7663 if (AllowBoolConversions && LHSVecType && RHSVecType &&
7673 if (!IsCompAssign &&
7676 RHSVecType->getElementType()->isIntegerType()) {
7684 if (!RHSVecType && isa<ExtVectorType>(LHSVecType)) {
7689 if (!LHSVecType && isa<ExtVectorType>(RHSVecType)) {
7691 LHSType, RHSVecType->getElementType(),
7700 if (isLaxVectorConversion(RHSType, LHSType)) {
7709 if ((!RHSVecType && !RHSType->
isRealType()) ||
7711 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
7712 << LHSType << RHSType
7713 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7721 if (getLangOpts().OpenCL &&
7722 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
7723 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
7724 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
7730 Diag(Loc, diag::err_typecheck_vector_not_convertable)
7731 << LHSType << RHSType
7732 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7744 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
7745 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
7747 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
7751 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
7752 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
7758 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
7766 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
7767 NonNullType->canDecayToPointerType())
7770 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
7771 << LHSNull << NonNullType
7772 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7779 llvm::APSInt RHSValue;
7780 if (!RHS.
get()->isValueDependent() &&
7781 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) && RHSValue == 0)
7783 S.
PDiag(diag::warn_remainder_division_by_zero)
7784 << IsDiv << RHS.
get()->getSourceRange());
7789 bool IsCompAssign,
bool IsDiv) {
7794 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
7795 getLangOpts().AltiVec,
7798 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
7804 return InvalidOperands(Loc, LHS, RHS);
7818 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
7819 getLangOpts().AltiVec,
7821 return InvalidOperands(Loc, LHS, RHS);
7824 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
7829 return InvalidOperands(Loc, LHS, RHS);
7838 ? diag::err_typecheck_pointer_arith_void_type
7839 : diag::ext_gnu_void_ptr)
7840 << 1 << LHSExpr->getSourceRange()
7841 << RHSExpr->getSourceRange();
7848 ? diag::err_typecheck_pointer_arith_void_type
7849 : diag::ext_gnu_void_ptr)
7850 << 0 << Pointer->getSourceRange();
7859 ? diag::err_typecheck_pointer_arith_function_type
7860 : diag::ext_gnu_ptr_func_arith)
7866 << LHS->getSourceRange() << RHS->getSourceRange();
7874 ? diag::err_typecheck_pointer_arith_function_type
7875 : diag::ext_gnu_ptr_func_arith)
7878 << Pointer->getSourceRange();
7888 ResType = ResAtomicType->getValueType();
7893 diag::err_typecheck_arithmetic_incomplete_type,
7894 PointeeTy, Operand->getSourceRange());
7909 ResType = ResAtomicType->getValueType();
7941 if (!isLHSPointer && !isRHSPointer)
return true;
7943 QualType LHSPointeeTy, RHSPointeeTy;
7948 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
7953 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
7955 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
7961 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
7962 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
7963 if (isLHSVoidPtr || isRHSVoidPtr) {
7971 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
7972 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
7973 if (isLHSFuncPtr || isRHSFuncPtr) {
7995 Expr* IndexExpr = RHSExpr;
7998 IndexExpr = LHSExpr;
8001 bool IsStringPlusInt = StrExpr &&
8003 if (!IsStringPlusInt || IndexExpr->isValueDependent())
8007 if (IndexExpr->EvaluateAsInt(index, Self.
getASTContext())) {
8008 unsigned StrLenWithNull = StrExpr->
getLength() + 1;
8009 if (index.isNonNegative() &&
8010 index <= llvm::APSInt(llvm::APInt(index.getBitWidth(), StrLenWithNull),
8011 index.isUnsigned()))
8015 SourceRange DiagRange(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
8016 Self.
Diag(OpLoc, diag::warn_string_plus_int)
8017 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
8020 if (IndexExpr == RHSExpr) {
8022 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8027 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8033 const Expr *StringRefExpr = LHSExpr;
8039 StringRefExpr = RHSExpr;
8042 if (!CharExpr || !StringRefExpr)
8056 SourceRange DiagRange(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
8059 if (!CharType->isAnyCharacterType() &&
8060 CharType->isIntegerType() &&
8062 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8063 << DiagRange << Ctx.
CharTy;
8065 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8066 << DiagRange << CharExpr->
getType();
8072 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8077 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8086 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
8087 << LHSExpr->
getType() << RHSExpr->
getType() << LHSExpr->getSourceRange()
8088 << RHSExpr->getSourceRange();
8099 QualType compType = CheckVectorOperands(
8100 LHS, RHS, Loc, CompLHSTy,
8101 getLangOpts().AltiVec,
8102 getLangOpts().ZVector);
8103 if (CompLHSTy) *CompLHSTy = compType;
8107 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
8119 if (CompLHSTy) *CompLHSTy = compType;
8129 isObjCPointer =
false;
8131 isObjCPointer =
true;
8133 std::swap(PExp, IExp);
8135 isObjCPointer =
false;
8137 isObjCPointer =
true;
8139 return InvalidOperands(Loc, LHS, RHS);
8144 if (!IExp->getType()->isIntegerType())
8145 return InvalidOperands(Loc, LHS, RHS);
8154 CheckArrayAccess(PExp, IExp);
8177 QualType compType = CheckVectorOperands(
8178 LHS, RHS, Loc, CompLHSTy,
8179 getLangOpts().AltiVec,
8180 getLangOpts().ZVector);
8181 if (CompLHSTy) *CompLHSTy = compType;
8185 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
8193 if (CompLHSTy) *CompLHSTy = compType;
8212 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
8215 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
8248 if (ElementSize.
isZero()) {
8249 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
8251 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8255 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
8260 return InvalidOperands(Loc, LHS, RHS);
8265 return ET->getDecl()->isScoped();
8279 if (RHS.
get()->isValueDependent() ||
8283 if (Right.isNegative()) {
8285 S.
PDiag(diag::warn_shift_negative)
8286 << RHS.
get()->getSourceRange());
8289 llvm::APInt LeftBits(Right.getBitWidth(),
8291 if (Right.uge(LeftBits)) {
8293 S.
PDiag(diag::warn_shift_gt_typewidth)
8294 << RHS.
get()->getSourceRange());
8305 if (LHS.
get()->isValueDependent() ||
8312 if (Left.isNegative()) {
8314 S.
PDiag(diag::warn_shift_lhs_negative)
8315 << LHS.
get()->getSourceRange());
8319 llvm::APInt ResultBits =
8320 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
8321 if (LeftBits.uge(ResultBits))
8323 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
8324 Result = Result.shl(Right);
8329 Result.toString(HexResult, 16,
false,
true);
8335 if (LeftBits == ResultBits - 1) {
8336 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
8337 << HexResult << LHSType
8338 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8342 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
8343 << HexResult.str() << Result.getMinSignedBits() << LHSType
8344 << Left.getBitWidth() << LHS.
get()->getSourceRange()
8345 << RHS.
get()->getSourceRange();
8354 if (!LHS.
get()->getType()->isVectorType()) {
8355 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
8356 << RHS.
get()->getType() << LHS.
get()->getType()
8357 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8361 if (!IsCompAssign) {
8379 if (!LHSEleType->isIntegerType()) {
8380 S.
Diag(Loc, diag::err_typecheck_expect_int)
8381 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
8385 if (!RHSEleType->isIntegerType()) {
8386 S.
Diag(Loc, diag::err_typecheck_expect_int)
8387 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
8396 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
8397 << LHS.
get()->getType() << RHS.
get()->getType()
8398 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8414 bool IsCompAssign) {
8420 if (LangOpts.OpenCL)
8422 if (LangOpts.ZVector) {
8428 return InvalidOperands(Loc, LHS, RHS);
8431 return InvalidOperands(Loc, LHS, RHS);
8434 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8445 LHS = UsualUnaryConversions(LHS.
get());
8449 if (IsCompAssign) LHS = OldLHS;
8452 RHS = UsualUnaryConversions(RHS.
get());
8460 return InvalidOperands(Loc, LHS, RHS);
8466 return InvalidOperands(Loc, LHS, RHS);
8477 if (isa<ClassTemplateSpecializationDecl>(DC))
8480 return FD->isFunctionTemplateSpecialization();
8507 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
8508 << LHSStrippedType << RHSStrippedType
8509 << LHS->getSourceRange() << RHS->getSourceRange();
8516 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
8517 : diag::ext_typecheck_comparison_of_distinct_pointers)
8518 << LHS.
get()->getType() << RHS.
get()->getType()
8519 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8551 bool NonStandardCompositeType =
false;
8552 bool *BoolPtr = S.
isSFINAEContext() ?
nullptr : &NonStandardCompositeType;
8559 if (NonStandardCompositeType)
8560 S.
Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers_nonstandard)
8561 << LHSType << RHSType << T << LHS.
get()->getSourceRange()
8562 << RHS.
get()->getSourceRange();
8573 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
8574 : diag::ext_typecheck_comparison_of_fptr_to_void)
8575 << LHS.
get()->getType() << RHS.
get()->getType()
8576 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8580 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
8581 case Stmt::ObjCArrayLiteralClass:
8582 case Stmt::ObjCDictionaryLiteralClass:
8583 case Stmt::ObjCStringLiteralClass:
8584 case Stmt::ObjCBoxedExprClass:
8640 switch (FromE->getStmtClass()) {
8643 case Stmt::ObjCStringLiteralClass:
8646 case Stmt::ObjCArrayLiteralClass:
8649 case Stmt::ObjCDictionaryLiteralClass:
8651 return LK_Dictionary;
8652 case Stmt::BlockExprClass:
8654 case Stmt::ObjCBoxedExprClass: {
8656 switch (Inner->getStmtClass()) {
8657 case Stmt::IntegerLiteralClass:
8658 case Stmt::FloatingLiteralClass:
8659 case Stmt::CharacterLiteralClass:
8660 case Stmt::ObjCBoolLiteralExprClass:
8661 case Stmt::CXXBoolLiteralExprClass:
8664 case Stmt::ImplicitCastExprClass: {
8665 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
8686 Literal = LHS.
get();
8689 Literal = RHS.
get();
8705 llvm_unreachable(
"Unknown Objective-C object literal kind");
8709 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
8710 << Literal->getSourceRange();
8712 S.
Diag(Loc, diag::warn_objc_literal_comparison)
8713 << LiteralKind << Literal->getSourceRange();
8722 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
8738 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
8773 return DR->getDecl();
8775 if (Ivar->isFreeIvar())
8776 return Ivar->getDecl();
8778 if (
MemberExpr* Mem = dyn_cast<MemberExpr>(E)) {
8779 if (Mem->isImplicitAccess())
8780 return Mem->getMemberDecl();
8788 bool IsRelational) {
8794 return CheckVectorCompareOperands(LHS, RHS, Loc, IsRelational);
8807 !LHS.
get()->getLocStart().isMacroID() &&
8808 !RHS.
get()->getLocStart().isMacroID() &&
8809 ActiveTemplateInstantiations.empty()) {
8823 DiagRuntimeBehavior(Loc,
nullptr, PDiag(diag::warn_comparison_always)
8832 char always_evals_to;
8835 always_evals_to = 0;
8838 always_evals_to = 1;
8842 always_evals_to = 2;
8845 DiagRuntimeBehavior(Loc,
nullptr, PDiag(diag::warn_comparison_always)
8847 << always_evals_to);
8850 if (isa<CastExpr>(LHSStripped))
8852 if (isa<CastExpr>(RHSStripped))
8857 Expr *literalString =
nullptr;
8858 Expr *literalStringStripped =
nullptr;
8859 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
8862 literalString = LHS.
get();
8863 literalStringStripped = LHSStripped;
8864 }
else if ((isa<StringLiteral>(RHSStripped) ||
8865 isa<ObjCEncodeExpr>(RHSStripped)) &&
8868 literalString = RHS.
get();
8869 literalStringStripped = RHSStripped;
8872 if (literalString) {
8873 DiagRuntimeBehavior(Loc,
nullptr,
8874 PDiag(diag::warn_stringcompare)
8875 << isa<ObjCEncodeExpr>(literalStringStripped)
8876 << literalString->getSourceRange());
8881 UsualArithmeticConversions(LHS, RHS);
8897 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
8910 if (!IsRelational && LHSIsNull != RHSIsNull) {
8911 bool IsEquality = Opc ==
BO_EQ;
8913 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
8914 RHS.
get()->getSourceRange());
8916 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
8917 LHS.
get()->getSourceRange());
8929 if (LCanPointeeTy == RCanPointeeTy)
8931 if (!IsRelational &&
8938 && !LHSIsNull && !RHSIsNull) {
8940 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
8942 if (isSFINAEContext())
8960 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
8961 << LHSType << RHSType << LHS.
get()->getSourceRange()
8962 << RHS.
get()->getSourceRange();
8964 }
else if (!IsRelational &&
8968 && !LHSIsNull && !RHSIsNull)
8975 if (LCanPointeeTy != RCanPointeeTy) {
8977 if (getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
8981 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8982 << LHSType << RHSType << 0
8983 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8990 if (LHSIsNull && !RHSIsNull)
8991 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
8993 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
8998 if (getLangOpts().CPlusPlus) {
9009 RHS = ImpCastExprToType(RHS.
get(), LHSType,
9019 LHS = ImpCastExprToType(LHS.
get(), RHSType,
9027 if (!IsRelational &&
9049 if (!LHSIsNull && !RHSIsNull &&
9051 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9052 << LHSType << RHSType << LHS.
get()->getSourceRange()
9053 << RHS.
get()->getSourceRange();
9063 if (!LHSIsNull && !RHSIsNull) {
9068 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9069 << LHSType << RHSType << LHS.
get()->getSourceRange()
9070 << RHS.
get()->getSourceRange();
9072 if (LHSIsNull && !RHSIsNull)
9073 LHS = ImpCastExprToType(LHS.
get(), RHSType,
9077 RHS = ImpCastExprToType(RHS.get(), LHSType,
9089 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
9091 if (!LPtrToVoid && !RPtrToVoid &&
9096 if (LHSIsNull && !RHSIsNull) {
9098 if (getLangOpts().ObjCAutoRefCount)
9099 CheckObjCARCConversion(
SourceRange(), RHSType, E, CCK_ImplicitConversion);
9100 LHS = ImpCastExprToType(E, RHSType,
9105 if (getLangOpts().ObjCAutoRefCount)
9107 CCK_ImplicitConversion,
true,
9109 RHS = ImpCastExprToType(E, LHSType,
9122 if (LHSIsNull && !RHSIsNull)
9125 RHS = ImpCastExprToType(RHS.get(), LHSType,
CK_BitCast);
9131 unsigned DiagID = 0;
9132 bool isError =
false;
9133 if (LangOpts.DebuggerSupport) {
9138 if (IsRelational && !getLangOpts().CPlusPlus)
9139 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
9140 }
else if (IsRelational && !getLangOpts().CPlusPlus)
9141 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
9142 else if (getLangOpts().CPlusPlus) {
9143 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
9146 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
9150 << LHSType << RHSType << LHS.
get()->getSourceRange()
9151 << RHS.
get()->getSourceRange();
9157 LHS = ImpCastExprToType(LHS.
get(), RHSType,
9160 RHS = ImpCastExprToType(RHS.
get(), LHSType,
9166 if (!IsRelational && RHSIsNull
9171 if (!IsRelational && LHSIsNull
9177 return InvalidOperands(Loc, LHS, RHS);
9196 "Unhandled vector element size in vector compare");
9206 bool IsRelational) {
9209 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
9211 getLangOpts().ZVector);
9219 if (getLangOpts().AltiVec &&
9227 ActiveTemplateInstantiations.empty()) {
9232 if (DRL->getDecl() == DRR->getDecl())
9233 DiagRuntimeBehavior(Loc,
nullptr,
9234 PDiag(diag::warn_comparison_always)
9243 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
9247 return GetSignedVectorType(LHSType);
9254 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
9258 return InvalidOperands(Loc, LHS, RHS);
9259 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
9261 return InvalidOperands(Loc, LHS, RHS);
9263 return GetSignedVectorType(LHS.
get()->
getType());
9274 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
9276 getLangOpts().ZVector);
9277 return InvalidOperands(Loc, LHS, RHS);
9281 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
9283 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
9285 LHS = LHSResult.
get();
9286 RHS = RHSResult.
get();
9290 return InvalidOperands(Loc, LHS, RHS);
9299 return CheckVectorLogicalOperands(LHS, RHS, Loc);
9308 !Loc.
isMacroID() && ActiveTemplateInstantiations.empty()) {
9317 (Result != 0 && Result != 1)) {
9318 Diag(Loc, diag::warn_logical_instead_of_bitwise)
9319 << RHS.
get()->getSourceRange()
9320 << (Opc ==
BO_LAnd ?
"&&" :
"||");
9322 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
9323 << (Opc ==
BO_LAnd ?
"&" :
"|")
9325 Loc, getLocForEndOfToken(Loc)),
9329 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
9332 RHS.
get()->getLocEnd()));
9343 return InvalidOperands(Loc, LHS, RHS);
9346 LHS = UsualUnaryConversions(LHS.
get());
9350 RHS = UsualUnaryConversions(RHS.
get());
9356 return InvalidOperands(Loc, LHS, RHS);
9367 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
9369 return InvalidOperands(Loc, LHS, RHS);
9372 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
9374 return InvalidOperands(Loc, LHS, RHS);
9385 if (!ME)
return false;
9389 if (!Base)
return false;
9410 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
9451 bool DiagnosticEmitted =
false;
9455 bool IsDereference =
false;
9456 bool NextIsDereference =
false;
9460 IsDereference = NextIsDereference;
9461 NextIsDereference =
false;
9464 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
9465 NextIsDereference = ME->isArrow();
9466 const ValueDecl *VD = ME->getMemberDecl();
9467 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
9469 if (Field->isMutable()) {
9470 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
9475 if (!DiagnosticEmitted) {
9476 S.
Diag(Loc, diag::err_typecheck_assign_const)
9477 << ExprRange << ConstMember <<
false << Field
9478 << Field->getType();
9479 DiagnosticEmitted =
true;
9482 << ConstMember <<
false << Field << Field->getType()
9483 << Field->getSourceRange();
9487 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
9488 if (VDecl->getType().isConstQualified()) {
9489 if (!DiagnosticEmitted) {
9490 S.
Diag(Loc, diag::err_typecheck_assign_const)
9491 << ExprRange << ConstMember <<
true << VDecl
9492 << VDecl->getType();
9493 DiagnosticEmitted =
true;
9496 << ConstMember <<
true << VDecl << VDecl->getType()
9497 << VDecl->getSourceRange();
9507 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9511 if (!DiagnosticEmitted) {
9512 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
9513 << ConstFunction << FD;
9514 DiagnosticEmitted =
true;
9517 diag::note_typecheck_assign_const)
9521 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
9523 if (
const ValueDecl *VD = DRE->getDecl()) {
9525 if (!DiagnosticEmitted) {
9526 S.
Diag(Loc, diag::err_typecheck_assign_const)
9527 << ExprRange << ConstVariable << VD << VD->getType();
9528 DiagnosticEmitted =
true;
9530 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
9531 << ConstVariable << VD << VD->getType() << VD->getSourceRange();
9534 }
else if (isa<CXXThisExpr>(E)) {
9536 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
9537 if (MD->isConst()) {
9538 if (!DiagnosticEmitted) {
9539 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
9540 << ConstMethod << MD;
9541 DiagnosticEmitted =
true;
9543 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
9544 << ConstMethod << MD << MD->getSourceRange();
9550 if (DiagnosticEmitted)
9554 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstUnknown;
9569 unsigned DiagID = 0;
9570 bool NeedType =
false;
9577 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
9579 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
9587 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
9600 ? diag::err_typecheck_arc_assign_self_class_method
9601 : diag::err_typecheck_arc_assign_self;
9605 DiagID = diag::err_typecheck_arr_assign_enumeration;
9610 S.
Diag(Loc, DiagID) << E->getSourceRange() << Assign;
9631 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
9635 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
9639 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
9642 llvm_unreachable(
"did not take early return for MLV_Valid");
9646 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
9651 diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
E);
9653 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
9656 llvm_unreachable(
"readonly properties should be processed differently");
9658 DiagID = diag::error_readonly_message_assignment;
9661 DiagID = diag::error_no_subobject_property_setting;
9669 S.
Diag(Loc, DiagID) << E->
getType() << E->getSourceRange() << Assign;
9671 S.
Diag(Loc, DiagID) << E->getSourceRange() << Assign;
9681 if (ML && MR && ML->
getMemberDecl() == MR->getMemberDecl()) {
9682 if (isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase()))
9683 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
9689 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
9692 if (RL && RR && RL->
getDecl() == RR->getDecl())
9693 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
9711 if (CompoundType.
isNull()) {
9717 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
9721 if (ConvTy == IncompatiblePointer &&
9726 ConvTy = Compatible;
9728 if (ConvTy == Compatible &&
9730 Diag(Loc, diag::err_objc_object_assignment)
9737 RHSCheck = ICE->getSubExpr();
9738 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
9739 if ((UO->getOpcode() ==
UO_Plus ||
9741 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
9747 UO->getSubExpr()->getLocStart().
isFileID()) {
9748 Diag(Loc, diag::warn_not_compound_assign)
9749 << (UO->getOpcode() ==
UO_Plus ?
"+" :
"-")
9750 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
9754 if (ConvTy == Compatible) {
9762 checkRetainCycles(LHSExpr, RHS.
get());
9771 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
9772 RHS.
get()->getLocStart()))
9773 getCurFunction()->markSafeWeakUse(RHS.
get());
9775 }
else if (getLangOpts().ObjCAutoRefCount) {
9776 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
9781 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
9784 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
9785 RHS.
get(), AA_Assigning))
9825 if (!RHS.
get()->getType()->isVoidType())
9827 diag::err_incomplete_type);
9830 return RHS.
get()->getType();
9839 bool IsInc,
bool IsPrefix) {
9848 ResType = ResAtomicType->getValueType();
9850 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
9852 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
9855 S.
Diag(OpLoc, diag::err_decrement_bool) << Op->getSourceRange();
9860 : diag::warn_increment_bool)
9861 << Op->getSourceRange();
9862 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
9864 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
9866 }
else if (ResType->isRealType()) {
9868 }
else if (ResType->isPointerType()) {
9872 }
else if (ResType->isObjCObjectPointerType()) {
9878 }
else if (ResType->isAnyComplexType()) {
9880 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
9881 << ResType << Op->getSourceRange();
9882 }
else if (ResType->isPlaceholderType()) {
9887 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
9889 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
9890 (ResType->getAs<
VectorType>()->getVectorKind() !=
9893 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
9897 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
9898 << ResType << int(IsInc) << Op->getSourceRange();
9914 return ResType.getUnqualifiedType();
9932 switch (E->getStmtClass()) {
9933 case Stmt::DeclRefExprClass:
9934 return cast<DeclRefExpr>(
E)->getDecl();
9935 case Stmt::MemberExprClass:
9939 if (cast<MemberExpr>(E)->isArrow())
9943 case Stmt::ArraySubscriptExprClass: {
9946 Expr*
Base = cast<ArraySubscriptExpr>(
E)->getBase();
9948 if (ICE->getSubExpr()->getType()->isArrayType())
9953 case Stmt::UnaryOperatorClass: {
9965 case Stmt::ParenExprClass:
9967 case Stmt::ImplicitCastExprClass:
9979 AO_Vector_Element = 1,
9980 AO_Property_Expansion = 2,
9981 AO_Register_Variable = 3,
9990 S.
Diag(Loc, diag::err_typecheck_address_of) << Type << E->getSourceRange();
10002 if (PTy->getKind() == BuiltinType::Overload) {
10004 if (!isa<OverloadExpr>(E)) {
10005 assert(cast<UnaryOperator>(E)->getOpcode() ==
UO_AddrOf);
10006 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
10007 << OrigOp.
get()->getSourceRange();
10012 if (isa<UnresolvedMemberExpr>(Ovl))
10013 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
10014 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10015 << OrigOp.
get()->getSourceRange();
10022 if (PTy->getKind() == BuiltinType::UnknownAny)
10025 if (PTy->getKind() == BuiltinType::BoundMember) {
10026 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10027 << OrigOp.
get()->getSourceRange();
10031 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
10045 Diag(op->
getExprLoc(), diag::err_opencl_taking_function_address);
10049 if (getLangOpts().
C99) {
10055 return uOp->getSubExpr()->getType();
10062 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
10064 op->getLocStart()))
10068 unsigned AddressOfError = AO_No_Error;
10071 bool sfinae = (
bool)isSFINAEContext();
10072 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
10073 : diag::ext_typecheck_addrof_temporary)
10074 << op->
getType() << op->getSourceRange();
10080 }
else if (isa<ObjCSelectorExpr>(op)) {
10087 if (!isa<DeclRefExpr>(op)) {
10088 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10089 << OrigOp.
get()->getSourceRange();
10096 if (OrigOp.
get() != DRE) {
10097 Diag(OpLoc, diag::err_parens_pointer_member_function)
10098 << OrigOp.
get()->getSourceRange();
10102 if (MD->getParent()->getName().empty())
10103 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
10104 << op->getSourceRange();
10107 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
10108 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
10109 << op->getSourceRange()
10115 if (isa<CXXDestructorDecl>(MD))
10116 Diag(OpLoc, diag::err_typecheck_addrof_dtor) << op->getSourceRange();
10122 (
void)isCompleteType(OpLoc, MPTy);
10129 if (isa<PseudoObjectExpr>(op)) {
10130 AddressOfError = AO_Property_Expansion;
10132 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
10133 << op->
getType() << op->getSourceRange();
10139 AddressOfError = AO_Bit_Field;
10142 AddressOfError = AO_Vector_Element;
10146 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
10150 !getLangOpts().CPlusPlus) {
10151 AddressOfError = AO_Register_Variable;
10153 }
else if (isa<MSPropertyDecl>(dcl)) {
10154 AddressOfError = AO_Property_Expansion;
10155 }
else if (isa<FunctionTemplateDecl>(dcl)) {
10157 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
10161 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->
getQualifier()) {
10166 diag::err_cannot_form_pointer_to_member_of_reference_type)
10171 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
10179 (
void)isCompleteType(OpLoc, MPTy);
10183 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl))
10184 llvm_unreachable(
"Unknown/unexpected decl type");
10187 if (AddressOfError != AO_No_Error) {
10196 Diag(OpLoc, diag::ext_typecheck_addrof_void) << op->getSourceRange();
10216 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
10219 if (!FD->ModifiedNonNullParams.count(Param))
10220 FD->ModifiedNonNullParams.insert(Param);
10230 if (ConvResult.isInvalid())
10232 Op = ConvResult.get();
10236 if (isa<CXXReinterpretCastExpr>(Op)) {
10239 Op->getSourceRange());
10250 if (PR.
get() != Op)
10255 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
10256 << OpTy << Op->getSourceRange();
10270 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
10271 << OpTy << Op->getSourceRange();
10286 default: llvm_unreachable(
"Unknown binop!");
10287 case tok::periodstar: Opc =
BO_PtrMemD;
break;
10288 case tok::arrowstar: Opc =
BO_PtrMemI;
break;
10289 case tok::star: Opc =
BO_Mul;
break;
10290 case tok::slash: Opc =
BO_Div;
break;
10291 case tok::percent: Opc =
BO_Rem;
break;
10292 case tok::plus: Opc =
BO_Add;
break;
10293 case tok::minus: Opc =
BO_Sub;
break;
10294 case tok::lessless: Opc =
BO_Shl;
break;
10295 case tok::greatergreater: Opc =
BO_Shr;
break;
10296 case tok::lessequal: Opc =
BO_LE;
break;
10297 case tok::less: Opc =
BO_LT;
break;
10298 case tok::greaterequal: Opc =
BO_GE;
break;
10299 case tok::greater: Opc =
BO_GT;
break;
10300 case tok::exclaimequal: Opc =
BO_NE;
break;
10301 case tok::equalequal: Opc =
BO_EQ;
break;
10302 case tok::amp: Opc =
BO_And;
break;
10303 case tok::caret: Opc =
BO_Xor;
break;
10304 case tok::pipe: Opc =
BO_Or;
break;
10305 case tok::ampamp: Opc =
BO_LAnd;
break;
10306 case tok::pipepipe: Opc =
BO_LOr;
break;
10307 case tok::equal: Opc =
BO_Assign;
break;
10314 case tok::greatergreaterequal: Opc =
BO_ShrAssign;
break;
10318 case tok::comma: Opc =
BO_Comma;
break;
10327 default: llvm_unreachable(
"Unknown unary op!");
10328 case tok::plusplus: Opc =
UO_PreInc;
break;
10329 case tok::minusminus: Opc =
UO_PreDec;
break;
10331 case tok::star: Opc =
UO_Deref;
break;
10332 case tok::plus: Opc =
UO_Plus;
break;
10333 case tok::minus: Opc =
UO_Minus;
break;
10334 case tok::tilde: Opc =
UO_Not;
break;
10335 case tok::exclaim: Opc =
UO_LNot;
break;
10336 case tok::kw___real: Opc =
UO_Real;
break;
10337 case tok::kw___imag: Opc =
UO_Imag;
break;
10338 case tok::kw___extension__: Opc =
UO_Extension;
break;
10356 if (!LHSDeclRef || !RHSDeclRef ||
10358 RHSDeclRef->getLocation().isMacroID())
10363 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
10364 if (LHSDecl != RHSDecl)
10369 if (RefTy->getPointeeType().isVolatileQualified())
10372 S.
Diag(OpLoc, diag::warn_self_assignment)
10374 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
10384 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
10389 ObjCPointerExpr = LHS;
10393 ObjCPointerExpr = RHS;
10401 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
10402 unsigned Diag = diag::warn_objc_pointer_masking;
10411 if (SelArg0.startswith(
"performSelector"))
10412 Diag = diag::warn_objc_pointer_masking_performSelector;
10415 S.
Diag(OpLoc, Diag)
10416 << ObjCPointerExpr->getSourceRange();
10423 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
10424 return DRE->getDecl();
10425 if (
auto *ME = dyn_cast<MemberExpr>(E))
10426 return ME->getMemberDecl();
10427 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
10428 return IRE->getDecl();
10438 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
10450 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
10453 RHSExpr = Init.
get();
10468 LHS = CorrectDelayedTyposInExpr(LHSExpr);
10469 RHS = CorrectDelayedTyposInExpr(RHSExpr, [Opc, LHS](
Expr *
E) {
10476 if (!LHS.
isUsable() || !RHS.isUsable())
10480 if (getLangOpts().OpenCL) {
10485 SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
10487 Diag(OpLoc, diag::err_atomic_init_constant) << SR;
10489 ResultTy = InvalidOperands(OpLoc, LHS, RHS);
10496 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
10497 if (getLangOpts().CPlusPlus &&
10502 if (!ResultTy.
isNull()) {
10504 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
10510 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
10515 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
10519 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
10522 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
10525 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
10529 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
10535 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
true);
10539 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
false);
10545 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc);
10549 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
10553 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
10555 CompLHSTy = CompResultTy;
10557 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10560 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
10561 CompLHSTy = CompResultTy;
10563 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10566 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
10568 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10571 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
10573 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10577 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
10578 CompLHSTy = CompResultTy;
10580 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10586 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc,
true);
10587 CompLHSTy = CompResultTy;
10589 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10593 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
10594 VK = RHS.get()->getValueKind();
10595 OK = RHS.get()->getObjectKind();
10603 CheckArrayAccess(LHS.
get());
10604 CheckArrayAccess(RHS.get());
10607 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
10610 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
10611 SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getLocEnd());
10624 if (CompResultTy.
isNull())
10626 OK, OpLoc, FPFeatures.fp_contract);
10633 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
10634 OpLoc, FPFeatures.fp_contract);
10649 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
10650 if (isLeftComp == isRightComp)
10655 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
10656 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
10657 if (isLeftBitwise || isRightBitwise)
10663 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
10666 :
SourceRange(LHSExpr->getLocStart(), RHSBO->getLHS()->getLocEnd());
10668 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
10671 Self.
PDiag(diag::note_precedence_silence) << OpStr,
10672 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
10674 Self.
PDiag(diag::note_precedence_bitwise_first)
10687 << Bop->getSourceRange() << OpLoc;
10689 Self.
PDiag(diag::note_precedence_silence)
10691 Bop->getSourceRange());
10714 if (Bop->getOpcode() ==
BO_LAnd) {
10721 }
else if (Bop->getOpcode() ==
BO_LOr) {
10722 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
10736 if (Bop->getOpcode() ==
BO_LAnd) {
10753 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
10754 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
10756 << Bop->getSourceRange() << OpLoc;
10758 S.
PDiag(diag::note_precedence_silence)
10759 << Bop->getOpcodeStr(),
10760 Bop->getSourceRange());
10768 if (Bop->getOpcode() ==
BO_Add || Bop->getOpcode() ==
BO_Sub) {
10769 StringRef Op = Bop->getOpcodeStr();
10770 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
10771 << Bop->getSourceRange() << OpLoc << Shift << Op;
10773 S.
PDiag(diag::note_precedence_silence) << Op,
10774 Bop->getSourceRange());
10790 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
10793 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
10794 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange()
10795 << (Kind == OO_LessLess);
10797 S.
PDiag(diag::note_precedence_silence)
10798 << (Kind == OO_LessLess ?
"<<" :
">>"),
10801 S.
PDiag(diag::note_evaluate_comparison_first),
10803 RHSExpr->getLocEnd()));
10847 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
10848 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
10853 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
10867 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
10888 if (pty->getKind() == BuiltinType::PseudoObject &&
10890 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
10893 if (pty->getKind() == BuiltinType::Overload) {
10899 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
10901 RHSExpr = resolvedRHS.
get();
10908 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
10910 LHSExpr = LHS.
get();
10917 if (Opc ==
BO_Assign && pty->getKind() == BuiltinType::Overload) {
10924 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
10928 if (pty->getKind() == BuiltinType::Overload &&
10932 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
10934 RHSExpr = resolvedRHS.
get();
10951 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
10961 if (getLangOpts().OpenCL) {
10964 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10966 << Input.
get()->getSourceRange());
10982 resultType = CheckAddressOfOperand(Input, OpLoc);
10986 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
10993 Input = UsualUnaryConversions(Input.
get());
11006 else if (getLangOpts().CPlusPlus &&
11011 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11012 << resultType << Input.
get()->getSourceRange());
11015 Input = UsualUnaryConversions(Input.
get());
11024 Diag(OpLoc, diag::ext_integer_complement_complex)
11025 << resultType << Input.
get()->getSourceRange();
11034 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11035 << resultType << Input.
get()->getSourceRange());
11039 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11040 << resultType << Input.
get()->getSourceRange());
11046 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
11064 ScalarTypeToBooleanCastKind(resultType));
11070 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11071 << resultType << Input.
get()->getSourceRange());
11080 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11081 << resultType << Input.
get()->getSourceRange());
11084 resultType = GetSignedVectorType(resultType);
11087 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11088 << resultType << Input.
get()->getSourceRange());
11107 Input = DefaultLvalueConversion(Input.
get());
11125 CheckArrayAccess(Input.
get());
11135 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11136 if (!DRE->getQualifier())
11143 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
11146 return Method->isInstance();
11152 if (!ULE->getQualifier())
11157 if (Method->isInstance())
11177 if (pty->getKind() == BuiltinType::PseudoObject &&
11179 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
11183 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
11188 (pty->getKind() == BuiltinType::Overload ||
11189 pty->getKind() == BuiltinType::UnknownAny ||
11190 pty->getKind() == BuiltinType::BoundMember))
11191 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
11196 Input = Result.
get();
11209 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
11212 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
11215 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
11241 if (!cleanups)
return nullptr;
11257 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
11264 DiscardCleanupsInEvaluationContext();
11265 PopExpressionEvaluationContext();
11271 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
11274 if (hasAnyUnrecoverableErrorsInThisFunction())
11275 DiscardCleanupsInEvaluationContext();
11276 assert(!ExprNeedsCleanups &&
"cleanups within StmtExpr not correctly bound!");
11277 PopExpressionEvaluationContext();
11286 bool StmtExprMayBindToTemp =
false;
11291 while (
LabelStmt *Label = dyn_cast<LabelStmt>(LastStmt)) {
11292 LastLabelStmt = Label;
11293 LastStmt = Label->getSubStmt();
11296 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
11299 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
11311 if (
Expr *rebuiltLastStmt
11313 LastExpr = rebuiltLastStmt;
11315 LastExpr = PerformCopyInitialization(
11325 if (LastExpr.
get() !=
nullptr) {
11326 if (!LastLabelStmt)
11330 StmtExprMayBindToTemp =
true;
11339 if (StmtExprMayBindToTemp)
11340 return MaybeBindToTemporary(ResStmtExpr);
11341 return ResStmtExpr;
11356 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
11357 << ArgTy << TypeRange);
11362 && RequireCompleteType(BuiltinLoc, ArgTy,
11363 diag::err_offsetof_incomplete_type, TypeRange))
11370 if (Components.size() != 1)
11371 Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator)
11372 <<
SourceRange(Components[1].LocStart, Components.back().LocEnd);
11374 bool DidWarnAboutNonPOD =
false;
11379 if (OC.isBrackets) {
11384 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
11390 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
11400 diag::err_typecheck_subscript_not_integer)
11401 << Idx->getSourceRange());
11404 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
11405 Exprs.push_back(Idx);
11413 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
11419 if (RequireCompleteType(OC.LocStart, CurrentType,
11420 diag::err_offsetof_incomplete_type))
11426 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
11438 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
11440 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
11441 : diag::ext_offsetof_non_pod_type;
11443 if (!IsSafe && !DidWarnAboutNonPOD &&
11444 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
11446 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
11448 DidWarnAboutNonPOD =
true;
11452 LookupResult R(*
this, OC.U.IdentInfo, OC.LocStart, LookupMemberName);
11453 LookupQualifiedName(R, RD);
11458 MemberDecl = IndirectMemberDecl->getAnonField();
11463 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
11471 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
11479 if (IndirectMemberDecl)
11480 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
11487 if (Paths.getDetectedVirtual()) {
11488 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
11499 if (IndirectMemberDecl) {
11500 for (
auto *FI : IndirectMemberDecl->chain()) {
11501 assert(isa<FieldDecl>(FI));
11503 cast<FieldDecl>(FI), OC.LocEnd));
11506 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
11512 Comps, Exprs, RParenLoc);
11523 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
11530 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
11538 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
11543 bool ValueDependent =
false;
11544 bool CondIsTrue =
false;
11547 ValueDependent =
true;
11550 llvm::APSInt condEval(32);
11552 = VerifyIntegerConstantExpression(CondExpr, &condEval,
11553 diag::err_typecheck_choose_expr_requires_constant,
false);
11556 CondExpr = CondICE.
get();
11557 CondIsTrue = condEval.getZExtValue();
11560 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
11562 resType = ActiveExpr->
getType();
11569 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
11581 if (LangOpts.CPlusPlus) {
11582 Decl *ManglingContextDecl;
11585 ManglingContextDecl)) {
11586 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
11591 PushBlockScope(CurScope, Block);
11592 CurContext->addDecl(Block);
11594 PushDeclContext(CurScope, Block);
11596 CurContext = Block;
11598 getCurBlock()->HasImplicitReturnType =
true;
11602 PushExpressionEvaluationContext(PotentiallyEvaluated);
11608 "block-id should have no identifier!");
11612 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
11617 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
11630 "GetTypeForDeclarator made a non-function block signature");
11641 if (ExplicitSignature.getLocalRangeBegin() ==
11642 ExplicitSignature.getLocalRangeEnd()) {
11654 CurBlock->TheDecl->setSignatureAsWritten(Sig);
11655 CurBlock->FunctionType = T;
11660 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
11662 CurBlock->TheDecl->setIsVariadic(isVariadic);
11669 CurBlock->ReturnType = RetTy;
11670 CurBlock->TheDecl->setBlockMissingReturnType(
false);
11671 CurBlock->HasImplicitReturnType =
false;
11676 if (ExplicitSignature) {
11677 for (
unsigned I = 0,
E = ExplicitSignature.getNumParams();
I !=
E; ++
I) {
11682 !getLangOpts().CPlusPlus)
11684 Params.push_back(Param);
11690 for (
const auto &
I : Fn->param_types()) {
11693 Params.push_back(Param);
11698 if (!Params.empty()) {
11699 CurBlock->TheDecl->setParams(Params);
11700 CheckParmsForFunctionDef(CurBlock->TheDecl->param_begin(),
11701 CurBlock->TheDecl->param_end(),
11706 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
11709 for (
auto AI : CurBlock->TheDecl->params()) {
11710 AI->setOwningFunction(CurBlock->TheDecl);
11713 if (AI->getIdentifier()) {
11714 CheckShadow(CurBlock->TheScope, AI);
11716 PushOnScopeChains(AI, CurBlock->TheScope);
11725 DiscardCleanupsInEvaluationContext();
11726 PopExpressionEvaluationContext();
11730 PopFunctionScopeInfo();
11738 if (!LangOpts.Blocks)
11739 Diag(CaretLoc, diag::err_blocks_disable);
11742 if (hasAnyUnrecoverableErrorsInThisFunction())
11743 DiscardCleanupsInEvaluationContext();
11744 assert(!ExprNeedsCleanups &&
"cleanups within block not correctly bound!");
11745 PopExpressionEvaluationContext();
11747 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
11750 deduceClosureReturnType(*BSI);
11769 Captures.push_back(NewCap);
11778 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
11781 if (isa<FunctionNoProtoType>(FTy)) {
11813 if (getCurFunction()->NeedsScopeChecking() &&
11814 !PP.isCodeCompletionEnabled())
11815 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
11824 computeNRVO(Body, BSI);
11828 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
11835 ExprNeedsCleanups =
true;
11840 const VarDecl *var = CI.getVariable();
11842 getCurFunction()->setHasBranchProtectedScope();
11855 GetTypeFromParser(Ty, &TInfo);
11856 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
11862 Expr *OrigExpr =
E;
11891 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
11897 if (Init.isInvalid())
11899 E = Init.getAs<
Expr>();
11912 diag::err_first_argument_to_va_arg_not_of_type_va_list)
11913 << OrigExpr->
getType() << E->getSourceRange());
11917 diag::err_second_parameter_to_va_arg_incomplete,
11923 diag::err_second_parameter_to_va_arg_abstract,
11930 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
11931 : diag::warn_second_parameter_to_va_arg_not_pod)
11948 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
11970 llvm_unreachable(
"I don't know size of pointer!");
11997 if (OV->getSourceExpr())
12011 const Expr *SrcExpr) {
12026 SrcExpr->getLocStart());
12033 bool *Complained) {
12035 *Complained =
false;
12038 bool CheckInferredResultType =
false;
12040 unsigned DiagKind = 0;
12043 bool MayHaveConvFixit =
false;
12044 bool MayHaveFunctionDiff =
false;
12054 DiagKind = diag::ext_typecheck_convert_pointer_int;
12056 MayHaveConvFixit =
true;
12059 DiagKind = diag::ext_typecheck_convert_int_pointer;
12061 MayHaveConvFixit =
true;
12066 diag::err_arc_typecheck_convert_incompatible_pointer :
12067 diag::ext_typecheck_convert_incompatible_pointer);
12070 if (Hint.
isNull() && !CheckInferredResultType) {
12073 else if (CheckInferredResultType) {
12077 MayHaveConvFixit =
true;
12080 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
12083 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
12092 DiagKind = diag::err_typecheck_incompatible_address_space;
12097 DiagKind = diag::err_typecheck_incompatible_ownership;
12101 llvm_unreachable(
"unknown error case for discarding qualifiers!");
12117 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
12120 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
12123 DiagKind = diag::err_int_to_block_pointer;
12126 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
12132 for (
auto *srcProto : srcOPT->
quals()) {
12138 IFace = IFaceT->getDecl();
12143 for (
auto *dstProto : dstOPT->
quals()) {
12149 IFace = IFaceT->getDecl();
12151 DiagKind = diag::warn_incompatible_qualified_id;
12155 DiagKind = diag::warn_incompatible_vectors;
12158 DiagKind = diag::err_arc_weak_unavailable_assign;
12163 *Complained =
true;
12167 DiagKind = diag::err_typecheck_convert_incompatible;
12169 MayHaveConvFixit =
true;
12171 MayHaveFunctionDiff =
true;
12180 FirstType = DstType;
12181 SecondType = SrcType;
12191 FirstType = SrcType;
12192 SecondType = DstType;
12198 FDiag << FirstType << SecondType <<
AA_Passing << SrcExpr->getSourceRange();
12200 FDiag << FirstType << SecondType << Action << SrcExpr->getSourceRange();
12204 if (!ConvHints.
isNull()) {
12210 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
12212 if (MayHaveFunctionDiff)
12216 if (DiagKind == diag::warn_incompatible_qualified_id &&
12218 Diag(IFace->
getLocation(), diag::not_incomplete_class_and_qualified_id)
12225 if (CheckInferredResultType)
12232 *Complained =
true;
12237 llvm::APSInt *Result) {
12241 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
12249 llvm::APSInt *Result,
12256 IDDiagnoser(
unsigned DiagID)
12260 S.
Diag(Loc, DiagID) << SR;
12262 } Diagnoser(DiagID);
12269 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
12287 CXX11ConvertDiagnoser(
bool Silent)
12293 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
12298 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
12303 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
12314 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
12325 llvm_unreachable(
"conversion functions are permitted");
12327 } ConvertDiagnoser(Diagnoser.
Suppress);
12333 E = Converted.
get();
12353 EvalResult.
Diag = &Notes;
12372 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
12373 diag::note_invalid_subexpr_in_const_expr) {
12374 DiagLoc = Notes[0].first;
12378 if (!Folded || !AllowFold) {
12388 Diagnoser.
diagnoseFold(*
this, DiagLoc, E->getSourceRange());
12400 class TransformToPE :
public TreeTransform<TransformToPE> {
12404 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
12407 bool AlwaysRebuild() {
return true; }
12414 return BaseTransform::TransformLabelStmt(S);
12425 if (isa<FieldDecl>(E->
getDecl()) &&
12426 !SemaRef.isUnevaluatedContext())
12428 diag::err_invalid_non_static_member_use)
12429 << E->
getDecl() << E->getSourceRange();
12431 return BaseTransform::TransformDeclRefExpr(E);
12439 return BaseTransform::TransformUnaryOperator(E);
12451 "Should only transform unevaluated expressions");
12456 return TransformToPE(*this).TransformExpr(E);
12461 Decl *LambdaContextDecl,
12490 D = diag::err_lambda_unevaluated_operand;
12496 D = diag::err_lambda_in_constant_expression;
12498 for (
const auto *L : Rec.
Lambdas)
12499 Diag(L->getLocStart(), D);
12503 for (
auto *Lambda : Rec.
Lambdas) {
12504 for (
auto *
C : Lambda->capture_inits())
12533 assert(NumTypos == 0 &&
"There are outstanding typos after popping the "
12534 "last ExpressionEvaluationContextRecord");
12578 llvm_unreachable(
"Invalid context");
12585 assert(Func &&
"No function?");
12597 if (Func->
isUsed(
false) ||
12631 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
12632 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
12633 if (Constructor->isDefaultConstructor()) {
12634 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
12637 }
else if (Constructor->isCopyConstructor()) {
12639 }
else if (Constructor->isMoveConstructor()) {
12642 }
else if (Constructor->getInheritedConstructor()) {
12646 dyn_cast<CXXDestructorDecl>(Func)) {
12647 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
12648 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
12649 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
12653 if (Destructor->isVirtual() &&
getLangOpts().AppleKext)
12655 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
12656 if (MethodDecl->isOverloadedOperator() &&
12657 MethodDecl->getOverloadedOperator() == OO_Equal) {
12658 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
12659 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
12660 if (MethodDecl->isCopyAssignmentOperator())
12665 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
12666 MethodDecl->getParent()->isLambda()) {
12668 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
12673 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
12687 if (!OdrUse)
return;
12692 bool AlreadyInstantiated =
false;
12696 if (SpecInfo->getPointOfInstantiation().isInvalid())
12697 SpecInfo->setPointOfInstantiation(Loc);
12698 else if (SpecInfo->getTemplateSpecializationKind()
12700 AlreadyInstantiated =
true;
12701 PointOfInstantiation = SpecInfo->getPointOfInstantiation();
12705 if (MSInfo->getPointOfInstantiation().isInvalid())
12706 MSInfo->setPointOfInstantiation(Loc);
12707 else if (MSInfo->getTemplateSpecializationKind()
12709 AlreadyInstantiated =
true;
12710 PointOfInstantiation = MSInfo->getPointOfInstantiation();
12714 if (!AlreadyInstantiated || Func->
isConstexpr()) {
12719 std::make_pair(Func, PointOfInstantiation));
12727 PointOfInstantiation));
12734 for (
auto i : Func->
redecls()) {
12735 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
12742 if (mightHaveNonExternalLinkage(Func))
12771 if (isa<ParmVarDecl>(var) &&
12772 isa<TranslationUnitDecl>(VarDC))
12785 if (isa<CXXMethodDecl>(VarDC) &&
12786 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
12787 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_lambda)
12789 }
else if (
FunctionDecl *fn = dyn_cast<FunctionDecl>(VarDC)) {
12790 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_function)
12792 }
else if (isa<BlockDecl>(VarDC)) {
12793 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_block)
12798 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_context)
12811 bool &SubCapturesAreNested,
12817 SubCapturesAreNested =
true;
12830 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
12831 !(isa<CapturedRegionScopeInfo>(CSI) &&
12832 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
12843 const bool Diagnose,
Sema &S) {
12858 const bool Diagnose,
Sema &S) {
12860 bool IsBlock = isa<BlockScopeInfo>(CSI);
12861 bool IsLambda = isa<LambdaScopeInfo>(CSI);
12869 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
12878 S.
Diag(Loc, diag::err_ref_vm_type);
12887 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
12890 S.
Diag(Loc, diag::err_ref_flexarray_type);
12892 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
12900 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
12903 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
12905 S.
Diag(Loc, diag::err_capture_block_variable)
12919 const bool BuildAndDiagnose,
12924 Expr *CopyExpr =
nullptr;
12925 bool ByRef =
false;
12929 if (BuildAndDiagnose) {
12930 S.
Diag(Loc, diag::err_ref_array_type);
12939 if (BuildAndDiagnose) {
12940 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
12947 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
12955 DeclRefType = CaptureType;
12957 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
12964 if (isa<ParmVarDecl>(Var))
12981 CaptureType,
false),
12988 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
12991 CopyExpr = Result.
get();
12998 if (BuildAndDiagnose)
12999 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
13011 const bool BuildAndDiagnose,
13014 const bool RefersToCapturedVariable,
13029 CaptureType = DeclRefType;
13031 Expr *CopyExpr =
nullptr;
13032 if (BuildAndDiagnose) {
13053 if (BuildAndDiagnose)
13054 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
13066 bool RefersToCapturedVariable) {
13083 const bool BuildAndDiagnose,
13086 const bool RefersToCapturedVariable,
13089 const bool IsTopScope,
13093 bool ByRef =
false;
13127 if (!RefType->getPointeeType()->isFunctionType())
13133 if (BuildAndDiagnose) {
13134 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
13142 if (BuildAndDiagnose) {
13145 diag::err_capture_of_incomplete_type,
13150 diag::err_capture_of_abstract_type))
13156 if (BuildAndDiagnose)
13158 RefersToCapturedVariable);
13175 if (BuildAndDiagnose)
13176 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
13177 Loc, EllipsisLoc, CaptureType,
nullptr);
13185 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
13193 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
13197 if (FunctionScopeIndexToStopAt) {
13199 while (FSIndex != MaxFunctionScopesIndex) {
13208 if (VarDC == DC)
return true;
13224 CaptureType = Var->
getType();
13226 bool Nested =
false;
13228 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
13229 unsigned OpenMPLevel = 0;
13242 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
13261 if (BuildAndDiagnose) {
13284 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
13285 QTy = PVD->getOriginalType();
13290 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
13300 FunctionScopesIndex--;
13303 Nested = !isTargetCap;
13315 if (BuildAndDiagnose) {
13319 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
13320 diag::note_lambda_decl);
13336 FunctionScopesIndex--;
13339 }
while (!VarDC->
Equals(DC));
13346 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1;
I != N;
13352 BuildAndDiagnose, CaptureType,
13353 DeclRefType, Nested, *
this))
13358 BuildAndDiagnose, CaptureType,
13359 DeclRefType, Nested, *
this))
13365 BuildAndDiagnose, CaptureType,
13366 DeclRefType, Nested, Kind, EllipsisLoc,
13367 I == N - 1, *
this))
13381 DeclRefType,
nullptr);
13388 false, CaptureType,
13389 DeclRefType,
nullptr);
13398 false, CaptureType,
13399 DeclRefType,
nullptr))
13402 return DeclRefType;
13416 const VarDecl *DefVD =
nullptr;
13443 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
13444 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
13445 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
13446 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
13449 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
13471 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13472 Var = cast<VarDecl>(DRE->getDecl());
13473 Loc = DRE->getLocation();
13474 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
13475 Var = cast<VarDecl>(ME->getMemberDecl());
13476 Loc = ME->getMemberLoc();
13478 llvm_unreachable(
"Unexpected expression");
13485 MaybeODRUseExprs.clear();
13491 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
13492 "Invalid Expr argument to DoMarkVarDeclReferenced");
13496 bool MarkODRUsed =
true;
13510 const bool RefersToEnclosingScope =
13513 if (RefersToEnclosingScope) {
13523 assert(E &&
"Capture variable should be used in an expression.");
13534 MarkODRUsed =
false;
13539 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
13540 "Can't instantiate a partial template specialization.");
13549 if (TryInstantiating && !isa<VarTemplateSpecializationDecl>(Var)) {
13553 L->StaticDataMemberInstantiated(Var);
13557 TryInstantiating =
false;
13563 if (TryInstantiating) {
13565 bool InstantiationDependent =
false;
13566 bool IsNonDependent =
13572 if (IsNonDependent) {
13579 .push_back(std::make_pair(Var, PointOfInstantiation));
13585 if(!MarkODRUsed)
return;
13614 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
13630 bool IsVirtualCall = MD->
isVirtual() &&
13632 if (!IsVirtualCall)
13636 if (!MostDerivedClassDecl)
13639 if (!DM || DM->
isPure())
13649 bool OdrUse =
true;
13651 if (Method->isVirtual())
13664 bool OdrUse =
true;
13667 if (Method->isPure())
13681 if (
auto *VD = dyn_cast<VarDecl>(D)) {
13686 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
13711 bool MarkReferencedDecls::TraverseTemplateArgument(
13715 S.MarkAnyDeclReferenced(Loc, D,
true);
13718 return Inherited::TraverseTemplateArgument(Arg);
13721 bool MarkReferencedDecls::TraverseRecordType(
RecordType *T) {
13723 = dyn_cast<ClassTemplateSpecializationDecl>(T->
getDecl())) {
13725 return TraverseTemplateArguments(Args.
data(), Args.
size());
13732 MarkReferencedDecls Marker(*
this, Loc);
13741 bool SkipLocalVariables;
13746 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
13747 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
13751 if (SkipLocalVariables) {
13753 if (VD->hasLocalStorage())
13757 S.MarkDeclRefReferenced(E);
13761 S.MarkMemberReferenced(E);
13762 Inherited::VisitMemberExpr(E);
13776 Inherited::VisitCXXNewExpr(E);
13784 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
13786 S.LookupDestructor(Record));
13789 Inherited::VisitCXXDeleteExpr(E);
13794 Inherited::VisitCXXConstructExpr(E);
13802 Inherited::VisitImplicitCastExpr(E);
13805 S.UpdateMarkingForLValueToRValue(E->
getSubExpr());
13816 bool SkipLocalVariables) {
13817 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
13875 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
13881 : FD(FD), CE(CE) { }
13885 S.
Diag(Loc, diag::err_call_incomplete_return)
13886 << T << CE->getSourceRange();
13890 S.
Diag(Loc, diag::err_call_function_incomplete_return)
13891 << CE->getSourceRange() << FD->
getDeclName() << T;
13895 } Diagnoser(FD, CE);
13908 unsigned diagnostic = diag::warn_condition_is_assignment;
13909 bool IsOrAssign =
false;
13919 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
13924 diagnostic = diag::warn_condition_is_idiomatic_assignment;
13928 diagnostic = diag::warn_condition_is_idiomatic_assignment;
13931 Loc = Op->getOperatorLoc();
13933 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
13936 IsOrAssign = Op->getOperator() == OO_PipeEqual;
13937 Loc = Op->getOperatorLoc();
13945 Diag(Loc, diagnostic) << E->getSourceRange();
13949 Diag(Loc, diag::note_condition_assign_silence)
13954 Diag(Loc, diag::note_condition_or_assign_to_comparison)
13957 Diag(Loc, diag::note_condition_assign_to_comparison)
13975 if (opE->getOpcode() ==
BO_EQ &&
13976 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
13980 Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
13981 SourceRange ParenERange = ParenE->getSourceRange();
13982 Diag(Loc, diag::note_equality_comparison_silence)
13985 Diag(Loc, diag::note_equality_comparison_to_assign)
13992 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
14010 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
14011 << T << E->getSourceRange();
14014 CheckBoolLikeConversion(E, Loc);
14031 struct RebuildUnknownAnyFunction
14032 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
14036 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
14039 llvm_unreachable(
"unexpected statement!");
14043 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
14044 << E->getSourceRange();
14050 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
14051 ExprResult SubResult = Visit(E->getSubExpr());
14054 Expr *SubExpr = SubResult.
get();
14055 E->setSubExpr(SubExpr);
14056 E->setType(SubExpr->
getType());
14063 return rebuildSugarExpr(E);
14067 return rebuildSugarExpr(E);
14074 Expr *SubExpr = SubResult.
get();
14083 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
14088 if (S.getLangOpts().CPlusPlus &&
14089 !(isa<CXXMethodDecl>(VD) &&
14090 cast<CXXMethodDecl>(VD)->isInstance()))
14101 return resolveDecl(E, E->
getDecl());
14119 struct RebuildUnknownAnyExpr
14120 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
14128 : S(S), DestType(CastType) {}
14131 llvm_unreachable(
"unexpected statement!");
14135 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
14136 << E->getSourceRange();
14145 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
14146 ExprResult SubResult = Visit(E->getSubExpr());
14148 Expr *SubExpr = SubResult.
get();
14149 E->setSubExpr(SubExpr);
14150 E->setType(SubExpr->
getType());
14157 return rebuildSugarExpr(E);
14161 return rebuildSugarExpr(E);
14168 << E->getSourceRange();
14192 return resolveDecl(E, E->
getDecl());
14203 FK_FunctionPointer,
14209 if (CalleeType == S.Context.BoundMemberTy) {
14210 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
14211 Kind = FK_MemberFunction;
14215 Kind = FK_FunctionPointer;
14218 Kind = FK_BlockPointer;
14223 if (DestType->isArrayType() || DestType->isFunctionType()) {
14224 unsigned diagID = diag::err_func_returning_array_function;
14225 if (Kind == FK_BlockPointer)
14226 diagID = diag::err_block_returning_array_function;
14229 << DestType->isFunctionType() << DestType;
14234 E->
setType(DestType.getNonLValueExprType(S.Context));
14262 if (ParamTypes.empty() && Proto->isVariadic()) {
14264 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
14268 ArgType = S.Context.getLValueReferenceType(ArgType);
14270 ArgType = S.Context.getRValueReferenceType(ArgType);
14272 ArgTypes.push_back(ArgType);
14274 ParamTypes = ArgTypes;
14276 DestType = S.Context.getFunctionType(DestType, ParamTypes,
14277 Proto->getExtProtoInfo());
14279 DestType = S.Context.getFunctionNoProtoType(DestType,
14285 case FK_MemberFunction:
14289 case FK_FunctionPointer:
14290 DestType = S.Context.getPointerType(DestType);
14293 case FK_BlockPointer:
14294 DestType = S.Context.getBlockPointerType(DestType);
14299 ExprResult CalleeResult = Visit(CalleeExpr);
14304 return S.MaybeBindToTemporary(E);
14309 if (DestType->isArrayType() || DestType->isFunctionType()) {
14310 S.Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
14311 << DestType->isFunctionType() << DestType;
14317 assert(Method->getReturnType() == S.Context.UnknownAnyTy);
14318 Method->setReturnType(DestType);
14322 E->
setType(DestType.getNonReferenceType());
14325 return S.MaybeBindToTemporary(E);
14337 DestType = DestType->castAs<
PointerType>()->getPointeeType();
14348 assert(isa<BlockPointerType>(E->
getType()));
14353 DestType = S.Context.getLValueReferenceType(DestType);
14361 llvm_unreachable(
"Unhandled cast type!");
14377 return S.ImpCastExprToType(Result.
get(), Type,
14382 S.Diag(E->
getExprLoc(), diag::err_unknown_any_function)
14383 << VD << E->getSourceRange();
14394 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
14397 FD->getDeclContext(),
14398 Loc, Loc, FD->getNameInfo().getName(),
14399 DestType, FD->getTypeSourceInfo(),
14401 FD->hasPrototype(),
14404 if (FD->getQualifier())
14408 for (
const auto &AI : FT->param_types()) {
14410 S.BuildParmVarDeclForTypedef(FD, Loc, AI);
14412 Params.push_back(Param);
14414 NewFD->setParams(Params);
14415 DRE->setDecl(NewFD);
14416 VD = DRE->getDecl();
14421 if (MD->isInstance()) {
14423 Type = S.Context.BoundMemberTy;
14427 if (!S.getLangOpts().CPlusPlus)
14431 }
else if (isa<VarDecl>(VD)) {
14435 S.Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
14436 << VD << E->getSourceRange();
14442 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_decl)
14443 << VD << E->getSourceRange();
14461 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
14464 CastExpr = result.
get();
14472 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
14500 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
14503 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
14504 E = call->getCallee();
14505 diagID = diag::err_uncasted_call_of_unknown_any;
14513 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
14514 loc = ref->getLocation();
14515 d = ref->getDecl();
14516 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
14517 loc = mem->getMemberLoc();
14518 d = mem->getMemberDecl();
14520 diagID = diag::err_uncasted_call_of_unknown_any;
14521 loc = msg->getSelectorStartLoc();
14522 d = msg->getMethodDecl();
14524 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
14525 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
14526 << orig->getSourceRange();
14531 << E->getSourceRange();
14535 S.
Diag(loc, diagID) << d << orig->getSourceRange();
14554 if (!placeholderType)
return E;
14556 switch (placeholderType->
getKind()) {
14559 case BuiltinType::Overload: {
14575 case BuiltinType::BoundMember: {
14580 if (isa<CXXPseudoDestructorExpr>(BME)) {
14581 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
14582 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
14583 if (ME->getMemberNameInfo().getName().getNameKind() ==
14585 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
14593 case BuiltinType::ARCUnbridgedCast: {
14600 case BuiltinType::UnknownAny:
14604 case BuiltinType::PseudoObject:
14607 case BuiltinType::BuiltinFn: {
14611 auto *FD = cast<FunctionDecl>(DRE->getDecl());
14612 if (FD->getBuiltinID() == Builtin::BI__noop) {
14620 Diag(E->getLocStart(), diag::err_builtin_fn_use);
14625 case BuiltinType::OMPArraySection:
14626 Diag(E->getLocStart(), diag::err_omp_array_section_use);
14630 #define BUILTIN_TYPE(Id, SingletonId) \
14631 case BuiltinType::Id:
14632 #define PLACEHOLDER_TYPE(Id, SingletonId)
14633 #include "clang/AST/BuiltinTypes.def"
14637 llvm_unreachable(
"invalid placeholder type!");
14651 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
14652 "Unknown Objective-C Boolean value!");
Abstract class used to diagnose incomplete types.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
SourceLocation getLocStart() const LLVM_READONLY
unsigned getNumElements() const
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
Return the address space of this type.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
const ComplexType * getAsComplexIntegerType() const
SourceLocation getRParenLoc() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
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 hasDefinition() const
Determine whether this class has been defined.
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
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.
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)
SourceLocation getEnd() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
const Expr * getBase() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
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)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
static void diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, VarDecl *var, DeclContext *DC)
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.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
Scope * getCurScope() const
Retrieve the parser's current scope.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
bool isNullPtrType() const
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Smart pointer class that efficiently represents Objective-C method names.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
A class which contains all the information about a particular captured value.
bool isCXX98PODType(ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension...
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
A (possibly-)qualified type.
bool isConstantArrayType() 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)
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
bool isThisCapture() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
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.
ObjCInterfaceDecl * getClassInterface()
bool isBitField() const
Determines whether this field is a bitfield.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
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.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
bool isMemberPointerType() const
SourceLocation getLocation() const
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
TheContext getContext() const
static const CastKind CK_Invalid
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Hande arithmetic conversion from integer to float.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Expr * getInitExpr() const
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
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.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
DeclClass * getAsSingle() const
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
SourceLocation getEndLoc() const
getEndLoc - Retrieve the location of the last token.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
FunctionType - C99 6.7.5.3 - Function Declarators.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
unsigned getIntWidth(QualType T) const
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
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.
static bool IsReadonlyMessage(Expr *E, Sema &S)
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Defines the SourceManager interface.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
void addConst()
Add the const type qualifier to this QualType.
ActionResult< Expr * > ExprResult
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
The current expression is potentially evaluated at run time, which means that code may be generated t...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
bool isRecordType() const
bool isMultiplicativeOp() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Decl - This represents one declaration (or definition), e.g.
bool 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.
SourceLocation getLocStart() const LLVM_READONLY
ExprResult CheckBooleanCondition(Expr *E, SourceLocation Loc)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
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.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
param_iterator param_end()
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...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Defines the C++ template declaration subclasses.
bool isVoidPointerType() const
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Represents a C++11 auto or C++14 decltype(auto) type.
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...
bool isEnumeralType() const
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
ParenExpr - This represents a parethesized expression, e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
bool CheckVecStepExpr(Expr *E)
std::string getAsString() const
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)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
CanQualType ARCUnbridgedCastTy
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
bool isObjCQualifiedClassType() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
std::unique_ptr< llvm::MemoryBuffer > Buffer
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
const Expr * getInit() const
void MarkDeclRefReferenced(DeclRefExpr *E)
Perform reference-marking and odr-use handling for a DeclRefExpr.
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr * > Args)
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
CK_FloatingToIntegral - Floating point to integral.
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST...
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 isBooleanType() const
TemplateNameKind Kind
The kind of template that Template refers to.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
A container of type source information.
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
SourceLocation getOperatorLoc() const
SourceLocation getLocStart() const LLVM_READONLY
MS property subscript expression.
bool isBlockPointerType() const
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
static bool IsWithinTemplateSpecialization(Decl *D)
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
Wrapper for source info for pointers decayed from arrays and functions.
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
Abstract base class used for diagnosing integer constant expression violations.
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
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.
const llvm::APInt & getSize() const
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
CK_IntegralToFloating - Integral to floating point.
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.
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)
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
RAII object that enters a new expression evaluation context.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CK_IntegralCast - A cast between integral types (other than to boolean).
visible_categories_range visible_categories() const
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
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()
CompoundLiteralExpr - [C99 6.5.2.5].
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
bool hasCaptures() const
hasCaptures - True if this block (or its nested blocks) captures anything of local storage from its e...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
Extra information about a function prototype.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
AutoTypeKeyword getKeyword() const
bool isUnresolvableResult() const
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...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
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.
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()
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
const BuiltinType * getAsPlaceholderType() const
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
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.
unsigned getValue() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
std::vector< FixItHint > Hints
The list of Hints generated so far.
ParmVarDecl - Represents a parameter to a function.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
SourceLocation getLocation() const
bool isEmpty() const
No scope specifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
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.
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
QualType withConst() const
Retrieves a version of this type with const applied.
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.
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.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS)
Create a binary operation that may resolve to an overloaded operator.
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.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool OdrUse)
Perform marking for a reference to an arbitrary declaration.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType CondTy, SourceLocation QuestionLoc)
Convert scalar operands to a vector that matches the condition in length.
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
bool isComparisonOp() const
bool hasUninstantiatedDefaultArg() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
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...
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
bool isScalarType() const
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension...
bool isOpenMPTargetCapturedVar(VarDecl *VD, unsigned Level)
Check if the specified variable is captured by 'target' directive.
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Represents a class type in Objective C.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
A vector component is an element or range of elements on a vector.
Expr * getSizeExpr() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
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.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
Converts between different integral complex types.
ArrayRef< QualType > getParamTypes() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
ObjCMethodFamily
A family of Objective-C methods.
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getReturnType() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isAnyPointerType() const
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly...
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
bool isOverloaded() const
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
bool isPure() const
Whether this virtual function is pure, i.e.
static void checkUnusedDeclAttributes(Sema &S, const AttributeList *A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
SourceLocation getLocEnd() const LLVM_READONLY
unsigned size() const
Retrieve the number of template arguments in this template argument list.
unsigned getCVRQualifiers() 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...
SourceRange getLocalSourceRange() const
Get the local source range.
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CK_FloatingCast - Casting between floating types of different size.
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
Token - This structure provides full information about a lexed token.
CK_VectorSplat - A conversion from an arithmetic type to a vector of that element type...
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)
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, VarDecl *Var, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
void setKind(tok::TokenKind K)
VarDecl * getVariable() const
SourceLocation getLocStart() const LLVM_READONLY
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
bool isOpenMPPrivateVar(VarDecl *VD, unsigned Level)
Check if the specified variable is used in 'private' clause.
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 isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
bool isParamConsumed(unsigned I) const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
void PopExpressionEvaluationContext()
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceRange getExprRange(Expr *E) const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
CK_PointerToIntegral - Pointer to integral.
CK_IntegralToPointer - Integral to pointer.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Converts a floating point complex to bool by comparing against 0+0i.
ExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc, Expr *SubExpr)
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
A location where the result (returned value) of evaluating a statement should be stored.
SourceLocation getBeginLoc() const
Get the begin source location.
Describes an C or C++ initializer list.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
CK_IntegralToBoolean - Integral to boolean.
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)
uint32_t getCodeUnit(size_t i) const
QualType getCallResultType(ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
Represents a C++ unqualified-id that has been parsed.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool OdrUse)
param_type_range param_types() const
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
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...
const TargetInfo & getTargetInfo() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
QualType getOriginalType() const
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)
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
const LangOptions & getLangOpts() const
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool HasFormOfMemberPointer
unsigned getLength() const
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.
Qualifiers withoutObjCGCAttr() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
QualType getReturnType() const
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
field_range fields() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
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.
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
An implicit 'self' parameter.
CanQualType PseudoObjectTy
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() const
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
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)
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
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...
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
bool CanUseDecl(NamedDecl *D)
Determine whether the use of this declaration is valid, without emitting diagnostics.
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...
TypeClass getTypeClass() const
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
Helper class for OffsetOfExpr.
Represents an Objective-C protocol declaration.
QualType getDestroyedType() const
Retrieve the type being destroyed.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Represents binding an expression to a temporary.
tok::TokenKind getKind() const
CXXTemporary * getTemporary()
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
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...
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'.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
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 depth-first traversal on the entire Clang AST and visits each node...
Represents an ObjC class declaration.
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
bool isExtVectorType() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
static QualType getBaseOriginalType(Expr *Base)
Return original type of the base expression for array section.
detail::InMemoryDirectory::const_iterator I
IncompatiblePointer - The assignment is between two pointers types which point to integers which have...
bool isEqualityOp() const
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
SourceLocation getLParenLoc() const
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
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).
bool ExprNeedsCleanups
ExprNeedsCleanups - True if the current evaluation context requires cleanups to be run at its conclus...
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
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
static void CheckForNullPointerDereference(Sema &S, Expr *E)
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
void ActOnStmtExprError()
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID)
Lookup a property by name in the specified DeclContext.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
AvailabilityResult
Captures the result of checking the availability of a declaration.
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
EnumDecl * getDecl() const
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
bool isBlockCapture() const
CXXSpecialMember
Kinds of C++ special members.
OverloadFixItKind Kind
The type of fix applied.
OpenMP 4.0 [2.4, Array Sections].
FunctionDecl * getOperatorDelete() const
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ConditionalOperator - The ?: ternary operator.
AvailabilityResult getAvailability(std::string *Message=nullptr) const
Determine the availability of the given declaration.
ExtInfo getExtInfo() const
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 isAssignmentOp() const
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
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 }.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
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...
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceLocation getLocStart() const LLVM_READONLY
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...
static QualType checkOpenCLVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when an OpenCL vector is shifted by a scalar or vector shift amount...
Retains information about a captured region.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
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...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
CastKind
CastKind - The kind of operation required for a conversion.
static bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
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)
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
Represents a call to the builtin function __builtin_va_arg.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
FunctionDecl * getOperatorDelete() const
ID
Defines the set of possible language-specific address spaces.
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
CK_FunctionToPointerDecay - Function to pointer decay.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
SourceLocation getOpLoc() const
bool isFunctionPointerType() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Converts between different floating point complex types.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
bool isRealFloatingType() const
Floating point categories.
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
const ObjCMethodDecl * getMethodDecl() const
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition...
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
LabelDecl * getDecl() const
unsigned getNumExprs() const
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
bool isDeleted() const
Whether this function has been deleted.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const Type * getTypeForDecl() const
unsigned param_size() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
Expr - This represents one expression.
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 isOrdinaryOrBitFieldObject() const
DeclarationName getLookupName() const
Gets the name to look up.
CK_PointerToBoolean - Pointer to boolean conversion.
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
const Expr * getExpr(unsigned Init) const
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
Represents a character-granular source range.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
bool isAnyComplexType() const
bool isObjCClassType() const
static bool EvaluatesAsTrue(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'true'.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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.
bool isAtomicType() const
static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
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...
Represents a C++ destructor within a class.
CanQualType OMPArraySectionTy
SourceRange getSourceRange() const
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isVariableArrayType() const
Defines the clang::Preprocessor interface.
SmallVectorImpl< OverloadCandidate >::iterator iterator
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 ...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
ExtProtoInfo getExtProtoInfo() const
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
IncompatibleVectors - The assignment is between two vector types that have the same size...
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr * > Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DeclContext * getDeclContext()
Overload resolution succeeded.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
bool isFloatingType() const
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.
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...
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 ...
ImplicitParamDecl * getSelfDecl() const
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.
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
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 RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
llvm::DenseMap< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Defines the clang::TypeLoc interface and its subclasses.
bool isObjCIdType() const
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void DiscardCleanupsInEvaluationContext()
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
ASTMutationListener * getASTMutationListener() const
QualType getType() const
Get the type for which this source info wrapper provides information.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
Expr * getSubExpr() const
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static bool IsPotentiallyEvaluatedContext(Sema &SemaRef)
bool isInstanceMethod() const
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
bool isFunctionOrMethod() const
clang::ObjCRuntime ObjCRuntime
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConverion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
QualType getObjCIdType() const
Represents the Objective-CC id type.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
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...
bool isExternallyVisible() const
Converts from an integral complex to a floating complex.
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Represents a GCC generic vector type.
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
void CleanupVarDeclMarking()
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool isRelational)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
QualType getElementType() const
Represents a C++ conversion function within a class.
bool isComplexIntegerType() const
The result type of a method or function.
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.
bool ParentNeedsCleanups
Whether the enclosing context needed a cleanup.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
void setBlockMangling(unsigned Number, Decl *Ctx)
void removeCVRQualifiers(unsigned mask)
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.
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
TypeSourceInfo * getTypeSourceInfo() const
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
QualType getWideCharType() const
Return the type of wide characters.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
const Expr * getAnyInitializer() const
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
CK_ArrayToPointerDecay - Array to pointer decay.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing...
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool *NonStandardCompositeType=nullptr)
Find a merged pointer type and convert the two expressions to it.
ivar_iterator ivar_begin() const
static CharSourceRange getCharRange(SourceRange R)
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...
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
param_iterator param_begin()
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isClassMethod() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
ArrayRef< ParmVarDecl * > parameters() const
static bool isBitwiseOp(Opcode Opc)
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
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.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
static AvailabilityResult DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we we can fold and convert to a ...
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
Assigning into this object requires the old value to be released and the new value to be retained...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
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...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool CheckCaseExpression(Expr *E)
not a target-specific vector type
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.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
A stack object to be created when performing template instantiation.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
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...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
QualType getElementType() const
QualType withCVRQualifiers(unsigned CVR) const
Expression is not a Null pointer constant.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
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.
CXXRecordDecl * Lambda
The class that describes the lambda.
const TemplateArgumentListInfo & getTemplateArgsInfo() const
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
bool IsNoReturnConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noreturn"...
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isValid() const
Return true if this is a valid SourceLocation object.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
void setLastStmt(Stmt *S)
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
CK_NullToMemberPointer - Null pointer constant to member pointer.
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.
ASTContext & getASTContext() const
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setReferenced(bool R=true)
LabelDecl - Represents the declaration of a label.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
QualType withConst() const
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
SourceLocation getLocStart() const LLVM_READONLY
Represents a static or instance method of a struct/union/class.
bool isObjCBuiltinType() const
void setIdentifierInfo(IdentifierInfo *II)
ExprResult TransformToPotentiallyEvaluated(Expr *E)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
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.
ExtInfo withNoReturn(bool noReturn) const
bool isInvalid() const
An error occurred during parsing of the scope specifier.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
ObjCCategoryDecl - Represents a category declaration.
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...
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Describes the kind of initialization being performed, along with location information for tokens rela...
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
is AltiVec 'vector bool ...'
SmallVector< Capture, 4 > Captures
Captures - The captures.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
Converts from an integral real to an integral complex whose element type matches the source...
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Represents one property declaration in an Objective-C interface.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool isRelational)
QualType getReturnType() const
SourceLocation getBegin() const
virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR)
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.
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
void setKind(IdKind kind)
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isVectorType() const
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
sema::FunctionScopeInfo * getCurFunction() const
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
const BlockDecl * getBlockDecl() const
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
void setLAngleLoc(SourceLocation Loc)
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getPointeeType() const
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
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 isAdditiveOp() const
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...
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
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.
Base class for declarations which introduce a typedef-name.
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
Converts a floating point complex to floating point real of the source's element type.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
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 ...
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...
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)
static const Type * getElementType(const Expr *BaseExpr)
void setBody(CompoundStmt *B)
StringRef getOpcodeStr() const
const Expr * getExpr() const
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
Qualifiers withoutObjCLifetime() const
static bool isScopedEnumerationType(QualType T)
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
EvalResult is a struct with detailed info about an evaluated expression.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
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...
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)
Converts an integral complex to bool by comparing against 0+0i.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
bool isZero() const
isZero - Test whether the quantity equals zero.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
QualType GetSignedVectorType(QualType V)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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 CheckAlignOfExpr(Sema &S, Expr *E)
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
bool isInvalidDecl() const
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
static bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context)
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy)
Try to convert a value of non-vector type to a vector type by converting the type to the element type...
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
TypeLoc IgnoreParens() const
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.
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
DeclarationName - The name of a declaration.
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr * > Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
OverloadExpr * Expression
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
bool hasDefinition() const
Determine whether this protocol has a definition.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
U cast(CodeGen::Address addr)
ExpressionEvaluationContext Context
The expression evaluation context.
virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D)
Invoked when a function is implicitly instantiated.
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
A set of unresolved declarations.
bool isCopyCapture() const
SourceLocation getLocStart() const LLVM_READONLY
bool IsOpenMPCapturedByRef(VarDecl *VD, const sema::CapturedRegionScopeInfo *RSI)
Return true if the provided declaration VD should be captured by reference in the provided scope RSI...
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
EnumDecl - Represents an enum.
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.
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
detail::InMemoryDirectory::const_iterator E
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
A conversion of a floating point real to a floating point complex of the original type...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
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)
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
QualType getCorrespondingUnsignedType(QualType T) const
ExprResult ActOnConstantExpression(ExprResult Res)
DeclClass * getCorrectionDeclAs() const
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false)
Instantiate the definition of the given function from its template.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
ExprResult checkPseudoObjectRValue(Expr *E)
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.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool IsOpenMPCapturedVar(VarDecl *VD)
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
CanQualType ObjCBuiltinBoolTy
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'.
bool empty() const
Return true if no decls were found.
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
bool isObjCObjectType() const
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.
ExprResult CheckCXXBooleanCondition(Expr *CondExpr)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
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.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Expr * getUninstantiatedDefaultArg()
SourceManager & getSourceManager() const
FunctionDecl * getOperatorNew() const
const T * getAs() const
Member-template getAs<specific type>'.
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...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
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 ...
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap.
QualType getCanonicalType() const
static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Return the resulting type for the conditional operator in OpenCL (aka "ternary selection operator"...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, bool IsDecltype=false)
IntToBlockPointer - The assignment converts an int to a block pointer.
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
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
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)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
Represents a call to a CUDA kernel function.
bool isObjCQualifiedIdType() const
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
SourceLocation getLocStart() const LLVM_READONLY
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
bool isFunctionType() const
NestedNameSpecifier * getQualifier() const
ExtVectorType - Extended vector type.
CK_LValueBitCast - A conversion which reinterprets the address of an l-value as an l-value of a diffe...
Converts from T to _Atomic(T).
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXConstructorDecl * getConstructor() const
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
unsigned getAddressSpace() const
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
Converts from a floating complex to an integral complex.
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
std::string getAsString(const LangOptions &LO) const
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 Usu...
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
SourceLocation getLocStart() const LLVM_READONLY
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D)
Diagnoses obvious problems with the use of the given declaration as an expression.
static bool isInvalid(SourceLocation Loc, bool *Invalid)
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...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
A template-id, e.g., f<int>.
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
bool isUnevaluated() const
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.
CK_UncheckedDerivedToBase - A conversion from a C++ class pointer/reference to a base class that can ...
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
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...
ObjCIvarRefExpr - A reference to an ObjC instance variable.
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...
IdentifierInfo * getIdentifier() const
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
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 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...
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
A template argument list.
const DeclContext * getCurObjCLexicalContext() const
SourceRange getCorrectionRange() const
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
AccessControl getAccessControl() const
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.
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
unsigned getFullDataSize() const
Returns the size of the type source info data block.
bool hasAddressSpace() 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.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Data structure used to record current or nested expression evaluation contexts.
const Expr * getSubExpr() const
Describes the sequence of initializations required to initialize a given object or reference with a s...
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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)
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool isObjCObjectPointerType() const
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
SourceLocation getLocStart() const LLVM_READONLY
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
ObjCIvarDecl - Represents an ObjC instance variable.
Provides information a specialization of a member of a class template, which may be a member function...
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...
ArraySizeModifier getSizeModifier() 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.
bool isObjCSelType(QualType T) const
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Builtin::Context & BuiltinInfo
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
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)
LookupResultKind getResultKind() const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
void setParameterCFAudited()
Converts from _Atomic(T) to T.
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
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.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
void UpdateMarkingForLValueToRValue(Expr *E)
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g.
ObjCInterfaceDecl * getSuperClass() const
AvailabilityResult getCurContextAvailability() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
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.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S)
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.
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isSet() const
Deprecated.
NamedDecl * getMostRecentDecl()
The class facilities generation and storage of conversion FixIts.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
unsigned getLength() const
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
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...
QualType getElementType() const
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool OdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool hasQualifiers() const
Determine whether this type has any qualifiers.
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.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
static bool HasRedeclarationWithoutAvailabilityInCategory(const Decl *D)
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
const Expr * getSubExpr() const
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.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false)
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 isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isInvalidType() const
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
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.
bool isArithmeticType() const
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.
bool isIncrementDecrementOp() const
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
bool isConstQualified() const
Determine whether this type is const-qualified.
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
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.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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.
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.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
CK_ToVoid - Cast to void, discarding the computed value.
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.
void setType(QualType newType)
static bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
SourceLocation ColonLoc
Location of ':'.
void EmitAvailabilityWarning(AvailabilityDiagnostic AD, NamedDecl *D, StringRef Message, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
void WillReplaceSpecifier(bool ForceReplacement)
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.
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents the canonical version of C arrays with a specified constant size.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
const CXXDestructorDecl * getDestructor() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
Declaration of a template function.
void clear()
Clears out any current state.
QualType getBOOLType() const
type of 'BOOL' type.
A class which abstracts out some details necessary for making a call.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
SourceLocation getLocStart() const LLVM_READONLY
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isOverloadedResult() const
Determines if the results are overloaded.
Attr - This represents one attribute.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
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".
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this method is...
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.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CanQualType UnsignedIntTy
bool isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
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)
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
CK_FloatingToBoolean - Floating point to boolean.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
SourceLocation getLocStart() const LLVM_READONLY
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)